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

Diff for /OpenXM/src/asir-contrib/testing/noro/ndbf.rr between version 1.1 and 1.20

version 1.1, 2009/10/09 07:15:44 version 1.20, 2014/09/05 11:55:19
Line 1 
Line 1 
   /* $OpenXM: OpenXM/src/asir-contrib/testing/noro/ndbf.rr,v 1.19 2011/03/30 05:07:01 noro Exp $ */
 /* requires 'primdec' */  /* requires 'primdec' */
   
 #define TMP_H hhhhhhhh  #define TMP_H hhhhhhhh
 #define TMP_S ssssssss  #define TMP_S ssssssss
 #define TMP_DS dssssssss  #define TMP_DS dssssssss
 #define TMP_T t  #define TMP_T tttttttt
 #define TMP_DT dt  #define TMP_DT dtttttttt
 #define TMP_Y1 yyyyyyyy1  #define TMP_Y1 yyyyyyyy1
 #define TMP_DY1 dyyyyyyyy1  #define TMP_DY1 dyyyyyyyy1
 #define TMP_Y2 yyyyyyyy2  #define TMP_Y2 yyyyyyyy2
Line 12 
Line 13 
   
 if (!module_definedp("gr")) load("gr")$ else{ }$  if (!module_definedp("gr")) load("gr")$ else{ }$
 if (!module_definedp("primdec")) load("primdec")$ else{ }$  if (!module_definedp("primdec")) load("primdec")$ else{ }$
   if (!module_definedp("newsyz")) load("noro_module_syz.rr")$ else{ }$
   /* Empty for now. It will be used in a future. */    /* Empty for now. It will be used in a future. */
   
 /* toplevel */  /* toplevel */
Line 21  module ndbf$
Line 23  module ndbf$
 /* bfunction */  /* bfunction */
   
 localf bfunction, in_ww, in_ww_main, ann, ann_n$  localf bfunction, in_ww, in_ww_main, ann, ann_n$
 localf ann0, psi, ww_weight, compare_first, generic_bfct$  localf ann0, ann_fa, psi, ww_weight, compare_first, generic_bfct$
 localf generic_bfct_1, initial_part, bfct, indicial1, bfct_via_gbfct$  localf generic_bfct_1, initial_part, bfct, indicial1, bfct_via_gbfct$
 localf bfct_via_gbfct_weight, bfct_via_gbfct_weight_1, bfct_via_gbfct_weight_2$  localf bfct_via_gbfct_weight, bfct_via_gbfct_weight_1, bfct_via_gbfct_weight_2$
 localf weyl_minipolym, weyl_minipoly, weyl_nf, weyl_nf_quo_check$  localf weyl_minipolym, weyl_minipoly, weyl_nf, weyl_nf_quo_check$
 localf weyl_nf_quo, weyl_nf_mod, b_subst, v_factorial, w_tdeg$  localf weyl_nf_quo, weyl_nf_mod, b_subst, v_factorial, w_tdeg$
 localf replace_vars_f, replace_vars_v, replace_var$  localf replace_vars_f, replace_vars_v, replace_var$
 localf action_on_gfs, action_on_gfs_1$  localf action_on_gfs, action_on_gfs_1$
   localf nd_gb_candidate$
   localf in_gb_oaku, homogenize_oaku$
   
 /* stratification */  /* stratification */
   
Line 41  localf ideal_intersection$
Line 45  localf ideal_intersection$
   
 def bfunction(F)  def bfunction(F)
 {  {
           if ( member(s,vars(F)) )
                   error("ann : the variable 's' is reserved.");
           /* F -> F/Fcont */
           F1 = ptozp(F); Fcont = sdiv(F,F1); F = F1;
   
         if ( type(Heu=getopt(heuristic)) == -1 ) Heu = 0;          if ( type(Heu=getopt(heuristic)) == -1 ) Heu = 0;
         if ( type(Vord=getopt(vord)) == -1 || type(Vord) != 4 ) Vord = 0;          if ( type(Vord=getopt(vord)) == -1 || type(Vord) != 4 ) Vord = 0;
         if ( type(Wt=getopt(weight)) == -1 ) Wt = 0;          if ( type(Wt=getopt(weight)) == -1 ) Wt = 0;
           if ( type(Op=getopt(op)) == -1 ) Op = 0;
         L = in_ww(F|weight=Wt,heuristic=Heu,vord=Vord);          L = in_ww(F|weight=Wt,heuristic=Heu,vord=Vord);
         Indata = L[0]; AllData = L[1]; VData = L[2];          Indata = L[0]; AllData = L[1]; VData = L[2];
         GIN = Indata[0]; VDV = Indata[1]; WVDV = AllData[4];          GIN = Indata[0]; VDV = Indata[1]; WVDV = AllData[4];
Line 51  def bfunction(F)
Line 61  def bfunction(F)
         dp_set_weight(W);          dp_set_weight(W);
         B = weyl_minipoly(GIN,VDV,0,WVDV);          B = weyl_minipoly(GIN,VDV,0,WVDV);
         dp_set_weight(0);          dp_set_weight(0);
         return subst(B,s,-s-1);          if ( !Op ) return subst(B,s,-s-1);
   
           V0 = VData[0]; DV0 = VData[1]; T = VData[2]; DT = VData[3];
           BPT = weyl_subst(B,T*DT,VDV);
   
           /* computation using G0,GIN0,VDV0 */
           G0 = AllData[0]; GIN0 = AllData[1]; VDV0 = AllData[2]; WtV0 = AllData[5];
           dp_set_weight(WtV0); dp_ord(0);
           PS = map(dp_ptod,GIN0,VDV0); Len = length(PS);
           for ( I = Len-1, Ind = []; I >= 0; I-- ) Ind = cons(I,Ind);
           /* QR = [D,M,Coef] */
           Ax = 1;
           AxBPT = dp_ptod(Ax*BPT,VDV0);
           QR = weyl_nf_quo(Ind,AxBPT,1,PS);
           if ( !weyl_nf_quo_check(AxBPT,PS,QR) )
                   error("bfunction : invalid quotient");
           if ( QR[0] ) error("bfunction : invalid quotient");
           Den = QR[1]; Coef = QR[2];
           for ( I = 0, R = Den*AxBPT; I < Len; I++ )
                   R -= dp_weyl_mul(Coef[I],dp_ptod(G0[I],VDV0));
           R = dp_dtop(R,VDV0);
           CR = conv_tdt(R,F,V0,DV0,T,DT);
   
           dp_set_weight(0);
           Cont = cont(CR); CR /= Cont;
           Cont *= dn(Fcont); Den *= nm(Fcont);
           Gcd = igcd(Den,Cont);
           return [subst(B,s,-s-1),(Cont*CR)/(Den*Ax)];
 }  }
   
 /*  /*
Line 65  def bfunction(F)
Line 102  def bfunction(F)
   
 def in_ww(F)  def in_ww(F)
 {  {
           F = ptozp(F);
         V = vars(F);          V = vars(F);
         N = length(V);          N = length(V);
         D = newvect(N);          D = newvect(N);
Line 74  def in_ww(F)
Line 112  def in_ww(F)
                 if ( type(Vord) != 4 ) {                  if ( type(Vord) != 4 ) {
                 for ( I = 0; I < N; I++ )                  for ( I = 0; I < N; I++ )
                         D[I] = [deg(F,V[I]),V[I]];                          D[I] = [deg(F,V[I]),V[I]];
                 qsort(D,compare_first);                  qsort(D,ndbf.compare_first);
                 for ( V = [], I = 0; I < N; I++ )                  for ( V = [], I = 0; I < N; I++ )
                         V = cons(D[I][1],V);                          V = cons(D[I][1],V);
                         V = reverse(V);                          V = reverse(V);
Line 93  def in_ww(F)
Line 131  def in_ww(F)
                         }                          }
                 for ( I = 0; I < N; I++ )                  for ( I = 0; I < N; I++ )
                         D[I] = [deg(F1,V[I]),V[I]];                          D[I] = [deg(F1,V[I]),V[I]];
                 qsort(D,compare_first);                  qsort(D,ndbf.compare_first);
                 for ( V = [], I = 0; I < N; I++ )                  for ( V = [], I = 0; I < N; I++ )
                         V = cons(D[I][1],V);                          V = cons(D[I][1],V);
                         V = reverse(V);                          V = reverse(V);
Line 203  def in_ww_main(F,VW1,VW2)
Line 241  def in_ww_main(F,VW1,VW2)
         VDVH = append(VDV,[TMP_H]);          VDVH = append(VDV,[TMP_H]);
         FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH);          FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH);
   
         /* compute a groebner basis of FH w.r.t. MWH */  /*
    * FH is a GB w.r.t. any term order s.t. LT(FH)=[t,dx1,...,dxn]
    * Compute a groebner basis of FH w.r.t. MWH by modular change of
    * ordering.
    * Since F is Z-coef, LC(FH)=[1,...,1] and we can use any prime p
    * for trace algorithm.
    */
 /*      dp_gr_flags(["Top",1,"NoRA",1]); */  /*      dp_gr_flags(["Top",1,"NoRA",1]); */
 #if 0          for ( I = 0, HC=[]; I <= N; I++ ) HC = cons(1,HC);
         GH = dp_weyl_gr_main(FH,VDVH,0,0,11);          GH = nd_gb_candidate(FH,VDVH,11,0,HC,1);
 #else  
 #if 0  
         GH = dp_weyl_gr_main(FH,VDVH,0,-1,11);  
 #else  
         GH = nd_weyl_gr_trace(FH,VDVH,0,-1,11);  
 #endif  
 #endif  
 /*      dp_gr_flags(["Top",0,"NoRA",0]); */  /*      dp_gr_flags(["Top",0,"NoRA",0]); */
   
         /* dehomigenize GH */          /* dehomigenize GH */
Line 232  def in_ww_main(F,VW1,VW2)
Line 269  def in_ww_main(F,VW1,VW2)
   
         AllData = [G,GIN,VDV,W,T,WtV];          AllData = [G,GIN,VDV,W,T,WtV];
         if ( VW2 ) {          if ( VW2 ) {
                   /* take LC(GIN) w.r.t. DRL */
           dp_set_weight(WtV); dp_ord(0);
           HC = map(dp_hc,map(dp_ptod,GIN,VDV));
                 V2 = VW2[0]; DV2 = VW2[1]; WtV2 = VW2[2];                  V2 = VW2[0]; DV2 = VW2[1]; WtV2 = VW2[2];
                 VDV2 = append(V2,DV2);                  VDV2 = append(V2,DV2);
                 dp_set_weight(WtV2);                  dp_set_weight(WtV2);
         GIN2 = nd_weyl_gr_trace(GIN,VDV2,0,-1,0);                  GIN2 = nd_gb_candidate(GIN,VDV2,0,0,HC,1);
                 InData = [GIN2,VDV2,V2,DV2,WtV2];                  InData = [GIN2,VDV2,V2,DV2,WtV2];
         } else {          } else {
                 if ( 0 ) {                  if ( 0 ) {
Line 259  def ann(F)
Line 299  def ann(F)
 {  {
         if ( member(s,vars(F)) )          if ( member(s,vars(F)) )
                 error("ann : the variable 's' is reserved.");                  error("ann : the variable 's' is reserved.");
           if ( type(Vord=getopt(vord)) == -1 ) Vord = 0;
           F = ptozp(F);
         V = vars(F);          V = vars(F);
           if ( Vord ) {
                   Param = setminus(V,Vord);
                   V = Vord;
           }
         N = length(V);          N = length(V);
         D = newvect(N);          D = newvect(N);
           if ( type(Wt=getopt(weight)) == -1 )
                   for ( I = N-1, Wt = []; I >= 0; I-- ) Wt = append([V[I],1],Wt);
   
         for ( I = 0; I < N; I++ )          Wt1 = vector(N);
                 D[I] = [deg(F,V[I]),V[I]];          for ( I = 0, F1 =F; I < N; I++ ) {
         qsort(D,compare_first);                  VI = Wt[2*I]; WI = Wt[2*I+1];
         for ( V = [], I = N-1; I >= 0; I-- )                  for ( J = 0; J < N; J++ )
                 V = cons(D[I][1],V);                          if ( VI == V[J] ) break;
                   F1 = subst(F1,VI,VI^WI);
           }
           for ( I = 0; I < N; I++ ) D[I] = [deg(F1,V[I]),V[I]];
           qsort(D,ndbf.compare_first);
           for ( V = [], I = 0; I < N; I++ ) V = cons(D[I][1],V);
           V = reverse(V);
           for ( I = 0; I < N; I++ ) {
                   VI = Wt[2*I]; WI = Wt[2*I+1];
                   for ( J = 0; J < N; J++ ) if ( VI == V[J] ) break;
                   Wt1[J] = WI;
           }
           Wt = vtol(Wt1);
   
         for ( I = N-1, DV = []; I >= 0; I-- )          for ( I = N-1, DV = []; I >= 0; I-- )
                 DV = cons(strtov("d"+rtostr(V[I])),DV);                  DV = cons(strtov("d"+rtostr(V[I])),DV);
Line 280  def ann(F)
Line 340  def ann(F)
                 B = cons(DV[I]+TMP_Y1*diff(F,V[I])*TMP_DT,B);                  B = cons(DV[I]+TMP_Y1*diff(F,V[I])*TMP_DT,B);
         }          }
   
         /* homogenized (heuristics) */          Tdeg = w_tdeg(F,V,Wt);
         dp_nelim(2);          /* y1*y2-1, t-y1*f, dx1+y1*df/dx1*dt ... */
         G0 = nd_weyl_gr(B,append(W,DW),0,[[0,2],[0,length(W)*2-2]]);          /* weight for [y1,y2,t,   x1,...,xn,  dy1,dy2, dt,dx1,...,dxn,   h]   */
           /*              0  1 2    3      N3-1 N3  N3+1 N3+2              2*N3 */
           /*              1  1 D+1  w1     wn    1   1    1  D       D      1    */
           N3 = N+3;
           WtV = newvect(2*N3+1);
           WtV[0] = WtV[1] = 1; WtV[2] = Tdeg+1;
           for ( I = 3; I < N3; I++ ) WtV[I] = Wt[I-3];
           for ( ; I <= N3+2; I++ ) WtV[I] = 1;
           for ( ; I < 2*N3; I++ ) WtV[I] = Tdeg;
           WtV[2*N3] = 1;
   
           /* B is already a GB => modular change of ordering can be applied */
           /* any prime is available => HC=[1] */
           dp_set_weight(WtV);
           G0 = nd_gb_candidate(B,append(W,DW),[[0,2],[0,length(W)*2-2]],0,[1],1);
           dp_set_weight(0);
         G1 = [];          G1 = [];
         for ( T = G0; T != []; T = cdr(T) ) {          for ( T = G0; T != []; T = cdr(T) ) {
                 E = car(T); VL = vars(E);                  E = car(T); VL = vars(E);
Line 294  def ann(F)
Line 369  def ann(F)
         return G3;          return G3;
 }  }
   
   def in_gb_oaku(F)
   {
           if ( member(s,vars(F)) )
                   error("ann : the variable 's' is reserved.");
           F = ptozp(F);
           V = vars(F);
           N = length(V);
           D = newvect(N);
           if ( type(Wt=getopt(weight)) == -1 )
                   for ( I = N-1, Wt = []; I >= 0; I-- ) Wt = append([V[I],1],Wt);
   
           Wt1 = vector(N);
           for ( I = 0, F1 =F; I < N; I++ ) {
                   VI = Wt[2*I]; WI = Wt[2*I+1];
                   for ( J = 0; J < N; J++ )
                           if ( VI == V[J] ) break;
                   F1 = subst(F1,VI,VI^WI);
           }
           for ( I = 0; I < N; I++ ) D[I] = [deg(F1,V[I]),V[I]];
           qsort(D,ndbf.compare_first);
           for ( V = [], I = 0; I < N; I++ ) V = cons(D[I][1],V);
           V = reverse(V);
           for ( I = 0; I < N; I++ ) {
                   VI = Wt[2*I]; WI = Wt[2*I+1];
                   for ( J = 0; J < N; J++ ) if ( VI == V[J] ) break;
                   Wt1[J] = WI;
           }
           Wt = vtol(Wt1);
   
           for ( I = N-1, DV = []; I >= 0; I-- )
                   DV = cons(strtov("d"+rtostr(V[I])),DV);
   
           W = append([TMP_Y1,TMP_Y2,TMP_T],V);
           DW = append([TMP_DY1,TMP_DY2,TMP_DT],DV);
   
           B = [TMP_T-TMP_Y1*F];
           for ( I = 0; I < N; I++ ) {
                   B = cons(DV[I]+TMP_Y1*diff(F,V[I])*TMP_DT,B);
           }
   
           Tdeg = w_tdeg(F,V,Wt);
           /* y1*y2-1, t-y1*f, dx1+y1*df/dx1*dt ... */
           /* weight for [y1,y2,t,   x1,...,xn,  dy1,dy2, dt,dx1,...,dxn,   h]   */
           /*              0  1 2    3      N3-1 N3  N3+1 N3+2              2*N3 */
           /*              1  1 D+1  1      1    1   1    1  D       D      1    */
           N3 = N+3;
           WtV = newvect(2*N3+1);
           WtV[0] = WtV[1] = 1; WtV[2] = Tdeg+1;
           for ( I = 3; I <= N3+2; I++ ) WtV[I] = 1;
           for ( ; I < 2*N3; I++ ) WtV[I] = Tdeg;
           WtV[2*N3] = 1;
   
           /* B is already a GB => modular change of ordering can be applied */
           /* any prime is available => HC=[1] */
           dp_set_weight(WtV);
           G0 = nd_gb_candidate(B,append(W,DW),[[0,2],[0,length(W)*2-2]],0,[1],1);
           dp_set_weight(0);
           G1 = map(subst,G0,TMP_Y1,1);
           return [G1,append(V,DV)];
   }
   
   /* homogenization w.r.t. (-W,W)-weight */
   /* VDV = [x1,...,xn,dx1,...,dxn] */
   /* homogenize F w.r.t. (W,-W,1) for (x,dx,y) */
   
   def homogenize_oaku(F,VDV,W,Y)
   {
           N = length(VDV);
           if ( N%2 ) error("invalid variable list");
           N2 = N/2;
           if ( length(W) != N2 ) error("inconsistent weight vector");
           W0 = dp_set_weight();
           Wt = append(W,append(vtol(-ltov(W)),[1]));
           dp_set_weight(Wt);
           H = homogenize(F,VDV,Y);
           dp_set_weight(W0);
           if ( type(Vars=getopt(vars)) != -1 && Vars ) {
                   DY = strtov("d"+rtostr(Y));
                   for ( I = 0, T = VDV, V = []; I < N2; I++, T = cdr(T) )
                           V = cons(car(T),V);
                   T = cons(Y,append(T,[DY]));
                   for ( ; V != []; V = cdr(V) ) T = cons(car(V),T);
                   return [H,T];
           } else return H;
   }
   
 /* F = [F0,F1,...] */  /* F = [F0,F1,...] */
   
 def ann_n(F)  def ann_n(F)
Line 331  def ann_n(F)
Line 492  def ann_n(F)
         VA = append(U,append(W,V));          VA = append(U,append(W,V));
         DVA = append(DU,append(DW,DV));          DVA = append(DU,append(DW,DV));
         VDV = append(VA,DVA);          VDV = append(VA,DVA);
   #if 0
         G0 = nd_weyl_gr(B,VDV,0,[[0,2*L],[0,length(VDV)-2*L]]);          G0 = nd_weyl_gr(B,VDV,0,[[0,2*L],[0,length(VDV)-2*L]]);
   #else
           G0 = nd_gb_candidate(B,VDV,[[0,2*L],[0,length(VDV)-2*L]],0,[1],1);
   #endif
         G1 = [];          G1 = [];
         for ( T = G0; T != []; T = cdr(T) ) {          for ( T = G0; T != []; T = cdr(T) ) {
                 E = car(T); VL = vars(E);                  E = car(T); VL = vars(E);
Line 369  def ann0(F)
Line 534  def ann0(F)
         return [Min,map(subst,Ann,s,Min,TMP_S,s,TMP_DS,ds)];          return [Min,map(subst,Ann,s,Min,TMP_S,s,TMP_DS,ds)];
 }  }
   
   /*
    * For a polynomial F and a scalar A,
    * compute generators of Ann(F^A).
    */
   
   def ann_fa(F,A)
   {
           if ( type(Syz=getopt(syz)) == -1 ) Syz = 0;
   
           F = subst(F,s,TMP_S);
           Ann = ann(F);
           Bf = bfunction(F);
   
           FList = cdr(fctr(Bf));
           for ( T = FList, Min = 0; T != []; T = cdr(T) ) {
                   LF = car(car(T));
                   Root = -coef(LF,0)/coef(LF,1);
                   if ( dn(Root) == 1 && Root < Min )
                           Min = Root;
           }
           D = A-Min;
           if ( dn(D) != 1 || D <= 0 )
                   return map(ptozp,map(subst,Ann,s,A,TMP_S,s,TMP_DS,ds));
   
           V = vars(F);
           for ( I = length(V)-1, DV = []; I >= 0; I-- )
                   DV = cons(strtov("d"+rtostr(V[I])),DV);
           VDV = append(V,DV);
           R = map(subst,Ann,s,Min,TMP_S,s,TMP_DS,ds);
           F = ptozp(F);
   
           if ( Syz ) {
                   /* syzygy method */
                   S = newsyz.module_syz(cons(F^D,R),VDV,1,0|weyl=1);
                   B = car(S);
                   for ( R = []; B != []; B = cdr(B) )
                           if ( H = car(car(B)) )
                                   R = cons(ptozp(H),R);
           } else {
                   /* colon method */
                   for ( I = 0; I < D; I++ )
                           R = weyl_ideal_quotient(R,F,VDV);
           }
           return R;
   }
   
 def psi0(F,T,DT)  def psi0(F,T,DT)
 {  {
         D = dp_ptod(F,[T,DT]);          D = dp_ptod(F,[T,DT]);
Line 584  def bfct(F)
Line 795  def bfct(F)
   
         for ( I = 0; I < N; I++ )          for ( I = 0; I < N; I++ )
                 D[I] = [deg(F,V[I]),V[I]];                  D[I] = [deg(F,V[I]),V[I]];
         qsort(D,compare_first);          qsort(D,ndbf.compare_first);
         for ( V = [], I = 0; I < N; I++ )          for ( V = [], I = 0; I < N; I++ )
                 V = cons(D[I][1],V);                  V = cons(D[I][1],V);
         for ( I = N-1, DV = []; I >= 0; I-- )          for ( I = N-1, DV = []; I >= 0; I-- )
Line 630  def bfct_via_gbfct(F)
Line 841  def bfct_via_gbfct(F)
   
         for ( I = 0; I < N; I++ )          for ( I = 0; I < N; I++ )
                 D[I] = [deg(F,V[I]),V[I]];                  D[I] = [deg(F,V[I]),V[I]];
         qsort(D,compare_first);          qsort(D,ndbf.compare_first);
         for ( V = [], I = 0; I < N; I++ )          for ( V = [], I = 0; I < N; I++ )
                 V = cons(D[I][1],V);                  V = cons(D[I][1],V);
         V = reverse(V);          V = reverse(V);
Line 1082  def replace_var(V,X,Y)
Line 1293  def replace_var(V,X,Y)
   
 def action_on_gfs(P,V,GFS)  def action_on_gfs(P,V,GFS)
 {  {
           for ( T = V, DV = []; T != []; T = cdr(T) )
                   DV = cons(strtov("d"+rtostr(car(T))),DV);
           V = append(append(V,[s]),reverse(cons(ds,DV)));
         DP = dp_ptod(P,V);          DP = dp_ptod(P,V);
         N = length(V)/2;          N = length(V)/2;
         for ( I = N-1, V0 = []; I >= 0; I-- )          for ( I = N-1, V0 = []; I >= 0; I-- )
Line 1223  def weyl_ideal_quotient(B,F,VDV)
Line 1437  def weyl_ideal_quotient(B,F,VDV)
         O1 = [[0,1],[0,N+1]];          O1 = [[0,1],[0,N+1]];
         GJ = nd_weyl_gr(J,VDV1,0,O1);          GJ = nd_weyl_gr(J,VDV1,0,O1);
         R = elimination(GJ,VDV);          R = elimination(GJ,VDV);
         return R;          return map(weyl_divide_by_right,R,F,VDV,0);
 }  }
   
 def bf_strat(F)  def bf_strat(F)
 {  {
           if ( member(s,vars(F)) )
                   error("ann : the variable 's' is reserved.");
         dp_ord(0);          dp_ord(0);
         T0 = time();          T0 = time();
         if ( type(Heu=getopt(heuristic)) == -1 ) Heu = 0;          if ( type(Heu=getopt(heuristic)) == -1 ) Heu = 0;
         if ( type(Vord=getopt(vord)) == -1 || type(Vord) != 4 ) Vord = 0;          if ( type(Vord=getopt(vord)) == -1 || type(Vord) != 4 ) Vord = 0;
         if ( type(Wt=getopt(weight)) == -1 ) Wt = 0;          if ( type(Wt=getopt(weight)) == -1 ) Wt = 0;
           if ( type(ElimIdeal=getopt(elimideal)) == -1 ) ElimIdeal = 0;
         L = in_ww(F|weight=Wt,heuristic=Heu,vord=Vord);          L = in_ww(F|weight=Wt,heuristic=Heu,vord=Vord);
         T1 = time();          T1 = time();
         print(["in_ww",(T1[0]+T1[1])-(T0[0]+T0[1])]);          print(["in_ww",(T1[0]+T1[1])-(T0[0]+T0[1])]);
Line 1271  def bf_strat(F)
Line 1488  def bf_strat(F)
         }          }
   
         L2 = bf_strat_stage2(L);          L2 = bf_strat_stage2(L);
           if ( ElimIdeal ) return L2;
         S = bf_strat_stage3(L2);          S = bf_strat_stage3(L2);
         R = [];          R = [];
         for ( T = S; T != []; T = cdr(T) ) {          for ( T = S; T != []; T = cdr(T) ) {
Line 1304  def bf_strat_stage2(L)
Line 1522  def bf_strat_stage2(L)
                 M = elim_mat(VDV,DVRV);                  M = elim_mat(VDV,DVRV);
                 for ( K = 0; K < N; K++ )                  for ( K = 0; K < N; K++ )
                         M[1][K] = W[K];                          M[1][K] = W[K];
                 dp_ord(0); H1 = map(dp_ht,map(dp_ptod,G1,VDV));                  dp_ord(0); D1 = map(dp_ptod,G1,VDV);
                   H1 = map(dp_ht,D1); HC1 = map(dp_hc,D1);
                 dp_ord(M); H2 = map(dp_ht,map(dp_ptod,G1,VDV));                  dp_ord(M); H2 = map(dp_ht,map(dp_ptod,G1,VDV));
                 if ( H1 == H2 )                  if ( H1 == H2 )
                         G2 = G1;                          G2 = G1;
                 else                  else
                         G2 = nd_weyl_gr_trace(G1,VDV,0,-1,M);                          G2 = nd_gb_candidate(G1,VDV,M,0,HC1,1);
                 G1 = elimination(G2,DVRV);                  G1 = elimination(G2,DVRV);
         }          }
         T1 = time();          T1 = time();
Line 1332  def bf_strat_stage3(L)
Line 1551  def bf_strat_stage3(L)
         QQ = L[0]; V0 = L[2]; B = L[3]; BF = L[4]; W0 = L[5];          QQ = L[0]; V0 = L[2]; B = L[3]; BF = L[4]; W0 = L[5];
         NF = length(BF);          NF = length(BF);
         Data = vector(NF);          Data = vector(NF);
           W1 = W0? cons(1,append(W0,[1])) : 0;
         for ( I = J = 0; I < NF; I++ ) {          for ( I = J = 0; I < NF; I++ ) {
                 DI = tower_in_p(QQ,B,BF[I],V0,W0);                  DI = tower_in_p(QQ,B,BF[I],V0,W0);
                 NDI = length(DI);                  NDI = length(DI);
                   dp_set_weight(W1);
                 for ( K = 0; K < J; K++ ) {                  for ( K = 0; K < J; K++ ) {
                         if ( length(DK=Data[K]) == NDI ) {                          if ( length(DK=Data[K]) == NDI ) {
                                 for ( L = 0; L < NDI; L++ ) {                                  for ( L = 0; L < NDI; L++ ) {
Line 1345  def bf_strat_stage3(L)
Line 1566  def bf_strat_stage3(L)
                                 if ( L == NDI ) break;                                  if ( L == NDI ) break;
                         }                          }
                 }                  }
                   dp_set_weight(0);
                 if ( K < J ) {                  if ( K < J ) {
                         for ( L = 0, T = []; L < NDI; L++ )                          for ( L = 0, T = []; L < NDI; L++ ) {
   #if 0
                                   NewId = DK[L][1];
   #else
                                   NewId = ideal_intersection(DK[L][1],DI[L][1],V0,0);
   #endif
                                 T = cons([[DK[L][0][0]*DI[L][0][0],DK[L][0][1]],                                  T = cons([[DK[L][0][0]*DI[L][0][0],DK[L][0][1]],
                                         DK[L][1],DK[L][2]],T);                                          NewId,DK[L][2]],T);
                           }
                         Data[K] = reverse(T);                          Data[K] = reverse(T);
                 } else                  } else
                         Data[J++] = DI;                          Data[J++] = DI;
Line 1357  def bf_strat_stage3(L)
Line 1585  def bf_strat_stage3(L)
         for ( I = 0; I < J; I++ )          for ( I = 0; I < J; I++ )
                 Data1[I] = Data[I];                  Data1[I] = Data[I];
         T1 = time();          T1 = time();
         Str = stratify_bf(Data1,V0);          Str = stratify_bf(Data1,V0,W0);
         T2 = time();          T2 = time();
         print(["tower",(T1[0]+T1[1])-(T0[0]+T0[1])]);          print(["tower",(T1[0]+T1[1])-(T0[0]+T0[1])]);
         print(["strat",(T2[0]+T2[1])-(T1[0]+T1[1])]);          print(["strat",(T2[0]+T2[1])-(T1[0]+T1[1])]);
Line 1371  def bf_strat_stage3(L)
Line 1599  def bf_strat_stage3(L)
   
 def bf_local(F,P)  def bf_local(F,P)
 {  {
           if ( member(s,vars(F)) )
                   error("ann : the variable 's' is reserved.");
           /* F -> F/Fcont */
           F1 = ptozp(F); Fcont = sdiv(F,F1); F = F1;
         if ( type(Heu=getopt(heuristic)) == -1 ) Heu = 0;          if ( type(Heu=getopt(heuristic)) == -1 ) Heu = 0;
         if ( type(Vord=getopt(vord)) == -1 || type(Vord) != 4 ) Vord = 0;          if ( type(Vord=getopt(vord)) == -1 || type(Vord) != 4 ) Vord = 0;
         if ( type(Wt=getopt(weight)) == -1 ) Wt = 0;          if ( type(Wt=getopt(weight)) == -1 ) Wt = 0;
           if ( type(Op=getopt(op)) == -1 ) Op = 0;
         L = in_ww(F|weight=Wt,heuristic=Heu,vord=Vord);          L = in_ww(F|weight=Wt,heuristic=Heu,vord=Vord);
         InData = L[0]; AllData = L[1]; VData = L[2];          InData = L[0]; AllData = L[1]; VData = L[2];
         G = InData[0]; VDV = InData[1];          G = InData[0]; VDV = InData[1];
Line 1407  def bf_local(F,P)
Line 1640  def bf_local(F,P)
                         break;                          break;
         if ( List == [] ) error("bf_local : inconsitent intersection");          if ( List == [] ) error("bf_local : inconsitent intersection");
         Ax = car(List);          Ax = car(List);
         for ( BPT = 1, List = BP; List != []; List = cdr(List) )          LB = [];
           for ( BPT = 1, List = BP; List != []; List = cdr(List) ) {
                 BPT *= car(List)[0]^car(List)[1];                  BPT *= car(List)[0]^car(List)[1];
                   LB = cons([subst(car(List)[0],s,-s-1),car(List)[1]],LB);
           }
           LB = reverse(LB);
           if ( !Op ) return LB;
   
         BPT = weyl_subst(BPT,T*DT,VDV);          BPT = weyl_subst(BPT,T*DT,VDV);
   
         /* computation using G0,GIN0,VDV0 */          /* computation using G0,GIN0,VDV0 */
Line 1428  def bf_local(F,P)
Line 1667  def bf_local(F,P)
         CR = conv_tdt(R,F,V0,DV0,T,DT);          CR = conv_tdt(R,F,V0,DV0,T,DT);
   
         dp_set_weight(0);          dp_set_weight(0);
         return [BP,Ax,CR];          Cont = cont(CR); CR /= Cont;
           Cont *= dn(Fcont); Den *= nm(Fcont);
           Gcd = igcd(Den,Cont);
           return [LB,(Den/Gcd)*Ax,(Cont/Gcd)*CR];
 }  }
   
 /* t^(l+k)*dt^l (k>l) -> (s-k)(s-k-1)...(s-(k+l-1))t^k */  /* t^(l+k)*dt^l (k>l) -> (s-k)(s-k-1)...(s-(k+l-1))t^k */
Line 1453  def conv_tdt(P,F,V0,DV0,T,DT)
Line 1695  def conv_tdt(P,F,V0,DV0,T,DT)
         return subst(R,T,s);          return subst(R,T,s);
 }  }
   
 def merge_tower(Str,Tower,V)  /* W1=[W,1], W2=[1,W,1] */
   
   def merge_tower(Str,Tower,V,W1,W2)
 {  {
         Prev = car(Tower); T = cdr(Tower);          Prev = car(Tower); T = cdr(Tower);
         Str1 = [];          Str1 = [];
Line 1468  def merge_tower(Str,Tower,V)
Line 1712  def merge_tower(Str,Tower,V)
         U = [];          U = [];
         for ( T = Str; T != []; T = cdr(T) ) {          for ( T = Str; T != []; T = cdr(T) ) {
                 for ( S = Str1; S != []; S = cdr(S) ) {                  for ( S = Str1; S != []; S = cdr(S) ) {
                         Int = int_cons(T[0],S[0],V);                          Int = int_cons(T[0],S[0],V,W1,W2);
                         if ( Int[0] != [1] )                          if ( Int[0] != [1] )
                                 U = cons(append(Int,[append(T[0][2],S[0][2])]),U);                                  U = cons(append(Int,[append(T[0][2],S[0][2])]),U);
                 }                  }
Line 1477  def merge_tower(Str,Tower,V)
Line 1721  def merge_tower(Str,Tower,V)
         return U;          return U;
 }  }
   
 def stratify_bf(Data,V)  def stratify_bf(Data,V,W)
 {  {
         N = length(Data);          N = length(Data);
         R = [];          R = [];
           if ( W ) {
                   W1 = append(W,[1]);
                   W2 = cons(1,W1);
           } else
                   W1 = W2 = 0;
         for ( I = 0; I < N; I++ )          for ( I = 0; I < N; I++ )
                 R = merge_tower(R,Data[I],V);                  R = merge_tower(R,Data[I],V,W1,W2);
         return R;          return R;
 }  }
   
Line 1588  def zero_inclusion(A,B,V)
Line 1837  def zero_inclusion(A,B,V)
         NV = ttttt;          NV = ttttt;
         for ( T = A; T != []; T = cdr(T) ) {          for ( T = A; T != []; T = cdr(T) ) {
                 F = car(T);                  F = car(T);
                 G = nd_gr_trace(cons(NV*F-1,B),cons(NV,V),1,-1,0);                  G = nd_gr_trace(cons(NV*F-1,B),cons(NV,V),1,1,0);
                 if ( type(car(G)) != 1 ) return 0;                  if ( type(car(G)) != 1 ) return 0;
         }          }
         return 1;          return 1;
Line 1622  def elim_mat(V,W)
Line 1871  def elim_mat(V,W)
    =(P cap R)-(Q cup S)     =(P cap R)-(Q cup S)
 */  */
   
 def int_cons(A,B,V)  def int_cons(A,B,V,W1,W2)
 {  {
         AZ = A[0]; AN = A[1];          AZ = A[0]; AN = A[1];
         BZ = B[0]; BN = B[1];          BZ = B[0]; BN = B[1];
           if ( W1 ) dp_set_weight(W1);
         CZ = nd_gr_trace(append(AZ,BZ),V,1,1,0);          CZ = nd_gr_trace(append(AZ,BZ),V,1,1,0);
           if ( W2 ) dp_set_weight(W2);
         CN = ideal_intersection(AN,BN,V,0);          CN = ideal_intersection(AN,BN,V,0);
         if ( zero_inclusion(CN,CZ,V) )          ZI = zero_inclusion(CN,CZ,V);
           dp_set_weight(0);
           if ( ZI )
                 return [[1],[]];                  return [[1],[]];
         else          else
                 return [CZ,CN];                  return [CZ,CN];
Line 1641  def ideal_intersection(A,B,V,Ord)
Line 1894  def ideal_intersection(A,B,V,Ord)
                 cons(T,V),1,1,[[0,1],[Ord,length(V)]]);                  cons(T,V),1,1,[[0,1],[Ord,length(V)]]);
         return elimination(G,V);          return elimination(G,V);
 }  }
   
   def nd_gb_candidate(G,V,Ord,Homo,HC,Weyl)
   {
           Ind = 0;
           N = length(HC);
           while ( 1 ) {
                   P = lprime(Ind++);
                   for ( I = 0; I < N; I++ )
                           if ( !(HC[I]%P) ) break;
                   if ( I < N ) continue;
                   if ( Weyl )
                           G = nd_weyl_gr_trace(G,V,Homo,-P,Ord);
                   else
                           G = nd_gr_trace(G,V,Homo,-P,Ord);
                   if ( G ) return G;
           }
   }
   
 endmodule $  endmodule $
 end$  end$
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.20

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