1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * ABSTRACT - Kernel: noncomm. alg. of Buchberger |
---|
6 | */ |
---|
7 | #define PLURAL_INTERNAL_DECLARATIONS |
---|
8 | |
---|
9 | #include "kernel/mod2.h" |
---|
10 | |
---|
11 | #ifdef HAVE_PLURAL |
---|
12 | |
---|
13 | |
---|
14 | #include "omalloc/omalloc.h" |
---|
15 | #include "misc/options.h" |
---|
16 | #include "misc/intvec.h" |
---|
17 | |
---|
18 | #include "polys/weight.h" |
---|
19 | #include "kernel/polys.h" |
---|
20 | #include "polys/monomials/ring.h" |
---|
21 | |
---|
22 | #include "polys/nc/gb_hack.h" |
---|
23 | #include "polys/nc/nc.h" |
---|
24 | #include "polys/nc/sca.h" |
---|
25 | |
---|
26 | |
---|
27 | #include "kernel/ideals.h" |
---|
28 | #include "kernel/GBEngine/kstd1.h" |
---|
29 | #include "kernel/GBEngine/khstd.h" |
---|
30 | //#include "spolys.h" |
---|
31 | //#include "cntrlc.h" |
---|
32 | #include "kernel/GBEngine/ratgring.h" |
---|
33 | #include "kernel/GBEngine/kutil.h" |
---|
34 | |
---|
35 | #include "kernel/GBEngine/nc.h" |
---|
36 | |
---|
37 | #if 0 |
---|
38 | /*3 |
---|
39 | * reduction of p2 with p1 |
---|
40 | * do not destroy p1 and p2 |
---|
41 | * p1 divides p2 -> for use in NF algorithm |
---|
42 | */ |
---|
43 | poly gnc_ReduceSpolyNew(const poly p1, poly p2/*,poly spNoether*/, const ring r) |
---|
44 | { |
---|
45 | return(nc_ReduceSPoly(p1,p_Copy(p2,r)/*,spNoether*/,r)); |
---|
46 | } |
---|
47 | #endif |
---|
48 | |
---|
49 | /*2 |
---|
50 | *reduces h with elements from T choosing the first possible |
---|
51 | * element in t with respect to the given pDivisibleBy |
---|
52 | */ |
---|
53 | int redGrFirst (LObject* h,kStrategy strat) |
---|
54 | { |
---|
55 | int at,reddeg,d,i; |
---|
56 | int pass = 0; |
---|
57 | int j = 0; |
---|
58 | |
---|
59 | d = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
60 | reddeg = strat->LazyDegree+d; |
---|
61 | loop |
---|
62 | { |
---|
63 | if (j > strat->sl) |
---|
64 | { |
---|
65 | #ifdef KDEBUG |
---|
66 | if (TEST_OPT_DEBUG) PrintLn(); |
---|
67 | #endif |
---|
68 | return 0; |
---|
69 | } |
---|
70 | #ifdef KDEBUG |
---|
71 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
72 | #endif |
---|
73 | if (pDivisibleBy(strat->S[j],(*h).p)) |
---|
74 | { |
---|
75 | #ifdef KDEBUG |
---|
76 | if (TEST_OPT_DEBUG) PrintS("+\n"); |
---|
77 | #endif |
---|
78 | /* |
---|
79 | * the polynomial to reduce with is; |
---|
80 | * T[j].p |
---|
81 | */ |
---|
82 | if (!TEST_OPT_INTSTRATEGY) |
---|
83 | pNorm(strat->S[j]); |
---|
84 | #ifdef KDEBUG |
---|
85 | if (TEST_OPT_DEBUG) |
---|
86 | { |
---|
87 | wrp(h->p); |
---|
88 | PrintS(" with "); |
---|
89 | wrp(strat->S[j]); |
---|
90 | } |
---|
91 | #endif |
---|
92 | (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p, currRing); |
---|
93 | //spSpolyRed(strat->T[j].p,(*h).p,strat->kNoether); |
---|
94 | |
---|
95 | #ifdef KDEBUG |
---|
96 | if (TEST_OPT_DEBUG) |
---|
97 | { |
---|
98 | PrintS(" to "); |
---|
99 | wrp(h->p); |
---|
100 | } |
---|
101 | #endif |
---|
102 | if ((*h).p == NULL) |
---|
103 | { |
---|
104 | if (h->lcm!=NULL) p_LmFree((*h).lcm, currRing); |
---|
105 | return 0; |
---|
106 | } |
---|
107 | if (TEST_OPT_INTSTRATEGY) |
---|
108 | { |
---|
109 | h->pCleardenom();// also removes Content |
---|
110 | } |
---|
111 | /*computes the ecart*/ |
---|
112 | d = currRing->pLDeg((*h).p,&((*h).length),currRing); |
---|
113 | (*h).FDeg=currRing->pFDeg((*h).p,currRing); |
---|
114 | (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/ |
---|
115 | if ((strat->syzComp!=0) && !strat->honey) |
---|
116 | { |
---|
117 | if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
118 | { |
---|
119 | #ifdef KDEBUG |
---|
120 | if (TEST_OPT_DEBUG) PrintS(" > sysComp\n"); |
---|
121 | #endif |
---|
122 | return 0; |
---|
123 | } |
---|
124 | } |
---|
125 | /*- try to reduce the s-polynomial -*/ |
---|
126 | pass++; |
---|
127 | /* |
---|
128 | *test whether the polynomial should go to the lazyset L |
---|
129 | *-if the degree jumps |
---|
130 | *-if the number of pre-defined reductions jumps |
---|
131 | */ |
---|
132 | if ((strat->Ll >= 0) |
---|
133 | && ((d >= reddeg) || (pass > strat->LazyPass)) |
---|
134 | && !strat->homog) |
---|
135 | { |
---|
136 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
137 | if (at <= strat->Ll) |
---|
138 | { |
---|
139 | i=strat->sl+1; |
---|
140 | do |
---|
141 | { |
---|
142 | i--; |
---|
143 | if (i<0) return 0; |
---|
144 | } while (!pDivisibleBy(strat->S[i],(*h).p)); |
---|
145 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
146 | #ifdef KDEBUG |
---|
147 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
148 | #endif |
---|
149 | (*h).p = NULL; |
---|
150 | return 0; |
---|
151 | } |
---|
152 | } |
---|
153 | if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
154 | { |
---|
155 | reddeg = d+1; |
---|
156 | Print(".%d",d);mflush(); |
---|
157 | } |
---|
158 | j = 0; |
---|
159 | #ifdef KDEBUG |
---|
160 | if TEST_OPT_DEBUG PrintLn(); |
---|
161 | #endif |
---|
162 | } |
---|
163 | else |
---|
164 | { |
---|
165 | #ifdef KDEBUG |
---|
166 | if (TEST_OPT_DEBUG) PrintS("-"); |
---|
167 | #endif |
---|
168 | j++; |
---|
169 | } |
---|
170 | } |
---|
171 | } |
---|
172 | void ratGB_divide_out(poly p) |
---|
173 | { |
---|
174 | /* extracts monomial content from localized expression */ |
---|
175 | /* searches for an m (monomial in var 1.. real_var_start-1) |
---|
176 | * such that m divides p and divides p by this m if it exist*/ |
---|
177 | if (p==NULL) return; |
---|
178 | poly root=p; |
---|
179 | assume(rIsRatGRing(currRing)); |
---|
180 | poly f=pHead(p); |
---|
181 | int i; |
---|
182 | for (i=currRing->real_var_start;i<=currRing->real_var_end;i++) |
---|
183 | { |
---|
184 | pSetExp(f,i,0); |
---|
185 | } |
---|
186 | loop |
---|
187 | { |
---|
188 | pIter(p); |
---|
189 | if (p==NULL) { pSetm(f); break;} |
---|
190 | for (i=1;i<=rVar(currRing);i++) |
---|
191 | { |
---|
192 | pSetExp(f,i,si_min(pGetExp(f,i),pGetExp(p,i))); |
---|
193 | } |
---|
194 | } |
---|
195 | if (!pIsConstant(f)) |
---|
196 | { |
---|
197 | #ifdef KDEBUG |
---|
198 | if (TEST_OPT_DEBUG) |
---|
199 | { |
---|
200 | PrintS("divide out:");p_wrp(f,currRing); |
---|
201 | PrintS(" from ");pWrite(root); |
---|
202 | } |
---|
203 | #endif |
---|
204 | p=root; |
---|
205 | loop |
---|
206 | { |
---|
207 | if (p==NULL) break; |
---|
208 | for (i=1;i<=rVar(currRing);i++) |
---|
209 | { |
---|
210 | pSetExp(p,i,pGetExp(p,i)-pGetExp(f,i)); |
---|
211 | } |
---|
212 | pSetm(p); |
---|
213 | pIter(p); |
---|
214 | } |
---|
215 | } |
---|
216 | pDelete(&f); |
---|
217 | } |
---|
218 | |
---|
219 | #ifdef HAVE_RATGRING |
---|
220 | /*2 |
---|
221 | *reduces h with elements from T choosing the first possible |
---|
222 | * element in t with respect to the given pDivisibleBy |
---|
223 | * for use in ratGB |
---|
224 | */ |
---|
225 | int redGrRatGB (LObject* h,kStrategy strat) |
---|
226 | { |
---|
227 | int at,reddeg,d,i; |
---|
228 | int pass = 0; |
---|
229 | int j = 0; |
---|
230 | int c_j=-1, c_e=-2; |
---|
231 | poly c_p=NULL; |
---|
232 | assume(strat->tailRing==currRing); |
---|
233 | |
---|
234 | ratGB_divide_out((*h).p); |
---|
235 | d = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
236 | reddeg = strat->LazyDegree+d; |
---|
237 | if (!TEST_OPT_INTSTRATEGY) |
---|
238 | { |
---|
239 | h->pCleardenom();// also does a pContentRat |
---|
240 | } |
---|
241 | loop |
---|
242 | { |
---|
243 | if (j > strat->sl) |
---|
244 | { |
---|
245 | if (c_j>=0) |
---|
246 | { |
---|
247 | /* |
---|
248 | * the polynomial to reduce with is; |
---|
249 | * S[c_j] |
---|
250 | */ |
---|
251 | if (!TEST_OPT_INTSTRATEGY) |
---|
252 | pNorm(strat->S[c_j]); |
---|
253 | #ifdef KDEBUG |
---|
254 | if (TEST_OPT_DEBUG) |
---|
255 | if (TEST_OPT_DEBUG) |
---|
256 | { |
---|
257 | wrp(h->p); |
---|
258 | Print(" with S[%d]= ",c_j); |
---|
259 | wrp(strat->S[c_j]); |
---|
260 | } |
---|
261 | #endif |
---|
262 | //poly hh = nc_CreateSpoly(strat->S[c_j],(*h).p, currRing); |
---|
263 | // Print("vor nc_rat_ReduceSpolyNew (ce:%d) ",c_e);wrp(h->p);PrintLn(); |
---|
264 | //if(c_e==-1) |
---|
265 | // c_p = nc_CreateSpoly(pCopy(strat->S[c_j]),pCopy((*h).p), currRing); |
---|
266 | //else |
---|
267 | // c_p=nc_rat_ReduceSpolyNew(strat->S[c_j],pCopy((*h).p), currRing->real_var_start-1,currRing); |
---|
268 | // Print("nach nc_rat_ReduceSpolyNew ");wrp(c_p);PrintLn(); |
---|
269 | // pDelete(&((*h).p)); |
---|
270 | |
---|
271 | c_p=nc_rat_ReduceSpolyNew(strat->S[c_j],(*h).p, currRing->real_var_start-1,currRing); |
---|
272 | (*h).p=c_p; |
---|
273 | if (!TEST_OPT_INTSTRATEGY) |
---|
274 | { |
---|
275 | h->pCleardenom();// also removes Content |
---|
276 | } |
---|
277 | |
---|
278 | #ifdef KDEBUG |
---|
279 | if (TEST_OPT_DEBUG) |
---|
280 | { |
---|
281 | PrintS(" to "); |
---|
282 | wrp(h->p); |
---|
283 | PrintLn(); |
---|
284 | } |
---|
285 | #endif |
---|
286 | if ((*h).p == NULL) |
---|
287 | { |
---|
288 | if (h->lcm!=NULL) p_LmFree((*h).lcm, currRing); |
---|
289 | return 0; |
---|
290 | } |
---|
291 | ratGB_divide_out((*h).p); |
---|
292 | d = currRing->pLDeg((*h).p,&((*h).length),currRing); |
---|
293 | (*h).FDeg=currRing->pFDeg((*h).p,currRing); |
---|
294 | (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/ |
---|
295 | /*- try to reduce the s-polynomial again -*/ |
---|
296 | pass++; |
---|
297 | j=0; |
---|
298 | c_j=-1; c_e=-2; c_p=NULL; |
---|
299 | } |
---|
300 | else |
---|
301 | { // nothing found |
---|
302 | return 0; |
---|
303 | } |
---|
304 | } |
---|
305 | // first try usal division |
---|
306 | if (p_LmDivisibleBy(strat->S[j],(*h).p,currRing)) |
---|
307 | { |
---|
308 | #ifdef KDEBUG |
---|
309 | if(TEST_OPT_DEBUG) |
---|
310 | { |
---|
311 | p_wrp(h->p,currRing); Print(" divisible by S[%d]=",j); |
---|
312 | p_wrp(strat->S[j],currRing); PrintS(" e=-1\n"); |
---|
313 | } |
---|
314 | #endif |
---|
315 | if ((c_j<0)||(c_e>=0)) |
---|
316 | { |
---|
317 | c_e=-1; c_j=j; |
---|
318 | } |
---|
319 | } |
---|
320 | else |
---|
321 | if (p_LmDivisibleByPart(strat->S[j],(*h).p,currRing, |
---|
322 | currRing->real_var_start,currRing->real_var_end)) |
---|
323 | { |
---|
324 | int a_e=(p_Totaldegree(strat->S[j],currRing)-currRing->pFDeg(strat->S[j],currRing)); |
---|
325 | #ifdef KDEBUG |
---|
326 | if(TEST_OPT_DEBUG) |
---|
327 | { |
---|
328 | p_wrp(h->p,currRing); Print(" divisibly by S[%d]=",j); |
---|
329 | p_wrp(strat->S[j],currRing); Print(" e=%d\n",a_e); |
---|
330 | } |
---|
331 | #endif |
---|
332 | if ((c_j<0)||(c_e>a_e)) |
---|
333 | { |
---|
334 | c_e=a_e; c_j=j; |
---|
335 | //c_p = nc_CreateSpoly(pCopy(strat->S[c_j]),pCopy((*h).p), currRing); |
---|
336 | } |
---|
337 | /*computes the ecart*/ |
---|
338 | if ((strat->syzComp!=0) && !strat->honey) |
---|
339 | { |
---|
340 | if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
341 | { |
---|
342 | #ifdef KDEBUG |
---|
343 | if (TEST_OPT_DEBUG) PrintS(" > sysComp\n"); |
---|
344 | #endif |
---|
345 | return 0; |
---|
346 | } |
---|
347 | } |
---|
348 | } |
---|
349 | else |
---|
350 | { |
---|
351 | #ifdef KDEBUG |
---|
352 | if(TEST_OPT_DEBUG) |
---|
353 | { |
---|
354 | p_wrp(h->p,currRing); Print(" not divisibly by S[%d]=",j); |
---|
355 | p_wrp(strat->S[j],currRing); PrintLn(); |
---|
356 | } |
---|
357 | #endif |
---|
358 | } |
---|
359 | j++; |
---|
360 | } |
---|
361 | } |
---|
362 | #endif |
---|
363 | |
---|
364 | /*2 |
---|
365 | * reduction procedure for the homogeneous case |
---|
366 | * and the case of a degree-ordering |
---|
367 | */ |
---|
368 | #if 0 |
---|
369 | // currently unused |
---|
370 | static int nc_redHomog (LObject* h,kStrategy strat) |
---|
371 | { |
---|
372 | if (strat->tl<0) |
---|
373 | { |
---|
374 | enterT((*h),strat); |
---|
375 | return 1; |
---|
376 | } |
---|
377 | |
---|
378 | int j = 0; |
---|
379 | |
---|
380 | if (TEST_OPT_DEBUG) |
---|
381 | { |
---|
382 | PrintS("red:"); |
---|
383 | wrp(h->p); |
---|
384 | PrintS(" "); |
---|
385 | } |
---|
386 | loop |
---|
387 | { |
---|
388 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
389 | if (pDivisibleBy(strat->S[j],(*h).p)) |
---|
390 | { |
---|
391 | if (TEST_OPT_DEBUG) |
---|
392 | { |
---|
393 | PrintS("+\nwith "); |
---|
394 | wrp(strat->S[j]); |
---|
395 | } |
---|
396 | /*- compute the s-polynomial -*/ |
---|
397 | (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,currRing); |
---|
398 | if ((*h).p == NULL) |
---|
399 | { |
---|
400 | if (TEST_OPT_DEBUG) PrintS(" to 0\n"); |
---|
401 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
402 | (*h).lcm=NULL; |
---|
403 | return 0; |
---|
404 | } |
---|
405 | /* |
---|
406 | * else if (strat->syzComp) |
---|
407 | * { |
---|
408 | * if (pMinComp((*h).p) > strat->syzComp) |
---|
409 | * { |
---|
410 | * enterT((*h),strat); |
---|
411 | * return; |
---|
412 | * } |
---|
413 | * } |
---|
414 | */ |
---|
415 | /*- try to reduce the s-polynomial -*/ |
---|
416 | j = 0; |
---|
417 | } |
---|
418 | else |
---|
419 | { |
---|
420 | if (j >= strat->sl) |
---|
421 | { |
---|
422 | enterT((*h),strat); |
---|
423 | return 1; |
---|
424 | } |
---|
425 | j++; |
---|
426 | } |
---|
427 | } |
---|
428 | } |
---|
429 | #endif |
---|
430 | |
---|
431 | #if 0 |
---|
432 | /*2 |
---|
433 | * reduction procedure for the homogeneous case |
---|
434 | * and the case of a degree-ordering |
---|
435 | */ |
---|
436 | static int nc_redHomog0 (LObject* h,kStrategy strat) |
---|
437 | { |
---|
438 | if (strat->tl<0) |
---|
439 | { |
---|
440 | enterT((*h),strat); |
---|
441 | return 0; |
---|
442 | } |
---|
443 | |
---|
444 | int j = 0; |
---|
445 | int k = 0; |
---|
446 | |
---|
447 | if (TEST_OPT_DEBUG) |
---|
448 | { |
---|
449 | PrintS("red:"); |
---|
450 | wrp(h->p); |
---|
451 | PrintS(" "); |
---|
452 | } |
---|
453 | loop |
---|
454 | { |
---|
455 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
456 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
457 | { |
---|
458 | if (TEST_OPT_DEBUG) |
---|
459 | { |
---|
460 | PrintS("+\nwith "); |
---|
461 | wrp(strat->S[j]); |
---|
462 | } |
---|
463 | /*- compute the s-polynomial -*/ |
---|
464 | (*h).p = nc_ReduceSpoly(strat->T[j].p,(*h).p,strat->kNoether,currRing); |
---|
465 | if ((*h).p == NULL) |
---|
466 | { |
---|
467 | if (TEST_OPT_DEBUG) PrintS(" to 0\n"); |
---|
468 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
469 | (*h).lcm=NULL; |
---|
470 | return 0; |
---|
471 | } |
---|
472 | else |
---|
473 | { |
---|
474 | if (TEST_OPT_INTSTRATEGY) |
---|
475 | { |
---|
476 | h->pCleardenom();// also removes Content |
---|
477 | } |
---|
478 | if (strat->syzComp!=0) |
---|
479 | { |
---|
480 | if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
481 | { |
---|
482 | /* |
---|
483 | * (*h).length=pLength0((*h).p); |
---|
484 | */ |
---|
485 | enterT((*h),strat); |
---|
486 | return 0; |
---|
487 | } |
---|
488 | } |
---|
489 | } |
---|
490 | /*- try to reduce the s-polynomial -*/ |
---|
491 | j = 0; |
---|
492 | } |
---|
493 | else |
---|
494 | { |
---|
495 | if (j >= strat->tl) |
---|
496 | { |
---|
497 | if (TEST_OPT_INTSTRATEGY) |
---|
498 | { |
---|
499 | h->pCleardenom();// also removes Content |
---|
500 | } |
---|
501 | /* |
---|
502 | * (*h).length=pLength0((*h).p); |
---|
503 | */ |
---|
504 | enterT((*h),strat); |
---|
505 | return 0; |
---|
506 | } |
---|
507 | j++; |
---|
508 | } |
---|
509 | } |
---|
510 | } |
---|
511 | |
---|
512 | /*2 |
---|
513 | * reduction procedure for the inhomogeneous case |
---|
514 | * and not a degree-ordering |
---|
515 | */ |
---|
516 | static int nc_redLazy (LObject* h,kStrategy strat) |
---|
517 | { |
---|
518 | if (strat->tl<0) |
---|
519 | { |
---|
520 | enterT((*h),strat); |
---|
521 | return 0; |
---|
522 | } |
---|
523 | |
---|
524 | int at,d,i; |
---|
525 | int j = 0; |
---|
526 | int pass = 0; |
---|
527 | int reddeg = currRing->pFDeg((*h).p,currRing); |
---|
528 | |
---|
529 | if (TEST_OPT_DEBUG) |
---|
530 | { |
---|
531 | PrintS("red:"); |
---|
532 | wrp(h->p); |
---|
533 | PrintS(" "); |
---|
534 | } |
---|
535 | loop |
---|
536 | { |
---|
537 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
538 | if (pDivisibleBy(strat->S[j],(*h).p)) |
---|
539 | { |
---|
540 | if (TEST_OPT_DEBUG) |
---|
541 | { |
---|
542 | PrintS("+\nwith "); |
---|
543 | wrp(strat->S[j]); |
---|
544 | } |
---|
545 | /*- compute the s-polynomial -*/ |
---|
546 | (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,strat->kNoether,currRing); |
---|
547 | if ((*h).p == NULL) |
---|
548 | { |
---|
549 | if (TEST_OPT_DEBUG) PrintS(" to 0\n"); |
---|
550 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
551 | (*h).lcm=NULL; |
---|
552 | return 0; |
---|
553 | } |
---|
554 | // else if (strat->syzComp) |
---|
555 | // { |
---|
556 | // if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
557 | // { |
---|
558 | // if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
559 | // if (TEST_OPT_INTSTRATEGY) p_Content(h->p,currRing); |
---|
560 | // enterTBba((*h),strat->tl+1,strat); |
---|
561 | // return; |
---|
562 | // } |
---|
563 | // } |
---|
564 | else |
---|
565 | { |
---|
566 | if (TEST_OPT_DEBUG) |
---|
567 | { |
---|
568 | PrintS("to:"); |
---|
569 | wrp((*h).p); |
---|
570 | PrintLn(); |
---|
571 | } |
---|
572 | if (TEST_OPT_INTSTRATEGY) |
---|
573 | { |
---|
574 | pCleardenom(h->p);// also removes Content |
---|
575 | } |
---|
576 | } |
---|
577 | /*- try to reduce the s-polynomial -*/ |
---|
578 | pass++; |
---|
579 | d = currRing->pFDeg((*h).p,currRing); |
---|
580 | if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
581 | { |
---|
582 | at = posInL11(strat->L,strat->Ll,h,strat); |
---|
583 | if (at <= strat->Ll) |
---|
584 | { |
---|
585 | i=strat->sl+1; |
---|
586 | do |
---|
587 | { |
---|
588 | i--; |
---|
589 | if (i<0) |
---|
590 | { |
---|
591 | enterT((*h),strat); |
---|
592 | return 0; |
---|
593 | } |
---|
594 | } |
---|
595 | while (!pDivisibleBy(strat->S[i],(*h).p)); |
---|
596 | if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at); |
---|
597 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
598 | (*h).p = NULL; |
---|
599 | return 0; |
---|
600 | } |
---|
601 | } |
---|
602 | else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d != reddeg)) |
---|
603 | { |
---|
604 | Print(".%d",d);mflush(); |
---|
605 | reddeg = d; |
---|
606 | } |
---|
607 | j = 0; |
---|
608 | } |
---|
609 | else |
---|
610 | { |
---|
611 | if (TEST_OPT_DEBUG) PrintS("-"); |
---|
612 | if (j >= strat->sl) |
---|
613 | { |
---|
614 | if (TEST_OPT_DEBUG) PrintLn(); |
---|
615 | if (TEST_OPT_INTSTRATEGY) |
---|
616 | { |
---|
617 | h->pCleardenom();// also removes Content |
---|
618 | } |
---|
619 | enterT((*h),strat); |
---|
620 | return 0; |
---|
621 | } |
---|
622 | j++; |
---|
623 | } |
---|
624 | } |
---|
625 | } |
---|
626 | |
---|
627 | /*2 |
---|
628 | * reduction procedure for the sugar-strategy (honey) |
---|
629 | * reduces h with elements from T choosing first possible |
---|
630 | * element in T with respect to the given ecart |
---|
631 | */ |
---|
632 | static int nc_redHoney (LObject* h,kStrategy strat) |
---|
633 | { |
---|
634 | if (strat->tl<0) |
---|
635 | { |
---|
636 | enterT((*h),strat); |
---|
637 | return 0; |
---|
638 | } |
---|
639 | |
---|
640 | poly pi; |
---|
641 | int i,j,at,reddeg,d,pass,ei; |
---|
642 | |
---|
643 | pass = j = 0; |
---|
644 | d = reddeg = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
645 | if (TEST_OPT_DEBUG) |
---|
646 | { |
---|
647 | PrintS("red:"); |
---|
648 | wrp((*h).p); |
---|
649 | } |
---|
650 | loop |
---|
651 | { |
---|
652 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
653 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
654 | { |
---|
655 | if (TEST_OPT_DEBUG) PrintS("+"); |
---|
656 | pi = strat->T[j].p; |
---|
657 | ei = strat->T[j].ecart; |
---|
658 | /* |
---|
659 | * the polynomial to reduce with (up to the moment) is; |
---|
660 | * pi with ecart ei |
---|
661 | */ |
---|
662 | i = j; |
---|
663 | loop |
---|
664 | { |
---|
665 | /*- takes the first possible with respect to ecart -*/ |
---|
666 | i++; |
---|
667 | if (i > strat->tl) |
---|
668 | break; |
---|
669 | if ((!BTEST1(20)) && (ei <= (*h).ecart)) |
---|
670 | break; |
---|
671 | if (TEST_OPT_DEBUG) Print("%d",i); |
---|
672 | if ((strat->T[i].ecart < ei) && pDivisibleBy(strat->T[i].p,(*h).p)) |
---|
673 | { |
---|
674 | if (TEST_OPT_DEBUG) PrintS("+"); |
---|
675 | /* |
---|
676 | * the polynomial to reduce with is now; |
---|
677 | */ |
---|
678 | pi = strat->T[i].p; |
---|
679 | ei = strat->T[i].ecart; |
---|
680 | } |
---|
681 | else if (TEST_OPT_DEBUG) PrintS("-"); |
---|
682 | } |
---|
683 | |
---|
684 | /* |
---|
685 | * end of search: have to reduce with pi |
---|
686 | */ |
---|
687 | if (ei > (*h).ecart) |
---|
688 | { |
---|
689 | /* |
---|
690 | * It is not possible to reduce h with smaller ecart; |
---|
691 | * if possible h goes to the lazy-set L,i.e |
---|
692 | * if its position in L would be not the last one |
---|
693 | */ |
---|
694 | if (strat->Ll >= 0) /* L is not empty */ |
---|
695 | { |
---|
696 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
697 | if(at <= strat->Ll) |
---|
698 | /*- h will not become the next element to reduce -*/ |
---|
699 | { |
---|
700 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
701 | if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at); |
---|
702 | (*h).p = NULL; |
---|
703 | return 0; |
---|
704 | } |
---|
705 | } |
---|
706 | } |
---|
707 | if (TEST_OPT_DEBUG) |
---|
708 | { |
---|
709 | PrintS("\nwith "); |
---|
710 | wrp(pi); |
---|
711 | } |
---|
712 | if (strat->fromT) |
---|
713 | { |
---|
714 | strat->fromT=FALSE; |
---|
715 | (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing); |
---|
716 | } |
---|
717 | else |
---|
718 | (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing); |
---|
719 | if (TEST_OPT_DEBUG) |
---|
720 | { |
---|
721 | PrintS(" to "); |
---|
722 | wrp((*h).p); |
---|
723 | PrintLn(); |
---|
724 | } |
---|
725 | if ((*h).p == NULL) |
---|
726 | { |
---|
727 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
728 | (*h).lcm=NULL; |
---|
729 | return 0; |
---|
730 | } |
---|
731 | if (TEST_OPT_INTSTRATEGY) |
---|
732 | { |
---|
733 | h->pCleardenom();// also does remove Content |
---|
734 | } |
---|
735 | /* compute the ecart */ |
---|
736 | if (ei <= (*h).ecart) |
---|
737 | (*h).ecart = d-currRing->pFDeg((*h).p,currRing); |
---|
738 | else |
---|
739 | (*h).ecart = d-currRing->pFDeg((*h).p,currRing)+ei-(*h).ecart; |
---|
740 | // if (strat->syzComp) |
---|
741 | // { |
---|
742 | // if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
743 | // { |
---|
744 | // if (TEST_OPT_DEBUG) |
---|
745 | // PrintS(" >syzComp\n"); |
---|
746 | // if (TEST_OPT_INTSTRATEGY) p_Content(h->p,currRing); |
---|
747 | // at=strat->posInT(strat->T,strat->tl,(*h)); |
---|
748 | // enterTBba((*h),at,strat); |
---|
749 | // return; |
---|
750 | // } |
---|
751 | // } |
---|
752 | /* |
---|
753 | * try to reduce the s-polynomial h |
---|
754 | *test first whether h should go to the lazyset L |
---|
755 | *-if the degree jumps |
---|
756 | *-if the number of pre-defined reductions jumps |
---|
757 | */ |
---|
758 | pass++; |
---|
759 | d = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
760 | if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
761 | { |
---|
762 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
763 | if (at <= strat->Ll) |
---|
764 | { |
---|
765 | /*test if h is already standardbasis element*/ |
---|
766 | i=strat->sl+1; |
---|
767 | do |
---|
768 | { |
---|
769 | i--; |
---|
770 | if (i<0) |
---|
771 | { |
---|
772 | enterT((*h),strat); |
---|
773 | return 0; |
---|
774 | } |
---|
775 | } while (!pDivisibleBy(strat->S[i],(*h).p)); |
---|
776 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
777 | if (TEST_OPT_DEBUG) |
---|
778 | Print(" degree jumped: -> L%d\n",at); |
---|
779 | (*h).p = NULL; |
---|
780 | return 0; |
---|
781 | } |
---|
782 | } |
---|
783 | else if (TEST_OPT_PROT && (strat->Ll < 0) && (d > reddeg)) |
---|
784 | { |
---|
785 | reddeg = d; |
---|
786 | Print(".%d",d); mflush(); |
---|
787 | } |
---|
788 | j = 0; |
---|
789 | } |
---|
790 | else |
---|
791 | { |
---|
792 | if (TEST_OPT_DEBUG) PrintS("-"); |
---|
793 | if (j >= strat->tl) |
---|
794 | { |
---|
795 | if (TEST_OPT_DEBUG) PrintLn(); |
---|
796 | if (TEST_OPT_INTSTRATEGY) |
---|
797 | { |
---|
798 | h->pCleardenom();// also does remove Content |
---|
799 | } |
---|
800 | enterT((*h),strat); |
---|
801 | return 0; |
---|
802 | } |
---|
803 | j++; |
---|
804 | } |
---|
805 | } |
---|
806 | } |
---|
807 | |
---|
808 | /*2 |
---|
809 | * reduction procedure for tests only |
---|
810 | * reduces with elements from T and chooses the best possible |
---|
811 | */ |
---|
812 | static int nc_redBest (LObject* h,kStrategy strat) |
---|
813 | { |
---|
814 | if (strat->tl<0) |
---|
815 | { |
---|
816 | enterT((*h),strat); |
---|
817 | return 0; |
---|
818 | } |
---|
819 | |
---|
820 | int j,jbest,at,reddeg,d,pass; |
---|
821 | poly p,ph; |
---|
822 | pass = j = 0; |
---|
823 | |
---|
824 | if (strat->honey) |
---|
825 | reddeg = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
826 | else |
---|
827 | reddeg = currRing->pFDeg((*h).p,currRing); |
---|
828 | loop |
---|
829 | { |
---|
830 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
831 | { |
---|
832 | /* compute the s-polynomial */ |
---|
833 | if (!TEST_OPT_INTSTRATEGY) pNorm((*h).p); |
---|
834 | #ifdef SDRING |
---|
835 | // spSpolyShortBba will not work in the SRING case |
---|
836 | if (pSDRING) |
---|
837 | { |
---|
838 | p=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether); |
---|
839 | if (p!=NULL) pDelete(&pNext(p)); |
---|
840 | } |
---|
841 | else |
---|
842 | #endif |
---|
843 | p = nc_CreateShortSpoly(strat->T[j].p,(*h).p); |
---|
844 | /* computes only the first monomial of the spoly */ |
---|
845 | if (p) |
---|
846 | { |
---|
847 | jbest = j; |
---|
848 | /* looking for the best possible reduction */ |
---|
849 | if ((strat->syzComp==0) || (pMinComp(p) <= strat->syzComp)) |
---|
850 | { |
---|
851 | loop |
---|
852 | { |
---|
853 | j++; |
---|
854 | if (j > strat->tl) |
---|
855 | break; |
---|
856 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
857 | { |
---|
858 | #ifdef SDRING |
---|
859 | // spSpolyShortBba will not work in the SRING case |
---|
860 | if (pSDRING) |
---|
861 | { |
---|
862 | ph=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether); |
---|
863 | if (ph!=NULL) pDelete(&pNext(ph)); |
---|
864 | } |
---|
865 | else |
---|
866 | #endif |
---|
867 | ph = nc_CreateShortSpoly(strat->T[j].p,(*h).p); |
---|
868 | if (ph==NULL) |
---|
869 | { |
---|
870 | pLmFree(p); |
---|
871 | pDelete(&((*h).p)); |
---|
872 | if (h->lcm!=NULL) |
---|
873 | { |
---|
874 | pLmFree((*h).lcm); |
---|
875 | (*h).lcm=NULL; |
---|
876 | } |
---|
877 | return 0; |
---|
878 | } |
---|
879 | else if (pLmCmp(ph,p) == -1) |
---|
880 | { |
---|
881 | pLmFree(p); |
---|
882 | p = ph; |
---|
883 | jbest = j; |
---|
884 | } |
---|
885 | else |
---|
886 | { |
---|
887 | pLmFree(ph); |
---|
888 | } |
---|
889 | } |
---|
890 | } |
---|
891 | } |
---|
892 | pLmFree(p); |
---|
893 | (*h).p = nc_ReduceSpoly(strat->T[jbest].p,(*h).p,strat->kNoether,currRing); |
---|
894 | } |
---|
895 | else |
---|
896 | { |
---|
897 | if (h->lcm!=NULL) |
---|
898 | { |
---|
899 | pLmFree((*h).lcm); |
---|
900 | (*h).lcm=NULL; |
---|
901 | } |
---|
902 | (*h).p = NULL; |
---|
903 | return 0; |
---|
904 | } |
---|
905 | if (strat->honey && currRing->pLexOrder) |
---|
906 | strat->initEcart(h); |
---|
907 | /* h.length:=l; */ |
---|
908 | /* try to reduce the s-polynomial */ |
---|
909 | // if (strat->syzComp) |
---|
910 | // { |
---|
911 | // if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
912 | // { |
---|
913 | // if (TEST_OPT_DEBUG) |
---|
914 | // PrintS(" >syzComp\n"); |
---|
915 | // if (TEST_OPT_INTSTRATEGY) p_Content(h->p,currRing); |
---|
916 | // at=strat->posInT(strat->T,strat->tl,(*h)); |
---|
917 | // enterTBba((*h),at,strat); |
---|
918 | // return; |
---|
919 | // } |
---|
920 | // } |
---|
921 | if (strat->honey || currRing->pLexOrder) |
---|
922 | { |
---|
923 | pass++; |
---|
924 | d = currRing->pFDeg((*h).p,currRing); |
---|
925 | if (strat->honey) |
---|
926 | d += (*h).ecart; |
---|
927 | if ((strat->Ll >= 0) && ((pass > strat->LazyPass) || (d > reddeg))) |
---|
928 | { |
---|
929 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
930 | if (at <= strat->Ll) |
---|
931 | { |
---|
932 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
933 | (*h).p = NULL; |
---|
934 | return 0; |
---|
935 | } |
---|
936 | } |
---|
937 | else if (TEST_OPT_PROT && (strat->Ll < 0) && (d != reddeg)) |
---|
938 | { |
---|
939 | reddeg = d; |
---|
940 | Print("%d."); |
---|
941 | mflush(); |
---|
942 | } |
---|
943 | } |
---|
944 | j = 0; |
---|
945 | } |
---|
946 | else |
---|
947 | { |
---|
948 | if (j >= strat->tl) |
---|
949 | { |
---|
950 | if (TEST_OPT_INTSTRATEGY) |
---|
951 | { |
---|
952 | h->pCleardenom();// also removes Content |
---|
953 | } |
---|
954 | enterT((*h),strat); |
---|
955 | return 0; |
---|
956 | } |
---|
957 | j++; |
---|
958 | } |
---|
959 | } |
---|
960 | } |
---|
961 | |
---|
962 | #endif |
---|
963 | |
---|
964 | #ifdef HAVE_RATGRING |
---|
965 | void nc_gr_initBba(ideal F, kStrategy strat) |
---|
966 | #else |
---|
967 | void nc_gr_initBba(ideal, kStrategy strat) |
---|
968 | #endif |
---|
969 | { |
---|
970 | assume(rIsPluralRing(currRing)); |
---|
971 | |
---|
972 | // int i; |
---|
973 | // idhdl h; |
---|
974 | /* setting global variables ------------------- */ |
---|
975 | strat->enterS = enterSBba; |
---|
976 | |
---|
977 | /* |
---|
978 | if ((BTEST1(20)) && (!strat->honey)) |
---|
979 | strat->red = nc_redBest; |
---|
980 | else if (strat->honey) |
---|
981 | strat->red = nc_redHoney; |
---|
982 | else if (currRing->pLexOrder && !strat->homog) |
---|
983 | strat->red = nc_redLazy; |
---|
984 | else if (TEST_OPT_INTSTRATEGY && strat->homog) |
---|
985 | strat->red = nc_redHomog0; |
---|
986 | else |
---|
987 | strat->red = nc_redHomog; |
---|
988 | */ |
---|
989 | |
---|
990 | // if (rIsPluralRing(currRing)) |
---|
991 | strat->red = redGrFirst; |
---|
992 | #ifdef HAVE_RATGRING |
---|
993 | if (rIsRatGRing(currRing)) |
---|
994 | { |
---|
995 | int ii=IDELEMS(F)-1; |
---|
996 | int jj; |
---|
997 | BOOLEAN is_rat_id=FALSE; |
---|
998 | for(;ii>=0;ii--) |
---|
999 | { |
---|
1000 | for(jj=currRing->real_var_start;jj<=currRing->real_var_end;jj++) |
---|
1001 | { |
---|
1002 | if(pGetExp(F->m[ii],jj)>0) { is_rat_id=TRUE; break; } |
---|
1003 | } |
---|
1004 | if (is_rat_id) break; |
---|
1005 | } |
---|
1006 | if (is_rat_id) strat->red=redGrRatGB; |
---|
1007 | } |
---|
1008 | #endif |
---|
1009 | |
---|
1010 | if (currRing->pLexOrder && strat->honey) |
---|
1011 | strat->initEcart = initEcartNormal; |
---|
1012 | else |
---|
1013 | strat->initEcart = initEcartBBA; |
---|
1014 | if (strat->honey) |
---|
1015 | strat->initEcartPair = initEcartPairMora; |
---|
1016 | else |
---|
1017 | strat->initEcartPair = initEcartPairBba; |
---|
1018 | // if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
1019 | // { |
---|
1020 | // //interred machen Aenderung |
---|
1021 | // pFDegOld=currRing->pFDeg; |
---|
1022 | // pLDegOld=currRing->pLDeg; |
---|
1023 | // // h=ggetid("ecart"); |
---|
1024 | // // if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD)) |
---|
1025 | // // { |
---|
1026 | // // ecartWeights=iv2array(IDINTVEC(h)); |
---|
1027 | // // } |
---|
1028 | // // else |
---|
1029 | // { |
---|
1030 | // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short)); |
---|
1031 | // /*uses automatic computation of the ecartWeights to set them*/ |
---|
1032 | // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights); |
---|
1033 | // } |
---|
1034 | // currRing->pFDeg=totaldegreeWecart; |
---|
1035 | // currRing->pLDeg=maxdegreeWecart; |
---|
1036 | // for(i=1; i<=(currRing->N); i++) |
---|
1037 | // Print(" %d",ecartWeights[i]); |
---|
1038 | // PrintLn(); |
---|
1039 | // mflush(); |
---|
1040 | // } |
---|
1041 | } |
---|
1042 | |
---|
1043 | #define MYTEST 0 |
---|
1044 | |
---|
1045 | ideal k_gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing) |
---|
1046 | { |
---|
1047 | const ring save = currRing; if( currRing != _currRing ) rChangeCurrRing(_currRing); |
---|
1048 | |
---|
1049 | #if MYTEST |
---|
1050 | PrintS("<gnc_gr_bba>\n"); |
---|
1051 | #endif |
---|
1052 | |
---|
1053 | #ifdef HAVE_PLURAL |
---|
1054 | #if MYTEST |
---|
1055 | PrintS("currRing: \n"); |
---|
1056 | rWrite(currRing); |
---|
1057 | #ifdef RDEBUG |
---|
1058 | rDebugPrint(currRing); |
---|
1059 | #endif |
---|
1060 | |
---|
1061 | PrintS("F: \n"); |
---|
1062 | idPrint(F); |
---|
1063 | PrintS("Q: \n"); |
---|
1064 | idPrint(Q); |
---|
1065 | #endif |
---|
1066 | #endif |
---|
1067 | |
---|
1068 | assume(currRing->OrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?) |
---|
1069 | |
---|
1070 | // intvec *w=NULL; |
---|
1071 | // intvec *hilb=NULL; |
---|
1072 | int olddeg,reduc; |
---|
1073 | int red_result=1; |
---|
1074 | int /*hilbeledeg=1,*/hilbcount=0/*,minimcnt=0*/; |
---|
1075 | |
---|
1076 | initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ |
---|
1077 | // initHilbCrit(F,Q,&hilb,strat); |
---|
1078 | /* in plural we don't need Hilb yet */ |
---|
1079 | nc_gr_initBba(F,strat); |
---|
1080 | initBuchMoraPos(strat); |
---|
1081 | if (rIsRatGRing(currRing)) |
---|
1082 | { |
---|
1083 | strat->posInL=posInL0; // by pCmp of lcm |
---|
1084 | } |
---|
1085 | /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ |
---|
1086 | /*Shdl=*/initBuchMora(F, Q,strat); |
---|
1087 | strat->posInT=posInT110; |
---|
1088 | reduc = olddeg = 0; |
---|
1089 | |
---|
1090 | /* compute------------------------------------------------------- */ |
---|
1091 | while (strat->Ll >= 0) |
---|
1092 | { |
---|
1093 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
1094 | |
---|
1095 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
1096 | if (TEST_OPT_DEGBOUND |
---|
1097 | && ((strat->honey |
---|
1098 | && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
1099 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
1100 | { |
---|
1101 | /* |
---|
1102 | *stops computation if |
---|
1103 | * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
1104 | *a predefined number Kstd1_deg |
---|
1105 | */ |
---|
1106 | while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
1107 | break; |
---|
1108 | } |
---|
1109 | /* picks the last element from the lazyset L */ |
---|
1110 | strat->P = strat->L[strat->Ll]; |
---|
1111 | strat->Ll--; |
---|
1112 | //kTest(strat); |
---|
1113 | |
---|
1114 | if (strat->P.p != NULL) |
---|
1115 | if (pNext(strat->P.p) == strat->tail) |
---|
1116 | { |
---|
1117 | /* deletes the short spoly and computes */ |
---|
1118 | pLmFree(strat->P.p); |
---|
1119 | /* the real one */ |
---|
1120 | // if (ncRingType(currRing)==nc_lie) /* prod crit */ |
---|
1121 | // if(pHasNotCF(strat->P.p1,strat->P.p2)) |
---|
1122 | // { |
---|
1123 | // strat->cp++; |
---|
1124 | // /* prod.crit itself in nc_CreateSpoly */ |
---|
1125 | // } |
---|
1126 | |
---|
1127 | |
---|
1128 | if( ! rIsRatGRing(currRing) ) |
---|
1129 | { |
---|
1130 | strat->P.p = nc_CreateSpoly(strat->P.p1,strat->P.p2,currRing); |
---|
1131 | } |
---|
1132 | #ifdef HAVE_RATGRING |
---|
1133 | else |
---|
1134 | { |
---|
1135 | /* rational case */ |
---|
1136 | strat->P.p = nc_rat_CreateSpoly(strat->P.p1,strat->P.p2,currRing->real_var_start-1,currRing); |
---|
1137 | } |
---|
1138 | #endif |
---|
1139 | |
---|
1140 | |
---|
1141 | #ifdef PDEBUG |
---|
1142 | p_Test(strat->P.p, currRing); |
---|
1143 | #endif |
---|
1144 | |
---|
1145 | #if MYTEST |
---|
1146 | if (TEST_OPT_DEBUG) |
---|
1147 | { |
---|
1148 | PrintS("p1: "); pWrite(strat->P.p1); |
---|
1149 | PrintS("p2: "); pWrite(strat->P.p2); |
---|
1150 | PrintS("SPoly: "); pWrite(strat->P.p); |
---|
1151 | } |
---|
1152 | #endif |
---|
1153 | } |
---|
1154 | |
---|
1155 | |
---|
1156 | if (strat->P.p != NULL) |
---|
1157 | { |
---|
1158 | if (TEST_OPT_PROT) |
---|
1159 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
1160 | &olddeg,&reduc,strat, red_result); |
---|
1161 | |
---|
1162 | #if MYTEST |
---|
1163 | if (TEST_OPT_DEBUG) |
---|
1164 | { |
---|
1165 | PrintS("p1: "); pWrite(strat->P.p1); |
---|
1166 | PrintS("p2: "); pWrite(strat->P.p2); |
---|
1167 | PrintS("SPoly before: "); pWrite(strat->P.p); |
---|
1168 | } |
---|
1169 | #endif |
---|
1170 | |
---|
1171 | /* reduction of the element chosen from L */ |
---|
1172 | strat->red(&strat->P,strat); |
---|
1173 | |
---|
1174 | #if MYTEST |
---|
1175 | if (TEST_OPT_DEBUG) |
---|
1176 | { |
---|
1177 | PrintS("red SPoly: "); pWrite(strat->P.p); |
---|
1178 | } |
---|
1179 | #endif |
---|
1180 | } |
---|
1181 | if (strat->P.p != NULL) |
---|
1182 | { |
---|
1183 | if (TEST_OPT_PROT) |
---|
1184 | { |
---|
1185 | PrintS("s\n"); |
---|
1186 | } |
---|
1187 | /* enter P.p into s and L */ |
---|
1188 | { |
---|
1189 | /* quick unit detection in the rational case */ |
---|
1190 | #ifdef HAVE_RATGRING |
---|
1191 | if( rIsRatGRing(currRing) ) |
---|
1192 | { |
---|
1193 | if ( p_LmIsConstantRat(strat->P.p, currRing) ) |
---|
1194 | { |
---|
1195 | #ifdef PDEBUG |
---|
1196 | PrintS("unit element detected:"); |
---|
1197 | p_wrp(strat->P.p,currRing); |
---|
1198 | #endif |
---|
1199 | p_Delete(&strat->P.p,currRing, strat->tailRing); |
---|
1200 | strat->P.p = pOne(); |
---|
1201 | } |
---|
1202 | } |
---|
1203 | #endif |
---|
1204 | strat->P.sev=0; |
---|
1205 | int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart); |
---|
1206 | { |
---|
1207 | if (TEST_OPT_INTSTRATEGY) |
---|
1208 | { |
---|
1209 | if ((strat->syzComp==0)||(!strat->homog)) |
---|
1210 | { |
---|
1211 | #ifdef HAVE_RATGRING |
---|
1212 | if(!rIsRatGRing(currRing)) |
---|
1213 | #endif |
---|
1214 | strat->P.p = redtailBba(strat->P.p,pos-1,strat); |
---|
1215 | } |
---|
1216 | |
---|
1217 | strat->P.p=p_Cleardenom(strat->P.p, currRing); |
---|
1218 | } |
---|
1219 | else |
---|
1220 | { |
---|
1221 | pNorm(strat->P.p); |
---|
1222 | if ((strat->syzComp==0)||(!strat->homog)) |
---|
1223 | { |
---|
1224 | strat->P.p = redtailBba(strat->P.p,pos-1,strat); |
---|
1225 | } |
---|
1226 | } |
---|
1227 | if (TEST_OPT_DEBUG) |
---|
1228 | { |
---|
1229 | PrintS("new s:"); wrp(strat->P.p); |
---|
1230 | PrintLn(); |
---|
1231 | #if MYTEST |
---|
1232 | PrintS("s: "); pWrite(strat->P.p); |
---|
1233 | #endif |
---|
1234 | |
---|
1235 | } |
---|
1236 | // kTest(strat); |
---|
1237 | // |
---|
1238 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat); |
---|
1239 | |
---|
1240 | if (strat->sl==-1) pos=0; |
---|
1241 | else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
1242 | |
---|
1243 | strat->enterS(strat->P,pos,strat,-1); |
---|
1244 | } |
---|
1245 | // if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
1246 | } |
---|
1247 | if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); |
---|
1248 | } |
---|
1249 | #ifdef KDEBUG |
---|
1250 | strat->P.lcm=NULL; |
---|
1251 | #endif |
---|
1252 | //kTest(strat); |
---|
1253 | } |
---|
1254 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
1255 | |
---|
1256 | /* complete reduction of the standard basis--------- */ |
---|
1257 | if (TEST_OPT_SB_1) |
---|
1258 | { |
---|
1259 | int k=1; |
---|
1260 | int j; |
---|
1261 | while(k<=strat->sl) |
---|
1262 | { |
---|
1263 | j=0; |
---|
1264 | loop |
---|
1265 | { |
---|
1266 | if (j>=k) break; |
---|
1267 | clearS(strat->S[j],strat->sevS[j],&k,&j,strat); |
---|
1268 | j++; |
---|
1269 | } |
---|
1270 | k++; |
---|
1271 | } |
---|
1272 | } |
---|
1273 | |
---|
1274 | if (TEST_OPT_REDSB) |
---|
1275 | completeReduce(strat); |
---|
1276 | /* release temp data-------------------------------- */ |
---|
1277 | exitBuchMora(strat); |
---|
1278 | // if (TEST_OPT_WEIGHTM) |
---|
1279 | // { |
---|
1280 | // currRing->pFDeg=pFDegOld; |
---|
1281 | // currRing->pLDeg=pLDegOld; |
---|
1282 | // if (ecartWeights) |
---|
1283 | // { |
---|
1284 | // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
1285 | // ecartWeights=NULL; |
---|
1286 | // } |
---|
1287 | // } |
---|
1288 | if (TEST_OPT_PROT) messageStat(hilbcount,strat); |
---|
1289 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
1290 | |
---|
1291 | |
---|
1292 | #ifdef PDEBUG |
---|
1293 | /* for counting number of pairs [enterL] in Plural */ |
---|
1294 | /* extern int zaehler; */ |
---|
1295 | /* Print("Total pairs considered:%d\n",zaehler); zaehler=0; */ |
---|
1296 | #endif /*PDEBUG*/ |
---|
1297 | |
---|
1298 | #if MYTEST |
---|
1299 | PrintS("</gnc_gr_bba>\n"); |
---|
1300 | #endif |
---|
1301 | |
---|
1302 | if( currRing != save ) rChangeCurrRing(save); |
---|
1303 | |
---|
1304 | return (strat->Shdl); |
---|
1305 | } |
---|
1306 | |
---|
1307 | ideal k_gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing) |
---|
1308 | { |
---|
1309 | #ifndef SING_NDEBUG |
---|
1310 | // Not yet! |
---|
1311 | WarnS("Sorry, non-commutative mora is not yet implemented!"); |
---|
1312 | #endif |
---|
1313 | |
---|
1314 | return gnc_gr_bba(F, Q, NULL, NULL, strat, _currRing); |
---|
1315 | } |
---|
1316 | |
---|
1317 | #endif |
---|
1318 | |
---|