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))
1932 {
1933 kDebugPrint(strat);
1934 }
1935//deleteInL(strat->L,&strat->Ll,1,strat);
1936//deleteInL(strat->L,&strat->Ll,0,strat);
1937
1938 /*- compute-------------------------------------------*/
1939 while (strat->Ll >= 0)
1940 {
1941 #ifdef KDEBUG
1942 if (TEST_OPT_DEBUG) messageSets(strat);
1943 #endif
1944 if (siCntrlc)
1945 {
1946 while (strat->Ll >= 0)
1947 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1948 strat->noClearS=TRUE;
1949 }
1951 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg))
1952 {
1953 /*
1954 * stops computation if
1955 * - 24 (degBound)
1956 * && upper degree is bigger than Kstd1_deg
1957 */
1958 while ((strat->Ll >= 0)
1959 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
1960 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)
1961 )
1962 {
1963 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1964 //if (TEST_OPT_PROT)
1965 //{
1966 // PrintS("D"); mflush();
1967 //}
1968 }
1969 if (strat->Ll<0) break;
1970 else strat->noClearS=TRUE;
1971 }
1972 strat->P = strat->L[strat->Ll];/*- picks the last element from the lazyset L -*/
1973 if (strat->Ll==0) strat->interpt=TRUE;
1974 strat->Ll--;
1975 // create the real Spoly
1976 if (pNext(strat->P.p) == strat->tail)
1977 {
1978 /*- deletes the short spoly and computes -*/
1980 pLmDelete(strat->P.p);
1981 else
1982 pLmFree(strat->P.p);
1983 strat->P.p = NULL;
1984 poly m1 = NULL, m2 = NULL;
1985 // check that spoly creation is ok
1986 while (strat->tailRing != currRing &&
1987 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
1988 {
1989 assume(m1 == NULL && m2 == NULL);
1990 // if not, change to a ring where exponents are large enough
1991 kStratChangeTailRing(strat);
1992 }
1993 /* create the real one */
1994 ksCreateSpoly(&(strat->P), strat->kNoetherTail(), strat->use_buckets,
1995 strat->tailRing, m1, m2, strat->R);
1996 if (!strat->use_buckets)
1997 strat->P.SetLength(strat->length_pLength);
1998 strat->P.PrepareRed(strat->use_buckets);
1999 }
2000 else if (strat->P.p1 == NULL)
2001 {
2002 // for input polys, prepare reduction (buckets !)
2003 strat->P.SetLength(strat->length_pLength);
2004 strat->P.PrepareRed(strat->use_buckets);
2005 }
2006
2007 // the s-poly
2008 if (!strat->P.IsNull())
2009 {
2010 // might be NULL from noether !!!
2011 if (TEST_OPT_PROT)
2012 message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result);
2013 // reduce
2014 red_result = strat->red(&strat->P,strat);
2015 }
2016
2017 // the reduced s-poly
2018 if (! strat->P.IsNull())
2019 {
2020 strat->P.GetP();
2021 // statistics
2022 if (TEST_OPT_PROT) PrintS("s");
2023 // normalization
2025 strat->P.pCleardenom();
2026 else
2027 strat->P.pNorm();
2028 // tailreduction
2029 strat->P.p = redtail(&(strat->P),strat->sl,strat);
2030 if (strat->P.p==NULL)
2031 {
2032 WerrorS("exponent overflow - wrong ordering");
2033 return(idInit(1,1));
2034 }
2035 // set ecart -- might have changed because of tail reductions
2036 if ((!strat->noTailReduction) && (!strat->honey))
2037 strat->initEcart(&strat->P);
2038 // cancel unit
2039 cancelunit(&strat->P);
2040 // for char 0, clear denominators
2041 if ((strat->P.p->next==NULL) /* i.e. cancelunit did something*/
2043 strat->P.pCleardenom();
2044
2045 strat->P.SetShortExpVector();
2046 enterT(strat->P,strat);
2047 // build new pairs
2049 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
2050 else
2051 enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
2052 // put in S
2053 strat->enterS(strat->P,
2054 posInS(strat,strat->sl,strat->P.p, strat->P.ecart),
2055 strat, strat->tl);
2056 // apply hilbert criterion
2057 if (hilb!=NULL)
2058 {
2059 if (strat->homog==isHomog)
2061 else
2063 }
2064
2065 // clear strat->P
2066 kDeleteLcm(&strat->P);
2067
2068#ifdef KDEBUG
2069 // make sure kTest_TS does not complain about strat->P
2070 strat->P.Clear();
2071#endif
2072 }
2073 if (strat->kAllAxis)
2074 {
2075 if ((TEST_OPT_FINDET)
2076 || ((TEST_OPT_MULTBOUND) && (scMult0Int(strat->Shdl,NULL) < Kstd1_mu)))
2077 {
2078 // obachman: is this still used ???
2079 /*
2080 * stops computation if strat->kAllAxis and
2081 * - 27 (finiteDeterminacyTest)
2082 * or
2083 * - 23
2084 * (multBound)
2085 * && multiplicity of the ideal is smaller then a predefined number mu
2086 */
2087 while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2088 }
2089 }
2090 kTest_TS(strat);
2091 }
2092 /*- complete reduction of the standard basis------------------------ -*/
2093 if (TEST_OPT_REDSB) completeReduce(strat);
2094 else if (TEST_OPT_PROT) PrintLn();
2095 /*- release temp data------------------------------- -*/
2096 exitBuchMora(strat);
2097 /*- polynomials used for HECKE: HC, noether -*/
2098 if (TEST_OPT_FINDET)
2099 {
2100 if (strat->kNoether!=NULL)
2101 Kstd1_mu=currRing->pFDeg(strat->kNoether,currRing);
2102 else
2103 Kstd1_mu=-1;
2104 }
2105 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
2107// if (TEST_OPT_WEIGHTM)
2108// {
2109// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
2110// if (ecartWeights)
2111// {
2112// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2113// ecartWeights=NULL;
2114// }
2115// }
2116 if(nCoeff_is_Z(currRing->cf))
2117 finalReduceByMon(strat);
2118 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
2120 idTest(strat->Shdl);
2121 return (strat->Shdl);
2122}
2123
2124poly kNF1 (ideal F,ideal Q,poly q, kStrategy strat, int lazyReduce)
2125{
2126 assume(q!=NULL);
2127 assume(!(idIs0(F)&&(Q==NULL)));
2128
2129// lazy_reduce flags: can be combined by |
2130//#define KSTD_NF_LAZY 1
2131 // do only a reduction of the leading term
2132//#define KSTD_NF_ECART 2
2133 // only local: reduce even with bad ecart
2134 poly p;
2135 int i;
2136 int j;
2137 int o;
2138 LObject h;
2139 BITSET save1;
2141
2142 //if ((idIs0(F))&&(Q==NULL))
2143 // return pCopy(q); /*F=0*/
2144 //strat->ak = si_max(idRankFreeModule(F),pMaxComp(q));
2145 /*- creating temp data structures------------------- -*/
2146 strat->kAllAxis = (currRing->ppNoether) != NULL;
2147 strat->kNoether = pCopy((currRing->ppNoether));
2150 si_opt_1&=~Sy_bit(OPT_INTSTRATEGY);
2152 && (! TEST_V_DEG_STOP)
2153 && (0<Kstd1_deg)
2154 && ((strat->kNoether==NULL)
2156 {
2157 pLmDelete(&strat->kNoether);
2158 strat->kNoether=pOne();
2159 pSetExp(strat->kNoether,1, Kstd1_deg+1);
2160 pSetm(strat->kNoether);
2161 // strat->kAllAxis=TRUE;
2162 }
2163 initBuchMoraCrit(strat);
2165 initBuchMoraPosRing(strat);
2166 else
2167 initBuchMoraPos(strat);
2168 initMora(F,strat);
2169 strat->enterS = enterSMoraNF;
2170 /*- set T -*/
2171 strat->tl = -1;
2172 strat->tmax = setmaxT;
2173 strat->T = initT();
2174 strat->R = initR();
2175 strat->sevT = initsevT();
2176 /*- set S -*/
2177 strat->sl = -1;
2178 /*- init local data struct.-------------------------- -*/
2179 /*Shdl=*/initS(F,Q,strat);
2180 if ((strat->ak!=0)
2181 && (strat->kAllAxis)) /*never true for ring-cf*/
2182 {
2183 if (strat->ak!=1)
2184 {
2185 pSetComp(strat->kNoether,1);
2186 pSetmComp(strat->kNoether);
2187 poly p=pHead(strat->kNoether);
2188 pSetComp(p,strat->ak);
2189 pSetmComp(p);
2190 p=pAdd(strat->kNoether,p);
2191 strat->kNoether=pNext(p);
2193 }
2194 }
2195 if (((lazyReduce & KSTD_NF_LAZY)==0)
2196 && (!rField_is_Ring(currRing)))
2197 {
2198 for (i=strat->sl; i>=0; i--)
2199 pNorm(strat->S[i]);
2200 }
2201 /*- puts the elements of S also to T -*/
2202 for (i=0; i<=strat->sl; i++)
2203 {
2204 h.p = strat->S[i];
2205 h.ecart = strat->ecartS[i];
2206 if (strat->sevS[i] == 0) strat->sevS[i] = pGetShortExpVector(h.p);
2207 else assume(strat->sevS[i] == pGetShortExpVector(h.p));
2208 h.length = pLength(h.p);
2209 h.sev = strat->sevS[i];
2210 h.SetpFDeg();
2211 enterT(h,strat);
2212 }
2213#ifdef KDEBUG
2214// kDebugPrint(strat);
2215#endif
2216 /*- compute------------------------------------------- -*/
2217 p = pCopy(q);
2218 deleteHC(&p,&o,&j,strat);
2219 kTest(strat);
2220 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
2221 if (BVERBOSE(23)) kDebugPrint(strat);
2223 {
2225 }
2226 else
2227 {
2229 }
2230 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
2231 {
2232 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
2233 p = redtail(p,strat->sl,strat);
2234 }
2235 /*- release temp data------------------------------- -*/
2236 cleanT(strat);
2237 assume(strat->L==NULL); /*strat->L unused */
2238 assume(strat->B==NULL); /*strat->B unused */
2239 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
2240 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
2241 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
2242 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
2243 omFree(strat->sevT);
2244 omFree(strat->S_2_R);
2245 omFree(strat->R);
2246
2247 omfree((ADDRESS)strat->fromQ);
2248 strat->fromQ=NULL;
2249 if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
2250// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
2251// {
2252// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
2253// if (ecartWeights)
2254// {
2255// omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short));
2256// ecartWeights=NULL;
2257// }
2258// }
2259 idDelete(&strat->Shdl);
2261 if (TEST_OPT_PROT) PrintLn();
2262 return p;
2263}
2264
2266{
2267 assume(!idIs0(q));
2268 assume(!(idIs0(F)&&(Q==NULL)));
2269
2270// lazy_reduce flags: can be combined by |
2271//#define KSTD_NF_LAZY 1
2272 // do only a reduction of the leading term
2273//#define KSTD_NF_ECART 2
2274 // only local: reduce even with bad ecart
2275 poly p;
2276 int i;
2277 int j;
2278 int o;
2279 LObject h;
2280 ideal res;
2281 BITSET save1;
2283
2284 //if (idIs0(q)) return idInit(IDELEMS(q),si_max(q->rank,F->rank));
2285 //if ((idIs0(F))&&(Q==NULL))
2286 // return idCopy(q); /*F=0*/
2287 //strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(q));
2288 /*- creating temp data structures------------------- -*/
2289 strat->kAllAxis = (currRing->ppNoether) != NULL;
2290 strat->kNoether=pCopy((currRing->ppNoether));
2293 && (0<Kstd1_deg)
2294 && ((strat->kNoether==NULL)
2296 {
2297 pLmDelete(&strat->kNoether);
2298 strat->kNoether=pOne();
2299 pSetExp(strat->kNoether,1, Kstd1_deg+1);
2300 pSetm(strat->kNoether);
2301 //strat->kAllAxis=TRUE;
2302 }
2303 initBuchMoraCrit(strat);
2305 initBuchMoraPosRing(strat);
2306 else
2307 initBuchMoraPos(strat);
2308 initMora(F,strat);
2309 strat->enterS = enterSMoraNF;
2310 /*- set T -*/
2311 strat->tl = -1;
2312 strat->tmax = setmaxT;
2313 strat->T = initT();
2314 strat->R = initR();
2315 strat->sevT = initsevT();
2316 /*- set S -*/
2317 strat->sl = -1;
2318 /*- init local data struct.-------------------------- -*/
2319 /*Shdl=*/initS(F,Q,strat);
2320 if ((strat->ak!=0)
2321 && (strat->kNoether!=NULL))
2322 {
2323 if (strat->ak!=1)
2324 {
2325 pSetComp(strat->kNoether,1);
2326 pSetmComp(strat->kNoether);
2327 poly p=pHead(strat->kNoether);
2328 pSetComp(p,strat->ak);
2329 pSetmComp(p);
2330 p=pAdd(strat->kNoether,p);
2331 strat->kNoether=pNext(p);
2333 }
2334 }
2335 if (((lazyReduce & KSTD_NF_LAZY)==0)
2336 && (!rField_is_Ring(currRing)))
2337 {
2338 for (i=strat->sl; i>=0; i--)
2339 pNorm(strat->S[i]);
2340 }
2341 /*- compute------------------------------------------- -*/
2342 res=idInit(IDELEMS(q),strat->ak);
2343 for (i=0; i<IDELEMS(q); i++)
2344 {
2345 if (q->m[i]!=NULL)
2346 {
2347 p = pCopy(q->m[i]);
2348 deleteHC(&p,&o,&j,strat);
2349 if (p!=NULL)
2350 {
2351 /*- puts the elements of S also to T -*/
2352 for (j=0; j<=strat->sl; j++)
2353 {
2354 h.p = strat->S[j];
2355 h.ecart = strat->ecartS[j];
2356 h.pLength = h.length = pLength(h.p);
2357 if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p);
2358 else assume(strat->sevS[j] == pGetShortExpVector(h.p));
2359 h.sev = strat->sevS[j];
2360 h.SetpFDeg();
2362 enterT_strong(h,strat);
2363 else
2364 enterT(h,strat);
2365 }
2366 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
2368 {
2369 p = redMoraNFRing(p,strat, lazyReduce);
2370 }
2371 else
2372 p = redMoraNF(p,strat, lazyReduce);
2373 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
2374 {
2375 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
2376 p = redtail(p,strat->sl,strat);
2377 }
2378 cleanT(strat);
2379 }
2380 res->m[i]=p;
2381 }
2382 //else
2383 // res->m[i]=NULL;
2384 }
2385 /*- release temp data------------------------------- -*/
2386 assume(strat->L==NULL); /*strat->L unused */
2387 assume(strat->B==NULL); /*strat->B unused */
2388 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
2389 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
2390 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
2391 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
2392 omFree(strat->sevT);
2393 omFree(strat->S_2_R);
2394 omFree(strat->R);
2395 omfree((ADDRESS)strat->fromQ);
2396 strat->fromQ=NULL;
2397 if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
2398// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
2399// {
2400// pFDeg=strat->pOrigFDeg;
2401// pLDeg=strat->pOrigLDeg;
2402// if (ecartWeights)
2403// {
2404// omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short));
2405// ecartWeights=NULL;
2406// }
2407// }
2408 idDelete(&strat->Shdl);
2410 if (TEST_OPT_PROT) PrintLn();
2411 return res;
2412}
2413
2415
2416long kModDeg(poly p,const ring r)
2417{
2418 long o=p_WDegree(p, r);
2419 long i=__p_GetComp(p, r);
2420 if (i==0) return o;
2421 //assume((i>0) && (i<=kModW->length()));
2422 if (i<=kModW->length())
2423 return o+(*kModW)[i-1];
2424 return o;
2425}
2426long kHomModDeg(poly p,const ring r)
2427{
2428 int i;
2429 long j=0;
2430
2431 for (i=r->N;i>0;i--)
2432 j+=p_GetExp(p,i,r)*(*kHomW)[i-1];
2433 if (kModW == NULL) return j;
2434 i = __p_GetComp(p,r);
2435 if (i==0) return j;
2436 return j+(*kModW)[i-1];
2437}
2438
2440 int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
2441{
2442 assume(!idIs0(F));
2443 assume((Q==NULL)||(!idIs0(Q)));
2444
2445 kStrategy strat=new skStrategy;
2446
2447 ideal r;
2448 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2450
2451 strat->s_poly=sp;
2453 strat->syzComp = syzComp;
2454 if (TEST_OPT_SB_1
2456 )
2457 strat->newIdeal = newIdeal;
2459 strat->LazyPass=20;
2460 else
2461 strat->LazyPass=2;
2462 strat->LazyDegree = 1;
2463 strat->ak = 0;
2464 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2465 strat->kModW=kModW=NULL;
2466 strat->kHomW=kHomW=NULL;
2467 if (vw != NULL)
2468 {
2469 currRing->pLexOrder=FALSE;
2470 strat->kHomW=kHomW=vw;
2471 strat->pOrigFDeg = currRing->pFDeg;
2472 strat->pOrigLDeg = currRing->pLDeg;
2474 toReset = TRUE;
2475 }
2476 if (h==testHomog)
2477 {
2478 if (strat->ak == 0)
2479 {
2480 h = (tHomog)idHomIdeal(F,Q);
2481 w=NULL;
2482 }
2483 else if (!TEST_OPT_DEGBOUND)
2484 {
2485 if (w!=NULL)
2486 h = (tHomog)idHomModule(F,Q,w);
2487 else
2488 h = (tHomog)idHomIdeal(F,Q);
2489 }
2490 }
2491 currRing->pLexOrder=b;
2492 if (h==isHomog)
2493 {
2494 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
2495 {
2496 strat->kModW = kModW = *w;
2497 if (vw == NULL)
2498 {
2499 strat->pOrigFDeg = currRing->pFDeg;
2500 strat->pOrigLDeg = currRing->pLDeg;
2502 toReset = TRUE;
2503 }
2504 }
2505 currRing->pLexOrder = TRUE;
2506 if (hilb==NULL) strat->LazyPass*=2;
2507 }
2508 strat->homog=h;
2509#ifdef KDEBUG
2510 idTest(F);
2511 if (Q!=NULL) idTest(Q);
2512#endif
2513#ifdef HAVE_PLURAL
2515 {
2516 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
2517 strat->no_prod_crit = ! bIsSCA;
2518 if (w!=NULL)
2519 r = nc_GB(F, Q, *w, hilb, strat, currRing);
2520 else
2521 r = nc_GB(F, Q, NULL, hilb, strat, currRing);
2522 }
2523 else
2524#endif
2525 {
2526 #if PRE_INTEGER_CHECK
2527 //the preinteger check strategy is not for modules
2528 if(nCoeff_is_Z(currRing->cf) && strat->ak <= 0)
2529 {
2530 ideal FCopy = idCopy(F);
2531 poly pFmon = preIntegerCheck(FCopy, Q);
2532 if(pFmon != NULL)
2533 {
2535 strat->kModW=kModW=NULL;
2536 if (h==testHomog)
2537 {
2539 w=NULL;
2540 }
2541 currRing->pLexOrder=b;
2542 if (h==isHomog)
2543 {
2544 if ((w!=NULL) && (*w!=NULL))
2545 {
2546 strat->kModW = kModW = *w;
2547 if (vw == NULL)
2548 {
2549 strat->pOrigFDeg = currRing->pFDeg;
2550 strat->pOrigLDeg = currRing->pLDeg;
2552 toReset = TRUE;
2553 }
2554 }
2555 currRing->pLexOrder = TRUE;
2556 if (hilb==NULL) strat->LazyPass*=2;
2557 }
2558 strat->homog=h;
2559 }
2560 omTestMemory(1);
2561 if(w == NULL)
2562 {
2564 r=mora(FCopy,Q,NULL,hilb,strat);
2565 else
2566 r=bba(FCopy,Q,NULL,hilb,strat);
2567 }
2568 else
2569 {
2571 r=mora(FCopy,Q,*w,hilb,strat);
2572 else
2573 r=bba(FCopy,Q,*w,hilb,strat);
2574 }
2575 idDelete(&FCopy);
2576 }
2577 else
2578 #endif
2579 {
2580 if(w==NULL)
2581 {
2583 r=mora(F,Q,NULL,hilb,strat);
2584 else
2585 r=bba(F,Q,NULL,hilb,strat);
2586 }
2587 else
2588 {
2590 r=mora(F,Q,*w,hilb,strat);
2591 else
2592 r=bba(F,Q,*w,hilb,strat);
2593 }
2594 }
2595 }
2596#ifdef KDEBUG
2597 idTest(r);
2598#endif
2599 if (toReset)
2600 {
2601 kModW = NULL;
2603 }
2604 currRing->pLexOrder = b;
2605//Print("%d reductions canceled \n",strat->cel);
2606 delete(strat);
2607 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2608 return r;
2609}
2610
2612 int newIdeal, intvec *vw, s_poly_proc_t sp)
2613{
2614 if(idIs0(F))
2615 return idInit(1,F->rank);
2616
2617 if(idIs0(Q)) Q=NULL;
2618#ifdef HAVE_SHIFTBBA
2619 if(rIsLPRing(currRing)) return kStdShift(F, Q, h, w, hilb, syzComp, newIdeal, vw, FALSE);
2620#endif
2621
2622 if ((hilb==NULL)
2623 && (vw==NULL)
2624 && (newIdeal==0)
2625 && (sp==NULL)
2626 && (IDELEMS(F)>1)
2627 && (!TEST_OPT_SB_1)
2628 && (currRing->ppNoether==NULL)
2629 && !rIsPluralRing(currRing) /*!rIsLPRing already tested above*/
2630 && (!id_IsModule(F,currRing)))
2631 {
2632 /* test HC precomputation*/
2636 && (!idIsMonomial(F)))
2637 {
2638 currRing->ppNoether=kTryHC(F,Q);
2639 ideal res=kStd_internal(F,Q,h,w,hilb,syzComp,newIdeal,vw,sp);
2640 if (currRing->ppNoether!=NULL) pLmDelete(currRing->ppNoether);
2641 currRing->ppNoether=NULL;
2642 return res;
2643 }
2644 /* test hilbstd */
2646 && (!TEST_OPT_RETURN_SB)
2647 && (!TEST_OPT_DEGBOUND)
2648 && (currRing->LexOrder
2650 && (!idIsMonomial(F)))
2651 {
2653 //ideal result=kTryHilbstd_par(F,Q,h,w);
2654 if (result!=NULL)
2655 {
2656 return result;
2657 }
2658 }
2659 }
2660 return kStd_internal(F,Q,h,w,hilb,syzComp,newIdeal,vw,sp);
2661}
2662
2664 int newIdeal, intvec *vw, s_poly_proc_t sp)
2665{
2667 ideal res=kStd2(F,Q,h,w,hh,syzComp,newIdeal,vw,sp);
2668 if (hh!=NULL) delete hh;
2669 return res;
2670}
2671
2672ideal kSba(ideal F, ideal Q, tHomog h,intvec ** w, int sbaOrder, int arri, bigintmat *hilb,int syzComp,
2673 int newIdeal, intvec *vw)
2674{
2675 if(idIs0(F))
2676 return idInit(1,F->rank);
2678 {
2679 ideal r;
2680 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2682 kStrategy strat=new skStrategy;
2683 strat->sbaOrder = sbaOrder;
2684 if (arri!=0)
2685 {
2686 strat->rewCrit1 = arriRewDummy;
2687 strat->rewCrit2 = arriRewCriterion;
2689 }
2690 else
2691 {
2695 }
2696
2698 strat->syzComp = syzComp;
2699 if (TEST_OPT_SB_1)
2700 //if(!rField_is_Ring(currRing)) // always true here
2701 strat->newIdeal = newIdeal;
2703 strat->LazyPass=20;
2704 else
2705 strat->LazyPass=2;
2706 strat->LazyDegree = 1;
2710 strat->ak = 0;
2711 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2712 strat->kModW=kModW=NULL;
2713 strat->kHomW=kHomW=NULL;
2714 if (vw != NULL)
2715 {
2716 currRing->pLexOrder=FALSE;
2717 strat->kHomW=kHomW=vw;
2718 strat->pOrigFDeg = currRing->pFDeg;
2719 strat->pOrigLDeg = currRing->pLDeg;
2721 toReset = TRUE;
2722 }
2723 if (h==testHomog)
2724 {
2725 if (strat->ak == 0)
2726 {
2727 h = (tHomog)idHomIdeal(F,Q);
2728 w=NULL;
2729 }
2730 else if (!TEST_OPT_DEGBOUND)
2731 {
2732 if (w!=NULL)
2733 h = (tHomog)idHomModule(F,Q,w);
2734 else
2735 h = (tHomog)idHomIdeal(F,Q);
2736 }
2737 }
2738 currRing->pLexOrder=b;
2739 if (h==isHomog)
2740 {
2741 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
2742 {
2743 strat->kModW = kModW = *w;
2744 if (vw == NULL)
2745 {
2746 strat->pOrigFDeg = currRing->pFDeg;
2747 strat->pOrigLDeg = currRing->pLDeg;
2749 toReset = TRUE;
2750 }
2751 }
2752 currRing->pLexOrder = TRUE;
2753 if (hilb==NULL) strat->LazyPass*=2;
2754 }
2755 strat->homog=h;
2756 #ifdef KDEBUG
2757 idTest(F);
2758 if(Q != NULL)
2759 idTest(Q);
2760 #endif
2761 #ifdef HAVE_PLURAL
2763 {
2764 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
2765 strat->no_prod_crit = ! bIsSCA;
2766 if (w!=NULL)
2767 r = nc_GB(F, Q, *w, hilb, strat, currRing);
2768 else
2769 r = nc_GB(F, Q, NULL, hilb, strat, currRing);
2770 }
2771 else
2772 #endif
2773 {
2775 {
2776 if (w!=NULL)
2777 r=mora(F,Q,*w,hilb,strat);
2778 else
2779 r=mora(F,Q,NULL,hilb,strat);
2780 }
2781 else
2782 {
2783 strat->sigdrop = FALSE;
2784 if (w!=NULL)
2785 r=sba(F,Q,*w,hilb,strat);
2786 else
2787 r=sba(F,Q,NULL,hilb,strat);
2788 }
2789 }
2790 #ifdef KDEBUG
2791 idTest(r);
2792 #endif
2793 if (toReset)
2794 {
2795 kModW = NULL;
2797 }
2798 currRing->pLexOrder = b;
2799 //Print("%d reductions canceled \n",strat->cel);
2800 //delete(strat);
2801 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2802 return r;
2803 }
2804 else
2805 {
2806 //--------------------------RING CASE-------------------------
2807 assume(sbaOrder == 1);
2808 assume(arri == 0);
2809 ideal r;
2810 r = idCopy(F);
2811 int sbaEnterS = -1;
2812 bool sigdrop = TRUE;
2813 //This is how we set the SBA algorithm;
2814 int totalsbaruns = 1,blockedreductions = 20,blockred = 0,loops = 0;
2815 while(sigdrop && (loops < totalsbaruns || totalsbaruns == -1)
2816 && (blockred <= blockedreductions))
2817 {
2818 loops++;
2819 if(loops == 1)
2820 sigdrop = FALSE;
2821 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2823 kStrategy strat=new skStrategy;
2824 strat->sbaEnterS = sbaEnterS;
2825 strat->sigdrop = sigdrop;
2826 #if 0
2827 strat->blockred = blockred;
2828 #else
2829 strat->blockred = 0;
2830 #endif
2832 //printf("\nsbaEnterS beginning = %i\n",strat->sbaEnterS);
2833 //printf("\nsigdrop beginning = %i\n",strat->sigdrop);
2834 strat->sbaOrder = sbaOrder;
2835 if (arri!=0)
2836 {
2837 strat->rewCrit1 = arriRewDummy;
2838 strat->rewCrit2 = arriRewCriterion;
2840 }
2841 else
2842 {
2846 }
2847
2849 strat->syzComp = syzComp;
2850 if (TEST_OPT_SB_1)
2852 strat->newIdeal = newIdeal;
2854 strat->LazyPass=20;
2855 else
2856 strat->LazyPass=2;
2857 strat->LazyDegree = 1;
2861 strat->ak = 0;
2862 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2863 strat->kModW=kModW=NULL;
2864 strat->kHomW=kHomW=NULL;
2865 if (vw != NULL)
2866 {
2867 currRing->pLexOrder=FALSE;
2868 strat->kHomW=kHomW=vw;
2869 strat->pOrigFDeg = currRing->pFDeg;
2870 strat->pOrigLDeg = currRing->pLDeg;
2872 toReset = TRUE;
2873 }
2874 if (h==testHomog)
2875 {
2876 if (strat->ak == 0)
2877 {
2878 h = (tHomog)idHomIdeal(F,Q);
2879 w=NULL;
2880 }
2881 else if (!TEST_OPT_DEGBOUND)
2882 {
2883 if (w!=NULL)
2884 h = (tHomog)idHomModule(F,Q,w);
2885 else
2886 h = (tHomog)idHomIdeal(F,Q);
2887 }
2888 }
2889 currRing->pLexOrder=b;
2890 if (h==isHomog)
2891 {
2892 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
2893 {
2894 strat->kModW = kModW = *w;
2895 if (vw == NULL)
2896 {
2897 strat->pOrigFDeg = currRing->pFDeg;
2898 strat->pOrigLDeg = currRing->pLDeg;
2900 toReset = TRUE;
2901 }
2902 }
2903 currRing->pLexOrder = TRUE;
2904 if (hilb==NULL) strat->LazyPass*=2;
2905 }
2906 strat->homog=h;
2907 #ifdef KDEBUG
2908 idTest(F);
2909 if(Q != NULL)
2910 idTest(Q);
2911 #endif
2912 #ifdef HAVE_PLURAL
2914 {
2915 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
2916 strat->no_prod_crit = ! bIsSCA;
2917 if (w!=NULL)
2918 r = nc_GB(F, Q, *w, hilb, strat, currRing);
2919 else
2920 r = nc_GB(F, Q, NULL, hilb, strat, currRing);
2921 }
2922 else
2923 #endif
2924 {
2926 {
2927 if (w!=NULL)
2928 r=mora(F,Q,*w,hilb,strat);
2929 else
2930 r=mora(F,Q,NULL,hilb,strat);
2931 }
2932 else
2933 {
2934 if (w!=NULL)
2935 r=sba(r,Q,*w,hilb,strat);
2936 else
2937 {
2938 r=sba(r,Q,NULL,hilb,strat);
2939 }
2940 }
2941 }
2942 #ifdef KDEBUG
2943 idTest(r);
2944 #endif
2945 if (toReset)
2946 {
2947 kModW = NULL;
2949 }
2950 currRing->pLexOrder = b;
2951 //Print("%d reductions canceled \n",strat->cel);
2952 sigdrop = strat->sigdrop;
2953 sbaEnterS = strat->sbaEnterS;
2954 blockred = strat->blockred;
2955 delete(strat);
2956 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2957 }
2958 // Go to std
2959 if(sigdrop || blockred > blockedreductions)
2960 {
2961 r = kStd2(r, Q, h, w, hilb, syzComp, newIdeal, vw);
2962 }
2963 return r;
2964 }
2965}
2966
2967#ifdef HAVE_SHIFTBBA
2969 int newIdeal, intvec *vw, BOOLEAN rightGB)
2970{
2972 assume(idIsInV(F));
2974 {
2975 /* error: no local ord yet with shifts */
2976 WerrorS("No local ordering possible for shift algebra");
2977 return(NULL);
2978 }
2979 ideal r;
2980 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
2982 kStrategy strat=new skStrategy;
2983
2984 strat->rightGB = rightGB;
2985
2987 strat->syzComp = syzComp;
2988 if (TEST_OPT_SB_1)
2990 strat->newIdeal = newIdeal;
2992 strat->LazyPass=20;
2993 else
2994 strat->LazyPass=2;
2995 strat->LazyDegree = 1;
2996 strat->ak = 0;
2997 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
2998 strat->kModW=kModW=NULL;
2999 strat->kHomW=kHomW=NULL;
3000 if (vw != NULL)
3001 {
3002 currRing->pLexOrder=FALSE;
3003 strat->kHomW=kHomW=vw;
3004 strat->pOrigFDeg = currRing->pFDeg;
3005 strat->pOrigLDeg = currRing->pLDeg;
3007 toReset = TRUE;
3008 }
3009 if (h==testHomog)
3010 {
3011 if (strat->ak == 0)
3012 {
3013 h = (tHomog)idHomIdeal(F,Q);
3014 w=NULL;
3015 }
3016 else if (!TEST_OPT_DEGBOUND)
3017 {
3018 if (w!=NULL)
3019 h = (tHomog)idHomModule(F,Q,w);
3020 else
3021 h = (tHomog)idHomIdeal(F,Q);
3022 }
3023 }
3024 currRing->pLexOrder=b;
3025 if (h==isHomog)
3026 {
3027 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
3028 {
3029 strat->kModW = kModW = *w;
3030 if (vw == NULL)
3031 {
3032 strat->pOrigFDeg = currRing->pFDeg;
3033 strat->pOrigLDeg = currRing->pLDeg;
3035 toReset = TRUE;
3036 }
3037 }
3038 currRing->pLexOrder = TRUE;
3039 if (hilb==NULL) strat->LazyPass*=2;
3040 }
3041 strat->homog=h;
3042#ifdef KDEBUG
3043 idTest(F);
3044#endif
3045 /* global ordering */
3046 if (w!=NULL)
3047 r=bbaShift(F,Q,*w,hilb,strat);
3048 else
3049 r=bbaShift(F,Q,NULL,hilb,strat);
3050#ifdef KDEBUG
3051 idTest(r);
3052#endif
3053 if (toReset)
3054 {
3055 kModW = NULL;
3057 }
3058 currRing->pLexOrder = b;
3059//Print("%d reductions canceled \n",strat->cel);
3060 delete(strat);
3061 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
3062 assume(idIsInV(r));
3063 return r;
3064}
3065#endif
3066
3067//##############################################################
3068//##############################################################
3069//##############################################################
3070//##############################################################
3071//##############################################################
3072
3074 int syzComp, int reduced)
3075{
3076 if(idIs0(F))
3077 {
3078 M=idInit(1,F->rank);
3079 return idInit(1,F->rank);
3080 }
3082 {
3083 ideal sb;
3084 sb = kStd2(F, Q, h, w, hilb);
3086 if(IDELEMS(sb) <= IDELEMS(F))
3087 {
3088 M = idCopy(sb);
3089 idSkipZeroes(M);
3090 return(sb);
3091 }
3092 else
3093 {
3094 M = idCopy(F);
3095 idSkipZeroes(M);
3096 return(sb);
3097 }
3098 }
3099 ideal r=NULL;
3100 int Kstd1_OldDeg = Kstd1_deg,i;
3102 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
3105 kStrategy strat=new skStrategy;
3106
3108 strat->syzComp = syzComp;
3110 strat->LazyPass=20;
3111 else
3112 strat->LazyPass=2;
3113 strat->LazyDegree = 1;
3114 strat->minim=(reduced % 2)+1;
3115 strat->ak = 0;
3116 if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
3117 if (delete_w)
3118 {
3119 temp_w=new intvec((strat->ak)+1);
3120 w = &temp_w;
3121 }
3122 if (h==testHomog)
3123 {
3124 if (strat->ak == 0)
3125 {
3126 h = (tHomog)idHomIdeal(F,Q);
3127 w=NULL;
3128 }
3129 else
3130 {
3131 h = (tHomog)idHomModule(F,Q,w);
3132 }
3133 }
3134 if (h==isHomog)
3135 {
3136 if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
3137 {
3138 kModW = *w;
3139 strat->kModW = *w;
3140 assume(currRing->pFDeg != NULL && currRing->pLDeg != NULL);
3141 strat->pOrigFDeg = currRing->pFDeg;
3142 strat->pOrigLDeg = currRing->pLDeg;
3144
3145 toReset = TRUE;
3146 if (reduced>1)
3147 {
3149 Kstd1_deg = -1;
3150 for (i=IDELEMS(F)-1;i>=0;i--)
3151 {
3152 if ((F->m[i]!=NULL) && (currRing->pFDeg(F->m[i],currRing)>=Kstd1_deg))
3153 Kstd1_deg = currRing->pFDeg(F->m[i],currRing)+1;
3154 }
3155 }
3156 }
3157 currRing->pLexOrder = TRUE;
3158 strat->LazyPass*=2;
3159 }
3160 strat->homog=h;
3161 ideal SB=NULL;
3163 {
3164 r=idMinBase(F,&SB); // SB and M via minbase
3165 strat->M=r;
3166 r=SB;
3167 }
3168 else
3169 {
3170 if (w!=NULL)
3171 r=bba(F,Q,*w,hilb,strat);
3172 else
3173 r=bba(F,Q,NULL,hilb,strat);
3174 }
3175#ifdef KDEBUG
3176 {
3177 int i;
3178 for (i=IDELEMS(r)-1; i>=0; i--) pTest(r->m[i]);
3179 }
3180#endif
3181 idSkipZeroes(r);
3182 if (toReset)
3183 {
3185 kModW = NULL;
3186 }
3187 currRing->pLexOrder = b;
3188 if ((delete_w)&&(temp_w!=NULL)) delete temp_w;
3189 if ((IDELEMS(r)==1) && (r->m[0]!=NULL) && pIsConstant(r->m[0]) && (strat->ak==0))
3190 {
3191 M=idInit(1,F->rank);
3192 M->m[0]=pOne();
3193 //if (strat->ak!=0) { pSetComp(M->m[0],strat->ak); pSetmComp(M->m[0]); }
3194 if (strat->M!=NULL) idDelete(&strat->M);
3195 }
3196 else if (strat->M==NULL)
3197 {
3198 M=idInit(1,F->rank);
3199 WarnS("no minimal generating set computed");
3200 }
3201 else
3202 {
3203 idSkipZeroes(strat->M);
3204 M=strat->M;
3205 strat->M=NULL;
3206 }
3207 delete(strat);
3208 if (reduced>2)
3209 {
3211 if (!oldDegBound)
3212 si_opt_1 &= ~Sy_bit(OPT_DEGBOUND);
3213 }
3214 else
3215 {
3216 if (IDELEMS(M)>IDELEMS(r))
3217 {
3218 idDelete(&M);
3219 M=idCopy(r);
3220 }
3221 }
3222 return r;
3223}
3224
3226 int syzComp, int reduced)
3227{
3229 ideal res=kMin_std2(F,Q,h,w,M,hh,syzComp,reduced);
3230 if (hh!=NULL) delete hh;
3231 return res;
3232}
3233poly kNF(ideal F, ideal Q, poly p,int syzComp, int lazyReduce)
3234{
3235 if (p==NULL)
3236 return NULL;
3237
3238 poly pp = p;
3239
3240#ifdef HAVE_PLURAL
3241 if(rIsSCA(currRing))
3242 {
3243 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3244 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3246
3247 if(Q == currRing->qideal)
3249 }
3250#endif
3251 if(idIs0(Q)) Q=NULL;
3252
3253 if ((idIs0(F))&&(Q==NULL))
3254 {
3255#ifdef HAVE_PLURAL
3256 if(p != pp)
3257 return pp;
3258#endif
3259 return pCopy(p); /*F+Q=0*/
3260 }
3261
3262 kStrategy strat=new skStrategy;
3263 strat->syzComp = syzComp;
3265 poly res;
3266
3268 {
3269#ifdef HAVE_SHIFTBBA
3270 if (currRing->isLPring)
3271 {
3272 WerrorS("No local ordering possible for shift algebra");
3273 return(NULL);
3274 }
3275#endif
3276 res=kNF1(F,Q,pp,strat,lazyReduce);
3277 }
3278 else
3279 res=kNF2(F,Q,pp,strat,lazyReduce);
3280 delete(strat);
3281
3282#ifdef HAVE_PLURAL
3283 if(pp != p)
3284 p_Delete(&pp, currRing);
3285#endif
3286 return res;
3287}
3288
3289poly kNFBound(ideal F, ideal Q, poly p,int bound,int syzComp, int lazyReduce)
3290{
3291 if (p==NULL)
3292 return NULL;
3293
3294 poly pp = p;
3295
3296#ifdef HAVE_PLURAL
3297 if(rIsSCA(currRing))
3298 {
3299 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3300 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3302
3303 if(Q == currRing->qideal)
3305 }
3306#endif
3307
3308 if ((idIs0(F))&&(Q==NULL))
3309 {
3310#ifdef HAVE_PLURAL
3311 if(p != pp)
3312 return pp;
3313#endif
3314 return pCopy(p); /*F+Q=0*/
3315 }
3316
3317 kStrategy strat=new skStrategy;
3318 strat->syzComp = syzComp;
3320 poly res;
3321 res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
3322 delete(strat);
3323
3324#ifdef HAVE_PLURAL
3325 if(pp != p)
3326 p_Delete(&pp, currRing);
3327#endif
3328 return res;
3329}
3330
3331ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce)
3332{
3333 ideal res;
3334 if (TEST_OPT_PROT)
3335 {
3336 Print("(S:%d)",IDELEMS(p));mflush();
3337 }
3338 if (idIs0(p))
3339 return idInit(IDELEMS(p),si_max(p->rank,F->rank));
3340
3341 ideal pp = p;
3342#ifdef HAVE_PLURAL
3343 if(rIsSCA(currRing))
3344 {
3345 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3346 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3348
3349 if(Q == currRing->qideal)
3351 }
3352#endif
3353
3354 if (idIs0(Q)) Q=NULL;
3355
3356 if ((idIs0(F))&&(Q==NULL))
3357 {
3358#ifdef HAVE_PLURAL
3359 if(p != pp)
3360 return pp;
3361#endif
3362 return idCopy(p); /*F+Q=0*/
3363 }
3364
3365 kStrategy strat=new skStrategy;
3366 strat->syzComp = syzComp;
3368 if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
3369 {
3370 strat->ak = si_max(strat->ak,(int)F->rank);
3371 }
3372
3374 {
3375#ifdef HAVE_SHIFTBBA
3376 if (currRing->isLPring)
3377 {
3378 WerrorS("No local ordering possible for shift algebra");
3379 return(NULL);
3380 }
3381#endif
3382 res=kNF1(F,Q,pp,strat,lazyReduce);
3383 }
3384 else
3385 res=kNF2(F,Q,pp,strat,lazyReduce);
3386 delete(strat);
3387
3388#ifdef HAVE_PLURAL
3389 if(pp != p)
3391#endif
3392
3393 return res;
3394}
3395
3397{
3398 ideal res;
3399 if (TEST_OPT_PROT)
3400 {
3401 Print("(S:%d)",IDELEMS(p));mflush();
3402 }
3403 if (idIs0(p))
3404 return idInit(IDELEMS(p),si_max(p->rank,F->rank));
3405
3406 ideal pp = p;
3407#ifdef HAVE_PLURAL
3408 if(rIsSCA(currRing))
3409 {
3410 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3411 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3413
3414 if(Q == currRing->qideal)
3416 }
3417#endif
3418
3419 if ((idIs0(F))&&(Q==NULL))
3420 {
3421#ifdef HAVE_PLURAL
3422 if(p != pp)
3423 return pp;
3424#endif
3425 return idCopy(p); /*F+Q=0*/
3426 }
3427
3428 kStrategy strat=new skStrategy;
3429 strat->syzComp = syzComp;
3431 if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
3432 {
3433 strat->ak = si_max(strat->ak,(int)F->rank);
3434 }
3435
3436 res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
3437 delete(strat);
3438
3439#ifdef HAVE_PLURAL
3440 if(pp != p)
3442#endif
3443
3444 return res;
3445}
3446
3447poly k_NF (ideal F, ideal Q, poly p,int syzComp, int lazyReduce, const ring _currRing)
3448{
3449 const ring save = currRing;
3451 poly ret = kNF(F, Q, p, syzComp, lazyReduce);
3453 return ret;
3454}
3455
3456/*2
3457*interreduces F
3458*/
3459// old version
3461{
3462 int j;
3463 kStrategy strat = new skStrategy;
3464
3465 ideal tempF = F;
3466 ideal tempQ = Q;
3467
3468#ifdef HAVE_PLURAL
3469 if(rIsSCA(currRing))
3470 {
3471 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
3472 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
3474
3475 // this should be done on the upper level!!! :
3476 // tempQ = SCAQuotient(currRing);
3477
3478 if(Q == currRing->qideal)
3480 }
3481#endif
3482
3483// if (TEST_OPT_PROT)
3484// {
3485// writeTime("start InterRed:");
3486// mflush();
3487// }
3488 //strat->syzComp = 0;
3489 strat->kAllAxis = (currRing->ppNoether) != NULL;
3490 strat->kNoether=pCopy((currRing->ppNoether));
3491 strat->ak = 0;
3493 initBuchMoraCrit(strat);
3494 strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN));
3495 for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE;
3496 strat->enterS = enterSBba;
3497 strat->posInT = posInT17;
3498 strat->initEcart = initEcartNormal;
3499 strat->sl = -1;
3500 strat->tl = -1;
3501 strat->tmax = setmaxT;
3502 strat->T = initT();
3503 strat->R = initR();
3504 strat->sevT = initsevT();
3506 initS(tempF, tempQ, strat);
3507 if (TEST_OPT_REDSB)
3508 strat->noTailReduction=FALSE;
3509 updateS(TRUE,strat);
3511 completeReduce(strat);
3512 //else if (TEST_OPT_PROT) PrintLn();
3513 cleanT(strat);
3514 if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
3515 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
3516 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
3517 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
3518 omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
3519 omfree(strat->sevT);
3520 omfree(strat->S_2_R);
3521 omfree(strat->R);
3522
3523 if (strat->fromQ)
3524 {
3525 for (j=IDELEMS(strat->Shdl)-1;j>=0;j--)
3526 {
3527 if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]);
3528 }
3529 omFree((ADDRESS)strat->fromQ);
3530 strat->fromQ=NULL;
3531 }
3532// if (TEST_OPT_PROT)
3533// {
3534// writeTime("end Interred:");
3535// mflush();
3536// }
3537 ideal shdl=strat->Shdl;
3539 if (strat->fromQ)
3540 {
3541 omfree(strat->fromQ);
3542 strat->fromQ=NULL;
3544 idDelete(&shdl);
3545 shdl=res;
3546 }
3547 delete(strat);
3548#ifdef HAVE_PLURAL
3549 if( tempF != F )
3551#endif
3552 return shdl;
3553}
3554// new version
3556{
3557 need_retry=0;
3558 int red_result = 1;
3559 int olddeg,reduc;
3560 // BOOLEAN withT = FALSE;
3561 // BOOLEAN toReset=FALSE;
3562 kStrategy strat=new skStrategy;
3563 tHomog h;
3564
3566 strat->LazyPass=20;
3567 else
3568 strat->LazyPass=2;
3569 strat->LazyDegree = 1;
3570 strat->ak = id_RankFreeModule(F,currRing);
3571 strat->syzComp = strat->ak;
3572 strat->kModW=kModW=NULL;
3573 strat->kHomW=kHomW=NULL;
3574 if (strat->ak == 0)
3575 {
3576 h = (tHomog)idHomIdeal(F,Q);
3577 }
3578 else if (!TEST_OPT_DEGBOUND)
3579 {
3580 h = (tHomog)idHomIdeal(F,Q);
3581 }
3582 else
3583 h = isNotHomog;
3584 if (h==isHomog)
3585 {
3586 strat->LazyPass*=2;
3587 }
3588 strat->homog=h;
3589#ifdef KDEBUG
3590 idTest(F);
3591#endif
3592
3593 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
3595 initBuchMoraPosRing(strat);
3596 else
3597 initBuchMoraPos(strat);
3598 initBba(strat);
3599 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
3600 strat->posInL=posInL0; /* ord according pComp */
3601
3602 /*Shdl=*/initBuchMora(F, Q, strat);
3603 reduc = olddeg = 0;
3604
3605#ifndef NO_BUCKETS
3607 strat->use_buckets = 1;
3608#endif
3609
3610 // redtailBBa against T for inhomogeneous input
3611 //if (!TEST_OPT_OLDSTD)
3612 // withT = ! strat->homog;
3613
3614 // strat->posInT = posInT_pLength;
3615 kTest_TS(strat);
3616
3617#ifdef HAVE_TAIL_RING
3619#endif
3620
3621 /* compute------------------------------------------------------- */
3622 while (strat->Ll >= 0)
3623 {
3624 #ifdef KDEBUG
3625 if (TEST_OPT_DEBUG) messageSets(strat);
3626 #endif
3627 if (strat->Ll== 0) strat->interpt=TRUE;
3628 /* picks the last element from the lazyset L */
3629 strat->P = strat->L[strat->Ll];
3630 strat->Ll--;
3631
3632 if (strat->P.p1 == NULL)
3633 {
3634 // for input polys, prepare reduction
3635 strat->P.PrepareRed(strat->use_buckets);
3636 }
3637
3638 if (strat->P.p == NULL && strat->P.t_p == NULL)
3639 {
3640 red_result = 0;
3641 }
3642 else
3643 {
3644 if (TEST_OPT_PROT)
3645 message(strat->P.pFDeg(),
3646 &olddeg,&reduc,strat, red_result);
3647
3648 /* reduction of the element chosen from L */
3649 red_result = strat->red(&strat->P,strat);
3650 }
3651
3652 // reduction to non-zero new poly
3653 if (red_result == 1)
3654 {
3655 /* statistic */
3656 if (TEST_OPT_PROT) PrintS("s");
3657
3658 // get the polynomial (canonicalize bucket, make sure P.p is set)
3659 strat->P.GetP(strat->lmBin);
3660
3661 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3662
3663 // reduce the tail and normalize poly
3664 // in the ring case we cannot expect LC(f) = 1,
3665 // therefore we call pCleardenom instead of pNorm
3667 {
3668 strat->P.pCleardenom();
3669 }
3670 else
3671 {
3672 strat->P.pNorm();
3673 }
3674
3675#ifdef KDEBUG
3676 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3677#endif
3678
3679 // enter into S, L, and T
3680 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3681 {
3682 enterT(strat->P, strat);
3683 // posInS only depends on the leading term
3684 strat->enterS(strat->P, pos, strat, strat->tl);
3685
3686 if (pos<strat->sl)
3687 {
3688 need_retry++;
3689 // move all "larger" elements fromS to L
3690 // remove them from T
3691 int ii=pos+1;
3692 for(;ii<=strat->sl;ii++)
3693 {
3694 LObject h;
3695 h.Clear();
3696 h.tailRing=strat->tailRing;
3697 h.p=strat->S[ii]; strat->S[ii]=NULL;
3698 strat->initEcart(&h);
3699 h.sev=strat->sevS[ii];
3700 int jj=strat->tl;
3701 while (jj>=0)
3702 {
3703 if (strat->T[jj].p==h.p)
3704 {
3705 strat->T[jj].p=NULL;
3706 if (jj<strat->tl)
3707 {
3708 memmove(&(strat->T[jj]),&(strat->T[jj+1]),
3709 (strat->tl-jj)*sizeof(strat->T[jj]));
3710 memmove(&(strat->sevT[jj]),&(strat->sevT[jj+1]),
3711 (strat->tl-jj)*sizeof(strat->sevT[jj]));
3712 }
3713 strat->tl--;
3714 break;
3715 }
3716 jj--;
3717 }
3718 int lpos=strat->posInL(strat->L,strat->Ll,&h,strat);
3719 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,lpos);
3720 #ifdef KDEBUG
3721 if (TEST_OPT_DEBUG)
3722 {
3723 Print("move S[%d] -> L[%d]: ",ii,pos);
3724 p_wrp(h.p,currRing, strat->tailRing);
3725 PrintLn();
3726 }
3727 #endif
3728 }
3729 if (strat->fromQ!=NULL)
3730 {
3731 for(ii=pos+1;ii<=strat->sl;ii++) strat->fromQ[ii]=0;
3732 }
3733 strat->sl=pos;
3734 }
3735 }
3736 else
3737 {
3738 // clean P
3739 }
3740 kDeleteLcm(&strat->P);
3741 }
3742
3743#ifdef KDEBUG
3744 if (TEST_OPT_DEBUG)
3745 {
3746 messageSets(strat);
3747 }
3748 strat->P.Clear();
3749#endif
3750 //kTest_TS(strat);: i_r out of sync in kInterRedBba, but not used!
3751 }
3752#ifdef KDEBUG
3753 //if (TEST_OPT_DEBUG) messageSets(strat);
3754#endif
3755 /* complete reduction of the standard basis--------- */
3756
3757 if((need_retry<=0) && (TEST_OPT_REDSB))
3758 {
3759 completeReduce(strat);
3760 if (strat->completeReduce_retry)
3761 {
3762 // completeReduce needed larger exponents, retry
3763 // hopefully: kStratChangeTailRing already provided a larger tailRing
3764 // (otherwise: it will fail again)
3766 completeReduce(strat);
3767 if (strat->completeReduce_retry)
3768 {
3769#ifdef HAVE_TAIL_RING
3770 if(currRing->bitmask>strat->tailRing->bitmask)
3771 {
3772 // retry without T
3774 cleanT(strat);strat->tailRing=currRing;
3775 int i;
3776 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3777 completeReduce(strat);
3778 }
3779 if (strat->completeReduce_retry)
3780#endif
3781 Werror("exponent bound is %ld",currRing->bitmask);
3782 }
3783 }
3784 }
3785 else if (TEST_OPT_PROT) PrintLn();
3786
3787
3788 /* release temp data-------------------------------- */
3789 exitBuchMora(strat);
3790// if (TEST_OPT_WEIGHTM)
3791// {
3792// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
3793// if (ecartWeights)
3794// {
3795// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
3796// ecartWeights=NULL;
3797// }
3798// }
3799 //if (TEST_OPT_PROT) messageStat(0/*hilbcount*/,strat);
3800 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3801 ideal res=strat->Shdl;
3802 strat->Shdl=NULL;
3803 delete strat;
3804 return res;
3805}
3807{
3808#ifdef HAVE_PLURAL
3809 if(rIsPluralRing(currRing)) return kInterRedOld(F,Q);
3810#endif
3813 )
3814 return kInterRedOld(F,Q);
3815
3816 //return kInterRedOld(F,Q);
3817
3818 BITSET save1;
3820 //si_opt_1|=Sy_bit(OPT_NOT_SUGAR);
3822 //si_opt_1&= ~Sy_bit(OPT_REDTAIL);
3823 //si_opt_1&= ~Sy_bit(OPT_REDSB);
3824 //extern char * showOption() ;
3825 //Print("%s\n",showOption());
3826
3827 int need_retry;
3828 int counter=3;
3829 ideal res, res1;
3830 int elems=0;
3831 ideal null=NULL;
3832 if ((Q==NULL) || (!TEST_OPT_REDSB))
3833 {
3834 elems=idElem(F);
3836 }
3837 else
3838 {
3839 ideal FF=idSimpleAdd(F,Q);
3841 idDelete(&FF);
3842 null=idInit(1,1);
3843 if (need_retry)
3845 else
3846 res1=kNF(null,Q,res);
3847 idDelete(&res);
3848 res=res1;
3849 need_retry=1;
3850 }
3851 if (idElem(res)<=1) need_retry=0;
3852 while (need_retry && (counter>0))
3853 {
3854 #ifdef KDEBUG
3855 if (TEST_OPT_DEBUG) { Print("retry counter %d\n",counter); }
3856 #endif
3858 int new_elems=idElem(res1);
3859 counter -= (new_elems >= elems);
3860 elems = new_elems;
3861 idDelete(&res);
3862 if (idElem(res1)<=1) need_retry=0;
3863 if ((Q!=NULL) && (TEST_OPT_REDSB))
3864 {
3865 if (need_retry)
3867 else
3868 res=kNF(null,Q,res1);
3869 idDelete(&res1);
3870 }
3871 else
3872 res = res1;
3873 if (idElem(res)<=1) need_retry=0;
3874 }
3875 if (null!=NULL) idDelete(&null);
3878 return res;
3879}
3880
3881// returns TRUE if mora should use buckets, false otherwise
3883{
3884#ifdef MORA_USE_BUCKETS
3886 return FALSE;
3887 if ((strat->red == redFirst)
3888 ||((strat->red == redEcart)&&(strat->kNoether!=NULL)))
3889 {
3890#ifdef NO_LDEG
3891 if (strat->syzComp==0)
3892 return TRUE;
3893#else
3894 if ((strat->homog || strat->honey) && (strat->syzComp==0))
3895 return TRUE;
3896#endif
3897 }
3898 else
3899 {
3900 assume(strat->red == redEcart || strat->red == redRiloc || strat->red == redRiloc_Z);
3901 if (strat->honey && (strat->syzComp==0))
3902 return TRUE;
3903 }
3904#endif
3905 return FALSE;
3906}
#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:336
bool sigdrop
Definition kutil.h:359
int syzComp
Definition kutil.h:355
int * S_2_R
Definition kutil.h:343
ring tailRing
Definition kutil.h:344
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition kutil.h:292
char noTailReduction
Definition kutil.h:377
int currIdx
Definition kutil.h:318
char posInLOldFlag
Definition kutil.h:381
pFDegProc pOrigFDeg_TailRing
Definition kutil.h:299
int Ll
Definition kutil.h:352
TSet T
Definition kutil.h:327
BOOLEAN(* rewCrit1)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:294
omBin lmBin
Definition kutil.h:345
intset ecartS
Definition kutil.h:310
char honey
Definition kutil.h:376
char rightGB
Definition kutil.h:368
polyset S
Definition kutil.h:307
int minim
Definition kutil.h:358
poly kNoether
Definition kutil.h:330
BOOLEAN * NotUsedAxis
Definition kutil.h:333
LSet B
Definition kutil.h:329
int ak
Definition kutil.h:354
TObject ** R
Definition kutil.h:341
BOOLEAN(* rewCrit3)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:296
int lastAxis
Definition kutil.h:356
ideal M
Definition kutil.h:306
int tl
Definition kutil.h:351
int(* red2)(LObject *L, kStrategy strat)
Definition kutil.h:280
unsigned long * sevT
Definition kutil.h:326
intvec * kHomW
Definition kutil.h:337
poly tail
Definition kutil.h:335
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:285
int blockred
Definition kutil.h:364
ideal Shdl
Definition kutil.h:304
unsigned sbaOrder
Definition kutil.h:317
pFDegProc pOrigFDeg
Definition kutil.h:297
int blockredmax
Definition kutil.h:365
int tmax
Definition kutil.h:351
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:289
char LDegLast
Definition kutil.h:384
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition kutil.h:288
char kAllAxis
Definition kutil.h:375
intset fromQ
Definition kutil.h:322
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:287
char use_buckets
Definition kutil.h:382
char interpt
Definition kutil.h:370
int newIdeal
Definition kutil.h:357
char fromT
Definition kutil.h:378
char completeReduce_retry
Definition kutil.h:402
void(* initEcart)(TObject *L)
Definition kutil.h:281
LObject P
Definition kutil.h:303
char noClearS
Definition kutil.h:401
int Lmax
Definition kutil.h:352
char z2homog
Definition kutil.h:373
int LazyPass
Definition kutil.h:354
char no_prod_crit
Definition kutil.h:393
char overflow
Definition kutil.h:403
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:291
LSet L
Definition kutil.h:328
char length_pLength
Definition kutil.h:386
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:295
int sl
Definition kutil.h:349
int sbaEnterS
Definition kutil.h:362
int LazyDegree
Definition kutil.h:354
char posInLDependsOnLength
Definition kutil.h:388
unsigned long * sevS
Definition kutil.h:323
char homog
Definition kutil.h:371
pLDegProc pOrigLDeg
Definition kutil.h:298
char update
Definition kutil.h:380
s_poly_proc_t s_poly
Definition kutil.h:301
pLDegProc pOrigLDeg_TailRing
Definition kutil.h:300
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
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
void enterSMora(LObject &p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1629
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2426
poly kNFBound(ideal F, ideal Q, poly p, int bound, int syzComp, int lazyReduce)
Definition kstd1.cc:3289
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:2416
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:3447
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
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:2439
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:3225
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:2968
static void updateT(kStrategy strat)
Definition kstd1.cc:1540
static void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1279
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1682
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:3555
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3073
static BOOLEAN kMoraUseBucket(kStrategy strat)
Definition kstd1.cc:3882
poly kNF1(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
Definition kstd1.cc:2124
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3806
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:2611
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:2672
void kDebugPrint(kStrategy strat)
Definition kutil.cc:11501
VAR intvec * kHomW
Definition kstd1.cc:2414
VAR intvec * kModW
Definition kstd1.cc:2414
ideal kInterRedOld(ideal F, const ideal Q)
Definition kstd1.cc:3460
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:3233
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
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:2663
#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:724
ideal sba(ideal F0, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:2981
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:468
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:146
poly kNF2(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
Definition kstd2.cc:3943
int redHoney(LObject *h, kStrategy strat)
Definition kstd2.cc:2114
int redHomog(LObject *h, kStrategy strat)
Definition kstd2.cc:1154
int redLazy(LObject *h, kStrategy strat)
Definition kstd2.cc:1909
int redSigRing(LObject *h, kStrategy strat)
Definition kstd2.cc:1540
ideal bbaShift(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:4593
int redSig(LObject *h, kStrategy strat)
Definition kstd2.cc:1373
poly kNF2Bound(ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
Definition kstd2.cc:4031
int redRing(LObject *h, kStrategy strat)
Definition kstd2.cc:992
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:321
ideal bba(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:2618
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:6833
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:9744
VAR int HCord
Definition kutil.cc:239
BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int)
Definition kutil.cc:6643
void enterT(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9136
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7460
BOOLEAN arriRewCriterion(poly, unsigned long, poly, kStrategy strat, int start=0)
Definition kutil.cc:6618
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8910
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1004
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:6559
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:9573
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7583
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10962
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 enterT_strong(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9235
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
Definition kutil.cc:10705
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:9831
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:8552
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10482
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:10074
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:11059
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9428
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10280
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9658
void messageSets(kStrategy strat)
Definition kutil.cc:7533
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:10541
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:7501
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10870
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8787
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10402
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365
void initHilbCrit(ideal, ideal, bigintmat **hilb, kStrategy strat)
Definition kutil.cc:9410
LObject * LSet
Definition kutil.h:61
static void kDeleteLcm(LObject *P)
Definition kutil.h:881
#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:3729
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:3717
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