source: git/Tst/dyn_modules/test_clear_enum.tst @ 75f460

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