1 | #include "kernel/mod2.h" |
---|
2 | |
---|
3 | #include "omalloc/omalloc.h" |
---|
4 | #include "factory/factory.h" // :( |
---|
5 | |
---|
6 | #include "misc/intvec.h" |
---|
7 | #include "misc/int64vec.h" |
---|
8 | #include "misc/mylimits.h" |
---|
9 | #include "misc/options.h" |
---|
10 | |
---|
11 | #include "reporter/reporter.h" |
---|
12 | |
---|
13 | #include "resources/feFopen.h" |
---|
14 | #include "resources/feResource.h" |
---|
15 | |
---|
16 | #include "coeffs/coeffs.h" |
---|
17 | |
---|
18 | #include "coeffs/si_gmp.h" |
---|
19 | |
---|
20 | #include "polys/kbuckets.h" |
---|
21 | #include "polys/matpol.h" |
---|
22 | #include "polys/mod_raw.h" |
---|
23 | #include "polys/prCopy.h" |
---|
24 | #include "polys/sbuckets.h" |
---|
25 | #include "polys/simpleideals.h" |
---|
26 | #include "polys/weight.h" |
---|
27 | |
---|
28 | #include "polys/monomials/maps.h" |
---|
29 | #include "polys/monomials/monomials.h" |
---|
30 | #include "polys/monomials/p_polys.h" |
---|
31 | #include "polys/monomials/ring.h" |
---|
32 | |
---|
33 | #include "polys/nc/nc.h" |
---|
34 | #include "polys/nc/ncSACache.h" |
---|
35 | #include "polys/nc/ncSAFormula.h" |
---|
36 | #include "polys/nc/ncSAMult.h" |
---|
37 | #include "polys/nc/sca.h" |
---|
38 | #include "polys/nc/summator.h" |
---|
39 | |
---|
40 | |
---|
41 | #include "polys/templates/p_MemAdd.h" |
---|
42 | #include "polys/templates/p_Procs.h" |
---|
43 | |
---|
44 | #include "polys/operations/pShallowCopyDelete.h" |
---|
45 | |
---|
46 | #include "polys/clapsing.h" |
---|
47 | |
---|
48 | #include "coeffs/numbers.h" |
---|
49 | |
---|
50 | #include "structs.h" |
---|
51 | |
---|
52 | |
---|
53 | // HEADERS: |
---|
54 | #include "kernel/combinatorics/hutil.h" |
---|
55 | #include "kernel/combinatorics/stairc.h" |
---|
56 | #include "kernel/ideals.h" |
---|
57 | #include "kernel/GBEngine/syz.h" |
---|
58 | #include "kernel/maps/fast_maps.h" |
---|
59 | #include "kernel/groebner_walk/walkProc.h" |
---|
60 | #include "kernel/groebner_walk/walkMain.h" |
---|
61 | #include "kernel/groebner_walk/walkSupport.h" |
---|
62 | #include "kernel/GBEngine/khstd.h" |
---|
63 | /// #include "kernel/sparsmat.h" // TODO: install polys/this! |
---|
64 | //+ |
---|
65 | |
---|
66 | #include "kernel/fglm/fglm.h" |
---|
67 | #include "kernel/GBEngine/kstd1.h" |
---|
68 | #include "kernel/fglm/fglmgauss.h" |
---|
69 | #include "kernel/fglm/fglmvec.h" |
---|
70 | #include "kernel/GBEngine/kstdfac.h" |
---|
71 | #include "kernel/spectrum/kmatrix.h" |
---|
72 | #include "kernel/spectrum/GMPrat.h" |
---|
73 | #include "kernel/spectrum/multicnt.h" |
---|
74 | #include "kernel/spectrum/npolygon.h" |
---|
75 | #include "kernel/spectrum/semic.h" |
---|
76 | #include "kernel/spectrum/spectrum.h" |
---|
77 | #include "kernel/spectrum/splist.h" |
---|
78 | #include "kernel/spectrum/multicnt.h" |
---|
79 | #include "kernel/linear_algebra/eigenval.h" |
---|
80 | #include "kernel/GBEngine/units.h" |
---|
81 | #include "kernel/GBEngine/ratgring.h" |
---|
82 | #include "kernel/GBEngine/shiftgb.h" |
---|
83 | |
---|
84 | |
---|
85 | #include "kernel/GBEngine/kutil.h" |
---|
86 | |
---|
87 | // #include "CCRing.h" // Too old! |
---|
88 | #include "kernel/digitech.h" |
---|
89 | #include "kernel/linear_algebra/eigenval.h" |
---|
90 | #include "kernel/maps/fast_maps.h" |
---|
91 | #include "kernel/fast_mult.h" |
---|
92 | |
---|
93 | #include "kernel/fglm/fglmgauss.h" |
---|
94 | #include "kernel/fglm/fglm.h" |
---|
95 | #include "kernel/fglm/fglmvec.h" |
---|
96 | |
---|
97 | ////////#include "kernel/F5cData.h" |
---|
98 | #include "kernel/GBEngine/f5c.h" |
---|
99 | #include "kernel/GBEngine/f5data.h" |
---|
100 | #include "kernel/GBEngine/f5gb.h" |
---|
101 | #include "kernel/GBEngine/f5lists.h" |
---|
102 | ////////#include "kernel/F5cLists.h" |
---|
103 | |
---|
104 | |
---|
105 | #include "kernel/ideals.h" |
---|
106 | |
---|
107 | #include "kernel/spectrum/kmatrix.h" |
---|
108 | #include "kernel/GBEngine/kstd1.h" |
---|
109 | #include "kernel/GBEngine/kstdfac.h" |
---|
110 | #include "kernel/GBEngine/khstd.h" |
---|
111 | |
---|
112 | #include "kernel/linear_algebra/linearAlgebra.h" |
---|
113 | |
---|
114 | #include "kernel/spectrum/multicnt.h" |
---|
115 | #include "kernel/spectrum/npolygon.h" |
---|
116 | #include "kernel/preimage.h" |
---|
117 | |
---|
118 | #include "kernel/GBEngine/nc.h" |
---|
119 | |
---|
120 | #include "kernel/GBEngine/ratgring.h" |
---|
121 | #include "kernel/GBEngine/ringgb.h" |
---|
122 | #include "kernel/spectrum/semic.h" |
---|
123 | #include "kernel/GBEngine/shiftgb.h" |
---|
124 | #include "kernel/spectrum/spectrum.h" |
---|
125 | #include "kernel/spectrum/splist.h" |
---|
126 | #include "kernel/structs.h" |
---|
127 | #include "kernel/GBEngine/syz.h" |
---|
128 | // #include "kernel/testpoly.h" // Too old? |
---|
129 | |
---|
130 | #include "kernel/GBEngine/tgbgauss.h" |
---|
131 | #include "kernel/GBEngine/tgb.h" |
---|
132 | |
---|
133 | |
---|
134 | #include "kernel/GBEngine/units.h" |
---|
135 | #include "kernel/groebner_walk/walkMain.h" |
---|
136 | #include "kernel/groebner_walk/walkProc.h" |
---|
137 | #include "kernel/groebner_walk/walkSupport.h" |
---|
138 | |
---|
139 | #include "kernel/GBEngine/janet.h" |
---|
140 | #include "kernel/linear_algebra/interpolation.h" |
---|
141 | #include "kernel/linear_algebra/minpoly.h" |
---|
142 | |
---|
143 | #include "kernel/linear_algebra/Minor.h" |
---|
144 | #include "kernel/linear_algebra/MinorInterface.h" |
---|
145 | #include "kernel/linear_algebra/MinorProcessor.h" |
---|
146 | #include "kernel/linear_algebra/Cache.h" |
---|
147 | #include "kernel/linear_algebra/CacheImplementation.h" |
---|
148 | |
---|
149 | // #include "polys/clapconv.h" // due to factory? :( |
---|
150 | // #include "kernel/tgb_internal.h" // :( |
---|
151 | |
---|
152 | // #include "kernel/fglm/fglmzero.cc" // looks like <factory/templates/ftmpl_list.h> must be installed! |
---|
153 | // TODO: looks like "coeffs/mpr_complex.h" must be installed! |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | #include "kernel/polys.h" |
---|
158 | |
---|
159 | void TestGBEngine() |
---|
160 | { |
---|
161 | |
---|
162 | // R = MPolynomialRing_polydict(QQ,5,'w,x,y,z,C', order='degrevlex') |
---|
163 | // J = (w*w - x*z, w*x - y*z, x*x - w*y, x*y - z*z, y*y - w*z) |
---|
164 | |
---|
165 | const short w = 1; |
---|
166 | const short x = 2; |
---|
167 | const short y = 3; |
---|
168 | const short z = 4; |
---|
169 | |
---|
170 | const short N = (z - w + 1); |
---|
171 | |
---|
172 | char **n=(char**)omalloc(N*sizeof(char*)); |
---|
173 | |
---|
174 | |
---|
175 | n[w-1]=omStrDup("w"); |
---|
176 | n[x-1]=omStrDup("x"); |
---|
177 | n[y-1]=omStrDup("y"); |
---|
178 | n[z-1]=omStrDup("z"); |
---|
179 | |
---|
180 | |
---|
181 | const int D = 3; |
---|
182 | rRingOrder_t *order = (rRingOrder_t *) omAlloc0(D* sizeof(rRingOrder_t)); |
---|
183 | int *block0 = (int *)omAlloc0(D * sizeof(int)); |
---|
184 | int *block1 = (int *)omAlloc0(D * sizeof(int)); |
---|
185 | |
---|
186 | order[0] = ringorder_dp; |
---|
187 | block0[0] = 1; |
---|
188 | block1[0] = N; |
---|
189 | |
---|
190 | order[1] = ringorder_C; |
---|
191 | block0[1] = 1; |
---|
192 | block1[1] = N; |
---|
193 | |
---|
194 | ring R = rDefault(0, N, n, D, order, block0, block1); |
---|
195 | |
---|
196 | // ring R = rDefault(0, N, n); |
---|
197 | |
---|
198 | rWrite(R); PrintLn(); |
---|
199 | |
---|
200 | #ifdef RDEBUG |
---|
201 | rDebugPrint(R); |
---|
202 | #endif |
---|
203 | |
---|
204 | ideal I = idInit(5, 1); |
---|
205 | |
---|
206 | int gen = 0; |
---|
207 | |
---|
208 | { |
---|
209 | // -xz |
---|
210 | poly p = p_ISet(-1,R); |
---|
211 | |
---|
212 | p_SetExp(p, x, 1, R); |
---|
213 | p_SetExp(p, z, 1, R); |
---|
214 | p_Setm(p, R); |
---|
215 | |
---|
216 | assume( p_GetExp(p, x, R) == 1 ); |
---|
217 | assume( p_GetExp(p, z, R) == 1 ); |
---|
218 | assume( p_GetExp(p, w, R) == 0 ); |
---|
219 | assume( p_GetExp(p, y, R) == 0 ); |
---|
220 | |
---|
221 | // +w2 |
---|
222 | poly lp = p_ISet(1,R); |
---|
223 | p_SetExp(lp, w, 2, R); |
---|
224 | p_Setm(lp, R); |
---|
225 | |
---|
226 | assume( p_GetExp(lp, w, R) == 2 ); |
---|
227 | assume( p_GetExp(lp, x, R) == 0 ); |
---|
228 | assume( p_GetExp(lp, y, R) == 0 ); |
---|
229 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
230 | |
---|
231 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // w2 - xz |
---|
232 | } |
---|
233 | |
---|
234 | { |
---|
235 | // -yz |
---|
236 | poly p = p_ISet(-1,R); |
---|
237 | |
---|
238 | p_SetExp(p, y, 1, R); |
---|
239 | p_SetExp(p, z, 1, R); |
---|
240 | p_Setm(p, R); |
---|
241 | |
---|
242 | assume( p_GetExp(p, y, R) == 1 ); |
---|
243 | assume( p_GetExp(p, z, R) == 1 ); |
---|
244 | assume( p_GetExp(p, w, R) == 0 ); |
---|
245 | assume( p_GetExp(p, x, R) == 0 ); |
---|
246 | |
---|
247 | // +wx |
---|
248 | poly lp = p_ISet(1,R); |
---|
249 | p_SetExp(lp, w, 1, R); |
---|
250 | p_SetExp(lp, x, 1, R); |
---|
251 | p_Setm(lp, R); |
---|
252 | |
---|
253 | assume( p_GetExp(lp, w, R) == 1 ); |
---|
254 | assume( p_GetExp(lp, x, R) == 1 ); |
---|
255 | assume( p_GetExp(lp, y, R) == 0 ); |
---|
256 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
257 | |
---|
258 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // wx - yz |
---|
259 | } |
---|
260 | |
---|
261 | |
---|
262 | { |
---|
263 | // -wy |
---|
264 | poly p = p_ISet(-1,R); |
---|
265 | |
---|
266 | p_SetExp(p, y, 1, R); |
---|
267 | p_SetExp(p, w, 1, R); |
---|
268 | p_Setm(p, R); |
---|
269 | |
---|
270 | assume( p_GetExp(p, y, R) == 1 ); |
---|
271 | assume( p_GetExp(p, w, R) == 1 ); |
---|
272 | assume( p_GetExp(p, z, R) == 0 ); |
---|
273 | assume( p_GetExp(p, x, R) == 0 ); |
---|
274 | |
---|
275 | // +x2 |
---|
276 | poly lp = p_ISet(1,R); |
---|
277 | p_SetExp(lp, x, 2, R); |
---|
278 | p_Setm(lp, R); |
---|
279 | |
---|
280 | assume( p_GetExp(lp, w, R) == 0 ); |
---|
281 | assume( p_GetExp(lp, x, R) == 2 ); |
---|
282 | assume( p_GetExp(lp, y, R) == 0 ); |
---|
283 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
284 | |
---|
285 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // x2 - wy |
---|
286 | } |
---|
287 | |
---|
288 | |
---|
289 | { |
---|
290 | // -z2 |
---|
291 | poly p = p_ISet(-1,R); |
---|
292 | |
---|
293 | p_SetExp(p, z, 2, R); |
---|
294 | p_Setm(p, R); |
---|
295 | |
---|
296 | assume( p_GetExp(p, y, R) == 0 ); |
---|
297 | assume( p_GetExp(p, w, R) == 0 ); |
---|
298 | assume( p_GetExp(p, z, R) == 2 ); |
---|
299 | assume( p_GetExp(p, x, R) == 0 ); |
---|
300 | |
---|
301 | // +xy |
---|
302 | poly lp = p_ISet(1,R); |
---|
303 | p_SetExp(lp, x, 1, R); |
---|
304 | p_SetExp(lp, y, 1, R); |
---|
305 | p_Setm(lp, R); |
---|
306 | |
---|
307 | assume( p_GetExp(lp, w, R) == 0 ); |
---|
308 | assume( p_GetExp(lp, x, R) == 1 ); |
---|
309 | assume( p_GetExp(lp, y, R) == 1 ); |
---|
310 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
311 | |
---|
312 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // xy - z2 |
---|
313 | } |
---|
314 | |
---|
315 | |
---|
316 | { |
---|
317 | // -wz |
---|
318 | poly p = p_ISet(-1,R); |
---|
319 | |
---|
320 | p_SetExp(p, w, 1, R); |
---|
321 | p_SetExp(p, z, 1, R); |
---|
322 | p_Setm(p, R); |
---|
323 | |
---|
324 | assume( p_GetExp(p, y, R) == 0 ); |
---|
325 | assume( p_GetExp(p, w, R) == 1 ); |
---|
326 | assume( p_GetExp(p, z, R) == 1 ); |
---|
327 | assume( p_GetExp(p, x, R) == 0 ); |
---|
328 | |
---|
329 | // +y2 |
---|
330 | poly lp = p_ISet(1,R); |
---|
331 | p_SetExp(lp, y, 2, R); |
---|
332 | p_Setm(lp, R); |
---|
333 | |
---|
334 | assume( p_GetExp(lp, w, R) == 0 ); |
---|
335 | assume( p_GetExp(lp, x, R) == 0 ); |
---|
336 | assume( p_GetExp(lp, y, R) == 2 ); |
---|
337 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
338 | |
---|
339 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // y2 - wz |
---|
340 | } |
---|
341 | #ifdef PDEBUG |
---|
342 | PrintS("I: "); |
---|
343 | idShow(I, R, R, 0); |
---|
344 | #endif |
---|
345 | |
---|
346 | |
---|
347 | // ideal kStd(ideal F, ideal Q, tHomog h, intvec ** mw,intvec *hilb=NULL, |
---|
348 | // int syzComp=0,int newIdeal=0, intvec *vw=NULL); |
---|
349 | // make R the default ring: |
---|
350 | rChangeCurrRing(R); |
---|
351 | |
---|
352 | { |
---|
353 | ideal G = kStd(I, currRing->qideal, testHomog, NULL); |
---|
354 | |
---|
355 | #ifdef PDEBUG |
---|
356 | PrintS("GB: "); |
---|
357 | idShow(G, R, R, 0); |
---|
358 | #endif |
---|
359 | |
---|
360 | id_Delete( &G, R); |
---|
361 | } |
---|
362 | |
---|
363 | { |
---|
364 | intvec *weights = NULL; |
---|
365 | ideal SYZ = idSyzygies(I, testHomog, &weights); |
---|
366 | |
---|
367 | #ifdef PDEBUG |
---|
368 | PrintS("SYZ: "); |
---|
369 | idShow(SYZ, R, R, 0); |
---|
370 | #endif |
---|
371 | |
---|
372 | id_Delete(&SYZ, R); |
---|
373 | if (weights!=NULL) { PrintS("weights: "); weights->show(); delete weights; } |
---|
374 | } |
---|
375 | |
---|
376 | |
---|
377 | { |
---|
378 | PrintS("\n**********************************\n"); |
---|
379 | PrintS("lres: \n"); |
---|
380 | int dummy; |
---|
381 | syStrategy r = syLaScala3(I,&dummy); |
---|
382 | |
---|
383 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
384 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
385 | delete b; |
---|
386 | |
---|
387 | Print("length: %d\n", sySize(r)); |
---|
388 | |
---|
389 | syPrint(r, "R"); |
---|
390 | |
---|
391 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
392 | |
---|
393 | b = syBettiOfComputation(r, TRUE); |
---|
394 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
395 | delete b; |
---|
396 | |
---|
397 | Print("length: %d\n", sySize(r)); |
---|
398 | |
---|
399 | syPrint(r, "R"); |
---|
400 | |
---|
401 | syKillComputation(r, R); |
---|
402 | } |
---|
403 | |
---|
404 | { |
---|
405 | PrintS("\n**********************************\n"); |
---|
406 | PrintS("sres: \n"); |
---|
407 | const int maxl = rVar(R)-1; // +2*(1); |
---|
408 | |
---|
409 | syStrategy r = sySchreyer(I, rVar(R)); |
---|
410 | |
---|
411 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
412 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
413 | delete b; |
---|
414 | |
---|
415 | Print("length: %d\n", sySize(r)); |
---|
416 | |
---|
417 | syPrint(r, "R"); |
---|
418 | |
---|
419 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
420 | |
---|
421 | b = syBettiOfComputation(r, TRUE); |
---|
422 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
423 | delete b; |
---|
424 | |
---|
425 | Print("length: %d\n", sySize(r)); |
---|
426 | |
---|
427 | syPrint(r, "R"); |
---|
428 | |
---|
429 | syKillComputation(r, R); |
---|
430 | } |
---|
431 | |
---|
432 | |
---|
433 | |
---|
434 | { |
---|
435 | PrintS("\n**********************************\n"); |
---|
436 | PrintS("nres: \n"); |
---|
437 | intvec *weights=NULL; |
---|
438 | // const int maxl = rVar(R)-1 + 2*(1); |
---|
439 | syStrategy r = syResolution(I, rVar(R)-1, weights, FALSE/*iiOp==MRES_CMD*/); |
---|
440 | |
---|
441 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
442 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
443 | delete b; |
---|
444 | |
---|
445 | Print("length: %d\n", sySize(r)); |
---|
446 | |
---|
447 | syPrint(r, "R"); |
---|
448 | |
---|
449 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
450 | |
---|
451 | b = syBettiOfComputation(r, TRUE); |
---|
452 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
453 | delete b; |
---|
454 | |
---|
455 | Print("length: %d\n", sySize(r)); |
---|
456 | |
---|
457 | syPrint(r, "R"); |
---|
458 | |
---|
459 | syKillComputation(r, R); |
---|
460 | } |
---|
461 | |
---|
462 | |
---|
463 | { |
---|
464 | PrintS("\n**********************************\n"); |
---|
465 | PrintS("mres: \n"); |
---|
466 | intvec *weights=NULL; |
---|
467 | // const int maxl = rVar(R)-1 + 2*(1); |
---|
468 | syStrategy r = syResolution(I, rVar(R)+1, weights, TRUE/*iiOp==MRES_CMD*/); |
---|
469 | |
---|
470 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
471 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
472 | delete b; |
---|
473 | |
---|
474 | Print("length: %d\n", sySize(r)); |
---|
475 | |
---|
476 | syPrint(r, "R"); |
---|
477 | |
---|
478 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
479 | |
---|
480 | b = syBettiOfComputation(r, TRUE); |
---|
481 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
482 | delete b; |
---|
483 | |
---|
484 | Print("length: %d\n", sySize(r)); |
---|
485 | |
---|
486 | syPrint(r, "R"); |
---|
487 | |
---|
488 | syKillComputation(r, R); |
---|
489 | } |
---|
490 | |
---|
491 | |
---|
492 | |
---|
493 | |
---|
494 | id_Delete( &I, R); |
---|
495 | rDelete(R); // should cleanup every belonging polynomial, right!? |
---|
496 | |
---|
497 | } |
---|
498 | |
---|
499 | |
---|
500 | |
---|
501 | void TestSimpleRingArithmetcs() |
---|
502 | { |
---|
503 | // Libpolys tests: |
---|
504 | |
---|
505 | // construct the ring Z/32003[x,y,z] |
---|
506 | // the variable names |
---|
507 | char **n=(char**)omalloc(3*sizeof(char*)); |
---|
508 | n[0]=omStrDup("x"); |
---|
509 | n[1]=omStrDup("y"); |
---|
510 | n[2]=omStrDup("z2"); |
---|
511 | |
---|
512 | ring R = rDefault(32003,3,n); // ring R = rDefault(0,3,n); |
---|
513 | |
---|
514 | rWrite(R); PrintLn(); |
---|
515 | |
---|
516 | #ifdef RDEBUG |
---|
517 | rDebugPrint(R); |
---|
518 | #endif |
---|
519 | |
---|
520 | |
---|
521 | poly p = p_ISet(1,R); p_SetExp(p,1,1, R); p_Setm(p, R); |
---|
522 | |
---|
523 | assume( p_GetExp(p,1, R) == 1 ); |
---|
524 | |
---|
525 | poly pp = pp_Mult_qq( p, p, R); |
---|
526 | |
---|
527 | PrintS("p: "); p_Write0(p, R); Print(", deg(p): %ld", p_Totaldegree(p, R)); assume( 1 == p_Totaldegree(p, R) ); |
---|
528 | |
---|
529 | PrintS("; p*p : "); p_Write0(pp, R); Print("deg(pp): %ld\n", p_Totaldegree(pp, R)); assume( 2 == p_Totaldegree(pp, R) ); |
---|
530 | |
---|
531 | |
---|
532 | p_Delete(&p, R); |
---|
533 | |
---|
534 | assume( p_GetExp(pp,1, R) == 2 ); |
---|
535 | |
---|
536 | p_Delete(&pp, R); |
---|
537 | |
---|
538 | |
---|
539 | // rDelete(R); |
---|
540 | |
---|
541 | // make R the default ring: |
---|
542 | rChangeCurrRing(R); |
---|
543 | |
---|
544 | // create the polynomial 1 |
---|
545 | poly p1=pISet(1); |
---|
546 | |
---|
547 | // create tthe polynomial 2*x^3*z^2 |
---|
548 | poly p2=p_ISet(2,R); |
---|
549 | pSetExp(p2,1,3); |
---|
550 | pSetExp(p2,3,2); |
---|
551 | pSetm(p2); |
---|
552 | |
---|
553 | // print p1 + p2 |
---|
554 | PrintS("p1: "); pWrite0(p1); |
---|
555 | PrintS(" + p2: "); pWrite0(p2); |
---|
556 | PrintS(" ---- >>>> "); |
---|
557 | |
---|
558 | // compute p1+p2 |
---|
559 | p1=p_Add_q(p1,p2,R); p2=NULL; |
---|
560 | pWrite(p1); |
---|
561 | |
---|
562 | // clean up: |
---|
563 | // pDelete(&p1); |
---|
564 | |
---|
565 | rDelete(R); // should cleanup every belonging polynomial, right!? |
---|
566 | } |
---|
567 | |
---|
568 | |
---|
569 | int main( int, char *argv[] ) |
---|
570 | { |
---|
571 | assume( sizeof(long) == SIZEOF_LONG ); |
---|
572 | |
---|
573 | if( sizeof(long) != SIZEOF_LONG ) |
---|
574 | { |
---|
575 | WerrorS("Bad config.h: wrong size of long!"); |
---|
576 | |
---|
577 | return(1); |
---|
578 | } |
---|
579 | |
---|
580 | |
---|
581 | feInitResources(argv[0]); |
---|
582 | |
---|
583 | StringSetS("ressources in use (as reported by feStringAppendResources(0):\n"); |
---|
584 | feStringAppendResources(0); |
---|
585 | |
---|
586 | PrintLn(); |
---|
587 | { char* s = StringEndS(); PrintS(s); omFree(s); } |
---|
588 | |
---|
589 | TestGBEngine(); |
---|
590 | TestSimpleRingArithmetcs(); |
---|
591 | |
---|
592 | return 0; |
---|
593 | } |
---|