source: git/dyn_modules/syzextra/test_clear_enum.tst @ 643877c

jengelh-datetimespielwiese
Last change on this file since 643877c was 643877c, checked in by Oleksandr Motsak <motsak@…>, 10 years ago
Expose function m2_end function Conflicts: Singular/LIB/schreyer.lib dyn_modules/syzextra/mod_main.cc
  • Property mode set to 100644
File size: 11.4 KB
Line 
1"ndebug?: ", system("with", "ndebug");
2"om_ndebug?: ", system("with", "om_ndebug");
3
4listvar(Top);
5
6if( system("with", "ndebug") )
7{
8  "Loading the Release version!";
9  LIB("syzextra.so");
10  listvar(Syzextra);
11}
12else
13{
14  "Loading the Debug version!";
15  LIB("syzextra_g.so");
16  listvar(Syzextra_g);
17}
18
19
20noop();
21
22proc 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
34proc 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
70proc 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    "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
114proc TestClearRingX(poly X)
115{
116// // clearcontent:
117
118// with polynomials in 'X'
119TestClearContent(poly(1), number(1), poly(1)); // {1} -> {1}, c=1
120TestClearContent(poly(2), number(2), poly(1)); // {2} -> {1}, c=2
121TestClearContent(poly(222222222222*X + 2), number(2), poly(111111111111*X + 1)); // {222222222222, 2 } -> { 111111111111, 1} c=2
122TestClearContent(poly(2*X + 222222222222), number(2), poly(1*X + 111111111111)); // {2, 222222222222 } -> { 1, 111111111111} c=2
123
124// use vector instead:
125TestClearContent(vector(1), number(1), vector(1)); // {1} -> {1}, c=1
126TestClearContent(vector(2), number(2), vector(1)); // {2} -> {1}, c=2
127TestClearContent(vector([222222222222, 2]), number(2), vector([111111111111, 1])); // {222222222222, 2 } -> { 111111111111, 1} c=2
128TestClearContent(vector([2, 222222222222]), number(2), vector([1, 111111111111])); // {2, 222222222222 } -> { 1, 111111111111} c=2
129
130
131// with negative leading coeff!
132TestClearContent(-poly(1), -number(1), poly(1)); // {1} -> {1}, c=1
133TestClearContent(-poly(2), -number(2), poly(1)); // {2} -> {1}, c=2
134TestClearContent(-poly(222222222222*X + 2), -number(2), poly(111111111111*X + 1)); // {222222222222, 2 } -> { 111111111111, 1} c=2
135TestClearContent(-poly(2*X + 222222222222), -number(2), poly(1*X + 111111111111)); // {2, 222222222222 } -> { 1, 111111111111} c=2
136
137// use vector instead:
138TestClearContent(-vector(1), -number(1), vector(1)); // {1} -> {1}, c=1
139TestClearContent(-vector(2), -number(2), vector(1)); // {2} -> {1}, c=2
140TestClearContent(-vector([222222222222, 2]), -number(2), vector([111111111111, 1])); // {222222222222, 2 } -> { 111111111111, 1} c=2
141TestClearContent(-vector([2, 222222222222]), -number(2), vector([1, 111111111111])); // {2, 222222222222 } -> { 1, 111111111111} c=2
142
143
144
145
146TestClearDenominators(poly(1), number(1), poly(1)); // {1} -> {1}, c=1
147TestClearDenominators(poly(2), number(1), poly(2)); // {2} -> {2}, c=1
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
153
154
155TestClearDenominators(vector([1]), number(1), vector([1])); // {1} -> {1}, c=1
156TestClearDenominators(vector([2]), number(1), vector([2])); // {2} -> {2}, c=1
157TestClearDenominators(vector([1, 1/2]), number(2), vector([2, 1])); // {1, 1/2} -> {2, 1}, c=2
158TestClearDenominators(vector([1/2, 1]), number(2), vector([1, 2])); // {1/2, 1} -> {1, 2}, c=2
159TestClearDenominators(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
160TestClearDenominators(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/*
163TestClearDenominators(-poly(1), -number(1), poly(1)); // {1} -> {1}, c=1
164TestClearDenominators(-poly(2), -number(1), poly(2)); // {2} -> {2}, c=1
165
166TestClearDenominators(-poly(X + (1/2)), -number(2), poly(2*X + 1)); // {1, 1/2 } -> {2, 1}, c=2
167TestClearDenominators(-poly((1/2)*X + 1), -number(2), poly(X + 2)); // {1/2, 1} -> {1, 2}, c=2
168TestClearDenominators(-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
169TestClearDenominators(-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
171TestClearDenominators(-vector([1]), -number(1), vector([1])); // {1} -> {1}, c=1
172TestClearDenominators(-vector([2]), -number(1), vector([2])); // {2} -> {2}, c=1
173TestClearDenominators(-vector([1, 1/2]), -number(2), vector([2, 1])); // {1, 1/2} -> {2, 1}, c=2
174TestClearDenominators(-vector([1/2, 1]), -number(2), vector([1, 2])); // {1/2, 1} -> {1, 2}, c=2
175TestClearDenominators(-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
176TestClearDenominators(-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
181ring R = 0, (x), dp;
182TestClearRingX(x);
183kill R;
184
185ring R = 0, (x, y, z), dp;
186TestClearRingX(x);
187TestClearRingX(y);
188TestClearRingX(z);
189
190TestClearRingX(xy);
191TestClearRingX(yz);
192TestClearRingX(xz);
193
194TestClearRingX(xyz);
195
196
197TestClearContent(poly(9x2y2z-18xyz2-18xyz+18z2+18z), number(9), poly(x2y2z-2xyz2-2xyz+2z2+2z)); // I[6]: Manual/Generalized_Hilbert_Syzygy_Theorem.tst
198TestClearContent(-poly(9x2y2z-18xyz2-18xyz+18z2+18z), -number(9), poly(x2y2z-2xyz2-2xyz+2z2+2z)); // -_
199
200
201TestClearContent(poly(4x3+2xy3), number(2), poly(2x3+xy3)); // j[1]: Old/err3.tst
202TestClearContent(-poly(4x3+2xy3), -number(2), poly(2x3+xy3)); // j[1]: Old/err3.tst
203
204TestClearContent(poly(2xy), number(2), poly(xy)); // _[2]: Manual/Delta.tst     
205TestClearContent(poly(6x2z+2y2z), number(2), poly(3x2z+y2z)); // _[3]: Manual/Delta.tst
206
207kill R;
208ring R=0,(x,y),dp;
209TestClearRingX(x);
210TestClearRingX(y);
211TestClearRingX(xy);
212
213TestClearDenominators(poly(1/2x2 + 1/3y), number(6), poly(6*(1/2x2 + 1/3y)));
214
215
2161/2x2 + 1/3y; cleardenom(_);
217
218
219kill R;
220ring 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
225TestClearDenominators((-g)/(m2)*gen(3)+(-m1*g)/(m2^2)*gen(2), number((m2^2)), (-g*m2)*gen(3)+(-g*m1)*gen(2));
226
227// cleardenom(_);
228   
229
230
231kill R;
232ring 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));
233ideal q= cy^2+sy^2-1, cx^2+sx^2-1, i^2+1;
234q = std(q);
235q;
236
237qring Q = q;
238basering;
239
240number n = (Cy^2*dt^2);
241
242cleardenom(n);
243
244n;
245
246denominator(n);
247
248numerator(n);
249
250kill R;
251
252
253kill R;
254ring R = (0,t), (x), dp;
255
256TestClearRingX(x);
257
258minpoly = t^2 + 1;
259TestClearRingX(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];
265cleardenom(_);
266
267[((1/3)/(2t)), 1];
268cleardenom(_);
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/*
333experiments 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;
3421/3
343> poly p = (a / (2t)) * x + 1;
344> p;
3451/(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] );
3576*gen(2)+(-t)*gen(1)
358>  [(1/3)/(2t), 1];
359gen(2)+(-1/6t)*gen(1)
360
361
362
363*/
364
365
366kill R;
367ring 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
371TestClearRingX(x);
372
373minpoly = a2 + 1;
374
375R;
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
388option(); //options: intStrategy redefine usage prompt
389attrib(I); //          no attributes
390
391(a)*x2+(2a)*xv+(a)*v2;
392cleardenom(_); // x2+2*xv+v2
393
394ideal I = y2+(a)*x+v3, (-a)*y4-2*y2v+(-a)*y2v3-xv3+(a)*v2-2*v4;
395
396poly(2a);
397cleardenom(_); // 1??
398
399poly(-2a);
400cleardenom(_); // 1??
401
402
403(-2a)*x + (4a)*y;
404
405cleardenom(_); // 1??
406
407kill Q;
408
409poly P = (2a)*x;
410poly Q = (4a)*y;
411         
412gcd(P, Q);
413gcd(-P, Q);
414gcd(P, -Q);
415gcd(-P, -Q);
416
417
418y2+(a)*x+v3;
419cleardenom(_);
420
421I[2] + a* y2 * I[1];
422cleardenom(_);
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
431exit;
432
433
Note: See TracBrowser for help on using the repository browser.