Annotation of OpenXM/src/asir-contrib/testing/noro/grcrt.rr, Revision 1.2
1.1 noro 1: module noro_grcrt$
2:
3: localf f4_chr, gr_chr_d, f4_chr_d, store_history, read_history, store_bv,
4: store_bvn, store_bvn3, nd_f4_p2, nd_gr_recompute_trace_p,
5: nd_gr_gentrace_p, comp_by_ht, intdpltoratdpl2, intdptoratdp,
6: dp_mulmod, dp_chrem2, monic_gb, dp_monic_mod,
7: calcb, sp_sqrt, init_pprocs, nd_gbcheck, gbcheck_p, elimination$
8: localf iso_eq_mod, iso_eq_gentrace, iso_eq_mod, elim_top,
9: iso_eq_d2, iso_c1eq_mod, iso_c1eq_d2, iso_eq_gentrace2,
10: iso_eq_mod2, iso_eq_d2new, iso_sat_gentrace, iso_sat_mod, iso_sat_d2$
11:
12: static GB_History,GB_B,GB_V,GB_N,GB_H$
13: static GB_N1,GB_N2,GB_N3$
14: static GB_NZ$
15:
16: def f4_chr(B,V,O)
17: {
18: dp_ord(O);
19: Proc = getopt(proc);
20: NZ = getopt(nz);
21: Prev = getopt(prev);
22: Homo = getopt(homo);
23: Elim = getopt(elim);
24: Weight = getopt(weight);
25: if ( type(Prev) == -1 ) Prev = 0;
26: if ( type(Homo) == -1 ) Homo = 0;
27: if ( type(Elim) == -1 ) Elim = -1;
28: if ( type(Weight) == -1 ) Weight = 0;
29: OldWeight = dp_set_weight();
30: dp_set_weight(Weight);
31: if ( type(NZ) == -1 )
32: NZ = nd_f4(B,V,lprime(0),O|gentrace=1);
33: if ( type(Proc) != -1 ) {
34: G = f4_chr_d(B,V,O,Proc,NZ,Prev,Homo,Elim,Weight);
35: dp_set_weight(OldWeight);
36: return G;
37: }
38: B = map(ptozp,B);
39: Remain = 1; /* XXX */
40: for ( I = 0, N = 0, Mod = 1; Remain; I++ ) {
41: P = lprime(I);
42: GM = nd_f4(B,V,P,O|dp=1,trace=NZ);
43: if ( !GM ) continue;
44: if ( Elim >= 0 ) GM = elimination(GM,Elim);
45: if ( !N ) {
46: Remain = N = length(GM);
47: Stat = vector(N);
48: G = vector(N);
49: }
50: L = monic_gb(GM,V,O,P); GM = L[0];
51: T0 = time();
52: dp_chrem2(G,Mod,GM,P,Stat);
53: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
54: Mod *= P;
55: if ( !(I%3) ) {
56: T0 = time();
57: New = intdpltoratdpl2(G,Mod,Stat);
58: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
59: Remain -= New;
60: }
61: }
62: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
63: G = vtol(map(dp_dtop,G,V));
64: dp_set_weight(OldWeight);
65: return G;
66: }
67:
68: /* Prev = [G,Stat,I,Mod] */
69:
70: def f4_chr_d(B,V,O,Proc,NZ,Prev,Homo,Elim,Weight)
71: {
72: map(ox_reset,Proc);
73: B = map(ptozp,B);
74: NProc = length(Proc);
75: CRTime = 0; IRTime = 0;
76: /* gentrace */
77: map(ox_rpc,Proc,"dp_set_weight",Weight);
78: map(ox_pop_local,Proc);
79: map(ox_rpc,Proc,"noro_grcrt.store_bvn",B,V,NZ,Homo);
80: map(ox_pop_local,Proc);
81: if ( Prev ) {
82: G = Prev[0];
83: N = length(N);
84: Stat = Prev[1];
85: for ( J = 0, Remain = 0; J < N; J++ )
86: if ( Stat[J] != 2 ) Remain++;
87: I = Prev[2];
88: Mod = Prev[3];
89: } else {
90: I = 0;
91: N = 0;
92: Remain = 1; /* dummy */
93: Mod = 1;
94: }
95: for ( T = Proc; T != []; T = cdr(T), I++ )
96: ox_rpc(car(T),"noro_grcrt.nd_f4_p2",lprime(I),O);
97: while ( Remain ) {
98: for ( T = Proc; T != []; T = cdr(T), I++ ) {
99: print(["from",car(T)],2);
100: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
101: if ( Elim >= 0 ) GM = elimination(GM,Elim);
102: print(" done");
103: ox_rpc(car(T),"noro_grcrt.nd_f4_p2",lprime(I),O);
104: if ( GM ) {
105: L = monic_gb(GM,V,O,P); GM = L[0];
106: if ( !N ) {
107: Remain = N = length(GM);
108: Stat = vector(N);
109: G = vector(N);
110: }
111: T0 = time();
112: Fail = dp_chrem2(G,Mod,GM,P,Stat);
113: Remain += Fail;
114: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
115: Mod *= P;
116: }
117: }
118: T0 = time();
119: New = intdpltoratdpl2(G,Mod,Stat);
120: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
121: Remain -= New;
122: print((N-Remain)/N*100.0,0); print("% done");
123: }
124: map(ox_reset,Proc);
125: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
126: return vtol(map(dp_dtop,G,V));
127: }
128:
129: def store_history(D)
130: {
131: GB_History=D;
132: return 1;
133: }
134:
135: def read_history(Dname)
136: {
137: GB_History=bload(Dname);
138: return 1;
139: }
140:
141:
142: def store_bvn(B,V,N,H)
143: {
144: GB_B=B;
145: GB_V=V;
146: if ( type(N) == 7 )
147: GB_N = bload(N);
148: else
149: GB_N=N;
150: GB_H=H;
151: }
152:
153: def store_bvn3(B,V,N1,N2,N3)
154: {
155: GB_B=B;
156: GB_V=V;
157: GB_N1 = N1;
158: GB_N2 = N2;
159: GB_N3 = N3;
160: }
161:
162:
163: def nd_f4_p2(P,O)
164: {
165: if ( GB_H )
166: return [nd_f4(GB_B,GB_V,P,O|dp=1,trace=GB_N,nora=1),P];
167: else
168: return [nd_f4(GB_B,GB_V,P,O|dp=1,trace=GB_N),P];
169: }
170:
171:
172: def nd_gr_recompute_trace_p(B,V,P,O)
173: {
174: T0 = time();
175: R = nd_gr_recompute_trace(B,V,P,O,GB_History);
176: T1 = time();
177: Time = (T1[0]-T0[0])+(T1[1]-T0[1]);
178: return [nd_gr_recompute_trace(B,V,P,O,GB_History),P,Time];
179: }
180:
181: def nd_gr_gentrace_p(B,V,P,O)
182: {
183: return [nd_gr(B,V,P,O|gentrace=1),P];
184: }
185:
186: def comp_by_ht(A,B)
187: {
188: HA = dp_ht(A); HB = dp_ht(B);
189: if ( HA > HB )
190: return 1;
191: else if ( HA < HB )
192: return -1;
193: else
194: return 0;
195: }
196:
197: def intdpltoratdpl2(G,Mod,Stat)
198: {
199: N = size(G)[0];
200: M = calcb(Mod);
201: New = 0;
202: Den = 1;
203: for ( I = 0; I < N; I++ ) {
204: if ( Stat[I] == 2 ) continue;
205: if ( !I || dp_td(G[I]) != dp_td(G[I-1]) )
206: Den = 1;
207: T = intdptoratdp(G[I]*Den,Mod,M);
208: if ( T ) {
209: print([I],2);
210: T = dp_ptozp(T);
211: Den = ilcm(Den,dp_hc(T));
212: G[I] = T; Stat[I] = 2; New++;
213: } else {
214: print("("+rtostr(I)+")",2);
215: }
216: }
217: print("");
218: return New;
219: }
220:
221: def intdptoratdp(F,Mod,M)
222: {
223: for ( T = F, N = 0; T; T = dp_rest(T), N++ );
224: C = newvect(N);
225: for ( I = 0, T = F; I < N; T = dp_rest(T), I++ ) {
226: L = inttorat(dp_hc(T)%Mod,Mod,M);
227: if ( !L )
228: return 0;
229: else
230: C[I] = (L[0]/L[1])*dp_ht(T);
231: }
232: for ( R = 0, I = N-1; I >= 0; I-- )
233: R += C[I];
234: return R;
235: }
236:
237: def dp_mulmod(C,F,M)
238: {
239: L = [];
240: for ( T = F; T; T = dp_rest(T) ) {
241: A = (dp_hc(T)*C)%M;
242: L = cons(A*dp_ht(T),L);
243: }
244: for ( R = 0; L != []; L = cdr(L) )
245: R += car(L);
246: return R;
247: }
248:
249: def dp_chrem2(G,Mod,GM,P,Stat)
250: {
251: N = size(G)[0];
252: setmod(P);
253: M1 = ptomp(inv(Mod,P),P);
254: Fail = 0;
255: for ( I = 0; I < N; I++ ) {
256: if ( Stat[I] == 2 ) {
257: T = dp_mod(G[I],P,[]); T = dp_rat(T/dp_hc(T));
258: if ( GM[I] != T ) {
259: C = inv(dp_hc(G[I]),Mod);
260: G[I] = dp_mulmod(C,G[I],Mod);
261: if ( dp_hc(G[I]) != 1 )
262: error("");
263: Stat[I] = 0;
264: Fail++;
265: } else continue;
266: }
267: T = (dp_mod(GM[I],P,[])-dp_mod(G[I],P,[]))*M1;
268: G[I] = G[I]+dp_rat(T)*Mod;
269: Stat[I] = 1;
270: #if 0
271: print("|"+rtostr(I),2);
272: #endif
273: }
274: return Fail;
275: #if 0
276: print("");
277: #endif
278: }
279:
280: def monic_gb(D,V,O,P)
281: {
282: dp_ord(O); setmod(P);
283: /* D = map(dp_ptod,G,V); */
284: D = map(dp_monic_mod,D,P);
285: /* D = vtol(qsort(newvect(length(D),D),comp_by_ht)); */
286: return [D,map(dp_ht,D)];
287: }
288:
289: def dp_monic_mod(F,P)
290: {
291: FP = dp_mod(F,P,[]);
292: return dp_rat(FP/dp_hc(FP));
293: }
294:
295: def calcb(M) {
296: N = 2*M;
297: T = sp_sqrt(N);
298: if ( T^2 <= N && N < (T+1)^2 )
299: return idiv(T,2);
300: else
301: error("afo");
302: }
303:
304: def sp_sqrt(A) {
305: for ( J = 0, T = A; T >= 2^27; J++ ) {
306: T = idiv(T,2^27)+1;
307: }
308: for ( I = 0; T >= 2; I++ ) {
309: S = idiv(T,2);
310: if ( T = S+S )
311: T = S;
312: else
313: T = S+1;
314: }
315: X = (2^27)^idiv(J,2)*2^idiv(I,2);
316: while ( 1 ) {
317: if ( (Y=X^2) < A )
318: X += X;
319: else if ( Y == A )
320: return X;
321: else
322: break;
323: }
324: while ( 1 )
325: if ( (Y = X^2) <= A )
326: return X;
327: else
328: X = idiv(A + Y,2*X);
329: }
330:
331: def init_pprocs(L)
332: {
333: R = [];
334: if ( type(NoX=getopt(nox)) == -1 ) NoX = 0;
335: for ( T = L; T != []; T = cdr(T) ) {
336: Host = car(T)[0]; N = car(T)[1];
337: if ( !Host ) {
338: for ( I = 0; I < N; I++ ) {
339: P = NoX ? ox_launch_nox() : ox_launch();
340: R = cons(P,R);
341: }
342: } else {
343: Lib = get_rootdir();
344: Client = "ox_asir";
345: for ( I = 0; I < N; I++ ) {
346: P = NoX ? ox_launch_nox(Host,Lib,Client)
347: : ox_launch(Host,Lib,Client);
348: R = cons(P,R);
349: }
350: }
351: }
352: return reverse(R);
353: }
354:
355: def nd_gbcheck(G,V,P,O)
356: {
357: Proc = getopt(proc);
358: if ( type(Proc) == -1 ) Proc = 0;
359: F4 = getopt(f4);
360: if ( type(F4) == -1 ) F4 = 0;
361: /* XXX */
362: S = getopt(splist);
363: if ( type(S) == -1 ) {
364: if ( type(G) == 7 )
365: S = nd_gr(bload(G),V,lprime(0),O|splist=1);
366: else
367: S = nd_gr(G,V,lprime(0),O|splist=1);
368: }
369: if ( Proc ) {
370: N = length(Proc);
371: L = vector(N);
372: for ( I = 0; I < N; I++ ) L[I] = [];
373: for ( I = 0, T = S; T != []; T = cdr(T), I = (I+1)%N )
374: L[I] = cons(car(T),L[I]);
375: for ( I = 0; I < N; I++ )
376: ox_rpc(Proc[I],"noro_grcrt.gbcheck_p",G,V,P,O,reverse(L[I]),F4);
377: for ( I = 0; I < N; I++ )
378: if ( !ox_pop_local(Proc[I]) ) return 0;
379: return 1;
380: } else {
381: if ( F4 )
382: R = nd_f4(G,V,P,O|check_splist=S);
383: else
384: R = nd_gr(G,V,P,O|check_splist=S);
385: return R;
386: }
387: }
388:
389: def gbcheck_p(G,V,P,O,S,F4)
390: {
391: if ( type(G) == 7 )
392: G = bload(G);
393: if ( F4 )
394: return nd_f4(G,V,P,O|check_splist=S);
395: else
396: return nd_gr(G,V,P,O|check_splist=S);
397: }
398:
399: def elimination(L,Elim)
400: {
401: if ( type(Elim) <= 1 ) {
402: for ( R = []; L != []; L = cdr(L) ) {
403: H = dp_etov(dp_ht(car(L)));
404: for ( I = 0; I <= Pos && !H[I]; I++ );
405: if ( I > Pos ) R = cons(car(L),R);
406: }
407: } else {
408: for ( R = []; L != []; L = cdr(L) )
409: if ( dp_ht(car(L)) <= Elim ) R = cons(car(L),R);
410: }
411: return reverse(R);
412: }
413:
414: #if 0
415: def iso_eq_mod(Mod,UseNZ)
416: {
417: B = GB_B; V = GB_V;
418:
1.2 ! noro 419: /* V = [c1,bb,aa,b,a], W = [1,3,2,3,2,1] */
! 420: W = [1,3,2,3,2,1];
1.1 noro 421: dp_set_weight(W);
422: G1 = nd_f4(B,V,Mod,[[0,1],[0,4]]);
423: V1 = cdr(V);
424: G1 = noro_pd.elimination(G1,V1);
425: D = res(x,x^3+a*x+b,3*x^2+a);
426: G2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]);
427: G2 = noro_pd.elimination(G2,V1);
428: W1 = cdr(W);
429: dp_set_weight(W1);
430: if ( UseNZ )
431: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,trace=GB_NZ);
432: else {
433: GB_NZ = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,gentrace=1);
434: G3 = GB_NZ[0];
435: }
436: dp_ord([[0,1],[0,3]]);
437: #if 1
438: for ( T = []; G3 != []; G3 = cdr(G3) )
439: if ( dp_ht(car(G3)) < <<2,0,0,0>> ) T = cons(car(G3),T);
440: return [reverse(T),Mod];
441: #endif
442: return [G3,Mod];
443: }
444: #else
445:
446: def iso_eq_gentrace(B,V,Mod)
447: {
1.2 ! noro 448: W = [1,3,2,3,2,1];
1.1 noro 449:
450: dp_set_weight(W);
451: N1 = nd_f4(B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
452: G1 = N1[0];
453: G1 = elim_top(G1,<<1,0,0,0,0>>);
454: V1 = cdr(V);
455: G1 = map(dp_dtop,G1,V);
456:
457: D = res(x,x^3+a*x+b,3*x^2+a);
458: N2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
459: G2 = N2[0];
460: G2 = elim_top(G2,<<1,0,0,0,0>>);
461: G2 = map(dp_dtop,G2,cons(t,V1));
462:
463: W1 = cdr(W);
464: dp_set_weight(W1);
465: N3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,gentrace=1);
466: return [N1,N2,N3];
467: }
468:
469: def iso_eq_mod(Mod)
470: {
471: V = [c1,bb,aa,b,a];
1.2 ! noro 472: W = [1,3,2,3,2,1];
1.1 noro 473:
474: dp_set_weight(W);
475: if ( GB_N1 )
476: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N1);
477: else
478: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1);
479: G1 = elim_top(G1,<<1,0,0,0,0>>);
480: V1 = cdr(V);
481: G1 = map(dp_dtop,G1,V);
482:
483: D = res(x,x^3+a*x+b,3*x^2+a);
484: if ( GB_N2 )
485: G2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N2);
486: else
487: G2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]|dp=1,nora=1);
488: G2 = elim_top(G2,<<1,0,0,0,0>>);
489: G2 = map(dp_dtop,G2,cons(t,V1));
490:
491: W1 = cdr(W);
492: dp_set_weight(W1);
493: if ( GB_N3 )
494: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,trace=GB_N3);
495: else
496: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1);
497: G3 = elim_top(G3,<<2,0,0,0>>);
498: return [G3,Mod];
499: }
500:
501: def elim_top(G,H)
502: {
503: N = length(dp_etov(dp_ht(G[0])));
504: Ord = dp_ord();
505: dp_ord([[0,1],[0,N-1]]);
506: for ( T = []; G != []; G = cdr(G) )
507: if ( dp_ht(car(G)) < H ) T = cons(car(G),T);
508: dp_ord(Ord);
509: return reverse(T);
510: }
511: #endif
512:
513: def iso_eq_d2(L)
514: {
515: Proc = getopt(proc);
516: if ( type(Proc) == -1 ) {
517: Proc = [];
518: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
519: } else if ( type(Proc) == 1 ) {
520: M = Proc;
521: Proc = [];
522: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
523: }
524: F = generateF(L);
525: A = polysys(F);
526: A = simpsys(A);
527: C = A[0]; B = A[1]; V = A[2]; W = A[3];
528:
529: map(ox_reset,Proc);
530: B = map(ptozp,B);
531: NProc = length(Proc);
532: CRTime = 0; IRTime = 0;
533: /* gentrace */
534: L = iso_eq_gentrace(B,V,lprime(0));
535: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,L[0],L[1],L[2]);
536: map(ox_pop_local,Proc);
537: I = 0;
538: N = 0;
539: Remain = 1; /* dummy */
540: Mod = 1;
541: O = [[0,1],[0,3]];
542: dp_ord(O);
543: dp_set_weight(cdr(W));
544: for ( T = Proc; T != []; T = cdr(T), I++ )
545: ox_rpc(car(T),"noro_grcrt.iso_eq_mod",lprime(I));
546: V1 = cdr(V);
547: while ( Remain ) {
548: for ( T = Proc; T != []; T = cdr(T), I++ ) {
549: print(["from",car(T)],2);
550: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
551: print(" done");
552: ox_rpc(car(T),"noro_grcrt.iso_eq_mod",lprime(I));
553: if ( GM ) {
554: L = monic_gb(GM,V1,O,P); GM = L[0];
555: if ( !N ) {
556: Remain = N = length(GM);
557: Stat = vector(N);
558: G = vector(N);
559: }
560: T0 = time();
561: Fail = dp_chrem2(G,Mod,GM,P,Stat);
562: Remain += Fail;
563: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
564: Mod *= P;
565: }
566: }
567: T0 = time();
568: New = intdpltoratdpl2(G,Mod,Stat);
569: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
570: Remain -= New;
571: print((N-Remain)/N*100.0,0); print("% done");
572: }
573: map(ox_reset,Proc);
574: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
575: return [vtol(map(dp_dtop,G,V1)),Proc];
576: }
577:
578: def iso_c1eq_mod(Mod)
579: {
580: V = [c1,bb,aa,b,a];
1.2 ! noro 581: W = [1,3,2,3,2,1];
1.1 noro 582:
583: dp_set_weight(W);
584: if ( GB_N1 )
585: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N1);
586: else
587: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1);
588: G1 = elim_top(G1,<<2,0,0,0,0>>);
589: return [G1,Mod];
590: }
591:
592: def iso_c1eq_d2(L)
593: {
594: Proc = getopt(proc);
595: if ( type(Proc) == -1 ) {
596: Proc = [];
597: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
598: } else if ( type(Proc) == 1 ) {
599: M = Proc;
600: Proc = [];
601: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
602: }
603: F = generateF(L);
604: A = polysys(F);
605: A = simpsys(A);
606: C = A[0]; B = A[1]; V = A[2]; W = A[3];
607:
608: map(ox_reset,Proc);
609: B = map(ptozp,B);
610: NProc = length(Proc);
611: CRTime = 0; IRTime = 0;
612: /* gentrace */
1.2 ! noro 613: W = [1,3,2,3,2,1];
1.1 noro 614: dp_set_weight(W);
615: N1 = nd_f4(B,V,lprime(0),[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
616: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,N1,0,0);
617: map(ox_pop_local,Proc);
618: I = 0;
619: N = 0;
620: Remain = 1; /* dummy */
621: Mod = 1;
622: O = [[0,1],[0,4]];
623: dp_ord(O);
624: for ( T = Proc; T != []; T = cdr(T), I++ )
625: ox_rpc(car(T),"noro_grcrt.iso_c1eq_mod",lprime(I));
626: V1 = cdr(V);
627: while ( Remain ) {
628: for ( T = Proc; T != []; T = cdr(T), I++ ) {
629: print(["from",car(T)],2);
630: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
631: print(" done");
632: ox_rpc(car(T),"noro_grcrt.iso_c1eq_mod",lprime(I));
633: if ( GM ) {
634: L = monic_gb(GM,V1,O,P); GM = L[0];
635: if ( !N ) {
636: Remain = N = length(GM);
637: Stat = vector(N);
638: G = vector(N);
639: }
640: T0 = time();
641: Fail = dp_chrem2(G,Mod,GM,P,Stat);
642: Remain += Fail;
643: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
644: Mod *= P;
645: }
646: }
647: T0 = time();
648: New = intdpltoratdpl2(G,Mod,Stat);
649: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
650: Remain -= New;
651: print((N-Remain)/N*100.0,0); print("% done");
652: }
653: map(ox_reset,Proc);
654: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
655: return [vtol(map(dp_dtop,G,V)),Proc];
656: }
657:
658: def iso_eq_gentrace2(B,V,Mod)
659: {
1.2 ! noro 660: Wt = [1,1,3,2,3,2,1];
1.1 noro 661: Vt = cons(t,V);
662: dp_set_weight(Wt);
663: D = res(x,x^3+a*x+b,3*x^2+a);
664: N1 = nd_f4(cons(t*D-1,B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1,gentrace=1);
665: G1 = N1[0];
666: G1 = elim_top(G1,<<1,0,0,0,0,0>>);
667: G1 = map(dp_dtop,G1,Vt);
668:
669: W = cdr(Wt);
670: dp_set_weight(W);
671: N2 = nd_f4(G1,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
672: G2 = N2[0];
673: G2 = elim_top(G2,<<1,0,0,0,0>>);
674: G2 = map(dp_dtop,G2,V);
675:
676: W1 = cdr(W);
677: V1 = cdr(V);
678: dp_set_weight(W1);
679: N3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,gentrace=1);
680: return [N1,N2,N3];
681: }
682:
683: def iso_eq_mod2(Mod)
684: {
685: V = [c1,bb,aa,b,a];
686: Vt = cons(t,V);
1.2 ! noro 687: Wt = [1,1,3,2,3,2,1];
1.1 noro 688: dp_set_weight(Wt);
689: D = res(x,x^3+a*x+b,3*x^2+a);
690: if ( GB_N1 )
691: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1,trace=GB_N1);
692: else
693: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1);
694: G1 = elim_top(G1,<<1,0,0,0,0,0>>);
695: G1 = map(dp_dtop,G1,Vt);
696:
697: W = cdr(Wt);
698: dp_set_weight(W);
699: if ( GB_N2 )
700: G2 = nd_f4(G1,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N2);
701: else
702: G2 = nd_f4(G1,V,Mod,[[0,1],[0,4]]|dp=1,nora=1);
703: G2 = elim_top(G2,<<1,0,0,0,0>>);
704: G2 = map(dp_dtop,G2,V);
705:
706: W1 = cdr(W);
707: V1 = cdr(V);
708: dp_set_weight(W1);
709: if ( GB_N3 )
710: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,trace=GB_N3);
711: else
712: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1);
713: G3 = elim_top(G3,<<2,0,0,0>>);
714: return [G3,Mod];
715: }
716:
717: def iso_eq_d2new(L)
718: {
719: Proc = getopt(proc);
720: if ( type(Proc) == -1 ) {
721: Proc = [];
722: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
723: } else if ( type(Proc) == 1 ) {
724: M = Proc;
725: Proc = [];
726: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
727: }
728: F = generateF(L);
729: A = polysys(F);
730: A = simpsys(A);
731: C = A[0]; B = A[1]; V = A[2]; W = A[3];
732:
733: map(ox_reset,Proc);
734: B = map(ptozp,B);
735: NProc = length(Proc);
736: CRTime = 0; IRTime = 0;
737: /* gentrace */
738: L = iso_eq_gentrace2(B,V,lprime(0));
739: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,L[0],L[1],L[2]);
740: map(ox_pop_local,Proc);
741: I = 0;
742: N = 0;
743: Remain = 1; /* dummy */
744: Mod = 1;
745: O = [[0,1],[0,3]];
746: dp_ord(O);
747: dp_set_weight(cdr(W));
748: for ( T = Proc; T != []; T = cdr(T), I++ )
749: ox_rpc(car(T),"noro_grcrt.iso_eq_mod2",lprime(I));
750: V1 = cdr(V);
751: while ( Remain ) {
752: for ( T = Proc; T != []; T = cdr(T), I++ ) {
753: print(["from",car(T)],2);
754: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
755: print(" done");
756: ox_rpc(car(T),"noro_grcrt.iso_eq_mod2",lprime(I));
757: if ( GM ) {
758: L = monic_gb(GM,V1,O,P); GM = L[0];
759: if ( !N ) {
760: Remain = N = length(GM);
761: Stat = vector(N);
762: G = vector(N);
763: }
764: T0 = time();
765: Fail = dp_chrem2(G,Mod,GM,P,Stat);
766: Remain += Fail;
767: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
768: Mod *= P;
769: }
770: }
771: T0 = time();
772: New = intdpltoratdpl2(G,Mod,Stat);
773: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
774: Remain -= New;
775: print((N-Remain)/N*100.0,0); print("% done");
776: }
777: map(ox_reset,Proc);
778: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
779: return [vtol(map(dp_dtop,G,V1)),Proc];
780: }
781:
782: def iso_sat_gentrace(B,V,Mod)
783: {
1.2 ! noro 784: Wt = [1,1,3,2,3,2,1];
1.1 noro 785: Vt = cons(t,V);
786: dp_set_weight(Wt);
787: D = res(x,x^3+a*x+b,3*x^2+a);
788: N1 = nd_f4(cons(t*D-1,B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1,gentrace=1);
789: return N1;
790: }
791:
792: def iso_sat_mod(Mod)
793: {
794: V = [c1,bb,aa,b,a];
795: Vt = cons(t,V);
1.2 ! noro 796: Wt = [1,1,3,2,3,2,1];
1.1 noro 797: dp_set_weight(Wt);
798: D = res(x,x^3+a*x+b,3*x^2+a);
799: if ( GB_N1 )
800: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1,trace=GB_N1);
801: else
802: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1);
803: G1 = elim_top(G1,<<1,0,0,0,0,0>>);
804: return [G1,Mod];
805: }
806:
807: def iso_sat_d2(L)
808: {
809: Proc = getopt(proc);
810: Sys = getopt(sys);
811: if ( type(Proc) == -1 ) {
812: Proc = [];
813: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
814: } else if ( type(Proc) == 1 ) {
815: M = Proc;
816: Proc = [];
817: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
818: }
819: if ( type(Sys) == -1 ) {
820: F = generateF(L);
821: A = polysys(F);
822: A = simpsys(A);
823: C = A[0]; B = A[1]; V = A[2]; W = A[3];
824: } else {
825: C = Sys[0]; B = Sys[1]; V = Sys[2]; W = Sys[3];
826: }
827:
828: map(ox_reset,Proc);
829: B = map(ptozp,B);
830: NProc = length(Proc);
831: CRTime = 0; IRTime = 0;
832: /* gentrace */
833: NZ = iso_sat_gentrace(B,V,lprime(0));
834: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,NZ,0,0);
835: map(ox_pop_local,Proc);
836: I = 0;
837: N = 0;
838: Remain = 1; /* dummy */
839: Mod = 1;
840: Vt = [t,c1,bb,aa,b,a];
841: Wt = [1,1,3,2,3,2,1];
842: O = [[0,1],[0,5]];
843: dp_ord(O);
844: dp_set_weight(Wt);
845: for ( T = Proc; T != []; T = cdr(T), I++ )
846: ox_rpc(car(T),"noro_grcrt.iso_sat_mod",lprime(I));
847: while ( Remain ) {
848: for ( T = Proc; T != []; T = cdr(T), I++ ) {
849: print(["from",car(T)],2);
850: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
851: print(" done");
852: ox_rpc(car(T),"noro_grcrt.iso_sat_mod",lprime(I));
853: if ( GM ) {
854: L = monic_gb(GM,Vt,O,P); GM = L[0];
855: if ( !N ) {
856: Remain = N = length(GM);
857: Stat = vector(N);
858: G = vector(N);
859: }
860: T0 = time();
861: Fail = dp_chrem2(G,Mod,GM,P,Stat);
862: Remain += Fail;
863: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
864: Mod *= P;
865: }
866: }
867: T0 = time();
868: New = intdpltoratdpl2(G,Mod,Stat);
869: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
870: Remain -= New;
871: print((N-Remain)/N*100.0,0); print("% done");
872: }
873: map(ox_reset,Proc);
874: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
875: return [vtol(map(dp_dtop,G,Vt)),Proc];
876: }
877:
878: endmodule$
879:
880: end$
881:
882: /* old functions */
883:
884: def gr_chrem(B,V,O)
885: {
886: Proc = getopt(proc);
887: Dname = getopt(dname);
888: if ( type(Proc) != -1 ) {
889: if ( type(Dname) != -1 )
890: return gr_chr_d(B,V,O,Proc,Dname);
891: else
892: return gr_chrem_d(B,V,O,Proc);
893: }
894:
895: B = map(ptozp,B);
896: Mod = 1;
897: D = nd_gr(B,V,lprime(0),O|gentrace=1);
898: Remain = N = length(D[0]);
899: Stat = vector(N);
900: G = vector(N);
901: for ( I = 1; Remain; I++ ) {
902: P = lprime(I);
903: GM = nd_gr_recompute_trace(B,V,P,O,D);
904: if ( !GM ) continue;
905: L = monic_gb(GM,V,O,P); GM = L[0];
906: T0 = time();
907: dp_chrem2(G,Mod,GM,P,Stat);
908: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
909: Mod *= P;
910: if ( !(I%3) ) {
911: T0 = time();
912: New = intdpltoratdpl2(G,Mod,Stat);
913: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
914: Remain -= New;
915: }
916: }
917: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
918: return vtol(map(dp_dtop,G,V));
919: }
920:
921: /* NZ = [*,*,NZ,BPE] */
922:
923: def f4_chrem(B,V,O)
924: {
925: Proc = getopt(proc);
926: NZ = getopt(nz);
927: Prev = getopt(prev);
928: Homo = getopt(homo);
929: Elim = getopt(elim);
930: Weight = getopt(weight);
931: if ( type(NZ) == -1 ) NZ = 0;
932: if ( type(Prev) == -1 ) Prev = 0;
933: if ( type(Homo) == -1 ) Homo = 0;
934: if ( type(Elim) == -1 ) Elim = -1;
935: if ( type(Weight) == -1 ) Weight = 0;
936: OldWeight = dp_set_weight();
937: dp_set_weight(Weight);
938: if ( type(Proc) != -1 ) {
939: if ( NZ )
940: G = f4_chr_d(B,V,O,Proc,NZ,Prev,Homo,Elim,Weight);
941: else
942: G = f4_chrem_d(B,V,O,Proc);
943: dp_set_weight(OldWeight);
944: return G;
945: }
946: B = map(ptozp,B);
947: Remain = 1; /* XXX */
948: for ( I = 0, N = 0, Mod = 1; Remain; I++ ) {
949: P = lprime(I);
950: if ( NZ )
951: GM = nd_f4(B,V,P,O|dp=1,trace=NZ);
952: else
953: GM = nd_f4(B,V,P,O|dp=1);
954: if ( !GM ) continue;
955: if ( !N ) {
956: Remain = N = length(GM);
957: Stat = vector(N);
958: G = vector(N);
959: }
960: L = monic_gb(GM,V,O,P); GM = L[0];
961: T0 = time();
962: dp_chrem2(G,Mod,GM,P,Stat);
963: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
964: Mod *= P;
965: if ( !(I%3) ) {
966: T0 = time();
967: New = intdpltoratdpl2(G,Mod,Stat);
968: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
969: Remain -= New;
970: }
971: }
972: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
973: G = vtol(map(dp_dtop,G,V));
974: dp_set_weight(OldWeight);
975: return G;
976: }
977:
978: def gr_chrem_d(B,V,O,Proc)
979: {
980: map(ox_reset,Proc);
981: B = map(ptozp,B);
982: NProc = length(Proc); D = vector(NProc); H = vector(NProc);
983: CRTime = 0; IRTime = 0;
984: /* gentrace */
985: I = 0;
986: T0 = time();
987: while ( 1 ) {
988: for ( J = 0; J < NProc; J++, I++ )
989: ox_rpc(Proc[J],"noro_grcrt.nd_gr_gentrace_p",B,V,lprime(I),O);
990: for ( J = 0; J < NProc; J++, I++ ) {
991: D[J] = ox_pop_local(Proc[J]);
992: H[J] = map(dp_ptod,D[J][0][0],V);
993: }
994: for ( J = 1; J < NProc; J++ )
995: if ( map(dp_ht,H[J]) != map(dp_ht,H[0]) ) break;
996: if ( J == NProc ) break;
997: }
998: T1 = time(); TTime += (T1[3]-T0[3]);
999: print(["Template",TTime]);
1000: map(ox_rpc,Proc,"noro_grcrt.store_history",D[0][0]); map(ox_pop_local,Proc);
1001: for ( J = 0; J < NProc; J++, I++ )
1002: ox_rpc(Proc[J],"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1003:
1004: Remain = N = length(D[0][0][0]);
1005: Stat = vector(N); G = vector(N);
1006: Mod = 1;
1007:
1008: for ( J = 0; J < NProc; J++ ) {
1009: P = D[J][1];
1010: L = monic_gb(H[J],V,O,P); GM = L[0];
1011: T0 = time();
1012: dp_chrem2(G,Mod,GM,P,Stat);
1013: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1014: Mod *= P;
1015: }
1016:
1017: while ( Remain ) {
1018: for ( T = Proc; T != []; T = cdr(T), I++ ) {
1019: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1020: ox_rpc(car(T),"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1021: if ( GM ) {
1022: L = monic_gb(GM,V,O,P); GM = L[0];
1023: T0 = time();
1024: dp_chrem2(G,Mod,GM,P,Stat);
1025: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1026: Mod *= P;
1027: }
1028: }
1029: T0 = time();
1030: New = intdpltoratdpl2(G,Mod,Stat);
1031: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1032: Remain -= New;
1033: print((N-Remain)/N*100.0,0); print("% done");
1034: }
1035: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I-NProc]);
1036: return vtol(map(dp_dtop,G,V));
1037: }
1038:
1039: def gr_chr_d(B,V,O,Proc,Dname)
1040: {
1041: map(ox_reset,Proc);
1042: B = map(ptozp,B);
1043: NProc = length(Proc); D = vector(NProc); H = vector(NProc);
1044: CRTime = 0; IRTime = 0;
1045: /* gentrace */
1046: map(ox_rpc,Proc,"noro_grcrt.read_history",Dname); map(ox_pop_local,Proc);
1047: for ( J = 0; J < NProc; J++, I++ )
1048: ox_rpc(Proc[J],"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1049:
1050: Remain = N = length(D[0][0][0]);
1051: Stat = vector(N); G = vector(N);
1052: Mod = 1;
1053:
1054: for ( J = 0; J < NProc; J++ ) {
1055: P = D[J][1];
1056: L = monic_gb(H[J],V,O,P); GM = L[0];
1057: T0 = time();
1058: dp_chrem2(G,Mod,GM,P,Stat);
1059: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1060: Mod *= P;
1061: }
1062:
1063: while ( Remain ) {
1064: for ( T = Proc; T != []; T = cdr(T), I++ ) {
1065: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1066: ox_rpc(car(T),"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1067: if ( GM ) {
1068: L = monic_gb(GM,V,O,P); GM = L[0];
1069: T0 = time();
1070: dp_chrem2(G,Mod,GM,P,Stat);
1071: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1072: Mod *= P;
1073: }
1074: }
1075: T0 = time();
1076: New = intdpltoratdpl2(G,Mod,Stat);
1077: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1078: Remain -= New;
1079: print((N-Remain)/N*100.0,0); print("% done");
1080: }
1081: print(["CRT",CRTime,"IR",IRTime,"#P",I-NProc]);
1082: return vtol(map(dp_dtop,G,V));
1083: }
1084:
1085: def f4_chrem_d(B,V,O,Proc)
1086: {
1087: map(ox_reset,Proc);
1088: B = map(ptozp,B);
1089: NProc = length(Proc); D = vector(NProc); H = vector(NProc);
1090: CRTime = 0; IRTime = 0;
1091: /* gentrace */
1092: I = 0;
1093: map(ox_rpc,Proc,"noro_grcrt.store_bv",B,V);
1094: map(ox_pop_local,Proc);
1095: T0 = time();
1096: while ( 1 ) {
1097: for ( J = 0; J < NProc; J++, I++ )
1098: ox_rpc(Proc[J],"noro_grcrt.nd_f4_p",lprime(I),O);
1099: for ( J = 0; J < NProc; J++ ) {
1100: D[J] = ox_pop_local(Proc[J]);
1101: H[J] = D[J][0];
1102: }
1103: for ( J = 1; J < NProc; J++ )
1104: if ( map(dp_ht,H[J]) != map(dp_ht,H[0]) ) break;
1105: if ( J == NProc ) break;
1106: }
1107: T1 = time(); TTime += (T1[3]-T0[3]);
1108: print(["Template",TTime]);
1109: for ( J = 0; J < NProc; J++, I++ )
1110: ox_rpc(Proc[J],"noro_grcrt.nd_f4_p",lprime(I),O);
1111:
1112: Remain = N = length(D[0][0]);
1113: Stat = vector(N); G = vector(N);
1114: Mod = 1;
1115:
1116: for ( J = 0; J < NProc; J++ ) {
1117: P = D[J][1];
1118: L = monic_gb(H[J],V,O,P); GM = L[0];
1119: T0 = time();
1120: dp_chrem2(G,Mod,GM,P,Stat);
1121: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1122: Mod *= P;
1123: }
1124:
1125: while ( Remain ) {
1126: for ( T = Proc; T != []; T = cdr(T), I++ ) {
1127: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1128: ox_rpc(car(T),"noro_grcrt.nd_f4_p",lprime(I),O);
1129: if ( GM ) {
1130: L = monic_gb(GM,V,O,P); GM = L[0];
1131: T0 = time();
1132: dp_chrem2(G,Mod,GM,P,Stat);
1133: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1134: Mod *= P;
1135: }
1136: }
1137: T0 = time();
1138: New = intdpltoratdpl2(G,Mod,Stat);
1139: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1140: Remain -= New;
1141: print((N-Remain)/N*100.0,0); print("% done");
1142: }
1143: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I-NProc]);
1144: return vtol(map(dp_dtop,G,V));
1145: }
1146:
1147: def nd_f4_p(P,O)
1148: {
1149: return [nd_f4(GB_B,GB_V,P,O|dp=1),P];
1150: }
1151:
1152: def store_bv(B,V)
1153: {
1154: GB_B=B;
1155: GB_V=V;
1156: }
1157:
1158:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>