Annotation of OpenXM_contrib2/asir2000/lib/bfct, Revision 1.19
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.19 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.18 2002/01/28 02:42:27 noro Exp $
1.10 noro 49: */
1.1 noro 50: /* requires 'primdec' */
51:
1.6 noro 52: /* annihilating ideal of F^s */
1.1 noro 53:
54: def ann(F)
55: {
56: V = vars(F);
57: N = length(V);
1.8 noro 58: D = newvect(N);
59:
60: for ( I = 0; I < N; I++ )
61: D[I] = [deg(F,V[I]),V[I]];
62: qsort(D,compare_first);
63: for ( V = [], I = N-1; I >= 0; I-- )
64: V = cons(D[I][1],V);
65:
1.1 noro 66: for ( I = N-1, DV = []; I >= 0; I-- )
67: DV = cons(strtov("d"+rtostr(V[I])),DV);
1.8 noro 68:
69: W = append([y1,y2,t],V);
1.1 noro 70: DW = append([dy1,dy2,dt],DV);
1.8 noro 71:
72: B = [1-y1*y2,t-y1*F];
1.1 noro 73: for ( I = 0; I < N; I++ ) {
74: B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
75: }
1.10 noro 76:
77: /* homogenized (heuristics) */
1.1 noro 78: dp_nelim(2);
1.10 noro 79: G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
1.1 noro 80: G1 = [];
81: for ( T = G0; T != []; T = cdr(T) ) {
82: E = car(T); VL = vars(E);
83: if ( !member(y1,VL) && !member(y2,VL) )
84: G1 = cons(E,G1);
85: }
1.12 noro 86: G2 = map(psi,G1,t,dt);
87: G3 = map(subst,G2,t,-1-s);
88: return G3;
1.1 noro 89: }
90:
1.10 noro 91: /*
92: * compute J_f|s=r, where r = the minimal integral root of global b_f(s)
93: * ann0(F) returns [MinRoot,Ideal]
94: */
95:
96: def ann0(F)
97: {
98: V = vars(F);
99: N = length(V);
100: D = newvect(N);
101:
102: for ( I = 0; I < N; I++ )
103: D[I] = [deg(F,V[I]),V[I]];
104: qsort(D,compare_first);
105: for ( V = [], I = 0; I < N; I++ )
106: V = cons(D[I][1],V);
107:
108: for ( I = N-1, DV = []; I >= 0; I-- )
109: DV = cons(strtov("d"+rtostr(V[I])),DV);
110:
111: /* XXX : heuristics */
112: W = append([y1,y2,t],reverse(V));
113: DW = append([dy1,dy2,dt],reverse(DV));
114: WDW = append(W,DW);
115:
116: B = [1-y1*y2,t-y1*F];
117: for ( I = 0; I < N; I++ ) {
118: B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
119: }
120:
121: /* homogenized (heuristics) */
122: dp_nelim(2);
123: G0 = dp_weyl_gr_main(B,WDW,1,0,6);
124: G1 = [];
125: for ( T = G0; T != []; T = cdr(T) ) {
126: E = car(T); VL = vars(E);
127: if ( !member(y1,VL) && !member(y2,VL) )
128: G1 = cons(E,G1);
129: }
1.12 noro 130: G2 = map(psi,G1,t,dt);
131: G3 = map(subst,G2,t,-1-s);
1.10 noro 132:
1.12 noro 133: /* G3 = J_f(s) */
1.10 noro 134:
135: V1 = cons(s,V); DV1 = cons(ds,DV); V1DV1 = append(V1,DV1);
1.12 noro 136: G4 = dp_weyl_gr_main(cons(F,G3),V1DV1,0,1,0);
137: Bf = weyl_minipoly(G4,V1DV1,0,s);
1.10 noro 138:
139: FList = cdr(fctr(Bf));
140: for ( T = FList, Min = 0; T != []; T = cdr(T) ) {
141: LF = car(car(T));
142: Root = -coef(LF,0)/coef(LF,1);
143: if ( dn(Root) == 1 && Root < Min )
144: Min = Root;
145: }
1.12 noro 146: return [Min,map(subst,G3,s,Min)];
1.10 noro 147: }
148:
1.7 noro 149: def indicial1(F,V)
1.6 noro 150: {
151: W = append([y1,t],V);
152: N = length(V);
153: B = [t-y1*F];
154: for ( I = N-1, DV = []; I >= 0; I-- )
155: DV = cons(strtov("d"+rtostr(V[I])),DV);
156: DW = append([dy1,dt],DV);
157: for ( I = 0; I < N; I++ ) {
158: B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
159: }
160: dp_nelim(1);
1.10 noro 161:
162: /* homogenized (heuristics) */
1.7 noro 163: G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
1.6 noro 164: G1 = map(subst,G0,y1,1);
165: G2 = map(psi,G1,t,dt);
166: G3 = map(subst,G2,t,-s-1);
167: return G3;
168: }
169:
170: def psi(F,T,DT)
171: {
172: D = dp_ptod(F,[T,DT]);
173: Wmax = weight(D);
174: D1 = dp_rest(D);
175: for ( ; D1; D1 = dp_rest(D1) )
176: if ( weight(D1) > Wmax )
177: Wmax = weight(D1);
178: for ( D1 = D, Dmax = 0; D1; D1 = dp_rest(D1) )
179: if ( weight(D1) == Wmax )
180: Dmax += dp_hm(D1);
181: if ( Wmax >= 0 )
182: Dmax = dp_weyl_mul(<<Wmax,0>>,Dmax);
183: else
184: Dmax = dp_weyl_mul(<<0,-Wmax>>,Dmax);
185: Rmax = dp_dtop(Dmax,[T,DT]);
186: R = b_subst(subst(Rmax,DT,1),T);
187: return R;
188: }
189:
190: def weight(D)
191: {
192: V = dp_etov(D);
193: return V[1]-V[0];
194: }
195:
196: def compare_first(A,B)
197: {
198: A0 = car(A);
199: B0 = car(B);
200: if ( A0 > B0 )
201: return 1;
202: else if ( A0 < B0 )
203: return -1;
204: else
205: return 0;
206: }
207:
1.13 noro 208: /* generic b-function w.r.t. weight vector W */
209:
210: def generic_bfct(F,V,DV,W)
211: {
212: N = length(V);
213: N2 = N*2;
214:
1.16 noro 215: /* If W is a list, convert it to a vector */
216: if ( type(W) == 4 )
217: W = newvect(length(W),W);
1.15 noro 218: dp_weyl_set_weight(W);
219:
1.14 noro 220: /* create a term order M in D<x,d> (DRL) */
1.13 noro 221: M = newmat(N2,N2);
222: for ( J = 0; J < N2; J++ )
223: M[0][J] = 1;
224: for ( I = 1; I < N2; I++ )
225: M[I][N2-I] = -1;
226:
227: VDV = append(V,DV);
228:
229: /* create a non-term order MW in D<x,d> */
230: MW = newmat(N2+1,N2);
231: for ( J = 0; J < N; J++ )
232: MW[0][J] = -W[J];
233: for ( ; J < N2; J++ )
234: MW[0][J] = W[J-N];
235: for ( I = 1; I <= N2; I++ )
236: for ( J = 0; J < N2; J++ )
237: MW[I][J] = M[I-1][J];
238:
239: /* create a homogenized term order MWH in D<x,d,h> */
240: MWH = newmat(N2+2,N2+1);
241: for ( J = 0; J <= N2; J++ )
242: MWH[0][J] = 1;
243: for ( I = 1; I <= N2+1; I++ )
244: for ( J = 0; J < N2; J++ )
245: MWH[I][J] = MW[I-1][J];
246:
247: /* homogenize F */
248: VDVH = append(VDV,[h]);
249: FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH);
250:
251: /* compute a groebner basis of FH w.r.t. MWH */
1.15 noro 252: dp_gr_flags(["Top",1,"NoRA",1]);
253: GH = dp_weyl_gr_main(FH,VDVH,0,1,11);
254: dp_gr_flags(["Top",0,"NoRA",0]);
1.13 noro 255:
256: /* dehomigenize GH */
257: G = map(subst,GH,h,1);
258:
259: /* G is a groebner basis w.r.t. a non term order MW */
260: /* take the initial part w.r.t. (-W,W) */
261: GIN = map(initial_part,G,VDV,MW,W);
262:
263: /* GIN is a groebner basis w.r.t. a term order M */
264: /* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */
265:
266: /* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */
267: for ( I = 0, T = 0; I < N; I++ )
268: T += W[I]*V[I]*DV[I];
1.14 noro 269: B = weyl_minipoly(GIN,VDV,0,T); /* M represents DRL order */
1.13 noro 270: return B;
271: }
272:
1.18 noro 273: /* all term reduction + interreduce */
274: def generic_bfct_1(F,V,DV,W)
275: {
276: N = length(V);
277: N2 = N*2;
278:
279: /* If W is a list, convert it to a vector */
280: if ( type(W) == 4 )
281: W = newvect(length(W),W);
282: dp_weyl_set_weight(W);
283:
284: /* create a term order M in D<x,d> (DRL) */
285: M = newmat(N2,N2);
286: for ( J = 0; J < N2; J++ )
287: M[0][J] = 1;
288: for ( I = 1; I < N2; I++ )
289: M[I][N2-I] = -1;
290:
291: VDV = append(V,DV);
292:
293: /* create a non-term order MW in D<x,d> */
294: MW = newmat(N2+1,N2);
295: for ( J = 0; J < N; J++ )
296: MW[0][J] = -W[J];
297: for ( ; J < N2; J++ )
298: MW[0][J] = W[J-N];
299: for ( I = 1; I <= N2; I++ )
300: for ( J = 0; J < N2; J++ )
301: MW[I][J] = M[I-1][J];
302:
303: /* create a homogenized term order MWH in D<x,d,h> */
304: MWH = newmat(N2+2,N2+1);
305: for ( J = 0; J <= N2; J++ )
306: MWH[0][J] = 1;
307: for ( I = 1; I <= N2+1; I++ )
308: for ( J = 0; J < N2; J++ )
309: MWH[I][J] = MW[I-1][J];
310:
311: /* homogenize F */
312: VDVH = append(VDV,[h]);
313: FH = map(dp_dtop,map(dp_homo,map(dp_ptod,F,VDV)),VDVH);
314:
315: /* compute a groebner basis of FH w.r.t. MWH */
316: /* dp_gr_flags(["Top",1,"NoRA",1]); */
317: GH = dp_weyl_gr_main(FH,VDVH,0,1,11);
318: /* dp_gr_flags(["Top",0,"NoRA",0]); */
319:
320: /* dehomigenize GH */
321: G = map(subst,GH,h,1);
322:
323: /* G is a groebner basis w.r.t. a non term order MW */
324: /* take the initial part w.r.t. (-W,W) */
325: GIN = map(initial_part,G,VDV,MW,W);
326:
327: /* GIN is a groebner basis w.r.t. a term order M */
328: /* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */
329:
330: /* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */
331: for ( I = 0, T = 0; I < N; I++ )
332: T += W[I]*V[I]*DV[I];
333: B = weyl_minipoly(GIN,VDV,0,T); /* M represents DRL order */
334: return B;
335: }
336:
1.13 noro 337: def initial_part(F,V,MW,W)
338: {
339: N2 = length(V);
340: N = N2/2;
341: dp_ord(MW);
342: DF = dp_ptod(F,V);
343: R = dp_hm(DF);
344: DF = dp_rest(DF);
345:
346: E = dp_etov(R);
347: for ( I = 0, TW = 0; I < N; I++ )
348: TW += W[I]*(-E[I]+E[N+I]);
349: RW = TW;
350:
351: for ( ; DF; DF = dp_rest(DF) ) {
352: E = dp_etov(DF);
353: for ( I = 0, TW = 0; I < N; I++ )
354: TW += W[I]*(-E[I]+E[N+I]);
355: if ( TW == RW )
356: R += dp_hm(DF);
357: else if ( TW < RW )
358: break;
359: else
360: error("initial_part : cannot happen");
361: }
362: return dp_dtop(R,V);
363:
364: }
365:
1.1 noro 366: /* b-function of F ? */
367:
368: def bfct(F)
369: {
370: V = vars(F);
371: N = length(V);
1.6 noro 372: D = newvect(N);
1.7 noro 373:
1.6 noro 374: for ( I = 0; I < N; I++ )
375: D[I] = [deg(F,V[I]),V[I]];
376: qsort(D,compare_first);
377: for ( V = [], I = 0; I < N; I++ )
378: V = cons(D[I][1],V);
1.1 noro 379: for ( I = N-1, DV = []; I >= 0; I-- )
380: DV = cons(strtov("d"+rtostr(V[I])),DV);
1.6 noro 381: V1 = cons(s,V); DV1 = cons(ds,DV);
1.7 noro 382:
383: G0 = indicial1(F,reverse(V));
384: G1 = dp_weyl_gr_main(G0,append(V1,DV1),0,1,0);
385: Minipoly = weyl_minipoly(G1,append(V1,DV1),0,s);
1.6 noro 386: return Minipoly;
387: }
388:
1.14 noro 389: /* b-function computation via generic_bfct() (experimental) */
390:
391: def bfct_via_gbfct(F)
392: {
393: V = vars(F);
394: N = length(V);
395: D = newvect(N);
396:
397: for ( I = 0; I < N; I++ )
398: D[I] = [deg(F,V[I]),V[I]];
399: qsort(D,compare_first);
400: for ( V = [], I = 0; I < N; I++ )
401: V = cons(D[I][1],V);
402: V = reverse(V);
403: for ( I = N-1, DV = []; I >= 0; I-- )
404: DV = cons(strtov("d"+rtostr(V[I])),DV);
405:
406: B = [t-F];
407: for ( I = 0; I < N; I++ ) {
408: B = cons(DV[I]+diff(F,V[I])*dt,B);
409: }
410: V1 = cons(t,V); DV1 = cons(dt,DV);
411: W = newvect(N+1);
412: W[0] = 1;
1.18 noro 413: R = generic_bfct_1(B,V1,DV1,W);
1.14 noro 414:
415: return subst(R,s,-s-1);
416: }
417:
1.17 noro 418: /* use an order s.t. [t,x,y,z,...,dt,dx,dy,dz,...,h] */
419:
420: def bfct_via_gbfct_weight(F,V)
421: {
422: N = length(V);
423: D = newvect(N);
424: Wt = getopt(weight);
1.18 noro 425: if ( type(Wt) != 4 ) {
426: for ( I = 0, Wt = []; I < N; I++ )
427: Wt = cons(1,Wt);
428: }
429: Tdeg = w_tdeg(F,V,Wt);
430: WtV = newvect(2*(N+1)+1);
431: WtV[0] = Tdeg;
432: WtV[N+1] = 1;
433: /* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */
434: for ( I = 1; I <= N; I++ ) {
435: WtV[I] = Wt[I-1];
436: WtV[N+1+I] = Tdeg-Wt[I-1]+1;
1.17 noro 437: }
1.18 noro 438: WtV[2*(N+1)] = 1;
439: dp_set_weight(WtV);
1.17 noro 440: for ( I = N-1, DV = []; I >= 0; I-- )
441: DV = cons(strtov("d"+rtostr(V[I])),DV);
442:
443: B = [t-F];
444: for ( I = 0; I < N; I++ ) {
445: B = cons(DV[I]+diff(F,V[I])*dt,B);
446: }
447: V1 = cons(t,V); DV1 = cons(dt,DV);
448: W = newvect(N+1);
449: W[0] = 1;
1.18 noro 450: R = generic_bfct_1(B,V1,DV1,W);
451: dp_set_weight(0);
1.17 noro 452: return subst(R,s,-s-1);
453: }
454:
455: /* use an order s.t. [x,y,z,...,t,dx,dy,dz,...,dt,h] */
456:
457: def bfct_via_gbfct_weight_1(F,V)
458: {
459: N = length(V);
460: D = newvect(N);
461: Wt = getopt(weight);
1.18 noro 462: if ( type(Wt) != 4 ) {
463: for ( I = 0, Wt = []; I < N; I++ )
464: Wt = cons(1,Wt);
465: }
466: Tdeg = w_tdeg(F,V,Wt);
467: WtV = newvect(2*(N+1)+1);
468: /* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */
469: for ( I = 0; I < N; I++ ) {
470: WtV[I] = Wt[I];
471: WtV[N+1+I] = Tdeg-Wt[I]+1;
1.17 noro 472: }
1.18 noro 473: WtV[N] = Tdeg;
474: WtV[2*N+1] = 1;
475: WtV[2*(N+1)] = 1;
476: dp_set_weight(WtV);
1.17 noro 477: for ( I = N-1, DV = []; I >= 0; I-- )
478: DV = cons(strtov("d"+rtostr(V[I])),DV);
479:
480: B = [t-F];
481: for ( I = 0; I < N; I++ ) {
482: B = cons(DV[I]+diff(F,V[I])*dt,B);
483: }
484: V1 = append(V,[t]); DV1 = append(DV,[dt]);
485: W = newvect(N+1);
486: W[N] = 1;
487: R = generic_bfct(B,V1,DV1,W);
1.19 ! noro 488: dp_set_weight(0);
! 489: return subst(R,s,-s-1);
! 490: }
! 491:
! 492: def bfct_via_gbfct_weight_2(F,V)
! 493: {
! 494: N = length(V);
! 495: D = newvect(N);
! 496: Wt = getopt(weight);
! 497: if ( type(Wt) != 4 ) {
! 498: for ( I = 0, Wt = []; I < N; I++ )
! 499: Wt = cons(1,Wt);
! 500: }
! 501: Tdeg = w_tdeg(F,V,Wt);
! 502:
! 503: /* a weight for the first GB computation */
! 504: /* [t,x1,...,xn,dt,dx1,...,dxn,h] */
! 505: WtV = newvect(2*(N+1)+1);
! 506: WtV[0] = Tdeg;
! 507: WtV[N+1] = 1;
! 508: WtV[2*(N+1)] = 1;
! 509: /* wdeg(V[I])=Wt[I], wdeg(DV[I])=Tdeg-Wt[I]+1 */
! 510: for ( I = 1; I <= N; I++ ) {
! 511: WtV[I] = Wt[I-1];
! 512: WtV[N+1+I] = Tdeg-Wt[I-1]+1;
! 513: }
! 514: dp_set_weight(WtV);
! 515:
! 516: /* a weight for the second GB computation */
! 517: /* [x1,...,xn,t,dx1,...,dxn,dt,h] */
! 518: WtV2 = newvect(2*(N+1)+1);
! 519: WtV2[N] = Tdeg;
! 520: WtV2[2*N+1] = 1;
! 521: WtV2[2*(N+1)] = 1;
! 522: for ( I = 0; I < N; I++ ) {
! 523: WtV2[I] = Wt[I];
! 524: WtV2[N+1+I] = Tdeg-Wt[I]+1;
! 525: }
! 526:
! 527: for ( I = N-1, DV = []; I >= 0; I-- )
! 528: DV = cons(strtov("d"+rtostr(V[I])),DV);
! 529:
! 530: B = [t-F];
! 531: for ( I = 0; I < N; I++ ) {
! 532: B = cons(DV[I]+diff(F,V[I])*dt,B);
! 533: }
! 534: V1 = cons(t,V); DV1 = cons(dt,DV);
! 535: V2 = append(V,[t]); DV2 = append(DV,[dt]);
! 536: W = newvect(N+1,[1]);
! 537: dp_weyl_set_weight(W);
! 538:
! 539: VDV = append(V1,DV1);
! 540: N1 = length(V1);
! 541: N2 = N1*2;
! 542:
! 543: /* create a non-term order MW in D<x,d> */
! 544: MW = newmat(N2+1,N2);
! 545: for ( J = 0; J < N1; J++ ) {
! 546: MW[0][J] = -W[J]; MW[0][N1+J] = W[J];
! 547: }
! 548: for ( J = 0; J < N2; J++ ) MW[1][J] = 1;
! 549: for ( I = 2; I <= N2; I++ ) MW[I][N2-I+1] = -1;
! 550:
! 551: /* homogenize F */
! 552: VDVH = append(VDV,[h]);
! 553: FH = map(dp_dtop,map(dp_homo,map(dp_ptod,B,VDV)),VDVH);
! 554:
! 555: /* compute a groebner basis of FH w.r.t. MWH */
! 556: GH = dp_weyl_gr_main(FH,VDVH,0,1,11);
! 557:
! 558: /* dehomigenize GH */
! 559: G = map(subst,GH,h,1);
! 560:
! 561: /* G is a groebner basis w.r.t. a non term order MW */
! 562: /* take the initial part w.r.t. (-W,W) */
! 563: GIN = map(initial_part,G,VDV,MW,W);
! 564:
! 565: /* GIN is a groebner basis w.r.t. a term order M */
! 566: /* As -W+W=0, gr_(-W,W)(D<x,d>) = D<x,d> */
! 567:
! 568: /* find b(W1*x1*d1+...+WN*xN*dN) in Id(GIN) */
! 569: for ( I = 0, T = 0; I < N1; I++ )
! 570: T += W[I]*V1[I]*DV1[I];
! 571:
! 572: /* change of ordering from VDV to VDV2 */
! 573: VDV2 = append(V2,DV2);
! 574: dp_set_weight(WtV2);
! 575: GIN2 = dp_weyl_gr_main(GIN,VDV2,0,-1,0);
! 576:
! 577: R = weyl_minipoly(GIN2,VDV2,0,T); /* M represents DRL order */
1.18 noro 578: dp_set_weight(0);
1.17 noro 579: return subst(R,s,-s-1);
580: }
581:
1.6 noro 582: def weyl_minipolym(G,V,O,M,V0)
583: {
584: N = length(V);
585: Len = length(G);
586: dp_ord(O);
587: setmod(M);
588: PS = newvect(Len);
589: PS0 = newvect(Len);
590:
591: for ( I = 0, T = G; T != []; T = cdr(T), I++ )
592: PS0[I] = dp_ptod(car(T),V);
593: for ( I = 0, T = G; T != []; T = cdr(T), I++ )
594: PS[I] = dp_mod(dp_ptod(car(T),V),M,[]);
595:
596: for ( I = Len - 1, GI = []; I >= 0; I-- )
597: GI = cons(I,GI);
598:
599: U = dp_mod(dp_ptod(V0,V),M,[]);
1.17 noro 600: U = dp_weyl_nf_mod(GI,U,PS,1,M);
1.6 noro 601:
602: T = dp_mod(<<0>>,M,[]);
603: TT = dp_mod(dp_ptod(1,V),M,[]);
604: G = H = [[TT,T]];
605:
606: for ( I = 1; ; I++ ) {
1.14 noro 607: if ( dp_gr_print() )
608: print(".",2);
1.6 noro 609: T = dp_mod(<<I>>,M,[]);
610:
611: TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M);
612: H = cons([TT,T],H);
613: L = dp_lnf_mod([TT,T],G,M);
1.14 noro 614: if ( !L[0] ) {
615: if ( dp_gr_print() )
616: print("");
1.13 noro 617: return dp_dtop(L[1],[t]); /* XXX */
1.14 noro 618: } else
1.6 noro 619: G = insert(G,L);
620: }
621: }
622:
1.13 noro 623: def weyl_minipoly(G0,V0,O0,P)
1.6 noro 624: {
1.11 noro 625: HM = hmlist(G0,V0,O0);
1.13 noro 626:
627: N = length(V0);
628: Len = length(G0);
629: dp_ord(O0);
630: PS = newvect(Len);
631: for ( I = 0, T = G0, HL = []; T != []; T = cdr(T), I++ )
632: PS[I] = dp_ptod(car(T),V0);
633: for ( I = Len - 1, GI = []; I >= 0; I-- )
634: GI = cons(I,GI);
635: DP = dp_ptod(P,V0);
636:
1.6 noro 637: for ( I = 0; ; I++ ) {
638: Prime = lprime(I);
1.11 noro 639: if ( !valid_modulus(HM,Prime) )
640: continue;
1.13 noro 641: MP = weyl_minipolym(G0,V0,O0,Prime,P);
642: D = deg(MP,var(MP));
643:
644: NFP = weyl_nf(GI,DP,1,PS);
645: NF = [[dp_ptod(1,V0),1]];
646: LCM = 1;
647:
648: for ( J = 1; J <= D; J++ ) {
1.14 noro 649: if ( dp_gr_print() )
650: print(".",2);
1.13 noro 651: NFPrev = car(NF);
652: NFJ = weyl_nf(GI,
653: dp_weyl_mul(NFP[0],NFPrev[0]),NFP[1]*NFPrev[1],PS);
654: NFJ = remove_cont(NFJ);
655: NF = cons(NFJ,NF);
656: LCM = ilcm(LCM,NFJ[1]);
657: }
1.14 noro 658: if ( dp_gr_print() )
659: print("");
1.13 noro 660: U = NF[0][0]*idiv(LCM,NF[0][1]);
661: Coef = [];
662: for ( J = D-1; J >= 0; J-- ) {
663: Coef = cons(strtov("u"+rtostr(J)),Coef);
664: U += car(Coef)*NF[D-J][0]*idiv(LCM,NF[D-J][1]);
665: }
1.6 noro 666:
1.13 noro 667: for ( UU = U, Eq = []; UU; UU = dp_rest(UU) )
668: Eq = cons(dp_hc(UU),Eq);
669: M = etom([Eq,Coef]);
670: B = henleq(M,Prime);
671: if ( dp_gr_print() )
672: print("");
1.6 noro 673: if ( B ) {
1.13 noro 674: R = 0;
675: for ( I = 0; I < D; I++ )
676: R += B[0][I]*s^I;
677: R += B[1]*s^D;
1.6 noro 678: return R;
679: }
680: }
681: }
682:
683: def weyl_nf(B,G,M,PS)
684: {
685: for ( D = 0; G; ) {
686: for ( U = 0, L = B; L != []; L = cdr(L) ) {
687: if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
688: GCD = igcd(dp_hc(G),dp_hc(R));
689: CG = idiv(dp_hc(R),GCD); CR = idiv(dp_hc(G),GCD);
690: U = CG*G-dp_weyl_mul(CR*dp_subd(G,R),R);
691: if ( !U )
692: return [D,M];
693: D *= CG; M *= CG;
694: break;
695: }
696: }
697: if ( U )
698: G = U;
699: else {
700: D += dp_hm(G); G = dp_rest(G);
701: }
702: }
703: return [D,M];
704: }
705:
706: def weyl_nf_mod(B,G,PS,Mod)
707: {
708: for ( D = 0; G; ) {
709: for ( U = 0, L = B; L != []; L = cdr(L) ) {
710: if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
711: CR = dp_hc(G)/dp_hc(R);
712: U = G-dp_weyl_mul_mod(CR*dp_mod(dp_subd(G,R),Mod,[]),R,Mod);
713: if ( !U )
714: return D;
1.1 noro 715: break;
1.6 noro 716: }
717: }
718: if ( U )
719: G = U;
720: else {
721: D += dp_hm(G); G = dp_rest(G);
1.1 noro 722: }
723: }
1.6 noro 724: return D;
1.1 noro 725: }
726:
727: def remove_zero(L)
728: {
729: for ( R = []; L != []; L = cdr(L) )
730: if ( car(L) )
731: R = cons(car(L),R);
732: return R;
733: }
734:
735: def z_subst(F,V)
736: {
737: for ( ; V != []; V = cdr(V) )
738: F = subst(F,car(V),0);
739: return F;
740: }
741:
742: def flatmf(L) {
743: for ( S = []; L != []; L = cdr(L) )
744: if ( type(F=car(car(L))) != NUM )
745: S = append(S,[F]);
746: return S;
747: }
748:
749: def member(A,L) {
750: for ( ; L != []; L = cdr(L) )
751: if ( A == car(L) )
752: return 1;
753: return 0;
754: }
755:
756: def intersection(A,B)
757: {
758: for ( L = []; A != []; A = cdr(A) )
759: if ( member(car(A),B) )
760: L = cons(car(A),L);
761: return L;
762: }
763:
764: def b_subst(F,V)
765: {
766: D = deg(F,V);
767: C = newvect(D+1);
768: for ( I = D; I >= 0; I-- )
769: C[I] = coef(F,I,V);
770: for ( I = 0, R = 0; I <= D; I++ )
771: if ( C[I] )
772: R += C[I]*v_factorial(V,I);
773: return R;
774: }
775:
776: def v_factorial(V,N)
777: {
778: for ( J = N-1, R = 1; J >= 0; J-- )
779: R *= V-J;
1.17 noro 780: return R;
781: }
782:
783: def w_tdeg(F,V,W)
784: {
785: dp_set_weight(newvect(length(W),W));
786: T = dp_ptod(F,V);
787: for ( R = 0; T; T = cdr(T) ) {
788: D = dp_td(T);
789: if ( D > R ) R = D;
790: }
1.1 noro 791: return R;
792: }
793: end$
794:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>