source: git/Tst/dyn_modules/test_clear_enum.tst

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