Annotation of OpenXM/src/asir-contrib/testing/noro/module_syz.rr, Revision 1.5
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 == [] ) {
1.5 ! noro 172: R = reverse(R);
1.3 noro 173: if ( DP ) return R;
174: else return map(dpmlisttollist,R,V);
175: }
176: R = cons(L,R);
177: }
178: }
179:
180: def minres(F,V,H,O)
181: {
182: if ( type(Weyl=getopt(weyl)) == -1 ) Weyl = 0;
183: if ( type(F4=getopt(f4)) == -1 ) F4 = 0;
184: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
185: L = todpmlist(F,V); F = L[0];
186: R = [F];
187: while ( 1 ) {
188: if ( Weyl )
189: L = module_syz(car(R),V,H,O|weyl=1,dp=1,f4=F4);
190: else
191: L = module_syz(car(R),V,H,O|dp=1,f4=F4);
192: L = L[0];
193: L = ordcheck(L,V);
194: if ( L == [] ) break;
195: S = dpm_simplify_syz(L,R[0]);
196: if ( S[0] == [] && S[1] == [] ) {
197: R = cdr(R); break;
198: }
199: R = append([S[0],S[1]],cdr(R));
200: if ( R[0] == [] ) {
201: R = cdr(R); break;
202: }
203: }
1.5 ! noro 204: R = reverse(R);
1.3 noro 205: if ( DP ) return R;
206: else return map(dpmlisttollist,R,V);
207: }
208:
209: def dpmlisttollist(F,V)
210: {
211: return map(dpm_dtol,F,V);
212: }
213:
214: def sres(F,V,H,Ord)
215: {
216: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
217: dpm_set_schreyer(0);
218: dp_ord(Ord);
219: K = length(F);
220: K = length(F);
221: for ( I = 0; I < K; I++ ) if ( F[I] ) break;
222: if ( I == K ) return [[],[],[]];
223: L = todpmlist(F,V);
224: F = L[0]; N = L[1];
225: G = nd_gr(F,V,H,[0,Ord]|dp=1);
226: G = reverse(G);
227: R = [G];
228: dp_ord([0,Ord]);
229: while ( 1 ) {
230: S = dpm_schreyer_base(R[0]);
231: print(["length",length(S)]);
232: if ( S == [] ) break;
233: else R = cons(S,R);
234: }
235: dp_ord([0,0]);
1.5 ! noro 236: R = reverse(R);
1.3 noro 237: if ( DP ) return R;
238: else return map(dpmlisttollist,R,V);
239: }
240:
241: def minsres(F,V,H,Ord)
242: {
243: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
244: R = sres(F,V,H,Ord|dp=1);
1.5 ! noro 245: R = ltov(reverse(R));
1.3 noro 246: M = length(R);
247: for ( I = 0; I < M; I++ ) R[I] = map(dpm_sort,R[I]);
248: R = vtol(R);
249: for ( T = R, U = []; length(T) >= 2; ) {
250: Z = dpm_simplify_syz(T[0],T[1]);
251: U = cons(Z[0],U);
252: T = cons(Z[1],cdr(cdr(T)));
253: }
254: U = cons(T[0],U);
255: if ( DP ) return U;
256: else return map(dpmlisttollist,U,V);
257: }
258:
259: def ordcheck(D,V)
260: {
261: B=map(dpm_dtol,D,V);
262: dp_ord([1,0]);
263: D = map(dpm_sort,D);
264: D1 = map(dpm_ltod,B,V);
265: if ( D != D1 )
266: print("afo");
267: return D1;
268: }
269:
270: def complsb(A,B)
271: {
272: AL = A[3]; AD = A[4];
273: BL = B[3]; BD = B[4];
274: if ( AD > BD ) return 1;
275: else if ( AD < BD ) return -1;
276: else if ( AL < BL ) return 1;
277: else if ( AL > BL ) return -1;
278: else return 0;
279: }
280:
281: def complsb_sd(A,B)
282: {
283: AL = A[3]; AD = A[4];
284: BL = B[3]; BD = B[4];
285: if ( AD-AL > BD-BL ) return 1;
286: else if ( AD-AL < BD-BL ) return -1;
287: else if ( AL > BL ) return 1;
288: else if ( AL < BL ) return -1;
289: else return 0;
290: }
291:
292: def sortlsb(A)
293: {
294: S = [];
295: N = length(A);
296: for ( I = 0; I < N; I++ ) S = append(cdr(vtol(A[I])),S);
297: // S = qsort(S,newsyz.complsb_sd);
298: S = qsort(S,newsyz.complsb);
299: return S;
300: }
301: /* D=[in,sum,deg,lev,ind] */
302: /* B=[0 B1 B2 ...] */
303: /* C=[0 C1 C2 ...] */
304: /* H=[0 H1 H2 ...] */
305: /* Z=[0 Z1 Z2 ...] */
306: /* Zi=[0 L1 L2 ...] */
307: /* Lj=[I1,I2,...] */
308: /* One=<<0,...,0>> */
309:
310: extern Rtime,Stime,Ptime$
311:
312: // B is sorted wrt positon
313: def find_pos(HF,B)
314: {
315: Len = length(B);
316: Pos = dpm_hp(HF);
317: First = 0; Last = Len-1;
318: if ( B[First][0] == HF ) return B[First][2];
319: if ( B[Last][0] == HF ) return B[Last][2];
320: while ( 1 ) {
321: Mid = idiv(First+Last,2);
322: PosM = dpm_hp(B[Mid][0]);
323: if ( PosM == Pos ) break;
324: else if ( PosM < Pos )
325: First = Mid;
326: else
327: Last = Mid;
328: }
329: for ( I = Mid; I < Len && dpm_hp(B[I][0]) == Pos; I++ )
330: if ( HF == B[I][0] ) return B[I][2];
331: for ( I = Mid-1; I >= 1 && dpm_hp(B[I][0]) == Pos; I-- )
332: if ( HF == B[I][0] ) return B[I][2];
333: error("find_pos : cannot happen");
334: }
335:
336: def reduce(D,B,Bpos,C,H,Z,K,Kind,G,One,Top)
337: {
338: M = D[0]; Ind = D[2]; I = D[3];
339: if ( I == 1 ) {
340: C[I][Ind] = G[Ind];
341: dpm_insert_to_zlist(Z[1],dpm_hp(G[Ind]),Ind);
342: H[I][Ind] = G[Ind];
343: } else {
344: /* M is in F(I-1) => phi(M) is in F(I-2) */
345: /* reduction in F(I-2) */
346: T0 = time()[0];
347: dpm_set_schreyer_level(I-2);
348: CI = C[I-1]; ZI = Z[I-1]; BI = B[I-1]; BposI = Bpos[I-1];
349: Len = size(CI);
350: T=dpm_hc(M); EM=dpm_hp(M);
351: XiM = T*dpm_ht(CI[EM]);
352: EXiM = dpm_hp(XiM);
353: ZIE = ZI[EXiM];
354: for ( ZIE = ZI[EXiM]; ZIE != []; ZIE = cdr(ZIE) ) {
355: J = car(ZIE);
356: if ( J > EM && dpm_redble(XiM,dpm_ht(CI[J])) ) break;
357: }
358: Ptime += time()[0]-T0;
359: T0 = time()[0];
360: QR = dpm_sp_nf(CI,ZI,EM,J|top=Top);
361: Rtime += time()[0]-T0;
362: G = QR[0]; F = QR[1];
363: if ( F ) {
364: HF = dpm_ht(F); EF = dpm_hp(HF);
365: /* find HF in B[I-1] */
366: T0 = time()[0];
367: J = find_pos(HF,BposI);
368: Stime += time()[0]-T0;
369: /* F=Ret[0]*Ret[1] */
370: Ret = dpm_remove_cont(F);
371: CI[J] = Ret[1];
372: Kind[I-1][J] = 2;
373: dpm_insert_to_zlist(ZI,EF,J);
374: dpm_set_schreyer_level(I-1);
375: Tail = -Ret[0]*dpm_dptodpm(One,J);
376: G += Tail;
377: dpm_set_schreyer_level(0);
378: Ret = dpm_remove_cont(G); G = Ret[1];
379: C[I][Ind] = G;
380: Kind[I][Ind] = 1;
381: K[I] = cons([G,Tail],K[I]);
382: dpm_insert_to_zlist(Z[I],EM,Ind);
383: /* level <- 0 */
384: BI[J][3] = 0;
385: } else {
386: Kind[I][Ind] = 0;
387: Ret = dpm_remove_cont(G); G = Ret[1];
388: H[I][Ind] = G;
389: C[I][Ind] = G;
390: dpm_insert_to_zlist(Z[I],EM,Ind);
391: }
392: }
393: }
394:
395: def lres_setup(F,V,H,Ord)
396: {
397: dpm_set_schreyer(0);
398: dp_ord(Ord);
399: K = length(F);
400: if ( type(F[0]) <= 2 ) {
401: // F is a polynimial list
402: F = map(dp_ptod,F,V);
403: F = map(dpm_dptodpm,F,1);
404: N = 1;
405: } else if ( type(F[0]) == 9 ) {
406: // F is a dpoly list
407: F = map(dpm_dptodpm,F,1);
408: N = 1;
409: } else if ( type(F[0]) == 4 ) {
410: // F is a list of poly lists
411: N = length(F[0]);
412: F = map(dpm_ltod,F,V);
413: } else if ( type(F[0]) == 26 ) {
414: // F is a DPM list
415: for ( N = 0, T = F; T != []; T = cdr(T) ) {
416: for ( A = car(T); A; A = dpm_rest(A) ) {
417: N1 = dpm_hp(A);
418: if ( N1 > N ) N = N1;
419: }
420: }
421: } else {
422: error("lres_setup: arugument type is invalid.");
423: }
424: G = nd_gr(F,V,H,[0,Ord]|dp=1);
425: G = reverse(G);
426: dp_ord([0,Ord]);
427: One = dp_ptod(1,V);
428: return [G,One];
429: }
430:
431: def dpm_sort1(L)
432: {
433: return [dpm_sort(L[0]),L[1]];
434: }
435:
436: def comp_pos(A,B)
437: {
438: PA = dpm_hp(A[0]); PB = dpm_hp(B[0]);
439: if ( PA > PB ) return 1;
440: else if ( PA < PB ) return -1;
441: else return 0;
442: }
443:
444: def lres(F,V,H,Ord)
445: {
446: T0 = time();
447: if ( type(Top=getopt(top)) == -1 ) Top = 0;
1.5 ! noro 448: if ( type(DP=getopt(dp)) == -1 ) DP = 0;
1.3 noro 449: if ( type(NoSimpK=getopt(nosimpk)) == -1 ) NoSimpK = 0;
450: if ( type(NoPreProj=getopt(nopreproj)) == -1 ) NoPreProj = 0;
451: Rtime = Stime = Ptime = 0;
452: L = lres_setup(F,V,H,Ord);
453: G = L[0];
454: One = L[1];
455: F = dpm_schreyer_frame(G);
456: G = ltov(cons(0,L[0]));
457: F = reverse(F);
458: F = ltov(F);
459: N = length(F);
460: for ( I = 0; I < N; I++ ) {
461: FI = F[I]; FI[0] = [];
462: FI = map(ltov,FI);
463: F[I] = FI;
464: }
465: R = sortlsb(F);
466: B = vector(N+1);
467: Bpos = vector(N+1);
468: C = vector(N+1);
469: H = vector(N+1);
470: Z = vector(N+1);
471: K = vector(N+1);
472: L = vector(N+1);
473: K = vector(N+1);
474: D = vector(N+1);
475: Kind = vector(N+1);
476:
477: for ( I = 1; I <= N; I++ ) {
478: FI = F[I-1]; Len = length(FI);
479: B[I] = FI;
480: T = vector(Len-1);
481: for ( J = 1; J < Len; J++ ) T[J-1] = FI[J];
482: Bpos[I] = qsort(T,newsyz.comp_pos);
483: C[I] = vector(Len);
484: H[I] = vector(Len);
485: Kind[I] = vector(Len);
486: K[I] = [];
487: Max = 0;
488: for ( J = 1; J < Len; J++ )
489: if ( (Pos = dpm_hp(FI[J][0])) > Max ) Max = Pos;
490: Z[I] = ZI = vector(Max+1);
491: for ( J = 1; J <= Max; J++ ) ZI[J] = [];
492: }
493: T1 = time(); Ftime = T1[0]-T0[0];
494: R = ltov(R); Len = length(R);
495: print(["Len",Len]);
496: for ( I = 0, NF = 0; I < Len; I++ ) {
497: if ( !((I+1)%100) ) print(".",2);
498: if ( !((I+1)%10000) ) print(I+1);
499: if ( !R[I][3] ) continue;
500: NF++;
501: reduce(R[I],B,Bpos,C,H,Z,K,Kind,G,One,Top);
502: }
503: print("");
504: print(["NF",NF]);
505: T0 = time();
506: dpm_set_schreyer_level(0);
507: D[1] = map(dpm_sort,H[1]);
508: for ( I = 2; I <= N; I++ ) {
509: // HTT = [Head,Tab,TailTop]
510: HTT = create_base_ord(K[I],length(Kind[I-1]));
511: Head = HTT[0]; Tab = HTT[1]; TailTopPos = HTT[2];
512: if ( !NoPreProj )
513: Tab = map(remove_k,map(dpm_sort,Tab),Kind[I-1]);
514: else
515: Tab = map(dpm_sort,Tab);
516: TailTop = dpm_dptodpm(One,TailTopPos);
517: if ( !NoSimpK ) {
518: print("simplify_k "+rtostr(I)+"...",2);
519: simplify_k(Head,Tab,TailTop,One);
520: print("done");
521: }
522: HI = map(remove_k,map(dpm_sort,H[I]),Kind[I-1]);
523: Len = length(HI);
524: print("simplify_by_k "+rtostr(I)+"...",2);
525: D[I] = vector(Len);
526: for ( J = 0; J < Len; J++ ) {
527: D[I][J] = simplify_by_k(HI[J],Tab,TailTop,One);
528: if ( NoPreProj )
529: D[I][J] = remove_k(D[I][J],Kind[I-1]);
530: }
531: print("done");
532: }
533: dp_ord([1,0]);
534: T1 = time();
535: print(["Frame",Ftime,"Prep",Ptime,"Reduce",Rtime,"Search",Stime,"Minimalize",T1[0]-T0[0]]);
536: // return [C,H,K,Kind,D];
537: D = compress_h(D);
1.5 ! noro 538: if ( DP ) return D;
! 539: else return vtol(map(dpmlisttollist,D,V));
1.3 noro 540: }
541:
542: def create_base_ord(K,N)
543: {
544: Tab = vector(N);
545: Ks = [];
546: for ( T = K; T != []; T = cdr(T) ) {
547: Ks = cons(I=dpm_hp(car(T)[1]),Ks);
548: Tab[I] = car(T)[0];
549: }
550: Others = [];
551: for ( I = N-1; I >= 1; I-- )
552: if ( !Tab[I] ) Others = cons(I,Others);
553: Ks = reverse(Ks);
554: dp_ord([4,append(Ks,Others),0]);
555: return [ltov(Ks),Tab,car(Others)];
556: }
557:
558: /* Head = [i1,i2,...], Tab[i1] = K[0], Tab[i2] = K[1],... */
559:
560: def simplify_k(Head,Tab,TailTop,One)
561: {
562: N = length(Tab);
563: Len = length(Head);
564: for ( I = Len-1; I >= 0; I-- ) {
565: M = 1;
566: R = Tab[Head[I]];
567: H = dpm_hm(R); R = dpm_rest(R);
568: while ( R && dpm_dptodpm(One,dpm_hp(R)) > TailTop ) {
569: Pos = dpm_hp(R); Red = Tab[Pos];
570: CRed = dp_hc(dpm_hc(Red));
571: CR = dpm_extract(R,Pos);
572: L = dpm_remove_cont(CRed*R-CR*Red);
573: R = L[1]; M *= CRed/L[0];
574: }
575: Tab[Head[I]] = M*H+R;
576: }
577: }
578:
579: def simplify_by_k(F,Tab,TailTop,One)
580: {
581: R = F;
582: M = 1;
583: while ( R && dpm_dptodpm(One,dpm_hp(R)) > TailTop ) {
584: Pos = dpm_hp(R); Red = Tab[Pos];
585: CRed = dp_hc(dpm_hc(Red));
586: CR = dpm_extract(R,Pos);
587: L = dpm_remove_cont(CRed*R-CR*Red);
588: R = L[1]; M *= CRed/L[0];
589: }
590: return (1/M)*R;
591: }
592:
593: /* Kind[I]=0 => phi(ei)\in H, Kind[I]=1 => phi(ei)\in K */
594: def remove_k(F,Kind)
595: {
596: R = [];
597: for ( T = F; T; T = dpm_rest(T) )
598: if ( Kind[dpm_hp(T)] != 1 ) R = cons(dpm_hm(T),R);
599: for ( S = 0; R != []; R = cdr(R) )
600: S += car(R);
601: return S;
602: }
603:
604: def remove_k1(F,Kind)
605: {
606: return [remove_k(F[0],Kind),F[1]];
607: }
608:
609: def extract_nonzero(A)
610: {
611: N = length(A);
612: R = [];
613: for ( C = I = 0; I < N; I++ )
614: if ( A[I] ) R=cons(A[I],R);
615: return reverse(R);;
616: }
617:
618: def nonzero(A)
619: {
620: N = length(A);
621: for ( C = I = 0; I < N; I++ )
622: if ( A[I] ) C++;
623: return C;
624: }
625:
626: def phi(C,F)
627: {
628: R = 0;
629: for ( T = F; T; T = dpm_rest(T) ) {
630: Coef = dpm_hc(T); Pos = dpm_hp(T);
631: R += Coef*C[Pos];
632: }
633: return R;
1.1 noro 634: }
635:
1.3 noro 636: def syz_check(H,I)
1.1 noro 637: {
1.3 noro 638: HI = H[I];
639: // dpm_set_schreyer_level(I-1);
640: HI1 = H[I+1];
641: Len = size(HI1)[0];
642: for ( J = 1; J < Len; J++ ) {
643: F = HI1[J];
644: R = phi(HI,F);
645: if ( R ) print([J,"NG"]);
646: }
1.1 noro 647: }
648:
1.3 noro 649: // for compressed C
650: def phi0(C,F)
1.1 noro 651: {
1.3 noro 652: R = 0;
653: for ( T = F; T; T = dpm_rest(T) ) {
654: Coef = dpm_hc(T); Pos = dpm_hp(T);
655: R += Coef*C[Pos-1];
656: }
657: return R;
1.1 noro 658: }
659:
1.3 noro 660: // for compressed H
661: def syz_check0(H,I)
1.1 noro 662: {
1.3 noro 663: HI = H[I];
664: // dpm_set_schreyer_level(I-1);
665: HI1 = H[I+1];
666: Len = length(HI1);
667: for ( J = 0; J < Len; J++ ) {
668: F = HI1[J];
669: R = phi0(HI,F);
670: if ( R ) print([J,"NG"]);
671: }
1.1 noro 672: }
673:
1.3 noro 674: // renumber position
675: def renumber_pos(F,Tab)
1.1 noro 676: {
1.3 noro 677: L = [];
678: for ( T = F; T; T = dpm_rest(T) )
679: L = cons(dpm_hm(T),L);
680: R = 0;
681: for ( T = L; T != []; T = cdr(T) )
682: R += dpm_dptodpm(dpm_hc(car(T)),Tab[dpm_hp(car(T))]);
683: return R;
1.1 noro 684: }
685:
1.3 noro 686: // compress H1 and renumber H
687: def compress(H,H1)
1.1 noro 688: {
1.3 noro 689: // create index table for H1
690: L1 = length(H1);
691: Tmp = vector(L1);
692: Tab = vector(L1);
693: for ( I = 1, J = 1; I < L1; I++ )
694: if ( H1[I] ) {
695: Tab[I] = J;
696: Tmp[J++] = H1[I];
697: }
698: NH1 = vector(J);
699: for ( I = 1; I < J; I++ )
700: NH1[I] = Tmp[I];
701: if ( H )
702: H = map(renumber_pos,H,Tab);
703: return [H,NH1];
1.1 noro 704: }
705:
1.3 noro 706: def compress_h(H)
1.1 noro 707: {
1.3 noro 708: // H = [0,H[1],...,H[L-1]]
709: L = length(H);
710: NH = vector(L-1);
711: H1 = H[1];
712: for ( I = 2; I < L; I++ ) {
713: R = compress(H[I],H1);
714: H1 = R[0];
715: NH[I-2] = cdr(vtol(R[1]));
716: }
717: R = compress(0,H1);
718: NH[L-2] = cdr(vtol(R[1]));
719: return NH;
1.1 noro 720: }
1.3 noro 721: endmodule$
1.1 noro 722: end$
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>