void GREADR(Word *a_, Word *t_) { Word C,S,a,t; /* hide algorithm */ Step1: /* Skip blanks and read sign, if any. */ t = 1; S = 1; C = CREADB(); if (C == '+') C = CREADB(); else if (C == '-') { C = CREADB(); S = -1; } if (DIGIT(C) == 0) { SWRITE("Error GREADR: A digit was expected.\n"); goto Step3; } Step2: /* Read digits and convert. */ a = 0; do { a = 10 * a + C - '0'; C = CREAD(); } while (!(DIGIT(C) == 0)); BKSP(); a = S * a; goto Return; Step3: /* Error. */ DIELOC(); t = 0; goto Return; Return: /* Prepare for return. */ *a_ = a; *t_ = t; return; }
Word ESPORD() { Word i,n,m,C,H,H1,H11; Step1: /* Read in the number of variables. */ do C = CREAD(); while (!DIGIT(C)); BKSP(); n = GREAD() - 1; FILINE(); FILINE(); Step2: /* Read in the rows. */ H = NIL; for (;;) { C = CREAD(); BKSP(); if (C == '.') break; H1 = NIL; for (i=1; i<=n; i++) { m = GREAD(); switch(m) { case 1: H11 = GTOP; break; case 10: H11 = EQOP; break; case 11: H11 = GEOP; break; case 100: H11 = LTOP; break; case 101: H11 = NEOP; break; case 110: H11 = LEOP; break; case 111: H11 = TAOP; break; default: FAIL("ESPORD","Illegal output from espresso."); } H1 = COMP(H11,H1); } FILINE(); H1 = INV(H1); H = COMP(H1,H); } H = INV(H); FILINE(); Return: /* Prepare for return. */ return(H); }
// This is where the packets are generated. I don't understand how the functions are // called in this instance. The greater-than signs aren't something I know how to look up! static int ns1_read_apdata(int fd, int version, struct apdata_s *packet, int apinfo) { // I added this, and figured out how to pass the variable above ^^^^^^ packet->duin = apinfo ; CREAD(le64,fd,&packet->timestamp); CREAD(le32,fd,&packet->signal); CREAD(le32,fd,&packet->noise); CREAD(le32,fd,&packet->location_source); if (packet->location_source) { CREAD(double,fd, &packet->latitude); CREAD(double,fd, &packet->longitude); CREAD(double,fd, &packet->altitude); if (packet->altitude < -1000.0) packet->altitude=0.0; CREAD(le32,fd, &packet->gps.sats); CREAD(double,fd, &packet->gps.speed); CREAD(double,fd, &packet->gps.track); CREAD(double,fd, &packet->gps.mag_variation); CREAD(double,fd, &packet->gps.hdop); }
void FMAATOMREAD(Word Q, Word V, Word *F_, Word *t_) { Word F,P,P1,P2,R,a,r,s,t,k,pi; char c; /* hide r,s,t; */ Step1: /* Read the left polynomial. */ t = 1; r = LENGTH(V); IPEXPREAD(r,V,&P1,&t); if (t == 0) goto Return; Step2: /* Read the relational operator. */ RLOPRDR(&R,&t); if (t == 0) goto Return; Step2p: /* Read Root expression (if it's there). */ k = 0; do { c = CREAD(); } while (c == ' ' || c == '\n'); if (c == '_') if (CREAD() == 'r' && CREAD() == 'o' && CREAD() == 'o' && CREAD() == 't' && CREAD() == '_') k = IREAD(); else { t = 0; goto Return; } else BKSP(); Step3: /* Read the right polynomial. */ IPEXPREAD(r,V,&P2,&t); if (t == 0) goto Return; Setp4: /* Tarski Atom. */ if (k == 0) { if (P2 != 0) { t = 0; goto Return; } pi = POLYINDEX(Q,P1,r,&t); F = LIST2(pi,R); goto Return; } Step5: /* Extended Atom. */ pi = POLYINDEX(Q,P2,r,&t); /* should do an error check here! */ F = LIST2(pi,LIST2(R,k)); goto Return; Step6: /* Error exit. */ DIELOC(); t = 0; goto Return; Return: /* Prepare for return. */ *F_ = F; *t_ = t; return; }
Word RNREAD() { Word C,R,R1,R2; /* hide C,R; */ Step1: /* Read. */ R1 = IREAD(); C = CREAD(); if (C == '/') R2 = IREAD(); else { R2 = 1; BKSP(); } if (R1 == 0) R = 0; else R = LIST2(R1,R2); Return: /* Prepare for return. */ return(R); }
Word sacMain() { interval *A; Word P,t,L,n; SWRITE("Enter pol. in x: "); IPEXPREAD(1,LIST1(LFS("x")),&P,&t); CREAD(); I = LBRIREAD(); Step1: /* Convert the isolating interval for \alpha to a hardware interval. */ L = NIL; LBRNIEEEE(FIRST(I), &t,&F1,&n1); if (t != 0) goto Return; w1 = F1.num; LBRNIEEEE(SECOND(I), &t,&F2,&n2); if (t != 0) goto Return; w2 = F2.num; np = MIN(n1,n2); Step2: /* Convert the minimal polynomial to a hardware interval polynomial and refine the hardware interval. */ FPCATCH(); IUPHIP(P,&A,&t); if (t == 0) { t = 1; goto Return; } n = PDEG(M); t = HIPFES(n,A,w2); if (FPCHECK() == 1) { t = 1; goto Return; } if (t == NIL) { t = 2; goto Return; } u = 0; while (u == 0 && np > 0) { p = (w1 + w2) / 2.0; s = HIPFES(n,A,p); if ((FPCHECK() == 1) || (s == NIL)) u = 1; else if (s == t) w2 = p; else if (s == -t) w1 = p; else { w1 = p; w2 = p; } np = np - 1; } K.left = w1; K.right = w2; HIPFES(PDEG(P),A,x); return 0; }