void buttons_runTest() { buttons_init(); // Initialize buttons display_init(); // Initialize display, which sets Rotation = 1 by default display_fillScreen(DISPLAY_BLACK); // blank the screen display_setTextColor(DISPLAY_BLACK); // Change text color to black display_setTextSize(BUTTONS_TEXT_SIZE); // Make text larger // Set the values of the global variables x_max = display_width(); y_max = display_height(); // Set the values of screen positions x_fourth = FOURTH(x_max); x_half = HALF(x_max); x_three_fourths = THREE_FOURTHS(x_max); y_fourth = FOURTH(y_max); y_half = HALF(y_max); y_three_fourths = THREE_FOURTHS(y_max); // Do an initial read of button values int32_t buttonValues = buttons_read(); // Until all 4 BTNS are pressed simultaneously, write info to the LCD while (buttonValues != BUTTONS_ALL_BTNS_ON) { // Draw the Rects/Text on the LCD corresponding to current buttons buttons_write_LCD(buttonValues); // Poll new value of buttons buttonValues = buttons_read(); } // After all buttons are pushed simultaneously, finish test. display_fillScreen(DISPLAY_BLACK); // blank screen display_setTextColor(DISPLAY_CYAN); // change text color display_setCursor(0,0); // reset cursor to origin display_println("Button Test Finished!"); // print that the test is complete }
void conn_func(const double X[NDIM], const struct of_geom *geom, double gamma[NDIM][NDIM][NDIM]) { #ifdef MINK int i,j,k ; for(i=0;i<NDIM;i++) for(j=0;j<NDIM;j++) for(k=0;k<NDIM;k++) gamma[i][j][k] = 0. ; #endif /* MINK */ #ifdef KS #define SQ(x) ((x)*(x)) #define CUBE(x) ((x)*(x)*(x)) #define FOURTH(x) ((x)*(x)*(x)*(x)) #define FIFTH(x) ((x)*(x)*(x)*(x)*(x)) #define SIXTH(x) ((x)*(x)*(x)*(x)*(x)*(x)) double sth,cth,s2,c2; double r,th ; double tfac,rfac,hfac,pfac ; double tfaci,rfaci,hfaci,pfaci ; double Pi, Delta ; double Sigma, Sigmai, Sigmai2, Sigmai3 ; double longcoefficient, longcoefficient2, longcoefficient3 ; double longcoefficient4, longcoefficient5, longcoefficient6 ; double a2,a3,a4,a5; double r2,r3,r4,r5; double rfacprime, hfacprime; bl_coord(X,&r,&th) ; a2=SQ(a); a3=CUBE(a); a4=FOURTH(a); a5=FIFTH(a); r2=SQ(r); r3=CUBE(r); r4=FOURTH(r); r5=FIFTH(r); cth = cos(th) ; sth = fabs(sin(th)) ; if (sth<SMALL) sth=SMALL ; s2 = SQ(sth) ; c2 = SQ(cth) ; Sigma = r2 + a2 * c2 ; Sigmai = 1./ Sigma ; Sigmai2 = SQ(Sigmai) ; Sigmai3 = CUBE(Sigmai) ; Pi = r2 - a2 * c2 ; Delta = r2 +a2 -2.*r ; longcoefficient = (r5+r*a4*FOURTH(cth)-a2*r2*s2+c2*(2.*a2*r3+a4*s2)) ; longcoefficient2 = (a4*c2*(2.*c2-1.) +a2*r2*s2-2.*r*Pi-r4) ; longcoefficient4 = (a2*c2*(2*r2+a2*c2) +2.*a2*r*s2+2.*r*Sigma+r4) ; longcoefficient3 = (r3+r4-a2*r*c2-FOURTH(a*cth)) ; longcoefficient5 = SIXTH(r)+SIXTH(a*cth) + a2*r3*(4.+r)*s2 + 2.*a4*r*FOURTH(sth)+ FOURTH(cth)*(3.*a4*r2+SIXTH(a)*s2)+ a2*r*c2*(3.*r3+2.*a2*(r+2.)*s2) ; longcoefficient6 = SQ(Sigma)/sth + a2*r*2.*sth ; tfac = 1. ; rfac = r - R0 ; hfac = M_PI + (1. - hslope)*M_PI*cos(2.*M_PI*X[2]) ; pfac = 1. ; tfaci = 1. ; rfaci = 1./ rfac ; hfaci = 1./ hfac ; pfaci = 1. ; rfacprime = 1. ; hfacprime = (2. * SQ(M_PI) * (hslope - 1.) * sin(2.*M_PI*X[2]) )/ hfac ; gamma[TT][TT][TT] = 2.*r*Pi*Sigmai3 *tfac ; gamma[TT][TT][RR] = Pi*(Sigma+2.*r)*Sigmai3 *rfac ; gamma[TT][TT][TH] = -2.*a2*r*cth*sth*Sigmai2 *hfac ; gamma[TT][TT][PH] = -2.*a*r*Pi*s2*Sigmai3 *pfac ; gamma[TT][RR][TT] = gamma[TT][TT][RR] ; gamma[TT][RR][RR] = 2.* longcoefficient3*Sigmai3 *tfaci*rfac*rfac ; gamma[TT][RR][TH] = -2.*a2*r*cth*sth*Sigmai2 *tfaci*rfac*hfac ; gamma[TT][RR][PH] = -a*Pi*(Sigma+2.*r)*s2*Sigmai3 *tfaci*rfac*pfac ; gamma[TT][TH][TT] = gamma[TT][TT][TH] ; gamma[TT][TH][RR] = gamma[TT][RR][TH] ; gamma[TT][TH][TH] = -2.*r2*Sigmai *tfaci*hfac*hfac ; gamma[TT][TH][PH] = 2.*CUBE(a*sth)*r*cth*Sigmai2 *tfaci*hfac*pfac ; gamma[TT][PH][TT] = gamma[TT][TT][PH] ; gamma[TT][PH][RR] = gamma[TT][RR][PH] ; gamma[TT][PH][TH] = gamma[TT][TH][PH] ; gamma[TT][PH][PH] = -2.*r*s2*longcoefficient*Sigmai3 *tfaci*pfac*pfac ; gamma[RR][TT][TT] = Delta*Pi*Sigmai3 *rfaci*tfac*tfac ; gamma[RR][TT][RR] = -Pi*(2.*r-a2*s2)*Sigmai3 *tfac ; gamma[RR][TT][TH] = 0. ; gamma[RR][TT][PH] = -a* Delta*Pi*s2 *Sigmai3 *rfaci*tfac*pfac ; gamma[RR][RR][TT] = gamma[RR][TT][RR] ; gamma[RR][RR][RR] = longcoefficient2 * Sigmai3*rfac + rfacprime ; gamma[RR][RR][TH] = -a2*sth*cth*Sigmai *hfac ; gamma[RR][RR][PH] = a*s2*(longcoefficient+2.*r*Pi)*Sigmai3 *pfac ; gamma[RR][TH][TT] = gamma[RR][TT][TH] ; gamma[RR][TH][RR] = gamma[RR][RR][TH] ; gamma[RR][TH][TH] = -r*Delta/Sigma *rfaci*hfac*hfac ; gamma[RR][TH][PH] = 0. ; gamma[RR][PH][TT] = gamma[RR][TT][PH] ; gamma[RR][PH][RR] = gamma[RR][RR][PH] ; gamma[RR][PH][TH] = gamma[RR][TH][PH] ; gamma[RR][PH][PH] = -longcoefficient*Delta*s2*Sigmai3 *rfaci*pfac*pfac ; gamma[TH][TT][TT] = -2.*a2*r*cth*sth*Sigmai3 *hfaci*tfac*tfac ; gamma[TH][TT][RR] = -2.*a2*r*cth*sth*Sigmai3 *hfaci*tfac*rfac ; gamma[TH][TT][TH] = 0. ; gamma[TH][TT][PH] = 2.*a*r*(a2+r2)*cth*sth*Sigmai3 *hfaci*tfac*pfac ; gamma[TH][RR][TT] = gamma[TH][TT][RR] ; gamma[TH][RR][RR] = -2.*a2*r*cth*sth*Sigmai3 *hfaci*rfac*rfac ; gamma[TH][RR][TH] = r*Sigmai *rfac ; gamma[TH][RR][PH] = a*cth*sth*longcoefficient4*Sigmai3 *hfaci*rfac*pfac ; gamma[TH][TH][TT] = gamma[TH][TT][TH] ; gamma[TH][TH][RR] = gamma[TH][RR][TH] ; gamma[TH][TH][TH] = -a2*cth*sth*Sigmai*hfac + hfacprime ; gamma[TH][TH][PH] = 0. ; gamma[TH][PH][TT] = gamma[TH][TT][PH] ; gamma[TH][PH][RR] = gamma[TH][RR][PH] ; gamma[TH][PH][TH] = gamma[TH][TH][PH] ; gamma[TH][PH][PH] = -cth*sth*longcoefficient5*Sigmai3 *hfaci*pfac*pfac ; gamma[PH][TT][TT] = a*Pi*Sigmai3 *pfaci*tfac*tfac ; gamma[PH][TT][RR] = a*Pi*Sigmai3 *pfaci*tfac*rfac ; gamma[PH][TT][TH] = -2.*a*r*cth*Sigmai2/sth *pfaci*tfac*hfac ; gamma[PH][TT][PH] = -a2*Pi*s2*Sigmai3 *tfac ; gamma[PH][RR][TT] = gamma[PH][TT][RR] ; gamma[PH][RR][RR] = a*Pi*Sigmai3 *pfaci*rfac*rfac ; gamma[PH][RR][TH] = -a*cth*(Sigma+2.*r)*Sigmai2/sth *pfaci*rfac*hfac ; gamma[PH][RR][PH] = longcoefficient*Sigmai3 *rfac ; gamma[PH][TH][TT] = gamma[PH][TT][TH] ; gamma[PH][TH][RR] = gamma[PH][RR][TH] ; gamma[PH][TH][TH] = -a*r*Sigmai *pfaci*hfac*hfac ; gamma[PH][TH][PH] = longcoefficient6 *cth*Sigmai2 *hfac ; gamma[PH][PH][TT] = gamma[PH][TT][PH] ; gamma[PH][PH][RR] = gamma[PH][RR][PH] ; gamma[PH][PH][TH] = gamma[PH][TH][PH] ; gamma[PH][PH][PH] = -longcoefficient*a*s2*Sigmai3 *pfac ; #undef SQ #undef CUBE #undef FOURTH #undef FIFTH #undef SIXTH #endif /* KS */ }
Word QepcadCls::PROJMCmod(Word r, Word A) { Word A1,A2,Ap,Ap1,Ap2,App,D,L,Lh,P,R,W,i,t,Q,j,S,Sp; Step1: /* Obtain coefficients. */ P = NIL; Ap = A; while (Ap != NIL) { ADV(Ap,&A1,&Ap); Ap1 = LELTI(A1,PO_POLY); /* Deal with projection points! */ if (LELTI(A1,PO_TYPE) == PO_POINT) { W = MPOLY(RED(Ap1),NIL,LIST1(LIST2(PT_PRJ,A1)),PO_POINT,PO_KEEP); P = COMP(W,P); continue; } /* Handle the leading coefficient! */ L = PLDCF(Ap1); Lh = NIL; t = 0; /* if (!PCONST(r - 1,L)) {*/ if (!VERIFYCONSTSIGN(r-1,IPIP(r-1,ISIGNF(PLBCF(r-1,L)),L),1,GVNA.W)) { W = MPOLY(L,NIL,LIST1(LIST3(PO_LCO,0,A1)),PO_OTHER,PO_KEEP); P = COMP(W,P); Lh = COMP(L,Lh); t = 1; } /* If r = 2 then we know the leading coefficient is always enough! */ if (r == 2) t = 0; /* If x_{r-1} is a bound variable, and the quantifier is either F or G, then we know we'll only be lifting over full dimensional cells so we don't have to add more coefficients! */ if (t) { j = r - GVNFV - 1; if (j > 0) { Q = LELTI(GVQ,j); /* Quantifier for x_{r-1} */ if (Q == FULLDE || Q == FULLDA) t = 0; } } /* If PCMZERROR is set to true, then we only need leading coefficients when projecting polynomials of level k+1 or lower. */ if (t && PCMZERROR && r <= GVNFV + 1) t = 0; /* If it can be determined that the system of coefficients is inconsistent ... we can stop with just the leading coeff! */ if (t) { j = CLOCK(); S = COEFSYS(r,Ap1); if (S == 1 || (Sp = SIMPLIFYSYSLIST(r-1,S,GVNA == NIL ? TRUE : GVNA.W)) == 1) t = 0; else { QepcadCls Q; Word G; for(t = 0; t == 0 && Sp != NIL; Sp = RED(Sp)) if ((G = SYSSOLVECAD(r-1,FIRST(Sp),GVNA == NIL ? TRUE : GVNA.W,GVVL,Q)) != NIL) { /* If there are finitely many solutions, add those points as projection points. */ if (ISLIST(G)) { for(Word Lp = G; Lp != NIL; Lp = RED(Lp)) { /* ADD POINTS to PROJECTION POLS! */ Word X = NIL; /* List of all sample points up to and inluding FIRST(G) */ Word c = Q.GVPC; for(Word I = LELTI(FIRST(Lp),INDX); I != NIL; I = RED(I)) { c = LELTI(LELTI(c,CHILD),FIRST(I)); Word s = LELTI(c,SAMPLE); X = COMP(ISPRIMIT(s) ? (LENGTH(s) > 3 ? FOURTH(s) : s) : s,X); } W = MPOLY(X,NIL,LIST1(LIST2(PT_NUL,A1)),PO_POINT,PO_KEEP); P = COMP(W,P); } } else t = 1; /* Instead of adding all the other coeffs, better to add system! */ } } j = CLOCK() - j; if (PCVERBOSE) { SWRITE("Coef consistency check took "); IWRITE(j); SWRITE("ms\n"); if (!t) SWRITE("Found system inconsistent for "); else SWRITE("Unable to determine consistency for "); IPDWRITE(r,Ap1,GVVL); SWRITE("\n"); } } /* Handle the rest of the coefficients as needed. */ i = 0; while (t) { Ap1 = PRED(Ap1); i++; L = PLDCF(Ap1); t = 0; if (Ap1 != 0) if (!PCONST(r - 1,L)) if (!IPFZT(r - 1,Lh)) { W = MPOLY(L,NIL,LIST1(LIST3(PO_LCO,i,A1)),PO_OTHER,PO_KEEP); P = COMP(W,P); Lh = COMP(L,Lh); t = 1; } } } Step2: /* Obtain discriminants. */ Ap = A; while (Ap != NIL) { ADV(Ap,&A1,&Ap); if (LELTI(A1,PO_TYPE) == PO_POINT) continue; if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON) continue; Ap1 = LELTI(A1,PO_POLY); if (PDEG(Ap1) >= 2) { D = IPDSCRQE(r,Ap1); W = MPOLY(D,NIL,LIST1(LIST4(PO_DIS,0,0,A1)),PO_OTHER,PO_KEEP); P = COMP(W,P); } } Step3: /* Obtain resultants. */ Ap = A; while (Ap != NIL) { ADV(Ap,&A1,&Ap); if (LELTI(A1,PO_TYPE) == PO_POINT) continue; Ap1 = LELTI(A1,PO_POLY); App = Ap; while (App != NIL) { ADV(App,&A2,&App); if (LELTI(A2,PO_TYPE) == PO_POINT) continue; if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON && LELTI(A2,PO_TYPE) != PO_ECON) continue; Ap2 = LELTI(A2,PO_POLY); R = IPRESQE(r,Ap1,Ap2); W = MPOLY(R,NIL,LIST1(LIST6(PO_RES,0,0,A1,0,A2)),PO_OTHER,PO_KEEP); P = COMP(W,P); } } Step4: /* Finish. */ P = INV(P); goto Return; Return: /* Prepare for return. */ return(P); }