Annotation of OpenXM_contrib2/asir2000/lib/bfct, Revision 1.26
1.2 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.3 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.26 ! takayama 48: * $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.25 2003/04/28 03:02:52 noro Exp $
1.10 noro 49: */
1.1 noro 50: /* requires 'primdec' */
1.22 noro 51:
1.23 noro 52: #define TMP_S ssssssss
1.24 noro 53: #define TMP_DS dssssssss
54: #define TMP_T dtttttttt
55: #define TMP_DT tttttttt
1.23 noro 56: #define TMP_Y1 yyyyyyyy1
1.24 noro 57: #define TMP_DY1 dyyyyyyyy1
1.23 noro 58: #define TMP_Y2 yyyyyyyy2
1.24 noro 59: #define TMP_DY2 dyyyyyyyy2
1.23 noro 60:
1.26 ! takayama 61: if (!module_definedp("gr")) load("gr") $$
! 62: if (!module_definedp("primdec")) load("primdec") $$
! 63: module bfct $
! 64: /* Empty for now. It will be used in a future. */
! 65: endmodule $
1.22 noro 66:
67: /* toplevel */
68:
69: def bfunction(F)
70: {
71: V = vars(F);
72: N = length(V);
73: D = newvect(N);
74:
75: for ( I = 0; I < N; I++ )
76: D[I] = [deg(F,V[I]),V[I]];
77: qsort(D,compare_first);
78: for ( V = [], I = 0; I < N; I++ )
79: V = cons(D[I][1],V);
80: return bfct_via_gbfct_weight(F,V);
81: }
1.1 noro 82:
1.6 noro 83: /* annihilating ideal of F^s */
1.1 noro 84:
85: def ann(F)
86: {
1.24 noro 87: if ( member(s,vars(F)) )
88: error("ann : the variable 's' is reserved.");
1.1 noro 89: V = vars(F);
90: N = length(V);
1.8 noro 91: D = newvect(N);
92:
93: for ( I = 0; I < N; I++ )
94: D[I] = [deg(F,V[I]),V[I]];
95: qsort(D,compare_first);
96: for ( V = [], I = N-1; I >= 0; I-- )
97: V = cons(D[I][1],V);
98:
1.1 noro 99: for ( I = N-1, DV = []; I >= 0; I-- )
100: DV = cons(strtov("d"+rtostr(V[I])),DV);
1.8 noro 101:
1.24 noro 102: W = append([TMP_Y1,TMP_Y2,TMP_T],V);
103: DW = append([TMP_DY1,TMP_DY2,TMP_DT],DV);
1.8 noro 104:
1.24 noro 105: B = [1-TMP_Y1*TMP_Y2,TMP_T-TMP_Y1*F];
1.1 noro 106: for ( I = 0; I < N; I++ ) {
1.24 noro 107: B = cons(DV[I]+TMP_Y1*diff(F,V[I])*TMP_DT,B);
1.1 noro 108: }
1.10 noro 109:
110: /* homogenized (heuristics) */
1.1 noro 111: dp_nelim(2);
1.10 noro 112: G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
1.1 noro 113: G1 = [];
114: for ( T = G0; T != []; T = cdr(T) ) {
115: E = car(T); VL = vars(E);
1.24 noro 116: if ( !member(TMP_Y1,VL) && !member(TMP_Y2,VL) )
1.1 noro 117: G1 = cons(E,G1);
118: }
1.24 noro 119: G2 = map(psi,G1,TMP_T,TMP_DT);
120: G3 = map(subst,G2,TMP_T,-1-s);
1.12 noro 121: return G3;
1.1 noro 122: }
123:
1.10 noro 124: /*
125: * compute J_f|s=r, where r = the minimal integral root of global b_f(s)
126: * ann0(F) returns [MinRoot,Ideal]
127: */
128:
129: def ann0(F)
130: {
1.25 noro 131: F = subst(F,s,TMP_S);
132: Ann = ann(F);
133: Bf = bfunction(F);
1.10 noro 134:
135: FList = cdr(fctr(Bf));
136: for ( T = FList, Min = 0; T != []; T = cdr(T) ) {
137: LF = car(car(T));
138: Root = -coef(LF,0)/coef(LF,1);
139: if ( dn(Root) == 1 && Root < Min )
140: Min = Root;
141: }
1.25 noro 142: return [Min,map(subst,Ann,s,Min,TMP_S,s,TMP_DS,ds)];
1.6 noro 143: }
144:
145: def psi(F,T,DT)
146: {
147: D = dp_ptod(F,[T,DT]);
148: Wmax = weight(D);
149: D1 = dp_rest(D);
150: for ( ; D1; D1 = dp_rest(D1) )
151: if ( weight(D1) > Wmax )
152: Wmax = weight(D1);
153: for ( D1 = D, Dmax = 0; D1; D1 = dp_rest(D1) )
154: if ( weight(D1) == Wmax )
155: Dmax += dp_hm(D1);
156: if ( Wmax >= 0 )
157: Dmax = dp_weyl_mul(<<Wmax,0>>,Dmax);
158: else
159: Dmax = dp_weyl_mul(<<0,-Wmax>>,Dmax);
160: Rmax = dp_dtop(Dmax,[T,DT]);
161: R = b_subst(subst(Rmax,DT,1),T);
162: return R;
163: }
164:
165: def weight(D)
166: {
167: V = dp_etov(D);
168: return V[1]-V[0];
169: }
170:
171: def compare_first(A,B)
172: {
173: A0 = car(A);
174: B0 = car(B);
175: if ( A0 > B0 )
176: return 1;
177: else if ( A0 < B0 )
178: return -1;
179: else
180: return 0;
181: }
182:
1.13 noro 183: /* generic b-function w.r.t. weight vector W */
184:
185: def generic_bfct(F,V,DV,W)
186: {
187: N = length(V);
188: N2 = N*2;
189:
1.16 noro 190: /* If W is a list, convert it to a vector */
191: if ( type(W) == 4 )
192: W = newvect(length(W),W);
1.15 noro 193: dp_weyl_set_weight(W);
194:
1.14 noro 195: /* create a term order M in D<x,d> (DRL) */
1.13 noro 196: M = newmat(N2,N2);
197: for ( J = 0; J < N2; J++ )
198: M[0][J] = 1;
199: for ( I = 1; I < N2; I++ )
200: M[I][N2-I] = -1;
201:
202: VDV = append(V,DV);
203:
204: /* create a non-term order MW in D<x,d> */
205: MW = newmat(N2+1,N2);
206: for ( J = 0; J < N; J++ )
207: MW[0][J] = -W[J];
208: for ( ; J < N2; J++ )
209: MW[0][J] = W[J-N];
210: for ( I = 1; I <= N2; I++ )
211: for ( J = 0; J < N2; J++ )
212: MW[I][J] = M[I-1][J];
213:
214: /* create a homogenized term order MWH in D<x,d,h> */
215: MWH = newmat(N2+2,N2+1);
216: for ( J = 0; J <= N2; J++ )
217: MWH[0][J] = 1;
218: for ( I = 1; I <= N2+1; I++ )
219: for ( J = 0; J < N2; J++ )
220: MWH[I][J] = MW[I-1][J];
221:
222: /* homogenize F */
223: VDVH = append(VDV,[h]);
224: FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH);
225:
226: /* compute a groebner basis of FH w.r.t. MWH */
1.21 noro 227: dp_gr_flags(["Top",1,"NoRA",1]);
1.15 noro 228: GH = dp_weyl_gr_main(FH,VDVH,0,1,11);
1.21 noro 229: dp_gr_flags(["Top",0,"NoRA",0]);
1.13 noro 230:
231: /* dehomigenize GH */
232: G = map(subst,GH,h,1);
233:
234: /* G is a groebner basis w.r.t. a non term order MW */
235: /* take the initial part w.r.t. (-W,W) */
236: GIN = map(initial_part,G,VDV,MW,W);
237:
238: /* GIN is a groebner basis w.r.t. a term order M */
239: /* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */
240:
241: /* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */
242: for ( I = 0, T = 0; I < N; I++ )
243: T += W[I]*V[I]*DV[I];
1.14 noro 244: B = weyl_minipoly(GIN,VDV,0,T); /* M represents DRL order */
1.13 noro 245: return B;
246: }
247:
1.18 noro 248: /* all term reduction + interreduce */
249: def generic_bfct_1(F,V,DV,W)
250: {
251: N = length(V);
252: N2 = N*2;
253:
254: /* If W is a list, convert it to a vector */
255: if ( type(W) == 4 )
256: W = newvect(length(W),W);
257: dp_weyl_set_weight(W);
258:
259: /* create a term order M in D<x,d> (DRL) */
260: M = newmat(N2,N2);
261: for ( J = 0; J < N2; J++ )
262: M[0][J] = 1;
263: for ( I = 1; I < N2; I++ )
264: M[I][N2-I] = -1;
265:
266: VDV = append(V,DV);
267:
268: /* create a non-term order MW in D<x,d> */
269: MW = newmat(N2+1,N2);
270: for ( J = 0; J < N; J++ )
271: MW[0][J] = -W[J];
272: for ( ; J < N2; J++ )
273: MW[0][J] = W[J-N];
274: for ( I = 1; I <= N2; I++ )
275: for ( J = 0; J < N2; J++ )
276: MW[I][J] = M[I-1][J];
277:
278: /* create a homogenized term order MWH in D<x,d,h> */
279: MWH = newmat(N2+2,N2+1);
280: for ( J = 0; J <= N2; J++ )
281: MWH[0][J] = 1;
282: for ( I = 1; I <= N2+1; I++ )
283: for ( J = 0; J < N2; J++ )
284: MWH[I][J] = MW[I-1][J];
285:
286: /* homogenize F */
287: VDVH = append(VDV,[h]);
288: FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH);
289:
290: /* compute a groebner basis of FH w.r.t. MWH */
291: /* dp_gr_flags(["Top",1,"NoRA",1]); */
292: GH = dp_weyl_gr_main(FH,VDVH,0,1,11);
293: /* dp_gr_flags(["Top",0,"NoRA",0]); */
294:
295: /* dehomigenize GH */
296: G = map(subst,GH,h,1);
297:
298: /* G is a groebner basis w.r.t. a non term order MW */
299: /* take the initial part w.r.t. (-W,W) */
300: GIN = map(initial_part,G,VDV,MW,W);
301:
302: /* GIN is a groebner basis w.r.t. a term order M */
303: /* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */
304:
305: /* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */
306: for ( I = 0, T = 0; I < N; I++ )
307: T += W[I]*V[I]*DV[I];
308: B = weyl_minipoly(GIN,VDV,0,T); /* M represents DRL order */
309: return B;
310: }
311:
1.13 noro 312: def initial_part(F,V,MW,W)
313: {
314: N2 = length(V);
315: N = N2/2;
316: dp_ord(MW);
317: DF = dp_ptod(F,V);
318: R = dp_hm(DF);
319: DF = dp_rest(DF);
320:
321: E = dp_etov(R);
322: for ( I = 0, TW = 0; I < N; I++ )
323: TW += W[I]*(-E[I]+E[N+I]);
324: RW = TW;
325:
326: for ( ; DF; DF = dp_rest(DF) ) {
327: E = dp_etov(DF);
328: for ( I = 0, TW = 0; I < N; I++ )
329: TW += W[I]*(-E[I]+E[N+I]);
330: if ( TW == RW )
331: R += dp_hm(DF);
332: else if ( TW < RW )
333: break;
334: else
335: error("initial_part : cannot happen");
336: }
337: return dp_dtop(R,V);
338:
339: }
340:
1.1 noro 341: /* b-function of F ? */
342:
343: def bfct(F)
344: {
1.23 noro 345: /* XXX */
346: F = replace_vars_f(F);
347:
1.1 noro 348: V = vars(F);
349: N = length(V);
1.6 noro 350: D = newvect(N);
1.7 noro 351:
1.6 noro 352: for ( I = 0; I < N; I++ )
353: D[I] = [deg(F,V[I]),V[I]];
354: qsort(D,compare_first);
355: for ( V = [], I = 0; I < N; I++ )
356: V = cons(D[I][1],V);
1.1 noro 357: for ( I = N-1, DV = []; I >= 0; I-- )
358: DV = cons(strtov("d"+rtostr(V[I])),DV);
1.6 noro 359: V1 = cons(s,V); DV1 = cons(ds,DV);
1.7 noro 360:
361: G0 = indicial1(F,reverse(V));
362: G1 = dp_weyl_gr_main(G0,append(V1,DV1),0,1,0);
363: Minipoly = weyl_minipoly(G1,append(V1,DV1),0,s);
1.6 noro 364: return Minipoly;
365: }
366:
1.24 noro 367: /* called from bfct() only */
368:
369: def indicial1(F,V)
370: {
371: W = append([y1,t],V);
372: N = length(V);
373: B = [t-y1*F];
374: for ( I = N-1, DV = []; I >= 0; I-- )
375: DV = cons(strtov("d"+rtostr(V[I])),DV);
376: DW = append([dy1,dt],DV);
377: for ( I = 0; I < N; I++ ) {
378: B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
379: }
380: dp_nelim(1);
381:
382: /* homogenized (heuristics) */
383: G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
384: G1 = map(subst,G0,y1,1);
385: G2 = map(psi,G1,t,dt);
386: G3 = map(subst,G2,t,-s-1);
387: return G3;
388: }
389:
1.14 noro 390: /* b-function computation via generic_bfct() (experimental) */
391:
392: def bfct_via_gbfct(F)
393: {
394: V = vars(F);
395: N = length(V);
396: D = newvect(N);
397:
398: for ( I = 0; I < N; I++ )
399: D[I] = [deg(F,V[I]),V[I]];
400: qsort(D,compare_first);
401: for ( V = [], I = 0; I < N; I++ )
402: V = cons(D[I][1],V);
403: V = reverse(V);
404: for ( I = N-1, DV = []; I >= 0; I-- )
405: DV = cons(strtov("d"+rtostr(V[I])),DV);
406:
1.24 noro 407: B = [TMP_T-F];
1.14 noro 408: for ( I = 0; I < N; I++ ) {
1.24 noro 409: B = cons(DV[I]+diff(F,V[I])*TMP_DT,B);
1.14 noro 410: }
1.24 noro 411: V1 = cons(TMP_T,V); DV1 = cons(TMP_DT,DV);
1.14 noro 412: W = newvect(N+1);
413: W[0] = 1;
1.21 noro 414: R = generic_bfct(B,V1,DV1,W);
1.14 noro 415:
416: return subst(R,s,-s-1);
417: }
418:
1.17 noro 419: /* use an order s.t. [t,x,y,z,...,dt,dx,dy,dz,...,h] */
420:
421: def bfct_via_gbfct_weight(F,V)
422: {
423: N = length(V);
424: D = newvect(N);
425: Wt = getopt(weight);
1.18 noro 426: if ( type(Wt) != 4 ) {
427: for ( I = 0, Wt = []; I < N; I++ )
428: Wt = cons(1,Wt);
429: }
430: Tdeg = w_tdeg(F,V,Wt);
431: WtV = newvect(2*(N+1)+1);
432: WtV[0] = Tdeg;
433: WtV[N+1] = 1;
434: /* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */
435: for ( I = 1; I <= N; I++ ) {
436: WtV[I] = Wt[I-1];
437: WtV[N+1+I] = Tdeg-Wt[I-1]+1;
1.17 noro 438: }
1.18 noro 439: WtV[2*(N+1)] = 1;
440: dp_set_weight(WtV);
1.17 noro 441: for ( I = N-1, DV = []; I >= 0; I-- )
442: DV = cons(strtov("d"+rtostr(V[I])),DV);
443:
1.24 noro 444: B = [TMP_T-F];
1.17 noro 445: for ( I = 0; I < N; I++ ) {
1.24 noro 446: B = cons(DV[I]+diff(F,V[I])*TMP_DT,B);
1.17 noro 447: }
1.24 noro 448: V1 = cons(TMP_T,V); DV1 = cons(TMP_DT,DV);
1.17 noro 449: W = newvect(N+1);
450: W[0] = 1;
1.18 noro 451: R = generic_bfct_1(B,V1,DV1,W);
452: dp_set_weight(0);
1.17 noro 453: return subst(R,s,-s-1);
454: }
455:
456: /* use an order s.t. [x,y,z,...,t,dx,dy,dz,...,dt,h] */
457:
458: def bfct_via_gbfct_weight_1(F,V)
459: {
460: N = length(V);
461: D = newvect(N);
462: Wt = getopt(weight);
1.18 noro 463: if ( type(Wt) != 4 ) {
464: for ( I = 0, Wt = []; I < N; I++ )
465: Wt = cons(1,Wt);
466: }
467: Tdeg = w_tdeg(F,V,Wt);
468: WtV = newvect(2*(N+1)+1);
469: /* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */
470: for ( I = 0; I < N; I++ ) {
471: WtV[I] = Wt[I];
472: WtV[N+1+I] = Tdeg-Wt[I]+1;
1.17 noro 473: }
1.18 noro 474: WtV[N] = Tdeg;
475: WtV[2*N+1] = 1;
476: WtV[2*(N+1)] = 1;
477: dp_set_weight(WtV);
1.17 noro 478: for ( I = N-1, DV = []; I >= 0; I-- )
479: DV = cons(strtov("d"+rtostr(V[I])),DV);
480:
1.24 noro 481: B = [TMP_T-F];
1.17 noro 482: for ( I = 0; I < N; I++ ) {
1.24 noro 483: B = cons(DV[I]+diff(F,V[I])*TMP_DT,B);
1.17 noro 484: }
1.24 noro 485: V1 = append(V,[TMP_T]); DV1 = append(DV,[TMP_DT]);
1.17 noro 486: W = newvect(N+1);
487: W[N] = 1;
1.21 noro 488: R = generic_bfct_1(B,V1,DV1,W);
1.19 noro 489: dp_set_weight(0);
490: return subst(R,s,-s-1);
491: }
492:
493: def bfct_via_gbfct_weight_2(F,V)
494: {
495: N = length(V);
496: D = newvect(N);
497: Wt = getopt(weight);
498: if ( type(Wt) != 4 ) {
499: for ( I = 0, Wt = []; I < N; I++ )
500: Wt = cons(1,Wt);
501: }
502: Tdeg = w_tdeg(F,V,Wt);
503:
504: /* a weight for the first GB computation */
505: /* [t,x1,...,xn,dt,dx1,...,dxn,h] */
506: WtV = newvect(2*(N+1)+1);
507: WtV[0] = Tdeg;
508: WtV[N+1] = 1;
509: WtV[2*(N+1)] = 1;
510: /* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */
511: for ( I = 1; I <= N; I++ ) {
512: WtV[I] = Wt[I-1];
513: WtV[N+1+I] = Tdeg-Wt[I-1]+1;
514: }
515: dp_set_weight(WtV);
516:
517: /* a weight for the second GB computation */
518: /* [x1,...,xn,t,dx1,...,dxn,dt,h] */
519: WtV2 = newvect(2*(N+1)+1);
520: WtV2[N] = Tdeg;
521: WtV2[2*N+1] = 1;
522: WtV2[2*(N+1)] = 1;
523: for ( I = 0; I < N; I++ ) {
524: WtV2[I] = Wt[I];
525: WtV2[N+1+I] = Tdeg-Wt[I]+1;
526: }
527:
528: for ( I = N-1, DV = []; I >= 0; I-- )
529: DV = cons(strtov("d"+rtostr(V[I])),DV);
530:
1.24 noro 531: B = [TMP_T-F];
1.19 noro 532: for ( I = 0; I < N; I++ ) {
1.24 noro 533: B = cons(DV[I]+diff(F,V[I])*TMP_DT,B);
1.19 noro 534: }
1.24 noro 535: V1 = cons(TMP_T,V); DV1 = cons(TMP_DT,DV);
536: V2 = append(V,[TMP_T]); DV2 = append(DV,[TMP_DT]);
1.19 noro 537: W = newvect(N+1,[1]);
538: dp_weyl_set_weight(W);
539:
540: VDV = append(V1,DV1);
541: N1 = length(V1);
542: N2 = N1*2;
543:
544: /* create a non-term order MW in D<x,d> */
545: MW = newmat(N2+1,N2);
546: for ( J = 0; J < N1; J++ ) {
547: MW[0][J] = -W[J]; MW[0][N1+J] = W[J];
548: }
549: for ( J = 0; J < N2; J++ ) MW[1][J] = 1;
550: for ( I = 2; I <= N2; I++ ) MW[I][N2-I+1] = -1;
551:
552: /* homogenize F */
553: VDVH = append(VDV,[h]);
554: FH = map(dp_dtop,map(dp_homo,map(dp_ptod,B,VDV)),VDVH);
555:
556: /* compute a groebner basis of FH w.r.t. MWH */
557: GH = dp_weyl_gr_main(FH,VDVH,0,1,11);
558:
559: /* dehomigenize GH */
560: G = map(subst,GH,h,1);
561:
562: /* G is a groebner basis w.r.t. a non term order MW */
563: /* take the initial part w.r.t. (-W,W) */
564: GIN = map(initial_part,G,VDV,MW,W);
565:
566: /* GIN is a groebner basis w.r.t. a term order M */
567: /* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */
568:
569: /* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */
570: for ( I = 0, T = 0; I < N1; I++ )
571: T += W[I]*V1[I]*DV1[I];
572:
573: /* change of ordering from VDV to VDV2 */
574: VDV2 = append(V2,DV2);
575: dp_set_weight(WtV2);
1.20 noro 576: for ( Pind = 0; ; Pind++ ) {
577: Prime = lprime(Pind);
578: GIN2 = dp_weyl_gr_main(GIN,VDV2,0,-Prime,0);
579: if ( GIN2 ) break;
580: }
1.19 noro 581:
582: R = weyl_minipoly(GIN2,VDV2,0,T); /* M represents DRL order */
1.18 noro 583: dp_set_weight(0);
1.17 noro 584: return subst(R,s,-s-1);
585: }
586:
1.24 noro 587: /* minimal polynomial of s; modular computation */
588:
1.6 noro 589: def weyl_minipolym(G,V,O,M,V0)
590: {
591: N = length(V);
592: Len = length(G);
593: dp_ord(O);
594: setmod(M);
595: PS = newvect(Len);
596: PS0 = newvect(Len);
597:
598: for ( I = 0, T = G; T != []; T = cdr(T), I++ )
599: PS0[I] = dp_ptod(car(T),V);
600: for ( I = 0, T = G; T != []; T = cdr(T), I++ )
601: PS[I] = dp_mod(dp_ptod(car(T),V),M,[]);
602:
603: for ( I = Len - 1, GI = []; I >= 0; I-- )
604: GI = cons(I,GI);
605:
606: U = dp_mod(dp_ptod(V0,V),M,[]);
1.17 noro 607: U = dp_weyl_nf_mod(GI,U,PS,1,M);
1.6 noro 608:
609: T = dp_mod(<<0>>,M,[]);
610: TT = dp_mod(dp_ptod(1,V),M,[]);
611: G = H = [[TT,T]];
612:
613: for ( I = 1; ; I++ ) {
1.14 noro 614: if ( dp_gr_print() )
615: print(".",2);
1.6 noro 616: T = dp_mod(<<I>>,M,[]);
617:
618: TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M);
619: H = cons([TT,T],H);
620: L = dp_lnf_mod([TT,T],G,M);
1.14 noro 621: if ( !L[0] ) {
622: if ( dp_gr_print() )
623: print("");
1.13 noro 624: return dp_dtop(L[1],[t]); /* XXX */
1.14 noro 625: } else
1.6 noro 626: G = insert(G,L);
627: }
628: }
629:
1.24 noro 630: /* minimal polynomial of s over Q */
631:
1.13 noro 632: def weyl_minipoly(G0,V0,O0,P)
1.6 noro 633: {
1.11 noro 634: HM = hmlist(G0,V0,O0);
1.13 noro 635:
636: N = length(V0);
637: Len = length(G0);
638: dp_ord(O0);
639: PS = newvect(Len);
640: for ( I = 0, T = G0, HL = []; T != []; T = cdr(T), I++ )
641: PS[I] = dp_ptod(car(T),V0);
642: for ( I = Len - 1, GI = []; I >= 0; I-- )
643: GI = cons(I,GI);
1.20 noro 644: PSM = newvect(Len);
1.13 noro 645: DP = dp_ptod(P,V0);
646:
1.20 noro 647: for ( Pind = 0; ; Pind++ ) {
648: Prime = lprime(Pind);
1.11 noro 649: if ( !valid_modulus(HM,Prime) )
650: continue;
1.20 noro 651: setmod(Prime);
652: for ( I = 0, T = G0, HL = []; T != []; T = cdr(T), I++ )
653: PSM[I] = dp_mod(dp_ptod(car(T),V0),Prime,[]);
1.13 noro 654:
655: NFP = weyl_nf(GI,DP,1,PS);
1.20 noro 656: NFPM = dp_mod(NFP[0],Prime,[])/ptomp(NFP[1],Prime);
657:
1.13 noro 658: NF = [[dp_ptod(1,V0),1]];
659: LCM = 1;
660:
1.20 noro 661: TM = dp_mod(<<0>>,Prime,[]);
662: TTM = dp_mod(dp_ptod(1,V0),Prime,[]);
663: GM = NFM = [[TTM,TM]];
664:
665: for ( D = 1; ; D++ ) {
1.14 noro 666: if ( dp_gr_print() )
667: print(".",2);
1.13 noro 668: NFPrev = car(NF);
669: NFJ = weyl_nf(GI,
670: dp_weyl_mul(NFP[0],NFPrev[0]),NFP[1]*NFPrev[1],PS);
671: NFJ = remove_cont(NFJ);
672: NF = cons(NFJ,NF);
673: LCM = ilcm(LCM,NFJ[1]);
1.20 noro 674:
675: /* modular computation */
676: TM = dp_mod(<<D>>,Prime,[]);
677: TTM = dp_mod(NFJ[0],Prime,[])/ptomp(NFJ[1],Prime);
678: NFM = cons([TTM,TM],NFM);
679: LM = dp_lnf_mod([TTM,TM],GM,Prime);
680: if ( !LM[0] )
681: break;
682: else
683: GM = insert(GM,LM);
1.13 noro 684: }
1.20 noro 685:
1.14 noro 686: if ( dp_gr_print() )
687: print("");
1.13 noro 688: U = NF[0][0]*idiv(LCM,NF[0][1]);
689: Coef = [];
690: for ( J = D-1; J >= 0; J-- ) {
691: Coef = cons(strtov("u"+rtostr(J)),Coef);
692: U += car(Coef)*NF[D-J][0]*idiv(LCM,NF[D-J][1]);
693: }
1.6 noro 694:
1.13 noro 695: for ( UU = U, Eq = []; UU; UU = dp_rest(UU) )
696: Eq = cons(dp_hc(UU),Eq);
697: M = etom([Eq,Coef]);
698: B = henleq(M,Prime);
699: if ( dp_gr_print() )
700: print("");
1.6 noro 701: if ( B ) {
1.13 noro 702: R = 0;
703: for ( I = 0; I < D; I++ )
704: R += B[0][I]*s^I;
705: R += B[1]*s^D;
1.6 noro 706: return R;
707: }
708: }
709: }
710:
711: def weyl_nf(B,G,M,PS)
712: {
713: for ( D = 0; G; ) {
714: for ( U = 0, L = B; L != []; L = cdr(L) ) {
715: if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
716: GCD = igcd(dp_hc(G),dp_hc(R));
717: CG = idiv(dp_hc(R),GCD); CR = idiv(dp_hc(G),GCD);
718: U = CG*G-dp_weyl_mul(CR*dp_subd(G,R),R);
719: if ( !U )
720: return [D,M];
721: D *= CG; M *= CG;
722: break;
723: }
724: }
725: if ( U )
726: G = U;
727: else {
728: D += dp_hm(G); G = dp_rest(G);
729: }
730: }
731: return [D,M];
732: }
733:
734: def weyl_nf_mod(B,G,PS,Mod)
735: {
736: for ( D = 0; G; ) {
737: for ( U = 0, L = B; L != []; L = cdr(L) ) {
738: if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
739: CR = dp_hc(G)/dp_hc(R);
740: U = G-dp_weyl_mul_mod(CR*dp_mod(dp_subd(G,R),Mod,[]),R,Mod);
741: if ( !U )
742: return D;
1.1 noro 743: break;
1.6 noro 744: }
745: }
746: if ( U )
747: G = U;
748: else {
749: D += dp_hm(G); G = dp_rest(G);
1.1 noro 750: }
751: }
1.6 noro 752: return D;
1.1 noro 753: }
754:
755: def remove_zero(L)
756: {
757: for ( R = []; L != []; L = cdr(L) )
758: if ( car(L) )
759: R = cons(car(L),R);
760: return R;
761: }
762:
763: def z_subst(F,V)
764: {
765: for ( ; V != []; V = cdr(V) )
766: F = subst(F,car(V),0);
767: return F;
768: }
769:
770: def flatmf(L) {
771: for ( S = []; L != []; L = cdr(L) )
772: if ( type(F=car(car(L))) != NUM )
773: S = append(S,[F]);
774: return S;
775: }
776:
777: def intersection(A,B)
778: {
779: for ( L = []; A != []; A = cdr(A) )
780: if ( member(car(A),B) )
781: L = cons(car(A),L);
782: return L;
783: }
784:
785: def b_subst(F,V)
786: {
787: D = deg(F,V);
788: C = newvect(D+1);
789: for ( I = D; I >= 0; I-- )
790: C[I] = coef(F,I,V);
791: for ( I = 0, R = 0; I <= D; I++ )
792: if ( C[I] )
793: R += C[I]*v_factorial(V,I);
794: return R;
795: }
796:
797: def v_factorial(V,N)
798: {
799: for ( J = N-1, R = 1; J >= 0; J-- )
800: R *= V-J;
1.17 noro 801: return R;
802: }
803:
804: def w_tdeg(F,V,W)
805: {
806: dp_set_weight(newvect(length(W),W));
807: T = dp_ptod(F,V);
808: for ( R = 0; T; T = cdr(T) ) {
809: D = dp_td(T);
810: if ( D > R ) R = D;
1.23 noro 811: }
812: return R;
813: }
814:
815: def replace_vars_f(F)
816: {
817: return subst(F,s,TMP_S,t,TMP_T,y1,TMP_Y1,y2,TMP_Y2);
818: }
819:
820: def replace_vars_v(V)
821: {
822: V = replace_var(V,s,TMP_S);
823: V = replace_var(V,t,TMP_T);
824: V = replace_var(V,y1,TMP_Y1);
825: V = replace_var(V,y2,TMP_Y2);
826: return V;
827: }
828:
829: def replace_var(V,X,Y)
830: {
831: V = reverse(V);
832: for ( R = []; V != []; V = cdr(V) ) {
833: Z = car(V);
834: if ( Z == X )
835: R = cons(Y,R);
836: else
837: R = cons(Z,R);
1.17 noro 838: }
1.1 noro 839: return R;
840: }
841: end$
842:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>