My Project
Loading...
Searching...
No Matches
kstd1.cc
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/*
5* ABSTRACT:
6*/
7
8// TODO: why the following is here instead of mod2.h???
9
10
11// define if buckets should be used
12#define MORA_USE_BUCKETS
13
14#define PRE_INTEGER_CHECK 0
15
16#include "kernel/mod2.h"
17
18#include "misc/options.h"
19#include "misc/intvec.h"
20
21#include "polys/weight.h"
22#include "kernel/polys.h"
23
28#include "kernel/ideals.h"
29
30//#include "ipprint.h"
31
32#ifdef HAVE_PLURAL
33#include "polys/nc/nc.h"
34#include "polys/nc/sca.h"
35#include "kernel/GBEngine/nc.h"
36#endif
37
39
40#ifdef HAVE_SHIFTBBA
41#include "polys/shiftop.h"
42#endif
43
44/* the list of all options which give a warning by test */
46 |Sy_bit(OPT_REDSB) /* 1 */
47 |Sy_bit(OPT_NOT_SUGAR) /* 3 */
48 |Sy_bit(OPT_INTERRUPT) /* 4 */
49 |Sy_bit(OPT_SUGARCRIT) /* 5 */
52 |Sy_bit(OPT_FASTHC) /* 10 */
53 |Sy_bit(OPT_INTSTRATEGY) /* 26 */
54 |Sy_bit(OPT_INFREDTAIL) /* 28 */
55 |Sy_bit(OPT_NOTREGULARITY) /* 30 */
56 |Sy_bit(OPT_WEIGHTM); /* 31 */
57
58/* the list of all options which may be used by option and test */
59/* definition of ALL options: libpolys/misc/options.h */
61 |Sy_bit(1)
62 |Sy_bit(2) // obachman 10/00: replaced by notBucket
63 |Sy_bit(3)
64 |Sy_bit(4)
65 |Sy_bit(5)
66 |Sy_bit(6)
67// |Sy_bit(7) obachman 11/00 tossed: 12/00 used for redThrough
68 |Sy_bit(7) // OPT_REDTHROUGH
69 |Sy_bit(8) // obachman 11/00 tossed -> motsak 2011 experimental: OPT_NO_SYZ_MINIM
70 |Sy_bit(9)
71 |Sy_bit(10)
72 |Sy_bit(11)
73 |Sy_bit(12)
74 |Sy_bit(13)
75 |Sy_bit(14)
76 |Sy_bit(15)
77 |Sy_bit(16)
78 |Sy_bit(17)
79 |Sy_bit(18)
80 |Sy_bit(19)
81// |Sy_bit(20) obachman 11/00 tossed: 12/00 used for redOldStd
83 |Sy_bit(21)
84 |Sy_bit(22)
85 /*|Sy_bit(23)*/
86 /*|Sy_bit(24)*/
89 |Sy_bit(27)
90 |Sy_bit(28)
91 |Sy_bit(29)
92 |Sy_bit(30)
93 |Sy_bit(31);
94
95//static BOOLEAN posInLOldFlag;
96 /*FALSE, if posInL == posInL10*/
97// returns TRUE if mora should use buckets, false otherwise
98static BOOLEAN kMoraUseBucket(kStrategy strat);
99
101{
102// if (strat->ak == 0 && !rIsSyzIndexRing(currRing))
103 strat->length_pLength = TRUE;
104// else
105// strat->length_pLength = FALSE;
106
107 if ((ldeg == pLDeg0c /*&& !rIsSyzIndexRing(currRing)*/) ||
108 (ldeg == pLDeg0 && strat->ak == 0))
109 {
110 strat->LDegLast = TRUE;
111 }
112 else
113 {
114 strat->LDegLast = FALSE;
115 }
116}
117
119{
120 int ret;
121#if KDEBUG > 0
122 kTest_L(h);
123 kTest_T(with);
124#endif
125 // Hmmm ... why do we do this -- polys from T should already be normalized
127 with->pNorm();
128#ifdef KDEBUG
129 if (TEST_OPT_DEBUG)
130 {
131 PrintS("reduce ");h->wrp();PrintS(" with ");with->wrp();PrintLn();
132 }
133#endif
134 if (intoT)
135 {
136 // need to do it exactly like this: otherwise
137 // we might get errors
138 LObject L= *h;
139 L.Copy();
140 h->GetP();
141 h->length=h->pLength=pLength(h->p);
142 ret = ksReducePoly(&L, with, strat->kNoetherTail(), NULL, NULL, strat);
143 if (ret)
144 {
145 if (ret < 0) return ret;
146 if (h->tailRing != strat->tailRing)
147 h->ShallowCopyDelete(strat->tailRing,
149 strat->tailRing));
150 }
152 enterT_strong(h,strat);
153 else
154 enterT(h,strat);
155 *h = L;
156 }
157 else
158 ret = ksReducePoly(h, with, strat->kNoetherTail(), NULL, NULL, strat);
159#ifdef KDEBUG
160 if (TEST_OPT_DEBUG)
161 {
162 PrintS("to ");h->wrp();PrintLn();
163 }
164#endif
165 return ret;
166}
167
169{
170 int i,at,ei,li,ii;
171 int j = 0;
172 int pass = 0;
173 long d,reddeg;
174
175 d = h->GetpFDeg()+ h->ecart;
176 reddeg = strat->LazyDegree+d;
177 h->SetShortExpVector();
178 loop
179 {
180 j = kFindDivisibleByInT(strat, h);
181 if (j < 0)
182 {
183 if (strat->honey) h->SetLength(strat->length_pLength);
184 return 1;
185 }
186
187 ei = strat->T[j].ecart;
188 ii = j;
189
190 if (ei > h->ecart)
191 {
192 unsigned long not_sev=~h->sev;
193 poly h_t= h->GetLmTailRing();
194 li = strat->T[j].length;
195 if (li<=0) li=strat->T[j].GetpLength();
196 // the polynomial to reduce with (up to the moment) is;
197 // pi with ecart ei and length li
198 // look for one with smaller ecart
199 i = j;
200 loop
201 {
202 /*- takes the first possible with respect to ecart -*/
203 i++;
204 if (i > strat->tl) break;
205#if 1
206 if (strat->T[i].length<=0) strat->T[i].GetpLength();
207 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
208 strat->T[i].length < li))
209 &&
210 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h_t, not_sev, strat->tailRing))
211#else
212 j = kFindDivisibleByInT(strat, h, i);
213 if (j < 0) break;
214 i = j;
215 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
216 strat->T[i].length < li))
217#endif
218 {
219 // the polynomial to reduce with is now
220 ii = i;
221 ei = strat->T[i].ecart;
222 if (ei <= h->ecart) break;
223 li = strat->T[i].length;
224 }
225 }
226 }
227
228 // end of search: have to reduce with pi
229 if ((ei > h->ecart)&&(strat->kNoether==NULL))
230 {
231 // It is not possible to reduce h with smaller ecart;
232 // if possible h goes to the lazy-set L,i.e
233 // if its position in L would be not the last one
234 strat->fromT = TRUE;
235 if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
236 {
237 h->SetLmCurrRing();
238 if (strat->honey && strat->posInLDependsOnLength)
239 h->SetLength(strat->length_pLength);
240 assume(h->FDeg == h->pFDeg());
241 at = strat->posInL(strat->L,strat->Ll,h,strat);
242 if (at <= strat->Ll)
243 {
244 /*- h will not become the next element to reduce -*/
245 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
246#ifdef KDEBUG
247 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
248#endif
249 h->Clear();
250 strat->fromT = FALSE;
251 return -1;
252 }
253 }
254 }
255
256 // now we finally can reduce
257 doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
258 strat->fromT=FALSE;
259
260 // are we done ???
261 if (h->IsNull())
262 {
264 kDeleteLcm(h);
265 h->Clear();
266 return 0;
267 }
268 if (TEST_OPT_IDLIFT)
269 {
270 if (h->p!=NULL)
271 {
272 if(p_GetComp(h->p,currRing)>strat->syzComp)
273 {
274 h->Delete();
275 return 0;
276 }
277 }
278 else // if (h->t_p!=NULL)
279 {
280 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
281 {
282 h->Delete();
283 return 0;
284 }
285 }
286 }
287 #if 0
288 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
289 {
290 if (h->p!=NULL)
291 {
292 if(p_GetComp(h->p,currRing)>strat->syzComp)
293 {
294 return 1;
295 }
296 }
297 else // if (h->t_p!=NULL)
298 {
299 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
300 {
301 return 1;
302 }
303 }
304 }
305 #endif
306
307 // done ? NO!
308 h->SetShortExpVector();
309 h->SetpFDeg();
310 if (strat->honey)
311 {
312 if (ei <= h->ecart)
313 h->ecart = d-h->GetpFDeg();
314 else
315 h->ecart = d-h->GetpFDeg()+ei-h->ecart;
316 }
317 else
318 // this has the side effect of setting h->length
319 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
320#if 0
321 if (strat->syzComp!=0)
322 {
323 if ((strat->syzComp>0) && (h->Comp() > strat->syzComp))
324 {
325 assume(h->MinComp() > strat->syzComp);
326 if (strat->honey) h->SetLength();
327#ifdef KDEBUG
328 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
329#endif
330 return -2;
331 }
332 }
333#endif
334 /*- try to reduce the s-polynomial -*/
335 pass++;
336 d = h->GetpFDeg()+h->ecart;
337 /*
338 *test whether the polynomial should go to the lazyset L
339 *-if the degree jumps
340 *-if the number of pre-defined reductions jumps
341 */
342 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
343 && ((d >= reddeg) || (pass > strat->LazyPass)))
344 {
345 h->SetLmCurrRing();
346 if (strat->honey && strat->posInLDependsOnLength)
347 h->SetLength(strat->length_pLength);
348 assume(h->FDeg == h->pFDeg());
349 at = strat->posInL(strat->L,strat->Ll,h,strat);
350 if (at <= strat->Ll)
351 {
352 int dummy=strat->sl;
353 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
354 {
355 if (strat->honey && !strat->posInLDependsOnLength)
356 h->SetLength(strat->length_pLength);
357 return 1;
358 }
359 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
360#ifdef KDEBUG
361 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
362#endif
363 h->Clear();
364 return -1;
365 }
366 }
367 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
368 {
369 Print(".%ld",d);mflush();
370 reddeg = d+1;
371 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
372 {
373 strat->overflow=TRUE;
374 //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
375 h->GetP();
376 at = strat->posInL(strat->L,strat->Ll,h,strat);
377 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
378 h->Clear();
379 return -1;
380 }
381 }
382 }
383}
384
386{
387 int i,at,ei,li,ii;
388 int j = 0;
389 int pass = 0;
390 long d,reddeg;
391
392 d = h->GetpFDeg()+ h->ecart;
393 reddeg = strat->LazyDegree+d;
394 h->SetShortExpVector();
395 loop
396 {
397 j = kFindDivisibleByInT(strat, h);
398 if (j < 0)
399 {
400 // over ZZ: cleanup coefficients by complete reduction with monomials
401 postReduceByMon(h, strat);
402 if(h->p == NULL)
403 {
404 kDeleteLcm(h);
405 h->Clear();
406 return 0;
407 }
408 if (strat->honey) h->SetLength(strat->length_pLength);
409 if(strat->tl >= 0)
410 h->i_r1 = strat->tl;
411 else
412 h->i_r1 = -1;
413 if (h->GetLmTailRing() == NULL)
414 {
415 kDeleteLcm(h);
416 h->Clear();
417 return 0;
418 }
419 return 1;
420 }
421
422 ei = strat->T[j].ecart;
423 ii = j;
424 if (ei > h->ecart && ii < strat->tl)
425 {
426 li = strat->T[j].length;
427 // the polynomial to reduce with (up to the moment) is;
428 // pi with ecart ei and length li
429 // look for one with smaller ecart
430 i = j;
431 loop
432 {
433 /*- takes the first possible with respect to ecart -*/
434 i++;
435#if 1
436 if (i > strat->tl) break;
437 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
438 strat->T[i].length < li))
439 &&
440 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)
441 &&
442 n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf))
443#else
444 j = kFindDivisibleByInT(strat, h, i);
445 if (j < 0) break;
446 i = j;
447 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
448 strat->T[i].length < li))
449#endif
450 {
451 // the polynomial to reduce with is now
452 ii = i;
453 ei = strat->T[i].ecart;
454 if (ei <= h->ecart) break;
455 li = strat->T[i].length;
456 }
457 }
458 }
459
460 // end of search: have to reduce with pi
461 if (ei > h->ecart)
462 {
463 // It is not possible to reduce h with smaller ecart;
464 // if possible h goes to the lazy-set L,i.e
465 // if its position in L would be not the last one
466 strat->fromT = TRUE;
467 if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
468 {
469 h->SetLmCurrRing();
470 if (strat->honey && strat->posInLDependsOnLength)
471 h->SetLength(strat->length_pLength);
472 assume(h->FDeg == h->pFDeg());
473 at = strat->posInL(strat->L,strat->Ll,h,strat);
474 if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef))
475 {
476 /*- h will not become the next element to reduce -*/
477 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
478 #ifdef KDEBUG
479 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
480 #endif
481 h->Clear();
482 strat->fromT = FALSE;
483 return -1;
484 }
485 }
486 doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE);
487 }
488 else
489 {
490 // now we finally can reduce
491 doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
492 }
493 strat->fromT=FALSE;
494 // are we done ???
495 if (h->IsNull())
496 {
497 kDeleteLcm(h);
498 h->Clear();
499 return 0;
500 }
501
502 // NO!
503 h->SetShortExpVector();
504 h->SetpFDeg();
505 if (strat->honey)
506 {
507 if (ei <= h->ecart)
508 h->ecart = d-h->GetpFDeg();
509 else
510 h->ecart = d-h->GetpFDeg()+ei-h->ecart;
511 }
512 else
513 // this has the side effect of setting h->length
514 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
515 /*- try to reduce the s-polynomial -*/
516 pass++;
517 d = h->GetpFDeg()+h->ecart;
518 /*
519 *test whether the polynomial should go to the lazyset L
520 *-if the degree jumps
521 *-if the number of pre-defined reductions jumps
522 */
523 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
524 && ((d >= reddeg) || (pass > strat->LazyPass)))
525 {
526 h->SetLmCurrRing();
527 if (strat->honey && strat->posInLDependsOnLength)
528 h->SetLength(strat->length_pLength);
529 assume(h->FDeg == h->pFDeg());
530 at = strat->posInL(strat->L,strat->Ll,h,strat);
531 if (at <= strat->Ll)
532 {
533 int dummy=strat->sl;
534 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
535 {
536 if (strat->honey && !strat->posInLDependsOnLength)
537 h->SetLength(strat->length_pLength);
538 return 1;
539 }
540 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
541#ifdef KDEBUG
542 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
543#endif
544 h->Clear();
545 return -1;
546 }
547 }
548 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
549 {
550 Print(".%ld",d);mflush();
551 reddeg = d+1;
552 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
553 {
554 strat->overflow=TRUE;
555 //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
556 h->GetP();
557 at = strat->posInL(strat->L,strat->Ll,h,strat);
558 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
559 h->Clear();
560 return -1;
561 }
562 }
563 }
564}
565
567{
568 int i,at,ei,li,ii;
569 int j = 0;
570 int pass = 0;
571 long d,reddeg;
572 int docoeffred = 0;
573 poly T0p = strat->T[0].p;
574 int T0ecart = strat->T[0].ecart;
575
576
577 d = h->GetpFDeg()+ h->ecart;
578 reddeg = strat->LazyDegree+d;
579 h->SetShortExpVector();
580 if ((strat->tl>=0)
581 &&strat->T[0].GetpFDeg() == 0
582 && strat->T[0].length <= 2)
583 {
584 docoeffred = 1;
585 }
586 loop
587 {
588 /* cut down the lead coefficients, only possible if the degree of
589 * T[0] is 0 (constant). This is only efficient if T[0] is short, thus
590 * we ask for the length of T[0] to be <= 2 */
591 if (docoeffred)
592 {
593 j = kTestDivisibleByT0_Z(strat, h);
594 if (j == 0 && n_DivBy(pGetCoeff(h->p), pGetCoeff(T0p), currRing->cf) == FALSE
595 && T0ecart <= h->ecart)
596 {
597 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
598 * => we try to cut down the lead coefficient at least */
599 /* first copy T[j] in order to multiply it with a coefficient later on */
601 TObject tj = strat->T[0];
602 tj.Copy();
603 /* compute division with remainder of lc(h) and lc(T[j]) */
605 &rest, currRing->cf);
606 /* set corresponding new lead coefficient already. we do not
607 * remove the lead term in ksReducePolyLC, but only apply
608 * a lead coefficient reduction */
609 tj.Mult_nn(mult);
610 ksReducePolyLC(h, &tj, NULL, &rest, strat);
611 tj.Delete();
612 tj.Clear();
613 if (n_IsZero(pGetCoeff(h->GetP()),currRing->cf))
614 {
615 h->LmDeleteAndIter();
616 }
617 }
618 }
619 j = kFindDivisibleByInT(strat, h);
620 if (j < 0)
621 {
622 // over ZZ: cleanup coefficients by complete reduction with monomials
623 postReduceByMon(h, strat);
624 if(h->p == NULL)
625 {
626 kDeleteLcm(h);
627 h->Clear();
628 return 0;
629 }
630 if (strat->honey) h->SetLength(strat->length_pLength);
631 if(strat->tl >= 0)
632 h->i_r1 = strat->tl;
633 else
634 h->i_r1 = -1;
635 if (h->GetLmTailRing() == NULL)
636 {
637 kDeleteLcm(h);
638 h->Clear();
639 return 0;
640 }
641 return 1;
642 }
643
644 ei = strat->T[j].ecart;
645 ii = j;
646#if 1
647 if (ei > h->ecart && ii < strat->tl)
648 {
649 li = strat->T[j].length;
650 // the polynomial to reduce with (up to the moment) is;
651 // pi with ecart ei and length li
652 // look for one with smaller ecart
653 i = j;
654 loop
655 {
656 /*- takes the first possible with respect to ecart -*/
657 i++;
658#if 1
659 if (i > strat->tl) break;
660 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
661 strat->T[i].length < li))
662 &&
663 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)
664 &&
665 n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf))
666#else
667 j = kFindDivisibleByInT(strat, h, i);
668 if (j < 0) break;
669 i = j;
670 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
671 strat->T[i].length < li))
672#endif
673 {
674 // the polynomial to reduce with is now
675 ii = i;
676 ei = strat->T[i].ecart;
677 if (ei <= h->ecart) break;
678 li = strat->T[i].length;
679 }
680 }
681 }
682#endif
683
684 // end of search: have to reduce with pi
685 if (ei > h->ecart)
686 {
687 // It is not possible to reduce h with smaller ecart;
688 // if possible h goes to the lazy-set L,i.e
689 // if its position in L would be not the last one
690 strat->fromT = TRUE;
691 if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
692 {
693 h->SetLmCurrRing();
694 if (strat->honey && strat->posInLDependsOnLength)
695 h->SetLength(strat->length_pLength);
696 assume(h->FDeg == h->pFDeg());
697 at = strat->posInL(strat->L,strat->Ll,h,strat);
698 if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef))
699 {
700 /*- h will not become the next element to reduce -*/
701 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
702#ifdef KDEBUG
703 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
704#endif
705 h->Clear();
706 strat->fromT = FALSE;
707 return -1;
708 }
709 }
710 doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE);
711 }
712 else
713 {
714 // now we finally can reduce
715 doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
716 }
717 strat->fromT=FALSE;
718 // are we done ???
719 if (h->IsNull())
720 {
721 kDeleteLcm(h);
722 h->Clear();
723 return 0;
724 }
725
726 // NO!
727 h->SetShortExpVector();
728 h->SetpFDeg();
729 if (strat->honey)
730 {
731 if (ei <= h->ecart)
732 h->ecart = d-h->GetpFDeg();
733 else
734 h->ecart = d-h->GetpFDeg()+ei-h->ecart;
735 }
736 else
737 // this has the side effect of setting h->length
738 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
739 /*- try to reduce the s-polynomial -*/
740 pass++;
741 d = h->GetpFDeg()+h->ecart;
742 /*
743 *test whether the polynomial should go to the lazyset L
744 *-if the degree jumps
745 *-if the number of pre-defined reductions jumps
746 */
747 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
748 && ((d >= reddeg) || (pass > strat->LazyPass)))
749 {
750 h->SetLmCurrRing();
751 if (strat->honey && strat->posInLDependsOnLength)
752 h->SetLength(strat->length_pLength);
753 assume(h->FDeg == h->pFDeg());
754 at = strat->posInL(strat->L,strat->Ll,h,strat);
755 if (at <= strat->Ll)
756 {
757 int dummy=strat->sl;
758 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
759 {
760 if (strat->honey && !strat->posInLDependsOnLength)
761 h->SetLength(strat->length_pLength);
762 return 1;
763 }
764 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
765#ifdef KDEBUG
766 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
767#endif
768 h->Clear();
769 return -1;
770 }
771 }
772 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
773 {
774 Print(".%ld",d);mflush();
775 reddeg = d+1;
776 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
777 {
778 strat->overflow=TRUE;
779 //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
780 h->GetP();
781 at = strat->posInL(strat->L,strat->Ll,h,strat);
782 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
783 h->Clear();
784 return -1;
785 }
786 }
787 }
788}
789
790/*2
791*reduces h with elements from T choosing the first possible
792* element in t with respect to the given pDivisibleBy
793*/
795{
796 if (strat->tl<0) return 1;
797 if (h->IsNull()) return 0;
798
799 int at;
800 long reddeg,d;
801 int pass = 0;
802 int cnt = RED_CANONICALIZE;
803 int j = 0;
804
805 reddeg = d = h->GetpFDeg();
806 if (! strat->homog)
807 {
808 d += h->ecart;
809 reddeg = strat->LazyDegree+d;
810 }
811 h->SetShortExpVector();
812 loop
813 {
814 j = kFindDivisibleByInT(strat, h);
815 if (j < 0)
816 {
817 h->SetDegStuffReturnLDeg(strat->LDegLast);
818 return 1;
819 }
820
822 strat->T[j].pNorm();
823#ifdef KDEBUG
824 if (TEST_OPT_DEBUG)
825 {
826 PrintS("reduce ");
827 h->wrp();
828 PrintS(" with ");
829 strat->T[j].wrp();
830 }
831#endif
832 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
833#ifdef KDEBUG
834 if (TEST_OPT_DEBUG)
835 {
836 PrintS(" to ");
837 wrp(h->p);
838 PrintLn();
839 }
840#endif
841 if (h->IsNull())
842 {
844 kDeleteLcm(h);
845 h->Clear();
846 return 0;
847 }
848 if (TEST_OPT_IDLIFT)
849 {
850 if (h->p!=NULL)
851 {
852 if(p_GetComp(h->p,currRing)>strat->syzComp)
853 {
854 h->Delete();
855 return 0;
856 }
857 }
858 else // if (h->t_p!=NULL)
859 {
860 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
861 {
862 h->Delete();
863 return 0;
864 }
865 }
866 }
867 #if 0
868 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
869 {
870 if (h->p!=NULL)
871 {
872 if(p_GetComp(h->p,currRing)>strat->syzComp)
873 {
874 return 1;
875 }
876 }
877 else // if (h->t_p!=NULL)
878 {
879 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
880 {
881 return 1;
882 }
883 }
884 }
885 #endif
886 h->SetShortExpVector();
887
888#if 0
889 if ((strat->syzComp!=0) && !strat->honey)
890 {
891 if ((strat->syzComp>0) &&
892 (h->Comp() > strat->syzComp))
893 {
894 assume(h->MinComp() > strat->syzComp);
895#ifdef KDEBUG
896 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
897#endif
898 if (strat->homog)
899 h->SetDegStuffReturnLDeg(strat->LDegLast);
900 return -2;
901 }
902 }
903#endif
904 if (!strat->homog)
905 {
906 if (!TEST_OPT_OLDSTD && strat->honey)
907 {
908 h->SetpFDeg();
909 if (strat->T[j].ecart <= h->ecart)
910 h->ecart = d - h->GetpFDeg();
911 else
912 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
913
914 d = h->GetpFDeg() + h->ecart;
915 }
916 else
917 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
918 /*- try to reduce the s-polynomial -*/
919 cnt--;
920 pass++;
921 /*
922 *test whether the polynomial should go to the lazyset L
923 *-if the degree jumps
924 *-if the number of pre-defined reductions jumps
925 */
926 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
927 && ((d >= reddeg) || (pass > strat->LazyPass)))
928 {
929 h->SetLmCurrRing();
930 if (strat->posInLDependsOnLength)
931 h->SetLength(strat->length_pLength);
932 at = strat->posInL(strat->L,strat->Ll,h,strat);
933 if (at <= strat->Ll)
934 {
935 int dummy=strat->sl;
936 if (kFindDivisibleByInS(strat,&dummy, h) < 0)
937 return 1;
938 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
939#ifdef KDEBUG
940 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
941#endif
942 h->Clear();
943 return -1;
944 }
945 }
946 if (UNLIKELY(cnt==0))
947 {
948 h->CanonicalizeP();
950 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
951 }
952 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
953 {
954 reddeg = d+1;
955 Print(".%ld",d);mflush();
956 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
957 {
958 strat->overflow=TRUE;
959 //Print("OVERFLOW in redFirst d=%ld, max=%ld",d,strat->tailRing->bitmask);
960 h->GetP();
961 at = strat->posInL(strat->L,strat->Ll,h,strat);
962 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
963 h->Clear();
964 return -1;
965 }
966 }
967 }
968 }
969}
970
971/*2
972* reduces h with elements from T choosing first possible
973* element in T with respect to the given ecart
974* used for computing normal forms outside kStd
975*/
976static poly redMoraNF (poly h,kStrategy strat, int flag)
977{
978 LObject H;
979 H.p = h;
980 int j = 0;
981 int z = 10;
982 int o = H.SetpFDeg();
983 H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o;
985 H.sev = pGetShortExpVector(H.p);
986 loop
987 {
988 if (j > strat->tl)
989 {
990 return H.p;
991 }
992 if (TEST_V_DEG_STOP)
993 {
994 if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p);
995 if (H.p==NULL) return NULL;
996 }
997 unsigned long not_sev = ~ H.sev;
998 if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)
999 )
1000 {
1001 /*- remember the found T-poly -*/
1002 // poly pi = strat->T[j].p;
1003 int ei = strat->T[j].ecart;
1004 int li = strat->T[j].length;
1005 int ii = j;
1006 /*
1007 * the polynomial to reduce with (up to the moment) is;
1008 * pi with ecart ei and length li
1009 */
1010 loop
1011 {
1012 /*- look for a better one with respect to ecart -*/
1013 /*- stop, if the ecart is small enough (<=ecart(H)) -*/
1014 j++;
1015 if (j > strat->tl) break;
1016 if (ei <= H.ecart) break;
1017 if (((strat->T[j].ecart < ei)
1018 || ((strat->T[j].ecart == ei)
1019 && (strat->T[j].length < li)))
1020 && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)
1021 )
1022 {
1023 /*
1024 * the polynomial to reduce with is now;
1025 */
1026 // pi = strat->T[j].p;
1027 ei = strat->T[j].ecart;
1028 li = strat->T[j].length;
1029 ii = j;
1030 }
1031 }
1032 /*
1033 * end of search: have to reduce with pi
1034 */
1035 z++;
1036 if (z>10)
1037 {
1038 pNormalize(H.p);
1039 z=0;
1040 }
1041 if ((ei > H.ecart) && (strat->kNoether==NULL))
1042 {
1043 /*
1044 * It is not possible to reduce h with smaller ecart;
1045 * we have to reduce with bad ecart: H has to enter in T
1046 */
1047 LObject L= H;
1048 L.Copy();
1049 H.GetP();
1050 H.length=H.pLength=pLength(H.p);
1051 ksReducePoly(&L, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
1052 (flag & KSTD_NF_NONORM)==0);
1053 enterT(&H,strat);
1054 H = L;
1055 }
1056 else
1057 {
1058 /*
1059 * we reduce with good ecart, h need not to be put to T
1060 */
1061 ksReducePoly(&H, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
1062 (flag & KSTD_NF_NONORM)==0);
1063 }
1064 if (H.p == NULL)
1065 return NULL;
1066 /*- try to reduce the s-polynomial -*/
1067 o = H.SetpFDeg();
1068 if ((flag & KSTD_NF_ECART) == 0) cancelunit(&H,TRUE);
1069 H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o;
1070 j = 0;
1071 H.sev = pGetShortExpVector(H.p);
1072 }
1073 else
1074 {
1075 j++;
1076 }
1077 }
1078}
1079
1080static poly redMoraNFRing (poly h,kStrategy strat, int flag)
1081{
1082 LObject H;
1083 H.p = h;
1084 int j0, j = 0;
1085 int docoeffred = 0;
1086 poly T0p = strat->T[0].p;
1087 int T0ecart = strat->T[0].ecart;
1088 int o = H.SetpFDeg();
1089 H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o;
1090 if ((flag & KSTD_NF_ECART) == 0) cancelunit(&H,TRUE);
1091 H.sev = pGetShortExpVector(H.p);
1092 unsigned long not_sev = ~ H.sev;
1093 if (strat->T[0].GetpFDeg() == 0 && strat->T[0].length <= 2)
1094 {
1095 docoeffred = 1; // euclidean ring required: n_QuotRem
1096 if (currRing->cf->cfQuotRem==ndQuotRem)
1097 {
1098 docoeffred = 0;
1099 }
1100 }
1101 loop
1102 {
1103 /* cut down the lead coefficients, only possible if the degree of
1104 * T[0] is 0 (constant). This is only efficient if T[0] is short, thus
1105 * we ask for the length of T[0] to be <= 2 */
1106 if (docoeffred)
1107 {
1108 j0 = kTestDivisibleByT0_Z(strat, &H);
1109 if ((j0 == 0)
1110 && (n_DivBy(pGetCoeff(H.p), pGetCoeff(T0p), currRing->cf) == FALSE)
1111 && (T0ecart <= H.ecart))
1112 {
1113 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
1114 * => we try to cut down the lead coefficient at least */
1115 /* first copy T[j0] in order to multiply it with a coefficient later on */
1116 number mult, rest;
1117 TObject tj = strat->T[0];
1118 tj.Copy();
1119 /* compute division with remainder of lc(h) and lc(T[j]) */
1121 &rest, currRing->cf);
1122 /* set corresponding new lead coefficient already. we do not
1123 * remove the lead term in ksReducePolyLC, but only apply
1124 * a lead coefficient reduction */
1125 tj.Mult_nn(mult);
1126 ksReducePolyLC(&H, &tj, NULL, &rest, strat);
1127 tj.Delete();
1128 tj.Clear();
1129 }
1130 }
1131 if (j > strat->tl)
1132 {
1133 return H.p;
1134 }
1135 if (TEST_V_DEG_STOP)
1136 {
1137 if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p);
1138 if (H.p==NULL) return NULL;
1139 }
1140 if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)
1141 && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
1142 )
1143 {
1144 /*- remember the found T-poly -*/
1145 // poly pi = strat->T[j].p;
1146 int ei = strat->T[j].ecart;
1147 int li = strat->T[j].length;
1148 int ii = j;
1149 /*
1150 * the polynomial to reduce with (up to the moment) is;
1151 * pi with ecart ei and length li
1152 */
1153 loop
1154 {
1155 /*- look for a better one with respect to ecart -*/
1156 /*- stop, if the ecart is small enough (<=ecart(H)) -*/
1157 j++;
1158 if (j > strat->tl) break;
1159 if (ei <= H.ecart) break;
1160 if (((strat->T[j].ecart < ei)
1161 || ((strat->T[j].ecart == ei)
1162 && (strat->T[j].length < li)))
1163 && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)
1164 && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
1165 )
1166 {
1167 /*
1168 * the polynomial to reduce with is now;
1169 */
1170 // pi = strat->T[j].p;
1171 ei = strat->T[j].ecart;
1172 li = strat->T[j].length;
1173 ii = j;
1174 }
1175 }
1176 /*
1177 * end of search: have to reduce with pi
1178 */
1179 if ((ei > H.ecart) && (strat->kNoether==NULL))
1180 {
1181 /*
1182 * It is not possible to reduce h with smaller ecart;
1183 * we have to reduce with bad ecart: H has to enter in T
1184 */
1185 LObject L= H;
1186 L.Copy();
1187 H.GetP();
1188 H.length=H.pLength=pLength(H.p);
1189 ksReducePoly(&L, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
1190 (flag & KSTD_NF_NONORM)==0);
1191 enterT_strong(&H,strat);
1192 H = L;
1193 }
1194 else
1195 {
1196 /*
1197 * we reduce with good ecart, h need not to be put to T
1198 */
1199 ksReducePoly(&H, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
1200 (flag & KSTD_NF_NONORM)==0);
1201 }
1202 if (H.p == NULL)
1203 return NULL;
1204 /*- try to reduce the s-polynomial -*/
1205 o = H.SetpFDeg();
1206 if ((flag &2 ) == 0) cancelunit(&H,TRUE);
1207 H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o;
1208 j = 0;
1209 H.sev = pGetShortExpVector(H.p);
1210 not_sev = ~ H.sev;
1211 }
1212 else
1213 {
1214 j++;
1215 }
1216 }
1217}
1218
1219/*2
1220*reorders L with respect to posInL
1221*/
1222static void reorderL(kStrategy strat)
1223{
1224 int i,j,at;
1225
1226 for (i=1; i<=strat->Ll; i++)
1227 {
1228 at = strat->posInL(strat->L,i-1,&(strat->L[i]),strat);
1229 if (at != i)
1230 {
1231 LObject p = strat->L[i];
1232 for (j=i-1; j>=at; j--) strat->L[j+1] = strat->L[j];
1233 strat->L[at] = p;
1234 }
1235 }
1236}
1237
1238/*2
1239*reorders T with respect to length
1240*/
1241static void reorderT(kStrategy strat)
1242{
1243 int i,j,at;
1244 TObject p;
1245 unsigned long sev;
1246
1247
1248 for (i=1; i<=strat->tl; i++)
1249 {
1250 if (strat->T[i-1].length > strat->T[i].length)
1251 {
1252 p = strat->T[i];
1253 sev = strat->sevT[i];
1254 at = i-1;
1255 loop
1256 {
1257 at--;
1258 if (at < 0) break;
1259 if (strat->T[i].length > strat->T[at].length) break;
1260 }
1261 for (j = i-1; j>at; j--)
1262 {
1263 strat->T[j+1]=strat->T[j];
1264 strat->sevT[j+1]=strat->sevT[j];
1265 strat->R[strat->T[j+1].i_r] = &(strat->T[j+1]);
1266 }
1267 strat->T[at+1]=p;
1268 strat->sevT[at+1] = sev;
1269 strat->R[p.i_r] = &(strat->T[at+1]);
1270 }
1271 }
1272}
1273
1274/*2
1275*looks whether exactly (currRing->N)-1 axis are used
1276*returns last != 0 in this case
1277*last is the (first) unused axis
1278*/
1279static void missingAxis (int* last,kStrategy strat)
1280{
1281 int i = 0;
1282 int k = 0;
1283
1284 *last = 0;
1286 {
1287 loop
1288 {
1289 i++;
1290 if (i > (currRing->N)) break;
1291 if (strat->NotUsedAxis[i])
1292 {
1293 *last = i;
1294 k++;
1295 }
1296 if (k>1)
1297 {
1298 *last = 0;
1299 break;
1300 }
1301 }
1302 }
1303}
1304
1305/*2
1306*last is the only non used axis, it looks
1307*for a monomial in p being a pure power of this
1308*variable and returns TRUE in this case
1309*(*length) gives the length between the pure power and the leading term
1310*(should be minimal)
1311*/
1312static BOOLEAN hasPurePower (const poly p,int last, int *length,kStrategy strat)
1313{
1314 poly h;
1315 int i;
1316
1317 if (pNext(p) == strat->tail)
1318 return FALSE;
1319 pp_Test(p, currRing, strat->tailRing);
1320 if (strat->ak <= 0 || p_MinComp(p, currRing, strat->tailRing) == strat->ak)
1321 {
1323 if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(p), currRing->cf))) i=0;
1324 if (i == last)
1325 {
1326 *length = 0;
1327 return TRUE;
1328 }
1329 *length = 1;
1330 h = pNext(p);
1331 while (h != NULL)
1332 {
1333 i = p_IsPurePower(h, strat->tailRing);
1334 if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(h), currRing->cf))) i=0;
1335 if (i==last) return TRUE;
1336 (*length)++;
1337 pIter(h);
1338 }
1339 }
1340 return FALSE;
1341}
1342
1344{
1345 if (L->bucket != NULL)
1346 {
1347 poly p = L->GetP();
1348 return hasPurePower(p, last, length, strat);
1349 }
1350 else
1351 {
1352 return hasPurePower(L->p, last, length, strat);
1353 }
1354}
1355
1356/*2
1357* looks up the position of polynomial p in L
1358* in the case of looking for the pure powers
1359*/
1360int posInL10 (const LSet set,const int length, LObject* p,const kStrategy strat)
1361{
1362 int j,dp,dL;
1363
1364 if (length<0) return 0;
1365 if (hasPurePower(p,strat->lastAxis,&dp,strat))
1366 {
1367 int op= p->GetpFDeg() +p->ecart;
1368 for (j=length; j>=0; j--)
1369 {
1370 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1371 return j+1;
1372 if (dp < dL)
1373 return j+1;
1374 if ((dp == dL)
1375 && (set[j].GetpFDeg()+set[j].ecart >= op))
1376 return j+1;
1377 }
1378 }
1379 j=length;
1380 loop
1381 {
1382 if (j<0) break;
1383 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1384 j--;
1385 }
1386 return strat->posInLOld(set,j,p,strat);
1387}
1388
1389
1390/*2
1391* computes the s-polynomials L[ ].p in L
1392* searchPP should be FALSE if updateL is followed by reorderL
1393*/
1395{
1396 // only in mora
1398 int dL;
1399 int j=strat->Ll;
1401 if (searchPP && (strat->kNoether==NULL))
1402 {
1403 loop
1404 {
1405 if (j<0) break;
1406 if (hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat))
1407 {
1408 LObject p;
1409 p=strat->L[strat->Ll];
1410 strat->L[strat->Ll]=strat->L[j];
1411 strat->L[j]=p;
1413 break;
1414 }
1415 j--;
1416 }
1417 }
1418 j=strat->Ll;
1419 loop
1420 {
1421 if (j<0) break;
1422 if (pNext(strat->L[j].p) == strat->tail)
1423 {
1425 pLmDelete(strat->L[j].p); /*deletes the short spoly and computes*/
1426 else
1427 pLmFree(strat->L[j].p); /*deletes the short spoly and computes*/
1428 strat->L[j].p = NULL;
1429 poly m1 = NULL, m2 = NULL;
1430 // check that spoly creation is ok
1431 while (strat->tailRing != currRing &&
1432 !kCheckSpolyCreation(&(strat->L[j]), strat, m1, m2))
1433 {
1434 assume(m1 == NULL && m2 == NULL);
1435 // if not, change to a ring where exponents are at least
1436 // large enough
1437 kStratChangeTailRing(strat);
1438 }
1439 /* create the real one */
1440 ksCreateSpoly(&(strat->L[j]), strat->kNoetherTail(), FALSE,
1441 strat->tailRing, m1, m2, strat->R);
1442
1443 strat->L[j].SetLmCurrRing();
1444 if (!strat->honey)
1445 strat->initEcart(&strat->L[j]);
1446 else
1447 strat->L[j].SetLength(strat->length_pLength);
1448
1449 BOOLEAN pp = FALSE;
1450 if (searchPP
1451 && (!lastPPfound)
1452 && (strat->kNoether==NULL))
1453 pp=hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat);
1454
1455 strat->L[j].PrepareRed(strat->use_buckets);
1456
1457 if (pp)
1458 {
1459 LObject p;
1460 p=strat->L[strat->Ll];
1461 strat->L[strat->Ll]=strat->L[j];
1462 strat->L[j]=p;
1463 break;
1464 }
1465 }
1466 j--;
1467 }
1468}
1469
1470/*2
1471* computes the s-polynomials L[ ].p in L and
1472* cuts elements in L above noether
1473*/
1474static void updateLHC(kStrategy strat)
1475{
1476
1477 int i = 0;
1478 kTest_TS(strat);
1479 while (i <= strat->Ll)
1480 {
1481 if (pNext(strat->L[i].p) == strat->tail)
1482 {
1483 /*- deletes the int spoly and computes -*/
1484 if (pLmCmp(strat->L[i].p,strat->kNoether) == -1)
1485 {
1487 pLmDelete(strat->L[i].p);
1488 else
1489 pLmFree(strat->L[i].p);
1490 strat->L[i].p = NULL;
1491 }
1492 else
1493 {
1495 pLmDelete(strat->L[i].p);
1496 else
1497 pLmFree(strat->L[i].p);
1498 strat->L[i].p = NULL;
1499 poly m1 = NULL, m2 = NULL;
1500 // check that spoly creation is ok
1501 while (strat->tailRing != currRing &&
1502 !kCheckSpolyCreation(&(strat->L[i]), strat, m1, m2))
1503 {
1504 assume(m1 == NULL && m2 == NULL);
1505 // if not, change to a ring where exponents are at least
1506 // large enough
1507 kStratChangeTailRing(strat);
1508 }
1509 /* create the real one */
1510 ksCreateSpoly(&(strat->L[i]), strat->kNoetherTail(), FALSE,
1511 strat->tailRing, m1, m2, strat->R);
1512 if (! strat->L[i].IsNull())
1513 {
1514 strat->L[i].SetLmCurrRing();
1515 strat->L[i].SetpFDeg();
1516 strat->L[i].ecart
1517 = strat->L[i].pLDeg(strat->LDegLast) - strat->L[i].GetpFDeg();
1518 if (strat->use_buckets) strat->L[i].PrepareRed(TRUE);
1519 }
1520 }
1521 }
1522 deleteHC(&(strat->L[i]), strat);
1523 if (strat->L[i].IsNull())
1524 deleteInL(strat->L,&strat->Ll,i,strat);
1525 else
1526 {
1527#ifdef KDEBUG
1528 kTest_L(&(strat->L[i]), strat, TRUE, i, strat->T, strat->tl);
1529#endif
1530 i++;
1531 }
1532 }
1533 kTest_TS(strat);
1534}
1535
1536/*2
1537* cuts in T above strat->kNoether and tries to cancel a unit
1538* changes also S as S is a subset of T
1539*/
1540static void updateT(kStrategy strat)
1541{
1542 int i = 0;
1543 LObject p;
1544
1545 while (i <= strat->tl)
1546 {
1547 p = strat->T[i];
1548 deleteHC(&p,strat, TRUE);
1549 /*- tries to cancel a unit: -*/
1550 cancelunit(&p);
1551 if (TEST_OPT_INTSTRATEGY) /* deleteHC and/or cancelunit may have changed p*/
1552 p.pCleardenom();
1553 if (p.p != strat->T[i].p)
1554 {
1555 strat->sevT[i] = pGetShortExpVector(p.p);
1556 p.SetpFDeg();
1557 }
1558 strat->T[i] = p;
1559 i++;
1560 }
1561}
1562
1563/*2
1564* arranges red, pos and T if strat->kAllAxis (first time)
1565*/
1566static void firstUpdate(kStrategy strat)
1567{
1568 if (strat->update)
1569 {
1570 kTest_TS(strat);
1571 strat->update = (strat->tl == -1);
1572 if (TEST_OPT_WEIGHTM)
1573 {
1575 if (strat->tailRing != currRing)
1576 {
1577 strat->tailRing->pFDeg = strat->pOrigFDeg_TailRing;
1578 strat->tailRing->pLDeg = strat->pOrigLDeg_TailRing;
1579 }
1580 int i;
1581 for (i=strat->Ll; i>=0; i--)
1582 {
1583 strat->L[i].SetpFDeg();
1584 }
1585 for (i=strat->tl; i>=0; i--)
1586 {
1587 strat->T[i].SetpFDeg();
1588 }
1589 if (ecartWeights)
1590 {
1591 omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short));
1593 }
1594 }
1595 if (TEST_OPT_FASTHC)
1596 {
1597 strat->posInL = strat->posInLOld;
1598 strat->lastAxis = 0;
1599 }
1600 if (TEST_OPT_FINDET)
1601 return;
1602
1603 strat->use_buckets = kMoraUseBucket(strat);
1604 updateT(strat);
1605
1607 {
1608 strat->posInT = posInT2;
1609 reorderT(strat);
1610 }
1611 }
1612 kTest_TS(strat);
1613}
1614
1615/*2
1616*-puts p to the standardbasis s at position at
1617*-reduces the tail of p if TEST_OPT_REDTAIL
1618*-tries to cancel a unit
1619*-HEckeTest
1620* if TRUE
1621* - decides about reduction-strategies
1622* - computes noether
1623* - stops computation if TEST_OPT_FINDET
1624* - cuts the tails of the polynomials
1625* in s,t and the elements in L above noether
1626* and cancels units if possible
1627* - reorders s,L
1628*/
1629void enterSMora (LObject* p,int atS,kStrategy strat, int atR)
1630{
1631 enterSBba(p, atS, strat, atR);
1632 #ifdef KDEBUG
1633 if (TEST_OPT_DEBUG)
1634 {
1635 Print("new s%d:",atS);
1636 p_wrp(p->p,currRing,strat->tailRing);
1637 PrintLn();
1638 }
1639 #endif
1640 HEckeTest(p->p,strat);
1641 if (strat->kAllAxis)
1642 {
1643 if (newHEdge(strat))
1644 {
1645 firstUpdate(strat);
1646 if (TEST_OPT_FINDET)
1647 return;
1648
1649 /*- cuts elements in L above noether and reorders L -*/
1650 updateLHC(strat);
1651 /*- reorders L with respect to posInL -*/
1652 reorderL(strat);
1653 }
1654 }
1655 else if ((strat->kNoether==NULL)
1656 && (TEST_OPT_FASTHC))
1657 {
1658 if (strat->posInLOldFlag)
1659 {
1660 missingAxis(&strat->lastAxis,strat);
1661 if (strat->lastAxis)
1662 {
1663 strat->posInLOld = strat->posInL;
1664 strat->posInLOldFlag = FALSE;
1665 strat->posInL = posInL10;
1666 strat->posInLDependsOnLength = TRUE;
1667 updateL(FALSE,strat);
1668 reorderL(strat);
1669 }
1670 }
1671 else if (strat->lastAxis)
1672 updateL(TRUE,strat);
1673 }
1674}
1675
1676/*2
1677*-puts p to the standardbasis s at position at
1678*-HEckeTest
1679* if TRUE
1680* - computes noether
1681*/
1682void enterSMoraNF (LObject* p, int atS,kStrategy strat, int atR)
1683{
1684 enterSBba(p, atS, strat, atR);
1685 if ((!strat->kAllAxis) || (strat->kNoether!=NULL)) HEckeTest(p->p,strat);
1686 if (strat->kAllAxis)
1687 newHEdge(strat);
1688}
1689
1691{
1692 /* setting global variables ------------------- */
1693 strat->enterS = enterSBba;
1694 strat->red = redHoney;
1695 if (strat->honey)
1696 strat->red = redHoney;
1697 else if (currRing->pLexOrder && !strat->homog)
1698 strat->red = redLazy;
1699 else
1700 {
1701 strat->LazyPass *=4;
1702 strat->red = redHomog;
1703 }
1705 {
1706 if (rField_is_Z(currRing))
1707 strat->red = redRing_Z;
1708 else
1709 strat->red = redRing;
1710 }
1711 if (TEST_OPT_IDLIFT
1712 && (!rIsNCRing(currRing))
1713 && (!rField_is_Ring(currRing)))
1714 strat->red=redLiftstd;
1715 if (currRing->pLexOrder && strat->honey)
1716 strat->initEcart = initEcartNormal;
1717 else
1718 strat->initEcart = initEcartBBA;
1719 if (strat->honey)
1721 else
1723// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1724// {
1725// //interred machen Aenderung
1726// strat->pOrigFDeg=pFDeg;
1727// strat->pOrigLDeg=pLDeg;
1728// //h=ggetid("ecart");
1729// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1730// //{
1731// // ecartWeights=iv2array(IDINTVEC(h));
1732// //}
1733// //else
1734// {
1735// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1736// /*uses automatic computation of the ecartWeights to set them*/
1737// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1738// }
1739// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1740// if (TEST_OPT_PROT)
1741// {
1742// for(i=1; i<=(currRing->N); i++)
1743// Print(" %d",ecartWeights[i]);
1744// PrintLn();
1745// mflush();
1746// }
1747// }
1748}
1749
1751{
1752 int i;
1753 //idhdl h;
1754 /* setting global variables ------------------- */
1755 strat->enterS = enterSSba;
1756 strat->red2 = redHoney;
1757 if (strat->honey)
1758 strat->red2 = redHoney;
1759 else if (currRing->pLexOrder && !strat->homog)
1760 strat->red2 = redLazy;
1761 else
1762 {
1763 strat->LazyPass *=4;
1764 strat->red2 = redHomog;
1765 }
1767 {
1769 {strat->red2 = redRiloc;}
1770 else
1771 {strat->red2 = redRing;}
1772 }
1773 if (currRing->pLexOrder && strat->honey)
1774 strat->initEcart = initEcartNormal;
1775 else
1776 strat->initEcart = initEcartBBA;
1777 if (strat->honey)
1779 else
1781 //strat->kIdeal = NULL;
1782 //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1783 //else strat->kIdeal->rtyp=MODUL_CMD;
1784 //strat->kIdeal->data=(void *)strat->Shdl;
1785 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1786 {
1787 //interred machen Aenderung
1788 strat->pOrigFDeg = currRing->pFDeg;
1789 strat->pOrigLDeg = currRing->pLDeg;
1790 //h=ggetid("ecart");
1791 //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1792 //{
1793 // ecartWeights=iv2array(IDINTVEC(h));
1794 //}
1795 //else
1796 {
1797 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1798 /*uses automatic computation of the ecartWeights to set them*/
1800 }
1802 if (TEST_OPT_PROT)
1803 {
1804 for(i=1; i<=(currRing->N); i++)
1805 Print(" %d",ecartWeights[i]);
1806 PrintLn();
1807 mflush();
1808 }
1809 }
1810 // for sig-safe reductions in signature-based
1811 // standard basis computations
1813 strat->red = redSigRing;
1814 else
1815 strat->red = redSig;
1816 //strat->sbaOrder = 1;
1817 strat->currIdx = 1;
1818}
1819
1821{
1822 int i,j;
1823
1824 strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN));
1825 for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE;
1826 strat->enterS = enterSMora;
1827 strat->initEcartPair = initEcartPairMora; /*- ecart approximation -*/
1828 strat->posInLOld = strat->posInL;
1829 strat->posInLOldFlag = TRUE;
1830 strat->initEcart = initEcartNormal;
1831 if (strat->homog)
1832 strat->red = redFirst; /*take the first possible in T*/
1833 else
1834 strat->red = redEcart;/*take the first possible in under ecart-restriction*/
1835 if ( currRing->ppNoether!=NULL )
1836 {
1837 strat->kNoether = pCopy((currRing->ppNoether));
1838 if (TEST_OPT_PROT)
1839 {
1840 Print("H(%ld)",p_FDeg(strat->kNoether,currRing)+1);
1841 mflush();
1842 }
1843 }
1844 if (strat->kNoether!=NULL)
1845 {
1846 HCord = currRing->pFDeg((strat->kNoether),currRing)+1;
1847 }
1848 else
1849 {
1850 HCord = INT_MAX-3;/*- very large -*/
1851 }
1852
1854 {
1855 if (rField_is_Z(currRing))
1856 strat->red = redRiloc_Z;
1857 else
1858 strat->red = redRiloc;
1859 }
1860
1861 /*reads the ecartWeights used for Graebes method from the
1862 *intvec ecart and set ecartWeights
1863 */
1864 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1865 {
1866 //interred machen Aenderung
1867 strat->pOrigFDeg=currRing->pFDeg;
1868 strat->pOrigLDeg=currRing->pLDeg;
1869 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1870 /*uses automatic computation of the ecartWeights to set them*/
1872
1874 if (TEST_OPT_PROT)
1875 {
1876 for(i=1; i<=(currRing->N); i++)
1877 Print(" %d",ecartWeights[i]);
1878 PrintLn();
1879 mflush();
1880 }
1881 }
1882 kOptimizeLDeg(currRing->pLDeg, strat);
1883}
1884
1885void kDebugPrint(kStrategy strat);
1886
1888{
1889 int olddeg = 0;
1890 int reduc = 0;
1891 int red_result = 1;
1892 int hilbeledeg=1,hilbcount=0;
1893 BITSET save1;
1896 {
1897 si_opt_1 &= ~Sy_bit(OPT_REDSB);
1898 si_opt_1 &= ~Sy_bit(OPT_REDTAIL);
1899 }
1900
1901 strat->update = TRUE;
1902 /*- setting global variables ------------------- -*/
1903 initBuchMoraCrit(strat);
1904 initHilbCrit(F,Q,&hilb,strat);
1905 initMora(F,strat);
1907 initBuchMoraPosRing(strat);
1908 else
1909 initBuchMoraPos(strat);
1910 /*Shdl=*/initBuchMora(F,Q,strat);
1911 if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat);
1912 /*updateS in initBuchMora has Hecketest
1913 * and could have put strat->kHEdgdeFound FALSE*/
1914 if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag)
1915 {
1916 strat->posInLOld = strat->posInL;
1917 strat->posInLOldFlag = FALSE;
1918 strat->posInL = posInL10;
1919 updateL(FALSE,strat);
1920 reorderL(strat);
1921 }
1922 kTest_TS(strat);
1923 strat->use_buckets = kMoraUseBucket(strat);
1924
1925#ifdef HAVE_TAIL_RING
1926 if (strat->homog && strat->red == redFirst)
1927 if(!idIs0(F) &&(!rField_is_Ring(currRing)))
1929#endif
1930
1931 if (BVERBOSE(23)) kDebugPrint(strat);
1932
1933 /*- compute-------------------------------------------*/
1934 while (strat->Ll >= 0)
1935 {
1936 #ifdef KDEBUG
1937 if (TEST_OPT_DEBUG) messageSets(strat);
1938 #endif
1939 if (siCntrlc)
1940 {
1941 while (strat->Ll >= 0)
1942 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1943 strat->noClearS=TRUE;
1944 }
1946 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg))
1947 {
1948 /*
1949 * stops computation if
1950 * - 24 (degBound)
1951 * && upper degree is bigger than Kstd1_deg
1952 */
1953 while ((strat->Ll >= 0)
1954 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
1955 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)
1956 )
1957 {
1958 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1959 //if (TEST_OPT_PROT)
1960 //{
1961 // PrintS("D"); mflush();
1962 //}
1963 }
1964 if (strat->Ll<0) break;
1965 else strat->noClearS=TRUE;
1966 }
1967 strat->P = strat->L[strat->Ll];/*- picks the last element from the lazyset L -*/
1968 if (strat->Ll==0) strat->interpt=TRUE;
1969 strat->Ll--;
1970 // create the real Spoly
1971 if (pNext(strat->P.p) == strat->tail)
1972 {
1973 /*- deletes the short spoly and computes -*/
1975 pLmDelete(strat->P.p);
1976 else
1977 pLmFree(strat->P.p);
1978 strat->P.p = NULL;
1979 poly m1 = NULL, m2 = NULL;
1980 // check that spoly creation is ok
1981 while (strat->tailRing != currRing &&
1982 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
1983 {
1984 assume(m1 == NULL && m2 == NULL);
1985 // if not, change to a ring where exponents are large enough
1986 kStratChangeTailRing(strat);
1987 }
1988 /* create the real one */
1989 ksCreateSpoly(&(strat->P), strat->kNoetherTail(), strat->use_buckets,
1990 strat->tailRing, m1, m2, strat->R);
1991 if (!strat->use_buckets)
1992 strat->P.SetLength(strat->length_pLength);
1993 strat->P.PrepareRed(strat->use_buckets);
1994 }
1995 else if (strat->P.p1 == NULL)
1996 {
1997 // for input polys, prepare reduction (buckets !)
1998 strat->P.SetLength(strat->length_pLength);
1999 strat->P.PrepareRed(strat->use_buckets);
2000 }
2001
2002 // the s-poly
2003 if (!strat->P.IsNull())
2004 {
2005 // might be NULL from noether !!!
2006 if (TEST_OPT_PROT)
2007 message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result);
2008 // reduce
2009 red_result = strat->red(&strat->P,strat);
2010 }
2011
2012 // the reduced s-poly
2013 if (! strat->P.IsNull())
2014 {
2015 strat->P.GetP();
2016 // statistics
2017 if (TEST_OPT_PROT) PrintS("s");
2018 // normalization
2020 strat->P.pCleardenom();
2021 else
2022 strat->P.pNorm();
2023 // tailreduction
2024 strat->P.p = redtail(&(strat->P),strat->sl,strat);
2025 if (strat->P.p==NULL)
2026 {
2027 WerrorS("exponent overflow - wrong ordering");
2028 return(idInit(1,1));
2029 }
2030 // set ecart -- might have changed because of tail reductions
2031 if ((!strat->noTailReduction) && (!strat->honey))
2032 strat->initEcart(&strat->P);
2033 // cancel unit
2034 cancelunit(&strat->P);
2035 // for char 0, clear denominators
2036 if ((strat->P.p->next==NULL) /* i.e. cancelunit did something*/
2038 strat->P.pCleardenom();
2039
2040 strat->P.SetShortExpVector();
2041 enterT(&strat->P,strat);
2042 // build new pairs
2044 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
2045 else
2046 enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
2047 // put in S
2048 strat->enterS(&strat->P,
2049 posInS(strat,strat->sl,strat->P.p, strat->P.ecart),
2050 strat, strat->tl);
2051 // apply hilbert criterion
2052 if (hilb!=NULL)
2053 {
2054 if (strat->homog==isHomog)
2056 else
2058 }
2059
2060 // clear strat->P
2061 kDeleteLcm(&strat->P);
2062
2063#ifdef KDEBUG
2064 // make sure kTest_TS does not complain about strat->P
2065 strat->P.Clear();
2066#endif
2067 }
2068 if (strat->kAllAxis)
2069 {
2070 if ((TEST_OPT_FINDET)
2071 || ((TEST_OPT_MULTBOUND) && (scMult0Int(strat->Shdl,NULL) < Kstd1_mu)))
2072 {
2073 // obachman: is this still used ???
2074 /*
2075 * stops computation if strat->kAllAxis and
2076 * - 27 (finiteDeterminacyTest)
2077 * or
2078 * - 23
2079 * (multBound)
2080 * && multiplicity of the ideal is smaller then a predefined number mu
2081 */
2082 while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2083 }
2084 }
2085 kTest_TS(strat);
2086 }
2087 /*- complete reduction of the standard basis------------------------ -*/
2088 if (TEST_OPT_REDSB) completeReduce(strat);
2089 else if (TEST_OPT_PROT) PrintLn();
2090 /*- release temp data------------------------------- -*/
2091 exitBuchMora(strat);
2092 /*- polynomials used for HECKE: HC, noether -*/
2093 if (TEST_OPT_FINDET)
2094 {
2095 if (strat->kNoether!=NULL)
2096 Kstd1_mu=currRing->pFDeg(strat->kNoether,currRing);
2097 else
2098 Kstd1_mu=-1;
2099 }
2100 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
2102// if (TEST_OPT_WEIGHTM)
2103// {
2104// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
2105// if (ecartWeights)
2106// {
2107// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2108// ecartWeights=NULL;
2109// }
2110// }
2111 if(nCoeff_is_Z(currRing->cf))
2112 finalReduceByMon(strat);
2113 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
2115 idTest(strat->Shdl);
2116 return (strat->Shdl);
2117}
2118
2119poly kNF1 (ideal F,ideal Q,poly q, kStrategy strat, int lazyReduce)
2120{
2121 assume(q!=NULL);
2122 assume(!(idIs0(F)&&(Q==NULL)));
2123
2124// lazy_reduce flags: can be combined by |
2125//#define KSTD_NF_LAZY 1
2126 // do only a reduction of the leading term
2127//#define KSTD_NF_ECART 2
2128 // only local: reduce even with bad ecart
2129 poly p;
2130 int i;
2131 int j;
2132 int o;
2133 LObject h;
2134 BITSET save1;
2136
2137 //if ((idIs0(F))&&(Q==NULL))
2138 // return pCopy(q); /*F=0*/
2139 //strat->ak = si_max(idRankFreeModule(F),pMaxComp(q));
2140 /*- creating temp data structures------------------- -*/
2141 strat->kAllAxis = (currRing->ppNoether) != NULL;
2142 strat->kNoether = pCopy((currRing->ppNoether));
2145 si_opt_1&=~Sy_bit(OPT_INTSTRATEGY);
2147 && (! TEST_V_DEG_STOP)
2148 && (0<Kstd1_deg)
2149 && ((strat->kNoether==NULL)
2151 {
2152 pLmDelete(&strat->kNoether);
2153 strat->kNoether=pOne();
2154 pSetExp(strat->kNoether,1, Kstd1_deg+1);
2155 pSetm(strat->kNoether);
2156 // strat->kAllAxis=TRUE;
2157 }
2158 initBuchMoraCrit(strat);
2160 initBuchMoraPosRing(strat);
2161 else
2162 initBuchMoraPos(strat);
2163 initMora(F,strat);
2164 strat->enterS = enterSMoraNF;
2165 /*- set T -*/
2166 strat->tl = -1;
2167 strat->tmax = setmaxT;
2168 strat->T = initT();
2169 strat->R = initR();
2170 strat->sevT = initsevT();
2171 /*- set S -*/
2172 strat->sl = -1;
2173 /*- init local data struct.-------------------------- -*/
2174 /*Shdl=*/initS(F,Q,strat);
2175 if ((strat->ak!=0)
2176 && (strat->kAllAxis)) /*never true for ring-cf*/
2177 {
2178 if (strat->ak!=1)
2179 {
2180 pSetComp(strat->kNoether,1);
2181 pSetmComp(strat->kNoether);
2182 poly p=pHead(strat->kNoether);
2183 pSetComp(p,strat->ak);
2184 pSetmComp(p);
2185 p=pAdd(strat->kNoether,p);
2186 strat->kNoether=pNext(p);
2188 }
2189 }
2190 if (((lazyReduce & KSTD_NF_LAZY)==0)
2191 && (!rField_is_Ring(currRing)))
2192 {
2193 for (i=strat->sl; i>=0; i--)
2194 pNorm(strat->S[i]);
2195 }
2196 /*- puts the elements of S also to T -*/
2197 for (i=0; i<=strat->sl; i++)
2198 {
2199 h.p = strat->S[i];
2200 h.ecart = strat->ecartS[i];
2201 if (strat->sevS[i] == 0) strat->sevS[i] = pGetShortExpVector(h.p);
2202 else assume(strat->sevS[i] == pGetShortExpVector(h.p));
2203 h.length = pLength(h.p);
2204 h.sev = strat->sevS[i];
2205 h.SetpFDeg();
2206 enterT(&h,strat);
2207 }
2208#ifdef KDEBUG
2209// kDebugPrint(strat);
2210#endif
2211 /*- compute------------------------------------------- -*/
2212 p = pCopy(q);
2213 deleteHC(&p,&o,&j,strat);
2214 kTest(strat);
2215 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
2216 if (BVERBOSE(23)) kDebugPrint(strat);
2218 {
2220 }
2221 else
2222 {
2224 }
2225 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
2226 {
2227 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
2228 p = redtail(p,strat->sl,strat);
2229 }
2230 /*- release temp data------------------------------- -*/
2231 cleanT(strat);
2232 assume(strat->L==NULL); /*strat->L unused */
2233 assume(strat->B==NULL); /*strat->B unused */
2234 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
2235 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
2236 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
2237 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
2238 omFree(strat->sevT);
2239 omFree(strat->S_2_R);
2240 omFree(strat->R);
2241
2242 omfree((ADDRESS)strat->fromQ);
2243 strat->fromQ=NULL;
2244 if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
2245// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
2246// {
2247// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
2248// if (ecartWeights)
2249// {
2250// omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short));
2251// ecartWeights=NULL;
2252// }
2253// }
2254 idDelete(&strat->Shdl);
2256 if (TEST_OPT_PROT) PrintLn();
2257 return p;
2258}
2259
2261{
2262 assume(!idIs0(q));
2263 assume(!(idIs0(F)&&(Q==NULL)));
2264
2265// lazy_reduce flags: can be combined by |
2266//#define KSTD_NF_LAZY 1
2267 // do only a reduction of the leading term
2268//#define KSTD_NF_ECART 2
2269 // only local: reduce even with bad ecart
2270 poly p;
2271 int i;
2272 int j;
2273 int o;
2274 LObject h;
2275 ideal res;
2276 BITSET save1;
2278
2279 //if (idIs0(q)) return idInit(IDELEMS(q),si_max(q->rank,F->rank));
2280 //if ((idIs0(F))&&(Q==NULL))
2281 // return idCopy(q); /*F=0*/
2282 //strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(q));
2283 /*- creating temp data structures------------------- -*/
2284 strat->kAllAxis = (currRing->ppNoether) != NULL;
2285 strat->kNoether=pCopy((currRing->ppNoether));
2288 && (0<Kstd1_deg)
2289 && ((strat->kNoether==NULL)
2291 {
2292 pLmDelete(&strat->kNoether);
2293 strat->kNoether=pOne();
2294 pSetExp(strat->kNoether,1, Kstd1_deg+1);
2295 pSetm(strat->kNoether);
2296 //strat->kAllAxis=TRUE;
2297 }
2298 initBuchMoraCrit(strat);
2300 initBuchMoraPosRing(strat);
2301 else
2302 initBuchMoraPos(strat);
2303 initMora(F,strat);
2304 strat->enterS = enterSMoraNF;
2305 /*- set T -*/
2306 strat->tl = -1;
2307 strat->tmax = setmaxT;
2308 strat->T = initT();
2309 strat->R = initR();
2310 strat->sevT = initsevT();
2311 /*- set S -*/
2312 strat->sl = -1;
2313 /*- init local data struct.-------------------------- -*/
2314 /*Shdl=*/initS(F,Q,strat);
2315 if ((strat->ak!=0)
2316 && (strat->kNoether!=NULL))
2317 {
2318 if (strat->ak!=1)
2319 {
2320 pSetComp(strat->kNoether,1);
2321 pSetmComp(strat->kNoether);
2322 poly p=pHead(strat->kNoether);
2323 pSetComp(p,strat->ak);
2324 pSetmComp(p);
2325 p=pAdd(strat->kNoether,p);
2326 strat->kNoether=pNext(p);
2328 }
2329 }
2330 if (((lazyReduce & KSTD_NF_LAZY)==0)
2331 && (!rField_is_Ring(currRing)))
2332 {
2333 for (i=strat->sl; i>=0; i--)
2334 pNorm(strat->S[i]);
2335 }
2336 /*- compute------------------------------------------- -*/
2337 res=idInit(IDELEMS(q),strat->ak);
2338 for (i=0; i<IDELEMS(q); i++)
2339 {
2340 if (q->m[i]!=NULL)
2341 {
2342 p = pCopy(q->m[i]);
2343 deleteHC(&p,&o,&j,strat);
2344 if (p!=NULL)
2345 {
2346 /*- puts the elements of S also to T -*/
2347 for (j=0; j<=strat->sl; j++)
2348 {
2349 h.p = strat->S[j];
2350 h.ecart = strat->ecartS[j];
2351 h.pLength = h.length = pLength(h.p);
2352 if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p);
2353 else assume(strat->sevS[j] == pGetShortExpVector(h.p));
2354 h.sev = strat->sevS[j];
2355 h.SetpFDeg();
2357 enterT_strong(&h,strat);
2358 else
2359 enterT(&h,strat);
2360 }
2361 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
2363 {
2364 p = redMoraNFRing(p,strat, lazyReduce);
2365 }
2366 else
2367 p = redMoraNF(p,strat, lazyReduce);
2368 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
2369 {
2370 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
2371 p = redtail(p,strat->sl,strat);
2372 }
2373 cleanT(strat);
2374 }
2375 res->m[i]=p;
2376 }
2377 //else
2378 // res->m[i]=NULL;
2379 }
2380 /*- release temp data------------------------------- -*/
2381 assume(strat->L==NULL); /*strat->L unused */
2382 assume(strat->B==NULL); /*strat->B unused */
2383 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
2384 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
2385 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
2386 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
2387 omFree(strat->sevT);
2388 omFree(strat->S_2_R);
2389 omFree(strat->R);
2390 omfree((ADDRESS)strat->fromQ);
2391 strat->fromQ=NULL;
2392 if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
2393// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
2394// {
2395// pFDeg=strat->pOrigFDeg;
2396// pLDeg=strat->pOrigLDeg;
2397// if (ecartWeights)
2398// {
2399// omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short));
2400// ecartWeights=NULL;
2401// }
2402// }
2403 idDelete(&strat->Shdl);
2405 if (TEST_OPT_PROT) PrintLn();
2406 return res;
2407}
2408
2410
2411long kModDeg(poly p,const ring r)
2412{
2413 long o=p_WDegree(p, r);
2414 long i=__p_GetComp(p, r);
2415 if (i==0) return o;
2416 //assume((i>0) && (i<=kModW->length()));
2417 if (i<=kModW->length())
2418 return o+(*kModW)[i-1];
2419 return o;
2420}
2421long kHomModDeg(poly p,const ring r)
2422{
2423 int i;
2424 long j=0;
2425
2426 for (i=r->N;i>0;i--)
2427 j+=p_GetExp(p,i,r)*(*kHomW)[i-1];
2428 if (kModW == NULL) return j;
2429 i = __p_GetComp(p,r);
2430 if (i==0) return j;
2431 return j+(*kModW)[i-1];
2432}
2433
2435 int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
2436{
2437 assume(!idIs0(F));
2438 assume((Q==NULL)||(!idIs0(Q)));
2439
2440 kStrategy strat=new skStrategy;
2441
2442 ideal r;
2443 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2445
2446 strat->s_poly=sp;
2448 strat->syzComp = syzComp;
2449 if (TEST_OPT_SB_1
2451 )
2452 strat->newIdeal = newIdeal;
2454 strat->LazyPass=20;
2455 else
2456 strat->LazyPass=2;
2457 strat->LazyDegree = 1;
2458 strat->ak = 0;
2459 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2460 strat->kModW=kModW=NULL;
2461 strat->kHomW=kHomW=NULL;
2462 if (vw != NULL)
2463 {
2464 currRing->pLexOrder=FALSE;
2465 strat->kHomW=kHomW=vw;
2466 strat->pOrigFDeg = currRing->pFDeg;
2467 strat->pOrigLDeg = currRing->pLDeg;
2469 toReset = TRUE;
2470 }
2471 if (h==testHomog)
2472 {
2473 if (strat->ak == 0)
2474 {
2475 h = (tHomog)idHomIdeal(F,Q);
2476 w=NULL;
2477 }
2478 else if (!TEST_OPT_DEGBOUND)
2479 {
2480 if (w!=NULL)
2481 h = (tHomog)idHomModule(F,Q,w);
2482 else
2483 h = (tHomog)idHomIdeal(F,Q);
2484 }
2485 }
2486 currRing->pLexOrder=b;
2487 if (h==isHomog)
2488 {
2489 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
2490 {
2491 strat->kModW = kModW = *w;
2492 if (vw == NULL)
2493 {
2494 strat->pOrigFDeg = currRing->pFDeg;
2495 strat->pOrigLDeg = currRing->pLDeg;
2497 toReset = TRUE;
2498 }
2499 }
2500 currRing->pLexOrder = TRUE;
2501 if (hilb==NULL) strat->LazyPass*=2;
2502 }
2503 strat->homog=h;
2504#ifdef KDEBUG
2505 idTest(F);
2506 if (Q!=NULL) idTest(Q);
2507#endif
2508#ifdef HAVE_PLURAL
2510 {
2511 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
2512 strat->no_prod_crit = ! bIsSCA;
2513 if (w!=NULL)
2514 r = nc_GB(F, Q, *w, hilb, strat, currRing);
2515 else
2516 r = nc_GB(F, Q, NULL, hilb, strat, currRing);
2517 }
2518 else
2519#endif
2520 {
2521 #if PRE_INTEGER_CHECK
2522 //the preinteger check strategy is not for modules
2523 if(nCoeff_is_Z(currRing->cf) && strat->ak <= 0)
2524 {
2525 ideal FCopy = idCopy(F);
2526 poly pFmon = preIntegerCheck(FCopy, Q);
2527 if(pFmon != NULL)
2528 {
2530 strat->kModW=kModW=NULL;
2531 if (h==testHomog)
2532 {
2534 w=NULL;
2535 }
2536 currRing->pLexOrder=b;
2537 if (h==isHomog)
2538 {
2539 if ((w!=NULL) && (*w!=NULL))
2540 {
2541 strat->kModW = kModW = *w;
2542 if (vw == NULL)
2543 {
2544 strat->pOrigFDeg = currRing->pFDeg;
2545 strat->pOrigLDeg = currRing->pLDeg;
2547 toReset = TRUE;
2548 }
2549 }
2550 currRing->pLexOrder = TRUE;
2551 if (hilb==NULL) strat->LazyPass*=2;
2552 }
2553 strat->homog=h;
2554 }
2555 omTestMemory(1);
2556 if(w == NULL)
2557 {
2559 r=mora(FCopy,Q,NULL,hilb,strat);
2560 else
2561 r=bba(FCopy,Q,NULL,hilb,strat);
2562 }
2563 else
2564 {
2566 r=mora(FCopy,Q,*w,hilb,strat);
2567 else
2568 r=bba(FCopy,Q,*w,hilb,strat);
2569 }
2570 idDelete(&FCopy);
2571 }
2572 else
2573 #endif
2574 {
2575 if(w==NULL)
2576 {
2578 r=mora(F,Q,NULL,hilb,strat);
2579 else
2580 r=bba(F,Q,NULL,hilb,strat);
2581 }
2582 else
2583 {
2585 r=mora(F,Q,*w,hilb,strat);
2586 else
2587 r=bba(F,Q,*w,hilb,strat);
2588 }
2589 }
2590 }
2591 if(errorreported) return NULL;
2592#ifdef KDEBUG
2593 idTest(r);
2594#endif
2595 if (toReset)
2596 {
2597 kModW = NULL;
2599 }
2600 currRing->pLexOrder = b;
2601//Print("%d reductions canceled \n",strat->cel);
2602 delete(strat);
2603 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2604 return r;
2605}
2606
2608 int newIdeal, intvec *vw, s_poly_proc_t sp)
2609{
2610 if(idIs0(F))
2611 return idInit(1,F->rank);
2612
2613 if(idIs0(Q)) Q=NULL;
2614#ifdef HAVE_SHIFTBBA
2615 if(rIsLPRing(currRing)) return kStdShift(F, Q, h, w, hilb, syzComp, newIdeal, vw, FALSE);
2616#endif
2617
2618 if ((hilb==NULL)
2619 && (vw==NULL)
2620 && (newIdeal==0)
2621 && (sp==NULL)
2622 && (IDELEMS(F)>1)
2623 && (!TEST_OPT_SB_1)
2624 && (currRing->ppNoether==NULL)
2625 && !rIsPluralRing(currRing) /*!rIsLPRing already tested above*/
2626 && (!id_IsModule(F,currRing)))
2627 {
2628 /* test HC precomputation*/
2632 && (!idIsMonomial(F)))
2633 {
2634 currRing->ppNoether=kTryHC(F,Q);
2635 ideal res=kStd_internal(F,Q,h,w,hilb,syzComp,newIdeal,vw,sp);
2636 if (currRing->ppNoether!=NULL) pLmDelete(currRing->ppNoether);
2637 currRing->ppNoether=NULL;
2638 return res;
2639 }
2640 /* test hilbstd */
2642 && (!TEST_OPT_RETURN_SB)
2643 && (!TEST_OPT_DEGBOUND)
2644 && (currRing->LexOrder
2646 && (!idIsMonomial(F)))
2647 {
2649 //ideal result=kTryHilbstd_par(F,Q,h,w);
2650 if (result!=NULL)
2651 {
2652 return result;
2653 }
2654 }
2655 }
2656 return kStd_internal(F,Q,h,w,hilb,syzComp,newIdeal,vw,sp);
2657}
2658
2660 int newIdeal, intvec *vw, s_poly_proc_t sp)
2661{
2663 ideal res=kStd2(F,Q,h,w,hh,syzComp,newIdeal,vw,sp);
2664 if (hh!=NULL) delete hh;
2665 return res;
2666}
2667
2668ideal kSba(ideal F, ideal Q, tHomog h,intvec ** w, int sbaOrder, int arri, bigintmat *hilb,int syzComp,
2669 int newIdeal, intvec *vw)
2670{
2671 if(idIs0(F))
2672 return idInit(1,F->rank);
2674 {
2675 ideal r;
2676 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2678 kStrategy strat=new skStrategy;
2679 strat->sbaOrder = sbaOrder;
2680 if (arri!=0)
2681 {
2682 strat->rewCrit1 = arriRewDummy;
2683 strat->rewCrit2 = arriRewCriterion;
2685 }
2686 else
2687 {
2691 }
2692
2694 strat->syzComp = syzComp;
2695 if (TEST_OPT_SB_1)
2696 //if(!rField_is_Ring(currRing)) // always true here
2697 strat->newIdeal = newIdeal;
2699 strat->LazyPass=20;
2700 else
2701 strat->LazyPass=2;
2702 strat->LazyDegree = 1;
2706 strat->ak = 0;
2707 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2708 strat->kModW=kModW=NULL;
2709 strat->kHomW=kHomW=NULL;
2710 if (vw != NULL)
2711 {
2712 currRing->pLexOrder=FALSE;
2713 strat->kHomW=kHomW=vw;
2714 strat->pOrigFDeg = currRing->pFDeg;
2715 strat->pOrigLDeg = currRing->pLDeg;
2717 toReset = TRUE;
2718 }
2719 if (h==testHomog)
2720 {
2721 if (strat->ak == 0)
2722 {
2723 h = (tHomog)idHomIdeal(F,Q);
2724 w=NULL;
2725 }
2726 else if (!TEST_OPT_DEGBOUND)
2727 {
2728 if (w!=NULL)
2729 h = (tHomog)idHomModule(F,Q,w);
2730 else
2731 h = (tHomog)idHomIdeal(F,Q);
2732 }
2733 }
2734 currRing->pLexOrder=b;
2735 if (h==isHomog)
2736 {
2737 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
2738 {
2739 strat->kModW = kModW = *w;
2740 if (vw == NULL)
2741 {
2742 strat->pOrigFDeg = currRing->pFDeg;
2743 strat->pOrigLDeg = currRing->pLDeg;
2745 toReset = TRUE;
2746 }
2747 }
2748 currRing->pLexOrder = TRUE;
2749 if (hilb==NULL) strat->LazyPass*=2;
2750 }
2751 strat->homog=h;
2752 #ifdef KDEBUG
2753 idTest(F);
2754 if(Q != NULL)
2755 idTest(Q);
2756 #endif
2757 #ifdef HAVE_PLURAL
2759 {
2760 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
2761 strat->no_prod_crit = ! bIsSCA;
2762 if (w!=NULL)
2763 r = nc_GB(F, Q, *w, hilb, strat, currRing);
2764 else
2765 r = nc_GB(F, Q, NULL, hilb, strat, currRing);
2766 }
2767 else
2768 #endif
2769 {
2771 {
2772 if (w!=NULL)
2773 r=mora(F,Q,*w,hilb,strat);
2774 else
2775 r=mora(F,Q,NULL,hilb,strat);
2776 }
2777 else
2778 {
2779 strat->sigdrop = FALSE;
2780 if (w!=NULL)
2781 r=sba(F,Q,*w,hilb,strat);
2782 else
2783 r=sba(F,Q,NULL,hilb,strat);
2784 }
2785 }
2786 #ifdef KDEBUG
2787 idTest(r);
2788 #endif
2789 if (toReset)
2790 {
2791 kModW = NULL;
2793 }
2794 currRing->pLexOrder = b;
2795 //Print("%d reductions canceled \n",strat->cel);
2796 //delete(strat);
2797 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2798 return r;
2799 }
2800 else
2801 {
2802 //--------------------------RING CASE-------------------------
2803 assume(sbaOrder == 1);
2804 assume(arri == 0);
2805 ideal r;
2806 r = idCopy(F);
2807 int sbaEnterS = -1;
2808 bool sigdrop = TRUE;
2809 //This is how we set the SBA algorithm;
2810 int totalsbaruns = 1,blockedreductions = 20,blockred = 0,loops = 0;
2811 while(sigdrop && (loops < totalsbaruns || totalsbaruns == -1)
2812 && (blockred <= blockedreductions))
2813 {
2814 loops++;
2815 if(loops == 1)
2816 sigdrop = FALSE;
2817 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2819 kStrategy strat=new skStrategy;
2820 strat->sbaEnterS = sbaEnterS;
2821 strat->sigdrop = sigdrop;
2822 #if 0
2823 strat->blockred = blockred;
2824 #else
2825 strat->blockred = 0;
2826 #endif
2828 //printf("\nsbaEnterS beginning = %i\n",strat->sbaEnterS);
2829 //printf("\nsigdrop beginning = %i\n",strat->sigdrop);
2830 strat->sbaOrder = sbaOrder;
2831 if (arri!=0)
2832 {
2833 strat->rewCrit1 = arriRewDummy;
2834 strat->rewCrit2 = arriRewCriterion;
2836 }
2837 else
2838 {
2842 }
2843
2845 strat->syzComp = syzComp;
2846 if (TEST_OPT_SB_1)
2848 strat->newIdeal = newIdeal;
2850 strat->LazyPass=20;
2851 else
2852 strat->LazyPass=2;
2853 strat->LazyDegree = 1;
2857 strat->ak = 0;
2858 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2859 strat->kModW=kModW=NULL;
2860 strat->kHomW=kHomW=NULL;
2861 if (vw != NULL)
2862 {
2863 currRing->pLexOrder=FALSE;
2864 strat->kHomW=kHomW=vw;
2865 strat->pOrigFDeg = currRing->pFDeg;
2866 strat->pOrigLDeg = currRing->pLDeg;
2868 toReset = TRUE;
2869 }
2870 if (h==testHomog)
2871 {
2872 if (strat->ak == 0)
2873 {
2874 h = (tHomog)idHomIdeal(F,Q);
2875 w=NULL;
2876 }
2877 else if (!TEST_OPT_DEGBOUND)
2878 {
2879 if (w!=NULL)
2880 h = (tHomog)idHomModule(F,Q,w);
2881 else
2882 h = (tHomog)idHomIdeal(F,Q);
2883 }
2884 }
2885 currRing->pLexOrder=b;
2886 if (h==isHomog)
2887 {
2888 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
2889 {
2890 strat->kModW = kModW = *w;
2891 if (vw == NULL)
2892 {
2893 strat->pOrigFDeg = currRing->pFDeg;
2894 strat->pOrigLDeg = currRing->pLDeg;
2896 toReset = TRUE;
2897 }
2898 }
2899 currRing->pLexOrder = TRUE;
2900 if (hilb==NULL) strat->LazyPass*=2;
2901 }
2902 strat->homog=h;
2903 #ifdef KDEBUG
2904 idTest(F);
2905 if(Q != NULL)
2906 idTest(Q);
2907 #endif
2908 #ifdef HAVE_PLURAL
2910 {
2911 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
2912 strat->no_prod_crit = ! bIsSCA;
2913 if (w!=NULL)
2914 r = nc_GB(F, Q, *w, hilb, strat, currRing);
2915 else
2916 r = nc_GB(F, Q, NULL, hilb, strat, currRing);
2917 }
2918 else
2919 #endif
2920 {
2922 {
2923 if (w!=NULL)
2924 r=mora(F,Q,*w,hilb,strat);
2925 else
2926 r=mora(F,Q,NULL,hilb,strat);
2927 }
2928 else
2929 {
2930 if (w!=NULL)
2931 r=sba(r,Q,*w,hilb,strat);
2932 else
2933 {
2934 r=sba(r,Q,NULL,hilb,strat);
2935 }
2936 }
2937 }
2938 #ifdef KDEBUG
2939 idTest(r);
2940 #endif
2941 if (toReset)
2942 {
2943 kModW = NULL;
2945 }
2946 currRing->pLexOrder = b;
2947 //Print("%d reductions canceled \n",strat->cel);
2948 sigdrop = strat->sigdrop;
2949 sbaEnterS = strat->sbaEnterS;
2950 blockred = strat->blockred;
2951 delete(strat);
2952 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2953 }
2954 // Go to std
2955 if(sigdrop || blockred > blockedreductions)
2956 {
2957 r = kStd2(r, Q, h, w, hilb, syzComp, newIdeal, vw);
2958 }
2959 return r;
2960 }
2961}
2962
2963#ifdef HAVE_SHIFTBBA
2965 int newIdeal, intvec *vw, BOOLEAN rightGB)
2966{
2968 assume(idIsInV(F));
2970 {
2971 /* error: no local ord yet with shifts */
2972 WerrorS("No local ordering possible for shift algebra");
2973 return(NULL);
2974 }
2975 ideal r;
2976 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2978 kStrategy strat=new skStrategy;
2979
2980 strat->rightGB = rightGB;
2981
2983 strat->syzComp = syzComp;
2984 if (TEST_OPT_SB_1)
2986 strat->newIdeal = newIdeal;
2988 strat->LazyPass=20;
2989 else
2990 strat->LazyPass=2;
2991 strat->LazyDegree = 1;
2992 strat->ak = 0;
2993 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2994 strat->kModW=kModW=NULL;
2995 strat->kHomW=kHomW=NULL;
2996 if (vw != NULL)
2997 {
2998 currRing->pLexOrder=FALSE;
2999 strat->kHomW=kHomW=vw;
3000 strat->pOrigFDeg = currRing->pFDeg;
3001 strat->pOrigLDeg = currRing->pLDeg;
3003 toReset = TRUE;
3004 }
3005 if (h==testHomog)
3006 {
3007 if (strat->ak == 0)
3008 {
3009 h = (tHomog)idHomIdeal(F,Q);
3010 w=NULL;
3011 }
3012 else if (!TEST_OPT_DEGBOUND)
3013 {
3014 if (w!=NULL)
3015 h = (tHomog)idHomModule(F,Q,w);
3016 else
3017 h = (tHomog)idHomIdeal(F,Q);
3018 }
3019 }
3020 currRing->pLexOrder=b;
3021 if (h==isHomog)
3022 {
3023 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
3024 {
3025 strat->kModW = kModW = *w;
3026 if (vw == NULL)
3027 {
3028 strat->pOrigFDeg = currRing->pFDeg;
3029 strat->pOrigLDeg = currRing->pLDeg;
3031 toReset = TRUE;
3032 }
3033 }
3034 currRing->pLexOrder = TRUE;
3035 if (hilb==NULL) strat->LazyPass*=2;
3036 }
3037 strat->homog=h;
3038#ifdef KDEBUG
3039 idTest(F);
3040#endif
3041 /* global ordering */
3042 if (w!=NULL)
3043 r=bbaShift(F,Q,*w,hilb,strat);
3044 else
3045 r=bbaShift(F,Q,NULL,hilb,strat);
3046#ifdef KDEBUG
3047 idTest(r);
3048#endif
3049 if (toReset)
3050 {
3051 kModW = NULL;
3053 }
3054 currRing->pLexOrder = b;
3055//Print("%d reductions canceled \n",strat->cel);
3056 delete(strat);
3057 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
3058 assume(idIsInV(r));
3059 return r;
3060}
3061#endif
3062
3063//##############################################################
3064//##############################################################
3065//##############################################################
3066//##############################################################
3067//##############################################################
3068
3070 int syzComp, int reduced)
3071{
3072 if(idIs0(F))
3073 {
3074 M=idInit(1,F->rank);
3075 return idInit(1,F->rank);
3076 }
3078 {
3079 ideal sb;
3080 sb = kStd2(F, Q, h, w, hilb);
3082 if(IDELEMS(sb) <= IDELEMS(F))
3083 {
3084 M = idCopy(sb);
3085 idSkipZeroes(M);
3086 return(sb);
3087 }
3088 else
3089 {
3090 M = idCopy(F);
3091 idSkipZeroes(M);
3092 return(sb);
3093 }
3094 }
3095 ideal r=NULL;
3096 int Kstd1_OldDeg = Kstd1_deg,i;
3098 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
3101 kStrategy strat=new skStrategy;
3102
3104 strat->syzComp = syzComp;
3106 strat->LazyPass=20;
3107 else
3108 strat->LazyPass=2;
3109 strat->LazyDegree = 1;
3110 strat->minim=(reduced % 2)+1;
3111 strat->ak = 0;
3112 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
3113 if (delete_w)
3114 {
3115 temp_w=new intvec((strat->ak)+1);
3116 w = &temp_w;
3117 }
3118 if (h==testHomog)
3119 {
3120 if (strat->ak == 0)
3121 {
3122 h = (tHomog)idHomIdeal(F,Q);
3123 w=NULL;
3124 }
3125 else
3126 {
3127 h = (tHomog)idHomModule(F,Q,w);
3128 }
3129 }
3130 if (h==isHomog)
3131 {
3132 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
3133 {
3134 kModW = *w;
3135 strat->kModW = *w;
3136 assume(currRing->pFDeg != NULL && currRing->pLDeg != NULL);
3137 strat->pOrigFDeg = currRing->pFDeg;
3138 strat->pOrigLDeg = currRing->pLDeg;
3140
3141 toReset = TRUE;
3142 if (reduced>1)
3143 {
3145 Kstd1_deg = -1;
3146 for (i=IDELEMS(F)-1;i>=0;i--)
3147 {
3148 if ((F->m[i]!=NULL) && (currRing->pFDeg(F->m[i],currRing)>=Kstd1_deg))
3149 Kstd1_deg = currRing->pFDeg(F->m[i],currRing)+1;
3150 }
3151 }
3152 }
3153 currRing->pLexOrder = TRUE;
3154 strat->LazyPass*=2;
3155 }
3156 strat->homog=h;
3157 ideal SB=NULL;
3159 {
3160 r=idMinBase(F,&SB); // SB and M via minbase
3161 strat->M=r;
3162 r=SB;
3163 }
3164 else
3165 {
3166 if (w!=NULL)
3167 r=bba(F,Q,*w,hilb,strat);
3168 else
3169 r=bba(F,Q,NULL,hilb,strat);
3170 }
3171#ifdef KDEBUG
3172 {
3173 int i;
3174 for (i=IDELEMS(r)-1; i>=0; i--) pTest(r->m[i]);
3175 }
3176#endif
3177 idSkipZeroes(r);
3178 if (toReset)
3179 {
3181 kModW = NULL;
3182 }
3183 currRing->pLexOrder = b;
3184 if ((delete_w)&&(temp_w!=NULL)) delete temp_w;
3185 if ((IDELEMS(r)==1) && (r->m[0]!=NULL) && pIsConstant(r->m[0]) && (strat->ak==0))
3186 {
3187 M=idInit(1,F->rank);
3188 M->m[0]=pOne();
3189 //if (strat->ak!=0) { pSetComp(M->m[0],strat->ak); pSetmComp(M->m[0]); }
3190 if (strat->M!=NULL) idDelete(&strat->M);
3191 }
3192 else if (strat->M==NULL)
3193 {
3194 M=idInit(1,F->rank);
3195 WarnS("no minimal generating set computed");
3196 }
3197 else
3198 {
3199 idSkipZeroes(strat->M);
3200 M=strat->M;
3201 strat->M=NULL;
3202 }
3203 delete(strat);
3204 if (reduced>2)
3205 {
3207 if (!oldDegBound)
3208 si_opt_1 &= ~Sy_bit(OPT_DEGBOUND);
3209 }
3210 else
3211 {
3212 if (IDELEMS(M)>IDELEMS(r))
3213 {
3214 idDelete(&M);
3215 M=idCopy(r);
3216 }
3217 }
3218 return r;
3219}
3220
3222 int syzComp, int reduced)
3223{
3225 ideal res=kMin_std2(F,Q,h,w,M,hh,syzComp,reduced);
3226 if (hh!=NULL) delete hh;
3227 return res;
3228}
3229poly kNF(ideal F, ideal Q, poly p,int syzComp, int lazyReduce)
3230{
3231 if (p==NULL)
3232 return NULL;
3233
3234 poly pp = p;
3235
3236#ifdef HAVE_PLURAL
3237 if(rIsSCA(currRing))
3238 {
3239 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3240 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3242
3243 if(Q == currRing->qideal)
3245 }
3246#endif
3247 if(idIs0(Q)) Q=NULL;
3248
3249 if ((idIs0(F))&&(Q==NULL))
3250 {
3251#ifdef HAVE_PLURAL
3252 if(p != pp)
3253 return pp;
3254#endif
3255 return pCopy(p); /*F+Q=0*/
3256 }
3257
3258 kStrategy strat=new skStrategy;
3259 strat->syzComp = syzComp;
3261 poly res;
3262
3264 {
3265#ifdef HAVE_SHIFTBBA
3266 if (currRing->isLPring)
3267 {
3268 WerrorS("No local ordering possible for shift algebra");
3269 return(NULL);
3270 }
3271#endif
3272 res=kNF1(F,Q,pp,strat,lazyReduce);
3273 }
3274 else
3275 res=kNF2(F,Q,pp,strat,lazyReduce);
3276 delete(strat);
3277
3278#ifdef HAVE_PLURAL
3279 if(pp != p)
3280 p_Delete(&pp, currRing);
3281#endif
3282 return res;
3283}
3284
3285poly kNFBound(ideal F, ideal Q, poly p,int bound,int syzComp, int lazyReduce)
3286{
3287 if (p==NULL)
3288 return NULL;
3289
3290 poly pp = p;
3291
3292#ifdef HAVE_PLURAL
3293 if(rIsSCA(currRing))
3294 {
3295 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3296 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3298
3299 if(Q == currRing->qideal)
3301 }
3302#endif
3303
3304 if ((idIs0(F))&&(Q==NULL))
3305 {
3306#ifdef HAVE_PLURAL
3307 if(p != pp)
3308 return pp;
3309#endif
3310 return pCopy(p); /*F+Q=0*/
3311 }
3312
3313 kStrategy strat=new skStrategy;
3314 strat->syzComp = syzComp;
3316 poly res;
3317 res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
3318 delete(strat);
3319
3320#ifdef HAVE_PLURAL
3321 if(pp != p)
3322 p_Delete(&pp, currRing);
3323#endif
3324 return res;
3325}
3326
3327ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce)
3328{
3329 ideal res;
3330 if (TEST_OPT_PROT)
3331 {
3332 Print("(S:%d)",IDELEMS(p));mflush();
3333 }
3334 if (idIs0(p))
3335 return idInit(IDELEMS(p),si_max(p->rank,F->rank));
3336
3337 ideal pp = p;
3338#ifdef HAVE_PLURAL
3339 if(rIsSCA(currRing))
3340 {
3341 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3342 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3344
3345 if(Q == currRing->qideal)
3347 }
3348#endif
3349
3350 if (idIs0(Q)) Q=NULL;
3351
3352 if ((idIs0(F))&&(Q==NULL))
3353 {
3354#ifdef HAVE_PLURAL
3355 if(p != pp)
3356 return pp;
3357#endif
3358 return idCopy(p); /*F+Q=0*/
3359 }
3360
3361 kStrategy strat=new skStrategy;
3362 strat->syzComp = syzComp;
3364 if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
3365 {
3366 strat->ak = si_max(strat->ak,(int)F->rank);
3367 }
3368
3370 {
3371#ifdef HAVE_SHIFTBBA
3372 if (currRing->isLPring)
3373 {
3374 WerrorS("No local ordering possible for shift algebra");
3375 return(NULL);
3376 }
3377#endif
3378 res=kNF1(F,Q,pp,strat,lazyReduce);
3379 }
3380 else
3381 res=kNF2(F,Q,pp,strat,lazyReduce);
3382 delete(strat);
3383
3384#ifdef HAVE_PLURAL
3385 if(pp != p)
3387#endif
3388
3389 return res;
3390}
3391
3393{
3394 ideal res;
3395 if (TEST_OPT_PROT)
3396 {
3397 Print("(S:%d)",IDELEMS(p));mflush();
3398 }
3399 if (idIs0(p))
3400 return idInit(IDELEMS(p),si_max(p->rank,F->rank));
3401
3402 ideal pp = p;
3403#ifdef HAVE_PLURAL
3404 if(rIsSCA(currRing))
3405 {
3406 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3407 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3409
3410 if(Q == currRing->qideal)
3412 }
3413#endif
3414
3415 if ((idIs0(F))&&(Q==NULL))
3416 {
3417#ifdef HAVE_PLURAL
3418 if(p != pp)
3419 return pp;
3420#endif
3421 return idCopy(p); /*F+Q=0*/
3422 }
3423
3424 kStrategy strat=new skStrategy;
3425 strat->syzComp = syzComp;
3427 if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
3428 {
3429 strat->ak = si_max(strat->ak,(int)F->rank);
3430 }
3431
3432 res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
3433 delete(strat);
3434
3435#ifdef HAVE_PLURAL
3436 if(pp != p)
3438#endif
3439
3440 return res;
3441}
3442
3443poly k_NF (ideal F, ideal Q, poly p,int syzComp, int lazyReduce, const ring _currRing)
3444{
3445 const ring save = currRing;
3447 poly ret = kNF(F, Q, p, syzComp, lazyReduce);
3449 return ret;
3450}
3451
3452/*2
3453*interreduces F
3454*/
3455// old version
3457{
3458 int j;
3459 kStrategy strat = new skStrategy;
3460
3461 ideal tempF = F;
3462 ideal tempQ = Q;
3463
3464#ifdef HAVE_PLURAL
3465 if(rIsSCA(currRing))
3466 {
3467 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3468 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3470
3471 // this should be done on the upper level!!! :
3472 // tempQ = SCAQuotient(currRing);
3473
3474 if(Q == currRing->qideal)
3476 }
3477#endif
3478
3479// if (TEST_OPT_PROT)
3480// {
3481// writeTime("start InterRed:");
3482// mflush();
3483// }
3484 //strat->syzComp = 0;
3485 strat->kAllAxis = (currRing->ppNoether) != NULL;
3486 strat->kNoether=pCopy((currRing->ppNoether));
3487 strat->ak = 0;
3489 initBuchMoraCrit(strat);
3490 strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN));
3491 for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE;
3492 strat->enterS = enterSBba;
3493 strat->posInT = posInT17;
3494 strat->initEcart = initEcartNormal;
3495 strat->sl = -1;
3496 strat->tl = -1;
3497 strat->tmax = setmaxT;
3498 strat->T = initT();
3499 strat->R = initR();
3500 strat->sevT = initsevT();
3502 initS(tempF, tempQ, strat);
3503 if (TEST_OPT_REDSB)
3504 strat->noTailReduction=FALSE;
3505 updateS(TRUE,strat);
3507 completeReduce(strat);
3508 //else if (TEST_OPT_PROT) PrintLn();
3509 cleanT(strat);
3510 if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
3511 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
3512 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
3513 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
3514 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
3515 omfree(strat->sevT);
3516 omfree(strat->S_2_R);
3517 omfree(strat->R);
3518
3519 if (strat->fromQ)
3520 {
3521 for (j=IDELEMS(strat->Shdl)-1;j>=0;j--)
3522 {
3523 if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]);
3524 }
3525 omFree((ADDRESS)strat->fromQ);
3526 strat->fromQ=NULL;
3527 }
3528// if (TEST_OPT_PROT)
3529// {
3530// writeTime("end Interred:");
3531// mflush();
3532// }
3533 ideal shdl=strat->Shdl;
3535 if (strat->fromQ)
3536 {
3537 omfree(strat->fromQ);
3538 strat->fromQ=NULL;
3540 idDelete(&shdl);
3541 shdl=res;
3542 }
3543 delete(strat);
3544#ifdef HAVE_PLURAL
3545 if( tempF != F )
3547#endif
3548 return shdl;
3549}
3550// new version
3552{
3553 need_retry=0;
3554 int red_result = 1;
3555 int olddeg,reduc;
3556 // BOOLEAN withT = FALSE;
3557 // BOOLEAN toReset=FALSE;
3558 kStrategy strat=new skStrategy;
3559 tHomog h;
3560
3562 strat->LazyPass=20;
3563 else
3564 strat->LazyPass=2;
3565 strat->LazyDegree = 1;
3566 strat->ak = id_RankFreeModule(F,currRing);
3567 strat->syzComp = strat->ak;
3568 strat->kModW=kModW=NULL;
3569 strat->kHomW=kHomW=NULL;
3570 if (strat->ak == 0)
3571 {
3572 h = (tHomog)idHomIdeal(F,Q);
3573 }
3574 else if (!TEST_OPT_DEGBOUND)
3575 {
3576 h = (tHomog)idHomIdeal(F,Q);
3577 }
3578 else
3579 h = isNotHomog;
3580 if (h==isHomog)
3581 {
3582 strat->LazyPass*=2;
3583 }
3584 strat->homog=h;
3585#ifdef KDEBUG
3586 idTest(F);
3587#endif
3588
3589 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
3591 initBuchMoraPosRing(strat);
3592 else
3593 initBuchMoraPos(strat);
3594 initBba(strat);
3595 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
3596 strat->posInL=posInL0; /* ord according pComp */
3597
3598 /*Shdl=*/initBuchMora(F, Q, strat);
3599 reduc = olddeg = 0;
3600
3601#ifndef NO_BUCKETS
3603 strat->use_buckets = 1;
3604#endif
3605
3606 // redtailBBa against T for inhomogeneous input
3607 //if (!TEST_OPT_OLDSTD)
3608 // withT = ! strat->homog;
3609
3610 // strat->posInT = posInT_pLength;
3611 kTest_TS(strat);
3612
3613#ifdef HAVE_TAIL_RING
3615#endif
3616
3617 /* compute------------------------------------------------------- */
3618 while (strat->Ll >= 0)
3619 {
3620 #ifdef KDEBUG
3621 if (TEST_OPT_DEBUG) messageSets(strat);
3622 #endif
3623 if (strat->Ll== 0) strat->interpt=TRUE;
3624 /* picks the last element from the lazyset L */
3625 strat->P = strat->L[strat->Ll];
3626 strat->Ll--;
3627
3628 if (strat->P.p1 == NULL)
3629 {
3630 // for input polys, prepare reduction
3631 strat->P.PrepareRed(strat->use_buckets);
3632 }
3633
3634 if (strat->P.p == NULL && strat->P.t_p == NULL)
3635 {
3636 red_result = 0;
3637 }
3638 else
3639 {
3640 if (TEST_OPT_PROT)
3641 message(strat->P.pFDeg(),
3642 &olddeg,&reduc,strat, red_result);
3643
3644 /* reduction of the element chosen from L */
3645 red_result = strat->red(&strat->P,strat);
3646 }
3647
3648 // reduction to non-zero new poly
3649 if (red_result == 1)
3650 {
3651 /* statistic */
3652 if (TEST_OPT_PROT) PrintS("s");
3653
3654 // get the polynomial (canonicalize bucket, make sure P.p is set)
3655 strat->P.GetP(strat->lmBin);
3656
3657 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3658
3659 // reduce the tail and normalize poly
3660 // in the ring case we cannot expect LC(f) = 1,
3661 // therefore we call pCleardenom instead of pNorm
3663 {
3664 strat->P.pCleardenom();
3665 }
3666 else
3667 {
3668 strat->P.pNorm();
3669 }
3670
3671#ifdef KDEBUG
3672 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3673#endif
3674
3675 // enter into S, L, and T
3676 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3677 {
3678 enterT(&strat->P, strat);
3679 // posInS only depends on the leading term
3680 strat->enterS(&strat->P, pos, strat, strat->tl);
3681
3682 if (pos<strat->sl)
3683 {
3684 need_retry++;
3685 // move all "larger" elements fromS to L
3686 // remove them from T
3687 int ii=pos+1;
3688 for(;ii<=strat->sl;ii++)
3689 {
3690 LObject h;
3691 h.Clear();
3692 h.tailRing=strat->tailRing;
3693 h.p=strat->S[ii]; strat->S[ii]=NULL;
3694 strat->initEcart(&h);
3695 h.sev=strat->sevS[ii];
3696 int jj=strat->tl;
3697 while (jj>=0)
3698 {
3699 if (strat->T[jj].p==h.p)
3700 {
3701 strat->T[jj].p=NULL;
3702 if (jj<strat->tl)
3703 {
3704 memmove(&(strat->T[jj]),&(strat->T[jj+1]),
3705 (strat->tl-jj)*sizeof(strat->T[jj]));
3706 memmove(&(strat->sevT[jj]),&(strat->sevT[jj+1]),
3707 (strat->tl-jj)*sizeof(strat->sevT[jj]));
3708 }
3709 strat->tl--;
3710 break;
3711 }
3712 jj--;
3713 }
3714 int lpos=strat->posInL(strat->L,strat->Ll,&h,strat);
3715 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,lpos);
3716 #ifdef KDEBUG
3717 if (TEST_OPT_DEBUG)
3718 {
3719 Print("move S[%d] -> L[%d]: ",ii,pos);
3720 p_wrp(h.p,currRing, strat->tailRing);
3721 PrintLn();
3722 }
3723 #endif
3724 }
3725 if (strat->fromQ!=NULL)
3726 {
3727 for(ii=pos+1;ii<=strat->sl;ii++) strat->fromQ[ii]=0;
3728 }
3729 strat->sl=pos;
3730 }
3731 }
3732 else
3733 {
3734 // clean P
3735 }
3736 kDeleteLcm(&strat->P);
3737 }
3738
3739#ifdef KDEBUG
3740 if (TEST_OPT_DEBUG)
3741 {
3742 messageSets(strat);
3743 }
3744 strat->P.Clear();
3745#endif
3746 //kTest_TS(strat);: i_r out of sync in kInterRedBba, but not used!
3747 }
3748#ifdef KDEBUG
3749 //if (TEST_OPT_DEBUG) messageSets(strat);
3750#endif
3751 /* complete reduction of the standard basis--------- */
3752
3753 if((need_retry<=0) && (TEST_OPT_REDSB))
3754 {
3755 completeReduce(strat);
3756 if (strat->completeReduce_retry)
3757 {
3758 // completeReduce needed larger exponents, retry
3759 // hopefully: kStratChangeTailRing already provided a larger tailRing
3760 // (otherwise: it will fail again)
3762 completeReduce(strat);
3763 if (strat->completeReduce_retry)
3764 {
3765#ifdef HAVE_TAIL_RING
3766 if(currRing->bitmask>strat->tailRing->bitmask)
3767 {
3768 // retry without T
3770 cleanT(strat);strat->tailRing=currRing;
3771 int i;
3772 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3773 completeReduce(strat);
3774 }
3775 if (strat->completeReduce_retry)
3776#endif
3777 Werror("exponent bound is %ld",currRing->bitmask);
3778 }
3779 }
3780 }
3781 else if (TEST_OPT_PROT) PrintLn();
3782
3783
3784 /* release temp data-------------------------------- */
3785 exitBuchMora(strat);
3786// if (TEST_OPT_WEIGHTM)
3787// {
3788// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
3789// if (ecartWeights)
3790// {
3791// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
3792// ecartWeights=NULL;
3793// }
3794// }
3795 //if (TEST_OPT_PROT) messageStat(0/*hilbcount*/,strat);
3796 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3797 ideal res=strat->Shdl;
3798 strat->Shdl=NULL;
3799 delete strat;
3800 return res;
3801}
3803{
3804#ifdef HAVE_PLURAL
3805 if(rIsPluralRing(currRing)) return kInterRedOld(F,Q);
3806#endif
3809 )
3810 return kInterRedOld(F,Q);
3811
3812 //return kInterRedOld(F,Q);
3813
3814 BITSET save1;
3816 //si_opt_1|=Sy_bit(OPT_NOT_SUGAR);
3818 //si_opt_1&= ~Sy_bit(OPT_REDTAIL);
3819 //si_opt_1&= ~Sy_bit(OPT_REDSB);
3820 //extern char * showOption() ;
3821 //Print("%s\n",showOption());
3822
3823 int need_retry;
3824 int counter=3;
3825 ideal res, res1;
3826 int elems=0;
3827 ideal null=NULL;
3828 if ((Q==NULL) || (!TEST_OPT_REDSB))
3829 {
3830 elems=idElem(F);
3832 }
3833 else
3834 {
3835 ideal FF=idSimpleAdd(F,Q);
3837 idDelete(&FF);
3838 null=idInit(1,1);
3839 if (need_retry)
3841 else
3842 res1=kNF(null,Q,res);
3843 idDelete(&res);
3844 res=res1;
3845 need_retry=1;
3846 }
3847 if (idElem(res)<=1) need_retry=0;
3848 while (need_retry && (counter>0))
3849 {
3850 #ifdef KDEBUG
3851 if (TEST_OPT_DEBUG) { Print("retry counter %d\n",counter); }
3852 #endif
3854 int new_elems=idElem(res1);
3855 counter -= (new_elems >= elems);
3856 elems = new_elems;
3857 idDelete(&res);
3858 if (idElem(res1)<=1) need_retry=0;
3859 if ((Q!=NULL) && (TEST_OPT_REDSB))
3860 {
3861 if (need_retry)
3863 else
3864 res=kNF(null,Q,res1);
3865 idDelete(&res1);
3866 }
3867 else
3868 res = res1;
3869 if (idElem(res)<=1) need_retry=0;
3870 }
3871 if (null!=NULL) idDelete(&null);
3874 return res;
3875}
3876
3877// returns TRUE if mora should use buckets, false otherwise
3879{
3880#ifdef MORA_USE_BUCKETS
3882 return FALSE;
3883 if ((strat->red == redFirst)
3884 ||((strat->red == redEcart)&&(strat->kNoether!=NULL)))
3885 {
3886#ifdef NO_LDEG
3887 if (strat->syzComp==0)
3888 return TRUE;
3889#else
3890 if ((strat->homog || strat->honey) && (strat->syzComp==0))
3891 return TRUE;
3892#endif
3893 }
3894 else
3895 {
3896 assume(strat->red == redEcart || strat->red == redRiloc || strat->red == redRiloc_Z);
3897 if (strat->honey && (strat->syzComp==0))
3898 return TRUE;
3899 }
3900#endif
3901 return FALSE;
3902}
#define BITSET
Definition auxiliary.h:85
static int si_max(const int a, const int b)
Definition auxiliary.h:125
#define UNLIKELY(X)
Definition auxiliary.h:405
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
int p
Definition cfModGcd.cc:4086
CanonicalForm b
Definition cfModGcd.cc:4111
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
int length() const
Matrices of numbers.
Definition bigintmat.h:51
KINLINE poly kNoetherTail()
Definition kInline.h:66
intvec * kModW
Definition kutil.h:334
bool sigdrop
Definition kutil.h:357
int syzComp
Definition kutil.h:353
int * S_2_R
Definition kutil.h:341
ring tailRing
Definition kutil.h:342
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition kutil.h:290
char noTailReduction
Definition kutil.h:375
int currIdx
Definition kutil.h:316
char posInLOldFlag
Definition kutil.h:379
pFDegProc pOrigFDeg_TailRing
Definition kutil.h:297
int Ll
Definition kutil.h:350
TSet T
Definition kutil.h:325
BOOLEAN(* rewCrit1)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:292
omBin lmBin
Definition kutil.h:343
intset ecartS
Definition kutil.h:308
char honey
Definition kutil.h:374
char rightGB
Definition kutil.h:366
polyset S
Definition kutil.h:305
int minim
Definition kutil.h:356
poly kNoether
Definition kutil.h:328
BOOLEAN * NotUsedAxis
Definition kutil.h:331
LSet B
Definition kutil.h:327
int ak
Definition kutil.h:352
TObject ** R
Definition kutil.h:339
BOOLEAN(* rewCrit3)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:294
int lastAxis
Definition kutil.h:354
ideal M
Definition kutil.h:304
int tl
Definition kutil.h:349
int(* red2)(LObject *L, kStrategy strat)
Definition kutil.h:280
unsigned long * sevT
Definition kutil.h:324
intvec * kHomW
Definition kutil.h:335
poly tail
Definition kutil.h:333
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:283
int blockred
Definition kutil.h:362
ideal Shdl
Definition kutil.h:302
unsigned sbaOrder
Definition kutil.h:315
pFDegProc pOrigFDeg
Definition kutil.h:295
int blockredmax
Definition kutil.h:363
int tmax
Definition kutil.h:349
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:287
char LDegLast
Definition kutil.h:382
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition kutil.h:286
void(* enterS)(LObject *h, int pos, kStrategy strat, int atR)
Definition kutil.h:285
char kAllAxis
Definition kutil.h:373
intset fromQ
Definition kutil.h:320
char use_buckets
Definition kutil.h:380
char interpt
Definition kutil.h:368
int newIdeal
Definition kutil.h:355
char fromT
Definition kutil.h:376
char completeReduce_retry
Definition kutil.h:400
void(* initEcart)(TObject *L)
Definition kutil.h:281
LObject P
Definition kutil.h:301
char noClearS
Definition kutil.h:399
int Lmax
Definition kutil.h:350
char z2homog
Definition kutil.h:371
int LazyPass
Definition kutil.h:352
char no_prod_crit
Definition kutil.h:391
char overflow
Definition kutil.h:401
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:289
LSet L
Definition kutil.h:326
char length_pLength
Definition kutil.h:384
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:279
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:293
int sl
Definition kutil.h:347
int sbaEnterS
Definition kutil.h:360
int LazyDegree
Definition kutil.h:352
char posInLDependsOnLength
Definition kutil.h:386
unsigned long * sevS
Definition kutil.h:321
char homog
Definition kutil.h:369
pLDegProc pOrigLDeg
Definition kutil.h:296
char update
Definition kutil.h:378
s_poly_proc_t s_poly
Definition kutil.h:299
pLDegProc pOrigLDeg_TailRing
Definition kutil.h:298
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:811
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition coeffs.h:521
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition coeffs.h:684
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition coeffs.h:750
#define Print
Definition emacs.cc:80
#define WarnS
Definition emacs.cc:78
return result
CanonicalForm res
Definition facAbsFact.cc:60
const CanonicalForm & w
Definition facAbsFact.cc:51
CanonicalForm H
Definition facAbsFact.cc:60
int j
Definition facHensel.cc:110
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
#define VAR
Definition globaldefs.h:5
long scMult0Int(ideal S, ideal Q)
Definition hdegree.cc:924
STATIC_VAR poly last
Definition hdegree.cc:1138
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define idSimpleAdd(A, B)
Definition ideals.h:42
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
#define idTest(id)
Definition ideals.h:47
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
ideal idCopy(ideal A)
Definition ideals.h:60
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
bigintmat * iv2biv(intvec *hilb, const coeffs cf)
Definition intvec.cc:851
STATIC_VAR Poly * h
Definition janet.cc:971
KINLINE TSet initT()
Definition kInline.h:84
KINLINE TObject ** initR()
Definition kInline.h:95
KINLINE BOOLEAN arriRewDummy(poly, unsigned long, poly, kStrategy, int)
Definition kInline.h:1258
KINLINE unsigned long * initsevT()
Definition kInline.h:100
int redLiftstd(LObject *h, kStrategy strat)
Definition kLiftstd.cc:167
static ideal nc_GB(const ideal F, const ideal Q, const intvec *w, const bigintmat *hilb, kStrategy strat, const ring r)
Definition nc.h:27
void khCheck(ideal Q, intvec *w, bigintmat *hilb, int &eledeg, int &count, kStrategy strat)
Definition khstd.cc:28
void khCheckLocInhom(ideal Q, intvec *w, bigintmat *hilb, int &count, kStrategy strat)
Definition khstd.cc:248
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:477
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition kspoly.cc:1203
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat, BOOLEAN reduce)
Definition kspoly.cc:187
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2421
poly kNFBound(ideal F, ideal Q, poly p, int bound, int syzComp, int lazyReduce)
Definition kstd1.cc:3285
void initMora(ideal F, kStrategy strat)
Definition kstd1.cc:1820
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:794
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2411
poly k_NF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce, const ring _currRing)
NOTE: this is just a wrapper which sets currRing for the actual kNF call.
Definition kstd1.cc:3443
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
void enterSMora(LObject *p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1629
ideal kStd_internal(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
pure GB/SB computations
Definition kstd1.cc:2434
static BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition kstd1.cc:1312
static int doRed(LObject *h, TObject *with, BOOLEAN intoT, kStrategy strat, bool redMoraNF)
Definition kstd1.cc:118
static void firstUpdate(kStrategy strat)
Definition kstd1.cc:1566
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition kstd1.cc:3221
static void updateL(BOOLEAN searchPP, kStrategy strat)
Definition kstd1.cc:1394
ideal kStdShift(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, BOOLEAN rightGB)
Definition kstd1.cc:2964
static void updateT(kStrategy strat)
Definition kstd1.cc:1540
static void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1279
static void updateLHC(kStrategy strat)
Definition kstd1.cc:1474
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1360
ideal kInterRedBba(ideal F, ideal Q, int &need_retry)
Definition kstd1.cc:3551
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3069
static BOOLEAN kMoraUseBucket(kStrategy strat)
Definition kstd1.cc:3878
poly kNF1(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
Definition kstd1.cc:2119
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3802
static void kOptimizeLDeg(pLDegProc ldeg, kStrategy strat)
Definition kstd1.cc:100
void initBba(kStrategy strat)
Definition kstd1.cc:1690
ideal mora(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd1.cc:1887
int redRiloc(LObject *h, kStrategy strat)
Definition kstd1.cc:385
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2607
void initSba(ideal F, kStrategy strat)
Definition kstd1.cc:1750
static poly redMoraNFRing(poly h, kStrategy strat, int flag)
Definition kstd1.cc:1080
static void reorderL(kStrategy strat)
Definition kstd1.cc:1222
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw)
Definition kstd1.cc:2668
void kDebugPrint(kStrategy strat)
Definition kutil.cc:11478
VAR intvec * kHomW
Definition kstd1.cc:2409
VAR intvec * kModW
Definition kstd1.cc:2409
ideal kInterRedOld(ideal F, const ideal Q)
Definition kstd1.cc:3456
VAR BITSET validOpts
Definition kstd1.cc:60
static void reorderT(kStrategy strat)
Definition kstd1.cc:1241
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3229
static poly redMoraNF(poly h, kStrategy strat, int flag)
Definition kstd1.cc:976
VAR BITSET kOptions
Definition kstd1.cc:45
int redRiloc_Z(LObject *h, kStrategy strat)
Definition kstd1.cc:566
void enterSMoraNF(LObject *p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1682
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations
Definition kstd1.cc:2659
#define KSTD_NF_LAZY
Definition kstd1.h:18
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
#define KSTD_NF_NONORM
Definition kstd1.h:22
#define KSTD_NF_CANCELUNIT
Definition kstd1.h:24
BOOLEAN(* s_poly_proc_t)(kStrategy strat)
Definition kstd1.h:15
#define KSTD_NF_ECART
Definition kstd1.h:20
EXTERN_VAR int Kstd1_mu
Definition kstd1.h:70
poly kTryHC(ideal F, ideal Q)
Definition kstdhelper.cc:38
ideal kTryHilbstd(ideal F, ideal Q)
int redRing_Z(LObject *h, kStrategy strat)
Definition kstd2.cc:720
ideal sba(ideal F0, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:2971
int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject *L)
return -1 if no divisor is found number of first divisor in S, otherwise
Definition kstd2.cc:464
int kTestDivisibleByT0_Z(const kStrategy strat, const LObject *L)
tests if T[0] divides the leading monomial of L, returns -1 if not
Definition kstd2.cc:142
poly kNF2(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
Definition kstd2.cc:3927
int redHoney(LObject *h, kStrategy strat)
Definition kstd2.cc:2110
int redHomog(LObject *h, kStrategy strat)
Definition kstd2.cc:1150
int redLazy(LObject *h, kStrategy strat)
Definition kstd2.cc:1905
int redSigRing(LObject *h, kStrategy strat)
Definition kstd2.cc:1536
ideal bbaShift(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:4577
int redSig(LObject *h, kStrategy strat)
Definition kstd2.cc:1369
poly kNF2Bound(ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
Definition kstd2.cc:4015
int redRing(LObject *h, kStrategy strat)
Definition kstd2.cc:988
int kFindDivisibleByInT(const kStrategy strat, const LObject *L, const int start)
return -1 if no divisor is found number of first divisor in T, otherwise
Definition kstd2.cc:317
ideal bba(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:2614
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:6836
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5278
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9749
VAR int HCord
Definition kutil.cc:239
BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int)
Definition kutil.cc:6646
void enterSBba(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8792
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7463
BOOLEAN arriRewCriterion(poly, unsigned long, poly, kStrategy strat, int start=0)
Definition kutil.cc:6621
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1004
void enterT_strong(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:9242
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1067
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:1939
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1269
BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly, kStrategy strat, int start=0)
Definition kutil.cc:6562
int posInT2(const TSet set, const int length, LObject &p)
Definition kutil.cc:4925
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4487
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition kutil.cc:1315
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9580
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7586
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10939
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5611
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3445
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
Definition kutil.cc:10682
void HEckeTest(poly pp, kStrategy strat)
Definition kutil.cc:493
BOOLEAN kTest_L(LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
Definition kutil.cc:916
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9837
void initEcartNormal(TObject *h)
Definition kutil.cc:1293
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4663
void updateS(BOOLEAN toT, kStrategy strat)
Definition kutil.cc:8557
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10459
void enterT(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:9143
void cleanT(kStrategy strat)
Definition kutil.cc:557
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition kutil.cc:789
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition kutil.cc:286
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10051
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4457
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1208
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11036
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9435
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10257
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9664
void enterSSba(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8915
void messageSets(kStrategy strat)
Definition kutil.cc:7536
poly preIntegerCheck(const ideal Forig, const ideal Q)
used for GB over ZZ: look for constant and monomial elements in the ideal background: any known const...
Definition kutil.cc:10518
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3204
void initEcartBBA(TObject *h)
Definition kutil.cc:1301
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition kutil.cc:1308
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7504
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10847
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10379
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365
void initHilbCrit(ideal, ideal, bigintmat **hilb, kStrategy strat)
Definition kutil.cc:9417
LObject * LSet
Definition kutil.h:61
static void kDeleteLcm(LObject *P)
Definition kutil.h:876
#define setmaxT
Definition kutil.h:34
#define RED_CANONICALIZE
Definition kutil.h:37
class sTObject TObject
Definition kutil.h:58
class sLObject LObject
Definition kutil.h:59
static bool rIsSCA(const ring r)
Definition nc.h:190
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
Definition sca.cc:1518
poly p_KillSquares(const poly p, const short iFirstAltVar, const short iLastAltVar, const ring r)
Definition sca.cc:1463
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:647
#define assume(x)
Definition mod2.h:389
#define p_GetComp(p, r)
Definition monomials.h:64
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define __p_GetComp(p, r)
Definition monomials.h:63
number ndQuotRem(number a, number b, number *r, const coeffs R)
Definition numbers.cc:356
#define nEqual(n1, n2)
Definition numbers.h:20
#define omfree(addr)
#define omFreeSize(addr, size)
omError_t omTestMemory(int check_level)
Definition omDebug.c:94
#define omAlloc(size)
#define omFree(addr)
#define NULL
Definition omList.c:12
VAR BOOLEAN siCntrlc
Definition options.c:14
VAR unsigned si_opt_1
Definition options.c:5
#define TEST_OPT_WEIGHTM
Definition options.h:123
#define OPT_SUGARCRIT
Definition options.h:81
#define OPT_PROT
Definition options.h:76
#define OPT_INFREDTAIL
Definition options.h:95
#define OPT_INTSTRATEGY
Definition options.h:93
#define TEST_OPT_IDLIFT
Definition options.h:131
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define BVERBOSE(a)
Definition options.h:35
#define OPT_WEIGHTM
Definition options.h:98
#define TEST_OPT_FINDET
Definition options.h:113
#define OPT_REDTAIL
Definition options.h:92
#define SI_SAVE_OPT1(A)
Definition options.h:21
#define SI_RESTORE_OPT1(A)
Definition options.h:24
#define OPT_NOT_SUGAR
Definition options.h:79
#define TEST_OPT_OLDSTD
Definition options.h:125
#define OPT_REDTHROUGH
Definition options.h:83
#define OPT_REDSB
Definition options.h:77
#define Sy_bit(x)
Definition options.h:31
#define TEST_OPT_REDSB
Definition options.h:106
#define OPT_NOTREGULARITY
Definition options.h:97
#define TEST_OPT_DEGBOUND
Definition options.h:115
#define TEST_OPT_SB_1
Definition options.h:121
#define TEST_OPT_RETURN_SB
Definition options.h:114
#define TEST_OPT_MULTBOUND
Definition options.h:116
#define TEST_OPT_PROT
Definition options.h:105
#define TEST_OPT_REDTHROUGH
Definition options.h:124
#define OPT_INTERRUPT
Definition options.h:80
#define OPT_DEGBOUND
Definition options.h:91
#define TEST_V_DEG_STOP
Definition options.h:140
#define TEST_OPT_FASTHC
Definition options.h:111
#define TEST_OPT_DEBUG
Definition options.h:110
#define OPT_FASTHC
Definition options.h:86
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:119
#define OPT_OLDSTD
Definition options.h:87
#define TEST_OPT_STAIRCASEBOUND
Definition options.h:117
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
pShallowCopyDeleteProc pGetShallowCopyDeleteProc(ring, ring)
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition p_polys.cc:1227
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3774
long pLDeg0c(poly p, int *l, const ring r)
Definition p_polys.cc:771
long pLDeg0(poly p, int *l, const ring r)
Definition p_polys.cc:740
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3762
long p_WDegree(poly p, const ring r)
Definition p_polys.cc:715
static int pLength(poly a)
Definition p_polys.h:190
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:382
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:315
#define pp_Test(p, lmRing, tailRing)
Definition p_polys.h:163
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1931
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
Compatibility layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition polys.h:204
#define pTest(p)
Definition polys.h:415
#define pDelete(p_ptr)
Definition polys.h:187
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
#define pSetm(p)
Definition polys.h:272
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
#define pGetComp(p)
Component.
Definition polys.h:38
void pNorm(poly p)
Definition polys.h:363
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
Definition polys.h:147
#define pMaxComp(p)
Definition polys.h:300
#define pSetComp(p, v)
Definition polys.h:39
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153
void wrp(poly p)
Definition polys.h:311
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
#define pSetmComp(p)
TODO:
Definition polys.h:274
#define pNormalize(p)
Definition polys.h:318
#define pSetExp(p, i, v)
Definition polys.h:43
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pOne()
Definition polys.h:316
#define pWTotaldegree(p)
Definition polys.h:284
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314
void Werror(const char *fmt,...)
Definition reporter.cc:189
#define mflush()
Definition reporter.h:58
BOOLEAN rHasBlockOrder(const ring r)
Definition ring.cc:1924
BOOLEAN rOrd_is_Ds(const ring r)
Definition ring.cc:2076
BOOLEAN rOrd_is_ds(const ring r)
Definition ring.cc:2066
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769
static BOOLEAN rHasGlobalOrdering(const ring r)
Definition ring.h:768
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:38
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:521
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:770
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:554
#define rField_is_Ring(R)
Definition ring.h:491
ideal SCAQuotient(const ring r)
Definition sca.h:10
static short scaLastAltVar(ring r)
Definition sca.h:25
static short scaFirstAltVar(ring r)
Definition sca.h:18
#define idIsInV(I)
Definition shiftop.h:49
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
BOOLEAN id_IsModule(ideal A, const ring src)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
BOOLEAN idIsMonomial(ideal h)
returns true if h is generated by monomials
#define IDELEMS(i)
static int idElem(const ideal F)
number of non-zero polys in F
#define M
Definition sirandom.c:25
#define Q
Definition sirandom.c:26
tHomog
Definition structs.h:31
@ isHomog
Definition structs.h:33
@ testHomog
Definition structs.h:34
@ isNotHomog
Definition structs.h:32
#define loop
Definition structs.h:71
long totaldegreeWecart(poly p, ring r)
Definition weight.cc:217
long maxdegreeWecart(poly p, int *l, ring r)
Definition weight.cc:247
void kEcartWeights(poly *s, int sl, short *eweight, const ring R)
Definition weight.cc:182
EXTERN_VAR short * ecartWeights
Definition weight.h:12