Annotation of OpenXM_contrib2/asir2000/lib/bfct, Revision 1.12
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.12 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.11 2000/12/15 01:52:36 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.1 noro 208: /* b-function of F ? */
209:
210: def bfct(F)
211: {
212: V = vars(F);
213: N = length(V);
1.6 noro 214: D = newvect(N);
1.7 noro 215:
1.6 noro 216: for ( I = 0; I < N; I++ )
217: D[I] = [deg(F,V[I]),V[I]];
218: qsort(D,compare_first);
219: for ( V = [], I = 0; I < N; I++ )
220: V = cons(D[I][1],V);
1.1 noro 221: for ( I = N-1, DV = []; I >= 0; I-- )
222: DV = cons(strtov("d"+rtostr(V[I])),DV);
1.6 noro 223: V1 = cons(s,V); DV1 = cons(ds,DV);
1.7 noro 224:
225: G0 = indicial1(F,reverse(V));
226: G1 = dp_weyl_gr_main(G0,append(V1,DV1),0,1,0);
227: Minipoly = weyl_minipoly(G1,append(V1,DV1),0,s);
1.6 noro 228: return Minipoly;
229: }
230:
231: def weyl_minipolym(G,V,O,M,V0)
232: {
233: N = length(V);
234: Len = length(G);
235: dp_ord(O);
236: setmod(M);
237: PS = newvect(Len);
238: PS0 = newvect(Len);
239:
240: for ( I = 0, T = G; T != []; T = cdr(T), I++ )
241: PS0[I] = dp_ptod(car(T),V);
242: for ( I = 0, T = G; T != []; T = cdr(T), I++ )
243: PS[I] = dp_mod(dp_ptod(car(T),V),M,[]);
244:
245: for ( I = Len - 1, GI = []; I >= 0; I-- )
246: GI = cons(I,GI);
247:
248: U = dp_mod(dp_ptod(V0,V),M,[]);
249:
250: T = dp_mod(<<0>>,M,[]);
251: TT = dp_mod(dp_ptod(1,V),M,[]);
252: G = H = [[TT,T]];
253:
254: for ( I = 1; ; I++ ) {
255: T = dp_mod(<<I>>,M,[]);
256:
257: TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M);
258: H = cons([TT,T],H);
259: L = dp_lnf_mod([TT,T],G,M);
260: if ( !L[0] )
261: return dp_dtop(L[1],[V0]);
262: else
263: G = insert(G,L);
264: }
265: }
266:
267: def weyl_minipoly(G0,V0,O0,V)
268: {
1.11 noro 269: HM = hmlist(G0,V0,O0);
1.6 noro 270: for ( I = 0; ; I++ ) {
271: Prime = lprime(I);
1.11 noro 272: if ( !valid_modulus(HM,Prime) )
273: continue;
1.6 noro 274: MP = weyl_minipolym(G0,V0,O0,Prime,V);
275: for ( D = deg(MP,V), TL = [], J = 0; J <= D; J++ )
276: TL = cons(V^J,TL);
277: dp_ord(O0);
278: NF = weyl_gennf(G0,TL,V0,O0)[0];
279:
280: LHS = weyl_nf_tab(-car(TL),NF,V0);
281: B = weyl_hen_ttob(cdr(TL),NF,LHS,V0,Prime);
282: if ( B ) {
283: R = ptozp(B[1]*car(TL)+B[0]);
284: return R;
285: }
286: }
287: }
288:
289: def weyl_gennf(G,TL,V,O)
290: {
291: N = length(V); Len = length(G); dp_ord(O); PS = newvect(Len);
292: for ( I = 0, T = G, HL = []; T != []; T = cdr(T), I++ ) {
293: PS[I] = dp_ptod(car(T),V); HL = cons(dp_ht(PS[I]),HL);
294: }
295: for ( I = 0, DTL = []; TL != []; TL = cdr(TL) )
296: DTL = cons(dp_ptod(car(TL),V),DTL);
297: for ( I = Len - 1, GI = []; I >= 0; I-- )
298: GI = cons(I,GI);
299: T = car(DTL); DTL = cdr(DTL);
300: H = [weyl_nf(GI,T,T,PS)];
1.1 noro 301:
1.6 noro 302: T0 = time()[0];
303: while ( DTL != [] ) {
304: T = car(DTL); DTL = cdr(DTL);
305: if ( dp_gr_print() )
306: print(".",2);
307: if ( L = search_redble(T,H) ) {
308: DD = dp_subd(T,L[1]);
309: NF = weyl_nf(GI,dp_weyl_mul(L[0],dp_subd(T,L[1])),dp_hc(L[1])*T,PS);
310: } else
311: NF = weyl_nf(GI,T,T,PS);
312: NF = remove_cont(NF);
313: H = cons(NF,H);
314: }
1.10 noro 315: print("");
1.6 noro 316: TNF = time()[0]-T0;
317: if ( dp_gr_print() )
318: print("gennf(TAB="+rtostr(TTAB)+" NF="+rtostr(TNF)+")");
319: return [H,PS,GI];
320: }
1.1 noro 321:
1.6 noro 322: def weyl_nf(B,G,M,PS)
323: {
324: for ( D = 0; G; ) {
325: for ( U = 0, L = B; L != []; L = cdr(L) ) {
326: if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
327: GCD = igcd(dp_hc(G),dp_hc(R));
328: CG = idiv(dp_hc(R),GCD); CR = idiv(dp_hc(G),GCD);
329: U = CG*G-dp_weyl_mul(CR*dp_subd(G,R),R);
330: if ( !U )
331: return [D,M];
332: D *= CG; M *= CG;
333: break;
334: }
335: }
336: if ( U )
337: G = U;
338: else {
339: D += dp_hm(G); G = dp_rest(G);
340: }
341: }
342: return [D,M];
343: }
344:
345: def weyl_nf_mod(B,G,PS,Mod)
346: {
347: for ( D = 0; G; ) {
348: for ( U = 0, L = B; L != []; L = cdr(L) ) {
349: if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
350: CR = dp_hc(G)/dp_hc(R);
351: U = G-dp_weyl_mul_mod(CR*dp_mod(dp_subd(G,R),Mod,[]),R,Mod);
352: if ( !U )
353: return D;
1.1 noro 354: break;
1.6 noro 355: }
356: }
357: if ( U )
358: G = U;
359: else {
360: D += dp_hm(G); G = dp_rest(G);
1.1 noro 361: }
362: }
1.6 noro 363: return D;
364: }
365:
366: def weyl_hen_ttob(T,NF,LHS,V,MOD)
367: {
368: T0 = time()[0]; M = etom(weyl_leq_nf(T,NF,LHS,V)); TE = time()[0] - T0;
369: T0 = time()[0]; U = henleq(M,MOD); TH = time()[0] - T0;
370: if ( dp_gr_print() ) {
371: print("(etom="+rtostr(TE)+" hen="+rtostr(TH)+")");
372: }
373: return U ? vtop(T,U,LHS) : 0;
374: }
375:
376: def weyl_leq_nf(TL,NF,LHS,V)
377: {
378: TLen = length(NF);
379: T = newvect(TLen); M = newvect(TLen);
380: for ( I = 0; I < TLen; I++ ) {
381: T[I] = dp_ht(NF[I][1]);
382: M[I] = dp_hc(NF[I][1]);
383: }
384: Len = length(TL); INDEX = newvect(Len); COEF = newvect(Len);
385: for ( L = TL, J = 0; L != []; L = cdr(L), J++ ) {
386: D = dp_ptod(car(L),V);
387: for ( I = 0; I < TLen; I++ )
388: if ( D == T[I] )
389: break;
390: INDEX[J] = I; COEF[J] = strtov("u"+rtostr(J));
391: }
392: if ( !LHS ) {
393: COEF[0] = 1; NM = 0; DN = 1;
394: } else {
395: NM = LHS[0]; DN = LHS[1];
396: }
397: for ( J = 0, S = -NM; J < Len; J++ ) {
398: DNJ = M[INDEX[J]];
399: GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD;
400: S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J];
401: DN *= CS;
402: }
403: for ( D = S, E = []; D; D = dp_rest(D) )
404: E = cons(dp_hc(D),E);
405: BOUND = LHS ? 0 : 1;
406: for ( I = Len - 1, W = []; I >= BOUND; I-- )
407: W = cons(COEF[I],W);
408: return [E,W];
409: }
410:
411: def weyl_nf_tab(A,NF,V)
412: {
413: TLen = length(NF);
414: T = newvect(TLen); M = newvect(TLen);
415: for ( I = 0; I < TLen; I++ ) {
416: T[I] = dp_ht(NF[I][1]);
417: M[I] = dp_hc(NF[I][1]);
418: }
419: A = dp_ptod(A,V);
420: for ( Z = A, Len = 0; Z; Z = dp_rest(Z), Len++ );
421: INDEX = newvect(Len); COEF = newvect(Len);
422: for ( Z = A, J = 0; Z; Z = dp_rest(Z), J++ ) {
423: D = dp_ht(Z);
424: for ( I = 0; I < TLen; I++ )
425: if ( D == T[I] )
426: break;
427: INDEX[J] = I; COEF[J] = dp_hc(Z);
428: }
429: for ( J = 0, S = 0, DN = 1; J < Len; J++ ) {
430: DNJ = M[INDEX[J]];
431: GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD;
432: S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J];
433: DN *= CS;
434: }
435: return [S,DN];
1.1 noro 436: }
437:
438: def remove_zero(L)
439: {
440: for ( R = []; L != []; L = cdr(L) )
441: if ( car(L) )
442: R = cons(car(L),R);
443: return R;
444: }
445:
446: def z_subst(F,V)
447: {
448: for ( ; V != []; V = cdr(V) )
449: F = subst(F,car(V),0);
450: return F;
451: }
452:
453: def flatmf(L) {
454: for ( S = []; L != []; L = cdr(L) )
455: if ( type(F=car(car(L))) != NUM )
456: S = append(S,[F]);
457: return S;
458: }
459:
460: def member(A,L) {
461: for ( ; L != []; L = cdr(L) )
462: if ( A == car(L) )
463: return 1;
464: return 0;
465: }
466:
467: def intersection(A,B)
468: {
469: for ( L = []; A != []; A = cdr(A) )
470: if ( member(car(A),B) )
471: L = cons(car(A),L);
472: return L;
473: }
474:
475: def b_subst(F,V)
476: {
477: D = deg(F,V);
478: C = newvect(D+1);
479: for ( I = D; I >= 0; I-- )
480: C[I] = coef(F,I,V);
481: for ( I = 0, R = 0; I <= D; I++ )
482: if ( C[I] )
483: R += C[I]*v_factorial(V,I);
484: return R;
485: }
486:
487: def v_factorial(V,N)
488: {
489: for ( J = N-1, R = 1; J >= 0; J-- )
490: R *= V-J;
491: return R;
492: }
493: end$
494:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>