package Current.popups.Deg100; import Current.*; import Current.basic.*; import Current.plot.Dyadic.*; import Current.manage.*; import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; import java.math.*; public class Deg100Verifier { Manager M; //the input data int type; //either local or global int select; //tile number Color C; //color of plot Complex Z; //parameter point - used with local plot Complex[] POLY; //the polygon Deg100Polygon DPOLY; //the polygon String word; //the word; int exact; //tells whether or not to do rigorous computations; int palindrome; //decides if the word is a palindrome; int EXCEPTION0=0; int EXCEPTION1=0; int debug; //some output data; stats on the algorithm int max; //number of boxes int[][] record=new int[2][500]; //record of the tournament //needed for computing the defining function int[][] numerator=new int[3][500]; //numerator int[][][] denominator=new int[3][3][500]; //denominators of defining functions CombinatorialTriangle[] CT; //all the combinatorial info is encoded here int[] top; //list of top vertices int[] bot; //list of bottom vertices int spine; //spine number for defining function VertexPair V; //indexes current defining function //lists of dyadic squares DyadicSquare[] D=new DyadicSquare[500]; DyadicSquare[] IN=new DyadicSquare[10000]; int D_N,IN_N; //memory VertexPair[] VP=new VertexPair[10000]; public Deg100Verifier(Manager M) { this.M=M; M.addListener(this); } public void communicate() { Deg100Interface DI=(Deg100Interface)(M.mcbGet(Deg100Interface.class)); if (DI!=null) { this.DPOLY=DI.getDeg100Polygon(); this.POLY=DI.getPOLY(); int[] modes=DI.getModes(); exact=modes[0]; type=modes[1]; select=modes[2]; } } public DyadicTile basicPlot(String word) { communicate(); this.word=word; this.C=M.getColor(); this.Z=M.getZ(); if(DPOLY==null) return(null); doReset(); System.out.println("starting "+select); double time1=System.currentTimeMillis(); max=0; while(D_N>0) processSquare(); if(IN_N==0) return(null); //picture is created GeneralPath gp=new GeneralPath(); if (IN_N==0) return(null); for(int i=0;iOLD) { OLD=NEW; ++count; n[count]=i-1; } } if(2*count0) cert[0]=cert[1]; if(cert[1]==0) cert[0]=certify(); return(cert); } public void recordCertify(int q,int[] cert) { DyadicSquare A=D[D_N-1]; if(q==1) { if((cert[1]==0)&&(cert[0]>0)) { //record certificate for later use ++A.V1[0].cert; int L=A.V1[0].cert; A.V1[L]=new VertexPair(V.o1,V.e1,V.o2,V.e2); A.V1[L].cert=cert[0]; }} if(q==2) { if((cert[1]==0)&&(cert[0]>0)) { //record certificate for later use ++A.V2[0].cert; int L=A.V2[0].cert; A.V2[L]=new VertexPair(V.o1,V.e1,V.o2,V.e2); A.V2[L].cert=cert[0]; }} } /**LOOKING UP STORED INFORMATION*/ public int compare(VertexPair VV1,VertexPair VV2) { if(VV1.o1!=VV2.o1) return(0); if(VV1.e1!=VV2.e1) return(0); if(VV1.o2!=VV2.o2) return(0); if(VV1.e2!=VV2.e2) return(0); return(VV2.cert); } public int lookup1() { int N=D[D_N-1].V1[0].cert; int cert=0; for(int i=N;i>=1;--i) { cert=compare(V,D[D_N-1].V1[i]); if(cert!=0) return(cert); } return(0); } public int lookup2() { int N=D[D_N-1].V2[0].cert; int cert=0; for(int i=N;i>=1;--i) { cert=compare(V,D[D_N-1].V2[i]); if(cert!=0) return(cert); } return(0); } public int[] compare3(VertexPair VV1,VertexPair VV2) { int[] a=new int[3]; a[0]=0; a[1]=0; a[2]=0; int test=1; if(VV1.o1!=VV2.o1) test=0; if(VV1.e1!=VV2.e1) test=0; if(VV1.o2!=VV2.o2) test=0; if(VV1.e2!=VV2.e2) test=0; if(test==1) { a[0]=VV2.a20; a[1]=VV2.a11; a[2]=VV2.a02; } return(a); } public int[] lookup3() { int N=VP[0].cert; int[] a=new int[3]; a[0]=0; a[1]=0; a[2]=0; for(int i=N;i>=1;--i) { a=compare3(V,VP[i]); if(a[0]!=0) return(a); } return(a); } public int getMatchNumber() { return(D[D_N-1].top[0]*D[D_N-1].bot[0]); } /**HERE IS THE ALGORITHM*/ public void processSquare() { DyadicSquare A=D[D_N-1]; if(max=2) { Z=A.getCenter(); // set Z D_N=0; } ++IN_N; --D_N; } /**When type=2 we have the local mode. This mode discards any squares which * do not contain a specific point, and thereby lets the user trace what * the algorithm one box at a time. The routine to ConvexIntersector is * not done with interval arithmetic, and doesn't have to be done with * interval arithmetic. The idea * here is just to use the point Z to select a box.*/ public int determineAction() { DyadicSquare A=D[D_N-1]; if(A.x[0]>A.y[0]) return(-1); //throws out boxes centered on acute side. if(type==2) { int touch=ConvexIntersector.checkTouch(Z,A.toPolygon()); //NUMERICAL if(touch==0) return(-1); } /**This is what we use for the vast majority of the calculations. * There are only 7 exceptions below. We can't use the rigorous * intersector on the 7 exceptions because they have rational but * non-dyadic rational vertices. */ int test=0; if(select<=221) { if(exact==1) test=Deg100IntegerPolygon.checkDisjoint(A,DPOLY); //RIGOROUS if(exact==0) test=ConvexIntersector.checkDisjoint(A,POLY); //NUMERICAL } /**We only invoke this numerical method for the 7 exceptional tiles * P222,...,P228. In each of these cases, the final output is a * just a few squares and we visually inspect that it covers * the tile. In other words, we overcome any roundoff error just * by inspection */ if(select>221) { test=ConvexIntersector.checkDisjoint(A,POLY); //NUMERICAL } if(test==3) return(-1); //does not intersect tournament(); int p=playoffs(); return(p); } public void tournament() { int STOP=1; while(STOP!=0) STOP=round(1); STOP=1; while(STOP!=0) STOP=round(2); } public int round(int q) { int match=0; int count=0; int previous=0; int elim=0; int BEFORE=0; DyadicSquare A=D[D_N-1]; if(q==1) BEFORE=A.top[0]; if(q==2) BEFORE=A.bot[0]; for(int i=1;i0)&&(isException==1)) return(3); if((select==222)&&(isException==1)) return(3); //here is tile 222 match=signEvaluate(cert[0]); if(getMatchNumber()<=25) recordCertify(2,cert); //don't want to overload memory return(match); } /**Here we check the exceptions. We ignore the pair * provided it is on our list of exceptions AND the * function for this pair is certified. There is one * special exception, and that is for tile 222. This * tile contains the right angled isosceles point * as a vertex. In a neighborhood of a vertex we cannot * certify the defining functions computationally. We * have to analyze it analytically. */ public int checkExceptions() { int exc=0; for(int ii=1;ii<=DPOLY.exceptions[0][0];++ii) { if((EXCEPTION0==DPOLY.exceptions[ii][0])&&(EXCEPTION1==DPOLY.exceptions[ii][1])) exc=1; } return(exc); } }