Annotation of OpenXM/src/asir-contrib/testing/noro/module_syz.rr, Revision 1.4
1.1 noro 1: module newsyz;
2:
1.4 ! noro 3: localf module_syz, module_syz_old;
1.3 noro 4: localf simplify_syz, icont, mod, remove_cont,ordcheck;
5: localf complsb, complsb_sd, sortlsb, find_pos, find_pos, reduce, lres_setup, dpm_sort1, comp_pos;
6: localf fres,minres,sres,minsres,lres, create_base_ord, simplify_k, simplify_by_k, remove_k, remove_k1, extract_nonzero;
7: localf nonzero, phi, syz_check, renumber_pos, compress, compress_h;
8: localf syz_check0,phi0,todpmlist,dpmlisttollist;
1.1 noro 9:
10: /* F : a list of (lists or polynomials),
11: V : a variable list, H >1=> over GF(H), H=0,1=> over Q
12: O : term order
13: return: [GS,G]
14: GS : a GB of syz(F) wrt [1,O] (POT), G: a GB of F wrt [1,O]
15: */
16:
1.3 noro 17: // return [dpmlist F,rank N]
18: def todpmlist(F,V)
1.1 noro 19: {
1.3 noro 20: K = length(F);
21: for ( I = 0; I < K; I++ ) if ( F[I] ) break;
22: if ( I == K ) return [];
23: if ( type(F[I]) <= 2 ) {
24: // F is a polynimial list
25: F = map(dp_ptod,F,V);
26: F = map(dpm_dptodpm,F,1);
27: N = 1;
28: } else if ( type(F[I]) == 9 ) {
29: // F is a dpoly list
30: F = map(dpm_dptodpm,F,1);
31: N = 1;
32: } else if ( type(F[I]) == 4 ) {
33: // F is a list of poly lists
34: N = length(F[0]);
35: F = map(dpm_ltod,F,V);
36: } else if ( type(F[I]) == 26 ) {
37: // F is a DPM list
38: for ( N = 0, T = F; T != []; T = cdr(T) ) {
39: for ( A = car(T); A; A = dpm_rest(A) ) {
40: N1 = dpm_hp(A);
41: if ( N1 > N ) N = N1;
42: }
43: }
44: } else {
45: error("todpmlist: arugument type is invalid.");
46: }
47: return [F,N];
48: }
49:
50: def module_syz(F,V,H,Ord)
51: {
52: if ( type(Weyl=getopt(weyl)) == -1 ) Weyl = 0;
53: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
54: if ( type(F4=getopt(f4)) == -1 ) F4 = 0;
55: dp_ord(Ord);
56: K = length(F);
57: for ( I = 0; I < K; I++ ) if ( F[I] ) break;
58: if ( I == K ) return [[],[],[]];
59: L = todpmlist(F,V);
60: F = L[0]; N = L[1];
61: dp_ord([1,Ord]);
62: B = [];
63: for ( I = 0; I < K; I++ ) {
64: B = cons(F[I]+dpm_dptodpm(dp_ptod(1,V),N+I+1),B);
65: }
66: B = reverse(B);
1.4 ! noro 67: if ( H >= 2 ) {
! 68: // finite field
! 69: if ( Weyl )
! 70: G = nd_weyl_gr(B,V,H,[1,Ord]|dp=1);
! 71: else if ( F4 )
! 72: G = nd_f4(B,V,H,[1,Ord]|dp=1);
! 73: else
! 74: G = nd_gr(B,V,H,[1,Ord]|dp=1);
! 75: } else {
! 76: if ( Weyl )
! 77: G = nd_weyl_gr(B,V,0,[1,Ord]|dp=1,homo=H);
! 78: else if ( F4 ) {
! 79: Ind = 0;
! 80: while ( 1 ) {
! 81: G = nd_f4_trace(B,V,H,-lprime(Ind),[1,Ord]|dp=1);
! 82: if ( G ) break;
! 83: else Ind++;
! 84: }
! 85: } else
! 86: G = nd_gr(B,V,0,[1,Ord]|dp=1,homo=H);
! 87: }
1.3 noro 88: G0 = []; S0 = []; Gen0 = [];
89: for ( T = G; T != []; T = cdr(T) ) {
90: H = car(T);
91: if ( dpm_hp(H) > N ) {
92: S0 = cons(dpm_shift(H,N),S0);
93: } else {
94: L = dpm_split(H,N);
95: G0 = cons(L[0],G0);
96: Gen0 = cons(dpm_shift(L[1],N),Gen0);
1.1 noro 97: }
1.3 noro 98: }
99: #if 0
100: S0 = reverse(S0); G0 = reverse(G0); Gen0 = reverse(Gen0);
101: #endif
102: if ( !DP ) {
103: S0 = map(dpm_dtol,S0,V); G0 = map(dpm_dtol,G0,V); Gen0 = map(dpm_dtol,Gen0,V);
104: }
105: return [S0,G0,Gen0];
106: }
107:
1.4 ! noro 108: def module_syz_old(F,V,H,O)
! 109: {
! 110: Weyl = type(getopt(weyl)) != -1 ? 1 : 0;
! 111: K = length(F);
! 112: if ( type(F[0]) <= 2 ) {
! 113: for ( T = [], S = F; S != []; S = cdr(S) )
! 114: T = cons([car(S)],T);
! 115: F = reverse(T);
! 116: }
! 117: N = length(F[0]);
! 118: B = [];
! 119: for ( I = 0; I < K; I++ ) {
! 120: E = vector(N+K);
! 121: for ( J = 0; J < N; J++ ) E[J] = F[I][J];
! 122: E[N+I] = 1;
! 123: B = cons(vtol(E),B);
! 124: }
! 125: B = reverse(B);
! 126: if ( H >= 2 ) {
! 127: if ( Weyl )
! 128: G = nd_weyl_gr(B,V,H,[1,O]);
! 129: else
! 130: G = nd_gr(B,V,H,[1,O]);
! 131: } else {
! 132: if ( Weyl )
! 133: G = nd_weyl_gr_trace(B,V,H,-1,[1,O]);
! 134: else
! 135: G = nd_gr_trace(B,V,H,-1,[1,O]);
! 136: }
! 137: G0 = []; S0 = []; Gen0 = [];
! 138: for ( T = G; T != []; T = cdr(T) ) {
! 139: H = car(T);
! 140: for ( J = 0; J < N; J++ ) if ( H[J] ) break;
! 141: if ( J == N ) {
! 142: H1 = vector(K);
! 143: for ( J = 0; J < K; J++ ) H1[J] = H[N+J];
! 144: S0 = cons(vtol(H1),S0);
! 145: } else {
! 146: H1 = vector(N);
! 147: for ( J = 0; J < N; J++ ) H1[J] = H[J];
! 148: G0 = cons(vtol(H1),G0);
! 149: H1 = vector(K);
! 150: for ( J = 0; J < K; J++ ) H1[J] = H[N+J];
! 151: Gen0 = cons(vtol(H1),Gen0);
! 152: }
! 153: }
! 154: return [S0,G0,Gen0];
! 155: }
! 156:
1.3 noro 157: def fres(F,V,H,O)
158: {
159: if ( type(Weyl=getopt(weyl)) == -1 ) Weyl = 0;
160: if ( type(F4=getopt(f4)) == -1 ) F4 = 0;
161: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
162: L = todpmlist(F,V); F = L[0];
163: R = [F];
164: while ( 1 ) {
165: if ( Weyl )
166: L = module_syz(car(R),V,H,O|weyl=1,dp=1,f4=F4);
167: else
168: L = module_syz(car(R),V,H,O|dp=1,f4=F4);
169: L = L[0];
170: L = ordcheck(L,V);
171: if ( L == [] ) {
172: if ( DP ) return R;
173: else return map(dpmlisttollist,R,V);
174: }
175: R = cons(L,R);
176: }
177: }
178:
179: def minres(F,V,H,O)
180: {
181: if ( type(Weyl=getopt(weyl)) == -1 ) Weyl = 0;
182: if ( type(F4=getopt(f4)) == -1 ) F4 = 0;
183: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
184: L = todpmlist(F,V); F = L[0];
185: R = [F];
186: while ( 1 ) {
187: if ( Weyl )
188: L = module_syz(car(R),V,H,O|weyl=1,dp=1,f4=F4);
189: else
190: L = module_syz(car(R),V,H,O|dp=1,f4=F4);
191: L = L[0];
192: L = ordcheck(L,V);
193: if ( L == [] ) break;
194: S = dpm_simplify_syz(L,R[0]);
195: if ( S[0] == [] && S[1] == [] ) {
196: R = cdr(R); break;
197: }
198: R = append([S[0],S[1]],cdr(R));
199: if ( R[0] == [] ) {
200: R = cdr(R); break;
201: }
202: }
203: if ( DP ) return R;
204: else return map(dpmlisttollist,R,V);
205: }
206:
207: def dpmlisttollist(F,V)
208: {
209: return map(dpm_dtol,F,V);
210: }
211:
212: def sres(F,V,H,Ord)
213: {
214: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
215: dpm_set_schreyer(0);
216: dp_ord(Ord);
217: K = length(F);
218: K = length(F);
219: for ( I = 0; I < K; I++ ) if ( F[I] ) break;
220: if ( I == K ) return [[],[],[]];
221: L = todpmlist(F,V);
222: F = L[0]; N = L[1];
223: G = nd_gr(F,V,H,[0,Ord]|dp=1);
224: G = reverse(G);
225: R = [G];
226: dp_ord([0,Ord]);
227: while ( 1 ) {
228: S = dpm_schreyer_base(R[0]);
229: print(["length",length(S)]);
230: if ( S == [] ) break;
231: else R = cons(S,R);
232: }
233: dp_ord([0,0]);
234: if ( DP ) return R;
235: else return map(dpmlisttollist,R,V);
236: }
237:
238: def minsres(F,V,H,Ord)
239: {
240: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
241: R = sres(F,V,H,Ord|dp=1);
242: R = ltov(R);
243: M = length(R);
244: for ( I = 0; I < M; I++ ) R[I] = map(dpm_sort,R[I]);
245: R = vtol(R);
246: for ( T = R, U = []; length(T) >= 2; ) {
247: Z = dpm_simplify_syz(T[0],T[1]);
248: U = cons(Z[0],U);
249: T = cons(Z[1],cdr(cdr(T)));
250: }
251: U = cons(T[0],U);
252: if ( DP ) return U;
253: else return map(dpmlisttollist,U,V);
254: }
255:
256: def ordcheck(D,V)
257: {
258: B=map(dpm_dtol,D,V);
259: dp_ord([1,0]);
260: D = map(dpm_sort,D);
261: D1 = map(dpm_ltod,B,V);
262: if ( D != D1 )
263: print("afo");
264: return D1;
265: }
266:
267: def complsb(A,B)
268: {
269: AL = A[3]; AD = A[4];
270: BL = B[3]; BD = B[4];
271: if ( AD > BD ) return 1;
272: else if ( AD < BD ) return -1;
273: else if ( AL < BL ) return 1;
274: else if ( AL > BL ) return -1;
275: else return 0;
276: }
277:
278: def complsb_sd(A,B)
279: {
280: AL = A[3]; AD = A[4];
281: BL = B[3]; BD = B[4];
282: if ( AD-AL > BD-BL ) return 1;
283: else if ( AD-AL < BD-BL ) return -1;
284: else if ( AL > BL ) return 1;
285: else if ( AL < BL ) return -1;
286: else return 0;
287: }
288:
289: def sortlsb(A)
290: {
291: S = [];
292: N = length(A);
293: for ( I = 0; I < N; I++ ) S = append(cdr(vtol(A[I])),S);
294: // S = qsort(S,newsyz.complsb_sd);
295: S = qsort(S,newsyz.complsb);
296: return S;
297: }
298: /* D=[in,sum,deg,lev,ind] */
299: /* B=[0 B1 B2 ...] */
300: /* C=[0 C1 C2 ...] */
301: /* H=[0 H1 H2 ...] */
302: /* Z=[0 Z1 Z2 ...] */
303: /* Zi=[0 L1 L2 ...] */
304: /* Lj=[I1,I2,...] */
305: /* One=<<0,...,0>> */
306:
307: extern Rtime,Stime,Ptime$
308:
309: // B is sorted wrt positon
310: def find_pos(HF,B)
311: {
312: Len = length(B);
313: Pos = dpm_hp(HF);
314: First = 0; Last = Len-1;
315: if ( B[First][0] == HF ) return B[First][2];
316: if ( B[Last][0] == HF ) return B[Last][2];
317: while ( 1 ) {
318: Mid = idiv(First+Last,2);
319: PosM = dpm_hp(B[Mid][0]);
320: if ( PosM == Pos ) break;
321: else if ( PosM < Pos )
322: First = Mid;
323: else
324: Last = Mid;
325: }
326: for ( I = Mid; I < Len && dpm_hp(B[I][0]) == Pos; I++ )
327: if ( HF == B[I][0] ) return B[I][2];
328: for ( I = Mid-1; I >= 1 && dpm_hp(B[I][0]) == Pos; I-- )
329: if ( HF == B[I][0] ) return B[I][2];
330: error("find_pos : cannot happen");
331: }
332:
333: def reduce(D,B,Bpos,C,H,Z,K,Kind,G,One,Top)
334: {
335: M = D[0]; Ind = D[2]; I = D[3];
336: if ( I == 1 ) {
337: C[I][Ind] = G[Ind];
338: dpm_insert_to_zlist(Z[1],dpm_hp(G[Ind]),Ind);
339: H[I][Ind] = G[Ind];
340: } else {
341: /* M is in F(I-1) => phi(M) is in F(I-2) */
342: /* reduction in F(I-2) */
343: T0 = time()[0];
344: dpm_set_schreyer_level(I-2);
345: CI = C[I-1]; ZI = Z[I-1]; BI = B[I-1]; BposI = Bpos[I-1];
346: Len = size(CI);
347: T=dpm_hc(M); EM=dpm_hp(M);
348: XiM = T*dpm_ht(CI[EM]);
349: EXiM = dpm_hp(XiM);
350: ZIE = ZI[EXiM];
351: for ( ZIE = ZI[EXiM]; ZIE != []; ZIE = cdr(ZIE) ) {
352: J = car(ZIE);
353: if ( J > EM && dpm_redble(XiM,dpm_ht(CI[J])) ) break;
354: }
355: Ptime += time()[0]-T0;
356: T0 = time()[0];
357: QR = dpm_sp_nf(CI,ZI,EM,J|top=Top);
358: Rtime += time()[0]-T0;
359: G = QR[0]; F = QR[1];
360: if ( F ) {
361: HF = dpm_ht(F); EF = dpm_hp(HF);
362: /* find HF in B[I-1] */
363: T0 = time()[0];
364: J = find_pos(HF,BposI);
365: Stime += time()[0]-T0;
366: /* F=Ret[0]*Ret[1] */
367: Ret = dpm_remove_cont(F);
368: CI[J] = Ret[1];
369: Kind[I-1][J] = 2;
370: dpm_insert_to_zlist(ZI,EF,J);
371: dpm_set_schreyer_level(I-1);
372: Tail = -Ret[0]*dpm_dptodpm(One,J);
373: G += Tail;
374: dpm_set_schreyer_level(0);
375: Ret = dpm_remove_cont(G); G = Ret[1];
376: C[I][Ind] = G;
377: Kind[I][Ind] = 1;
378: K[I] = cons([G,Tail],K[I]);
379: dpm_insert_to_zlist(Z[I],EM,Ind);
380: /* level <- 0 */
381: BI[J][3] = 0;
382: } else {
383: Kind[I][Ind] = 0;
384: Ret = dpm_remove_cont(G); G = Ret[1];
385: H[I][Ind] = G;
386: C[I][Ind] = G;
387: dpm_insert_to_zlist(Z[I],EM,Ind);
388: }
389: }
390: }
391:
392: def lres_setup(F,V,H,Ord)
393: {
394: dpm_set_schreyer(0);
395: dp_ord(Ord);
396: K = length(F);
397: if ( type(F[0]) <= 2 ) {
398: // F is a polynimial list
399: F = map(dp_ptod,F,V);
400: F = map(dpm_dptodpm,F,1);
401: N = 1;
402: } else if ( type(F[0]) == 9 ) {
403: // F is a dpoly list
404: F = map(dpm_dptodpm,F,1);
405: N = 1;
406: } else if ( type(F[0]) == 4 ) {
407: // F is a list of poly lists
408: N = length(F[0]);
409: F = map(dpm_ltod,F,V);
410: } else if ( type(F[0]) == 26 ) {
411: // F is a DPM list
412: for ( N = 0, T = F; T != []; T = cdr(T) ) {
413: for ( A = car(T); A; A = dpm_rest(A) ) {
414: N1 = dpm_hp(A);
415: if ( N1 > N ) N = N1;
416: }
417: }
418: } else {
419: error("lres_setup: arugument type is invalid.");
420: }
421: G = nd_gr(F,V,H,[0,Ord]|dp=1);
422: G = reverse(G);
423: dp_ord([0,Ord]);
424: One = dp_ptod(1,V);
425: return [G,One];
426: }
427:
428: def dpm_sort1(L)
429: {
430: return [dpm_sort(L[0]),L[1]];
431: }
432:
433: def comp_pos(A,B)
434: {
435: PA = dpm_hp(A[0]); PB = dpm_hp(B[0]);
436: if ( PA > PB ) return 1;
437: else if ( PA < PB ) return -1;
438: else return 0;
439: }
440:
441: def lres(F,V,H,Ord)
442: {
443: T0 = time();
444: if ( type(Top=getopt(top)) == -1 ) Top = 0;
445: if ( type(NoSimpK=getopt(nosimpk)) == -1 ) NoSimpK = 0;
446: if ( type(NoPreProj=getopt(nopreproj)) == -1 ) NoPreProj = 0;
447: Rtime = Stime = Ptime = 0;
448: L = lres_setup(F,V,H,Ord);
449: G = L[0];
450: One = L[1];
451: F = dpm_schreyer_frame(G);
452: G = ltov(cons(0,L[0]));
453: F = reverse(F);
454: F = ltov(F);
455: N = length(F);
456: for ( I = 0; I < N; I++ ) {
457: FI = F[I]; FI[0] = [];
458: FI = map(ltov,FI);
459: F[I] = FI;
460: }
461: R = sortlsb(F);
462: B = vector(N+1);
463: Bpos = vector(N+1);
464: C = vector(N+1);
465: H = vector(N+1);
466: Z = vector(N+1);
467: K = vector(N+1);
468: L = vector(N+1);
469: K = vector(N+1);
470: D = vector(N+1);
471: Kind = vector(N+1);
472:
473: for ( I = 1; I <= N; I++ ) {
474: FI = F[I-1]; Len = length(FI);
475: B[I] = FI;
476: T = vector(Len-1);
477: for ( J = 1; J < Len; J++ ) T[J-1] = FI[J];
478: Bpos[I] = qsort(T,newsyz.comp_pos);
479: C[I] = vector(Len);
480: H[I] = vector(Len);
481: Kind[I] = vector(Len);
482: K[I] = [];
483: Max = 0;
484: for ( J = 1; J < Len; J++ )
485: if ( (Pos = dpm_hp(FI[J][0])) > Max ) Max = Pos;
486: Z[I] = ZI = vector(Max+1);
487: for ( J = 1; J <= Max; J++ ) ZI[J] = [];
488: }
489: T1 = time(); Ftime = T1[0]-T0[0];
490: R = ltov(R); Len = length(R);
491: print(["Len",Len]);
492: for ( I = 0, NF = 0; I < Len; I++ ) {
493: if ( !((I+1)%100) ) print(".",2);
494: if ( !((I+1)%10000) ) print(I+1);
495: if ( !R[I][3] ) continue;
496: NF++;
497: reduce(R[I],B,Bpos,C,H,Z,K,Kind,G,One,Top);
498: }
499: print("");
500: print(["NF",NF]);
501: T0 = time();
502: dpm_set_schreyer_level(0);
503: D[1] = map(dpm_sort,H[1]);
504: for ( I = 2; I <= N; I++ ) {
505: // HTT = [Head,Tab,TailTop]
506: HTT = create_base_ord(K[I],length(Kind[I-1]));
507: Head = HTT[0]; Tab = HTT[1]; TailTopPos = HTT[2];
508: if ( !NoPreProj )
509: Tab = map(remove_k,map(dpm_sort,Tab),Kind[I-1]);
510: else
511: Tab = map(dpm_sort,Tab);
512: TailTop = dpm_dptodpm(One,TailTopPos);
513: if ( !NoSimpK ) {
514: print("simplify_k "+rtostr(I)+"...",2);
515: simplify_k(Head,Tab,TailTop,One);
516: print("done");
517: }
518: HI = map(remove_k,map(dpm_sort,H[I]),Kind[I-1]);
519: Len = length(HI);
520: print("simplify_by_k "+rtostr(I)+"...",2);
521: D[I] = vector(Len);
522: for ( J = 0; J < Len; J++ ) {
523: D[I][J] = simplify_by_k(HI[J],Tab,TailTop,One);
524: if ( NoPreProj )
525: D[I][J] = remove_k(D[I][J],Kind[I-1]);
526: }
527: print("done");
528: }
529: dp_ord([1,0]);
530: T1 = time();
531: print(["Frame",Ftime,"Prep",Ptime,"Reduce",Rtime,"Search",Stime,"Minimalize",T1[0]-T0[0]]);
532: // return [C,H,K,Kind,D];
533: D = compress_h(D);
534: return D;
535: }
536:
537: def create_base_ord(K,N)
538: {
539: Tab = vector(N);
540: Ks = [];
541: for ( T = K; T != []; T = cdr(T) ) {
542: Ks = cons(I=dpm_hp(car(T)[1]),Ks);
543: Tab[I] = car(T)[0];
544: }
545: Others = [];
546: for ( I = N-1; I >= 1; I-- )
547: if ( !Tab[I] ) Others = cons(I,Others);
548: Ks = reverse(Ks);
549: dp_ord([4,append(Ks,Others),0]);
550: return [ltov(Ks),Tab,car(Others)];
551: }
552:
553: /* Head = [i1,i2,...], Tab[i1] = K[0], Tab[i2] = K[1],... */
554:
555: def simplify_k(Head,Tab,TailTop,One)
556: {
557: N = length(Tab);
558: Len = length(Head);
559: for ( I = Len-1; I >= 0; I-- ) {
560: M = 1;
561: R = Tab[Head[I]];
562: H = dpm_hm(R); R = dpm_rest(R);
563: while ( R && dpm_dptodpm(One,dpm_hp(R)) > TailTop ) {
564: Pos = dpm_hp(R); Red = Tab[Pos];
565: CRed = dp_hc(dpm_hc(Red));
566: CR = dpm_extract(R,Pos);
567: L = dpm_remove_cont(CRed*R-CR*Red);
568: R = L[1]; M *= CRed/L[0];
569: }
570: Tab[Head[I]] = M*H+R;
571: }
572: }
573:
574: def simplify_by_k(F,Tab,TailTop,One)
575: {
576: R = F;
577: M = 1;
578: while ( R && dpm_dptodpm(One,dpm_hp(R)) > TailTop ) {
579: Pos = dpm_hp(R); Red = Tab[Pos];
580: CRed = dp_hc(dpm_hc(Red));
581: CR = dpm_extract(R,Pos);
582: L = dpm_remove_cont(CRed*R-CR*Red);
583: R = L[1]; M *= CRed/L[0];
584: }
585: return (1/M)*R;
586: }
587:
588: /* Kind[I]=0 => phi(ei)\in H, Kind[I]=1 => phi(ei)\in K */
589: def remove_k(F,Kind)
590: {
591: R = [];
592: for ( T = F; T; T = dpm_rest(T) )
593: if ( Kind[dpm_hp(T)] != 1 ) R = cons(dpm_hm(T),R);
594: for ( S = 0; R != []; R = cdr(R) )
595: S += car(R);
596: return S;
597: }
598:
599: def remove_k1(F,Kind)
600: {
601: return [remove_k(F[0],Kind),F[1]];
602: }
603:
604: def extract_nonzero(A)
605: {
606: N = length(A);
607: R = [];
608: for ( C = I = 0; I < N; I++ )
609: if ( A[I] ) R=cons(A[I],R);
610: return reverse(R);;
611: }
612:
613: def nonzero(A)
614: {
615: N = length(A);
616: for ( C = I = 0; I < N; I++ )
617: if ( A[I] ) C++;
618: return C;
619: }
620:
621: def phi(C,F)
622: {
623: R = 0;
624: for ( T = F; T; T = dpm_rest(T) ) {
625: Coef = dpm_hc(T); Pos = dpm_hp(T);
626: R += Coef*C[Pos];
627: }
628: return R;
1.1 noro 629: }
630:
1.3 noro 631: def syz_check(H,I)
1.1 noro 632: {
1.3 noro 633: HI = H[I];
634: // dpm_set_schreyer_level(I-1);
635: HI1 = H[I+1];
636: Len = size(HI1)[0];
637: for ( J = 1; J < Len; J++ ) {
638: F = HI1[J];
639: R = phi(HI,F);
640: if ( R ) print([J,"NG"]);
641: }
1.1 noro 642: }
643:
1.3 noro 644: // for compressed C
645: def phi0(C,F)
1.1 noro 646: {
1.3 noro 647: R = 0;
648: for ( T = F; T; T = dpm_rest(T) ) {
649: Coef = dpm_hc(T); Pos = dpm_hp(T);
650: R += Coef*C[Pos-1];
651: }
652: return R;
1.1 noro 653: }
654:
1.3 noro 655: // for compressed H
656: def syz_check0(H,I)
1.1 noro 657: {
1.3 noro 658: HI = H[I];
659: // dpm_set_schreyer_level(I-1);
660: HI1 = H[I+1];
661: Len = length(HI1);
662: for ( J = 0; J < Len; J++ ) {
663: F = HI1[J];
664: R = phi0(HI,F);
665: if ( R ) print([J,"NG"]);
666: }
1.1 noro 667: }
668:
1.3 noro 669: // renumber position
670: def renumber_pos(F,Tab)
1.1 noro 671: {
1.3 noro 672: L = [];
673: for ( T = F; T; T = dpm_rest(T) )
674: L = cons(dpm_hm(T),L);
675: R = 0;
676: for ( T = L; T != []; T = cdr(T) )
677: R += dpm_dptodpm(dpm_hc(car(T)),Tab[dpm_hp(car(T))]);
678: return R;
1.1 noro 679: }
680:
1.3 noro 681: // compress H1 and renumber H
682: def compress(H,H1)
1.1 noro 683: {
1.3 noro 684: // create index table for H1
685: L1 = length(H1);
686: Tmp = vector(L1);
687: Tab = vector(L1);
688: for ( I = 1, J = 1; I < L1; I++ )
689: if ( H1[I] ) {
690: Tab[I] = J;
691: Tmp[J++] = H1[I];
692: }
693: NH1 = vector(J);
694: for ( I = 1; I < J; I++ )
695: NH1[I] = Tmp[I];
696: if ( H )
697: H = map(renumber_pos,H,Tab);
698: return [H,NH1];
1.1 noro 699: }
700:
1.3 noro 701: def compress_h(H)
1.1 noro 702: {
1.3 noro 703: // H = [0,H[1],...,H[L-1]]
704: L = length(H);
705: NH = vector(L-1);
706: H1 = H[1];
707: for ( I = 2; I < L; I++ ) {
708: R = compress(H[I],H1);
709: H1 = R[0];
710: NH[I-2] = cdr(vtol(R[1]));
711: }
712: R = compress(0,H1);
713: NH[L-2] = cdr(vtol(R[1]));
714: return NH;
1.1 noro 715: }
1.3 noro 716: endmodule$
1.1 noro 717: end$
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>