kspoly.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT - Routines for Spoly creation and reductions
6 */
7 
8 // #define PDEBUG 2
9 
10 
11 
12 #include <kernel/mod2.h>
13 #include <misc/options.h>
14 #include <kernel/GBEngine/kutil.h>
15 #include <coeffs/numbers.h>
18 #include <polys/nc/nc.h>
19 #ifdef KDEBUG
20 #endif
21 #ifdef HAVE_RINGS
22 #include <kernel/polys.h>
23 #endif
24 
25 //#define ADIDEBUG 0
26 
27 #ifdef KDEBUG
28 int red_count = 0;
29 int create_count = 0;
30 // define this if reductions are reported on TEST_OPT_DEBUG
31 #define TEST_OPT_DEBUG_RED
32 #endif
33 
34 /***************************************************************
35  *
36  * Reduces PR with PW
37  * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
38  *
39  * returns 0: okay
40  * 1: tailRing changed
41  * -1: cannot change tailRing
42  * 2: cannot change tailRing: strat==NULL
43  *
44  ***************************************************************/
46  TObject* PW,
47  poly spNoether,
48  number *coef,
50 {
51 #ifdef KDEBUG
52  red_count++;
53 #ifdef TEST_OPT_DEBUG_RED
54 // if (TEST_OPT_DEBUG)
55 // {
56 // Print("Red %d:", red_count); PR->wrp(); Print(" with:");
57 // PW->wrp();
58 // //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
59 // //pWrite(PR->p);
60 // }
61 #endif
62 #endif
63  int ret = 0;
64  ring tailRing = PR->tailRing;
65  kTest_L(PR);
66  kTest_T(PW);
67 
68  poly p1 = PR->GetLmTailRing(); // p2 | p1
69  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
70  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
71  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
72  p_CheckPolyRing(p1, tailRing);
73  p_CheckPolyRing(p2, tailRing);
74 
75  pAssume1(p2 != NULL && p1 != NULL &&
76  p_DivisibleBy(p2, p1, tailRing));
77 
78  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
79  (p_GetComp(p2, tailRing) == 0 &&
80  p_MaxComp(pNext(p2),tailRing) == 0));
81 
82 #ifdef HAVE_PLURAL
84  {
85  // for the time being: we know currRing==strat->tailRing
86  // no exp-bound checking needed
87  // (only needed if exp-bound(tailring)<exp-b(currRing))
88  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
89  else
90  {
91  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
92  assume(_p != NULL);
93  nc_PolyPolyRed(_p, p2,coef, currRing);
94  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
95  PR->pLength=0; // usually not used, GetpLength re-computes it if needed
96  }
97  return 0;
98  }
99 #endif
100 
101  if (t2==NULL) // Divisor is just one term, therefore it will
102  { // just cancel the leading term
103  PR->LmDeleteAndIter();
104  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
105  return 0;
106  }
107 
108  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
109 
110  //if (tailRing != currRing)
111  {
112  // check that reduction does not violate exp bound
113  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
114  {
115  // undo changes of lm
116  p_ExpVectorAdd(lm, p2, tailRing);
117  if (strat == NULL) return 2;
118  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
119  tailRing = strat->tailRing;
120  p1 = PR->GetLmTailRing();
121  p2 = PW->GetLmTailRing();
122  t2 = pNext(p2);
123  lm = p1;
124  p_ExpVectorSub(lm, p2, tailRing);
125  ret = 1;
126  }
127  }
128 
129  // take care of coef buisness
130  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
131  {
132  number bn = pGetCoeff(lm);
133  number an = pGetCoeff(p2);
134  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
135  p_SetCoeff(lm, bn, tailRing);
136  if ((ct == 0) || (ct == 2))
137  PR->Tail_Mult_nn(an);
138  if (coef != NULL) *coef = an;
139  else n_Delete(&an, tailRing->cf);
140  }
141  else
142  {
143  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
144  }
145 
146 
147  // and finally,
148  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
149  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
150  PR->LmDeleteAndIter();
151 
152  // the following is commented out: shrinking
153 #ifdef HAVE_SHIFTBBA_NONEXISTENT
154  if ( (currRing->isLPring) && (!strat->homog) )
155  {
156  // assume? h->p in currRing
157  PR->GetP();
158  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
159  PR->Clear(); // does the right things
160  PR->p = qq;
161  PR->t_p = NULL;
162  PR->SetShortExpVector();
163  }
164 #endif
165 
166 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
167  if (TEST_OPT_DEBUG)
168  {
169  Print(" to: "); PR->wrp(); Print("\n");
170  //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
171  }
172 #endif
173  return ret;
174 }
175 
177  TObject* PW,
178  int bound,
179  poly spNoether,
180  number *coef,
182 {
183 #ifdef KDEBUG
184  red_count++;
185 #ifdef TEST_OPT_DEBUG_RED
186  if (TEST_OPT_DEBUG)
187  {
188  Print("Red %d:", red_count); PR->wrp(); Print(" with:");
189  PW->wrp();
190  //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
191  //pWrite(PR->p);
192  }
193 #endif
194 #endif
195  int ret = 0;
196  ring tailRing = PR->tailRing;
197  kTest_L(PR);
198  kTest_T(PW);
199 
200  poly p1 = PR->GetLmTailRing(); // p2 | p1
201  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
202  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
203  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
204  p_CheckPolyRing(p1, tailRing);
205  p_CheckPolyRing(p2, tailRing);
206 
207  pAssume1(p2 != NULL && p1 != NULL &&
208  p_DivisibleBy(p2, p1, tailRing));
209 
210  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
211  (p_GetComp(p2, tailRing) == 0 &&
212  p_MaxComp(pNext(p2),tailRing) == 0));
213 
214 #ifdef HAVE_PLURAL
215  if (rIsPluralRing(currRing))
216  {
217  // for the time being: we know currRing==strat->tailRing
218  // no exp-bound checking needed
219  // (only needed if exp-bound(tailring)<exp-b(currRing))
220  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
221  else
222  {
223  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
224  assume(_p != NULL);
225  nc_PolyPolyRed(_p, p2,coef, currRing);
226  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
227  PR->pLength=0; // usually not used, GetpLength re-computes it if needed
228  }
229  return 0;
230  }
231 #endif
232 
233  if (t2==NULL) // Divisor is just one term, therefore it will
234  { // just cancel the leading term
235  PR->LmDeleteAndIter();
236  if (coef != NULL) *coef = n_Init(1, tailRing);
237  return 0;
238  }
239 
240  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
241 
242  if (tailRing != currRing)
243  {
244  // check that reduction does not violate exp bound
245  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
246  {
247  // undo changes of lm
248  p_ExpVectorAdd(lm, p2, tailRing);
249  if (strat == NULL) return 2;
250  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
251  tailRing = strat->tailRing;
252  p1 = PR->GetLmTailRing();
253  p2 = PW->GetLmTailRing();
254  t2 = pNext(p2);
255  lm = p1;
256  p_ExpVectorSub(lm, p2, tailRing);
257  ret = 1;
258  }
259  }
260 
261  // take care of coef buisness
262  if (! n_IsOne(pGetCoeff(p2), tailRing))
263  {
264  number bn = pGetCoeff(lm);
265  number an = pGetCoeff(p2);
266  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
267  p_SetCoeff(lm, bn, tailRing);
268  if ((ct == 0) || (ct == 2))
269  PR->Tail_Mult_nn(an);
270  if (coef != NULL) *coef = an;
271  else n_Delete(&an, tailRing);
272  }
273  else
274  {
275  if (coef != NULL) *coef = n_Init(1, tailRing);
276  }
277 
278 
279  // and finally,
280  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
281  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
282  PR->LmDeleteAndIter();
283 
284  // the following is commented out: shrinking
285 #ifdef HAVE_SHIFTBBA_NONEXISTENT
286  if ( (currRing->isLPring) && (!strat->homog) )
287  {
288  // assume? h->p in currRing
289  PR->GetP();
290  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
291  PR->Clear(); // does the right things
292  PR->p = qq;
293  PR->t_p = NULL;
294  PR->SetShortExpVector();
295  }
296 #endif
297 
298 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
299  if (TEST_OPT_DEBUG)
300  {
301  Print(" to: "); PR->wrp(); Print("\n");
302  //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
303  }
304 #endif
305  return ret;
306 }
307 
308 /***************************************************************
309  *
310  * Reduces PR with PW
311  * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
312  *
313  ***************************************************************/
314 
316  TObject* PW,
317  long /*idx*/,
318  poly spNoether,
319  number *coef,
321 {
322 #ifdef KDEBUG
323  red_count++;
324 #ifdef TEST_OPT_DEBUG_RED
325  if (TEST_OPT_DEBUG)
326  {
327  Print("Red %d:", red_count); PR->wrp(); Print(" with:");
328  PW->wrp();
329  }
330 #endif
331 #endif
332  int ret = 0;
333  ring tailRing = PR->tailRing;
334  kTest_L(PR);
335  kTest_T(PW);
336 
337  // signature-based stuff:
338  // checking for sig-safeness first
339  // NOTE: This has to be done in the current ring
340  //
341  /**********************************************
342  *
343  * TODO:
344  * --------------------------------------------
345  * if strat->sbaOrder == 1
346  * Since we are subdividing lower index and
347  * current index reductions it is enough to
348  * look at the polynomial part of the signature
349  * for a check. This should speed-up checking
350  * a lot!
351  * if !strat->sbaOrder == 0
352  * We are not subdividing lower and current index
353  * due to the fact that we are using the induced
354  * Schreyer order
355  *
356  * nevertheless, this different behaviour is
357  * taken care of by is_sigsafe
358  * => one reduction procedure can be used for
359  * both, the incremental and the non-incremental
360  * attempt!
361  * --------------------------------------------
362  *
363  *********************************************/
364  //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
365  if (!PW->is_sigsafe)
366  {
367  poly sigMult = pCopy(PW->sig); // copy signature of reducer
368 //#if 1
369 #ifdef DEBUGF5
370  printf("IN KSREDUCEPOLYSIG: \n");
371  pWrite(pHead(f1));
372  pWrite(pHead(f2));
373  pWrite(sigMult);
374  printf("--------------\n");
375 #endif
376  p_ExpVectorAddSub(sigMult,PR->GetLmCurrRing(),PW->GetLmCurrRing(),currRing);
377 //#if 1
378 #ifdef DEBUGF5
379  printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
380  pWrite(pHead(f1));
381  pWrite(pHead(f2));
382  pWrite(sigMult);
383  pWrite(PR->sig);
384  printf("--------------\n");
385 #endif
386  int sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
387  // now we can delete the copied polynomial data used for checking for
388  // sig-safeness of the reduction step
389 //#if 1
390 #ifdef DEBUGF5
391  printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
392 
393 #endif
394  //pDelete(&f1);
395  pDelete(&sigMult);
396  // go on with the computations only if the signature of p2 is greater than the
397  // signature of fm*p1
398  if(sigSafe != 1)
399  {
400  PR->is_redundant = TRUE;
401  return 3;
402  }
403  //PW->is_sigsafe = TRUE;
404  }
405  PR->is_redundant = FALSE;
406  poly p1 = PR->GetLmTailRing(); // p2 | p1
407  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
408  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
409  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
410  p_CheckPolyRing(p1, tailRing);
411  p_CheckPolyRing(p2, tailRing);
412 
413  pAssume1(p2 != NULL && p1 != NULL &&
414  p_DivisibleBy(p2, p1, tailRing));
415 
416  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
417  (p_GetComp(p2, tailRing) == 0 &&
418  p_MaxComp(pNext(p2),tailRing) == 0));
419 
420 #ifdef HAVE_PLURAL
421  if (rIsPluralRing(currRing))
422  {
423  // for the time being: we know currRing==strat->tailRing
424  // no exp-bound checking needed
425  // (only needed if exp-bound(tailring)<exp-b(currRing))
426  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
427  else
428  {
429  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
430  assume(_p != NULL);
431  nc_PolyPolyRed(_p, p2, coef, currRing);
432  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
433  PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
434  }
435  return 0;
436  }
437 #endif
438 
439  if (t2==NULL) // Divisor is just one term, therefore it will
440  { // just cancel the leading term
441  PR->LmDeleteAndIter();
442  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
443  return 0;
444  }
445 
446  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
447 
448  if (tailRing != currRing)
449  {
450  // check that reduction does not violate exp bound
451  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
452  {
453  // undo changes of lm
454  p_ExpVectorAdd(lm, p2, tailRing);
455  if (strat == NULL) return 2;
456  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
457  tailRing = strat->tailRing;
458  p1 = PR->GetLmTailRing();
459  p2 = PW->GetLmTailRing();
460  t2 = pNext(p2);
461  lm = p1;
462  p_ExpVectorSub(lm, p2, tailRing);
463  ret = 1;
464  }
465  }
466 
467  // take care of coef buisness
468  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
469  {
470  number bn = pGetCoeff(lm);
471  number an = pGetCoeff(p2);
472  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
473  p_SetCoeff(lm, bn, tailRing);
474  if ((ct == 0) || (ct == 2))
475  PR->Tail_Mult_nn(an);
476  if (coef != NULL) *coef = an;
477  else n_Delete(&an, tailRing->cf);
478  }
479  else
480  {
481  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
482  }
483 
484 
485  // and finally,
486  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
487  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
488  PR->LmDeleteAndIter();
489 
490  // the following is commented out: shrinking
491 #ifdef HAVE_SHIFTBBA_NONEXISTENT
492  if ( (currRing->isLPring) && (!strat->homog) )
493  {
494  // assume? h->p in currRing
495  PR->GetP();
496  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
497  PR->Clear(); // does the right things
498  PR->p = qq;
499  PR->t_p = NULL;
500  PR->SetShortExpVector();
501  }
502 #endif
503 
504 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
505  if (TEST_OPT_DEBUG)
506  {
507  Print(" to: "); PR->wrp(); Print("\n");
508  }
509 #endif
510  return ret;
511 }
512 
514  TObject* PW,
515  long /*idx*/,
516  poly spNoether,
517  number *coef,
519 {
520 #ifdef ADIDEBUG
521 printf("\nksReducePolySig\n");
522 pWrite(PR->p);pWrite(PR->sig);
523 pWrite(PW->p);pWrite(PW->sig);
524 #endif
525 #ifdef KDEBUG
526  red_count++;
527 #ifdef TEST_OPT_DEBUG_RED
528  if (TEST_OPT_DEBUG)
529  {
530  Print("Red %d:", red_count); PR->wrp(); Print(" with:");
531  PW->wrp();
532  }
533 #endif
534 #endif
535  int ret = 0;
536  ring tailRing = PR->tailRing;
537  kTest_L(PR);
538  kTest_T(PW);
539 
540  // signature-based stuff:
541  // checking for sig-safeness first
542  // NOTE: This has to be done in the current ring
543  //
544  /**********************************************
545  *
546  * TODO:
547  * --------------------------------------------
548  * if strat->sbaOrder == 1
549  * Since we are subdividing lower index and
550  * current index reductions it is enough to
551  * look at the polynomial part of the signature
552  * for a check. This should speed-up checking
553  * a lot!
554  * if !strat->sbaOrder == 0
555  * We are not subdividing lower and current index
556  * due to the fact that we are using the induced
557  * Schreyer order
558  *
559  * nevertheless, this different behaviour is
560  * taken care of by is_sigsafe
561  * => one reduction procedure can be used for
562  * both, the incremental and the non-incremental
563  * attempt!
564  * --------------------------------------------
565  *
566  *********************************************/
567  //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
568  if (!PW->is_sigsafe)
569  {
570  poly sigMult = pCopy(PW->sig); // copy signature of reducer
571 //#if 1
572 #ifdef DEBUGF5
573  printf("IN KSREDUCEPOLYSIG: \n");
574  pWrite(pHead(f1));
575  pWrite(pHead(f2));
576  pWrite(sigMult);
577  printf("--------------\n");
578 #endif
579  p_ExpVectorAddSub(sigMult,PR->GetLmCurrRing(),PW->GetLmCurrRing(),currRing);
580  //I have also to set the leading coeficient for sigMult (in the case of rings)
582  {
583  pSetCoeff(sigMult,nMult(nDiv(pGetCoeff(PR->p),pGetCoeff(PW->p)), pGetCoeff(sigMult)));
584  if(nIsZero(pGetCoeff(sigMult)))
585  {
586  sigMult = NULL;
587  }
588  }
589 //#if 1
590 #ifdef DEBUGF5
591  printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
592  pWrite(pHead(f1));
593  pWrite(pHead(f2));
594  pWrite(sigMult);
595  pWrite(PR->sig);
596  printf("--------------\n");
597 #endif
598  int sigSafe;
600  sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
601  // now we can delete the copied polynomial data used for checking for
602  // sig-safeness of the reduction step
603 //#if 1
604 #ifdef DEBUGF5
605  printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
606 
607 #endif
609  {
610  // Set the sig
611  poly origsig = pCopy(PR->sig);
612  if(sigMult != NULL)
613  PR->sig = pHead(pSub(PR->sig, sigMult));
614  //The sigs have the same lm, have to substract
615  //It may happen that now the signature is 0 (drop)
616  if(PR->sig == NULL)
617  {
618  #ifdef ADIDEBUG
619  printf("\nPossible sigdrop in ksreducepolysig (lost signature)\n");
620  #endif
621  strat->sigdrop=TRUE;
622  }
623  else
624  {
625  if(pLtCmp(PR->sig,origsig) == 1)
626  {
627  // do not allow this reduction - it will increase it's signature
628  // and the partially standard basis is just till the old sig, not the new one
629  PR->is_redundant = TRUE;
630  pDelete(&PR->sig);
631  PR->sig = origsig;
632  strat->blockred++;
633  return 3;
634  }
635  if(pLtCmp(PR->sig,origsig) == -1)
636  {
637  #ifdef ADIDEBUG
638  printf("\nSigdrop in ksreducepolysig from * to *\n");pWrite(origsig);pWrite(PR->sig);
639  #endif
640  strat->sigdrop=TRUE;
641  }
642  }
643  pDelete(&origsig);
644  }
645  //pDelete(&f1);
646  // go on with the computations only if the signature of p2 is greater than the
647  // signature of fm*p1
648  if(sigSafe != 1 && !rField_is_Ring(currRing))
649  {
650  PR->is_redundant = TRUE;
651  return 3;
652  }
653  //PW->is_sigsafe = TRUE;
654  }
655  PR->is_redundant = FALSE;
656  poly p1 = PR->GetLmTailRing(); // p2 | p1
657  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
658  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
659  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
660  p_CheckPolyRing(p1, tailRing);
661  p_CheckPolyRing(p2, tailRing);
662 
663  pAssume1(p2 != NULL && p1 != NULL &&
664  p_DivisibleBy(p2, p1, tailRing));
665 
666  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
667  (p_GetComp(p2, tailRing) == 0 &&
668  p_MaxComp(pNext(p2),tailRing) == 0));
669 
670 #ifdef HAVE_PLURAL
671  if (rIsPluralRing(currRing))
672  {
673  // for the time being: we know currRing==strat->tailRing
674  // no exp-bound checking needed
675  // (only needed if exp-bound(tailring)<exp-b(currRing))
676  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
677  else
678  {
679  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
680  assume(_p != NULL);
681  nc_PolyPolyRed(_p, p2, coef, currRing);
682  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
683  PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
684  }
685  return 0;
686  }
687 #endif
688 
689  if (t2==NULL) // Divisor is just one term, therefore it will
690  { // just cancel the leading term
691  PR->LmDeleteAndIter();
692  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
693  return 0;
694  }
695 
696  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
697 
698  if (tailRing != currRing)
699  {
700  // check that reduction does not violate exp bound
701  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
702  {
703  // undo changes of lm
704  p_ExpVectorAdd(lm, p2, tailRing);
705  if (strat == NULL) return 2;
706  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
707  tailRing = strat->tailRing;
708  p1 = PR->GetLmTailRing();
709  p2 = PW->GetLmTailRing();
710  t2 = pNext(p2);
711  lm = p1;
712  p_ExpVectorSub(lm, p2, tailRing);
713  ret = 1;
714  }
715  }
716  // take care of coef buisness
718  {
719  p_SetCoeff(lm, nDiv(pGetCoeff(lm),pGetCoeff(p2)), tailRing);
720  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
721  }
722  else
723  {
724  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
725  {
726  number bn = pGetCoeff(lm);
727  number an = pGetCoeff(p2);
728  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
729  p_SetCoeff(lm, bn, tailRing);
730  if (((ct == 0) || (ct == 2)))
731  PR->Tail_Mult_nn(an);
732  if (coef != NULL) *coef = an;
733  else n_Delete(&an, tailRing->cf);
734  }
735  else
736  {
737  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
738  }
739  }
740 
741  // and finally,
742  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
743  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
744  PR->LmDeleteAndIter();
745 
746  // the following is commented out: shrinking
747 #ifdef HAVE_SHIFTBBA_NONEXISTENT
748  if ( (currRing->isLPring) && (!strat->homog) )
749  {
750  // assume? h->p in currRing
751  PR->GetP();
752  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
753  PR->Clear(); // does the right things
754  PR->p = qq;
755  PR->t_p = NULL;
756  PR->SetShortExpVector();
757  }
758 #endif
759 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
760  if (TEST_OPT_DEBUG)
761  {
762  Print(" to: "); PR->wrp(); Print("\n");
763  }
764 #endif
765  return ret;
766 }
767 
768 /***************************************************************
769  *
770  * Creates S-Poly of p1 and p2
771  *
772  *
773  ***************************************************************/
774 void ksCreateSpoly(LObject* Pair, poly spNoether,
775  int use_buckets, ring tailRing,
776  poly m1, poly m2, TObject** R)
777 {
778 #ifdef KDEBUG
779  create_count++;
780 #endif
781  kTest_L(Pair);
782  poly p1 = Pair->p1;
783  poly p2 = Pair->p2;
784  Pair->tailRing = tailRing;
785 
786  assume(p1 != NULL);
787  assume(p2 != NULL);
788  assume(tailRing != NULL);
789 
790  poly a1 = pNext(p1), a2 = pNext(p2);
791  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
792  int co=0/*, ct = ksCheckCoeff(&lc1, &lc2, currRing->cf)*/; // gcd and zero divisors
793  (void) ksCheckCoeff(&lc1, &lc2, currRing->cf);
794 
795  int l1=0, l2=0;
796 
797  if (p_GetComp(p1, currRing)!=p_GetComp(p2, currRing))
798  {
799  if (p_GetComp(p1, currRing)==0)
800  {
801  co=1;
802  p_SetCompP(p1,p_GetComp(p2, currRing), currRing, tailRing);
803  }
804  else
805  {
806  co=2;
807  p_SetCompP(p2, p_GetComp(p1, currRing), currRing, tailRing);
808  }
809  }
810 
811  // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
812  // m2 = LCM(LM(p1), LM(p2))/LM(p2)
813  if (m1 == NULL)
814  k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing);
815 
816  pSetCoeff0(m1, lc2);
817  pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2)
818 
819  if (R != NULL)
820  {
821  if (Pair->i_r1 == -1)
822  {
823  l1 = pLength(p1) - 1;
824  }
825  else
826  {
827  l1 = (R[Pair->i_r1])->GetpLength() - 1;
828  }
829  if ((Pair->i_r2 == -1)||(R[Pair->i_r2]==NULL))
830  {
831  l2 = pLength(p2) - 1;
832  }
833  else
834  {
835  l2 = (R[Pair->i_r2])->GetpLength() - 1;
836  }
837  }
838 
839  // get m2 * a2
840  if (spNoether != NULL)
841  {
842  l2 = -1;
843  a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
844  assume(l2 == pLength(a2));
845  }
846  else
847  a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
848 #ifdef HAVE_RINGS
849  if (!(rField_is_Domain(currRing))) l2 = pLength(a2);
850 #endif
851 
852  Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
853 
854  // get m2*a2 - m1*a1
855  Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
856 
857  // Clean-up time
858  Pair->LmDeleteAndIter();
859  p_LmDelete(m1, tailRing);
860 
861  if (co != 0)
862  {
863  if (co==1)
864  {
865  p_SetCompP(p1,0, currRing, tailRing);
866  }
867  else
868  {
869  p_SetCompP(p2,0, currRing, tailRing);
870  }
871  }
872 
873  // the following is commented out: shrinking
874 #ifdef HAVE_SHIFTBBA_NONEXISTENT
875  if (currRing->isLPring)
876  {
877  // assume? h->p in currRing
878  Pair->GetP();
879  poly qq = p_Shrink(Pair->p, currRing->isLPring, currRing);
880  Pair->Clear(); // does the right things
881  Pair->p = qq;
882  Pair->t_p = NULL;
883  Pair->SetShortExpVector();
884  }
885 #endif
886 
887 }
888 
889 int ksReducePolyTail(LObject* PR, TObject* PW, poly Current, poly spNoether)
890 {
891  BOOLEAN ret;
892  number coef;
893  poly Lp = PR->GetLmCurrRing();
894  poly Save = PW->GetLmCurrRing();
895 
896  kTest_L(PR);
897  kTest_T(PW);
898  pAssume(pIsMonomOf(Lp, Current));
899 
900  assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
901  assume(PR->bucket == NULL);
902 
903  LObject Red(pNext(Current), PR->tailRing);
904  TObject With(PW, Lp == Save);
905 
906  pAssume(!pHaveCommonMonoms(Red.p, With.p));
907  ret = ksReducePoly(&Red, &With, spNoether, &coef);
908 
909  if (!ret)
910  {
911  if (! n_IsOne(coef, currRing->cf))
912  {
913  pNext(Current) = NULL;
914  if (Current == PR->p && PR->t_p != NULL)
915  pNext(PR->t_p) = NULL;
916  PR->Mult_nn(coef);
917  }
918 
919  n_Delete(&coef, currRing->cf);
920  pNext(Current) = Red.GetLmTailRing();
921  if (Current == PR->p && PR->t_p != NULL)
922  pNext(PR->t_p) = pNext(Current);
923  }
924 
925  if (Lp == Save)
926  With.Delete();
927 
928  // the following is commented out: shrinking
929 #ifdef HAVE_SHIFTBBA_NONEXISTENT
930  if (currRing->isLPring)
931  {
932  // assume? h->p in currRing
933  PR->GetP();
934  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
935  PR->Clear(); // does the right things
936  PR->p = qq;
937  PR->t_p = NULL;
938  PR->SetShortExpVector();
939  }
940 #endif
941 
942  return ret;
943 }
944 
945 int ksReducePolyTailBound(LObject* PR, TObject* PW, int bound, poly Current, poly spNoether)
946 {
947  BOOLEAN ret;
948  number coef;
949  poly Lp = PR->GetLmCurrRing();
950  poly Save = PW->GetLmCurrRing();
951 
952  kTest_L(PR);
953  kTest_T(PW);
954  pAssume(pIsMonomOf(Lp, Current));
955 
956  assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
957  assume(PR->bucket == NULL);
958 
959  LObject Red(pNext(Current), PR->tailRing);
960  TObject With(PW, Lp == Save);
961 
962  pAssume(!pHaveCommonMonoms(Red.p, With.p));
963  ret = ksReducePolyBound(&Red, &With,bound, spNoether, &coef);
964 
965  if (!ret)
966  {
967  if (! n_IsOne(coef, currRing))
968  {
969  pNext(Current) = NULL;
970  if (Current == PR->p && PR->t_p != NULL)
971  pNext(PR->t_p) = NULL;
972  PR->Mult_nn(coef);
973  }
974 
975  n_Delete(&coef, currRing);
976  pNext(Current) = Red.GetLmTailRing();
977  if (Current == PR->p && PR->t_p != NULL)
978  pNext(PR->t_p) = pNext(Current);
979  }
980 
981  if (Lp == Save)
982  With.Delete();
983 
984  // the following is commented out: shrinking
985 #ifdef HAVE_SHIFTBBA_NONEXISTENT
986  if (currRing->isLPring)
987  {
988  // assume? h->p in currRing
989  PR->GetP();
990  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
991  PR->Clear(); // does the right things
992  PR->p = qq;
993  PR->t_p = NULL;
994  PR->SetShortExpVector();
995  }
996 #endif
997 
998  return ret;
999 }
1000 
1001 /***************************************************************
1002  *
1003  * Auxillary Routines
1004  *
1005  *
1006  ***************************************************************/
1007 
1008 /*2
1009 * creates the leading term of the S-polynomial of p1 and p2
1010 * do not destroy p1 and p2
1011 * remarks:
1012 * 1. the coefficient is 0 (nNew)
1013 * 1. a) in the case of coefficient ring, the coefficient is calculated
1014 * 2. pNext is undefined
1015 */
1016 //static void bbb() { int i=0; }
1018 {
1019  poly a1 = pNext(p1), a2 = pNext(p2);
1020  long c1=p_GetComp(p1, currRing),c2=p_GetComp(p2, currRing);
1021  long c;
1022  poly m1,m2;
1023  number t1 = NULL,t2 = NULL;
1024  int cm,i;
1025  BOOLEAN equal;
1026 
1027 #ifdef HAVE_RINGS
1028  BOOLEAN is_Ring=rField_is_Ring(currRing);
1029  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
1030  if (is_Ring)
1031  {
1032  ksCheckCoeff(&lc1, &lc2, currRing->cf); // gcd and zero divisors
1033  if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
1034  if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
1035  while (a1 != NULL && nIsZero(t2))
1036  {
1037  pIter(a1);
1038  nDelete(&t2);
1039  if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
1040  }
1041  while (a2 != NULL && nIsZero(t1))
1042  {
1043  pIter(a2);
1044  nDelete(&t1);
1045  if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
1046  }
1047  }
1048 #endif
1049 
1050  if (a1==NULL)
1051  {
1052  if(a2!=NULL)
1053  {
1054  m2=p_Init(currRing);
1055 x2:
1056  for (i = (currRing->N); i; i--)
1057  {
1058  c = p_GetExpDiff(p1, p2,i, currRing);
1059  if (c>0)
1060  {
1061  p_SetExp(m2,i,(c+p_GetExp(a2,i,tailRing)),currRing);
1062  }
1063  else
1064  {
1065  p_SetExp(m2,i,p_GetExp(a2,i,tailRing),currRing);
1066  }
1067  }
1068  if ((c1==c2)||(c2!=0))
1069  {
1070  p_SetComp(m2,p_GetComp(a2,tailRing), currRing);
1071  }
1072  else
1073  {
1074  p_SetComp(m2,c1,currRing);
1075  }
1076  p_Setm(m2, currRing);
1077 #ifdef HAVE_RINGS
1078  if (is_Ring)
1079  {
1080  nDelete(&lc1);
1081  nDelete(&lc2);
1082  nDelete(&t2);
1083  pSetCoeff0(m2, t1);
1084  }
1085  else
1086 #endif
1087  nNew(&(pGetCoeff(m2)));
1088  return m2;
1089  }
1090  else
1091  {
1092 #ifdef HAVE_RINGS
1093  if (is_Ring)
1094  {
1095  nDelete(&lc1);
1096  nDelete(&lc2);
1097  nDelete(&t1);
1098  nDelete(&t2);
1099  }
1100 #endif
1101  return NULL;
1102  }
1103  }
1104  if (a2==NULL)
1105  {
1106  m1=p_Init(currRing);
1107 x1:
1108  for (i = (currRing->N); i; i--)
1109  {
1110  c = p_GetExpDiff(p2, p1,i,currRing);
1111  if (c>0)
1112  {
1113  p_SetExp(m1,i,(c+p_GetExp(a1,i, tailRing)),currRing);
1114  }
1115  else
1116  {
1117  p_SetExp(m1,i,p_GetExp(a1,i, tailRing), currRing);
1118  }
1119  }
1120  if ((c1==c2)||(c1!=0))
1121  {
1122  p_SetComp(m1,p_GetComp(a1,tailRing),currRing);
1123  }
1124  else
1125  {
1126  p_SetComp(m1,c2,currRing);
1127  }
1128  p_Setm(m1, currRing);
1129 #ifdef HAVE_RINGS
1130  if (is_Ring)
1131  {
1132  pSetCoeff0(m1, t2);
1133  nDelete(&lc1);
1134  nDelete(&lc2);
1135  nDelete(&t1);
1136  }
1137  else
1138 #endif
1139  nNew(&(pGetCoeff(m1)));
1140  return m1;
1141  }
1142  m1 = p_Init(currRing);
1143  m2 = p_Init(currRing);
1144  loop
1145  {
1146  for (i = (currRing->N); i; i--)
1147  {
1148  c = p_GetExpDiff(p1, p2,i,currRing);
1149  if (c > 0)
1150  {
1151  p_SetExp(m2,i,(c+p_GetExp(a2,i,tailRing)), currRing);
1152  p_SetExp(m1,i,p_GetExp(a1,i, tailRing), currRing);
1153  }
1154  else
1155  {
1156  p_SetExp(m1,i,(p_GetExp(a1,i,tailRing)-c), currRing);
1157  p_SetExp(m2,i,p_GetExp(a2,i, tailRing), currRing);
1158  }
1159  }
1160  if(c1==c2)
1161  {
1162  p_SetComp(m1,p_GetComp(a1, tailRing), currRing);
1163  p_SetComp(m2,p_GetComp(a2, tailRing), currRing);
1164  }
1165  else
1166  {
1167  if(c1!=0)
1168  {
1169  p_SetComp(m1,p_GetComp(a1, tailRing), currRing);
1170  p_SetComp(m2,c1, currRing);
1171  }
1172  else
1173  {
1174  p_SetComp(m2,p_GetComp(a2, tailRing), currRing);
1175  p_SetComp(m1,c2, currRing);
1176  }
1177  }
1178  p_Setm(m1,currRing);
1179  p_Setm(m2,currRing);
1180  cm = p_LmCmp(m1, m2,currRing);
1181  if (cm!=0)
1182  {
1183  if(cm==1)
1184  {
1185  p_LmFree(m2,currRing);
1186 #ifdef HAVE_RINGS
1187  if (is_Ring)
1188  {
1189  pSetCoeff0(m1, t2);
1190  nDelete(&lc1);
1191  nDelete(&lc2);
1192  nDelete(&t1);
1193  }
1194  else
1195 #endif
1196  nNew(&(pGetCoeff(m1)));
1197  return m1;
1198  }
1199  else
1200  {
1201  p_LmFree(m1,currRing);
1202 #ifdef HAVE_RINGS
1203  if (is_Ring)
1204  {
1205  pSetCoeff0(m2, t1);
1206  nDelete(&lc1);
1207  nDelete(&lc2);
1208  nDelete(&t2);
1209  }
1210  else
1211 #endif
1212  nNew(&(pGetCoeff(m2)));
1213  return m2;
1214  }
1215  }
1216 #ifdef HAVE_RINGS
1217  if (is_Ring)
1218  {
1219  equal = nEqual(t1,t2);
1220  }
1221  else
1222 #endif
1223  {
1224  t1 = nMult(pGetCoeff(a2),pGetCoeff(p1));
1225  t2 = nMult(pGetCoeff(a1),pGetCoeff(p2));
1226  equal = nEqual(t1,t2);
1227  nDelete(&t2);
1228  nDelete(&t1);
1229  }
1230  if (!equal)
1231  {
1232  p_LmFree(m2,currRing);
1233 #ifdef HAVE_RINGS
1234  if (is_Ring)
1235  {
1236  pSetCoeff0(m1, nSub(t1, t2));
1237  nDelete(&lc1);
1238  nDelete(&lc2);
1239  nDelete(&t1);
1240  nDelete(&t2);
1241  }
1242  else
1243 #endif
1244  nNew(&(pGetCoeff(m1)));
1245  return m1;
1246  }
1247  pIter(a1);
1248  pIter(a2);
1249 #ifdef HAVE_RINGS
1250  if (is_Ring)
1251  {
1252  if (a2 != NULL)
1253  {
1254  nDelete(&t1);
1255  t1 = nMult(pGetCoeff(a2),lc1);
1256  }
1257  if (a1 != NULL)
1258  {
1259  nDelete(&t2);
1260  t2 = nMult(pGetCoeff(a1),lc2);
1261  }
1262  while ((a1 != NULL) && nIsZero(t2))
1263  {
1264  pIter(a1);
1265  if (a1 != NULL)
1266  {
1267  nDelete(&t2);
1268  t2 = nMult(pGetCoeff(a1),lc2);
1269  }
1270  }
1271  while ((a2 != NULL) && nIsZero(t1))
1272  {
1273  pIter(a2);
1274  if (a2 != NULL)
1275  {
1276  nDelete(&t1);
1277  t1 = nMult(pGetCoeff(a2),lc1);
1278  }
1279  }
1280  }
1281 #endif
1282  if (a2==NULL)
1283  {
1284  p_LmFree(m2,currRing);
1285  if (a1==NULL)
1286  {
1287 #ifdef HAVE_RINGS
1288  if (is_Ring)
1289  {
1290  nDelete(&lc1);
1291  nDelete(&lc2);
1292  nDelete(&t1);
1293  nDelete(&t2);
1294  }
1295 #endif
1296  p_LmFree(m1,currRing);
1297  return NULL;
1298  }
1299  goto x1;
1300  }
1301  if (a1==NULL)
1302  {
1303  p_LmFree(m1,currRing);
1304  goto x2;
1305  }
1306  }
1307 }
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
Definition: kInline.h:935
static void nc_kBucketPolyRed(kBucket_pt b, poly p, number *c)
Definition: nc.h:292
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
#define Print
Definition: emacs.cc:83
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
Definition: old.gring.cc:2294
class sLObject LObject
Definition: kutil.h:60
bool sigdrop
Definition: kutil.h:356
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:94
Compatiblity layer for legacy polynomial operations (over currRing)
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
#define pAssume(cond)
Definition: monomials.h:98
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
#define p_GetComp(p, r)
Definition: monomials.h:72
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:1911
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
int ksCheckCoeff(number *a, number *b)
int ksReducePolyTailBound(LObject *PR, TObject *PW, int bound, poly Current, poly spNoether)
Definition: kspoly.cc:945
#define pLtCmp(p, q)
Definition: polys.h:123
#define TRUE
Definition: auxiliary.h:98
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:45
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:480
void pWrite(poly p)
Definition: polys.h:290
#define TEST_OPT_DEBUG
Definition: options.h:103
#define nEqual(n1, n2)
Definition: numbers.h:20
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition: kspoly.cc:1017
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition: pDebug.cc:174
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:407
static void p_LmFree(poly p, ring)
Definition: p_polys.h:678
BOOLEAN pIsMonomOf(poly p, poly m)
Definition: pDebug.cc:164
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:315
#define pIter(p)
Definition: monomials.h:44
poly p_Shrink(poly p, int lV, const ring r)
Definition: shiftgb.cc:373
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition: pDebug.cc:111
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:630
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
bool equal
Definition: cfModGcd.cc:4067
BOOLEAN homog
Definition: kutil.h:369
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
#define pSub(a, b)
Definition: polys.h:269
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
#define assume(x)
Definition: mod2.h:394
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
#define nMult(n1, n2)
Definition: numbers.h:17
const ring R
Definition: DebugPrint.cc:36
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition: kspoly.cc:774
#define kTest_L(T)
Definition: kutil.h:652
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1777
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1467
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition: kutil.cc:11280
#define nSub(n1, n2)
Definition: numbers.h:22
int red_count
Definition: kspoly.cc:28
int i
Definition: cfEzgcd.cc:123
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition: p_polys.h:1363
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1334
static unsigned pLength(poly a)
Definition: p_polys.h:189
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
Definition: polys.h:67
#define nDelete(n)
Definition: numbers.h:16
int int kStrategy strat
Definition: myNF.cc:68
int ksReducePolyBound(LObject *PR, TObject *PW, int bound, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:176
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define nDiv(a, b)
Definition: numbers.h:32
#define nIsZero(n)
Definition: numbers.h:19
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
int create_count
Definition: kspoly.cc:29
ring tailRing
Definition: kutil.h:339
int blockred
Definition: kutil.h:361
#define pDelete(p_ptr)
Definition: polys.h:169
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
#define pSetCoeff0(p, n)
Definition: monomials.h:67
void nNew(number *a)
Definition: numbers.cc:49
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:706
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
#define kTest_T(T)
Definition: kutil.h:650
static void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
Definition: p_polys.h:1379
polyrec * poly
Definition: hilb.h:10
int ksReducePolyTail(LObject *PR, TObject *PW, poly Current, poly spNoether)
Definition: kspoly.cc:889
int BOOLEAN
Definition: auxiliary.h:85
#define pAssume1(cond)
Definition: monomials.h:179
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
class sTObject TObject
Definition: kutil.h:59
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:287
#define pCopy(p)
return a copy of the poly
Definition: polys.h:168
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:513