1 | "ndebug?: ", system("with", "ndebug"); |
---|
2 | "om_ndebug?: ", system("with", "om_ndebug"); |
---|
3 | |
---|
4 | listvar(Top); |
---|
5 | |
---|
6 | if( system("with", "ndebug") ) |
---|
7 | { |
---|
8 | "Loading the Release version!"; |
---|
9 | LIB("syzextra.so"); |
---|
10 | listvar(Syzextra); |
---|
11 | } |
---|
12 | else |
---|
13 | { |
---|
14 | "Loading the Debug version!"; |
---|
15 | LIB("syzextra.so"); |
---|
16 | listvar(Syzextra); |
---|
17 | } |
---|
18 | |
---|
19 | |
---|
20 | noop(); |
---|
21 | |
---|
22 | proc NegativeNumber(number c) |
---|
23 | { |
---|
24 | string s = sprintf("(%s)", c); int i = 1; |
---|
25 | |
---|
26 | // cannot run ouside of s (with '(((('), right? |
---|
27 | while( s[i] == "(" || s[i] == " " ) { i++; }; |
---|
28 | |
---|
29 | // now should either sign or digit or letter come, right? |
---|
30 | return (s[i] == "-" ); |
---|
31 | } |
---|
32 | |
---|
33 | |
---|
34 | proc TestClearContent(def i, number c, def o) |
---|
35 | { |
---|
36 | ""; |
---|
37 | "Test: ClearContent(", i, " --?-> ", o, " / => ", c, "): "; |
---|
38 | int pass = 1; |
---|
39 | number @c = ClearContent(i); |
---|
40 | |
---|
41 | if( NegativeNumber(leadcoef(i)) ) |
---|
42 | { |
---|
43 | "ERROR: negative leading coeff. after clearing content: ", leadcoef(i), " instead of ", leadcoef(o); |
---|
44 | pass = 0; |
---|
45 | } |
---|
46 | if( @c != c ) |
---|
47 | { |
---|
48 | "ERROR: wrong content: ", @c, " instead of ", c; |
---|
49 | pass = 0; |
---|
50 | } |
---|
51 | if( i != o ) |
---|
52 | { |
---|
53 | "ERROR: wrong element after clearing content: ", i, " instead of ", o; |
---|
54 | pass = 0; |
---|
55 | } |
---|
56 | |
---|
57 | if( pass ) |
---|
58 | { |
---|
59 | "[TestClearContent -- PASSED]"; |
---|
60 | } else |
---|
61 | { |
---|
62 | basering; |
---|
63 | "ERROR: [TestClearContent -- FAILED]"; |
---|
64 | m2_end(666); |
---|
65 | } |
---|
66 | ""; |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | proc TestClearDenominators(def i, number c, def o) |
---|
71 | { |
---|
72 | def ii = cleardenom(i); |
---|
73 | ""; |
---|
74 | "Test: ClearDenominators(", i, " --?-> ", o, " / => ", c, "): "; |
---|
75 | int pass = 1; |
---|
76 | number @c = ClearDenominators(i); |
---|
77 | |
---|
78 | // if( NegativeNumber(leadcoef(i)) ) |
---|
79 | // { |
---|
80 | // "ERROR: negative leading coeff. after clearing denominators: ", leadcoef(i), " instead of ", leadcoef(o); |
---|
81 | // pass = 0; |
---|
82 | // } |
---|
83 | if( @c != c ) |
---|
84 | { |
---|
85 | "ERROR: wrong multiplier: ", @c, " instead of ", c; |
---|
86 | pass = 0; |
---|
87 | } |
---|
88 | if( i != o ) |
---|
89 | { |
---|
90 | "ERROR: wrong element after clearing denominators: ", i, " instead of ", o; |
---|
91 | pass = 0; |
---|
92 | } |
---|
93 | |
---|
94 | number cntnt = ClearContent(i); // cleardenom seems to run clearcontent on its own... |
---|
95 | if( i != ii ) |
---|
96 | { |
---|
97 | "WARNING/ERROR?: result of clearing denominators: ", i, " is inconsistent with cleardenom(): ", ii; |
---|
98 | // pass = 0; |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | if( pass ) |
---|
103 | { |
---|
104 | "[TestClearDenominators -- PASSED]"; |
---|
105 | } else |
---|
106 | { |
---|
107 | basering; |
---|
108 | "ERROR: [TestClearDenominators -- FAILED]"; |
---|
109 | m2_end(666); |
---|
110 | } |
---|
111 | ""; |
---|
112 | } |
---|
113 | |
---|
114 | proc TestClearRingX(poly X) |
---|
115 | { |
---|
116 | // // clearcontent: |
---|
117 | |
---|
118 | // with polynomials in 'X' |
---|
119 | TestClearContent(poly(1), number(1), poly(1)); // {1} -> {1}, c=1 |
---|
120 | TestClearContent(poly(2), number(2), poly(1)); // {2} -> {1}, c=2 |
---|
121 | TestClearContent(poly(222222222222*X + 2), number(2), poly(111111111111*X + 1)); // {222222222222, 2 } -> { 111111111111, 1} c=2 |
---|
122 | TestClearContent(poly(2*X + 222222222222), number(2), poly(1*X + 111111111111)); // {2, 222222222222 } -> { 1, 111111111111} c=2 |
---|
123 | |
---|
124 | // use vector instead: |
---|
125 | TestClearContent(vector(1), number(1), vector(1)); // {1} -> {1}, c=1 |
---|
126 | TestClearContent(vector(2), number(2), vector(1)); // {2} -> {1}, c=2 |
---|
127 | TestClearContent(vector([222222222222, 2]), number(2), vector([111111111111, 1])); // {222222222222, 2 } -> { 111111111111, 1} c=2 |
---|
128 | TestClearContent(vector([2, 222222222222]), number(2), vector([1, 111111111111])); // {2, 222222222222 } -> { 1, 111111111111} c=2 |
---|
129 | |
---|
130 | |
---|
131 | // with negative leading coeff! |
---|
132 | TestClearContent(-poly(1), -number(1), poly(1)); // {1} -> {1}, c=1 |
---|
133 | TestClearContent(-poly(2), -number(2), poly(1)); // {2} -> {1}, c=2 |
---|
134 | TestClearContent(-poly(222222222222*X + 2), -number(2), poly(111111111111*X + 1)); // {222222222222, 2 } -> { 111111111111, 1} c=2 |
---|
135 | TestClearContent(-poly(2*X + 222222222222), -number(2), poly(1*X + 111111111111)); // {2, 222222222222 } -> { 1, 111111111111} c=2 |
---|
136 | |
---|
137 | // use vector instead: |
---|
138 | TestClearContent(-vector(1), -number(1), vector(1)); // {1} -> {1}, c=1 |
---|
139 | TestClearContent(-vector(2), -number(2), vector(1)); // {2} -> {1}, c=2 |
---|
140 | TestClearContent(-vector([222222222222, 2]), -number(2), vector([111111111111, 1])); // {222222222222, 2 } -> { 111111111111, 1} c=2 |
---|
141 | TestClearContent(-vector([2, 222222222222]), -number(2), vector([1, 111111111111])); // {2, 222222222222 } -> { 1, 111111111111} c=2 |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | TestClearDenominators(poly(1), number(1), poly(1)); // {1} -> {1}, c=1 |
---|
147 | TestClearDenominators(poly(2), number(1), poly(2)); // {2} -> {2}, c=1 |
---|
148 | TestClearDenominators(poly(X + (1/2)), number(2), poly(2*X + 1)); // {1, 1/2 } -> {2, 1}, c=2 |
---|
149 | TestClearDenominators(poly((1/2)*X + 1), number(2), poly(X + 2)); // {1/2, 1} -> {1, 2}, c=2 |
---|
150 | TestClearDenominators(poly((1/3)*(X*X*X)+(1/4)*X*X+(1/6)*X+1), number(12), poly(4*X*X*X+3*X*X+2*X+12)); // {1/3, 1/4, 1/6, 1 } -> {4, 3, 2, 12}, c=12 |
---|
151 | TestClearDenominators(poly((1/2)*X*X*X+(1/4)*X*X+(3/2)*X+111111111111), number(4), poly(2*X*X*X+X*X+6*X+444444444444)); // {1/2, 1/4, 3/2, 111111111111 } -> {2, 1, 6, 444444444444} , c=4 |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | TestClearDenominators(vector([1]), number(1), vector([1])); // {1} -> {1}, c=1 |
---|
156 | TestClearDenominators(vector([2]), number(1), vector([2])); // {2} -> {2}, c=1 |
---|
157 | TestClearDenominators(vector([1, 1/2]), number(2), vector([2, 1])); // {1, 1/2} -> {2, 1}, c=2 |
---|
158 | TestClearDenominators(vector([1/2, 1]), number(2), vector([1, 2])); // {1/2, 1} -> {1, 2}, c=2 |
---|
159 | TestClearDenominators(vector([1/3,1/4,1/6,1]), number(12), vector([4,3,2,12])); // {1/3, 1/4, 1/6, 1 } -> {4, 3, 2, 12}, c=12 |
---|
160 | TestClearDenominators(vector([1/2,1/4,3/2,111111111111]), number(4), vector([2,1,6,444444444444])); // {1/2, 1/4, 3/2, 111111111111 } -> {2, 1, 6, 444444444444} , c=4 |
---|
161 | |
---|
162 | /* |
---|
163 | TestClearDenominators(-poly(1), -number(1), poly(1)); // {1} -> {1}, c=1 |
---|
164 | TestClearDenominators(-poly(2), -number(1), poly(2)); // {2} -> {2}, c=1 |
---|
165 | |
---|
166 | TestClearDenominators(-poly(X + (1/2)), -number(2), poly(2*X + 1)); // {1, 1/2 } -> {2, 1}, c=2 |
---|
167 | TestClearDenominators(-poly((1/2)*X + 1), -number(2), poly(X + 2)); // {1/2, 1} -> {1, 2}, c=2 |
---|
168 | TestClearDenominators(-poly((1/3)*(X*X*X)+(1/4)*X*X+(1/6)*X+1), -number(12), poly(4*X*X*X+3*X*X+2*X+12)); // {1/3, 1/4, 1/6, 1 } -> {4, 3, 2, 12}, c=12 |
---|
169 | TestClearDenominators(-poly((1/2)*X*X*X+(1/4)*X*X+(3/2)*X+111111111111), -number(4), poly(2*X*X*X+X*X+6*X+444444444444)); // {1/2, 1/4, 3/2, 111111111111 } -> {2, 1, 6, 444444444444} , c=4 |
---|
170 | |
---|
171 | TestClearDenominators(-vector([1]), -number(1), vector([1])); // {1} -> {1}, c=1 |
---|
172 | TestClearDenominators(-vector([2]), -number(1), vector([2])); // {2} -> {2}, c=1 |
---|
173 | TestClearDenominators(-vector([1, 1/2]), -number(2), vector([2, 1])); // {1, 1/2} -> {2, 1}, c=2 |
---|
174 | TestClearDenominators(-vector([1/2, 1]), -number(2), vector([1, 2])); // {1/2, 1} -> {1, 2}, c=2 |
---|
175 | TestClearDenominators(-vector([1/3,1/4,1/6,1]), -number(12), vector([4,3,2,12])); // {1/3, 1/4, 1/6, 1 } -> {4, 3, 2, 12}, c=12 |
---|
176 | TestClearDenominators(-vector([1/2,1/4,3/2,111111111111]), -number(4), vector([2,1,6,444444444444])); // {1/2, 1/4, 3/2, 111111111111 } -> {2, 1, 6, 444444444444} , c=4 |
---|
177 | */ |
---|
178 | |
---|
179 | } |
---|
180 | |
---|
181 | ring R = 0, (x), dp; |
---|
182 | TestClearRingX(x); |
---|
183 | kill R; |
---|
184 | |
---|
185 | ring R = 0, (x, y, z), dp; |
---|
186 | TestClearRingX(x); |
---|
187 | TestClearRingX(y); |
---|
188 | TestClearRingX(z); |
---|
189 | |
---|
190 | TestClearRingX(xy); |
---|
191 | TestClearRingX(yz); |
---|
192 | TestClearRingX(xz); |
---|
193 | |
---|
194 | TestClearRingX(xyz); |
---|
195 | |
---|
196 | |
---|
197 | TestClearContent(poly(9x2y2z-18xyz2-18xyz+18z2+18z), number(9), poly(x2y2z-2xyz2-2xyz+2z2+2z)); // I[6]: Manual/Generalized_Hilbert_Syzygy_Theorem.tst |
---|
198 | TestClearContent(-poly(9x2y2z-18xyz2-18xyz+18z2+18z), -number(9), poly(x2y2z-2xyz2-2xyz+2z2+2z)); // -_ |
---|
199 | |
---|
200 | |
---|
201 | TestClearContent(poly(4x3+2xy3), number(2), poly(2x3+xy3)); // j[1]: Old/err3.tst |
---|
202 | TestClearContent(-poly(4x3+2xy3), -number(2), poly(2x3+xy3)); // j[1]: Old/err3.tst |
---|
203 | |
---|
204 | TestClearContent(poly(2xy), number(2), poly(xy)); // _[2]: Manual/Delta.tst |
---|
205 | TestClearContent(poly(6x2z+2y2z), number(2), poly(3x2z+y2z)); // _[3]: Manual/Delta.tst |
---|
206 | |
---|
207 | kill R; |
---|
208 | ring R=0,(x,y),dp; |
---|
209 | TestClearRingX(x); |
---|
210 | TestClearRingX(y); |
---|
211 | TestClearRingX(xy); |
---|
212 | |
---|
213 | TestClearDenominators(poly(1/2x2 + 1/3y), number(6), poly(6*(1/2x2 + 1/3y))); |
---|
214 | |
---|
215 | |
---|
216 | 1/2x2 + 1/3y; cleardenom(_); |
---|
217 | |
---|
218 | |
---|
219 | kill R; |
---|
220 | ring R = (0, m1, m2, M, g, L), (Dt), (dp(1), C); |
---|
221 | |
---|
222 | // Manual/canonize.tst |
---|
223 | (-g)/(m2)*gen(3)+(-m1*g)/(m2^2)*gen(2); |
---|
224 | |
---|
225 | TestClearDenominators((-g)/(m2)*gen(3)+(-m1*g)/(m2^2)*gen(2), number((m2^2)), (-m2*g)*gen(3)+(-m1*g)*gen(2)); |
---|
226 | |
---|
227 | // cleardenom(_); |
---|
228 | |
---|
229 | |
---|
230 | |
---|
231 | kill R; |
---|
232 | ring R = (0, I, T, Px, Py, Cx, Cy, Sx, Sy, a, b, dt, dx, dy), (i, t, x, y, cx, cy, sx, sy), (c, lp(8)); |
---|
233 | ideal q= cy^2+sy^2-1, cx^2+sx^2-1, i^2+1; |
---|
234 | q = std(q); |
---|
235 | q; |
---|
236 | |
---|
237 | qring Q = q; |
---|
238 | basering; |
---|
239 | |
---|
240 | number n = (Cy^2*dt^2); |
---|
241 | |
---|
242 | cleardenom(n); |
---|
243 | |
---|
244 | n; |
---|
245 | |
---|
246 | denominator(n); |
---|
247 | |
---|
248 | numerator(n); |
---|
249 | |
---|
250 | kill R; |
---|
251 | |
---|
252 | |
---|
253 | kill R; |
---|
254 | ring R = (0,t), (x), dp; |
---|
255 | |
---|
256 | TestClearRingX(x); |
---|
257 | |
---|
258 | minpoly = t^2 + 1; |
---|
259 | TestClearRingX(x); |
---|
260 | |
---|
261 | // the following tests are wrong: t never appears in denominators (due to minpoly) |
---|
262 | // [(1/(2t)), 1] -> [1, (2t)], (2t) |
---|
263 | |
---|
264 | [(1/(2t)), 1]; |
---|
265 | cleardenom(_); |
---|
266 | |
---|
267 | [((1/3)/(2t)), 1]; |
---|
268 | cleardenom(_); |
---|
269 | |
---|
270 | // TestClearDenominators(vector([(1/(2t)), 1]), number(2t), vector([1, (2t)])); |
---|
271 | // alg: [((1/3)/(2t)), 1] ->[1, (6t)], (6t) |
---|
272 | // TestClearDenominators(vector([((1/3)/(2t)), 1]), number(6t), vector([1, (6t)])); |
---|
273 | |
---|
274 | // trans. [((1/3)/(2t)), 1] -> [(1/3), (2t)], (2t) ??? |
---|
275 | |
---|
276 | |
---|
277 | |
---|
278 | |
---|
279 | |
---|
280 | /* |
---|
281 | < _[1]=8x4l*gen(3)-16x3l2*gen(1)+8x2l3*gen(2)-8x*gen(2)+8y*gen(1)-8z*gen(3) |
---|
282 | < _[2]=8x5*gen(3)-16x4l*gen(1)+8x3l2*gen(2)+8y*gen(2)-8z*gen(1) |
---|
283 | --- |
---|
284 | > _[1]=33554432x4l*gen(3)-67108864x3l2*gen(1)+33554432x2l3*gen(2)-33554432x*gen(2)+33554432y*gen(1)-33554432z*gen(3) |
---|
285 | > _[2]=33554432x5*gen(3)-67108864x4l*gen(1)+33554432x3l2*gen(2)+33554432y*gen(2)-33554432z*gen(1) |
---|
286 | |
---|
287 | |
---|
288 | < j[3]=11x4y2+9x5+9x7 |
---|
289 | --- |
---|
290 | > j[3]=55x4y2+45x5+45x7 |
---|
291 | |
---|
292 | |
---|
293 | |
---|
294 | < qsat[1]=12zt+3z-10 |
---|
295 | < qsat[2]=5z2+12xt+3x |
---|
296 | < qsat[3]=144xt2+72xt+9x+50z |
---|
297 | --- |
---|
298 | > qsat[1]=21600zt+5400z-18000 |
---|
299 | > qsat[2]=9000z2+21600xt+5400x |
---|
300 | > qsat[3]=259200xt2+129600xt+16200x+90000z |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | |
---|
305 | < q[1]=12zty+3zy-10y2 |
---|
306 | < q[2]=60z2t-36xty-9xy-50zy |
---|
307 | < q[3]=12xty2+5z2y+3xy2 |
---|
308 | < q[4]=z3y+2xy3 |
---|
309 | --- |
---|
310 | > q[1]=216zty+54zy-180y2 |
---|
311 | > q[2]=1080z2t-648xty-162xy-900zy |
---|
312 | > q[3]=648xty2+270z2y+162xy2 |
---|
313 | > q[4]=270z3y+540xy3 |
---|
314 | |
---|
315 | |
---|
316 | |
---|
317 | < qsat[1]=12zt+3z-10y |
---|
318 | < qsat[2]=12xty+5z2+3xy |
---|
319 | < qsat[3]=144xt2+72xt+9x+50z |
---|
320 | < qsat[4]=z3+2xy2 |
---|
321 | --- |
---|
322 | > qsat[1]=23328000zt+5832000z-19440000y |
---|
323 | > qsat[2]=233280000xty+97200000z2+58320000xy |
---|
324 | > qsat[3]=279936000xt2+139968000xt+17496000x+97200000z |
---|
325 | > qsat[4]=97200000z3+194400000xy2 |
---|
326 | |
---|
327 | |
---|
328 | |
---|
329 | */ |
---|
330 | |
---|
331 | |
---|
332 | /* |
---|
333 | experiments master Singular (together with Claus / exts. of Q): |
---|
334 | |
---|
335 | > ring R = (0,t), x, dp; |
---|
336 | > cleardenom ( [1/(2t), 1] ); |
---|
337 | (2t)*gen(2)+gen(1) |
---|
338 | > cleardenom ( [(1/3)/(2t), 1] ); |
---|
339 | (6t)*gen(2)+gen(1) |
---|
340 | > number a = 1/3; |
---|
341 | > a; |
---|
342 | 1/3 |
---|
343 | > poly p = (a / (2t)) * x + 1; |
---|
344 | > p; |
---|
345 | 1/(6t)*x+1 |
---|
346 | > poly p = ((a + t) / (2t+1)) * x + 1; |
---|
347 | // ** redefining p ** |
---|
348 | > p; |
---|
349 | (3t+1)/(6t+3)*x+1 |
---|
350 | > ^Z |
---|
351 | |
---|
352 | |
---|
353 | |
---|
354 | ring R = (0,t), x, dp;cleardenom ( [(1/3)/(2t), 1] ); |
---|
355 | (6t)*gen(2)+gen(1) |
---|
356 | > ring R = (0,t), x, dp; minpoly = t2 + 1; cleardenom ( [(1/3)/(2t), 1] ); |
---|
357 | 6*gen(2)+(-t)*gen(1) |
---|
358 | > [(1/3)/(2t), 1]; |
---|
359 | gen(2)+(-1/6t)*gen(1) |
---|
360 | |
---|
361 | |
---|
362 | |
---|
363 | */ |
---|
364 | |
---|
365 | |
---|
366 | kill R; |
---|
367 | ring R = (0,a), (x, y, z, u, v), (a(1, 2, 0, 0, 0), ws(1, 2, 3, 4, 5), C); |
---|
368 | |
---|
369 | // poly pp = 1/3*x3+1/4*x2+1/6*x+1 ; ClearDenominators(pp); pp; |
---|
370 | |
---|
371 | TestClearRingX(x); |
---|
372 | |
---|
373 | minpoly = a2 + 1; |
---|
374 | |
---|
375 | R; |
---|
376 | // characteristic : 0 |
---|
377 | // 1 parameter : a |
---|
378 | // minpoly : (a2+1) |
---|
379 | // number of vars : 5 |
---|
380 | // block 1 : ordering a |
---|
381 | // : names x y z u v |
---|
382 | // : weights 1 2 0 0 0 |
---|
383 | // block 2 : ordering ws |
---|
384 | // : names x y z u v |
---|
385 | // : weights 1 2 3 4 5 |
---|
386 | // block 3 : ordering C |
---|
387 | |
---|
388 | option(); //options: intStrategy redefine usage prompt |
---|
389 | attrib(I); // no attributes |
---|
390 | |
---|
391 | (a)*x2+(2a)*xv+(a)*v2; |
---|
392 | cleardenom(_); // x2+2*xv+v2 |
---|
393 | |
---|
394 | ideal I = y2+(a)*x+v3, (-a)*y4-2*y2v+(-a)*y2v3-xv3+(a)*v2-2*v4; |
---|
395 | |
---|
396 | poly(2a); |
---|
397 | cleardenom(_); // 1?? |
---|
398 | |
---|
399 | poly(-2a); |
---|
400 | cleardenom(_); // 1?? |
---|
401 | |
---|
402 | |
---|
403 | (-2a)*x + (4a)*y; |
---|
404 | |
---|
405 | cleardenom(_); // 1?? |
---|
406 | |
---|
407 | kill Q; |
---|
408 | |
---|
409 | poly P = (2a)*x; |
---|
410 | poly Q = (4a)*y; |
---|
411 | |
---|
412 | gcd(P, Q); |
---|
413 | gcd(-P, Q); |
---|
414 | gcd(P, -Q); |
---|
415 | gcd(-P, -Q); |
---|
416 | |
---|
417 | |
---|
418 | y2+(a)*x+v3; |
---|
419 | cleardenom(_); |
---|
420 | |
---|
421 | I[2] + a* y2 * I[1]; |
---|
422 | cleardenom(_); |
---|
423 | |
---|
424 | |
---|
425 | |
---|
426 | "GB: "; groebner(I); // _[1]=x2+2*xv+v2 _[2]=y2+(a)*x+v3 |
---|
427 | "SB: "; std(I); // _[1]=x2+2*xv+v2 _[2]=y2+(a)*x+v3 |
---|
428 | |
---|
429 | |
---|
430 | |
---|
431 | exit; |
---|
432 | |
---|
433 | |
---|