My Project
Loading...
Searching...
No Matches
kutil.cc File Reference
#include "kernel/mod2.h"
#include "misc/mylimits.h"
#include "misc/options.h"
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#include "polys/weight.h"
#include <stdlib.h>
#include <string.h>
#include "kernel/GBEngine/kutil.h"
#include "polys/kbuckets.h"
#include "coeffs/numbers.h"
#include "kernel/polys.h"
#include "polys/monomials/ring.h"
#include "kernel/ideals.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/GBEngine/kstd1.h"
#include "polys/operations/pShallowCopyDelete.h"
#include "polys/shiftop.h"
#include "polys/prCopy.h"
#include "kernel/GBEngine/ratgring.h"

Go to the source code of this file.

Macros

#define KUTIL_CC
 
#define MYTEST   0
 
#define ALL_VS_JUST   0
 
#define EXT_POLY_NEW   0
 
#define KDEBUG   2
 
#define ENTER_USE_MEMMOVE
 
#define pDivComp_EQUAL   2
 
#define pDivComp_LESS   1
 
#define pDivComp_GREATER   -1
 
#define pDivComp_INCOMP   0
 
#define kFalseReturn(x)
 

Functions

static poly redMora (poly h, int maxIndex, kStrategy strat)
 
static poly redBba (poly h, int maxIndex, kStrategy strat)
 
static int pDivCompRing (poly p, poly q)
 
static int pDivComp (poly p, poly q)
 
static int pLPDivComp (poly p, poly q)
 
static void deleteHCBucket (LObject *L, kStrategy strat)
 
void deleteHC (LObject *L, kStrategy strat, BOOLEAN fromNext)
 
void deleteHC (poly *p, int *e, int *l, kStrategy strat)
 
void cancelunit (LObject *L, BOOLEAN inNF)
 
void HEckeTest (poly pp, kStrategy strat)
 
static intset initec (const int maxnr)
 
static unsigned long * initsevS (const int maxnr)
 
static int * initS_2_R (const int maxnr)
 
static void enlargeT (TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
 
void cleanT (kStrategy strat)
 
void cleanTSbaRing (kStrategy strat)
 
static void enlargeL (LSet *L, int *length, const int incr)
 
void initPairtest (kStrategy strat)
 
BOOLEAN isInPairsetL (int length, poly p1, poly p2, int *k, kStrategy strat)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
int kFindInT (poly p, kStrategy strat)
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindInTShift (poly p, kStrategy strat)
 
static const char * kTest_LmEqual (poly p, poly t_p, ring tailRing)
 
BOOLEAN kTest_T (TObject *T, kStrategy strat, int i, char TN)
 
BOOLEAN kTest_L (LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
 
BOOLEAN kTest (kStrategy strat)
 
BOOLEAN kTest_S (kStrategy strat)
 
BOOLEAN kTest_TS (kStrategy strat)
 
void deleteInS (int i, kStrategy strat)
 
static BOOLEAN is_shifted_p1 (const poly p, const kStrategy strat)
 
void deleteInL (LSet set, int *length, int j, kStrategy strat)
 
void enterL (LSet *set, int *length, int *LSetmax, LObject p, int at)
 
void initEcartNormal (TObject *h)
 
void initEcartBBA (TObject *h)
 
void initEcartPairBba (LObject *Lp, poly, poly, int, int)
 
void initEcartPairMora (LObject *Lp, poly, poly, int ecartF, int ecartG)
 
static BOOLEAN sugarDivisibleBy (int ecart1, int ecart2)
 
static void enterOnePairRing (int i, poly p, int, int isFromQ, kStrategy strat, int atR)
 
static BOOLEAN enterOneStrongPoly (int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
 
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
 
static BOOLEAN enterOneStrongPolySig (int i, poly p, poly sig, int, int, kStrategy strat, int atR)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static BOOLEAN p_HasNotCF_Lift (poly p1, poly p2, const ring r)
 p_HasNotCF for the IDLIFT case and syzComp==1: ignore component
 
static void enterOnePairLift (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static void enterOnePairSig (int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static void enterOnePairSigRing (int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void enterOnePairSpecial (int i, poly p, int ecart, kStrategy strat, int atR=-1)
 
void kMergeBintoL (kStrategy strat)
 
void kMergeBintoLSba (kStrategy strat)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int, kStrategy strat)
 
void chainCritPart (poly p, int ecart, kStrategy strat)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
 
void initenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void initenterpairsSigRing (poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void chainCritRing (poly p, int, kStrategy strat)
 
void initenterstrongPairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static void initenterstrongPairsSig (poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void enterExtendedSpoly (poly h, kStrategy strat)
 
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
 
void clearSbatch (poly h, int k, int pos, kStrategy strat)
 
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterpairsSpecial (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
void reorderS (int *suc, kStrategy strat)
 
int posInS (const kStrategy strat, const int length, const poly p, const int ecart_p)
 
int posInSMonFirst (const kStrategy strat, const int length, const poly p)
 
int posInIdealMonFirst (const ideal F, const poly p, int start, int end)
 
int posInT0 (const TSet, const int length, LObject &)
 
int posInT1 (const TSet set, const int length, LObject &p)
 
int posInT2 (const TSet set, const int length, LObject &p)
 
int posInT11 (const TSet set, const int length, LObject &p)
 
int posInT11Ring (const TSet set, const int length, LObject &p)
 
int posInT110 (const TSet set, const int length, LObject &p)
 
int posInT110Ring (const TSet set, const int length, LObject &p)
 
int posInT13 (const TSet set, const int length, LObject &p)
 
int posInT_EcartpLength (const TSet set, const int length, LObject &p)
 
int posInT15 (const TSet set, const int length, LObject &p)
 
int posInT15Ring (const TSet set, const int length, LObject &p)
 
int posInT17 (const TSet set, const int length, LObject &p)
 
int posInT17Ring (const TSet set, const int length, LObject &p)
 
int posInT17_c (const TSet set, const int length, LObject &p)
 
int posInT17_cRing (const TSet set, const int length, LObject &p)
 
int posInT19 (const TSet set, const int length, LObject &p)
 
int posInLSpecial (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL0 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL0Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInLSig (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInLSigRing (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInSyz (const kStrategy strat, poly sig)
 
int posInLF5C (const LSet, const int, LObject *, const kStrategy strat)
 
int posInL11 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL11Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInLF5CRing (const LSet set, int start, const int length, LObject *p, const kStrategy)
 
int posInL11Ringls (const LSet set, const int length, LObject *p, const kStrategy)
 
int getIndexRng (long coeff)
 
int posInL110 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL110Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL13 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL15 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL15Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17_c (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17_cRing (const LSet set, const int length, LObject *p, const kStrategy)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly, kStrategy strat, int start=0)
 
BOOLEAN arriRewCriterion (poly, unsigned long, poly, kStrategy strat, int start=0)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int)
 
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
 
poly redtail (LObject *L, int end_pos, kStrategy strat)
 
poly redtail (poly p, int end_pos, kStrategy strat)
 
poly redtailBba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
poly redtailBbaBound (LObject *L, int end_pos, kStrategy strat, int bound, BOOLEAN withT, BOOLEAN normalize)
 
void redtailBbaAlsoLC_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_NF (poly p, kStrategy strat)
 
poly redtailBba_Ring (LObject *L, int end_pos, kStrategy strat)
 
void message (int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
 
void messageStat (int hilbcount, kStrategy strat)
 
void messageStatSBA (int hilbcount, kStrategy strat)
 
void messageSets (kStrategy strat)
 
void initS (ideal F, ideal Q, kStrategy strat)
 
void initSL (ideal F, ideal Q, kStrategy strat)
 
void initSLSba (ideal F, ideal Q, kStrategy strat)
 
void initSyzRules (kStrategy strat)
 
void initSSpecial (ideal F, ideal Q, ideal P, kStrategy strat)
 
void initSSpecialSba (ideal F, ideal Q, ideal P, kStrategy strat)
 
static poly redBba1 (poly h, int maxIndex, kStrategy strat)
 
void cancelunit1 (LObject *p, int *suc, int index, kStrategy strat)
 
void updateS (BOOLEAN toT, kStrategy strat)
 
void enterSBba (LObject &p, int atS, kStrategy strat, int atR)
 
void enterSBbaShift (LObject &p, int atS, kStrategy strat, int atR)
 
void enterSSba (LObject &p, int atS, kStrategy strat, int atR)
 
void replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
void enterT (LObject &p, kStrategy strat, int atT)
 
void enterT_strong (LObject &p, kStrategy strat, int atT)
 
void enterSyz (LObject &p, kStrategy strat, int atT)
 
void initHilbCrit (ideal, ideal, bigintmat **hilb, kStrategy strat)
 
void initBuchMoraCrit (kStrategy strat)
 
void initSbaCrit (kStrategy strat)
 
BOOLEAN kPosInLDependsOnLength (int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
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 constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
 
void kStratInitChangeTailRing (kStrategy strat)
 
ring sbaRing (kStrategy strat, const ring r, BOOLEAN, int)
 
int posInT_EcartFDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_FDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_pLength (const TSet set, const int length, LObject &p)
 
int redFirst (LObject *h, kStrategy strat)
 
int redEcart (LObject *h, kStrategy strat)
 
void enterSMora (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSMoraNF (LObject &p, int atS, kStrategy strat, int atR=-1)
 
char * showOption ()
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
 
static BOOLEAN enterOneStrongPolyShift (poly q, poly p, int, int, kStrategy strat, int atR, int, int, int shiftcount, int ifromS)
 
static void enterOnePairRingShift (poly q, poly p, int, int isFromQ, kStrategy strat, int atR, int, int qisFromQ, int shiftcount, int ifromS)
 
static BOOLEAN enterOneStrongPolyAndEnterOnePairRingShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
static BOOLEAN enterOnePairWithShifts (int q_inS, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int, int p_lastVblock, int q_lastVblock)
 
static BOOLEAN enterOnePairWithoutShifts (int p_inS, poly q, poly p, int ecartq, int q_isFromQ, kStrategy strat, int, int p_lastVblock, int q_shift)
 
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void initenterpairsShift (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
 
void initenterstrongPairsShift (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterTShift (LObject p, kStrategy strat, int atT)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 

Variables

VAR denominator_list DENOMINATOR_LIST =NULL
 
VAR int HCord
 
VAR int Kstd1_deg
 
VAR int Kstd1_mu =INT_MAX
 
STATIC_VAR BOOLEAN sloppy_max = FALSE
 

Macro Definition Documentation

◆ ALL_VS_JUST

#define ALL_VS_JUST   0

Definition at line 17 of file kutil.cc.

◆ ENTER_USE_MEMMOVE

#define ENTER_USE_MEMMOVE

Definition at line 47 of file kutil.cc.

◆ EXT_POLY_NEW

#define EXT_POLY_NEW   0

Definition at line 21 of file kutil.cc.

◆ KDEBUG

#define KDEBUG   2

Definition at line 36 of file kutil.cc.

◆ kFalseReturn

#define kFalseReturn ( x)
Value:
do { if (!x) return FALSE;} while (0)
#define FALSE
Definition auxiliary.h:97
Variable x
Definition cfModGcd.cc:4090

Definition at line 772 of file kutil.cc.

◆ KUTIL_CC

#define KUTIL_CC

Definition at line 10 of file kutil.cc.

◆ MYTEST

#define MYTEST   0

Definition at line 12 of file kutil.cc.

◆ pDivComp_EQUAL

#define pDivComp_EQUAL   2

Definition at line 129 of file kutil.cc.

◆ pDivComp_GREATER

#define pDivComp_GREATER   -1

Definition at line 131 of file kutil.cc.

◆ pDivComp_INCOMP

#define pDivComp_INCOMP   0

Definition at line 132 of file kutil.cc.

◆ pDivComp_LESS

#define pDivComp_LESS   1

Definition at line 130 of file kutil.cc.

Function Documentation

◆ arriRewCriterion()

BOOLEAN arriRewCriterion ( poly sig,
unsigned long not_sevSig,
poly lm,
kStrategy strat,
int start = 0 )

Definition at line 6625 of file kutil.cc.

6626{
6628 return FALSE;
6629 poly p1 = pOne();
6630 poly p2 = pOne();
6631 for (int ii=strat->sl; ii>start; ii--)
6632 {
6633 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6634 {
6635 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6636 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6637 if (!(pLmCmp(p1,p2) == 1))
6638 {
6639 pDelete(&p1);
6640 pDelete(&p2);
6641 return TRUE;
6642 }
6643 }
6644 }
6645 pDelete(&p1);
6646 pDelete(&p2);
6647 return FALSE;
6648}
#define TRUE
Definition auxiliary.h:101
polyset S
Definition kutil.h:307
unsigned long * sevSig
Definition kutil.h:325
polyset sig
Definition kutil.h:309
LObject P
Definition kutil.h:303
int sl
Definition kutil.h:349
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1441
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1926
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pDelete(p_ptr)
Definition polys.h:187
#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 pOne()
Definition polys.h:316
#define rField_is_Ring(R)
Definition ring.h:491

◆ arriRewCriterionPre()

BOOLEAN arriRewCriterionPre ( poly sig,
unsigned long not_sevSig,
poly lm,
kStrategy strat,
int start )

Definition at line 6650 of file kutil.cc.

6651{
6652 //Over Rings, there are still some changes to do: considering coeffs
6654 return FALSE;
6655 int found = -1;
6656 for (int i=strat->Bl; i>-1; i--)
6657 {
6658 if (pLmEqual(strat->B[i].sig,sig))
6659 {
6660 found = i;
6661 break;
6662 }
6663 }
6664 if (found != -1)
6665 {
6666 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6667 {
6668 deleteInL(strat->B,&strat->Bl,found,strat);
6669 }
6670 else
6671 {
6672 return TRUE;
6673 }
6674 }
6675 poly p1 = pOne();
6676 poly p2 = pOne();
6677 for (int ii=strat->sl; ii>-1; ii--)
6678 {
6679 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6680 {
6681 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6682 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6683 if (!(pLmCmp(p1,p2) == 1))
6684 {
6685 pDelete(&p1);
6686 pDelete(&p2);
6687 return TRUE;
6688 }
6689 }
6690 }
6691 pDelete(&p1);
6692 pDelete(&p2);
6693 return FALSE;
6694}
int i
Definition cfEzgcd.cc:132
int Bl
Definition kutil.h:353
LSet B
Definition kutil.h:329
bool found
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1215
#define pLmEqual(p1, p2)
Definition polys.h:112

◆ cancelunit()

void cancelunit ( LObject * L,
BOOLEAN inNF )

Definition at line 365 of file kutil.cc.

366{
367 if(rHasGlobalOrdering (currRing)) return;
368 if(TEST_OPT_CANCELUNIT) return;
369
370 ring r = L->tailRing;
371 poly p = L->GetLmTailRing();
372 if(p_GetComp(p, r) != 0 && !p_OneComp(p, r)) return;
373
374 number lc=NULL; /*dummy, is always set if rField_is_Ring(r) */
375 if (rField_is_Ring(r) /*&& (rHasLocalOrMixedOrdering(r))*/)
376 lc = pGetCoeff(p);
377
378 // Leading coef have to be a unit
379 // example 2x+4x2 should be simplified to 2x*(1+2x)
380 // and 2 is not a unit in Z
381 //if ( !(n_IsUnit(pGetCoeff(p), r->cf)) ) return;
382
383 poly h = pNext(p);
384 int i;
385
387 {
388 loop
389 {
390 if (h==NULL)
391 {
392 p_Delete(&pNext(p), r);
393 if (!inNF)
394 {
395 number eins= nCopy(lc);
396 if (L->p != NULL)
397 {
398 pSetCoeff(L->p,eins);
399 if (L->t_p != NULL)
400 pSetCoeff0(L->t_p,eins);
401 }
402 else
403 pSetCoeff(L->t_p,eins);
404 /* p and t_p share the same coeff, if both are !=NULL */
405 /* p==NULL==t_p cannot happen here */
406 }
407 L->ecart = 0;
408 L->length = 1;
409 //if (L->pLength > 0)
410 L->pLength = 1;
411 L->max_exp = NULL;
412
413 if (L->t_p != NULL && pNext(L->t_p) != NULL)
414 p_Delete(&pNext(L->t_p),r);
415 if (L->p != NULL && pNext(L->p) != NULL)
416 pNext(L->p) = NULL;
417 return;
418 }
419 i = rVar(r);
420 loop
421 {
422 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
423 i--;
424 if (i == 0) break; // does divide, try next monom
425 }
426 //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
427 // Note: As long as qring j forbidden if j contains integer (i.e. ground rings are
428 // domains), no zerodivisor test needed CAUTION
429 if (!n_DivBy(pGetCoeff(h),lc,r->cf))
430 {
431 return;
432 }
433 pIter(h);
434 }
435 }
436 else
437 {
438 loop
439 {
440 if (h==NULL)
441 {
442 p_Delete(&pNext(p), r);
443 if (!inNF)
444 {
445 number eins=nInit(1);
446 if (L->p != NULL)
447 {
448 pSetCoeff(L->p,eins);
449 if (L->t_p != NULL)
450 pSetCoeff0(L->t_p,eins);
451 }
452 else
453 pSetCoeff(L->t_p,eins);
454 /* p and t_p share the same coeff, if both are !=NULL */
455 /* p==NULL==t_p cannot happen here */
456 }
457 L->ecart = 0;
458 L->length = 1;
459 //if (L->pLength > 0)
460 L->pLength = 1;
461 L->max_exp = NULL;
462
463 if (L->t_p != NULL && pNext(L->t_p) != NULL)
464 p_Delete(&pNext(L->t_p),r);
465 if (L->p != NULL && pNext(L->p) != NULL)
466 pNext(L->p) = NULL;
467
468 return;
469 }
470 i = rVar(r);
471 loop
472 {
473 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
474 i--;
475 if (i == 0) break; // does divide, try next monom
476 }
477 //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
478 pIter(h);
479 }
480 }
481}
CanonicalForm lc(const CanonicalForm &f)
int p
Definition cfModGcd.cc:4086
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:748
STATIC_VAR Poly * h
Definition janet.cc:971
#define p_GetComp(p, r)
Definition monomials.h:64
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define pSetCoeff0(p, n)
Definition monomials.h:59
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 nCopy(n)
Definition numbers.h:15
#define nInit(i)
Definition numbers.h:24
#define NULL
Definition omList.c:12
#define TEST_OPT_CANCELUNIT
Definition options.h:130
BOOLEAN p_OneComp(poly p, const ring r)
return TRUE if all monoms have the same component
Definition p_polys.cc:1209
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
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
static BOOLEAN rHasGlobalOrdering(const ring r)
Definition ring.h:768
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
#define loop
Definition structs.h:71

◆ cancelunit1()

void cancelunit1 ( LObject * p,
int * suc,
int index,
kStrategy strat )

Definition at line 8404 of file kutil.cc.

8405{
8406 int k;
8407 poly r,h,h1,q;
8408
8409 if (!pIsVector((*p).p) && ((*p).ecart != 0))
8410 {
8411 // Leading coef have to be a unit: no
8412 // example 2x+4x2 should be simplified to 2x*(1+2x)
8413 // and 2 is not a unit in Z
8414 //if ( !(n_IsUnit(pGetCoeff((*p).p), currRing->cf)) ) return;
8415 k = 0;
8416 h1 = r = pCopy((*p).p);
8417 h =pNext(r);
8418 loop
8419 {
8420 if (h==NULL)
8421 {
8422 pDelete(&r);
8423 pDelete(&(pNext((*p).p)));
8424 (*p).ecart = 0;
8425 (*p).length = 1;
8426 (*p).pLength = 1;
8427 (*suc)=0;
8428 return;
8429 }
8430 if (!pDivisibleBy(r,h))
8431 {
8432 q=redBba1(h,index ,strat);
8433 if (q != h)
8434 {
8435 k++;
8436 pDelete(&h);
8437 pNext(h1) = h = q;
8438 }
8439 else
8440 {
8441 pDelete(&r);
8442 return;
8443 }
8444 }
8445 else
8446 {
8447 h1 = h;
8448 pIter(h);
8449 }
8450 if (k > 10)
8451 {
8452 pDelete(&r);
8453 return;
8454 }
8455 }
8456 }
8457}
int k
Definition cfEzgcd.cc:99
static poly redBba1(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8387
static int index(p_Length length, p_Ord ord)
#define pIsVector(p)
Definition polys.h:251
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition polys.h:139
#define pCopy(p)
return a copy of the poly
Definition polys.h:186

◆ chainCritNormal()

void chainCritNormal ( poly p,
int ecart,
kStrategy strat )

Definition at line 3211 of file kutil.cc.

3212{
3213 int i,j,l;
3214
3215 /*
3216 *pairtest[i] is TRUE if spoly(S[i],p) == 0.
3217 *In this case all elements in B such
3218 *that their lcm is divisible by the leading term of S[i] can be canceled
3219 */
3220 if (strat->pairtest!=NULL)
3221 {
3222#ifdef HAVE_SHIFTBBA
3223 // only difference is pLPDivisibleBy instead of pDivisibleBy
3224 if (rIsLPRing(currRing))
3225 {
3226 for (j=0; j<=strat->sl; j++)
3227 {
3228 if (strat->pairtest[j])
3229 {
3230 for (i=strat->Bl; i>=0; i--)
3231 {
3232 if (pLPDivisibleBy(strat->S[j],strat->B[i].lcm))
3233 {
3234 deleteInL(strat->B,&strat->Bl,i,strat);
3235 strat->c3++;
3236 }
3237 }
3238 }
3239 }
3240 }
3241 else
3242#endif
3243 {
3244 /*- i.e. there is an i with pairtest[i]==TRUE -*/
3245 for (j=0; j<=strat->sl; j++)
3246 {
3247 if (strat->pairtest[j])
3248 {
3249 for (i=strat->Bl; i>=0; i--)
3250 {
3251 if (pDivisibleBy(strat->S[j],strat->B[i].lcm))
3252 {
3253 deleteInL(strat->B,&strat->Bl,i,strat);
3254 strat->c3++;
3255 }
3256 }
3257 }
3258 }
3259 }
3260 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3261 strat->pairtest=NULL;
3262 }
3263 if (strat->Gebauer || strat->fromT)
3264 {
3265 if (strat->sugarCrit)
3266 {
3267 /*
3268 *suppose L[j] == (s,r) and p/lcm(s,r)
3269 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3270 *and in case the sugar is o.k. then L[j] can be canceled
3271 */
3272 for (j=strat->Ll; j>=0; j--)
3273 {
3274 if (sugarDivisibleBy(ecart,strat->L[j].ecart)
3275 && ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
3276 && pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3277 {
3278 if (strat->L[j].p == strat->tail)
3279 {
3280 deleteInL(strat->L,&strat->Ll,j,strat);
3281 strat->c3++;
3282 }
3283 }
3284 }
3285 /*
3286 *this is GEBAUER-MOELLER:
3287 *in B all elements with the same lcm except the "best"
3288 *(i.e. the last one in B with this property) will be canceled
3289 */
3290 j = strat->Bl;
3291 loop /*cannot be changed into a for !!! */
3292 {
3293 if (j <= 0) break;
3294 i = j-1;
3295 loop
3296 {
3297 if (i < 0) break;
3298 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3299 {
3300 strat->c3++;
3301 if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart))
3302 {
3303 deleteInL(strat->B,&strat->Bl,i,strat);
3304 j--;
3305 }
3306 else
3307 {
3308 deleteInL(strat->B,&strat->Bl,j,strat);
3309 break;
3310 }
3311 }
3312 i--;
3313 }
3314 j--;
3315 }
3316 }
3317 else /*sugarCrit*/
3318 {
3319 /*
3320 *suppose L[j] == (s,r) and p/lcm(s,r)
3321 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3322 *and in case the sugar is o.k. then L[j] can be canceled
3323 */
3324 for (j=strat->Ll; j>=0; j--)
3325 {
3326 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3327 {
3328 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3329 {
3330 deleteInL(strat->L,&strat->Ll,j,strat);
3331 strat->c3++;
3332 }
3333 }
3334 }
3335 /*
3336 *this is GEBAUER-MOELLER:
3337 *in B all elements with the same lcm except the "best"
3338 *(i.e. the last one in B with this property) will be canceled
3339 */
3340 j = strat->Bl;
3341 loop /*cannot be changed into a for !!! */
3342 {
3343 if (j <= 0) break;
3344 for(i=j-1; i>=0; i--)
3345 {
3346 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3347 {
3348 strat->c3++;
3349 deleteInL(strat->B,&strat->Bl,i,strat);
3350 j--;
3351 }
3352 }
3353 j--;
3354 }
3355 }
3356 /*
3357 *the elements of B enter L
3358 */
3359 kMergeBintoL(strat);
3360 }
3361 else
3362 {
3363 for (j=strat->Ll; j>=0; j--)
3364 {
3365 #ifdef HAVE_SHIFTBBA
3366 if ((strat->L[j].p1!=NULL) &&
3367 pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3368 #else
3369 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3370 #endif
3371 {
3372 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3373 {
3374 deleteInL(strat->L,&strat->Ll,j,strat);
3375 strat->c3++;
3376 }
3377 }
3378 }
3379 /*
3380 *this is our MODIFICATION of GEBAUER-MOELLER:
3381 *First the elements of B enter L,
3382 *then we fix a lcm and the "best" element in L
3383 *(i.e the last in L with this lcm and of type (s,p))
3384 *and cancel all the other elements of type (r,p) with this lcm
3385 *except the case the element (s,r) has also the same lcm
3386 *and is on the worst position with respect to (s,p) and (r,p)
3387 */
3388 /*
3389 *B enters to L/their order with respect to B is permutated for elements
3390 *B[i].p with the same leading term
3391 */
3392 kMergeBintoL(strat);
3393 j = strat->Ll;
3394 loop /*cannot be changed into a for !!! */
3395 {
3396 if (j <= 0)
3397 {
3398 /*now L[0] cannot be canceled any more and the tail can be removed*/
3399 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3400 break;
3401 }
3402 if (strat->L[j].p2 == p)
3403 {
3404 i = j-1;
3405 loop
3406 {
3407 if (i < 0) break;
3408 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3409 {
3410 /*L[i] could be canceled but we search for a better one to cancel*/
3411 strat->c3++;
3412 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3413 && (pNext(strat->L[l].p) == strat->tail)
3414 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3415 && pDivisibleBy(p,strat->L[l].lcm))
3416 {
3417 /*
3418 *"NOT equal(...)" because in case of "equal" the element L[l]
3419 *is "older" and has to be from theoretical point of view behind
3420 *L[i], but we do not want to reorder L
3421 */
3422 strat->L[i].p2 = strat->tail;
3423 /*
3424 *L[l] will be canceled, we cannot cancel L[i] later on,
3425 *so we mark it with "tail"
3426 */
3427 deleteInL(strat->L,&strat->Ll,l,strat);
3428 i--;
3429 }
3430 else
3431 {
3432 deleteInL(strat->L,&strat->Ll,i,strat);
3433 }
3434 j--;
3435 }
3436 i--;
3437 }
3438 }
3439 else if (strat->L[j].p2 == strat->tail)
3440 {
3441 /*now L[j] cannot be canceled any more and the tail can be removed*/
3442 strat->L[j].p2 = p;
3443 }
3444 j--;
3445 }
3446 }
3447}
int BOOLEAN
Definition auxiliary.h:88
int l
Definition cfEzgcd.cc:100
int Ll
Definition kutil.h:352
BOOLEAN * pairtest
Definition kutil.h:334
poly tail
Definition kutil.h:335
char sugarCrit
Definition kutil.h:376
char Gebauer
Definition kutil.h:377
char fromT
Definition kutil.h:378
LSet L
Definition kutil.h:328
int c3
Definition kutil.h:348
int j
Definition facHensel.cc:110
BOOLEAN pCompareChain(poly p, poly p1, poly p2, poly lcm, const ring R)
Returns TRUE if.
Definition kpolys.cc:17
void kMergeBintoL(kStrategy strat)
Definition kutil.cc:3168
static BOOLEAN sugarDivisibleBy(int ecart1, int ecart2)
Definition kutil.cc:1333
BOOLEAN isInPairsetL(int length, poly p1, poly p2, int *k, kStrategy strat)
Definition kutil.cc:694
#define omFreeSize(addr, size)
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417
#define pLPDivisibleBy(a, b)
Definition shiftop.h:57

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly ,
int ,
kStrategy strat )

Definition at line 3452 of file kutil.cc.

3453{
3454 if (strat->pairtest!=NULL)
3455 {
3456 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3457 strat->pairtest=NULL;
3458 }
3459 /*
3460 *the elements of B enter L
3461 */
3462 kMergeBintoL(strat);
3463}

◆ chainCritPart()

void chainCritPart ( poly p,
int ecart,
kStrategy strat )

Definition at line 3527 of file kutil.cc.

3528{
3529 int i,j,l;
3530
3531 /*
3532 *pairtest[i] is TRUE if spoly(S[i],p) == 0.
3533 *In this case all elements in B such
3534 *that their lcm is divisible by the leading term of S[i] can be canceled
3535 */
3536 if (strat->pairtest!=NULL)
3537 {
3538 /*- i.e. there is an i with pairtest[i]==TRUE -*/
3539 for (j=0; j<=strat->sl; j++)
3540 {
3541 if (strat->pairtest[j])
3542 {
3543 for (i=strat->Bl; i>=0; i--)
3544 {
3545 if (_p_LmDivisibleByPart(strat->S[j],currRing,
3546 strat->B[i].lcm,currRing,
3547 currRing->real_var_start,currRing->real_var_end))
3548 {
3549 if(TEST_OPT_DEBUG)
3550 {
3551 Print("chain-crit-part: S[%d]=",j);
3552 p_wrp(strat->S[j],currRing);
3553 Print(" divide B[%d].lcm=",i);
3554 p_wrp(strat->B[i].lcm,currRing);
3555 PrintLn();
3556 }
3557 deleteInL(strat->B,&strat->Bl,i,strat);
3558 strat->c3++;
3559 }
3560 }
3561 }
3562 }
3563 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3564 strat->pairtest=NULL;
3565 }
3566 if (strat->Gebauer || strat->fromT)
3567 {
3568 if (strat->sugarCrit)
3569 {
3570 /*
3571 *suppose L[j] == (s,r) and p/lcm(s,r)
3572 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3573 *and in case the sugar is o.k. then L[j] can be canceled
3574 */
3575 for (j=strat->Ll; j>=0; j--)
3576 {
3577 if (sugarDivisibleBy(ecart,strat->L[j].ecart)
3578 && ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
3579 && pCompareChainPart(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3580 {
3581 if (strat->L[j].p == strat->tail)
3582 {
3583 if(TEST_OPT_DEBUG)
3584 {
3585 PrintS("chain-crit-part: pCompareChainPart p=");
3586 p_wrp(p,currRing);
3587 Print(" delete L[%d]",j);
3588 p_wrp(strat->L[j].lcm,currRing);
3589 PrintLn();
3590 }
3591 deleteInL(strat->L,&strat->Ll,j,strat);
3592 strat->c3++;
3593 }
3594 }
3595 }
3596 /*
3597 *this is GEBAUER-MOELLER:
3598 *in B all elements with the same lcm except the "best"
3599 *(i.e. the last one in B with this property) will be canceled
3600 */
3601 j = strat->Bl;
3602 loop /*cannot be changed into a for !!! */
3603 {
3604 if (j <= 0) break;
3605 i = j-1;
3606 loop
3607 {
3608 if (i < 0) break;
3609 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3610 {
3611 strat->c3++;
3612 if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart))
3613 {
3614 if(TEST_OPT_DEBUG)
3615 {
3616 Print("chain-crit-part: sugar B[%d].lcm=",j);
3617 p_wrp(strat->B[j].lcm,currRing);
3618 Print(" delete B[%d]",i);
3619 p_wrp(strat->B[i].lcm,currRing);
3620 PrintLn();
3621 }
3622 deleteInL(strat->B,&strat->Bl,i,strat);
3623 j--;
3624 }
3625 else
3626 {
3627 if(TEST_OPT_DEBUG)
3628 {
3629 Print("chain-crit-part: sugar B[%d].lcm=",i);
3630 p_wrp(strat->B[i].lcm,currRing);
3631 Print(" delete B[%d]",j);
3632 p_wrp(strat->B[j].lcm,currRing);
3633 PrintLn();
3634 }
3635 deleteInL(strat->B,&strat->Bl,j,strat);
3636 break;
3637 }
3638 }
3639 i--;
3640 }
3641 j--;
3642 }
3643 }
3644 else /*sugarCrit*/
3645 {
3646 /*
3647 *suppose L[j] == (s,r) and p/lcm(s,r)
3648 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3649 *and in case the sugar is o.k. then L[j] can be canceled
3650 */
3651 for (j=strat->Ll; j>=0; j--)
3652 {
3653 if (pCompareChainPart(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3654 {
3655 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3656 {
3657 if(TEST_OPT_DEBUG)
3658 {
3659 PrintS("chain-crit-part: sugar:pCompareChainPart p=");
3660 p_wrp(p,currRing);
3661 Print(" delete L[%d]",j);
3662 p_wrp(strat->L[j].lcm,currRing);
3663 PrintLn();
3664 }
3665 deleteInL(strat->L,&strat->Ll,j,strat);
3666 strat->c3++;
3667 }
3668 }
3669 }
3670 /*
3671 *this is GEBAUER-MOELLER:
3672 *in B all elements with the same lcm except the "best"
3673 *(i.e. the last one in B with this property) will be canceled
3674 */
3675 j = strat->Bl;
3676 loop /*cannot be changed into a for !!! */
3677 {
3678 if (j <= 0) break;
3679 for(i=j-1; i>=0; i--)
3680 {
3681 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3682 {
3683 if(TEST_OPT_DEBUG)
3684 {
3685 Print("chain-crit-part: equal lcm B[%d].lcm=",j);
3686 p_wrp(strat->B[j].lcm,currRing);
3687 Print(" delete B[%d]\n",i);
3688 }
3689 strat->c3++;
3690 deleteInL(strat->B,&strat->Bl,i,strat);
3691 j--;
3692 }
3693 }
3694 j--;
3695 }
3696 }
3697 /*
3698 *the elements of B enter L
3699 */
3700 kMergeBintoL(strat);
3701 }
3702 else
3703 {
3704 for (j=strat->Ll; j>=0; j--)
3705 {
3706 if (pCompareChainPart(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3707 {
3708 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3709 {
3710 if(TEST_OPT_DEBUG)
3711 {
3712 PrintS("chain-crit-part: pCompareChainPart p=");
3713 p_wrp(p,currRing);
3714 Print(" delete L[%d]",j);
3715 p_wrp(strat->L[j].lcm,currRing);
3716 PrintLn();
3717 }
3718 deleteInL(strat->L,&strat->Ll,j,strat);
3719 strat->c3++;
3720 }
3721 }
3722 }
3723 /*
3724 *this is our MODIFICATION of GEBAUER-MOELLER:
3725 *First the elements of B enter L,
3726 *then we fix a lcm and the "best" element in L
3727 *(i.e the last in L with this lcm and of type (s,p))
3728 *and cancel all the other elements of type (r,p) with this lcm
3729 *except the case the element (s,r) has also the same lcm
3730 *and is on the worst position with respect to (s,p) and (r,p)
3731 */
3732 /*
3733 *B enters to L/their order with respect to B is permutated for elements
3734 *B[i].p with the same leading term
3735 */
3736 kMergeBintoL(strat);
3737 j = strat->Ll;
3738 loop /*cannot be changed into a for !!! */
3739 {
3740 if (j <= 0)
3741 {
3742 /*now L[0] cannot be canceled any more and the tail can be removed*/
3743 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3744 break;
3745 }
3746 if (strat->L[j].p2 == p)
3747 {
3748 i = j-1;
3749 loop
3750 {
3751 if (i < 0) break;
3752 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3753 {
3754 /*L[i] could be canceled but we search for a better one to cancel*/
3755 strat->c3++;
3756 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3757 && (pNext(strat->L[l].p) == strat->tail)
3758 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3760 strat->L[l].lcm,currRing,
3761 currRing->real_var_start, currRing->real_var_end))
3762
3763 {
3764 /*
3765 *"NOT equal(...)" because in case of "equal" the element L[l]
3766 *is "older" and has to be from theoretical point of view behind
3767 *L[i], but we do not want to reorder L
3768 */
3769 strat->L[i].p2 = strat->tail;
3770 /*
3771 *L[l] will be canceled, we cannot cancel L[i] later on,
3772 *so we mark it with "tail"
3773 */
3774 if(TEST_OPT_DEBUG)
3775 {
3776 PrintS("chain-crit-part: divisible_by p=");
3777 p_wrp(p,currRing);
3778 Print(" delete L[%d]",l);
3779 p_wrp(strat->L[l].lcm,currRing);
3780 PrintLn();
3781 }
3782 deleteInL(strat->L,&strat->Ll,l,strat);
3783 i--;
3784 }
3785 else
3786 {
3787 if(TEST_OPT_DEBUG)
3788 {
3789 PrintS("chain-crit-part: divisible_by(2) p=");
3790 p_wrp(p,currRing);
3791 Print(" delete L[%d]",i);
3792 p_wrp(strat->L[i].lcm,currRing);
3793 PrintLn();
3794 }
3795 deleteInL(strat->L,&strat->Ll,i,strat);
3796 }
3797 j--;
3798 }
3799 i--;
3800 }
3801 }
3802 else if (strat->L[j].p2 == strat->tail)
3803 {
3804 /*now L[j] cannot be canceled any more and the tail can be removed*/
3805 strat->L[j].p2 = p;
3806 }
3807 j--;
3808 }
3809 }
3810}
#define Print
Definition emacs.cc:80
BOOLEAN pCompareChainPart(poly p, poly p1, poly p2, poly lcm, const ring R)
Definition kpolys.cc:71
#define TEST_OPT_DEBUG
Definition options.h:110
static BOOLEAN _p_LmDivisibleByPart(poly a, const ring r_a, poly b, const ring r_b, const int start, const int end)
Definition p_polys.h:1872
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310

◆ chainCritRing()

void chainCritRing ( poly p,
int ,
kStrategy strat )

Definition at line 4003 of file kutil.cc.

4004{
4005 int i,j,l;
4006 /*
4007 *pairtest[i] is TRUE if spoly(S[i],p) == 0.
4008 *In this case all elements in B such
4009 *that their lcm is divisible by the leading term of S[i] can be canceled
4010 */
4011 if (strat->pairtest!=NULL)
4012 {
4013 {
4014 /*- i.e. there is an i with pairtest[i]==TRUE -*/
4015 for (j=0; j<=strat->sl; j++)
4016 {
4017 if (strat->pairtest[j])
4018 {
4019 for (i=strat->Bl; i>=0; i--)
4020 {
4021 if (pDivisibleBy(strat->S[j],strat->B[i].lcm) && n_DivBy(pGetCoeff(strat->B[i].lcm), pGetCoeff(strat->S[j]),currRing->cf))
4022 {
4023#ifdef KDEBUG
4024 if (TEST_OPT_DEBUG)
4025 {
4026 PrintS("--- chain criterion func chainCritRing type 1\n");
4027 PrintS("strat->S[j]:");
4028 wrp(strat->S[j]);
4029 PrintS(" strat->B[i].lcm:");
4030 wrp(strat->B[i].lcm);PrintLn();
4031 pWrite(strat->B[i].p);
4032 pWrite(strat->B[i].p1);
4033 pWrite(strat->B[i].p2);
4034 wrp(strat->B[i].lcm);
4035 PrintLn();
4036 }
4037#endif
4038 deleteInL(strat->B,&strat->Bl,i,strat);
4039 strat->c3++;
4040 }
4041 }
4042 }
4043 }
4044 }
4045 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
4046 strat->pairtest=NULL;
4047 }
4048 assume(!(strat->Gebauer || strat->fromT));
4049 for (j=strat->Ll; j>=0; j--)
4050 {
4051 if ((strat->L[j].lcm != NULL) && n_DivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(p), currRing->cf))
4052 {
4053 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
4054 {
4055 if ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
4056 {
4057 deleteInL(strat->L,&strat->Ll,j,strat);
4058 strat->c3++;
4059#ifdef KDEBUG
4060 if (TEST_OPT_DEBUG)
4061 {
4062 PrintS("--- chain criterion func chainCritRing type 2\n");
4063 PrintS("strat->L[j].p:");
4064 wrp(strat->L[j].p);
4065 PrintS(" p:");
4066 wrp(p);
4067 PrintLn();
4068 }
4069#endif
4070 }
4071 }
4072 }
4073 }
4074 /*
4075 *this is our MODIFICATION of GEBAUER-MOELLER:
4076 *First the elements of B enter L,
4077 *then we fix a lcm and the "best" element in L
4078 *(i.e the last in L with this lcm and of type (s,p))
4079 *and cancel all the other elements of type (r,p) with this lcm
4080 *except the case the element (s,r) has also the same lcm
4081 *and is on the worst position with respect to (s,p) and (r,p)
4082 */
4083 /*
4084 *B enters to L/their order with respect to B is permutated for elements
4085 *B[i].p with the same leading term
4086 */
4087 kMergeBintoL(strat);
4088 j = strat->Ll;
4089 loop /*cannot be changed into a for !!! */
4090 {
4091 if (j <= 0)
4092 {
4093 /*now L[0] cannot be canceled any more and the tail can be removed*/
4094 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
4095 break;
4096 }
4097 if (strat->L[j].p2 == p) // Was the element added from B?
4098 {
4099 i = j-1;
4100 loop
4101 {
4102 if (i < 0) break;
4103 // Element is from B and has the same lcm as L[j]
4104 if ((strat->L[i].p2 == p) && n_DivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(strat->L[i].lcm), currRing->cf)
4105 && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
4106 {
4107 /*L[i] could be canceled but we search for a better one to cancel*/
4108 strat->c3++;
4109#ifdef KDEBUG
4110 if (TEST_OPT_DEBUG)
4111 {
4112 PrintS("--- chain criterion func chainCritRing type 3\n");
4113 PrintS("strat->L[j].lcm:");
4114 wrp(strat->L[j].lcm);
4115 PrintS(" strat->L[i].lcm:");
4116 wrp(strat->L[i].lcm);
4117 PrintLn();
4118 }
4119#endif
4120 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
4121 && (pNext(strat->L[l].p) == strat->tail)
4122 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
4123 && pDivisibleBy(p,strat->L[l].lcm))
4124 {
4125 /*
4126 *"NOT equal(...)" because in case of "equal" the element L[l]
4127 *is "older" and has to be from theoretical point of view behind
4128 *L[i], but we do not want to reorder L
4129 */
4130 strat->L[i].p2 = strat->tail;
4131 /*
4132 *L[l] will be canceled, we cannot cancel L[i] later on,
4133 *so we mark it with "tail"
4134 */
4135 deleteInL(strat->L,&strat->Ll,l,strat);
4136 i--;
4137 }
4138 else
4139 {
4140 deleteInL(strat->L,&strat->Ll,i,strat);
4141 }
4142 j--;
4143 }
4144 i--;
4145 }
4146 }
4147 else if (strat->L[j].p2 == strat->tail)
4148 {
4149 /*now L[j] cannot be canceled any more and the tail can be removed*/
4150 strat->L[j].p2 = p;
4151 }
4152 j--;
4153 }
4154}
#define assume(x)
Definition mod2.h:389
void wrp(poly p)
Definition polys.h:311
void pWrite(poly p)
Definition polys.h:309

◆ chainCritSig()

void chainCritSig ( poly p,
int ecart,
kStrategy strat )

Definition at line 3468 of file kutil.cc.

3469{
3470 int i,j,l;
3471 kMergeBintoLSba(strat);
3472 j = strat->Ll;
3473 loop /*cannot be changed into a for !!! */
3474 {
3475 if (j <= 0)
3476 {
3477 /*now L[0] cannot be canceled any more and the tail can be removed*/
3478 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3479 break;
3480 }
3481 if (strat->L[j].p2 == p)
3482 {
3483 i = j-1;
3484 loop
3485 {
3486 if (i < 0) break;
3487 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3488 {
3489 /*L[i] could be canceled but we search for a better one to cancel*/
3490 strat->c3++;
3491 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3492 && (pNext(strat->L[l].p) == strat->tail)
3493 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3494 && pDivisibleBy(p,strat->L[l].lcm))
3495 {
3496 /*
3497 *"NOT equal(...)" because in case of "equal" the element L[l]
3498 *is "older" and has to be from theoretical point of view behind
3499 *L[i], but we do not want to reorder L
3500 */
3501 strat->L[i].p2 = strat->tail;
3502 /*
3503 *L[l] will be canceled, we cannot cancel L[i] later on,
3504 *so we mark it with "tail"
3505 */
3506 deleteInL(strat->L,&strat->Ll,l,strat);
3507 i--;
3508 }
3509 else
3510 {
3511 deleteInL(strat->L,&strat->Ll,i,strat);
3512 }
3513 j--;
3514 }
3515 i--;
3516 }
3517 }
3518 else if (strat->L[j].p2 == strat->tail)
3519 {
3520 /*now L[j] cannot be canceled any more and the tail can be removed*/
3521 strat->L[j].p2 = p;
3522 }
3523 j--;
3524 }
3525}
void kMergeBintoLSba(kStrategy strat)
Definition kutil.cc:3189

◆ cleanT()

void cleanT ( kStrategy strat)

Definition at line 557 of file kutil.cc.

558{
559 int i,j;
560 poly p;
561 assume(currRing == strat->tailRing || strat->tailRing != NULL);
562
563 pShallowCopyDeleteProc p_shallow_copy_delete =
564 (strat->tailRing != currRing ?
566 NULL);
567 for (j=0; j<=strat->tl; j++)
568 {
569 p = strat->T[j].p;
570 strat->T[j].p=NULL;
571 if (strat->T[j].max_exp != NULL)
572 {
573 p_LmFree(strat->T[j].max_exp, strat->tailRing);
574 }
575 i = -1;
576 loop
577 {
578 i++;
579 if (i>strat->sl)
580 {
581 if (strat->T[j].t_p != NULL)
582 {
583 p_Delete(&(strat->T[j].t_p), strat->tailRing);
585 }
586 else
587 {
588#ifdef HAVE_SHIFTBBA
589 if (currRing->isLPring && strat->T[j].shift > 0)
590 {
591 pNext(p) = NULL; // pNext(p) points to the unshifted tail, don't try to delete it here
592 }
593#endif
594 pDelete(&p);
595 }
596 break;
597 }
598 if (p == strat->S[i])
599 {
600 if (strat->T[j].t_p != NULL)
601 {
602 if (p_shallow_copy_delete!=NULL)
603 {
604 pNext(p) = p_shallow_copy_delete(pNext(p),strat->tailRing,currRing,
605 currRing->PolyBin);
606 }
607 p_LmFree(strat->T[j].t_p, strat->tailRing);
608 }
609 break;
610 }
611 }
612 }
613 strat->tl=-1;
614}
ring tailRing
Definition kutil.h:344
TSet T
Definition kutil.h:327
int tl
Definition kutil.h:351
pShallowCopyDeleteProc pGetShallowCopyDeleteProc(ring, ring)
static void p_LmFree(poly p, ring)
Definition p_polys.h:685
poly(* pShallowCopyDeleteProc)(poly s_p, ring source_r, ring dest_r, omBin dest_bin)
returns a poly from dest_r which is a ShallowCopy of s_p from source_r assumes that source_r->N == de...
Definition ring.h:45

◆ cleanTSbaRing()

void cleanTSbaRing ( kStrategy strat)

Definition at line 616 of file kutil.cc.

617{
618 int i,j;
619 poly p;
620 assume(currRing == strat->tailRing || strat->tailRing != NULL);
621
622 pShallowCopyDeleteProc p_shallow_copy_delete =
623 (strat->tailRing != currRing ?
625 NULL);
626 for (j=0; j<=strat->tl; j++)
627 {
628 p = strat->T[j].p;
629 strat->T[j].p=NULL;
630 if (strat->T[j].max_exp != NULL)
631 {
632 p_LmFree(strat->T[j].max_exp, strat->tailRing);
633 }
634 i = -1;
635 loop
636 {
637 i++;
638 if (i>strat->sl)
639 {
640 if (strat->T[j].t_p != NULL)
641 {
642 p_Delete(&(strat->T[j].t_p), strat->tailRing);
644 }
645 else
646 {
647 //pDelete(&p);
648 p = NULL;
649 }
650 break;
651 }
652 if (p == strat->S[i])
653 {
654 if (strat->T[j].t_p != NULL)
655 {
656 assume(p_shallow_copy_delete != NULL);
657 pNext(p) = p_shallow_copy_delete(pNext(p),strat->tailRing,currRing,
658 currRing->PolyBin);
659 p_LmFree(strat->T[j].t_p, strat->tailRing);
660 }
661 break;
662 }
663 }
664 }
665 strat->tl=-1;
666}

◆ clearSbatch()

void clearSbatch ( poly h,
int k,
int pos,
kStrategy strat )

Definition at line 4440 of file kutil.cc.

4441{
4442 int j = pos;
4443 if ( (!strat->fromT)
4444 && ((strat->syzComp==0)
4445 ||(pGetComp(h)<=strat->syzComp)
4446 ))
4447 {
4448 // Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl);
4449 unsigned long h_sev = pGetShortExpVector(h);
4450 loop
4451 {
4452 if (j > k) break;
4453 clearS(h,h_sev, &j,&k,strat);
4454 j++;
4455 }
4456 // Print("end clearS sl=%d\n",strat->sl);
4457 }
4458}
int syzComp
Definition kutil.h:355
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition kInline.h:1232
#define pGetComp(p)
Component.
Definition polys.h:38
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153

◆ completeReduce()

void completeReduce ( kStrategy strat,
BOOLEAN withT )

Definition at line 10287 of file kutil.cc.

10288{
10289 int i;
10290 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10291 LObject L;
10292
10293#ifdef KDEBUG
10294 // need to set this: during tailreductions of T[i], T[i].max is out of
10295 // sync
10296 sloppy_max = TRUE;
10297#endif
10298
10299 strat->noTailReduction = FALSE;
10300 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10301 if (TEST_OPT_PROT)
10302 {
10303 PrintLn();
10304// if (timerv) writeTime("standard base computed:");
10305 }
10306 if (TEST_OPT_PROT)
10307 {
10308 Print("(S:%d)",strat->sl);mflush();
10309 }
10310 for (i=strat->sl; i>=low; i--)
10311 {
10312 int end_pos=strat->sl;
10313 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10314 if (strat->ak==0) end_pos=i-1;
10315 TObject* T_j = strat->s_2_t(i);
10316 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10317 {
10318 L = *T_j;
10319 #ifdef KDEBUG
10320 if (TEST_OPT_DEBUG)
10321 {
10322 Print("test S[%d]:",i);
10323 p_wrp(L.p,currRing,strat->tailRing);
10324 PrintLn();
10325 }
10326 #endif
10328 strat->S[i] = redtailBba(&L, end_pos, strat, withT,FALSE /*no normalize*/);
10329 else
10330 strat->S[i] = redtail(&L, strat->sl, strat);
10331 #ifdef KDEBUG
10332 if (TEST_OPT_DEBUG)
10333 {
10334 Print("to (tailR) S[%d]:",i);
10335 p_wrp(strat->S[i],currRing,strat->tailRing);
10336 PrintLn();
10337 }
10338 #endif
10339
10340 if (strat->redTailChange)
10341 {
10342 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10343 if (pNext(T_j->p) != NULL)
10344 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10345 else
10346 T_j->max_exp = NULL;
10347 }
10349 T_j->pCleardenom();
10350 }
10351 else
10352 {
10353 assume(currRing == strat->tailRing);
10354 #ifdef KDEBUG
10355 if (TEST_OPT_DEBUG)
10356 {
10357 Print("test S[%d]:",i);
10358 p_wrp(strat->S[i],currRing,strat->tailRing);
10359 PrintLn();
10360 }
10361 #endif
10363 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10364 else
10365 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10367 {
10369 {
10370 number n;
10371 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10372 if (!nIsOne(n))
10373 {
10375 denom->n=nInvers(n);
10376 denom->next=DENOMINATOR_LIST;
10377 DENOMINATOR_LIST=denom;
10378 }
10379 nDelete(&n);
10380 }
10381 else
10382 {
10383 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10384 }
10385 }
10386 #ifdef KDEBUG
10387 if (TEST_OPT_DEBUG)
10388 {
10389 Print("to (-tailR) S[%d]:",i);
10390 p_wrp(strat->S[i],currRing,strat->tailRing);
10391 PrintLn();
10392 }
10393 #endif
10394 }
10395 if (TEST_OPT_PROT)
10396 PrintS("-");
10397 }
10398 if (TEST_OPT_PROT) PrintLn();
10399#ifdef KDEBUG
10400 sloppy_max = FALSE;
10401#endif
10402}
char noTailReduction
Definition kutil.h:377
int ak
Definition kutil.h:354
KINLINE TObject * s_2_t(int i)
Definition kInline.h:47
intset fromQ
Definition kutil.h:322
char redTailChange
Definition kutil.h:398
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:6840
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kutil.cc:6916
STATIC_VAR BOOLEAN sloppy_max
Definition kutil.cc:795
VAR denominator_list DENOMINATOR_LIST
Definition kutil.cc:79
denominator_list_s * denominator_list
Definition kutil.h:64
denominator_list next
Definition kutil.h:66
class sTObject TObject
Definition kutil.h:58
class sLObject LObject
Definition kutil.h:59
#define nDelete(n)
Definition numbers.h:16
#define nInvers(a)
Definition numbers.h:33
#define nIsOne(n)
Definition numbers.h:25
#define omAlloc(size)
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define TEST_OPT_PROT
Definition options.h:105
#define TEST_OPT_CONTENTSB
Definition options.h:129
poly p_GetMaxExpP(poly p, const ring r)
return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0,...
Definition p_polys.cc:1139
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition p_polys.cc:2958
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
#define mflush()
Definition reporter.h:58

◆ deleteHC() [1/2]

void deleteHC ( LObject * L,
kStrategy strat,
BOOLEAN fromNext )

Definition at line 286 of file kutil.cc.

287{
288 if (strat->kNoether!=NULL)
289 {
290 kTest_L(L,strat);
291 poly p1;
292 poly p = L->GetLmTailRing();
293 int l = 1;
294
295 if (!fromNext && p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
296 {
297 if (L->bucket != NULL) kBucketDestroy(&L->bucket);
298 L->Delete();
299 L->Clear();
300 L->ecart = -1;
301 return;
302 }
303 if (L->bucket != NULL)
304 {
305 deleteHCBucket(L,strat);
306 return;
307 }
308 BOOLEAN cut=FALSE;
309 p1 = p;
310 while (pNext(p1)!=NULL)
311 {
312 if (p_LmCmp(pNext(p1), strat->kNoetherTail(), L->tailRing) == -1)
313 {
314 cut=(pNext(p1)!=NULL);
315 if (cut)
316 {
317 p_Delete(&pNext(p1), L->tailRing);
318
319 if (p1 == p)
320 {
321 if (L->t_p != NULL)
322 {
323 assume(L->p != NULL && p == L->t_p);
324 pNext(L->p) = NULL;
325 }
326 L->max_exp = NULL;
327 }
328 else if (fromNext)
329 L->max_exp = p_GetMaxExpP(pNext(L->p), L->tailRing ); // p1;
330 //if (L->pLength != 0)
331 L->pLength = l;
332 // Hmmm when called from updateT, then only
333 // reset ecart when cut
334 if (fromNext)
335 L->ecart = L->pLDeg() - L->GetpFDeg();
336 }
337 break;
338 }
339 l++;
340 pIter(p1);
341 }
342 if ((!fromNext) && cut)
343 {
344 L->SetpFDeg();
345 L->ecart = L->pLDeg(strat->LDegLast) - L->GetpFDeg();
346 }
347 kTest_L(L,strat);
348 }
349}
KINLINE poly kNoetherTail()
Definition kInline.h:66
poly kNoether
Definition kutil.h:330
char LDegLast
Definition kutil.h:384
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition kbuckets.cc:216
static void deleteHCBucket(LObject *L, kStrategy strat)
Definition kutil.cc:243
BOOLEAN kTest_L(LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
Definition kutil.cc:923
static int p_Cmp(poly p1, poly p2, ring r)
Definition p_polys.h:1743
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1596

◆ deleteHC() [2/2]

void deleteHC ( poly * p,
int * e,
int * l,
kStrategy strat )

Definition at line 351 of file kutil.cc.

352{
353 LObject L(*p, currRing, strat->tailRing);
354
355 deleteHC(&L, strat);
356 *p = L.p;
357 *e = L.ecart;
358 *l = L.length;
359 if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
360}
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition kutil.cc:286

◆ deleteHCBucket()

static void deleteHCBucket ( LObject * L,
kStrategy strat )
static

Definition at line 243 of file kutil.cc.

244{
245 if ((strat->kNoether!=NULL)
246 && (L->bucket != NULL))
247 {
248 for (int i=1; i<= (int) L->bucket->buckets_used; i++)
249 {
250 poly p=L->bucket->buckets[i];
251 if(p!=NULL)
252 {
253 if (p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
254 {
255 L->bucket->buckets[i]=NULL;
256 L->bucket->buckets_length[i]=0;
257 }
258 else
259 {
260 do
261 {
262 if (p_Cmp(pNext(p),strat->kNoetherTail(), L->tailRing) == -1)
263 {
264 p_Delete(&pNext(p), L->tailRing);
265 L->bucket->buckets_length[i]=pLength(L->bucket->buckets[i]);
266 break;
267 }
268 pIter(p);
269 } while(p!=NULL);
270 }
271 }
272 }
273 int i=L->bucket->buckets_used;
274 while ((i>0)&&(L->bucket->buckets[i]==NULL))
275 {
276 i--;
277 L->bucket->buckets_used=i;
278 }
279 }
280}
static int pLength(poly a)
Definition p_polys.h:190

◆ deleteInL()

void deleteInL ( LSet set,
int * length,
int j,
kStrategy strat )

Definition at line 1215 of file kutil.cc.

1216{
1217 if (set[j].lcm!=NULL)
1218 {
1219 kDeleteLcm(&set[j]);
1220 }
1221 if (set[j].sig!=NULL)
1222 {
1223 if (pGetCoeff(set[j].sig) != NULL)
1224 pLmDelete(set[j].sig);
1225 else
1226 pLmFree(set[j].sig);
1227 }
1228 if (set[j].p!=NULL)
1229 {
1230 if (pNext(set[j].p) == strat->tail)
1231 {
1232 if (pGetCoeff(set[j].p) != NULL)
1233 pLmDelete(set[j].p);
1234 else
1235 pLmFree(set[j].p);
1236 /*- tail belongs to several int spolys -*/
1237 }
1238 else
1239 {
1240 // search p in T, if it is there, do not delete it
1241 if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1242 {
1243 // assure that for global orderings kFindInT fails
1244 //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1245 set[j].Delete();
1246 }
1247 }
1248 }
1249 #ifdef HAVE_SHIFTBBA
1250 if (is_shifted_p1(strat->P.p1,strat))
1251 {
1252 // clean up strat->P.p1: may be shifted
1253 pLmDelete(strat->P.p1);
1254 strat->P.p1=NULL;
1255 }
1256 #endif
1257 if (*length > 0 && j < *length)
1258 {
1259#ifdef ENTER_USE_MEMMOVE
1260 memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1261#else
1262 int i;
1263 for (i=j; i < (*length); i++)
1264 set[i] = set[i+1];
1265#endif
1266 }
1267#ifdef KDEBUG
1268 set[*length].Init();
1269#endif
1270 (*length)--;
1271}
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
int kFindInT(poly p, TSet T, int tlength)
returns index of p in TSet, or -1 if not found
Definition kutil.cc:710
static BOOLEAN is_shifted_p1(const poly p, const kStrategy strat)
Definition kutil.cc:1188
static void kDeleteLcm(LObject *P)
Definition kutil.h:870
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:709
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
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

◆ deleteInS()

void deleteInS ( int i,
kStrategy strat )

Definition at line 1139 of file kutil.cc.

1140{
1141#ifdef ENTER_USE_MEMMOVE
1142 memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1143 memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1144 memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1145 memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1146#else
1147 int j;
1148 for (j=i; j<strat->sl; j++)
1149 {
1150 strat->S[j] = strat->S[j+1];
1151 strat->ecartS[j] = strat->ecartS[j+1];
1152 strat->sevS[j] = strat->sevS[j+1];
1153 strat->S_2_R[j] = strat->S_2_R[j+1];
1154 }
1155#endif
1156 if (strat->lenS!=NULL)
1157 {
1158#ifdef ENTER_USE_MEMMOVE
1159 memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1160#else
1161 for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1162#endif
1163 }
1164 if (strat->lenSw!=NULL)
1165 {
1166#ifdef ENTER_USE_MEMMOVE
1167 memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1168#else
1169 for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1170#endif
1171 }
1172 if (strat->fromQ!=NULL)
1173 {
1174#ifdef ENTER_USE_MEMMOVE
1175 memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1176#else
1177 for (j=i; j<strat->sl; j++)
1178 {
1179 strat->fromQ[j] = strat->fromQ[j+1];
1180 }
1181#endif
1182 }
1183 strat->S[strat->sl] = NULL;
1184 strat->sl--;
1185}
int * S_2_R
Definition kutil.h:343
intset lenS
Definition kutil.h:320
intset ecartS
Definition kutil.h:310
wlen_set lenSw
Definition kutil.h:321
unsigned long * sevS
Definition kutil.h:323
int64 wlen_type
Definition kutil.h:55

◆ enlargeL()

static void enlargeL ( LSet * L,
int * length,
const int incr )
inlinestatic

Definition at line 675 of file kutil.cc.

676{
677 assume((*L)!=NULL);
678 assume(((*length)+incr)>0);
679
680 *L = (LSet)omReallocSize((*L),(*length)*sizeof(LObject),
681 ((*length)+incr)*sizeof(LObject));
682 (*length) += incr;
683}
LObject * LSet
Definition kutil.h:61
#define omReallocSize(addr, o_size, size)

◆ enlargeT()

static void enlargeT ( TSet & T,
TObject **& R,
unsigned long *& sevT,
int & length,
const int incr )
inlinestatic

Definition at line 536 of file kutil.cc.

538{
539 assume(T!=NULL);
540 assume(sevT!=NULL);
541 assume(R!=NULL);
542 assume((length+incr) > 0);
543
544 int i;
545 T = (TSet)omRealloc0Size(T, length*sizeof(TObject),
546 (length+incr)*sizeof(TObject));
547
548 sevT = (unsigned long*) omReallocSize(sevT, length*sizeof(long*),
549 (length+incr)*sizeof(long*));
550
551 R = (TObject**)omRealloc0Size(R,length*sizeof(TObject*),
552 (length+incr)*sizeof(TObject*));
553 for (i=length-1;i>=0;i--) R[T[i].i_r] = &(T[i]);
554 length += incr;
555}
STATIC_VAR jList * T
Definition janet.cc:30
TObject * TSet
Definition kutil.h:60
#define omRealloc0Size(addr, o_size, size)
#define R
Definition sirandom.c:27

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly h,
kStrategy strat )

Definition at line 4239 of file kutil.cc.

4240{
4241 if (nIsOne(pGetCoeff(h))) return;
4242 number gcd;
4243 number zero=n_Init(0,currRing->cf);
4244 bool go = false;
4245 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4246 {
4247 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4248 go = true;
4249 }
4250 else
4251 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4252 if (go || !nIsOne(gcd))
4253 {
4254 poly p = h->next;
4255 if (!go)
4256 {
4257 number tmp = gcd;
4258 gcd = n_Ann(gcd,currRing->cf);
4259 nDelete(&tmp);
4260 }
4261 p_Test(p,strat->tailRing);
4262 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4263
4264 if (p != NULL)
4265 {
4266 if (TEST_OPT_PROT)
4267 {
4268 PrintS("Z");
4269 }
4270#ifdef KDEBUG
4271 if (TEST_OPT_DEBUG)
4272 {
4273 PrintS("--- create zero spoly: ");
4274 p_wrp(h,currRing,strat->tailRing);
4275 PrintS(" ---> ");
4276 }
4277#endif
4278 poly tmp = pInit();
4279 pSetCoeff0(tmp, pGetCoeff(p));
4280 for (int i = 1; i <= rVar(currRing); i++)
4281 {
4282 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4283 }
4285 {
4286 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4287 }
4288 p_Setm(tmp, currRing);
4289 p = p_LmFreeAndNext(p, strat->tailRing);
4290 pNext(tmp) = p;
4291 LObject Lp;
4292 Lp.Init();
4293 Lp.p = tmp;
4294 Lp.tailRing = strat->tailRing;
4295 int posx;
4296 if (Lp.p!=NULL)
4297 {
4298 strat->initEcart(&Lp);
4299 if (strat->Ll==-1)
4300 posx =0;
4301 else
4302 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4303 Lp.sev = pGetShortExpVector(Lp.p);
4304 if (strat->tailRing != currRing)
4305 {
4306 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4307 }
4308#ifdef KDEBUG
4309 if (TEST_OPT_DEBUG)
4310 {
4311 p_wrp(tmp,currRing,strat->tailRing);
4312 PrintLn();
4313 }
4314#endif
4315 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4316 }
4317 }
4318 }
4319 nDelete(&zero);
4320 nDelete(&gcd);
4321}
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:285
void(* initEcart)(TObject *L)
Definition kutil.h:281
int Lmax
Definition kutil.h:352
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:665
static FORCE_INLINE number n_Ann(number a, const coeffs r)
if r is a ring with zero divisors, return an annihilator!=0 of b otherwise return NULL
Definition coeffs.h:680
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:539
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:956
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1276
#define __p_GetComp(p, r)
Definition monomials.h:63
#define rRing_has_Comp(r)
Definition monomials.h:266
#define __pp_Mult_nn(p, n, r)
Definition p_polys.h:1004
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static poly p_LmFreeAndNext(poly p, ring)
Definition p_polys.h:713
#define p_Test(p, r)
Definition p_polys.h:161
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
#define pSetExp(p, i, v)
Definition polys.h:43
int gcd(int a, int b)

◆ enterExtendedSpolySig()

void enterExtendedSpolySig ( poly h,
poly hSig,
kStrategy strat )

Definition at line 4323 of file kutil.cc.

4324{
4325 if (nIsOne(pGetCoeff(h))) return;
4326 number gcd;
4327 number zero=n_Init(0,currRing->cf);
4328 bool go = false;
4329 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4330 {
4331 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4332 go = true;
4333 }
4334 else
4335 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4336 if (go || !nIsOne(gcd))
4337 {
4338 poly p = h->next;
4339 if (!go)
4340 {
4341 number tmp = gcd;
4342 gcd = n_Ann(gcd,currRing->cf);
4343 nDelete(&tmp);
4344 }
4345 p_Test(p,strat->tailRing);
4346 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4347
4348 if (p != NULL)
4349 {
4350 if (TEST_OPT_PROT)
4351 {
4352 PrintS("Z");
4353 }
4354#ifdef KDEBUG
4355 if (TEST_OPT_DEBUG)
4356 {
4357 PrintS("--- create zero spoly: ");
4358 p_wrp(h,currRing,strat->tailRing);
4359 PrintS(" ---> ");
4360 }
4361#endif
4362 poly tmp = pInit();
4363 pSetCoeff0(tmp, pGetCoeff(p));
4364 for (int i = 1; i <= rVar(currRing); i++)
4365 {
4366 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4367 }
4369 {
4370 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4371 }
4372 p_Setm(tmp, currRing);
4373 p = p_LmFreeAndNext(p, strat->tailRing);
4374 pNext(tmp) = p;
4375 LObject Lp;
4376 Lp.Init();
4377 Lp.p = tmp;
4378 //printf("\nOld\n");pWrite(h);pWrite(hSig);
4379 #if EXT_POLY_NEW
4380 Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4381 if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4382 {
4383 strat->sigdrop = TRUE;
4384 //Try to reduce it as far as we can via redRing
4385 int red_result = redRing(&Lp,strat);
4386 if(red_result == 0)
4387 {
4388 // Cancel the sigdrop
4389 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4390 strat->sigdrop = FALSE;
4391 }
4392 else
4393 {
4394 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4395 #if 1
4396 strat->enterS(Lp,0,strat,strat->tl);
4397 #endif
4398 }
4399 nDelete(&zero);
4400 nDelete(&gcd);
4401 return;
4402 }
4403 #else
4404 Lp.sig = pOne();
4405 if(strat->Ll >= 0)
4406 p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4407 else
4408 p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4409 #endif
4410 Lp.tailRing = strat->tailRing;
4411 int posx;
4412 if (Lp.p!=NULL)
4413 {
4414 strat->initEcart(&Lp);
4415 if (strat->Ll==-1)
4416 posx =0;
4417 else
4418 posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4419 Lp.sev = pGetShortExpVector(Lp.p);
4420 if (strat->tailRing != currRing)
4421 {
4422 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4423 }
4424#ifdef KDEBUG
4425 if (TEST_OPT_DEBUG)
4426 {
4427 p_wrp(tmp,currRing,strat->tailRing);
4428 PrintLn();
4429 }
4430#endif
4431 //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4432 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4433 }
4434 }
4435 }
4436 nDelete(&gcd);
4437 nDelete(&zero);
4438}
bool sigdrop
Definition kutil.h:359
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:287
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:283
int redRing(LObject *h, kStrategy strat)
Definition kstd2.cc:992
#define nIsZero(n)
Definition numbers.h:19

◆ enterL()

void enterL ( LSet * set,
int * length,
int * LSetmax,
LObject p,
int at )

Definition at line 1276 of file kutil.cc.

1277{
1278 // this should be corrected
1279 assume(p.FDeg == p.pFDeg());
1280
1281 if ((*length)>=0)
1282 {
1283 if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1284 if (at <= (*length))
1285#ifdef ENTER_USE_MEMMOVE
1286 memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1287#else
1288 for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1289#endif
1290 }
1291 else at = 0;
1292 (*set)[at] = p;
1293 (*length)++;
1294}
static void enlargeL(LSet *L, int *length, const int incr)
Definition kutil.cc:675
#define setmaxLinc
Definition kutil.h:32

◆ enterOnePairLift()

static void enterOnePairLift ( int i,
poly p,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )
static

Definition at line 2228 of file kutil.cc.

2229{
2230 assume(ALLOW_PROD_CRIT(strat));
2232 assume(i<=strat->sl);
2233 assume(strat->syzComp==1);
2234
2235 if ((strat->S[i]==NULL) || (p==NULL))
2236 return;
2237
2238 int l,j,compare;
2239 LObject Lp;
2240 Lp.i_r = -1;
2241
2242#ifdef KDEBUG
2243 Lp.ecart=0; Lp.length=0;
2244#endif
2245 /*- computes the lcm(s[i],p) -*/
2246 Lp.lcm = p_Lcm(p,strat->S[i],currRing);
2247
2248 if (strat->sugarCrit)
2249 {
2250 if((!((strat->ecartS[i]>0)&&(ecart>0)))
2251 && p_HasNotCF_Lift(p,strat->S[i],currRing))
2252 {
2253 /*
2254 *the product criterion has applied for (s,p),
2255 *i.e. lcm(s,p)=product of the leading terms of s and p.
2256 *Suppose (s,r) is in L and the leading term
2257 *of p divides lcm(s,r)
2258 *(==> the leading term of p divides the leading term of r)
2259 *but the leading term of s does not divide the leading term of r
2260 *(notice that tis condition is automatically satisfied if r is still
2261 *in S), then (s,r) can be cancelled.
2262 *This should be done here because the
2263 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2264 *
2265 *Moreover, skipping (s,r) holds also for the noncommutative case.
2266 */
2267 strat->cp++;
2268 pLmFree(Lp.lcm);
2269 return;
2270 }
2271 else
2272 Lp.ecart = si_max(ecart,strat->ecartS[i]);
2273 if (strat->fromT && (strat->ecartS[i]>ecart))
2274 {
2275 pLmFree(Lp.lcm);
2276 return;
2277 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2278 }
2279 /*
2280 *the set B collects the pairs of type (S[j],p)
2281 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2282 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2283 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2284 */
2285 {
2286 j = strat->Bl;
2287 loop
2288 {
2289 if (j < 0) break;
2290 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2291 if ((compare==1)
2292 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
2293 {
2294 strat->c3++;
2295 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2296 {
2297 pLmFree(Lp.lcm);
2298 return;
2299 }
2300 break;
2301 }
2302 else
2303 if ((compare ==-1)
2304 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
2305 {
2306 deleteInL(strat->B,&strat->Bl,j,strat);
2307 strat->c3++;
2308 }
2309 j--;
2310 }
2311 }
2312 }
2313 else /*sugarcrit*/
2314 {
2315 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
2316 p_HasNotCF_Lift(p,strat->S[i],currRing))
2317 {
2318 /*
2319 *the product criterion has applied for (s,p),
2320 *i.e. lcm(s,p)=product of the leading terms of s and p.
2321 *Suppose (s,r) is in L and the leading term
2322 *of p divides lcm(s,r)
2323 *(==> the leading term of p divides the leading term of r)
2324 *but the leading term of s does not divide the leading term of r
2325 *(notice that tis condition is automatically satisfied if r is still
2326 *in S), then (s,r) can be canceled.
2327 *This should be done here because the
2328 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2329 */
2330 strat->cp++;
2331 pLmFree(Lp.lcm);
2332 return;
2333 }
2334 if (strat->fromT && (strat->ecartS[i]>ecart))
2335 {
2336 pLmFree(Lp.lcm);
2337 return;
2338 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2339 }
2340 /*
2341 *the set B collects the pairs of type (S[j],p)
2342 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2343 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2344 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2345 */
2346 for(j = strat->Bl;j>=0;j--)
2347 {
2348 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2349 if (compare==1)
2350 {
2351 strat->c3++;
2352 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2353 {
2354 pLmFree(Lp.lcm);
2355 return;
2356 }
2357 break;
2358 }
2359 else
2360 if (compare ==-1)
2361 {
2362 deleteInL(strat->B,&strat->Bl,j,strat);
2363 strat->c3++;
2364 }
2365 }
2366 }
2367 /*
2368 *the pair (S[i],p) enters B if the spoly != 0
2369 */
2370 /*- compute the short s-polynomial -*/
2371 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2372 pNorm(p);
2373
2374 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2375 Lp.p=NULL;
2376 else
2377 {
2379 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2380 }
2381 if (Lp.p == NULL)
2382 {
2383 /*- the case that the s-poly is 0 -*/
2384 if (strat->pairtest==NULL) initPairtest(strat);
2385 strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
2386 strat->pairtest[strat->sl+1] = TRUE;
2387 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
2388 /*
2389 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
2390 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
2391 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
2392 *term of p divides the lcm(s,r)
2393 *(this canceling should be done here because
2394 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
2395 *the first case is handled in chainCrit
2396 */
2397 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2398 }
2399 else
2400 {
2401 /*- the pair (S[i],p) enters B -*/
2402 Lp.p1 = strat->S[i];
2403 Lp.p2 = p;
2404
2405 pNext(Lp.p) = strat->tail; // !!!
2406
2407 if (atR >= 0)
2408 {
2409 Lp.i_r1 = strat->S_2_R[i];
2410 Lp.i_r2 = atR;
2411 }
2412 else
2413 {
2414 Lp.i_r1 = -1;
2415 Lp.i_r2 = -1;
2416 }
2417 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2418
2420 {
2423 && (Lp.p->coef!=NULL))
2424 nDelete(&(Lp.p->coef));
2425 }
2426
2427 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
2428 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2429 }
2430}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
int cp
Definition kutil.h:348
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition kutil.h:288
int Bmax
Definition kutil.h:353
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition kspoly.cc:1446
void initPairtest(kStrategy strat)
Definition kutil.cc:685
static BOOLEAN p_HasNotCF_Lift(poly p1, poly p2, const ring r)
p_HasNotCF for the IDLIFT case and syzComp==1: ignore component
Definition kutil.cc:2209
static int pDivComp(poly p, poly q)
Definition kutil.cc:176
#define ALLOW_PROD_CRIT(A)
Definition kutil.h:394
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659
void pNorm(poly p)
Definition polys.h:363
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406

◆ enterOnePairNormal()

void enterOnePairNormal ( int i,
poly p,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )

Definition at line 1946 of file kutil.cc.

1947{
1948 assume(i<=strat->sl);
1949
1950 int l,j,compare;
1951 LObject Lp;
1952 Lp.i_r = -1;
1953
1954#ifdef KDEBUG
1955 Lp.ecart=0; Lp.length=0;
1956#endif
1957 /*- computes the lcm(s[i],p) -*/
1958 Lp.lcm = pInit();
1959
1960#ifndef HAVE_RATGRING
1961 pLcm(p,strat->S[i],Lp.lcm);
1962#elif defined(HAVE_RATGRING)
1963 if (rIsRatGRing(currRing))
1964 pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
1965 else
1966 pLcm(p,strat->S[i],Lp.lcm);
1967#endif
1968 pSetm(Lp.lcm);
1969
1970
1971 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
1972 {
1973 if (strat->fromT && (strat->ecartS[i]>ecart))
1974 {
1975 pLmFree(Lp.lcm);
1976 return;
1977 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
1978 }
1979 if((!((strat->ecartS[i]>0)&&(ecart>0)))
1980 && pHasNotCF(p,strat->S[i]))
1981 {
1982 /*
1983 *the product criterion has applied for (s,p),
1984 *i.e. lcm(s,p)=product of the leading terms of s and p.
1985 *Suppose (s,r) is in L and the leading term
1986 *of p divides lcm(s,r)
1987 *(==> the leading term of p divides the leading term of r)
1988 *but the leading term of s does not divide the leading term of r
1989 *(notice that tis condition is automatically satisfied if r is still
1990 *in S), then (s,r) can be cancelled.
1991 *This should be done here because the
1992 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
1993 *
1994 *Moreover, skipping (s,r) holds also for the noncommutative case.
1995 */
1996 strat->cp++;
1997 pLmFree(Lp.lcm);
1998 return;
1999 }
2000 Lp.ecart = si_max(ecart,strat->ecartS[i]);
2001 /*
2002 *the set B collects the pairs of type (S[j],p)
2003 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2004 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2005 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2006 */
2007 {
2008 j = strat->Bl;
2009 loop
2010 {
2011 if (j < 0) break;
2012 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2013 if ((compare==1)
2014 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
2015 {
2016 strat->c3++;
2017 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2018 {
2019 pLmFree(Lp.lcm);
2020 return;
2021 }
2022 break;
2023 }
2024 else
2025 if ((compare ==-1)
2026 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
2027 {
2028 deleteInL(strat->B,&strat->Bl,j,strat);
2029 strat->c3++;
2030 }
2031 j--;
2032 }
2033 }
2034 }
2035 else /*sugarcrit*/
2036 {
2037 if (ALLOW_PROD_CRIT(strat))
2038 {
2039 if (strat->fromT && (strat->ecartS[i]>ecart))
2040 {
2041 pLmFree(Lp.lcm);
2042 return;
2043 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2044 }
2045 // if currRing->nc_type!=quasi (or skew)
2046 // TODO: enable productCrit for super commutative algebras...
2047 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
2048 pHasNotCF(p,strat->S[i]))
2049 {
2050 /*
2051 *the product criterion has applied for (s,p),
2052 *i.e. lcm(s,p)=product of the leading terms of s and p.
2053 *Suppose (s,r) is in L and the leading term
2054 *of p divides lcm(s,r)
2055 *(==> the leading term of p divides the leading term of r)
2056 *but the leading term of s does not divide the leading term of r
2057 *(notice that tis condition is automatically satisfied if r is still
2058 *in S), then (s,r) can be canceled.
2059 *This should be done here because the
2060 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2061 */
2062 strat->cp++;
2063 pLmFree(Lp.lcm);
2064 return;
2065 }
2066 /*
2067 *the set B collects the pairs of type (S[j],p)
2068 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2069 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2070 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2071 */
2072 for(j = strat->Bl;j>=0;j--)
2073 {
2074 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2075 if (compare==1)
2076 {
2077 strat->c3++;
2078 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2079 {
2080 pLmFree(Lp.lcm);
2081 return;
2082 }
2083 break;
2084 }
2085 else
2086 if (compare ==-1)
2087 {
2088 deleteInL(strat->B,&strat->Bl,j,strat);
2089 strat->c3++;
2090 }
2091 }
2092 }
2093 }
2094 /*
2095 *the pair (S[i],p) enters B if the spoly != 0
2096 */
2097 /*- compute the short s-polynomial -*/
2098 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2099 pNorm(p);
2100
2101 if ((strat->S[i]==NULL) || (p==NULL))
2102 return;
2103
2104 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2105 Lp.p=NULL;
2106 else
2107 {
2108 #ifdef HAVE_PLURAL
2109 if ( rIsPluralRing(currRing) )
2110 {
2111 if(pHasNotCF(p, strat->S[i]))
2112 {
2113 if(ncRingType(currRing) == nc_lie)
2114 {
2115 // generalized prod-crit for lie-type
2116 strat->cp++;
2117 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2118 }
2119 else
2120 if( ALLOW_PROD_CRIT(strat) )
2121 {
2122 // product criterion for homogeneous case in SCA
2123 strat->cp++;
2124 Lp.p = NULL;
2125 }
2126 else
2127 {
2128 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2129 nc_CreateShortSpoly(strat->S[i], p, currRing);
2130 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2131 pNext(Lp.p) = strat->tail; // !!!
2132 }
2133 }
2134 else
2135 {
2136 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2137 nc_CreateShortSpoly(strat->S[i], p, currRing);
2138
2139 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2140 pNext(Lp.p) = strat->tail; // !!!
2141 }
2142 }
2143 else
2144 #endif
2145 {
2147 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2148 }
2149 }
2150 if (Lp.p == NULL)
2151 {
2152 /*- the case that the s-poly is 0 -*/
2153 if (strat->pairtest==NULL) initPairtest(strat);
2154 strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
2155 strat->pairtest[strat->sl+1] = TRUE;
2156 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
2157 /*
2158 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
2159 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
2160 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
2161 *term of p divides the lcm(s,r)
2162 *(this canceling should be done here because
2163 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
2164 *the first case is handled in chainCrit
2165 */
2166 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2167 }
2168 else
2169 {
2170 /*- the pair (S[i],p) enters B -*/
2171 Lp.p1 = strat->S[i];
2172 Lp.p2 = p;
2173
2174 if (
2176// || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
2177 )
2178 {
2179 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2180 pNext(Lp.p) = strat->tail; // !!!
2181 }
2182
2183 if (atR >= 0)
2184 {
2185 Lp.i_r1 = strat->S_2_R[i];
2186 Lp.i_r2 = atR;
2187 }
2188 else
2189 {
2190 Lp.i_r1 = -1;
2191 Lp.i_r2 = -1;
2192 }
2193 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2194
2196 {
2199 && (Lp.p->coef!=NULL))
2200 nDelete(&(Lp.p->coef));
2201 }
2202
2203 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
2204 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2205 }
2206}
poly nc_CreateShortSpoly(poly p1, poly p2, const ring r)
@ nc_lie
Definition nc.h:18
static nc_type & ncRingType(nc_struct *p)
Definition nc.h:159
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
#define pSetm(p)
Definition polys.h:272
#define pHasNotCF(p1, p2)
Definition polys.h:264
#define pLcm(a, b, m)
Definition polys.h:296
void pLcmRat(poly a, poly b, poly m, int rat_shift)
Definition ratgring.cc:30
static BOOLEAN rIsRatGRing(const ring r)
Definition ring.h:433

◆ enterOnePairRing()

static void enterOnePairRing ( int i,
poly p,
int ,
int isFromQ,
kStrategy strat,
int atR )
static

Definition at line 1341 of file kutil.cc.

1342{
1343 assume(atR >= 0);
1344 assume(i<=strat->sl);
1345 assume(p!=NULL);
1347 #if ALL_VS_JUST
1348 //Over rings, if we construct the strong pair, do not add the spair
1350 {
1351 number s,t,d;
1352 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1353
1354 if (!nIsZero(s) && !nIsZero(t)) // evtl. durch divBy tests ersetzen
1355 {
1356 nDelete(&d);
1357 nDelete(&s);
1358 nDelete(&t);
1359 return;
1360 }
1361 nDelete(&d);
1362 nDelete(&s);
1363 nDelete(&t);
1364 }
1365 #endif
1366 int j,compare,compareCoeff;
1367 LObject h;
1368
1369#ifdef KDEBUG
1370 h.ecart=0; h.length=0;
1371#endif
1372 /*- computes the lcm(s[i],p) -*/
1373 if(pHasNotCFRing(p,strat->S[i]))
1374 {
1375 strat->cp++;
1376 return;
1377 }
1378 h.lcm = p_Lcm(p,strat->S[i],currRing);
1379 pSetCoeff0(h.lcm, n_Lcm(pGetCoeff(p), pGetCoeff(strat->S[i]), currRing->cf));
1380 if (nIsZero(pGetCoeff(h.lcm)))
1381 {
1382 strat->cp++;
1383 pLmDelete(h.lcm);
1384 return;
1385 }
1386 // basic chain criterion
1387 /*
1388 *the set B collects the pairs of type (S[j],p)
1389 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
1390 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
1391 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
1392 */
1393
1394 for(j = strat->Bl;j>=0;j--)
1395 {
1396 compare=pDivCompRing(strat->B[j].lcm,h.lcm);
1397 compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(h.lcm), currRing->cf);
1398 if(compare == pDivComp_EQUAL)
1399 {
1400 //They have the same LM
1401 if(compareCoeff == pDivComp_LESS)
1402 {
1403 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1404 {
1405 strat->c3++;
1406 pLmDelete(h.lcm);
1407 return;
1408 }
1409 break;
1410 }
1411 if(compareCoeff == pDivComp_GREATER)
1412 {
1413 deleteInL(strat->B,&strat->Bl,j,strat);
1414 strat->c3++;
1415 }
1416 if(compareCoeff == pDivComp_EQUAL)
1417 {
1418 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1419 {
1420 strat->c3++;
1421 pLmDelete(h.lcm);
1422 return;
1423 }
1424 break;
1425 }
1426 }
1427 if(compareCoeff == compare || compareCoeff == pDivComp_EQUAL)
1428 {
1429 if(compare == pDivComp_LESS)
1430 {
1431 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1432 {
1433 strat->c3++;
1434 pLmDelete(h.lcm);
1435 return;
1436 }
1437 break;
1438 }
1439 if(compare == pDivComp_GREATER)
1440 {
1441 deleteInL(strat->B,&strat->Bl,j,strat);
1442 strat->c3++;
1443 }
1444 }
1445 }
1446 number s, t;
1447 poly m1, m2, gcd = NULL;
1448 s = pGetCoeff(strat->S[i]);
1449 t = pGetCoeff(p);
1450 k_GetLeadTerms(p,strat->S[i],currRing,m1,m2,currRing);
1451 ksCheckCoeff(&s, &t, currRing->cf);
1452 pSetCoeff0(m1, s);
1453 pSetCoeff0(m2, t);
1454 m2 = pNeg(m2);
1455 p_Test(m1,strat->tailRing);
1456 p_Test(m2,strat->tailRing);
1457 poly si = pCopy(strat->S[i]);
1458 poly pm1 = pp_Mult_mm(pNext(p), m1, strat->tailRing);
1459 poly sim2 = pp_Mult_mm(pNext(si), m2, strat->tailRing);
1460 pDelete(&si);
1461 p_LmDelete(m1, currRing);
1462 p_LmDelete(m2, currRing);
1463 if(sim2 == NULL)
1464 {
1465 if(pm1 == NULL)
1466 {
1467 if(h.lcm != NULL)
1468 {
1469 pLmDelete(h.lcm);
1470 h.lcm=NULL;
1471 }
1472 h.Clear();
1473 if (strat->pairtest==NULL) initPairtest(strat);
1474 strat->pairtest[i] = TRUE;
1475 strat->pairtest[strat->sl+1] = TRUE;
1476 return;
1477 }
1478 else
1479 {
1480 gcd = pm1;
1481 pm1 = NULL;
1482 }
1483 }
1484 else
1485 {
1486 if((pGetComp(strat->S[i]) == 0) && (0 != pGetComp(p)))
1487 {
1488 p_SetCompP(sim2, pGetComp(p), strat->tailRing);
1489 pSetmComp(sim2);
1490 }
1491 //p_Write(pm1,strat->tailRing);p_Write(sim2,strat->tailRing);
1492 gcd = p_Add_q(pm1, sim2, strat->tailRing);
1493 }
1494 p_Test(gcd, strat->tailRing);
1495#ifdef KDEBUG
1496 if (TEST_OPT_DEBUG)
1497 {
1498 wrp(gcd);
1499 PrintLn();
1500 }
1501#endif
1502 h.p = gcd;
1503 h.i_r = -1;
1504 if(h.p == NULL)
1505 {
1506 if (strat->pairtest==NULL) initPairtest(strat);
1507 strat->pairtest[i] = TRUE;
1508 strat->pairtest[strat->sl+1] = TRUE;
1509 return;
1510 }
1511 h.tailRing = strat->tailRing;
1512 int posx;
1513 //h.pCleardenom();
1514 //pSetm(h.p);
1515 h.i_r1 = -1;h.i_r2 = -1;
1516 strat->initEcart(&h);
1517 #if 1
1518 h.p2 = strat->S[i];
1519 h.p1 = p;
1520 #endif
1521 #if 1
1522 if (atR >= 0)
1523 {
1524 h.i_r1 = atR;
1525 h.i_r2 = strat->S_2_R[i];
1526 }
1527 #endif
1528 if (strat->Bl==-1)
1529 posx =0;
1530 else
1531 posx = strat->posInL(strat->B,strat->Bl,&h,strat);
1532 h.sev = pGetShortExpVector(h.p);
1533 if (currRing!=strat->tailRing)
1534 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
1535 if (strat->P.p!=NULL) strat->P.sev = pGetShortExpVector(strat->P.p);
1536 else strat->P.sev=0L;
1537 enterL(&strat->B,&strat->Bl,&strat->Bmax,h,posx);
1538 kTest_TS(strat);
1539}
static FORCE_INLINE number n_Lcm(number a, number b, const coeffs r)
in Z: return the lcm of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:691
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:672
static FORCE_INLINE int n_DivComp(number a, number b, const coeffs r)
Definition coeffs.h:525
const CanonicalForm int s
Definition facAbsFact.cc:51
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:1015
int ksCheckCoeff(number *a, number *b, const coeffs r)
Definition kbuckets.cc:1504
#define pDivComp_LESS
Definition kutil.cc:130
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1074
static int pDivCompRing(poly p, poly q)
Definition kutil.cc:138
#define pDivComp_GREATER
Definition kutil.cc:131
#define pDivComp_EQUAL
Definition kutil.cc:129
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1033
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:256
#define pNeg(p)
Definition polys.h:199
#define pSetmComp(p)
TODO:
Definition polys.h:274
#define pHasNotCFRing(p1, p2)
Definition polys.h:263

◆ enterOnePairRingShift()

static void enterOnePairRingShift ( poly q,
poly p,
int ,
int isFromQ,
kStrategy strat,
int atR,
int ,
int qisFromQ,
int shiftcount,
int ifromS )
static

Definition at line 11816 of file kutil.cc.

11817{
11818 /* assume(atR >= 0); */
11819 /* assume(i<=strat->sl); */
11820 assume(p!=NULL);
11822 assume(pIsInV(p));
11823 #if ALL_VS_JUST
11824 //Over rings, if we construct the strong pair, do not add the spair
11826 {
11827 number s,t,d;
11828 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(q, &s, &t, currRing->cf);
11829
11830 if (!nIsZero(s) && !nIsZero(t)) // evtl. durch divBy tests ersetzen
11831 {
11832 nDelete(&d);
11833 nDelete(&s);
11834 nDelete(&t);
11835 return;
11836 }
11837 nDelete(&d);
11838 nDelete(&s);
11839 nDelete(&t);
11840 }
11841 #endif
11842 int j,compare,compareCoeff;
11843 LObject h;
11844
11845#ifdef KDEBUG
11846 h.ecart=0; h.length=0;
11847#endif
11848 /*- computes the lcm(s[i],p) -*/
11849 if(pHasNotCFRing(p,q))
11850 {
11851 strat->cp++;
11852 return;
11853 }
11854 h.lcm = p_Lcm(p,q,currRing);
11855 pSetCoeff0(h.lcm, n_Lcm(pGetCoeff(p), pGetCoeff(q), currRing->cf));
11856 if (nIsZero(pGetCoeff(h.lcm)))
11857 {
11858 strat->cp++;
11859 pLmDelete(h.lcm);
11860 return;
11861 }
11862
11863 /* the V criterion */
11864 if (!pmIsInV(h.lcm))
11865 {
11866 strat->cv++;
11867 pLmDelete(h.lcm);
11868 return;
11869 }
11870 // basic chain criterion
11871 /*
11872 *the set B collects the pairs of type (S[j],p)
11873 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
11874 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
11875 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
11876 */
11877
11878 for(j = strat->Bl;j>=0;j--)
11879 {
11880 compare=pDivCompRing(strat->B[j].lcm,h.lcm);
11881 compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(h.lcm), currRing->cf);
11882 if(compare == pDivComp_EQUAL)
11883 {
11884 //They have the same LM
11885 if(compareCoeff == pDivComp_LESS)
11886 {
11887 if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
11888 {
11889 strat->c3++;
11890 pLmDelete(h.lcm);
11891 return;
11892 }
11893 break;
11894 }
11895 if(compareCoeff == pDivComp_GREATER)
11896 {
11897 deleteInL(strat->B,&strat->Bl,j,strat);
11898 strat->c3++;
11899 }
11900 if(compareCoeff == pDivComp_EQUAL)
11901 {
11902 if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
11903 {
11904 strat->c3++;
11905 pLmDelete(h.lcm);
11906 return;
11907 }
11908 break;
11909 }
11910 }
11911 if(compareCoeff == compare || compareCoeff == pDivComp_EQUAL)
11912 {
11913 if(compare == pDivComp_LESS)
11914 {
11915 if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
11916 {
11917 strat->c3++;
11918 pLmDelete(h.lcm);
11919 return;
11920 }
11921 break;
11922 }
11923 if(compare == pDivComp_GREATER)
11924 {
11925 deleteInL(strat->B,&strat->Bl,j,strat);
11926 strat->c3++;
11927 }
11928 }
11929 }
11930 number s, t;
11931 poly m1, m2, gcd = NULL;
11932 s = pGetCoeff(q);
11933 t = pGetCoeff(p);
11935
11936 poly m12, m22;
11940 // manually free the coeffs, because pSetCoeff0 is used in the next step
11941 n_Delete(&(m1->coef), currRing->cf);
11942 n_Delete(&(m2->coef), currRing->cf);
11943
11944 ksCheckCoeff(&s, &t, currRing->cf);
11945 pSetCoeff0(m1, s);
11946 pSetCoeff0(m2, t);
11947 m2 = pNeg(m2);
11948 p_Test(m1,strat->tailRing);
11949 p_Test(m2,strat->tailRing);
11950 p_Test(m12,strat->tailRing);
11951 p_Test(m22,strat->tailRing);
11952 assume(pmIsInV(m1));
11953 assume(pmIsInV(m2));
11954 assume(pmIsInV(m12));
11955 assume(pmIsInV(m22));
11956 poly pm1 = pp_Mult_mm(pp_mm_Mult(pNext(p), m1, strat->tailRing), m12, strat->tailRing);
11957 poly sim2 = pp_Mult_mm(pp_mm_Mult(pNext(q), m2, strat->tailRing), m22, strat->tailRing);
11958 assume(pIsInV(pm1));
11959 assume(pIsInV(sim2));
11960 p_LmDelete(m1, currRing);
11961 p_LmDelete(m2, currRing);
11962 p_LmDelete(m12, currRing);
11963 p_LmDelete(m22, currRing);
11964 if(sim2 == NULL)
11965 {
11966 if(pm1 == NULL)
11967 {
11968 if(h.lcm != NULL)
11969 {
11970 pLmDelete(h.lcm);
11971 h.lcm=NULL;
11972 }
11973 h.Clear();
11974 /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
11975 /* if (strat->pairtest==NULL) initPairtest(strat); */
11976 /* strat->pairtest[i] = TRUE; */
11977 /* strat->pairtest[strat->sl+1] = TRUE; */
11978 return;
11979 }
11980 else
11981 {
11982 gcd = pm1;
11983 pm1 = NULL;
11984 }
11985 }
11986 else
11987 {
11988 if((pGetComp(q) == 0) && (0 != pGetComp(p)))
11989 {
11990 p_SetCompP(sim2, pGetComp(p), strat->tailRing);
11991 pSetmComp(sim2);
11992 }
11993 //p_Write(pm1,strat->tailRing);p_Write(sim2,strat->tailRing);
11994 gcd = p_Add_q(pm1, sim2, strat->tailRing);
11995 }
11996 p_Test(gcd, strat->tailRing);
11997 assume(pIsInV(gcd));
11998#ifdef KDEBUG
11999 if (TEST_OPT_DEBUG)
12000 {
12001 wrp(gcd);
12002 PrintLn();
12003 }
12004#endif
12005 h.p = gcd;
12006 h.i_r = -1;
12007 if(h.p == NULL)
12008 {
12009 /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
12010 /* if (strat->pairtest==NULL) initPairtest(strat); */
12011 /* strat->pairtest[i] = TRUE; */
12012 /* strat->pairtest[strat->sl+1] = TRUE; */
12013 return;
12014 }
12015 h.tailRing = strat->tailRing;
12016 int posx;
12017 //h.pCleardenom();
12018 //pSetm(h.p);
12019 h.i_r1 = -1;h.i_r2 = -1;
12020 strat->initEcart(&h);
12021 #if 1
12022 h.p1 = p;
12023 h.p2 = q;
12024 #endif
12025 #if 1
12026 /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12027 /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12028 if (atR >= 0 && shiftcount == 0 && ifromS >= 0)
12029 {
12030 h.i_r2 = kFindInT(h.p1, strat); //strat->S_2_R[i];
12031 h.i_r1 = atR;
12032 }
12033 else
12034 {
12035 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12036 h.i_r1 = -1;
12037 h.i_r2 = -1;
12038 }
12039 #endif
12040 if (strat->Bl==-1)
12041 posx =0;
12042 else
12043 posx = strat->posInL(strat->B,strat->Bl,&h,strat);
12044 h.sev = pGetShortExpVector(h.p);
12045 if (currRing!=strat->tailRing)
12046 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
12047
12048 assume(pIsInV(h.p));
12049 assume(pIsInV(h.p1));
12050 assume(h.lcm != NULL);
12051 assume(pIsInV(h.lcm));
12052
12053 enterL(&strat->B,&strat->Bl,&strat->Bmax,h,posx);
12054 kTest_TS(strat);
12055}
int cv
Definition kutil.h:367
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
if(!FE_OPT_NO_SHELL_FLAG)
Definition fehelp.cc:1000
static poly pp_mm_Mult(poly p, poly m, const ring r)
Definition p_polys.h:1043
int p_mFirstVblock(poly p, const ring ri)
Definition shiftop.cc:478
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)
Definition shiftop.cc:600
#define pIsInV(p)
Definition shiftop.h:50
#define pmIsInV(p)
Definition shiftop.h:51

◆ enterOnePairShift()

BOOLEAN enterOnePairShift ( poly q,
poly p,
int ecart,
int isFromQ,
kStrategy strat,
int atR,
int ecartq,
int qisFromQ,
int shiftcount,
int ifromS )

Definition at line 12169 of file kutil.cc.

12170{
12171#ifdef CRITERION_DEBUG
12172 if (TEST_OPT_DEBUG)
12173 {
12174 PrintS("Consider pair ("); wrp(q); PrintS(", "); wrp(p); PrintS(")"); PrintLn();
12175 // also write the LMs in separate lines:
12176 poly lmq = pHead(q);
12177 poly lmp = pHead(p);
12178 pSetCoeff(lmq, n_Init(1, currRing->cf));
12179 pSetCoeff(lmp, n_Init(1, currRing->cf));
12180 Print(" %s\n", pString(lmq));
12181 Print(" %s\n", pString(lmp));
12182 pLmDelete(lmq);
12183 pLmDelete(lmp);
12184 }
12185#endif
12186
12187 /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
12188
12189 /* check this Formats: */
12194
12195 /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
12196
12197 int qfromQ = qisFromQ;
12198
12199 /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */
12200
12201 int l,j,compare;
12202 LObject Lp;
12203 Lp.i_r = -1;
12204
12205#ifdef KDEBUG
12206 Lp.ecart=0; Lp.length=0;
12207#endif
12208 /*- computes the lcm(s[i],p) -*/
12209 Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
12210
12211 /* the V criterion */
12212 if (!pmIsInV(Lp.lcm))
12213 {
12214 strat->cv++; // counter for applying the V criterion
12215 pLmFree(Lp.lcm);
12216#ifdef CRITERION_DEBUG
12217 if (TEST_OPT_DEBUG) PrintS("--- V crit\n");
12218#endif
12219 return TRUE;
12220 }
12221
12222 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
12223 {
12224 if((!((ecartq>0)&&(ecart>0)))
12225 && pHasNotCF(p,q))
12226 {
12227 /*
12228 *the product criterion has applied for (s,p),
12229 *i.e. lcm(s,p)=product of the leading terms of s and p.
12230 *Suppose (s,r) is in L and the leading term
12231 *of p divides lcm(s,r)
12232 *(==> the leading term of p divides the leading term of r)
12233 *but the leading term of s does not divide the leading term of r
12234 *(notice that this condition is automatically satisfied if r is still
12235 *in S), then (s,r) can be cancelled.
12236 *This should be done here because the
12237 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12238 *
12239 *Moreover, skipping (s,r) holds also for the noncommutative case.
12240 */
12241 strat->cp++;
12242 pLmFree(Lp.lcm);
12243#ifdef CRITERION_DEBUG
12244 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12245#endif
12246 return TRUE;
12247 }
12248 else
12249 Lp.ecart = si_max(ecart,ecartq);
12250 if (strat->fromT && (ecartq>ecart))
12251 {
12252 pLmFree(Lp.lcm);
12253#ifdef CRITERION_DEBUG
12254 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12255#endif
12256 return TRUE;
12257 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12258 }
12259 /*
12260 *the set B collects the pairs of type (S[j],p)
12261 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12262 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12263 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12264 */
12265 {
12266 j = strat->Bl;
12267 loop
12268 {
12269 if (j < 0) break;
12270 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12271 if ((compare==1)
12272 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
12273 {
12274 strat->c3++;
12275 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12276 {
12277 pLmFree(Lp.lcm);
12278#ifdef CRITERION_DEBUG
12279 if (TEST_OPT_DEBUG)
12280 {
12281 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12282 }
12283#endif
12284 return TRUE;
12285 }
12286 break;
12287 }
12288 else
12289 if ((compare ==-1)
12290 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
12291 {
12292#ifdef CRITERION_DEBUG
12293 if (TEST_OPT_DEBUG)
12294 {
12295 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12296 }
12297#endif
12298 deleteInL(strat->B,&strat->Bl,j,strat);
12299 strat->c3++;
12300 }
12301 j--;
12302 }
12303 }
12304 }
12305 else /*sugarcrit*/
12306 {
12307 if (ALLOW_PROD_CRIT(strat))
12308 {
12309 // if currRing->nc_type!=quasi (or skew)
12310 // TODO: enable productCrit for super commutative algebras...
12311 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
12312 pHasNotCF(p,q))
12313 {
12314 /*
12315 *the product criterion has applied for (s,p),
12316 *i.e. lcm(s,p)=product of the leading terms of s and p.
12317 *Suppose (s,r) is in L and the leading term
12318 *of p divides lcm(s,r)
12319 *(==> the leading term of p divides the leading term of r)
12320 *but the leading term of s does not divide the leading term of r
12321 *(notice that tis condition is automatically satisfied if r is still
12322 *in S), then (s,r) can be canceled.
12323 *This should be done here because the
12324 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12325 */
12326 strat->cp++;
12327 pLmFree(Lp.lcm);
12328#ifdef CRITERION_DEBUG
12329 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12330#endif
12331 return TRUE;
12332 }
12333 if (strat->fromT && (ecartq>ecart))
12334 {
12335 pLmFree(Lp.lcm);
12336#ifdef CRITERION_DEBUG
12337 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12338#endif
12339 return TRUE;
12340 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12341 }
12342 /*
12343 *the set B collects the pairs of type (S[j],p)
12344 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12345 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12346 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12347 */
12348 for(j = strat->Bl;j>=0;j--)
12349 {
12350 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12351 if (compare==1)
12352 {
12353 strat->c3++;
12354 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12355 {
12356 pLmFree(Lp.lcm);
12357#ifdef CRITERION_DEBUG
12358 if (TEST_OPT_DEBUG)
12359 {
12360 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12361 }
12362#endif
12363 return TRUE;
12364 }
12365 break;
12366 }
12367 else
12368 if (compare ==-1)
12369 {
12370#ifdef CRITERION_DEBUG
12371 if (TEST_OPT_DEBUG)
12372 {
12373 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12374 }
12375#endif
12376 deleteInL(strat->B,&strat->Bl,j,strat);
12377 strat->c3++;
12378 }
12379 }
12380 }
12381 }
12382 /*
12383 *the pair (S[i],p) enters B if the spoly != 0
12384 */
12385 /*- compute the short s-polynomial -*/
12386 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
12387 pNorm(p);
12388 if ((q==NULL) || (p==NULL))
12389 {
12390#ifdef CRITERION_DEBUG
12391 if (TEST_OPT_DEBUG) PrintS("--- q == NULL || p == NULL\n");
12392#endif
12393 return FALSE;
12394 }
12395 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
12396 {
12397 Lp.p=NULL;
12398#ifdef CRITERION_DEBUG
12399 if (TEST_OPT_DEBUG) PrintS("--- pair is from Q\n");
12400#endif
12401 }
12402 else
12403 {
12404// if ( rIsPluralRing(currRing) )
12405// {
12406// if(pHasNotCF(p, q))
12407// {
12408// if(ncRingType(currRing) == nc_lie)
12409// {
12410// // generalized prod-crit for lie-type
12411// strat->cp++;
12412// Lp.p = nc_p_Bracket_qq(pCopy(p),q, currRing);
12413// }
12414// else
12415// if( ALLOW_PROD_CRIT(strat) )
12416// {
12417// // product criterion for homogeneous case in SCA
12418// strat->cp++;
12419// Lp.p = NULL;
12420// }
12421// else
12422// Lp.p = nc_CreateSpoly(q,p,currRing); // ?
12423// }
12424// else Lp.p = nc_CreateSpoly(q,p,currRing);
12425// }
12426// else
12427// {
12428
12429 /* ksCreateShortSpoly needs two Lobject-kind presentations */
12430 /* p is already in this form, so convert q */
12431 Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
12432 // }
12433 }
12434 if (Lp.p == NULL)
12435 {
12436 /*- the case that the s-poly is 0 -*/
12437 // TODO: currently ifromS is only > 0 if called from enterOnePairWithShifts
12438 if (ifromS > 0)
12439 {
12440 if (strat->pairtest==NULL) initPairtest(strat);
12441 strat->pairtest[ifromS] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
12442 strat->pairtest[strat->sl+1] = TRUE;
12443 }
12444 //if (TEST_OPT_DEBUG){Print("!");} // option teach
12445 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12446 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
12447 /*
12448 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
12449 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
12450 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
12451 *term of p divides the lcm(s,r)
12452 *(this canceling should be done here because
12453 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
12454 *the first case is handled in chainCrit
12455 */
12456 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
12457#ifdef CRITERION_DEBUG
12458 if (TEST_OPT_DEBUG) PrintS("--- S-poly = 0\n");
12459#endif
12460 return TRUE;
12461 }
12462 else
12463 {
12464 /*- the pair (S[i],p) enters B -*/
12465 /* both of them should have their LM in currRing and TAIL in tailring */
12466 Lp.p1 = q; // already in the needed form
12467 Lp.p2 = p; // already in the needed form
12468
12469 if ( !rIsPluralRing(currRing) )
12470 pNext(Lp.p) = strat->tail;
12471
12472 /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12473 /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12474 if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
12475 {
12476 Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
12477 Lp.i_r2 = atR;
12478 }
12479 else
12480 {
12481 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12482 Lp.i_r1 = -1;
12483 Lp.i_r2 = -1;
12484 }
12485 strat->initEcartPair(&Lp,q,p,ecartq,ecart);
12486
12488 {
12491 && (Lp.p->coef!=NULL))
12492 nDelete(&(Lp.p->coef));
12493 }
12494
12495 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
12496 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
12497#ifdef CRITERION_DEBUG
12498 if (TEST_OPT_DEBUG) PrintS("+++ Entered pair\n");
12499#endif
12500 }
12501 return FALSE;
12502}
static int pLPDivComp(poly p, poly q)
Definition kutil.cc:225
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition pDebug.cc:105
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition pDebug.cc:74
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
char * pString(poly p)
Definition polys.h:307

◆ enterOnePairSig()

static void enterOnePairSig ( int i,
poly p,
poly pSig,
int ,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )
static

Definition at line 2440 of file kutil.cc.

2442{
2443 assume(i<=strat->sl);
2444
2445 int l;
2446 poly m1 = NULL,m2 = NULL; // we need the multipliers for the s-polynomial to compute
2447 // the corresponding signatures for criteria checks
2448 LObject Lp;
2449 poly pSigMult = p_Copy(pSig,currRing);
2450 poly sSigMult = p_Copy(strat->sig[i],currRing);
2451 unsigned long pSigMultNegSev,sSigMultNegSev;
2452 Lp.i_r = -1;
2453
2454#ifdef KDEBUG
2455 Lp.ecart=0; Lp.length=0;
2456#endif
2457 /*- computes the lcm(s[i],p) -*/
2458 Lp.lcm = pInit();
2459 k_GetLeadTerms(p,strat->S[i],currRing,m1,m2,currRing);
2460#ifndef HAVE_RATGRING
2461 pLcm(p,strat->S[i],Lp.lcm);
2462#elif defined(HAVE_RATGRING)
2463 if (rIsRatGRing(currRing))
2464 pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
2465 else
2466 pLcm(p,strat->S[i],Lp.lcm);
2467#endif
2468 pSetm(Lp.lcm);
2469
2470 // set coeffs of multipliers m1 and m2
2471 pSetCoeff0(m1, nInit(1));
2472 pSetCoeff0(m2, nInit(1));
2473//#if 1
2474#ifdef DEBUGF5
2475 PrintS("P1 ");
2476 pWrite(pHead(p));
2477 PrintS("P2 ");
2478 pWrite(pHead(strat->S[i]));
2479 PrintS("M1 ");
2480 pWrite(m1);
2481 PrintS("M2 ");
2482 pWrite(m2);
2483#endif
2484 // get multiplied signatures for testing
2485 pSigMult = currRing->p_Procs->pp_Mult_mm(pSigMult,m1,currRing);
2486 pSigMultNegSev = ~p_GetShortExpVector(pSigMult,currRing);
2487 sSigMult = currRing->p_Procs->pp_Mult_mm(sSigMult,m2,currRing);
2488 sSigMultNegSev = ~p_GetShortExpVector(sSigMult,currRing);
2489
2490//#if 1
2491#ifdef DEBUGF5
2492 PrintS("----------------\n");
2493 pWrite(pSigMult);
2494 pWrite(sSigMult);
2495 PrintS("----------------\n");
2496 Lp.checked = 0;
2497#endif
2498 int sigCmp = p_LmCmp(pSigMult,sSigMult,currRing);
2499//#if 1
2500#if DEBUGF5
2501 Print("IN PAIR GENERATION - COMPARING SIGS: %d\n",sigCmp);
2502 pWrite(pSigMult);
2503 pWrite(sSigMult);
2504#endif
2505 if(sigCmp==0)
2506 {
2507 // printf("!!!! EQUAL SIGS !!!!\n");
2508 // pSig = sSig, delete element due to Rewritten Criterion
2509 pDelete(&pSigMult);
2510 pDelete(&sSigMult);
2512 pLmDelete(Lp.lcm);
2513 else
2514 pLmFree(Lp.lcm);
2515 pDelete (&m1);
2516 pDelete (&m2);
2517 return;
2518 }
2519 // testing by syzCrit = F5 Criterion
2520 // testing by rewCrit1 = Rewritten Criterion
2521 // NOTE: Arri's Rewritten Criterion is tested below, we need Lp.p for it!
2522 if ( strat->syzCrit(pSigMult,pSigMultNegSev,strat) ||
2523 strat->syzCrit(sSigMult,sSigMultNegSev,strat)
2524 || strat->rewCrit1(sSigMult,sSigMultNegSev,Lp.lcm,strat,i+1)
2525 )
2526 {
2527 pDelete(&pSigMult);
2528 pDelete(&sSigMult);
2530 pLmDelete(Lp.lcm);
2531 else
2532 pLmFree(Lp.lcm);
2533 pDelete (&m1);
2534 pDelete (&m2);
2535 return;
2536 }
2537 /*
2538 *the pair (S[i],p) enters B if the spoly != 0
2539 */
2540 /*- compute the short s-polynomial -*/
2541 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2542 pNorm(p);
2543
2544 if ((strat->S[i]==NULL) || (p==NULL))
2545 return;
2546
2547 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2548 Lp.p=NULL;
2549 else
2550 {
2551 #ifdef HAVE_PLURAL
2552 if ( rIsPluralRing(currRing) )
2553 {
2554 if(pHasNotCF(p, strat->S[i]))
2555 {
2556 if(ncRingType(currRing) == nc_lie)
2557 {
2558 // generalized prod-crit for lie-type
2559 strat->cp++;
2560 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2561 }
2562 else
2563 if( ALLOW_PROD_CRIT(strat) )
2564 {
2565 // product criterion for homogeneous case in SCA
2566 strat->cp++;
2567 Lp.p = NULL;
2568 }
2569 else
2570 {
2571 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2572 nc_CreateShortSpoly(strat->S[i], p, currRing);
2573
2574 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2575 pNext(Lp.p) = strat->tail; // !!!
2576 }
2577 }
2578 else
2579 {
2580 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2581 nc_CreateShortSpoly(strat->S[i], p, currRing);
2582
2583 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2584 pNext(Lp.p) = strat->tail; // !!!
2585 }
2586 }
2587 else
2588 #endif
2589 {
2591 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2592 }
2593 }
2594 // store from which element this pair comes from for further tests
2595 //Lp.from = strat->sl+1;
2596 if(sigCmp==currRing->OrdSgn)
2597 {
2598 // pSig > sSig
2599 pDelete (&sSigMult);
2600 Lp.sig = pSigMult;
2601 Lp.sevSig = ~pSigMultNegSev;
2602 }
2603 else
2604 {
2605 // pSig < sSig
2606 pDelete (&pSigMult);
2607 Lp.sig = sSigMult;
2608 Lp.sevSig = ~sSigMultNegSev;
2609 }
2610 if (Lp.p == NULL)
2611 {
2612 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2613 int pos = posInSyz(strat, Lp.sig);
2614 enterSyz(Lp, strat, pos);
2615 }
2616 else
2617 {
2618 // testing by rewCrit3 = Arris Rewritten Criterion (for F5 nothing happens!)
2619 if (strat->rewCrit3(Lp.sig,~Lp.sevSig,Lp.p,strat,strat->sl+1))
2620 {
2621 pLmFree(Lp.lcm);
2622 pDelete(&Lp.sig);
2623 pDelete (&m1);
2624 pDelete (&m2);
2625 return;
2626 }
2627 // in any case Lp is checked up to the next strat->P which is added
2628 // to S right after this critical pair creation.
2629 // NOTE: this even holds if the 2nd generator gives the bigger signature
2630 // moreover, this improves rewCriterion,
2631 // i.e. strat->checked > strat->from if and only if the 2nd generator
2632 // gives the bigger signature.
2633 Lp.checked = strat->sl+1;
2634 // at this point it is clear that the pair will be added to L, since it has
2635 // passed all tests up to now
2636
2637 // adds buchberger's first criterion
2638 if (pLmCmp(m2,pHead(p)) == 0)
2639 {
2640 Lp.prod_crit = TRUE; // Product Criterion
2641#if 0
2642 int pos = posInSyz(strat, Lp.sig);
2643 enterSyz(Lp, strat, pos);
2644 pDelete (&m1);
2645 pDelete (&m2);
2646 return;
2647#endif
2648 }
2649 pDelete (&m1);
2650 pDelete (&m2);
2651#if DEBUGF5
2652 PrintS("SIGNATURE OF PAIR: ");
2653 pWrite(Lp.sig);
2654#endif
2655 /*- the pair (S[i],p) enters B -*/
2656 Lp.p1 = strat->S[i];
2657 Lp.p2 = p;
2658
2659 if (
2661// || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
2662 )
2663 {
2664 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2665 pNext(Lp.p) = strat->tail; // !!!
2666 }
2667
2668 if (atR >= 0)
2669 {
2670 Lp.i_r1 = strat->S_2_R[i];
2671 Lp.i_r2 = atR;
2672 }
2673 else
2674 {
2675 Lp.i_r1 = -1;
2676 Lp.i_r2 = -1;
2677 }
2678 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2679
2681 {
2684 && (Lp.p->coef!=NULL))
2685 nDelete(&(Lp.p->coef));
2686 }
2687
2688 l = strat->posInLSba(strat->B,strat->Bl,&Lp,strat);
2689 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2690 }
2691}
BOOLEAN(* rewCrit1)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:294
BOOLEAN(* rewCrit3)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:296
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.h:293
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9343
int posInSyz(const kStrategy strat, poly sig)
Definition kutil.cc:5765
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4889
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848

◆ enterOnePairSigRing()

static void enterOnePairSigRing ( int i,
poly p,
poly pSig,
int ,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )
static

Definition at line 2697 of file kutil.cc.

2699{
2700 #if ALL_VS_JUST
2701 //Over rings, if we construct the strong pair, do not add the spair
2703 {
2704 number s,t,d;
2705 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
2706
2707 if (!nIsZero(s) && !nIsZero(t)) // evtl. durch divBy tests ersetzen
2708 {
2709 nDelete(&d);
2710 nDelete(&s);
2711 nDelete(&t);
2712 return;
2713 }
2714 nDelete(&d);
2715 nDelete(&s);
2716 nDelete(&t);
2717 }
2718 #endif
2719 assume(i<=strat->sl);
2720 int l;
2721 poly m1 = NULL,m2 = NULL; // we need the multipliers for the s-polynomial to compute
2722 // the corresponding signatures for criteria checks
2723 LObject Lp;
2724 poly pSigMult = p_Copy(pSig,currRing);
2725 poly sSigMult = p_Copy(strat->sig[i],currRing);
2726 unsigned long pSigMultNegSev,sSigMultNegSev;
2727 Lp.i_r = -1;
2728
2729#ifdef KDEBUG
2730 Lp.ecart=0; Lp.length=0;
2731#endif
2732 /*- computes the lcm(s[i],p) -*/
2733 Lp.lcm = pInit();
2734 k_GetLeadTerms(p,strat->S[i],currRing,m1,m2,currRing);
2735#ifndef HAVE_RATGRING
2736 pLcm(p,strat->S[i],Lp.lcm);
2737#elif defined(HAVE_RATGRING)
2738 if (rIsRatGRing(currRing))
2739 pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
2740 else
2741 pLcm(p,strat->S[i],Lp.lcm);
2742#endif
2743 pSetm(Lp.lcm);
2744
2745 // set coeffs of multipliers m1 and m2
2747 {
2748 number s = nCopy(pGetCoeff(strat->S[i]));
2749 number t = nCopy(pGetCoeff(p));
2750 pSetCoeff0(Lp.lcm, n_Lcm(s, t, currRing->cf));
2751 ksCheckCoeff(&s, &t, currRing->cf);
2752 pSetCoeff0(m1,s);
2753 pSetCoeff0(m2,t);
2754 }
2755 else
2756 {
2757 pSetCoeff0(m1, nInit(1));
2758 pSetCoeff0(m2, nInit(1));
2759 }
2760#ifdef DEBUGF5
2761 Print("P1 ");
2762 pWrite(pHead(p));
2763 Print("P2 ");
2764 pWrite(pHead(strat->S[i]));
2765 Print("M1 ");
2766 pWrite(m1);
2767 Print("M2 ");
2768 pWrite(m2);
2769#endif
2770
2771 // get multiplied signatures for testing
2772 pSigMult = pp_Mult_mm(pSigMult,m1,currRing);
2773 if(pSigMult != NULL)
2774 pSigMultNegSev = ~p_GetShortExpVector(pSigMult,currRing);
2775 sSigMult = pp_Mult_mm(sSigMult,m2,currRing);
2776 if(sSigMult != NULL)
2777 sSigMultNegSev = ~p_GetShortExpVector(sSigMult,currRing);
2778//#if 1
2779#ifdef DEBUGF5
2780 Print("----------------\n");
2781 pWrite(pSigMult);
2782 pWrite(sSigMult);
2783 Print("----------------\n");
2784 Lp.checked = 0;
2785#endif
2786 int sigCmp;
2787 if(pSigMult != NULL && sSigMult != NULL)
2788 {
2790 sigCmp = p_LtCmpNoAbs(pSigMult,sSigMult,currRing);
2791 else
2792 sigCmp = p_LmCmp(pSigMult,sSigMult,currRing);
2793 }
2794 else
2795 {
2796 if(pSigMult == NULL)
2797 {
2798 if(sSigMult == NULL)
2799 sigCmp = 0;
2800 else
2801 sigCmp = -1;
2802 }
2803 else
2804 sigCmp = 1;
2805 }
2806//#if 1
2807#if DEBUGF5
2808 Print("IN PAIR GENERATION - COMPARING SIGS: %d\n",sigCmp);
2809 pWrite(pSigMult);
2810 pWrite(sSigMult);
2811#endif
2812 //In the ring case we already build the sig
2814 {
2815 if(sigCmp == 0)
2816 {
2817 //sigdrop since we loose the signature
2818 strat->sigdrop = TRUE;
2819 //Try to reduce it as far as we can via redRing
2821 {
2822 poly p1 = p_Copy(p,currRing);
2823 poly p2 = p_Copy(strat->S[i],currRing);
2824 p1 = p_Mult_mm(p1,m1,currRing);
2825 p2 = p_Mult_mm(p2,m2,currRing);
2826 Lp.p = p_Sub(p1,p2,currRing);
2827 if(Lp.p != NULL)
2828 Lp.sev = p_GetShortExpVector(Lp.p,currRing);
2829 }
2830 int red_result = redRing(&Lp,strat);
2831 if(red_result == 0)
2832 {
2833 // Cancel the sigdrop
2834 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
2835 strat->sigdrop = FALSE;
2836 return;
2837 }
2838 else
2839 {
2840 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
2841 #if 1
2842 strat->enterS(Lp,0,strat,strat->tl);
2843 #endif
2844 return;
2845 }
2846 }
2847 if(pSigMult != NULL && sSigMult != NULL && p_LmCmp(pSigMult,sSigMult,currRing) == 0)
2848 {
2849 //Same lm, have to subtract
2850 Lp.sig = p_Sub(pCopy(pSigMult),pCopy(sSigMult),currRing);
2851 }
2852 else
2853 {
2854 if(sigCmp == 1)
2855 {
2856 Lp.sig = pCopy(pSigMult);
2857 }
2858 if(sigCmp == -1)
2859 {
2860 Lp.sig = pNeg(pCopy(sSigMult));
2861 }
2862 }
2863 Lp.sevSig = p_GetShortExpVector(Lp.sig,currRing);
2864 }
2865
2866 #if 0
2867 if(sigCmp==0)
2868 {
2869 // printf("!!!! EQUAL SIGS !!!!\n");
2870 // pSig = sSig, delete element due to Rewritten Criterion
2871 pDelete(&pSigMult);
2872 pDelete(&sSigMult);
2874 pLmDelete(Lp.lcm);
2875 else
2876 pLmFree(Lp.lcm);
2877 pDelete (&m1);
2878 pDelete (&m2);
2879 return;
2880 }
2881 #endif
2882 // testing by syzCrit = F5 Criterion
2883 // testing by rewCrit1 = Rewritten Criterion
2884 // NOTE: Arri's Rewritten Criterion is tested below, we need Lp.p for it!
2885 if ( strat->syzCrit(pSigMult,pSigMultNegSev,strat) ||
2886 strat->syzCrit(sSigMult,sSigMultNegSev,strat)
2887 // With this rewCrit activated i get a wrong deletion in sba_int_56.tst
2888 //|| strat->rewCrit1(sSigMult,sSigMultNegSev,Lp.lcm,strat,i+1)
2889 )
2890 {
2891 pDelete(&pSigMult);
2892 pDelete(&sSigMult);
2894 pLmDelete(Lp.lcm);
2895 else
2896 pLmFree(Lp.lcm);
2897 pDelete (&m1);
2898 pDelete (&m2);
2899 return;
2900 }
2901 /*
2902 *the pair (S[i],p) enters B if the spoly != 0
2903 */
2904 /*- compute the short s-polynomial -*/
2905 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2906 pNorm(p);
2907
2908 if ((strat->S[i]==NULL) || (p==NULL))
2909 return;
2910
2911 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2912 Lp.p=NULL;
2913 else
2914 {
2915 //Build p
2917 {
2918 poly p1 = p_Copy(p,currRing);
2919 poly p2 = p_Copy(strat->S[i],currRing);
2920 p1 = p_Mult_mm(p1,m1,currRing);
2921 p2 = p_Mult_mm(p2,m2,currRing);
2922 Lp.p = p_Sub(p1,p2,currRing);
2923 if(Lp.p != NULL)
2924 Lp.sev = p_GetShortExpVector(Lp.p,currRing);
2925 }
2926 else
2927 {
2928 #ifdef HAVE_PLURAL
2929 if ( rIsPluralRing(currRing) )
2930 {
2931 if(ncRingType(currRing) == nc_lie)
2932 {
2933 // generalized prod-crit for lie-type
2934 strat->cp++;
2935 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2936 }
2937 else
2938 if( ALLOW_PROD_CRIT(strat) )
2939 {
2940 // product criterion for homogeneous case in SCA
2941 strat->cp++;
2942 Lp.p = NULL;
2943 }
2944 else
2945 {
2946 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2947 nc_CreateShortSpoly(strat->S[i], p, currRing);
2948
2949 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2950 pNext(Lp.p) = strat->tail; // !!!
2951 }
2952 }
2953 else
2954 #endif
2955 {
2957 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2958 }
2959 }
2960 }
2961 // store from which element this pair comes from for further tests
2962 //Lp.from = strat->sl+1;
2964 {
2965 //Put the sig to be > 0
2966 if(!nGreaterZero(pGetCoeff(Lp.sig)))
2967 {
2968 Lp.sig = pNeg(Lp.sig);
2969 Lp.p = pNeg(Lp.p);
2970 }
2971 }
2972 else
2973 {
2974 if(sigCmp==currRing->OrdSgn)
2975 {
2976 // pSig > sSig
2977 pDelete (&sSigMult);
2978 Lp.sig = pSigMult;
2979 Lp.sevSig = ~pSigMultNegSev;
2980 }
2981 else
2982 {
2983 // pSig < sSig
2984 pDelete (&pSigMult);
2985 Lp.sig = sSigMult;
2986 Lp.sevSig = ~sSigMultNegSev;
2987 }
2988 }
2989 if (Lp.p == NULL)
2990 {
2991 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2992 int pos = posInSyz(strat, Lp.sig);
2993 enterSyz(Lp, strat, pos);
2994 }
2995 else
2996 {
2997 // testing by rewCrit3 = Arris Rewritten Criterion (for F5 nothing happens!)
2998 if (strat->rewCrit3(Lp.sig,~Lp.sevSig,Lp.p,strat,strat->sl+1))
2999 {
3000 pLmFree(Lp.lcm);
3001 pDelete(&Lp.sig);
3002 pDelete (&m1);
3003 pDelete (&m2);
3004 return;
3005 }
3006 // in any case Lp is checked up to the next strat->P which is added
3007 // to S right after this critical pair creation.
3008 // NOTE: this even holds if the 2nd generator gives the bigger signature
3009 // moreover, this improves rewCriterion,
3010 // i.e. strat->checked > strat->from if and only if the 2nd generator
3011 // gives the bigger signature.
3012 Lp.checked = strat->sl+1;
3013 // at this point it is clear that the pair will be added to L, since it has
3014 // passed all tests up to now
3015
3016 // adds buchberger's first criterion
3017 if (pLmCmp(m2,pHead(p)) == 0)
3018 {
3019 Lp.prod_crit = TRUE; // Product Criterion
3020#if 0
3021 int pos = posInSyz(strat, Lp.sig);
3022 enterSyz(Lp, strat, pos);
3023 pDelete (&m1);
3024 pDelete (&m2);
3025 return;
3026#endif
3027 }
3028 pDelete (&m1);
3029 pDelete (&m2);
3030#if DEBUGF5
3031 PrintS("SIGNATURE OF PAIR: ");
3032 pWrite(Lp.sig);
3033#endif
3034 /*- the pair (S[i],p) enters B -*/
3035 Lp.p1 = strat->S[i];
3036 Lp.p2 = p;
3037
3038 if (
3040// || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
3042 )
3043 {
3044 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
3045 pNext(Lp.p) = strat->tail; // !!!
3046 }
3047
3048 if (atR >= 0)
3049 {
3050 Lp.i_r1 = strat->S_2_R[i];
3051 Lp.i_r2 = atR;
3052 }
3053 else
3054 {
3055 Lp.i_r1 = -1;
3056 Lp.i_r2 = -1;
3057 }
3058 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
3059
3061 {
3064 && (Lp.p->coef!=NULL))
3065 nDelete(&(Lp.p->coef));
3066 }
3067 // Check for sigdrop
3068 if(rField_is_Ring(currRing) && pLtCmp(Lp.sig,pSig) == -1)
3069 {
3070 strat->sigdrop = TRUE;
3071 // Completely reduce it
3072 int red_result = redRing(&Lp,strat);
3073 if(red_result == 0)
3074 {
3075 // Reduced to 0
3076 strat->sigdrop = FALSE;
3077 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
3078 return;
3079 }
3080 else
3081 {
3082 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
3083 // 0 - add just the original poly causing the sigdrop, 1 - add also this
3084 #if 1
3085 strat->enterS(Lp,0,strat, strat->tl+1);
3086 #endif
3087 return;
3088 }
3089 }
3090 l = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
3091 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l);
3092 }
3093}
#define nGreaterZero(n)
Definition numbers.h:27
poly p_Sub(poly p1, poly p2, const ring r)
Definition p_polys.cc:1994
static int p_LtCmpNoAbs(poly p, poly q, const ring r)
Definition p_polys.h:1663
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
#define pLtCmp(p, q)
Definition polys.h:124

◆ enterOnePairSpecial()

void enterOnePairSpecial ( int i,
poly p,
int ecart,
kStrategy strat,
int atR = -1 )

Definition at line 3099 of file kutil.cc.

3100{
3101 //PrintS("try ");wrp(strat->S[i]);PrintS(" and ");wrp(p);PrintLn();
3102 if(pHasNotCF(p,strat->S[i]))
3103 {
3104 //PrintS("prod-crit\n");
3105 if(ALLOW_PROD_CRIT(strat))
3106 {
3107 //PrintS("prod-crit\n");
3108 strat->cp++;
3109 return;
3110 }
3111 }
3112
3113 int l;
3114 LObject Lp;
3115 Lp.i_r = -1;
3116
3117 Lp.lcm = p_Lcm(p,strat->S[i],currRing);
3118 /*- compute the short s-polynomial -*/
3119
3120 #ifdef HAVE_PLURAL
3122 {
3123 Lp.p = nc_CreateShortSpoly(strat->S[i],p, currRing); // ??? strat->tailRing?
3124 }
3125 else
3126 #endif
3127 Lp.p = ksCreateShortSpoly(strat->S[i],p,strat->tailRing);
3128
3129 if (Lp.p == NULL)
3130 {
3131 //PrintS("short spoly==NULL\n");
3132 pLmFree(Lp.lcm);
3133 }
3134 else
3135 {
3136 /*- the pair (S[i],p) enters L -*/
3137 Lp.p1 = strat->S[i];
3138 Lp.p2 = p;
3139 if (atR >= 0)
3140 {
3141 Lp.i_r1 = strat->S_2_R[i];
3142 Lp.i_r2 = atR;
3143 }
3144 else
3145 {
3146 Lp.i_r1 = -1;
3147 Lp.i_r2 = -1;
3148 }
3149 assume(pNext(Lp.p) == NULL);
3150 pNext(Lp.p) = strat->tail;
3151 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
3153 {
3156 && (Lp.p->coef!=NULL))
3157 nDelete(&(Lp.p->coef));
3158 }
3159 l = strat->posInL(strat->L,strat->Ll,&Lp,strat);
3160 //Print("-> L[%d]\n",l);
3161 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l);
3162 }
3163}

◆ enterOnePairWithoutShifts()

static BOOLEAN enterOnePairWithoutShifts ( int p_inS,
poly q,
poly p,
int ecartq,
int q_isFromQ,
kStrategy strat,
int ,
int p_lastVblock,
int q_shift )
static

Definition at line 12131 of file kutil.cc.

12132{
12133 // note: ecart and isFromQ is for p
12134 assume(p_inS < 0 || strat->S[p_inS] == p); // if p is from S, p_inS should be the index of p in S
12135 assume(pmFirstVblock(p) == 1);
12136 assume(p_lastVblock == pmLastVblock(p));
12137 assume(q_shift == pmFirstVblock(q) - 1);
12138
12139 // TODO: is ecartp = 0 still ok?
12140 int ecartp = 0; //Hans says it's ok; we're in the homog e:, no ecart
12141
12142 int p_isFromQ = 0;
12143 if (strat->fromQ != NULL && p_inS >= 0)
12144 p_isFromQ = strat->fromQ[p_inS];
12145
12147 {
12148 assume(q_shift <= p_lastVblock); // we allow the special case where there is no overlap
12149 return enterOneStrongPolyAndEnterOnePairRingShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
12150 }
12151 else
12152 {
12153 assume(q_shift <= p_lastVblock - ((pGetComp(q) > 0 || pGetComp(p) > 0) ? 0 : 1)); // there should be an overlap (in the module case epsilon overlap is also allowed)
12154 return enterOnePairShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
12155 }
12156}
static BOOLEAN enterOneStrongPolyAndEnterOnePairRingShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
Definition kutil.cc:12060
BOOLEAN enterOnePairShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
Definition kutil.cc:12169
#define pmFirstVblock(p)
Definition shiftop.h:35
#define pmLastVblock(p)
Definition shiftop.h:33

◆ enterOnePairWithShifts()

static BOOLEAN enterOnePairWithShifts ( int q_inS,
poly q,
poly p,
int ecartp,
int p_isFromQ,
kStrategy strat,
int ,
int p_lastVblock,
int q_lastVblock )
static

Definition at line 12070 of file kutil.cc.

12071{
12072 // note: ecart and isFromQ is for p
12073 assume(q_inS < 0 || strat->S[q_inS] == q); // if q is from S, q_inS should be the index of q in S
12074 assume(pmFirstVblock(p) == 1);
12075 assume(pmFirstVblock(q) == 1);
12076 assume(p_lastVblock == pmLastVblock(p));
12077 assume(q_lastVblock == pmLastVblock(q));
12078
12079 // TODO: is ecartq = 0 still ok?
12080 int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
12081
12082 int q_isFromQ = 0;
12083 if (strat->fromQ != NULL && q_inS >= 0)
12084 q_isFromQ = strat->fromQ[q_inS];
12085
12086 BOOLEAN (*enterPair)(poly, poly, int, int, kStrategy, int, int, int, int, int);
12089 else
12090 enterPair = enterOnePairShift;
12091
12092 int degbound = currRing->N/currRing->isLPring;
12093 int neededShift = p_lastVblock - ((pGetComp(p) > 0 || pGetComp(q) > 0) ? 0 : 1); // in the module case, product criterion does not hold
12094 int maxPossibleShift = degbound - q_lastVblock;
12095 int maxShift = si_min(neededShift, maxPossibleShift);
12096 int firstShift = (q == p ? 1 : 0); // do not add (q,p) if q=p
12097 BOOLEAN delete_pair=TRUE;
12098 for (int j = firstShift; j <= maxShift; j++)
12099 {
12100 poly qq = pLPCopyAndShiftLM(q, j);
12101 if (enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, j, q_inS))
12102 {
12103 if (j>0) pLmDelete(qq);
12104 // delete qq, if not it does not enter the pair set
12105 }
12106 else
12107 delete_pair=FALSE;
12108 }
12109
12110 if (rField_is_Ring(currRing) && p_lastVblock >= firstShift && p_lastVblock <= maxPossibleShift)
12111 {
12112 // add pairs (m*shifts(q), p) where m is a monomial and the pair has no overlap
12113 for (int j = p_lastVblock; j <= maxPossibleShift; j++)
12114 {
12115 ideal fillers = id_MaxIdeal(j - p_lastVblock, currRing);
12116 for (int k = 0; k < IDELEMS(fillers); k++)
12117 {
12118 poly qq = pLPCopyAndShiftLM(pp_mm_Mult(q, fillers->m[k], currRing), p_lastVblock);
12119 enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, p_lastVblock, q_inS);
12120 }
12121 idDelete(&fillers);
12122 }
12123 }
12124 return delete_pair;
12125}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define pLPCopyAndShiftLM(p, sh)
Definition shiftgb.h:15
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
#define IDELEMS(i)
skStrategy * kStrategy
Definition structs.h:54
#define degbound(p)
Definition tgb.cc:153

◆ enterOneStrongPoly()

static BOOLEAN enterOneStrongPoly ( int i,
poly p,
int ,
int ,
kStrategy strat,
int atR,
bool enterTstrong )
static

Definition at line 1545 of file kutil.cc.

1546{
1547 number d, s, t;
1548 assume(atR >= 0);
1550 poly m1, m2, gcd,si;
1551 if(!enterTstrong)
1552 {
1553 assume(i<=strat->sl);
1554 si = strat->S[i];
1555 }
1556 else
1557 {
1558 assume(i<=strat->tl);
1559 si = strat->T[i].p;
1560 }
1561 //printf("\n--------------------------------\n");
1562 //pWrite(p);pWrite(si);
1563 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(si), &s, &t, currRing->cf);
1564
1565 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1566 {
1567 nDelete(&d);
1568 nDelete(&s);
1569 nDelete(&t);
1570 return FALSE;
1571 }
1572
1573 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1574
1576 {
1577 unsigned long sev = pGetShortExpVector(gcd);
1578
1579 for (int j = 0; j < strat->sl; j++)
1580 {
1581 if (j == i)
1582 continue;
1583
1584 if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf)
1585 && !(strat->sevS[j] & ~sev)
1586 && p_LmDivisibleBy(strat->S[j], gcd, currRing))
1587 {
1588 nDelete(&d);
1589 nDelete(&s);
1590 nDelete(&t);
1591 return FALSE;
1592 }
1593 }
1594 }
1595
1596 //p_Test(m1,strat->tailRing);
1597 //p_Test(m2,strat->tailRing);
1598 /*if(!enterTstrong)
1599 {
1600 while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
1601 {
1602 memset(&(strat->P), 0, sizeof(strat->P));
1603 kStratChangeTailRing(strat);
1604 strat->P = *(strat->R[atR]);
1605 p_LmFree(m1, strat->tailRing);
1606 p_LmFree(m2, strat->tailRing);
1607 p_LmFree(gcd, currRing);
1608 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1609 }
1610 }*/
1611 pSetCoeff0(m1, s);
1612 pSetCoeff0(m2, t);
1613 pSetCoeff0(gcd, d);
1614 p_Test(m1,strat->tailRing);
1615 p_Test(m2,strat->tailRing);
1616 //printf("\n===================================\n");
1617 //pWrite(m1);pWrite(m2);pWrite(gcd);
1618#ifdef KDEBUG
1619 if (TEST_OPT_DEBUG)
1620 {
1621 // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
1622 PrintS("m1 = ");
1623 p_wrp(m1, strat->tailRing);
1624 PrintS(" ; m2 = ");
1625 p_wrp(m2, strat->tailRing);
1626 PrintS(" ; gcd = ");
1627 wrp(gcd);
1628 PrintS("\n--- create strong gcd poly: ");
1629 Print("\n p: %d", i);
1630 wrp(p);
1631 Print("\n strat->S[%d]: ", i);
1632 wrp(si);
1633 PrintS(" ---> ");
1634 }
1635#endif
1636
1637 pNext(gcd) = p_Add_q(pp_Mult_mm(pNext(p), m1, strat->tailRing), pp_Mult_mm(pNext(si), m2, strat->tailRing), strat->tailRing);
1638 p_LmDelete(m1, strat->tailRing);
1639 p_LmDelete(m2, strat->tailRing);
1640#ifdef KDEBUG
1641 if (TEST_OPT_DEBUG)
1642 {
1643 wrp(gcd);
1644 PrintLn();
1645 }
1646#endif
1647
1648 LObject h;
1649 h.p = gcd;
1650 h.tailRing = strat->tailRing;
1651 int posx;
1652 strat->initEcart(&h);
1653 h.sev = pGetShortExpVector(h.p);
1654 h.i_r1 = -1;h.i_r2 = -1;
1655 if (currRing!=strat->tailRing)
1656 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
1657 if(!enterTstrong)
1658 {
1659 #if 1
1660 h.p1 = p;h.p2 = strat->S[i];
1661 #endif
1662 if (atR >= 0)
1663 {
1664 h.i_r2 = strat->S_2_R[i];
1665 h.i_r1 = atR;
1666 }
1667 else
1668 {
1669 h.i_r1 = -1;
1670 h.i_r2 = -1;
1671 }
1672 if (strat->Ll==-1)
1673 posx =0;
1674 else
1675 posx = strat->posInL(strat->L,strat->Ll,&h,strat);
1676 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
1677 }
1678 else
1679 {
1680 if(h.IsNull()) return FALSE;
1681 //int red_result;
1682 //reduzieren ist teur!!!
1683 //if(strat->L != NULL)
1684 //red_result = strat->red(&h,strat);
1685 if(!h.IsNull())
1686 {
1687 enterT(h, strat,-1);
1688 //int pos = posInS(strat,strat->sl,h.p,h.ecart);
1689 //strat->enterS(h,pos,strat,-1);
1690 }
1691 }
1692 return TRUE;
1693}
KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring tailRing)
Definition kInline.h:1057
void enterT(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9143
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1907
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769

◆ enterOneStrongPolyAndEnterOnePairRingShift()

static BOOLEAN enterOneStrongPolyAndEnterOnePairRingShift ( poly q,
poly p,
int ecart,
int isFromQ,
kStrategy strat,
int atR,
int ecartq,
int qisFromQ,
int shiftcount,
int ifromS )
static

Definition at line 12060 of file kutil.cc.

12061{
12062 enterOneStrongPolyShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "gpoly"
12063 enterOnePairRingShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "spoly"
12064 return FALSE; // TODO: delete q?
12065}
static void enterOnePairRingShift(poly q, poly p, int, int isFromQ, kStrategy strat, int atR, int, int qisFromQ, int shiftcount, int ifromS)
Definition kutil.cc:11816
static BOOLEAN enterOneStrongPolyShift(poly q, poly p, int, int, kStrategy strat, int atR, int, int, int shiftcount, int ifromS)
Definition kutil.cc:11647

◆ enterOneStrongPolyShift()

static BOOLEAN enterOneStrongPolyShift ( poly q,
poly p,
int ,
int ,
kStrategy strat,
int atR,
int ,
int ,
int shiftcount,
int ifromS )
static

Definition at line 11647 of file kutil.cc.

11648{
11649 number d, s, t;
11650 /* assume(atR >= 0); */
11651 assume(ifromS <= strat->sl);
11653 poly m1, m2, gcd;
11654 //printf("\n--------------------------------\n");
11655 //pWrite(p);pWrite(si);
11656 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(q), &s, &t, currRing->cf);
11657
11658 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
11659 {
11660 nDelete(&d);
11661 nDelete(&s);
11662 nDelete(&t);
11663 return FALSE;
11664 }
11665
11666 assume(pIsInV(p));
11667
11668 k_GetStrongLeadTerms(p, q, currRing, m1, m2, gcd, strat->tailRing);
11669
11670 /* the V criterion */
11671 if (!pmIsInV(gcd))
11672 {
11673 strat->cv++;
11674 nDelete(&d);
11675 nDelete(&s);
11676 nDelete(&t);
11677 pLmFree(gcd);
11678 return FALSE;
11679 }
11680
11681 // disabled for Letterplace because it is not so easy to check
11682 /* if (!rHasLocalOrMixedOrdering(currRing)) { */
11683 /* unsigned long sev = pGetShortExpVector(gcd); */
11684
11685 /* for (int j = 0; j < strat->sl; j++) { */
11686 /* if (j == i) */
11687 /* continue; */
11688
11689 /* if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf) && */
11690 /* !(strat->sevS[j] & ~sev) && */
11691 /* p_LmDivisibleBy(strat->S[j], gcd, currRing)) { */
11692 /* nDelete(&d); */
11693 /* nDelete(&s); */
11694 /* nDelete(&t); */
11695 /* return FALSE; */
11696 /* } */
11697 /* } */
11698 /* } */
11699
11700 poly m12, m22;
11704 // manually free the coeffs, because pSetCoeff0 is used in the next step
11705 n_Delete(&(m1->coef), currRing->cf);
11706 n_Delete(&(m2->coef), currRing->cf);
11707
11708 //p_Test(m1,strat->tailRing);
11709 //p_Test(m2,strat->tailRing);
11710 /*if(!enterTstrong)
11711 {
11712 while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
11713 {
11714 memset(&(strat->P), 0, sizeof(strat->P));
11715 kStratChangeTailRing(strat);
11716 strat->P = *(strat->R[atR]);
11717 p_LmFree(m1, strat->tailRing);
11718 p_LmFree(m2, strat->tailRing);
11719 p_LmFree(gcd, currRing);
11720 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
11721 }
11722 }*/
11723 pSetCoeff0(m1, s);
11724 pSetCoeff0(m2, t);
11725 pSetCoeff0(gcd, d);
11726 p_Test(m1,strat->tailRing);
11727 p_Test(m2,strat->tailRing);
11728 p_Test(m12,strat->tailRing);
11729 p_Test(m22,strat->tailRing);
11730 assume(pmIsInV(m1));
11731 assume(pmIsInV(m2));
11732 assume(pmIsInV(m12));
11733 assume(pmIsInV(m22));
11734 //printf("\n===================================\n");
11735 //pWrite(m1);pWrite(m2);pWrite(gcd);
11736#ifdef KDEBUG
11737 if (TEST_OPT_DEBUG)
11738 {
11739 // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
11740 PrintS("m1 = ");
11741 p_wrp(m1, strat->tailRing);
11742 PrintS("m12 = ");
11743 p_wrp(m12, strat->tailRing);
11744 PrintS(" ; m2 = ");
11745 p_wrp(m2, strat->tailRing);
11746 PrintS(" ; m22 = ");
11747 p_wrp(m22, strat->tailRing);
11748 PrintS(" ; gcd = ");
11749 wrp(gcd);
11750 PrintS("\n--- create strong gcd poly: ");
11751 PrintS("\n p: ");
11752 wrp(p);
11753 Print("\n q (strat->S[%d]): ", ifromS);
11754 wrp(q);
11755 PrintS(" ---> ");
11756 }
11757#endif
11758
11759 pNext(gcd) = p_Add_q(pp_Mult_mm(pp_mm_Mult(pNext(p), m1, strat->tailRing), m12, strat->tailRing), pp_Mult_mm(pp_mm_Mult(pNext(q), m2, strat->tailRing), m22, strat->tailRing), strat->tailRing);
11760 p_LmDelete(m1, strat->tailRing);
11761 p_LmDelete(m2, strat->tailRing);
11762 p_LmDelete(m12, strat->tailRing);
11763 p_LmDelete(m22, strat->tailRing);
11764
11765 assume(pIsInV(gcd));
11766
11767#ifdef KDEBUG
11768 if (TEST_OPT_DEBUG)
11769 {
11770 wrp(gcd);
11771 PrintLn();
11772 }
11773#endif
11774
11775 LObject h;
11776 h.p = gcd;
11777 h.tailRing = strat->tailRing;
11778 int posx;
11779 strat->initEcart(&h);
11780 h.sev = pGetShortExpVector(h.p);
11781 h.i_r1 = -1;h.i_r2 = -1;
11782 if (currRing!=strat->tailRing)
11783 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
11784#if 1
11785 h.p1 = p;
11786 h.p2 = q;
11787#endif
11788 if (atR >= 0 && shiftcount == 0 && ifromS >= 0)
11789 {
11790 h.i_r2 = kFindInT(h.p1, strat);
11791 h.i_r1 = atR;
11792 }
11793 else
11794 {
11795 h.i_r1 = -1;
11796 h.i_r2 = -1;
11797 }
11798 if (strat->Ll==-1)
11799 posx =0;
11800 else
11801 posx = strat->posInL(strat->L,strat->Ll,&h,strat);
11802
11803 assume(pIsInV(h.p));
11804 assume(pIsInV(h.p1));
11805
11806 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
11807 return TRUE;
11808}

◆ enterOneStrongPolySig()

static BOOLEAN enterOneStrongPolySig ( int i,
poly p,
poly sig,
int ,
int ,
kStrategy strat,
int atR )
static

Definition at line 1753 of file kutil.cc.

1754{
1755 number d, s, t;
1756 assume(atR >= 0);
1757 poly m1, m2, gcd,si;
1758 assume(i<=strat->sl);
1759 si = strat->S[i];
1760 //printf("\n--------------------------------\n");
1761 //pWrite(p);pWrite(si);
1762 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(si), &s, &t, currRing->cf);
1763
1764 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1765 {
1766 nDelete(&d);
1767 nDelete(&s);
1768 nDelete(&t);
1769 return FALSE;
1770 }
1771
1772 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1773 //p_Test(m1,strat->tailRing);
1774 //p_Test(m2,strat->tailRing);
1775 /*if(!enterTstrong)
1776 {
1777 while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
1778 {
1779 memset(&(strat->P), 0, sizeof(strat->P));
1780 kStratChangeTailRing(strat);
1781 strat->P = *(strat->R[atR]);
1782 p_LmFree(m1, strat->tailRing);
1783 p_LmFree(m2, strat->tailRing);
1784 p_LmFree(gcd, currRing);
1785 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1786 }
1787 }*/
1788 pSetCoeff0(m1, s);
1789 pSetCoeff0(m2, t);
1790 pSetCoeff0(gcd, d);
1791 p_Test(m1,strat->tailRing);
1792 p_Test(m2,strat->tailRing);
1793 //printf("\n===================================\n");
1794 //pWrite(m1);pWrite(m2);pWrite(gcd);
1795#ifdef KDEBUG
1796 if (TEST_OPT_DEBUG)
1797 {
1798 // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
1799 PrintS("m1 = ");
1800 p_wrp(m1, strat->tailRing);
1801 PrintS(" ; m2 = ");
1802 p_wrp(m2, strat->tailRing);
1803 PrintS(" ; gcd = ");
1804 wrp(gcd);
1805 PrintS("\n--- create strong gcd poly: ");
1806 Print("\n p: %d", i);
1807 wrp(p);
1808 Print("\n strat->S[%d]: ", i);
1809 wrp(si);
1810 PrintS(" ---> ");
1811 }
1812#endif
1813
1814 pNext(gcd) = p_Add_q(pp_Mult_mm(pNext(p), m1, strat->tailRing), pp_Mult_mm(pNext(si), m2, strat->tailRing), strat->tailRing);
1815
1816#ifdef KDEBUG
1817 if (TEST_OPT_DEBUG)
1818 {
1819 wrp(gcd);
1820 PrintLn();
1821 }
1822#endif
1823
1824 //Check and set the signatures
1825 poly pSigMult = p_Copy(sig,currRing);
1826 poly sSigMult = p_Copy(strat->sig[i],currRing);
1827 pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1828 sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1829 p_LmDelete(m1, strat->tailRing);
1830 p_LmDelete(m2, strat->tailRing);
1831 poly pairsig;
1832 if(pLmCmp(pSigMult,sSigMult) == 0)
1833 {
1834 //Same lm, have to add them
1835 pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1836 //This might be zero
1837 }
1838 else
1839 {
1840 //Set the sig to either pSigMult or sSigMult
1841 if(pLtCmp(pSigMult,sSigMult)==1)
1842 {
1843 pairsig = pSigMult;
1844 pDelete(&sSigMult);
1845 }
1846 else
1847 {
1848 pairsig = sSigMult;
1849 pDelete(&pSigMult);
1850 }
1851 }
1852
1853 LObject h;
1854 h.p = gcd;
1855 h.tailRing = strat->tailRing;
1856 h.sig = pairsig;
1857 int posx;
1858 strat->initEcart(&h);
1859 h.sev = pGetShortExpVector(h.p);
1860 h.i_r1 = -1;h.i_r2 = -1;
1861 if (currRing!=strat->tailRing)
1862 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
1863 if(h.sig == NULL)
1864 {
1865 //sigdrop since we loose the signature
1866 strat->sigdrop = TRUE;
1867 //Try to reduce it as far as we can via redRing
1868 int red_result = redRing(&h,strat);
1869 if(red_result == 0)
1870 {
1871 // Cancel the sigdrop
1872 p_Delete(&h.sig,currRing);h.sig = NULL;
1873 strat->sigdrop = FALSE;
1874 return FALSE;
1875 }
1876 else
1877 {
1878 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
1879 #if 1
1880 strat->enterS(h,0,strat,strat->tl);
1881 #endif
1882 return FALSE;
1883 }
1884 }
1885 if(!nGreaterZero(pGetCoeff(h.sig)))
1886 {
1887 h.sig = pNeg(h.sig);
1888 h.p = pNeg(h.p);
1889 }
1890
1891 if(rField_is_Ring(currRing) && pLtCmp(h.sig,sig) == -1)
1892 {
1893 strat->sigdrop = TRUE;
1894 // Completely reduce it
1895 int red_result = redRing(&h,strat);
1896 if(red_result == 0)
1897 {
1898 // Reduced to 0
1899 strat->sigdrop = FALSE;
1900 p_Delete(&h.sig,currRing);h.sig = NULL;
1901 return FALSE;
1902 }
1903 else
1904 {
1905 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
1906 // 0 - add just the original poly causing the sigdrop, 1 - add also this
1907 #if 1
1908 strat->enterS(h,0,strat, strat->tl+1);
1909 #endif
1910 return FALSE;
1911 }
1912 }
1913 //Check for sigdrop
1914 if(gcd != NULL && pLtCmp(sig,pairsig) > 0 && pLtCmp(strat->sig[i],pairsig) > 0)
1915 {
1916 strat->sigdrop = TRUE;
1917 //Enter this element to S
1918 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
1919 strat->enterS(h,strat->sl+1,strat,strat->tl+1);
1920 }
1921 #if 1
1922 h.p1 = p;h.p2 = strat->S[i];
1923 #endif
1924 if (atR >= 0)
1925 {
1926 h.i_r2 = strat->S_2_R[i];
1927 h.i_r1 = atR;
1928 }
1929 else
1930 {
1931 h.i_r1 = -1;
1932 h.i_r2 = -1;
1933 }
1934 if (strat->Ll==-1)
1935 posx =0;
1936 else
1937 posx = strat->posInLSba(strat->L,strat->Ll,&h,strat);
1938 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
1939 return TRUE;
1940}

◆ enterpairs()

void enterpairs ( poly h,
int k,
int ecart,
int pos,
kStrategy strat,
int atR )

Definition at line 4494 of file kutil.cc.

4495{
4496 int j=pos;
4497
4499 initenterpairs(h,k,ecart,0,strat, atR);
4500 if ( (!strat->fromT)
4501 && ((strat->syzComp==0)
4502 ||(pGetComp(h)<=strat->syzComp)))
4503 {
4504 unsigned long h_sev = pGetShortExpVector(h);
4505 loop
4506 {
4507 if (j > k) break;
4508 clearS(h,h_sev, &j,&k,strat);
4509 j++;
4510 }
4511 }
4512}
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:3816

◆ enterpairsShift()

void enterpairsShift ( poly h,
int k,
int ecart,
int pos,
kStrategy strat,
int atR )

Definition at line 12953 of file kutil.cc.

12954{
12955 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12956 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
12957 int j=pos;
12958
12959 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
12960 initenterpairsShift(h,k,ecart,0,strat, atR);
12961 if ( (!strat->fromT)
12962 && ((strat->syzComp==0)
12963 ||(pGetComp(h)<=strat->syzComp)))
12964 {
12965 unsigned long h_sev = pGetShortExpVector(h);
12966 loop
12967 {
12968 if (j > k) break;
12969 // TODO this currently doesn't clear all possible elements because of commutative division
12970 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
12971 clearS(h,h_sev, &j,&k,strat);
12972 j++;
12973 }
12974 }
12975}
char rightGB
Definition kutil.h:368
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:12511

◆ enterpairsSig()

void enterpairsSig ( poly h,
poly hSig,
int hFrom,
int k,
int ecart,
int pos,
kStrategy strat,
int atR )

Definition at line 4520 of file kutil.cc.

4521{
4522 int j=pos;
4524 initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4525 if ( (!strat->fromT)
4526 && ((strat->syzComp==0)
4527 ||(pGetComp(h)<=strat->syzComp)))
4528 {
4529 unsigned long h_sev = pGetShortExpVector(h);
4530 loop
4531 {
4532 if (j > k) break;
4533 clearS(h,h_sev, &j,&k,strat);
4534 j++;
4535 }
4536 }
4537}
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3881

◆ enterpairsSpecial()

void enterpairsSpecial ( poly h,
int k,
int ecart,
int pos,
kStrategy strat,
int atR = -1 )

Definition at line 4543 of file kutil.cc.

4544{
4545 int j;
4546 const int iCompH = pGetComp(h);
4547
4549 {
4550 for (j=0; j<=k; j++)
4551 {
4552 const int iCompSj = pGetComp(strat->S[j]);
4553 if ((iCompH==iCompSj)
4554 //|| (0==iCompH) // can only happen,if iCompSj==0
4555 || (0==iCompSj))
4556 {
4557 enterOnePairRing(j,h,ecart,FALSE,strat, atR);
4558 }
4559 }
4560 kMergeBintoL(strat);
4561 }
4562 else
4563 {
4564 for (j=0; j<=k; j++)
4565 {
4566 const int iCompSj = pGetComp(strat->S[j]);
4567 if ((iCompH==iCompSj)
4568 //|| (0==iCompH) // can only happen,if iCompSj==0
4569 || (0==iCompSj))
4570 {
4571 enterOnePairSpecial(j,h,ecart,strat, atR);
4572 }
4573 }
4574 }
4575
4576 if (strat->noClearS) return;
4577
4578// #ifdef HAVE_PLURAL
4579/*
4580 if (rIsPluralRing(currRing))
4581 {
4582 j=pos;
4583 loop
4584 {
4585 if (j > k) break;
4586
4587 if (pLmDivisibleBy(h, strat->S[j]))
4588 {
4589 deleteInS(j, strat);
4590 j--;
4591 k--;
4592 }
4593
4594 j++;
4595 }
4596 }
4597 else
4598*/
4599// #endif // ??? Why was the following cancellation disabled for non-commutative rings?
4600 {
4601 j=pos;
4602 loop
4603 {
4604 unsigned long h_sev = pGetShortExpVector(h);
4605 if (j > k) break;
4606 clearS(h,h_sev,&j,&k,strat);
4607 j++;
4608 }
4609 }
4610}
char noClearS
Definition kutil.h:401
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:1341
void enterOnePairSpecial(int i, poly p, int ecart, kStrategy strat, int atR=-1)
Definition kutil.cc:3099

◆ enterSBba()

void enterSBba ( LObject & p,
int atS,
kStrategy strat,
int atR )

Definition at line 8794 of file kutil.cc.

8795{
8796 strat->news = TRUE;
8797 /*- puts p to the standardbasis s at position at -*/
8798 if (strat->sl == IDELEMS(strat->Shdl)-1)
8799 {
8800 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
8801 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8802 (IDELEMS(strat->Shdl)+setmaxTinc)
8803 *sizeof(unsigned long));
8804 strat->ecartS = (intset)omReallocSize(strat->ecartS,
8805 IDELEMS(strat->Shdl)*sizeof(int),
8806 (IDELEMS(strat->Shdl)+setmaxTinc)
8807 *sizeof(int));
8808 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
8809 IDELEMS(strat->Shdl)*sizeof(int),
8810 (IDELEMS(strat->Shdl)+setmaxTinc)
8811 *sizeof(int));
8812 if (strat->lenS!=NULL)
8813 strat->lenS=(int*)omRealloc0Size(strat->lenS,
8814 IDELEMS(strat->Shdl)*sizeof(int),
8815 (IDELEMS(strat->Shdl)+setmaxTinc)
8816 *sizeof(int));
8817 if (strat->lenSw!=NULL)
8818 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
8819 IDELEMS(strat->Shdl)*sizeof(wlen_type),
8820 (IDELEMS(strat->Shdl)+setmaxTinc)
8821 *sizeof(wlen_type));
8822 if (strat->fromQ!=NULL)
8823 {
8824 strat->fromQ = (intset)omReallocSize(strat->fromQ,
8825 IDELEMS(strat->Shdl)*sizeof(int),
8826 (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
8827 }
8828 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
8829 IDELEMS(strat->Shdl)+=setmaxTinc;
8830 strat->Shdl->m=strat->S;
8831 }
8832 if (atS <= strat->sl)
8833 {
8834#ifdef ENTER_USE_MEMMOVE
8835 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
8836 (strat->sl - atS + 1)*sizeof(poly));
8837 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
8838 (strat->sl - atS + 1)*sizeof(int));
8839 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
8840 (strat->sl - atS + 1)*sizeof(unsigned long));
8841 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
8842 (strat->sl - atS + 1)*sizeof(int));
8843 if (strat->lenS!=NULL)
8844 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
8845 (strat->sl - atS + 1)*sizeof(int));
8846 if (strat->lenSw!=NULL)
8847 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
8848 (strat->sl - atS + 1)*sizeof(wlen_type));
8849#else
8850 for (i=strat->sl+1; i>=atS+1; i--)
8851 {
8852 strat->S[i] = strat->S[i-1];
8853 strat->ecartS[i] = strat->ecartS[i-1];
8854 strat->sevS[i] = strat->sevS[i-1];
8855 strat->S_2_R[i] = strat->S_2_R[i-1];
8856 }
8857 if (strat->lenS!=NULL)
8858 for (i=strat->sl+1; i>=atS+1; i--)
8859 strat->lenS[i] = strat->lenS[i-1];
8860 if (strat->lenSw!=NULL)
8861 for (i=strat->sl+1; i>=atS+1; i--)
8862 strat->lenSw[i] = strat->lenSw[i-1];
8863#endif
8864 }
8865 if (strat->fromQ!=NULL)
8866 {
8867#ifdef ENTER_USE_MEMMOVE
8868 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
8869 (strat->sl - atS + 1)*sizeof(int));
8870#else
8871 for (i=strat->sl+1; i>=atS+1; i--)
8872 {
8873 strat->fromQ[i] = strat->fromQ[i-1];
8874 }
8875#endif
8876 strat->fromQ[atS]=0;
8877 }
8878
8879 /*- save result -*/
8880 poly pp=p.p;
8881 strat->S[atS] = pp;
8882 if (strat->honey) strat->ecartS[atS] = p.ecart;
8883 if (p.sev == 0)
8884 p.sev = pGetShortExpVector(pp);
8885 else
8886 assume(p.sev == pGetShortExpVector(pp));
8887 strat->sevS[atS] = p.sev;
8888 strat->ecartS[atS] = p.ecart;
8889 strat->S_2_R[atS] = atR;
8890 strat->sl++;
8891}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
char news
Definition kutil.h:399
char honey
Definition kutil.h:376
ideal Shdl
Definition kutil.h:304
#define setmaxTinc
Definition kutil.h:35
int * intset
Definition kutil.h:54
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3776

◆ enterSBbaShift()

void enterSBbaShift ( LObject & p,
int atS,
kStrategy strat,
int atR )

Definition at line 8894 of file kutil.cc.

8895{
8896 enterSBba(p, atS, strat, atR);
8897
8898 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
8899 for (int i = maxPossibleShift; i > 0; i--)
8900 {
8901 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
8902 // in `kNF2` because of lazy poly normalizations.
8903 LObject qq(p_Copy(p.p, strat->tailRing));
8904 p_mLPshift(qq.p, i, strat->tailRing);
8905 qq.shift = i;
8906 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
8907 int atS = posInS(strat, strat->sl, qq.p, qq.ecart); // S needs to stay sorted because this is for example assumed when searching S later
8908 enterSBba(qq, atS, strat, -1);
8909 }
8910}
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4670
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8794
int p_mLPmaxPossibleShift(poly p, const ring r)
Definition shiftgb.cc:45
void p_mLPshift(poly m, int sh, const ring ri)
Definition shiftop.cc:362

◆ enterSMora()

void enterSMora ( LObject & p,
int atS,
kStrategy strat,
int atR = -1 )

Definition at line 1620 of file kstd1.cc.

1621{
1622 enterSBba(p, atS, strat, atR);
1623 #ifdef KDEBUG
1624 if (TEST_OPT_DEBUG)
1625 {
1626 Print("new s%d:",atS);
1627 p_wrp(p.p,currRing,strat->tailRing);
1628 PrintLn();
1629 }
1630 #endif
1631 HEckeTest(p.p,strat);
1632 if (strat->kAllAxis)
1633 {
1634 if (newHEdge(strat))
1635 {
1636 firstUpdate(strat);
1637 if (TEST_OPT_FINDET)
1638 return;
1639
1640 /*- cuts elements in L above noether and reorders L -*/
1641 updateLHC(strat);
1642 /*- reorders L with respect to posInL -*/
1643 reorderL(strat);
1644 }
1645 }
1646 else if ((strat->kNoether==NULL)
1647 && (TEST_OPT_FASTHC))
1648 {
1649 if (strat->posInLOldFlag)
1650 {
1651 missingAxis(&strat->lastAxis,strat);
1652 if (strat->lastAxis)
1653 {
1654 strat->posInLOld = strat->posInL;
1655 strat->posInLOldFlag = FALSE;
1656 strat->posInL = posInL10;
1657 strat->posInLDependsOnLength = TRUE;
1658 updateL(strat);
1659 reorderL(strat);
1660 }
1661 }
1662 else if (strat->lastAxis)
1663 updateL(strat);
1664 }
1665}
char posInLOldFlag
Definition kutil.h:381
int lastAxis
Definition kutil.h:356
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:289
char kAllAxis
Definition kutil.h:375
char posInLDependsOnLength
Definition kutil.h:388
void firstUpdate(kStrategy strat)
Definition kstd1.cc:1557
void updateLHC(kStrategy strat)
Definition kstd1.cc:1465
void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1279
void reorderL(kStrategy strat)
Definition kstd1.cc:1222
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1360
void updateL(kStrategy strat)
Definition kstd1.cc:1393
void HEckeTest(poly pp, kStrategy strat)
Definition kutil.cc:493
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10409
#define TEST_OPT_FINDET
Definition options.h:113
#define TEST_OPT_FASTHC
Definition options.h:111

◆ enterSMoraNF()

void enterSMoraNF ( LObject & p,
int atS,
kStrategy strat,
int atR = -1 )

Definition at line 1673 of file kstd1.cc.

1674{
1675 enterSBba(p, atS, strat, atR);
1676 if ((!strat->kAllAxis) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat);
1677 if (strat->kAllAxis)
1678 newHEdge(strat);
1679}

◆ enterSSba()

void enterSSba ( LObject & p,
int atS,
kStrategy strat,
int atR )

Definition at line 8917 of file kutil.cc.

8918{
8919 strat->news = TRUE;
8920 /*- puts p to the standardbasis s at position at -*/
8921 if (strat->sl == IDELEMS(strat->Shdl)-1)
8922 {
8923 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
8924 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8925 (IDELEMS(strat->Shdl)+setmax)
8926 *sizeof(unsigned long));
8927 strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
8928 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8929 (IDELEMS(strat->Shdl)+setmax)
8930 *sizeof(unsigned long));
8931 strat->ecartS = (intset)omReallocSize(strat->ecartS,
8932 IDELEMS(strat->Shdl)*sizeof(int),
8933 (IDELEMS(strat->Shdl)+setmax)
8934 *sizeof(int));
8935 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
8936 IDELEMS(strat->Shdl)*sizeof(int),
8937 (IDELEMS(strat->Shdl)+setmax)
8938 *sizeof(int));
8939 if (strat->lenS!=NULL)
8940 strat->lenS=(int*)omRealloc0Size(strat->lenS,
8941 IDELEMS(strat->Shdl)*sizeof(int),
8942 (IDELEMS(strat->Shdl)+setmax)
8943 *sizeof(int));
8944 if (strat->lenSw!=NULL)
8945 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
8946 IDELEMS(strat->Shdl)*sizeof(wlen_type),
8947 (IDELEMS(strat->Shdl)+setmax)
8948 *sizeof(wlen_type));
8949 if (strat->fromQ!=NULL)
8950 {
8951 strat->fromQ = (intset)omReallocSize(strat->fromQ,
8952 IDELEMS(strat->Shdl)*sizeof(int),
8953 (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
8954 }
8955 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
8956 pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
8957 IDELEMS(strat->Shdl)+=setmax;
8958 strat->Shdl->m=strat->S;
8959 }
8960 // in a signature-based algorithm the following situation will never
8961 // appear due to the fact that the critical pairs are already sorted
8962 // by increasing signature.
8963 // True. However, in the case of integers we need to put the element
8964 // that caused the signature drop on the first position
8965 if (atS <= strat->sl)
8966 {
8967#ifdef ENTER_USE_MEMMOVE
8968 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
8969 (strat->sl - atS + 1)*sizeof(poly));
8970 memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
8971 (strat->sl - atS + 1)*sizeof(poly));
8972 memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
8973 (strat->sl - atS + 1)*sizeof(unsigned long));
8974 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
8975 (strat->sl - atS + 1)*sizeof(int));
8976 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
8977 (strat->sl - atS + 1)*sizeof(unsigned long));
8978 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
8979 (strat->sl - atS + 1)*sizeof(int));
8980 if (strat->lenS!=NULL)
8981 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
8982 (strat->sl - atS + 1)*sizeof(int));
8983 if (strat->lenSw!=NULL)
8984 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
8985 (strat->sl - atS + 1)*sizeof(wlen_type));
8986#else
8987 for (i=strat->sl+1; i>=atS+1; i--)
8988 {
8989 strat->S[i] = strat->S[i-1];
8990 strat->ecartS[i] = strat->ecartS[i-1];
8991 strat->sevS[i] = strat->sevS[i-1];
8992 strat->S_2_R[i] = strat->S_2_R[i-1];
8993 strat->sig[i] = strat->sig[i-1];
8994 strat->sevSig[i] = strat->sevSig[i-1];
8995 }
8996 if (strat->lenS!=NULL)
8997 for (i=strat->sl+1; i>=atS+1; i--)
8998 strat->lenS[i] = strat->lenS[i-1];
8999 if (strat->lenSw!=NULL)
9000 for (i=strat->sl+1; i>=atS+1; i--)
9001 strat->lenSw[i] = strat->lenSw[i-1];
9002#endif
9003 }
9004 if (strat->fromQ!=NULL)
9005 {
9006#ifdef ENTER_USE_MEMMOVE
9007 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9008 (strat->sl - atS + 1)*sizeof(int));
9009#else
9010 for (i=strat->sl+1; i>=atS+1; i--)
9011 {
9012 strat->fromQ[i] = strat->fromQ[i-1];
9013 }
9014#endif
9015 strat->fromQ[atS]=0;
9016 }
9017
9018 /*- save result -*/
9019 strat->S[atS] = p.p;
9020 strat->sig[atS] = p.sig; // TODO: get the correct signature in here!
9021 if (strat->honey) strat->ecartS[atS] = p.ecart;
9022 if (p.sev == 0)
9023 p.sev = pGetShortExpVector(p.p);
9024 else
9025 assume(p.sev == pGetShortExpVector(p.p));
9026 strat->sevS[atS] = p.sev;
9027 // during the interreduction process of a signature-based algorithm we do not
9028 // compute the signature at this point, but when the whole interreduction
9029 // process finishes, i.e. f5c terminates!
9030 if (p.sig != NULL)
9031 {
9032 if (p.sevSig == 0)
9033 p.sevSig = pGetShortExpVector(p.sig);
9034 else
9035 assume(p.sevSig == pGetShortExpVector(p.sig));
9036 strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9037 }
9038 strat->ecartS[atS] = p.ecart;
9039 strat->S_2_R[atS] = atR;
9040 strat->sl++;
9041#ifdef DEBUGF5
9042 int k;
9043 Print("--- LIST S: %d ---\n",strat->sl);
9044 for(k=0;k<=strat->sl;k++)
9045 {
9046 pWrite(strat->sig[k]);
9047 }
9048 PrintS("--- LIST S END ---\n");
9049#endif
9050}
#define setmax
Definition kutil.h:30

◆ enterSyz()

void enterSyz ( LObject & p,
kStrategy strat,
int atT )

Definition at line 9343 of file kutil.cc.

9344{
9345 int i;
9346 strat->newt = TRUE;
9347 if (strat->syzl == strat->syzmax-1)
9348 {
9349 pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9350 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9351 (strat->syzmax)*sizeof(unsigned long),
9352 ((strat->syzmax)+setmax)
9353 *sizeof(unsigned long));
9354 strat->syzmax += setmax;
9355 }
9356 if (atT < strat->syzl)
9357 {
9358#ifdef ENTER_USE_MEMMOVE
9359 memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9360 (strat->syzl-atT+1)*sizeof(poly));
9361 memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9362 (strat->syzl-atT+1)*sizeof(unsigned long));
9363#endif
9364 for (i=strat->syzl; i>=atT+1; i--)
9365 {
9366#ifndef ENTER_USE_MEMMOVE
9367 strat->syz[i] = strat->syz[i-1];
9368 strat->sevSyz[i] = strat->sevSyz[i-1];
9369#endif
9370 }
9371 }
9372 //i = strat->syzl;
9373 i = atT;
9374 //Makes sure the syz saves just the signature
9376 pNext(p.sig) = NULL;
9377 strat->syz[atT] = p.sig;
9378 strat->sevSyz[atT] = p.sevSig;
9379 strat->syzl++;
9380#if F5DEBUG
9381 Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9382 pWrite(strat->syz[atT]);
9383#endif
9384 // recheck pairs in strat->L with new rule and delete correspondingly
9385 int cc = strat->Ll;
9386 while (cc>-1)
9387 {
9388 //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9389 //printf("\npLmShDivBy(syz,L) = %i\nn_DivBy(L,syz) = %i\n pLtCmp(L,syz) = %i",p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],strat->L[cc].sig, ~strat->L[cc].sevSig, currRing), n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing), pLtCmp(strat->L[cc].sig,strat->syz[atT])==1);
9390 if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9391 strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9393 || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9394 )
9395 {
9396 //printf("\nYES!\n");
9397 deleteInL(strat->L,&strat->Ll,cc,strat);
9398 }
9399 cc--;
9400 }
9401//#if 1
9402#ifdef DEBUGF5
9403 PrintS("--- Syzygies ---\n");
9404 Print("syzl %d\n",strat->syzl);
9405 Print("syzmax %d\n",strat->syzmax);
9406 PrintS("--------------------------------\n");
9407 for(i=0;i<=strat->syzl-1;i++)
9408 {
9409 Print("%d - ",i);
9410 pWrite(strat->syz[i]);
9411 }
9412 PrintS("--------------------------------\n");
9413#endif
9414}
unsigned long * sevSyz
Definition kutil.h:324
int syzmax
Definition kutil.h:350
int syzl
Definition kutil.h:350
polyset syz
Definition kutil.h:308
char newt
Definition kutil.h:400

◆ enterT()

void enterT ( LObject & p,
kStrategy strat,
int atT )

Definition at line 9143 of file kutil.cc.

9144{
9145 int i;
9146
9147#ifdef PDEBUG
9148#ifdef HAVE_SHIFTBBA
9149 if (currRing->isLPring && p.shift > 0)
9150 {
9151 // in this case, the order is not correct. test LM and tail separately
9152 p_LmTest(p.p, currRing);
9153 p_Test(pNext(p.p), currRing);
9154 }
9155 else
9156#endif
9157 {
9158 pp_Test(p.p, currRing, p.tailRing);
9159 }
9160#endif
9161 assume(strat->tailRing == p.tailRing);
9162 // redMoraNF complains about this -- but, we don't really
9163 // need this so far
9164 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9165 assume(!strat->homog || (p.FDeg == p.pFDeg()));
9166 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9167
9168#ifdef KDEBUG
9169 // do not put an LObject twice into T:
9170 for(i=strat->tl;i>=0;i--)
9171 {
9172 if (p.p==strat->T[i].p)
9173 {
9174 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9175 return;
9176 }
9177 }
9178#endif
9179
9180#ifdef HAVE_TAIL_RING
9181 if (currRing!=strat->tailRing)
9182 {
9183 p.t_p=p.GetLmTailRing();
9184 }
9185#endif
9186 strat->newt = TRUE;
9187 if (atT < 0)
9188 atT = strat->posInT(strat->T, strat->tl, p);
9189 if (strat->tl == strat->tmax-1)
9190 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9191 if (atT <= strat->tl)
9192 {
9193#ifdef ENTER_USE_MEMMOVE
9194 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9195 (strat->tl-atT+1)*sizeof(TObject));
9196 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9197 (strat->tl-atT+1)*sizeof(unsigned long));
9198#endif
9199 for (i=strat->tl+1; i>=atT+1; i--)
9200 {
9201#ifndef ENTER_USE_MEMMOVE
9202 strat->T[i] = strat->T[i-1];
9203 strat->sevT[i] = strat->sevT[i-1];
9204#endif
9205 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9206 }
9207 }
9208
9209 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9210 {
9211#ifdef HAVE_SHIFTBBA
9212 // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9213 if (!(currRing->isLPring && p.shift > 0))
9214#endif
9215 {
9217 (strat->tailRing != NULL ?
9218 strat->tailRing : currRing),
9219 strat->tailBin);
9220 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9221 }
9222 }
9223 strat->T[atT] = (TObject) p;
9224 //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9225
9226 if ((pNext(p.p) != NULL) && (!rIsLPRing(currRing)))
9227 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9228 else
9229 strat->T[atT].max_exp = NULL;
9230
9231 strat->tl++;
9232 strat->R[strat->tl] = &(strat->T[atT]);
9233 strat->T[atT].i_r = strat->tl;
9234 assume((p.sev == 0) || (pGetShortExpVector(p.p) == p.sev));
9235 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9236 kTest_T(&(strat->T[atT]),strat);
9237}
TObject ** R
Definition kutil.h:341
unsigned long * sevT
Definition kutil.h:326
int tmax
Definition kutil.h:351
omBin tailBin
Definition kutil.h:346
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
char homog
Definition kutil.h:371
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition kutil.cc:536
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition kutil.cc:796
#define pp_Test(p, lmRing, tailRing)
Definition p_polys.h:163
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition p_polys.h:930
#define p_LmTest(p, r)
Definition p_polys.h:162
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition ring.h:726

◆ enterT_strong()

void enterT_strong ( LObject & p,
kStrategy strat,
int atT )

Definition at line 9242 of file kutil.cc.

9243{
9245 int i;
9246
9247 pp_Test(p.p, currRing, p.tailRing);
9248 assume(strat->tailRing == p.tailRing);
9249 // redMoraNF complains about this -- but, we don't really
9250 // need this so far
9251 assume(p.pLength == 0 || (int)pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9252 assume(p.FDeg == p.pFDeg());
9253 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9254
9255#ifdef KDEBUG
9256 // do not put an LObject twice into T:
9257 for(i=strat->tl;i>=0;i--)
9258 {
9259 if (p.p==strat->T[i].p)
9260 {
9261 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9262 return;
9263 }
9264 }
9265#endif
9266
9267#ifdef HAVE_TAIL_RING
9268 if (currRing!=strat->tailRing)
9269 {
9270 p.t_p=p.GetLmTailRing();
9271 }
9272#endif
9273 strat->newt = TRUE;
9274 if (atT < 0)
9275 atT = strat->posInT(strat->T, strat->tl, p);
9276 if (strat->tl == strat->tmax-1)
9277 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9278 if (atT <= strat->tl)
9279 {
9280#ifdef ENTER_USE_MEMMOVE
9281 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9282 (strat->tl-atT+1)*sizeof(TObject));
9283 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9284 (strat->tl-atT+1)*sizeof(unsigned long));
9285#endif
9286 for (i=strat->tl+1; i>=atT+1; i--)
9287 {
9288#ifndef ENTER_USE_MEMMOVE
9289 strat->T[i] = strat->T[i-1];
9290 strat->sevT[i] = strat->sevT[i-1];
9291#endif
9292 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9293 }
9294 }
9295
9296 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9297 {
9299 (strat->tailRing != NULL ?
9300 strat->tailRing : currRing),
9301 strat->tailBin);
9302 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9303 }
9304 strat->T[atT] = (TObject) p;
9305 //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9306
9307 if (pNext(p.p) != NULL)
9308 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9309 else
9310 strat->T[atT].max_exp = NULL;
9311
9312 strat->tl++;
9313 strat->R[strat->tl] = &(strat->T[atT]);
9314 strat->T[atT].i_r = strat->tl;
9315 assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9316 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9317 #if 1
9319 && !n_IsUnit(p.p->coef, currRing->cf))
9320 {
9321 for(i=strat->tl;i>=0;i--)
9322 {
9323 if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9324 {
9325 enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9326 }
9327 }
9328 }
9329 /*
9330 printf("\nThis is T:\n");
9331 for(i=strat->tl;i>=0;i--)
9332 {
9333 pWrite(strat->T[i].p);
9334 }
9335 //getchar();*/
9336 #endif
9337 kTest_T(&(strat->T[atT]),strat);
9338}
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:519

◆ enterTShift()

void enterTShift ( LObject p,
kStrategy strat,
int atT )

Definition at line 12983 of file kutil.cc.

12984{
12985 /* determine how many elements we have to insert */
12986 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
12987 /* hence, a total number of elt's to add is: */
12988 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
12989 pAssume(p.p != NULL);
12990
12991 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
12992
12993 for (int i = 1; i <= maxPossibleShift; i++)
12994 {
12995 LObject qq;
12996 qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
12997 qq.shift = i;
12998 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
12999
13000 enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13001 }
13002}
#define pAssume(cond)
Definition monomials.h:90

◆ exitBuchMora()

void exitBuchMora ( kStrategy strat)

Definition at line 9838 of file kutil.cc.

9839{
9840 /*- release temp data -*/
9841 cleanT(strat);
9842 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
9843 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
9844 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
9845 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
9846 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
9847 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
9848 /*- set L: should be empty -*/
9849 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
9850 /*- set B: should be empty -*/
9851 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
9852 pLmFree(&strat->tail);
9853 strat->syzComp=0;
9854
9855#ifdef HAVE_SHIFTBBA
9856 if (rIsLPRing(currRing) && strat->rightGB)
9857 {
9858 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
9859 strat->fromQ=NULL;
9860 }
9861#endif
9862}
void * ADDRESS
Definition auxiliary.h:120
void cleanT(kStrategy strat)
Definition kutil.cc:557

◆ exitSba()

void exitSba ( kStrategy strat)

Definition at line 10041 of file kutil.cc.

10042{
10043 /*- release temp data -*/
10045 cleanTSbaRing(strat);
10046 else
10047 cleanT(strat);
10048 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10049 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10050 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10051 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10052 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10053 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10054 if(strat->syzmax>0)
10055 {
10056 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10057 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10058 if (strat->sbaOrder == 1)
10059 {
10060 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10061 }
10062 }
10063 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10064 /*- set L: should be empty -*/
10065 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10066 /*- set B: should be empty -*/
10067 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10068 /*- set sig: no need for the signatures anymore -*/
10069 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10070 pLmDelete(&strat->tail);
10071 strat->syzComp=0;
10072}
int syzidxmax
Definition kutil.h:350
intset syzIdx
Definition kutil.h:314
unsigned sbaOrder
Definition kutil.h:317
void cleanTSbaRing(kStrategy strat)
Definition kutil.cc:616

◆ faugereRewCriterion()

BOOLEAN faugereRewCriterion ( poly sig,
unsigned long not_sevSig,
poly lm,
kStrategy strat,
int start = 0 )

Definition at line 6566 of file kutil.cc.

6567{
6568 //printf("Faugere Rewritten Criterion\n");
6570 return FALSE;
6571//#if 1
6572#ifdef DEBUGF5
6573 PrintS("rewritten criterion checks: ");
6574 pWrite(sig);
6575#endif
6576 for(int k = strat->sl; k>=start; k--)
6577 {
6578//#if 1
6579#ifdef DEBUGF5
6580 PrintS("checking with: ");
6581 pWrite(strat->sig[k]);
6582 pWrite(pHead(strat->S[k]));
6583#endif
6584 if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6585 {
6586//#if 1
6587#ifdef DEBUGF5
6588 PrintS("DELETE!\n");
6589#endif
6590 strat->nrrewcrit++;
6591 return TRUE;
6592 }
6593 //k--;
6594 }
6595#ifdef DEBUGF5
6596 PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6597 for(int kk = 0; kk<strat->sl+1; kk++)
6598 {
6599 pWrite(pHead(strat->S[kk]));
6600 }
6601 PrintS("------------------------------\n");
6602#endif
6603 return FALSE;
6604}
int nrrewcrit
Definition kutil.h:361

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy strat)

used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output

Definition at line 10869 of file kutil.cc.

10870{
10871 assume(strat->tl<0); /* can only be called with no elements in T:
10872 i.e. after exitBuchMora */
10873 /* do not use strat->S, strat->sl as they may be out of sync*/
10874 if(!nCoeff_is_Z(currRing->cf))
10875 return;
10876 poly p,pp;
10877 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
10878 {
10879 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
10880 {
10881 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
10882 {
10883 if((i != j) && (strat->Shdl->m[i] != NULL))
10884 {
10885 p = strat->Shdl->m[i];
10886 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
10887#if HAVE_SHIFTBBA
10888 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
10889#endif
10890 ))
10891 {
10892 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
10893 if (!nEqual(dummy,p->coef))
10894 {
10895 if (nIsZero(dummy))
10896 {
10897 nDelete(&dummy);
10898 pLmDelete(&strat->Shdl->m[i]);
10899 p=strat->Shdl->m[i];
10900 }
10901 else
10902 {
10903 p_SetCoeff(p,dummy,currRing);
10904 break;
10905 }
10906 }
10907 else
10908 {
10909 nDelete(&dummy);
10910 break;
10911 }
10912 }
10913 if (p!=NULL)
10914 {
10915 pp = pNext(p);
10916 while(pp != NULL)
10917 {
10918 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
10919#if HAVE_SHIFTBBA
10920 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
10921#endif
10922 )
10923 {
10924 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
10925 if (!nEqual(dummy,pp->coef))
10926 {
10927 p_SetCoeff(pp,dummy,currRing);
10928 if(nIsZero(pp->coef))
10929 {
10930 pLmDelete(&pNext(p));
10931 pp = pNext(p);
10932 }
10933 else
10934 {
10935 p = pp;
10936 pp = pNext(p);
10937 }
10938 }
10939 else
10940 {
10941 nDelete(&dummy);
10942 p = pp;
10943 pp = pNext(p);
10944 }
10945 }
10946 else
10947 {
10948 p = pp;
10949 pp = pNext(p);
10950 }
10951 }
10952 }
10953 }
10954 }
10955 //idPrint(strat->Shdl);
10956 }
10957 }
10958 idSkipZeroes(strat->Shdl);
10959}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:809
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition coeffs.h:629
#define nEqual(n1, n2)
Definition numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition polys.h:141
#define pLPLmDivisibleBy(a, b)
Definition shiftop.h:58
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ getIndexRng()

int getIndexRng ( long coeff)
inline

Definition at line 6004 of file kutil.cc.

6005{
6006 if (coeff == 0) return -1;
6007 long tmp = coeff;
6008 int ind = 0;
6009 while (tmp % 2 == 0)
6010 {
6011 tmp = tmp / 2;
6012 ind++;
6013 }
6014 return ind;
6015}

◆ HEckeTest()

void HEckeTest ( poly pp,
kStrategy strat )

Definition at line 493 of file kutil.cc.

494{
495 int j,p;
496
497 if (currRing->pLexOrder
499 || (strat->ak >1)
501 {
502 return;
503 }
505 if (p!=0)
506 strat->NotUsedAxis[p] = FALSE;
507 /*- the leading term of pp is a power of the p-th variable -*/
508 for (j=(currRing->N);j>0; j--)
509 {
510 if (strat->NotUsedAxis[j])
511 {
512 strat->kAllAxis=FALSE;
513 return;
514 }
515 }
516 strat->kAllAxis=TRUE;
517}
BOOLEAN * NotUsedAxis
Definition kutil.h:333
#define pIsPurePower(p)
Definition polys.h:249
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:770

◆ initBuchMora()

void initBuchMora ( ideal F,
ideal Q,
kStrategy strat )

Definition at line 9751 of file kutil.cc.

9752{
9753 strat->interpt = BTEST1(OPT_INTERRUPT);
9754 /*- creating temp data structures------------------- -*/
9755 //strat->cp = 0; // already by skStragy()
9756 //strat->c3 = 0; // already by skStragy()
9757#ifdef HAVE_SHIFTBBA
9758 strat->cv = 0; // already by skStragy()
9759#endif
9760 strat->tail = pInit();
9761 /*- set s -*/
9762 strat->sl = -1;
9763 /*- set L -*/
9764 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9765 strat->Ll = -1;
9766 strat->L = initL(strat->Lmax);
9767 /*- set B -*/
9768 strat->Bmax = setmaxL;
9769 strat->Bl = -1;
9770 strat->B = initL();
9771 /*- set T -*/
9772 strat->tl = -1;
9773 strat->tmax = setmaxT;
9774 strat->T = initT();
9775 strat->R = initR();
9776 strat->sevT = initsevT();
9777 /*- init local data struct.---------------------------------------- -*/
9778 //strat->P.ecart=0; // already by skStragy()
9779 //strat->P.length=0; // already by skStragy()
9780 //strat->P.pLength=0; // already by skStragy()
9782 {
9783 if (strat->kNoether!=NULL)
9784 {
9785 pSetComp(strat->kNoether, strat->ak);
9786 pSetComp(strat->kNoetherTail(), strat->ak);
9787 }
9788 }
9790 {
9791 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9792 }
9793 else
9794 {
9795 if(TEST_OPT_SB_1)
9796 {
9797 int i;
9798 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
9799 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9800 {
9801 P->m[i-strat->newIdeal] = F->m[i];
9802 F->m[i] = NULL;
9803 }
9804 initSSpecial(F,Q,P,strat);
9805 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9806 {
9807 F->m[i] = P->m[i-strat->newIdeal];
9808 P->m[i-strat->newIdeal] = NULL;
9809 }
9810 idDelete(&P);
9811 }
9812 else
9813 {
9814 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9815 // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
9816 }
9817 }
9818 strat->fromT = FALSE;
9820 if ((!TEST_OPT_SB_1)
9822 )
9823 {
9824 updateS(TRUE,strat);
9825 }
9826#ifdef HAVE_SHIFTBBA
9827 if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
9828#endif
9829 {
9830 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
9831 strat->fromQ=NULL;
9832 }
9833 #ifdef KDEBUG
9834 assume(kTest_TS(strat));
9835 #endif
9836}
char interpt
Definition kutil.h:370
int newIdeal
Definition kutil.h:357
KINLINE TSet initT()
Definition kInline.h:84
KINLINE TObject ** initR()
Definition kInline.h:95
KINLINE unsigned long * initsevT()
Definition kInline.h:100
void initSSpecial(ideal F, ideal Q, ideal P, kStrategy strat)
Definition kutil.cc:8090
void updateS(BOOLEAN toT, kStrategy strat)
Definition kutil.cc:8559
void initSL(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7683
#define setmaxL
Definition kutil.h:31
static LSet initL(int nr=setmaxL)
Definition kutil.h:419
#define setmaxT
Definition kutil.h:34
#define TEST_OPT_REDTAIL
Definition options.h:118
#define TEST_OPT_SB_1
Definition options.h:121
#define OPT_INTERRUPT
Definition options.h:80
#define BTEST1(a)
Definition options.h:34
#define pSetComp(p, v)
Definition polys.h:39
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define Q
Definition sirandom.c:26

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy strat)

Definition at line 9435 of file kutil.cc.

9436{
9439 if (TEST_OPT_SB_1)
9442 {
9444 strat->chainCrit=chainCritRing;
9445 }
9446#ifdef HAVE_RATGRING
9447 if (rIsRatGRing(currRing))
9448 {
9449 strat->chainCrit=chainCritPart;
9450 /* enterOnePairNormal get rational part in it */
9451 }
9452#endif
9453 if (TEST_OPT_IDLIFT
9454 && (strat->syzComp==1)
9455 && (!rIsPluralRing(currRing)))
9457
9459 strat->Gebauer = strat->homog || strat->sugarCrit;
9460 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9461 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9462 strat->pairtest = NULL;
9463 /* always use tailreduction, except:
9464 * - in local rings, - in lex order case, -in ring over extensions */
9466 //if(rHasMixedOrdering(currRing)==2)
9467 //{
9468 // strat->noTailReduction =TRUE;
9469 //}
9470
9471#ifdef HAVE_PLURAL
9472 // and r is plural_ring
9473 // hence this holds for r a rational_plural_ring
9474 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9475 { //or it has non-quasi-comm type... later
9476 strat->sugarCrit = FALSE;
9477 strat->Gebauer = FALSE;
9478 strat->honey = FALSE;
9479 }
9480#endif
9481
9482 // Coefficient ring?
9484 {
9485 strat->sugarCrit = FALSE;
9486 strat->Gebauer = FALSE;
9487 strat->honey = FALSE;
9488 }
9489 #ifdef KDEBUG
9490 if (TEST_OPT_DEBUG)
9491 {
9492 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9493 else PrintS("ideal/module is not homogeneous\n");
9494 }
9495 #endif
9496}
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition kutil.h:292
char z2homog
Definition kutil.h:373
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:291
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:1946
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3452
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2228
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3527
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3211
void chainCritRing(poly p, int, kStrategy strat)
Definition kutil.cc:4003
static bool rIsSCA(const ring r)
Definition nc.h:190
#define TEST_OPT_WEIGHTM
Definition options.h:123
#define TEST_OPT_IDLIFT
Definition options.h:131
#define TEST_OPT_SUGARCRIT
Definition options.h:109
#define TEST_OPT_NOT_SUGAR
Definition options.h:108

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy strat)

Definition at line 9580 of file kutil.cc.

9581{
9583 {
9584 if (strat->honey)
9585 {
9586 strat->posInL = posInL15;
9587 // ok -- here is the deal: from my experiments for Singular-2-0
9588 // I conclude that that posInT_EcartpLength is the best of
9589 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9590 // see the table at the end of this file
9591 if (TEST_OPT_OLDSTD)
9592 strat->posInT = posInT15;
9593 else
9594 strat->posInT = posInT_EcartpLength;
9595 }
9596 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9597 {
9598 strat->posInL = posInL11;
9599 strat->posInT = posInT11;
9600 }
9601 else if (TEST_OPT_INTSTRATEGY)
9602 {
9603 strat->posInL = posInL11;
9604 strat->posInT = posInT11;
9605 }
9606 else
9607 {
9608 strat->posInL = posInL0;
9609 strat->posInT = posInT0;
9610 }
9611 //if (strat->minim>0) strat->posInL =posInLSpecial;
9612 if (strat->homog)
9613 {
9614 strat->posInL = posInL110;
9615 strat->posInT = posInT110;
9616 }
9617 }
9618 else /* local/mixed ordering */
9619 {
9620 if (strat->homog)
9621 {
9622 strat->posInL = posInL11;
9623 strat->posInT = posInT11;
9624 }
9625 else
9626 {
9627 if ((currRing->order[0]==ringorder_c)
9628 ||(currRing->order[0]==ringorder_C))
9629 {
9630 strat->posInL = posInL17_c;
9631 strat->posInT = posInT17_c;
9632 }
9633 else
9634 {
9635 strat->posInL = posInL17;
9636 strat->posInT = posInT17;
9637 }
9638 }
9639 }
9640 if (strat->minim>0) strat->posInL =posInLSpecial;
9641 // for further tests only
9642 if ((BTEST1(11)) || (BTEST1(12)))
9643 strat->posInL = posInL11;
9644 else if ((BTEST1(13)) || (BTEST1(14)))
9645 strat->posInL = posInL13;
9646 else if ((BTEST1(15)) || (BTEST1(16)))
9647 strat->posInL = posInL15;
9648 else if ((BTEST1(17)) || (BTEST1(18)))
9649 strat->posInL = posInL17;
9650 if (BTEST1(11))
9651 strat->posInT = posInT11;
9652 else if (BTEST1(13))
9653 strat->posInT = posInT13;
9654 else if (BTEST1(15))
9655 strat->posInT = posInT15;
9656 else if ((BTEST1(17)))
9657 strat->posInT = posInT17;
9658 else if ((BTEST1(19)))
9659 strat->posInT = posInT19;
9660 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9661 strat->posInT = posInT1;
9663}
int minim
Definition kutil.h:358
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6062
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5285
int posInT11(const TSet set, const int length, LObject &p)
Definition kutil.cc:4960
int posInT1(const TSet set, const int length, LObject &p)
Definition kutil.cc:4903
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:5153
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4892
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6149
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition kutil.cc:9567
int posInT13(const TSet set, const int length, LObject &p)
Definition kutil.cc:5124
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5618
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6184
int posInT17_c(const TSet set, const int length, LObject &p)
Definition kutil.cc:5391
int posInT15(const TSet set, const int length, LObject &p)
Definition kutil.cc:5191
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5574
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6259
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5036
int posInT19(const TSet set, const int length, LObject &p)
Definition kutil.cc:5517
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6352
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5806
#define TEST_OPT_OLDSTD
Definition options.h:125
@ ringorder_C
Definition ring.h:74
@ ringorder_c
Definition ring.h:73

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy strat)

Definition at line 9665 of file kutil.cc.

9666{
9668 {
9669 if (strat->honey)
9670 {
9671 strat->posInL = posInL15Ring;
9672 // ok -- here is the deal: from my experiments for Singular-2-0
9673 // I conclude that that posInT_EcartpLength is the best of
9674 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9675 // see the table at the end of this file
9676 if (TEST_OPT_OLDSTD)
9677 strat->posInT = posInT15Ring;
9678 else
9679 strat->posInT = posInT_EcartpLength;
9680 }
9681 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9682 {
9683 strat->posInL = posInL11Ring;
9684 strat->posInT = posInT11;
9685 }
9686 else if (TEST_OPT_INTSTRATEGY)
9687 {
9688 strat->posInL = posInL11Ring;
9689 strat->posInT = posInT11;
9690 }
9691 else
9692 {
9693 strat->posInL = posInL0Ring;
9694 strat->posInT = posInT0;
9695 }
9696 //if (strat->minim>0) strat->posInL =posInLSpecial;
9697 if (strat->homog)
9698 {
9699 strat->posInL = posInL110Ring;
9700 strat->posInT = posInT110Ring;
9701 }
9702 }
9703 else
9704 {
9705 if (strat->homog)
9706 {
9707 //printf("\nHere 3\n");
9708 strat->posInL = posInL11Ring;
9709 strat->posInT = posInT11Ring;
9710 }
9711 else
9712 {
9713 if ((currRing->order[0]==ringorder_c)
9714 ||(currRing->order[0]==ringorder_C))
9715 {
9716 strat->posInL = posInL17_cRing;
9717 strat->posInT = posInT17_cRing;
9718 }
9719 else
9720 {
9721 strat->posInL = posInL11Ringls;
9722 strat->posInT = posInT17Ring;
9723 }
9724 }
9725 }
9726 if (strat->minim>0) strat->posInL =posInLSpecial;
9727 // for further tests only
9728 if ((BTEST1(11)) || (BTEST1(12)))
9729 strat->posInL = posInL11Ring;
9730 else if ((BTEST1(13)) || (BTEST1(14)))
9731 strat->posInL = posInL13;
9732 else if ((BTEST1(15)) || (BTEST1(16)))
9733 strat->posInL = posInL15Ring;
9734 else if ((BTEST1(17)) || (BTEST1(18)))
9735 strat->posInL = posInL17Ring;
9736 if (BTEST1(11))
9737 strat->posInT = posInT11Ring;
9738 else if (BTEST1(13))
9739 strat->posInT = posInT13;
9740 else if (BTEST1(15))
9741 strat->posInT = posInT15Ring;
9742 else if ((BTEST1(17)))
9743 strat->posInT = posInT17Ring;
9744 else if ((BTEST1(19)))
9745 strat->posInT = posInT19;
9746 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9747 strat->posInT = posInT1;
9749}
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6303
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6416
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5848
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5078
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6103
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5645
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:4996
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5916
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6219
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5245
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5346
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition kutil.cc:5452

◆ initec()

static intset initec ( const int maxnr)
inlinestatic

Definition at line 522 of file kutil.cc.

523{
524 return (intset)omAlloc(maxnr*sizeof(int));
525}

◆ initEcartBBA()

void initEcartBBA ( TObject * h)

Definition at line 1308 of file kutil.cc.

1309{
1310 h->FDeg = h->pFDeg();
1311 (*h).ecart = 0;
1312 h->length=h->pLength=pLength(h->p);
1313}

◆ initEcartNormal()

void initEcartNormal ( TObject * h)

Definition at line 1300 of file kutil.cc.

1301{
1302 h->FDeg = h->pFDeg();
1303 h->ecart = h->pLDeg() - h->FDeg;
1304 // h->length is set by h->pLDeg
1305 h->length=h->pLength=pLength(h->p);
1306}

◆ initEcartPairBba()

void initEcartPairBba ( LObject * Lp,
poly f,
poly g,
int ecartF,
int ecartG )

Definition at line 1315 of file kutil.cc.

1316{
1317 Lp->FDeg = Lp->pFDeg();
1318 (*Lp).ecart = 0;
1319 (*Lp).length = 0;
1320}

◆ initEcartPairMora()

void initEcartPairMora ( LObject * Lp,
poly f,
poly g,
int ecartF,
int ecartG )

Definition at line 1322 of file kutil.cc.

1323{
1324 Lp->FDeg = Lp->pFDeg();
1325 (*Lp).ecart = si_max(ecartF,ecartG);
1326 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1327 (*Lp).length = 0;
1328}
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:382

◆ initenterpairs()

void initenterpairs ( poly h,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR )

Definition at line 3816 of file kutil.cc.

3817{
3818
3819 if ((strat->syzComp==0)
3820 || (pGetComp(h)<=strat->syzComp))
3821 {
3822 int j;
3823 BOOLEAN new_pair=FALSE;
3824
3825 if (pGetComp(h)==0)
3826 {
3827 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3828 if ((isFromQ)&&(strat->fromQ!=NULL))
3829 {
3830 for (j=0; j<=k; j++)
3831 {
3832 if (!strat->fromQ[j])
3833 {
3834 new_pair=TRUE;
3835 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3836 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3837 }
3838 }
3839 }
3840 else
3841 {
3842 new_pair=TRUE;
3843 for (j=0; j<=k; j++)
3844 {
3845 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3846 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3847 }
3848 }
3849 }
3850 else
3851 {
3852 for (j=0; j<=k; j++)
3853 {
3854 if ((pGetComp(h)==pGetComp(strat->S[j]))
3855 || (pGetComp(strat->S[j])==0))
3856 {
3857 new_pair=TRUE;
3858 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3859 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3860 }
3861 }
3862 }
3863 if (new_pair)
3864 {
3865 #ifdef HAVE_RATGRING
3866 if (currRing->real_var_start>0)
3867 chainCritPart(h,ecart,strat);
3868 else
3869 #endif
3870 strat->chainCrit(h,ecart,strat);
3871 }
3872 kMergeBintoL(strat);
3873 }
3874}

◆ initenterpairsShift()

void initenterpairsShift ( poly h,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR )

Definition at line 12511 of file kutil.cc.

12512{
12513 int h_lastVblock = pmLastVblock(h);
12514 assume(h_lastVblock != 0 || pLmIsConstantComp(h));
12515 // TODO: is it allowed to skip pairs with constants? also with constants from other components?
12516 if (h_lastVblock == 0) return;
12517 assume(pmFirstVblock(h) == 1);
12518 /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12519 // atR = -1;
12520 if ((strat->syzComp==0)
12521 || (pGetComp(h)<=strat->syzComp))
12522 {
12523 int i,j;
12524 BOOLEAN new_pair=FALSE;
12525
12526 int degbound = currRing->N/currRing->isLPring;
12527 int maxShift = degbound - h_lastVblock;
12528
12529 if (pGetComp(h)==0)
12530 {
12531 if (strat->rightGB)
12532 {
12533 if (isFromQ)
12534 {
12535 // pairs (shifts(h),s[1..k]), (h, s[1..k])
12536 for (i=0; i<=maxShift; i++)
12537 {
12538 poly hh = pLPCopyAndShiftLM(h, i);
12539 BOOLEAN delete_hh=TRUE;
12540 for (j=0; j<=k; j++)
12541 {
12542 if (strat->fromQ == NULL || !strat->fromQ[j])
12543 {
12544 new_pair=TRUE;
12545 poly s = strat->S[j];
12546 if (!enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i))
12547 delete_hh=FALSE;
12548 }
12549 }
12550 if (delete_hh) pLmDelete(hh);
12551 }
12552 }
12553 else
12554 {
12555 new_pair=TRUE;
12556 for (j=0; j<=k; j++)
12557 {
12558 poly s = strat->S[j];
12559 if (strat->fromQ != NULL && strat->fromQ[j])
12560 {
12561 // pairs (shifts(s[j]),h), (s[j],h)
12562 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12563 }
12564 else
12565 {
12566 // pair (h, s[j])
12567 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12568 }
12569 }
12570 }
12571 }
12572 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
12573 else if ((isFromQ)&&(strat->fromQ!=NULL))
12574 {
12575 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12576 for (j=0; j<=k; j++)
12577 {
12578 if (!strat->fromQ[j])
12579 {
12580 new_pair=TRUE;
12581 poly s = strat->S[j];
12582 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12583 }
12584 }
12585 // pairs (shifts(h),s[1..k])
12586 if (new_pair)
12587 {
12588 for (i=1; i<=maxShift; i++)
12589 {
12590 BOOLEAN delete_hh=TRUE;
12591 poly hh = pLPCopyAndShiftLM(h, i);
12592 for (j=0; j<=k; j++)
12593 {
12594 if (!strat->fromQ[j])
12595 {
12596 poly s = strat->S[j];
12597 int s_lastVblock = pmLastVblock(s);
12598 if (i < s_lastVblock || (pGetComp(s) > 0 && i == s_lastVblock)) // in the module case, product criterion does not hold (note: comp h is always zero here)
12599 {
12600 if(!enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i))
12601 delete_hh=FALSE;
12602 }
12603 else if (rField_is_Ring(currRing))
12604 {
12605 assume(i >= s_lastVblock); // this is always the case, but just to be very sure
12606 ideal fillers = id_MaxIdeal(i - s_lastVblock, currRing);
12607 for (int k = 0; k < IDELEMS(fillers); k++)
12608 {
12609 poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), s_lastVblock);
12610 enterOnePairWithoutShifts(j, hhh, s, ecart, isFromQ, strat, atR, s_lastVblock, s_lastVblock);
12611 }
12612 idDelete(&fillers);
12613 }
12614 }
12615 }
12616 if (delete_hh) p_LmDelete(hh,currRing);
12617 }
12618 }
12619 }
12620 else
12621 {
12622 new_pair=TRUE;
12623 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12624 for (j=0; j<=k; j++)
12625 {
12626 poly s = strat->S[j];
12627 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12628 }
12629 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12630 for (i=1; i<=maxShift; i++)
12631 {
12632 poly hh = pLPCopyAndShiftLM(h, i);
12633 BOOLEAN delete_hh=TRUE;
12634 for (j=0; j<=k; j++)
12635 {
12636 poly s = strat->S[j];
12637 int s_lastVblock = pmLastVblock(s);
12638 if (i < s_lastVblock || (pGetComp(s) > 0 && i == s_lastVblock)) // in the module case, product criterion does not hold (note: comp h is always zero here)
12639 delete_hh=enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i)
12640 && delete_hh;
12641 else if (rField_is_Ring(currRing))
12642 {
12643 assume(i >= s_lastVblock); // this is always the case, but just to be very sure
12644 ideal fillers = id_MaxIdeal(i - s_lastVblock, currRing);
12645 for (int k = 0; k < IDELEMS(fillers); k++)
12646 {
12647 poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), s_lastVblock);
12648 enterOnePairWithoutShifts(j, hhh, s, ecart, isFromQ, strat, atR, s_lastVblock, s_lastVblock);
12649 }
12650 idDelete(&fillers);
12651 }
12652 }
12653 if (i < h_lastVblock) // in the module case, product criterion does not hold (note: comp h is always zero here)
12654 delete_hh=enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i)
12655 && delete_hh;
12656 else if (rField_is_Ring(currRing))
12657 {
12658 assume(i >= h_lastVblock); // this is always the case, but just to be very sure
12659 ideal fillers = id_MaxIdeal(i - h_lastVblock, currRing);
12660 for (int k = 0; k < IDELEMS(fillers); k++)
12661 {
12662 poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), h_lastVblock);
12663 enterOnePairWithoutShifts(-1, hhh, h, ecart, isFromQ, strat, atR, h_lastVblock, h_lastVblock);
12664 }
12665 idDelete(&fillers);
12666 }
12667 if (delete_hh) pLmDelete(hh);
12668 }
12669 }
12670 }
12671 else
12672 {
12673 assume(isFromQ == 0); // an element from Q should always has 0 component
12674 new_pair=TRUE;
12675 if (strat->rightGB)
12676 {
12677 for (j=0; j<=k; j++)
12678 {
12679 if ((pGetComp(h)==pGetComp(strat->S[j]))
12680 || (pGetComp(strat->S[j])==0))
12681 {
12682 poly s = strat->S[j];
12683 if (strat->fromQ != NULL && strat->fromQ[j])
12684 {
12685 // pairs (shifts(s[j]),h), (s[j],h)
12686 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12687 }
12688 else
12689 {
12690 // pair (h, s[j])
12691 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12692 }
12693 }
12694 }
12695 }
12696 else
12697 {
12698 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12699 for (j=0; j<=k; j++)
12700 {
12701 if ((pGetComp(h)==pGetComp(strat->S[j]))
12702 || (pGetComp(strat->S[j])==0))
12703 {
12704 poly s = strat->S[j];
12705 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12706 }
12707 }
12708 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12709 for (i=1; i<=maxShift; i++)
12710 {
12711 poly hh = pLPCopyAndShiftLM(h, i);
12712 for (j=0; j<=k; j++)
12713 {
12714 if ((pGetComp(h)==pGetComp(strat->S[j]))
12715 || (pGetComp(strat->S[j])==0))
12716 {
12717 poly s = strat->S[j];
12718 int s_lastVblock = pmLastVblock(s);
12719 if (i <= s_lastVblock) // in the module case, product criterion does not hold
12720 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i);
12721 else if (rField_is_Ring(currRing))
12722 {
12723 assume(i >= s_lastVblock); // this is always the case, but just to be very sure
12724 ideal fillers = id_MaxIdeal(i - s_lastVblock, currRing);
12725 for (int k = 0; k < IDELEMS(fillers); k++)
12726 {
12727 poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), s_lastVblock);
12728 enterOnePairWithoutShifts(j, hhh, s, ecart, isFromQ, strat, atR, s_lastVblock, s_lastVblock);
12729 }
12730 idDelete(&fillers);
12731 }
12732 }
12733 }
12734 if (i <= h_lastVblock) // in the module case, product criterion does not hold
12735 enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
12736 else if (rField_is_Ring(currRing))
12737 {
12738 assume(i >= h_lastVblock); // this is always the case, but just to be very sure
12739 ideal fillers = id_MaxIdeal(i - h_lastVblock, currRing);
12740 for (int k = 0; k < IDELEMS(fillers); k++)
12741 {
12742 BOOLEAN delete_hhh=TRUE;
12743 poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), h_lastVblock);
12744 if(!enterOnePairWithoutShifts(-1, hhh, h, ecart, isFromQ, strat, atR, h_lastVblock, h_lastVblock))
12745 delete_hhh=FALSE;
12746 if (delete_hhh) p_LmDelete(hhh,currRing);
12747 }
12748 idDelete(&fillers);
12749 }
12750 }
12751 }
12752 }
12753
12754 if (new_pair)
12755 {
12756 strat->chainCrit(h,ecart,strat);
12757 }
12758 kMergeBintoL(strat);
12759 }
12760}
static BOOLEAN enterOnePairWithShifts(int q_inS, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int, int p_lastVblock, int q_lastVblock)
Definition kutil.cc:12070
static BOOLEAN enterOnePairWithoutShifts(int p_inS, poly q, poly p, int ecartq, int q_isFromQ, kStrategy strat, int, int p_lastVblock, int q_shift)
Definition kutil.cc:12131
#define pLmIsConstantComp(p)
like above, except that p must be != NULL
Definition polys.h:243

◆ initenterpairsSig()

void initenterpairsSig ( poly h,
poly hSig,
int hFrom,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )

Definition at line 3881 of file kutil.cc.

3882{
3883
3884 if ((strat->syzComp==0)
3885 || (pGetComp(h)<=strat->syzComp))
3886 {
3887 int j;
3888 BOOLEAN new_pair=FALSE;
3889
3890 if (pGetComp(h)==0)
3891 {
3892 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3893 if ((isFromQ)&&(strat->fromQ!=NULL))
3894 {
3895 for (j=0; j<=k; j++)
3896 {
3897 if (!strat->fromQ[j])
3898 {
3899 new_pair=TRUE;
3900 enterOnePairSig(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3901 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3902 }
3903 }
3904 }
3905 else
3906 {
3907 new_pair=TRUE;
3908 for (j=0; j<=k; j++)
3909 {
3910 enterOnePairSig(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3911 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3912 }
3913 }
3914 }
3915 else
3916 {
3917 for (j=0; j<=k; j++)
3918 {
3919 if ((pGetComp(h)==pGetComp(strat->S[j]))
3920 || (pGetComp(strat->S[j])==0))
3921 {
3922 new_pair=TRUE;
3923 enterOnePairSig(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3924 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3925 }
3926 }
3927 }
3928
3929 if (new_pair)
3930 {
3931#ifdef HAVE_RATGRING
3932 if (currRing->real_var_start>0)
3933 chainCritPart(h,ecart,strat);
3934 else
3935#endif
3936 strat->chainCrit(h,ecart,strat);
3937 }
3938 }
3939}
static void enterOnePairSig(int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2440

◆ initenterpairsSigRing()

void initenterpairsSigRing ( poly h,
poly hSig,
int hFrom,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )

Definition at line 3941 of file kutil.cc.

3942{
3943
3944 if ((strat->syzComp==0)
3945 || (pGetComp(h)<=strat->syzComp))
3946 {
3947 int j;
3948
3949 if (pGetComp(h)==0)
3950 {
3951 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3952 if ((isFromQ)&&(strat->fromQ!=NULL))
3953 {
3954 for (j=0; j<=k && !strat->sigdrop; j++)
3955 {
3956 if (!strat->fromQ[j])
3957 {
3958 enterOnePairSigRing(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3959 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3960 }
3961 }
3962 }
3963 else
3964 {
3965 for (j=0; j<=k && !strat->sigdrop; j++)
3966 {
3967 enterOnePairSigRing(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3968 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3969 }
3970 }
3971 }
3972 else
3973 {
3974 for (j=0; j<=k && !strat->sigdrop; j++)
3975 {
3976 if ((pGetComp(h)==pGetComp(strat->S[j]))
3977 || (pGetComp(strat->S[j])==0))
3978 {
3979 enterOnePairSigRing(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3980 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3981 }
3982 }
3983 }
3984
3985#if 0
3986 if (new_pair)
3987 {
3988#ifdef HAVE_RATGRING
3989 if (currRing->real_var_start>0)
3990 chainCritPart(h,ecart,strat);
3991 else
3992#endif
3993 strat->chainCrit(h,ecart,strat);
3994 }
3995#endif
3996 }
3997}
static void enterOnePairSigRing(int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2697

◆ initenterstrongPairs()

void initenterstrongPairs ( poly h,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )

Definition at line 4159 of file kutil.cc.

4160{
4161 if (!nIsOne(pGetCoeff(h)))
4162 {
4163 int j;
4164 BOOLEAN new_pair=FALSE;
4165
4166 if (pGetComp(h)==0)
4167 {
4168 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
4169 if ((isFromQ)&&(strat->fromQ!=NULL))
4170 {
4171 for (j=0; j<=k; j++)
4172 {
4173 if (!strat->fromQ[j])
4174 {
4175 new_pair=TRUE;
4176 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR, FALSE);
4177 }
4178 }
4179 }
4180 else
4181 {
4182 new_pair=TRUE;
4183 for (j=0; j<=k; j++)
4184 {
4185 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR, FALSE);
4186 }
4187 }
4188 }
4189 else
4190 {
4191 for (j=0; j<=k; j++)
4192 {
4193 if ((pGetComp(h)==pGetComp(strat->S[j]))
4194 || (pGetComp(strat->S[j])==0))
4195 {
4196 new_pair=TRUE;
4197 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR, FALSE);
4198 }
4199 }
4200 }
4201 if (new_pair)
4202 {
4203 #ifdef HAVE_RATGRING
4204 if (currRing->real_var_start>0)
4205 chainCritPart(h,ecart,strat);
4206 else
4207 #endif
4208 strat->chainCrit(h,ecart,strat);
4209 }
4210 kMergeBintoL(strat);
4211 }
4212}
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition kutil.cc:1545

◆ initenterstrongPairsShift()

void initenterstrongPairsShift ( poly h,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR )

Definition at line 12769 of file kutil.cc.

12770{
12771 int h_lastVblock = pmLastVblock(h);
12772 assume(h_lastVblock != 0 || pLmIsConstantComp(h));
12773 // TODO: is it allowed to skip pairs with constants? also with constants from other components?
12774 if (h_lastVblock == 0) return;
12775 assume(pmFirstVblock(h) == 1);
12776 /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12777 // atR = -1;
12778 if ((strat->syzComp==0)
12779 || (pGetComp(h)<=strat->syzComp))
12780 {
12781 int i,j;
12782 BOOLEAN new_pair=FALSE;
12783
12784 int degbound = currRing->N/currRing->isLPring;
12785 int maxShift = degbound - h_lastVblock;
12786
12787 if (pGetComp(h)==0)
12788 {
12789 if (strat->rightGB)
12790 {
12791 if (isFromQ)
12792 {
12793 // pairs (shifts(h),s[1..k]), (h, s[1..k])
12794 for (i=0; i<=maxShift; i++)
12795 {
12796 poly hh = pLPCopyAndShiftLM(h, i);
12797 for (j=0; j<=k; j++)
12798 {
12799 if (strat->fromQ == NULL || !strat->fromQ[j])
12800 {
12801 new_pair=TRUE;
12802 poly s = strat->S[j];
12803 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
12804 }
12805 }
12806 }
12807 }
12808 else
12809 {
12810 new_pair=TRUE;
12811 for (j=0; j<=k; j++)
12812 {
12813 poly s = strat->S[j];
12814 if (strat->fromQ != NULL && strat->fromQ[j])
12815 {
12816 // pairs (shifts(s[j]),h), (s[j],h)
12817 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12818 }
12819 else
12820 {
12821 // pair (h, s[j])
12822 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12823 }
12824 }
12825 }
12826 }
12827 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
12828 else if ((isFromQ)&&(strat->fromQ!=NULL))
12829 {
12830 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12831 for (j=0; j<=k; j++)
12832 {
12833 if (!strat->fromQ[j])
12834 {
12835 new_pair=TRUE;
12836 poly s = strat->S[j];
12837 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12838 }
12839 }
12840 // pairs (shifts(h),s[1..k])
12841 if (new_pair)
12842 {
12843 for (i=1; i<=maxShift; i++)
12844 {
12845 poly hh = pLPCopyAndShiftLM(h, i);
12846 for (j=0; j<=k; j++)
12847 {
12848 if (!strat->fromQ[j])
12849 {
12850 poly s = strat->S[j];
12851 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
12852 }
12853 }
12854 }
12855 }
12856 }
12857 else
12858 {
12859 new_pair=TRUE;
12860 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12861 for (j=0; j<=k; j++)
12862 {
12863 poly s = strat->S[j];
12864 // TODO: cache lastVblock of s[1..k] for later use
12865 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12866 }
12867 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12868 for (i=1; i<=maxShift; i++)
12869 {
12870 poly hh = pLPCopyAndShiftLM(h, i);
12871 BOOLEAN delete_hh=TRUE;
12872 for (j=0; j<=k; j++)
12873 {
12874 poly s = strat->S[j];
12875 if(!enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i))
12876 delete_hh=FALSE;
12877 }
12878 if(!enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i))
12879 delete_hh=FALSE;
12880 if (delete_hh) p_LmDelete(hh,currRing);
12881 }
12882 }
12883 }
12884 else
12885 {
12886 new_pair=TRUE;
12887 if (strat->rightGB)
12888 {
12889 for (j=0; j<=k; j++)
12890 {
12891 if ((pGetComp(h)==pGetComp(strat->S[j]))
12892 || (pGetComp(strat->S[j])==0))
12893 {
12894 assume(isFromQ == 0); // this case is not handled here and should also never happen
12895 poly s = strat->S[j];
12896 if (strat->fromQ != NULL && strat->fromQ[j])
12897 {
12898 // pairs (shifts(s[j]),h), (s[j],h)
12899 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12900 }
12901 else
12902 {
12903 // pair (h, s[j])
12904 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12905 }
12906 }
12907 }
12908 }
12909 else
12910 {
12911 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12912 for (j=0; j<=k; j++)
12913 {
12914 if ((pGetComp(h)==pGetComp(strat->S[j]))
12915 || (pGetComp(strat->S[j])==0))
12916 {
12917 poly s = strat->S[j];
12918 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
12919 }
12920 }
12921 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12922 for (i=1; i<=maxShift; i++)
12923 {
12924 poly hh = pLPCopyAndShiftLM(h, i);
12925 for (j=0; j<=k; j++)
12926 {
12927 if ((pGetComp(h)==pGetComp(strat->S[j]))
12928 || (pGetComp(strat->S[j])==0))
12929 {
12930 poly s = strat->S[j];
12931 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
12932 }
12933 }
12934 enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
12935 }
12936 }
12937 }
12938
12939 if (new_pair)
12940 {
12941 strat->chainCrit(h,ecart,strat);
12942 }
12943 kMergeBintoL(strat);
12944 }
12945}

◆ initenterstrongPairsSig()

static void initenterstrongPairsSig ( poly h,
poly hSig,
int k,
int ecart,
int isFromQ,
kStrategy strat,
int atR = -1 )
static

Definition at line 4214 of file kutil.cc.

4215{
4216 const int iCompH = pGetComp(h);
4217 if (!nIsOne(pGetCoeff(h)))
4218 {
4219 int j;
4220
4221 for (j=0; j<=k && !strat->sigdrop; j++)
4222 {
4223 // Print("j:%d, Ll:%d\n",j,strat->Ll);
4224// if (((unsigned long) pGetCoeff(h) % (unsigned long) pGetCoeff(strat->S[j]) != 0) &&
4225// ((unsigned long) pGetCoeff(strat->S[j]) % (unsigned long) pGetCoeff(h) != 0))
4226 if (((iCompH == pGetComp(strat->S[j]))
4227 || (0 == pGetComp(strat->S[j])))
4228 && ((iCompH<=strat->syzComp)||(strat->syzComp==0)))
4229 {
4230 enterOneStrongPolySig(j,h,hSig,ecart,isFromQ,strat, atR);
4231 }
4232 }
4233 }
4234}
static BOOLEAN enterOneStrongPolySig(int i, poly p, poly sig, int, int, kStrategy strat, int atR)
Definition kutil.cc:1753

◆ initHilbCrit()

void initHilbCrit ( ideal F,
ideal Q,
bigintmat ** hilb,
kStrategy strat )

Definition at line 9417 of file kutil.cc.

9418{
9419
9420 //if the ordering is local, then hilb criterion
9421 //can be used also if the ideal is not homogeneous
9423 {
9425 *hilb=NULL;
9426 else
9427 return;
9428 }
9429 if (strat->homog!=isHomog)
9430 {
9431 *hilb=NULL;
9432 }
9433}
@ isHomog
Definition structs.h:33

◆ initPairtest()

void initPairtest ( kStrategy strat)

Definition at line 685 of file kutil.cc.

686{
687 strat->pairtest = (BOOLEAN *)omAlloc0((strat->sl+2)*sizeof(BOOLEAN));
688}
#define omAlloc0(size)

◆ initS()

void initS ( ideal F,
ideal Q,
kStrategy strat )

Definition at line 7590 of file kutil.cc.

7591{
7592 int i,pos;
7593
7595 else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7596 if (i<setmaxTinc) i=setmaxT;
7597 strat->ecartS=initec(i);
7598 strat->sevS=initsevS(i);
7599 strat->S_2_R=initS_2_R(i);
7600 strat->fromQ=NULL;
7601 strat->Shdl=idInit(i,F->rank);
7602 strat->S=strat->Shdl->m;
7603 /*- put polys into S -*/
7604 if (Q!=NULL)
7605 {
7606 strat->fromQ=initec(i);
7607 memset(strat->fromQ,0,i*sizeof(int));
7608 for (i=0; i<IDELEMS(Q); i++)
7609 {
7610 if (Q->m[i]!=NULL)
7611 {
7612 LObject h;
7613 h.p = pCopy(Q->m[i]);
7615 {
7616 h.pCleardenom(); // also does remove Content
7617 }
7618 else
7619 {
7620 h.pNorm();
7621 }
7623 {
7624 deleteHC(&h, strat);
7625 }
7626 if (h.p!=NULL)
7627 {
7628 strat->initEcart(&h);
7629 if (strat->sl==-1)
7630 pos =0;
7631 else
7632 {
7633 pos = posInS(strat,strat->sl,h.p,h.ecart);
7634 }
7635 h.sev = pGetShortExpVector(h.p);
7636 strat->enterS(h,pos,strat,-1);
7637 strat->fromQ[pos]=1;
7638 }
7639 }
7640 }
7641 }
7642 for (i=0; i<IDELEMS(F); i++)
7643 {
7644 if (F->m[i]!=NULL)
7645 {
7646 LObject h;
7647 h.p = pCopy(F->m[i]);
7649 {
7650 cancelunit(&h); /*- tries to cancel a unit -*/
7651 deleteHC(&h, strat);
7652 }
7653 if (h.p!=NULL)
7654 // do not rely on the input being a SB!
7655 {
7657 {
7658 h.pCleardenom(); // also does remove Content
7659 }
7660 else
7661 {
7662 h.pNorm();
7663 }
7664 strat->initEcart(&h);
7665 if (strat->sl==-1)
7666 pos =0;
7667 else
7668 pos = posInS(strat,strat->sl,h.p,h.ecart);
7669 h.sev = pGetShortExpVector(h.p);
7670 strat->enterS(h,pos,strat,-1);
7671 }
7672 }
7673 }
7674 /*- test, if a unit is in F -*/
7675 if ((strat->sl>=0)
7676 && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7677 && pIsConstant(strat->S[0]))
7678 {
7679 while (strat->sl>0) deleteInS(strat->sl,strat);
7680 }
7681}
static intset initec(const int maxnr)
Definition kutil.cc:522
static int * initS_2_R(const int maxnr)
Definition kutil.cc:531
void deleteInS(int i, kStrategy strat)
Definition kutil.cc:1139
static unsigned long * initsevS(const int maxnr)
Definition kutil.cc:527
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239

◆ initS_2_R()

static int * initS_2_R ( const int maxnr)
inlinestatic

Definition at line 531 of file kutil.cc.

532{
533 return (int*)omAlloc0(maxnr*sizeof(int));
534}

◆ initSbaBuchMora()

void initSbaBuchMora ( ideal F,
ideal Q,
kStrategy strat )

Definition at line 9966 of file kutil.cc.

9967{
9968 strat->interpt = BTEST1(OPT_INTERRUPT);
9969 //strat->kNoether=NULL; // done by skStrategy
9970 /*- creating temp data structures------------------- -*/
9971 //strat->cp = 0; // done by skStrategy
9972 //strat->c3 = 0; // done by skStrategy
9973 strat->tail = pInit();
9974 /*- set s -*/
9975 strat->sl = -1;
9976 /*- set ps -*/
9977 strat->syzl = -1;
9978 /*- set L -*/
9979 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9980 strat->Ll = -1;
9981 strat->L = initL(strat->Lmax);
9982 /*- set B -*/
9983 strat->Bmax = setmaxL;
9984 strat->Bl = -1;
9985 strat->B = initL();
9986 /*- set T -*/
9987 strat->tl = -1;
9988 strat->tmax = setmaxT;
9989 strat->T = initT();
9990 strat->R = initR();
9991 strat->sevT = initsevT();
9992 /*- init local data struct.---------------------------------------- -*/
9993 //strat->P.ecart=0; // done by skStrategy
9994 //strat->P.length=0; // done by skStrategy
9996 {
9997 if (strat->kNoether!=NULL)
9998 {
9999 pSetComp(strat->kNoether, strat->ak);
10000 pSetComp(strat->kNoetherTail(), strat->ak);
10001 }
10002 }
10004 {
10005 /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10006 }
10007 else
10008 {
10009 if(TEST_OPT_SB_1)
10010 {
10011 int i;
10012 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10013 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10014 {
10015 P->m[i-strat->newIdeal] = F->m[i];
10016 F->m[i] = NULL;
10017 }
10018 initSSpecialSba(F,Q,P,strat);
10019 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10020 {
10021 F->m[i] = P->m[i-strat->newIdeal];
10022 P->m[i-strat->newIdeal] = NULL;
10023 }
10024 idDelete(&P);
10025 }
10026 else
10027 {
10028 initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10029 }
10030 }
10031 //strat->fromT = FALSE; // done by skStrategy
10032 if (!TEST_OPT_SB_1)
10033 {
10034 if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10035 }
10036 //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10037 //strat->fromQ=NULL;
10038 assume(kTest_TS(strat));
10039}
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7783
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition kutil.cc:8238

◆ initSbaCrit()

void initSbaCrit ( kStrategy strat)

Definition at line 9498 of file kutil.cc.

9499{
9500 //strat->enterOnePair=enterOnePairNormal;
9502 //strat->chainCrit=chainCritNormal;
9503 strat->chainCrit = chainCritSig;
9504 /******************************************
9505 * rewCrit1 and rewCrit2 are already set in
9506 * kSba() in kstd1.cc
9507 *****************************************/
9508 //strat->rewCrit1 = faugereRewCriterion;
9509 if (strat->sbaOrder == 1)
9510 {
9511 strat->syzCrit = syzCriterionInc;
9512 }
9513 else
9514 {
9515 strat->syzCrit = syzCriterion;
9516 }
9518 {
9520 strat->chainCrit=chainCritRing;
9521 }
9522#ifdef HAVE_RATGRING
9523 if (rIsRatGRing(currRing))
9524 {
9525 strat->chainCrit=chainCritPart;
9526 /* enterOnePairNormal get rational part in it */
9527 }
9528#endif
9529
9531 strat->Gebauer = strat->homog || strat->sugarCrit;
9532 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9533 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9534 strat->pairtest = NULL;
9535 /* always use tailreduction, except:
9536 * - in local rings, - in lex order case, -in ring over extensions */
9539
9540#ifdef HAVE_PLURAL
9541 // and r is plural_ring
9542 // hence this holds for r a rational_plural_ring
9543 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9544 { //or it has non-quasi-comm type... later
9545 strat->sugarCrit = FALSE;
9546 strat->Gebauer = FALSE;
9547 strat->honey = FALSE;
9548 }
9549#endif
9550
9551 // Coefficient ring?
9553 {
9554 strat->sugarCrit = FALSE;
9555 strat->Gebauer = FALSE ;
9556 strat->honey = FALSE;
9557 }
9558 #ifdef KDEBUG
9559 if (TEST_OPT_DEBUG)
9560 {
9561 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9562 else PrintS("ideal/module is not homogeneous\n");
9563 }
9564 #endif
9565}
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6517
void chainCritSig(poly p, int, kStrategy strat)
Definition kutil.cc:3468
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6482

◆ initSbaPos()

void initSbaPos ( kStrategy strat)

Definition at line 9864 of file kutil.cc.

9865{
9867 {
9868 if (strat->honey)
9869 {
9870 strat->posInL = posInL15;
9871 // ok -- here is the deal: from my experiments for Singular-2-0
9872 // I conclude that that posInT_EcartpLength is the best of
9873 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9874 // see the table at the end of this file
9875 if (TEST_OPT_OLDSTD)
9876 strat->posInT = posInT15;
9877 else
9878 strat->posInT = posInT_EcartpLength;
9879 }
9880 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9881 {
9882 strat->posInL = posInL11;
9883 strat->posInT = posInT11;
9884 }
9885 else if (TEST_OPT_INTSTRATEGY)
9886 {
9887 strat->posInL = posInL11;
9888 strat->posInT = posInT11;
9889 }
9890 else
9891 {
9892 strat->posInL = posInL0;
9893 strat->posInT = posInT0;
9894 }
9895 //if (strat->minim>0) strat->posInL =posInLSpecial;
9896 if (strat->homog)
9897 {
9898 strat->posInL = posInL110;
9899 strat->posInT = posInT110;
9900 }
9901 }
9902 else
9903 {
9904 if (strat->homog)
9905 {
9906 strat->posInL = posInL11;
9907 strat->posInT = posInT11;
9908 }
9909 else
9910 {
9911 if ((currRing->order[0]==ringorder_c)
9912 ||(currRing->order[0]==ringorder_C))
9913 {
9914 strat->posInL = posInL17_c;
9915 strat->posInT = posInT17_c;
9916 }
9917 else
9918 {
9919 strat->posInL = posInL17;
9920 strat->posInT = posInT17;
9921 }
9922 }
9923 }
9924 if (strat->minim>0) strat->posInL =posInLSpecial;
9925 // for further tests only
9926 if ((BTEST1(11)) || (BTEST1(12)))
9927 strat->posInL = posInL11;
9928 else if ((BTEST1(13)) || (BTEST1(14)))
9929 strat->posInL = posInL13;
9930 else if ((BTEST1(15)) || (BTEST1(16)))
9931 strat->posInL = posInL15;
9932 else if ((BTEST1(17)) || (BTEST1(18)))
9933 strat->posInL = posInL17;
9934 if (BTEST1(11))
9935 strat->posInT = posInT11;
9936 else if (BTEST1(13))
9937 strat->posInT = posInT13;
9938 else if (BTEST1(15))
9939 strat->posInT = posInT15;
9940 else if ((BTEST1(17)))
9941 strat->posInT = posInT17;
9942 else if ((BTEST1(19)))
9943 strat->posInT = posInT19;
9944 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9945 strat->posInT = posInT1;
9947 {
9948 strat->posInL = posInL11Ring;
9949 if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
9950 strat->posInL = posInL11Ringls;
9951 strat->posInT = posInT11;
9952 }
9954 strat->posInLSba = posInLSig;
9955 //strat->posInL = posInLSig;
9956 strat->posInL = posInLF5C;
9957 /*
9958 if (rField_is_Ring(currRing))
9959 {
9960 strat->posInLSba = posInLSigRing;
9961 strat->posInL = posInL11Ring;
9962 }*/
9963 //strat->posInT = posInTSig;
9964}
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5676
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition kutil.cc:5794

◆ initsevS()

static unsigned long * initsevS ( const int maxnr)
inlinestatic

Definition at line 527 of file kutil.cc.

528{
529 return (unsigned long*)omAlloc0(maxnr*sizeof(unsigned long));
530}

◆ initSL()

void initSL ( ideal F,
ideal Q,
kStrategy strat )

Definition at line 7683 of file kutil.cc.

7684{
7685 int i,pos;
7686
7687 if (Q!=NULL)
7688 {
7690 if (i<setmaxTinc) i=setmaxT;
7691 }
7692 else i=setmaxT;
7693 strat->ecartS=initec(i);
7694 strat->sevS=initsevS(i);
7695 strat->S_2_R=initS_2_R(i);
7696 strat->fromQ=NULL;
7697 strat->Shdl=idInit(i,F->rank);
7698 strat->S=strat->Shdl->m;
7699 /*- put polys into S -*/
7700 if (Q!=NULL)
7701 {
7702 strat->fromQ=initec(i);
7703 memset(strat->fromQ,0,i*sizeof(int));
7704 for (i=0; i<IDELEMS(Q); i++)
7705 {
7706 if (Q->m[i]!=NULL)
7707 {
7708 LObject h;
7709 h.p = pCopy(Q->m[i]);
7711 {
7712 deleteHC(&h,strat);
7713 cancelunit(&h); /*- tries to cancel a unit -*/
7714 }
7716 {
7717 h.pCleardenom(); // also does remove Content
7718 }
7719 else
7720 {
7721 h.pNorm();
7722 }
7723 if (h.p!=NULL)
7724 {
7725 strat->initEcart(&h);
7726 if (strat->sl==-1)
7727 pos =0;
7728 else
7729 {
7730 pos = posInS(strat,strat->sl,h.p,h.ecart);
7731 }
7732 h.sev = pGetShortExpVector(h.p);
7733 strat->enterS(h,pos,strat,-1);
7734 strat->fromQ[pos]=1;
7735 }
7736 }
7737 }
7738 }
7739 for (i=0; i<IDELEMS(F); i++)
7740 {
7741 if (F->m[i]!=NULL)
7742 {
7743 LObject h;
7744 h.p = pCopy(F->m[i]);
7745 if (h.p!=NULL)
7746 {
7748 {
7749 cancelunit(&h); /*- tries to cancel a unit -*/
7750 deleteHC(&h, strat);
7751 }
7752 if (h.p!=NULL)
7753 {
7755 {
7756 h.pCleardenom(); // also does remove Content
7757 }
7758 else
7759 {
7760 h.pNorm();
7761 }
7762 strat->initEcart(&h);
7763 if (strat->Ll==-1)
7764 pos =0;
7765 else
7766 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
7767 h.sev = pGetShortExpVector(h.p);
7768 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7769 }
7770 }
7771 }
7772 }
7773 /*- test, if a unit is in F -*/
7774
7775 if ((strat->Ll>=0)
7776 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7777 && pIsConstant(strat->L[strat->Ll].p))
7778 {
7779 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7780 }
7781}

◆ initSLSba()

void initSLSba ( ideal F,
ideal Q,
kStrategy strat )

Definition at line 7783 of file kutil.cc.

7784{
7785 int i,pos;
7786 if (Q!=NULL)
7787 {
7789 if (i<setmaxTinc) i=setmaxT;
7790 }
7791 else i=setmaxT;
7792 strat->ecartS = initec(i);
7793 strat->sevS = initsevS(i);
7794 strat->sevSig = initsevS(i);
7795 strat->S_2_R = initS_2_R(i);
7796 strat->fromQ = NULL;
7797 strat->Shdl = idInit(i,F->rank);
7798 strat->S = strat->Shdl->m;
7799 strat->sig = (poly *)omAlloc0(i*sizeof(poly));
7800 if (strat->sbaOrder != 1)
7801 {
7802 strat->syz = (poly *)omAlloc0(i*sizeof(poly));
7803 strat->sevSyz = initsevS(i);
7804 strat->syzmax = i;
7805 strat->syzl = 0;
7806 }
7807 /*- put polys into S -*/
7808 if (Q!=NULL)
7809 {
7810 strat->fromQ=initec(i);
7811 memset(strat->fromQ,0,i*sizeof(int));
7812 for (i=0; i<IDELEMS(Q); i++)
7813 {
7814 if (Q->m[i]!=NULL)
7815 {
7816 LObject h;
7817 h.p = pCopy(Q->m[i]);
7819 {
7820 deleteHC(&h,strat);
7821 }
7823 {
7824 h.pCleardenom(); // also does remove Content
7825 }
7826 else
7827 {
7828 h.pNorm();
7829 }
7830 if (h.p!=NULL)
7831 {
7832 strat->initEcart(&h);
7833 if (strat->sl==-1)
7834 pos =0;
7835 else
7836 {
7837 pos = posInS(strat,strat->sl,h.p,h.ecart);
7838 }
7839 h.sev = pGetShortExpVector(h.p);
7840 strat->enterS(h,pos,strat,-1);
7841 strat->fromQ[pos]=1;
7842 }
7843 }
7844 }
7845 }
7846 for (i=0; i<IDELEMS(F); i++)
7847 {
7848 if (F->m[i]!=NULL)
7849 {
7850 LObject h;
7851 h.p = pCopy(F->m[i]);
7852 h.sig = pOne();
7853 //h.sig = pInit();
7854 //p_SetCoeff(h.sig,nInit(1),currRing);
7855 p_SetComp(h.sig,i+1,currRing);
7856 // if we are working with the Schreyer order we generate it
7857 // by multiplying the initial signatures with the leading monomial
7858 // of the corresponding initial polynomials generating the ideal
7859 // => we can keep the underlying monomial order and get a Schreyer
7860 // order without any bigger overhead
7861 if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
7862 {
7863 p_ExpVectorAdd (h.sig,F->m[i],currRing);
7864 }
7865 h.sevSig = pGetShortExpVector(h.sig);
7866#ifdef DEBUGF5
7867 pWrite(h.p);
7868 pWrite(h.sig);
7869#endif
7870 if (h.p!=NULL)
7871 {
7873 {
7874 cancelunit(&h); /*- tries to cancel a unit -*/
7875 deleteHC(&h, strat);
7876 }
7877 if (h.p!=NULL)
7878 {
7880 {
7881 h.pCleardenom(); // also does remove Content
7882 }
7883 else
7884 {
7885 h.pNorm();
7886 }
7887 strat->initEcart(&h);
7888 if (strat->Ll==-1)
7889 pos =0;
7890 else
7891 pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
7892 h.sev = pGetShortExpVector(h.p);
7893 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7894 }
7895 }
7896 /*
7897 if (strat->sbaOrder != 1)
7898 {
7899 for(j=0;j<i;j++)
7900 {
7901 strat->syz[ctr] = pCopy(F->m[j]);
7902 p_SetCompP(strat->syz[ctr],i+1,currRing);
7903 // add LM(F->m[i]) to the signature to get a Schreyer order
7904 // without changing the underlying polynomial ring at all
7905 p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
7906 // since p_Add_q() destroys all input
7907 // data we need to recreate help
7908 // each time
7909 poly help = pCopy(F->m[i]);
7910 p_SetCompP(help,j+1,currRing);
7911 pWrite(strat->syz[ctr]);
7912 pWrite(help);
7913 printf("%d\n",pLmCmp(strat->syz[ctr],help));
7914 strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
7915 printf("%d. SYZ ",ctr);
7916 pWrite(strat->syz[ctr]);
7917 strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
7918 ctr++;
7919 }
7920 strat->syzl = ps;
7921 }
7922 */
7923 }
7924 }
7925 /*- test, if a unit is in F -*/
7926
7927 if ((strat->Ll>=0)
7928 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7929 && pIsConstant(strat->L[strat->Ll].p))
7930 {
7931 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7932 }
7933}
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition p_polys.h:1427

◆ initSSpecial()

void initSSpecial ( ideal F,
ideal Q,
ideal P,
kStrategy strat )

Definition at line 8090 of file kutil.cc.

8091{
8092 int i,pos;
8093
8094 if (Q!=NULL)
8095 {
8097 if (i<setmaxTinc) i=setmaxT;
8098 }
8099 else i=setmaxT;
8100 i=((i+IDELEMS(F)+IDELEMS(P)+setmax-1)/setmax)*setmax;
8101 strat->ecartS=initec(i);
8102 strat->sevS=initsevS(i);
8103 strat->S_2_R=initS_2_R(i);
8104 strat->fromQ=NULL;
8105 strat->Shdl=idInit(i,F->rank);
8106 strat->S=strat->Shdl->m;
8107
8108 /*- put polys into S -*/
8109 if (Q!=NULL)
8110 {
8111 strat->fromQ=initec(i);
8112 memset(strat->fromQ,0,i*sizeof(int));
8113 for (i=0; i<IDELEMS(Q); i++)
8114 {
8115 if (Q->m[i]!=NULL)
8116 {
8117 LObject h;
8118 h.p = pCopy(Q->m[i]);
8119 //if (TEST_OPT_INTSTRATEGY)
8120 //{
8121 // h.pCleardenom(); // also does remove Content
8122 //}
8123 //else
8124 //{
8125 // h.pNorm();
8126 //}
8128 {
8129 deleteHC(&h,strat);
8130 }
8131 if (h.p!=NULL)
8132 {
8133 strat->initEcart(&h);
8134 if (strat->sl==-1)
8135 pos =0;
8136 else
8137 {
8138 pos = posInS(strat,strat->sl,h.p,h.ecart);
8139 }
8140 h.sev = pGetShortExpVector(h.p);
8141 strat->enterS(h,pos,strat, strat->tl+1);
8142 enterT(h, strat);
8143 strat->fromQ[pos]=1;
8144 }
8145 }
8146 }
8147 }
8148 /*- put polys into S -*/
8149 for (i=0; i<IDELEMS(F); i++)
8150 {
8151 if (F->m[i]!=NULL)
8152 {
8153 LObject h;
8154 h.p = pCopy(F->m[i]);
8156 {
8157 deleteHC(&h,strat);
8158 }
8159 else if (TEST_OPT_REDTAIL || TEST_OPT_REDSB)
8160 {
8161 h.p=redtailBba(h.p,strat->sl,strat);
8162 }
8163 if (h.p!=NULL)
8164 {
8165 strat->initEcart(&h);
8166 if (strat->sl==-1)
8167 pos =0;
8168 else
8169 pos = posInS(strat,strat->sl,h.p,h.ecart);
8170 h.sev = pGetShortExpVector(h.p);
8171 strat->enterS(h,pos,strat, strat->tl+1);
8172 enterT(h,strat);
8173 }
8174 }
8175 }
8176 for (i=0; i<IDELEMS(P); i++)
8177 {
8178 if (P->m[i]!=NULL)
8179 {
8180 LObject h;
8181 h.p=pCopy(P->m[i]);
8183 {
8184 h.pCleardenom();
8185 }
8186 else
8187 {
8188 h.pNorm();
8189 }
8190 if(strat->sl>=0)
8191 {
8193 {
8194 h.p=redBba(h.p,strat->sl,strat);
8195 if ((h.p!=NULL)&&(TEST_OPT_REDTAIL || TEST_OPT_REDSB))
8196 {
8197 h.p=redtailBba(h.p,strat->sl,strat);
8198 }
8199 }
8200 else
8201 {
8202 h.p=redMora(h.p,strat->sl,strat);
8203 }
8204 if(h.p!=NULL)
8205 {
8206 strat->initEcart(&h);
8208 {
8209 h.pCleardenom();
8210 }
8211 else
8212 {
8213 h.is_normalized = 0;
8214 h.pNorm();
8215 }
8216 h.sev = pGetShortExpVector(h.p);
8217 h.SetpFDeg();
8218 pos = posInS(strat,strat->sl,h.p,h.ecart);
8219 enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1);
8220 strat->enterS(h,pos,strat, strat->tl+1);
8221 enterT(h,strat);
8222 }
8223 }
8224 else
8225 {
8226 h.sev = pGetShortExpVector(h.p);
8227 strat->initEcart(&h);
8228 strat->enterS(h,0,strat, strat->tl+1);
8229 enterT(h,strat);
8230 }
8231 }
8232 }
8233}
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8514
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8490
void enterpairsSpecial(poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
Definition kutil.cc:4543
#define TEST_OPT_REDSB
Definition options.h:106

◆ initSSpecialSba()

void initSSpecialSba ( ideal F,
ideal Q,
ideal P,
kStrategy strat )

Definition at line 8238 of file kutil.cc.

8239{
8240 int i,pos;
8241
8242 if (Q!=NULL)
8243 {
8245 if (i<setmaxTinc) i=setmaxT;
8246 }
8247 else i=setmaxT;
8248 i=((i+IDELEMS(F)+IDELEMS(P)+setmax-1)/setmax)*setmax;
8249 strat->sevS=initsevS(i);
8250 strat->sevSig=initsevS(i);
8251 strat->S_2_R=initS_2_R(i);
8252 strat->fromQ=NULL;
8253 strat->Shdl=idInit(i,F->rank);
8254 strat->S=strat->Shdl->m;
8255 strat->sig=(poly *)omAlloc0(i*sizeof(poly));
8256 /*- put polys into S -*/
8257 if (Q!=NULL)
8258 {
8259 strat->fromQ=initec(i);
8260 memset(strat->fromQ,0,i*sizeof(int));
8261 for (i=0; i<IDELEMS(Q); i++)
8262 {
8263 if (Q->m[i]!=NULL)
8264 {
8265 LObject h;
8266 h.p = pCopy(Q->m[i]);
8267 //if (TEST_OPT_INTSTRATEGY)
8268 //{
8269 // h.pCleardenom(); // also does remove Content
8270 //}
8271 //else
8272 //{
8273 // h.pNorm();
8274 //}
8276 {
8277 deleteHC(&h,strat);
8278 }
8279 if (h.p!=NULL)
8280 {
8281 strat->initEcart(&h);
8282 if (strat->sl==-1)
8283 pos =0;
8284 else
8285 {
8286 pos = posInS(strat,strat->sl,h.p,h.ecart);
8287 }
8288 h.sev = pGetShortExpVector(h.p);
8289 strat->enterS(h,pos,strat, strat->tl+1);
8290 enterT(h, strat);
8291 strat->fromQ[pos]=1;
8292 }
8293 }
8294 }
8295 }
8296 /*- put polys into S -*/
8297 for (i=0; i<IDELEMS(F); i++)
8298 {
8299 if (F->m[i]!=NULL)
8300 {
8301 LObject h;
8302 h.p = pCopy(F->m[i]);
8304 {
8305 deleteHC(&h,strat);
8306 }
8307 else if (TEST_OPT_REDTAIL || TEST_OPT_REDSB)
8308 {
8309 h.p=redtailBba(h.p,strat->sl,strat);
8310 }
8311 if (h.p!=NULL)
8312 {
8313 strat->initEcart(&h);
8314 if (strat->sl==-1)
8315 pos =0;
8316 else
8317 pos = posInS(strat,strat->sl,h.p,h.ecart);
8318 h.sev = pGetShortExpVector(h.p);
8319 strat->enterS(h,pos,strat, strat->tl+1);
8320 enterT(h,strat);
8321 }
8322 }
8323 }
8324 for (i=0; i<IDELEMS(P); i++)
8325 {
8326 if (P->m[i]!=NULL)
8327 {
8328 LObject h;
8329 h.p=pCopy(P->m[i]);
8331 {
8332 h.pCleardenom();
8333 }
8334 else
8335 {
8336 h.pNorm();
8337 }
8338 if(strat->sl>=0)
8339 {
8341 {
8342 h.p=redBba(h.p,strat->sl,strat);
8343 if ((h.p!=NULL)&&(TEST_OPT_REDTAIL || TEST_OPT_REDSB))
8344 {
8345 h.p=redtailBba(h.p,strat->sl,strat);
8346 }
8347 }
8348 else
8349 {
8350 h.p=redMora(h.p,strat->sl,strat);
8351 }
8352 if(h.p!=NULL)
8353 {
8354 strat->initEcart(&h);
8356 {
8357 h.pCleardenom();
8358 }
8359 else
8360 {
8361 h.is_normalized = 0;
8362 h.pNorm();
8363 }
8364 h.sev = pGetShortExpVector(h.p);
8365 h.SetpFDeg();
8366 pos = posInS(strat,strat->sl,h.p,h.ecart);
8367 enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1);
8368 strat->enterS(h,pos,strat, strat->tl+1);
8369 enterT(h,strat);
8370 }
8371 }
8372 else
8373 {
8374 h.sev = pGetShortExpVector(h.p);
8375 strat->initEcart(&h);
8376 strat->enterS(h,0,strat, strat->tl+1);
8377 enterT(h,strat);
8378 }
8379 }
8380 }
8381}

◆ initSyzRules()

void initSyzRules ( kStrategy strat)

Definition at line 7935 of file kutil.cc.

7936{
7937 if( strat->S[0] )
7938 {
7939 if( strat->S[1] && !rField_is_Ring(currRing))
7940 {
7941 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
7942 omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
7943 omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
7944 }
7945 int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
7946 /************************************************************
7947 * computing the length of the syzygy array needed
7948 ***********************************************************/
7949 for(i=1; i<=strat->sl; i++)
7950 {
7951 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
7952 {
7953 ps += i;
7954 }
7955 }
7956 ps += strat->sl+1;
7957 //comp = pGetComp (strat->P.sig);
7958 comp = strat->currIdx;
7959 strat->syzIdx = initec(comp);
7960 strat->sevSyz = initsevS(ps);
7961 strat->syz = (poly *)omAlloc(ps*sizeof(poly));
7962 strat->syzmax = ps;
7963 strat->syzl = 0;
7964 strat->syzidxmax = comp;
7965#if defined(DEBUGF5) || defined(DEBUGF51)
7966 PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
7967#endif
7968 i = 1;
7969 j = 0;
7970 /************************************************************
7971 * generating the leading terms of the principal syzygies
7972 ***********************************************************/
7973 while (i <= strat->sl)
7974 {
7975 /**********************************************************
7976 * principal syzygies start with component index 2
7977 * the array syzIdx starts with index 0
7978 * => the rules for a signature with component comp start
7979 * at strat->syz[strat->syzIdx[comp-2]] !
7980 *********************************************************/
7981 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
7982 {
7983 comp = pGetComp(strat->sig[i]);
7984 comp_old = pGetComp(strat->sig[i-1]);
7985 diff = comp - comp_old - 1;
7986 // diff should be zero, but sometimes also the initial generating
7987 // elements of the input ideal reduce to zero. then there is an
7988 // index-gap between the signatures. for these in-between signatures we
7989 // can safely set syzIdx[j] = 0 as no such element will be ever computed
7990 // in the following.
7991 // doing this, we keep the relation "j = comp - 2" alive, which makes
7992 // jumps way easier when checking criteria
7993 while (diff>0)
7994 {
7995 strat->syzIdx[j] = 0;
7996 diff--;
7997 j++;
7998 }
7999 strat->syzIdx[j] = ctr;
8000 j++;
8001 LObject Q;
8002 int pos;
8003 for (k = 0; k<i; k++)
8004 {
8005 Q.sig = pOne();
8008 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8009 p_SetCompP (Q.sig, comp, currRing);
8010 poly q = p_One(currRing);
8013 p_ExpVectorCopy(q,strat->S[i],currRing);
8014 q = p_Neg (q, currRing);
8015 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8016 Q.sig = p_Add_q (Q.sig, q, currRing);
8017 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8018 pos = posInSyz(strat, Q.sig);
8019 enterSyz(Q, strat, pos);
8020 ctr++;
8021 }
8022 }
8023 i++;
8024 }
8025 /**************************************************************
8026 * add syzygies for upcoming first element of new iteration step
8027 **************************************************************/
8028 comp = strat->currIdx;
8029 comp_old = pGetComp(strat->sig[i-1]);
8030 diff = comp - comp_old - 1;
8031 // diff should be zero, but sometimes also the initial generating
8032 // elements of the input ideal reduce to zero. then there is an
8033 // index-gap between the signatures. for these in-between signatures we
8034 // can safely set syzIdx[j] = 0 as no such element will be ever computed
8035 // in the following.
8036 // doing this, we keep the relation "j = comp - 2" alive, which makes
8037 // jumps way easier when checking criteria
8038 while (diff>0)
8039 {
8040 strat->syzIdx[j] = 0;
8041 diff--;
8042 j++;
8043 }
8044 strat->syzIdx[j] = ctr;
8045 LObject Q;
8046 int pos;
8047 for (k = 0; k<strat->sl+1; k++)
8048 {
8049 Q.sig = pOne();
8052 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8053 p_SetCompP (Q.sig, comp, currRing);
8054 poly q = p_One(currRing);
8056 p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8057 p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8058 q = p_Neg (q, currRing);
8059 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8060 Q.sig = p_Add_q (Q.sig, q, currRing);
8061 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8062 pos = posInSyz(strat, Q.sig);
8063 enterSyz(Q, strat, pos);
8064 ctr++;
8065 }
8066//#if 1
8067#ifdef DEBUGF5
8068 PrintS("Principal syzygies:\n");
8069 Print("syzl %d\n",strat->syzl);
8070 Print("syzmax %d\n",strat->syzmax);
8071 Print("ps %d\n",ps);
8072 PrintS("--------------------------------\n");
8073 for(i=0;i<=strat->syzl-1;i++)
8074 {
8075 Print("%d - ",i);
8076 pWrite(strat->syz[i]);
8077 }
8078 for(i=0;i<strat->currIdx;i++)
8079 {
8080 Print("%d - %d\n",i,strat->syzIdx[i]);
8081 }
8082 PrintS("--------------------------------\n");
8083#endif
8084 }
8085}
int currIdx
Definition kutil.h:318
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define p_GetCoeff(p, r)
Definition monomials.h:50
STATIC_VAR gmp_float * diff
poly p_One(const ring r)
Definition p_polys.cc:1314
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1109
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition p_polys.h:1329

◆ is_shifted_p1()

static BOOLEAN is_shifted_p1 ( const poly p,
const kStrategy strat )
static

Definition at line 1188 of file kutil.cc.

1189{
1190 if (rIsLPRing(currRing)
1191 && (strat->P.p1!=NULL))
1192 {
1193 // clean up strat->P.p1: may be shifted
1194 poly p=strat->P.p1;
1195 int lv=currRing->isLPring;
1196 BOOLEAN is_shifted=TRUE;
1197 for (int i=lv;i>0;i--)
1198 {
1199 if (pGetExp(p,i)!=0) { is_shifted=FALSE; break;}
1200 }
1201 if (is_shifted
1202 && (kFindInL1(p, strat)<0)
1203 && (kFindInT(p, strat->T, strat->tl) < 0)
1204 )
1205 {
1206 return TRUE;
1207 }
1208 }
1209 return FALSE;
1210}
static int kFindInL1(const poly p, const kStrategy strat)
Definition kutil.h:841
#define pGetExp(p, i)
Exponent.
Definition polys.h:42

◆ isInPairsetL()

BOOLEAN isInPairsetL ( int length,
poly p1,
poly p2,
int * k,
kStrategy strat )

Definition at line 694 of file kutil.cc.

695{
696 LObject *p=&(strat->L[length]);
697
698 *k = length;
699 loop
700 {
701 if ((*k) < 0) return FALSE;
702 if (((p1 == (*p).p1) && (p2 == (*p).p2))
703 || ((p1 == (*p).p2) && (p2 == (*p).p1)))
704 return TRUE;
705 (*k)--;
706 p--;
707 }
708}

◆ kCheckSpolyCreation()

BOOLEAN kCheckSpolyCreation ( LObject * L,
kStrategy strat,
poly & m1,
poly & m2 )

Definition at line 10481 of file kutil.cc.

10482{
10483 if (strat->overflow) return FALSE;
10484 assume(L->p1 != NULL && L->p2 != NULL);
10485 // shift changes: from 0 to -1
10486 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10487 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10488
10489 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10490 return FALSE;
10491 // shift changes: extra case inserted
10492 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10493 {
10494 return TRUE;
10495 }
10496 poly p1_max=NULL;
10497 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10498 poly p2_max=NULL;
10499 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10500
10501 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10502 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10503 {
10504 p_LmFree(m1, strat->tailRing);
10505 p_LmFree(m2, strat->tailRing);
10506 m1 = NULL;
10507 m2 = NULL;
10508 return FALSE;
10509 }
10510 return TRUE;
10511}
char overflow
Definition kutil.h:403
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition p_polys.h:2015

◆ kCheckStrongCreation()

BOOLEAN kCheckStrongCreation ( int atR,
poly m1,
int atS,
poly m2,
kStrategy strat )

Definition at line 10519 of file kutil.cc.

10520{
10521 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10522 //assume(strat->tailRing != currRing);
10523
10524 poly p1_max = (strat->R[atR])->max_exp;
10525 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10526
10527 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10528 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10529 {
10530 return FALSE;
10531 }
10532 return TRUE;
10533}

◆ kDebugPrint()

void kDebugPrint ( kStrategy strat)

Output some debug info about a given strategy.

Definition at line 11505 of file kutil.cc.

11506{
11507 printf("red: ");
11508 if (strat->red==redFirst) printf("redFirst\n");
11509 else if (strat->red==redHoney) printf("redHoney\n");
11510 else if (strat->red==redEcart) printf("redEcart\n");
11511 else if (strat->red==redHomog) printf("redHomog\n");
11512 else if (strat->red==redLazy) printf("redLazy\n");
11513 else if (strat->red==redLiftstd) printf("redLiftstd\n");
11514 else printf("%p\n",(void*)strat->red);
11515 printf("posInT: ");
11516 if (strat->posInT==posInT0) printf("posInT0\n");
11517 else if (strat->posInT==posInT1) printf("posInT1\n");
11518 else if (strat->posInT==posInT11) printf("posInT11\n");
11519 else if (strat->posInT==posInT110) printf("posInT110\n");
11520 else if (strat->posInT==posInT13) printf("posInT13\n");
11521 else if (strat->posInT==posInT15) printf("posInT15\n");
11522 else if (strat->posInT==posInT17) printf("posInT17\n");
11523 else if (strat->posInT==posInT17_c) printf("posInT17_c\n");
11524 else if (strat->posInT==posInT19) printf("posInT19\n");
11525 else if (strat->posInT==posInT2) printf("posInT2\n");
11526 else if (strat->posInT==posInT11Ring) printf("posInT11Ring\n");
11527 else if (strat->posInT==posInT110Ring) printf("posInT110Ring\n");
11528 else if (strat->posInT==posInT15Ring) printf("posInT15Ring\n");
11529 else if (strat->posInT==posInT17Ring) printf("posInT17Ring\n");
11530 else if (strat->posInT==posInT17_cRing) printf("posInT17_cRing\n");
11531#ifdef HAVE_MORE_POS_IN_T
11532 else if (strat->posInT==posInT_EcartFDegpLength) printf("posInT_EcartFDegpLength\n");
11533 else if (strat->posInT==posInT_FDegpLength) printf("posInT_FDegpLength\n");
11534 else if (strat->posInT==posInT_pLength) printf("posInT_pLength\n");
11535#endif
11536 else if (strat->posInT==posInT_EcartpLength) printf("posInT_EcartpLength\n");
11537 else printf("%p\n",(void*)strat->posInT);
11538 printf("posInL: ");
11539 if (strat->posInL==posInL0) printf("posInL0\n");
11540 else if (strat->posInL==posInL10) printf("posInL10\n");
11541 else if (strat->posInL==posInL11) printf("posInL11\n");
11542 else if (strat->posInL==posInL110) printf("posInL110\n");
11543 else if (strat->posInL==posInL13) printf("posInL13\n");
11544 else if (strat->posInL==posInL15) printf("posInL15\n");
11545 else if (strat->posInL==posInL17) printf("posInL17\n");
11546 else if (strat->posInL==posInL17_c) printf("posInL17_c\n");
11547 else if (strat->posInL==posInL0) printf("posInL0Ring\n");
11548 else if (strat->posInL==posInL11Ring) printf("posInL11Ring\n");
11549 else if (strat->posInL==posInL11Ringls) printf("posInL11Ringls\n");
11550 else if (strat->posInL==posInL110Ring) printf("posInL110Ring\n");
11551 else if (strat->posInL==posInL15Ring) printf("posInL15Ring\n");
11552 else if (strat->posInL==posInL17Ring) printf("posInL17Ring\n");
11553 else if (strat->posInL==posInL17_cRing) printf("posInL17_cRing\n");
11554 else if (strat->posInL==posInLSpecial) printf("posInLSpecial\n");
11555 else printf("%p\n",(void*)strat->posInL);
11556 printf("enterS: ");
11557 if (strat->enterS==enterSBba) printf("enterSBba\n");
11558 else if (strat->enterS==enterSMora) printf("enterSMora\n");
11559 else if (strat->enterS==enterSMoraNF) printf("enterSMoraNF\n");
11560 else printf("%p\n",(void*)strat->enterS);
11561 printf("initEcart: ");
11562 if (strat->initEcart==initEcartBBA) printf("initEcartBBA\n");
11563 else if (strat->initEcart==initEcartNormal) printf("initEcartNormal\n");
11564 else printf("%p\n",(void*)strat->initEcart);
11565 printf("initEcartPair: ");
11566 if (strat->initEcartPair==initEcartPairBba) printf("initEcartPairBba\n");
11567 else if (strat->initEcartPair==initEcartPairMora) printf("initEcartPairMora\n");
11568 else printf("%p\n",(void*)strat->initEcartPair);
11569 printf("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11570 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11571 printf("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11572 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11573 printf("chainCrit: ");
11574 if (strat->chainCrit==chainCritNormal) printf("chainCritNormal\n");
11575 else if (strat->chainCrit==chainCritOpt_1) printf("chainCritOpt_1\n");
11576 else printf("%p\n",(void*)strat->chainCrit);
11577 printf("posInLDependsOnLength=%d\n",
11578 strat->posInLDependsOnLength);
11579 printf("%s\n",showOption());
11580 printf("LDeg: ");
11581 if (currRing->pLDeg==pLDeg0) printf("pLDeg0");
11582 else if (currRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11583 else if (currRing->pLDeg==pLDegb) printf("pLDegb");
11584 else if (currRing->pLDeg==pLDeg1) printf("pLDeg1");
11585 else if (currRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11586 else if (currRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11587 else if (currRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11588 else if (currRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11589 else if (currRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11590 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11591 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11592 else if (currRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11593 else printf("? (%lx)", (long)currRing->pLDeg);
11594 printf(" / ");
11595 if (strat->tailRing->pLDeg==pLDeg0) printf("pLDeg0");
11596 else if (strat->tailRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11597 else if (strat->tailRing->pLDeg==pLDegb) printf("pLDegb");
11598 else if (strat->tailRing->pLDeg==pLDeg1) printf("pLDeg1");
11599 else if (strat->tailRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11600 else if (strat->tailRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11601 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11602 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11603 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11604 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11605 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11606 else if (strat->tailRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11607 else printf("? (%lx)", (long)strat->tailRing->pLDeg);
11608 printf("\n");
11609 printf("currRing->pFDeg: ");
11610 if (currRing->pFDeg==p_Totaldegree) printf("p_Totaldegree");
11611 else if (currRing->pFDeg==p_WFirstTotalDegree) printf("pWFirstTotalDegree");
11612 else if (currRing->pFDeg==p_Deg) printf("p_Deg");
11613 else if (currRing->pFDeg==kHomModDeg) printf("kHomModDeg");
11614 else if (currRing->pFDeg==totaldegreeWecart) printf("totaldegreeWecart");
11615 else if (currRing->pFDeg==p_WTotaldegree) printf("p_WTotaldegree");
11616 else printf("? (%lx)", (long)currRing->pFDeg);
11617 printf("\n");
11618 printf(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11620 printf(" degBound: %d\n", Kstd1_deg);
11621
11622 if( ecartWeights != NULL )
11623 {
11624 printf("ecartWeights: ");
11625 for (int i = rVar(currRing); i > 0; i--)
11626 printf("%hd ", ecartWeights[i]);
11627 printf("\n");
11629 }
11630
11631#ifndef SING_NDEBUG
11633#endif
11634}
char use_buckets
Definition kutil.h:382
int LazyPass
Definition kutil.h:354
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:279
int LazyDegree
Definition kutil.h:354
int redLiftstd(LObject *h, kStrategy strat)
Definition kLiftstd.cc:167
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2417
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:794
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition kstd1.cc:1673
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition kstd1.cc:1620
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
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 posInT2(const TSet set, const int length, LObject &p)
Definition kutil.cc:4932
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11471
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition kutil.cc:1322
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11380
void initEcartNormal(TObject *h)
Definition kutil.cc:1300
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11434
void initEcartBBA(TObject *h)
Definition kutil.cc:1308
char * showOption()
Definition misc_ip.cc:711
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition kutil.cc:1315
#define TEST_OPT_DEGBOUND
Definition options.h:115
long pLDegb(poly p, int *l, const ring r)
Definition p_polys.cc:812
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition p_polys.cc:976
long p_WFirstTotalDegree(poly p, const ring r)
Definition p_polys.cc:595
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition p_polys.cc:1039
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition p_polys.cc:1069
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition p_polys.cc:942
long pLDeg1(poly p, int *l, const ring r)
Definition p_polys.cc:842
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition p_polys.cc:911
long p_WTotaldegree(poly p, const ring r)
Definition p_polys.cc:612
long pLDeg1c(poly p, int *l, const ring r)
Definition p_polys.cc:878
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition p_polys.cc:1006
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
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523
void rDebugPrint(const ring r)
Definition ring.cc:4214
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:729
long totaldegreeWecart(poly p, ring r)
Definition weight.cc:217
long maxdegreeWecart(poly p, int *l, ring r)
Definition weight.cc:247
EXTERN_VAR short * ecartWeights
Definition weight.h:12

◆ kFindDivisibleByInS_T()

TObject * kFindDivisibleByInS_T ( kStrategy strat,
int end_pos,
LObject * L,
TObject * T,
long ecart )

Definition at line 6701 of file kutil.cc.

6702{
6703 int j = 0;
6704 const unsigned long not_sev = ~L->sev;
6705 const unsigned long* sev = strat->sevS;
6706 poly p;
6707 ring r;
6708 L->GetLm(p, r);
6709
6710 assume(~not_sev == p_GetShortExpVector(p, r));
6711
6712 if (r == currRing)
6713 {
6714 if(!rField_is_Ring(r))
6715 {
6716 loop
6717 {
6718 if (j > end_pos) return NULL;
6719 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6720 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6721 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6722 #else
6723 if (!(sev[j] & not_sev) &&
6724 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
6725 p_LmDivisibleBy(strat->S[j], p, r))
6726 #endif
6727 {
6728 break;
6729 }
6730 j++;
6731 }
6732 }
6733 else
6734 {
6735 loop
6736 {
6737 if (j > end_pos) return NULL;
6738 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6739 if (strat->S[j]!= NULL
6740 && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r)
6741 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6742 && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6743 #else
6744 if (!(sev[j] & not_sev)
6745 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6746 && p_LmDivisibleBy(strat->S[j], p, r)
6747 && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6748 #endif
6749 {
6750 break; // found
6751 }
6752 j++;
6753 }
6754 }
6755 // if called from NF, T objects do not exist:
6756 if (strat->tl < 0 || strat->S_2_R[j] == -1)
6757 {
6758 T->Set(strat->S[j], r, strat->tailRing);
6759 assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
6760 return T;
6761 }
6762 else
6763 {
6764///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
6765///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
6766// assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
6767 return strat->S_2_T(j);
6768 }
6769 }
6770 else
6771 {
6772 TObject* t;
6773 if(!rField_is_Ring(r))
6774 {
6775 loop
6776 {
6777 if (j > end_pos) return NULL;
6778 assume(strat->S_2_R[j] != -1);
6779 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6780 t = strat->S_2_T(j);
6781 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
6782 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r)
6783 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6784 {
6785 t->pLength=pLength(t->t_p);
6786 return t;
6787 }
6788 #else
6789 if (! (sev[j] & not_sev)
6790 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6791 {
6792 t = strat->S_2_T(j);
6793 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
6794 if (p_LmDivisibleBy(t->t_p, p, r))
6795 {
6796 t->pLength=pLength(t->t_p);
6797 return t;
6798 }
6799 }
6800 #endif
6801 j++;
6802 }
6803 }
6804 else
6805 {
6806 loop
6807 {
6808 if (j > end_pos) return NULL;
6809 assume(strat->S_2_R[j] != -1);
6810 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6811 t = strat->S_2_T(j);
6812 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
6813 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r)
6814 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6815 && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
6816 {
6817 t->pLength=pLength(t->t_p);
6818 return t;
6819 }
6820 #else
6821 if (! (sev[j] & not_sev)
6822 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6823 {
6824 t = strat->S_2_T(j);
6825 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
6826 if (p_LmDivisibleBy(t->t_p, p, r)
6827 && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
6828 {
6829 t->pLength=pLength(t->t_p);
6830 return t;
6831 }
6832 }
6833 #endif
6834 j++;
6835 }
6836 }
6837 }
6838}
KINLINE TObject * S_2_T(int i)
Definition kInline.h:38

◆ kFindInT() [1/2]

int kFindInT ( poly p,
kStrategy strat )

Definition at line 721 of file kutil.cc.

722{
723 int i;
724 do
725 {
726 i = kFindInT(p, strat->T, strat->tl);
727 if (i >= 0) return i;
728 strat = strat->next;
729 }
730 while (strat != NULL);
731 return -1;
732}
kStrategy next
Definition kutil.h:278

◆ kFindInT() [2/2]

int kFindInT ( poly p,
TSet T,
int tlength )

returns index of p in TSet, or -1 if not found

Definition at line 710 of file kutil.cc.

711{
712 int i;
713
714 for (i=0; i<=tlength; i++)
715 {
716 if (T[i].p == p) return i;
717 }
718 return -1;
719}

◆ kFindInTShift() [1/2]

int kFindInTShift ( poly p,
kStrategy strat )

Definition at line 749 of file kutil.cc.

750{
751 int i;
752 do
753 {
754 i = kFindInTShift(p, strat->T, strat->tl);
755 if (i >= 0) return i;
756 strat = strat->next;
757 }
758 while (strat != NULL);
759 return -1;
760}
int kFindInTShift(poly p, TSet T, int tlength)
Definition kutil.cc:735

◆ kFindInTShift() [2/2]

int kFindInTShift ( poly p,
TSet T,
int tlength )

Definition at line 735 of file kutil.cc.

736{
737 int i;
738
739 for (i=0; i<=tlength; i++)
740 {
741 // in the Letterplace ring the LMs in T and L are copies thus we have to use pEqualPolys() instead of ==
742 if (pEqualPolys(T[i].p, p)) return i;
743 }
744 return -1;
745}
#define pEqualPolys(p1, p2)
Definition polys.h:400

◆ kMergeBintoL()

void kMergeBintoL ( kStrategy strat)

Definition at line 3168 of file kutil.cc.

3169{
3170 int j=strat->Ll+strat->Bl+1;
3171 if (j>strat->Lmax)
3172 {
3173 j=((j+setmaxLinc-1)/setmaxLinc)*setmaxLinc-strat->Lmax;
3174 enlargeL(&(strat->L),&(strat->Lmax),j);
3175 }
3176 j = strat->Ll;
3177 int i;
3178 for (i=strat->Bl; i>=0; i--)
3179 {
3180 j = strat->posInL(strat->L,j,&(strat->B[i]),strat);
3181 enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j);
3182 }
3183 strat->Bl = -1;
3184}

◆ kMergeBintoLSba()

void kMergeBintoLSba ( kStrategy strat)

Definition at line 3189 of file kutil.cc.

3190{
3191 int j=strat->Ll+strat->Bl+1;
3192 if (j>strat->Lmax)
3193 {
3194 j=((j+setmaxLinc-1)/setmaxLinc)*setmaxLinc-strat->Lmax;
3195 enlargeL(&(strat->L),&(strat->Lmax),j);
3196 }
3197 j = strat->Ll;
3198 int i;
3199 for (i=strat->Bl; i>=0; i--)
3200 {
3201 j = strat->posInLSba(strat->L,j,&(strat->B[i]),strat);
3202 enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j);
3203 }
3204 strat->Bl = -1;
3205}

◆ kPosInLDependsOnLength()

BOOLEAN kPosInLDependsOnLength ( int(* pos_in_l )(const LSet set, const int length, LObject *L, const kStrategy strat))

Definition at line 9567 of file kutil.cc.

9570{
9571 if (pos_in_l == posInL110
9572 || pos_in_l == posInL10
9573 || pos_in_l == posInL110Ring
9574 )
9575 return TRUE;
9576
9577 return FALSE;
9578}

◆ kStratChangeTailRing()

BOOLEAN kStratChangeTailRing ( kStrategy strat,
LObject * L,
TObject * T,
unsigned long expbound )

Definition at line 10961 of file kutil.cc.

10962{
10963 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
10964 /* initial setup or extending */
10965
10966 if (rIsLPRing(currRing)) return TRUE;
10967 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
10968 if (expbound >= currRing->bitmask) return FALSE;
10969 strat->overflow=FALSE;
10970 ring new_tailRing = rModifyRing(currRing,
10971 // Hmmm .. the condition pFDeg == p_Deg
10972 // might be too strong
10973 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
10974 (strat->ak==0), // omit_comp if the input is an ideal
10975 expbound); // exp_limit
10976
10977 if (new_tailRing == currRing) return TRUE;
10978
10979 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
10980 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
10981
10982 if (currRing->pFDeg != currRing->pFDegOrig)
10983 {
10984 new_tailRing->pFDeg = currRing->pFDeg;
10985 new_tailRing->pLDeg = currRing->pLDeg;
10986 }
10987
10988 if (TEST_OPT_PROT)
10989 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
10990 #ifdef KDEBUG
10991 kTest_TS(strat);
10992 assume(new_tailRing != strat->tailRing);
10993 #endif
10994 pShallowCopyDeleteProc p_shallow_copy_delete
10995 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
10996
10997 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
10998
10999 int i;
11000 for (i=0; i<=strat->tl; i++)
11001 {
11002 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11003 p_shallow_copy_delete);
11004 }
11005 for (i=0; i<=strat->Ll; i++)
11006 {
11007 assume(strat->L[i].p != NULL);
11008 if (pNext(strat->L[i].p) != strat->tail)
11009 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11010 }
11011 if ((strat->P.t_p != NULL) ||
11012 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11013 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11014
11015 if ((L != NULL) && (L->tailRing != new_tailRing))
11016 {
11017 if (L->i_r < 0)
11018 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11019 else
11020 {
11021 assume(L->i_r <= strat->tl);
11022 TObject* t_l = strat->R[L->i_r];
11023 assume(t_l != NULL);
11024 L->tailRing = new_tailRing;
11025 L->p = t_l->p;
11026 L->t_p = t_l->t_p;
11027 L->max_exp = t_l->max_exp;
11028 }
11029 }
11030
11031 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11032 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11033
11034 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11035 if (strat->tailRing != currRing)
11037
11038 strat->tailRing = new_tailRing;
11039 strat->tailBin = new_tailBin;
11041 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11042
11043 if (strat->kNoether != NULL)
11044 {
11045 if (strat->t_kNoether != NULL)
11046 p_LmFree(strat->t_kNoether, strat->tailRing);
11047 strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_tailRing);
11048 }
11049
11050 #ifdef KDEBUG
11051 kTest_TS(strat);
11052 #endif
11053 if (TEST_OPT_PROT)
11054 PrintS("]");
11055 return TRUE;
11056}
poly t_kNoether
Definition kutil.h:331
pFDegProc pOrigFDeg_TailRing
Definition kutil.h:299
pShallowCopyDeleteProc p_shallow_copy_delete
Definition kutil.h:339
pLDegProc pOrigLDeg_TailRing
Definition kutil.h:300
omBin_t * omBin
Definition omStructs.h:12
void rKillModifiedRing(ring r)
Definition ring.cc:3118
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition ring.cc:2757
#define omGetStickyBinOfBin(B)
Definition xalloc.h:247
#define omMergeStickyBinIntoBin(A, B)
Definition xalloc.h:275

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy strat)

Definition at line 11058 of file kutil.cc.

11059{
11060 unsigned long l = 0;
11061 int i;
11062 long e;
11063
11064 assume(strat->tailRing == currRing);
11065
11066 for (i=0; i<= strat->Ll; i++)
11067 {
11068 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11069 }
11070 for (i=0; i<=strat->tl; i++)
11071 {
11072 // Hmm ... this we could do in one Step
11073 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11074 }
11076 {
11077 l *= 2;
11078 }
11079 e = p_GetMaxExp(l, currRing);
11080 if (e <= 1) e = 2;
11081 if (rIsLPRing(currRing)) e = 1;
11082
11083 kStratChangeTailRing(strat, NULL, NULL, e);
11084}
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10961
unsigned long p_GetMaxExpL(poly p, const ring r, unsigned long l_max)
return the maximal exponent of p in form of the maximal long var
Definition p_polys.cc:1176
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition p_polys.h:783

◆ kTest()

BOOLEAN kTest ( kStrategy strat)

Definition at line 1011 of file kutil.cc.

1012{
1013 int i;
1014 // test P
1015 kFalseReturn(kTest_L(&(strat->P), strat,
1016 (strat->P.p != NULL && pNext(strat->P.p)!=strat->tail),
1017 -1, strat->T, strat->tl));
1018
1019 // test T
1020 if (strat->T != NULL)
1021 {
1022 for (i=0; i<=strat->tl; i++)
1023 {
1024 kFalseReturn(kTest_T(&(strat->T[i]), strat, i, 'T'));
1025 if (strat->sevT[i] != pGetShortExpVector(strat->T[i].p))
1026 return dReportError("strat->sevT[%d] out of sync", i);
1027 }
1028 }
1029
1030 // test L
1031 if (strat->L != NULL)
1032 {
1033 for (i=0; i<=strat->Ll; i++)
1034 {
1035 kFalseReturn(kTest_L(&(strat->L[i]), strat,
1036 strat->L[i].Next() != strat->tail, i,
1037 strat->T, strat->tl));
1038 // may be unused
1039 //if (strat->use_buckets && strat->L[i].Next() != strat->tail &&
1040 // strat->L[i].Next() != NULL && strat->L[i].p1 != NULL)
1041 //{
1042 // assume(strat->L[i].bucket != NULL);
1043 //}
1044 }
1045 }
1046
1047 // test S
1048 if (strat->S != NULL)
1049 kFalseReturn(kTest_S(strat));
1050
1051 return TRUE;
1052}
#define kFalseReturn(x)
Definition kutil.cc:772
BOOLEAN kTest_S(kStrategy strat)
Definition kutil.cc:1056
int dReportError(const char *fmt,...)
Definition dError.cc:44

◆ kTest_L()

BOOLEAN kTest_L ( LObject * L,
kStrategy strat,
BOOLEAN testp,
int lpos,
TSet T,
int tlength )

Definition at line 923 of file kutil.cc.

925{
926 ring strat_tailRing=strat->tailRing;
927 if (L->p!=NULL)
928 {
929 if ((L->t_p==NULL)
930 &&(pNext(L->p)!=NULL)
931 &&(pGetCoeff(pNext(L->p))!=NULL)) /* !=strat->tail*/
932 {
933 p_Test(pNext(L->p),currRing);
934 nTest(pGetCoeff(L->p));
935 }
936 }
937 if (L->t_p!=NULL)
938 {
939 if ((pNext(L->t_p)!=NULL)
940 &&(pGetCoeff(pNext(L->t_p))!=NULL)) /* !=strat->tail*/
941 {
942 p_Test(pNext(L->t_p),strat_tailRing);
943 nTest(pGetCoeff(L->t_p));
944 }
945 }
946 if ((L->p!=NULL)&&(L->t_p!=NULL)) assume(pGetCoeff(L->p)==pGetCoeff(L->t_p));
947
948 if (testp)
949 {
950 poly pn = NULL;
951 if (L->bucket != NULL)
952 {
953 kFalseReturn(kbTest(L->bucket));
954 r_assume(L->bucket->bucket_ring == L->tailRing);
955 if (L->p != NULL && pNext(L->p) != NULL)
956 {
957 pn = pNext(L->p);
958 pNext(L->p) = NULL;
959 }
960 }
961 kFalseReturn(kTest_T(L, strat, lpos, 'L'));
962 if (pn != NULL)
963 pNext(L->p) = pn;
964
965 ring r;
966 poly p;
967 L->GetLm(p, r);
968 if (L->sev != 0L)
969 {
970 if (p_GetShortExpVector(p, r) != L->sev)
971 {
972 return dReportError("L[%d] wrong sev: has %lo, specified to have %lo",
973 lpos, p_GetShortExpVector(p, r), L->sev);
974 }
975 }
976 }
977 if (L->p1 == NULL)
978 {
979 // L->p2 either NULL or "normal" poly
980 pFalseReturn(pp_Test(L->p2, currRing, L->tailRing));
981 }
982 else if (tlength > 0 && T != NULL && (lpos >=0))
983 {
984 // now p1 and p2 must be != NULL and must be contained in T
985 int i;
986#ifdef HAVE_SHIFTBBA
987 if (rIsLPRing(currRing))
988 i = kFindInTShift(L->p1, T, tlength);
989 else
990#endif
991 i = kFindInT(L->p1, T, tlength);
992 if (i < 0)
993 return dReportError("L[%d].p1 not in T",lpos);
994#ifdef HAVE_SHIFTBBA
995 if (rIsLPRing(currRing))
996 {
997 if (rField_is_Ring(currRing)) return TRUE; // m*shift(q) is not in T
998 i = kFindInTShift(L->p2, T, tlength);
999 }
1000 else
1001#endif
1002 i = kFindInT(L->p2, T, tlength);
1003 if (i < 0)
1004 return dReportError("L[%d].p2 not in T",lpos);
1005 }
1006 return TRUE;
1007}
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition kbuckets.cc:197
#define r_assume(x)
Definition mod2.h:390
#define pFalseReturn(cond)
Definition monomials.h:139
#define nTest(a)
Definition numbers.h:35

◆ kTest_LmEqual()

static const char * kTest_LmEqual ( poly p,
poly t_p,
ring tailRing )
static

Definition at line 776 of file kutil.cc.

777{
778 int i;
779 for (i=1; i<=tailRing->N; i++)
780 {
781 if (p_GetExp(p, i, currRing) != p_GetExp(t_p, i, tailRing))
782 return "Lm[i] different";
783 }
784 if (p_GetComp(p, currRing) != p_GetComp(t_p, tailRing))
785 return "Lm[0] different";
786 if (pNext(p) != pNext(t_p))
787 return "Lm.next different";
788 if (pGetCoeff(p) != pGetCoeff(t_p))
789 return "Lm.coeff different";
790 return NULL;
791}

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy strat)

Definition at line 1056 of file kutil.cc.

1057{
1058 int i;
1059 BOOLEAN ret = TRUE;
1060 for (i=0; i<=strat->sl; i++)
1061 {
1062 if (strat->S[i] != NULL &&
1063 strat->sevS[i] != pGetShortExpVector(strat->S[i]))
1064 {
1065 return dReportError("S[%d] wrong sev: has %o, specified to have %o",
1066 i , pGetShortExpVector(strat->S[i]), strat->sevS[i]);
1067 }
1068 }
1069 return ret;
1070}

◆ kTest_T()

BOOLEAN kTest_T ( TObject * T,
kStrategy strat,
int i,
char TN )

Definition at line 796 of file kutil.cc.

797{
798 ring tailRing = T->tailRing;
799 ring strat_tailRing = strat->tailRing;
800 if (strat_tailRing == NULL) strat_tailRing = tailRing;
801 r_assume(strat_tailRing == tailRing);
802
803 poly p = T->p;
804 // ring r = currRing;
805
806 if (T->p == NULL && T->t_p == NULL && i >= 0)
807 return dReportError("%c[%d].poly is NULL", TN, i);
808
809 if (T->p!=NULL)
810 {
811 nTest(pGetCoeff(T->p));
812 if ((T->t_p==NULL)&&(pNext(T->p)!=NULL)) p_Test(pNext(T->p),currRing);
813 }
814 if (T->t_p!=NULL)
815 {
816 nTest(pGetCoeff(T->t_p));
817 if (pNext(T->t_p)!=NULL) p_Test(pNext(T->t_p),strat_tailRing);
818 }
819 if ((T->p!=NULL)&&(T->t_p!=NULL)) assume(pGetCoeff(T->p)==pGetCoeff(T->t_p));
820
821 if (T->tailRing != currRing)
822 {
823 if (T->t_p == NULL && i > 0)
824 return dReportError("%c[%d].t_p is NULL", TN, i);
825 pFalseReturn(p_Test(T->t_p, T->tailRing));
826 if (T->p != NULL) pFalseReturn(p_LmTest(T->p, currRing));
827 if ((T->p != NULL) && (T->t_p != NULL))
828 {
829 const char* msg = kTest_LmEqual(T->p, T->t_p, T->tailRing);
830 if (msg != NULL)
831 return dReportError("%c[%d] %s", TN, i, msg);
832 // r = T->tailRing;
833 p = T->t_p;
834 }
835 if (T->p == NULL)
836 {
837 p = T->t_p;
838 // r = T->tailRing;
839 }
840 if (T->t_p != NULL && i >= 0 && TN == 'T')
841 {
842 if (pNext(T->t_p) == NULL)
843 {
844 if (T->max_exp != NULL)
845 return dReportError("%c[%d].max_exp is not NULL as it should be", TN, i);
846 }
847 else
848 {
849 if (T->max_exp == NULL)
850 return dReportError("%c[%d].max_exp is NULL", TN, i);
851 if (pNext(T->max_exp) != NULL)
852 return dReportError("pNext(%c[%d].max_exp) != NULL", TN, i);
853
854 pFalseReturn(p_CheckPolyRing(T->max_exp, tailRing));
855 omCheckBinAddrSize(T->max_exp, (omSizeWOfBin(tailRing->PolyBin))*SIZEOF_LONG);
856#if KDEBUG > 0
857 if (! sloppy_max)
858 {
859 poly test_max = p_GetMaxExpP(pNext(T->t_p), tailRing);
860 p_Setm(T->max_exp, tailRing);
861 p_Setm(test_max, tailRing);
862 BOOLEAN equal = p_ExpVectorEqual(T->max_exp, test_max, tailRing);
863 if (! equal)
864 return dReportError("%c[%d].max out of sync", TN, i);
865 p_LmFree(test_max, tailRing);
866 }
867#endif
868 }
869 }
870 }
871 else
872 {
873 if (T->p == NULL && i > 0)
874 return dReportError("%c[%d].p is NULL", TN, i);
875#ifdef HAVE_SHIFTBBA
876 if (currRing->isLPring && T->shift > 0)
877 {
878 // in this case, the order is not correct. test LM and tail separately
881 }
882 else
883#endif
884 {
886 }
887 }
888
889 if ((i >= 0) && (T->pLength != 0)
890 && (! rIsSyzIndexRing(currRing)) && (T->pLength != pLength(p)))
891 {
892 int l=T->pLength;
893 T->pLength=pLength(p);
894 return dReportError("%c[%d] pLength error: has %d, specified to have %d",
895 TN, i , pLength(p), l);
896 }
897
898 // check FDeg, for elements in L and T
899 if (i >= 0 && (TN == 'T' || TN == 'L'))
900 {
901 // FDeg has ir element from T of L set
902 if (strat->homog && (T->FDeg != T->pFDeg()))
903 {
904 int d=T->FDeg;
905 T->FDeg=T->pFDeg();
906 return dReportError("%c[%d] FDeg error: has %d, specified to have %d",
907 TN, i , T->pFDeg(), d);
908 }
909 }
910
911 // check is_normalized for elements in T
912 if (i >= 0 && TN == 'T')
913 {
914 if (T->is_normalized && ! nIsOne(pGetCoeff(p)))
915 return dReportError("T[%d] is_normalized error", i);
916
917 }
918 return TRUE;
919}
bool equal
Definition cfModGcd.cc:4134
static const char * kTest_LmEqual(poly p, poly t_p, ring tailRing)
Definition kutil.cc:776
#define omCheckBinAddrSize(addr, size)
#define omSizeWOfBin(bin_ptr)
static BOOLEAN p_ExpVectorEqual(poly p1, poly p2, const ring r1, const ring r2)
Definition p_polys.cc:4635
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition pDebug.cc:115

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy strat)

Definition at line 1074 of file kutil.cc.

1075{
1076 int i, j;
1077 // BOOLEAN ret = TRUE;
1078 kFalseReturn(kTest(strat));
1079
1080 // test strat->R, strat->T[i].i_r
1081 for (i=0; i<=strat->tl; i++)
1082 {
1083 if (strat->T[i].i_r < 0 || strat->T[i].i_r > strat->tl)
1084 return dReportError("strat->T[%d].i_r == %d out of bounds", i,
1085 strat->T[i].i_r);
1086 if (strat->R[strat->T[i].i_r] != &(strat->T[i]))
1087 return dReportError("T[%d].i_r with R out of sync", i);
1088 }
1089 // test containment of S inT
1090 if ((strat->S != NULL)&&(strat->tl>=0))
1091 {
1092 for (i=0; i<=strat->sl; i++)
1093 {
1094 j = kFindInT(strat->S[i], strat->T, strat->tl);
1095 if (j < 0)
1096 return dReportError("S[%d] not in T", i);
1097 if (strat->S_2_R[i] != strat->T[j].i_r)
1098 return dReportError("S_2_R[%d]=%d != T[%d].i_r=%d\n",
1099 i, strat->S_2_R[i], j, strat->T[j].i_r);
1100 }
1101 }
1102 // test strat->L[i].i_r1
1103 #ifdef HAVE_SHIFTBBA
1104 if (!rIsLPRing(currRing)) // in the Letterplace ring we currently don't set/use i_r1 and i_r2
1105 #endif
1106 if (strat->L!=NULL)
1107 {
1108 for (i=0; i<=strat->Ll; i++)
1109 {
1110 if (strat->L[i].p1 != NULL && strat->L[i].p2)
1111 {
1112 if (strat->L[i].i_r1 < 0 ||
1113 strat->L[i].i_r1 > strat->tl ||
1114 strat->L[i].T_1(strat)->p != strat->L[i].p1)
1115 return dReportError("L[%d].i_r1 out of sync", i);
1116 if (strat->L[i].i_r2 < 0 ||
1117 strat->L[i].i_r2 > strat->tl ||
1118 strat->L[i].T_2(strat)->p != strat->L[i].p2)
1119 return dReportError("L[%d].i_r2 out of sync", i);
1120 }
1121 else
1122 {
1123 if (strat->L[i].i_r1 != -1)
1124 return dReportError("L[%d].i_r1 out of sync", i);
1125 if (strat->L[i].i_r2 != -1)
1126 return dReportError("L[%d].i_r2 out of sync", i);
1127 }
1128 if (strat->L[i].i_r != -1)
1129 return dReportError("L[%d].i_r out of sync", i);
1130 }
1131 }
1132 return TRUE;
1133}
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1011

◆ message()

void message ( int i,
int * reduc,
int * olddeg,
kStrategy strat,
int red_result )

Definition at line 7467 of file kutil.cc.

7468{
7469 if (i != *olddeg)
7470 {
7471 Print("%d",i);
7472 *olddeg = i;
7473 }
7474 if (TEST_OPT_OLDSTD)
7475 {
7476 if (strat->Ll != *reduc)
7477 {
7478 if (strat->Ll != *reduc-1)
7479 Print("(%d)",strat->Ll+1);
7480 else
7481 PrintS("-");
7482 *reduc = strat->Ll;
7483 }
7484 else
7485 PrintS(".");
7486 mflush();
7487 }
7488 else
7489 {
7490 if (red_result == 0)
7491 PrintS("-");
7492 else if (red_result < 0)
7493 PrintS(".");
7494 if ((red_result > 0) || ((strat->Ll % 100)==99))
7495 {
7496 if (strat->Ll != *reduc && strat->Ll > 0)
7497 {
7498 Print("(%d)",strat->Ll+1);
7499 *reduc = strat->Ll;
7500 }
7501 }
7502 }
7503}

◆ messageSets()

void messageSets ( kStrategy strat)

Definition at line 7540 of file kutil.cc.

7541{
7542 int i;
7543 if (strat->news)
7544 {
7545 PrintS("set S");
7546 for (i=0; i<=strat->sl; i++)
7547 {
7548 Print("\n %d:",i);
7549 p_wrp(strat->S[i], currRing, strat->tailRing);
7550 if (strat->fromQ!=NULL && strat->fromQ[i])
7551 Print(" (from Q)");
7552 }
7553 strat->news = FALSE;
7554 }
7555 if (strat->newt)
7556 {
7557 PrintS("\nset T");
7558 for (i=0; i<=strat->tl; i++)
7559 {
7560 Print("\n %d:",i);
7561 strat->T[i].wrp();
7562 if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7563 Print(" o:%ld e:%d l:%d",
7564 strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7565 }
7566 strat->newt = FALSE;
7567 }
7568 PrintS("\nset L");
7569 for (i=strat->Ll; i>=0; i--)
7570 {
7571 Print("\n%d:",i);
7572 p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7573 PrintS(" ");
7574 p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7575 PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7576 PrintS("\n p : ");
7577 strat->L[i].wrp();
7578 Print(" o:%ld e:%d l:%d",
7579 strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7580 }
7581 PrintLn();
7582}

◆ messageStat()

void messageStat ( int hilbcount,
kStrategy strat )

Definition at line 7508 of file kutil.cc.

7509{
7510 //PrintS("\nUsage/Allocation of temporary storage:\n");
7511 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7512 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7513 Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7514 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7515 #ifdef HAVE_SHIFTBBA
7516 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7517 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7518 #endif
7519}

◆ messageStatSBA()

void messageStatSBA ( int hilbcount,
kStrategy strat )

Definition at line 7521 of file kutil.cc.

7522{
7523 //PrintS("\nUsage/Allocation of temporary storage:\n");
7524 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7525 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7526 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7527 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7528 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7529 #ifdef HAVE_SHIFTBBA
7530 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7531 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7532 #endif
7533}
int nrsyzcrit
Definition kutil.h:360

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy strat)

Definition at line 10409 of file kutil.cc.

10410{
10411 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10412 return FALSE;
10413 int i,j;
10414 poly newNoether;
10415
10416#if 0
10417 if (currRing->weight_all_1)
10418 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10419 else
10420 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10421#else
10422 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10423#endif
10424 if (strat->kNoether==NULL) return FALSE;
10425 if (strat->t_kNoether != NULL)
10426 {
10427 p_LmFree(strat->t_kNoether, strat->tailRing);
10428 strat->t_kNoether=NULL;
10429 }
10430 if (strat->tailRing != currRing)
10432 /* compare old and new noether*/
10433 newNoether = pLmInit(strat->kNoether);
10434 pSetCoeff0(newNoether,nInit(1));
10435 j = p_FDeg(newNoether,currRing);
10436 for (i=1; i<=(currRing->N); i++)
10437 {
10438 if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10439 }
10440 pSetm(newNoether);
10441 if (j < HCord) /*- statistics -*/
10442 {
10443 if (TEST_OPT_PROT)
10444 {
10445 Print("H(%d)",j);
10446 mflush();
10447 }
10448 HCord=j;
10449 #ifdef KDEBUG
10450 if (TEST_OPT_DEBUG)
10451 {
10452 Print("H(%d):",j);
10453 wrp(strat->kNoether);
10454 PrintLn();
10455 }
10456 #endif
10457 }
10458 if (pCmp(strat->kNoether,newNoether)!=1)
10459 {
10460 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10461 strat->kNoether=newNoether;
10462 if (strat->t_kNoether != NULL)
10463 {
10464 p_LmFree(strat->t_kNoether, strat->tailRing);
10465 strat->t_kNoether=NULL;
10466 }
10467 if (strat->tailRing != currRing)
10469
10470 return TRUE;
10471 }
10472 pLmDelete(newNoether);
10473 return FALSE;
10474}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition hdegree.cc:1074
VAR int HCord
Definition kutil.cc:239
static void p_LmDelete0(poly p, const ring r)
Definition p_polys.h:735
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition polys.h:116
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65
#define pDecrExp(p, i)
Definition polys.h:45

◆ p_HasNotCF_Lift()

static BOOLEAN p_HasNotCF_Lift ( poly p1,
poly p2,
const ring r )
inlinestatic

p_HasNotCF for the IDLIFT case and syzComp==1: ignore component

Definition at line 2209 of file kutil.cc.

2210{
2211 int i = rVar(r);
2212 loop
2213 {
2214 if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
2215 return FALSE;
2216 i--;
2217 if (i == 0)
2218 return TRUE;
2219 }
2220}

◆ pDivComp()

static int pDivComp ( poly p,
poly q )
inlinestatic

Definition at line 176 of file kutil.cc.

177{
178 if ((currRing->pCompIndex < 0)
180 {
181#ifdef HAVE_RATGRING
183 {
185 q,currRing,
186 currRing->real_var_start, currRing->real_var_end))
187 return 0;
188 return pLmCmp(q,p); // ONLY FOR GLOBAL ORDER!
189 }
190#endif
191 BOOLEAN a=FALSE, b=FALSE;
192 int i;
193 unsigned long la, lb;
194 unsigned long divmask = currRing->divmask;
195 for (i=0; i<currRing->VarL_Size; i++)
196 {
197 la = p->exp[currRing->VarL_Offset[i]];
198 lb = q->exp[currRing->VarL_Offset[i]];
199 if (la != lb)
200 {
201 if (la < lb)
202 {
203 if (b) return 0;
204 if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))
205 return 0;
206 a = TRUE;
207 }
208 else
209 {
210 if (a) return 0;
211 if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask))
212 return 0;
213 b = TRUE;
214 }
215 }
216 }
217 if (a) { /*assume(pLmCmp(q,p)==1);*/ return 1; }
218 if (b) { /*assume(pLmCmp(q,p)==-1);*/return -1; }
219 /*assume(pLmCmp(q,p)==0);*/
220 }
221 return 0;
222}
CanonicalForm b
Definition cfModGcd.cc:4111

◆ pDivCompRing()

static int pDivCompRing ( poly p,
poly q )
inlinestatic

Definition at line 138 of file kutil.cc.

139{
140 if ((currRing->pCompIndex < 0)
142 {
143 BOOLEAN a=FALSE, b=FALSE;
144 int i;
145 unsigned long la, lb;
146 unsigned long divmask = currRing->divmask;
147 for (i=0; i<currRing->VarL_Size; i++)
148 {
149 la = p->exp[currRing->VarL_Offset[i]];
150 lb = q->exp[currRing->VarL_Offset[i]];
151 if (la != lb)
152 {
153 if (la < lb)
154 {
155 if (b) return pDivComp_INCOMP;
156 if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))
157 return pDivComp_INCOMP;
158 a = TRUE;
159 }
160 else
161 {
162 if (a) return pDivComp_INCOMP;
163 if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask))
164 return pDivComp_INCOMP;
165 b = TRUE;
166 }
167 }
168 }
169 if (a) return pDivComp_LESS;
170 if (b) return pDivComp_GREATER;
171 if (!a & !b) return pDivComp_EQUAL;
172 }
173 return pDivComp_INCOMP;
174}
#define pDivComp_INCOMP
Definition kutil.cc:132

◆ pLPDivComp()

static int pLPDivComp ( poly p,
poly q )
inlinestatic

Definition at line 225 of file kutil.cc.

226{
227 if ((currRing->pCompIndex < 0) || (__p_GetComp(p,currRing) == __p_GetComp(q,currRing)))
228 {
229 // maybe there is a more performant way to do this? This will get called quite often in bba.
230 if (_p_LPLmDivisibleByNoComp(p, q, currRing)) return 1;
231 if (_p_LPLmDivisibleByNoComp(q, p, currRing)) return -1;
232 }
233
234 return 0;
235}
BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r)
Definition shiftop.cc:796

◆ posInIdealMonFirst()

int posInIdealMonFirst ( const ideal F,
const poly p,
int start,
int end )

Definition at line 4848 of file kutil.cc.

4849{
4850 if(end < 0 || end >= IDELEMS(F))
4851 end = IDELEMS(F);
4852 if (end<0) return 0;
4853 if(pNext(p) == NULL) return start;
4854 polyset set=F->m;
4855 int o = p_Deg(p,currRing);
4856 int op;
4857 int i;
4858 int an = start;
4859 for(i=start;i<end;i++)
4860 if(set[i] != NULL && pNext(set[i]) == NULL)
4861 an++;
4862 if(an == end-1)
4863 return end;
4864 int en= end;
4865 loop
4866 {
4867 if(an>=en)
4868 return en;
4869 if (an == en-1)
4870 {
4871 op = p_Deg(set[an],currRing);
4872 if ((op < o)
4873 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4874 return en;
4875 return an;
4876 }
4877 i=(an+en) / 2;
4878 op = p_Deg(set[i],currRing);
4879 if ((op < o)
4880 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4881 an=i;
4882 else
4883 en=i;
4884 }
4885}
poly * polyset
Definition polys.h:260

◆ posInL0()

int posInL0 ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5618 of file kutil.cc.

5620{
5621 if (length<0) return 0;
5622
5623 int cmp_int=currRing->OrdSgn;
5624
5625 if (pLmCmp(set[length].p,p->p)== cmp_int)
5626 return length+1;
5627
5628 int i;
5629 int an = 0;
5630 int en= length;
5631 loop
5632 {
5633 if (an >= en-1)
5634 {
5635 if (pLmCmp(set[an].p,p->p) == cmp_int) return en;
5636 return an;
5637 }
5638 i=(an+en) / 2;
5639 if (pLmCmp(set[i].p,p->p) == cmp_int) an=i;
5640 else en=i;
5641 /*aend. fuer lazy == in !=- machen */
5642 }
5643}

◆ posInL0Ring()

int posInL0Ring ( const LSet set,
const int length,
LObject * p,
const kStrategy  )

Definition at line 5645 of file kutil.cc.

5647{
5648 if (length<0) return 0;
5649
5650 if (pLtCmpOrdSgnEqP(set[length].p,p->p))
5651 return length+1;
5652
5653 int i;
5654 int an = 0;
5655 int en= length;
5656 loop
5657 {
5658 if (an >= en-1)
5659 {
5660 if (pLtCmpOrdSgnEqP(set[an].p,p->p)) return en;
5661 return an;
5662 }
5663 i=(an+en) / 2;
5664 if (pLtCmpOrdSgnEqP(set[i].p,p->p)) an=i;
5665 else en=i;
5666 /*aend. fuer lazy == in !=- machen */
5667 }
5668}
#define pLtCmpOrdSgnEqP(p, q)
Definition polys.h:129

◆ posInL11()

int posInL11 ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5806 of file kutil.cc.

5808{
5809 if (length<0) return 0;
5810
5811 int o = p->GetpFDeg();
5812 int op = set[length].GetpFDeg();
5813 int cmp_int= -currRing->OrdSgn;
5814
5815 if ((op > o)
5816 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
5817 return length+1;
5818 int i;
5819 int an = 0;
5820 int en= length;
5821 loop
5822 {
5823 if (an >= en-1)
5824 {
5825 op = set[an].GetpFDeg();
5826 if ((op > o)
5827 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
5828 return en;
5829 return an;
5830 }
5831 i=(an+en) / 2;
5832 op = set[i].GetpFDeg();
5833 if ((op > o)
5834 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
5835 an=i;
5836 else
5837 en=i;
5838 }
5839}

◆ posInL110()

int posInL110 ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 6062 of file kutil.cc.

6064{
6065 if (length<0) return 0;
6066
6067 int o = p->GetpFDeg();
6068 int op = set[length].GetpFDeg();
6069 int cmp_int= -currRing->OrdSgn;
6070
6071 if ((op > o)
6072 || ((op == o) && (set[length].length >p->length))
6073 || ((op == o) && (set[length].length <= p->length)
6074 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6075 return length+1;
6076 int i;
6077 int an = 0;
6078 int en= length;
6079 loop
6080 {
6081 if (an >= en-1)
6082 {
6083 op = set[an].GetpFDeg();
6084 if ((op > o)
6085 || ((op == o) && (set[an].length >p->length))
6086 || ((op == o) && (set[an].length <=p->length)
6087 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6088 return en;
6089 return an;
6090 }
6091 i=(an+en) / 2;
6092 op = set[i].GetpFDeg();
6093 if ((op > o)
6094 || ((op == o) && (set[i].length > p->length))
6095 || ((op == o) && (set[i].length <= p->length)
6096 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6097 an=i;
6098 else
6099 en=i;
6100 }
6101}

◆ posInL110Ring()

int posInL110Ring ( const LSet set,
const int length,
LObject * p,
const kStrategy  )

Definition at line 6103 of file kutil.cc.

6105{
6106 if (length<0) return 0;
6107
6108 int o = p->GetpFDeg();
6109 int op = set[length].GetpFDeg();
6110
6111 if ((op > o)
6112 || ((op == o) && (set[length].length >p->length))
6113 || ((op == o) && (set[length].length <= p->length)
6114 && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6115 return length+1;
6116 int i;
6117 int an = 0;
6118 int en= length;
6119 loop
6120 {
6121 if (an >= en-1)
6122 {
6123 op = set[an].GetpFDeg();
6124 if ((op > o)
6125 || ((op == o) && (set[an].length >p->length))
6126 || ((op == o) && (set[an].length <=p->length)
6127 && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6128 return en;
6129 return an;
6130 }
6131 i=(an+en) / 2;
6132 op = set[i].GetpFDeg();
6133 if ((op > o)
6134 || ((op == o) && (set[i].length > p->length))
6135 || ((op == o) && (set[i].length <= p->length)
6136 && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6137 an=i;
6138 else
6139 en=i;
6140 }
6141}
#define pLtCmpOrdSgnDiffM(p, q)
Definition polys.h:126

◆ posInL11Ring()

int posInL11Ring ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5848 of file kutil.cc.

5850{
5851 if (length<0) return 0;
5852
5853 int o = p->GetpFDeg();
5854 int op = set[length].GetpFDeg();
5855
5856 if ((op > o)
5857 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
5858 return length+1;
5859 int i;
5860 int an = 0;
5861 int en= length;
5862 loop
5863 {
5864 if (an >= en-1)
5865 {
5866 op = set[an].GetpFDeg();
5867 if ((op > o)
5868 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
5869 return en;
5870 return an;
5871 }
5872 i=(an+en) / 2;
5873 op = set[i].GetpFDeg();
5874 if ((op > o)
5875 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
5876 an=i;
5877 else
5878 en=i;
5879 }
5880}

◆ posInL11Ringls()

int posInL11Ringls ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5916 of file kutil.cc.

5918{
5919 if (length < 0) return 0;
5920 int an,en,i;
5921 an = 0;
5922 en = length+1;
5923 loop
5924 {
5925 if (an >= en-1)
5926 {
5927 if(an == en)
5928 return en;
5929 if (set[an].FDeg > p->FDeg)
5930 return en;
5931 if (set[an].FDeg < p->FDeg)
5932 return an;
5933 if (set[an].FDeg == p->FDeg)
5934 {
5935 number lcset,lcp;
5936 lcset = pGetCoeff(set[an].p);
5937 lcp = pGetCoeff(p->p);
5938 if(!nGreaterZero(lcset))
5939 {
5940 set[an].p=p_Neg(set[an].p,currRing);
5941 if (set[an].t_p!=NULL)
5942 pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
5943 lcset=pGetCoeff(set[an].p);
5944 }
5945 if(!nGreaterZero(lcp))
5946 {
5947 p->p=p_Neg(p->p,currRing);
5948 if (p->t_p!=NULL)
5949 pSetCoeff0(p->t_p,pGetCoeff(p->p));
5950 lcp=pGetCoeff(p->p);
5951 }
5952 if(nGreater(lcset, lcp))
5953 {
5954 return en;
5955 }
5956 else
5957 {
5958 return an;
5959 }
5960 }
5961 }
5962 i=(an+en) / 2;
5963 if (set[i].FDeg > p->FDeg)
5964 an=i;
5965 if (set[i].FDeg < p->FDeg)
5966 en=i;
5967 if (set[i].FDeg == p->FDeg)
5968 {
5969 number lcset,lcp;
5970 lcset = pGetCoeff(set[i].p);
5971 lcp = pGetCoeff(p->p);
5972 if(!nGreaterZero(lcset))
5973 {
5974 set[i].p=p_Neg(set[i].p,currRing);
5975 if (set[i].t_p!=NULL)
5976 pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
5977 lcset=pGetCoeff(set[i].p);
5978 }
5979 if(!nGreaterZero(lcp))
5980 {
5981 p->p=p_Neg(p->p,currRing);
5982 if (p->t_p!=NULL)
5983 pSetCoeff0(p->t_p,pGetCoeff(p->p));
5984 lcp=pGetCoeff(p->p);
5985 }
5986 if(nGreater(lcset, lcp))
5987 {
5988 an = i;
5989 }
5990 else
5991 {
5992 en = i;
5993 }
5994 }
5995 }
5996}
#define nGreater(a, b)
Definition numbers.h:28

◆ posInL13()

int posInL13 ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 6149 of file kutil.cc.

6151{
6152 if (length<0) return 0;
6153
6154 int o = p->GetpFDeg();
6155
6156 if (set[length].GetpFDeg() > o)
6157 return length+1;
6158
6159 int i;
6160 int an = 0;
6161 int en= length;
6162 loop
6163 {
6164 if (an >= en-1)
6165 {
6166 if (set[an].GetpFDeg() >= o)
6167 return en;
6168 return an;
6169 }
6170 i=(an+en) / 2;
6171 if (set[i].GetpFDeg() >= o)
6172 an=i;
6173 else
6174 en=i;
6175 }
6176}

◆ posInL15()

int posInL15 ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 6184 of file kutil.cc.

6186{
6187 if (length<0) return 0;
6188
6189 int o = p->GetpFDeg() + p->ecart;
6190 int op = set[length].GetpFDeg() + set[length].ecart;
6191 int cmp_int= -currRing->OrdSgn;
6192
6193 if ((op > o)
6194 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
6195 return length+1;
6196 int i;
6197 int an = 0;
6198 int en= length;
6199 loop
6200 {
6201 if (an >= en-1)
6202 {
6203 op = set[an].GetpFDeg() + set[an].ecart;
6204 if ((op > o)
6205 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
6206 return en;
6207 return an;
6208 }
6209 i=(an+en) / 2;
6210 op = set[i].GetpFDeg() + set[i].ecart;
6211 if ((op > o)
6212 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
6213 an=i;
6214 else
6215 en=i;
6216 }
6217}

◆ posInL15Ring()

int posInL15Ring ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 6219 of file kutil.cc.

6221{
6222 if (length<0) return 0;
6223
6224 int o = p->GetpFDeg() + p->ecart;
6225 int op = set[length].GetpFDeg() + set[length].ecart;
6226
6227 if ((op > o)
6228 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6229 return length+1;
6230 int i;
6231 int an = 0;
6232 int en= length;
6233 loop
6234 {
6235 if (an >= en-1)
6236 {
6237 op = set[an].GetpFDeg() + set[an].ecart;
6238 if ((op > o)
6239 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6240 return en;
6241 return an;
6242 }
6243 i=(an+en) / 2;
6244 op = set[i].GetpFDeg() + set[i].ecart;
6245 if ((op > o)
6246 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6247 an=i;
6248 else
6249 en=i;
6250 }
6251}

◆ posInL17()

int posInL17 ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 6259 of file kutil.cc.

6261{
6262 if (length<0) return 0;
6263
6264 int o = p->GetpFDeg() + p->ecart;
6265 int cmp_int= -currRing->OrdSgn;
6266
6267 if ((set[length].GetpFDeg() + set[length].ecart > o)
6268 || ((set[length].GetpFDeg() + set[length].ecart == o)
6269 && (set[length].ecart > p->ecart))
6270 || ((set[length].GetpFDeg() + set[length].ecart == o)
6271 && (set[length].ecart == p->ecart)
6272 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6273 return length+1;
6274 int i;
6275 int an = 0;
6276 int en= length;
6277 loop
6278 {
6279 if (an >= en-1)
6280 {
6281 if ((set[an].GetpFDeg() + set[an].ecart > o)
6282 || ((set[an].GetpFDeg() + set[an].ecart == o)
6283 && (set[an].ecart > p->ecart))
6284 || ((set[an].GetpFDeg() + set[an].ecart == o)
6285 && (set[an].ecart == p->ecart)
6286 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6287 return en;
6288 return an;
6289 }
6290 i=(an+en) / 2;
6291 if ((set[i].GetpFDeg() + set[i].ecart > o)
6292 || ((set[i].GetpFDeg() + set[i].ecart == o)
6293 && (set[i].ecart > p->ecart))
6294 || ((set[i].GetpFDeg() +set[i].ecart == o)
6295 && (set[i].ecart == p->ecart)
6296 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6297 an=i;
6298 else
6299 en=i;
6300 }
6301}

◆ posInL17_c()

int posInL17_c ( const LSet set,
const int length,
LObject * p,
const kStrategy  )

Definition at line 6352 of file kutil.cc.

6354{
6355 if (length<0) return 0;
6356
6357 int cc = (-1+2*currRing->order[0]==ringorder_c);
6358 /* cc==1 for (c,..), cc==-1 for (C,..) */
6359 long c = pGetComp(p->p)*cc;
6360 int o = p->GetpFDeg() + p->ecart;
6361 int cmp_int= -currRing->OrdSgn;
6362
6363 if (pGetComp(set[length].p)*cc > c)
6364 return length+1;
6365 if (pGetComp(set[length].p)*cc == c)
6366 {
6367 if ((set[length].GetpFDeg() + set[length].ecart > o)
6368 || ((set[length].GetpFDeg() + set[length].ecart == o)
6369 && (set[length].ecart > p->ecart))
6370 || ((set[length].GetpFDeg() + set[length].ecart == o)
6371 && (set[length].ecart == p->ecart)
6372 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6373 return length+1;
6374 }
6375 int i;
6376 int an = 0;
6377 int en= length;
6378 loop
6379 {
6380 if (an >= en-1)
6381 {
6382 if (pGetComp(set[an].p)*cc > c)
6383 return en;
6384 if (pGetComp(set[an].p)*cc == c)
6385 {
6386 if ((set[an].GetpFDeg() + set[an].ecart > o)
6387 || ((set[an].GetpFDeg() + set[an].ecart == o)
6388 && (set[an].ecart > p->ecart))
6389 || ((set[an].GetpFDeg() + set[an].ecart == o)
6390 && (set[an].ecart == p->ecart)
6391 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6392 return en;
6393 }
6394 return an;
6395 }
6396 i=(an+en) / 2;
6397 if (pGetComp(set[i].p)*cc > c)
6398 an=i;
6399 else if (pGetComp(set[i].p)*cc == c)
6400 {
6401 if ((set[i].GetpFDeg() + set[i].ecart > o)
6402 || ((set[i].GetpFDeg() + set[i].ecart == o)
6403 && (set[i].ecart > p->ecart))
6404 || ((set[i].GetpFDeg() +set[i].ecart == o)
6405 && (set[i].ecart == p->ecart)
6406 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6407 an=i;
6408 else
6409 en=i;
6410 }
6411 else
6412 en=i;
6413 }
6414}

◆ posInL17_cRing()

int posInL17_cRing ( const LSet set,
const int length,
LObject * p,
const kStrategy  )

Definition at line 6416 of file kutil.cc.

6418{
6419 if (length<0) return 0;
6420
6421 int cc = (-1+2*currRing->order[0]==ringorder_c);
6422 /* cc==1 for (c,..), cc==-1 for (C,..) */
6423 long c = pGetComp(p->p)*cc;
6424 int o = p->GetpFDeg() + p->ecart;
6425
6426 if (pGetComp(set[length].p)*cc > c)
6427 return length+1;
6428 if (pGetComp(set[length].p)*cc == c)
6429 {
6430 if ((set[length].GetpFDeg() + set[length].ecart > o)
6431 || ((set[length].GetpFDeg() + set[length].ecart == o)
6432 && (set[length].ecart > p->ecart))
6433 || ((set[length].GetpFDeg() + set[length].ecart == o)
6434 && (set[length].ecart == p->ecart)
6435 && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6436 return length+1;
6437 }
6438 int i;
6439 int an = 0;
6440 int en= length;
6441 loop
6442 {
6443 if (an >= en-1)
6444 {
6445 if (pGetComp(set[an].p)*cc > c)
6446 return en;
6447 if (pGetComp(set[an].p)*cc == c)
6448 {
6449 if ((set[an].GetpFDeg() + set[an].ecart > o)
6450 || ((set[an].GetpFDeg() + set[an].ecart == o)
6451 && (set[an].ecart > p->ecart))
6452 || ((set[an].GetpFDeg() + set[an].ecart == o)
6453 && (set[an].ecart == p->ecart)
6454 && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6455 return en;
6456 }
6457 return an;
6458 }
6459 i=(an+en) / 2;
6460 if (pGetComp(set[i].p)*cc > c)
6461 an=i;
6462 else if (pGetComp(set[i].p)*cc == c)
6463 {
6464 if ((set[i].GetpFDeg() + set[i].ecart > o)
6465 || ((set[i].GetpFDeg() + set[i].ecart == o)
6466 && (set[i].ecart > p->ecart))
6467 || ((set[i].GetpFDeg() +set[i].ecart == o)
6468 && (set[i].ecart == p->ecart)
6469 && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6470 an=i;
6471 else
6472 en=i;
6473 }
6474 else
6475 en=i;
6476 }
6477}

◆ posInL17Ring()

int posInL17Ring ( const LSet set,
const int length,
LObject * p,
const kStrategy  )

Definition at line 6303 of file kutil.cc.

6305{
6306 if (length<0) return 0;
6307
6308 int o = p->GetpFDeg() + p->ecart;
6309
6310 if ((set[length].GetpFDeg() + set[length].ecart > o)
6311 || ((set[length].GetpFDeg() + set[length].ecart == o)
6312 && (set[length].ecart > p->ecart))
6313 || ((set[length].GetpFDeg() + set[length].ecart == o)
6314 && (set[length].ecart == p->ecart)
6315 && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6316 return length+1;
6317 int i;
6318 int an = 0;
6319 int en= length;
6320 loop
6321 {
6322 if (an >= en-1)
6323 {
6324 if ((set[an].GetpFDeg() + set[an].ecart > o)
6325 || ((set[an].GetpFDeg() + set[an].ecart == o)
6326 && (set[an].ecart > p->ecart))
6327 || ((set[an].GetpFDeg() + set[an].ecart == o)
6328 && (set[an].ecart == p->ecart)
6329 && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6330 return en;
6331 return an;
6332 }
6333 i=(an+en) / 2;
6334 if ((set[i].GetpFDeg() + set[i].ecart > o)
6335 || ((set[i].GetpFDeg() + set[i].ecart == o)
6336 && (set[i].ecart > p->ecart))
6337 || ((set[i].GetpFDeg() +set[i].ecart == o)
6338 && (set[i].ecart == p->ecart)
6339 && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6340 an=i;
6341 else
6342 en=i;
6343 }
6344}

◆ posInLF5C()

int posInLF5C ( const LSet set,
const int length,
LObject * L,
const kStrategy strat )

Definition at line 5794 of file kutil.cc.

5796{
5797 return strat->Ll+1;
5798}

◆ posInLF5CRing()

int posInLF5CRing ( const LSet set,
int start,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5882 of file kutil.cc.

5884{
5885 if (length<0) return 0;
5886 if(start == (length +1)) return (length+1);
5887 int o = p->GetpFDeg();
5888 int op = set[length].GetpFDeg();
5889
5890 if ((op > o)
5891 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
5892 return length+1;
5893 int i;
5894 int an = start;
5895 int en= length;
5896 loop
5897 {
5898 if (an >= en-1)
5899 {
5900 op = set[an].GetpFDeg();
5901 if ((op > o)
5902 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
5903 return en;
5904 return an;
5905 }
5906 i=(an+en) / 2;
5907 op = set[i].GetpFDeg();
5908 if ((op > o)
5909 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
5910 an=i;
5911 else
5912 en=i;
5913 }
5914}

◆ posInLSig()

int posInLSig ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5676 of file kutil.cc.

5678{
5679 if (length<0) return 0;
5680 int cmp_int=currRing->OrdSgn;
5681 if (pLtCmp(set[length].sig,p->sig)==cmp_int)
5682 return length+1;
5683
5684 int i;
5685 int an = 0;
5686 int en= length;
5687 loop
5688 {
5689 if (an >= en-1)
5690 {
5691 if (pLtCmp(set[an].sig,p->sig) == cmp_int) return en;
5692 return an;
5693 }
5694 i=(an+en) / 2;
5695 if (pLtCmp(set[i].sig,p->sig) == cmp_int) an=i;
5696 else en=i;
5697 /*aend. fuer lazy == in !=- machen */
5698 }
5699}

◆ posInLSigRing()

int posInLSigRing ( const LSet set,
const int length,
LObject * p,
const kStrategy strat )

Definition at line 5701 of file kutil.cc.

5703{
5704 assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
5705 if (length<0) return 0;
5706 if (pLtCmp(set[length].sig,p->sig)== 1)
5707 return length+1;
5708
5709 int an,en,i;
5710 an = 0;
5711 en = length+1;
5712 int cmp;
5713 loop
5714 {
5715 if (an >= en-1)
5716 {
5717 if(an == en)
5718 return en;
5719 cmp = pLtCmp(set[an].sig,p->sig);
5720 if (cmp == 1)
5721 return en;
5722 if (cmp == -1)
5723 return an;
5724 if (cmp == 0)
5725 {
5726 if (set[an].FDeg > p->FDeg)
5727 return en;
5728 if (set[an].FDeg < p->FDeg)
5729 return an;
5730 if (set[an].FDeg == p->FDeg)
5731 {
5732 cmp = pLtCmp(set[an].p,p->p);
5733 if(cmp == 1)
5734 return en;
5735 else
5736 return an;
5737 }
5738 }
5739 }
5740 i=(an+en) / 2;
5741 cmp = pLtCmp(set[i].sig,p->sig);
5742 if (cmp == 1)
5743 an = i;
5744 if (cmp == -1)
5745 en = i;
5746 if (cmp == 0)
5747 {
5748 if (set[i].FDeg > p->FDeg)
5749 an = i;
5750 if (set[i].FDeg < p->FDeg)
5751 en = i;
5752 if (set[i].FDeg == p->FDeg)
5753 {
5754 cmp = pLtCmp(set[i].p,p->p);
5755 if(cmp == 1)
5756 an = i;
5757 else
5758 en = i;
5759 }
5760 }
5761 }
5762}

◆ posInLSpecial()

int posInLSpecial ( const LSet set,
const int length,
LObject * p,
const kStrategy  )

Definition at line 5574 of file kutil.cc.

5576{
5577 if (length<0) return 0;
5578
5579 int d=p->GetpFDeg();
5580 int op=set[length].GetpFDeg();
5581 int cmp_int=currRing->OrdSgn;
5582
5583 if ((op > d)
5584 || ((op == d) && (p->p1!=NULL)&&(set[length].p1==NULL))
5585 || (pLmCmp(set[length].p,p->p)== cmp_int))
5586 return length+1;
5587
5588 int i;
5589 int an = 0;
5590 int en= length;
5591 loop
5592 {
5593 if (an >= en-1)
5594 {
5595 op=set[an].GetpFDeg();
5596 if ((op > d)
5597 || ((op == d) && (p->p1!=NULL) && (set[an].p1==NULL))
5598 || (pLmCmp(set[an].p,p->p)== cmp_int))
5599 return en;
5600 return an;
5601 }
5602 i=(an+en) / 2;
5603 op=set[i].GetpFDeg();
5604 if ((op>d)
5605 || ((op==d) && (p->p1!=NULL) && (set[i].p1==NULL))
5606 || (pLmCmp(set[i].p,p->p) == cmp_int))
5607 an=i;
5608 else
5609 en=i;
5610 }
5611}

◆ posInS()

int posInS ( const kStrategy strat,
const int length,
const poly p,
const int ecart_p )

Definition at line 4670 of file kutil.cc.

4672{
4673 if(length==-1) return 0;
4674 polyset set=strat->S;
4675 int i;
4676 int an = 0;
4677 int en = length;
4678 int cmp_int = currRing->OrdSgn;
4680#ifdef HAVE_PLURAL
4681 && (currRing->real_var_start==0)
4682#endif
4683#if 0
4684 || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
4685#endif
4686 )
4687 {
4688 int o=p_Deg(p,currRing);
4689 int oo=p_Deg(set[length],currRing);
4690
4691 if ((oo<o)
4692 || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
4693 return length+1;
4694
4695 loop
4696 {
4697 if (an >= en-1)
4698 {
4699 if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
4700 {
4701 return an;
4702 }
4703 return en;
4704 }
4705 i=(an+en) / 2;
4706 if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
4707 else an=i;
4708 }
4709 }
4710 else
4711 {
4713 {
4714 if (pLmCmp(set[length],p)== -cmp_int)
4715 return length+1;
4716 int cmp;
4717 loop
4718 {
4719 if (an >= en-1)
4720 {
4721 cmp = pLmCmp(set[an],p);
4722 if (cmp == cmp_int) return an;
4723 if (cmp == -cmp_int) return en;
4724 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
4725 return an;
4726 }
4727 i = (an+en) / 2;
4728 cmp = pLmCmp(set[i],p);
4729 if (cmp == cmp_int) en = i;
4730 else if (cmp == -cmp_int) an = i;
4731 else
4732 {
4733 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
4734 else en = i;
4735 }
4736 }
4737 }
4738 else
4739 if (pLmCmp(set[length],p)== -cmp_int)
4740 return length+1;
4741
4742 loop
4743 {
4744 if (an >= en-1)
4745 {
4746 if (pLmCmp(set[an],p) == cmp_int) return an;
4747 if (pLmCmp(set[an],p) == -cmp_int) return en;
4748 if ((cmp_int!=1)
4749 && ((strat->ecartS[an])>ecart_p))
4750 return an;
4751 return en;
4752 }
4753 i=(an+en) / 2;
4754 if (pLmCmp(set[i],p) == cmp_int) en=i;
4755 else if (pLmCmp(set[i],p) == -cmp_int) an=i;
4756 else
4757 {
4758 if ((cmp_int!=1)
4759 &&((strat->ecartS[i])<ecart_p))
4760 en=i;
4761 else
4762 an=i;
4763 }
4764 }
4765 }
4766}

◆ posInSMonFirst()

int posInSMonFirst ( const kStrategy strat,
const int length,
const poly p )

Definition at line 4771 of file kutil.cc.

4772{
4773 if (length<0) return 0;
4774 polyset set=strat->S;
4775 if(pNext(p) == NULL)
4776 {
4777 int mon = 0;
4778 for(int i = 0;i<=length;i++)
4779 {
4780 if(set[i] != NULL && pNext(set[i]) == NULL)
4781 mon++;
4782 }
4783 int o = p_Deg(p,currRing);
4784 int op = p_Deg(set[mon],currRing);
4785
4786 if ((op < o)
4787 || ((op == o) && (pLtCmp(set[mon],p) == -1)))
4788 return length+1;
4789 int i;
4790 int an = 0;
4791 int en= mon;
4792 loop
4793 {
4794 if (an >= en-1)
4795 {
4796 op = p_Deg(set[an],currRing);
4797 if ((op < o)
4798 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4799 return en;
4800 return an;
4801 }
4802 i=(an+en) / 2;
4803 op = p_Deg(set[i],currRing);
4804 if ((op < o)
4805 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4806 an=i;
4807 else
4808 en=i;
4809 }
4810 }
4811 else /*if(pNext(p) != NULL)*/
4812 {
4813 int o = p_Deg(p,currRing);
4814 int op = p_Deg(set[length],currRing);
4815
4816 if ((op < o)
4817 || ((op == o) && (pLtCmp(set[length],p) == -1)))
4818 return length+1;
4819 int i;
4820 int an = 0;
4821 for(i=0;i<=length;i++)
4822 if(set[i] != NULL && pNext(set[i]) == NULL)
4823 an++;
4824 int en= length;
4825 loop
4826 {
4827 if (an >= en-1)
4828 {
4829 op = p_Deg(set[an],currRing);
4830 if ((op < o)
4831 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4832 return en;
4833 return an;
4834 }
4835 i=(an+en) / 2;
4836 op = p_Deg(set[i],currRing);
4837 if ((op < o)
4838 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4839 an=i;
4840 else
4841 en=i;
4842 }
4843 }
4844}

◆ posInSyz()

int posInSyz ( const kStrategy strat,
poly sig )

Definition at line 5765 of file kutil.cc.

5766{
5767 if (strat->syzl==0) return 0;
5768 int cmp_int=currRing->OrdSgn;
5769 if (pLtCmp(strat->syz[strat->syzl-1],sig) != cmp_int)
5770 return strat->syzl;
5771 int i;
5772 int an = 0;
5773 int en= strat->syzl-1;
5774 loop
5775 {
5776 if (an >= en-1)
5777 {
5778 if (pLtCmp(strat->syz[an],sig) != cmp_int) return en;
5779 return an;
5780 }
5781 i=(an+en) / 2;
5782 if (pLtCmp(strat->syz[i],sig) != cmp_int) an=i;
5783 else en=i;
5784 /*aend. fuer lazy == in !=- machen */
5785 }
5786}

◆ posInT0()

int posInT0 ( const TSet set,
const int length,
LObject & p )

Definition at line 4892 of file kutil.cc.

4893{
4894 return (length+1);
4895}

◆ posInT1()

int posInT1 ( const TSet set,
const int length,
LObject & p )

Definition at line 4903 of file kutil.cc.

4904{
4905 if (length==-1) return 0;
4906
4907 if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
4908
4909 int i;
4910 int an = 0;
4911 int en= length;
4912 int cmp_int=currRing->OrdSgn;
4913
4914 loop
4915 {
4916 if (an >= en-1)
4917 {
4918 if (pLmCmp(set[an].p,p.p) == cmp_int) return an;
4919 return en;
4920 }
4921 i=(an+en) / 2;
4922 if (pLmCmp(set[i].p,p.p) == cmp_int) en=i;
4923 else an=i;
4924 }
4925}

◆ posInT11()

int posInT11 ( const TSet set,
const int length,
LObject & p )

Definition at line 4960 of file kutil.cc.

4961{
4962 if (length==-1) return 0;
4963
4964 int o = p.GetpFDeg();
4965 int op = set[length].GetpFDeg();
4966 int cmp_int=currRing->OrdSgn;
4967
4968 if ((op < o)
4969 || ((op == o) && (pLmCmp(set[length].p,p.p) != cmp_int)))
4970 return length+1;
4971
4972 int i;
4973 int an = 0;
4974 int en= length;
4975
4976 loop
4977 {
4978 if (an >= en-1)
4979 {
4980 op= set[an].GetpFDeg();
4981 if ((op > o)
4982 || (( op == o) && (pLmCmp(set[an].p,p.p) == cmp_int)))
4983 return an;
4984 return en;
4985 }
4986 i=(an+en) / 2;
4987 op = set[i].GetpFDeg();
4988 if (( op > o)
4989 || (( op == o) && (pLmCmp(set[i].p,p.p) == cmp_int)))
4990 en=i;
4991 else
4992 an=i;
4993 }
4994}

◆ posInT110()

int posInT110 ( const TSet set,
const int length,
LObject & p )

Definition at line 5036 of file kutil.cc.

5037{
5038 if (length==-1) return 0;
5039 p.GetpLength();
5040
5041 int o = p.GetpFDeg();
5042 int op = set[length].GetpFDeg();
5043 int cmp_int=currRing->OrdSgn;
5044
5045 if (( op < o)
5046 || (( op == o) && (set[length].length<p.length))
5047 || (( op == o) && (set[length].length == p.length)
5048 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5049 return length+1;
5050
5051 int i;
5052 int an = 0;
5053 int en= length;
5054 loop
5055 {
5056 if (an >= en-1)
5057 {
5058 op = set[an].GetpFDeg();
5059 if (( op > o)
5060 || (( op == o) && (set[an].length > p.length))
5061 || (( op == o) && (set[an].length == p.length)
5062 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5063 return an;
5064 return en;
5065 }
5066 i=(an+en) / 2;
5067 op = set[i].GetpFDeg();
5068 if (( op > o)
5069 || (( op == o) && (set[i].length > p.length))
5070 || (( op == o) && (set[i].length == p.length)
5071 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5072 en=i;
5073 else
5074 an=i;
5075 }
5076}

◆ posInT110Ring()

int posInT110Ring ( const TSet set,
const int length,
LObject & p )

Definition at line 5078 of file kutil.cc.

5079{
5080 if (length==-1) return 0;
5081 p.GetpLength();
5082
5083 int o = p.GetpFDeg();
5084 int op = set[length].GetpFDeg();
5085
5086 if (( op < o)
5087 || (( op == o) && (set[length].length<p.length))
5088 || (( op == o) && (set[length].length == p.length)
5089 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5090 return length+1;
5091
5092 int i;
5093 int an = 0;
5094 int en= length;
5095 loop
5096 {
5097 if (an >= en-1)
5098 {
5099 op = set[an].GetpFDeg();
5100 if (( op > o)
5101 || (( op == o) && (set[an].length > p.length))
5102 || (( op == o) && (set[an].length == p.length)
5103 && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5104 return an;
5105 return en;
5106 }
5107 i=(an+en) / 2;
5108 op = set[i].GetpFDeg();
5109 if (( op > o)
5110 || (( op == o) && (set[i].length > p.length))
5111 || (( op == o) && (set[i].length == p.length)
5112 && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5113 en=i;
5114 else
5115 an=i;
5116 }
5117}
#define pLtCmpOrdSgnDiffP(p, q)
Definition polys.h:127

◆ posInT11Ring()

int posInT11Ring ( const TSet set,
const int length,
LObject & p )

Definition at line 4996 of file kutil.cc.

4997{
4998 if (length==-1) return 0;
4999
5000 int o = p.GetpFDeg();
5001 int op = set[length].GetpFDeg();
5002
5003 if ((op < o)
5004 || ((op == o) && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5005 return length+1;
5006
5007 int i;
5008 int an = 0;
5009 int en= length;
5010
5011 loop
5012 {
5013 if (an >= en-1)
5014 {
5015 op= set[an].GetpFDeg();
5016 if ((op > o)
5017 || (( op == o) && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5018 return an;
5019 return en;
5020 }
5021 i=(an+en) / 2;
5022 op = set[i].GetpFDeg();
5023 if (( op > o)
5024 || (( op == o) && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5025 en=i;
5026 else
5027 an=i;
5028 }
5029}

◆ posInT13()

int posInT13 ( const TSet set,
const int length,
LObject & p )

Definition at line 5124 of file kutil.cc.

5125{
5126 if (length==-1) return 0;
5127
5128 int o = p.GetpFDeg();
5129
5130 if (set[length].GetpFDeg() <= o)
5131 return length+1;
5132
5133 int i;
5134 int an = 0;
5135 int en= length;
5136 loop
5137 {
5138 if (an >= en-1)
5139 {
5140 if (set[an].GetpFDeg() > o)
5141 return an;
5142 return en;
5143 }
5144 i=(an+en) / 2;
5145 if (set[i].GetpFDeg() > o)
5146 en=i;
5147 else
5148 an=i;
5149 }
5150}

◆ posInT15()

int posInT15 ( const TSet set,
const int length,
LObject & p )

Definition at line 5191 of file kutil.cc.

5210{
5211 if (length==-1) return 0;
5212
5213 int o = p.GetpFDeg() + p.ecart;
5214 int op = set[length].GetpFDeg()+set[length].ecart;
5215 int cmp_int=currRing->OrdSgn;
5216
5217 if ((op < o)
5218 || ((op == o)
5219 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5220 return length+1;
5221
5222 int i;
5223 int an = 0;
5224 int en= length;
5225 loop
5226 {
5227 if (an >= en-1)
5228 {
5229 op = set[an].GetpFDeg()+set[an].ecart;
5230 if (( op > o)
5231 || (( op == o) && (pLmCmp(set[an].p,p.p) == cmp_int)))
5232 return an;
5233 return en;
5234 }
5235 i=(an+en) / 2;
5236 op = set[i].GetpFDeg()+set[i].ecart;
5237 if (( op > o)
5238 || (( op == o) && (pLmCmp(set[i].p,p.p) == cmp_int)))
5239 en=i;
5240 else
5241 an=i;
5242 }
5243}

◆ posInT15Ring()

int posInT15Ring ( const TSet set,
const int length,
LObject & p )

Definition at line 5245 of file kutil.cc.

5246{
5247 if (length==-1) return 0;
5248
5249 int o = p.GetpFDeg() + p.ecart;
5250 int op = set[length].GetpFDeg()+set[length].ecart;
5251
5252 if ((op < o)
5253 || ((op == o)
5254 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5255 return length+1;
5256
5257 int i;
5258 int an = 0;
5259 int en= length;
5260 loop
5261 {
5262 if (an >= en-1)
5263 {
5264 op = set[an].GetpFDeg()+set[an].ecart;
5265 if (( op > o)
5266 || (( op == o) && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5267 return an;
5268 return en;
5269 }
5270 i=(an+en) / 2;
5271 op = set[i].GetpFDeg()+set[i].ecart;
5272 if (( op > o)
5273 || (( op == o) && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5274 en=i;
5275 else
5276 an=i;
5277 }
5278}

◆ posInT17()

int posInT17 ( const TSet set,
const int length,
LObject & p )

Definition at line 5285 of file kutil.cc.

5306{
5307 if (length==-1) return 0;
5308
5309 int o = p.GetpFDeg() + p.ecart;
5310 int op = set[length].GetpFDeg()+set[length].ecart;
5311 int cmp_int=currRing->OrdSgn;
5312
5313 if ((op < o)
5314 || (( op == o) && (set[length].ecart > p.ecart))
5315 || (( op == o) && (set[length].ecart==p.ecart)
5316 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5317 return length+1;
5318
5319 int i;
5320 int an = 0;
5321 int en= length;
5322 loop
5323 {
5324 if (an >= en-1)
5325 {
5326 op = set[an].GetpFDeg()+set[an].ecart;
5327 if (( op > o)
5328 || (( op == o) && (set[an].ecart < p.ecart))
5329 || (( op == o) && (set[an].ecart==p.ecart)
5330 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5331 return an;
5332 return en;
5333 }
5334 i=(an+en) / 2;
5335 op = set[i].GetpFDeg()+set[i].ecart;
5336 if ((op > o)
5337 || (( op == o) && (set[i].ecart < p.ecart))
5338 || (( op == o) && (set[i].ecart == p.ecart)
5339 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5340 en=i;
5341 else
5342 an=i;
5343 }
5344}

◆ posInT17_c()

int posInT17_c ( const TSet set,
const int length,
LObject & p )

Definition at line 5391 of file kutil.cc.

5392{
5393 if (length==-1) return 0;
5394
5395 int cc = (-1+2*currRing->order[0]==ringorder_c);
5396 /* cc==1 for (c,..), cc==-1 for (C,..) */
5397 int o = p.GetpFDeg() + p.ecart;
5398 int c = pGetComp(p.p)*cc;
5399 int cmp_int=currRing->OrdSgn;
5400
5401 if (pGetComp(set[length].p)*cc < c)
5402 return length+1;
5403 if (pGetComp(set[length].p)*cc == c)
5404 {
5405 int op = set[length].GetpFDeg()+set[length].ecart;
5406 if ((op < o)
5407 || ((op == o) && (set[length].ecart > p.ecart))
5408 || ((op == o) && (set[length].ecart==p.ecart)
5409 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5410 return length+1;
5411 }
5412
5413 int i;
5414 int an = 0;
5415 int en= length;
5416 loop
5417 {
5418 if (an >= en-1)
5419 {
5420 if (pGetComp(set[an].p)*cc < c)
5421 return en;
5422 if (pGetComp(set[an].p)*cc == c)
5423 {
5424 int op = set[an].GetpFDeg()+set[an].ecart;
5425 if ((op > o)
5426 || ((op == o) && (set[an].ecart < p.ecart))
5427 || ((op == o) && (set[an].ecart==p.ecart)
5428 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5429 return an;
5430 }
5431 return en;
5432 }
5433 i=(an+en) / 2;
5434 if (pGetComp(set[i].p)*cc > c)
5435 en=i;
5436 else if (pGetComp(set[i].p)*cc == c)
5437 {
5438 int op = set[i].GetpFDeg()+set[i].ecart;
5439 if ((op > o)
5440 || ((op == o) && (set[i].ecart < p.ecart))
5441 || ((op == o) && (set[i].ecart == p.ecart)
5442 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5443 en=i;
5444 else
5445 an=i;
5446 }
5447 else
5448 an=i;
5449 }
5450}

◆ posInT17_cRing()

int posInT17_cRing ( const TSet set,
const int length,
LObject & p )

Definition at line 5452 of file kutil.cc.

5453{
5454 if (length==-1) return 0;
5455
5456 int cc = (-1+2*currRing->order[0]==ringorder_c);
5457 /* cc==1 for (c,..), cc==-1 for (C,..) */
5458 int o = p.GetpFDeg() + p.ecart;
5459 int c = pGetComp(p.p)*cc;
5460
5461 if (pGetComp(set[length].p)*cc < c)
5462 return length+1;
5463 if (pGetComp(set[length].p)*cc == c)
5464 {
5465 int op = set[length].GetpFDeg()+set[length].ecart;
5466 if ((op < o)
5467 || ((op == o) && (set[length].ecart > p.ecart))
5468 || ((op == o) && (set[length].ecart==p.ecart)
5469 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5470 return length+1;
5471 }
5472
5473 int i;
5474 int an = 0;
5475 int en= length;
5476 loop
5477 {
5478 if (an >= en-1)
5479 {
5480 if (pGetComp(set[an].p)*cc < c)
5481 return en;
5482 if (pGetComp(set[an].p)*cc == c)
5483 {
5484 int op = set[an].GetpFDeg()+set[an].ecart;
5485 if ((op > o)
5486 || ((op == o) && (set[an].ecart < p.ecart))
5487 || ((op == o) && (set[an].ecart==p.ecart)
5488 && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5489 return an;
5490 }
5491 return en;
5492 }
5493 i=(an+en) / 2;
5494 if (pGetComp(set[i].p)*cc > c)
5495 en=i;
5496 else if (pGetComp(set[i].p)*cc == c)
5497 {
5498 int op = set[i].GetpFDeg()+set[i].ecart;
5499 if ((op > o)
5500 || ((op == o) && (set[i].ecart < p.ecart))
5501 || ((op == o) && (set[i].ecart == p.ecart)
5502 && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5503 en=i;
5504 else
5505 an=i;
5506 }
5507 else
5508 an=i;
5509 }
5510}

◆ posInT17Ring()

int posInT17Ring ( const TSet set,
const int length,
LObject & p )

Definition at line 5346 of file kutil.cc.

5347{
5348 if (length==-1) return 0;
5349
5350 int o = p.GetpFDeg() + p.ecart;
5351 int op = set[length].GetpFDeg()+set[length].ecart;
5352
5353 if ((op < o)
5354 || (( op == o) && (set[length].ecart > p.ecart))
5355 || (( op == o) && (set[length].ecart==p.ecart)
5356 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5357 return length+1;
5358
5359 int i;
5360 int an = 0;
5361 int en= length;
5362 loop
5363 {
5364 if (an >= en-1)
5365 {
5366 op = set[an].GetpFDeg()+set[an].ecart;
5367 if (( op > o)
5368 || (( op == o) && (set[an].ecart < p.ecart))
5369 || (( op == o) && (set[an].ecart==p.ecart)
5370 && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5371 return an;
5372 return en;
5373 }
5374 i=(an+en) / 2;
5375 op = set[i].GetpFDeg()+set[i].ecart;
5376 if ((op > o)
5377 || (( op == o) && (set[i].ecart < p.ecart))
5378 || (( op == o) && (set[i].ecart == p.ecart)
5379 && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5380 en=i;
5381 else
5382 an=i;
5383 }
5384}

◆ posInT19()

int posInT19 ( const TSet set,
const int length,
LObject & p )

Definition at line 5517 of file kutil.cc.

5518{
5519 p.GetpLength();
5520 if (length==-1) return 0;
5521
5522 int o = p.ecart;
5523 int op=p.GetpFDeg();
5524
5525 if (set[length].ecart < o)
5526 return length+1;
5527 if (set[length].ecart == o)
5528 {
5529 int oo=set[length].GetpFDeg();
5530 if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5531 return length+1;
5532 }
5533
5534 int i;
5535 int an = 0;
5536 int en= length;
5537 loop
5538 {
5539 if (an >= en-1)
5540 {
5541 if (set[an].ecart > o)
5542 return an;
5543 if (set[an].ecart == o)
5544 {
5545 int oo=set[an].GetpFDeg();
5546 if((oo > op)
5547 || ((oo==op) && (set[an].length > p.length)))
5548 return an;
5549 }
5550 return en;
5551 }
5552 i=(an+en) / 2;
5553 if (set[i].ecart > o)
5554 en=i;
5555 else if (set[i].ecart == o)
5556 {
5557 int oo=set[i].GetpFDeg();
5558 if ((oo > op)
5559 || ((oo == op) && (set[i].length > p.length)))
5560 en=i;
5561 else
5562 an=i;
5563 }
5564 else
5565 an=i;
5566 }
5567}

◆ posInT2()

int posInT2 ( const TSet set,
const int length,
LObject & p )

Definition at line 4932 of file kutil.cc.

4933{
4934 if (length==-1) return 0;
4935 p.GetpLength();
4936 if (set[length].length<p.length) return length+1;
4937
4938 int i;
4939 int an = 0;
4940 int en= length;
4941
4942 loop
4943 {
4944 if (an >= en-1)
4945 {
4946 if (set[an].length>p.length) return an;
4947 return en;
4948 }
4949 i=(an+en) / 2;
4950 if (set[i].length>p.length) en=i;
4951 else an=i;
4952 }
4953}

◆ posInT_EcartFDegpLength()

int posInT_EcartFDegpLength ( const TSet set,
const int length,
LObject & p )

Definition at line 11380 of file kutil.cc.

11381{
11382
11383 if (length==-1) return 0;
11384
11385 int o = p.ecart;
11386 int op=p.GetpFDeg();
11387 int ol = p.GetpLength();
11388
11389 if (set[length].ecart < o)
11390 return length+1;
11391 if (set[length].ecart == o)
11392 {
11393 int oo=set[length].GetpFDeg();
11394 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11395 return length+1;
11396 }
11397
11398 int i;
11399 int an = 0;
11400 int en= length;
11401 loop
11402 {
11403 if (an >= en-1)
11404 {
11405 if (set[an].ecart > o)
11406 return an;
11407 if (set[an].ecart == o)
11408 {
11409 int oo=set[an].GetpFDeg();
11410 if((oo > op)
11411 || ((oo==op) && (set[an].pLength > ol)))
11412 return an;
11413 }
11414 return en;
11415 }
11416 i=(an+en) / 2;
11417 if (set[i].ecart > o)
11418 en=i;
11419 else if (set[i].ecart == o)
11420 {
11421 int oo=set[i].GetpFDeg();
11422 if ((oo > op)
11423 || ((oo == op) && (set[i].pLength > ol)))
11424 en=i;
11425 else
11426 an=i;
11427 }
11428 else
11429 an=i;
11430 }
11431}

◆ posInT_EcartpLength()

int posInT_EcartpLength ( const TSet set,
const int length,
LObject & p )

Definition at line 5153 of file kutil.cc.

5154{
5155 if (length==-1) return 0;
5156 int ol = p.GetpLength();
5157 int op=p.ecart;
5158 int oo=set[length].ecart;
5159
5160 if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5161 return length+1;
5162
5163 int i;
5164 int an = 0;
5165 int en= length;
5166 loop
5167 {
5168 if (an >= en-1)
5169 {
5170 int oo=set[an].ecart;
5171 if((oo > op)
5172 || ((oo==op) && (set[an].pLength > ol)))
5173 return an;
5174 return en;
5175 }
5176 i=(an+en) / 2;
5177 int oo=set[i].ecart;
5178 if ((oo > op)
5179 || ((oo == op) && (set[i].pLength > ol)))
5180 en=i;
5181 else
5182 an=i;
5183 }
5184}

◆ posInT_FDegpLength()

int posInT_FDegpLength ( const TSet set,
const int length,
LObject & p )

Definition at line 11434 of file kutil.cc.

11435{
11436
11437 if (length==-1) return 0;
11438
11439 int op=p.GetpFDeg();
11440 int ol = p.GetpLength();
11441
11442 int oo=set[length].GetpFDeg();
11443 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11444 return length+1;
11445
11446 int i;
11447 int an = 0;
11448 int en= length;
11449 loop
11450 {
11451 if (an >= en-1)
11452 {
11453 int oo=set[an].GetpFDeg();
11454 if((oo > op)
11455 || ((oo==op) && (set[an].pLength > ol)))
11456 return an;
11457 return en;
11458 }
11459 i=(an+en) / 2;
11460 int oo=set[i].GetpFDeg();
11461 if ((oo > op)
11462 || ((oo == op) && (set[i].pLength > ol)))
11463 en=i;
11464 else
11465 an=i;
11466 }
11467}

◆ posInT_pLength()

int posInT_pLength ( const TSet set,
const int length,
LObject & p )

Definition at line 11471 of file kutil.cc.

11472{
11473 int ol = p.GetpLength();
11474 if (length==-1)
11475 return 0;
11476 if (set[length].length<p.length)
11477 return length+1;
11478
11479 int i;
11480 int an = 0;
11481 int en= length;
11482
11483 loop
11484 {
11485 if (an >= en-1)
11486 {
11487 if (set[an].pLength>ol) return an;
11488 return en;
11489 }
11490 i=(an+en) / 2;
11491 if (set[i].pLength>ol) en=i;
11492 else an=i;
11493 }
11494}

◆ postReduceByMon()

void postReduceByMon ( LObject * h,
kStrategy strat )

used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell

Definition at line 10704 of file kutil.cc.

10705{
10706 if(!nCoeff_is_Z(currRing->cf))
10707 return;
10708 poly pH = h->GetP();
10709 poly p,pp;
10710 p = pH;
10711 bool deleted = FALSE, ok = FALSE;
10712 for(int i = 0; i<=strat->sl; i++)
10713 {
10714 p = pH;
10715 if(pNext(strat->S[i]) == NULL)
10716 {
10717 //pWrite(p);
10718 //pWrite(strat->S[i]);
10719 while(ok == FALSE && p != NULL)
10720 {
10721 if(pLmDivisibleBy(strat->S[i], p)
10722#ifdef HAVE_SHIFTBBA
10723 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
10724#endif
10725 )
10726 {
10727 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10728 p_SetCoeff(p,dummy,currRing);
10729 }
10730 if(nIsZero(p->coef))
10731 {
10732 pLmDelete(&p);
10733 h->p = p;
10734 deleted = TRUE;
10735 }
10736 else
10737 {
10738 ok = TRUE;
10739 }
10740 }
10741 if (p!=NULL)
10742 {
10743 pp = pNext(p);
10744 while(pp != NULL)
10745 {
10746 if(pLmDivisibleBy(strat->S[i], pp)
10747#ifdef HAVE_SHIFTBBA
10748 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
10749#endif
10750 )
10751 {
10752 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10753 p_SetCoeff(pp,dummy,currRing);
10754 if(nIsZero(pp->coef))
10755 {
10756 pLmDelete(&pNext(p));
10757 pp = pNext(p);
10758 deleted = TRUE;
10759 }
10760 else
10761 {
10762 p = pp;
10763 pp = pNext(p);
10764 }
10765 }
10766 else
10767 {
10768 p = pp;
10769 pp = pNext(p);
10770 }
10771 }
10772 }
10773 }
10774 }
10775 h->SetLmCurrRing();
10776 if((deleted)&&(h->p!=NULL))
10777 strat->initEcart(h);
10778}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject * h,
kStrategy strat )

Definition at line 10780 of file kutil.cc.

10781{
10782 if(!nCoeff_is_Z(currRing->cf))
10783 return;
10784 poly hSig = h->sig;
10785 poly pH = h->GetP();
10786 poly p,pp;
10787 p = pH;
10788 bool deleted = FALSE, ok = FALSE;
10789 for(int i = 0; i<=strat->sl; i++)
10790 {
10791 p = pH;
10792 if(pNext(strat->S[i]) == NULL)
10793 {
10794 while(ok == FALSE && p!=NULL)
10795 {
10796 if(pLmDivisibleBy(strat->S[i], p))
10797 {
10798 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10799 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10800 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10801 {
10802 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10803 p_SetCoeff(p,dummy,currRing);
10804 }
10805 pDelete(&sigMult);
10806 }
10807 if(nIsZero(p->coef))
10808 {
10809 pLmDelete(&p);
10810 h->p = p;
10811 deleted = TRUE;
10812 }
10813 else
10814 {
10815 ok = TRUE;
10816 }
10817 }
10818 if(p == NULL)
10819 return;
10820 pp = pNext(p);
10821 while(pp != NULL)
10822 {
10823 if(pLmDivisibleBy(strat->S[i], pp))
10824 {
10825 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10826 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10827 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10828 {
10829 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10830 p_SetCoeff(pp,dummy,currRing);
10831 if(nIsZero(pp->coef))
10832 {
10833 pLmDelete(&pNext(p));
10834 pp = pNext(p);
10835 deleted = TRUE;
10836 }
10837 else
10838 {
10839 p = pp;
10840 pp = pNext(p);
10841 }
10842 }
10843 else
10844 {
10845 p = pp;
10846 pp = pNext(p);
10847 }
10848 pDelete(&sigMult);
10849 }
10850 else
10851 {
10852 p = pp;
10853 pp = pNext(p);
10854 }
10855 }
10856 }
10857 }
10858 h->SetLmCurrRing();
10859 if(deleted)
10860 strat->initEcart(h);
10861
10862}
#define ppMult_mm(p, m)
Definition polys.h:202
#define pDivideM(a, b)
Definition polys.h:295

◆ preIntegerCheck()

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 constant element of ideal suppresses intermediate coefficient swell

Definition at line 10540 of file kutil.cc.

10541{
10543 ideal F = idCopy(Forig);
10544 idSkipZeroes(F);
10545 poly pmon;
10546 ring origR = currRing;
10547 ideal monred = idInit(1,1);
10548 for(int i=0; i<idElem(F); i++)
10549 {
10550 if(pNext(F->m[i]) == NULL)
10551 idInsertPoly(monred, pCopy(F->m[i]));
10552 }
10553 int posconst = idPosConstant(F);
10554 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10555 {
10556 idDelete(&F);
10557 idDelete(&monred);
10558 return NULL;
10559 }
10560 int idelemQ = 0;
10561 if(Q!=NULL)
10562 {
10563 idelemQ = IDELEMS(Q);
10564 for(int i=0; i<idelemQ; i++)
10565 {
10566 if(pNext(Q->m[i]) == NULL)
10567 idInsertPoly(monred, pCopy(Q->m[i]));
10568 }
10569 idSkipZeroes(monred);
10570 posconst = idPosConstant(monred);
10571 //the constant, if found, will be from Q
10572 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10573 {
10574 pmon = pCopy(monred->m[posconst]);
10575 idDelete(&F);
10576 idDelete(&monred);
10577 return pmon;
10578 }
10579 }
10580 ring QQ_ring = rCopy0(currRing,FALSE);
10581 nKillChar(QQ_ring->cf);
10582 QQ_ring->cf = nInitChar(n_Q, NULL);
10583 rComplete(QQ_ring,1);
10584 QQ_ring = rAssure_c_dp(QQ_ring);
10585 rChangeCurrRing(QQ_ring);
10586 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10587 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10588 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10589 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10590 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10591 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10592 ideal one = kStd2(II, NULL, isNotHomog, NULL,(bigintmat*)NULL);
10593 idSkipZeroes(one);
10594 if(idIsConstant(one))
10595 {
10596 //one should be <1>
10597 for(int i = IDELEMS(II)-1; i>=0; i--)
10598 if(II->m[i] != NULL)
10599 II->m[i+1] = II->m[i];
10600 II->m[0] = pOne();
10601 ideal syz = idSyzygies(II, isNotHomog, NULL);
10602 poly integer = NULL;
10603 for(int i = IDELEMS(syz)-1;i>=0; i--)
10604 {
10605 if(pGetComp(syz->m[i]) == 1)
10606 {
10607 pSetComp(syz->m[i],0);
10608 if(pIsConstant(pHead(syz->m[i])))
10609 {
10610 integer = pHead(syz->m[i]);
10611 break;
10612 }
10613 }
10614 }
10615 rChangeCurrRing(origR);
10616 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10617 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10618 idDelete(&monred);
10619 idDelete(&F);
10620 id_Delete(&II,QQ_ring);
10621 id_Delete(&one,QQ_ring);
10622 id_Delete(&syz,QQ_ring);
10623 p_Delete(&integer,QQ_ring);
10624 rDelete(QQ_ring);
10625 return pmon;
10626 }
10627 else
10628 {
10629 if(idIs0(monred))
10630 {
10631 poly mindegmon = NULL;
10632 for(int i = 0; i<IDELEMS(one); i++)
10633 {
10634 if(pNext(one->m[i]) == NULL)
10635 {
10636 if(mindegmon == NULL)
10637 mindegmon = pCopy(one->m[i]);
10638 else
10639 {
10640 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10641 mindegmon = pCopy(one->m[i]);
10642 }
10643 }
10644 }
10645 if(mindegmon != NULL)
10646 {
10647 for(int i = IDELEMS(II)-1; i>=0; i--)
10648 if(II->m[i] != NULL)
10649 II->m[i+1] = II->m[i];
10650 II->m[0] = pCopy(mindegmon);
10651 ideal syz = idSyzygies(II, isNotHomog, NULL);
10652 bool found = FALSE;
10653 for(int i = IDELEMS(syz)-1;i>=0; i--)
10654 {
10655 if(pGetComp(syz->m[i]) == 1)
10656 {
10657 pSetComp(syz->m[i],0);
10658 if(pIsConstant(pHead(syz->m[i])))
10659 {
10660 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10661 found = TRUE;
10662 break;
10663 }
10664 }
10665 }
10666 id_Delete(&syz,QQ_ring);
10667 if (found == FALSE)
10668 {
10669 rChangeCurrRing(origR);
10670 idDelete(&monred);
10671 idDelete(&F);
10672 id_Delete(&II,QQ_ring);
10673 id_Delete(&one,QQ_ring);
10674 rDelete(QQ_ring);
10675 return NULL;
10676 }
10677 rChangeCurrRing(origR);
10678 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10679 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10680 idDelete(&monred);
10681 idDelete(&F);
10682 id_Delete(&II,QQ_ring);
10683 id_Delete(&one,QQ_ring);
10684 id_Delete(&syz,QQ_ring);
10685 rDelete(QQ_ring);
10686 return pmon;
10687 }
10688 }
10689 }
10690 rChangeCurrRing(origR);
10691 idDelete(&monred);
10692 idDelete(&F);
10693 id_Delete(&II,QQ_ring);
10694 id_Delete(&one,QQ_ring);
10695 rDelete(QQ_ring);
10696 return NULL;
10697}
Matrices of numbers.
Definition bigintmat.h:51
@ n_Q
rational (GMP) numbers
Definition coeffs.h:30
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:556
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:836
#define idIsConstant(I)
Definition ideals.h:40
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
ideal idCopy(ideal A)
Definition ideals.h:60
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition ideals.h:37
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:2602
void rChangeCurrRing(ring r)
Definition polys.cc:16
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition prCopy.cc:45
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3526
ring rAssure_c_dp(const ring r)
Definition ring.cc:5134
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1426
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
static int idElem(const ideal F)
number of non-zero polys in F
@ isNotHomog
Definition structs.h:32

◆ redBba()

static poly redBba ( poly h,
int maxIndex,
kStrategy strat )
static

Definition at line 8490 of file kutil.cc.

8491{
8492 int j = 0;
8493 unsigned long not_sev = ~ pGetShortExpVector(h);
8494
8495 while (j <= maxIndex)
8496 {
8497 if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev))
8498 {
8499 h = ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail());
8500 if (h==NULL) return NULL;
8501 j = 0;
8502 not_sev = ~ pGetShortExpVector(h);
8503 }
8504 else j++;
8505 }
8506 return h;
8507}
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition kInline.h:1171
#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

◆ redBba1()

static poly redBba1 ( poly h,
int maxIndex,
kStrategy strat )
static

Definition at line 8387 of file kutil.cc.

8388{
8389 int j = 0;
8390 unsigned long not_sev = ~ pGetShortExpVector(h);
8391
8392 while (j <= maxIndex)
8393 {
8394 if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j],h, not_sev))
8395 return ksOldSpolyRedNew(strat->S[j],h,strat->kNoetherTail());
8396 else j++;
8397 }
8398 return h;
8399}
KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether)
Definition kInline.h:1181

◆ redEcart()

int redEcart ( LObject * h,
kStrategy strat )

Definition at line 168 of file kstd1.cc.

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}
char length_pLength
Definition kutil.h:386
static int doRed(LObject *h, TObject *with, BOOLEAN intoT, kStrategy strat, bool redMoraNF)
Definition kstd1.cc:118
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 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
#define TEST_OPT_REDTHROUGH
Definition options.h:124
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:119

◆ redFirst()

int redFirst ( LObject * h,
kStrategy strat )

Definition at line 794 of file kstd1.cc.

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}
#define UNLIKELY(X)
Definition auxiliary.h:405
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat, BOOLEAN reduce)
Definition kspoly.cc:187
#define RED_CANONICALIZE
Definition kutil.h:37

◆ redMora()

static poly redMora ( poly h,
int maxIndex,
kStrategy strat )
static

Definition at line 8514 of file kutil.cc.

8515{
8516 int j=0;
8517 int e,l;
8518 unsigned long not_sev = ~ pGetShortExpVector(h);
8519
8520 if (maxIndex >= 0)
8521 {
8522 e = currRing->pLDeg(h,&l,currRing)-p_FDeg(h,currRing);
8523 do
8524 {
8525 if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev)
8526 && ((e >= strat->ecartS[j]) || (strat->kNoether!=NULL)))
8527 {
8528#ifdef KDEBUG
8529 if (TEST_OPT_DEBUG)
8530 {
8531 PrintS("reduce ");wrp(h);Print(" with S[%d] (",j);wrp(strat->S[j]);
8532 }
8533#endif
8534 h = ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail());
8535#ifdef KDEBUG
8536 if(TEST_OPT_DEBUG)
8537 {
8538 PrintS(")\nto "); wrp(h); PrintLn();
8539 }
8540#endif
8541 // pDelete(&h);
8542 if (h == NULL) return NULL;
8543 e = currRing->pLDeg(h,&l,currRing)-p_FDeg(h,currRing);
8544 j = 0;
8545 not_sev = ~ pGetShortExpVector(h);
8546 }
8547 else j++;
8548 }
8549 while (j <= maxIndex);
8550 }
8551 return h;
8552}

◆ redtail() [1/2]

poly redtail ( LObject * L,
int end_pos,
kStrategy strat )

Definition at line 6840 of file kutil.cc.

6841{
6842 poly h, hn;
6843 strat->redTailChange=FALSE;
6844
6845 L->GetP();
6846 poly p = L->p;
6847 if (strat->noTailReduction || pNext(p) == NULL)
6848 return p;
6849
6850 LObject Ln(strat->tailRing);
6851 TObject* With;
6852 // placeholder in case strat->tl < 0
6853 TObject With_s(strat->tailRing);
6854 h = p;
6855 hn = pNext(h);
6856 long op = strat->tailRing->pFDeg(hn, strat->tailRing);
6857 long e;
6858 int l;
6859 BOOLEAN save_HE=strat->kAllAxis;
6860 strat->kAllAxis |=
6861 ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
6862
6863 while(hn != NULL)
6864 {
6865 op = strat->tailRing->pFDeg(hn, strat->tailRing);
6866 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
6867 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
6868 loop
6869 {
6870 Ln.Set(hn, strat->tailRing);
6871 Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
6872 if (strat->kAllAxis)
6873 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
6874 else
6875 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
6876 if (With == NULL) break;
6877 With->length=0;
6878 With->pLength=0;
6879 strat->redTailChange=TRUE;
6880 if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
6881 {
6882 // reducing the tail would violate the exp bound
6883 if (kStratChangeTailRing(strat, L))
6884 {
6885 strat->kAllAxis = save_HE;
6886 return redtail(L, end_pos, strat);
6887 }
6888 else
6889 return NULL;
6890 }
6891 hn = pNext(h);
6892 if (hn == NULL) goto all_done;
6893 op = strat->tailRing->pFDeg(hn, strat->tailRing);
6894 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
6895 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
6896 }
6897 h = hn;
6898 hn = pNext(h);
6899 }
6900
6901 all_done:
6902 if (strat->redTailChange)
6903 {
6904 L->pLength = 0;
6905 }
6906 strat->kAllAxis = save_HE;
6907 return p;
6908}
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1144
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition kutil.cc:6701
#define TEST_OPT_INFREDTAIL
Definition options.h:120

◆ redtail() [2/2]

poly redtail ( poly p,
int end_pos,
kStrategy strat )

Definition at line 6910 of file kutil.cc.

6911{
6912 LObject L(p, currRing);
6913 return redtail(&L, end_pos, strat);
6914}

◆ redtailBba()

poly redtailBba ( LObject * L,
int end_pos,
kStrategy strat,
BOOLEAN withT,
BOOLEAN normalize )

Definition at line 6916 of file kutil.cc.

6917{
6918 strat->redTailChange=FALSE;
6919 if (strat->noTailReduction) return L->GetLmCurrRing();
6920 poly h, p;
6921 p = h = L->GetLmTailRing();
6922 if ((h==NULL) || (pNext(h)==NULL))
6923 return L->GetLmCurrRing();
6924
6925 TObject* With;
6926 // placeholder in case strat->tl < 0
6927 TObject With_s(strat->tailRing);
6928
6929 LObject Ln(pNext(h), strat->tailRing);
6930 Ln.GetpLength();
6931
6932 pNext(h) = NULL;
6933 if (L->p != NULL)
6934 {
6935 pNext(L->p) = NULL;
6936 if (L->t_p != NULL) pNext(L->t_p) = NULL;
6937 }
6938 L->pLength = 1;
6939
6940 Ln.PrepareRed(strat->use_buckets);
6941
6942 int cnt=REDTAIL_CANONICALIZE;
6943 while(!Ln.IsNull())
6944 {
6945 loop
6946 {
6947 if (TEST_OPT_IDLIFT)
6948 {
6949 if (Ln.p!=NULL)
6950 {
6951 if ((int)__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
6952 }
6953 else
6954 {
6955 if ((int)__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
6956 }
6957 }
6958 Ln.SetShortExpVector();
6959 if (withT)
6960 {
6961 int j;
6962 j = kFindDivisibleByInT(strat, &Ln);
6963 if (j < 0) break;
6964 With = &(strat->T[j]);
6965 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
6966 }
6967 else
6968 {
6969 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
6970 if (With == NULL) break;
6971 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
6972 }
6973 cnt--;
6974 if (cnt==0)
6975 {
6977 /*poly tmp=*/Ln.CanonicalizeP();
6978 if (normalize)
6979 {
6980 Ln.Normalize();
6981 //pNormalize(tmp);
6982 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
6983 }
6984 }
6985 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
6986 {
6987 With->pNorm();
6988 }
6989 strat->redTailChange=TRUE;
6990 if (ksReducePolyTail(L, With, &Ln))
6991 {
6992 // reducing the tail would violate the exp bound
6993 // set a flag and hope for a retry (in bba)
6995 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
6996 do
6997 {
6998 pNext(h) = Ln.LmExtractAndIter();
6999 pIter(h);
7000 L->pLength++;
7001 } while (!Ln.IsNull());
7002 goto all_done;
7003 }
7004 if (Ln.IsNull()) goto all_done;
7005 if (! withT) With_s.Init(currRing);
7006 }
7007 pNext(h) = Ln.LmExtractAndIter();
7008 pIter(h);
7009 pNormalize(h);
7010 L->pLength++;
7011 }
7012
7013 all_done:
7014 Ln.Delete();
7015 if (L->p != NULL) pNext(L->p) = pNext(p);
7016
7017 if (strat->redTailChange)
7018 {
7019 L->length = 0;
7020 L->pLength = 0;
7021 }
7022
7023 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7024 //L->Normalize(); // HANNES: should have a test
7025 kTest_L(L,strat);
7026 return L->GetLmCurrRing();
7027}
char completeReduce_retry
Definition kutil.h:402
#define REDTAIL_CANONICALIZE
Definition kutil.h:39
#define pNormalize(p)
Definition polys.h:318
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition syz3.cc:1027

◆ redtailBba_NF()

poly redtailBba_NF ( poly p,
kStrategy strat )

Definition at line 7354 of file kutil.cc.

7355{
7356 strat->redTailChange=FALSE;
7357 if (strat->noTailReduction) return p;
7358 if ((p==NULL) || (pNext(p)==NULL))
7359 return p;
7360
7361 int max_ind;
7362 poly h=p;
7363 p=pNext(p);
7364 pNext(h)=NULL;
7365 while(p!=NULL)
7366 {
7367 p=redNF(p,max_ind,1,strat);
7368 if (p!=NULL)
7369 {
7370 poly hh=p;
7371 p=pNext(p);
7372 pNext(hh)=NULL;
7373 h=p_Add_q(h,hh,currRing);
7374 }
7375 }
7376 return h;
7377}
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2315

◆ redtailBba_Ring()

poly redtailBba_Ring ( LObject * L,
int end_pos,
kStrategy strat )

Definition at line 7379 of file kutil.cc.

7381{
7382 strat->redTailChange=FALSE;
7383 if (strat->noTailReduction) return L->GetLmCurrRing();
7384 poly h, p;
7385 p = h = L->GetLmTailRing();
7386 if ((h==NULL) || (pNext(h)==NULL))
7387 return L->GetLmCurrRing();
7388
7389 TObject* With;
7390 // placeholder in case strat->tl < 0
7391 TObject With_s(strat->tailRing);
7392
7393 LObject Ln(pNext(h), strat->tailRing);
7394 Ln.pLength = L->GetpLength() - 1;
7395
7396 pNext(h) = NULL;
7397 if (L->p != NULL) pNext(L->p) = NULL;
7398 L->pLength = 1;
7399
7400 Ln.PrepareRed(strat->use_buckets);
7401
7402 int cnt=REDTAIL_CANONICALIZE;
7403 while(!Ln.IsNull())
7404 {
7405 loop
7406 {
7407 Ln.SetShortExpVector();
7408 With_s.Init(currRing);
7409 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7410 if (With == NULL) break;
7411 cnt--;
7412 if (cnt==0)
7413 {
7415 /*poly tmp=*/Ln.CanonicalizeP();
7416 }
7417 // we are in a ring, do not call pNorm
7418 // test divisibility of coefs:
7419 poly p_Ln=Ln.GetLmCurrRing();
7420 poly p_With=With->GetLmCurrRing();
7421 if (n_DivBy(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf))
7422 {
7423 strat->redTailChange=TRUE;
7424
7425 if (ksReducePolyTail_Z(L, With, &Ln))
7426 {
7427 // reducing the tail would violate the exp bound
7428 // set a flag and hope for a retry (in bba)
7430 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7431 do
7432 {
7433 pNext(h) = Ln.LmExtractAndIter();
7434 pIter(h);
7435 L->pLength++;
7436 } while (!Ln.IsNull());
7437 goto all_done;
7438 }
7439 }
7440 else break; /*proceed to next monomial*/
7441 if (Ln.IsNull()) goto all_done;
7442 }
7443 pNext(h) = Ln.LmExtractAndIter();
7444 pIter(h);
7445 pNormalize(h);
7446 L->pLength++;
7447 }
7448
7449 all_done:
7450 Ln.Delete();
7451 if (L->p != NULL) pNext(L->p) = pNext(p);
7452
7453 if (strat->redTailChange)
7454 {
7455 L->length = 0;
7456 }
7457
7458 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7459 //L->Normalize(); // HANNES: should have a test
7460 kTest_L(L,strat);
7461 return L->GetLmCurrRing();
7462}
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1122

◆ redtailBba_Z()

poly redtailBba_Z ( LObject * L,
int end_pos,
kStrategy strat )

Definition at line 7273 of file kutil.cc.

7275{
7276 strat->redTailChange=FALSE;
7277 if (strat->noTailReduction) return L->GetLmCurrRing();
7278 poly h, p;
7279 p = h = L->GetLmTailRing();
7280 if ((h==NULL) || (pNext(h)==NULL))
7281 return L->GetLmCurrRing();
7282
7283 TObject* With;
7284 // placeholder in case strat->tl < 0
7285 TObject With_s(strat->tailRing);
7286
7287 LObject Ln(pNext(h), strat->tailRing);
7288 Ln.pLength = L->GetpLength() - 1;
7289
7290 pNext(h) = NULL;
7291 if (L->p != NULL) pNext(L->p) = NULL;
7292 L->pLength = 1;
7293
7294 Ln.PrepareRed(strat->use_buckets);
7295
7296 int cnt=REDTAIL_CANONICALIZE;
7297 while(!Ln.IsNull())
7298 {
7299 loop
7300 {
7301 Ln.SetShortExpVector();
7302 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7303 if (With == NULL) break;
7304 cnt--;
7305 if (cnt==0)
7306 {
7308 /*poly tmp=*/Ln.CanonicalizeP();
7309 }
7310 // we are in Z, do not call pNorm
7311 strat->redTailChange=TRUE;
7312 // test divisibility of coefs:
7313 Ln.GetLmCurrRing();
7314 With->GetLmCurrRing();
7315
7316 if (ksReducePolyTail_Z(L, With, &Ln))
7317 {
7318 // reducing the tail would violate the exp bound
7319 // set a flag and hope for a retry (in bba)
7321 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7322 do
7323 {
7324 pNext(h) = Ln.LmExtractAndIter();
7325 pIter(h);
7326 L->pLength++;
7327 } while (!Ln.IsNull());
7328 goto all_done;
7329 }
7330 if (Ln.IsNull()) goto all_done;
7331 With_s.Init(currRing);
7332 }
7333 pNext(h) = Ln.LmExtractAndIter();
7334 pIter(h);
7335 pNormalize(h);
7336 L->pLength++;
7337 }
7338
7339 all_done:
7340 Ln.Delete();
7341 if (L->p != NULL) pNext(L->p) = pNext(p);
7342
7343 if (strat->redTailChange)
7344 {
7345 L->length = 0;
7346 }
7347
7348 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7349 //L->Normalize(); // HANNES: should have a test
7350 kTest_L(L,strat);
7351 return L->GetLmCurrRing();
7352}

◆ redtailBbaAlsoLC_Z()

void redtailBbaAlsoLC_Z ( LObject * L,
int end_pos,
kStrategy strat )

Definition at line 7144 of file kutil.cc.

7146{
7147 strat->redTailChange=FALSE;
7148
7149 poly h, p;
7150 p = h = L->GetLmTailRing();
7151 if ((h==NULL) || (pNext(h)==NULL))
7152 return;
7153
7154 TObject* With;
7155 LObject Ln(pNext(h), strat->tailRing);
7156 Ln.GetpLength();
7157
7158 pNext(h) = NULL;
7159 if (L->p != NULL)
7160 {
7161 pNext(L->p) = NULL;
7162 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7163 }
7164 L->pLength = 1;
7165
7166 Ln.PrepareRed(strat->use_buckets);
7167
7168 int cnt=REDTAIL_CANONICALIZE;
7169
7170 while(!Ln.IsNull())
7171 {
7172 loop
7173 {
7174 if (TEST_OPT_IDLIFT)
7175 {
7176 if (Ln.p!=NULL)
7177 {
7178 if ((int)__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7179 }
7180 else
7181 {
7182 if ((int)__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7183 }
7184 }
7185 Ln.SetShortExpVector();
7186 int j;
7187 j = kFindDivisibleByInT(strat, &Ln);
7188 if (j < 0)
7189 {
7190 j = kFindDivisibleByInT_Z(strat, &Ln);
7191 if (j < 0)
7192 {
7193 break;
7194 }
7195 else
7196 {
7197 /* reduction not cancelling a tail term, but reducing its coefficient */
7198 With = &(strat->T[j]);
7199 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7200 cnt--;
7201 if (cnt==0)
7202 {
7204 /*poly tmp=*/Ln.CanonicalizeP();
7205 }
7206 strat->redTailChange=TRUE;
7207 /* reduction cancelling a tail term */
7208 if (ksReducePolyTailLC_Z(L, With, &Ln))
7209 {
7210 // reducing the tail would violate the exp bound
7211 // set a flag and hope for a retry (in bba)
7213 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7214 do
7215 {
7216 pNext(h) = Ln.LmExtractAndIter();
7217 pIter(h);
7218 L->pLength++;
7219 } while (!Ln.IsNull());
7220 goto all_done;
7221 }
7222 /* we have to break since we did not cancel the term, but only decreased
7223 * its coefficient. */
7224 break;
7225 }
7226 } else {
7227 With = &(strat->T[j]);
7228 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7229 cnt--;
7230 if (cnt==0)
7231 {
7233 /*poly tmp=*/Ln.CanonicalizeP();
7234 }
7235 strat->redTailChange=TRUE;
7236 /* reduction cancelling a tail term */
7237 if (ksReducePolyTail_Z(L, With, &Ln))
7238 {
7239 // reducing the tail would violate the exp bound
7240 // set a flag and hope for a retry (in bba)
7242 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7243 do
7244 {
7245 pNext(h) = Ln.LmExtractAndIter();
7246 pIter(h);
7247 L->pLength++;
7248 } while (!Ln.IsNull());
7249 goto all_done;
7250 }
7251 }
7252 if (Ln.IsNull()) goto all_done;
7253 }
7254 pNext(h) = Ln.LmExtractAndIter();
7255 pIter(h);
7256 L->pLength++;
7257 }
7258
7259 all_done:
7260 Ln.Delete();
7261 if (L->p != NULL) pNext(L->p) = pNext(p);
7262
7263 if (strat->redTailChange)
7264 {
7265 L->length = 0;
7266 L->pLength = 0;
7267 }
7268
7269 kTest_L(L, strat);
7270 return;
7271}
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1104
int kFindDivisibleByInT_Z(const kStrategy strat, const LObject *L, const int start)
Definition kstd2.cc:213

◆ redtailBbaBound()

poly redtailBbaBound ( LObject * L,
int end_pos,
kStrategy strat,
int bound,
BOOLEAN withT,
BOOLEAN normalize )

Definition at line 7029 of file kutil.cc.

7030{
7031 strat->redTailChange=FALSE;
7032 if (strat->noTailReduction) return L->GetLmCurrRing();
7033 poly h, p;
7034 p = h = L->GetLmTailRing();
7035 if ((h==NULL) || (pNext(h)==NULL))
7036 return L->GetLmCurrRing();
7037
7038 TObject* With;
7039 // placeholder in case strat->tl < 0
7040 TObject With_s(strat->tailRing);
7041
7042 LObject Ln(pNext(h), strat->tailRing);
7043 Ln.pLength = L->GetpLength() - 1;
7044
7045 pNext(h) = NULL;
7046 if (L->p != NULL) pNext(L->p) = NULL;
7047 L->pLength = 1;
7048
7049 Ln.PrepareRed(strat->use_buckets);
7050
7051 int cnt=REDTAIL_CANONICALIZE;
7052 while(!Ln.IsNull())
7053 {
7054 loop
7055 {
7056 if (TEST_OPT_IDLIFT)
7057 {
7058 if (Ln.p!=NULL)
7059 {
7060 if ((int)__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7061 }
7062 else
7063 {
7064 if ((int)__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7065 }
7066 }
7067 Ln.SetShortExpVector();
7068 if (withT)
7069 {
7070 int j;
7071 j = kFindDivisibleByInT(strat, &Ln);
7072 if (j < 0) break;
7073 With = &(strat->T[j]);
7074 }
7075 else
7076 {
7077 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7078 if (With == NULL) break;
7079 }
7080 cnt--;
7081 if (cnt==0)
7082 {
7084 /*poly tmp=*/Ln.CanonicalizeP();
7085 if (normalize)
7086 {
7087 Ln.Normalize();
7088 //pNormalize(tmp);
7089 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7090 }
7091 }
7092 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7093 {
7094 With->pNorm();
7095 }
7096 strat->redTailChange=TRUE;
7097 if (ksReducePolyTail(L, With, &Ln))
7098 {
7099 // reducing the tail would violate the exp bound
7100 // set a flag and hope for a retry (in bba)
7102 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7103 do
7104 {
7105 pNext(h) = Ln.LmExtractAndIter();
7106 pIter(h);
7107 L->pLength++;
7108 } while (!Ln.IsNull());
7109 goto all_done;
7110 }
7111 if(!Ln.IsNull())
7112 {
7113 Ln.GetP();
7114 Ln.p = pJet(Ln.p,bound);
7115 }
7116 if (Ln.IsNull())
7117 {
7118 goto all_done;
7119 }
7120 if (! withT) With_s.Init(currRing);
7121 }
7122 pNext(h) = Ln.LmExtractAndIter();
7123 pIter(h);
7124 pNormalize(h);
7125 L->pLength++;
7126 }
7127
7128 all_done:
7129 Ln.Delete();
7130 if (L->p != NULL) pNext(L->p) = pNext(p);
7131
7132 if (strat->redTailChange)
7133 {
7134 L->length = 0;
7135 L->pLength = 0;
7136 }
7137
7138 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7139 //L->Normalize(); // HANNES: should have a test
7140 kTest_L(L,strat);
7141 return L->GetLmCurrRing();
7142}
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
#define pJet(p, m)
Definition polys.h:368

◆ redtailBbaShift()

poly redtailBbaShift ( LObject * L,
int pos,
kStrategy strat,
BOOLEAN withT,
BOOLEAN normalize )

Definition at line 13006 of file kutil.cc.

13007{
13008 /* for the shift case need to run it with withT = TRUE */
13009 strat->redTailChange=FALSE;
13010 if (strat->noTailReduction) return L->GetLmCurrRing();
13011 poly h, p;
13012 p = h = L->GetLmTailRing();
13013 if ((h==NULL) || (pNext(h)==NULL))
13014 return L->GetLmCurrRing();
13015
13016 TObject* With;
13017 // placeholder in case strat->tl < 0
13018 TObject With_s(strat->tailRing);
13019
13020 LObject Ln(pNext(h), strat->tailRing);
13021 Ln.pLength = L->GetpLength() - 1;
13022
13023 pNext(h) = NULL;
13024 if (L->p != NULL) pNext(L->p) = NULL;
13025 L->pLength = 1;
13026
13027 Ln.PrepareRed(strat->use_buckets);
13028
13029 while(!Ln.IsNull())
13030 {
13031 loop
13032 {
13033 Ln.SetShortExpVector();
13034 if (withT)
13035 {
13036 int j;
13037 j = kFindDivisibleByInT(strat, &Ln);
13038 if (j < 0) break;
13039 With = &(strat->T[j]);
13040 }
13041 else
13042 {
13043 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13044 if (With == NULL) break;
13045 }
13046 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13047 {
13048 With->pNorm();
13049 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13050 }
13051 strat->redTailChange=TRUE;
13052 if (ksReducePolyTail(L, With, &Ln))
13053 {
13054 // reducing the tail would violate the exp bound
13055 // set a flag and hope for a retry (in bba)
13057 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13058 do
13059 {
13060 pNext(h) = Ln.LmExtractAndIter();
13061 pIter(h);
13062 L->pLength++;
13063 } while (!Ln.IsNull());
13064 goto all_done;
13065 }
13066 if (Ln.IsNull()) goto all_done;
13067 if (! withT) With_s.Init(currRing);
13068 }
13069 pNext(h) = Ln.LmExtractAndIter();
13070 pIter(h);
13071 L->pLength++;
13072 }
13073
13074 all_done:
13075 Ln.Delete();
13076 if (L->p != NULL) pNext(L->p) = pNext(p);
13077
13078 if (strat->redTailChange)
13079 {
13080 L->length = 0;
13081 }
13082 L->Normalize(); // HANNES: should have a test
13083 kTest_L(L,strat);
13084 return L->GetLmCurrRing();
13085}

◆ reorderS()

void reorderS ( int * suc,
kStrategy strat )

Definition at line 4617 of file kutil.cc.

4618{
4619 int i,j,at,ecart, s2r;
4620 int fq=0;
4621 unsigned long sev;
4622 poly p;
4623 int new_suc=strat->sl+1;
4624 i= *suc;
4625 if (i<0) i=0;
4626
4627 for (; i<=strat->sl; i++)
4628 {
4629 at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4630 if (at != i)
4631 {
4632 if (new_suc > at) new_suc = at;
4633 p = strat->S[i];
4634 ecart = strat->ecartS[i];
4635 sev = strat->sevS[i];
4636 s2r = strat->S_2_R[i];
4637 if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4638 for (j=i; j>=at+1; j--)
4639 {
4640 strat->S[j] = strat->S[j-1];
4641 strat->ecartS[j] = strat->ecartS[j-1];
4642 strat->sevS[j] = strat->sevS[j-1];
4643 strat->S_2_R[j] = strat->S_2_R[j-1];
4644 }
4645 strat->S[at] = p;
4646 strat->ecartS[at] = ecart;
4647 strat->sevS[at] = sev;
4648 strat->S_2_R[at] = s2r;
4649 if (strat->fromQ!=NULL)
4650 {
4651 for (j=i; j>=at+1; j--)
4652 {
4653 strat->fromQ[j] = strat->fromQ[j-1];
4654 }
4655 strat->fromQ[at]=fq;
4656 }
4657 }
4658 }
4659 if (new_suc <= strat->sl) *suc=new_suc;
4660 else *suc=-1;
4661}

◆ replaceInLAndSAndT()

void replaceInLAndSAndT ( LObject & p,
int tj,
kStrategy strat )

Definition at line 9052 of file kutil.cc.

9053{
9054 p.GetP(strat->lmBin);
9055 if (strat->homog) strat->initEcart(&p);
9056 strat->redTailChange=FALSE;
9058 {
9059 p.pCleardenom();
9061 {
9062#ifdef HAVE_SHIFTBBA
9063 if (rIsLPRing(currRing))
9064 p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9065 else
9066#endif
9067 {
9068 p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9069 }
9070 p.pCleardenom();
9071 if (strat->redTailChange)
9072 p.t_p=NULL;
9073 if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9074 else strat->P.sev=0;
9075 }
9076 }
9077
9078 assume(strat->tailRing == p.tailRing);
9079 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9080
9081 int i, j, pos;
9082 poly tp = strat->T[tj].p;
9083
9084 /* enter p to T set */
9085 enterT(p, strat);
9086
9087 for (j = 0; j <= strat->sl; ++j)
9088 {
9089 if (pLtCmp(tp, strat->S[j]) == 0)
9090 {
9091 break;
9092 }
9093 }
9094 /* it may be that the exchanged element
9095 * is until now only in T and not in S */
9096 if (j <= strat->sl)
9097 {
9098 deleteInS(j, strat);
9099 }
9100
9101 pos = posInS(strat, strat->sl, p.p, p.ecart);
9102
9103 pp_Test(p.p, currRing, p.tailRing);
9104 assume(p.FDeg == p.pFDeg());
9105
9106 /* remove useless pairs from L set */
9107 for (i = 0; i <= strat->Ll; ++i)
9108 {
9109 if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9110 {
9111 deleteInL(strat->L, &(strat->Ll), i, strat);
9112 i--;
9113 continue;
9114 }
9115 if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9116 {
9117 deleteInL(strat->L, &(strat->Ll), i, strat);
9118 i--;
9119 }
9120 }
9121#ifdef HAVE_SHIFTBBA
9122 if (rIsLPRing(currRing))
9123 enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9124 else
9125#endif
9126 {
9127 /* generate new pairs with p, probably removing older, now useless pairs */
9128 superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9129 }
9130 /* enter p to S set */
9131 strat->enterS(p, pos, strat, strat->tl);
9132
9133#ifdef HAVE_SHIFTBBA
9134 /* do this after enterS so that the index in R (which is strat->tl) is correct */
9135 if (rIsLPRing(currRing) && !strat->rightGB)
9136 enterTShift(p,strat);
9137#endif
9138}
omBin lmBin
Definition kutil.h:345
void enterTShift(LObject p, kStrategy strat, int atT)
Definition kutil.cc:12983
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:12953
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4464

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject * h,
kStrategy strat )

Definition at line 1695 of file kutil.cc.

1696{
1697 if(strat->sl < 0) return FALSE;
1698 int i;
1699 for(i=0;i<strat->sl;i++)
1700 {
1701 //Construct the gcd pair between h and S[i]
1702 number d, s, t;
1703 poly m1, m2, gcd;
1704 d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1705 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1706 {
1707 nDelete(&d);
1708 nDelete(&s);
1709 nDelete(&t);
1710 }
1711 else
1712 {
1713 k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1714 pSetCoeff0(m1, s);
1715 pSetCoeff0(m2, t);
1716 pSetCoeff0(gcd, d);
1717 pNext(gcd) = p_Add_q(pp_Mult_mm(pNext(h->p), m1, strat->tailRing), pp_Mult_mm(pNext(strat->S[i]), m2, strat->tailRing), strat->tailRing);
1718 poly pSigMult = p_Copy(h->sig,currRing);
1719 poly sSigMult = p_Copy(strat->sig[i],currRing);
1720 pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1721 sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1722 p_LmDelete(m1, strat->tailRing);
1723 p_LmDelete(m2, strat->tailRing);
1724 poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1725 if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1726 {
1727 pDelete(&h->p);
1728 h->p = gcd;
1729 pDelete(&h->sig);
1730 h->sig = pairsig;
1731 pNext(h->sig) = NULL;
1732 strat->initEcart(h);
1733 h->sev = pGetShortExpVector(h->p);
1734 h->sevSig = pGetShortExpVector(h->sig);
1735 h->i_r1 = -1;h->i_r2 = -1;
1736 if(h->lcm != NULL)
1737 {
1738 pLmDelete(h->lcm);
1739 h->lcm = NULL;
1740 }
1741 if (currRing!=strat->tailRing)
1742 h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1743 return TRUE;
1744 }
1745 //Delete what you didn't use
1746 pDelete(&gcd);
1747 pDelete(&pairsig);
1748 }
1749 }
1750 return FALSE;
1751}

◆ sbaRing()

ring sbaRing ( kStrategy strat,
const ring r,
BOOLEAN complete,
int sgn )

Definition at line 11086 of file kutil.cc.

11087{
11088 int n = rBlocks(r); // Including trailing zero!
11089 // if sbaOrder == 1 => use (C,monomial order from r)
11090 if (strat->sbaOrder == 1)
11091 {
11092 if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11093 {
11094 return r;
11095 }
11096 ring res = rCopy0(r, TRUE, FALSE);
11097 res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11098 res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11099 res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11100 int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11101 res->wvhdl = wvhdl;
11102 for (int i=1; i<n; i++)
11103 {
11104 res->order[i] = r->order[i-1];
11105 res->block0[i] = r->block0[i-1];
11106 res->block1[i] = r->block1[i-1];
11107 res->wvhdl[i] = r->wvhdl[i-1];
11108 }
11109
11110 // new 1st block
11111 res->order[0] = ringorder_C; // Prefix
11112 // removes useless secondary component order if defined in old ring
11113 for (int i=rBlocks(res); i>0; --i)
11114 {
11115 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11116 {
11117 res->order[i] = (rRingOrder_t)0;
11118 }
11119 }
11120 rComplete(res, 1);
11121#ifdef HAVE_PLURAL
11122 if (rIsPluralRing(r))
11123 {
11124 if ( nc_rComplete(r, res, false) ) // no qideal!
11125 {
11126#ifndef SING_NDEBUG
11127 WarnS("error in nc_rComplete");
11128#endif
11129 // cleanup?
11130
11131 // rDelete(res);
11132 // return r;
11133
11134 // just go on..
11135 }
11136 }
11137#endif
11138 strat->tailRing = res;
11139 return (res);
11140 }
11141 // if sbaOrder == 3 => degree - position - ring order
11142 if (strat->sbaOrder == 3)
11143 {
11144 ring res = rCopy0(r, TRUE, FALSE);
11145 res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11146 res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11147 res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11148 int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11149 res->wvhdl = wvhdl;
11150 for (int i=2; i<n+2; i++)
11151 {
11152 res->order[i] = r->order[i-2];
11153 res->block0[i] = r->block0[i-2];
11154 res->block1[i] = r->block1[i-2];
11155 res->wvhdl[i] = r->wvhdl[i-2];
11156 }
11157
11158 // new 1st block
11159 res->order[0] = ringorder_a; // Prefix
11160 res->block0[0] = 1;
11161 res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11162 for (int i=0; i<res->N; ++i)
11163 res->wvhdl[0][i] = 1;
11164 res->block1[0] = si_min(res->N, rVar(res));
11165 // new 2nd block
11166 res->order[1] = ringorder_C; // Prefix
11167 res->wvhdl[1] = NULL;
11168 // removes useless secondary component order if defined in old ring
11169 for (int i=rBlocks(res); i>1; --i)
11170 {
11171 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11172 {
11173 res->order[i] = (rRingOrder_t)0;
11174 }
11175 }
11176 rComplete(res, 1);
11177#ifdef HAVE_PLURAL
11178 if (rIsPluralRing(r))
11179 {
11180 if ( nc_rComplete(r, res, false) ) // no qideal!
11181 {
11182#ifndef SING_NDEBUG
11183 WarnS("error in nc_rComplete");
11184#endif
11185 // cleanup?
11186
11187 // rDelete(res);
11188 // return r;
11189
11190 // just go on..
11191 }
11192 }
11193#endif
11194 strat->tailRing = res;
11195 return (res);
11196 }
11197
11198 // not sbaOrder == 1 => use Schreyer order
11199 // this is done by a trick when initializing the signatures
11200 // in initSLSba():
11201 // Instead of using the signature 1e_i for F->m[i], we start
11202 // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11203 // Schreyer order w.r.t. the underlying monomial order.
11204 // => we do not need to change the underlying polynomial ring at all!
11205
11206 // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11207
11208 /*
11209 else
11210 {
11211 ring res = rCopy0(r, FALSE, FALSE);
11212 // Create 2 more blocks for prefix/suffix:
11213 res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11214 res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11215 res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11216 int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11217
11218 // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11219 // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11220
11221 // new 1st block
11222 int j = 0;
11223 res->order[j] = ringorder_IS; // Prefix
11224 res->block0[j] = res->block1[j] = 0;
11225 // wvhdl[j] = NULL;
11226 j++;
11227
11228 for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11229 {
11230 res->order [j] = r->order [i];
11231 res->block0[j] = r->block0[i];
11232 res->block1[j] = r->block1[i];
11233
11234 if (r->wvhdl[i] != NULL)
11235 {
11236 wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11237 } // else wvhdl[j] = NULL;
11238 }
11239
11240 // new last block
11241 res->order [j] = ringorder_IS; // Suffix
11242 res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11243 // wvhdl[j] = NULL;
11244 j++;
11245
11246 // res->order [j] = 0; // The End!
11247 res->wvhdl = wvhdl;
11248
11249 // j == the last zero block now!
11250 assume(j == (n+1));
11251 assume(res->order[0]==ringorder_IS);
11252 assume(res->order[j-1]==ringorder_IS);
11253 assume(res->order[j]==0);
11254
11255 if (complete)
11256 {
11257 rComplete(res, 1);
11258
11259#ifdef HAVE_PLURAL
11260 if (rIsPluralRing(r))
11261 {
11262 if ( nc_rComplete(r, res, false) ) // no qideal!
11263 {
11264 }
11265 }
11266 assume(rIsPluralRing(r) == rIsPluralRing(res));
11267#endif
11268
11269
11270#ifdef HAVE_PLURAL
11271 ring old_ring = r;
11272
11273#endif
11274
11275 if (r->qideal!=NULL)
11276 {
11277 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11278
11279 assume(idRankFreeModule(res->qideal, res) == 0);
11280
11281#ifdef HAVE_PLURAL
11282 if( rIsPluralRing(res) )
11283 if( nc_SetupQuotient(res, r, true) )
11284 {
11285 // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11286 }
11287
11288#endif
11289 assume(idRankFreeModule(res->qideal, res) == 0);
11290 }
11291
11292#ifdef HAVE_PLURAL
11293 assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11294 assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11295 assume(rIsSCA(res) == rIsSCA(old_ring));
11296 assume(ncRingType(res) == ncRingType(old_ring));
11297#endif
11298 }
11299 strat->tailRing = res;
11300 return res;
11301 }
11302 */
11303
11304 assume(FALSE);
11305 return(NULL);
11306}
#define WarnS
Definition emacs.cc:78
CanonicalForm res
Definition facAbsFact.cc:60
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition ring.cc:5833
static int rBlocks(const ring r)
Definition ring.h:574
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_a
Definition ring.h:71

◆ showOption()

char * showOption ( )
extern

Definition at line 711 of file misc_ip.cc.

712{
713 int i;
714 BITSET tmp;
715
716 StringSetS("//options:");
717 if ((si_opt_1!=0)||(si_opt_2!=0))
718 {
719 tmp=si_opt_1;
720 if(tmp)
721 {
722 for (i=0; optionStruct[i].setval!=0; i++)
723 {
724 if (optionStruct[i].setval & tmp)
725 {
727 tmp &=optionStruct[i].resetval;
728 }
729 }
730 for (i=0; i<32; i++)
731 {
732 if (tmp & Sy_bit(i)) StringAppend(" %d",i);
733 }
734 }
735 tmp=si_opt_2;
736 if (tmp)
737 {
738 for (i=0; verboseStruct[i].setval!=0; i++)
739 {
740 if (verboseStruct[i].setval & tmp)
741 {
743 tmp &=verboseStruct[i].resetval;
744 }
745 }
746 for (i=1; i<32; i++)
747 {
748 if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
749 }
750 }
751 return StringEndS();
752 }
753 StringAppendS(" none");
754 return StringEndS();
755}
#define BITSET
Definition auxiliary.h:85
#define StringAppend
Definition emacs.cc:79
const struct soptionStruct verboseStruct[]
Definition misc_ip.cc:539
const struct soptionStruct optionStruct[]
Definition misc_ip.cc:508
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
#define Sy_bit(x)
Definition options.h:31
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151
int name
New type name for int.

◆ sugarDivisibleBy()

static BOOLEAN sugarDivisibleBy ( int ecart1,
int ecart2 )
inlinestatic

Definition at line 1333 of file kutil.cc.

1334{
1335 return (ecart1 <= ecart2);
1336}

◆ superenterpairs()

void superenterpairs ( poly h,
int k,
int ecart,
int pos,
kStrategy strat,
int atR )

Definition at line 4464 of file kutil.cc.

4465{
4467#if HAVE_SHIFTBBA
4468 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4469#endif
4470 // enter also zero divisor * poly, if this is non zero and of smaller degree
4472 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4473 initenterpairs(h, k, ecart, 0, strat, atR);
4474 clearSbatch(h, k, pos, strat);
4475}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition kutil.cc:4440
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4159
void enterExtendedSpoly(poly h, kStrategy strat)
Definition kutil.cc:4239
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493

◆ superenterpairsSig()

void superenterpairsSig ( poly h,
poly hSig,
int hFrom,
int k,
int ecart,
int pos,
kStrategy strat,
int atR )

Definition at line 4477 of file kutil.cc.

4478{
4480 // enter also zero divisor * poly, if this is non zero and of smaller degree
4481 if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4482 if(strat->sigdrop) return;
4483 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4484 if(strat->sigdrop) return;
4485 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4486 if(strat->sigdrop) return;
4487 clearSbatch(h, k, pos, strat);
4488}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3941
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4214
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition kutil.cc:4323

◆ syzCriterion()

BOOLEAN syzCriterion ( poly sig,
unsigned long not_sevSig,
kStrategy strat )

Definition at line 6482 of file kutil.cc.

6483{
6484//#if 1
6485#ifdef DEBUGF5
6486 PrintS("syzygy criterion checks: ");
6487 pWrite(sig);
6488#endif
6489 for (int k=0; k<strat->syzl; k++)
6490 {
6491 //printf("-%d",k);
6492//#if 1
6493#ifdef DEBUGF5
6494 Print("checking with: %d / %d -- \n",k,strat->syzl);
6495 pWrite(pHead(strat->syz[k]));
6496#endif
6497 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6498 && (!rField_is_Ring(currRing) ||
6499 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6500 {
6501//#if 1
6502#ifdef DEBUGF5
6503 PrintS("DELETE!\n");
6504#endif
6505 strat->nrsyzcrit++;
6506 //printf("- T -\n\n");
6507 return TRUE;
6508 }
6509 }
6510 //printf("- F -\n\n");
6511 return FALSE;
6512}

◆ syzCriterionInc()

BOOLEAN syzCriterionInc ( poly sig,
unsigned long not_sevSig,
kStrategy strat )

Definition at line 6517 of file kutil.cc.

6518{
6519//#if 1
6520 if(sig == NULL)
6521 return FALSE;
6522#ifdef DEBUGF5
6523 PrintS("--- syzygy criterion checks: ");
6524 pWrite(sig);
6525#endif
6526 int comp = (int)__p_GetComp(sig, currRing);
6527 int min, max;
6528 if (comp<=1)
6529 return FALSE;
6530 else
6531 {
6532 min = strat->syzIdx[comp-2];
6533 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6534 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6535 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6536 if (comp == strat->currIdx)
6537 {
6538 max = strat->syzl;
6539 }
6540 else
6541 {
6542 max = strat->syzIdx[comp-1];
6543 }
6544 for (int k=min; k<max; k++)
6545 {
6546#ifdef F5DEBUG
6547 Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6548 Print("checking with: %d -- ",k);
6549 pWrite(pHead(strat->syz[k]));
6550#endif
6551 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6552 && (!rField_is_Ring(currRing) ||
6553 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6554 {
6555 strat->nrsyzcrit++;
6556 return TRUE;
6557 }
6558 }
6559 return FALSE;
6560 }
6561}
static int min(int a, int b)
Definition fast_mult.cc:268
static int max(int a, int b)
Definition fast_mult.cc:264

◆ updateResult()

void updateResult ( ideal r,
ideal Q,
kStrategy strat )

Definition at line 10081 of file kutil.cc.

10082{
10083 int l;
10084 if (strat->ak>0)
10085 {
10086 for (l=IDELEMS(r)-1;l>=0;l--)
10087 {
10088 if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10089 {
10090 pDelete(&r->m[l]); // and set it to NULL
10091 }
10092 }
10093 int q;
10094 poly p;
10096 {
10097 for (l=IDELEMS(r)-1;l>=0;l--)
10098 {
10099 if ((r->m[l]!=NULL)
10100 //&& (strat->syzComp>0)
10101 //&& (pGetComp(r->m[l])<=strat->syzComp)
10102 )
10103 {
10104 for(q=IDELEMS(Q)-1; q>=0;q--)
10105 {
10106 if ((Q->m[q]!=NULL)
10107 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10108 {
10109 if (TEST_OPT_REDSB)
10110 {
10111 p=r->m[l];
10112 r->m[l]=kNF(Q,NULL,p);
10113 pDelete(&p);
10114 }
10115 else
10116 {
10117 pDelete(&r->m[l]); // and set it to NULL
10118 }
10119 break;
10120 }
10121 }
10122 }
10123 }
10124 }
10125 else
10126 {
10127 for (l=IDELEMS(r)-1;l>=0;l--)
10128 {
10129 if ((r->m[l]!=NULL)
10130 //&& (strat->syzComp>0)
10131 //&& (pGetComp(r->m[l])<=strat->syzComp)
10132 )
10133 {
10134 for(q=IDELEMS(Q)-1; q>=0;q--)
10135 {
10136 if ((Q->m[q]!=NULL)
10137 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10138 {
10139 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10140 {
10141 if (TEST_OPT_REDSB)
10142 {
10143 p=r->m[l];
10144 r->m[l]=kNF(Q,NULL,p);
10145 pDelete(&p);
10146 }
10147 else
10148 {
10149 pDelete(&r->m[l]); // and set it to NULL
10150 }
10151 break;
10152 }
10153 }
10154 }
10155 }
10156 }
10157 }
10158 }
10159 else
10160 {
10161 int q;
10162 poly p;
10163 BOOLEAN reduction_found=FALSE;
10165 {
10166 for (l=IDELEMS(r)-1;l>=0;l--)
10167 {
10168 if (r->m[l]!=NULL)
10169 {
10170 for(q=IDELEMS(Q)-1; q>=0;q--)
10171 {
10172 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10173 {
10174 if (TEST_OPT_REDSB)
10175 {
10176 p=r->m[l];
10177 r->m[l]=kNF(Q,NULL,p);
10178 pDelete(&p);
10179 reduction_found=TRUE;
10180 }
10181 else
10182 {
10183 pDelete(&r->m[l]); // and set it to NULL
10184 }
10185 break;
10186 }
10187 }
10188 }
10189 }
10190 }
10191 //Also need divisibility of the leading coefficients
10192 else
10193 {
10194 for (l=IDELEMS(r)-1;l>=0;l--)
10195 {
10196 if (r->m[l]!=NULL)
10197 {
10198 for(q=IDELEMS(Q)-1; q>=0;q--)
10199 {
10200 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10201 {
10202 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10203 {
10204 if (TEST_OPT_REDSB)
10205 {
10206 p=r->m[l];
10207 r->m[l]=kNF(Q,NULL,p);
10208 pDelete(&p);
10209 reduction_found=TRUE;
10210 }
10211 else
10212 {
10213 pDelete(&r->m[l]); // and set it to NULL
10214 }
10215 break;
10216 }
10217 }
10218 }
10219 }
10220 }
10221 }
10222 if (/*TEST_OPT_REDSB &&*/ reduction_found)
10223 {
10225 {
10226 for (l=IDELEMS(r)-1;l>=0;l--)
10227 {
10228 if (r->m[l]!=NULL)
10229 {
10230 for(q=IDELEMS(r)-1;q>=0;q--)
10231 {
10232 if ((l!=q)
10233 && (r->m[q]!=NULL)
10234 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10235 &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10236 )
10237 {
10238 //If they are equal then take the one with the smallest length
10239 if(pLmDivisibleBy(r->m[q],r->m[l])
10240 && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10241 && (pLength(r->m[q]) < pLength(r->m[l]) ||
10242 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10243 {
10244 pDelete(&r->m[l]);
10245 break;
10246 }
10247 else
10248 pDelete(&r->m[q]);
10249 }
10250 }
10251 }
10252 }
10253 }
10254 else
10255 {
10256 for (l=IDELEMS(r)-1;l>=0;l--)
10257 {
10258 if (r->m[l]!=NULL)
10259 {
10260 for(q=IDELEMS(r)-1;q>=0;q--)
10261 {
10262 if ((l!=q)
10263 && (r->m[q]!=NULL)
10264 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10265 )
10266 {
10267 //If they are equal then take the one with the smallest length
10268 if(pLmDivisibleBy(r->m[q],r->m[l])
10269 &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10270 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10271 {
10272 pDelete(&r->m[l]);
10273 break;
10274 }
10275 else
10276 pDelete(&r->m[q]);
10277 }
10278 }
10279 }
10280 }
10281 }
10282 }
10283 }
10284 idSkipZeroes(r);
10285}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3224

◆ updateS()

void updateS ( BOOLEAN toT,
kStrategy strat )

Definition at line 8559 of file kutil.cc.

8560{
8561 LObject h;
8562 int i, suc=0;
8563 poly redSi=NULL;
8564 BOOLEAN change,any_change;
8565// Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
8566// for (i=0; i<=(strat->sl); i++)
8567// {
8568// Print("s%d:",i);
8569// if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
8570// pWrite(strat->S[i]);
8571// }
8572// Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
8573 any_change=FALSE;
8575 {
8576 while (suc != -1)
8577 {
8578 i=suc+1;
8579 while (i<=strat->sl)
8580 {
8581 change=FALSE;
8583 any_change = FALSE;
8584 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8585 {
8586 redSi = pHead(strat->S[i]);
8587 strat->S[i] = redBba(strat->S[i],i-1,strat);
8588 //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
8589 // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
8590 if (pCmp(redSi,strat->S[i])!=0)
8591 {
8592 change=TRUE;
8593 any_change=TRUE;
8594 #ifdef KDEBUG
8595 if (TEST_OPT_DEBUG)
8596 {
8597 PrintS("reduce:");
8598 wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
8599 }
8600 #endif
8601 if (TEST_OPT_PROT)
8602 {
8603 if (strat->S[i]==NULL)
8604 PrintS("V");
8605 else
8606 PrintS("v");
8607 mflush();
8608 }
8609 }
8610 pLmDelete(&redSi);
8611 if (strat->S[i]==NULL)
8612 {
8613 deleteInS(i,strat);
8614 i--;
8615 }
8616 else if (change)
8617 {
8619 {
8621 {
8622 number n;
8623 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8624 if (!nIsOne(n))
8625 {
8627 denom->n=nInvers(n);
8628 denom->next=DENOMINATOR_LIST;
8629 DENOMINATOR_LIST=denom;
8630 }
8631 nDelete(&n);
8632 }
8633 else
8634 {
8635 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8636 }
8637 }
8638 else
8639 {
8640 pNorm(strat->S[i]);
8641 }
8642 strat->sevS[i] = pGetShortExpVector(strat->S[i]);
8643 }
8644 }
8645 i++;
8646 }
8647 if (any_change) reorderS(&suc,strat);
8648 else break;
8649 }
8650 if (toT)
8651 {
8652 for (i=0; i<=strat->sl; i++)
8653 {
8654 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8655 {
8656 h.p = redtailBba(strat->S[i],i-1,strat);
8658 {
8659 h.pCleardenom();// also does remove Content
8660 }
8661 }
8662 else
8663 {
8664 h.p = strat->S[i];
8665 }
8666 strat->initEcart(&h);
8667 if (strat->honey)
8668 {
8669 strat->ecartS[i] = h.ecart;
8670 }
8671 if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
8672 else assume(strat->sevS[i] == pGetShortExpVector(h.p));
8673 h.sev = strat->sevS[i];
8674 /*puts the elements of S also to T*/
8675 strat->initEcart(&h);
8676 /*if (toT) - already checked*/ enterT(h,strat);
8677 strat->S_2_R[i] = strat->tl;
8678#ifdef HAVE_SHIFTBBA
8679 if (/*(toT) && */(currRing->isLPring))
8680 enterTShift(h, strat);
8681#endif
8682 }
8683 }
8684 }
8685 else
8686 {
8687 while (suc != -1)
8688 {
8689 i=suc;
8690 while (i<=strat->sl)
8691 {
8692 change=FALSE;
8693 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8694 {
8695 redSi=pHead((strat->S)[i]);
8696 (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
8697 if ((strat->S)[i]==NULL)
8698 {
8699 deleteInS(i,strat);
8700 i--;
8701 }
8702 else if (pCmp((strat->S)[i],redSi)!=0)
8703 {
8704 any_change=TRUE;
8705 h.p = strat->S[i];
8706 strat->initEcart(&h);
8707 strat->ecartS[i] = h.ecart;
8709 {
8711 {
8712 number n;
8713 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8714 if (!nIsOne(n))
8715 {
8717 denom->n=nInvers(n);
8718 denom->next=DENOMINATOR_LIST;
8719 DENOMINATOR_LIST=denom;
8720 }
8721 nDelete(&n);
8722 }
8723 else
8724 {
8725 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8726 }
8727 }
8728 else
8729 {
8730 pNorm(strat->S[i]); // == h.p
8731 }
8732 h.sev = pGetShortExpVector(h.p);
8733 strat->sevS[i] = h.sev;
8734 }
8735 pLmDelete(&redSi);
8736 kTest(strat);
8737 }
8738 i++;
8739 }
8740#ifdef KDEBUG
8741 kTest(strat);
8742#endif
8743 if (any_change) reorderS(&suc,strat);
8744 else { suc=-1; break; }
8745 if (h.p!=NULL)
8746 {
8747 if (!strat->kAllAxis)
8748 {
8749 /*strat->kAllAxis =*/ HEckeTest(h.p,strat);
8750 }
8751 if (strat->kAllAxis)
8752 newHEdge(strat);
8753 }
8754 }
8755 for (i=0; i<=strat->sl; i++)
8756 {
8757 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8758 {
8759 strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
8760 strat->initEcart(&h);
8761 strat->ecartS[i] = h.ecart;
8762 h.sev = pGetShortExpVector(h.p);
8763 strat->sevS[i] = h.sev;
8764 }
8765 else
8766 {
8767 h.p = strat->S[i];
8768 h.ecart=strat->ecartS[i];
8769 h.sev = strat->sevS[i];
8770 h.length = h.pLength = pLength(h.p);
8771 }
8772 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8773 cancelunit1(&h,&suc,strat->sl,strat);
8774 h.SetpFDeg();
8775 /*puts the elements of S also to T*/
8776 enterT(h,strat);
8777 strat->S_2_R[i] = strat->tl;
8778#ifdef HAVE_SHIFTBBA
8779 if (currRing->isLPring)
8780 enterTShift(h, strat);
8781#endif
8782 }
8783 if (suc!= -1) updateS(toT,strat);
8784 }
8785#ifdef KDEBUG
8786 kTest(strat);
8787#endif
8788}
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition kutil.cc:8404
void reorderS(int *suc, kStrategy strat)
Definition kutil.cc:4617

Variable Documentation

◆ DENOMINATOR_LIST

VAR denominator_list DENOMINATOR_LIST =NULL

Definition at line 79 of file kutil.cc.

◆ HCord

VAR int HCord

Definition at line 239 of file kutil.cc.

◆ Kstd1_deg

VAR int Kstd1_deg

Definition at line 240 of file kutil.cc.

◆ Kstd1_mu

VAR int Kstd1_mu =INT_MAX

Definition at line 241 of file kutil.cc.

◆ sloppy_max

STATIC_VAR BOOLEAN sloppy_max = FALSE

Definition at line 795 of file kutil.cc.