Annotation of OpenXM/src/asir-contrib/testing/noro/mwl.rr, Revision 1.5
1.1 noro 1: /*
2: F=y^2-x*(x-1)*(x-t)$
3: F=y^2-(x^3+t^7)$
4: F=y^2-(x^3+t*(t^10+1))$
5: F=y^2-(x^3+t^11+1)$
6: F=(y^2+72*x*y-10*t^2*y)-(x^3+60*x^2*t-15*x*t^3+t^5)$
7: */
8: /* 6A1fibre2a.txt */
9: A1=y^2-(x^3+(2*t^2+18)*x^2+(t^4-82*t^2+81)*x)$
10: /* A2try3d.txt */
11: A2=y^2-(x^3-x+t^2)$
12: /* A8fibre2.txt */
13: A8=y^2-(x^3+t^2*x^2-8*t*x+16)$
14: /* D8fibre1.txt */
15: D8=y^2-(x^3-3*(t^2-1)*x-2*t^3+3*t)$
16: /* E7A1fibre1.txt */
17: E7=y^2-(x^3+t*x)$
18: /* F5ss1new2.txt */
19: F5=y^2-(x^3+t^11-t)$
20: /* F6ss1new2.txt */
21: F6=y^2-(x^3+t^12-1)$
1.2 noro 22: /* OS8split4 */
23: OS8=y^2-240*x*y-300*t^2*y-x^3+476*t*x^2+65*t^3*x-t^5$
1.1 noro 24: import("gr")$
25: module mwl$
26: localf generate_coef_ideal$
27: localf pdecomp,pdecomp_main,ideal_intersection,ldim$
28: localf pdecomp_ff,pdecomp_ff_main,ideal_intersection_ff,ldim_ff$
29: localf ideal_elimination,gbcheck,f4$
1.3 noro 30: localf pdecomp_de,pdecomp_de_main,split,zcolon$
1.1 noro 31: static GBCheck,F4$
32: #define Tmp ttttt
33:
34: def gbcheck(A)
35: {
36: if ( A ) GBCheck = 1;
37: else GBCheck = -1;
38: }
39:
40: def f4(A)
41: {
42: if ( A ) F4 = 1;
43: else F4 = 0;
44: }
45:
1.2 noro 46: /* if option simp=1 is given, we try simplifying the output ideal. */
47: /* Remove an^3-bm^2 and an -> v^2, bm -> v^3 */
48:
1.1 noro 49: def generate_coef_ideal(F)
50: {
1.2 noro 51: if ( type(Simp=getopt(simp)) == -1 ) Simp = 0;
1.1 noro 52: A1 = coef(coef(F,1,x),1,y);
53: A2 = -coef(coef(F,2,x),0,y);
54: A3 = coef(coef(F,0,x),1,y);
55: A4 = -coef(coef(F,1,x),0,y);
56: A6 = -coef(coef(F,0,x),0,y);
57: D = vector(5,
58: [deg(A1,t)/1,deg(A2,t)/2,deg(A3,t)/3,deg(A4,t)/4,deg(A6,t)/6]);
59: D = map(ceil,D);
60: for ( K = D[0], I = 1; I < 5; I++ ) if ( K < D[I] ) K = D[I];
61: VX = [];
62: for ( I = 0, X = 0; I <= 2*K; I++ ) {
63: V = strtov("a"+rtostr(I));
64: X += V*t^I;
65: VX = cons(V,VX);
66: }
67: VY = [];
68: for ( I = 0, Y = 0; I <= 3*K; I++ ) {
69: V = strtov("b"+rtostr(I));
70: Y += V*t^I;
71: VY = cons(V,VY);
72: }
73: S = subst(F,x,X,y,Y);
74: N = deg(S,t);
75: for ( R = [], I = 0; I <= N; I++ ) R = cons(coef(S,I,t),R);
1.2 noro 76: if ( Simp ) {
77: R0 = car(R); R = cdr(R);
78: VX0 = car(VX); VX = cdr(VX);
79: VY0 = car(VY); VY = cdr(VY);
80: if ( subst(R0,VX0,v^2,VY0,v^3)==0 ) {
81: R = subst(R,VX0,v^2,VY0,v^3);
82: return [R,append(append(VY,VX),[v])];
83: } else
84: error("The output ideal cannot be simplified");
85: } else
86: return [R,append((VY),(VX))];
1.1 noro 87: }
88:
89: def pdecomp(B,V) {
1.4 noro 90: if ( type(IsF4=getopt(f4)) == -1 ) f4(0);
91: else f4(IsF4);
1.5 ! noro 92: if ( type(IsGBCheck=getopt(gbcheck)) == -1 ) gbcheck(1);
1.4 noro 93: else gbcheck(IsGBCheck);
1.1 noro 94: if ( F4 ) G0 = nd_f4_trace(B,V,1,GBCheck,0);
95: else G0 = nd_gr_trace(B,V,1,GBCheck,0);
96: G=[G0];
97: for ( T = reverse(V); T !=[]; T = cdr(T) ) {
98: G1 = [];
99: X = car(T);
100: for ( S = G; S != []; S = cdr(S) ) {
101: GX = pdecomp_main(car(S),V,0,X);
102: G1 = append(GX,G1);
103: }
104: G = G1;
105: }
106: return [G,G0];
107: }
108:
109: def pdecomp_ff(B,V,Mod) {
1.4 noro 110: if ( type(IsF4=getopt(f4)) == -1 ) f4(0);
111: else f4(IsF4);
1.1 noro 112: if ( F4 ) G0 = nd_f4(B,V,Mod,0);
113: else G0 = nd_gr(B,V,Mod,0);
114: G=[G0];
115: for ( T = reverse(V); T !=[]; T = cdr(T) ) {
116: G1 = [];
117: X = car(T);
118: for ( S = G; S != []; S = cdr(S) ) {
119: GX = pdecomp_ff_main(car(S),V,0,X,Mod);
120: G1 = append(GX,G1);
121: }
122: G = G1;
123: }
124: return [G,G0];
125: }
126:
127: def pdecomp_main(G,V,Ord,X) {
128: M = minipoly(G,V,Ord,X,Tmp);
129: M = subst(M,Tmp,X);
130: FM = cdr(fctr(M));
131: if ( length(FM) == 1 ) return [G];
132: G2 = [];
133: for ( T = FM; T != []; T = cdr(T) ) {
134: F1 = car(T);
135: for ( I = 0, N = F1[1], NF=1; I < N; I++ )
136: NF = p_nf(NF*F1[0],G,V,Ord);
137: if ( F4 ) G1 = nd_f4_trace(cons(NF,G),V,1,GBCheck,Ord);
138: else G1 = nd_gr_trace(cons(NF,G),V,1,GBCheck,Ord);
139: G2 =cons(G1,G2);
140: }
141: return G2;
142: }
143:
144: def pdecomp_ff_main(G,V,Ord,X,Mod) {
145: M = minipolym(G,V,Ord,X,Tmp,Mod);
146: M = subst(M,Tmp,X);
147: FM = cdr(modfctr(M,Mod));
148: if ( length(FM) == 1 ) return [G];
149: G2 = [];
150: for ( T = FM; T != []; T = cdr(T) ) {
151: F1 = car(T);
152: for ( I = 0, N = F1[1], NF=1; I < N; I++ )
153: NF = p_nf_mod(NF*F1[0],G,V,Ord,Mod);
154: if ( F4 ) G1 = nd_f4(cons(NF,G),V,Mod,Ord);
155: else G1 = nd_gr(cons(NF,G),V,Mod,Ord);
156: G2 =cons(G1,G2);
157: }
158: return G2;
159: }
160:
1.3 noro 161: def pdecomp_de(B,V) {
162: if ( F4 ) G0 = nd_f4_trace(B,V,1,GBCheck,0);
163: else G0 = nd_gr_trace(B,V,1,GBCheck,0);
164: G=[G0];
165: for ( T = reverse(V); T !=[]; T = cdr(T) ) {
166: G1 = [];
167: X = car(T);
168: for ( S = G; S != []; S = cdr(S) ) {
169: GX = pdecomp_de_main(car(S),V,0,X);
170: G1 = append(GX,G1);
171: }
172: G = G1;
173: }
174: return [G,G0];
175: }
176:
177: #if 1
178: def pdecomp_de_main(G,V,Ord,X) {
179: M = minipoly(G,V,Ord,X,Tmp);
180: M = subst(M,Tmp,X);
181: FM = cdr(fctr(M));
182: if ( length(FM) == 1 ) return [G];
183: G2 = [];
184: G1 = G;
185: for ( T = FM; length(T) > 1; T = cdr(T) ) {
186: F1 = car(T);
187: for ( I = 0, N = F1[1], NF=1; I < N; I++ )
188: NF = p_nf(NF*F1[0],G1,V,Ord);
189: C = split(V,G1,NF,Ord);
190: /* C = [G1:NF,G1+NF] */
191: G1 = C[0]; G2 =cons(C[1],G2);
192: }
193: G2 = cons(G1,G2);
194: return G2;
195: }
196: #else
197: def pdecomp_de_main(G,V,Ord,X) {
198: M = minipoly(G,V,Ord,X,Tmp);
199: M = subst(M,Tmp,X);
200: FM = cdr(fctr(M));
201: if ( length(FM) == 1 ) return [G];
202: G2 = [];
203: G1 = G;
204: NFM = length(FM);
205: A = vector(NFM);
206: for ( J = 0; J < NFM; J++ ) {
207: FJ = FM[J];
208: for ( I = 0, N = FJ[1], NF=1; I < N; I++ )
209: NF = p_nf(NF*FJ[0],G1,V,Ord);
210: A[J] = NF;
211: }
212: for ( T = FM, J = 0; J < NFM; J++ ) {
213: for ( I = 0, NF=1; I < NFM; I++ )
214: if ( I != J )
215: NF = p_nf(NF*A[I],G,V,Ord);
216: C = zcolon(V,G1,NF,Ord);
217: G2 =cons(C,G2);
218: }
219: return G2;
220: }
221: #endif
222:
223: /* from de.rr */
224:
225: def split(V,Id,F,Ord)
226: {
227: Id = map(ptozp,Id);
228: N = length(V);
229: dp_ord(Ord);
230: set_field(Id,V,Ord);
231: DF = dptodalg(dp_ptod(F,V));
232: Ret = inv_or_split_dalg(DF);
233: /* Ret = GB(Id:F) */
234: /* compute GB(Id+<f>) */
235: Gquo = append(map(ptozp,map(dp_dtop,Ret,V)),Id);
236: /* inter-reduction */
237: Gquo = nd_gr_postproc(Gquo,V,0,Ord,0);
238: B = cons(F,Id);
239: if ( F4 ) Grem = nd_f4_trace(B,V,1,GBCheck,Ord);
240: else Grem = nd_gr_trace(B,V,1,GBCheck,Ord);
241: return [map(ptozp,Gquo),map(ptozp,Grem)];
242: }
243:
244: /* Id:F for zero-dim. ideal Id */
245:
246: def zcolon(V,Id,F,Ord)
247: {
248: Id = map(ptozp,Id);
249: N = length(V);
250: dp_ord(Ord);
251: set_field(Id,V,Ord);
252: DF = dptodalg(dp_ptod(F,V));
253: Ret = inv_or_split_dalg(DF);
254: /* Ret = GB(Id:F) */
255: /* compute GB(Id+<f>) */
256: Gquo = append(map(ptozp,map(dp_dtop,Ret,V)),Id);
257: Gquo = nd_gr_postproc(Gquo,V,0,Ord,0);
258: return map(ptozp,Gquo);
259: }
260:
1.1 noro 261: def ideal_intersection(L,V,Ord)
262: {
263: N = length(L);
264: if ( N == 1 ) return L[0];
265: N2 = idiv(N,2);
266: for ( I = 0, L1 = []; I < N2; I++, L = cdr(L) ) L1 = cons(car(L),L1);
267: L1 = reverse(L1);
268: J = ideal_intersection(L,V,Ord);
269: J1 = ideal_intersection(L1,V,Ord);
270: R = append(vtol(ltov(J)*Tmp),vtol(ltov(J1)*(1-Tmp)));
271: if ( F4 ) G = nd_f4_trace(R,cons(Tmp,V),1,GBCheck,[[0,1],[Ord,length(V)]]);
272: else G = nd_gr_trace(R,cons(Tmp,V),1,GBCheck,[[0,1],[Ord,length(V)]]);
273: G = ideal_elimination(G,V);
274: return G;
275: }
276:
277: def ideal_intersection_ff(L,V,Ord,Mod)
278: {
279: N = length(L);
280: if ( N == 1 ) return L[0];
281: N2 = idiv(N,2);
282: for ( I = 0, L1 = []; I < N2; I++, L = cdr(L) ) L1 = cons(car(L),L1);
283: L1 = reverse(L1);
284: J = ideal_intersection_ff(L,V,Ord,Mod);
285: J1 = ideal_intersection_ff(L1,V,Ord,Mod);
286: R = append(vtol(ltov(J)*Tmp),vtol(ltov(J1)*(1-Tmp)));
287: if ( F4 ) G = nd_f4(R,cons(Tmp,V),Mod,[[0,1],[Ord,length(V)]]);
288: else G = nd_gr(R,cons(Tmp,V),Mod,[[0,1],[Ord,length(V)]]);
289: G = ideal_elimination(G,V);
290: return G;
291: }
292:
293: def ideal_elimination(G,V)
294: {
295: ANS=[];
296: NG=length(G);
297:
298: for (I=NG-1;I>=0;I--) {
299: VSet=vars(G[I]);
300: DIFF=setminus(VSet,V);
301: if ( DIFF ==[] ) ANS=cons(G[I],ANS);
302: }
303: return ANS;
304: }
305:
306: def ldim(G,V)
307: {
308: G = nd_gr_trace(G,V,1,1,0);
309: if ( ! zero_dim(G,V,0) ) error("<G> is not zero-dimensional");
310: return length(dp_mbase(map(dp_ptod,G,V)));
311: }
312:
313: def ldim_ff(G,V,Mod)
314: {
315: G = nd_gr(G,V,Mod,0);
316: if ( ! zero_dim(G,V,0) ) error("<G> is not zero-dimensional");
317: return length(dp_mbase(map(dp_ptod,G,V)));
318: }
319: endmodule$
320: end$
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>