void QepcadCls::PRCCS() { Word C,S,S1,W; /* hide C,S1; */ Step0: /* If fast-cell-choice is used, we cannot honor the strategy! */ if (PCCHFLAG) { SWRITE("The \"fast-cell-choice\" strategy is now switched off!\n"); PCCHFLAG = 0; } Step1: /* Read in the strategy. */ S = NIL; C = CREADB(); if (C != '(') { SWRITE("Error PRCCS: '(' was expected.\n"); goto Step3; } do { W = GETWORD(); if (EQUAL(W,LFS("TC"))) S1 = TCORD; else if (EQUAL(W,LFS("NC"))) S1 = NCORD; else if (EQUAL(W,LFS("LD"))) S1 = LDORD; else if (EQUAL(W,LFS("GD"))) S1 = GDORD; else if (EQUAL(W,LFS("SR"))) S1 = SRORD; else if (EQUAL(W,LFS("SN"))) S1 = SNORD; else if (EQUAL(W,LFS("HL"))) S1 = HLORD; else if (EQUAL(W,LFS("LL"))) S1 = LLORD; else if (EQUAL(W,LFS("GI"))) S1 = GIORD; else if (EQUAL(W,LFS("LI"))) S1 = LIORD; else { SWRITE("Error PRCCS: A partial ordering was expected.\n"); goto Step3; } S = COMP(S1,S); C = CREADB(); if (C != ',' && C != ')') { SWRITE("Error PRCCS: ',' or ')' was expected.\n"); goto Step3; } } while (!(C == ')')); S = INV(S); Step2: /* Set. */ PCCCS = S; goto Return; Step3: /* Error exit. */ DIELOC(); goto Return; Return: /* Prepare for return. */ return; }
void testSIimplOI(BDigit r, Word P, Word ZL, Word NZ, Word A) { /* Compute generators A and all its 1st order partials */ Word L = LIST1(A); for(int i = 1; i <= r; ++i) { Word D = IPDER(r,A,i); if (D != 0) L = COMP(D,L); } L = CCONC(L,ZL); /* Compute a variable list for output purposes. */ Word V = NIL; for(int i = r; i > 0; i--) { char s[2]; s[0] = 'a' - 1 + i; s[1] = '\0'; V = COMP(LFS(s),V); } /* Go through assumptions and find non-vanishing conditions. */ Word M = NZ; SWRITE("Test si ==> oi: "); IPDWRITE(r,A,V); SWRITE("\n"); GBTest(r,L,V); }
void PPCXEmitter::LoadFloatSwap(PPCReg FRt, PPCReg Base, PPCReg offset) { // used for swapping float ... u32 tmp; // Load Value into a temp REG LWBRX(R6, Base, offset); // Save it in tmp MOVI2R(R7, (u32)&tmp); STW(R6, R7); // Load the final value LFS(FRt, R7, 0); }
int sacMain() { Word V,B,t,Vx,M,L,Lp,i,k = 20; Word wii, p, J, *I , *Bp; /* Read bivariate polynomial */ V = LIST2(LFS("x"),LFS("y")); SWRITE("Enter B, a polynomial in x and y : "); IPEXPREADR(2,V,&B,&t); if (!t) { SWRITE("Polynomial read unsuccessfull!\n"); return 1; } else { SWRITE("Polynomial read in is: "); IPDWRITE(2,B,V); SWRITE("\n"); } /* Get precision */ SWRITE("Enter precision: "); p = IREAD(); SWRITE("Precision read is: "); IWRITE(p); SWRITE("\n"); /* Read Interval */ SWRITE("Enter binary rational interval: "); J = LBRIREAD(); /* Sub! */ Bp = GETARRAY(1 + (PDEG(B) + 1)*2*(p + 3)); IBPELBRISIPR(B,J,p,Bp); SWRITE("Evaluation result is : "); SIPWRITE(Bp,p,k); SWRITE("\n"); return 0; }
void SAMPLEWR(Word k, Word s, Word PCNUMDEC) { Word I,Ip,M,Mp,b,bp,F,j,Ms,Is; Word M1; Step2: /* Extended representation. */ if (ISPRIMIT(s)) goto Step3; FIRST5(s,&M,&I,&Mp,&Ip,&bp); SWRITE("The sample point is in an EXTENDED representation.\n\n"); SWRITE("alpha = "); IUPRWR(LFS("x"),Mp,Ip); SWRITE("\n"); SWRITE(" = "); ANDWRITE(Mp,Ip,PCNUMDEC); SWRITE("\n\n"); AFLWR(Mp,Ip,LFS("Coordinate "),LFS("alpha"),bp,PCNUMDEC); SWRITE("Coordinate "); GWRITE(k); SWRITE(" = "); AFUPRWR(LFS("alpha"),LFS("x"),M,I); SWRITE("\n"); F = AFPNIP(Mp,M); M = AFPICR(1,M); IPSRP(2,M,&M1,&M); AMUPMPR(Mp,Ip,M,I,F,&Is,&j); Ms = LELTI(F,j); Is = IPSIFI(Ms,Is); SWRITE(" = "); IUPRWR(LFS("x"),Ms,Is); SWRITE("\n"); SWRITE(" = "); ANDWRITE(Ms,Is,PCNUMDEC); SWRITE("\n"); goto Return; Step3: /* Primitive representation. */ FIRST3(s,&M,&I,&b); SWRITE("The sample point is in a PRIMITIVE representation.\n\n"); SWRITE("alpha = "); IUPRWR(LFS("x"),M,I); SWRITE("\n"); SWRITE(" = "); ANDWRITE(M,I,PCNUMDEC); SWRITE("\n\n"); AFLWR(M,I,LFS("Coordinate "),LFS("alpha"),b,PCNUMDEC); SWRITE("\n"); Return: /* Prepare for return. */ return; }
Word GROUPSAMEPJ(Word r, Word J) { Word J1,Jp,Js,t, Js1, Jt, J2, Jt2, i; Step1: /* Group. */ Jp = NIL; Js = J; i = 0; while (Js != NIL) { ADV(Js,&J1,&Js); Js1 = LELTI(J1,PO_POLY); Jt = Jp; t = 0; while (Jt != NIL) { ADV(Jt,&J2,&Jt); Jt2 = LELTI(J2,PO_POLY); if (LELTI(J1,PO_TYPE) == PO_POINT && LELTI(J2,PO_TYPE) == PO_POINT && PRJPNTEQUAL(Js1,Jt2) || LELTI(J1,PO_TYPE) != PO_POINT && LELTI(J2,PO_TYPE) != PO_POINT && EQUAL(Js1,Jt2)) { SLELTI(J2,PO_PARENT,CONC(LELTI(J2,PO_PARENT),LELTI(J1,PO_PARENT))); t = 1; break; } } if (t == 0) { i = i + 1; SLELTI(J1,PO_LABEL,LIST3(LFS("J"),r,i)); Jp = COMP(J1,Jp); } } Jp = INV(Jp); Return: /* Prepare for return. */ return(Jp); }
Word SYSSOLVECAD(BDigit r, Word L, Word A, Word Vp, QepcadCls &Q) { Word F, Fp, d, t, Lt, Lf, V, S; /* Set variable list */ if (LENGTH(Vp) < r) { V = NIL; for(int i = r; i > 0; i--) { char s[2]; s[0] = 'a' - 1 + i; s[1] = '\0'; V = COMP(LFS(s),V); } } else V = Vp; /* Create a CAD representing the solutions of the system */ F = SYSTOUNNORMFORMULA(r,L); Q.SETINPUTFORMULA(V,LIST4(r,r,NIL,F)); Q.SETASSUMPTIONS(A); Q.CADautoConst(); /* List solution points */ S = NIL; for(LISTOFCWTV(Q.GVPC,&Lt,&Lf); Lt != NIL && S != 0; Lt = RED(Lt)) { Word dc = CELLDIM(FIRST(Lt)) + r - LELTI(FIRST(Lt),LEVEL); if (dc == 0) S = COMP(FIRST(Lt),S); else S = 0; } /* Prepare to return */ return S; }
void PPCXEmitter::MOVI2F (PPCReg dest, float imm, bool negate) { u32 tmp; union convert { unsigned int i; float f; } fc; fc.f = imm; MOVI2R(R6, fc.i); // R7 = imm MOVI2R(R7, (u32)&tmp); STW(R6, R7); // dest = R7 LFS(dest, R7, 0); if (negate == true) { FNEG(dest, dest); } }
void QepcadCls::CSORCELLTR_MOD(Word c, Word Pp, Word PpO, Word PpN, Word P) { Word f,s,sh,M,K,C,Pps,L,T,B,E,I,A,a,b,k; Word PP,NP,L_P,TP,i,ta,t; Step0: k = LELTI(c,LEVEL); s = LELTI(c,SAMPLE); sh = CONVERT(s,k); SLELTI(c,SAMPLE,sh); /* Trick CONSTRUCT into working for us by wrapping the elements of Pp (which are SACLIB polynomials) in a dummy QEPCAD projection polynomial/factor data structure. */ Word PpM = NIL; for(Word PpR = CINV(Pp),j=LENGTH(Pp); PpR != NIL; PpR = RED(PpR),--j) PpM = COMP( LIST5(FIRST(PpR),LIST3(LFS("P"),k+1,j),0,PO_FAC,0) ,PpM); CONSTRUCT(c,k,GVNFV,PpM,GVNIP); Step5: /* Add two new fields to each cell to make it an RCell. */ T = NIL; for(A = LELTI(c,CHILD); A != NIL; A = RED(A)) { T = COMP(CCONC(FIRST(A),LIST2(NIL,NIL)),T); } SLELTI(c,CHILD,CINV(T)); Step6: /* Add truth values and other information. */ /* Get mask for pivot pol's, i.e. a list of 1's and zeros corresponding to PpO, where the non-pivot pol positions are 1, and the pivot pol positions are zero. */ SEPPIVNONPIV(LELTI(P,k+1),k+1,&PP,&NP); /* Get list of pivot pol's for this level. */ if ( (NP != NIL) && SINTER(LELTI(GVPIVOT,k+1),LLPFZC(c,P)) != NIL ) { PP = LELTI(P,k+1); NP = NIL; } L_P = NIL; ta = FIRST(LELTI(FIRST(LELTI(c,CHILD)),SIGNPF)); /* signiture of a sector on level k+1 pols. */ for(TP = LELTI(P,k+1); TP != NIL; TP = RED(TP)) { /* Subtle point: a pivot pol might vanish identically in this stack, which would mess everything up. If this pol does vanish identically in the stack, don't include it in the mask! */ ADV(ta,&i,&ta); /* sign of current pol in a sector: if 0 then pol vanishes in stack. */ if ( PFPIPFL(FIRST(TP),PP) && i ) { L_P = COMP(0,L_P); } else L_P = COMP(1,L_P); } L_P = INV(L_P); A = LELTI(c,CHILD); /* Stack with more cells, i.e. new. */ B = LELTI(LELTI(c,INCELL),CHILD); /* Stack with fewer cells, i.e. old. */ ADV(B,&b,&B); ADV(A,&a,&A); while (A != NIL) { SLELTI(a,INCELL,b); SLELTI(a,TRUTH,LELTI(b,TRUTH)); SLELTI(a,HOWTV,LELTI(b,HOWTV)); ADV(A,&a,&A); if (LELTI(b,MULSUB) != NIL) ADV(B,&b,&B); /* i.e. if b is a section. */ if ( ISCSOPP(a,L_P) ) { do{ ADV(B,&b,&B); } while( ! ISCSOPP(b,L_P) ); } } SLELTI(a,INCELL,b); SLELTI(a,TRUTH,LELTI(b,TRUTH)); SLELTI(a,HOWTV,LELTI(b,HOWTV)); Return: /* */ return; }
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; }