Annotation of OpenXM/src/asir-contrib/testing/noro/grcrt.rr, Revision 1.3
1.1 noro 1: module noro_grcrt$
2:
1.3 ! noro 3: localf f4_chr, f4_chr_d, store_history, read_history, store_bv,
1.1 noro 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$
1.3 ! noro 11: localf large_factor,largefactor_res,intptoratp,p_chrem2,p_checkcrt,store_minipoly$
! 12: localf iso_sat_d3,minipoly_chr$
! 13: localf nd_gr_p2$
1.1 noro 14:
15: static GB_History,GB_B,GB_V,GB_N,GB_H$
16: static GB_N1,GB_N2,GB_N3$
17: static GB_NZ$
1.3 ! noro 18: static MiniPoly$
1.1 noro 19:
20: def f4_chr(B,V,O)
21: {
22: dp_ord(O);
23: Proc = getopt(proc);
24: NZ = getopt(nz);
25: Prev = getopt(prev);
26: Homo = getopt(homo);
27: Elim = getopt(elim);
28: Weight = getopt(weight);
29: if ( type(Prev) == -1 ) Prev = 0;
30: if ( type(Homo) == -1 ) Homo = 0;
31: if ( type(Elim) == -1 ) Elim = -1;
32: if ( type(Weight) == -1 ) Weight = 0;
33: OldWeight = dp_set_weight();
34: dp_set_weight(Weight);
1.3 ! noro 35: #if 1
1.1 noro 36: if ( type(NZ) == -1 )
1.3 ! noro 37: NZ = nd_f4(B,V,lprime(0),O|gentrace=1,homo=Homo);
! 38: #endif
1.1 noro 39: if ( type(Proc) != -1 ) {
1.3 ! noro 40: #if 1
1.1 noro 41: G = f4_chr_d(B,V,O,Proc,NZ,Prev,Homo,Elim,Weight);
1.3 ! noro 42: #else
! 43: G = f4_chr_d(B,V,O,Proc,0,Prev,Homo,Elim,Weight);
! 44: #endif
1.1 noro 45: dp_set_weight(OldWeight);
46: return G;
47: }
48: B = map(ptozp,B);
1.3 ! noro 49: for ( I = 0, N = 0, Mod = 1; ; I++ ) {
1.1 noro 50: P = lprime(I);
1.3 ! noro 51: #if 1
! 52: GM = nd_f4(B,V,P,O|dp=1,trace=NZ,homo=Homo);
! 53: #else
! 54: GM = nd_f4(B,V,P,O|dp=1,homo=Homo);
! 55: #endif
1.1 noro 56: if ( !GM ) continue;
57: if ( Elim >= 0 ) GM = elimination(GM,Elim);
58: if ( !N ) {
59: Remain = N = length(GM);
60: Stat = vector(N);
61: G = vector(N);
62: }
63: L = monic_gb(GM,V,O,P); GM = L[0];
64: T0 = time();
65: dp_chrem2(G,Mod,GM,P,Stat);
66: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
67: Mod *= P;
1.3 ! noro 68: if ( !(I%1) ) {
1.1 noro 69: T0 = time();
1.3 ! noro 70: intdpltoratdpl2(G,Mod,Stat);
1.1 noro 71: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
72: }
1.3 ! noro 73: for ( J = 0; J < N; J++ )
! 74: if ( Stat[J] < 3 ) break;
! 75: if ( J == N ) break;
1.1 noro 76: }
77: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
78: G = vtol(map(dp_dtop,G,V));
79: dp_set_weight(OldWeight);
80: return G;
81: }
82:
83: /* Prev = [G,Stat,I,Mod] */
84:
85: def f4_chr_d(B,V,O,Proc,NZ,Prev,Homo,Elim,Weight)
86: {
87: map(ox_reset,Proc);
88: B = map(ptozp,B);
89: NProc = length(Proc);
90: CRTime = 0; IRTime = 0;
91: /* gentrace */
92: map(ox_rpc,Proc,"dp_set_weight",Weight);
93: map(ox_pop_local,Proc);
1.3 ! noro 94: map(ox_rpc,Proc,"noro_grcrt.store_bvn",B,V,NZ,Homo);
! 95: map(ox_pop_local,Proc);
! 96: if ( Prev ) {
! 97: G = Prev[0];
! 98: N = length(N);
! 99: Stat = Prev[1];
! 100: for ( J = 0, Remain = 0; J < N; J++ )
! 101: if ( Stat[J] != 2 ) Remain++;
! 102: I = Prev[2];
! 103: Mod = Prev[3];
! 104: } else {
! 105: I = 0;
! 106: N = 0;
! 107: Remain = 1; /* dummy */
! 108: Mod = 1;
! 109: }
! 110: for ( T = Proc; T != []; T = cdr(T), I++ )
! 111: ox_rpc(car(T),"noro_grcrt.nd_f4_p2",lprime(I),O);
! 112: map(ox_push_cmd,Proc,258);
! 113: while ( 1 ) {
! 114: Ready = ox_select(Proc);
! 115: for ( T = Ready; T != []; T = cdr(T), I++ ) {
! 116: print(["from",car(T)],2);
! 117: L = ox_get(car(T)); GM = L[0]; P = L[1];
! 118: if ( Elim >= 0 ) GM = elimination(GM,Elim);
! 119: print(" done ",2); print(L[2]);
! 120: ox_rpc(car(T),"noro_grcrt.nd_f4_p2",lprime(I),O);
! 121: ox_push_cmd(car(T),258);
! 122: if ( GM ) {
! 123: L = monic_gb(GM,V,O,P); GM = L[0];
! 124: if ( !N ) {
! 125: N = length(GM);
! 126: Stat = vector(N);
! 127: G = vector(N);
! 128: }
! 129: T0 = time();
! 130: dp_chrem2(G,Mod,GM,P,Stat);
! 131: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
! 132: Mod *= P;
! 133: }
! 134: }
! 135: T0 = time();
! 136: intdpltoratdpl2(G,Mod,Stat);
! 137: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
! 138: for ( J = Remain = 0; J < N; J++ )
! 139: if ( Stat[J] < 3 ) Remain++;
! 140: print((N-Remain)/N*100.0,0); print("% done");
! 141: if ( !Remain ) break;
! 142: }
! 143: map(ox_reset,Proc);
! 144: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
! 145: return vtol(map(dp_dtop,G,V));
1.1 noro 146: }
147:
148: def store_history(D)
149: {
1.3 ! noro 150: GB_History=D;
! 151: return 1;
1.1 noro 152: }
153:
154: def read_history(Dname)
155: {
1.3 ! noro 156: GB_History=bload(Dname);
! 157: return 1;
1.1 noro 158: }
159:
160:
161: def store_bvn(B,V,N,H)
162: {
1.3 ! noro 163: GB_B=B;
! 164: GB_V=V;
! 165: if ( type(N) == 7 )
! 166: GB_N = bload(N);
! 167: else
! 168: GB_N=N;
! 169: GB_H=H;
1.1 noro 170: }
171:
172: def store_bvn3(B,V,N1,N2,N3)
173: {
1.3 ! noro 174: GB_B=B;
! 175: GB_V=V;
1.1 noro 176: GB_N1 = N1;
177: GB_N2 = N2;
178: GB_N3 = N3;
179: }
180:
181:
182: def nd_f4_p2(P,O)
183: {
1.3 ! noro 184: T0 = time()[3];
! 185: #if 0
! 186: if ( GB_H )
! 187: return [nd_f4(GB_B,GB_V,P,O|dp=1,homo=GB_H,trace=GB_N,nora=1),P,time()[3]-T0];
! 188: else
! 189: #endif
! 190: return [nd_f4(GB_B,GB_V,P,O|dp=1,homo=GB_H,trace=GB_N),P,time()[3]-T0];
1.1 noro 191: }
192:
1.3 ! noro 193: def nd_gr_p2(P,O)
! 194: {
! 195: T0 = time()[3];
! 196: return [nd_gr_recompute_trace(GB_B,GB_V,P,O,GB_H|dp=1,trace=GB_N),P,time()[3]-T0];
! 197: }
1.1 noro 198:
199: def nd_gr_recompute_trace_p(B,V,P,O)
200: {
1.3 ! noro 201: T0 = time();
! 202: R = nd_gr_recompute_trace(B,V,P,O,GB_History);
! 203: T1 = time();
! 204: Time = (T1[0]-T0[0])+(T1[1]-T0[1]);
! 205: return [nd_gr_recompute_trace(B,V,P,O,GB_History),P,Time];
1.1 noro 206: }
207:
208: def nd_gr_gentrace_p(B,V,P,O)
209: {
1.3 ! noro 210: return [nd_gr(B,V,P,O|gentrace=1),P];
1.1 noro 211: }
212:
213: def comp_by_ht(A,B)
214: {
1.3 ! noro 215: HA = dp_ht(A); HB = dp_ht(B);
! 216: if ( HA > HB )
! 217: return 1;
! 218: else if ( HA < HB )
! 219: return -1;
! 220: else
! 221: return 0;
1.1 noro 222: }
223:
224: def intdpltoratdpl2(G,Mod,Stat)
225: {
1.3 ! noro 226: N = size(G)[0];
! 227: M = calcb(Mod);
! 228: New = 0;
! 229: Den = 1;
! 230: for ( I = 0; I < N; I++ ) {
! 231: if ( Stat[I] >= 2 ) continue;
! 232: if ( !I || dp_td(G[I]) != dp_td(G[I-1]) )
! 233: Den = 1;
! 234: T = intdptoratdp(G[I]*Den,Mod,M);
! 235: if ( T ) {
! 236: print([I],2);
! 237: T = dp_ptozp(T);
! 238: Den = ilcm(Den,dp_hc(T));
! 239: G[I] = T; Stat[I] = 2;
! 240: } else {
! 241: print("("+rtostr(I)+")",2);
! 242: }
! 243: if ( Stat[I] >= 3 ) New++;
! 244: }
! 245: print("");
! 246: return New;
1.1 noro 247: }
248:
249: def intdptoratdp(F,Mod,M)
250: {
1.3 ! noro 251: for ( T = F, N = 0; T; T = dp_rest(T), N++ );
! 252: C = newvect(N);
! 253: for ( I = 0, T = F; I < N; T = dp_rest(T), I++ ) {
! 254: L = inttorat(dp_hc(T)%Mod,Mod,M);
! 255: if ( !L )
! 256: return 0;
! 257: else
! 258: C[I] = (L[0]/L[1])*dp_ht(T);
! 259: }
! 260: for ( R = 0, I = N-1; I >= 0; I-- )
! 261: R += C[I];
! 262: return R;
! 263: }
! 264:
! 265: def intptoratp(P,M,B) {
! 266: if ( type(P) == 1 ) {
! 267: L = inttorat(P%M,M,B);
! 268: if ( L == 0 )
! 269: return 0;
! 270: else
! 271: return L[0]/L[1];
! 272: } else {
! 273: V = var(P);
! 274: S = 0;
! 275: while ( P ) {
! 276: D = deg(P,V);
! 277: C = coef(P,D,V);
! 278: T = intptoratp(C,M,B);
! 279: if ( T == 0 )
! 280: return 0;
! 281: S += T*V^D;
! 282: P -= C*V^D;
! 283: }
! 284: return S;
! 285: }
1.1 noro 286: }
287:
288: def dp_mulmod(C,F,M)
289: {
1.3 ! noro 290: L = [];
! 291: for ( T = F; T; T = dp_rest(T) ) {
! 292: A = (dp_hc(T)*C)%M;
! 293: L = cons(A*dp_ht(T),L);
! 294: }
! 295: for ( R = 0; L != []; L = cdr(L) )
! 296: R += car(L);
! 297: return R;
1.1 noro 298: }
299:
300: def dp_chrem2(G,Mod,GM,P,Stat)
301: {
1.3 ! noro 302: N = size(G)[0];
! 303: setmod(P);
! 304: M1 = ptomp(inv(Mod,P),P);
! 305: Fail = 0;
! 306: for ( I = 0; I < N; I++ ) {
! 307: if ( Stat[I] >= 2 ) {
! 308: T = dp_mod(G[I],P,[]); T = dp_rat(T/dp_hc(T));
! 309: if ( GM[I] != T ) {
! 310: C = inv(dp_hc(G[I]),Mod);
! 311: G[I] = dp_mulmod(C,G[I],Mod);
! 312: if ( dp_hc(G[I]) != 1 )
! 313: error("");
! 314: Stat[I] = 0;
! 315: Fail++;
! 316: } else {
! 317: Stat[I]++;
! 318: continue;
! 319: }
! 320: }
! 321: T = (dp_mod(GM[I],P,[])-dp_mod(G[I],P,[]))*M1;
! 322: G[I] = G[I]+dp_rat(T)*Mod;
! 323: Stat[I] = 1;
1.1 noro 324: #if 0
1.3 ! noro 325: print("|"+rtostr(I),2);
1.1 noro 326: #endif
1.3 ! noro 327: }
! 328: return Fail;
1.1 noro 329: #if 0
1.3 ! noro 330: print("");
1.1 noro 331: #endif
332: }
333:
1.3 ! noro 334: def p_checkcrt(G,G0,P)
! 335: {
! 336: setmod(P);
! 337: GM = mptop(ptomp(G));
! 338: if ( GM == G0 ) return 1;
! 339: else return 0;
! 340: }
! 341:
! 342: def p_chrem2(G,Mod,GM,P)
! 343: {
! 344: M1 = inv(Mod,P);
! 345: G += (GM-G)*(M1*Mod);
! 346: Mod1 = Mod*P;
! 347: G %= Mod1;
! 348: return G;
! 349: }
! 350:
1.1 noro 351: def monic_gb(D,V,O,P)
352: {
1.3 ! noro 353: dp_ord(O); setmod(P);
1.1 noro 354: /* D = map(dp_ptod,G,V); */
1.3 ! noro 355: D = map(dp_monic_mod,D,P);
1.1 noro 356: /* D = vtol(qsort(newvect(length(D),D),comp_by_ht)); */
1.3 ! noro 357: return [D,map(dp_ht,D)];
1.1 noro 358: }
359:
360: def dp_monic_mod(F,P)
361: {
1.3 ! noro 362: FP = dp_mod(F,P,[]);
! 363: return dp_rat(FP/dp_hc(FP));
1.1 noro 364: }
365:
366: def calcb(M) {
1.3 ! noro 367: N = 2*M;
! 368: T = sp_sqrt(N);
! 369: if ( T^2 <= N && N < (T+1)^2 )
! 370: return idiv(T,2);
! 371: else
! 372: error("afo");
1.1 noro 373: }
374:
375: def sp_sqrt(A) {
1.3 ! noro 376: for ( J = 0, T = A; T >= 2^27; J++ ) {
! 377: T = idiv(T,2^27)+1;
! 378: }
! 379: for ( I = 0; T >= 2; I++ ) {
! 380: S = idiv(T,2);
! 381: if ( T = S+S )
! 382: T = S;
! 383: else
! 384: T = S+1;
! 385: }
! 386: X = (2^27)^idiv(J,2)*2^idiv(I,2);
! 387: while ( 1 ) {
! 388: if ( (Y=X^2) < A )
! 389: X += X;
! 390: else if ( Y == A )
! 391: return X;
! 392: else
! 393: break;
! 394: }
! 395: while ( 1 )
! 396: if ( (Y = X^2) <= A )
! 397: return X;
! 398: else
! 399: X = idiv(A + Y,2*X);
1.1 noro 400: }
401:
402: def init_pprocs(L)
403: {
1.3 ! noro 404: R = [];
1.1 noro 405: if ( type(NoX=getopt(nox)) == -1 ) NoX = 0;
1.3 ! noro 406: for ( T = L; T != []; T = cdr(T) ) {
! 407: Host = car(T)[0]; N = car(T)[1];
! 408: if ( !Host ) {
! 409: for ( I = 0; I < N; I++ ) {
! 410: P = NoX ? ox_launch_nox() : ox_launch();
! 411: R = cons(P,R);
! 412: }
! 413: } else {
! 414: Lib = get_rootdir();
! 415: Client = "ox_asir";
! 416: for ( I = 0; I < N; I++ ) {
! 417: P = NoX ? ox_launch_nox(Host,Lib,Client)
! 418: : ox_launch(Host,Lib,Client);
! 419: R = cons(P,R);
! 420: }
! 421: }
! 422: }
! 423: return reverse(R);
1.1 noro 424: }
425:
426: def nd_gbcheck(G,V,P,O)
427: {
1.3 ! noro 428: Proc = getopt(proc);
! 429: if ( type(Proc) == -1 ) Proc = 0;
! 430: F4 = getopt(f4);
! 431: if ( type(F4) == -1 ) F4 = 0;
! 432: /* XXX */
! 433: S = getopt(splist);
! 434: if ( type(S) == -1 ) {
! 435: if ( type(G) == 7 )
! 436: S = nd_gr(bload(G),V,lprime(0),O|splist=1);
! 437: else
! 438: S = nd_gr(G,V,lprime(0),O|splist=1);
! 439: }
! 440: if ( Proc ) {
! 441: N = length(Proc);
! 442: L = vector(N);
! 443: for ( I = 0; I < N; I++ ) L[I] = [];
! 444: for ( I = 0, T = S; T != []; T = cdr(T), I = (I+1)%N )
! 445: L[I] = cons(car(T),L[I]);
! 446: for ( I = 0; I < N; I++ )
! 447: ox_rpc(Proc[I],"noro_grcrt.gbcheck_p",G,V,P,O,reverse(L[I]),F4);
! 448: for ( I = 0; I < N; I++ )
! 449: if ( !ox_pop_local(Proc[I]) ) return 0;
! 450: return 1;
! 451: } else {
! 452: if ( F4 )
! 453: R = nd_f4(G,V,P,O|check_splist=S);
! 454: else
! 455: R = nd_gr(G,V,P,O|check_splist=S);
! 456: return R;
! 457: }
1.1 noro 458: }
459:
460: def gbcheck_p(G,V,P,O,S,F4)
461: {
1.3 ! noro 462: if ( type(G) == 7 )
! 463: G = bload(G);
! 464: if ( F4 )
! 465: return nd_f4(G,V,P,O|check_splist=S);
! 466: else
! 467: return nd_gr(G,V,P,O|check_splist=S);
1.1 noro 468: }
469:
470: def elimination(L,Elim)
471: {
1.3 ! noro 472: if ( !Elim ) return L;
1.1 noro 473: if ( type(Elim) <= 1 ) {
1.3 ! noro 474: for ( R = []; L != []; L = cdr(L) ) {
! 475: H = dp_etov(dp_ht(car(L)));
! 476: for ( I = 0; I <= Elim && !H[I]; I++ );
! 477: if ( I > Elim ) {
! 478: print(H);
! 479: R = cons(car(L),R);
! 480: }
! 481: }
1.1 noro 482: } else {
1.3 ! noro 483: for ( R = []; L != []; L = cdr(L) )
! 484: if ( dp_ht(car(L)) < Elim ) R = cons(car(L),R);
1.1 noro 485: }
486: return reverse(R);
487: }
488:
489: #if 0
490: def iso_eq_mod(Mod,UseNZ)
491: {
492: B = GB_B; V = GB_V;
493:
1.2 noro 494: /* V = [c1,bb,aa,b,a], W = [1,3,2,3,2,1] */
495: W = [1,3,2,3,2,1];
1.1 noro 496: dp_set_weight(W);
497: G1 = nd_f4(B,V,Mod,[[0,1],[0,4]]);
498: V1 = cdr(V);
499: G1 = noro_pd.elimination(G1,V1);
500: D = res(x,x^3+a*x+b,3*x^2+a);
501: G2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]);
502: G2 = noro_pd.elimination(G2,V1);
503: W1 = cdr(W);
504: dp_set_weight(W1);
505: if ( UseNZ )
506: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,trace=GB_NZ);
507: else {
508: GB_NZ = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,gentrace=1);
509: G3 = GB_NZ[0];
510: }
511: dp_ord([[0,1],[0,3]]);
512: #if 1
513: for ( T = []; G3 != []; G3 = cdr(G3) )
514: if ( dp_ht(car(G3)) < <<2,0,0,0>> ) T = cons(car(G3),T);
515: return [reverse(T),Mod];
516: #endif
517: return [G3,Mod];
518: }
519: #else
520:
521: def iso_eq_gentrace(B,V,Mod)
522: {
1.2 noro 523: W = [1,3,2,3,2,1];
1.1 noro 524:
525: dp_set_weight(W);
526: N1 = nd_f4(B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
527: G1 = N1[0];
528: G1 = elim_top(G1,<<1,0,0,0,0>>);
529: V1 = cdr(V);
530: G1 = map(dp_dtop,G1,V);
531:
532: D = res(x,x^3+a*x+b,3*x^2+a);
533: N2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
534: G2 = N2[0];
535: G2 = elim_top(G2,<<1,0,0,0,0>>);
536: G2 = map(dp_dtop,G2,cons(t,V1));
537:
538: W1 = cdr(W);
539: dp_set_weight(W1);
540: N3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,gentrace=1);
541: return [N1,N2,N3];
542: }
543:
544: def iso_eq_mod(Mod)
545: {
546: V = [c1,bb,aa,b,a];
1.2 noro 547: W = [1,3,2,3,2,1];
1.1 noro 548:
549: dp_set_weight(W);
550: if ( GB_N1 )
551: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N1);
552: else
553: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1);
554: G1 = elim_top(G1,<<1,0,0,0,0>>);
555: V1 = cdr(V);
556: G1 = map(dp_dtop,G1,V);
557:
558: D = res(x,x^3+a*x+b,3*x^2+a);
559: if ( GB_N2 )
560: G2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N2);
561: else
562: G2 = nd_f4(cons(t*D-1,G1),cons(t,V1),Mod,[[0,1],[0,4]]|dp=1,nora=1);
563: G2 = elim_top(G2,<<1,0,0,0,0>>);
564: G2 = map(dp_dtop,G2,cons(t,V1));
565:
566: W1 = cdr(W);
567: dp_set_weight(W1);
568: if ( GB_N3 )
569: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,trace=GB_N3);
570: else
571: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1);
572: G3 = elim_top(G3,<<2,0,0,0>>);
573: return [G3,Mod];
574: }
575:
576: def elim_top(G,H)
577: {
578: N = length(dp_etov(dp_ht(G[0])));
1.3 ! noro 579: W = dp_set_weight();
1.1 noro 580: Ord = dp_ord();
1.3 ! noro 581: dp_set_weight(0);
1.1 noro 582: dp_ord([[0,1],[0,N-1]]);
583: for ( T = []; G != []; G = cdr(G) )
584: if ( dp_ht(car(G)) < H ) T = cons(car(G),T);
585: dp_ord(Ord);
1.3 ! noro 586: dp_set_weight(W);
1.1 noro 587: return reverse(T);
588: }
589: #endif
590:
591: def iso_eq_d2(L)
592: {
593: Proc = getopt(proc);
594: if ( type(Proc) == -1 ) {
595: Proc = [];
596: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
597: } else if ( type(Proc) == 1 ) {
598: M = Proc;
599: Proc = [];
600: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
601: }
602: F = generateF(L);
603: A = polysys(F);
604: A = simpsys(A);
605: C = A[0]; B = A[1]; V = A[2]; W = A[3];
606:
607: map(ox_reset,Proc);
608: B = map(ptozp,B);
609: NProc = length(Proc);
610: CRTime = 0; IRTime = 0;
611: /* gentrace */
612: L = iso_eq_gentrace(B,V,lprime(0));
613: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,L[0],L[1],L[2]);
614: map(ox_pop_local,Proc);
615: I = 0;
616: N = 0;
617: Remain = 1; /* dummy */
618: Mod = 1;
619: O = [[0,1],[0,3]];
620: dp_ord(O);
621: dp_set_weight(cdr(W));
622: for ( T = Proc; T != []; T = cdr(T), I++ )
623: ox_rpc(car(T),"noro_grcrt.iso_eq_mod",lprime(I));
624: V1 = cdr(V);
625: while ( Remain ) {
626: for ( T = Proc; T != []; T = cdr(T), I++ ) {
627: print(["from",car(T)],2);
628: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
629: print(" done");
630: ox_rpc(car(T),"noro_grcrt.iso_eq_mod",lprime(I));
631: if ( GM ) {
632: L = monic_gb(GM,V1,O,P); GM = L[0];
633: if ( !N ) {
634: Remain = N = length(GM);
635: Stat = vector(N);
636: G = vector(N);
637: }
638: T0 = time();
639: Fail = dp_chrem2(G,Mod,GM,P,Stat);
640: Remain += Fail;
641: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
642: Mod *= P;
643: }
644: }
645: T0 = time();
646: New = intdpltoratdpl2(G,Mod,Stat);
647: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
648: Remain -= New;
649: print((N-Remain)/N*100.0,0); print("% done");
650: }
651: map(ox_reset,Proc);
652: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
653: return [vtol(map(dp_dtop,G,V1)),Proc];
654: }
655:
656: def iso_c1eq_mod(Mod)
657: {
658: V = [c1,bb,aa,b,a];
1.2 noro 659: W = [1,3,2,3,2,1];
1.1 noro 660:
661: dp_set_weight(W);
662: if ( GB_N1 )
663: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N1);
664: else
665: G1 = nd_f4(GB_B,V,Mod,[[0,1],[0,4]]|dp=1,nora=1);
666: G1 = elim_top(G1,<<2,0,0,0,0>>);
667: return [G1,Mod];
668: }
669:
670: def iso_c1eq_d2(L)
671: {
672: Proc = getopt(proc);
673: if ( type(Proc) == -1 ) {
674: Proc = [];
675: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
676: } else if ( type(Proc) == 1 ) {
677: M = Proc;
678: Proc = [];
679: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
680: }
681: F = generateF(L);
682: A = polysys(F);
683: A = simpsys(A);
684: C = A[0]; B = A[1]; V = A[2]; W = A[3];
685:
686: map(ox_reset,Proc);
687: B = map(ptozp,B);
688: NProc = length(Proc);
689: CRTime = 0; IRTime = 0;
690: /* gentrace */
1.2 noro 691: W = [1,3,2,3,2,1];
1.1 noro 692: dp_set_weight(W);
693: N1 = nd_f4(B,V,lprime(0),[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
694: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,N1,0,0);
695: map(ox_pop_local,Proc);
696: I = 0;
697: N = 0;
698: Remain = 1; /* dummy */
699: Mod = 1;
700: O = [[0,1],[0,4]];
701: dp_ord(O);
702: for ( T = Proc; T != []; T = cdr(T), I++ )
703: ox_rpc(car(T),"noro_grcrt.iso_c1eq_mod",lprime(I));
704: V1 = cdr(V);
705: while ( Remain ) {
706: for ( T = Proc; T != []; T = cdr(T), I++ ) {
707: print(["from",car(T)],2);
708: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
709: print(" done");
710: ox_rpc(car(T),"noro_grcrt.iso_c1eq_mod",lprime(I));
711: if ( GM ) {
712: L = monic_gb(GM,V1,O,P); GM = L[0];
713: if ( !N ) {
714: Remain = N = length(GM);
715: Stat = vector(N);
716: G = vector(N);
717: }
718: T0 = time();
719: Fail = dp_chrem2(G,Mod,GM,P,Stat);
720: Remain += Fail;
721: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
722: Mod *= P;
723: }
724: }
725: T0 = time();
726: New = intdpltoratdpl2(G,Mod,Stat);
727: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
728: Remain -= New;
729: print((N-Remain)/N*100.0,0); print("% done");
730: }
731: map(ox_reset,Proc);
732: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
733: return [vtol(map(dp_dtop,G,V)),Proc];
734: }
735:
736: def iso_eq_gentrace2(B,V,Mod)
737: {
1.2 noro 738: Wt = [1,1,3,2,3,2,1];
1.1 noro 739: Vt = cons(t,V);
740: dp_set_weight(Wt);
741: D = res(x,x^3+a*x+b,3*x^2+a);
742: N1 = nd_f4(cons(t*D-1,B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1,gentrace=1);
743: G1 = N1[0];
744: G1 = elim_top(G1,<<1,0,0,0,0,0>>);
745: G1 = map(dp_dtop,G1,Vt);
746:
747: W = cdr(Wt);
748: dp_set_weight(W);
749: N2 = nd_f4(G1,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,gentrace=1);
750: G2 = N2[0];
751: G2 = elim_top(G2,<<1,0,0,0,0>>);
752: G2 = map(dp_dtop,G2,V);
753:
754: W1 = cdr(W);
755: V1 = cdr(V);
756: dp_set_weight(W1);
757: N3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,gentrace=1);
758: return [N1,N2,N3];
759: }
760:
761: def iso_eq_mod2(Mod)
762: {
763: V = [c1,bb,aa,b,a];
764: Vt = cons(t,V);
1.2 noro 765: Wt = [1,1,3,2,3,2,1];
1.1 noro 766: dp_set_weight(Wt);
767: D = res(x,x^3+a*x+b,3*x^2+a);
768: if ( GB_N1 )
769: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1,trace=GB_N1);
770: else
771: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,[[0,1],[0,5]]|dp=1,nora=1);
772: G1 = elim_top(G1,<<1,0,0,0,0,0>>);
773: G1 = map(dp_dtop,G1,Vt);
774:
775: W = cdr(Wt);
776: dp_set_weight(W);
777: if ( GB_N2 )
778: G2 = nd_f4(G1,V,Mod,[[0,1],[0,4]]|dp=1,nora=1,trace=GB_N2);
779: else
780: G2 = nd_f4(G1,V,Mod,[[0,1],[0,4]]|dp=1,nora=1);
781: G2 = elim_top(G2,<<1,0,0,0,0>>);
782: G2 = map(dp_dtop,G2,V);
783:
784: W1 = cdr(W);
785: V1 = cdr(V);
786: dp_set_weight(W1);
787: if ( GB_N3 )
788: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1,trace=GB_N3);
789: else
790: G3 = nd_f4(G2,V1,Mod,[[0,1],[0,3]]|dp=1);
791: G3 = elim_top(G3,<<2,0,0,0>>);
792: return [G3,Mod];
793: }
794:
795: def iso_eq_d2new(L)
796: {
797: Proc = getopt(proc);
798: if ( type(Proc) == -1 ) {
799: Proc = [];
800: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
801: } else if ( type(Proc) == 1 ) {
802: M = Proc;
803: Proc = [];
804: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
805: }
806: F = generateF(L);
807: A = polysys(F);
808: A = simpsys(A);
809: C = A[0]; B = A[1]; V = A[2]; W = A[3];
810:
811: map(ox_reset,Proc);
812: B = map(ptozp,B);
813: NProc = length(Proc);
814: CRTime = 0; IRTime = 0;
815: /* gentrace */
816: L = iso_eq_gentrace2(B,V,lprime(0));
817: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,L[0],L[1],L[2]);
818: map(ox_pop_local,Proc);
819: I = 0;
820: N = 0;
821: Remain = 1; /* dummy */
822: Mod = 1;
823: O = [[0,1],[0,3]];
824: dp_ord(O);
825: dp_set_weight(cdr(W));
826: for ( T = Proc; T != []; T = cdr(T), I++ )
827: ox_rpc(car(T),"noro_grcrt.iso_eq_mod2",lprime(I));
828: V1 = cdr(V);
829: while ( Remain ) {
830: for ( T = Proc; T != []; T = cdr(T), I++ ) {
831: print(["from",car(T)],2);
832: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
833: print(" done");
834: ox_rpc(car(T),"noro_grcrt.iso_eq_mod2",lprime(I));
835: if ( GM ) {
836: L = monic_gb(GM,V1,O,P); GM = L[0];
837: if ( !N ) {
838: Remain = N = length(GM);
839: Stat = vector(N);
840: G = vector(N);
841: }
842: T0 = time();
843: Fail = dp_chrem2(G,Mod,GM,P,Stat);
844: Remain += Fail;
845: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
846: Mod *= P;
847: }
848: }
849: T0 = time();
850: New = intdpltoratdpl2(G,Mod,Stat);
851: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
852: Remain -= New;
853: print((N-Remain)/N*100.0,0); print("% done");
854: }
855: map(ox_reset,Proc);
856: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
857: return [vtol(map(dp_dtop,G,V1)),Proc];
858: }
859:
1.3 ! noro 860: def iso_sat_gentrace(B,V,Mod,Wt,Wt2,Ord)
1.1 noro 861: {
862: Vt = cons(t,V);
863: dp_set_weight(Wt);
1.3 ! noro 864: dp_gr_flags(["Reverse",1]);
1.1 noro 865: D = res(x,x^3+a*x+b,3*x^2+a);
1.3 ! noro 866: N1 = nd_f4(cons(t*D-1,B),Vt,Mod,Ord|dp=1,gentrace=1,sugarweight=Wt2);
! 867: dp_gr_flags(["Reverse",0]);
! 868: dp_set_weight(0);
1.1 noro 869: return N1;
870: }
871:
1.3 ! noro 872: def iso_sat_mod(Mod,V,Wt,Wt2,Ord)
1.1 noro 873: {
1.3 ! noro 874: T0 = time();
1.1 noro 875: Vt = cons(t,V);
1.3 ! noro 876: D = res(x,x^3+a*x+b,3*x^2+a);
1.1 noro 877: dp_set_weight(Wt);
1.3 ! noro 878: dp_gr_flags(["Reverse",1]);
! 879: if ( GB_N1 ) {
! 880: print("doing computation with history");
! 881: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,Ord|dp=1,trace=GB_N1, sugarweight=Wt2);
! 882: } else {
! 883: print("doing computation without history");
! 884: G1 = nd_f4(cons(t*D-1,GB_B),Vt,Mod,Ord|dp=1,sugarweight=Wt2);
! 885: }
! 886: dp_set_weight(0);
! 887: dp_gr_flags(["Reverse",0]);
1.1 noro 888: G1 = elim_top(G1,<<1,0,0,0,0,0>>);
1.3 ! noro 889: T1 = time();
! 890: print(["iso_sat_mod",T1[3]-T0[3]]);
! 891: return [G1,Mod,T1[3]-T0[3]];
1.1 noro 892: }
893:
894: def iso_sat_d2(L)
895: {
1.3 ! noro 896: Tall0=time();
1.1 noro 897: Proc = getopt(proc);
898: Sys = getopt(sys);
899: if ( type(Proc) == -1 ) {
900: Proc = [];
901: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
902: } else if ( type(Proc) == 1 ) {
903: M = Proc;
904: Proc = [];
905: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
906: }
907: if ( type(Sys) == -1 ) {
908: F = generateF(L);
909: A = polysys(F);
910: A = simpsys(A);
911: C = A[0]; B = A[1]; V = A[2]; W = A[3];
912: } else {
913: C = Sys[0]; B = Sys[1]; V = Sys[2]; W = Sys[3];
914: }
915:
916: map(ox_reset,Proc);
917: B = map(ptozp,B);
918: NProc = length(Proc);
919: CRTime = 0; IRTime = 0;
1.3 ! noro 920: /* gentrace Wt,Ord */
! 921: Wt = [1,3,2,1,3,2,1];
! 922: Wt2 = [-6,3,2,1,3,2,1];
! 923: Ord = [[0,1],[0,5]];
! 924: V = [bb,aa,c1,b,a];
! 925: Vt = cons(t,V);
! 926: dp_ord(Ord);
! 927: #if 0
! 928: NZ = iso_sat_gentrace(B,V,lprime(0),Wt,Wt2,Ord);
1.1 noro 929: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,NZ,0,0);
1.3 ! noro 930: #else
! 931: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,0,0,0);
! 932: #endif
1.1 noro 933: map(ox_pop_local,Proc);
934: I = 0;
935: N = 0;
936: Remain = 1; /* dummy */
937: Mod = 1;
1.3 ! noro 938: dp_set_weight(cdr(Wt));
! 939: Ord0 = 0;
1.1 noro 940: for ( T = Proc; T != []; T = cdr(T), I++ )
1.3 ! noro 941: ox_rpc(car(T),"noro_grcrt.iso_sat_mod",lprime(I),V,Wt,Wt2,Ord);
1.1 noro 942: while ( Remain ) {
943: for ( T = Proc; T != []; T = cdr(T), I++ ) {
944: print(["from",car(T)],2);
945: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1.3 ! noro 946: print(" done ",2); print(L[2]);
! 947: ox_rpc(car(T),"noro_grcrt.iso_sat_mod",lprime(I),V,Wt,Wt2,Ord);
! 948: if ( GM ) {
! 949: /* bsave(GM,"gm4/"+rtostr(P)); */
! 950: L = monic_gb(GM,Vt,Ord0,P); GM = L[0];
! 951: if ( !N ) {
! 952: Remain = N = length(GM);
! 953: Stat = vector(N);
! 954: G = vector(N);
! 955: }
! 956: T0 = time();
! 957: Fail = dp_chrem2(G,Mod,GM,P,Stat);
! 958: Remain += Fail;
! 959: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
! 960: Mod *= P;
! 961: }
! 962: }
! 963: T0 = time();
! 964: New = intdpltoratdpl2(G,Mod,Stat);
! 965: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
! 966: Remain -= New;
! 967: print((N-Remain)/N*100.0,0); print("% done");
! 968: }
! 969: map(ox_reset,Proc);
! 970: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
! 971: Tall1 = time();
! 972: Tcpu = Tall1[0]-Tall0[0];
! 973: Tgc = Tall1[1]-Tall0[1];
! 974: Treal = Tall1[3]-Tall0[3];
! 975: return [vtol(map(dp_dtop,G,Vt)),Proc,["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I,"cpu",Tcpu,"gc",Tgc,"real",Treal]];
! 976: }
! 977:
! 978: def iso_sat_d3(L)
! 979: {
! 980: Tall0=time();
! 981: Proc = getopt(proc);
! 982: Sys = getopt(sys);
! 983: if ( type(Proc) == -1 ) {
! 984: Proc = [];
! 985: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
! 986: } else if ( type(Proc) == 1 ) {
! 987: M = Proc;
! 988: Proc = [];
! 989: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
! 990: }
! 991: if ( type(Sys) == -1 ) {
! 992: F = generateF(L);
! 993: A = polysys(F);
! 994: A = simpsys(A);
! 995: C = A[0]; B = A[1]; V = A[2]; W = A[3];
! 996: } else {
! 997: C = Sys[0]; B = Sys[1]; V = Sys[2]; W = Sys[3];
! 998: }
! 999:
! 1000: map(ox_reset,Proc);
! 1001: B = map(ptozp,B);
! 1002: NProc = length(Proc);
! 1003: CRTime = 0; IRTime = 0;
! 1004: /* gentrace Wt,Ord */
! 1005: Wt = [1,3,2,1,3,2,1];
! 1006: Wt2 = [-6,3,2,1,3,2,1];
! 1007: Ord = [[0,1],[0,5]];
! 1008: V = [bb,aa,c1,b,a];
! 1009: Vt = cons(t,V);
! 1010: dp_ord(Ord);
! 1011: #if 0
! 1012: NZ = iso_sat_gentrace(B,V,lprime(0),Wt,Wt2,Ord);
! 1013: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,NZ,0,0);
! 1014: #else
! 1015: map(ox_rpc,Proc,"noro_grcrt.store_bvn3",B,V,0,0,0);
! 1016: #endif
! 1017: map(ox_pop_local,Proc);
! 1018: I = 0;
! 1019: N = 0;
! 1020: Remain = 1; /* dummy */
! 1021: Mod = 1;
! 1022: dp_set_weight(cdr(Wt));
! 1023: Ord0 = 0;
! 1024: for ( T = Proc; T != []; T = cdr(T), I++ ) {
! 1025: ox_rpc(car(T),"noro_grcrt.iso_sat_mod",lprime(I),V,Wt,Wt2,Ord);
! 1026: }
! 1027: map(ox_push_cmd,Proc,258);
! 1028: while ( Remain ) {
! 1029: Ready = ox_select(Proc);
! 1030: for ( T = Ready; T != []; T = cdr(T), I++ ) {
! 1031: print(["from",car(T)],2);
! 1032: L = ox_get(car(T)); GM = L[0]; P = L[1];
! 1033: print(" done ",2); print(L[2]);
! 1034: ox_rpc(car(T),"noro_grcrt.iso_sat_mod",lprime(I),V,Wt,Wt2,Ord);
! 1035: ox_push_cmd(car(T),258);
1.1 noro 1036: if ( GM ) {
1.3 ! noro 1037: /* bsave(GM,"gm4/"+rtostr(P)); */
! 1038: L = monic_gb(GM,Vt,Ord0,P); GM = L[0];
1.1 noro 1039: if ( !N ) {
1040: Remain = N = length(GM);
1041: Stat = vector(N);
1042: G = vector(N);
1043: }
1044: T0 = time();
1045: Fail = dp_chrem2(G,Mod,GM,P,Stat);
1046: Remain += Fail;
1047: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1048: Mod *= P;
1049: }
1050: }
1051: T0 = time();
1052: New = intdpltoratdpl2(G,Mod,Stat);
1053: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1054: Remain -= New;
1055: print((N-Remain)/N*100.0,0); print("% done");
1056: }
1057: map(ox_reset,Proc);
1058: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I]);
1.3 ! noro 1059: Tall1 = time();
! 1060: Tcpu = Tall1[0]-Tall0[0];
! 1061: Tgc = Tall1[1]-Tall0[1];
! 1062: Treal = Tall1[3]-Tall0[3];
! 1063: return [vtol(map(dp_dtop,G,Vt)),Proc,["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I,"cpu",Tcpu,"gc",Tgc,"real",Treal]];
! 1064: }
! 1065:
! 1066: def store_minipoly(Mp)
! 1067: {
! 1068: MiniPoly=Mp;
! 1069: }
! 1070:
! 1071: #if 0
! 1072: def large_factor(Mod)
! 1073: {
! 1074: A = nd_res(c1,MiniPoly,diff(MiniPoly,c1),Mod);
! 1075: D = 4*a^3+27*b^2;
! 1076: while ( Q = tdiv(A,D,Mod) ) A = Q;
! 1077: while ( Q = tdiv(A,a,Mod) ) A = Q;
! 1078: while ( Q = tdiv(A,b,Mod) ) A = Q;
! 1079: setmod(Mod);
! 1080: A = ptomp(A,Mod);
! 1081: H = coef(A,deg(A,b),b);
! 1082: H = coef(H,deg(H,a),a);
! 1083: A /= H;
! 1084:
! 1085: N=deg(A,b)/2;
! 1086: M=deg(coef(A,2*N,b),a)/2;
! 1087: CS=[];
! 1088: for (I=0;I<=N;I++) {
! 1089: CA="d"+rtostr(I);
! 1090: CB=strtov(CA);
! 1091: Y=Y+CB*b^I;
! 1092: CS=cons(CB,CS);
! 1093: }
! 1094: PB=A-ptomp(1)*Y^2;
! 1095: PS=[];
! 1096: for (I=0;I<=2*N;I++) {
! 1097: CC=coef(PB,I,b);
! 1098: PS=cons(CC,PS);
! 1099: }
! 1100:
! 1101: LC = ptomp(1)*a^M;
! 1102: ANS=[LC];
! 1103: BNS=ANS[0]*b^N;
! 1104: for (I=1;I<=N;I++) {
! 1105: print(".",2);
! 1106: C0X=coef(PS[I],0,CS[I]);
! 1107: for (J=0;J<I;J++) {
! 1108: C0X=subst(C0X,CS[J],ANS[J]);
! 1109: }
! 1110: AX=sdiv(C0X,2*LC);
! 1111: ANS=append(ANS,[AX]);
! 1112: BNS=BNS+ANS[I]*b^(N-I);
! 1113: }
! 1114: return [mptop(BNS),Mod];
! 1115: }
! 1116: #else
! 1117: def large_factor(Mod)
! 1118: {
! 1119: A = nd_res(c1,MiniPoly,diff(MiniPoly,c1),Mod);
! 1120: D = 4+27*b^2;
! 1121: while ( Q = tdiv(A,D,Mod) ) A = Q;
! 1122: while ( Q = tdiv(A,b,Mod) ) A = Q;
! 1123: L = modsqfr(A,Mod);
! 1124: setmod(Mod);
! 1125: GM = ptomp(L[1][0]);
! 1126: GM /= coef(GM,deg(GM,b));
! 1127: return [mptop(GM),Mod];
! 1128: }
! 1129: #endif
! 1130:
! 1131: extern TrueG$
! 1132: localf compare_trueg$
! 1133:
! 1134: def compare_trueg(GM,P)
! 1135: {
! 1136: setmod(P);
! 1137: T = ptomp(TrueG);
! 1138: D = deg(T,b);
! 1139: H = coef(T,D,b);
! 1140: H = coef(H,deg(H,a),a);
! 1141: T = mptop(T/H);
! 1142: if ( T==GM ) print("ok");
! 1143: else print("ng");
! 1144: }
! 1145:
! 1146: def largefactor_res(Mp)
! 1147: {
! 1148: Proc = getopt(proc);
! 1149: if ( type(Proc) == -1 ) {
! 1150: Proc = [];
! 1151: for ( I = 0; I < 10; I++ ) Proc = cons(ox_launch_nox(),Proc);
! 1152: } else if ( type(Proc) == 1 ) {
! 1153: M = Proc;
! 1154: Proc = [];
! 1155: for ( I = 0; I < M; I++ ) Proc = cons(ox_launch_nox(),Proc);
! 1156: }
! 1157: MiniPoly = Mp;
! 1158:
! 1159: map(ox_reset,Proc);
! 1160: map(ox_rpc,Proc,"noro_grcrt.store_minipoly",Mp);
! 1161: map(ox_pop_local,Proc);
! 1162: P0 = lprime(0); GM0 = large_factor(P0)[0];
! 1163: for ( I = 1, Mod = 1, T = Proc; T != []; T = cdr(T), I++ )
! 1164: ox_rpc(car(T),"noro_grcrt.large_factor",lprime(I));
! 1165: G = 0;
! 1166: while ( 1 ) {
! 1167: for ( T = Proc; T != []; T = cdr(T), I++ ) {
! 1168: print(["from",car(T)],2);
! 1169: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
! 1170: print(" done");
! 1171: ox_rpc(car(T),"noro_grcrt.large_factor",lprime(I));
! 1172: T0 = time();
! 1173: G = p_chrem2(G,Mod,GM,P);
! 1174: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
! 1175: Mod *= P;
! 1176: }
! 1177: T0 = time();
! 1178: Bound = calcb(Mod);
! 1179: Gr = intptoratp(G,Mod,Bound);
! 1180: if ( Gr && p_checkcrt(Gr,GM0,P0) ) break;
! 1181: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
! 1182: }
! 1183: map(ox_reset,Proc);
! 1184: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
! 1185: return [ptozp(Gr),Proc];
1.1 noro 1186: }
1187:
1188: endmodule$
1189:
1190: end$
1191:
1192: /* old functions */
1193:
1194: def gr_chrem(B,V,O)
1195: {
1196: Proc = getopt(proc);
1197: Dname = getopt(dname);
1198: if ( type(Proc) != -1 ) {
1199: if ( type(Dname) != -1 )
1200: return gr_chr_d(B,V,O,Proc,Dname);
1201: else
1202: return gr_chrem_d(B,V,O,Proc);
1203: }
1204:
1205: B = map(ptozp,B);
1206: Mod = 1;
1207: D = nd_gr(B,V,lprime(0),O|gentrace=1);
1208: Remain = N = length(D[0]);
1209: Stat = vector(N);
1210: G = vector(N);
1211: for ( I = 1; Remain; I++ ) {
1212: P = lprime(I);
1213: GM = nd_gr_recompute_trace(B,V,P,O,D);
1214: if ( !GM ) continue;
1215: L = monic_gb(GM,V,O,P); GM = L[0];
1216: T0 = time();
1217: dp_chrem2(G,Mod,GM,P,Stat);
1218: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1219: Mod *= P;
1220: if ( !(I%3) ) {
1221: T0 = time();
1222: New = intdpltoratdpl2(G,Mod,Stat);
1223: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1224: Remain -= New;
1225: }
1226: }
1227: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
1228: return vtol(map(dp_dtop,G,V));
1229: }
1230:
1231: /* NZ = [*,*,NZ,BPE] */
1232:
1233: def f4_chrem(B,V,O)
1234: {
1235: Proc = getopt(proc);
1236: NZ = getopt(nz);
1237: Prev = getopt(prev);
1238: Homo = getopt(homo);
1239: Elim = getopt(elim);
1240: Weight = getopt(weight);
1241: if ( type(NZ) == -1 ) NZ = 0;
1242: if ( type(Prev) == -1 ) Prev = 0;
1243: if ( type(Homo) == -1 ) Homo = 0;
1244: if ( type(Elim) == -1 ) Elim = -1;
1245: if ( type(Weight) == -1 ) Weight = 0;
1246: OldWeight = dp_set_weight();
1247: dp_set_weight(Weight);
1248: if ( type(Proc) != -1 ) {
1249: if ( NZ )
1250: G = f4_chr_d(B,V,O,Proc,NZ,Prev,Homo,Elim,Weight);
1251: else
1252: G = f4_chrem_d(B,V,O,Proc);
1253: dp_set_weight(OldWeight);
1254: return G;
1255: }
1256: B = map(ptozp,B);
1257: Remain = 1; /* XXX */
1258: for ( I = 0, N = 0, Mod = 1; Remain; I++ ) {
1259: P = lprime(I);
1260: if ( NZ )
1261: GM = nd_f4(B,V,P,O|dp=1,trace=NZ);
1262: else
1263: GM = nd_f4(B,V,P,O|dp=1);
1264: if ( !GM ) continue;
1265: if ( !N ) {
1266: Remain = N = length(GM);
1267: Stat = vector(N);
1268: G = vector(N);
1269: }
1270: L = monic_gb(GM,V,O,P); GM = L[0];
1271: T0 = time();
1272: dp_chrem2(G,Mod,GM,P,Stat);
1273: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1274: Mod *= P;
1275: if ( !(I%3) ) {
1276: T0 = time();
1277: New = intdpltoratdpl2(G,Mod,Stat);
1278: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1279: Remain -= New;
1280: }
1281: }
1282: print(["CRT",CRTime,"IR",IRTime,"#P",I]);
1283: G = vtol(map(dp_dtop,G,V));
1284: dp_set_weight(OldWeight);
1285: return G;
1286: }
1287:
1288: def gr_chrem_d(B,V,O,Proc)
1289: {
1290: map(ox_reset,Proc);
1291: B = map(ptozp,B);
1292: NProc = length(Proc); D = vector(NProc); H = vector(NProc);
1293: CRTime = 0; IRTime = 0;
1294: /* gentrace */
1295: I = 0;
1296: T0 = time();
1297: while ( 1 ) {
1298: for ( J = 0; J < NProc; J++, I++ )
1299: ox_rpc(Proc[J],"noro_grcrt.nd_gr_gentrace_p",B,V,lprime(I),O);
1300: for ( J = 0; J < NProc; J++, I++ ) {
1301: D[J] = ox_pop_local(Proc[J]);
1302: H[J] = map(dp_ptod,D[J][0][0],V);
1303: }
1304: for ( J = 1; J < NProc; J++ )
1305: if ( map(dp_ht,H[J]) != map(dp_ht,H[0]) ) break;
1306: if ( J == NProc ) break;
1307: }
1308: T1 = time(); TTime += (T1[3]-T0[3]);
1309: print(["Template",TTime]);
1310: map(ox_rpc,Proc,"noro_grcrt.store_history",D[0][0]); map(ox_pop_local,Proc);
1311: for ( J = 0; J < NProc; J++, I++ )
1312: ox_rpc(Proc[J],"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1313:
1314: Remain = N = length(D[0][0][0]);
1315: Stat = vector(N); G = vector(N);
1316: Mod = 1;
1317:
1318: for ( J = 0; J < NProc; J++ ) {
1319: P = D[J][1];
1320: L = monic_gb(H[J],V,O,P); GM = L[0];
1321: T0 = time();
1322: dp_chrem2(G,Mod,GM,P,Stat);
1323: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1324: Mod *= P;
1325: }
1326:
1327: while ( Remain ) {
1328: for ( T = Proc; T != []; T = cdr(T), I++ ) {
1329: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1330: ox_rpc(car(T),"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1331: if ( GM ) {
1332: L = monic_gb(GM,V,O,P); GM = L[0];
1333: T0 = time();
1334: dp_chrem2(G,Mod,GM,P,Stat);
1335: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1336: Mod *= P;
1337: }
1338: }
1339: T0 = time();
1340: New = intdpltoratdpl2(G,Mod,Stat);
1341: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1342: Remain -= New;
1343: print((N-Remain)/N*100.0,0); print("% done");
1344: }
1345: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I-NProc]);
1346: return vtol(map(dp_dtop,G,V));
1347: }
1348:
1349: def gr_chr_d(B,V,O,Proc,Dname)
1350: {
1351: map(ox_reset,Proc);
1352: B = map(ptozp,B);
1353: NProc = length(Proc); D = vector(NProc); H = vector(NProc);
1354: CRTime = 0; IRTime = 0;
1355: /* gentrace */
1356: map(ox_rpc,Proc,"noro_grcrt.read_history",Dname); map(ox_pop_local,Proc);
1357: for ( J = 0; J < NProc; J++, I++ )
1358: ox_rpc(Proc[J],"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1359:
1360: Remain = N = length(D[0][0][0]);
1361: Stat = vector(N); G = vector(N);
1362: Mod = 1;
1363:
1364: for ( J = 0; J < NProc; J++ ) {
1365: P = D[J][1];
1366: L = monic_gb(H[J],V,O,P); GM = L[0];
1367: T0 = time();
1368: dp_chrem2(G,Mod,GM,P,Stat);
1369: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1370: Mod *= P;
1371: }
1372:
1373: while ( Remain ) {
1374: for ( T = Proc; T != []; T = cdr(T), I++ ) {
1375: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1376: ox_rpc(car(T),"noro_grcrt.nd_gr_recompute_trace_p",B,V,lprime(I),O);
1377: if ( GM ) {
1378: L = monic_gb(GM,V,O,P); GM = L[0];
1379: T0 = time();
1380: dp_chrem2(G,Mod,GM,P,Stat);
1381: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1382: Mod *= P;
1383: }
1384: }
1385: T0 = time();
1386: New = intdpltoratdpl2(G,Mod,Stat);
1387: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1388: Remain -= New;
1389: print((N-Remain)/N*100.0,0); print("% done");
1390: }
1391: print(["CRT",CRTime,"IR",IRTime,"#P",I-NProc]);
1392: return vtol(map(dp_dtop,G,V));
1393: }
1394:
1395: def f4_chrem_d(B,V,O,Proc)
1396: {
1397: map(ox_reset,Proc);
1398: B = map(ptozp,B);
1399: NProc = length(Proc); D = vector(NProc); H = vector(NProc);
1400: CRTime = 0; IRTime = 0;
1401: /* gentrace */
1402: I = 0;
1.3 ! noro 1403: map(ox_rpc,Proc,"noro_grcrt.store_minipoly",Mp);
1.1 noro 1404: map(ox_pop_local,Proc);
1405: T0 = time();
1406: while ( 1 ) {
1407: for ( J = 0; J < NProc; J++, I++ )
1408: ox_rpc(Proc[J],"noro_grcrt.nd_f4_p",lprime(I),O);
1409: for ( J = 0; J < NProc; J++ ) {
1410: D[J] = ox_pop_local(Proc[J]);
1411: H[J] = D[J][0];
1412: }
1413: for ( J = 1; J < NProc; J++ )
1414: if ( map(dp_ht,H[J]) != map(dp_ht,H[0]) ) break;
1415: if ( J == NProc ) break;
1416: }
1417: T1 = time(); TTime += (T1[3]-T0[3]);
1418: print(["Template",TTime]);
1419: for ( J = 0; J < NProc; J++, I++ )
1420: ox_rpc(Proc[J],"noro_grcrt.nd_f4_p",lprime(I),O);
1421:
1422: Remain = N = length(D[0][0]);
1423: Stat = vector(N); G = vector(N);
1424: Mod = 1;
1425:
1426: for ( J = 0; J < NProc; J++ ) {
1427: P = D[J][1];
1428: L = monic_gb(H[J],V,O,P); GM = L[0];
1429: T0 = time();
1430: dp_chrem2(G,Mod,GM,P,Stat);
1431: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1432: Mod *= P;
1433: }
1434:
1435: while ( Remain ) {
1436: for ( T = Proc; T != []; T = cdr(T), I++ ) {
1437: L = ox_pop_local(car(T)); GM = L[0]; P = L[1];
1438: ox_rpc(car(T),"noro_grcrt.nd_f4_p",lprime(I),O);
1439: if ( GM ) {
1440: L = monic_gb(GM,V,O,P); GM = L[0];
1441: T0 = time();
1442: dp_chrem2(G,Mod,GM,P,Stat);
1443: T1 = time(); CRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1444: Mod *= P;
1445: }
1446: }
1447: T0 = time();
1448: New = intdpltoratdpl2(G,Mod,Stat);
1449: T1 = time(); IRTime += (T1[0]-T0[0])+(T1[1]-T0[1]);
1450: Remain -= New;
1451: print((N-Remain)/N*100.0,0); print("% done");
1452: }
1453: print(["Template",TTime,"CRT",CRTime,"IR",IRTime,"#P",I-NProc]);
1454: return vtol(map(dp_dtop,G,V));
1455: }
1456:
1457: def nd_f4_p(P,O)
1458: {
1459: return [nd_f4(GB_B,GB_V,P,O|dp=1),P];
1460: }
1461:
1462: def store_bv(B,V)
1463: {
1464: GB_B=B;
1465: GB_V=V;
1466: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>