ppolyb.sa


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


partial class POLY2_B{POLY}

partial class POLY2_B{POLY} is shared px:POLY; -- positive exchange shared nx:POLY; -- negative exchange shared ps:POLY; -- positive smoothing shared ns:POLY; -- negative smoothing shared polys:POLY; -- sum stub setVar; stub polyb(b:BRAID):POLY; stub StumpSum(compo:INT, poly:POLY); test_time(braid:BRAID):FLT is s::="3: 1 -2 endcode"; b:BRAID:=#(s); b:=b^10; --#OUT+"test_time: "+b.str+"\n"; setVar; time:TIME_MEASURE:=#; time.mark; p:POLY:=polyb(b); --#OUT+"test_time: "+p.str+"\n"+"elapsed time="+time.elapsed.str+"\n"; t0:FLT:=time.elapsed.flt/b.w.size.flt; t1:FLT:=t0*braid.w.size.flt; -- factor:ARRAY{FLT}:=|0.0, 0.0, 1.0, 2.0, 15.0, 100.0, 1.0e3, 1.2e4, 1.7e5, 2.7e6, 5.1e7 |; -- t1:FLT:=t1*factor[(factor.size-1).min(braid.index)]; loop i::=1.upto!(braid.index); t1:=t1*(i+1).flt; end; return t1; end; incHash(inout hash:MAP{PERM,POLY}, perm:PERM, poly:POLY) is if hash.has_ind(perm) then hash[perm]:=hash[perm]+poly; else hash[perm]:=poly; end; end; polyb(b:BRAID, p0:POLY) is hash:MAP{PERM,POLY}:=#; hash[ #PERM(b.index) ]:=p0; loop i::=b.w.ind!; s::=b.w[i]; sa:CARD:=s.abs.card; hash1:MAP{PERM,POLY}:=#; loop perm::=hash.ind!; p::=hash[perm]; perm1::=perm.swap(sa,sa+1); if s.is_pos and (perm[sa]<perm[sa+1]) then incHash(inout hash1, perm1,p*px); incHash(inout hash1, perm, p*ps); elsif s.is_neg and (perm[sa]>perm[sa+1]) then incHash(inout hash1, perm1,p*nx); incHash(inout hash1, perm, p*ns); else incHash(inout hash1, perm1,p); end; end; hash:=hash1; end; loop perm::=hash.ind!; poly::=hash[perm]; b1:BRAID:=BRAID_REDUCTION::wordReduction(perm.inv.braid,true); if b1.size.is_pos then polyb(b1,poly); else StumpSum(b1.index.int, poly);--trivial link. b1.index component end; end; end; end;

class PPOLYB

class PPOLYB is -- P polynomial. -- sample: 94 crossing knot 5 string cloced braid (1 -2 3 -4)^(24). -- 169sec -- IBM ThinkPad240 (Celelon 300), Linux2.0.38/libc.so.5.4.46. include POLY2_B{POLYM_INTI}; shared link:POLYM_INTI; setVar is setVar(PPOLY::Def_xyz); end; setVar(DefS:CARD) is polys:= POLYM_INTI::zero; case DefS when PPOLY::Def_xyz then -- xP_{L+} -yP_{L-} = zP_{L0} px:=#POLYM_INTI("y")*#POLYM_INTI(1.inti,"x",-1); ps:=#POLYM_INTI("z")*#POLYM_INTI(1.inti,"x",-1); nx:=#POLYM_INTI("x")*#POLYM_INTI(1.inti,"y",-1); ns:=-#POLYM_INTI("z")*#POLYM_INTI(1.inti,"y",-1); link:=(#POLYM_INTI("x")-#POLYM_INTI("y")) *#POLYM_INTI(1.inti,"z",-1); when PPOLY::Def_lm then -- lP_{L+} +(1/l)P_{L-} +mP_{L0} = 0 px:=-#POLYM_INTI(1.inti,"l",-2); ps:=-#POLYM_INTI("m")*#POLYM_INTI(1.inti,"l",-1); nx:=-#POLYM_INTI(1.inti,"l",2.int); ns:=-#POLYM_INTI("m")*#POLYM_INTI(1.inti,"l",1.int); link:=-(#POLYM_INTI("l")+#POLYM_INTI(1.inti,"l",-1)) *#POLYM_INTI(1.inti,"m",-1); when PPOLY::Def_vz then -- (1/v)P_{L+} -vP_{L-} = zP_{L0} px:=#POLYM_INTI(1.inti,"v",2.int); ps:=#POLYM_INTI("z")*#POLYM_INTI(1.inti,"v",1.int); nx:=#POLYM_INTI(1.inti,"v",-2); ns:=-#POLYM_INTI("z")*#POLYM_INTI(1.inti,"v",-1); link:=(#POLYM_INTI(1.inti,"v",-1)-#POLYM_INTI(1.inti,"v",1.int)) *#POLYM_INTI(1.inti,"z",-1); end; end; StumpSum(compo:INT, poly:POLYM_INTI) is polys:=polys+poly*link^(compo-1); end; polyb(braid:BRAID):POLYM_INTI is polyb(braid, POLYM_INTI::one); return polys; end; polyb(tcode:TCODE):POLYM_INTI is polys:=POLYM_INTI::zero; braid:BRAID:=#; if ~BRAID_CNV::TCode2Braid(tcode, out braid) then return polys; end; return polyb(braid); end; Ppoly(tcode:TCODE,DefS:CARD):POLYM_INTI is setVar(DefS); return polyb(tcode); end; end;

class VPOLYB

class VPOLYB is include POLY2_B{POLYM_INTI}; shared link:POLYM_INTI; setVar is polys:= POLYM_INTI::zero; px:=#POLYM_INTI(1.inti,"s",-4); ps:=-#POLYM_INTI(1.inti,"s",-1)+#POLYM_INTI(1.inti,"s",-3); nx:=#POLYM_INTI(1.inti,"s",4.int); ns:= #POLYM_INTI(1.inti,"s",3.int)-#POLYM_INTI(1.inti,"s",1.int); link:=-(#POLYM_INTI(1.inti,"s",1.int)+#POLYM_INTI(1.inti,"s",-1)); end; StumpSum(compo:INT, poly:POLYM_INTI) is polys:=polys+poly*link^(compo-1); end; polyb(braid:BRAID):POLYM_INTI is polyb(braid, POLYM_INTI::one); return polys; end; polyb(tcode:TCODE):POLYM_INTI is polys:=POLYM_INTI::zero; braid:BRAID:=#; if ~BRAID_CNV::TCode2Braid(tcode, out braid) then return polys; end; return polyb(braid); end; Vpoly(tcode:TCODE,out poly:POLYS_INTI,out offset:INT) is -- Jones polynomial. -- tV_{L+} - (1/t)V_{L-} = -(\sqrt{t}-1/\sqrt{t})V_{L0}. -- (s^2) V_{L+} - (s^(-2)) V_{L-} = -(s-1/s) V_{L0}. where s=sqrt(t). setVar; pm:POLYM_INTI:=polyb(tcode); mdeg:INT:=0; loop i::=pm.monomials.ind!; mdeg:=mdeg.min(pm.monomials[i]["s"]); end; offset:=-mdeg; poly:=#; loop i::=pm.monomials.ind!; poly[(pm.monomials[i]["s"]+offset).card]:=pm.monomials[i].coeff; end; end; end;

class CPOLYB

class CPOLYB is include POLY2_B{POLYS_INTI}; StumpSum(compo:INT, poly:POLYS_INTI) is if compo.is_one then polys:=polys+poly; end; end; setVar is polys:= POLYS_INTI::zero; px:= POLYS_INTI::one; nx:= POLYS_INTI::one; ps:= POLYS_INTI::x; ns:= -(POLYS_INTI::x); end; polyb(braid:BRAID):POLYS_INTI is polyb(braid, POLYS_INTI::one); return polys; end; polyb(tcode:TCODE):POLYS_INTI is polys:= POLYS_INTI::zero; braid:BRAID:=#; if ~BRAID_CNV::TCode2Braid(tcode, out braid) then return polys; end; return polyb(braid); end; Cpoly(tcode:TCODE):POLYS_INTI is -- Conway poly. setVar; return polyb(tcode); end; Cpoly(braid:BRAID):POLYS_INTI is -- Conway poly. setVar; return polyb(braid); end; end;

class TEST_PPOLYB

class TEST_PPOLYB is include TEST; main is class_name("PPOLYB"); POLYS_INTI::init; POLYM_INTI::init; s:STR; b:BRAID:=#("2 : 1 1 1 endcode"); s:=CPOLYB::Cpoly(b).str; test("3_1", s, "x^{2}+1"); b:=#("3 : -1 2 -1 2 endcode"); s:=CPOLYB::Cpoly(b).str; test("4_1", s, "-x^{2}+1"); b:=#("4 : -1 2 3 2 1 2 2 2 2 -3 2 endcode"); s:=CPOLYB::Cpoly(b).str; test("7_3", s, "2*x^{4}+5*x^{2}+1"); finish; end; end;