gbases.sa


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

-- 
--  This code is distributed freely in the sence of 
--  GPL(GNU General Public License).
--


class GBASES_INTI

class GBASES_INTI is -- reduced minimal strong Grobner base for ideal in Z[x] -- Use as: glist=getGBaseI([f1,f2,f3,...]) -- -- 2001-02-03 Sather version -- K.Kodama 2000-02-04 Ruby first version -- include GBASES_INTI_ALG{POLYS_INTI,INTI}; end;

class GBASES_INTI_L

class GBASES_INTI_L is -- reduced minimal strong Grobner base for ideal -- in Laurent polynomial Z<x>. -- -- Use as: glist=getGBaseIL([f1,f2,f3,...]) -- -- 2001-02-03 Sather version -- K.Kodama 2000-02-17 Ruby first version include GBASES_INTI_ALG{POLYS_INTI,INTI}; include GBASES_INTI_L_ALG{POLYS_INTI,INTI}; end;

partial class GBASES_INTI_L_ALG{POLY,R}

partial class GBASES_INTI_L_ALG{POLY,R} is shared GPoly:POLY; makeGBaseI1L is -- make Grobner basis GBase.sort; GBase:=GBase.reverse; absGB; q:ARRAY{POLY}; s,h:POLY; lcH:INTI; loop while!(S_list.is_empty.not); s:=S_list.pop.element; h:=s.mod_lt(GBase); if ~h.is_zero then h:=h.shift0; if h.lc.is_neg then h:=-h; end; loop S_list.insert( wrap.create(h.S_poly_PID(GBase.elt!))); end; S_list.insert( wrap.create(h.S_poly_PID_L2(GPoly))); S_list.insert( wrap.create(h.S_poly_PID_L3(GPoly))); -- GBase:=GBase.append(|h|); GBase.sort; GBase:=GBase.reverse; GBase:=ARRAY_SORT{POLY}::sorted_rev_insert(GBase, h); end; end; end; shift0GBase:BOOL is sFlg::=false; loop i::=GBase.ind!; if GBase[i][0].is_zero then sFlg:=true; GBase[i]:=GBase[i].shift0; end; end; return sFlg; end; getGBaseIL(fList:ARRAY{POLY}):ARRAY{POLY} is GBase:=#; loop fi::=fList.elt!.normalize; if fi.is_zero.not then GBase:=GBase.append(|fi|); end; end; if GBase.size=0 then return (#); end; loop while!(shift0GBase); GBase:=GBASES_INTI::getGBaseI(GBase); end; listr:ARRAY{POLY}:=#(GBase.size); loop i::=GBase.ind!; listr[i]:=GBase[i].reverseDeg; end; gf:POLY:=POLY::one*2; loop f::=listr.elt!; if ( (f.lc.abs=POLY::r_1)and ((gf.lc.abs/=POLY::r_1)or(f.degree<gf.degree))) then gf:=f.copy; end; end; if gf.lc.abs /= POLY::r_1 then listr:=GBASES_INTI::getGBaseI(listr); gf:=listr[0].copy; end; if gf.lc.is_neg then gf:=-gf; end; GPoly:=gf.reverseDeg; S_list:=#; loop i::=GBase.ind!; S_list.insert( wrap.create(GBase[i].S_poly_PID_L2(GPoly))); S_list.insert( wrap.create(GBase[i].S_poly_PID_L3(GPoly))); end; makeGBaseI1L; makeStrongGBI; makeMinimalStrongGBI; GBase.sort; GBase:=GBase.reverse; return GBase; end; end;

partial class GBASES_INTI_ALG{POLY,R}

partial class GBASES_INTI_ALG{POLY,R} is shared S_list:A_PQ{PQMIN{POLY}}; -- queue of S-polynomial. shared wrap:PQMIN{POLY}; shared GBase:ARRAY{POLY}; absGB is loop i::=GBase.ind!; if GBase[i].lc.is_neg then GBase[i]:=-GBase[i]; end; end; end; makeGBaseI is -- make Grobner basis GBase.sort; GBase:=GBase.reverse; absGB; q:ARRAY{POLY}; s,h:POLY; lcH:INTI; loop while!(S_list.is_empty.not); s:=S_list.pop.element; h:=s.mod_lt(GBase); if ~h.is_zero then if h.lc.is_neg then h:=-h; end; loop S_list.insert( wrap.create(h.S_poly_PID(GBase.elt!))); end; -- GBase:=GBase.append(|h|); GBase.sort; GBase:=GBase.reverse; GBase:=ARRAY_SORT{POLY}::sorted_rev_insert(GBase, h); end; end; end; shared StrongGb:ARRAY{POLY}; searchSaturatedSubsetI(i:INT, lcmD:INT) is -- lcmM::=lcmP.lp; -- lcmD:INT:=lcmP.degree; (c.f gbasem.sa) if i>=GBase.size then sat:ARRAY{POLY}; -- set saturated subset sat:=#; -- lcmP: lcm of j[*].lp. for poly in GBase loop poly::=GBase.elt!; if lcmD>=poly.degree then sat:=sat.append(|poly|); end; end; if sat.size=0 then return; end; cj:ARRAY{R}:=#(sat.size); loop k::=sat.ind!; cj[k]:=sat[k].lc; end; aj:ARRAY{R}; cJ:R; cJ:=INTI_EXT::extended_gcd(cj,out aj); fJ::=POLY::zero; loop k::=sat.ind!; fJ:=fJ+(sat[k]*aj[k]).shift_deg(lcmD-sat[k].degree); end; StrongGb:=StrongGb.append(|fJ|); else d::=GBase[i].degree; searchSaturatedSubsetI(i+1,lcmD); if lcmD<d then --if ~lcmP.lp.is_divisible(lp) then searchSaturatedSubsetI(i+1,d); end; end; end; reductionSameLpI is GBase.sort; GBase:=GBase.reverse; -- Make GBase[] have different lp. --#OUT+"reductionSameLpI\n"; f:POLY; a0,a1:R; i::=0; loop while!(i<GBase.size-1); j::=i+1; loop while!(j<GBase.size); if GBase[i].degree=GBase[j].degree then gcd::=INTI_EXT::extended_gcd(GBase[i].lc,GBase[j].lc,out a0,out a1); f:=GBase[i]*a0+GBase[j]*a1; GBase[i]:=f; GBase:=ARRAY_EXT{POLY}::delete_at(j,GBase); else j:=j+1; end; end; i:=i+1; end; end; makeStrongGBI is -- make strong Grobner basis absGB; reductionSameLpI; -- for all saturated subset GBase.sort; GBase:=GBase.reverse; StrongGb:=#; searchSaturatedSubsetI(0,0); GBase:=StrongGb.copy; absGB; reductionSameLpI; GBase.sort; GBase:=GBase.reverse; end; makeMinimalStrongGBI is g:ARRAY{POLY}:=#; p,r:POLY; GBase.sort; GBase:=GBase.reverse; i::=0; loop while!(i<GBase.size); p:=GBase[i]; g:=ARRAY_EXT{POLY}::delete_at(i,GBase); r:=p.mod(g); if r.is_zero then GBase:=ARRAY_EXT{POLY}::delete_at(i,GBase); else GBase[i]:=r; i:=i+1; end; end; GBase.sort; GBase:=GBase.reverse; end; getGBaseI(fList:ARRAY{POLY}):ARRAY{POLY} is GBase:=#; loop fi::=fList.elt!.normalize; if fi.is_zero.not then GBase:=GBase.append(|fi|); end; end; if GBase.size=0 then return (#); end; S_list:=#; loop i::=0.upto!(GBase.size-2); loop j::=(i+1).upto!(GBase.size-1); S_list.insert( wrap.create(GBase[i].S_poly_PID(GBase[j])) ); end; end; --#OUT+GBase.str+"\n"; --#OUT+"makeGBaseI\n"; makeGBaseI; --#OUT+GBase.str+"\n"; --#OUT+"makeStrongGBI\n"; makeStrongGBI; --#OUT+GBase.str+"\n"; --#OUT+"makeMinimalStrongGBI\n"; makeMinimalStrongGBI; --#OUT+GBase.str+"\n"; --#OUT+"sort\n"; GBase.sort; GBase:=GBase.reverse; --#OUT+GBase.str+"\n"; return GBase; end; end;