version 1.11, 2000/12/15 01:52:36 |
version 1.24, 2003/04/28 02:15:30 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.10 2000/12/15 01:34:31 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.23 2003/04/20 11:59:57 noro Exp $ |
*/ |
*/ |
/* requires 'primdec' */ |
/* requires 'primdec' */ |
|
|
|
#define TMP_S ssssssss |
|
#define TMP_DS dssssssss |
|
#define TMP_T dtttttttt |
|
#define TMP_DT tttttttt |
|
#define TMP_Y1 yyyyyyyy1 |
|
#define TMP_DY1 dyyyyyyyy1 |
|
#define TMP_Y2 yyyyyyyy2 |
|
#define TMP_DY2 dyyyyyyyy2 |
|
|
|
extern LIBRARY_GR_LOADED$ |
|
extern LIBRARY_PRIMDEC_LOADED$ |
|
|
|
if(!LIBRARY_GR_LOADED) load("gr"); else ; LIBRARY_GR_LOADED = 1$ |
|
if(!LIBRARY_PRIMDEC_LOADED) load("primdec"); else ; LIBRARY_PRIMDEC_LOADED = 1$ |
|
|
|
/* toplevel */ |
|
|
|
def bfunction(F) |
|
{ |
|
V = vars(F); |
|
N = length(V); |
|
D = newvect(N); |
|
|
|
for ( I = 0; I < N; I++ ) |
|
D[I] = [deg(F,V[I]),V[I]]; |
|
qsort(D,compare_first); |
|
for ( V = [], I = 0; I < N; I++ ) |
|
V = cons(D[I][1],V); |
|
return bfct_via_gbfct_weight(F,V); |
|
} |
|
|
/* annihilating ideal of F^s */ |
/* annihilating ideal of F^s */ |
|
|
def ann(F) |
def ann(F) |
{ |
{ |
|
if ( member(s,vars(F)) ) |
|
error("ann : the variable 's' is reserved."); |
V = vars(F); |
V = vars(F); |
N = length(V); |
N = length(V); |
D = newvect(N); |
D = newvect(N); |
|
|
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); |
|
|
W = append([y1,y2,t],V); |
W = append([TMP_Y1,TMP_Y2,TMP_T],V); |
DW = append([dy1,dy2,dt],DV); |
DW = append([TMP_DY1,TMP_DY2,TMP_DT],DV); |
|
|
B = [1-y1*y2,t-y1*F]; |
B = [1-TMP_Y1*TMP_Y2,TMP_T-TMP_Y1*F]; |
for ( I = 0; I < N; I++ ) { |
for ( I = 0; I < N; I++ ) { |
B = cons(DV[I]+y1*diff(F,V[I])*dt,B); |
B = cons(DV[I]+TMP_Y1*diff(F,V[I])*TMP_DT,B); |
} |
} |
|
|
/* homogenized (heuristics) */ |
/* homogenized (heuristics) */ |
|
|
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); |
if ( !member(y1,VL) && !member(y2,VL) ) |
if ( !member(TMP_Y1,VL) && !member(TMP_Y2,VL) ) |
G1 = cons(E,G1); |
G1 = cons(E,G1); |
} |
} |
G2 = map(subst,G1,dt,1); |
G2 = map(psi,G1,TMP_T,TMP_DT); |
G3 = map(b_subst,G2,t); |
G3 = map(subst,G2,TMP_T,-1-s); |
G4 = map(subst,G3,t,-1-s); |
return G3; |
return G4; |
|
} |
} |
|
|
/* |
/* |
|
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
|
/* XXX : heuristics */ |
/* XXX : heuristics */ |
W = append([y1,y2,t],reverse(V)); |
W = append([TMP_Y1,TMP_Y2,TMP_T],reverse(V)); |
DW = append([dy1,dy2,dt],reverse(DV)); |
DW = append([TMP_DY1,TMP_DY2,TMP_DT],reverse(DV)); |
WDW = append(W,DW); |
WDW = append(W,DW); |
|
|
B = [1-y1*y2,t-y1*F]; |
B = [1-TMP_Y1*TMP_Y2,TMP_T-TMP_Y1*F]; |
for ( I = 0; I < N; I++ ) { |
for ( I = 0; I < N; I++ ) { |
B = cons(DV[I]+y1*diff(F,V[I])*dt,B); |
B = cons(DV[I]+TMP_Y1*diff(F,V[I])*TMP_DT,B); |
} |
} |
|
|
/* homogenized (heuristics) */ |
/* homogenized (heuristics) */ |
|
|
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); |
if ( !member(y1,VL) && !member(y2,VL) ) |
if ( !member(TMP_Y1,VL) && !member(TMP_Y2,VL) ) |
G1 = cons(E,G1); |
G1 = cons(E,G1); |
} |
} |
G2 = map(subst,G1,dt,1); |
G2 = map(psi,G1,TMP_T,TMP_DT); |
G3 = map(b_subst,G2,t); |
G3 = map(subst,G2,TMP_T,-1-TMP_S); |
G4 = map(subst,G3,t,-1-s); |
|
|
|
/* G4 = J_f(s) */ |
/* G3 = J_f(s) */ |
|
|
V1 = cons(s,V); DV1 = cons(ds,DV); V1DV1 = append(V1,DV1); |
V1 = cons(TMP_S,V); DV1 = cons(TMP_DS,DV); V1DV1 = append(V1,DV1); |
G5 = dp_weyl_gr_main(cons(F,G4),V1DV1,0,1,0); |
G4 = dp_weyl_gr_main(cons(F,G3),V1DV1,0,1,0); |
Bf = weyl_minipoly(G5,V1DV1,0,s); |
Bf = weyl_minipoly(G4,V1DV1,0,TMP_S); |
|
|
FList = cdr(fctr(Bf)); |
FList = cdr(fctr(Bf)); |
for ( T = FList, Min = 0; T != []; T = cdr(T) ) { |
for ( T = FList, Min = 0; T != []; T = cdr(T) ) { |
|
|
if ( dn(Root) == 1 && Root < Min ) |
if ( dn(Root) == 1 && Root < Min ) |
Min = Root; |
Min = Root; |
} |
} |
return [Min,map(subst,G4,s,Min)]; |
return [Min,map(subst,G3,TMP_S,Min)]; |
} |
} |
|
|
def indicial1(F,V) |
|
{ |
|
W = append([y1,t],V); |
|
N = length(V); |
|
B = [t-y1*F]; |
|
for ( I = N-1, DV = []; I >= 0; I-- ) |
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
DW = append([dy1,dt],DV); |
|
for ( I = 0; I < N; I++ ) { |
|
B = cons(DV[I]+y1*diff(F,V[I])*dt,B); |
|
} |
|
dp_nelim(1); |
|
|
|
/* homogenized (heuristics) */ |
|
G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6); |
|
G1 = map(subst,G0,y1,1); |
|
Mat = newmat(2,2,[[-1,1],[0,1]]); |
|
G2 = map(psi,G1,t,dt); |
|
G3 = map(subst,G2,t,-s-1); |
|
return G3; |
|
} |
|
|
|
def psi(F,T,DT) |
def psi(F,T,DT) |
{ |
{ |
D = dp_ptod(F,[T,DT]); |
D = dp_ptod(F,[T,DT]); |
Line 208 def compare_first(A,B) |
|
Line 217 def compare_first(A,B) |
|
return 0; |
return 0; |
} |
} |
|
|
|
/* generic b-function w.r.t. weight vector W */ |
|
|
|
def generic_bfct(F,V,DV,W) |
|
{ |
|
N = length(V); |
|
N2 = N*2; |
|
|
|
/* If W is a list, convert it to a vector */ |
|
if ( type(W) == 4 ) |
|
W = newvect(length(W),W); |
|
dp_weyl_set_weight(W); |
|
|
|
/* create a term order M in D<x,d> (DRL) */ |
|
M = newmat(N2,N2); |
|
for ( J = 0; J < N2; J++ ) |
|
M[0][J] = 1; |
|
for ( I = 1; I < N2; I++ ) |
|
M[I][N2-I] = -1; |
|
|
|
VDV = append(V,DV); |
|
|
|
/* create a non-term order MW in D<x,d> */ |
|
MW = newmat(N2+1,N2); |
|
for ( J = 0; J < N; J++ ) |
|
MW[0][J] = -W[J]; |
|
for ( ; J < N2; J++ ) |
|
MW[0][J] = W[J-N]; |
|
for ( I = 1; I <= N2; I++ ) |
|
for ( J = 0; J < N2; J++ ) |
|
MW[I][J] = M[I-1][J]; |
|
|
|
/* create a homogenized term order MWH in D<x,d,h> */ |
|
MWH = newmat(N2+2,N2+1); |
|
for ( J = 0; J <= N2; J++ ) |
|
MWH[0][J] = 1; |
|
for ( I = 1; I <= N2+1; I++ ) |
|
for ( J = 0; J < N2; J++ ) |
|
MWH[I][J] = MW[I-1][J]; |
|
|
|
/* homogenize F */ |
|
VDVH = append(VDV,[h]); |
|
FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH); |
|
|
|
/* compute a groebner basis of FH w.r.t. MWH */ |
|
dp_gr_flags(["Top",1,"NoRA",1]); |
|
GH = dp_weyl_gr_main(FH,VDVH,0,1,11); |
|
dp_gr_flags(["Top",0,"NoRA",0]); |
|
|
|
/* dehomigenize GH */ |
|
G = map(subst,GH,h,1); |
|
|
|
/* G is a groebner basis w.r.t. a non term order MW */ |
|
/* take the initial part w.r.t. (-W,W) */ |
|
GIN = map(initial_part,G,VDV,MW,W); |
|
|
|
/* GIN is a groebner basis w.r.t. a term order M */ |
|
/* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */ |
|
|
|
/* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */ |
|
for ( I = 0, T = 0; I < N; I++ ) |
|
T += W[I]*V[I]*DV[I]; |
|
B = weyl_minipoly(GIN,VDV,0,T); /* M represents DRL order */ |
|
return B; |
|
} |
|
|
|
/* all term reduction + interreduce */ |
|
def generic_bfct_1(F,V,DV,W) |
|
{ |
|
N = length(V); |
|
N2 = N*2; |
|
|
|
/* If W is a list, convert it to a vector */ |
|
if ( type(W) == 4 ) |
|
W = newvect(length(W),W); |
|
dp_weyl_set_weight(W); |
|
|
|
/* create a term order M in D<x,d> (DRL) */ |
|
M = newmat(N2,N2); |
|
for ( J = 0; J < N2; J++ ) |
|
M[0][J] = 1; |
|
for ( I = 1; I < N2; I++ ) |
|
M[I][N2-I] = -1; |
|
|
|
VDV = append(V,DV); |
|
|
|
/* create a non-term order MW in D<x,d> */ |
|
MW = newmat(N2+1,N2); |
|
for ( J = 0; J < N; J++ ) |
|
MW[0][J] = -W[J]; |
|
for ( ; J < N2; J++ ) |
|
MW[0][J] = W[J-N]; |
|
for ( I = 1; I <= N2; I++ ) |
|
for ( J = 0; J < N2; J++ ) |
|
MW[I][J] = M[I-1][J]; |
|
|
|
/* create a homogenized term order MWH in D<x,d,h> */ |
|
MWH = newmat(N2+2,N2+1); |
|
for ( J = 0; J <= N2; J++ ) |
|
MWH[0][J] = 1; |
|
for ( I = 1; I <= N2+1; I++ ) |
|
for ( J = 0; J < N2; J++ ) |
|
MWH[I][J] = MW[I-1][J]; |
|
|
|
/* homogenize F */ |
|
VDVH = append(VDV,[h]); |
|
FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH); |
|
|
|
/* compute a groebner basis of FH w.r.t. MWH */ |
|
/* dp_gr_flags(["Top",1,"NoRA",1]); */ |
|
GH = dp_weyl_gr_main(FH,VDVH,0,1,11); |
|
/* dp_gr_flags(["Top",0,"NoRA",0]); */ |
|
|
|
/* dehomigenize GH */ |
|
G = map(subst,GH,h,1); |
|
|
|
/* G is a groebner basis w.r.t. a non term order MW */ |
|
/* take the initial part w.r.t. (-W,W) */ |
|
GIN = map(initial_part,G,VDV,MW,W); |
|
|
|
/* GIN is a groebner basis w.r.t. a term order M */ |
|
/* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */ |
|
|
|
/* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */ |
|
for ( I = 0, T = 0; I < N; I++ ) |
|
T += W[I]*V[I]*DV[I]; |
|
B = weyl_minipoly(GIN,VDV,0,T); /* M represents DRL order */ |
|
return B; |
|
} |
|
|
|
def initial_part(F,V,MW,W) |
|
{ |
|
N2 = length(V); |
|
N = N2/2; |
|
dp_ord(MW); |
|
DF = dp_ptod(F,V); |
|
R = dp_hm(DF); |
|
DF = dp_rest(DF); |
|
|
|
E = dp_etov(R); |
|
for ( I = 0, TW = 0; I < N; I++ ) |
|
TW += W[I]*(-E[I]+E[N+I]); |
|
RW = TW; |
|
|
|
for ( ; DF; DF = dp_rest(DF) ) { |
|
E = dp_etov(DF); |
|
for ( I = 0, TW = 0; I < N; I++ ) |
|
TW += W[I]*(-E[I]+E[N+I]); |
|
if ( TW == RW ) |
|
R += dp_hm(DF); |
|
else if ( TW < RW ) |
|
break; |
|
else |
|
error("initial_part : cannot happen"); |
|
} |
|
return dp_dtop(R,V); |
|
|
|
} |
|
|
/* b-function of F ? */ |
/* b-function of F ? */ |
|
|
def bfct(F) |
def bfct(F) |
{ |
{ |
|
/* XXX */ |
|
F = replace_vars_f(F); |
|
|
V = vars(F); |
V = vars(F); |
N = length(V); |
N = length(V); |
D = newvect(N); |
D = newvect(N); |
|
|
return Minipoly; |
return Minipoly; |
} |
} |
|
|
|
/* called from bfct() only */ |
|
|
|
def indicial1(F,V) |
|
{ |
|
W = append([y1,t],V); |
|
N = length(V); |
|
B = [t-y1*F]; |
|
for ( I = N-1, DV = []; I >= 0; I-- ) |
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
DW = append([dy1,dt],DV); |
|
for ( I = 0; I < N; I++ ) { |
|
B = cons(DV[I]+y1*diff(F,V[I])*dt,B); |
|
} |
|
dp_nelim(1); |
|
|
|
/* homogenized (heuristics) */ |
|
G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6); |
|
G1 = map(subst,G0,y1,1); |
|
G2 = map(psi,G1,t,dt); |
|
G3 = map(subst,G2,t,-s-1); |
|
return G3; |
|
} |
|
|
|
/* b-function computation via generic_bfct() (experimental) */ |
|
|
|
def bfct_via_gbfct(F) |
|
{ |
|
V = vars(F); |
|
N = length(V); |
|
D = newvect(N); |
|
|
|
for ( I = 0; I < N; I++ ) |
|
D[I] = [deg(F,V[I]),V[I]]; |
|
qsort(D,compare_first); |
|
for ( V = [], I = 0; I < N; I++ ) |
|
V = cons(D[I][1],V); |
|
V = reverse(V); |
|
for ( I = N-1, DV = []; I >= 0; I-- ) |
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
|
|
B = [TMP_T-F]; |
|
for ( I = 0; I < N; I++ ) { |
|
B = cons(DV[I]+diff(F,V[I])*TMP_DT,B); |
|
} |
|
V1 = cons(TMP_T,V); DV1 = cons(TMP_DT,DV); |
|
W = newvect(N+1); |
|
W[0] = 1; |
|
R = generic_bfct(B,V1,DV1,W); |
|
|
|
return subst(R,s,-s-1); |
|
} |
|
|
|
/* use an order s.t. [t,x,y,z,...,dt,dx,dy,dz,...,h] */ |
|
|
|
def bfct_via_gbfct_weight(F,V) |
|
{ |
|
N = length(V); |
|
D = newvect(N); |
|
Wt = getopt(weight); |
|
if ( type(Wt) != 4 ) { |
|
for ( I = 0, Wt = []; I < N; I++ ) |
|
Wt = cons(1,Wt); |
|
} |
|
Tdeg = w_tdeg(F,V,Wt); |
|
WtV = newvect(2*(N+1)+1); |
|
WtV[0] = Tdeg; |
|
WtV[N+1] = 1; |
|
/* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */ |
|
for ( I = 1; I <= N; I++ ) { |
|
WtV[I] = Wt[I-1]; |
|
WtV[N+1+I] = Tdeg-Wt[I-1]+1; |
|
} |
|
WtV[2*(N+1)] = 1; |
|
dp_set_weight(WtV); |
|
for ( I = N-1, DV = []; I >= 0; I-- ) |
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
|
|
B = [TMP_T-F]; |
|
for ( I = 0; I < N; I++ ) { |
|
B = cons(DV[I]+diff(F,V[I])*TMP_DT,B); |
|
} |
|
V1 = cons(TMP_T,V); DV1 = cons(TMP_DT,DV); |
|
W = newvect(N+1); |
|
W[0] = 1; |
|
R = generic_bfct_1(B,V1,DV1,W); |
|
dp_set_weight(0); |
|
return subst(R,s,-s-1); |
|
} |
|
|
|
/* use an order s.t. [x,y,z,...,t,dx,dy,dz,...,dt,h] */ |
|
|
|
def bfct_via_gbfct_weight_1(F,V) |
|
{ |
|
N = length(V); |
|
D = newvect(N); |
|
Wt = getopt(weight); |
|
if ( type(Wt) != 4 ) { |
|
for ( I = 0, Wt = []; I < N; I++ ) |
|
Wt = cons(1,Wt); |
|
} |
|
Tdeg = w_tdeg(F,V,Wt); |
|
WtV = newvect(2*(N+1)+1); |
|
/* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */ |
|
for ( I = 0; I < N; I++ ) { |
|
WtV[I] = Wt[I]; |
|
WtV[N+1+I] = Tdeg-Wt[I]+1; |
|
} |
|
WtV[N] = Tdeg; |
|
WtV[2*N+1] = 1; |
|
WtV[2*(N+1)] = 1; |
|
dp_set_weight(WtV); |
|
for ( I = N-1, DV = []; I >= 0; I-- ) |
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
|
|
B = [TMP_T-F]; |
|
for ( I = 0; I < N; I++ ) { |
|
B = cons(DV[I]+diff(F,V[I])*TMP_DT,B); |
|
} |
|
V1 = append(V,[TMP_T]); DV1 = append(DV,[TMP_DT]); |
|
W = newvect(N+1); |
|
W[N] = 1; |
|
R = generic_bfct_1(B,V1,DV1,W); |
|
dp_set_weight(0); |
|
return subst(R,s,-s-1); |
|
} |
|
|
|
def bfct_via_gbfct_weight_2(F,V) |
|
{ |
|
N = length(V); |
|
D = newvect(N); |
|
Wt = getopt(weight); |
|
if ( type(Wt) != 4 ) { |
|
for ( I = 0, Wt = []; I < N; I++ ) |
|
Wt = cons(1,Wt); |
|
} |
|
Tdeg = w_tdeg(F,V,Wt); |
|
|
|
/* a weight for the first GB computation */ |
|
/* [t,x1,...,xn,dt,dx1,...,dxn,h] */ |
|
WtV = newvect(2*(N+1)+1); |
|
WtV[0] = Tdeg; |
|
WtV[N+1] = 1; |
|
WtV[2*(N+1)] = 1; |
|
/* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */ |
|
for ( I = 1; I <= N; I++ ) { |
|
WtV[I] = Wt[I-1]; |
|
WtV[N+1+I] = Tdeg-Wt[I-1]+1; |
|
} |
|
dp_set_weight(WtV); |
|
|
|
/* a weight for the second GB computation */ |
|
/* [x1,...,xn,t,dx1,...,dxn,dt,h] */ |
|
WtV2 = newvect(2*(N+1)+1); |
|
WtV2[N] = Tdeg; |
|
WtV2[2*N+1] = 1; |
|
WtV2[2*(N+1)] = 1; |
|
for ( I = 0; I < N; I++ ) { |
|
WtV2[I] = Wt[I]; |
|
WtV2[N+1+I] = Tdeg-Wt[I]+1; |
|
} |
|
|
|
for ( I = N-1, DV = []; I >= 0; I-- ) |
|
DV = cons(strtov("d"+rtostr(V[I])),DV); |
|
|
|
B = [TMP_T-F]; |
|
for ( I = 0; I < N; I++ ) { |
|
B = cons(DV[I]+diff(F,V[I])*TMP_DT,B); |
|
} |
|
V1 = cons(TMP_T,V); DV1 = cons(TMP_DT,DV); |
|
V2 = append(V,[TMP_T]); DV2 = append(DV,[TMP_DT]); |
|
W = newvect(N+1,[1]); |
|
dp_weyl_set_weight(W); |
|
|
|
VDV = append(V1,DV1); |
|
N1 = length(V1); |
|
N2 = N1*2; |
|
|
|
/* create a non-term order MW in D<x,d> */ |
|
MW = newmat(N2+1,N2); |
|
for ( J = 0; J < N1; J++ ) { |
|
MW[0][J] = -W[J]; MW[0][N1+J] = W[J]; |
|
} |
|
for ( J = 0; J < N2; J++ ) MW[1][J] = 1; |
|
for ( I = 2; I <= N2; I++ ) MW[I][N2-I+1] = -1; |
|
|
|
/* homogenize F */ |
|
VDVH = append(VDV,[h]); |
|
FH = map(dp_dtop,map(dp_homo,map(dp_ptod,B,VDV)),VDVH); |
|
|
|
/* compute a groebner basis of FH w.r.t. MWH */ |
|
GH = dp_weyl_gr_main(FH,VDVH,0,1,11); |
|
|
|
/* dehomigenize GH */ |
|
G = map(subst,GH,h,1); |
|
|
|
/* G is a groebner basis w.r.t. a non term order MW */ |
|
/* take the initial part w.r.t. (-W,W) */ |
|
GIN = map(initial_part,G,VDV,MW,W); |
|
|
|
/* GIN is a groebner basis w.r.t. a term order M */ |
|
/* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */ |
|
|
|
/* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */ |
|
for ( I = 0, T = 0; I < N1; I++ ) |
|
T += W[I]*V1[I]*DV1[I]; |
|
|
|
/* change of ordering from VDV to VDV2 */ |
|
VDV2 = append(V2,DV2); |
|
dp_set_weight(WtV2); |
|
for ( Pind = 0; ; Pind++ ) { |
|
Prime = lprime(Pind); |
|
GIN2 = dp_weyl_gr_main(GIN,VDV2,0,-Prime,0); |
|
if ( GIN2 ) break; |
|
} |
|
|
|
R = weyl_minipoly(GIN2,VDV2,0,T); /* M represents DRL order */ |
|
dp_set_weight(0); |
|
return subst(R,s,-s-1); |
|
} |
|
|
|
/* minimal polynomial of s; modular computation */ |
|
|
def weyl_minipolym(G,V,O,M,V0) |
def weyl_minipolym(G,V,O,M,V0) |
{ |
{ |
N = length(V); |
N = length(V); |
Line 249 def weyl_minipolym(G,V,O,M,V0) |
|
Line 641 def weyl_minipolym(G,V,O,M,V0) |
|
GI = cons(I,GI); |
GI = cons(I,GI); |
|
|
U = dp_mod(dp_ptod(V0,V),M,[]); |
U = dp_mod(dp_ptod(V0,V),M,[]); |
|
U = dp_weyl_nf_mod(GI,U,PS,1,M); |
|
|
T = dp_mod(<<0>>,M,[]); |
T = dp_mod(<<0>>,M,[]); |
TT = dp_mod(dp_ptod(1,V),M,[]); |
TT = dp_mod(dp_ptod(1,V),M,[]); |
G = H = [[TT,T]]; |
G = H = [[TT,T]]; |
|
|
for ( I = 1; ; I++ ) { |
for ( I = 1; ; I++ ) { |
|
if ( dp_gr_print() ) |
|
print(".",2); |
T = dp_mod(<<I>>,M,[]); |
T = dp_mod(<<I>>,M,[]); |
|
|
TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M); |
TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M); |
H = cons([TT,T],H); |
H = cons([TT,T],H); |
L = dp_lnf_mod([TT,T],G,M); |
L = dp_lnf_mod([TT,T],G,M); |
if ( !L[0] ) |
if ( !L[0] ) { |
return dp_dtop(L[1],[V0]); |
if ( dp_gr_print() ) |
else |
print(""); |
|
return dp_dtop(L[1],[t]); /* XXX */ |
|
} else |
G = insert(G,L); |
G = insert(G,L); |
} |
} |
} |
} |
|
|
def weyl_minipoly(G0,V0,O0,V) |
/* minimal polynomial of s over Q */ |
|
|
|
def weyl_minipoly(G0,V0,O0,P) |
{ |
{ |
HM = hmlist(G0,V0,O0); |
HM = hmlist(G0,V0,O0); |
for ( I = 0; ; I++ ) { |
|
Prime = lprime(I); |
N = length(V0); |
|
Len = length(G0); |
|
dp_ord(O0); |
|
PS = newvect(Len); |
|
for ( I = 0, T = G0, HL = []; T != []; T = cdr(T), I++ ) |
|
PS[I] = dp_ptod(car(T),V0); |
|
for ( I = Len - 1, GI = []; I >= 0; I-- ) |
|
GI = cons(I,GI); |
|
PSM = newvect(Len); |
|
DP = dp_ptod(P,V0); |
|
|
|
for ( Pind = 0; ; Pind++ ) { |
|
Prime = lprime(Pind); |
if ( !valid_modulus(HM,Prime) ) |
if ( !valid_modulus(HM,Prime) ) |
continue; |
continue; |
MP = weyl_minipolym(G0,V0,O0,Prime,V); |
setmod(Prime); |
for ( D = deg(MP,V), TL = [], J = 0; J <= D; J++ ) |
for ( I = 0, T = G0, HL = []; T != []; T = cdr(T), I++ ) |
TL = cons(V^J,TL); |
PSM[I] = dp_mod(dp_ptod(car(T),V0),Prime,[]); |
dp_ord(O0); |
|
NF = weyl_gennf(G0,TL,V0,O0)[0]; |
|
|
|
LHS = weyl_nf_tab(-car(TL),NF,V0); |
NFP = weyl_nf(GI,DP,1,PS); |
B = weyl_hen_ttob(cdr(TL),NF,LHS,V0,Prime); |
NFPM = dp_mod(NFP[0],Prime,[])/ptomp(NFP[1],Prime); |
if ( B ) { |
|
R = ptozp(B[1]*car(TL)+B[0]); |
NF = [[dp_ptod(1,V0),1]]; |
return R; |
LCM = 1; |
|
|
|
TM = dp_mod(<<0>>,Prime,[]); |
|
TTM = dp_mod(dp_ptod(1,V0),Prime,[]); |
|
GM = NFM = [[TTM,TM]]; |
|
|
|
for ( D = 1; ; D++ ) { |
|
if ( dp_gr_print() ) |
|
print(".",2); |
|
NFPrev = car(NF); |
|
NFJ = weyl_nf(GI, |
|
dp_weyl_mul(NFP[0],NFPrev[0]),NFP[1]*NFPrev[1],PS); |
|
NFJ = remove_cont(NFJ); |
|
NF = cons(NFJ,NF); |
|
LCM = ilcm(LCM,NFJ[1]); |
|
|
|
/* modular computation */ |
|
TM = dp_mod(<<D>>,Prime,[]); |
|
TTM = dp_mod(NFJ[0],Prime,[])/ptomp(NFJ[1],Prime); |
|
NFM = cons([TTM,TM],NFM); |
|
LM = dp_lnf_mod([TTM,TM],GM,Prime); |
|
if ( !LM[0] ) |
|
break; |
|
else |
|
GM = insert(GM,LM); |
} |
} |
} |
|
} |
|
|
|
def weyl_gennf(G,TL,V,O) |
if ( dp_gr_print() ) |
{ |
print(""); |
N = length(V); Len = length(G); dp_ord(O); PS = newvect(Len); |
U = NF[0][0]*idiv(LCM,NF[0][1]); |
for ( I = 0, T = G, HL = []; T != []; T = cdr(T), I++ ) { |
Coef = []; |
PS[I] = dp_ptod(car(T),V); HL = cons(dp_ht(PS[I]),HL); |
for ( J = D-1; J >= 0; J-- ) { |
} |
Coef = cons(strtov("u"+rtostr(J)),Coef); |
for ( I = 0, DTL = []; TL != []; TL = cdr(TL) ) |
U += car(Coef)*NF[D-J][0]*idiv(LCM,NF[D-J][1]); |
DTL = cons(dp_ptod(car(TL),V),DTL); |
} |
for ( I = Len - 1, GI = []; I >= 0; I-- ) |
|
GI = cons(I,GI); |
|
T = car(DTL); DTL = cdr(DTL); |
|
H = [weyl_nf(GI,T,T,PS)]; |
|
|
|
T0 = time()[0]; |
for ( UU = U, Eq = []; UU; UU = dp_rest(UU) ) |
while ( DTL != [] ) { |
Eq = cons(dp_hc(UU),Eq); |
T = car(DTL); DTL = cdr(DTL); |
M = etom([Eq,Coef]); |
|
B = henleq(M,Prime); |
if ( dp_gr_print() ) |
if ( dp_gr_print() ) |
print(".",2); |
print(""); |
if ( L = search_redble(T,H) ) { |
if ( B ) { |
DD = dp_subd(T,L[1]); |
R = 0; |
NF = weyl_nf(GI,dp_weyl_mul(L[0],dp_subd(T,L[1])),dp_hc(L[1])*T,PS); |
for ( I = 0; I < D; I++ ) |
} else |
R += B[0][I]*s^I; |
NF = weyl_nf(GI,T,T,PS); |
R += B[1]*s^D; |
NF = remove_cont(NF); |
return R; |
H = cons(NF,H); |
} |
} |
} |
print(""); |
|
TNF = time()[0]-T0; |
|
if ( dp_gr_print() ) |
|
print("gennf(TAB="+rtostr(TTAB)+" NF="+rtostr(TNF)+")"); |
|
return [H,PS,GI]; |
|
} |
} |
|
|
def weyl_nf(B,G,M,PS) |
def weyl_nf(B,G,M,PS) |
Line 366 def weyl_nf_mod(B,G,PS,Mod) |
|
Line 789 def weyl_nf_mod(B,G,PS,Mod) |
|
return D; |
return D; |
} |
} |
|
|
def weyl_hen_ttob(T,NF,LHS,V,MOD) |
|
{ |
|
T0 = time()[0]; M = etom(weyl_leq_nf(T,NF,LHS,V)); TE = time()[0] - T0; |
|
T0 = time()[0]; U = henleq(M,MOD); TH = time()[0] - T0; |
|
if ( dp_gr_print() ) { |
|
print("(etom="+rtostr(TE)+" hen="+rtostr(TH)+")"); |
|
} |
|
return U ? vtop(T,U,LHS) : 0; |
|
} |
|
|
|
def weyl_leq_nf(TL,NF,LHS,V) |
|
{ |
|
TLen = length(NF); |
|
T = newvect(TLen); M = newvect(TLen); |
|
for ( I = 0; I < TLen; I++ ) { |
|
T[I] = dp_ht(NF[I][1]); |
|
M[I] = dp_hc(NF[I][1]); |
|
} |
|
Len = length(TL); INDEX = newvect(Len); COEF = newvect(Len); |
|
for ( L = TL, J = 0; L != []; L = cdr(L), J++ ) { |
|
D = dp_ptod(car(L),V); |
|
for ( I = 0; I < TLen; I++ ) |
|
if ( D == T[I] ) |
|
break; |
|
INDEX[J] = I; COEF[J] = strtov("u"+rtostr(J)); |
|
} |
|
if ( !LHS ) { |
|
COEF[0] = 1; NM = 0; DN = 1; |
|
} else { |
|
NM = LHS[0]; DN = LHS[1]; |
|
} |
|
for ( J = 0, S = -NM; J < Len; J++ ) { |
|
DNJ = M[INDEX[J]]; |
|
GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD; |
|
S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J]; |
|
DN *= CS; |
|
} |
|
for ( D = S, E = []; D; D = dp_rest(D) ) |
|
E = cons(dp_hc(D),E); |
|
BOUND = LHS ? 0 : 1; |
|
for ( I = Len - 1, W = []; I >= BOUND; I-- ) |
|
W = cons(COEF[I],W); |
|
return [E,W]; |
|
} |
|
|
|
def weyl_nf_tab(A,NF,V) |
|
{ |
|
TLen = length(NF); |
|
T = newvect(TLen); M = newvect(TLen); |
|
for ( I = 0; I < TLen; I++ ) { |
|
T[I] = dp_ht(NF[I][1]); |
|
M[I] = dp_hc(NF[I][1]); |
|
} |
|
A = dp_ptod(A,V); |
|
for ( Z = A, Len = 0; Z; Z = dp_rest(Z), Len++ ); |
|
INDEX = newvect(Len); COEF = newvect(Len); |
|
for ( Z = A, J = 0; Z; Z = dp_rest(Z), J++ ) { |
|
D = dp_ht(Z); |
|
for ( I = 0; I < TLen; I++ ) |
|
if ( D == T[I] ) |
|
break; |
|
INDEX[J] = I; COEF[J] = dp_hc(Z); |
|
} |
|
for ( J = 0, S = 0, DN = 1; J < Len; J++ ) { |
|
DNJ = M[INDEX[J]]; |
|
GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD; |
|
S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J]; |
|
DN *= CS; |
|
} |
|
return [S,DN]; |
|
} |
|
|
|
def remove_zero(L) |
def remove_zero(L) |
{ |
{ |
for ( R = []; L != []; L = cdr(L) ) |
for ( R = []; L != []; L = cdr(L) ) |
|
|
return S; |
return S; |
} |
} |
|
|
def member(A,L) { |
|
for ( ; L != []; L = cdr(L) ) |
|
if ( A == car(L) ) |
|
return 1; |
|
return 0; |
|
} |
|
|
|
def intersection(A,B) |
def intersection(A,B) |
{ |
{ |
for ( L = []; A != []; A = cdr(A) ) |
for ( L = []; A != []; A = cdr(A) ) |
Line 491 def v_factorial(V,N) |
|
Line 835 def v_factorial(V,N) |
|
{ |
{ |
for ( J = N-1, R = 1; J >= 0; J-- ) |
for ( J = N-1, R = 1; J >= 0; J-- ) |
R *= V-J; |
R *= V-J; |
|
return R; |
|
} |
|
|
|
def w_tdeg(F,V,W) |
|
{ |
|
dp_set_weight(newvect(length(W),W)); |
|
T = dp_ptod(F,V); |
|
for ( R = 0; T; T = cdr(T) ) { |
|
D = dp_td(T); |
|
if ( D > R ) R = D; |
|
} |
|
return R; |
|
} |
|
|
|
def replace_vars_f(F) |
|
{ |
|
return subst(F,s,TMP_S,t,TMP_T,y1,TMP_Y1,y2,TMP_Y2); |
|
} |
|
|
|
def replace_vars_v(V) |
|
{ |
|
V = replace_var(V,s,TMP_S); |
|
V = replace_var(V,t,TMP_T); |
|
V = replace_var(V,y1,TMP_Y1); |
|
V = replace_var(V,y2,TMP_Y2); |
|
return V; |
|
} |
|
|
|
def replace_var(V,X,Y) |
|
{ |
|
V = reverse(V); |
|
for ( R = []; V != []; V = cdr(V) ) { |
|
Z = car(V); |
|
if ( Z == X ) |
|
R = cons(Y,R); |
|
else |
|
R = cons(Z,R); |
|
} |
return R; |
return R; |
} |
} |
end$ |
end$ |