ppoly.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 

partial class POLY2

partial class POLY2 is --Copyright (C) 1985 1996 Kouji KODAMA --1998/1 LongInt version -- 1996/10 -- LINUX version -- Date: 1993- 7-11 0:32:39. -- PC98 NS/L : i386/ 20MHz -- rateCl=234; -- Knot: C12 -- #resolution: PPoly, t= 375 , c= 36 , rs= 531441.0 , rv= 4025386.63 -- Knot: C13 -- #resolution: PPoly, t= 1141 , c= 39 , rs= 1594323.0 , rv= 15355783.15 -- Knot: T27 -- #resolution: PPoly, t= 241 , c= 27 , rs= 317811.0 , rv= 139074.38 -- Knot: T29 -- #resolution: PPoly, t= 654 , c= 29 , rs= 832040.0 , rv= 339907.60 -- Revision 1.2 93/06/22 20:56:36 KDM -- vpoly changed for module tunnel -- 1992/11 -- In Jones polynomial and Alexander polynomial, -- when "number of crossings>33" computation was halted, -- because it can be overflow. -- -- Now, I change the condition as follows. -- Alexander polynomial -- "In resolution tree, /=smoothing in a pass >33" -- Jones polynomial -- "In resolution, (/=smoothing-/=component+1 in a pass)>33" -- -- Note. -- 33 means upper limit of coefficients of (1+t)^n are not overflow. -- --1990/2 P(L,M),P(X,Y,Z), P-poly-Low --1989/11 Jones polynomial. --1989/8 Modula-2 version --1985/12 P-poly., C-poly. shared Alloc0:INT; shared Poly:ARRAY{ARRAY{INTI}}; -- [0..Alloc0][0..Alloc0] shared TCodeRes:ARRAY{RTCODE}; --[0..Alloc0] -- TYPE td=array[1..4] OF INT; -- inout TdRes:array[0..PPOLYmaxC] OF td; shared TdRes:ARRAY{ARRAY{INT}}; -- [0..Alloc0][0..4] shared TraceDeg:ARRAY{INT}; -- [0..4] shared TraceRes:ARRAY{RES_MARK}; -- [0..Alloc0] shared ResFlg:ARRAY{BOOL}; -- [0..Alloc0] shared CN,CP:ARRAY{POLYS_INTI}; -- [0..Alloc0][0..Alloc0] shared TCodeTmp,TCodePtr:RTCODE; shared endTc:VERTEXP; shared i:INT; shared r0,r1,r2:INT; shared o1,o2,o3:INT; shared n,n1,n2:INT; shared enp,stp:INT; shared tmp,tmpMax,tmpMp:INT; shared c0p,c0n,compo0,compo:INT; shared resPtr,tPtr,tPtr1,tPtr2:INT; shared count:INT; -- count resolution -------------------init---------------------- closeRes is Poly:=#; TCodeRes:=#; TraceRes:=#; TdRes:=#; TraceDeg:=#; ResFlg:=#; CP:=#; CN:=#; end; initRes(TCode:TCODE, tstep, cvRes, cvTime:FLT):BOOL is if TCode.has_band then return false; end; c0::=0; c0p:=0; c0n:=0; compo0:=0; b0::=0; TCode.numbers_count(inout c0,inout c0p,inout c0n,inout compo0,inout b0); Alloc0:=c0p+c0n+compo0; POLYS_INTI::init; Poly:=#(Alloc0+1); loop i::=Poly.ind!; Poly[i]:=#(Alloc0+1); loop j::=Poly[i].ind!; Poly[i][j]:=0.inti; end; end; TCodeRes:=#(Alloc0+1); loop i::=TCodeRes.ind!; TCodeRes[i]:=#; end; TraceRes:=#(Alloc0+1); loop i::=TraceRes.ind!; TraceRes[i]:=#; end; TdRes:=#(Alloc0+1); loop i::=TdRes.ind!; TdRes[i]:=#(5); end; TraceDeg:=#(5); loop i::=TraceDeg.ind!; TraceDeg[i]:=0; end; ResFlg:=#(Alloc0+1); loop i::=ResFlg.ind!; ResFlg[i]:=false; end; compo:=compo0; endTc:=#; endTc.sep:=TCode[TCode.length].sep.clone; endTc.companion:=0; TCodeTmp:=#(TCode); RTCODE_TRIM::SCode(inout TCodeTmp, tstep, cvRes, cvTime); TCodeRes[0]:=TCodeTmp; TCodeRes[1]:=TCodeTmp.clone; tmp:=0; tPtr:=0; tmp:=0; TraceRes[tmp].p:=tPtr; TraceRes[tmp].m:=TCodeTmp.length; TraceRes[tmp].c:=compo; TdRes[tmp]:=TraceDeg.copy; ResFlg[tmp]:=false; tmp:=tmp+1; TraceRes[tmp]:=TraceRes[tmp-1].clone; TdRes[tmp]:=TraceDeg.copy; ResFlg[tmp]:=true; resPtr:=tmp; TCodeTmp:=TCodeRes[tmp].clone; tmpMax:=TCodeTmp.length; return true; end; -- assert (tmpMax=TCodeTmp.length); --------- resolution------------- MakeRes201 is -- TCodeTmp, out TCodePtr, i,n1,tPtr1,tPtr2, -- local n n:=TCodeTmp[i].companion; TCodePtr.k[n1]:=#; if n<tPtr1 then TCodePtr[n1].companion:= n; elsif n<=tPtr2 then TCodePtr[n1].companion:= n+r2; elsif n<=enp then TCodePtr[n1].companion:= n-r1; else TCodePtr[n1].companion:=n; end; TCodePtr[n1].sep:=TCodeTmp[i].sep; end; MakeRes2 is resPtr:=resPtr+1; TCodePtr:=#; TCodePtr.k:=#(TCodeTmp.k.size); r1:=tPtr2-tPtr1+1; r2:=enp-tPtr2; --loop i:=0.upto!(tPtr1-1) ; n1:=i; MakeRes201; end; loop i:=tPtr1.upto!(tPtr2) ; n1:=i+r2; MakeRes201; end; loop i:=(tPtr2+1).upto!(enp) ; n1:=i-r1; MakeRes201; end; loop i:=(enp+1).upto!(tmpMax-1); n1:=i; MakeRes201; end; TCodePtr[tmpMax]:=endTc; TCodePtr[tPtr1+r2].sep:=VERTEXC::knot_s; TCodePtr[tPtr2+r2].sep:=VERTEXC::knot_e; TCodePtr.TrimC(tPtr,tPtr1+r2); TCodeRes[resPtr]:=TCodePtr; TraceRes[resPtr].p:=tPtr; TraceRes[resPtr].m:=TCodePtr.length; TraceRes[resPtr].c:=compo+1; end; MakeRes301 is n:=TCodeTmp[i].companion; TCodePtr.k[n1]:=#; if n<tPtr1 then TCodePtr[n1].companion:= n; elsif n<stp then TCodePtr[n1].companion:= n+o1; elsif n<tPtr2 then TCodePtr[n1].companion:= n+o2; elsif n<enp then TCodePtr[n1].companion:= n+o3; else TCodePtr[n1].companion:= n-4; end; TCodePtr[n1].sep:=TCodeTmp[i].sep; end; MakeRes3 is resPtr:=resPtr+1; TCodePtr:=#; TCodePtr.k:=#(TCodeTmp.k.size-4); r0:=stp-tPtr1-1; r1:=tPtr2-stp-1; r2:=enp-tPtr2-1; o1:=r1+r2-1; o2:=r2-r0-2; o3:=-r0-r1-3; --loop i:=0.upto!(tPtr1-1) ; n1:=i; MakeRes301; end; loop i:=(tPtr1+1).upto!(stp-1) ; n1:=i+o1; MakeRes301; end; loop i:=(stp+1).upto!(tPtr2-1) ; n1:=i+o2; MakeRes301; end; loop i:=(tPtr2+1).upto!(enp-1) ; n1:=i+o3; MakeRes301; end; loop i:=(enp+1).upto!(tmpMax-1) ; n1:=i-4; MakeRes301; end; TCodePtr[tmpMax-4]:=endTc; TCodePtr.TrimL(tPtr,tPtr2-1+o2); TCodeRes[resPtr]:=TCodePtr; TraceRes[resPtr].p:=tPtr; TraceRes[resPtr].m:=TCodePtr.length; TraceRes[resPtr].c:=compo-1; end; MakeRes is tPtr1:=tPtr; tPtr2:=TCodeTmp[tPtr].companion; stp:=tmpMax; loop enp:=stp-1; stp:=TCodeTmp[enp].companion; until!(stp<=tPtr2); end; if stp<tPtr1 then MakeRes2; else MakeRes3; end; TdRes[resPtr]:=TraceDeg.copy; ResFlg[resPtr]:=false; if VERTEXC::positive.in(TCodeTmp[tPtr].sep) then TraceDeg[2]:=TraceDeg[2]+1; TdRes[resPtr][4]:=TdRes[resPtr][4]+1; else TraceDeg[1]:=TraceDeg[1]+1; TdRes[resPtr][3]:=TdRes[resPtr][3]+1; end; tPtr:=tPtr+1; end; MakeResLow is tPtr1:=tPtr; tPtr2:=TCodeTmp[tPtr].companion; -- cod:=TCodeTmp[tPtr].sep; stp:=tmpMax; loop enp:=stp-1; stp:=TCodeTmp[enp].companion; until!(stp<=tPtr2); end; if stp<tPtr1 then MakeRes2; TdRes[resPtr]:=TraceDeg.copy; ResFlg[resPtr]:=false; if VERTEXC::positive.in(TCodeTmp[tPtr].sep) then TraceDeg[2]:=TraceDeg[2]+1; TdRes[resPtr][4]:=TdRes[resPtr][4]+1; else TraceDeg[1]:=TraceDeg[1]+1; TdRes[resPtr][3]:=TdRes[resPtr][3]+1; end; else -- MakeRes3; if VERTEXC::positive.in(TCodeTmp[tPtr].sep) then TraceDeg[2]:=TraceDeg[2]+1; else TraceDeg[1]:=TraceDeg[1]+1; end; end; tPtr:=tPtr+1; end; SetMp is if tmpMp>tPtr then flg:BOOL:=~VERTEXC::ks.in(TCodeTmp[tmpMp].sep); chf:ARRAY{BOOL}:=#(TCodeTmp.size); loop i:=tmpMp.upto!(tmpMax-1) ; chf[i]:=flg; end; tmpMp:=tmpMp-1; loop while!(tmpMp>= tPtr) ; -- TCodeTmp.printV; -- #OUT+"tPtr="+tPtr.str+" tmpMp="+tmpMp.str+"\n"; if TCodeTmp[tmpMp].companion<(tmpMp+2) then chf[tmpMp]:=true; tmpMp:=tmpMp-1; else tPtr1:=TCodeTmp[tmpMp].companion; if chf[tPtr1] then loop i:=tmpMp.upto!(tPtr1); chf[i]:=false; end; tmpMp:=tmpMp-1; elsif VERTEXC::over.in(TCodeTmp[tmpMp].sep) then tmpMp:=tmpMp-1; elsif VERTEXC::ks.in(TCodeTmp[tmpMp].sep) then loop i:=tmpMp.upto!(tPtr1); chf[i]:=false; end; tmpMp:=tmpMp-2; else tmpMp:=tmpMp+1; return; end; end; end; end; end; SetMpC is stp:=tmpMax; loop enp:=stp-1; stp:=TCodeTmp[enp].companion; until!(stp<=tPtr); end; tmpMp:=enp+1; if tmpMp=tmpMax then tmpMp:=tmpMax-4; SetMp; else loop tmpMp:=tmpMp-1; until!( (tmpMp<tPtr)or ((enp<TCodeTmp[tmpMp].companion) and(VERTEXC::under.in(TCodeTmp[tmpMp].sep)))); end; tmpMp:=tmpMp+1; end; end; SetNotWell:BOOL is loop if (tPtr>=tmpMp) then return false; elsif ((tPtr+2) < TCodeTmp[tPtr].companion) and (VERTEXC::under.in(TCodeTmp[tPtr].sep)) then return true; elsif VERTEXC::ks.in(TCodeTmp[tPtr].sep) then TCodeTmp.TrimDelPC(tPtr); tmpMax:=TCodeTmp.length; tmpMp:=TCodeTmp.length-4; SetMp; assert (tmpMax=TCodeTmp.length); end; tPtr:=tPtr+1; end; end; SetNotWellC:BOOL is loop if (tPtr>=tmpMp) then return false; elsif ((tPtr+2) < TCodeTmp[tPtr].companion) and (VERTEXC::under.in(TCodeTmp[tPtr].sep)) then return true; end; tPtr:=tPtr+1; end; end; SetTCodeTmp is loop while!(ResFlg[resPtr]) ; resPtr:=resPtr-1; end; tmp:=resPtr; TraceDeg:=TdRes[tmp].copy; ResFlg[tmp]:=true; tPtr:=TraceRes[tmp].p; tmpMax:=TraceRes[tmp].m; compo:=TraceRes[tmp].c; TCodeTmp:=TCodeRes[tmp].clone(tPtr); assert (tmpMax=TCodeTmp.length); end; end; -- POLY2

class PPOLY

class PPOLY is include POLY2; const Def_xyz,Def_lm,Def_vz; ------------------- P.poly. ----------------- private SetPolyP is degX::=TraceDeg[1]-TraceDeg[2]-TraceDeg[4]+c0p; degZ::=TraceDeg[3]+TraceDeg[4]-compo+compo0; -- polyT:=Poly[TraceDeg[3]+TraceDeg[4]-compo+compo0]; -- polyT Poly[degZ] --if (degZ<0)or(degZ>Alloc0) then -- out("Polynomial: error on degree-z."); --end; --if (degX<0)or(degX>Alloc0) then -- out("Polynomial: error on degree-x."); --end; case compo when 2 then if TraceDeg[3].is_odd then Poly[degZ][degX+1]:=Poly[degZ][degX+1]-1.inti; Poly[degZ][degX]:=Poly[degZ][degX]+1.inti; else Poly[degZ][degX+1]:=Poly[degZ][degX+1]+1.inti; Poly[degZ][degX]:=Poly[degZ][degX]-1.inti; end; when 1 then if TraceDeg[3].is_odd then Poly[degZ][degX]:=Poly[degZ][degX]-1.inti; else Poly[degZ][degX]:=Poly[degZ][degX]+1.inti; end; else degC::=compo-1; if TraceDeg[3].is_odd then loop i::=0.upto!(degC); j::=degX.up!; Poly[degZ][j]:=Poly[degZ][j]-CN[degC][i]; end; else loop i::=0.upto!(degC); j::=degX.up!; Poly[degZ][j]:=Poly[degZ][j]+CN[degC][i]; end; end; end; end; PpolyP(TCode:TCODE,DefS:INT) is -- for speed test -- rate: rateCl -- res/s: rateCl*4.4 -- 1.201< 1.25 <1.5 -- 1.25, 2.18 -- 1.27, 2.0 : (worst time)=(expected time) -- Worst case is (2,n) torus knot. -- 1.27, 6.0 : (real time) < 3*(expected time) -- 1.27202=sqrt((1+sqrt(5))/2)= sqrt of Fibonacci ratio. if ~ initRes(TCode, 1.27 , 0.0, 10000.0 ) then closeRes; return; end; count:=0; CN:=POLY_COEFF::AllocCN(Alloc0); loop while!(resPtr>0); tmpMp:=tmpMax-4; SetMp; loop while!(SetNotWell); MakeRes; end; -- count(compo); count:=count+1; SetPolyP; SetTCodeTmp; end; --t1::=DATE::get_difftime; --#OUT+"time: "+t1.str+"\n"; -- --WriteWrap; -- SetR(count.flt,"PPoly"); -- --WriteCount; --PPrintLog(DefS,"P-polynomial:"); closeRes; end; Ppoly(TCode:TCODE,DefS:INT) is -- rate: rateCl -- res/s: rateCl*4.4 -- 1.201< 1.25 <1.5 -- 1.25, 2.18 -- 1.27, 2.0 : (worst time)=(expected time) -- Worst case is (2,n) torus knot. -- 1.27, 6.0 : (real time) < 3*(expected time) -- 1.27202=sqrt((1+sqrt(5))/2)= sqrt of Fibonacci ratio. if ~ initRes(TCode, 1.27 , 0.5, POLY_TIME::rateCl*0.96) then closeRes; return; end; count:=0; time:TIME_MEASURE:=#; CN:=POLY_COEFF::AllocCN(Alloc0); loop while!(resPtr>0); tmpMp:=tmpMax-4; SetMp; loop while!(SetNotWell); MakeRes; end; -- count(compo); count:=count+1; SetPolyP; SetTCodeTmp; end; --t1::=DATE::diff_time; --#OUT+"time: "+t1.str+"\n"; -- --WriteWrap; POLY_TIME::SetR(count.flt,"PPoly"); -- --WriteCount; PPrintLog(DefS,"P-polynomial:"); closeRes; end; shared z,z1,x,x1:INT; shared ds,dx:INT; -- degree shared chs,chx:STR; shared ci:INTI; private CoeXYZs is ds:=z; chs:="(z/y)"; end; private CoeXYZx is ci:=Poly[z1][x1]; dx:=x; chx:="(x/y)"; end; private CoeVZs is ds:=z; chs:="z"; end; private CoeVZx is ci:=Poly[z1][x1]; dx:=-x-x-z; chx:="v"; end; private CoeLMs is ds:=z; chs:="m"; end; private CoeLMx is ci:=0.inti; if x.is_odd then ci:=ci-Poly[z1][x1]; else ci:=ci+Poly[z1][x1]; end; dx:=x+x+z; chx:="l"; end; private wrTitle(title,s:STR) is LOGOUT::Title(title,s); end; PPrintLog(DefS:INT,title:STR) is count,step:INT; flg,flg2:BOOL; -- not the first term, need +/- flgSt:BOOL; (* need * . *) CoeTps,CoeTpx:ROUT; case DefS when Def_xyz then -- x,y,z form. CoeTps:=bind(CoeXYZs); CoeTpx:=bind(CoeXYZx); wrTitle(title,"xP_{L+} -yP_{L-} = zP_{L0}"); when Def_lm then -- L-M form. CoeTps:=bind(CoeLMs); CoeTpx:=bind(CoeLMx); wrTitle(title,"lP_{L+} +(1/l)P_{L-} +mP_{L0} = 0"); when Def_vz then -- v-z form CoeTps:=bind(CoeVZs); CoeTpx:=bind(CoeVZx); wrTitle(title,"(1/v)P_{L+} -vP_{L-} = zP_{L0}"); else CoeTps:=bind(CoeLMs); CoeTpx:=bind(CoeLMx); DefS:=Def_lm; wrTitle(title,"unknown poly."); end; #OUT+"compo, cross(+/-): " +compo0.str+", " +c0p.str+"/" +c0n.str+"\n"; ci:=0.inti; flg:=false; z:=1-compo0; loop while!(z<=(c0p+c0n)); z1:=z+compo0-1; count:=0; loop x:=(-c0p).upto!(c0n-z); if Poly[z1][x+c0p]/=0.inti then count:=count+1; end; end; if count=1 then loop x:=(-c0p).upto!(c0n-z); x1:=x+c0p; CoeTps.call; CoeTpx.call; if ci/=0.inti then POLY_WRITE::wrCoeff(ci,inout flg,out flgSt); POLY_WRITE::wrVar(chx,dx,false,inout flgSt); POLY_WRITE::wrVar(chs,ds,true,inout flgSt); end; end; #LOGOUT+"\n"; elsif count>1 then ci:=1.inti; CoeTps.call; POLY_WRITE::wrCoeff(ci,inout flg,out flgSt); POLY_WRITE::wrVar(chs,ds,false,inout flgSt); if flgSt then #LOGOUT+"*"; end; #LOGOUT+"("; flg2:=false; case DefS when Def_xyz,Def_lm then x:=-c0p; step:=1; when Def_vz then x:=c0n-z; step:=-1; else ; end; loop while!((c0p+x)*(c0n-z-x)>=0); x1:=x+c0p; CoeTpx.call; if ci/=0.inti then POLY_WRITE::wrCoeff(ci,inout flg2,out flgSt); POLY_WRITE::wrVar(chx,dx,true,inout flgSt); end; x:=x+step; end; #LOGOUT+")\n"; end; z:=z+2; end; #LOGOUT+"\n"; LOGOUT::flush; end; -------------------P poly -LOW ---------------------- private CnvP is x1,z1:INT; ci:INTI:=0.inti; loop z1:=Alloc0.downto!(2); -- polyT:= Poly[z1-1]; loop x1:=0.upto!(Alloc0) ; ci:=Poly[z1][x1]; Poly[z1][x1]:=0.inti; if ci/=0.inti then Poly[z1-1][x1+1]:=Poly[z1-1][x1+1]+ci; Poly[z1-1][x1]:=Poly[z1-1][x1]-ci; end; end; end; polyT::=Poly[0]; -- exchange Poly[0]:=Poly[1]; Poly[1]:=polyT; end; PpolyLow(TCode:TCODE,DefS:INT) is -- 1.120< ? <1.124 if ~ initRes(TCode,1.123, 4.0, POLY_TIME::rateCl*39.0) then closeRes; return; end; count:=0; time:TIME_MEASURE:=#; loop while!(resPtr>0) ; count:=count+1; tmpMp:=tmpMax-4; loop while!(SetNotWell); MakeResLow; end; degX:INT:=TraceDeg[1]-TraceDeg[2] -TraceDeg[4]+c0p; if TraceDeg[3].is_odd then Poly[compo][degX]:= Poly[compo][degX]-1.inti; else Poly[compo][degX]:= Poly[compo][degX]+1.inti; end; SetTCodeTmp; end; --(*WriteWrap; WriteLn; *) POLY_TIME::SetR(count.flt,"PpolyLow"); CnvP; PPrintLog(DefS,"P-polynomial low:"); closeRes; end; end; -- class PPOLY

class VPOLY

class VPOLY is include POLY2; -- TYPE polyv=ARRAY[-4*PPOLYmaxC..4*PPOLYmaxC] OF LongInt; --------------------Jones' poly.--------- VPrintLog(polyV:ARRAY{INTI},shift:INT) is flg,flgSt:BOOL; t:INT; LOGOUT::Title("Jones polynomial:", "tV_{L+}-(1/t)V_{L-} = -(\sqrt{t}-1/\sqrt{t})V_{L0}"); flg:=false; loop i::=polyV.ind!; t:=i-shift; if polyV[i]/=0.inti then POLY_WRITE::wrCoeff(polyV[i],inout flg,out flgSt); if t=0 then if ~ flgSt then #LOGOUT+"1"; end; elsif t=2 then if flgSt then #LOGOUT+"*"; end; #LOGOUT+"t"; else if flgSt then #LOGOUT+"*"; end; #LOGOUT+"t"+"^{"; if t.is_odd then #LOGOUT+t.str+"/2"; else #LOGOUT+(t/2).str; end; #LOGOUT+"}"; end; end; end; -- if ~ flg then LogOut.Write('0'); end; #LOGOUT+"\n"; LOGOUT::flush; end; private SetPolyV2 is degX::=TraceDeg[1]-TraceDeg[2]-TraceDeg[4]+c0p; degZ::=TraceDeg[3]+TraceDeg[4]-compo+1; degC:INT; if degZ>=0 then degC:=compo-1; else degC:=compo-1+degZ; end; z::=degZ+compo0-1; -- polyT:= Poly[z]; if degC=2 then if TraceDeg[3].is_odd then Poly[z][degX+2]:=Poly[z][degX+2]-1.inti; Poly[z][degX+1]:=Poly[z][degX+1]+2.inti; Poly[z][degX]:=Poly[z][degX]-1.inti; else Poly[z][degX+2]:=Poly[z][degX+2]+1.inti; Poly[z][degX+1]:=Poly[z][degX+1]-2.inti; Poly[z][degX]:=Poly[z][degX]+1.inti; end; elsif degC=1 then if TraceDeg[3].is_odd then Poly[z][degX+1]:=Poly[z][degX+1]-1.inti; Poly[z][degX]:=Poly[z][degX]+1.inti; else Poly[z][degX+1]:=Poly[z][degX+1]+1.inti; Poly[z][degX]:=Poly[z][degX]-1.inti; end; elsif degC>1 then if TraceDeg[3].is_odd then loop i::=0.upto!(degC) ; j::=degX.up!; Poly[z][j]:=Poly[z][j]-CN[degC][i]; end; else loop i::=0.upto!(degC) ; j::=degX.up!; Poly[z][j]:=Poly[z][j]+CN[degC][i]; end; end; else if TraceDeg[3].is_odd then Poly[z][degX]:=Poly[z][degX]-1.inti; else Poly[z][degX]:=Poly[z][degX]+1.inti; end; end; end; private cnvV2(out polyV:ARRAY{INTI},out offset:INT):BOOL is -- Use with SetPolyV2 z,z1,maxZ,x:INT; ci:INTI; flg:BOOL; offset:=(Alloc0+1)*4; polyV:=#(offset*2+1); loop i::=polyV.ind!; polyV[i]:=0.inti; end; ci:=0.inti; flg:=true; maxZ:=c0p+c0n; z:=1-compo0; pcn:POLYS_INTI; loop while!(z<= maxZ); ci:=0.inti; if z>=0 then z1:=z; pcn:=CN[z1]; else z1:=-z; pcn:=CP[z1]; end; loop x:=(-c0p).upto!(c0n-z); degZ::=4*x+z; ci:=Poly[z+compo0-1][x+c0p]; if ci/=0.inti then if z1.is_odd then loop i:=0.upto!(z1) ; polyV[degZ+offset]:=polyV[degZ+offset]-ci*pcn[i]; degZ:=degZ+2; end; else loop i:=0.upto!(z1); polyV[degZ+offset]:=polyV[degZ+offset]+ci*pcn[i]; degZ:=degZ+2; end; end; end; ci:=0.inti; end; z:=z+2; end; loop while!(z<=(c0p+c0n)); loop x:=(-c0p).upto!(c0n-z); if Poly[z+compo0-1][x+c0p]/=0.inti then flg:=false; end; end; z:=z+2; end; return flg; end; VpolyP(TCode:TCODE, out polyV:ARRAY{INTI}, out offset:INT):BOOL is -- t * V(Lp) - 1/t * V(Ln) + (t^1/2 - t^(-1/2)) * V(Ls) = 0 . if ~initRes(TCode,1.27, 0.5,POLY_TIME::rateCl*0.96) then closeRes; return false; end; count:=0; time:TIME_MEASURE:=#; CN:=POLY_COEFF::AllocCN(Alloc0); CP:=POLY_COEFF::AllocCP(Alloc0); loop while!(resPtr>0); count:=count+1; tmpMp:=tmpMax-4; SetMp; loop while!( SetNotWell) ; MakeRes; end; SetPolyV2; SetTCodeTmp; end; VFlg::=cnvV2(out polyV,out offset); closeRes; return VFlg; end; Vpoly(TCode:TCODE) is -- t * V(Lp) - 1/t * V(Ln) + (t^1/2 - t^(-1/2)) * V(Ls) = 0 . polyV:ARRAY{INTI}; offset:INT; i:INT; if VpolyP(TCode, out polyV,out offset) then -- WriteWrap; WriteLn; POLY_TIME::SetR(count.flt,"VPoly"); VPrintLog(polyV,offset); end; end; VPara(TCode:TCODE, n:INT) is -- V polynomial of n-parallel for knot. polyV:ARRAY{INTI}; offset:INT; PARALLEL_T::parallel(inout TCode, n); if VpolyP(TCode, out polyV,out offset) then POLY_TIME::SetR(count.flt,"VPoly"); VPrintLog(polyV,offset); end; end; end; -- class VPOLY

class CPOLY

class CPOLY is include POLY2; --------------------C.poly.---------------- Cpoly(TCode:TCODE) is if ~ initRes(TCode,1.27, 0.5, POLY_TIME::rateCl*1.1) then closeRes; return; end; count:=0; time:TIME_MEASURE:=#; PolyCon:ARRAY{INTI}:=#(Alloc0+1); loop i::=PolyCon.ind!; PolyCon[i]:=0.inti; end; loop while!(resPtr>0); count:=count+1; SetMpC; loop while!( SetNotWellC) ; MakeRes; end; if compo=1 then if TraceDeg[3].is_odd then PolyCon[TraceDeg[3]+TraceDeg[4]]:= PolyCon[TraceDeg[3]+TraceDeg[4]]-1.inti; else PolyCon[TraceDeg[3]+TraceDeg[4]]:= PolyCon[TraceDeg[3]+TraceDeg[4]]+1.inti; end; end; SetTCodeTmp; end; -- WriteWrap; WriteLn; POLY_TIME::SetR(count.flt,"CPoly"); -- WriteCount; cpoly:POLYS_INTI:=POLYS_INTI::gen_func(PolyCon); cpoly.normalize; ALEXMAT::printConway(cpoly); closeRes; end; end; -- class CPOLY

class APOLY

class APOLY is include POLY2; ---------------- A.poly.--------------- ApolyC(TCode:TCODE) is if ~ initRes(TCode,1.27, 0.5, POLY_TIME::rateCl*1.1) then closeRes; return; end; count:=0; PolyCon:ARRAY{INTI}:=#(Alloc0); -- [0..maxC] loop i::=PolyCon.ind!; PolyCon[i]:=0.inti; end; loop while!(resPtr>0) ; count:=count+1; SetMpC; loop while!(SetNotWellC) ; MakeRes; end; if compo=1 then if TraceDeg[3].is_odd then PolyCon[TraceDeg[3]+TraceDeg[4]]:= PolyCon[TraceDeg[3]+TraceDeg[4]]-1.inti; else PolyCon[TraceDeg[3]+TraceDeg[4]]:= PolyCon[TraceDeg[3]+TraceDeg[4]]+1.inti; end; end; SetTCodeTmp; end; -- WriteWrap; WriteLn; POLY_TIME::SetR(count.flt,"APoly"); cpoly:POLYS_INTI:=POLYS_INTI::gen_func(PolyCon); cpoly.normalize; apoly:POLYS_INTI; ALEXMAT::conway2apoly(cpoly,out apoly); ALEXMAT::printApoly(apoly); closeRes; end; end; -- APOLY