[BACK]Return to pd.rr CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-contrib / testing / noro

Diff for /OpenXM/src/asir-contrib/testing/noro/Attic/pd.rr between version 1.6 and 1.7

version 1.6, 2010/05/21 06:45:06 version 1.7, 2010/06/02 04:25:46
Line 12  localf partial_decomp, partial_decomp0, zprimacomp, zp
Line 12  localf partial_decomp, partial_decomp0, zprimacomp, zp
 localf fast_gb, incremental_gb, elim_gb, ldim, make_mod_subst$  localf fast_gb, incremental_gb, elim_gb, ldim, make_mod_subst$
 localf rsgn, find_npos, gen_minipoly, indepset$  localf rsgn, find_npos, gen_minipoly, indepset$
 localf maxindep, contraction, ideal_list_intersection, ideal_intersection$  localf maxindep, contraction, ideal_list_intersection, ideal_intersection$
 localf radical_membership, quick_radical_membership, modular_radical_membership$  localf radical_membership, modular_radical_membership$
 localf radical_membership_rep, ideal_product, saturation$  localf radical_membership_rep, ideal_product, saturation$
 localf sat, satind, sat_ind, colon$  localf sat, satind, sat_ind, colon$
 localf ideal_colon, ideal_sat, ideal_inclusion, qd_simp_comp, qd_remove_redundant_comp$  localf ideal_colon, ideal_sat, ideal_inclusion, qd_simp_comp, qd_remove_redundant_comp$
 localf pd_remove_redundant_comp, ppart, sq$  localf pd_remove_redundant_comp, ppart, sq, gen_fctr, gen_nf, gen_gb_comp$
 localf lcfactor, compute_deg0, compute_deg, member$  localf gen_mptop, lcfactor, compute_deg0, compute_deg, member$
 localf elimination, setintersection, setminus, sep_list$  localf elimination, setintersection, setminus, sep_list$
 localf first_element, comp_tdeg, tdeg, comp_by_ord, comp_by_second$  localf first_element, comp_tdeg, tdeg, comp_by_ord, comp_by_second$
 localf gbcheck,f4,sathomo,qdcheck$  localf gbcheck,f4,sathomo,qd_check$
   
 SatHomo=0$  SatHomo=0$
 GBCheck=1$  GBCheck=1$
Line 71  def kill_procs()
Line 71  def kill_procs()
   
 def qd_check(B,V,QD)  def qd_check(B,V,QD)
 {  {
         G = nd_gr(B,V,0,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         Iso = ideal_list_intersection(map(first_element,QD[0]),V,0);          G = nd_gr(B,V,Mod,0);
         Emb = ideal_list_intersection(map(first_element,QD[1]),V,0);          Iso = ideal_list_intersection(map(first_element,QD[0]),V,0|mod=Mod);
         GG = ideal_intersection(Iso,Emb,V,0);          Emb = ideal_list_intersection(map(first_element,QD[1]),V,0|mod=Mod);
         return gb_comp(G,GG);          GG = ideal_intersection(Iso,Emb,V,0|mod=Mod);
           return gen_gb_comp(G,GG,Mod);
 }  }
   
 /* SYC primary decomositions */  /* SYC primary decomositions */
Line 83  def qd_check(B,V,QD)
Line 84  def qd_check(B,V,QD)
 def syca_dec(B,V)  def syca_dec(B,V)
 {  {
 T00 = time();  T00 = time();
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Nolexdec=getopt(nolexdec)) == -1 ) Nolexdec = 0;          if ( type(Nolexdec=getopt(nolexdec)) == -1 ) Nolexdec = 0;
         if ( type(SepIdeal=getopt(sepideal)) == -1 ) SepIdeal = 1;          if ( type(SepIdeal=getopt(sepideal)) == -1 ) SepIdeal = 1;
         if ( type(NoSimp=getopt(nosimp)) == -1 ) NoSimp = 0;          if ( type(NoSimp=getopt(nosimp)) == -1 ) NoSimp = 0;
         if ( type(Time=getopt(time)) == -1 ) Time = 0;          if ( type(Time=getopt(time)) == -1 ) Time = 0;
         Ord = 0;          Ord = 0;
         Gt = G0 = G = fast_gb(B,V,0,Ord);          Gt = G0 = G = fast_gb(B,V,Mod,Ord);
         Q0 = Q = []; IntQ0 = IntQ = [1]; First = 1;          Q0 = Q = []; IntQ0 = IntQ = [1]; First = 1;
         C = 0;          C = 0;
   
Line 97  T00 = time();
Line 99  T00 = time();
         while ( 1 ) {          while ( 1 ) {
                 if ( type(Gt[0])==1 ) break;                  if ( type(Gt[0])==1 ) break;
                 T0 = time();                  T0 = time();
                 Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec);                  Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod);
                 T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3];                  T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3];
                 T0 = time();                  T0 = time();
                 Qt = iso_comp(Gt,Pt,V,Ord);                  Qt = iso_comp(Gt,Pt,V,Ord|mod=Mod,isgb=1);
                 T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3];                  T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3];
                 IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord);                  IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod);
                 IntPt = ideal_list_intersection(map(first_element,Pt),V,Ord);                  IntPt = ideal_list_intersection(map(first_element,Pt),V,Ord|mod=Mod);
                 if ( First ) {                  if ( First ) {
                         IntQ0 = IntQ = IntQt; IntP = IntPt; Qi = Qt; First = 0;                          IntQ0 = IntQ = IntQt; IntP = IntPt; Qi = Qt; First = 0;
                 } else {                  } else {
                         IntQ1 = ideal_intersection(IntQ,IntQt,V,Ord);                          IntQ1 = ideal_intersection(IntQ,IntQt,V,Ord|mod=Mod);
                         if ( gb_comp(IntQ,IntQ1) ) {                          if ( gen_gb_comp(IntQ,IntQ1,Mod) ) {
                                 G = Gt; IntP = IntPt; Q = []; IntQ = [1]; C = 0;                                  G = Gt; IntP = IntPt; Q = []; IntQ = [1]; C = 0;
                                 continue;                                  continue;
                         } else {                          } else {
                                 IntQ = IntQ1;                                  IntQ = IntQ1;
                                 IntQ1 = ideal_intersection(IntQ0,IntQt,V,Ord);                                  IntQ1 = ideal_intersection(IntQ0,IntQt,V,Ord|mod=Mod);
                                 if ( !gb_comp(IntQ0,IntQ1) ) {                                  if ( !gen_gb_comp(IntQ0,IntQ1,Mod) ) {
                                           Q = append(Qt,Q);
   #if 1
                                           for ( T = Qt; T != []; T = cdr(T) )
                                                   if ( !ideal_inclusion(IntQ0,car(T)[0],V,Ord|mod=Mod) )
                                                           Q0 = append(Q0,[car(T)]);
   #else
                                           Q0 = append(Q0,Qt);
   #endif
                                         IntQ0 = IntQ1;                                          IntQ0 = IntQ1;
                                         Q = append(Qt,Q); Q0 = append(Qt,Q0);  
                                 }                                  }
                         }                          }
                 }                  }
                 if ( gb_comp(IntQt,Gt) || gb_comp(IntQ,G) || gb_comp(IntQ0,G0) ) break;                  if ( gen_gb_comp(IntQt,Gt,Mod) || gen_gb_comp(IntQ,G,Mod) || gen_gb_comp(IntQ0,G0,Mod) ) break;
                 T0 = time();                  T0 = time();
                 C1 = ideal_colon(G,IntQ,V);                  C1 = ideal_colon(G,IntQ,V|mod=Mod);
                 T1 = time(); Tcolon += T1[0]-T0[0]+T1[1]-T0[1]; Rcolon += T1[3]-T0[3];                  T1 = time(); Tcolon += T1[0]-T0[0]+T1[1]-T0[1]; Rcolon += T1[3]-T0[3];
                 if ( C && gb_comp(C,C1) ) {                  if ( C && gen_gb_comp(C,C1,Mod) ) {
                         G = Gt; IntP = IntPt; Q = []; IntQ = [1]; C = 0;                          G = Gt; IntP = IntPt; Q = []; IntQ = [1]; C = 0;
                         continue;                          continue;
                 } else C = C1;                  } else C = C1;
                 T0 = time();                  T0 = time();
                 if ( SepIdeal == 0 )                  if ( SepIdeal == 0 )
                         Ok = find_separating_ideal0(C,G,IntQ,IntP,V,Ord);                          Ok = find_separating_ideal0(C,G,IntQ,IntP,V,Ord|mod=Mod);
                 else if ( SepIdeal == 1 )                  else if ( SepIdeal == 1 )
                         Ok = find_separating_ideal1(C,G,IntQ,IntP,V,Ord);                          Ok = find_separating_ideal1(C,G,IntQ,IntP,V,Ord|mod=Mod);
                 else if ( SepIdeal == 2 )                  else if ( SepIdeal == 2 )
                         Ok = find_separating_ideal2(C,G,IntQ,IntP,V,Ord);                          Ok = find_separating_ideal2(C,G,IntQ,IntP,V,Ord|mod=Mod);
                 G1 = append(Ok,G);                  G1 = append(Ok,G);
                 Gt1 = fast_gb(G1,V,0,Ord);                  Gt1 = fast_gb(G1,V,Mod,Ord);
                 T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3];                  T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3];
 #if 0  #if 0
                 if ( ideal_inclusion(Gt1,Gt,V,Ord) ) {                  if ( ideal_inclusion(Gt1,Gt,V,Ord|mod=Mod) ) {
                         G = Gt; IntP = IntPt; Q = []; IntQ = [1]; C = 0;                          G = Gt; IntP = IntPt; Q = []; IntQ = [1]; C = 0;
                 } else                  } else
 #endif  #endif
                         Gt = Gt1;                          Gt = Gt1;
         }          }
         T0 = time();          T0 = time();
         if ( !NoSimp ) Q1 = qd_remove_redundant_comp(G0,Qi,Q0,V,Ord);          if ( !NoSimp ) Q1 = qd_remove_redundant_comp(G0,Qi,Q0,V,Ord|mod=Mod);
         else Q1 = Q0;          else Q1 = Q0;
         if ( Time ) {          if ( Time ) {
                 T1 = time(); Tirred += T1[0]-T0[0]+T1[1]-T0[1]; Rirred += T1[3]-T0[3];                  T1 = time(); Tirred += T1[0]-T0[0]+T1[1]-T0[1]; Rirred += T1[3]-T0[3];
Line 161  T00 = time();
Line 170  T00 = time();
 def syc_dec(B,V)  def syc_dec(B,V)
 {  {
 T00 = time();  T00 = time();
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Nolexdec=getopt(nolexdec)) == -1 ) Nolexdec = 0;          if ( type(Nolexdec=getopt(nolexdec)) == -1 ) Nolexdec = 0;
         if ( type(SepIdeal=getopt(sepideal)) == -1 ) SepIdeal = 1;          if ( type(SepIdeal=getopt(sepideal)) == -1 ) SepIdeal = 1;
         if ( type(NoSimp=getopt(nosimp)) == -1 ) NoSimp = 0;          if ( type(NoSimp=getopt(nosimp)) == -1 ) NoSimp = 0;
         if ( type(Time=getopt(time)) == -1 ) Time = 0;          if ( type(Time=getopt(time)) == -1 ) Time = 0;
         Ord = 0;          Ord = 0;
         G = fast_gb(B,V,0,Ord);          G = fast_gb(B,V,Mod,Ord);
         Q = []; IntQ = [1]; Gt = G; First = 1;          Q = []; IntQ = [1]; Gt = G; First = 1;
         Tass = Tiso = Tcolon = Tsep = Tirred = 0;          Tass = Tiso = Tcolon = Tsep = Tirred = 0;
         Rass = Riso = Rcolon = Rsep = Rirred = 0;          Rass = Riso = Rcolon = Rsep = Rirred = 0;
         while ( 1 ) {          while ( 1 ) {
                 if ( type(Gt[0])==1 ) break;                  if ( type(Gt[0])==1 ) break;
                 T0 = time();                  T0 = time();
                 Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec);                  Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod);
                 T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3];                  T1 = time(); Tass += T1[0]-T0[0]+T1[1]-T0[1]; Rass += T1[3]-T0[3];
                 T0 = time();                  T0 = time();
                 Qt = iso_comp(Gt,Pt,V,Ord);                  Qt = iso_comp(Gt,Pt,V,Ord|mod=Mod,isgb=1);
                 T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3];                  T1 = time(); Tiso += T1[0]-T0[0]+T1[1]-T0[1]; Riso += T1[3]-T0[3];
                 IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord);                  IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod);
                 IntPt = ideal_list_intersection(map(first_element,Pt),V,Ord);                  IntPt = ideal_list_intersection(map(first_element,Pt),V,Ord|mod=Mod);
                 if ( First ) {                  if ( First ) {
                         IntQ = IntQt; Qi = Qt; First = 0;                          IntQ = IntQt; Qi = Qt; First = 0;
                 } else {                  } else {
                         IntQ1 = ideal_intersection(IntQ,IntQt,V,Ord);                          IntQ1 = ideal_intersection(IntQ,IntQt,V,Ord|mod=Mod);
                         if ( !gb_comp(IntQ1,IntQ) )                          if ( !gen_gb_comp(IntQ1,IntQ,Mod) )
                                 Q = append(Qt,Q);                                  Q = append(Qt,Q);
                 }                  }
                 if ( gb_comp(IntQ,G) || gb_comp(IntQt,Gt) )                  if ( gen_gb_comp(IntQ,G,Mod) || gen_gb_comp(IntQt,Gt,Mod) )
                         break;                          break;
                 T0 = time();                  T0 = time();
                 C = ideal_colon(Gt,IntQt,V);                  C = ideal_colon(Gt,IntQt,V|mod=Mod);
                 T1 = time(); Tcolon += T1[0]-T0[0]+T1[1]-T0[1]; Rcolon += T1[3]-T0[3];                  T1 = time(); Tcolon += T1[0]-T0[0]+T1[1]-T0[1]; Rcolon += T1[3]-T0[3];
                 T0 = time();                  T0 = time();
                 if ( SepIdeal == 0 )                  if ( SepIdeal == 0 )
                         Ok = find_separating_ideal0(C,Gt,IntQt,IntPt,V,Ord);                          Ok = find_separating_ideal0(C,Gt,IntQt,IntPt,V,Ord|mod=Mod);
                 else if ( SepIdeal == 1 )                  else if ( SepIdeal == 1 )
                         Ok = find_separating_ideal1(C,Gt,IntQt,IntPt,V,Ord);                          Ok = find_separating_ideal1(C,Gt,IntQt,IntPt,V,Ord|mod=Mod);
                 else if ( SepIdeal == 2 )                  else if ( SepIdeal == 2 )
                         Ok = find_separating_ideal2(C,Gt,IntQt,IntPt,V,Ord);                          Ok = find_separating_ideal2(C,Gt,IntQt,IntPt,V,Ord|mod=Mod);
                 G1 = append(Ok,Gt);                  G1 = append(Ok,Gt);
                 Gt = fast_gb(G1,V,0,Ord);                  Gt = fast_gb(G1,V,Mod,Ord);
                 T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3];                  T1 = time(); Tsep += T1[0]-T0[0]+T1[1]-T0[1]; Rsep += T1[3]-T0[3];
         }          }
         T0 = time();          T0 = time();
         if ( !NoSimp ) Q1 = qd_remove_redundant_comp(G,Qi,Q,V,Ord);          if ( !NoSimp ) Q1 = qd_remove_redundant_comp(G,Qi,Q,V,Ord|mod=Mod);
         else Q1 = Q;          else Q1 = Q;
         T1 = time(); Tirred += T1[0]-T0[0]+T1[1]-T0[1]; Rirred += T1[3]-T0[3];          T1 = time(); Tirred += T1[0]-T0[0]+T1[1]-T0[1]; Rirred += T1[3]-T0[3];
         Tall = T1[0]-T00[0]+T1[1]-T00[1]; Rall += T1[3]-T00[3];          Tall = T1[0]-T00[0]+T1[1]-T00[1]; Rall += T1[3]-T00[3];
Line 216  T00 = time();
Line 226  T00 = time();
         return [Qi,Q1];          return [Qi,Q1];
 }  }
   
   /* XXX */
 /* C=G:Q, Rad=rad(Q), return J s.t. Q cap (G+J) = G */  /* C=G:Q, Rad=rad(Q), return J s.t. Q cap (G+J) = G */
   
 def find_separating_ideal0(C,G,Q,Rad,V,Ord) {  def find_separating_ideal0(C,G,Q,Rad,V,Ord) {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         for ( CI = C, I = 1; ; I++ ) {          for ( CI = C, I = 1; ; I++ ) {
                 for ( T = CI, S = []; T != []; T = cdr(T) )                  for ( T = CI, S = []; T != []; T = cdr(T) )
                         if ( nd_nf(car(T),Q,V,Ord,0) ) S = cons(car(T),S);                          if ( gen_nf(car(T),Q,V,Ord,Mod) ) S = cons(car(T),S);
                 if ( S == [] )                  if ( S == [] )
                         error("find_separating_ideal0 : cannot happen");                          error("find_separating_ideal0 : cannot happen");
                 G1 = append(S,G);                  G1 = append(S,G);
                 Int = ideal_intersection(G1,Q,V,Ord);                  Int = ideal_intersection(G1,Q,V,Ord|mod=Mod);
                 /* check whether (Q cap (G+S)) = G */                  /* check whether (Q cap (G+S)) = G */
                 if ( gb_comp(Int,G) ) return reverse(S);                  if ( gen_gb_comp(Int,G,Mod) ) return reverse(S);
                 CI = ideal_product(CI,C,V);                  CI = ideal_product(CI,C,V|mod=Mod);
         }          }
 }  }
   
 def find_separating_ideal1(C,G,Q,Rad,V,Ord) {  def find_separating_ideal1(C,G,Q,Rad,V,Ord) {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         for ( T = C, S = []; T != []; T = cdr(T) )          for ( T = C, S = []; T != []; T = cdr(T) )
                 if ( nd_nf(car(T),Q,V,Ord,0) ) S = cons(car(T),S);                  if ( gen_nf(car(T),Q,V,Ord,Mod) ) S = cons(car(T),S);
         if ( S == [] )          if ( S == [] )
                 error("find_separating_ideal1 : cannot happen");                  error("find_separating_ideal1 : cannot happen");
         G1 = append(S,G);          G1 = append(S,G);
         Int = ideal_intersection(G1,Q,V,Ord);          Int = ideal_intersection(G1,Q,V,Ord|mod=Mod);
         /* check whether (Q cap (G+S)) = G */          /* check whether (Q cap (G+S)) = G */
         if ( gb_comp(Int,G) ) return reverse(S);          if ( gen_gb_comp(Int,G,Mod) ) return reverse(S);
   
         /* or qsort(C,comp_tdeg) */          /* or qsort(C,comp_tdeg) */
         C = qsort(S,comp_tdeg);          C = qsort(S,comp_tdeg);
   
         Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]];          Tmp = ttttt; TV = cons(Tmp,V); Ord1 = [[0,1],[Ord,length(V)]];
         Int0 = incremental_gb(append(vtol(ltov(G)*Tmp),vtol(ltov(Q)*(1-Tmp))),          Int0 = incremental_gb(append(vtol(ltov(G)*Tmp),vtol(ltov(Q)*(1-Tmp))),
                 TV,Ord1|gbblock=[[0,length(G)]]);                  TV,Ord1|gbblock=[[0,length(G)]],mod=Mod);
         for ( T = C, S = []; T != []; T = cdr(T) ) {          for ( T = C, S = []; T != []; T = cdr(T) ) {
                 if ( !nd_nf(car(T),Rad,V,Ord,0) ) continue;                  if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue;
                 Ui = U = car(T);                  Ui = U = car(T);
                 for ( I = 1; ; I++ ) {                  for ( I = 1; ; I++ ) {
                         G1 = cons(Ui,G);                          G1 = cons(Ui,G);
                         Int = ideal_intersection(G1,Q,V,Ord);                          Int = ideal_intersection(G1,Q,V,Ord|mod=Mod);
                         if ( gb_comp(Int,G) ) break;                          if ( gen_gb_comp(Int,G,Mod) ) break;
                         else                          else
                                 Ui = nd_nf(Ui*U,G,V,Ord,0);                                  Ui = gen_nf(Ui*U,G,V,Ord,Mod);
                 }                  }
                 Int1 = incremental_gb(append(Int0,[Tmp*Ui]),TV,Ord1                  Int1 = incremental_gb(append(Int0,[Tmp*Ui]),TV,Ord1
                         |gbblock=[[0,length(Int0)]]);                          |gbblock=[[0,length(Int0)]],mod=Mod);
                 Int = elimination(Int1,V);                  Int = elimination(Int1,V);
                 if ( !gb_comp(Int,G) )                  if ( !gen_gb_comp(Int,G,Mod) )
                         break;                          break;
                 else {                  else {
                         Int0 = Int1;                          Int0 = Int1;
Line 272  def find_separating_ideal1(C,G,Q,Rad,V,Ord) {
Line 285  def find_separating_ideal1(C,G,Q,Rad,V,Ord) {
 }  }
   
 def find_separating_ideal2(C,G,Q,Rad,V,Ord) {  def find_separating_ideal2(C,G,Q,Rad,V,Ord) {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         for ( T = C, S = []; T != []; T = cdr(T) )          for ( T = C, S = []; T != []; T = cdr(T) )
                 if ( nd_nf(car(T),Q,V,Ord,0) ) S = cons(car(T),S);                  if ( gen_nf(car(T),Q,V,Ord,Mod) ) S = cons(car(T),S);
         if ( S == [] )          if ( S == [] )
                 error("find_separating_ideal2 : cannot happen");                  error("find_separating_ideal2 : cannot happen");
         G1 = append(S,G);          G1 = append(S,G);
         Int = ideal_intersection(G1,Q,V,Ord);          Int = ideal_intersection(G1,Q,V,Ord|mod=Mod);
         /* check whether (Q cap (G+S)) = G */          /* check whether (Q cap (G+S)) = G */
         if ( gb_comp(Int,G) ) return reverse(S);          if ( gen_gb_comp(Int,G,Mod) ) return reverse(S);
   
         /* or qsort(S,comp_tdeg) */          /* or qsort(S,comp_tdeg) */
         C = qsort(C,comp_tdeg);          C = qsort(C,comp_tdeg);
         Dp = dp_gr_print(); dp_gr_print(0);          Dp = dp_gr_print(); dp_gr_print(0);
         for ( T = C, S = []; T != []; T = cdr(T) ) {          for ( T = C, S = []; T != []; T = cdr(T) ) {
                 print(length(T));                  if ( !gen_nf(car(T),Rad,V,Ord,Mod) ) continue;
                 if ( !nd_nf(car(T),Rad,V,Ord,0) ) continue;  
                 Ui = U = car(T);                  Ui = U = car(T);
                 for ( I = 1; ; I++ ) {                  for ( I = 1; ; I++ ) {
                         G1 = cons(Ui,G);                          G1 = append(G,[Ui]);
                         Int = ideal_intersection(G1,Q,V,Ord);                          Int = ideal_intersection(G1,Q,V,Ord|mod=Mod,
                         if ( gb_comp(Int,G) ) break;                                  gbblock=[[0,length(G)],[length(G1),length(Q)]]);
                           if ( gen_gb_comp(Int,G,Mod) ) break;
                         else                          else
                                 Ui = nd_nf(Ui*U,G,V,Ord,0);                                  Ui = gen_nf(Ui*U,G,V,Ord,Mod);
                 }                  }
                   print([length(T),I],2);
                 S = cons(Ui,S);                  S = cons(Ui,S);
         }          }
           print("");
         S = qsort(S,comp_tdeg);          S = qsort(S,comp_tdeg);
         /* S = reverse(S); */          /* S = reverse(S); */
         Len = length(S);          Len = length(S);
Line 307  def find_separating_ideal2(C,G,Q,Rad,V,Ord) {
Line 323  def find_separating_ideal2(C,G,Q,Rad,V,Ord) {
                 Cur = 2;                  Cur = 2;
                 G1 = append(G,[S[0]]);                  G1 = append(G,[S[0]]);
                 Int0 = incremental_gb(append(vtol(ltov(G1)*Tmp),vtol(ltov(Q)*(1-Tmp))),                  Int0 = incremental_gb(append(vtol(ltov(G1)*Tmp),vtol(ltov(Q)*(1-Tmp))),
                         TV,Ord1|gbblock=[[0,length(G)]]);                          TV,Ord1|gbblock=[[0,length(G)]],mod=Mod);
                 while ( Prev < Cur ) {                  while ( Prev < Cur ) {
                         for ( St = [], I = Prev; I < Cur; I++ ) St = cons(Tmp*S[I],St);                          for ( St = [], I = Prev; I < Cur; I++ ) St = cons(Tmp*S[I],St);
                         Int1 = incremental_gb(append(Int0,St),TV,Ord1                          Int1 = incremental_gb(append(Int0,St),TV,Ord1
                                 |gbblock=[[0,length(Int0)]]);                                  |gbblock=[[0,length(Int0)]],mod=Mod);
                         Int = elimination(Int1,V);                          Int = elimination(Int1,V);
                         if ( gb_comp(Int,G) ) {                          if ( gen_gb_comp(Int,G,Mod) ) {
                                 print(Cur);                                  print(Cur);
                                 Prev = Cur;                                  Prev = Cur;
                                 Cur = Cur+idiv(Len-Cur+1,2);                                  Cur = Cur+idiv(Len-Cur+1,2);
Line 335  def find_separating_ideal2(C,G,Q,Rad,V,Ord) {
Line 351  def find_separating_ideal2(C,G,Q,Rad,V,Ord) {
   
 def sy_dec(B,V)  def sy_dec(B,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Nolexdec=getopt(nolexdec)) == -1 ) Nolexdec = 0;          if ( type(Nolexdec=getopt(nolexdec)) == -1 ) Nolexdec = 0;
         Ord = 0;          Ord = 0;
         G = fast_gb(B,V,0,Ord);          G = fast_gb(B,V,Mod,Ord);
         Q = [];          Q = [];
         IntQ = [1];          IntQ = [1];
         Gt = G;          Gt = G;
         First = 1;          First = 1;
         while ( 1 ) {          while ( 1 ) {
                 if ( type(Gt[0]) == 1 ) break;                  if ( type(Gt[0]) == 1 ) break;
                 Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec);                  Pt = prime_dec(Gt,V|indep=1,nolexdec=Nolexdec,mod=Mod);
                 L = pseudo_dec(Gt,Pt,V,Ord);                  L = pseudo_dec(Gt,Pt,V,Ord|mod=Mod);
                 Qt = L[0]; Rt = L[1]; St = L[2];                  Qt = L[0]; Rt = L[1]; St = L[2];
                 IntQt = ideal_list_intersection(Qt,V,Ord);                  IntQt = ideal_list_intersection(map(first_element,Qt),V,Ord|mod=Mod);
                 if ( First ) {                  if ( First ) {
                         IntQ = IntQt;                          IntQ = IntQt;
                         Qi = Qt;                          Qi = Qt;
                         First = 0;                          First = 0;
                 } else {                  } else {
                         IntQ = ideal_intersection(IntQ,IntQt,V,Ord);                          IntQ = ideal_intersection(IntQ,IntQt,V,Ord|mod=Mod);
                         Q = append(Qt,Q);                          Q = append(Qt,Q);
                 }                  }
                 if ( gb_comp(IntQ,G) ) break;                  if ( gen_gb_comp(IntQ,G,Mod) ) break;
                 for ( T = Rt; T != []; T = cdr(T) ) {                  for ( T = Rt; T != []; T = cdr(T) ) {
                         if ( type(car(T)[0]) == 1 ) continue;                          if ( type(car(T)[0]) == 1 ) continue;
                         U = sy_dec(car(T),V|nolexdec=Nolexdec);                          U = sy_dec(car(T),V|nolexdec=Nolexdec,mod=Mod);
                         IntQ = ideal_list_intersection(cons(IntQ,U),V,Ord);                          IntQ = ideal_list_intersection(cons(IntQ,map(first_element,U)),
                                   V,Ord|mod=Mod);
                         Q = append(U,Q);                          Q = append(U,Q);
                         if ( gb_comp(IntQ,G) ) break;                          if ( gen_gb_comp(IntQ,G,Mod) ) break;
                 }                  }
                 Gt = fast_gb(append(Gt,St),V,0,Ord);                  Gt = fast_gb(append(Gt,St),V,Mod,Ord);
         }          }
         Q = qd_remove_redundant_comp(G,Qi,Q,V,Ord);          Q = qd_remove_redundant_comp(G,Qi,Q,V,Ord|mod=Mod);
         return append(Qi,Q);          return append(Qi,Q);
 }  }
   
 def pseudo_dec(G,L,V,Ord)  def pseudo_dec(G,L,V,Ord)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         N = length(L);          N = length(L);
         S = vector(N);          S = vector(N);
         Q = vector(N);          Q = vector(N);
Line 379  def pseudo_dec(G,L,V,Ord)
Line 398  def pseudo_dec(G,L,V,Ord)
         L0 = map(first_element,L);          L0 = map(first_element,L);
         for ( I = 0; I < N; I++ ) {          for ( I = 0; I < N; I++ ) {
                 LI = setminus(L0,[L0[I]]);                  LI = setminus(L0,[L0[I]]);
                 PI = ideal_list_intersection(LI,V,Ord);                  PI = ideal_list_intersection(LI,V,Ord|mod=Mod);
                 PI = qsort(PI,comp_tdeg);                  PI = qsort(PI,comp_tdeg);
                 for ( T = PI; T != []; T = cdr(T) )                  for ( T = PI; T != []; T = cdr(T) )
                         if ( p_nf(car(T),L0[I],V,Ord) ) break;                          if ( gen_nf(car(T),L0[I],V,Ord,Mod) ) break;
                 if ( T == [] ) error("separator : cannot happen");                  if ( T == [] ) error("separator : cannot happen");
                 SI = sat_ind(G,car(T),V);                  SI = satind(G,car(T),V|mod=Mod);
                 QI = SI[0];                  QI = SI[0];
                 S[I] = car(T)^SI[1];                  S[I] = car(T)^SI[1];
                 PV = L[I][1];                  PV = L[I][1];
                 V0 = setminus(V,PV);                  V0 = setminus(V,PV);
 #if 0  #if 0
                 GI = fast_gb(QI,append(V0,PV),0,                  GI = fast_gb(QI,append(V0,PV),Mod,
                         [[Ord,length(V0)],[Ord,length(PV)]]);                          [[Ord,length(V0)],[Ord,length(PV)]]);
 #else  #else
                 GI = fast_gb(QI,append(V0,PV),0,                  GI = fast_gb(QI,append(V0,PV),Mod,
                         [[2,length(V0)],[Ord,length(PV)]]);                          [[2,length(V0)],[Ord,length(PV)]]);
 #endif  #endif
                 LCFI = lcfactor(GI,V0,Ord);                  LCFI = lcfactor(GI,V0,Ord,Mod);
                 for ( F = 1, T = LCFI, Gt = QI; T != []; T = cdr(T) ) {                  for ( F = 1, T = LCFI, Gt = QI; T != []; T = cdr(T) ) {
                         St = sat_ind(Gt,T[0],V);                          St = satind(Gt,T[0],V|mod=Mod);
                         Gt = St[0]; F *= T[0]^St[1];                          Gt = St[0]; F *= T[0]^St[1];
                 }                  }
                 Q[I] = Gt;                  Q[I] = [Gt,L0[I]];
                 R[I] = fast_gb(cons(F,QI),V,0,Ord);                  R[I] = fast_gb(cons(F,QI),V,Mod,Ord);
         }          }
         return [vtol(Q),vtol(R),vtol(S)];          return [vtol(Q),vtol(R),vtol(S)];
 }  }
   
 def iso_comp(G,L,V,Ord)  def iso_comp(G,L,V,Ord)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0;
         N = length(L);          N = length(L);
         S = vector(N);          S = vector(N);
         Ind = vector(N);          Ind = vector(N);
         Q = vector(N);          Q = vector(N);
         L0 = map(first_element,L);          L0 = map(first_element,L);
         G = nd_gr(G,V,0,Ord);          if ( !IsGB ) G = nd_gr(G,V,Mod,Ord);
         for ( I = 0; I < N; I++ ) {          for ( I = 0; I < N; I++ ) {
                 LI = setminus(L0,[L0[I]]);                  LI = setminus(L0,[L0[I]]);
                 PI = ideal_list_intersection(LI,V,Ord);                  PI = ideal_list_intersection(LI,V,Ord|mod=Mod);
                 for ( T = PI; T != []; T = cdr(T) )                  for ( T = PI; T != []; T = cdr(T) )
                         if ( p_nf(car(T),L0[I],V,Ord) ) break;                          if ( gen_nf(car(T),L0[I],V,Ord,Mod) ) break;
                 if ( T == [] ) error("separator : cannot happen");                  if ( T == [] ) error("separator : cannot happen");
                 S[I] = car(T);                  S[I] = car(T);
                 QI = sat(G,S[I],V|isgb=1);                  QI = sat(G,S[I],V|isgb=1,mod=Mod);
                 PV = L[I][1];                  PV = L[I][1];
                 V0 = setminus(V,PV);                  V0 = setminus(V,PV);
                 GI = elim_gb(QI,V0,PV,0,[[0,length(V0)],[0,length(PV)]]);                  GI = elim_gb(QI,V0,PV,Mod,[[0,length(V0)],[0,length(PV)]]);
                 Q[I] = [contraction(GI,V0),L0[I]];                  Q[I] = [contraction(GI,V0|mod=Mod),L0[I]];
         }          }
         return vtol(Q);          return vtol(Q);
 }  }
Line 435  def iso_comp(G,L,V,Ord)
Line 456  def iso_comp(G,L,V,Ord)
   
 def prima_dec(B,V)  def prima_dec(B,V)
 {  {
         G = nd_gr_trace(B,V,1,GBCheck,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         G0 = G;          if ( type(Ord=getopt(ord)) == -1 ) Ord = 0;
           G0 = fast_gb(B,V,Mod,0);
           G = fast_gb(G0,V,Mod,Ord);
         IntP = [1];          IntP = [1];
         QD = [];          QD = [];
         while ( 1 ) {          while ( 1 ) {
                 if ( ideal_inclusion(IntP,G0,V,0) )                  if ( type(G[0])==1 || ideal_inclusion(IntP,G0,V,0|mod=Mod) )
                         return QD;                          break;
                 W = maxindep(G,V,0); NP = length(W);                  W = maxindep(G,V,Ord); NP = length(W);
                 V0 = setminus(V,W); N = length(V0);                  V0 = setminus(V,W); N = length(V0);
                 V1 = append(V0,W);                  V1 = append(V0,W);
                 G1 = fast_gb(G,V1,0,[[0,N],[0,NP]]);                  G1 = fast_gb(G,V1,Mod,[[Ord,N],[Ord,NP]]);
                 LCF = lcfactor(G1,V0,0);                  LCF = lcfactor(G1,V0,Ord,Mod);
                 L = zprimacomp(G,V0);                  L = zprimacomp(G,V0|mod=Mod);
                 F = 1;                  F = 1;
                 for ( T = LCF, G2 = G1; T != []; T = cdr(T) ) {                  for ( T = LCF, G2 = G; T != []; T = cdr(T) ) {
                         S = sat_ind(G2,T[0],V1);                          S = satind(G2,T[0],V1|mod=Mod);
                         G2 = S[0]; F *= T[0]^S[1];                          G2 = S[0]; F *= T[0]^S[1];
                 }                  }
                 for ( T = L, QL = []; T != []; T = cdr(T) )                  for ( T = L, QL = []; T != []; T = cdr(T) )
                         QL = cons(car(T)[0],QL);                          QL = cons(car(T)[0],QL);
                 Int = ideal_list_intersection(QL,V,0);                  Int = ideal_list_intersection(QL,V,0|mod=Mod);
                 IntP = ideal_intersection(IntP,Int,V,0);                  IntP = ideal_intersection(IntP,Int,V,0|mod=Mod);
                 QD = append(QD,L);                  QD = append(QD,L);
                 F = p_nf(F,G,V,0);                  F = gen_nf(F,G,V,0,Mod);
                 G = cons(F,G);                  G = fast_gb(cons(F,G),V,Mod,Ord);
         }          }
           QD = qd_remove_redundant_comp(G0,[],QD,V,0);
           return QD;
 }  }
   
 /* SL prime decomposition */  /* SL prime decomposition */
   
 def prime_dec(B,V)  def prime_dec(B,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Indep=getopt(indep)) == -1 ) Indep = 0;          if ( type(Indep=getopt(indep)) == -1 ) Indep = 0;
         if ( type(NoLexDec=getopt(nolexdec)) == -1 ) NoLexDec = 0;          if ( type(NoLexDec=getopt(nolexdec)) == -1 ) NoLexDec = 0;
         B = map(sq,B);          B = map(sq,B,Mod);
         if ( !NoLexDec )          if ( !NoLexDec )
                 PD = lex_predec1(B,V);                  PD = lex_predec1(B,V|mod=Mod);
         else          else
                 PD = [B];                  PD = [B];
         G = ideal_list_intersection(PD,V,0);          G = ideal_list_intersection(PD,V,0|mod=Mod);
         PD = pd_remove_redundant_comp(G,PD,V,0);          PD = pd_remove_redundant_comp(G,PD,V,0|mod=Mod);
         R = [];          R = [];
         for ( T = PD; T != []; T = cdr(T) )          for ( T = PD; T != []; T = cdr(T) )
                 R = append(prime_dec_main(car(T),V|indep=Indep),R);                  R = append(prime_dec_main(car(T),V|indep=Indep,mod=Mod),R);
         if ( Indep ) {          if ( Indep ) {
                 G = ideal_list_intersection(map(first_element,R),V,0);                  G = ideal_list_intersection(map(first_element,R),V,0|mod=Mod);
                 if ( !NoLexDec ) R = pd_remove_redundant_comp(G,R,V,0|first=1);                  if ( !NoLexDec ) R = pd_remove_redundant_comp(G,R,V,0|first=1,mod=Mod);
         } else {          } else {
                 G = ideal_list_intersection(R,V,0);                  G = ideal_list_intersection(R,V,0|mod=Mod);
                 if ( !NoLexDec ) R = pd_remove_redundant_comp(G,R,V,0);                  if ( !NoLexDec ) R = pd_remove_redundant_comp(G,R,V,0|mod=Mod);
         }          }
         return R;          return R;
 }  }
   
 def prime_dec_main(B,V)  def prime_dec_main(B,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Indep=getopt(indep)) == -1 ) Indep = 0;          if ( type(Indep=getopt(indep)) == -1 ) Indep = 0;
         G = nd_gr_trace(B,V,1,GBCheck,0);          G = fast_gb(B,V,Mod,0);
         IntP = [1];          IntP = [1];
         PD = [];          PD = [];
         while ( 1 ) {          while ( 1 ) {
                 /* rad(G) subset IntP */                  /* rad(G) subset IntP */
                 /* check if IntP subset rad(G) */                  /* check if IntP subset rad(G) */
                 for ( T = IntP; T != []; T = cdr(T) ) {                  for ( T = IntP; T != []; T = cdr(T) ) {
                         if ( (GNV = modular_radical_membership(car(T),G,V)) ) {                          if ( (GNV = modular_radical_membership(car(T),G,V|mod=Mod)) ) {
                                 F = car(T);                                  F = car(T);
                                 break;                                  break;
                         }                          }
Line 507  def prime_dec_main(B,V)
Line 534  def prime_dec_main(B,V)
                 if ( T == [] ) return PD;                  if ( T == [] ) return PD;
   
                 /* GNV = [GB(<NV*F-1,G>),NV] */                  /* GNV = [GB(<NV*F-1,G>),NV] */
                 G1 = nd_gr_trace(GNV[0],cons(GNV[1],V),1,GBCheck,[[0,1],[0,length(V)]]);                  G1 = fast_gb(GNV[0],cons(GNV[1],V),Mod,[[0,1],[0,length(V)]]);
                 G0 = elimination(G1,V);                  G0 = elimination(G1,V);
                 PD0 = zprimecomp(G0,V,Indep);                  PD0 = zprimecomp(G0,V,Indep|mod=Mod);
                 if ( Indep ) {                  if ( Indep ) {
                         Int = ideal_list_intersection(PD0[0],V,0);                          Int = ideal_list_intersection(PD0[0],V,0|mod=Mod);
                         IndepSet = PD0[1];                          IndepSet = PD0[1];
                         for ( PD1 = [], T = PD0[0]; T != []; T = cdr(T) )                          for ( PD1 = [], T = PD0[0]; T != []; T = cdr(T) )
                                 PD1 = cons([car(T),IndepSet],PD1);                                  PD1 = cons([car(T),IndepSet],PD1);
                         PD = append(PD,reverse(PD1));                          PD = append(PD,reverse(PD1));
                 } else {                  } else {
                         Int = ideal_list_intersection(PD0,V,0);                          Int = ideal_list_intersection(PD0,V,0|mod=Mod);
                         PD = append(PD,PD0);                          PD = append(PD,PD0);
                 }                  }
                 IntP = ideal_intersection(IntP,Int,V,0);                  IntP = ideal_intersection(IntP,Int,V,0|mod=Mod);
         }          }
 }  }
   
Line 528  def prime_dec_main(B,V)
Line 555  def prime_dec_main(B,V)
   
 def lex_predec1(B,V)  def lex_predec1(B,V)
 {  {
         G = nd_gr_trace(B,V,1,GBCheck,2);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           G = fast_gb(B,V,Mod,2);
         for ( T = G; T != []; T = cdr(T) ) {          for ( T = G; T != []; T = cdr(T) ) {
                 F = fctr(car(T));                  F = gen_fctr(car(T),Mod);
                 if ( length(F) > 2 || length(F) == 2 && F[1][1] > 1 ) {                  if ( length(F) > 2 || length(F) == 2 && F[1][1] > 1 ) {
                         for ( R = [], S = cdr(F); S != []; S = cdr(S) ) {                          for ( R = [], S = cdr(F); S != []; S = cdr(S) ) {
                                 Ft = car(S)[0];                                  Ft = car(S)[0];
                                 Gt = map(ptozp,map(p_nf,G,[Ft],V,0));                                  Gt = map(ptozp,map(gen_nf,G,[Ft],V,0,Mod));
                                 R1 = nd_gr_trace(cons(Ft,Gt),V,1,GBCheck,0);                                  R1 = fast_gb(cons(Ft,Gt),V,Mod,0);
                                 R = cons(R1,R);                                  R = cons(R1,R);
                         }                          }
                         return R;                          return R;
Line 749  def partial_decomp0(GD,V,PV,Ord,I,Mod)
Line 777  def partial_decomp0(GD,V,PV,Ord,I,Mod)
                 Mt = car(car(T));                  Mt = car(car(T));
                 D1 = D*1;                  D1 = D*1;
                 D1[I] = Mt;                  D1[I] = Mt;
                 GIt = map(p_nf,GI,[Mt],V,Ord);                  GIt = map(gen_nf,GI,[Mt],V,Ord,Mod);
                 G1 = cons(Mt,GIt);                  G1 = cons(Mt,GIt);
                 Gelim = elim_gb(G1,V,PV,Mod,Ord);                  Gelim = elim_gb(G1,V,PV,Mod,Ord);
                 D1[N] = LD = ldim(Gelim,V);                  D1[N] = LD = ldim(Gelim,V);
Line 766  def partial_decomp0(GD,V,PV,Ord,I,Mod)
Line 794  def partial_decomp0(GD,V,PV,Ord,I,Mod)
 /* prime/primary components over rational function field */  /* prime/primary components over rational function field */
   
 def zprimacomp(G,V) {  def zprimacomp(G,V) {
         L = zprimadec(G,V,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           L = zprimadec(G,V,0|mod=Mod);
         R = [];          R = [];
         dp_ord(0);          dp_ord(0);
         for ( T = L; T != []; T = cdr(T) ) {          for ( T = L; T != []; T = cdr(T) ) {
                 S = car(T);                  S = car(T);
                 UQ = contraction(S[0],V);                  UQ = contraction(S[0],V|mod=Mod);
                 UP = contraction(S[1],V);                  UP = contraction(S[1],V|mod=Mod);
                 R = cons([UQ,UP],R);                  R = cons([UQ,UP],R);
         }          }
         return R;          return R;
 }  }
   
 def zprimecomp(G,V,Indep) {  def zprimecomp(G,V,Indep) {
         W = maxindep(G,V,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           W = maxindep(G,V,0|mod=Mod);
         V0 = setminus(V,W);          V0 = setminus(V,W);
         V1 = append(V0,W);          V1 = append(V0,W);
 #if 0  #if 0
         O1 = [[0,length(V0)],[0,length(W)]];          O1 = [[0,length(V0)],[0,length(W)]];
         G1 = nd_gr_trace(G,V1,1,GBCheck,O1);          G1 = fast_gb(G,V1,Mod,O1);
         dp_ord(0);          dp_ord(0);
 #else  #else
         G1 = G;          G1 = G;
 #endif  #endif
         PD = zprimedec(G1,V0,0);          PD = zprimedec(G1,V0,Mod);
         dp_ord(0);          dp_ord(0);
         R = [];          R = [];
         for ( T = PD; T != []; T = cdr(T) ) {          for ( T = PD; T != []; T = cdr(T) ) {
                 U = contraction(car(T),V0);                  U = contraction(car(T),V0|mod=Mod);
                 R = cons(U,R);                  R = cons(U,R);
         }          }
         if ( Indep ) return [R,W];          if ( Indep ) return [R,W];
Line 802  def zprimecomp(G,V,Indep) {
Line 832  def zprimecomp(G,V,Indep) {
   
 def fast_gb(B,V,Mod,Ord)  def fast_gb(B,V,Mod,Ord)
 {  {
         NoRA = (NoRA=getopt(nora))&&type(NoRA)!=-1 ? 1 : 0;          if ( type(Block=getopt(gbblock)) == -1 ) Block = 0;
           if ( type(NoRA=getopt(nora)) == -1 ) NoRA = 0;
         if ( Mod )          if ( Mod )
                 G = nd_f4(B,V,Mod,Ord|nora=NoRA);                  G = nd_f4(B,V,Mod,Ord|nora=NoRA);
         else {          else if ( F4 )
                 if ( F4 )                  G = map(ptozp,f4_chrem(B,V,Ord));
                         G = map(ptozp,f4_chrem(B,V,Ord));          else if ( Block )
                 else                  G = nd_gr_trace(B,V,1,GBCheck,Ord|nora=NoRA,gbblock=Block);
                         G = nd_gr_trace(B,V,1,GBCheck,Ord|nora=NoRA);          else
         }                  G = nd_gr_trace(B,V,1,GBCheck,Ord|nora=NoRA);
         return G;          return G;
 }  }
   
Line 818  def incremental_gb(A,V,Ord)
Line 849  def incremental_gb(A,V,Ord)
 {  {
         if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Block=getopt(gbblock)) == -1 ) Block = 0;          if ( type(Block=getopt(gbblock)) == -1 ) Block = 0;
         if ( Mod )          if ( Mod ) {
                 G = nd_gr(A,V,Mod,Ord);                  if ( Block )
         else if ( Procs ) {                          G = nd_gr(A,V,Mod,Ord|gbblock=Block);
                   else
                           G = nd_gr(A,V,Mod,Ord);
           } else if ( Procs ) {
                 Arg0 = ["nd_gr",A,V,0,Ord];                  Arg0 = ["nd_gr",A,V,0,Ord];
                 Arg1 = ["nd_gr_trace",A,V,1,GBCheck,Ord];                  Arg1 = ["nd_gr_trace",A,V,1,GBCheck,Ord];
                 G = competitive_exec(Procs,Arg0,Arg1);                  G = competitive_exec(Procs,Arg0,Arg1);
Line 837  def elim_gb(G,V,PV,Mod,Ord)
Line 871  def elim_gb(G,V,PV,Mod,Ord)
         O1 = [[0,N],[0,PN]];          O1 = [[0,N],[0,PN]];
         if ( Ord == O1 )          if ( Ord == O1 )
                 Ord = Ord[0][0];                  Ord = Ord[0][0];
         if ( Mod ) /* XXX */          if ( Mod ) /* XXX */ {
                   for ( T = G, H = []; T != []; T = cdr(T) )
                           if ( car(T) ) H = cons(car(T),H);
                   G = reverse(H);
                 G = dp_gr_mod_main(G,V,0,Mod,Ord);                  G = dp_gr_mod_main(G,V,0,Mod,Ord);
         else if ( Procs ) {          } else if ( Procs ) {
                 Arg0 = ["nd_gr_trace",G,V,1,GBCheck,Ord];                  Arg0 = ["nd_gr_trace",G,V,1,GBCheck,Ord];
                 Arg1 = ["nd_gr_trace_rat",G,V,PV,1,GBCheck,O1,Ord];                  Arg1 = ["nd_gr_trace_rat",G,V,PV,1,GBCheck,O1,Ord];
                 G = competitive_exec(Procs,Arg0,Arg1);                  G = competitive_exec(Procs,Arg0,Arg1);
Line 856  def ldim(G,V)
Line 893  def ldim(G,V)
         return D;          return D;
 }  }
   
   /* over Q only */
   
 def make_mod_subst(GD,V,PV,HC)  def make_mod_subst(GD,V,PV,HC)
 {  {
         N = length(V);          N = length(V);
Line 937  def gen_minipoly(G,V,PV,Ord,VI,Mod)
Line 976  def gen_minipoly(G,V,PV,Ord,VI,Mod)
         }          }
 #elif 1  #elif 1
         if ( Mod ) {          if ( Mod ) {
                 G = nd_gr(G,V1,Mod,[[0,length(W)],[0,length(PV1)]]|nora=1);                  V1 = append(W,PV1);
                   G = nd_gr(G,V1,Mod,[[0,length(W)],[0,length(PV1)]]);
                 G = elimination(G,PV1);                  G = elimination(G,PV1);
         } else {          } else {
                 PV2 = setminus(PV1,[PV1[length(PV1)-1]]);                  PV2 = setminus(PV1,[PV1[length(PV1)-1]]);
Line 981  def indepset(V,H)
Line 1021  def indepset(V,H)
   
 def maxindep(B,V,O)  def maxindep(B,V,O)
 {  {
         G = nd_gr_trace(B,V,1,GBCheck,O);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           G = fast_gb(B,V,Mod,O);
         Old = dp_ord();          Old = dp_ord();
         dp_ord(O);          dp_ord(O);
         H = map(dp_dtop,map(dp_ht,map(dp_ptod,G,V)),V);          H = map(dp_dtop,map(dp_ht,map(dp_ptod,G,V)),V);
Line 1004  def maxindep(B,V,O)
Line 1045  def maxindep(B,V,O)
 /* ideal operations */  /* ideal operations */
 def contraction(G,V)  def contraction(G,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         C = [];          C = [];
         for ( T = G; T != []; T = cdr(T) ) {          for ( T = G; T != []; T = cdr(T) ) {
                 C1 = dp_hc(dp_ptod(car(T),V));                  C1 = dp_hc(dp_ptod(car(T),V));
                 S = fctr(C1);                  S = gen_fctr(C1,Mod);
                 for ( S = cdr(S); S != []; S = cdr(S) )                  for ( S = cdr(S); S != []; S = cdr(S) )
                         if ( !member(S[0][0],C) ) C = cons(S[0][0],C);                          if ( !member(S[0][0],C) ) C = cons(S[0][0],C);
         }          }
Line 1017  def contraction(G,V)
Line 1059  def contraction(G,V)
         NV = ttttt;          NV = ttttt;
         for ( T = C, S = 1; T != []; T = cdr(T) )          for ( T = C, S = 1; T != []; T = cdr(T) )
                 S *= car(T);                  S *= car(T);
         G = saturation([G,NV],S,W);          G = saturation([G,NV],S,W|mod=Mod);
         return G;          return G;
 }  }
   
Line 1041  def ideal_intersection(A,B,V,Ord)
Line 1083  def ideal_intersection(A,B,V,Ord)
         if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(Block=getopt(gbblock)) == -1 ) Block = 0;          if ( type(Block=getopt(gbblock)) == -1 ) Block = 0;
         T = ttttt;          T = ttttt;
         if ( Mod )          if ( Mod ) {
                 G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),                  if ( Block )
                         cons(T,V),Mod,[[0,1],[Ord,length(V)]]);                          G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),
         else                                  cons(T,V),Mod,[[0,1],[Ord,length(V)]]|gbblock=Block,nora=1);
                   else
                           G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),
                                   cons(T,V),Mod,[[0,1],[Ord,length(V)]]|nora=1);
           } else
         if ( Procs ) {          if ( Procs ) {
                 Arg0 = ["nd_gr",                  Arg0 = ["nd_gr",
                         append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),                          append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),
Line 1056  def ideal_intersection(A,B,V,Ord)
Line 1102  def ideal_intersection(A,B,V,Ord)
         } else {          } else {
                 if ( Block )                  if ( Block )
                         G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),                          G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),
                                 cons(T,V),0,[[0,1],[Ord,length(V)]]|gbblock=Block);                                  cons(T,V),0,[[0,1],[Ord,length(V)]]|gbblock=Block,nora=0);
                 else                  else
                         G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),                          G = nd_gr(append(vtol(ltov(A)*T),vtol(ltov(B)*(1-T))),
                                 cons(T,V),0,[[0,1],[Ord,length(V)]]);                                  cons(T,V),0,[[0,1],[Ord,length(V)]]|nora=0);
         }          }
         G0 = elimination(G,V);          G0 = elimination(G,V);
           if ( 0 && !Procs )
                   G0 = nd_gr_postproc(G0,V,Mod,Ord,0);
         return G0;          return G0;
 }  }
   
 /* returns GB if F notin rad(G) */  /* returns GB if F notin rad(G) */
   
 def radical_membership(F,G,V) {  def radical_membership(F,G,V) {
         F = p_nf(F,G,V,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           F = gen_nf(F,G,V,0,Mod);
         if ( !F ) return 0;          if ( !F ) return 0;
         NV = ttttt;          NV = ttttt;
         T = nd_gr_trace(cons(NV*F-1,G),cons(NV,V),1,GBCheck,0);          T = fast_gb(cons(NV*F-1,G),cons(NV,V),Mod,0);
         if ( type(car(T)) != 1 ) return [T,NV];          if ( type(car(T)) != 1 ) return [T,NV];
         else return 0;          else return 0;
 }  }
   
 def quick_radical_membership(F,G,V) {  
         F = p_nf(F,G,V,0);  
         if ( !F ) return 1;  
         NV = ttttt;  
         T = nd_f4(cons(NV*F-1,G),cons(NV,V),lprime(0),0);  
         if ( type(car(T)) != 1 ) return 0;  
         else return 1;  
 }  
   
 def modular_radical_membership(F,G,V) {  def modular_radical_membership(F,G,V) {
         F = p_nf(F,G,V,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           if ( Mod )
                   return radical_membership(F,G,V|mod=Mod);
   
           F = gen_nf(F,G,V,0,0);
         if ( !F ) return 0;          if ( !F ) return 0;
         NV = ttttt;          NV = ttttt;
         for ( J = 0; ; J++ ) {          for ( J = 0; ; J++ ) {
Line 1109  def radical_membership_rep(F,G,V,Max,Ord,Mod) {
Line 1153  def radical_membership_rep(F,G,V,Max,Ord,Mod) {
         Ft = F;          Ft = F;
         I = 1;          I = 1;
         while ( Max < 0 || I <= Max ) {          while ( Max < 0 || I <= Max ) {
                 Ft = nd_nf(Ft,G,V,Ord,Mod);                  Ft = gen_nf(Ft,G,V,Ord,Mod);
                 if ( !Ft ) return I;                  if ( !Ft ) return I;
                 Ft *= F;                  Ft *= F;
                 I++;                  I++;
Line 1119  def radical_membership_rep(F,G,V,Max,Ord,Mod) {
Line 1163  def radical_membership_rep(F,G,V,Max,Ord,Mod) {
   
 def ideal_product(A,B,V)  def ideal_product(A,B,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         dp_ord(0);          dp_ord(0);
         DA = map(dp_ptod,A,V);          DA = map(dp_ptod,A,V);
         DB = map(dp_ptod,B,V);          DB = map(dp_ptod,B,V);
Line 1139  def ideal_product(A,B,V)
Line 1184  def ideal_product(A,B,V)
         Len = length(A)>length(B)?length(A):length(B);          Len = length(A)>length(B)?length(A):length(B);
         Len *= 2;          Len *= 2;
         L = sep_list(T,Len); B0 = L[0]; B1 = L[1];          L = sep_list(T,Len); B0 = L[0]; B1 = L[1];
         R = nd_gr_trace(B0,V,0,-1,0);          R = fast_gb(B0,V,Mod,0);
         while ( B1 != [] ) {          while ( B1 != [] ) {
                 print(length(B1));                  print(length(B1));
                 L = sep_list(B1,Len);                  L = sep_list(B1,Len);
                 B0 = L[0]; B1 = L[1];                  B0 = L[0]; B1 = L[1];
                 R = nd_gr_trace(append(R,B0),V,0,-1,0|gbblock=[[0,length(R)]],nora=1);                  R = fast_gb(append(R,B0),V,Mod,0|gbblock=[[0,length(R)]],nora=1);
         }          }
         return R;          return R;
 }  }
   
 def saturation(GNV,F,V)  def saturation(GNV,F,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         G = GNV[0]; NV = GNV[1];          G = GNV[0]; NV = GNV[1];
         if ( Procs ) {          if ( Mod )
                   G1 = nd_gr(cons(NV*F-1,G),cons(NV,V),Mod,[[0,1],[0,length(V)]]);
           else if ( Procs ) {
                 Arg0 = ["nd_gr_trace",                  Arg0 = ["nd_gr_trace",
                 cons(NV*F-1,G),cons(NV,V),0,GBCheck,[[0,1],[0,length(V)]]];                  cons(NV*F-1,G),cons(NV,V),0,GBCheck,[[0,1],[0,length(V)]]];
                 Arg1 = ["nd_gr_trace",                  Arg1 = ["nd_gr_trace",
Line 1165  def saturation(GNV,F,V) 
Line 1213  def saturation(GNV,F,V) 
   
 def sat(G,F,V)  def sat(G,F,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0;          if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0;
         NV = ttttt;          NV = ttttt;
         if ( Procs ) {          if ( Mod )
                   G1 = nd_gr(cons(NV*F-1,G),cons(NV,V),Mod,[[0,1],[0,length(V)]]);
           else if ( Procs ) {
                 Arg0 = ["nd_gr_trace",                  Arg0 = ["nd_gr_trace",
                 cons(NV*F-1,G),cons(NV,V),0,GBCheck,[[0,1],[0,length(V)]]];                  cons(NV*F-1,G),cons(NV,V),0,GBCheck,[[0,1],[0,length(V)]]];
                 Arg1 = ["nd_gr_trace",                  Arg1 = ["nd_gr_trace",
Line 1188  def sat(G,F,V) 
Line 1239  def sat(G,F,V) 
   
 def satind(G,F,V)  def satind(G,F,V)
 {  {
           if ( type(Block=getopt(gbblock)) == -1 ) Block = 0;
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         NV = ttttt;          NV = ttttt;
         N = length(V);          N = length(V);
         B = append(G,[NV*F-1]);          B = append(G,[NV*F-1]);
         V1 = cons(NV,V);          V1 = cons(NV,V);
         D = nd_gr_trace(B,V1,1,GBCheck,[[0,1],[0,N]]          Ord1 = [[0,1],[0,N]];
                 |nora=1,gentrace=1,gbblock=[[0,length(G)]]);          if ( Mod )
                   if ( Block )
                           D = nd_gr(B,V1,Mod,Ord1|nora=1,gentrace=1,gbblock=Block);
                   else
                           D = nd_gr(B,V1,Mod,Ord1|nora=1,gentrace=1);
           else
                   if ( Block )
                           D = nd_gr_trace(B,V1,SatHomo,GBCheck,Ord1
                                   |nora=1,gentrace=1,gbblock=Block);
                   else
                           D = nd_gr_trace(B,V1,SatHomo,GBCheck,Ord1
                                   |nora=1,gentrace=1);
         G1 = D[0];          G1 = D[0];
         Len = length(G1);          Len = length(G1);
         Deg = compute_deg(B,V1,NV,D);          Deg = compute_deg(B,V1,NV,D);
Line 1212  def satind(G,F,V)
Line 1276  def satind(G,F,V)
   
 def sat_ind(G,F,V)  def sat_ind(G,F,V)
 {  {
           if ( type(Ord=getopt(ord)) == -1 ) Ord = 0;
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         NV = ttttt;          NV = ttttt;
         F = p_nf(F,G,V,0);          F = gen_nf(F,G,V,Ord,Mod);
         for ( I = 0, GI = G; ; I++ ) {          for ( I = 0, GI = G; ; I++ ) {
                 G1 = colon(GI,F,V);                  G1 = colon(GI,F,V|mod=Mod,ord=Ord);
                 if ( ideal_inclusion(G1,GI,V,0) )  {                  if ( ideal_inclusion(G1,GI,V,Ord|mod=Mod) )  {
                         return [GI,I];                          return [GI,I];
                 }                  }
                 else GI = G1;                  else GI = G1;
Line 1225  def sat_ind(G,F,V)
Line 1291  def sat_ind(G,F,V)
   
 def colon(G,F,V)  def colon(G,F,V)
 {  {
           if ( type(Ord=getopt(ord)) == -1 ) Ord = 0;
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0;          if ( type(IsGB=getopt(isgb)) == -1 ) IsGB = 0;
         F = p_nf(F,G,V,0);          F = gen_nf(F,G,V,Ord,Mod);
         if ( !F ) return [1];          if ( !F ) return [1];
         if ( IsGB )          if ( IsGB )
                 T = ideal_intersection(G,[F],V,0|gbblock=[[0,length(G)]]);                  T = ideal_intersection(G,[F],V,Ord|gbblock=[[0,length(G)]],mod=Mod);
         else          else
                 T = ideal_intersection(G,[F],V,0);                  T = ideal_intersection(G,[F],V,Ord|mod=Mod);
         return map(ptozp,map(sdiv,T,F));          return Mod?map(sdivm,T,F,Mod):map(ptozp,map(sdiv,T,F));
 }  }
   
 def ideal_colon(G,F,V)  def ideal_colon(G,F,V)
 {  {
         G = nd_gr(G,V,0,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
           G = nd_gr(G,V,Mod,0);
         for ( T = F, L = []; T != []; T = cdr(T) )          for ( T = F, L = []; T != []; T = cdr(T) )
                 L = cons(colon(G,car(T),V|isgb=1),L);                  L = cons(colon(G,car(T),V|isgb=1,mod=Mod),L);
         L = reverse(L);          L = reverse(L);
         return ideal_list_intersection(L,V,0);          return ideal_list_intersection(L,V,0|mod=Mod);
 }  }
   
 def ideal_sat(G,F,V)  def ideal_sat(G,F,V)
 {  {
         G = nd_gr(G,V,0,0);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         L = mapat(sat,1,G,F,V);          G = nd_gr(G,V,Mod,0);
         return ideal_list_intersection(L,V,0);          for ( T = F, L = []; T != []; T = cdr(T) )
                   L = cons(sat(G,car(T),V|mod=Mod),L);
           L = reverse(L);
           return ideal_list_intersection(L,V,0|mod=Mod);
 }  }
   
 def ideal_inclusion(F,G,V,O)  def ideal_inclusion(F,G,V,O)
 {  {
         if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( Mod ) {          for ( T = F; T != []; T = cdr(T) )
                 for ( T = F; T != []; T = cdr(T) )                  if ( gen_nf(car(T),G,V,O,Mod) ) return 0;
                         if ( p_nf_mod(car(T),G,V,O,Mod) ) return 0;  
         } else {  
                 for ( T = F; T != []; T = cdr(T) )  
                         if ( p_nf(car(T),G,V,O) ) return 0;  
         }  
         return 1;          return 1;
 }  }
   
Line 1268  def ideal_inclusion(F,G,V,O)
Line 1335  def ideal_inclusion(F,G,V,O)
   
 def qd_simp_comp(QP,V)  def qd_simp_comp(QP,V)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         R = ltov(QP);          R = ltov(QP);
         N = length(R);          N = length(R);
         for ( I = 0; I < N; I++ ) {          for ( I = 0; I < N; I++ ) {
                 if ( R[I] ) {                  if ( R[I] ) {
                         QI = R[I][0]; PI = R[I][1];                          QI = R[I][0]; PI = R[I][1];
                         for ( J = I+1; J < N; J++ )                          for ( J = I+1; J < N; J++ )
                                 if ( R[J] && gb_comp(PI,R[J][1]) ) {                                  if ( R[J] && gen_gb_comp(PI,R[J][1],Mod) ) {
                                         QI = ideal_intersection(QI,R[J][0],V,0);                                          QI = ideal_intersection(QI,R[J][0],V,0|mod=Mod);
                                         R[J] = 0;                                          R[J] = 0;
                                 }                                  }
                         R[I] = [QI,PI];                          R[I] = [QI,PI];
Line 1288  def qd_simp_comp(QP,V)
Line 1356  def qd_simp_comp(QP,V)
   
 def qd_remove_redundant_comp(G,Iso,Emb,V,Ord)  def qd_remove_redundant_comp(G,Iso,Emb,V,Ord)
 {  {
         IsoInt = ideal_list_intersection(map(first_element,Iso),V,Ord);          if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         Emb = qd_simp_comp(Emb,V);          IsoInt = ideal_list_intersection(map(first_element,Iso),V,Ord|mod=Mod);
           Emb = qd_simp_comp(Emb,V|mod=Mod);
         Emb = reverse(qsort(Emb));          Emb = reverse(qsort(Emb));
         A = ltov(Emb); N = length(A);          A = ltov(Emb); N = length(A);
         Pre = IsoInt; Post = vector(N+1);          Pre = IsoInt; Post = vector(N+1);
         for ( Post[N] = [1], I = N-1; I >= 1; I-- )          for ( Post[N] = IsoInt, I = N-1; I >= 1; I-- )
                 Post[I] = ideal_intersection(Post[I+1],A[I][0],V,Ord);                  Post[I] = ideal_intersection(Post[I+1],A[I][0],V,Ord|mod=Mod);
         for ( I = 0; I < N; I++ ) {          for ( I = 0; I < N; I++ ) {
                 Int = ideal_intersection(Pre,Post[I+1],V,Ord);                  print(".",2);
                 if ( gb_comp(Int,G) ) A[I] = 0;                  Int = ideal_intersection(Pre,Post[I+1],V,Ord|mod=Mod);
                   if ( gen_gb_comp(Int,G,Mod) ) A[I] = 0;
                 else                  else
                         Pre = ideal_intersection(Pre,A[I][0],V,Ord);                          Pre = ideal_intersection(Pre,A[I][0],V,Ord|mod=Mod);
         }          }
         for ( T = [], I = 0; I < N; I++ )          for ( T = [], I = 0; I < N; I++ )
                 if ( A[I] ) T = cons(A[I],T);                  if ( A[I] ) T = cons(A[I],T);
Line 1308  def qd_remove_redundant_comp(G,Iso,Emb,V,Ord)
Line 1378  def qd_remove_redundant_comp(G,Iso,Emb,V,Ord)
   
 def pd_remove_redundant_comp(G,P,V,Ord)  def pd_remove_redundant_comp(G,P,V,Ord)
 {  {
           if ( type(Mod=getopt(mod)) == -1 ) Mod = 0;
         if ( type(First=getopt(first)) == -1 ) First = 0;          if ( type(First=getopt(first)) == -1 ) First = 0;
         A = ltov(P); N = length(A);          A = ltov(P); N = length(A);
         for ( I = 0; I < N; I++ ) {          for ( I = 0; I < N; I++ ) {
                 if ( !A[I] ) continue;                  if ( !A[I] ) continue;
                 for ( J = I+1; J < N; J++ )                  for ( J = I+1; J < N; J++ )
                         if ( A[J] &&                          if ( A[J] &&
                                 gb_comp(First?A[I][0]:A[I],First?A[J][0]:A[J]) ) A[J] = 0;                                  gen_gb_comp(First?A[I][0]:A[I],First?A[J][0]:A[J],Mod) ) A[J] = 0;
         }          }
         for ( I = 0, T = []; I < N; I++ ) if ( A[I] ) T = cons(A[I],T);          for ( I = 0, T = []; I < N; I++ ) if ( A[I] ) T = cons(A[I],T);
         A = ltov(reverse(T)); N = length(A);          A = ltov(reverse(T)); N = length(A);
         Pre = [1]; Post = vector(N+1);          Pre = [1]; Post = vector(N+1);
         for ( Post[N] = [1], I = N-1; I >= 1; I-- )          for ( Post[N] = [1], I = N-1; I >= 1; I-- )
                 Post[I] = ideal_intersection(Post[I+1],First?A[I][0]:A[I],V,Ord);                  Post[I] = ideal_intersection(Post[I+1],First?A[I][0]:A[I],V,Ord|mod=Mod);
         for ( I = 0; I < N; I++ ) {          for ( I = 0; I < N; I++ ) {
                 Int = ideal_intersection(Pre,Post[I+1],V,Ord);                  Int = ideal_intersection(Pre,Post[I+1],V,Ord|mod=Mod);
                 if ( gb_comp(Int,G) ) A[I] = 0;                  if ( gen_gb_comp(Int,G,Mod) ) A[I] = 0;
                 else                  else
                         Pre = ideal_intersection(Pre,First?A[I][0]:A[I],V,Ord);                          Pre = ideal_intersection(Pre,First?A[I][0]:A[I],V,Ord|mod=Mod);
         }          }
         for ( T = [], I = 0; I < N; I++ ) if ( A[I] ) T = cons(A[I],T);          for ( T = [], I = 0; I < N; I++ ) if ( A[I] ) T = cons(A[I],T);
         return reverse(T);          return reverse(T);
Line 1343  def ppart(F,V,Mod)
Line 1414  def ppart(F,V,Mod)
 }  }
   
   
 def sq(F)  def sq(F,Mod)
 {  {
         if ( !F ) return 0;          if ( !F ) return 0;
         A = cdr(fctr(F));          A = cdr(gen_fctr(F,Mod));
         for ( R = 1; A != []; A = cdr(A) )          for ( R = 1; A != []; A = cdr(A) )
                 R *= car(car(A));                  R *= car(car(A));
         return R;          return R;
 }  }
   
 def lcfactor(G,V,O)  def lcfactor(G,V,O,Mod)
 {  {
         O0 = dp_ord(); dp_ord(O);          O0 = dp_ord(); dp_ord(O);
         C = [];          C = [];
         for ( T = G; T != []; T = cdr(T) ) {          for ( T = G; T != []; T = cdr(T) ) {
                 C1 = dp_hc(dp_ptod(car(T),V));                  C1 = dp_hc(dp_ptod(car(T),V));
                 S = fctr(C1);                  S = gen_fctr(C1,Mod);
                 for ( S = cdr(S); S != []; S = cdr(S) )                  for ( S = cdr(S); S != []; S = cdr(S) )
                         if ( !member(S[0][0],C) ) C = cons(S[0][0],C);                          if ( !member(S[0][0],C) ) C = cons(S[0][0],C);
         }          }
Line 1366  def lcfactor(G,V,O)
Line 1437  def lcfactor(G,V,O)
         return C;          return C;
 }  }
   
   def gen_fctr(F,Mod)
   {
           if ( Mod ) return modfctr(F,Mod);
           else return fctr(F);
   }
   
   def gen_mptop(F)
   {
           if ( !F ) return F;
           else if ( type(F)==1 )
                   if ( ntype(F)==5 ) return mptop(F);
                   else return F;
           else {
                   V = var(F);
                   D = deg(F,V);
                   for ( R = 0, I = 0; I <= D; I++ )
                           if ( C = coef(F,I,V) ) R += gen_mptop(C)*V^I;
                   return R;
           }
   }
   
   def gen_nf(F,G,V,Ord,Mod)
   {
           if ( !Mod ) return p_nf(F,G,V,Ord);
   
           setmod(Mod);
           dp_ord(Ord); DF = dp_mod(dp_ptod(F,V),Mod,[]);
           N = length(G); DG = newvect(N);
           for ( I = N-1, IL = []; I >= 0; I-- ) {
                   DG[I] = dp_mod(dp_ptod(G[I],V),Mod,[]);
                   IL = cons(I,IL);
           }
           T = dp_nf_mod(IL,DF,DG,1,Mod);
           for ( R = 0; T; T = dp_rest(T) )
                   R += gen_mptop(dp_hc(T))*dp_dtop(dp_ht(T),V);
           return R;
   }
   
 /* Ti = [D,I,M,C] */  /* Ti = [D,I,M,C] */
   
 def compute_deg0(Ti,P,V,TV)  def compute_deg0(Ti,P,V,TV)
Line 1504  def comp_by_second(A,B)
Line 1613  def comp_by_second(A,B)
         else if ( A[1] < B[1] ) return -1;          else if ( A[1] < B[1] ) return -1;
         else return 0;          else return 0;
 }  }
   
   def gen_gb_comp(A,B,Mod)
   {
           if ( !Mod ) return gb_comp(A,B);
           LA = length(A); LB = length(B);
           if ( LA != LB ) return 0;
           A = qsort(A); B = qsort(B);
           if ( A != B ) return 0;
           return 1;
   }
   
 endmodule$  endmodule$
 end$  end$

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>