My Project
Loading...
Searching...
No Matches
kutil.h File Reference

Go to the source code of this file.

Data Structures

struct  denominator_list_s
class  sTObject
class  sLObject
class  skStrategy

Macros

#define HAVE_TAIL_RING
#define setmax   128
#define setmaxL   ((int)((4096-12)/sizeof(LObject)))
#define setmaxLinc   ((int)((4096)/sizeof(LObject)))
#define setmaxT   ((int)((4096-12)/sizeof(TObject)))
#define setmaxTinc   ((int)((4096)/sizeof(TObject)))
#define RED_CANONICALIZE   200
#define REDNF_CANONICALIZE   60
#define REDTAIL_CANONICALIZE   100
#define KINLINE
#define NO_KINLINE   1
#define ALLOW_PROD_CRIT(A)

Typedefs

typedef int * intset
typedef int64 wlen_type
typedef wlen_typewlen_set
typedef class sTObject TObject
typedef class sLObject LObject
typedef TObjectTSet
typedef LObjectLSet
typedef denominator_list_sdenominator_list

Functions

void deleteHC (poly *p, int *e, int *l, kStrategy strat)
void deleteHC (LObject *L, kStrategy strat, BOOLEAN fromNext=FALSE)
void deleteInS (int i, kStrategy strat)
void cleanT (kStrategy strat)
static LSet initL (int nr=setmaxL)
void deleteInL (LSet set, int *length, int j, kStrategy strat)
void enterL (LSet *set, int *length, int *LSetmax, LObject p, int at)
void enterSBba (LObject *p, int atS, kStrategy strat, int atR=-1)
void enterSBbaShift (LObject *p, int atS, kStrategy strat, int atR=-1)
void enterSSba (LObject *p, int atS, kStrategy strat, int atR=-1)
void initEcartPairBba (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
void initEcartPairMora (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
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=0, int end=-1)
int posInT0 (const TSet set, const int length, LObject &p)
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 posInTSig (const TSet set, const int length, LObject &p)
int posInT110 (const TSet set, const int length, LObject &p)
int posInT13 (const TSet set, const int length, LObject &p)
int posInT15 (const TSet set, const int length, LObject &p)
int posInT17 (const TSet set, const int length, LObject &p)
int posInT17_c (const TSet set, const int length, LObject &p)
int posInT19 (const TSet set, const int length, LObject &p)
int posInT_EcartpLength (const TSet set, const int length, LObject &p)
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)
void reorderS (int *suc, kStrategy strat)
int posInLSig (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInLSigRing (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInSyz (const kStrategy strat, const poly sig)
int posInL0 (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL11 (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL11Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInLF5CRing (const LSet set, int start, const int length, LObject *L, const kStrategy strat)
int posInL11Ringls (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL13 (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL15 (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL15Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL17 (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL10 (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL10Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
int posInL110 (const LSet set, const int length, LObject *L, const kStrategy strat)
KINLINE poly redtailBba (poly p, int end_pos, kStrategy strat, BOOLEAN normalize=FALSE)
KINLINE poly redtailBbaBound (poly p, int end_pos, kStrategy strat, int bound, BOOLEAN normalize=FALSE)
KINLINE poly redtailBba_Ring (poly p, int end_pos, kStrategy strat)
KINLINE poly redtailBba_Z (poly p, int end_pos, kStrategy strat)
poly redtailBba_NF (poly p, kStrategy strat)
poly redtailBba_Ring (LObject *L, int end_pos, kStrategy strat)
poly redtailBba_Z (LObject *L, int end_pos, kStrategy strat)
void redtailBbaAlsoLC_Z (LObject *L, int end_pos, kStrategy strat)
poly redtailBba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
poly redtailBbaBound (LObject *L, int end_pos, kStrategy strat, int bound, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
poly redtailSba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
poly redtailBba (TObject *T, int end_pos, kStrategy strat)
poly redtail (poly p, int end_pos, kStrategy strat)
poly redtail (LObject *L, int end_pos, kStrategy strat)
poly redNF (poly h, int &max_ind, int nonorm, kStrategy strat)
int redNF0 (LObject *P, kStrategy strat)
poly redNFTail (poly h, const int sl, kStrategy strat)
int redHoney (LObject *h, kStrategy strat)
int redHoneyM (LObject *h, kStrategy strat)
int redLiftstd (LObject *h, kStrategy strat)
int redRing (LObject *h, kStrategy strat)
int redRing_Z (LObject *h, kStrategy strat)
int redRiloc (LObject *h, kStrategy strat)
void enterExtendedSpoly (poly h, kStrategy strat)
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR=-1)
int redLazy (LObject *h, kStrategy strat)
int redHomog (LObject *h, kStrategy strat)
int redSig (LObject *h, kStrategy strat)
int redSigRing (LObject *h, kStrategy strat)
void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos, kStrategy strat, int atR=-1)
void enterpairs (poly h, int k, int ec, int pos, kStrategy strat, int atR=-1)
void entersets (LObject h)
void pairs ()
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
void message (int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
void messageStat (int hilbcount, kStrategy strat)
void messageStatSBA (int hilbcount, kStrategy strat)
void messageSets (kStrategy strat)
void initEcartNormal (TObject *h)
void initEcartBBA (TObject *h)
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 updateS (BOOLEAN toT, kStrategy strat)
void enterSyz (LObject &p, kStrategy strat, int atT)
void enterT (LObject *p, kStrategy strat, int atT=-1)
void enterT_strong (LObject *p, kStrategy strat, int atT=-1)
void cancelunit (LObject *p, BOOLEAN inNF=FALSE)
void HEckeTest (poly pp, kStrategy strat)
void initBuchMoraCrit (kStrategy strat)
void initSbaCrit (kStrategy strat)
void initHilbCrit (ideal F, ideal Q, bigintmat **hilb, kStrategy strat)
void initBuchMoraPos (kStrategy strat)
void initBuchMoraPosRing (kStrategy strat)
void initSbaPos (kStrategy strat)
void initBuchMora (ideal F, ideal Q, kStrategy strat)
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
void exitBuchMora (kStrategy strat)
void exitSba (kStrategy strat)
void updateResult (ideal r, ideal Q, kStrategy strat)
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
void kFreeStrat (kStrategy strat)
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
void chainCritNormal (poly p, int ecart, kStrategy strat)
void chainCritOpt_1 (poly, int, kStrategy strat)
void chainCritSig (poly p, int ecart, kStrategy strat)
BOOLEAN homogTest (polyset F, int Fmax)
BOOLEAN newHEdge (kStrategy strat)
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
int kFindInTShift (poly p, TSet T, int tlength)
int kFindDivisibleByInT (const kStrategy strat, const LObject *L, const int start=0)
 return -1 if no divisor is found number of first divisor in T, otherwise
int kFindDivisibleByInT_ecart (const kStrategy strat, const LObject *L, const int ecart)
int kFindDivisibleByInT_Z (const kStrategy strat, const LObject *L, const int start=0)
int kFindSameLMInT_Z (const kStrategy strat, const LObject *L, const int start=0)
int kTestDivisibleByT0_Z (const kStrategy strat, const LObject *L)
 tests if T[0] divides the leading monomial of L, returns -1 if not
int kFindDivisibleByInS (const kStrategy strat, int *max_ind, LObject *L)
 return -1 if no divisor is found number of first divisor in S, otherwise
int kFindNextDivisibleByInS (const kStrategy strat, int start, int max_ind, LObject *L)
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart=LONG_MAX)
KINLINE TSet initT ()
KINLINE TObject ** initR ()
KINLINE unsigned long * initsevT ()
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing)
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing)
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing)
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing)
KINLINE BOOLEAN k_GetLeadTerms (const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
KINLINE void k_GetStrongLeadTerms (const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring taiRing)
BOOLEAN kTest (kStrategy strat)
BOOLEAN kTest_TS (kStrategy strat)
BOOLEAN kTest_L (LObject *L, kStrategy strat, BOOLEAN testp=FALSE, int lpos=-1, TSet T=NULL, int tlength=-1)
BOOLEAN kTest_T (TObject *T, kStrategy strat, int tpos=-1, char TN='?')
BOOLEAN kTest_S (kStrategy strat)
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)
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
ideal bba (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
ideal sba (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
ideal kNF2 (ideal F, ideal Q, ideal q, kStrategy strat, int lazyReduce)
poly kNF2Bound (ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
ideal kNF2Bound (ideal F, ideal Q, ideal q, int bound, kStrategy strat, int lazyReduce)
void initBba (kStrategy strat)
void initSba (ideal F, kStrategy strat)
void f5c (kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, bigintmat *hilb)
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL, BOOLEAN redtail=FALSE)
int ksReducePolyZ (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolyLC (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolyGCD (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolyBound (LObject *PR, TObject *PW, int bound, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolySig (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolySigRing (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolyTail (LObject *PR, TObject *PW, poly Current, poly spNoether=NULL)
KINLINE int ksReducePolyTail (LObject *PR, TObject *PW, LObject *Red)
void ksCreateSpoly (LObject *Pair, poly spNoether=NULL, int use_buckets=0, ring tailRing=currRing, poly m1=NULL, poly m2=NULL, TObject **R=NULL)
poly ksCreateShortSpoly (poly p1, poly p2, ring tailRing)
KINLINE poly ksOldSpolyRed (poly p1, poly p2, poly spNoether=NULL)
KINLINE poly ksOldSpolyRedNew (poly p1, poly p2, poly spNoether=NULL)
KINLINE poly ksOldCreateSpoly (poly p1, poly p2, poly spNoether=NULL, ring r=currRing)
KINLINE void ksOldSpolyTail (poly p1, poly q, poly q2, poly spNoether, ring r=currRing)
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
poly preIntegerCheck (ideal F, 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=NULL, TObject *T=NULL, unsigned long new_expbound=0)
void kStratInitChangeTailRing (kStrategy strat)
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
static int kFindInL1 (const poly p, const kStrategy strat)
void enterTShift (LObject *p, kStrategy strat, int atT=-1)
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
void superenterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
int redFirstShift (LObject *h, kStrategy strat)
ideal bbaShift (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
static void kDeleteLcm (LObject *P)
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)

Variables

EXTERN_VAR denominator_list DENOMINATOR_LIST
EXTERN_VAR int strat_nr
EXTERN_VAR int HCord

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 66 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

#define ALLOW_PROD_CRIT ( A)
Value:
(!(A)->no_prod_crit)
#define A
Definition sirandom.c:24

Definition at line 392 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 28 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 50 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 51 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 37 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 38 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 39 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 30 of file kutil.h.

◆ setmaxL

#define setmaxL   ((int)((4096-12)/sizeof(LObject)))

Definition at line 31 of file kutil.h.

◆ setmaxLinc

#define setmaxLinc   ((int)((4096)/sizeof(LObject)))

Definition at line 32 of file kutil.h.

◆ setmaxT

#define setmaxT   ((int)((4096-12)/sizeof(TObject)))

Definition at line 34 of file kutil.h.

◆ setmaxTinc

#define setmaxTinc   ((int)((4096)/sizeof(TObject)))

Definition at line 35 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 64 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 54 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 59 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 61 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 58 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 60 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 56 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 55 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6621 of file kutil.cc.

6622{
6624 return FALSE;
6625 poly p1 = pOne();
6626 poly p2 = pOne();
6627 for (int ii=strat->sl; ii>start; ii--)
6628 {
6629 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6630 {
6631 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6632 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6633 if (!(pLmCmp(p1,p2) == 1))
6634 {
6635 pDelete(&p1);
6636 pDelete(&p2);
6637 return TRUE;
6638 }
6639 }
6640 }
6641 pDelete(&p1);
6642 pDelete(&p2);
6643 return FALSE;
6644}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
polyset S
Definition kutil.h:305
unsigned long * sevSig
Definition kutil.h:323
polyset sig
Definition kutil.h:307
LObject P
Definition kutil.h:301
int sl
Definition kutil.h:347
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1446
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1931
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 6646 of file kutil.cc.

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

◆ arriRewDummy()

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

Definition at line 1258 of file kInline.h.

1259{
1260 return FALSE;
1261}

◆ bba()

ideal bba ( ideal F,
ideal Q,
intvec * w,
bigintmat * hilb,
kStrategy strat )

Definition at line 2614 of file kstd2.cc.

2615{
2616 int red_result = 1;
2617 int olddeg,reduc;
2618 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2619 BOOLEAN withT = FALSE;
2620 BITSET save;
2621 SI_SAVE_OPT1(save);
2622
2623 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2625 initBuchMoraPosRing(strat);
2626 else
2627 initBuchMoraPos(strat);
2628 initHilbCrit(F,Q,&hilb,strat);
2629 initBba(strat);
2630 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2631 initBuchMora(F, Q,strat);
2632 if(errorreported) return NULL;
2633 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2634 reduc = olddeg = 0;
2635
2636#ifndef NO_BUCKETS
2638 strat->use_buckets = 1;
2639#endif
2640 // redtailBBa against T for inhomogeneous input
2641 if (!TEST_OPT_OLDSTD)
2642 withT = ! strat->homog;
2643
2644 // strat->posInT = posInT_pLength;
2645 #ifdef KDEBUG
2646 kTest_TS(strat);
2647 #endif
2648
2649#ifdef HAVE_TAIL_RING
2650 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2652#endif
2653
2654#ifdef KDEBUG
2655 //kDebugPrint(strat);
2656#endif
2657 /* compute------------------------------------------------------- */
2658 while (strat->Ll >= 0)
2659 {
2660 #ifdef KDEBUG
2661 if (TEST_OPT_DEBUG) messageSets(strat);
2662 #endif
2663 if (siCntrlc)
2664 {
2665 while (strat->Ll >= 0)
2666 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2667 strat->noClearS=TRUE;
2668 }
2670 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2671 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2672 {
2673 /*
2674 *stops computation if
2675 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2676 *a predefined number Kstd1_deg
2677 */
2678 while ((strat->Ll >= 0)
2679 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2680 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2681 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2682 )
2683 {
2684 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2685 if(TEST_OPT_PROT) PrintS("D");
2686 }
2687 if (strat->Ll<0) break;
2688 else strat->noClearS=TRUE;
2689 }
2690 if (strat->Ll== 0) strat->interpt=TRUE;
2691 /* picks the last element from the lazyset L */
2692 strat->P = strat->L[strat->Ll];
2693 strat->Ll--;
2694
2695 if (pNext(strat->P.p) == strat->tail)
2696 {
2697 // deletes the short spoly
2699 pLmDelete(strat->P.p);
2700 else
2701 pLmFree(strat->P.p);
2702 strat->P.p = NULL;
2703 poly m1 = NULL, m2 = NULL;
2704
2705 // check that spoly creation is ok
2706 while (strat->tailRing != currRing &&
2707 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2708 {
2709 assume(m1 == NULL && m2 == NULL);
2710 // if not, change to a ring where exponents are at least
2711 // large enough
2712 if (!kStratChangeTailRing(strat))
2713 {
2714 WerrorS("OVERFLOW...");
2715 break;
2716 }
2717 }
2718 // create the real one
2719 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2720 strat->tailRing, m1, m2, strat->R);
2721 }
2722 else if (strat->P.p1 == NULL)
2723 {
2724 if (strat->minim > 0)
2725 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2726 // for input polys, prepare reduction
2727 strat->P.PrepareRed(strat->use_buckets);
2728 }
2729
2730 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2731 {
2732 red_result = 0;
2733 }
2734 else
2735 {
2736 if (TEST_OPT_PROT)
2737 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2738 &olddeg,&reduc,strat, red_result);
2739
2740 /* reduction of the element chosen from L */
2741 red_result = strat->red(&strat->P,strat);
2742 if (errorreported) break;
2743 }
2744
2745 if (strat->overflow)
2746 {
2747 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2748 }
2749
2750 // reduction to non-zero new poly
2751 if (red_result == 1)
2752 {
2753 // get the polynomial (canonicalize bucket, make sure P.p is set)
2754 strat->P.GetP(strat->lmBin);
2755 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2756 // but now, for entering S, T, we reset it
2757 // in the inhomogeneous case: FDeg == pFDeg
2758 if (strat->homog) strat->initEcart(&(strat->P));
2759
2760 /* statistic */
2761 if (TEST_OPT_PROT) PrintS("s");
2762
2763 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2764
2765 // reduce the tail and normalize poly
2766 // in the ring case we cannot expect LC(f) = 1,
2767 strat->redTailChange=FALSE;
2768
2769 /* if we are computing over Z we always want to try and cut down
2770 * the coefficients in the tail terms */
2772 {
2773 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2774 }
2775
2777 {
2778 strat->P.pCleardenom();
2780 {
2781 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2782 strat->P.pCleardenom();
2783 if (strat->redTailChange) { strat->P.t_p=NULL; }
2784 }
2785 }
2786 else
2787 {
2788 strat->P.pNorm();
2790 {
2791 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2792 if (strat->redTailChange) { strat->P.t_p=NULL; }
2793 }
2794 }
2795
2796#ifdef KDEBUG
2797 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2798#endif /* KDEBUG */
2799
2800 // min_std stuff
2801 if ((strat->P.p1==NULL) && (strat->minim>0))
2802 {
2803 if (strat->minim==1)
2804 {
2805 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2806 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2807 }
2808 else
2809 {
2810 strat->M->m[minimcnt]=strat->P.p2;
2811 strat->P.p2=NULL;
2812 }
2813 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2814 pNext(strat->M->m[minimcnt])
2815 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2816 strat->tailRing, currRing,
2817 currRing->PolyBin);
2818 minimcnt++;
2819 }
2820
2821 // enter into S, L, and T
2822 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2823 {
2824 strat->P.SetShortExpVector();
2825 enterT(&strat->P, strat);
2827 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2828 else
2829 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2830 // posInS only depends on the leading term
2831 strat->enterS(&strat->P, pos, strat, strat->tl);
2832#if 0
2833 int pl=pLength(strat->P.p);
2834 if (pl==1)
2835 {
2836 //if (TEST_OPT_PROT)
2837 //PrintS("<1>");
2838 }
2839 else if (pl==2)
2840 {
2841 //if (TEST_OPT_PROT)
2842 //PrintS("<2>");
2843 }
2844#endif
2845 }
2846 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2847// Print("[%d]",hilbeledeg);
2848 kDeleteLcm(&strat->P);
2849 if (strat->s_poly!=NULL)
2850 {
2851 // the only valid entries are: strat->P.p,
2852 // strat->tailRing (read-only, keep it)
2853 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2854 if (strat->s_poly(strat))
2855 {
2856 // we are called AFTER enterS, i.e. if we change P
2857 // we have to add it also to S/T
2858 // and add pairs
2859 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2860 enterT(&strat->P, strat);
2862 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2863 else
2864 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2865 strat->enterS(&strat->P, pos, strat, strat->tl);
2866 }
2867 }
2868 }
2869 else if (strat->P.p1 == NULL && strat->minim > 0)
2870 {
2871 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2872 }
2873
2874#ifdef KDEBUG
2875 strat->P.Init();
2876 kTest_TS(strat);
2877#endif /* KDEBUG */
2878 }
2879#ifdef KDEBUG
2880 if (TEST_OPT_DEBUG) messageSets(strat);
2881#endif /* KDEBUG */
2882
2883 if (TEST_OPT_SB_1)
2884 {
2886 {
2887 int k=1;
2888 int j;
2889 while(k<=strat->sl)
2890 {
2891 j=0;
2892 loop
2893 {
2894 if (j>=k) break;
2895 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2896 j++;
2897 }
2898 k++;
2899 }
2900 }
2901 }
2902 /* complete reduction of the standard basis--------- */
2903 if (TEST_OPT_REDSB)
2904 {
2905 completeReduce(strat);
2906 if (strat->completeReduce_retry)
2907 {
2908 // completeReduce needed larger exponents, retry
2909 // to reduce with S (instead of T)
2910 // and in currRing (instead of strat->tailRing)
2911#ifdef HAVE_TAIL_RING
2912 if(currRing->bitmask>strat->tailRing->bitmask)
2913 {
2915 cleanT(strat);strat->tailRing=currRing;
2916 int i;
2917 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2918 completeReduce(strat);
2919 }
2920 if (strat->completeReduce_retry)
2921#endif
2922 Werror("exponent bound is %ld",currRing->bitmask);
2923 }
2924 }
2925 else if (TEST_OPT_PROT) PrintLn();
2926 /* release temp data-------------------------------- */
2927 exitBuchMora(strat);
2928 /* postprocessing for GB over ZZ --------------------*/
2929 if (!errorreported)
2930 {
2932 {
2933 for(int i = 0;i<=strat->sl;i++)
2934 {
2935 if(!nGreaterZero(pGetCoeff(strat->S[i])))
2936 {
2937 strat->S[i] = pNeg(strat->S[i]);
2938 }
2939 }
2940 finalReduceByMon(strat);
2941 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2942 {
2943 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2944 {
2945 strat->S[i] = pNeg(strat->Shdl->m[i]);
2946 }
2947 }
2948 }
2949 //else if (rField_is_Ring(currRing))
2950 // finalReduceByMon(strat);
2951 }
2952// if (TEST_OPT_WEIGHTM)
2953// {
2954// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2955// if (ecartWeights)
2956// {
2957// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2958// ecartWeights=NULL;
2959// }
2960// }
2961 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
2962 SI_RESTORE_OPT1(save);
2963 /* postprocessing for GB over Q-rings ------------------*/
2964 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2965
2966 idTest(strat->Shdl);
2967
2968 return (strat->Shdl);
2969}
#define BITSET
Definition auxiliary.h:85
int BOOLEAN
Definition auxiliary.h:88
int k
Definition cfEzgcd.cc:99
int syzComp
Definition kutil.h:353
int * S_2_R
Definition kutil.h:341
ring tailRing
Definition kutil.h:342
int Ll
Definition kutil.h:350
omBin lmBin
Definition kutil.h:343
char honey
Definition kutil.h:374
int minim
Definition kutil.h:356
TObject ** R
Definition kutil.h:339
ideal M
Definition kutil.h:304
int tl
Definition kutil.h:349
poly tail
Definition kutil.h:333
ideal Shdl
Definition kutil.h:302
void(* enterS)(LObject *h, int pos, kStrategy strat, int atR)
Definition kutil.h:285
pShallowCopyDeleteProc p_shallow_copy_delete
Definition kutil.h:337
char use_buckets
Definition kutil.h:380
char interpt
Definition kutil.h:368
char redTailChange
Definition kutil.h:396
char completeReduce_retry
Definition kutil.h:400
void(* initEcart)(TObject *L)
Definition kutil.h:281
char noClearS
Definition kutil.h:399
char overflow
Definition kutil.h:401
LSet L
Definition kutil.h:326
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:279
unsigned long * sevS
Definition kutil.h:321
char homog
Definition kutil.h:369
s_poly_proc_t s_poly
Definition kutil.h:299
const CanonicalForm & w
Definition facAbsFact.cc:51
int j
Definition facHensel.cc:110
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define idTest(id)
Definition ideals.h:47
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition kInline.h:1212
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition kInline.h:1235
void khCheck(ideal Q, intvec *w, bigintmat *hilb, int &eledeg, int &count, kStrategy strat)
Definition khstd.cc:28
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition kspoly.cc:1203
void initBba(kStrategy strat)
Definition kstd1.cc:1690
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9749
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7463
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1067
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4487
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:7140
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9580
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10939
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9837
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4663
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10459
void enterT(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:9143
void cleanT(kStrategy strat)
Definition kutil.cc:557
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10051
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4457
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11036
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9435
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10257
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9664
void messageSets(kStrategy strat)
Definition kutil.cc:7536
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7504
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10847
void initHilbCrit(ideal, ideal, bigintmat **hilb, kStrategy strat)
Definition kutil.cc:9417
static void kDeleteLcm(LObject *P)
Definition kutil.h:876
#define assume(x)
Definition mod2.h:389
#define pNext(p)
Definition monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define nGreaterZero(n)
Definition numbers.h:27
#define NULL
Definition omList.c:12
VAR BOOLEAN siCntrlc
Definition options.c:14
#define TEST_OPT_IDLIFT
Definition options.h:131
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define TEST_OPT_REDTAIL
Definition options.h:118
#define SI_SAVE_OPT1(A)
Definition options.h:21
#define SI_RESTORE_OPT1(A)
Definition options.h:24
#define TEST_OPT_OLDSTD
Definition options.h:125
#define TEST_OPT_REDSB
Definition options.h:106
#define TEST_OPT_DEGBOUND
Definition options.h:115
#define TEST_OPT_SB_1
Definition options.h:121
#define TEST_OPT_PROT
Definition options.h:105
#define TEST_OPT_DEBUG
Definition options.h:110
#define TEST_OPT_CONTENTSB
Definition options.h:129
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
static int pLength(poly a)
Definition p_polys.h:190
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
#define pNeg(p)
Definition polys.h:199
#define pGetComp(p)
Component.
Definition polys.h:38
#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
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314
void Werror(const char *fmt,...)
Definition reporter.cc:189
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:520
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:774
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define IDELEMS(i)
#define Q
Definition sirandom.c:26
#define loop
Definition structs.h:71

◆ bbaShift()

ideal bbaShift ( ideal F,
ideal Q,
intvec * w,
bigintmat * hilb,
kStrategy strat )

Definition at line 4577 of file kstd2.cc.

4578{
4579 int red_result = 1;
4580 int olddeg,reduc;
4581 int hilbeledeg=1,hilbcount=0,minimcnt=0;
4582 BOOLEAN withT = TRUE; // currently only T contains the shifts
4583 BITSET save;
4584 SI_SAVE_OPT1(save);
4585
4586 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
4588 initBuchMoraPosRing(strat);
4589 else
4590 initBuchMoraPos(strat);
4591 initHilbCrit(F,Q,&hilb,strat);
4592 initBba(strat);
4593 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
4594 /*Shdl=*/initBuchMora(F, Q,strat);
4595 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
4596 reduc = olddeg = 0;
4597
4598#ifndef NO_BUCKETS
4600 strat->use_buckets = 1;
4601#endif
4602 // redtailBBa against T for inhomogeneous input
4603 // if (!TEST_OPT_OLDSTD)
4604 // withT = ! strat->homog;
4605
4606 // strat->posInT = posInT_pLength;
4607 kTest_TS(strat);
4608
4609#ifdef HAVE_TAIL_RING
4610 // if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4611 // kStratInitChangeTailRing(strat);
4612 strat->tailRing=currRing;
4613#endif
4614
4615#ifdef KDEBUG
4616 //kDebugPrint(strat);
4617#endif
4618 /* compute------------------------------------------------------- */
4619 while (strat->Ll >= 0)
4620 {
4621 #ifdef KDEBUG
4622 if (TEST_OPT_DEBUG) messageSets(strat);
4623 #endif
4624 if (siCntrlc)
4625 {
4626 while (strat->Ll >= 0)
4627 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4628 strat->noClearS=TRUE;
4629 }
4631 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4632 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
4633 {
4634 /*
4635 *stops computation if
4636 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
4637 *a predefined number Kstd1_deg
4638 */
4639 while ((strat->Ll >= 0)
4640 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
4641 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4642 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
4643 )
4644 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4645 if (strat->Ll<0) break;
4646 else strat->noClearS=TRUE;
4647 }
4648 if (strat->Ll== 0) strat->interpt=TRUE;
4649 /* picks the last element from the lazyset L */
4650 strat->P = strat->L[strat->Ll];
4651 strat->Ll--;
4652
4653 if (pNext(strat->P.p) == strat->tail)
4654 {
4655 // deletes the short spoly
4657 pLmDelete(strat->P.p);
4658 else
4659 pLmFree(strat->P.p);
4660 strat->P.p = NULL;
4661 poly m1 = NULL, m2 = NULL;
4662
4663 // check that spoly creation is ok
4664 while (strat->tailRing != currRing &&
4665 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4666 {
4667 assume(m1 == NULL && m2 == NULL);
4668 // if not, change to a ring where exponents are at least
4669 // large enough
4670 if (!kStratChangeTailRing(strat))
4671 {
4672 WerrorS("OVERFLOW...");
4673 break;
4674 }
4675 }
4676 // create the real one
4677 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4678 strat->tailRing, m1, m2, strat->R);
4679 }
4680 else if (strat->P.p1 == NULL)
4681 {
4682 if (strat->minim > 0)
4683 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4684 // for input polys, prepare reduction
4685 strat->P.PrepareRed(strat->use_buckets);
4686 }
4687
4688 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
4689 {
4690 red_result = 0;
4691 }
4692 else
4693 {
4694 if (TEST_OPT_PROT)
4695 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4696 &olddeg,&reduc,strat, red_result);
4697
4698 /* reduction of the element chosen from L */
4699 red_result = strat->red(&strat->P,strat);
4700 if (errorreported) break;
4701 }
4702
4703 if (strat->overflow)
4704 {
4705 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4706 }
4707
4708 // reduction to non-zero new poly
4709 if (red_result == 1)
4710 {
4711 // get the polynomial (canonicalize bucket, make sure P.p is set)
4712 strat->P.GetP(strat->lmBin);
4713 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4714 // but now, for entering S, T, we reset it
4715 // in the inhomogeneous case: FDeg == pFDeg
4716 if (strat->homog) strat->initEcart(&(strat->P));
4717
4718 /* statistic */
4719 if (TEST_OPT_PROT) PrintS("s");
4720
4721 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4722
4723 // reduce the tail and normalize poly
4724 // in the ring case we cannot expect LC(f) = 1,
4725 strat->redTailChange=FALSE;
4726
4727 /* if we are computing over Z we always want to try and cut down
4728 * the coefficients in the tail terms */
4730 {
4731 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
4732 }
4733
4735 {
4736 strat->P.pCleardenom();
4738 {
4739 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
4740 strat->P.pCleardenom();
4741 if (strat->redTailChange)
4742 {
4743 strat->P.t_p=NULL;
4744 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4745 }
4746 }
4747 }
4748 else
4749 {
4750 strat->P.pNorm();
4752 {
4753 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4754 if (strat->redTailChange)
4755 {
4756 strat->P.t_p=NULL;
4757 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4758 }
4759 }
4760 }
4761
4762#ifdef KDEBUG
4763 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4764#endif /* KDEBUG */
4765
4766 // min_std stuff
4767 if ((strat->P.p1==NULL) && (strat->minim>0))
4768 {
4769 if (strat->minim==1)
4770 {
4771 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4772 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4773 }
4774 else
4775 {
4776 strat->M->m[minimcnt]=strat->P.p2;
4777 strat->P.p2=NULL;
4778 }
4779 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4780 pNext(strat->M->m[minimcnt])
4781 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4782 strat->tailRing, currRing,
4783 currRing->PolyBin);
4784 minimcnt++;
4785 }
4786
4787
4788 // enter into S, L, and T
4789 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4790 {
4791 enterT(&strat->P, strat);
4792 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4793 // posInS only depends on the leading term
4794 strat->enterS(&strat->P, pos, strat, strat->tl);
4795 if (!strat->rightGB)
4796 enterTShift(&strat->P, strat);
4797 }
4798
4799 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4800// Print("[%d]",hilbeledeg);
4801 kDeleteLcm(&strat->P);
4802 if (strat->s_poly!=NULL)
4803 {
4804 // the only valid entries are: strat->P.p,
4805 // strat->tailRing (read-only, keep it)
4806 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
4807 if (strat->s_poly(strat))
4808 {
4809 // we are called AFTER enterS, i.e. if we change P
4810 // we have to add it also to S/T
4811 // and add pairs
4812 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4813 enterT(&strat->P, strat);
4814 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4815 strat->enterS(&strat->P, pos, strat, strat->tl);
4816 if (!strat->rightGB)
4817 enterTShift(&strat->P,strat);
4818 }
4819 }
4820 }
4821 else if (strat->P.p1 == NULL && strat->minim > 0)
4822 {
4823 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4824 }
4825#ifdef KDEBUG
4826 strat->P.Init();
4827#endif /* KDEBUG */
4828 kTest_TS(strat);
4829 }
4830#ifdef KDEBUG
4831 if (TEST_OPT_DEBUG) messageSets(strat);
4832#endif /* KDEBUG */
4833 /* shift case: look for elt's in S such that they are divisible by elt in T */
4834 if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
4835 {
4837 {
4838 for (int k = 0; k <= strat->sl; ++k)
4839 {
4840 if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
4841 for (int j = 0; j<=strat->tl; ++j)
4842 {
4843 if (strat->T[j].p!=NULL)
4844 {
4845 // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
4846 assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
4847 assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
4848 if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
4849 {
4850 if (pLmCmp(strat->T[j].p, strat->S[k]) != 0)
4851 { // check whether LM is different
4852 deleteInS(k, strat);
4853 --k;
4854 break;
4855 }
4856 }
4857 }
4858 }
4859 }
4860 }
4861 }
4862 /* complete reduction of the standard basis--------- */
4863 if (TEST_OPT_REDSB)
4864 {
4865 completeReduce(strat, TRUE); //shift: withT = TRUE
4866 if (strat->completeReduce_retry)
4867 {
4868 // completeReduce needed larger exponents, retry
4869 // to reduce with S (instead of T)
4870 // and in currRing (instead of strat->tailRing)
4871#ifdef HAVE_TAIL_RING
4872 if(currRing->bitmask>strat->tailRing->bitmask)
4873 {
4875 cleanT(strat);strat->tailRing=currRing;
4876 int i;
4877 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
4878 WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know
4879 completeReduce(strat);
4880 }
4881 if (strat->completeReduce_retry)
4882#endif
4883 Werror("exponent bound is %ld",currRing->bitmask);
4884 }
4885 }
4886 else if (TEST_OPT_PROT) PrintLn();
4887
4888 /* release temp data-------------------------------- */
4889 exitBuchMora(strat);
4890 /* postprocessing for GB over ZZ --------------------*/
4891 if (!errorreported)
4892 {
4894 {
4895 for(int i = 0;i<=strat->sl;i++)
4896 {
4897 if(!nGreaterZero(pGetCoeff(strat->S[i])))
4898 {
4899 strat->S[i] = pNeg(strat->S[i]);
4900 }
4901 }
4902 finalReduceByMon(strat);
4903 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
4904 {
4905 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
4906 {
4907 strat->S[i] = pNeg(strat->Shdl->m[i]);
4908 }
4909 }
4910 }
4911 //else if (rField_is_Ring(currRing))
4912 // finalReduceByMon(strat);
4913 }
4914// if (TEST_OPT_WEIGHTM)
4915// {
4916// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
4917// if (ecartWeights)
4918// {
4919// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
4920// ecartWeights=NULL;
4921// }
4922// }
4923 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
4924 SI_RESTORE_OPT1(save);
4925 /* postprocessing for GB over Q-rings ------------------*/
4926 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
4927
4928 idTest(strat->Shdl);
4929
4930 return (strat->Shdl);
4931}
TSet T
Definition kutil.h:325
char rightGB
Definition kutil.h:366
unsigned long * sevT
Definition kutil.h:324
intset fromQ
Definition kutil.h:320
#define WarnS
Definition emacs.cc:78
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:12927
void enterTShift(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:12957
void deleteInS(int i, kStrategy strat)
Definition kutil.cc:1132
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
Definition polys.h:147
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153

◆ cancelunit()

void cancelunit ( LObject * p,
BOOLEAN inNF = FALSE )

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:747
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 pSetCoeff0(p, n)
Definition monomials.h:59
#define nCopy(n)
Definition numbers.h:15
#define nInit(i)
Definition numbers.h:24
#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
#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:773
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603

◆ chainCritNormal()

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

Definition at line 3204 of file kutil.cc.

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

3446{
3447 if (strat->pairtest!=NULL)
3448 {
3449 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3450 strat->pairtest=NULL;
3451 }
3452 /*
3453 *the elements of B enter L
3454 */
3455 kMergeBintoL(strat);
3456}

◆ chainCritSig()

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

Definition at line 3461 of file kutil.cc.

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

◆ 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}
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

◆ clearS()

KINLINE void clearS ( poly p,
unsigned long p_sev,
int * at,
int * k,
kStrategy strat )

Definition at line 1235 of file kInline.h.

1237{
1238 assume(p_sev == pGetShortExpVector(p));
1239 if (strat->noClearS) return;
1241 {
1242 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1243 return;
1244 if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1245 return;
1246 }
1247 else
1248 {
1249 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1250 }
1251 deleteInS((*at),strat);
1252 (*at)--;
1253 (*k)--;
1254}

◆ completeReduce()

void completeReduce ( kStrategy strat,
BOOLEAN withT = FALSE )

Definition at line 10257 of file kutil.cc.

10258{
10259 int i;
10260 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10261 LObject L;
10262
10263#ifdef KDEBUG
10264 // need to set this: during tailreductions of T[i], T[i].max is out of
10265 // sync
10266 sloppy_max = TRUE;
10267#endif
10268
10269 strat->noTailReduction = FALSE;
10270 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10271 if (TEST_OPT_PROT)
10272 {
10273 PrintLn();
10274// if (timerv) writeTime("standard base computed:");
10275 }
10276 if (TEST_OPT_PROT)
10277 {
10278 Print("(S:%d)",strat->sl);mflush();
10279 }
10280 for (i=strat->sl; i>=low; i--)
10281 {
10282 int end_pos=strat->sl;
10283 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10284 if (strat->ak==0) end_pos=i-1;
10285 TObject* T_j = strat->s_2_t(i);
10286 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10287 {
10288 L = *T_j;
10289 #ifdef KDEBUG
10290 if (TEST_OPT_DEBUG)
10291 {
10292 Print("test S[%d]:",i);
10293 p_wrp(L.p,currRing,strat->tailRing);
10294 PrintLn();
10295 }
10296 #endif
10298 strat->S[i] = redtailBba(&L, end_pos, strat, withT,FALSE /*no normalize*/);
10299 else
10300 strat->S[i] = redtail(&L, strat->sl, strat);
10301 #ifdef KDEBUG
10302 if (TEST_OPT_DEBUG)
10303 {
10304 Print("to (tailR) S[%d]:",i);
10305 p_wrp(strat->S[i],currRing,strat->tailRing);
10306 PrintLn();
10307 }
10308 #endif
10309
10310 if (strat->redTailChange)
10311 {
10312 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10313 if (pNext(T_j->p) != NULL)
10314 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10315 else
10316 T_j->max_exp = NULL;
10317 }
10319 T_j->pCleardenom();
10320 }
10321 else
10322 {
10323 assume(currRing == strat->tailRing);
10324 #ifdef KDEBUG
10325 if (TEST_OPT_DEBUG)
10326 {
10327 Print("test S[%d]:",i);
10328 p_wrp(strat->S[i],currRing,strat->tailRing);
10329 PrintLn();
10330 }
10331 #endif
10333 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10334 else
10335 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10337 {
10339 {
10340 number n;
10341 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10342 if (!nIsOne(n))
10343 {
10345 denom->n=nInvers(n);
10346 denom->next=DENOMINATOR_LIST;
10347 DENOMINATOR_LIST=denom;
10348 }
10349 nDelete(&n);
10350 }
10351 else
10352 {
10353 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10354 }
10355 }
10356 #ifdef KDEBUG
10357 if (TEST_OPT_DEBUG)
10358 {
10359 Print("to (-tailR) S[%d]:",i);
10360 p_wrp(strat->S[i],currRing,strat->tailRing);
10361 PrintLn();
10362 }
10363 #endif
10364 }
10365 if (TEST_OPT_PROT)
10366 PrintS("-");
10367 }
10368 if (TEST_OPT_PROT) PrintLn();
10369#ifdef KDEBUG
10370 sloppy_max = FALSE;
10371#endif
10372}
char noTailReduction
Definition kutil.h:375
int ak
Definition kutil.h:352
KINLINE TObject * s_2_t(int i)
Definition kInline.h:47
#define Print
Definition emacs.cc:80
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:6836
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kutil.cc:6912
STATIC_VAR BOOLEAN sloppy_max
Definition kutil.cc:788
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)
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:3002
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
#define mflush()
Definition reporter.h:58

◆ deleteHC() [1/2]

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

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:328
char LDegLast
Definition kutil.h:382
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:916
static int p_Cmp(poly p1, poly p2, ring r)
Definition p_polys.h:1748
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1601

◆ 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

◆ deleteInL()

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

Definition at line 1208 of file kutil.cc.

1209{
1210 if (set[j].lcm!=NULL)
1211 {
1212 kDeleteLcm(&set[j]);
1213 }
1214 if (set[j].sig!=NULL)
1215 {
1216 if (pGetCoeff(set[j].sig) != NULL)
1217 pLmDelete(set[j].sig);
1218 else
1219 pLmFree(set[j].sig);
1220 }
1221 if (set[j].p!=NULL)
1222 {
1223 if (pNext(set[j].p) == strat->tail)
1224 {
1225 if (pGetCoeff(set[j].p) != NULL)
1226 pLmDelete(set[j].p);
1227 else
1228 pLmFree(set[j].p);
1229 /*- tail belongs to several int spolys -*/
1230 }
1231 else
1232 {
1233 // search p in T, if it is there, do not delete it
1234 if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1235 {
1236 // assure that for global orderings kFindInT fails
1237 //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1238 set[j].Delete();
1239 }
1240 }
1241 }
1242 #ifdef HAVE_SHIFTBBA
1243 if (is_shifted_p1(/*strat->P.p1,*/strat))
1244 {
1245 // clean up strat->P.p1: may be shifted
1246 pLmDelete(strat->P.p1);
1247 strat->P.p1=NULL;
1248 }
1249 #endif
1250 if (*length > 0 && j < *length)
1251 {
1252#ifdef ENTER_USE_MEMMOVE
1253 memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1254#else
1255 int i;
1256 for (i=j; i < (*length); i++)
1257 set[i] = set[i+1];
1258#endif
1259 }
1260#ifdef KDEBUG
1261 set[*length].Init();
1262#endif
1263 (*length)--;
1264}
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:703
static BOOLEAN is_shifted_p1(const kStrategy strat)
Definition kutil.cc:1181
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:709

◆ deleteInS()

void deleteInS ( int i,
kStrategy strat )

Definition at line 1132 of file kutil.cc.

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly h,
kStrategy strat )

Definition at line 4232 of file kutil.cc.

4233{
4234 if (nIsOne(pGetCoeff(h))) return;
4235 number gcd;
4236 number zero=n_Init(0,currRing->cf);
4237 bool go = false;
4238 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4239 {
4240 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4241 go = true;
4242 }
4243 else
4244 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4245 if (go || !nIsOne(gcd))
4246 {
4247 poly p = h->next;
4248 if (!go)
4249 {
4250 number tmp = gcd;
4251 gcd = n_Ann(gcd,currRing->cf);
4252 nDelete(&tmp);
4253 }
4254 p_Test(p,strat->tailRing);
4255 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4256
4257 if (p != NULL)
4258 {
4259 if (TEST_OPT_PROT)
4260 {
4261 PrintS("Z");
4262 }
4263#ifdef KDEBUG
4264 if (TEST_OPT_DEBUG)
4265 {
4266 PrintS("--- create zero spoly: ");
4267 p_wrp(h,currRing,strat->tailRing);
4268 PrintS(" ---> ");
4269 }
4270#endif
4271 poly tmp = pInit();
4272 pSetCoeff0(tmp, pGetCoeff(p));
4273 for (int i = 1; i <= rVar(currRing); i++)
4274 {
4275 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4276 }
4278 {
4279 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4280 }
4281 p_Setm(tmp, currRing);
4282 p = p_LmFreeAndNext(p, strat->tailRing);
4283 pNext(tmp) = p;
4284 LObject Lp;
4285 Lp.Init();
4286 Lp.p = tmp;
4287 Lp.tailRing = strat->tailRing;
4288 int posx;
4289 if (Lp.p!=NULL)
4290 {
4291 strat->initEcart(&Lp);
4292 if (strat->Ll==-1)
4293 posx =0;
4294 else
4295 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4296 Lp.sev = pGetShortExpVector(Lp.p);
4297 if (strat->tailRing != currRing)
4298 {
4299 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4300 }
4301#ifdef KDEBUG
4302 if (TEST_OPT_DEBUG)
4303 {
4304 p_wrp(tmp,currRing,strat->tailRing);
4305 PrintLn();
4306 }
4307#endif
4308 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4309 }
4310 }
4311 }
4312 nDelete(&zero);
4313 nDelete(&gcd);
4314}
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:283
int Lmax
Definition kutil.h:350
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:667
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:682
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:541
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:959
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1269
#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 4316 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1269 of file kutil.cc.

1270{
1271 // this should be corrected
1272 assume(p.FDeg == p.pFDeg());
1273
1274 if ((*length)>=0)
1275 {
1276 if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,*LSetmax);
1277 if (at <= (*length))
1278#ifdef ENTER_USE_MEMMOVE
1279 memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1280#else
1281 for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1282#endif
1283 }
1284 else at = 0;
1285 (*set)[at] = p;
1286 (*length)++;
1287}
static void enlargeL(LSet *L, int *length, const int incr)
Definition kutil.cc:668

◆ enterOnePairNormal()

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

Definition at line 1939 of file kutil.cc.

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

◆ 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 12143 of file kutil.cc.

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

◆ enterpairs()

void enterpairs ( poly h,
int k,
int ec,
int pos,
kStrategy strat,
int atR = -1 )

Definition at line 4487 of file kutil.cc.

4488{
4489 int j=pos;
4490
4492 initenterpairs(h,k,ecart,0,strat, atR);
4493 if ( (!strat->fromT)
4494 && ((strat->syzComp==0)
4495 ||(pGetComp(h)<=strat->syzComp)))
4496 {
4497 unsigned long h_sev = pGetShortExpVector(h);
4498 loop
4499 {
4500 if (j > k) break;
4501 clearS(h,h_sev, &j,&k,strat);
4502 j++;
4503 }
4504 }
4505}
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:3809

◆ enterpairsShift()

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

Definition at line 12927 of file kutil.cc.

12928{
12929 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12930 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
12931 int j=pos;
12932
12933 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
12934 initenterpairsShift(h,k,ecart,0,strat, atR);
12935 if ( (!strat->fromT)
12936 && ((strat->syzComp==0)
12937 ||(pGetComp(h)<=strat->syzComp)))
12938 {
12939 unsigned long h_sev = pGetShortExpVector(h);
12940 loop
12941 {
12942 if (j > k) break;
12943 // TODO this currently doesn't clear all possible elements because of commutative division
12944 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
12945 clearS(h,h_sev, &j,&k,strat);
12946 j++;
12947 }
12948 }
12949}
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:12485

◆ enterpairsSig()

void enterpairsSig ( poly h,
poly hSig,
int from,
int k,
int ec,
int pos,
kStrategy strat,
int atR = -1 )

Definition at line 4513 of file kutil.cc.

4514{
4515 int j=pos;
4517 initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4518 if ( (!strat->fromT)
4519 && ((strat->syzComp==0)
4520 ||(pGetComp(h)<=strat->syzComp)))
4521 {
4522 unsigned long h_sev = pGetShortExpVector(h);
4523 loop
4524 {
4525 if (j > k) break;
4526 clearS(h,h_sev, &j,&k,strat);
4527 j++;
4528 }
4529 }
4530}
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3874

◆ enterSBba()

void enterSBba ( LObject * p,
int atS,
kStrategy strat,
int atR = -1 )

Definition at line 8792 of file kutil.cc.

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

◆ enterSBbaShift()

void enterSBbaShift ( LObject * p,
int atS,
kStrategy strat,
int atR = -1 )

Definition at line 8892 of file kutil.cc.

8893{
8894 enterSBba(p, atS, strat, atR);
8895
8896 int maxPossibleShift = p_mLPmaxPossibleShift(p->p, strat->tailRing);
8897 for (int i = maxPossibleShift; i > 0; i--)
8898 {
8899 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
8900 // in `kNF2` because of lazy poly normalizations.
8901 LObject qq(p_Copy(p->p, strat->tailRing));
8902 p_mLPshift(qq.p, i, strat->tailRing);
8903 qq.shift = i;
8904 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
8905 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
8906 enterSBba(&qq, atS, strat, -1);
8907 }
8908}
void enterSBba(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8792
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

◆ entersets()

void entersets ( LObject h)

◆ enterSMora()

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

Definition at line 1629 of file kstd1.cc.

1630{
1631 enterSBba(p, atS, strat, atR);
1632 #ifdef KDEBUG
1633 if (TEST_OPT_DEBUG)
1634 {
1635 Print("new s%d:",atS);
1636 p_wrp(p->p,currRing,strat->tailRing);
1637 PrintLn();
1638 }
1639 #endif
1640 HEckeTest(p->p,strat);
1641 if (strat->kAllAxis)
1642 {
1643 if (newHEdge(strat))
1644 {
1645 firstUpdate(strat);
1646 if (TEST_OPT_FINDET)
1647 return;
1648
1649 /*- cuts elements in L above noether and reorders L -*/
1650 updateLHC(strat);
1651 /*- reorders L with respect to posInL -*/
1652 reorderL(strat);
1653 }
1654 }
1655 else if ((strat->kNoether==NULL)
1656 && (TEST_OPT_FASTHC))
1657 {
1658 if (strat->posInLOldFlag)
1659 {
1660 missingAxis(&strat->lastAxis,strat);
1661 if (strat->lastAxis)
1662 {
1663 strat->posInLOld = strat->posInL;
1664 strat->posInLOldFlag = FALSE;
1665 strat->posInL = posInL10;
1666 strat->posInLDependsOnLength = TRUE;
1667 updateL(FALSE,strat);
1668 reorderL(strat);
1669 }
1670 }
1671 else if (strat->lastAxis)
1672 updateL(TRUE,strat);
1673 }
1674}
char posInLOldFlag
Definition kutil.h:379
int lastAxis
Definition kutil.h:354
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:287
char kAllAxis
Definition kutil.h:373
char posInLDependsOnLength
Definition kutil.h:386
static void firstUpdate(kStrategy strat)
Definition kstd1.cc:1566
static void updateL(BOOLEAN searchPP, kStrategy strat)
Definition kstd1.cc:1394
static void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1279
static void updateLHC(kStrategy strat)
Definition kstd1.cc:1474
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1360
static void reorderL(kStrategy strat)
Definition kstd1.cc:1222
void HEckeTest(poly pp, kStrategy strat)
Definition kutil.cc:493
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10379
#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 1682 of file kstd1.cc.

1683{
1684 enterSBba(p, atS, strat, atR);
1685 if ((!strat->kAllAxis) || (strat->kNoether!=NULL)) HEckeTest(p->p,strat);
1686 if (strat->kAllAxis)
1687 newHEdge(strat);
1688}

◆ enterSSba()

void enterSSba ( LObject * p,
int atS,
kStrategy strat,
int atR = -1 )

Definition at line 8915 of file kutil.cc.

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

◆ 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:322
int syzmax
Definition kutil.h:348
int syzl
Definition kutil.h:348
polyset syz
Definition kutil.h:306
char newt
Definition kutil.h:398
#define pLtCmp(p, q)
Definition polys.h:124

◆ enterT()

void enterT ( LObject * p,
kStrategy strat,
int atT = -1 )

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,strat->tmax);
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}
int tmax
Definition kutil.h:349
omBin tailBin
Definition kutil.h:344
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
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:789
#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:731

◆ enterT_strong()

void enterT_strong ( LObject * p,
kStrategy strat,
int atT = -1 )

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,strat->tmax);
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:521

◆ enterTShift()

void enterTShift ( LObject * p,
kStrategy strat,
int atT = -1 )

Definition at line 12957 of file kutil.cc.

12958{
12959 /* determine how many elements we have to insert */
12960 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
12961 /* hence, a total number of elt's to add is: */
12962 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
12963 pAssume(p->p != NULL);
12964
12965 int maxPossibleShift = p_mLPmaxPossibleShift(p->p, strat->tailRing);
12966
12967 for (int i = 1; i <= maxPossibleShift; i++)
12968 {
12969 LObject qq;
12970 qq.p = pLPCopyAndShiftLM(p->p, i); // don't use Set() because it'll test the poly order
12971 qq.shift = i;
12972 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
12973
12974 enterT(&qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
12975 }
12976}
#define pAssume(cond)
Definition monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy strat)

Definition at line 9837 of file kutil.cc.

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

◆ exitSba()

void exitSba ( kStrategy strat)

Definition at line 10011 of file kutil.cc.

10012{
10013 /*- release temp data -*/
10015 cleanTSbaRing(strat);
10016 else
10017 cleanT(strat);
10018 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10019 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10020 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10021 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10022 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10023 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10024 if(strat->syzmax>0)
10025 {
10026 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10027 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10028 if (strat->sbaOrder == 1)
10029 {
10030 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10031 }
10032 }
10033 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10034 /*- set L: should be empty -*/
10035 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10036 /*- set B: should be empty -*/
10037 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10038 /*- set sig: no need for the signatures anymore -*/
10039 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10040 pLmDelete(&strat->tail);
10041 strat->syzComp=0;
10042}
int syzidxmax
Definition kutil.h:348
intset syzIdx
Definition kutil.h:312
unsigned sbaOrder
Definition kutil.h:315
void cleanTSbaRing(kStrategy strat)
Definition kutil.cc:616

◆ f5c()

void f5c ( kStrategy strat,
int & olddeg,
int & minimcnt,
int & hilbeledeg,
int & hilbcount,
int & srmax,
int & lrmax,
int & reduc,
ideal Q,
intvec * w,
bigintmat * hilb )

Definition at line 4265 of file kstd2.cc.

4268{
4269 int Ll_old, red_result = 1;
4270 int pos = 0;
4271 hilbeledeg=1;
4272 hilbcount=0;
4273 minimcnt=0;
4274 srmax = 0; // strat->sl is 0 at this point
4275 reduc = olddeg = lrmax = 0;
4276 // we cannot use strat->T anymore
4277 //cleanT(strat);
4278 //strat->tl = -1;
4279 Ll_old = strat->Ll;
4280 while (strat->tl >= 0)
4281 {
4282 if(!strat->T[strat->tl].is_redundant)
4283 {
4284 LObject h;
4285 h.p = strat->T[strat->tl].p;
4286 h.tailRing = strat->T[strat->tl].tailRing;
4287 h.t_p = strat->T[strat->tl].t_p;
4288 if (h.p!=NULL)
4289 {
4290 if (currRing->OrdSgn==-1)
4291 {
4292 cancelunit(&h);
4293 deleteHC(&h, strat);
4294 }
4295 if (h.p!=NULL)
4296 {
4298 {
4299 h.pCleardenom(); // also does remove Content
4300 }
4301 else
4302 {
4303 h.pNorm();
4304 }
4305 strat->initEcart(&h);
4307 pos = posInLF5CRing(strat->L, Ll_old+1,strat->Ll,&h,strat);
4308 else
4309 pos = strat->Ll+1;
4310 h.sev = pGetShortExpVector(h.p);
4311 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
4312 }
4313 }
4314 }
4315 strat->tl--;
4316 }
4317 strat->sl = -1;
4318#if 0
4319//#ifdef HAVE_TAIL_RING
4320 if(!rField_is_Ring()) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4322#endif
4323 //enterpairs(pOne(),0,0,-1,strat,strat->tl);
4324 //strat->sl = -1;
4325 /* picks the last element from the lazyset L */
4326 while (strat->Ll>Ll_old)
4327 {
4328 strat->P = strat->L[strat->Ll];
4329 strat->Ll--;
4330//#if 1
4331#ifdef DEBUGF5
4332 PrintS("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
4333 PrintS("-------------------------------------------------\n");
4334 pWrite(pHead(strat->P.p));
4335 pWrite(pHead(strat->P.p1));
4336 pWrite(pHead(strat->P.p2));
4337 printf("%d\n",strat->tl);
4338 PrintS("-------------------------------------------------\n");
4339#endif
4340 if (pNext(strat->P.p) == strat->tail)
4341 {
4342 // deletes the short spoly
4344 pLmDelete(strat->P.p);
4345 else
4346 pLmFree(strat->P.p);
4347
4348 // TODO: needs some masking
4349 // TODO: masking needs to vanish once the signature
4350 // stuff is completely implemented
4351 strat->P.p = NULL;
4352 poly m1 = NULL, m2 = NULL;
4353
4354 // check that spoly creation is ok
4355 while (strat->tailRing != currRing &&
4356 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4357 {
4358 assume(m1 == NULL && m2 == NULL);
4359 // if not, change to a ring where exponents are at least
4360 // large enough
4361 if (!kStratChangeTailRing(strat))
4362 {
4363 WerrorS("OVERFLOW...");
4364 break;
4365 }
4366 }
4367 // create the real one
4368 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4369 strat->tailRing, m1, m2, strat->R);
4370 }
4371 else if (strat->P.p1 == NULL)
4372 {
4373 if (strat->minim > 0)
4374 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4375 // for input polys, prepare reduction
4377 strat->P.PrepareRed(strat->use_buckets);
4378 }
4379
4380 if (strat->P.p == NULL && strat->P.t_p == NULL)
4381 {
4382 red_result = 0;
4383 }
4384 else
4385 {
4386 if (TEST_OPT_PROT)
4387 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4388 &olddeg,&reduc,strat, red_result);
4389
4390#ifdef DEBUGF5
4391 PrintS("Poly before red: ");
4392 pWrite(strat->P.p);
4393#endif
4394 /* complete reduction of the element chosen from L */
4395 red_result = strat->red2(&strat->P,strat);
4396 if (errorreported) break;
4397 }
4398
4399 if (strat->overflow)
4400 {
4401 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4402 }
4403
4404 // reduction to non-zero new poly
4405 if (red_result == 1)
4406 {
4407 // get the polynomial (canonicalize bucket, make sure P.p is set)
4408 strat->P.GetP(strat->lmBin);
4409 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4410 // but now, for entering S, T, we reset it
4411 // in the inhomogeneous case: FDeg == pFDeg
4412 if (strat->homog) strat->initEcart(&(strat->P));
4413
4414 /* statistic */
4415 if (TEST_OPT_PROT) PrintS("s");
4416 int pos;
4417 #if 1
4419 pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4420 else
4421 pos = posInSMonFirst(strat,strat->sl,strat->P.p);
4422 #else
4423 pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4424 #endif
4425 // reduce the tail and normalize poly
4426 // in the ring case we cannot expect LC(f) = 1,
4427#if F5CTAILRED
4428 BOOLEAN withT = TRUE;
4430 {
4431 strat->P.pCleardenom();
4433 {
4434 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4435 strat->P.pCleardenom();
4436 }
4437 }
4438 else
4439 {
4440 strat->P.pNorm();
4442 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4443 }
4444#endif
4445#ifdef KDEBUG
4446 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4447#endif /* KDEBUG */
4448
4449 // min_std stuff
4450 if ((strat->P.p1==NULL) && (strat->minim>0))
4451 {
4452 if (strat->minim==1)
4453 {
4454 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4455 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4456 }
4457 else
4458 {
4459 strat->M->m[minimcnt]=strat->P.p2;
4460 strat->P.p2=NULL;
4461 }
4462 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4463 pNext(strat->M->m[minimcnt])
4464 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4465 strat->tailRing, currRing,
4466 currRing->PolyBin);
4467 minimcnt++;
4468 }
4469
4470 // enter into S, L, and T
4471 // here we need to recompute new signatures, but those are trivial ones
4472 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4473 {
4474 enterT(&strat->P, strat);
4475 // posInS only depends on the leading term
4476 strat->enterS(&strat->P, pos, strat, strat->tl);
4477//#if 1
4478#ifdef DEBUGF5
4479 PrintS("ELEMENT ADDED TO GCURR DURING INTERRED: ");
4480 pWrite(pHead(strat->S[strat->sl]));
4481 pWrite(strat->sig[strat->sl]);
4482#endif
4483 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4484 }
4485 // Print("[%d]",hilbeledeg);
4486 kDeleteLcm(&strat->P);
4487 if (strat->sl>srmax) srmax = strat->sl;
4488 }
4489 else
4490 {
4491 // adds signature of the zero reduction to
4492 // strat->syz. This is the leading term of
4493 // syzygy and can be used in syzCriterion()
4494 // the signature is added if and only if the
4495 // pair was not detected by the rewritten criterion in strat->red = redSig
4496 if (strat->P.p1 == NULL && strat->minim > 0)
4497 {
4498 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4499 }
4500 }
4501
4502#ifdef KDEBUG
4503 strat->P.Init();
4504#endif /* KDEBUG */
4505 }
4506 int cc = 0;
4507 while (cc<strat->tl+1)
4508 {
4509 strat->T[cc].sig = pOne();
4510 p_SetComp(strat->T[cc].sig,cc+1,currRing);
4511 strat->T[cc].sevSig = pGetShortExpVector(strat->T[cc].sig);
4512 strat->sig[cc] = strat->T[cc].sig;
4513 strat->sevSig[cc] = strat->T[cc].sevSig;
4514 strat->T[cc].is_sigsafe = TRUE;
4515 cc++;
4516 }
4517 strat->max_lower_index = strat->tl;
4518 // set current signature index of upcoming iteration step
4519 // NOTE: this needs to be set here, as otherwise initSyzRules cannot compute
4520 // the corresponding syzygy rules correctly
4521 strat->currIdx = cc+1;
4522 for (int cd=strat->Ll; cd>=0; cd--)
4523 {
4524 p_SetComp(strat->L[cd].sig,cc+1,currRing);
4525 cc++;
4526 }
4527 for (cc=strat->sl+1; cc<IDELEMS(strat->Shdl); ++cc)
4528 strat->Shdl->m[cc] = NULL;
4529 #if 0
4530 printf("\nAfter f5c sorting\n");
4531 for(int i=0;i<=strat->sl;i++)
4532 pWrite(pHead(strat->S[i]));
4533 getchar();
4534 #endif
4535//#if 1
4536#if DEBUGF5
4537 PrintS("------------------- STRAT S ---------------------\n");
4538 cc = 0;
4539 while (cc<strat->tl+1)
4540 {
4541 pWrite(pHead(strat->S[cc]));
4542 pWrite(strat->sig[cc]);
4543 printf("- - - - - -\n");
4544 cc++;
4545 }
4546 PrintS("-------------------------------------------------\n");
4547 PrintS("------------------- STRAT T ---------------------\n");
4548 cc = 0;
4549 while (cc<strat->tl+1)
4550 {
4551 pWrite(pHead(strat->T[cc].p));
4552 pWrite(strat->T[cc].sig);
4553 printf("- - - - - -\n");
4554 cc++;
4555 }
4556 PrintS("-------------------------------------------------\n");
4557 PrintS("------------------- STRAT L ---------------------\n");
4558 cc = 0;
4559 while (cc<strat->Ll+1)
4560 {
4561 pWrite(pHead(strat->L[cc].p));
4562 pWrite(pHead(strat->L[cc].p1));
4563 pWrite(pHead(strat->L[cc].p2));
4564 pWrite(strat->L[cc].sig);
4565 printf("- - - - - -\n");
4566 cc++;
4567 }
4568 PrintS("-------------------------------------------------\n");
4569 printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx);
4570#endif
4571
4572}
CanonicalForm cd(bCommonDen(FF))
Definition cfModGcd.cc:4097
int currIdx
Definition kutil.h:316
int(* red2)(LObject *L, kStrategy strat)
Definition kutil.h:280
int max_lower_index
Definition kutil.h:317
int posInSMonFirst(const kStrategy strat, const int length, const poly p)
Definition kutil.cc:4764
int posInLF5CRing(const LSet set, int start, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5878
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365

◆ faugereRewCriterion()

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

Definition at line 6562 of file kutil.cc.

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

◆ 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 10847 of file kutil.cc.

10848{
10849 assume(strat->tl<0); /* can only be called with no elements in T:
10850 i.e. after exitBuchMora */
10851 /* do not use strat->S, strat->sl as they may be out of sync*/
10852 if(!nCoeff_is_Z(currRing->cf))
10853 return;
10854 poly p,pp;
10855 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
10856 {
10857 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
10858 {
10859 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
10860 {
10861 if((i != j) && (strat->Shdl->m[i] != NULL))
10862 {
10863 p = strat->Shdl->m[i];
10864 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
10865#if HAVE_SHIFTBBA
10866 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
10867#endif
10868 ))
10869 {
10870 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
10871 if (!nEqual(dummy,p->coef))
10872 {
10873 if (nIsZero(dummy))
10874 {
10875 nDelete(&dummy);
10876 pLmDelete(&strat->Shdl->m[i]);
10877 p=strat->Shdl->m[i];
10878 }
10879 else
10880 {
10881 p_SetCoeff(p,dummy,currRing);
10882 break;
10883 }
10884 }
10885 else
10886 {
10887 nDelete(&dummy);
10888 break;
10889 }
10890 }
10891 if (p!=NULL)
10892 {
10893 pp = pNext(p);
10894 while(pp != NULL)
10895 {
10896 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
10897#if HAVE_SHIFTBBA
10898 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
10899#endif
10900 )
10901 {
10902 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
10903 if (!nEqual(dummy,pp->coef))
10904 {
10905 p_SetCoeff(pp,dummy,currRing);
10906 if(nIsZero(pp->coef))
10907 {
10908 pLmDelete(&pNext(p));
10909 pp = pNext(p);
10910 }
10911 else
10912 {
10913 p = pp;
10914 pp = pNext(p);
10915 }
10916 }
10917 else
10918 {
10919 nDelete(&dummy);
10920 p = pp;
10921 pp = pNext(p);
10922 }
10923 }
10924 else
10925 {
10926 p = pp;
10927 pp = pNext(p);
10928 }
10929 }
10930 }
10931 }
10932 }
10933 //idPrint(strat->Shdl);
10934 }
10935 }
10936 idSkipZeroes(strat->Shdl);
10937}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:814
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:631
#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

◆ findMinLMPair()

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

◆ 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:331
#define pIsPurePower(p)
Definition polys.h:249
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:775

◆ homogTest()

BOOLEAN homogTest ( polyset F,
int Fmax )

◆ initBba()

void initBba ( kStrategy strat)

Definition at line 1690 of file kstd1.cc.

1691{
1692 /* setting global variables ------------------- */
1693 strat->enterS = enterSBba;
1694 strat->red = redHoney;
1695 if (strat->honey)
1696 strat->red = redHoney;
1697 else if (currRing->pLexOrder && !strat->homog)
1698 strat->red = redLazy;
1699 else
1700 {
1701 strat->LazyPass *=4;
1702 strat->red = redHomog;
1703 }
1705 {
1706 if (rField_is_Z(currRing))
1707 strat->red = redRing_Z;
1708 else
1709 strat->red = redRing;
1710 }
1711 if (TEST_OPT_IDLIFT
1712 && (!rIsNCRing(currRing))
1713 && (!rField_is_Ring(currRing)))
1714 strat->red=redLiftstd;
1715 if (currRing->pLexOrder && strat->honey)
1716 strat->initEcart = initEcartNormal;
1717 else
1718 strat->initEcart = initEcartBBA;
1719 if (strat->honey)
1721 else
1723// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1724// {
1725// //interred machen Aenderung
1726// strat->pOrigFDeg=pFDeg;
1727// strat->pOrigLDeg=pLDeg;
1728// //h=ggetid("ecart");
1729// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1730// //{
1731// // ecartWeights=iv2array(IDINTVEC(h));
1732// //}
1733// //else
1734// {
1735// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1736// /*uses automatic computation of the ecartWeights to set them*/
1737// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1738// }
1739// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1740// if (TEST_OPT_PROT)
1741// {
1742// for(i=1; i<=(currRing->N); i++)
1743// Print(" %d",ecartWeights[i]);
1744// PrintLn();
1745// mflush();
1746// }
1747// }
1748}
int LazyPass
Definition kutil.h:352
int redLiftstd(LObject *h, kStrategy strat)
Definition kLiftstd.cc:167
int redRing_Z(LObject *h, kStrategy strat)
Definition kstd2.cc:720
int redHoney(LObject *h, kStrategy strat)
Definition kstd2.cc:2110
int redHomog(LObject *h, kStrategy strat)
Definition kstd2.cc:1150
int redLazy(LObject *h, kStrategy strat)
Definition kstd2.cc:1905
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition kutil.cc:1315
void initEcartNormal(TObject *h)
Definition kutil.cc:1293
void initEcartBBA(TObject *h)
Definition kutil.cc:1301
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition kutil.cc:1308
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427

◆ initBuchMora()

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

Definition at line 9749 of file kutil.cc.

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

◆ 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:290
char z2homog
Definition kutil.h:371
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:289
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:1939
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3445
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:1334
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2221
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3520
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3204
void chainCritRing(poly p, int, kStrategy strat)
Definition kutil.cc:3996
static bool rIsSCA(const ring r)
Definition nc.h:190
#define TEST_OPT_WEIGHTM
Definition options.h:123
#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->homog)
9612 {
9613 strat->posInL = posInL110;
9614 strat->posInT = posInT110;
9615 }
9616 }
9617 else /* local/mixed ordering */
9618 {
9619 if (strat->homog)
9620 {
9621 strat->posInL = posInL11;
9622 strat->posInT = posInT11;
9623 }
9624 else
9625 {
9626 if ((currRing->order[0]==ringorder_c)
9627 ||(currRing->order[0]==ringorder_C))
9628 {
9629 strat->posInL = posInL17_c;
9630 strat->posInT = posInT17_c;
9631 }
9632 else
9633 {
9634 strat->posInL = posInL17;
9635 strat->posInT = posInT17;
9636 }
9637 }
9638 }
9639 if (strat->minim>0) strat->posInL =posInLSpecial;
9640 // for further tests only
9641 if ((BTEST1(11)) || (BTEST1(12)))
9642 strat->posInL = posInL11;
9643 else if ((BTEST1(13)) || (BTEST1(14)))
9644 strat->posInL = posInL13;
9645 else if ((BTEST1(15)) || (BTEST1(16)))
9646 strat->posInL = posInL15;
9647 else if ((BTEST1(17)) || (BTEST1(18)))
9648 strat->posInL = posInL17;
9649 if (BTEST1(11))
9650 strat->posInT = posInT11;
9651 else if (BTEST1(13))
9652 strat->posInT = posInT13;
9653 else if (BTEST1(15))
9654 strat->posInT = posInT15;
9655 else if ((BTEST1(17)))
9656 strat->posInT = posInT17;
9657 else if ((BTEST1(19)))
9658 strat->posInT = posInT19;
9659 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9660 strat->posInT = posInT1;
9662}
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6058
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5278
int posInT11(const TSet set, const int length, LObject &p)
Definition kutil.cc:4953
int posInT1(const TSet set, const int length, LObject &p)
Definition kutil.cc:4896
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:5146
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4885
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6145
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:5117
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5611
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6180
int posInT17_c(const TSet set, const int length, LObject &p)
Definition kutil.cc:5384
int posInT15(const TSet set, const int length, LObject &p)
Definition kutil.cc:5184
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5567
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6255
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5029
int posInT19(const TSet set, const int length, LObject &p)
Definition kutil.cc:5510
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6348
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5802
@ ringorder_C
Definition ring.h:74
@ ringorder_c
Definition ring.h:73

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy strat)

Definition at line 9664 of file kutil.cc.

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

◆ initEcartBBA()

void initEcartBBA ( TObject * h)

Definition at line 1301 of file kutil.cc.

1302{
1303 h->FDeg = h->pFDeg();
1304 (*h).ecart = 0;
1305 h->length=h->pLength=pLength(h->p);
1306}

◆ initEcartNormal()

void initEcartNormal ( TObject * h)

Definition at line 1293 of file kutil.cc.

1294{
1295 h->FDeg = h->pFDeg();
1296 h->ecart = h->pLDeg() - h->FDeg;
1297 // h->length is set by h->pLDeg
1298 h->length=h->pLength=pLength(h->p);
1299}

◆ initEcartPairBba()

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

Definition at line 1308 of file kutil.cc.

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

◆ initEcartPairMora()

void initEcartPairMora ( 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 = si_max(ecartF,ecartG);
1319 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1320 (*Lp).length = 0;
1321}
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 = -1 )

Definition at line 3809 of file kutil.cc.

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

◆ 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

◆ initL()

LSet initL ( int nr = setmaxL)
inlinestatic

Definition at line 417 of file kutil.h.

418{ return (LSet)omAlloc(nr*sizeof(LObject)); }
LObject * LSet
Definition kutil.h:61

◆ initR()

KINLINE TObject ** initR ( )

Definition at line 95 of file kInline.h.

96{
97 return (TObject**) omAlloc0(setmaxT*sizeof(TObject*));
98}
#define omAlloc0(size)

◆ initS()

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

Definition at line 7586 of file kutil.cc.

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

◆ initSba()

void initSba ( ideal F,
kStrategy strat )

Definition at line 1750 of file kstd1.cc.

1751{
1752 int i;
1753 //idhdl h;
1754 /* setting global variables ------------------- */
1755 strat->enterS = enterSSba;
1756 strat->red2 = redHoney;
1757 if (strat->honey)
1758 strat->red2 = redHoney;
1759 else if (currRing->pLexOrder && !strat->homog)
1760 strat->red2 = redLazy;
1761 else
1762 {
1763 strat->LazyPass *=4;
1764 strat->red2 = redHomog;
1765 }
1767 {
1769 {strat->red2 = redRiloc;}
1770 else
1771 {strat->red2 = redRing;}
1772 }
1773 if (currRing->pLexOrder && strat->honey)
1774 strat->initEcart = initEcartNormal;
1775 else
1776 strat->initEcart = initEcartBBA;
1777 if (strat->honey)
1779 else
1781 //strat->kIdeal = NULL;
1782 //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1783 //else strat->kIdeal->rtyp=MODUL_CMD;
1784 //strat->kIdeal->data=(void *)strat->Shdl;
1785 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1786 {
1787 //interred machen Aenderung
1788 strat->pOrigFDeg = currRing->pFDeg;
1789 strat->pOrigLDeg = currRing->pLDeg;
1790 //h=ggetid("ecart");
1791 //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1792 //{
1793 // ecartWeights=iv2array(IDINTVEC(h));
1794 //}
1795 //else
1796 {
1797 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1798 /*uses automatic computation of the ecartWeights to set them*/
1800 }
1802 if (TEST_OPT_PROT)
1803 {
1804 for(i=1; i<=(currRing->N); i++)
1805 Print(" %d",ecartWeights[i]);
1806 PrintLn();
1807 mflush();
1808 }
1809 }
1810 // for sig-safe reductions in signature-based
1811 // standard basis computations
1813 strat->red = redSigRing;
1814 else
1815 strat->red = redSig;
1816 //strat->sbaOrder = 1;
1817 strat->currIdx = 1;
1818}
pFDegProc pOrigFDeg
Definition kutil.h:295
pLDegProc pOrigLDeg
Definition kutil.h:296
int redRiloc(LObject *h, kStrategy strat)
Definition kstd1.cc:385
int redSigRing(LObject *h, kStrategy strat)
Definition kstd2.cc:1536
int redSig(LObject *h, kStrategy strat)
Definition kstd2.cc:1369
void enterSSba(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8915
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3774
long totaldegreeWecart(poly p, ring r)
Definition weight.cc:217
long maxdegreeWecart(poly p, int *l, ring r)
Definition weight.cc:247
void kEcartWeights(poly *s, int sl, short *eweight, const ring R)
Definition weight.cc:182
EXTERN_VAR short * ecartWeights
Definition weight.h:12

◆ initSbaBuchMora()

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

Definition at line 9936 of file kutil.cc.

9937{
9938 strat->interpt = BTEST1(OPT_INTERRUPT);
9939 //strat->kNoether=NULL; // done by skStrategy
9940 /*- creating temp data structures------------------- -*/
9941 //strat->cp = 0; // done by skStrategy
9942 //strat->c3 = 0; // done by skStrategy
9943 strat->tail = pInit();
9944 /*- set s -*/
9945 strat->sl = -1;
9946 /*- set ps -*/
9947 strat->syzl = -1;
9948 /*- set L -*/
9949 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9950 strat->Ll = -1;
9951 strat->L = initL(strat->Lmax);
9952 /*- set B -*/
9953 strat->Bmax = setmaxL;
9954 strat->Bl = -1;
9955 strat->B = initL();
9956 /*- set T -*/
9957 strat->tl = -1;
9958 strat->tmax = setmaxT;
9959 strat->T = initT();
9960 strat->R = initR();
9961 strat->sevT = initsevT();
9962 /*- init local data struct.---------------------------------------- -*/
9963 //strat->P.ecart=0; // done by skStrategy
9964 //strat->P.length=0; // done by skStrategy
9966 {
9967 if (strat->kNoether!=NULL)
9968 {
9969 pSetComp(strat->kNoether, strat->ak);
9970 pSetComp(strat->kNoetherTail(), strat->ak);
9971 }
9972 }
9974 {
9975 /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
9976 }
9977 else
9978 {
9979 if(TEST_OPT_SB_1)
9980 {
9981 int i;
9982 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
9983 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9984 {
9985 P->m[i-strat->newIdeal] = F->m[i];
9986 F->m[i] = NULL;
9987 }
9988 initSSpecialSba(F,Q,P,strat);
9989 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9990 {
9991 F->m[i] = P->m[i-strat->newIdeal];
9992 P->m[i-strat->newIdeal] = NULL;
9993 }
9994 idDelete(&P);
9995 }
9996 else
9997 {
9998 initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
9999 }
10000 }
10001 //strat->fromT = FALSE; // done by skStrategy
10002 if (!TEST_OPT_SB_1)
10003 {
10004 if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10005 }
10006 //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10007 //strat->fromQ=NULL;
10008 assume(kTest_TS(strat));
10009}
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7781
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition kutil.cc:8236

◆ 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(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.h:291
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6513
void chainCritSig(poly p, int, kStrategy strat)
Definition kutil.cc:3461
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6478

◆ initSbaPos()

void initSbaPos ( kStrategy strat)

Definition at line 9863 of file kutil.cc.

9864{
9866 {
9867 if (strat->honey)
9868 {
9869 if (TEST_OPT_OLDSTD)
9870 strat->posInT = posInT15;
9871 else
9872 strat->posInT = posInT_EcartpLength;
9873 }
9874 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9875 {
9876 strat->posInT = posInT11;
9877 }
9878 else if (TEST_OPT_INTSTRATEGY)
9879 {
9880 strat->posInT = posInT11;
9881 }
9882 else
9883 {
9884 strat->posInT = posInT0;
9885 }
9886 if (strat->homog)
9887 {
9888 strat->posInT = posInT110;
9889 }
9890 }
9891 else
9892 {
9893 if (strat->homog)
9894 {
9895 strat->posInT = posInT11;
9896 }
9897 else
9898 {
9899 if ((currRing->order[0]==ringorder_c)
9900 ||(currRing->order[0]==ringorder_C))
9901 {
9902 strat->posInT = posInT17_c;
9903 }
9904 else
9905 {
9906 strat->posInT = posInT17;
9907 }
9908 }
9909 }
9910 // for further tests only
9911 if (BTEST1(11))
9912 strat->posInT = posInT11;
9913 else if (BTEST1(13))
9914 strat->posInT = posInT13;
9915 else if (BTEST1(15))
9916 strat->posInT = posInT15;
9917 else if ((BTEST1(17)))
9918 strat->posInT = posInT17;
9919 else if ((BTEST1(19)))
9920 strat->posInT = posInT19;
9921 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9922 strat->posInT = posInT1;
9924 {
9925 strat->posInT = posInT11;
9926 }
9928 strat->posInL = posInLSig;
9929 /*
9930 if (rField_is_Ring(currRing))
9931 {
9932 strat->posInL = posInLSigRing;
9933 }*/
9934}
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5669

◆ initsevT()

KINLINE unsigned long * initsevT ( )

Definition at line 100 of file kInline.h.

101{
102 return (unsigned long*) omAlloc0(setmaxT*sizeof(unsigned long));
103}

◆ initSL()

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

Definition at line 7679 of file kutil.cc.

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

◆ initSLSba()

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

Definition at line 7781 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy strat)

Definition at line 7933 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

85{
86 TSet T = (TSet)omAlloc0(setmaxT*sizeof(TObject));
87 for (int i=setmaxT-1; i>=0; i--)
88 {
89 T[i].tailRing = currRing;
90 T[i].i_r = -1;
91 }
92 return T;
93}
STATIC_VAR jList * T
Definition janet.cc:30
TObject * TSet
Definition kutil.h:60

◆ k_GetLeadTerms()

KINLINE BOOLEAN k_GetLeadTerms ( const poly p1,
const poly p2,
const ring p_r,
poly & m1,
poly & m2,
const ring m_r )

Definition at line 1018 of file kInline.h.

1020{
1021 p_LmCheckPolyRing(p1, p_r);
1022 p_LmCheckPolyRing(p2, p_r);
1023
1024 int i;
1025 long x;
1026 m1 = p_Init(m_r,m_r->PolyBin);
1027 m2 = p_Init(m_r,m_r->PolyBin);
1028
1029 for (i = p_r->N; i; i--)
1030 {
1031 x = p_GetExpDiff(p1, p2, i, p_r);
1032 if (x > 0)
1033 {
1034 if (x > (long) m_r->bitmask) goto false_return;
1035 p_SetExp(m2,i,x, m_r);
1036 p_SetExp(m1,i,0, m_r);
1037 }
1038 else
1039 {
1040 if (-x > (long) m_r->bitmask) goto false_return;
1041 p_SetExp(m1,i,-x, m_r);
1042 p_SetExp(m2,i,0, m_r);
1043 }
1044 }
1045
1046 p_Setm(m1, m_r);
1047 p_Setm(m2, m_r);
1048 return TRUE;
1049
1050 false_return:
1051 p_LmFree(m1, m_r);
1052 p_LmFree(m2, m_r);
1053 m1 = m2 = NULL;
1054 return FALSE;
1055}
Variable x
Definition cfModGcd.cc:4090
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition p_polys.h:637
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition pDebug.cc:123
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341

◆ k_GetStrongLeadTerms()

KINLINE void k_GetStrongLeadTerms ( const poly p1,
const poly p2,
const ring leadRing,
poly & m1,
poly & m2,
poly & lcm,
const ring taiRing )

Definition at line 1060 of file kInline.h.

1062{
1063 p_LmCheckPolyRing(p1, leadRing);
1064 p_LmCheckPolyRing(p2, leadRing);
1065
1066 int i;
1067 int x;
1068 int e1;
1069 int e2;
1070 int s;
1071 m1 = p_Init(tailRing,tailRing->PolyBin);
1072 m2 = p_Init(tailRing,tailRing->PolyBin);
1073 lcm = p_Init(leadRing,leadRing->PolyBin);
1074
1075 for (i = leadRing->N; i>=0; i--)
1076 {
1077 e1 = p_GetExp(p1,i,leadRing);
1078 e2 = p_GetExp(p2,i,leadRing);
1079 x = e1 - e2;
1080 if (x > 0)
1081 {
1082 p_SetExp(m2,i,x, tailRing);
1083 //p_SetExp(m1,i,0, tailRing); // done by p_Init
1084 s = e1;
1085 }
1086 else if (x<0)
1087 {
1088 p_SetExp(m1,i,-x, tailRing);
1089 //p_SetExp(m2,i,0, tailRing); // done by p_Init
1090 s = e2;
1091 }
1092 else
1093 s = e1; // e1==e2
1094 p_SetExp(lcm,i,s, leadRing);
1095 }
1096
1097 p_Setm(m1, tailRing);
1098 p_Setm(m2, tailRing);
1099 p_Setm(lcm, leadRing);
1100}
const CanonicalForm int s
Definition facAbsFact.cc:51

◆ k_LmInit_currRing_2_tailRing() [1/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly p,
ring tailRing )

Definition at line 991 of file kInline.h.

992{
993 return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
994}

◆ k_LmInit_currRing_2_tailRing() [2/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly p,
ring tailRing,
omBin bin )

Definition at line 959 of file kInline.h.

960{
961
962 poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
963 pNext(t_p) = pNext(p);
964 pSetCoeff0(t_p, pGetCoeff(p));
965 return t_p;
966}
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1356

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly p,
ring tailRing )

Definition at line 996 of file kInline.h.

997{
998 return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
999}
KINLINE poly k_LmInit_tailRing_2_currRing(poly t_p, ring tailRing, omBin lmBin)
Definition kInline.h:968

◆ k_LmInit_tailRing_2_currRing() [2/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly p,
ring tailRing,
omBin bin )

Definition at line 968 of file kInline.h.

969{
970 poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
971 pNext(p) = pNext(t_p);
972 pSetCoeff0(p, pGetCoeff(t_p));
973 return p;
974}

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly p,
ring tailRing )

Definition at line 1001 of file kInline.h.

1002{
1003 return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
1004}
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:977

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly p,
ring tailRing,
omBin bin )

Definition at line 977 of file kInline.h.

978{
979 poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
981 return np;
982}

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly p,
ring tailRing )

Definition at line 1006 of file kInline.h.

1007{
1008 return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
1009}
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition kInline.h:984

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly p,
ring tailRing,
omBin bin )

Definition at line 984 of file kInline.h.

985{
986 poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
987 p_LmFree(p, tailRing);
988 return np;
989}

◆ kCheckSpolyCreation()

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

Definition at line 10459 of file kutil.cc.

10460{
10461 if (strat->overflow) return FALSE;
10462 assume(L->p1 != NULL && L->p2 != NULL);
10463 // shift changes: from 0 to -1
10464 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10465 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10466
10467 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10468 return FALSE;
10469 // shift changes: extra case inserted
10470 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10471 {
10472 return TRUE;
10473 }
10474 poly p1_max=NULL;
10475 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10476 poly p2_max=NULL;
10477 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10478
10479 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10480 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10481 {
10482 p_LmFree(m1, strat->tailRing);
10483 p_LmFree(m2, strat->tailRing);
10484 m1 = NULL;
10485 m2 = NULL;
10486 return FALSE;
10487 }
10488 return TRUE;
10489}
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:1018
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition p_polys.h:2020

◆ kCheckStrongCreation()

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

Definition at line 10497 of file kutil.cc.

10498{
10499 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10500 //assume(strat->tailRing != currRing);
10501
10502 poly p1_max = (strat->R[atR])->max_exp;
10503 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10504
10505 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10506 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10507 {
10508 return FALSE;
10509 }
10510 return TRUE;
10511}

◆ kDebugPrint()

void kDebugPrint ( kStrategy strat)

Output some debug info about a given strategy.

Definition at line 11478 of file kutil.cc.

11479{
11480 printf("red: ");
11481 if (strat->red==redFirst) printf("redFirst\n");
11482 else if (strat->red==redHoney) printf("redHoney\n");
11483 else if (strat->red==redEcart) printf("redEcart\n");
11484 else if (strat->red==redHomog) printf("redHomog\n");
11485 else if (strat->red==redLazy) printf("redLazy\n");
11486 else if (strat->red==redLiftstd) printf("redLiftstd\n");
11487 else printf("%p\n",(void*)strat->red);
11488 printf("posInT: ");
11489 if (strat->posInT==posInT0) printf("posInT0\n");
11490 else if (strat->posInT==posInT1) printf("posInT1\n");
11491 else if (strat->posInT==posInT11) printf("posInT11\n");
11492 else if (strat->posInT==posInT110) printf("posInT110\n");
11493 else if (strat->posInT==posInT13) printf("posInT13\n");
11494 else if (strat->posInT==posInT15) printf("posInT15\n");
11495 else if (strat->posInT==posInT17) printf("posInT17\n");
11496 else if (strat->posInT==posInT17_c) printf("posInT17_c\n");
11497 else if (strat->posInT==posInT19) printf("posInT19\n");
11498 else if (strat->posInT==posInT2) printf("posInT2\n");
11499 else if (strat->posInT==posInT11Ring) printf("posInT11Ring\n");
11500 else if (strat->posInT==posInT110Ring) printf("posInT110Ring\n");
11501 else if (strat->posInT==posInT15Ring) printf("posInT15Ring\n");
11502 else if (strat->posInT==posInT17Ring) printf("posInT17Ring\n");
11503 else if (strat->posInT==posInT17_cRing) printf("posInT17_cRing\n");
11504#ifdef HAVE_MORE_POS_IN_T
11505 else if (strat->posInT==posInT_EcartFDegpLength) printf("posInT_EcartFDegpLength\n");
11506 else if (strat->posInT==posInT_FDegpLength) printf("posInT_FDegpLength\n");
11507 else if (strat->posInT==posInT_pLength) printf("posInT_pLength\n");
11508#endif
11509 else if (strat->posInT==posInT_EcartpLength) printf("posInT_EcartpLength\n");
11510 else printf("%p\n",(void*)strat->posInT);
11511 printf("posInL: ");
11512 if (strat->posInL==posInL0) printf("posInL0\n");
11513 else if (strat->posInL==posInL10) printf("posInL10\n");
11514 else if (strat->posInL==posInL11) printf("posInL11\n");
11515 else if (strat->posInL==posInL110) printf("posInL110\n");
11516 else if (strat->posInL==posInL13) printf("posInL13\n");
11517 else if (strat->posInL==posInL15) printf("posInL15\n");
11518 else if (strat->posInL==posInL17) printf("posInL17\n");
11519 else if (strat->posInL==posInL17_c) printf("posInL17_c\n");
11520 else if (strat->posInL==posInL0) printf("posInL0Ring\n");
11521 else if (strat->posInL==posInL11Ring) printf("posInL11Ring\n");
11522 else if (strat->posInL==posInL11Ringls) printf("posInL11Ringls\n");
11523 else if (strat->posInL==posInL110Ring) printf("posInL110Ring\n");
11524 else if (strat->posInL==posInL15Ring) printf("posInL15Ring\n");
11525 else if (strat->posInL==posInL17Ring) printf("posInL17Ring\n");
11526 else if (strat->posInL==posInL17_cRing) printf("posInL17_cRing\n");
11527 else if (strat->posInL==posInLSpecial) printf("posInLSpecial\n");
11528 else printf("%p\n",(void*)strat->posInL);
11529 printf("enterS: ");
11530 if (strat->enterS==enterSBba) printf("enterSBba\n");
11531 else if (strat->enterS==enterSMora) printf("enterSMora\n");
11532 else if (strat->enterS==enterSMoraNF) printf("enterSMoraNF\n");
11533 else printf("%p\n",(void*)strat->enterS);
11534 printf("initEcart: ");
11535 if (strat->initEcart==initEcartBBA) printf("initEcartBBA\n");
11536 else if (strat->initEcart==initEcartNormal) printf("initEcartNormal\n");
11537 else printf("%p\n",(void*)strat->initEcart);
11538 printf("initEcartPair: ");
11539 if (strat->initEcartPair==initEcartPairBba) printf("initEcartPairBba\n");
11540 else if (strat->initEcartPair==initEcartPairMora) printf("initEcartPairMora\n");
11541 else printf("%p\n",(void*)strat->initEcartPair);
11542 printf("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11543 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11544 printf("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11545 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11546 printf("chainCrit: ");
11547 if (strat->chainCrit==chainCritNormal) printf("chainCritNormal\n");
11548 else if (strat->chainCrit==chainCritOpt_1) printf("chainCritOpt_1\n");
11549 else printf("%p\n",(void*)strat->chainCrit);
11550 printf("posInLDependsOnLength=%d\n",
11551 strat->posInLDependsOnLength);
11552 printf("%s\n",showOption());
11553 printf("LDeg: ");
11554 if (currRing->pLDeg==pLDeg0) printf("pLDeg0");
11555 else if (currRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11556 else if (currRing->pLDeg==pLDegb) printf("pLDegb");
11557 else if (currRing->pLDeg==pLDeg1) printf("pLDeg1");
11558 else if (currRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11559 else if (currRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11560 else if (currRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11561 else if (currRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11562 else if (currRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11563 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11564 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11565 else if (currRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11566 else printf("? (%lx)", (long)currRing->pLDeg);
11567 printf(" / ");
11568 if (strat->tailRing->pLDeg==pLDeg0) printf("pLDeg0");
11569 else if (strat->tailRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11570 else if (strat->tailRing->pLDeg==pLDegb) printf("pLDegb");
11571 else if (strat->tailRing->pLDeg==pLDeg1) printf("pLDeg1");
11572 else if (strat->tailRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11573 else if (strat->tailRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11574 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11575 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11576 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11577 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11578 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11579 else if (strat->tailRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11580 else printf("? (%lx)", (long)strat->tailRing->pLDeg);
11581 printf("\n");
11582 printf("currRing->pFDeg: ");
11583 if (currRing->pFDeg==p_Totaldegree) printf("p_Totaldegree");
11584 else if (currRing->pFDeg==p_WFirstTotalDegree) printf("pWFirstTotalDegree");
11585 else if (currRing->pFDeg==p_Deg) printf("p_Deg");
11586 else if (currRing->pFDeg==kHomModDeg) printf("kHomModDeg");
11587 else if (currRing->pFDeg==kModDeg) printf("kModDeg");
11588 else if (currRing->pFDeg==totaldegreeWecart) printf("totaldegreeWecart");
11589 else if (currRing->pFDeg==p_WTotaldegree) printf("p_WTotaldegree");
11590 else printf("? (%lx)", (long)currRing->pFDeg);
11591 printf("\n");
11592 printf(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11594 printf(" degBound: %d\n", Kstd1_deg);
11595
11596 if( ecartWeights != NULL )
11597 {
11598 printf("ecartWeights: ");
11599 for (int i = rVar(currRing); i > 0; i--)
11600 printf("%hd ", ecartWeights[i]);
11601 printf("\n");
11603 }
11604
11605#ifndef SING_NDEBUG
11607#endif
11608}
int LazyDegree
Definition kutil.h:352
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2421
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:794
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2411
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
void enterSMora(LObject *p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1629
void enterSMoraNF(LObject *p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1682
int posInT2(const TSet set, const int length, LObject &p)
Definition kutil.cc:4925
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11449
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11358
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11412
char * showOption()
Definition misc_ip.cc:713
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:1528
void rDebugPrint(const ring r)
Definition ring.cc:4214
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:734

◆ kDeleteLcm()

void kDeleteLcm ( LObject * P)
inlinestatic

Definition at line 876 of file kutil.h.

877{
878 if (P->lcm!=NULL)
879 {
881 pLmDelete(P->lcm);
882 else
883 pLmFree(P->lcm);
884 P->lcm=NULL;
885 }
886}

◆ kFindDivisibleByInS()

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 at line 464 of file kstd2.cc.

465{
466 unsigned long not_sev = ~L->sev;
467 poly p = L->GetLmCurrRing();
468 int j = 0;
469
470 pAssume(~not_sev == p_GetShortExpVector(p, currRing));
471
473#if 1
474 int ende;
475 if (is_Ring
476 || (strat->ak>0)
477 || currRing->pLexOrder)
478 ende=strat->sl;
479 else
480 {
481 ende=posInS(strat,*max_ind,p,0)+1;
482 if (ende>(*max_ind)) ende=(*max_ind);
483 }
484#else
485 int ende=strat->sl;
486#endif
487 if(is_Ring)
488 {
489 loop
490 {
491 if (j > ende) return -1;
492#if defined(PDEBUG) || defined(PDIV_DEBUG)
493 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
494 p, not_sev, currRing))
495#else
496 if ( !(strat->sevS[j] & not_sev) &&
497 p_LmDivisibleBy(strat->S[j], p, currRing))
498#endif
499 {
500 if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
501 return j;
502 }
503 j++;
504 }
505 }
506 else
507 {
508 loop
509 {
510 if (j > ende) return -1;
511#if defined(PDEBUG) || defined(PDIV_DEBUG)
512 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
513 p, not_sev, currRing))
514#else
515 if ( !(strat->sevS[j] & not_sev) &&
516 p_LmDivisibleBy(strat->S[j], p, currRing))
517#endif
518 {
519 return j;
520 }
521 j++;
522 }
523 }
524}
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1912

◆ kFindDivisibleByInS_T()

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

Definition at line 6697 of file kutil.cc.

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

◆ kFindDivisibleByInT()

int kFindDivisibleByInT ( const kStrategy strat,
const LObject * L,
const int start = 0 )

return -1 if no divisor is found number of first divisor in T, otherwise

Definition at line 317 of file kstd2.cc.

318{
319 unsigned long not_sev = ~L->sev;
320 int j = start;
321
322 const TSet T=strat->T;
323 const unsigned long* sevT=strat->sevT;
324 const ring r=currRing;
325 const BOOLEAN is_Ring=rField_is_Ring(r);
326 if (L->p!=NULL)
327 {
328 const poly p=L->p;
329
330 pAssume(~not_sev == p_GetShortExpVector(p, r));
331
332 if(is_Ring)
333 {
334 loop
335 {
336 if (j > strat->tl) return -1;
337#if defined(PDEBUG) || defined(PDIV_DEBUG)
338 if ((T[j].p!=NULL)
339 && p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
340#else
341 if (!(sevT[j] & not_sev)
342 && (T[j].p!=NULL)
343 && p_LmDivisibleBy(T[j].p, p, r))
344#endif
345 {
346 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
347 return j;
348 }
349 j++;
350 }
351 }
352 else
353 {
354 loop
355 {
356 if (j > strat->tl) return -1;
357#if defined(PDEBUG) || defined(PDIV_DEBUG)
358 if ((T[j].p!=NULL)
359 && p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
360#else
361 if (!(sevT[j] & not_sev)
362 && (T[j].p!=NULL)
363 && p_LmDivisibleBy(T[j].p, p, r))
364#endif
365 {
366 return j;
367 }
368 j++;
369 }
370 }
371 }
372 else
373 {
374 const poly p=L->t_p;
375 const ring r=strat->tailRing;
376 if(is_Ring)
377 {
378 loop
379 {
380 if (j > strat->tl) return -1;
381#if defined(PDEBUG) || defined(PDIV_DEBUG)
382 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
383 p, not_sev, r))
384#else
385 if (!(sevT[j] & not_sev) &&
386 p_LmDivisibleBy(T[j].t_p, p, r))
387#endif
388 {
389 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
390 return j;
391 }
392 j++;
393 }
394 }
395 else
396 {
397 loop
398 {
399 if (j > strat->tl) return -1;
400#if defined(PDEBUG) || defined(PDIV_DEBUG)
401 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
402 p, not_sev, r))
403#else
404 if (!(sevT[j] & not_sev) &&
405 p_LmDivisibleBy(T[j].t_p, p, r))
406#endif
407 {
408 return j;
409 }
410 j++;
411 }
412 }
413 }
414}

◆ kFindDivisibleByInT_ecart()

int kFindDivisibleByInT_ecart ( const kStrategy strat,
const LObject * L,
const int ecart )

Definition at line 416 of file kstd2.cc.

417{
418 if (TEST_OPT_LENGTH)
419 {
420 int r=-1; // found, but bad ecart
421 int j=-2; // found, good ecart
422 int jj=-1; // current search
423 loop
424 {
425 jj=kFindDivisibleByInT(strat,L,jj+1);
426 if (jj== -1)
427 {
428 if (j<0) return r; // nothing with good ecart
429 else return j; // end of search, return best found
430 }
431 else if (r<0) r=jj; // save bad ecart found
432 if (strat->T[jj].ecart<=ecart) // good enough
433 {
434 if (strat->T[jj].pLength<=0)
435 strat->T[jj].pLength=strat->T[jj].GetpLength();
436 if (j== -2) j=jj; // first found
437 else if (strat->T[j].pLength > strat->T[jj].pLength) // jj better then j
438 j=jj;
439 if (strat->T[j].pLength<=2) return j; // length already minimal
440 }
441 }
442 }
443 else
444 {
445 int r=-1;
446 int jj=-1;
447 loop
448 {
449 jj=kFindDivisibleByInT(strat,L,jj+1);
450 if (jj== -1)
451 {
452 return r; // nothing found
453 }
454 else if (r== -1) r=jj;
455 if (strat->T[jj].ecart<=ecart) // good enough
456 {
457 return jj;
458 }
459 }
460 }
461}
int kFindDivisibleByInT(const kStrategy strat, const LObject *L, const int start)
return -1 if no divisor is found number of first divisor in T, otherwise
Definition kstd2.cc:317
#define TEST_OPT_LENGTH
Definition options.h:132

◆ kFindDivisibleByInT_Z()

int kFindDivisibleByInT_Z ( const kStrategy strat,
const LObject * L,
const int start = 0 )

Definition at line 209 of file kstd2.cc.

210{
211 unsigned long not_sev = ~L->sev;
212 int j = start;
213 int o = -1;
214
215 const TSet T=strat->T;
216 const unsigned long* sevT=strat->sevT;
217 number rest, orest, mult;
218 if (L->p!=NULL)
219 {
220 const ring r=currRing;
221 const poly p=L->p;
222 orest = pGetCoeff(p);
223
224 pAssume(~not_sev == p_GetShortExpVector(p, r));
225
226 loop
227 {
228 if (j > strat->tl) return o;
229#if defined(PDEBUG) || defined(PDIV_DEBUG)
230 if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
231#else
232 if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].p, p, r))
233#endif
234 {
235 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
236 if (!n_IsZero(mult, r->cf) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
237 {
238 o = j;
239 orest = rest;
240 }
241 }
242 j++;
243 }
244 }
245 else
246 {
247 const ring r=strat->tailRing;
248 const poly p=L->t_p;
249 orest = pGetCoeff(p);
250 loop
251 {
252 if (j > strat->tl) return o;
253#if defined(PDEBUG) || defined(PDIV_DEBUG)
254 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
255 p, not_sev, r))
256#else
257 if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].t_p, p, r))
258#endif
259 {
260 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf);
261 if (!n_IsZero(mult, r->cf) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
262 {
263 o = j;
264 orest = rest;
265 }
266 }
267 j++;
268 }
269 }
270}
static FORCE_INLINE number n_EucNorm(number a, const coeffs r)
Definition coeffs.h:678
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition coeffs.h:684
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition coeffs.h:517
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:647

◆ kFindInL1()

int kFindInL1 ( const poly p,
const kStrategy strat )
inlinestatic

Definition at line 852 of file kutil.h.

853{
854 for(int i=strat->Ll;i>=0;i--)
855 {
856 if (p==strat->L[i].p1) return i;
857 }
858 return -1;
859}

◆ kFindInT()

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

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

Definition at line 703 of file kutil.cc.

704{
705 int i;
706
707 for (i=0; i<=tlength; i++)
708 {
709 if (T[i].p == p) return i;
710 }
711 return -1;
712}

◆ kFindInTShift()

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

Definition at line 728 of file kutil.cc.

729{
730 int i;
731
732 for (i=0; i<=tlength; i++)
733 {
734 // in the Letterplace ring the LMs in T and L are copies thus we have to use pEqualPolys() instead of ==
735 if (pEqualPolys(T[i].p, p)) return i;
736 }
737 return -1;
738}
#define pEqualPolys(p1, p2)
Definition polys.h:400

◆ kFindNextDivisibleByInS()

int kFindNextDivisibleByInS ( const kStrategy strat,
int start,
int max_ind,
LObject * L )

Definition at line 567 of file kstd2.cc.

568{
569 unsigned long not_sev = ~L->sev;
570 poly p = L->GetLmCurrRing();
571 int j = start;
572
573 pAssume(~not_sev == p_GetShortExpVector(p, currRing));
574#if 1
575 int ende=max_ind;
576#else
577 int ende=strat->sl;
578#endif
579 loop
580 {
581 if (j > ende) return -1;
582#if defined(PDEBUG) || defined(PDIV_DEBUG)
583 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
584 p, not_sev, currRing))
585#else
586 if ( !(strat->sevS[j] & not_sev) &&
587 p_LmDivisibleBy(strat->S[j], p, currRing))
588#endif
589 {
590 return j;
591 }
592 j++;
593 }
594}

◆ kFindSameLMInT_Z()

int kFindSameLMInT_Z ( const kStrategy strat,
const LObject * L,
const int start = 0 )

◆ kFindZeroPoly()

poly kFindZeroPoly ( poly input_p,
ring leadRing,
ring tailRing )

Definition at line 609 of file kstd2.cc.

610{
611 // m = currRing->ch
612
613 if (input_p == NULL) return NULL;
614
615 poly p = input_p;
616 poly zeroPoly = NULL;
617 unsigned long a = (unsigned long) pGetCoeff(p);
618
619 int k_ind2 = 0;
620 int a_ind2 = SI_LOG2_LONG(a);
621
622 // unsigned long k = 1;
623 // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
624 for (int i = 1; i <= leadRing->N; i++)
625 {
626 k_ind2 = k_ind2 + ind_fact_2(p_GetExp(p, i, leadRing));
627 }
628
629 a = (unsigned long) pGetCoeff(p);
630
631 number tmp1;
632 poly tmp2, tmp3;
633 poly lead_mult = p_ISet(1, tailRing);
634 if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
635 {
636 int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf);
637 int s_exp;
638 zeroPoly = p_ISet(a, tailRing);
639 for (int i = 1; i <= leadRing->N; i++)
640 {
641 s_exp = p_GetExp(p, i,leadRing);
642 if (s_exp % 2 != 0)
643 {
644 s_exp = s_exp - 1;
645 }
646 while ( (0 < SI_LOG2_LONG(s_exp)) && (SI_LOG2_LONG(s_exp) <= too_much) )
647 {
648 too_much = too_much - SI_LOG2_LONG(s_exp);
649 s_exp = s_exp - 2;
650 }
651 p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
652 for (int j = 1; j <= s_exp; j++)
653 {
654 tmp1 = nInit(j);
655 tmp2 = p_ISet(1, tailRing);
656 p_SetExp(tmp2, i, 1, tailRing);
657 p_Setm(tmp2, tailRing);
658 if (nIsZero(tmp1))
659 { // should nowbe obsolet, test ! TODO OLIVER
660 zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
661 }
662 else
663 {
664 tmp3 = p_NSet(nCopy(tmp1), tailRing);
665 zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
666 }
667 }
668 }
669 p_Setm(lead_mult, tailRing);
670 zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing);
671 tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
672 for (int i = 1; i <= leadRing->N; i++)
673 {
674 pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
675 }
676 p_Setm(tmp2, leadRing);
677 zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
678 pNext(tmp2) = zeroPoly;
679 return tmp2;
680 }
681/* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
682 if (1 == 0 && alpha_k <= a)
683 { // Temporarily disabled, reducing coefficients not compatible with std TODO Oliver
684 zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
685 for (int i = 1; i <= leadRing->N; i++)
686 {
687 for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
688 {
689 tmp1 = nInit(j);
690 tmp2 = p_ISet(1, tailRing);
691 p_SetExp(tmp2, i, 1, tailRing);
692 p_Setm(tmp2, tailRing);
693 if (nIsZero(tmp1))
694 {
695 zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
696 }
697 else
698 {
699 tmp3 = p_ISet((unsigned long) tmp1, tailRing);
700 zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
701 }
702 }
703 }
704 tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing);
705 for (int i = 1; i <= leadRing->N; i++)
706 {
707 pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
708 }
709 p_Setm(tmp2, leadRing);
710 zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
711 pNext(tmp2) = zeroPoly;
712 return tmp2;
713 } */
714 return NULL;
715}
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:450
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
static long ind_fact_2(long arg)
Definition kstd2.cc:596
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1474
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
static int SI_LOG2_LONG(long v)
Definition si_log2.h:22

◆ kFreeStrat()

void kFreeStrat ( kStrategy strat)

◆ kNF2() [1/2]

ideal kNF2 ( ideal F,
ideal Q,
ideal q,
kStrategy strat,
int lazyReduce )

Definition at line 4090 of file kstd2.cc.

4091{
4092 assume(!idIs0(q));
4093 assume(!(idIs0(F)&&(Q==NULL)));
4094// lazy_reduce flags: can be combined by |
4095//#define KSTD_NF_LAZY 1
4096 // do only a reduction of the leading term
4097//#define KSTD_NF_NONORM 4
4098 // only global: avoid normalization, return a multiply of NF
4099 poly p;
4100 int i;
4101 ideal res;
4102 int max_ind;
4103
4104 //if (idIs0(q))
4105 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4106 //if ((idIs0(F))&&(Q==NULL))
4107 // return idCopy(q); /*F=0*/
4108 //strat->ak = idRankFreeModule(F);
4109 /*- creating temp data structures------------------- -*/
4110 BITSET save1;
4111 SI_SAVE_OPT1(save1);
4113 initBuchMoraCrit(strat);
4114 strat->initEcart = initEcartBBA;
4115#ifdef HAVE_SHIFTBBA
4116 if (rIsLPRing(currRing))
4117 {
4118 strat->enterS = enterSBbaShift;
4119 }
4120 else
4121#endif
4122 {
4123 strat->enterS = enterSBba;
4124 }
4125 /*- set S -*/
4126 strat->sl = -1;
4127#ifndef NO_BUCKETS
4129#endif
4130 /*- init local data struct.---------------------------------------- -*/
4131 /*Shdl=*/initS(F,Q,strat);
4132 /*- compute------------------------------------------------------- -*/
4133 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4134 for (i=IDELEMS(q)-1; i>=0; i--)
4135 {
4136 if (q->m[i]!=NULL)
4137 {
4138 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4139 p = redNF(pCopy(q->m[i]),max_ind,
4140 (lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat);
4141 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4142 {
4143 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4145 {
4146 p = redtailBba_NF(p,strat);
4147 }
4148 else
4149 {
4151 p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
4152 }
4153 }
4154 res->m[i]=p;
4155 }
4156 //else
4157 // res->m[i]=NULL;
4158 }
4159 /*- release temp data------------------------------- -*/
4160 assume(strat->L==NULL); /* strat->L unused */
4161 assume(strat->B==NULL); /* strat->B unused */
4162 omFree(strat->sevS);
4163 omFree(strat->ecartS);
4164 assume(strat->T==NULL);//omfree(strat->T);
4165 assume(strat->sevT==NULL);//omfree(strat->sevT);
4166 assume(strat->R==NULL);//omfree(strat->R);
4167 omfree(strat->S_2_R);
4168 omfree(strat->fromQ);
4169 strat->fromQ=NULL;
4170 idDelete(&strat->Shdl);
4171 SI_RESTORE_OPT1(save1);
4172 if (TEST_OPT_PROT) PrintLn();
4173 return res;
4174}
CanonicalForm res
Definition facAbsFact.cc:60
#define KSTD_NF_LAZY
Definition kstd1.h:18
#define KSTD_NF_NONORM
Definition kstd1.h:22
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2307
void enterSBbaShift(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8892
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7586
poly redtailBba_NF(poly p, kStrategy strat)
Definition kutil.cc:7350
#define omfree(addr)
#define omFree(addr)
VAR unsigned si_opt_1
Definition options.c:5
#define OPT_INTSTRATEGY
Definition options.h:93
#define OPT_REDTAIL
Definition options.h:92
#define Sy_bit(x)
Definition options.h:31

◆ kNF2() [2/2]

poly kNF2 ( ideal F,
ideal Q,
poly q,
kStrategy strat,
int lazyReduce )

Definition at line 3927 of file kstd2.cc.

3928{
3929 assume(q!=NULL);
3930 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3931
3932// lazy_reduce flags: can be combined by |
3933//#define KSTD_NF_LAZY 1
3934 // do only a reduction of the leading term
3935//#define KSTD_NF_NONORM 4
3936 // only global: avoid normalization, return a multiply of NF
3937//#define KSTD_NF_CANCELUNIT 8
3938 // apply cancelunit to f inf NF(f,I)
3939//#define KSTD_NF_NOLF 4096
3940 // avoid PrintLn with OPT_PROT
3941
3942 poly p;
3943
3944 //if ((idIs0(F))&&(Q==NULL))
3945 // return pCopy(q); /*F=0*/
3946 //strat->ak = idRankFreeModule(F);
3947 /*- creating temp data structures------------------- -*/
3948 BITSET save1;
3949 SI_SAVE_OPT1(save1);
3951 initBuchMoraCrit(strat);
3952 strat->initEcart = initEcartBBA;
3953#ifdef HAVE_SHIFTBBA
3954 if (rIsLPRing(currRing))
3955 {
3956 strat->enterS = enterSBbaShift;
3957 }
3958 else
3959#endif
3960 {
3961 strat->enterS = enterSBba;
3962 }
3963#ifndef NO_BUCKETS
3965#endif
3966 /*- set S -*/
3967 strat->sl = -1;
3968 /*- init local data struct.---------------------------------------- -*/
3969 /*Shdl=*/initS(F,Q,strat);
3970 /*- compute------------------------------------------------------- -*/
3971 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3972 //{
3973 // for (i=strat->sl;i>=0;i--)
3974 // pNorm(strat->S[i]);
3975 //}
3976 kTest(strat);
3977 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3978 if (BVERBOSE(23)) kDebugPrint(strat);
3979 int max_ind;
3980 p = redNF(pCopy(q),max_ind,(lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat);
3981 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3982 {
3983 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3985 {
3986 p = redtailBba_NF(p,strat);
3987 }
3988 else if (rField_is_Ring(currRing))
3989 {
3990 p = redtailBba_Ring(p,max_ind,strat);
3991 }
3992 else
3993 {
3995 p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3996 }
3997 }
3998 /*- release temp data------------------------------- -*/
3999 assume(strat->L==NULL); /* strat->L unused */
4000 assume(strat->B==NULL); /* strat->B unused */
4001 omFree(strat->sevS);
4002 omFree(strat->ecartS);
4003 assume(strat->T==NULL);//omfree(strat->T);
4004 assume(strat->sevT==NULL);//omfree(strat->sevT);
4005 assume(strat->R==NULL);//omfree(strat->R);
4006 omfree(strat->S_2_R);
4007 omfree(strat->fromQ);
4008 strat->fromQ=NULL;
4009 idDelete(&strat->Shdl);
4010 SI_RESTORE_OPT1(save1);
4011 if (TEST_OPT_PROT && ((lazyReduce &KSTD_NF_NOLF)==0)) PrintLn();
4012 return p;
4013}
KINLINE poly redtailBba_Ring(poly p, int pos, kStrategy strat)
Definition kInline.h:1224
#define KSTD_NF_NOLF
Definition kstd1.h:26
void kDebugPrint(kStrategy strat)
Definition kutil.cc:11478
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1004
#define BVERBOSE(a)
Definition options.h:35
static BOOLEAN rField_is_Zn(const ring r)
Definition ring.h:523

◆ kNF2Bound() [1/2]

ideal kNF2Bound ( ideal F,
ideal Q,
ideal q,
int bound,
kStrategy strat,
int lazyReduce )

Definition at line 4176 of file kstd2.cc.

4177{
4178 assume(!idIs0(q));
4179 assume(!(idIs0(F)&&(Q==NULL)));
4180// lazy_reduce flags: can be combined by |
4181//#define KSTD_NF_LAZY 1
4182 // do only a reduction of the leading term
4183//#define KSTD_NF_NONORM 4
4184 // only global: avoid normalization, return a multiply of NF
4185 poly p;
4186 int i;
4187 ideal res;
4188 int max_ind;
4189
4190 //if (idIs0(q))
4191 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4192 //if ((idIs0(F))&&(Q==NULL))
4193 // return idCopy(q); /*F=0*/
4194 //strat->ak = idRankFreeModule(F);
4195 /*- creating temp data structures------------------- -*/
4196 BITSET save1;
4197 SI_SAVE_OPT1(save1);
4199 initBuchMoraCrit(strat);
4200 strat->initEcart = initEcartBBA;
4201 strat->enterS = enterSBba;
4202 /*- set S -*/
4203 strat->sl = -1;
4204#ifndef NO_BUCKETS
4206#endif
4207 /*- init local data struct.---------------------------------------- -*/
4208 /*Shdl=*/initS(F,Q,strat);
4209 /*- compute------------------------------------------------------- -*/
4210 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4211 for (i=IDELEMS(q)-1; i>=0; i--)
4212 {
4213 if (q->m[i]!=NULL)
4214 {
4215 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4216 p = redNFBound(pCopy(q->m[i]),max_ind,
4217 (lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat,bound);
4218 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4219 {
4220 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4222 {
4223 p = redtailBba_Z(p,max_ind,strat);
4224 }
4225 else if (rField_is_Ring(currRing))
4226 {
4227 p = redtailBba_Ring(p,max_ind,strat);
4228 }
4229 else
4230 {
4232 p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
4233 }
4234 }
4235 res->m[i]=p;
4236 }
4237 //else
4238 // res->m[i]=NULL;
4239 }
4240 /*- release temp data------------------------------- -*/
4241 assume(strat->L==NULL); /* strat->L unused */
4242 assume(strat->B==NULL); /* strat->B unused */
4243 omFree(strat->sevS);
4244 omFree(strat->ecartS);
4245 assume(strat->T==NULL);//omfree(strat->T);
4246 assume(strat->sevT==NULL);//omfree(strat->sevT);
4247 assume(strat->R==NULL);//omfree(strat->R);
4248 omfree(strat->S_2_R);
4249 omfree(strat->fromQ);
4250 strat->fromQ=NULL;
4251 idDelete(&strat->Shdl);
4252 SI_RESTORE_OPT1(save1);
4253 if (TEST_OPT_PROT) PrintLn();
4254 return res;
4255}
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
KINLINE poly redtailBbaBound(poly p, int pos, kStrategy strat, int bound, BOOLEAN normalize)
Definition kInline.h:1218
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition kInline.h:1229
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
Definition kstd2.cc:2503

◆ kNF2Bound() [2/2]

poly kNF2Bound ( ideal F,
ideal Q,
poly q,
int bound,
kStrategy strat,
int lazyReduce )

Definition at line 4015 of file kstd2.cc.

4016{
4017 assume(q!=NULL);
4018 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
4019
4020// lazy_reduce flags: can be combined by |
4021//#define KSTD_NF_LAZY 1
4022 // do only a reduction of the leading term
4023//#define KSTD_NF_NONORM 4
4024 // only global: avoid normalization, return a multiply of NF
4025 poly p;
4026
4027 //if ((idIs0(F))&&(Q==NULL))
4028 // return pCopy(q); /*F=0*/
4029 //strat->ak = idRankFreeModule(F);
4030 /*- creating temp data structures------------------- -*/
4031 BITSET save1;
4032 SI_SAVE_OPT1(save1);
4034 initBuchMoraCrit(strat);
4035 strat->initEcart = initEcartBBA;
4036 strat->enterS = enterSBba;
4037#ifndef NO_BUCKETS
4039#endif
4040 /*- set S -*/
4041 strat->sl = -1;
4042 /*- init local data struct.---------------------------------------- -*/
4043 /*Shdl=*/initS(F,Q,strat);
4044 /*- compute------------------------------------------------------- -*/
4045 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
4046 //{
4047 // for (i=strat->sl;i>=0;i--)
4048 // pNorm(strat->S[i]);
4049 //}
4050 kTest(strat);
4051 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
4052 if (BVERBOSE(23)) kDebugPrint(strat);
4053 int max_ind;
4054 p = redNFBound(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
4055 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4056 {
4057 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4059 {
4060 p = redtailBba_Z(p,max_ind,strat);
4061 }
4062 else if (rField_is_Ring(currRing))
4063 {
4064 p = redtailBba_Ring(p,max_ind,strat);
4065 }
4066 else
4067 {
4069 p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
4070 //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
4071 }
4072 }
4073 /*- release temp data------------------------------- -*/
4074 assume(strat->L==NULL); /* strat->L unused */
4075 assume(strat->B==NULL); /* strat->B unused */
4076 omFree(strat->sevS);
4077 omFree(strat->ecartS);
4078 assume(strat->T==NULL);//omfree(strat->T);
4079 assume(strat->sevT==NULL);//omfree(strat->sevT);
4080 assume(strat->R==NULL);//omfree(strat->R);
4081 omfree(strat->S_2_R);
4082 omfree(strat->fromQ);
4083 strat->fromQ=NULL;
4084 idDelete(&strat->Shdl);
4085 SI_RESTORE_OPT1(save1);
4086 if (TEST_OPT_PROT) PrintLn();
4087 return p;
4088}

◆ ksCreateShortSpoly()

poly ksCreateShortSpoly ( poly p1,
poly p2,
ring tailRing )

Definition at line 1446 of file kspoly.cc.

1447{
1448 poly a1 = pNext(p1), a2 = pNext(p2);
1449#ifdef HAVE_SHIFTBBA
1450 int shift1, shift2;
1451 if (tailRing->isLPring)
1452 {
1453 // assume: LM is shifted, tail unshifted
1454 assume(p_FirstVblock(a1, tailRing) <= 1);
1455 assume(p_FirstVblock(a2, tailRing) <= 1);
1456 // save the shift of the LM so we can shift the other monomials on demand
1457 shift1 = p_mFirstVblock(p1, tailRing) - 1;
1458 shift2 = p_mFirstVblock(p2, tailRing) - 1;
1459 }
1460#endif
1461 long c1=p_GetComp(p1, currRing),c2=p_GetComp(p2, currRing);
1462 long c;
1463 poly m1,m2;
1464 number t1 = NULL,t2 = NULL;
1465 int cm,i;
1466 BOOLEAN equal;
1467
1469 number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
1470 if (is_Ring)
1471 {
1472 ksCheckCoeff(&lc1, &lc2, currRing->cf); // gcd and zero divisors
1473 if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
1474 if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
1475 while (a1 != NULL && nIsZero(t2))
1476 {
1477 pIter(a1);
1478 nDelete(&t2);
1479 if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
1480 }
1481 while (a2 != NULL && nIsZero(t1))
1482 {
1483 pIter(a2);
1484 nDelete(&t1);
1485 if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
1486 }
1487 }
1488
1489#ifdef HAVE_SHIFTBBA
1490 // shift the next monomial on demand
1491 if (tailRing->isLPring)
1492 {
1493 a1 = p_LPCopyAndShiftLM(a1, shift1, tailRing);
1494 a2 = p_LPCopyAndShiftLM(a2, shift2, tailRing);
1495 }
1496#endif
1497 if (a1==NULL)
1498 {
1499 if(a2!=NULL)
1500 {
1501 m2=p_Init(currRing);
1502x2:
1503 for (i = (currRing->N); i; i--)
1504 {
1505 c = p_GetExpDiff(p1, p2,i, currRing);
1506 if (c>0)
1507 {
1508 p_SetExp(m2,i,(c+p_GetExp(a2,i,tailRing)),currRing);
1509 }
1510 else
1511 {
1512 p_SetExp(m2,i,p_GetExp(a2,i,tailRing),currRing);
1513 }
1514 }
1515 if ((c1==c2)||(c2!=0))
1516 {
1517 p_SetComp(m2,p_GetComp(a2,tailRing), currRing);
1518 }
1519 else
1520 {
1521 p_SetComp(m2,c1,currRing);
1522 }
1523 p_Setm(m2, currRing);
1524 if (is_Ring)
1525 {
1526 nDelete(&lc1);
1527 nDelete(&lc2);
1528 nDelete(&t2);
1529 pSetCoeff0(m2, t1);
1530 }
1531#ifdef HAVE_SHIFTBBA
1532 if (tailRing->isLPring && (shift2!=0)) /*a1==NULL*/
1533 {
1534 p_LmDelete(a2, tailRing);
1535 }
1536#endif
1537 return m2;
1538 }
1539 else
1540 {
1541 if (is_Ring)
1542 {
1543 nDelete(&lc1);
1544 nDelete(&lc2);
1545 nDelete(&t1);
1546 nDelete(&t2);
1547 }
1548 return NULL;
1549 }
1550 }
1551 if (a2==NULL)
1552 {
1553 m1=p_Init(currRing);
1554x1:
1555 for (i = (currRing->N); i; i--)
1556 {
1557 c = p_GetExpDiff(p2, p1,i,currRing);
1558 if (c>0)
1559 {
1560 p_SetExp(m1,i,(c+p_GetExp(a1,i, tailRing)),currRing);
1561 }
1562 else
1563 {
1564 p_SetExp(m1,i,p_GetExp(a1,i, tailRing), currRing);
1565 }
1566 }
1567 if ((c1==c2)||(c1!=0))
1568 {
1569 p_SetComp(m1,p_GetComp(a1,tailRing),currRing);
1570 }
1571 else
1572 {
1573 p_SetComp(m1,c2,currRing);
1574 }
1575 p_Setm(m1, currRing);
1576 if (is_Ring)
1577 {
1578 pSetCoeff0(m1, t2);
1579 nDelete(&lc1);
1580 nDelete(&lc2);
1581 nDelete(&t1);
1582 }
1583#ifdef HAVE_SHIFTBBA
1584 if (tailRing->isLPring && (shift1!=0)) /*a2==NULL*/
1585 {
1586 p_LmDelete(a1, tailRing);
1587 }
1588#endif
1589 return m1;
1590 }
1591 m1 = p_Init(currRing);
1592 m2 = p_Init(currRing);
1593 loop
1594 {
1595 for (i = (currRing->N); i; i--)
1596 {
1597 c = p_GetExpDiff(p1, p2,i,currRing);
1598 if (c > 0)
1599 {
1600 p_SetExp(m2,i,(c+p_GetExp(a2,i,tailRing)), currRing);
1601 p_SetExp(m1,i,p_GetExp(a1,i, tailRing), currRing);
1602 }
1603 else
1604 {
1605 p_SetExp(m1,i,(p_GetExp(a1,i,tailRing)-c), currRing);
1606 p_SetExp(m2,i,p_GetExp(a2,i, tailRing), currRing);
1607 }
1608 }
1609 if(c1==c2)
1610 {
1611 p_SetComp(m1,p_GetComp(a1, tailRing), currRing);
1612 p_SetComp(m2,p_GetComp(a2, tailRing), currRing);
1613 }
1614 else
1615 {
1616 if(c1!=0)
1617 {
1618 p_SetComp(m1,p_GetComp(a1, tailRing), currRing);
1619 p_SetComp(m2,c1, currRing);
1620 }
1621 else
1622 {
1623 p_SetComp(m2,p_GetComp(a2, tailRing), currRing);
1624 p_SetComp(m1,c2, currRing);
1625 }
1626 }
1627 p_Setm(m1,currRing);
1628 p_Setm(m2,currRing);
1629 cm = p_LmCmp(m1, m2,currRing);
1630 if (cm!=0)
1631 {
1632 if(cm==1)
1633 {
1634 p_LmFree(m2,currRing);
1635 if (is_Ring)
1636 {
1637 pSetCoeff0(m1, t2);
1638 nDelete(&lc1);
1639 nDelete(&lc2);
1640 nDelete(&t1);
1641 }
1642#ifdef HAVE_SHIFTBBA
1643 if (tailRing->isLPring)
1644 {
1645 if (shift1!=0) p_LmDelete(a1, tailRing);
1646 if (shift2!=0) p_LmDelete(a2, tailRing);
1647 }
1648#endif
1649 return m1;
1650 }
1651 else
1652 {
1653 p_LmFree(m1,currRing);
1654 if (is_Ring)
1655 {
1656 pSetCoeff0(m2, t1);
1657 nDelete(&lc1);
1658 nDelete(&lc2);
1659 nDelete(&t2);
1660 }
1661#ifdef HAVE_SHIFTBBA
1662 if (tailRing->isLPring)
1663 {
1664 if (shift1!=0) p_LmDelete(a1, tailRing);
1665 if (shift2!=0) p_LmDelete(a2, tailRing);
1666 }
1667#endif
1668 return m2;
1669 }
1670 }
1671 if (is_Ring)
1672 {
1673 equal = nEqual(t1,t2);
1674 }
1675 else
1676 {
1677 t1 = nMult(pGetCoeff(a2),pGetCoeff(p1));
1678 t2 = nMult(pGetCoeff(a1),pGetCoeff(p2));
1679 equal = nEqual(t1,t2);
1680 nDelete(&t2);
1681 nDelete(&t1);
1682 }
1683 if (!equal)
1684 {
1685 p_LmFree(m2,currRing);
1686 if (is_Ring)
1687 {
1688 pSetCoeff0(m1, nSub(t1, t2));
1689 nDelete(&lc1);
1690 nDelete(&lc2);
1691 nDelete(&t1);
1692 nDelete(&t2);
1693 }
1694#ifdef HAVE_SHIFTBBA
1695 if (tailRing->isLPring)
1696 {
1697 if (shift1!=0) p_LmDelete(a1, tailRing);
1698 if (shift2!=0) p_LmDelete(a2, tailRing);
1699 }
1700#endif
1701 return m1;
1702 }
1703 pIter(a1);
1704 pIter(a2);
1705 if (is_Ring)
1706 {
1707 if (a2 != NULL)
1708 {
1709 nDelete(&t1);
1710 t1 = nMult(pGetCoeff(a2),lc1);
1711 }
1712 if (a1 != NULL)
1713 {
1714 nDelete(&t2);
1715 t2 = nMult(pGetCoeff(a1),lc2);
1716 }
1717 while ((a1 != NULL) && nIsZero(t2))
1718 {
1719 pIter(a1);
1720 if (a1 != NULL)
1721 {
1722 nDelete(&t2);
1723 t2 = nMult(pGetCoeff(a1),lc2);
1724 }
1725 }
1726 while ((a2 != NULL) && nIsZero(t1))
1727 {
1728 pIter(a2);
1729 if (a2 != NULL)
1730 {
1731 nDelete(&t1);
1732 t1 = nMult(pGetCoeff(a2),lc1);
1733 }
1734 }
1735 }
1736#ifdef HAVE_SHIFTBBA
1737 if (tailRing->isLPring)
1738 {
1739 a1 = p_LPCopyAndShiftLM(a1, shift1, tailRing);
1740 a2 = p_LPCopyAndShiftLM(a2, shift2, tailRing);
1741 }
1742#endif
1743 if (a2==NULL)
1744 {
1745 p_LmFree(m2,currRing);
1746 if (a1==NULL)
1747 {
1748 if (is_Ring)
1749 {
1750 nDelete(&lc1);
1751 nDelete(&lc2);
1752 nDelete(&t1);
1753 nDelete(&t2);
1754 }
1755 p_LmFree(m1,currRing);
1756 return NULL;
1757 }
1758 goto x1;
1759 }
1760 if (a1==NULL)
1761 {
1762 p_LmFree(m1,currRing);
1763 goto x2;
1764 }
1765 }
1766}
bool equal
Definition cfModGcd.cc:4134
int ksCheckCoeff(number *a, number *b, const coeffs r)
Definition kbuckets.cc:1504
#define nSub(n1, n2)
Definition numbers.h:22
#define nMult(n1, n2)
Definition numbers.h:17
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
poly p_LPCopyAndShiftLM(poly p, int sh, const ring r)
Definition shiftgb.cc:35
int p_mFirstVblock(poly p, const ring ri)
Definition shiftop.cc:478
int p_FirstVblock(poly p, const ring r)
Definition shiftop.cc:456

◆ ksCreateSpoly()

void ksCreateSpoly ( LObject * Pair,
poly spNoether = NULL,
int use_buckets = 0,
ring tailRing = currRing,
poly m1 = NULL,
poly m2 = NULL,
TObject ** R = NULL )

Definition at line 1203 of file kspoly.cc.

1206{
1207#ifdef KDEBUG
1208 create_count++;
1209#endif
1210 poly p1 = Pair->p1;
1211 poly p2 = Pair->p2;
1212 Pair->tailRing = tailRing;
1213
1214 assume(p1 != NULL);
1215 assume(p2 != NULL);
1216 assume(tailRing != NULL);
1217
1218 poly a1 = pNext(p1), a2 = pNext(p2);
1219 number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
1220 int co=0/*, ct = ksCheckCoeff(&lc1, &lc2, currRing->cf)*/; // gcd and zero divisors
1221 (void) ksCheckCoeff(&lc1, &lc2, currRing->cf);
1222
1223 int l1=0, l2=0;
1224
1225 if (currRing->pCompIndex >= 0)
1226 {
1228 {
1229 if (__p_GetComp(p1, currRing)==0)
1230 {
1231 co=1;
1232 p_SetCompP(p1,__p_GetComp(p2, currRing), currRing, tailRing);
1233 }
1234 else
1235 {
1236 co=2;
1237 p_SetCompP(p2, __p_GetComp(p1, currRing), currRing, tailRing);
1238 }
1239 }
1240 }
1241
1242 // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
1243 // m2 = LCM(LM(p1), LM(p2))/LM(p2)
1244 if (m1 == NULL)
1245 k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing);
1246
1247#ifdef HAVE_SHIFTBBA
1248 poly m12, m22;
1249 if (tailRing->isLPring)
1250 {
1251 assume(p_mFirstVblock(p1, tailRing) <= 1 || p_mFirstVblock(p2, tailRing) <= 1);
1252 k_SplitFrame(m1, m12, si_max(p_mFirstVblock(p1, tailRing), 1), tailRing);
1253 k_SplitFrame(m2, m22, si_max(p_mFirstVblock(p2, tailRing), 1), tailRing);
1254 // coeffs of m1,m2 are NULL here
1255 }
1256#endif
1257
1258 pSetCoeff0(m1, lc2);
1259 pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2)
1260
1261 if (R != NULL)
1262 {
1263 if (Pair->i_r1 == -1)
1264 {
1265 l1 = pLength(p1) - 1;
1266 }
1267 else
1268 {
1269 l1 = (R[Pair->i_r1])->GetpLength() - 1;
1270 }
1271 if ((Pair->i_r2 == -1)||(R[Pair->i_r2]==NULL))
1272 {
1273 l2 = pLength(p2) - 1;
1274 }
1275 else
1276 {
1277 l2 = (R[Pair->i_r2])->GetpLength() - 1;
1278 }
1279 }
1280
1281 // get m2 * a2
1282#ifdef HAVE_SHIFTBBA
1283 if (tailRing->isLPring)
1284 {
1285 // m2*a2*m22
1286 poly tmp= tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing);
1287 a2 = tailRing->p_Procs->pp_Mult_mm(tmp, m22, tailRing);
1288 p_Delete(&tmp,tailRing);
1289 }
1290 else
1291#endif
1292 if (spNoether != NULL)
1293 {
1294 l2 = -1;
1295 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1296 assume(l2 == (int)pLength(a2));
1297 }
1298 else
1299 {
1300 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1301 }
1302 if (!(rField_is_Domain(currRing))) l2 = pLength(a2);
1303
1304 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1305
1306#ifdef HAVE_SHIFTBBA
1307 if (tailRing->isLPring)
1308 {
1309 // get m2*a2*m22 - m1*a1*m12
1310 poly tmp=tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing);
1311 Pair->Tail_Minus_mm_Mult_qq(m1, tmp, l1, spNoether);
1312 p_Delete(&tmp,tailRing);
1313 }
1314 else
1315#endif
1316 {
1317 // get m2*a2 - m1*a1
1318 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1319 }
1320
1321 // Clean-up time
1322 Pair->LmDeleteAndIter();
1323 p_LmDelete(m1, tailRing);
1324#ifdef HAVE_SHIFTBBA
1325 if (tailRing->isLPring)
1326 {
1327 // just to be sure, check that the shift is correct
1328 assume(Pair->shift == 0);
1329 assume(si_max(p_mFirstVblock(Pair->p, tailRing) - 1, 0) == Pair->shift); // == 0
1330
1331 p_LmDelete(m12, tailRing);
1332 p_LmDelete(m22, tailRing);
1333 // m2 is already deleted
1334 }
1335#endif
1336
1337 if (co != 0)
1338 {
1339 if (co==1)
1340 {
1341 p_SetCompP(p1,0, currRing, tailRing);
1342 }
1343 else
1344 {
1345 p_SetCompP(p2,0, currRing, tailRing);
1346 }
1347 }
1348}
VAR int create_count
Definition kspoly.cc:26
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)
Definition shiftop.cc:600
#define R
Definition sirandom.c:27

◆ ksOldCreateSpoly()

KINLINE poly ksOldCreateSpoly ( poly p1,
poly p2,
poly spNoether = NULL,
ring r = currRing )

Definition at line 1194 of file kInline.h.

1195{
1196 LObject L(r);
1197 L.p1 = p1;
1198 L.p2 = p2;
1199
1200 ksCreateSpoly(&L, spNoether);
1201 return L.GetLmCurrRing();
1202}

◆ ksOldSpolyRed()

KINLINE poly ksOldSpolyRed ( poly p1,
poly p2,
poly spNoether = NULL )

Definition at line 1174 of file kInline.h.

1175{
1176 LObject L(p2);
1177 TObject T(p1);
1178
1179 ksReducePoly(&L, &T, spNoether);
1180
1181 return L.GetLmCurrRing();
1182}
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat, BOOLEAN reduce)
Definition kspoly.cc:187

◆ ksOldSpolyRedNew()

KINLINE poly ksOldSpolyRedNew ( poly p1,
poly p2,
poly spNoether = NULL )

Definition at line 1184 of file kInline.h.

1185{
1186 LObject L(p_Copy(p2, currRing));
1187 TObject T(p1);
1188
1189 ksReducePoly(&L, &T, spNoether);
1190
1191 return L.GetLmCurrRing();
1192}

◆ ksOldSpolyTail()

KINLINE void ksOldSpolyTail ( poly p1,
poly q,
poly q2,
poly spNoether,
ring r = currRing )

Definition at line 1204 of file kInline.h.

1205{
1206 LObject L(q, currRing, r);
1207 TObject T(p1, currRing, r);
1208
1209 ksReducePolyTail(&L, &T, q2, spNoether);
1210}
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1147

◆ ksReducePoly()

int ksReducePoly ( LObject * PR,
TObject * PW,
poly spNoether = NULL,
number * coef = NULL,
poly * mon = NULL,
kStrategy strat = NULL,
BOOLEAN redtail = FALSE )

Definition at line 187 of file kspoly.cc.

194{
195#ifdef KDEBUG
196 red_count++;
197#ifdef TEST_OPT_DEBUG_RED
198// if (TEST_OPT_DEBUG)
199// {
200// Print("Red %d:", red_count); PR->wrp(); Print(" with:");
201// PW->wrp();
202// //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
203// //pWrite(PR->p);
204// }
205#endif
206#endif
207 int ret = 0;
208 ring tailRing = PR->tailRing;
209 if (strat!=NULL)
210 {
211 kTest_L(PR,strat);
212 kTest_T(PW,strat);
213 }
214
215 poly p1 = PR->GetLmTailRing(); // p2 | p1
216 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
217 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
218 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
219 p_CheckPolyRing(p1, tailRing);
220 p_CheckPolyRing(p2, tailRing);
221
222 pAssume1(p2 != NULL && p1 != NULL &&
223 p_DivisibleBy(p2, p1, tailRing));
224
225 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
226 (p_GetComp(p2, tailRing) == 0 &&
227 p_MaxComp(pNext(p2),tailRing) == 0));
228
229#ifdef HAVE_PLURAL
231 {
232 // for the time being: we know currRing==strat->tailRing
233 // no exp-bound checking needed
234 // (only needed if exp-bound(tailring)<exp-b(currRing))
235 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef,reduce);
236 else
237 {
238 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
239 assume(_p != NULL);
240 nc_PolyPolyRed(_p, p2,coef, currRing);
241 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
242 PR->pLength=0; // usually not used, GetpLength re-computes it if needed
243 }
244 return 0;
245 }
246#endif
247
248 if ((t2==NULL)&&(mon==NULL)) // Divisor is just one term, therefore it will
249 { // just cancel the leading term
250 PR->LmDeleteAndIter();
251 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
252 return 0;
253 }
254
255 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
256
257 if (tailRing != currRing)
258 {
259 // check that reduction does not violate exp bound
260 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
261 {
262 // undo changes of lm
263 p_ExpVectorAdd(lm, p2, tailRing);
264 if (strat == NULL) return 2;
265 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
266 tailRing = strat->tailRing;
267 p1 = PR->GetLmTailRing();
268 p2 = PW->GetLmTailRing();
269 t2 = pNext(p2);
270 lm = p1;
271 p_ExpVectorSub(lm, p2, tailRing);
272 ret = 1;
273 }
274 }
275
276#ifdef HAVE_SHIFTBBA
277 poly lmRight=NULL;
278 if (tailRing->isLPring)
279 {
280 assume(PR->shift == 0);
281 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
282 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
283 }
284#endif
285
286 // take care of coef business
287 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
288 {
289 number bn = pGetCoeff(lm);
290 number an = pGetCoeff(p2);
291 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
292 if (reduce)
293 {
294 if(n_IsMOne(an, tailRing->cf))
295 {
296 an=n_InpNeg(an, tailRing->cf);
297 bn=n_InpNeg(bn, tailRing->cf);
298 ct+=1;
299 }
300#ifdef KDEBUG
301 else if(!n_IsOne(an,tailRing->cf))
302 {
303 StringSetS("ksReducePoly: ");n_Write(an,tailRing->cf);
304 StringAppendS("\n");
306 }
307#endif
308 }
309 // in case of reduce, do not multiply PR
310 p_SetCoeff(lm, bn, tailRing);
311 if ((ct == 0) || (ct == 2))
312 PR->Tail_Mult_nn(an);
313 if (coef != NULL) *coef = an;
314 else n_Delete(&an, tailRing->cf);
315 }
316 else
317 {
318 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
319 }
320 if(mon!=NULL) *mon=pHead(lm);
321
322 // and finally,
323#ifdef HAVE_SHIFTBBA
324 if (tailRing->isLPring)
325 {
326 poly tmp=tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing);
327 PR->Tail_Minus_mm_Mult_qq(lm, tmp, pLength(t2), spNoether);
328 p_Delete(&tmp,tailRing);
329 p_Delete(&lm,tailRing);
330 p_Delete(&lmRight,tailRing);
331 }
332 else
333#endif
334 {
335 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
336 }
337 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
338 PR->LmDeleteAndIter();
339
340 return ret;
341}
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
Definition cf_ops.cc:660
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
Definition coeffs.h:478
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:560
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:474
VAR int red_count
Definition kspoly.cc:25
static void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition nc.h:284
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
#define pAssume1(cond)
Definition monomials.h:171
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition p_polys.h:1461
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1921
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:294
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition pDebug.cc:115
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151

◆ ksReducePolyBound()

int ksReducePolyBound ( LObject * PR,
TObject * PW,
int bound,
poly spNoether = NULL,
number * coef = NULL,
kStrategy strat = NULL )

Definition at line 590 of file kspoly.cc.

596{
597#ifdef KDEBUG
598 red_count++;
599#ifdef TEST_OPT_DEBUG_RED
600 if (TEST_OPT_DEBUG)
601 {
602 Print("Red %d:", red_count); PR->wrp(); Print(" with:");
603 PW->wrp();
604 //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
605 //pWrite(PR->p);
606 }
607#endif
608#endif
609 int ret = 0;
610 ring tailRing = PR->tailRing;
611 if (strat!=NULL)
612 {
613 kTest_L(PR,strat);
614 kTest_T(PW,strat);
615 }
616
617 poly p1 = PR->GetLmTailRing(); // p2 | p1
618 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
619 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
620 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
621 p_CheckPolyRing(p1, tailRing);
622 p_CheckPolyRing(p2, tailRing);
623
624 pAssume1(p2 != NULL && p1 != NULL &&
625 p_DivisibleBy(p2, p1, tailRing));
626
627 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
628 (p_GetComp(p2, tailRing) == 0 &&
629 p_MaxComp(pNext(p2),tailRing) == 0));
630
631#ifdef HAVE_PLURAL
633 {
634 // for the time being: we know currRing==strat->tailRing
635 // no exp-bound checking needed
636 // (only needed if exp-bound(tailring)<exp-b(currRing))
637 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef,FALSE);
638 else
639 {
640 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
641 assume(_p != NULL);
642 nc_PolyPolyRed(_p, p2,coef, currRing);
643 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
644 PR->pLength=0; // usually not used, GetpLength re-computes it if needed
645 }
646 return 0;
647 }
648#endif
649
650 if (t2==NULL) // Divisor is just one term, therefore it will
651 { // just cancel the leading term
652 PR->LmDeleteAndIter();
653 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
654 return 0;
655 }
656
657 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
658
659 if (tailRing != currRing)
660 {
661 // check that reduction does not violate exp bound
662 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
663 {
664 // undo changes of lm
665 p_ExpVectorAdd(lm, p2, tailRing);
666 if (strat == NULL) return 2;
667 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
668 tailRing = strat->tailRing;
669 p1 = PR->GetLmTailRing();
670 p2 = PW->GetLmTailRing();
671 t2 = pNext(p2);
672 lm = p1;
673 p_ExpVectorSub(lm, p2, tailRing);
674 ret = 1;
675 }
676 }
677
678#ifdef HAVE_SHIFTBBA
679 poly lmRight;
680 if (tailRing->isLPring)
681 {
682 assume(PR->shift == 0);
683 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
684 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
685 }
686#endif
687
688 // take care of coef business
689 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
690 {
691 number bn = pGetCoeff(lm);
692 number an = pGetCoeff(p2);
693 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
694 p_SetCoeff(lm, bn, tailRing);
695 if ((ct == 0) || (ct == 2))
696 PR->Tail_Mult_nn(an);
697 if (coef != NULL) *coef = an;
698 else n_Delete(&an, tailRing->cf);
699 }
700 else
701 {
702 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
703 }
704
705
706 // and finally,
707#ifdef HAVE_SHIFTBBA
708 if (tailRing->isLPring)
709 {
710 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
711 }
712 else
713#endif
714 {
715 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
716 }
717 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
718 PR->LmDeleteAndIter();
719
720#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
721 if (TEST_OPT_DEBUG)
722 {
723 Print(" to: "); PR->wrp(); Print("\n");
724 //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
725 }
726#endif
727 return ret;
728}

◆ ksReducePolyGCD()

int ksReducePolyGCD ( LObject * PR,
TObject * PW,
poly spNoether = NULL,
number * coef = NULL,
kStrategy strat = NULL )

◆ ksReducePolyLC()

int ksReducePolyLC ( LObject * PR,
TObject * PW,
poly spNoether = NULL,
number * coef = NULL,
kStrategy strat = NULL )

Definition at line 477 of file kspoly.cc.

482{
483#ifdef KDEBUG
484 red_count++;
485#ifdef TEST_OPT_DEBUG_RED
486// if (TEST_OPT_DEBUG)
487// {
488// Print("Red %d:", red_count); PR->wrp(); Print(" with:");
489// PW->wrp();
490// //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
491// //pWrite(PR->p);
492// }
493#endif
494#endif
495 /* printf("PR->P: ");
496 * p_Write(PR->p, currRing, PR->tailRing); */
497 int ret = 0;
498 ring tailRing = PR->tailRing;
499 if (strat!=NULL)
500 {
501 kTest_L(PR,strat);
502 kTest_T(PW,strat);
503 }
504
505 poly p1 = PR->GetLmTailRing(); // p2 | p1
506 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
507 poly lm = p1; // really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
508 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
509 p_CheckPolyRing(p1, tailRing);
510 p_CheckPolyRing(p2, tailRing);
511
512 pAssume1(p2 != NULL && p1 != NULL &&
513 p_DivisibleBy(p2, p1, tailRing));
514
515 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
516 (p_GetComp(p2, tailRing) == 0 &&
517 p_MaxComp(pNext(p2),tailRing) == 0));
518
519#ifdef HAVE_PLURAL
521 {
522 // for the time being: we know currRing==strat->tailRing
523 // no exp-bound checking needed
524 // (only needed if exp-bound(tailring)<exp-b(currRing))
525 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef,FALSE);
526 else
527 {
528 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
529 assume(_p != NULL);
530 nc_PolyPolyRed(_p, p2,coef, currRing);
531 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
532 PR->pLength=0; // usually not used, GetpLength re-computes it if needed
533 }
534 return 0;
535 }
536#endif
537
538 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
539 p_SetCoeff(lm, n_Init(1, tailRing->cf), tailRing);
540 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
541 {
542 // undo changes of lm
543 p_ExpVectorAdd(lm, p2, tailRing);
544 if (strat == NULL) return 2;
545 /* if (! kStratChangeTailRing(strat, PR, PW)) return -1; */
546 tailRing = strat->tailRing;
547 p1 = PR->GetLmTailRing();
548 p2 = PW->GetLmTailRing();
549 lm = p1;
550 p_ExpVectorSub(lm, p2, tailRing);
551 ret = 1;
552 }
553
554#ifdef HAVE_SHIFTBBA
555 poly lmRight;
556 if (tailRing->isLPring)
557 {
558 assume(PR->shift == 0);
559 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
560 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
561 }
562#endif
563
564 // and finally,
565#ifdef HAVE_SHIFTBBA
566 if (tailRing->isLPring)
567 {
568 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing), pLength(p2), spNoether);
569 }
570 else
571#endif
572 {
573 PR->Tail_Minus_mm_Mult_qq(lm, p2, pLength(p2) /*PW->GetpLength() - 1*/, spNoether);
574 }
575 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
576
577 PR->LmDeleteAndIter();
578 p_SetCoeff(PR->p, *coef, currRing);
579
580#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
581 if (TEST_OPT_DEBUG)
582 {
583 Print(" to: "); PR->wrp(); Print("\n");
584 //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
585 }
586#endif
587 return ret;
588}

◆ ksReducePolySig()

int ksReducePolySig ( LObject * PR,
TObject * PW,
long idx,
poly spNoether = NULL,
number * coef = NULL,
kStrategy strat = NULL )

Definition at line 737 of file kspoly.cc.

743{
744#ifdef KDEBUG
745 red_count++;
746#ifdef TEST_OPT_DEBUG_RED
747 if (TEST_OPT_DEBUG)
748 {
749 Print("Red %d:", red_count); PR->wrp(); Print(" with:");
750 PW->wrp();
751 }
752#endif
753#endif
754 int ret = 0;
755 ring tailRing = PR->tailRing;
756 if (strat!=NULL)
757 {
758 kTest_L(PR,strat);
759 kTest_T(PW,strat);
760 }
761
762 // signature-based stuff:
763 // checking for sig-safeness first
764 // NOTE: This has to be done in the current ring
765 //
766 /**********************************************
767 *
768 * TODO:
769 * --------------------------------------------
770 * if strat->sbaOrder == 1
771 * Since we are subdividing lower index and
772 * current index reductions it is enough to
773 * look at the polynomial part of the signature
774 * for a check. This should speed-up checking
775 * a lot!
776 * if !strat->sbaOrder == 0
777 * We are not subdividing lower and current index
778 * due to the fact that we are using the induced
779 * Schreyer order
780 *
781 * nevertheless, this different behaviour is
782 * taken care of by is_sigsafe
783 * => one reduction procedure can be used for
784 * both, the incremental and the non-incremental
785 * attempt!
786 * --------------------------------------------
787 *
788 *********************************************/
789 //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
790 if (!PW->is_sigsafe)
791 {
792 poly sigMult = pCopy(PW->sig); // copy signature of reducer
793//#if 1
794#ifdef DEBUGF5
795 printf("IN KSREDUCEPOLYSIG: \n");
796 pWrite(pHead(f1));
797 pWrite(pHead(f2));
798 pWrite(sigMult);
799 printf("--------------\n");
800#endif
801 p_ExpVectorAddSub(sigMult,PR->GetLmCurrRing(),PW->GetLmCurrRing(),currRing);
802//#if 1
803#ifdef DEBUGF5
804 printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
805 pWrite(pHead(f1));
806 pWrite(pHead(f2));
807 pWrite(sigMult);
808 pWrite(PR->sig);
809 printf("--------------\n");
810#endif
811 int sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
812 // now we can delete the copied polynomial data used for checking for
813 // sig-safeness of the reduction step
814//#if 1
815#ifdef DEBUGF5
816 printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
817
818#endif
819 //pDelete(&f1);
820 pDelete(&sigMult);
821 // go on with the computations only if the signature of p2 is greater than the
822 // signature of fm*p1
823 if(sigSafe != 1)
824 {
825 PR->is_redundant = TRUE;
826 return 3;
827 }
828 //PW->is_sigsafe = TRUE;
829 }
830 PR->is_redundant = FALSE;
831 poly p1 = PR->GetLmTailRing(); // p2 | p1
832 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
833 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
834 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
835 p_CheckPolyRing(p1, tailRing);
836 p_CheckPolyRing(p2, tailRing);
837
838 pAssume1(p2 != NULL && p1 != NULL &&
839 p_DivisibleBy(p2, p1, tailRing));
840
841 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
842 (p_GetComp(p2, tailRing) == 0 &&
843 p_MaxComp(pNext(p2),tailRing) == 0));
844
845#ifdef HAVE_PLURAL
847 {
848 // for the time being: we know currRing==strat->tailRing
849 // no exp-bound checking needed
850 // (only needed if exp-bound(tailring)<exp-b(currRing))
851 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef,FALSE);
852 else
853 {
854 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
855 assume(_p != NULL);
856 nc_PolyPolyRed(_p, p2, coef, currRing);
857 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
858 PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
859 }
860 return 0;
861 }
862#endif
863
864 if (t2==NULL) // Divisor is just one term, therefore it will
865 { // just cancel the leading term
866 PR->LmDeleteAndIter();
867 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
868 return 0;
869 }
870
871 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
872
873 if (tailRing != currRing)
874 {
875 // check that reduction does not violate exp bound
876 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
877 {
878 // undo changes of lm
879 p_ExpVectorAdd(lm, p2, tailRing);
880 if (strat == NULL) return 2;
881 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
882 tailRing = strat->tailRing;
883 p1 = PR->GetLmTailRing();
884 p2 = PW->GetLmTailRing();
885 t2 = pNext(p2);
886 lm = p1;
887 p_ExpVectorSub(lm, p2, tailRing);
888 ret = 1;
889 }
890 }
891
892#ifdef HAVE_SHIFTBBA
893 poly lmRight;
894 if (tailRing->isLPring)
895 {
896 assume(PR->shift == 0);
897 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
898 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
899 }
900#endif
901
902 // take care of coef business
903 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
904 {
905 number bn = pGetCoeff(lm);
906 number an = pGetCoeff(p2);
907 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
908 p_SetCoeff(lm, bn, tailRing);
909 if ((ct == 0) || (ct == 2))
910 PR->Tail_Mult_nn(an);
911 if (coef != NULL) *coef = an;
912 else n_Delete(&an, tailRing->cf);
913 }
914 else
915 {
916 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
917 }
918
919
920 // and finally,
921#ifdef HAVE_SHIFTBBA
922 if (tailRing->isLPring)
923 {
924 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
925 }
926 else
927#endif
928 {
929 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
930 }
931 assume(PW->GetpLength() == (int)pLength(PW->p != NULL ? PW->p : PW->t_p));
932 PR->LmDeleteAndIter();
933
934#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
935 if (TEST_OPT_DEBUG)
936 {
937 Print(" to: "); PR->wrp(); Print("\n");
938 }
939#endif
940 return ret;
941}
static void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
Definition p_polys.h:1477

◆ ksReducePolySigRing()

int ksReducePolySigRing ( LObject * PR,
TObject * PW,
long idx,
poly spNoether = NULL,
number * coef = NULL,
kStrategy strat = NULL )

Definition at line 943 of file kspoly.cc.

949{
950#ifdef KDEBUG
951 red_count++;
952#ifdef TEST_OPT_DEBUG_RED
953 if (TEST_OPT_DEBUG)
954 {
955 Print("Red %d:", red_count); PR->wrp(); Print(" with:");
956 PW->wrp();
957 }
958#endif
959#endif
960 int ret = 0;
961 ring tailRing = PR->tailRing;
962 if (strat!=NULL)
963 {
964 kTest_L(PR,strat);
965 kTest_T(PW,strat);
966 }
967
968 // signature-based stuff:
969 // checking for sig-safeness first
970 // NOTE: This has to be done in the current ring
971 //
972 /**********************************************
973 *
974 * TODO:
975 * --------------------------------------------
976 * if strat->sbaOrder == 1
977 * Since we are subdividing lower index and
978 * current index reductions it is enough to
979 * look at the polynomial part of the signature
980 * for a check. This should speed-up checking
981 * a lot!
982 * if !strat->sbaOrder == 0
983 * We are not subdividing lower and current index
984 * due to the fact that we are using the induced
985 * Schreyer order
986 *
987 * nevertheless, this different behaviour is
988 * taken care of by is_sigsafe
989 * => one reduction procedure can be used for
990 * both, the incremental and the non-incremental
991 * attempt!
992 * --------------------------------------------
993 *
994 *********************************************/
995 //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
996 if (!PW->is_sigsafe)
997 {
998 poly sigMult = pCopy(PW->sig); // copy signature of reducer
999//#if 1
1000#ifdef DEBUGF5
1001 printf("IN KSREDUCEPOLYSIG: \n");
1002 pWrite(pHead(f1));
1003 pWrite(pHead(f2));
1004 pWrite(sigMult);
1005 printf("--------------\n");
1006#endif
1007 p_ExpVectorAddSub(sigMult,PR->GetLmCurrRing(),PW->GetLmCurrRing(),currRing);
1008 //I have also to set the leading coefficient for sigMult (in the case of rings)
1010 {
1011 pSetCoeff(sigMult,nMult(nDiv(pGetCoeff(PR->p),pGetCoeff(PW->p)), pGetCoeff(sigMult)));
1012 if(nIsZero(pGetCoeff(sigMult)))
1013 {
1014 sigMult = NULL;
1015 }
1016 }
1017//#if 1
1018#ifdef DEBUGF5
1019 printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
1020 pWrite(pHead(f1));
1021 pWrite(pHead(f2));
1022 pWrite(sigMult);
1023 pWrite(PR->sig);
1024 printf("--------------\n");
1025#endif
1026 int sigSafe;
1028 sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
1029 // now we can delete the copied polynomial data used for checking for
1030 // sig-safeness of the reduction step
1031//#if 1
1032#ifdef DEBUGF5
1033 printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
1034
1035#endif
1037 {
1038 // Set the sig
1039 poly origsig = pCopy(PR->sig);
1040 if(sigMult != NULL)
1041 PR->sig = pHead(pSub(PR->sig, sigMult));
1042 //The sigs have the same lm, have to subtract
1043 //It may happen that now the signature is 0 (drop)
1044 if(PR->sig == NULL)
1045 {
1046 strat->sigdrop=TRUE;
1047 }
1048 else
1049 {
1050 if(pLtCmp(PR->sig,origsig) == 1)
1051 {
1052 // do not allow this reduction - it will increase it's signature
1053 // and the partially standard basis is just till the old sig, not the new one
1054 PR->is_redundant = TRUE;
1055 pDelete(&PR->sig);
1056 PR->sig = origsig;
1057 strat->blockred++;
1058 return 3;
1059 }
1060 if(pLtCmp(PR->sig,origsig) == -1)
1061 {
1062 strat->sigdrop=TRUE;
1063 }
1064 }
1065 pDelete(&origsig);
1066 }
1067 //pDelete(&f1);
1068 // go on with the computations only if the signature of p2 is greater than the
1069 // signature of fm*p1
1070 if(sigSafe != 1 && !rField_is_Ring(currRing))
1071 {
1072 PR->is_redundant = TRUE;
1073 return 3;
1074 }
1075 //PW->is_sigsafe = TRUE;
1076 }
1077 PR->is_redundant = FALSE;
1078 poly p1 = PR->GetLmTailRing(); // p2 | p1
1079 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
1080 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
1081 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
1082 p_CheckPolyRing(p1, tailRing);
1083 p_CheckPolyRing(p2, tailRing);
1084
1085 pAssume1(p2 != NULL && p1 != NULL &&
1086 p_DivisibleBy(p2, p1, tailRing));
1087
1088 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
1089 (p_GetComp(p2, tailRing) == 0 &&
1090 p_MaxComp(pNext(p2),tailRing) == 0));
1091
1092#ifdef HAVE_PLURAL
1094 {
1095 // for the time being: we know currRing==strat->tailRing
1096 // no exp-bound checking needed
1097 // (only needed if exp-bound(tailring)<exp-b(currRing))
1098 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef,FALSE);
1099 else
1100 {
1101 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
1102 assume(_p != NULL);
1103 nc_PolyPolyRed(_p, p2, coef, currRing);
1104 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
1105 PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
1106 }
1107 return 0;
1108 }
1109#endif
1110
1111 if (t2==NULL) // Divisor is just one term, therefore it will
1112 { // just cancel the leading term
1113 PR->LmDeleteAndIter();
1114 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
1115 return 0;
1116 }
1117
1118 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
1119
1120 if (tailRing != currRing)
1121 {
1122 // check that reduction does not violate exp bound
1123 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
1124 {
1125 // undo changes of lm
1126 p_ExpVectorAdd(lm, p2, tailRing);
1127 if (strat == NULL) return 2;
1128 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
1129 tailRing = strat->tailRing;
1130 p1 = PR->GetLmTailRing();
1131 p2 = PW->GetLmTailRing();
1132 t2 = pNext(p2);
1133 lm = p1;
1134 p_ExpVectorSub(lm, p2, tailRing);
1135 ret = 1;
1136 }
1137 }
1138
1139#ifdef HAVE_SHIFTBBA
1140 poly lmRight;
1141 if (tailRing->isLPring)
1142 {
1143 assume(PR->shift == 0);
1144 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
1145 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
1146 }
1147#endif
1148
1149 // take care of coef business
1151 {
1152 p_SetCoeff(lm, nDiv(pGetCoeff(lm),pGetCoeff(p2)), tailRing);
1153 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
1154 }
1155 else
1156 {
1157 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
1158 {
1159 number bn = pGetCoeff(lm);
1160 number an = pGetCoeff(p2);
1161 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
1162 p_SetCoeff(lm, bn, tailRing);
1163 if (((ct == 0) || (ct == 2)))
1164 PR->Tail_Mult_nn(an);
1165 if (coef != NULL) *coef = an;
1166 else n_Delete(&an, tailRing->cf);
1167 }
1168 else
1169 {
1170 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
1171 }
1172 }
1173
1174 // and finally,
1175#ifdef HAVE_SHIFTBBA
1176 if (tailRing->isLPring)
1177 {
1178 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
1179 }
1180 else
1181#endif
1182 {
1183 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1184 }
1185 assume(PW->GetpLength() == (int)pLength(PW->p != NULL ? PW->p : PW->t_p));
1186 PR->LmDeleteAndIter();
1187
1188#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
1189 if (TEST_OPT_DEBUG)
1190 {
1191 Print(" to: "); PR->wrp(); Print("\n");
1192 }
1193#endif
1194 return ret;
1195}
int blockred
Definition kutil.h:362
#define nDiv(a, b)
Definition numbers.h:32
#define pSub(a, b)
Definition polys.h:288

◆ ksReducePolyTail() [1/2]

KINLINE int ksReducePolyTail ( LObject * PR,
TObject * PW,
LObject * Red )

Definition at line 1147 of file kInline.h.

1148{
1149 BOOLEAN ret;
1150 number coef;
1151
1152 assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1153 Red->HeadNormalize();
1154 ret = ksReducePoly(Red, PW, NULL, &coef);
1155
1156 if (!ret)
1157 {
1158 if (! n_IsOne(coef, currRing->cf))
1159 {
1160 PR->Mult_nn(coef);
1161 // HANNES: mark for Normalize
1162 }
1163 n_Delete(&coef, currRing->cf);
1164 }
1165 return ret;
1166}

◆ ksReducePolyTail() [2/2]

int ksReducePolyTail ( LObject * PR,
TObject * PW,
poly Current,
poly spNoether = NULL )

Definition at line 1350 of file kspoly.cc.

1351{
1352 BOOLEAN ret;
1353 number coef;
1354 poly Lp = PR->GetLmCurrRing();
1355 poly Save = PW->GetLmCurrRing();
1356
1357 pAssume(pIsMonomOf(Lp, Current));
1358
1359 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
1360 assume(PR->bucket == NULL);
1361
1362 LObject Red(pNext(Current), PR->tailRing);
1363 TObject With(PW, Lp == Save);
1364
1365 pAssume(!pHaveCommonMonoms(Red.p, With.p));
1366 ret = ksReducePoly(&Red, &With, spNoether, &coef);
1367
1368 if (!ret)
1369 {
1370 if (! n_IsOne(coef, currRing->cf))
1371 {
1372 pNext(Current) = NULL;
1373 if (Current == PR->p && PR->t_p != NULL)
1374 pNext(PR->t_p) = NULL;
1375 PR->Mult_nn(coef);
1376 }
1377
1378 n_Delete(&coef, currRing->cf);
1379 pNext(Current) = Red.GetLmTailRing();
1380 if (Current == PR->p && PR->t_p != NULL)
1381 pNext(PR->t_p) = pNext(Current);
1382 }
1383
1384 if (Lp == Save)
1385 With.Delete();
1386
1387 return ret;
1388}
BOOLEAN pIsMonomOf(poly p, poly m)
Definition pDebug.cc:164
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition pDebug.cc:174

◆ ksReducePolyZ()

int ksReducePolyZ ( LObject * PR,
TObject * PW,
poly spNoether = NULL,
number * coef = NULL,
kStrategy strat = NULL )

◆ kStratChangeTailRing()

BOOLEAN kStratChangeTailRing ( kStrategy strat,
LObject * L = NULL,
TObject * T = NULL,
unsigned long new_expbound = 0 )

Definition at line 10939 of file kutil.cc.

10940{
10941 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
10942 /* initial setup or extending */
10943
10944 if (rIsLPRing(currRing)) return TRUE;
10945 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
10946 if (expbound >= currRing->bitmask) return FALSE;
10947 strat->overflow=FALSE;
10948 ring new_tailRing = rModifyRing(currRing,
10949 // Hmmm .. the condition pFDeg == p_Deg
10950 // might be too strong
10951 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
10952 (strat->ak==0), // omit_comp if the input is an ideal
10953 expbound); // exp_limit
10954
10955 if (new_tailRing == currRing) return TRUE;
10956
10957 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
10958 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
10959
10960 if (currRing->pFDeg != currRing->pFDegOrig)
10961 {
10962 new_tailRing->pFDeg = currRing->pFDeg;
10963 new_tailRing->pLDeg = currRing->pLDeg;
10964 }
10965
10966 if (TEST_OPT_PROT)
10967 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
10968 #ifdef KDEBUG
10969 kTest_TS(strat);
10970 assume(new_tailRing != strat->tailRing);
10971 #endif
10972 pShallowCopyDeleteProc p_shallow_copy_delete
10973 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
10974
10975 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
10976
10977 int i;
10978 for (i=0; i<=strat->tl; i++)
10979 {
10980 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
10981 p_shallow_copy_delete);
10982 }
10983 for (i=0; i<=strat->Ll; i++)
10984 {
10985 assume(strat->L[i].p != NULL);
10986 if (pNext(strat->L[i].p) != strat->tail)
10987 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
10988 }
10989 if ((strat->P.t_p != NULL) ||
10990 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
10991 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
10992
10993 if ((L != NULL) && (L->tailRing != new_tailRing))
10994 {
10995 if (L->i_r < 0)
10996 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
10997 else
10998 {
10999 assume(L->i_r <= strat->tl);
11000 TObject* t_l = strat->R[L->i_r];
11001 assume(t_l != NULL);
11002 L->tailRing = new_tailRing;
11003 L->p = t_l->p;
11004 L->t_p = t_l->t_p;
11005 L->max_exp = t_l->max_exp;
11006 }
11007 }
11008
11009 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11010 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11011
11012 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11013 if (strat->tailRing != currRing)
11015
11016 strat->tailRing = new_tailRing;
11017 strat->tailBin = new_tailBin;
11019 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11020
11021 if (strat->kNoether != NULL)
11022 {
11023 if (strat->t_kNoether != NULL)
11024 p_LmFree(strat->t_kNoether, strat->tailRing);
11025 strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_tailRing);
11026 }
11027
11028 #ifdef KDEBUG
11029 kTest_TS(strat);
11030 #endif
11031 if (TEST_OPT_PROT)
11032 PrintS("]");
11033 return TRUE;
11034}
poly t_kNoether
Definition kutil.h:329
pFDegProc pOrigFDeg_TailRing
Definition kutil.h:297
pLDegProc pOrigLDeg_TailRing
Definition kutil.h:298
omBin_t * omBin
Definition omStructs.h:12
void rKillModifiedRing(ring r)
Definition ring.cc:3119
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition ring.cc:2758
#define omGetStickyBinOfBin(B)
Definition xalloc.h:247
#define omMergeStickyBinIntoBin(A, B)
Definition xalloc.h:275

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy strat)

Definition at line 11036 of file kutil.cc.

11037{
11038 unsigned long l = 0;
11039 int i;
11040 long e;
11041
11042 assume(strat->tailRing == currRing);
11043
11044 for (i=0; i<= strat->Ll; i++)
11045 {
11046 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11047 }
11048 for (i=0; i<=strat->tl; i++)
11049 {
11050 // Hmm ... this we could do in one Step
11051 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11052 }
11054 {
11055 l *= 2;
11056 }
11057 e = p_GetMaxExp(l, currRing);
11058 if (e <= 1) e = 2;
11059 if (rIsLPRing(currRing)) e = 1;
11060
11061 kStratChangeTailRing(strat, NULL, NULL, e);
11062}
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 1004 of file kutil.cc.

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

◆ kTest_L()

BOOLEAN kTest_L ( LObject * L,
kStrategy strat,
BOOLEAN testp = FALSE,
int lpos = -1,
TSet T = NULL,
int tlength = -1 )

Definition at line 916 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy strat)

Definition at line 1049 of file kutil.cc.

1050{
1051 int i;
1052 BOOLEAN ret = TRUE;
1053 for (i=0; i<=strat->sl; i++)
1054 {
1055 if (strat->S[i] != NULL &&
1056 strat->sevS[i] != pGetShortExpVector(strat->S[i]))
1057 {
1058 return dReportError("S[%d] wrong sev: has %o, specified to have %o",
1059 i , pGetShortExpVector(strat->S[i]), strat->sevS[i]);
1060 }
1061 }
1062 return ret;
1063}

◆ kTest_T()

BOOLEAN kTest_T ( TObject * T,
kStrategy strat,
int tpos = -1,
char TN = '?' )

Definition at line 789 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy strat)

Definition at line 1067 of file kutil.cc.

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

◆ kTestDivisibleByT0_Z()

int kTestDivisibleByT0_Z ( const kStrategy strat,
const LObject * L )

tests if T[0] divides the leading monomial of L, returns -1 if not

Definition at line 142 of file kstd2.cc.

143{
144 if (strat->tl < 1)
145 return -1;
146
147 unsigned long not_sev = ~L->sev;
148 const unsigned long sevT0 = strat->sevT[0];
149 number orest,rest,mult;
150 if (L->p!=NULL)
151 {
152 const poly T0p = strat->T[0].p;
153 const ring r = currRing;
154 const poly p = L->p;
155 orest = pGetCoeff(p);
156
157 pAssume(~not_sev == p_GetShortExpVector(p, r));
158
159#if defined(PDEBUG) || defined(PDIV_DEBUG)
160 if (p_LmShortDivisibleBy(T0p, sevT0, p, not_sev, r))
161#else
162 if (!(sevT0 & not_sev) && p_LmDivisibleBy(T0p, p, r))
163#endif
164 {
165 if (n_QuotRem!=ndQuotRem) /*euclidean ring*/
166 {
167 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf);
168 if (!n_IsZero(mult, r->cf) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
169 {
170 n_Delete(&mult,r->cf);
171 n_Delete(&rest,r->cf);
172 return 0;
173 }
174 n_Delete(&mult,r->cf);
175 n_Delete(&rest,r->cf);
176 }
177 }
178 }
179 else
180 {
181 const poly T0p = strat->T[0].t_p;
182 const ring r = strat->tailRing;
183 const poly p = L->t_p;
184 orest = pGetCoeff(p);
185#if defined(PDEBUG) || defined(PDIV_DEBUG)
186 if (p_LmShortDivisibleBy(T0p, sevT0,
187 p, not_sev, r))
188#else
189 if (!(sevT0 & not_sev) && p_LmDivisibleBy(T0p, p, r))
190#endif
191 {
192 if (n_QuotRem!=ndQuotRem) /*euclidean ring*/
193 {
194 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf);
195 if (!n_IsZero(mult, r->cf) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
196 {
197 n_Delete(&mult,r->cf);
198 n_Delete(&rest,r->cf);
199 return 0;
200 }
201 n_Delete(&mult,r->cf);
202 n_Delete(&rest,r->cf);
203 }
204 }
205 }
206 return -1;
207}
number ndQuotRem(number a, number b, number *r, const coeffs R)
Definition numbers.cc:356

◆ message()

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

Definition at line 7463 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy strat)

Definition at line 7536 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int hilbcount,
kStrategy strat )

Definition at line 7504 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int hilbcount,
kStrategy strat )

Definition at line 7517 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy strat)

Definition at line 10379 of file kutil.cc.

10380{
10381 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10382 return FALSE;
10383 int i,j;
10384 poly newNoether;
10385
10386#if 0
10387 if (currRing->weight_all_1)
10388 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10389 else
10390 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10391#else
10392 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10393#endif
10394 if (strat->kNoether==NULL) return FALSE;
10395 if (strat->t_kNoether != NULL)
10396 {
10397 p_LmFree(strat->t_kNoether, strat->tailRing);
10398 strat->t_kNoether=NULL;
10399 }
10400 if (strat->tailRing != currRing)
10402 /* compare old and new noether*/
10403 newNoether = pLmInit(strat->kNoether);
10404 pSetCoeff0(newNoether,nInit(1));
10405 j = p_FDeg(newNoether,currRing);
10406 // newNoether is now the new highest edge (on the boundary)
10407 // now find the next monomial after highest monomial in R/I
10408 // (the smallest monomial not in R/I)
10409 for (i=currRing->N-1;i>0; i--)
10410 {
10411 int e;
10412 if ((e=pGetExp(newNoether, i)) > 0)
10413 {
10414 e--;
10415 pSetExp(newNoether,i,e);
10416 }
10417 }
10418 pSetm(newNoether);
10419 if (j < HCord) /*- statistics -*/
10420 {
10421 if (TEST_OPT_PROT)
10422 {
10423 Print("H(%d)",j);
10424 mflush();
10425 }
10426 HCord=j;
10427 #ifdef KDEBUG
10428 if (TEST_OPT_DEBUG)
10429 {
10430 Print("H(%d):",j);
10431 wrp(strat->kNoether);
10432 PrintLn();
10433 }
10434 #endif
10435 }
10436 if (pCmp(strat->kNoether,newNoether)!=1)
10437 {
10438 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10439 strat->kNoether=newNoether;
10440 if (strat->t_kNoether != NULL)
10441 {
10442 p_LmFree(strat->t_kNoether, strat->tailRing);
10443 strat->t_kNoether=NULL;
10444 }
10445 if (strat->tailRing != currRing)
10447
10448 return TRUE;
10449 }
10450 pLmDelete(newNoether);
10451 return FALSE;
10452}
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 pGetExp(p, i)
Exponent.
Definition polys.h:42

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

int posInIdealMonFirst ( const ideal F,
const poly p,
int start = 0,
int end = -1 )

Definition at line 4841 of file kutil.cc.

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

◆ posInL0()

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

Definition at line 5611 of file kutil.cc.

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

◆ posInL10()

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

Definition at line 1360 of file kstd1.cc.

1361{
1362 int j,dp,dL;
1363
1364 if (length<0) return 0;
1365 if (hasPurePower(p,strat->lastAxis,&dp,strat))
1366 {
1367 int op= p->GetpFDeg() +p->ecart;
1368 for (j=length; j>=0; j--)
1369 {
1370 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1371 return j+1;
1372 if (dp < dL)
1373 return j+1;
1374 if ((dp == dL)
1375 && (set[j].GetpFDeg()+set[j].ecart >= op))
1376 return j+1;
1377 }
1378 }
1379 j=length;
1380 loop
1381 {
1382 if (j<0) break;
1383 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1384 j--;
1385 }
1386 return strat->posInLOld(set,j,p,strat);
1387}
static BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition kstd1.cc:1312

◆ posInL10Ring()

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

◆ posInL11()

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

Definition at line 5802 of file kutil.cc.

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

◆ posInL110()

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

Definition at line 6058 of file kutil.cc.

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

◆ posInL11Ring()

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

Definition at line 5844 of file kutil.cc.

5846{
5847 if (length<0) return 0;
5848
5849 int o = p->GetpFDeg();
5850 int op = set[length].GetpFDeg();
5851
5852 if ((op > o)
5853 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
5854 return length+1;
5855 int i;
5856 int an = 0;
5857 int en= length;
5858 loop
5859 {
5860 if (an >= en-1)
5861 {
5862 op = set[an].GetpFDeg();
5863 if ((op > o)
5864 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
5865 return en;
5866 return an;
5867 }
5868 i=(an+en) / 2;
5869 op = set[i].GetpFDeg();
5870 if ((op > o)
5871 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
5872 an=i;
5873 else
5874 en=i;
5875 }
5876}
#define pLtCmpOrdSgnDiffM(p, q)
Definition polys.h:126

◆ posInL11Ringls()

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

Definition at line 5912 of file kutil.cc.

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

◆ posInL13()

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

Definition at line 6145 of file kutil.cc.

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

◆ posInL15()

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

Definition at line 6180 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6215 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6255 of file kutil.cc.

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

◆ posInLF5CRing()

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

Definition at line 5878 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5669 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5694 of file kutil.cc.

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

◆ posInS()

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

Definition at line 4663 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4764 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy strat,
const poly sig )

Definition at line 5758 of file kutil.cc.

5759{
5760 if (strat->syzl==0) return 0;
5761 int cmp_int=currRing->OrdSgn;
5762 if (pLtCmp(strat->syz[strat->syzl-1],sig) != cmp_int)
5763 return strat->syzl;
5764 int i;
5765 int an = 0;
5766 int en= strat->syzl-1;
5767 loop
5768 {
5769 if (an >= en-1)
5770 {
5771 if (pLtCmp(strat->syz[an],sig) != cmp_int) return en;
5772 return an;
5773 }
5774 i=(an+en) / 2;
5775 if (pLtCmp(strat->syz[i],sig) != cmp_int) an=i;
5776 else en=i;
5777 /*aend. fuer lazy == in !=- machen */
5778 }
5779}

◆ posInT0()

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

Definition at line 4885 of file kutil.cc.

4886{
4887 return (length+1);
4888}

◆ posInT1()

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

Definition at line 4896 of file kutil.cc.

4897{
4898 if (length==-1) return 0;
4899
4900 if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
4901
4902 int i;
4903 int an = 0;
4904 int en= length;
4905 int cmp_int=currRing->OrdSgn;
4906
4907 loop
4908 {
4909 if (an >= en-1)
4910 {
4911 if (pLmCmp(set[an].p,p.p) == cmp_int) return an;
4912 return en;
4913 }
4914 i=(an+en) / 2;
4915 if (pLmCmp(set[i].p,p.p) == cmp_int) en=i;
4916 else an=i;
4917 }
4918}

◆ posInT11()

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

Definition at line 4953 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5029 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5117 of file kutil.cc.

5118{
5119 if (length==-1) return 0;
5120
5121 int o = p.GetpFDeg();
5122
5123 if (set[length].GetpFDeg() <= o)
5124 return length+1;
5125
5126 int i;
5127 int an = 0;
5128 int en= length;
5129 loop
5130 {
5131 if (an >= en-1)
5132 {
5133 if (set[an].GetpFDeg() > o)
5134 return an;
5135 return en;
5136 }
5137 i=(an+en) / 2;
5138 if (set[i].GetpFDeg() > o)
5139 en=i;
5140 else
5141 an=i;
5142 }
5143}

◆ posInT15()

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

Definition at line 5184 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5278 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5384 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5510 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4925 of file kutil.cc.

4926{
4927 if (length==-1) return 0;
4928 p.GetpLength();
4929 if (set[length].length<p.length) return length+1;
4930
4931 int i;
4932 int an = 0;
4933 int en= length;
4934
4935 loop
4936 {
4937 if (an >= en-1)
4938 {
4939 if (set[an].length>p.length) return an;
4940 return en;
4941 }
4942 i=(an+en) / 2;
4943 if (set[i].length>p.length) en=i;
4944 else an=i;
4945 }
4946}

◆ posInT_EcartFDegpLength()

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

Definition at line 11358 of file kutil.cc.

11359{
11360
11361 if (length==-1) return 0;
11362
11363 int o = p.ecart;
11364 int op=p.GetpFDeg();
11365 int ol = p.GetpLength();
11366
11367 if (set[length].ecart < o)
11368 return length+1;
11369 if (set[length].ecart == o)
11370 {
11371 int oo=set[length].GetpFDeg();
11372 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11373 return length+1;
11374 }
11375
11376 int i;
11377 int an = 0;
11378 int en= length;
11379 loop
11380 {
11381 if (an >= en-1)
11382 {
11383 if (set[an].ecart > o)
11384 return an;
11385 if (set[an].ecart == o)
11386 {
11387 int oo=set[an].GetpFDeg();
11388 if((oo > op)
11389 || ((oo==op) && (set[an].pLength > ol)))
11390 return an;
11391 }
11392 return en;
11393 }
11394 i=(an+en) / 2;
11395 if (set[i].ecart > o)
11396 en=i;
11397 else if (set[i].ecart == o)
11398 {
11399 int oo=set[i].GetpFDeg();
11400 if ((oo > op)
11401 || ((oo == op) && (set[i].pLength > ol)))
11402 en=i;
11403 else
11404 an=i;
11405 }
11406 else
11407 an=i;
11408 }
11409}

◆ posInT_EcartpLength()

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

Definition at line 5146 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11412 of file kutil.cc.

11413{
11414
11415 if (length==-1) return 0;
11416
11417 int op=p.GetpFDeg();
11418 int ol = p.GetpLength();
11419
11420 int oo=set[length].GetpFDeg();
11421 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11422 return length+1;
11423
11424 int i;
11425 int an = 0;
11426 int en= length;
11427 loop
11428 {
11429 if (an >= en-1)
11430 {
11431 int oo=set[an].GetpFDeg();
11432 if((oo > op)
11433 || ((oo==op) && (set[an].pLength > ol)))
11434 return an;
11435 return en;
11436 }
11437 i=(an+en) / 2;
11438 int oo=set[i].GetpFDeg();
11439 if ((oo > op)
11440 || ((oo == op) && (set[i].pLength > ol)))
11441 en=i;
11442 else
11443 an=i;
11444 }
11445}

◆ posInT_pLength()

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

Definition at line 11449 of file kutil.cc.

11450{
11451 int ol = p.GetpLength();
11452 if (length==-1)
11453 return 0;
11454 if (set[length].length<p.length)
11455 return length+1;
11456
11457 int i;
11458 int an = 0;
11459 int en= length;
11460
11461 loop
11462 {
11463 if (an >= en-1)
11464 {
11465 if (set[an].pLength>ol) return an;
11466 return en;
11467 }
11468 i=(an+en) / 2;
11469 if (set[i].pLength>ol) en=i;
11470 else an=i;
11471 }
11472}

◆ posInTSig()

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

◆ 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 10682 of file kutil.cc.

10683{
10684 if(!nCoeff_is_Z(currRing->cf))
10685 return;
10686 poly pH = h->GetP();
10687 poly p,pp;
10688 p = pH;
10689 bool deleted = FALSE, ok = FALSE;
10690 for(int i = 0; i<=strat->sl; i++)
10691 {
10692 p = pH;
10693 if(pNext(strat->S[i]) == NULL)
10694 {
10695 //pWrite(p);
10696 //pWrite(strat->S[i]);
10697 while(ok == FALSE && p != NULL)
10698 {
10699 if(pLmDivisibleBy(strat->S[i], p)
10700#ifdef HAVE_SHIFTBBA
10701 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
10702#endif
10703 )
10704 {
10705 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10706 p_SetCoeff(p,dummy,currRing);
10707 }
10708 if(nIsZero(p->coef))
10709 {
10710 pLmDelete(&p);
10711 h->p = p;
10712 deleted = TRUE;
10713 }
10714 else
10715 {
10716 ok = TRUE;
10717 }
10718 }
10719 if (p!=NULL)
10720 {
10721 pp = pNext(p);
10722 while(pp != NULL)
10723 {
10724 if(pLmDivisibleBy(strat->S[i], pp)
10725#ifdef HAVE_SHIFTBBA
10726 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
10727#endif
10728 )
10729 {
10730 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10731 p_SetCoeff(pp,dummy,currRing);
10732 if(nIsZero(pp->coef))
10733 {
10734 pLmDelete(&pNext(p));
10735 pp = pNext(p);
10736 deleted = TRUE;
10737 }
10738 else
10739 {
10740 p = pp;
10741 pp = pNext(p);
10742 }
10743 }
10744 else
10745 {
10746 p = pp;
10747 pp = pNext(p);
10748 }
10749 }
10750 }
10751 }
10752 }
10753 h->SetLmCurrRing();
10754 if((deleted)&&(h->p!=NULL))
10755 strat->initEcart(h);
10756}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject * h,
kStrategy strat )

Definition at line 10758 of file kutil.cc.

10759{
10760 if(!nCoeff_is_Z(currRing->cf))
10761 return;
10762 poly hSig = h->sig;
10763 poly pH = h->GetP();
10764 poly p,pp;
10765 p = pH;
10766 bool deleted = FALSE, ok = FALSE;
10767 for(int i = 0; i<=strat->sl; i++)
10768 {
10769 p = pH;
10770 if(pNext(strat->S[i]) == NULL)
10771 {
10772 while(ok == FALSE && p!=NULL)
10773 {
10774 if(pLmDivisibleBy(strat->S[i], p))
10775 {
10776 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10777 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10778 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10779 {
10780 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10781 p_SetCoeff(p,dummy,currRing);
10782 }
10783 pDelete(&sigMult);
10784 }
10785 if(nIsZero(p->coef))
10786 {
10787 pLmDelete(&p);
10788 h->p = p;
10789 deleted = TRUE;
10790 }
10791 else
10792 {
10793 ok = TRUE;
10794 }
10795 }
10796 if(p == NULL)
10797 return;
10798 pp = pNext(p);
10799 while(pp != NULL)
10800 {
10801 if(pLmDivisibleBy(strat->S[i], pp))
10802 {
10803 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10804 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10805 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10806 {
10807 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10808 p_SetCoeff(pp,dummy,currRing);
10809 if(nIsZero(pp->coef))
10810 {
10811 pLmDelete(&pNext(p));
10812 pp = pNext(p);
10813 deleted = TRUE;
10814 }
10815 else
10816 {
10817 p = pp;
10818 pp = pNext(p);
10819 }
10820 }
10821 else
10822 {
10823 p = pp;
10824 pp = pNext(p);
10825 }
10826 pDelete(&sigMult);
10827 }
10828 else
10829 {
10830 p = pp;
10831 pp = pNext(p);
10832 }
10833 }
10834 }
10835 }
10836 h->SetLmCurrRing();
10837 if(deleted)
10838 strat->initEcart(h);
10839
10840}
#define ppMult_mm(p, m)
Definition polys.h:202
#define pDivideM(a, b)
Definition polys.h:295

◆ preIntegerCheck()

poly preIntegerCheck ( ideal F,
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 10518 of file kutil.cc.

10519{
10521 ideal F = idCopy(Forig);
10522 idSkipZeroes(F);
10523 poly pmon;
10524 ring origR = currRing;
10525 ideal monred = idInit(1,1);
10526 for(int i=0; i<idElem(F); i++)
10527 {
10528 if(pNext(F->m[i]) == NULL)
10529 idInsertPoly(monred, pCopy(F->m[i]));
10530 }
10531 int posconst = idPosConstant(F);
10532 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10533 {
10534 idDelete(&F);
10535 idDelete(&monred);
10536 return NULL;
10537 }
10538 int idelemQ = 0;
10539 if(Q!=NULL)
10540 {
10541 idelemQ = IDELEMS(Q);
10542 for(int i=0; i<idelemQ; i++)
10543 {
10544 if(pNext(Q->m[i]) == NULL)
10545 idInsertPoly(monred, pCopy(Q->m[i]));
10546 }
10547 idSkipZeroes(monred);
10548 posconst = idPosConstant(monred);
10549 //the constant, if found, will be from Q
10550 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10551 {
10552 pmon = pCopy(monred->m[posconst]);
10553 idDelete(&F);
10554 idDelete(&monred);
10555 return pmon;
10556 }
10557 }
10558 ring QQ_ring = rCopy0(currRing,FALSE);
10559 nKillChar(QQ_ring->cf);
10560 QQ_ring->cf = nInitChar(n_Q, NULL);
10561 rComplete(QQ_ring,1);
10562 QQ_ring = rAssure_c_dp(QQ_ring);
10563 rChangeCurrRing(QQ_ring);
10564 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10565 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10566 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10567 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10568 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10569 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10570 ideal one = kStd2(II, NULL, isNotHomog, NULL,(bigintmat*)NULL);
10571 idSkipZeroes(one);
10572 if(idIsConstant(one))
10573 {
10574 //one should be <1>
10575 for(int i = IDELEMS(II)-1; i>=0; i--)
10576 if(II->m[i] != NULL)
10577 II->m[i+1] = II->m[i];
10578 II->m[0] = pOne();
10579 ideal syz = idSyzygies(II, isNotHomog, NULL);
10580 poly integer = NULL;
10581 for(int i = IDELEMS(syz)-1;i>=0; i--)
10582 {
10583 if(pGetComp(syz->m[i]) == 1)
10584 {
10585 pSetComp(syz->m[i],0);
10586 if(pIsConstant(pHead(syz->m[i])))
10587 {
10588 integer = pHead(syz->m[i]);
10589 break;
10590 }
10591 }
10592 }
10593 rChangeCurrRing(origR);
10594 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10595 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10596 idDelete(&monred);
10597 idDelete(&F);
10598 id_Delete(&II,QQ_ring);
10599 id_Delete(&one,QQ_ring);
10600 id_Delete(&syz,QQ_ring);
10601 p_Delete(&integer,QQ_ring);
10602 rDelete(QQ_ring);
10603 return pmon;
10604 }
10605 else
10606 {
10607 if(idIs0(monred))
10608 {
10609 poly mindegmon = NULL;
10610 for(int i = 0; i<IDELEMS(one); i++)
10611 {
10612 if(pNext(one->m[i]) == NULL)
10613 {
10614 if(mindegmon == NULL)
10615 mindegmon = pCopy(one->m[i]);
10616 else
10617 {
10618 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10619 mindegmon = pCopy(one->m[i]);
10620 }
10621 }
10622 }
10623 if(mindegmon != NULL)
10624 {
10625 for(int i = IDELEMS(II)-1; i>=0; i--)
10626 if(II->m[i] != NULL)
10627 II->m[i+1] = II->m[i];
10628 II->m[0] = pCopy(mindegmon);
10629 ideal syz = idSyzygies(II, isNotHomog, NULL);
10630 bool found = FALSE;
10631 for(int i = IDELEMS(syz)-1;i>=0; i--)
10632 {
10633 if(pGetComp(syz->m[i]) == 1)
10634 {
10635 pSetComp(syz->m[i],0);
10636 if(pIsConstant(pHead(syz->m[i])))
10637 {
10638 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10639 found = TRUE;
10640 break;
10641 }
10642 }
10643 }
10644 id_Delete(&syz,QQ_ring);
10645 if (found == FALSE)
10646 {
10647 rChangeCurrRing(origR);
10648 idDelete(&monred);
10649 idDelete(&F);
10650 id_Delete(&II,QQ_ring);
10651 id_Delete(&one,QQ_ring);
10652 rDelete(QQ_ring);
10653 return NULL;
10654 }
10655 rChangeCurrRing(origR);
10656 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10657 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10658 idDelete(&monred);
10659 idDelete(&F);
10660 id_Delete(&II,QQ_ring);
10661 id_Delete(&one,QQ_ring);
10662 id_Delete(&syz,QQ_ring);
10663 rDelete(QQ_ring);
10664 return pmon;
10665 }
10666 }
10667 }
10668 rChangeCurrRing(origR);
10669 idDelete(&monred);
10670 idDelete(&F);
10671 id_Delete(&II,QQ_ring);
10672 id_Delete(&one,QQ_ring);
10673 rDelete(QQ_ring);
10674 return NULL;
10675}
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:703
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
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:563
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:834
#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
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:2607
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:3527
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:1427
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

◆ 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:384
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:464
#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
#define RED_CANONICALIZE
Definition kutil.h:37

◆ redFirstShift()

int redFirstShift ( LObject * h,
kStrategy strat )

Definition at line 4951 of file kstd2.cc.

4952{
4953 if (h->IsNull()) return 0;
4954
4955 int at, reddeg,d;
4956 int pass = 0;
4957 int j = 0;
4958
4959 if (! strat->homog)
4960 {
4961 d = h->GetpFDeg() + h->ecart;
4962 reddeg = strat->LazyDegree+d;
4963 }
4964 h->SetShortExpVector();
4965 loop
4966 {
4967 j = kFindDivisibleByInT(strat, h);
4968 if (j < 0)
4969 {
4970 h->SetDegStuffReturnLDeg(strat->LDegLast);
4971 return 1;
4972 }
4973
4975 strat->T[j].pNorm();
4976#ifdef KDEBUG
4977 if (TEST_OPT_DEBUG)
4978 {
4979 PrintS("reduce ");
4980 h->wrp();
4981 PrintS(" with ");
4982 strat->T[j].wrp();
4983 }
4984#endif
4985 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
4986
4987#ifdef KDEBUG
4988 if (TEST_OPT_DEBUG)
4989 {
4990 PrintS("\nto ");
4991 wrp(h->p);
4992 PrintLn();
4993 }
4994#endif
4995 if (h->IsNull())
4996 {
4997 kDeleteLcm(h);
4998 h->Clear();
4999 return 0;
5000 }
5001 h->SetShortExpVector();
5002
5003#if 0
5004 if ((strat->syzComp!=0) && !strat->honey)
5005 {
5006 if ((strat->syzComp>0) &&
5007 (h->Comp() > strat->syzComp))
5008 {
5009 assume(h->MinComp() > strat->syzComp);
5010#ifdef KDEBUG
5011 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
5012#endif
5013 if (strat->homog)
5014 h->SetDegStuffReturnLDeg(strat->LDegLast);
5015 return -2;
5016 }
5017 }
5018#endif
5019 if (!strat->homog)
5020 {
5021 if (!TEST_OPT_OLDSTD && strat->honey)
5022 {
5023 h->SetpFDeg();
5024 if (strat->T[j].ecart <= h->ecart)
5025 h->ecart = d - h->GetpFDeg();
5026 else
5027 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
5028
5029 d = h->GetpFDeg() + h->ecart;
5030 }
5031 else
5032 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
5033 /*- try to reduce the s-polynomial -*/
5034 pass++;
5035 /*
5036 *test whether the polynomial should go to the lazyset L
5037 *-if the degree jumps
5038 *-if the number of pre-defined reductions jumps
5039 */
5040 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
5041 && ((d >= reddeg) || (pass > strat->LazyPass)))
5042 {
5043 h->SetLmCurrRing();
5044 if (strat->posInLDependsOnLength)
5045 h->SetLength(strat->length_pLength);
5046 at = strat->posInL(strat->L,strat->Ll,h,strat);
5047 if (at <= strat->Ll)
5048 {
5049 //int dummy=strat->sl;
5050 /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
5051 //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
5052 if (kFindDivisibleByInT(strat, h) < 0)
5053 return 1;
5054 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
5055#ifdef KDEBUG
5056 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
5057#endif
5058 h->Clear();
5059 return -1;
5060 }
5061 }
5062 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
5063 {
5064 reddeg = d+1;
5065 Print(".%d",d);mflush();
5066 }
5067 }
5068 }
5069}

◆ redHomog()

int redHomog ( LObject * h,
kStrategy strat )

Definition at line 1150 of file kstd2.cc.

1151{
1152 if (strat->tl<0) return 1;
1153 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1154 assume(h->FDeg == h->pFDeg());
1155
1156 poly h_p;
1157 int i,j,at,pass,cnt,ii;
1158 // long reddeg,d;
1159 int li;
1160 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1161
1162 pass = j = 0;
1163 cnt = RED_CANONICALIZE;
1164 h->SetShortExpVector();
1165 h_p = h->GetLmTailRing();
1166 h->PrepareRed(strat->use_buckets);
1167 loop
1168 {
1169 j = kFindDivisibleByInT(strat, h);
1170 if (j < 0) return 1;
1171
1172 li = strat->T[j].pLength;
1173 ii = j;
1174 /*
1175 * the polynomial to reduce with (up to the moment) is;
1176 * pi with length li
1177 */
1178 i = j;
1179#if 1
1180 if (test_opt_length)
1181 {
1182 if (li<=0) li=strat->T[j].GetpLength();
1183 if (li>2)
1184 {
1185 unsigned long not_sev = ~ h->sev;
1186 loop
1187 {
1188 /*- search the shortest possible with respect to length -*/
1189 i++;
1190 if (i > strat->tl)
1191 break;
1192 if ((strat->T[i].pLength < li)
1193 &&
1194 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1195 h_p, not_sev, strat->tailRing))
1196 {
1197 /*
1198 * the polynomial to reduce with is now;
1199 */
1200 li = strat->T[i].pLength;
1201 if (li<=0) li=strat->T[i].GetpLength();
1202 ii = i;
1203 if (li<3) break;
1204 }
1205 }
1206 }
1207 }
1208#endif
1209
1210 /*
1211 * end of search: have to reduce with pi
1212 */
1213#ifdef KDEBUG
1214 if (TEST_OPT_DEBUG)
1215 {
1216 PrintS("red:");
1217 h->wrp();
1218 PrintS(" with ");
1219 strat->T[ii].wrp();
1220 }
1221#endif
1222 assume(strat->fromT == FALSE);
1223
1224 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1225#if SBA_PRINT_REDUCTION_STEPS
1226 sba_interreduction_steps++;
1227#endif
1228#if SBA_PRINT_OPERATIONS
1229 sba_interreduction_operations += pLength(strat->T[ii].p);
1230#endif
1231
1232#ifdef KDEBUG
1233 if (TEST_OPT_DEBUG)
1234 {
1235 PrintS("\nto ");
1236 h->wrp();
1237 PrintLn();
1238 }
1239#endif
1240
1241 h_p = h->GetLmTailRing();
1242 if (h_p == NULL)
1243 {
1244 kDeleteLcm(h);
1245 return 0;
1246 }
1248 {
1249 if (h->p!=NULL)
1250 {
1251 if(p_GetComp(h->p,currRing)>strat->syzComp)
1252 {
1253 h->Delete();
1254 return 0;
1255 }
1256 }
1257 else //if (h->t_p!=NULL)
1258 {
1259 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1260 {
1261 h->Delete();
1262 return 0;
1263 }
1264 }
1265 }
1266 #if 0
1267 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1268 {
1269 if (h->p!=NULL)
1270 {
1271 if(p_GetComp(h->p,currRing)>strat->syzComp)
1272 {
1273 return 1;
1274 }
1275 }
1276 else // if (h->t_p!=NULL)
1277 {
1278 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1279 {
1280 return 1;
1281 }
1282 }
1283 }
1284 #endif
1285 h->SetShortExpVector();
1286 /*
1287 * try to reduce the s-polynomial h
1288 *test first whether h should go to the lazyset L
1289 *-if the degree jumps
1290 *-if the number of pre-defined reductions jumps
1291 */
1292 cnt--;
1293 pass++;
1294 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1295 {
1296 h->SetLmCurrRing();
1297 at = strat->posInL(strat->L,strat->Ll,h,strat);
1298 if (at <= strat->Ll)
1299 {
1300#ifdef HAVE_SHIFTBBA
1301 if (rIsLPRing(currRing))
1302 {
1303 if (kFindDivisibleByInT(strat, h) < 0)
1304 return 1;
1305 }
1306 else
1307#endif
1308 {
1309 int dummy=strat->sl;
1310 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1311 return 1;
1312 }
1313 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1314#ifdef KDEBUG
1315 if (TEST_OPT_DEBUG)
1316 Print(" lazy: -> L%d\n",at);
1317#endif
1318 h->Clear();
1319 return -1;
1320 }
1321 }
1322 else if (UNLIKELY(cnt==0))
1323 {
1324 h->CanonicalizeP();
1325 cnt=RED_CANONICALIZE;
1326 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
1327 }
1328 }
1329}

◆ redHoney()

int redHoney ( LObject * h,
kStrategy strat )

Definition at line 2110 of file kstd2.cc.

2111{
2112 if (strat->tl<0) return 1;
2113 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
2114 assume(h->FDeg == h->pFDeg());
2115 int j,at,pass,ei, ii, h_d;
2116 long reddeg,d;
2117
2118 pass = j = 0;
2119 d = reddeg = h->GetpFDeg() + h->ecart;
2120 h->SetShortExpVector();
2121
2122 h->PrepareRed(strat->use_buckets);
2123 loop
2124 {
2125 j=kFindDivisibleByInT_ecart(strat, h, h->ecart);
2126 if (j < 0) return 1;
2127
2128 ii = j;
2129 ei = strat->T[ii].ecart;
2130 /*
2131 * the polynomial to reduce with (up to the moment) is;
2132 * pi with ecart ei (T[ii])
2133 */
2134
2135 /*
2136 * end of search: have to reduce with pi
2137 */
2138 if (UNLIKELY(!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart)))
2139 {
2140 h->GetTP(); // clears bucket
2141 h->SetLmCurrRing();
2142 /*
2143 * It is not possible to reduce h with smaller ecart;
2144 * if possible h goes to the lazy-set L,i.e
2145 * if its position in L would be not the last one
2146 */
2147 if (strat->Ll >= 0) /* L is not empty */
2148 {
2149 at = strat->posInL(strat->L,strat->Ll,h,strat);
2150 if(at <= strat->Ll)
2151 /*- h will not become the next element to reduce -*/
2152 {
2153 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2154#ifdef KDEBUG
2155 if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
2156#endif
2157 h->Clear();
2158 return -1;
2159 }
2160 }
2161 }
2162#ifdef KDEBUG
2163 if (TEST_OPT_DEBUG)
2164 {
2165 PrintS("red:");
2166 h->wrp();
2167 Print("\nwith T[%d]:",ii);
2168 strat->T[ii].wrp();
2169 }
2170#endif
2171 assume(strat->fromT == FALSE);
2172
2173 ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,NULL, strat);
2174#if SBA_PRINT_REDUCTION_STEPS
2175 sba_interreduction_steps++;
2176#endif
2177#if SBA_PRINT_OPERATIONS
2178 sba_interreduction_operations += strat->T[ii].pLength;
2179#endif
2180#ifdef KDEBUG
2181 if (TEST_OPT_DEBUG)
2182 {
2183 PrintS("\nto:");
2184 h->wrp();
2185 PrintLn();
2186 }
2187#endif
2188 if(h->IsNull())
2189 {
2190 kDeleteLcm(h);
2191 h->Clear();
2192 return 0;
2193 }
2195 {
2196 if (h->p!=NULL)
2197 {
2198 if(p_GetComp(h->p,currRing)>strat->syzComp)
2199 {
2200 h->Delete();
2201 return 0;
2202 }
2203 }
2204 else //if (h->t_p!=NULL)
2205 {
2206 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2207 {
2208 h->Delete();
2209 return 0;
2210 }
2211 }
2212 }
2213 else
2214 if (UNLIKELY((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ)))
2215 {
2216 if (h->p!=NULL)
2217 {
2218 if(p_GetComp(h->p,currRing)>strat->syzComp)
2219 {
2220 return 1;
2221 }
2222 }
2223 else // if (h->t_p!=NULL)
2224 {
2225 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2226 {
2227 return 1;
2228 }
2229 }
2230 }
2231 h->SetShortExpVector();
2232 h_d = h->SetpFDeg();
2233 /* compute the ecart */
2234 if (ei <= h->ecart)
2235 h->ecart = d-h_d;
2236 else
2237 h->ecart = d-h_d+ei-h->ecart;
2238
2239 /*
2240 * try to reduce the s-polynomial h
2241 *test first whether h should go to the lazyset L
2242 *-if the degree jumps
2243 *-if the number of pre-defined reductions jumps
2244 */
2245 pass++;
2246 d = h_d + h->ecart;
2248 && (strat->Ll >= 0)
2249 && ((d > reddeg) || (pass > strat->LazyPass))))
2250 {
2251 h->GetTP(); // clear bucket
2252 h->SetLmCurrRing();
2253 at = strat->posInL(strat->L,strat->Ll,h,strat);
2254 if (at <= strat->Ll)
2255 {
2256#ifdef HAVE_SHIFTBBA
2257 if (rIsLPRing(currRing))
2258 {
2259 if (kFindDivisibleByInT(strat, h) < 0)
2260 return 1;
2261 }
2262 else
2263#endif
2264 {
2265 int dummy=strat->sl;
2266 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2267 return 1;
2268 }
2269 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2270#ifdef KDEBUG
2271 if (TEST_OPT_DEBUG)
2272 Print(" degree jumped: -> L%d\n",at);
2273#endif
2274 h->Clear();
2275 return -1;
2276 }
2277 }
2278 else if (d > reddeg)
2279 {
2280 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
2281 {
2282 if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask)
2283 {
2284 strat->overflow=TRUE;
2285 //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2286 h->GetP();
2287 at = strat->posInL(strat->L,strat->Ll,h,strat);
2288 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2289 h->Clear();
2290 return -1;
2291 }
2292 }
2293 else if (UNLIKELY(TEST_OPT_PROT && (strat->Ll < 0) ))
2294 {
2295 //h->wrp(); Print("<%d>\n",h->GetpLength());
2296 reddeg = d;
2297 Print(".%ld",d); mflush();
2298 }
2299 }
2300 }
2301}
int kFindDivisibleByInT_ecart(const kStrategy strat, const LObject *L, const int ecart)
Definition kstd2.cc:416

◆ redHoneyM()

int redHoneyM ( LObject * h,
kStrategy strat )

◆ redLazy()

int redLazy ( LObject * h,
kStrategy strat )

TEST_OPT_REDTHROUGH &&

Definition at line 1905 of file kstd2.cc.

1906{
1907 if (strat->tl<0) return 1;
1908 int at,i,ii,li;
1909 int j = 0;
1910 int pass = 0;
1911 int cnt = RED_CANONICALIZE;
1912 assume(h->pFDeg() == h->FDeg);
1913 long reddeg = h->GetpFDeg();
1914 long d;
1915 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1916
1917 h->SetShortExpVector();
1918 poly h_p = h->GetLmTailRing();
1919 h->PrepareRed(strat->use_buckets);
1920 loop
1921 {
1922 j = kFindDivisibleByInT(strat, h);
1923 if (j < 0) return 1;
1924
1925 li = strat->T[j].pLength;
1926 ii = j;
1927 /*
1928 * the polynomial to reduce with (up to the moment) is;
1929 * pi with length li
1930 */
1931
1932 i = j;
1933#if 1
1934 if (test_opt_length)
1935 {
1936 if (li<=0) li=strat->T[j].GetpLength();
1937 if(li>2)
1938 {
1939 unsigned long not_sev = ~ h->sev;
1940 loop
1941 {
1942 /*- search the shortest possible with respect to length -*/
1943 i++;
1944 if (i > strat->tl)
1945 break;
1946 if ((strat->T[i].pLength < li)
1947 &&
1948 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1949 h_p, not_sev, strat->tailRing))
1950 {
1951 /*
1952 * the polynomial to reduce with is now;
1953 */
1954 li = strat->T[i].pLength;
1955 if (li<=0) li=strat->T[i].GetpLength();
1956 ii = i;
1957 if (li<3) break;
1958 }
1959 }
1960 }
1961 }
1962#endif
1963
1964 /*
1965 * end of search: have to reduce with pi
1966 */
1967
1968
1969#ifdef KDEBUG
1970 if (TEST_OPT_DEBUG)
1971 {
1972 PrintS("red:");
1973 h->wrp();
1974 PrintS(" with ");
1975 strat->T[ii].wrp();
1976 }
1977#endif
1978
1979 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1980#if SBA_PRINT_REDUCTION_STEPS
1981 sba_interreduction_steps++;
1982#endif
1983#if SBA_PRINT_OPERATIONS
1984 sba_interreduction_operations += pLength(strat->T[ii].p);
1985#endif
1986
1987#ifdef KDEBUG
1988 if (TEST_OPT_DEBUG)
1989 {
1990 PrintS("\nto ");
1991 h->wrp();
1992 PrintLn();
1993 }
1994#endif
1995
1996 h_p=h->GetLmTailRing();
1997
1998 if (h_p == NULL)
1999 {
2000 kDeleteLcm(h);
2001 return 0;
2002 }
2004 {
2005 if (h->p!=NULL)
2006 {
2007 if(p_GetComp(h->p,currRing)>strat->syzComp)
2008 {
2009 h->Delete();
2010 return 0;
2011 }
2012 }
2013 else //if (h->t_p!=NULL)
2014 {
2015 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2016 {
2017 h->Delete();
2018 return 0;
2019 }
2020 }
2021 }
2022 #if 0
2023 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
2024 {
2025 if (h->p!=NULL)
2026 {
2027 if(p_GetComp(h->p,currRing)>strat->syzComp)
2028 {
2029 return 1;
2030 }
2031 }
2032 else // if (h->t_p!=NULL)
2033 {
2034 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2035 {
2036 return 1;
2037 }
2038 }
2039 }
2040 #endif
2041 h->SetShortExpVector();
2042 d = h->SetpFDeg();
2043 /*- try to reduce the s-polynomial -*/
2044 cnt--;
2045 pass++;
2046 if (//!TEST_OPT_REDTHROUGH &&
2047 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
2048 {
2049 h->SetLmCurrRing();
2050 at = strat->posInL(strat->L,strat->Ll,h,strat);
2051 if (at <= strat->Ll)
2052 {
2053#if 1
2054#ifdef HAVE_SHIFTBBA
2055 if (rIsLPRing(currRing))
2056 {
2057 if (kFindDivisibleByInT(strat, h) < 0)
2058 return 1;
2059 }
2060 else
2061#endif
2062 {
2063 int dummy=strat->sl;
2064 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2065 return 1;
2066 }
2067#endif
2068#ifdef KDEBUG
2069 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
2070#endif
2071 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2072 h->Clear();
2073 return -1;
2074 }
2075 }
2076 else if (d != reddeg)
2077 {
2078 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
2079 {
2080 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
2081 {
2082 strat->overflow=TRUE;
2083 //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2084 h->GetP();
2085 at = strat->posInL(strat->L,strat->Ll,h,strat);
2086 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2087 h->Clear();
2088 return -1;
2089 }
2090 }
2091 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
2092 {
2093 Print(".%ld",d);mflush();
2094 reddeg = d;
2095 }
2096 }
2097 else if (UNLIKELY(cnt==0))
2098 {
2099 h->CanonicalizeP();
2100 cnt=RED_CANONICALIZE;
2101 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
2102 }
2103 }
2104}

◆ redLiftstd()

int redLiftstd ( LObject * h,
kStrategy strat )

Definition at line 167 of file kLiftstd.cc.

168{
169 if (strat->tl<0) return 1;
170 assume(h->FDeg == h->pFDeg());
172 poly h_p;
173 int i,j,pass,ei, ii, h_d,ci;
174 unsigned long not_sev;
175 long reddeg,d;
176 #define START_REDUCE 512
177 int red_size=START_REDUCE;
178 number *A=(number*)omAlloc0(red_size*sizeof(number));
179 poly *C=(poly*)omAlloc0(red_size*sizeof(poly));
180 poly *T=(poly*)omAlloc0(red_size*sizeof(poly));
181 const ring tailRing=strat->tailRing;
182
183 pass = j = 0;
184 d = reddeg = h->GetpFDeg() + h->ecart;
185 h->SetShortExpVector();
186 int li;
187 h_p = h->GetLmTailRing();
188 not_sev = ~ h->sev;
189
190 // split h into main part (h) and tail (h_tail)
191 poly h_tail=kSplitAt(strat->syzComp,h,strat);
192 // fix h-pLength
193 h->pLength=0;
194 h->PrepareRed(strat->use_buckets);
195 loop
196 {
197 j=kFindDivisibleByInT(strat, h);
198 if (j < 0)
199 {
200 // lazy computation:
201 int l;
202 poly p=lazyComp(A,C,T,pass,h_tail,&l,strat->tailRing);
203 kBucket_Add_q(h->bucket,p,&l);
204 omFreeSize(A,red_size*sizeof(number));
205 omFreeSize(T,red_size*sizeof(poly));
206 omFreeSize(C,red_size*sizeof(poly));
207 return 1;
208 }
209
210 ei = strat->T[j].ecart;
211 li = strat->T[j].pLength;
212 ci = nSize(pGetCoeff(strat->T[j].p));
213 ii = j;
214 /*
215 * the polynomial to reduce with (up to the moment) is;
216 * pi with ecart ei (T[ii])
217 */
218 i = j;
219 if (TEST_OPT_LENGTH)
220 {
221 if (li<=0) li=strat->T[j].GetpLength();
222 if (li>1)
223 loop
224 {
225 /*- possible with respect to ecart, minimal nSize -*/
226 i++;
227 if (i > strat->tl)
228 break;
229 //if (ei < h->ecart)
230 // break;
231 if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
232 || ((strat->T[i].ecart <= h->ecart)
233 && (strat->T[i].pLength <= li)
234 && (nSize(pGetCoeff(strat->T[i].p)) <ci)))
235 &&
236 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
237 h_p, not_sev, tailRing))
238 {
239 /*
240 * the polynomial to reduce with is now;
241 */
242 ei = strat->T[i].ecart;
243 li = strat->T[i].pLength;
244 if (li<=0) li=strat->T[i].GetpLength();
245 ii = i;
246 if (li==1) break;
247 }
248 }
249 }
250
251 /*
252 * end of search: have to reduce with pi
253 */
254#ifdef KDEBUG
255 if (TEST_OPT_DEBUG)
256 {
257 PrintS("red:");
258 h->wrp();
259 Print("\nwith T[%d]:",ii);
260 strat->T[ii].wrp();
261 }
262#endif
263 assume(strat->fromT == FALSE);
264
265 //strat->T[ii].pCleardenom();
266 // split T[ii]:
267 // remember pLength of strat->T[ii]
268 int l_orig=strat->T[ii].pLength;
269 // split strat->T[ii]
270 poly T_tail=kSplitAt(strat->syzComp,&strat->T[ii],strat);
271 h->pLength=0; // force re-computation of length
272 ksReducePoly(h,&(strat->T[ii]),NULL,&A[pass],&C[pass], strat);
273 // restore T[ii]:
274 kAppend(T_tail,&strat->T[ii]);
275 strat->T[ii].pLength=l_orig;
276 // store T_tail
277 T[pass]=T_tail;
278 // delayed computation: A[pass]*tail-M[pass]*T[pass]
279#ifdef KDEBUG
280 if (TEST_OPT_DEBUG)
281 {
282 PrintS("\nto:");
283 h->wrp();
284 PrintLn();
285 }
286#endif
287 if(h->IsNull())
288 {
289 // clean up A,C,h_tail:
290 for(int i=0;i<=pass;i++)
291 {
292 n_Delete(&A[i],tailRing->cf);
293 p_Delete(&C[i],tailRing);
294 }
295 p_Delete(&h_tail,tailRing);
296 kDeleteLcm(h);
297 h->Clear();
298 omFreeSize(A,red_size*sizeof(number));
299 omFreeSize(T,red_size*sizeof(poly));
300 omFreeSize(C,red_size*sizeof(poly));
301 return 0;
302 }
303 h->SetShortExpVector();
304 not_sev = ~ h->sev;
305 h_d = h->SetpFDeg();
306 /* compute the ecart */
307 if (ei <= h->ecart)
308 h->ecart = d-h_d;
309 else
310 h->ecart = d-h_d+ei-h->ecart;
311
312 /*
313 * try to reduce the s-polynomial h
314 *test first whether h should go to the lazyset L
315 *-if the degree jumps
316 *-if the number of pre-defined reductions jumps
317 */
318 pass++;
319 d = h_d + h->ecart;
320 if (pass%RED_CANONICALIZE==0) kBucketCanonicalize(h->bucket);
321 // if cache is to small, double its size:
322 if (pass>=red_size-1)
323 {
324 A=(number*)omRealloc0Size(A,red_size*sizeof(number),2*red_size*sizeof(number));
325 C=(poly*)omRealloc0Size(C,red_size*sizeof(poly),2*red_size*sizeof(poly));
326 T=(poly*)omRealloc0Size(T,red_size*sizeof(poly),2*red_size*sizeof(poly));
327 if(TEST_OPT_PROT) {Print("+%d+",red_size);mflush();}
328 red_size*=2;
329 }
330 }
331}
static poly lazyComp(number *A, poly *M, poly *T, int index, poly s, int *l, const ring tailR)
Definition kLiftstd.cc:132
static void kAppend(poly t, TObject *h)
Definition kLiftstd.cc:121
#define START_REDUCE
static poly kSplitAt(int k, TObject *h, kStrategy strat)
Definition kLiftstd.cc:28
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition kbuckets.cc:660
int kBucketCanonicalize(kBucket_pt bucket)
Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in one bucket: Returns number of bu...
#define nSize(n)
Definition numbers.h:39

◆ redNF()

poly redNF ( poly h,
int & max_ind,
int nonorm,
kStrategy strat )

Definition at line 2307 of file kstd2.cc.

2308{
2309 if (h==NULL) return NULL;
2310 int j,j_ring;
2311 int cnt=REDNF_CANONICALIZE;
2312 max_ind=strat->sl;
2313
2314 if (0 > strat->sl)
2315 {
2316 return h;
2317 }
2318 LObject P(h);
2319 P.SetShortExpVector();
2320 P.t_p=NULL;
2321 BOOLEAN is_ring = rField_is_Ring(currRing);
2322 if(is_ring) nonorm=TRUE;
2323#ifdef KDEBUG
2324// if (TEST_OPT_DEBUG)
2325// {
2326// PrintS("redNF: starting S:\n");
2327// for( j = 0; j <= max_ind; j++ )
2328// {
2329// Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2330// pWrite(strat->S[j]);
2331// }
2332// };
2333#endif
2334 if (rField_is_Z(currRing))
2335 {
2336 redRing_Z_S(&P,strat);
2337 if (P.bucket!=NULL)
2338 {
2339 P.p=kBucketClear(P.bucket);
2340 kBucketDestroy(&P.bucket);
2341 }
2342 return P.p;
2343 }
2344 else if (rField_is_Ring(currRing))
2345 {
2346 redRing_S(&P,strat);
2347 if (P.bucket!=NULL)
2348 {
2349 P.p=kBucketClear(P.bucket);
2350 kBucketDestroy(&P.bucket);
2351 }
2352 return P.p;
2353 }
2354
2355 P.bucket = kBucketCreate(currRing);
2356 kBucketInit(P.bucket,P.p,pLength(P.p));
2357 kbTest(P.bucket);
2358 P.p=kBucketGetLm(P.bucket);
2359 loop
2360 {
2361 j_ring=j=kFindDivisibleByInS_noCF(strat,&max_ind,&P);
2362 while ((j>=0)
2363 && (nonorm)
2364 && (!n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[j]),currRing->cf)))
2365 j=kFindNextDivisibleByInS(strat,j+1,max_ind,&P);
2366 if (j>=0)
2367 {
2368 int sl=pSize(strat->S[j]);
2369 int jj=j;
2370 loop
2371 {
2372 int sll;
2373 jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
2374 if (jj<0) break;
2375 if ((!nonorm)
2376 || (n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[jj]),currRing->cf)))
2377 {
2378 sll=pSize(strat->S[jj]);
2379 if (sll<sl)
2380 {
2381 #ifdef KDEBUG
2382 if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2383 #endif
2384 //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2385 j=jj;
2386 sl=sll;
2387 }
2388 }
2389 }
2390 if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2391 {
2392 pNorm(strat->S[j]);
2393 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2394 }
2395 nNormalize(pGetCoeff(P.p));
2396#ifdef KDEBUG
2397 if (TEST_OPT_DEBUG)
2398 {
2399 PrintS("red:");
2400 wrp(P.p);
2401 PrintS(" with ");
2402 wrp(strat->S[j]);
2403 }
2404#endif
2405#ifdef HAVE_PLURAL
2407 {
2408 number coef;
2409 nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
2410 nDelete(&coef);
2411 }
2412 else
2413#endif
2414 {
2415 kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),
2416 strat->kNoether);
2417 }
2418 cnt--;
2419 if (cnt==0)
2420 {
2421 kBucketCanonicalize(P.bucket);
2423 }
2424 P.p=kBucketGetLm(P.bucket);
2425 //P.t_p=NULL;
2426#ifdef KDEBUG
2427 if (TEST_OPT_DEBUG)
2428 {
2429 PrintS("\nto:");
2430 wrp(P.p);
2431 PrintLn();
2432 }
2433#endif
2434 if (P.p==NULL)
2435 {
2436 kBucketDestroy(&P.bucket);
2437 return NULL;
2438 }
2439 kbTest(P.bucket);
2440 P.SetShortExpVector();
2441 }
2442 else if (is_ring && (j_ring>=0) && (currRing->cf->cfQuotRem!=ndQuotRem))
2443 {
2444 number r;
2445 number n=n_QuotRem(pGetCoeff(P.p),pGetCoeff(strat->S[j_ring]),&r,currRing->cf);
2446 if(!n_IsZero(n,currRing->cf))
2447 {
2448 poly lm=kBucketGetLm(P.bucket);
2449 poly m=p_Head(lm,currRing);
2450 p_ExpVectorSub(m,strat->S[j_ring],currRing);
2451 if (p_GetComp(strat->S[j_ring], currRing) != p_GetComp(lm, currRing))
2452 {
2454 }
2456 p_Setm(m,currRing);
2457#ifdef KDEBUG
2458 if (TEST_OPT_DEBUG)
2459 {
2460 PrintS("redi (coeff):");
2461 wrp(P.p);
2462 PrintS(" with ");
2463 wrp(strat->S[j]);
2464 }
2465#endif
2466 int l=-1;
2467 kBucket_Minus_m_Mult_p(P.bucket,m,strat->S[j_ring],&l);
2468 P.p=kBucketGetLm(P.bucket);
2470#ifdef KDEBUG
2471 if (TEST_OPT_DEBUG)
2472 {
2473 PrintS("\nto:");
2474 wrp(P.p);
2475 PrintLn();
2476 }
2477#endif
2478 }
2479 else
2480 {
2481 n_Delete(&n,currRing->cf);
2482 }
2483 n_Delete(&r,currRing->cf);
2484 P.p=kBucketClear(P.bucket);
2485 kBucketDestroy(&P.bucket);
2486 pNormalize(P.p);
2487 return P.p;
2488 }
2489 else
2490 {
2491 P.p=kBucketClear(P.bucket);
2492 kBucketDestroy(&P.bucket);
2493 pNormalize(P.p);
2494 return P.p;
2495 }
2496 }
2497}
int m
Definition cfEzgcd.cc:128
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition kbuckets.cc:521
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *l...
Definition kbuckets.cc:722
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition kbuckets.cc:493
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition kbuckets.cc:209
void kBucketPolyRedNF(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition kbuckets.cc:1188
const poly kBucketGetLm(kBucket_pt bucket)
Definition kbuckets.cc:506
int kFindNextDivisibleByInS(const kStrategy strat, int start, int max_ind, LObject *L)
Definition kstd2.cc:567
int kFindDivisibleByInS_noCF(const kStrategy strat, int *max_ind, LObject *L)
Definition kstd2.cc:527
static int redRing_S(LObject *h, kStrategy strat)
Definition kstd2.cc:1090
static int redRing_Z_S(LObject *h, kStrategy strat)
Definition kstd2.cc:878
#define REDNF_CANONICALIZE
Definition kutil.h:38
static void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition nc.h:275
#define nNormalize(n)
Definition numbers.h:30
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
#define pNormalize(p)
Definition polys.h:318
#define pSize(p)
Definition polys.h:319

◆ redNF0()

int redNF0 ( LObject * P,
kStrategy strat )

◆ redNFTail()

poly redNFTail ( poly h,
const int sl,
kStrategy strat )

◆ redRiloc()

int redRiloc ( LObject * h,
kStrategy strat )

Definition at line 385 of file kstd1.cc.

386{
387 int i,at,ei,li,ii;
388 int j = 0;
389 int pass = 0;
390 long d,reddeg;
391
392 d = h->GetpFDeg()+ h->ecart;
393 reddeg = strat->LazyDegree+d;
394 h->SetShortExpVector();
395 loop
396 {
397 j = kFindDivisibleByInT(strat, h);
398 if (j < 0)
399 {
400 // over ZZ: cleanup coefficients by complete reduction with monomials
401 postReduceByMon(h, strat);
402 if(h->p == NULL)
403 {
404 kDeleteLcm(h);
405 h->Clear();
406 return 0;
407 }
408 if (strat->honey) h->SetLength(strat->length_pLength);
409 if(strat->tl >= 0)
410 h->i_r1 = strat->tl;
411 else
412 h->i_r1 = -1;
413 if (h->GetLmTailRing() == NULL)
414 {
415 kDeleteLcm(h);
416 h->Clear();
417 return 0;
418 }
419 return 1;
420 }
421
422 ei = strat->T[j].ecart;
423 ii = j;
424 if (ei > h->ecart && ii < strat->tl)
425 {
426 li = strat->T[j].length;
427 // the polynomial to reduce with (up to the moment) is;
428 // pi with ecart ei and length li
429 // look for one with smaller ecart
430 i = j;
431 loop
432 {
433 /*- takes the first possible with respect to ecart -*/
434 i++;
435#if 1
436 if (i > strat->tl) break;
437 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
438 strat->T[i].length < li))
439 &&
440 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)
441 &&
442 n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf))
443#else
444 j = kFindDivisibleByInT(strat, h, i);
445 if (j < 0) break;
446 i = j;
447 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
448 strat->T[i].length < li))
449#endif
450 {
451 // the polynomial to reduce with is now
452 ii = i;
453 ei = strat->T[i].ecart;
454 if (ei <= h->ecart) break;
455 li = strat->T[i].length;
456 }
457 }
458 }
459
460 // end of search: have to reduce with pi
461 if (ei > h->ecart)
462 {
463 // It is not possible to reduce h with smaller ecart;
464 // if possible h goes to the lazy-set L,i.e
465 // if its position in L would be not the last one
466 strat->fromT = TRUE;
467 if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
468 {
469 h->SetLmCurrRing();
470 if (strat->honey && strat->posInLDependsOnLength)
471 h->SetLength(strat->length_pLength);
472 assume(h->FDeg == h->pFDeg());
473 at = strat->posInL(strat->L,strat->Ll,h,strat);
474 if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef))
475 {
476 /*- h will not become the next element to reduce -*/
477 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
478 #ifdef KDEBUG
479 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
480 #endif
481 h->Clear();
482 strat->fromT = FALSE;
483 return -1;
484 }
485 }
486 doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE);
487 }
488 else
489 {
490 // now we finally can reduce
491 doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
492 }
493 strat->fromT=FALSE;
494 // are we done ???
495 if (h->IsNull())
496 {
497 kDeleteLcm(h);
498 h->Clear();
499 return 0;
500 }
501
502 // NO!
503 h->SetShortExpVector();
504 h->SetpFDeg();
505 if (strat->honey)
506 {
507 if (ei <= h->ecart)
508 h->ecart = d-h->GetpFDeg();
509 else
510 h->ecart = d-h->GetpFDeg()+ei-h->ecart;
511 }
512 else
513 // this has the side effect of setting h->length
514 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
515 /*- try to reduce the s-polynomial -*/
516 pass++;
517 d = h->GetpFDeg()+h->ecart;
518 /*
519 *test whether the polynomial should go to the lazyset L
520 *-if the degree jumps
521 *-if the number of pre-defined reductions jumps
522 */
523 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
524 && ((d >= reddeg) || (pass > strat->LazyPass)))
525 {
526 h->SetLmCurrRing();
527 if (strat->honey && strat->posInLDependsOnLength)
528 h->SetLength(strat->length_pLength);
529 assume(h->FDeg == h->pFDeg());
530 at = strat->posInL(strat->L,strat->Ll,h,strat);
531 if (at <= strat->Ll)
532 {
533 int dummy=strat->sl;
534 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
535 {
536 if (strat->honey && !strat->posInLDependsOnLength)
537 h->SetLength(strat->length_pLength);
538 return 1;
539 }
540 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
541#ifdef KDEBUG
542 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
543#endif
544 h->Clear();
545 return -1;
546 }
547 }
548 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
549 {
550 Print(".%ld",d);mflush();
551 reddeg = d+1;
552 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
553 {
554 strat->overflow=TRUE;
555 //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
556 h->GetP();
557 at = strat->posInL(strat->L,strat->Ll,h,strat);
558 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
559 h->Clear();
560 return -1;
561 }
562 }
563 }
564}
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
Definition kutil.cc:10682

◆ redRing()

int redRing ( LObject * h,
kStrategy strat )

Definition at line 988 of file kstd2.cc.

989{
990 if (strat->tl<0) return 1;
991 if (h->IsNull()) return 0; // spoly is zero (can only occur with zero divisors)
992
993 int at/*,i*/;
994 long d;
995 int j = 0;
996 int pass = 0;
997 // poly zeroPoly = NULL;
998
999// TODO warum SetpFDeg notwendig?
1000 h->SetpFDeg();
1001 assume(h->pFDeg() == h->FDeg);
1002 long reddeg = h->GetpFDeg();
1003
1004 h->SetShortExpVector();
1005 loop
1006 {
1007 j = kFindDivisibleByInT(strat, h);
1008 if (j < 0)
1009 {
1010 // over ZZ: cleanup coefficients by complete reduction with monomials
1011 postReduceByMon(h, strat);
1012 if(h->p == NULL)
1013 {
1014 kDeleteLcm(h);
1015 h->Clear();
1016 return 0;
1017 }
1018 if(nIsZero(pGetCoeff(h->p))) return 2;
1019 j = kFindDivisibleByInT(strat, h);
1020 if(j < 0)
1021 {
1022 if(strat->tl >= 0)
1023 h->i_r1 = strat->tl;
1024 else
1025 h->i_r1 = -1;
1026 if (h->GetLmTailRing() == NULL)
1027 {
1028 kDeleteLcm(h);
1029 h->Clear();
1030 return 0;
1031 }
1032 return 1;
1033 }
1034 }
1035 //printf("\nFound one: ");pWrite(strat->T[j].p);
1036 //enterT(*h, strat);
1037 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat); // with debug output
1038 //printf("\nAfter small red: ");pWrite(h->p);
1039 if (h->GetLmTailRing() == NULL)
1040 {
1041 kDeleteLcm(h);
1042 h->Clear();
1043 return 0;
1044 }
1045 h->SetShortExpVector();
1046 d = h->SetpFDeg();
1047 /*- try to reduce the s-polynomial -*/
1048 pass++;
1049 if (!TEST_OPT_REDTHROUGH &&
1050 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1051 {
1052 h->SetLmCurrRing();
1053 if (strat->posInLDependsOnLength)
1054 h->SetLength(strat->length_pLength);
1055 at = strat->posInL(strat->L,strat->Ll,h,strat);
1056 if (at <= strat->Ll)
1057 {
1058#ifdef KDEBUG
1059 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1060#endif
1061 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
1062 h->Clear();
1063 return -1;
1064 }
1065 }
1066 if (d != reddeg)
1067 {
1068 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
1069 {
1070 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1071 {
1072 strat->overflow=TRUE;
1073 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1074 h->GetP();
1075 at = strat->posInL(strat->L,strat->Ll,h,strat);
1076 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1077 h->Clear();
1078 return -1;
1079 }
1080 }
1081 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1082 {
1083 Print(".%ld",d);mflush();
1084 reddeg = d;
1085 }
1086 }
1087 }
1088}

◆ redRing_Z()

int redRing_Z ( LObject * h,
kStrategy strat )

Definition at line 720 of file kstd2.cc.

721{
722 if (h->IsNull()) return 0; // spoly is zero (can only occur with zero divisors)
723 if (strat->tl<0) return 1;
724
725 int at;
726 long d;
727 int j = 0;
728 int pass = 0;
729
730// TODO warum SetpFDeg notwendig?
731 h->SetpFDeg();
732 assume(h->pFDeg() == h->FDeg);
733 long reddeg = h->GetpFDeg();
734
735 h->SetShortExpVector();
736 loop
737 {
738 /* check if a reducer of the lead term exists */
739 j = kFindDivisibleByInT(strat, h);
740 if (j < 0)
741 {
742#if STDZ_EXCHANGE_DURING_REDUCTION
743 /* check if a reducer with the same lead monomial exists */
744 j = kFindSameLMInT_Z(strat, h);
745 if (j < 0)
746 {
747#endif
748 /* check if a reducer of the lead monomial exists, by the above
749 * check this is a real divisor of the lead monomial */
750 j = kFindDivisibleByInT_Z(strat, h);
751 if (j < 0)
752 {
753 // over ZZ: cleanup coefficients by complete reduction with monomials
755 postReduceByMon(h, strat);
756 if(h->p == NULL)
757 {
758 if (h->lcm!=NULL) pLmDelete(h->lcm);
759 h->Clear();
760 return 0;
761 }
762 if(nIsZero(pGetCoeff(h->p))) return 2;
763 j = kFindDivisibleByInT(strat, h);
764 if(j < 0)
765 {
766 if(strat->tl >= 0)
767 h->i_r1 = strat->tl;
768 else
769 h->i_r1 = -1;
770 if (h->GetLmTailRing() == NULL)
771 {
772 if (h->lcm!=NULL) pLmDelete(h->lcm);
773 h->Clear();
774 return 0;
775 }
776 return 1;
777 }
778 }
779 else
780 {
781 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
782 * => we try to cut down the lead coefficient at least */
783 /* first copy T[j] in order to multiply it with a coefficient later on */
784 number mult, rest;
785 TObject tj = strat->T[j];
786 tj.Copy();
787 /* tj.max_exp = strat->T[j].max_exp; */
788 /* compute division with remainder of lc(h) and lc(T[j]) */
789 mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
790 &rest, currRing->cf);
791 /* set corresponding new lead coefficient already. we do not
792 * remove the lead term in ksReducePolyLC, but only apply
793 * a lead coefficient reduction */
794 tj.Mult_nn(mult);
795 ksReducePolyLC(h, &tj, NULL, &rest, strat);
796 tj.Delete();
797 tj.Clear();
798 }
799#if STDZ_EXCHANGE_DURING_REDUCTION
800 }
801 else
802 {
803 /* same lead monomial but lead coefficients do not divide each other:
804 * change the polys to h <- spoly(h,tj) and h2 <- gpoly(h,tj). */
805 LObject h2 = *h;
806 h2.Copy();
807
808 ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat);
809 ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat);
811 {
812 redtailBbaAlsoLC_Z(&h2, j, strat);
813 }
814 /* replace h2 for tj in L (already generated pairs with tj), S and T */
815 replaceInLAndSAndT(h2, j, strat);
816 }
817#endif
818 }
819 else
820 {
821 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat);
822 }
823 /* printf("\nAfter small red: ");pWrite(h->p); */
824 if (h->GetLmTailRing() == NULL)
825 {
826 if (h->lcm!=NULL) pLmDelete(h->lcm);
827#ifdef KDEBUG
828 h->lcm=NULL;
829#endif
830 h->Clear();
831 return 0;
832 }
833 h->SetShortExpVector();
834 d = h->SetpFDeg();
835 /*- try to reduce the s-polynomial -*/
836 pass++;
837 if (!TEST_OPT_REDTHROUGH &&
838 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
839 {
840 h->SetLmCurrRing();
841 if (strat->posInLDependsOnLength)
842 h->SetLength(strat->length_pLength);
843 at = strat->posInL(strat->L,strat->Ll,h,strat);
844 if (at <= strat->Ll)
845 {
846#ifdef KDEBUG
847 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
848#endif
849 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
850 h->Clear();
851 return -1;
852 }
853 }
854 if (d != reddeg)
855 {
856 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
857 {
858 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
859 {
860 strat->overflow=TRUE;
861 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
862 h->GetP();
863 at = strat->posInL(strat->L,strat->Ll,h,strat);
864 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
865 h->Clear();
866 return -1;
867 }
868 }
869 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
870 {
871 Print(".%ld",d);mflush();
872 reddeg = d;
873 }
874 }
875 }
876}
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:477
int kFindDivisibleByInT_Z(const kStrategy strat, const LObject *L, const int start)
Definition kstd2.cc:209
int ksReducePolyGCD(LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int kFindSameLMInT_Z(const kStrategy strat, const LObject *L, const int start=0)
int ksReducePolyZ(LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)

◆ redSig()

int redSig ( LObject * h,
kStrategy strat )

Definition at line 1369 of file kstd2.cc.

1370{
1371 if (strat->tl<0) return 1;
1372 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1373 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1374 assume(h->FDeg == h->pFDeg());
1375//#if 1
1376#ifdef DEBUGF5
1377 PrintS("------- IN REDSIG -------\n");
1378 Print("p: ");
1379 pWrite(pHead(h->p));
1380 PrintS("p1: ");
1381 pWrite(pHead(h->p1));
1382 PrintS("p2: ");
1383 pWrite(pHead(h->p2));
1384 PrintS("---------------------------\n");
1385#endif
1386 poly h_p;
1387 int i,j,at,pass, ii;
1388 int start=0;
1389 int sigSafe;
1390 unsigned long not_sev;
1391 // long reddeg,d;
1392 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1393 int li;
1394
1395 pass = j = 0;
1396 h->SetShortExpVector();
1397 h_p = h->GetLmTailRing();
1398 not_sev = ~ h->sev;
1399 loop
1400 {
1401 j = kFindDivisibleByInT(strat, h, start);
1402 if (j < 0)
1403 {
1404 return 1;
1405 }
1406
1407 li = strat->T[j].pLength;
1408 if (li<=0) li=strat->T[j].GetpLength();
1409 ii = j;
1410 /*
1411 * the polynomial to reduce with (up to the moment) is;
1412 * pi with length li
1413 */
1414 i = j;
1415#if 1
1416 if (test_opt_length)
1417 loop
1418 {
1419 /*- search the shortest possible with respect to length -*/
1420 i++;
1421 if (i > strat->tl)
1422 break;
1423 if (li==1)
1424 break;
1425 if ((strat->T[i].pLength < li)
1426 &&
1427 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1428 h_p, not_sev, strat->tailRing))
1429 {
1430 /*
1431 * the polynomial to reduce with is now;
1432 */
1433 li = strat->T[i].pLength;
1434 if (li<=0) li=strat->T[i].GetpLength();
1435 ii = i;
1436 }
1437 }
1438 start = ii+1;
1439#endif
1440
1441 /*
1442 * end of search: have to reduce with pi
1443 */
1444#ifdef KDEBUG
1445 if (TEST_OPT_DEBUG)
1446 {
1447 PrintS("red:");
1448 h->wrp();
1449 PrintS(" with ");
1450 strat->T[ii].wrp();
1451 }
1452#endif
1453 assume(strat->fromT == FALSE);
1454//#if 1
1455#ifdef DEBUGF5
1456 Print("BEFORE REDUCTION WITH %d:\n",ii);
1457 PrintS("--------------------------------\n");
1458 pWrite(h->sig);
1459 pWrite(strat->T[ii].sig);
1460 pWrite(h->GetLmCurrRing());
1461 pWrite(pHead(h->p1));
1462 pWrite(pHead(h->p2));
1463 pWrite(pHead(strat->T[ii].p));
1464 PrintS("--------------------------------\n");
1465 printf("INDEX OF REDUCER T: %d\n",ii);
1466#endif
1467 sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1468#if SBA_PRINT_REDUCTION_STEPS
1469 if (sigSafe != 3)
1470 sba_reduction_steps++;
1471#endif
1472#if SBA_PRINT_OPERATIONS
1473 if (sigSafe != 3)
1474 sba_operations += pLength(strat->T[ii].p);
1475#endif
1476 // if reduction has taken place, i.e. the reduction was sig-safe
1477 // otherwise start is already at the next position and the loop
1478 // searching reducers in T goes on from index start
1479//#if 1
1480#ifdef DEBUGF5
1481 Print("SigSAFE: %d\n",sigSafe);
1482#endif
1483 if (sigSafe != 3)
1484 {
1485 // start the next search for reducers in T from the beginning
1486 start = 0;
1487#ifdef KDEBUG
1488 if (TEST_OPT_DEBUG)
1489 {
1490 PrintS("\nto ");
1491 h->wrp();
1492 PrintLn();
1493 }
1494#endif
1495
1496 h_p = h->GetLmTailRing();
1497 if (h_p == NULL)
1498 {
1499 kDeleteLcm(h);
1500 return 0;
1501 }
1502 h->SetShortExpVector();
1503 not_sev = ~ h->sev;
1504 /*
1505 * try to reduce the s-polynomial h
1506 *test first whether h should go to the lazyset L
1507 *-if the degree jumps
1508 *-if the number of pre-defined reductions jumps
1509 */
1510 pass++;
1511 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1512 {
1513 h->SetLmCurrRing();
1514 at = strat->posInL(strat->L,strat->Ll,h,strat);
1515 if (at <= strat->Ll)
1516 {
1517 int dummy=strat->sl;
1518 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1519 {
1520 return 1;
1521 }
1522 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1523#ifdef KDEBUG
1524 if (TEST_OPT_DEBUG)
1525 Print(" lazy: -> L%d\n",at);
1526#endif
1527 h->Clear();
1528 return -1;
1529 }
1530 }
1531 }
1532 }
1533}
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:737

◆ redSigRing()

int redSigRing ( LObject * h,
kStrategy strat )

Definition at line 1536 of file kstd2.cc.

1537{
1538 //Since reduce is really bad for SBA we use the following idea:
1539 // We first check if we can build a gcd pair between h and S
1540 //where the sig remains the same and replace h by this gcd poly
1542 #if GCD_SBA
1543 while(sbaCheckGcdPair(h,strat))
1544 {
1545 h->sev = pGetShortExpVector(h->p);
1546 }
1547 #endif
1548 poly beforeredsig;
1549 beforeredsig = pCopy(h->sig);
1550
1551 if (strat->tl<0) return 1;
1552 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1553 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1554 assume(h->FDeg == h->pFDeg());
1555//#if 1
1556#ifdef DEBUGF5
1557 Print("------- IN REDSIG -------\n");
1558 Print("p: ");
1559 pWrite(pHead(h->p));
1560 Print("p1: ");
1561 pWrite(pHead(h->p1));
1562 Print("p2: ");
1563 pWrite(pHead(h->p2));
1564 Print("---------------------------\n");
1565#endif
1566 poly h_p;
1567 int i,j,at,pass, ii;
1568 int start=0;
1569 int sigSafe;
1570 unsigned long not_sev;
1571 // long reddeg,d;
1572 int li;
1573 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1574
1575 pass = j = 0;
1576 h->SetShortExpVector();
1577 h_p = h->GetLmTailRing();
1578 not_sev = ~ h->sev;
1579 loop
1580 {
1581 j = kFindDivisibleByInT(strat, h, start);
1582 if (j < 0)
1583 {
1584 #if GCD_SBA
1585 while(sbaCheckGcdPair(h,strat))
1586 {
1587 h->sev = pGetShortExpVector(h->p);
1588 h->is_redundant = FALSE;
1589 start = 0;
1590 }
1591 #endif
1592 // over ZZ: cleanup coefficients by complete reduction with monomials
1593 postReduceByMonSig(h, strat);
1594 if(h->p == NULL || nIsZero(pGetCoeff(h->p))) return 2;
1595 j = kFindDivisibleByInT(strat, h,start);
1596 if(j < 0)
1597 {
1598 if(strat->tl >= 0)
1599 h->i_r1 = strat->tl;
1600 else
1601 h->i_r1 = -1;
1602 if (h->GetLmTailRing() == NULL)
1603 {
1604 kDeleteLcm(h);
1605 h->Clear();
1606 return 0;
1607 }
1608 //Check for sigdrop after reduction
1609 if(pLtCmp(beforeredsig,h->sig) == 1)
1610 {
1611 strat->sigdrop = TRUE;
1612 //Reduce it as much as you can
1613 int red_result = redRing(h,strat);
1614 if(red_result == 0)
1615 {
1616 //It reduced to 0, cancel the sigdrop
1617 strat->sigdrop = FALSE;
1618 p_Delete(&h->sig,currRing);h->sig = NULL;
1619 return 0;
1620 }
1621 else
1622 {
1623 //strat->enterS(*h, strat->sl+1, strat, strat->tl);
1624 return 0;
1625 }
1626 }
1627 p_Delete(&beforeredsig,currRing);
1628 return 1;
1629 }
1630 }
1631
1632 li = strat->T[j].pLength;
1633 if (li<=0) li=strat->T[j].GetpLength();
1634 ii = j;
1635 /*
1636 * the polynomial to reduce with (up to the moment) is;
1637 * pi with length li
1638 */
1639 i = j;
1640 if (test_opt_length)
1641 loop
1642 {
1643 /*- search the shortest possible with respect to length -*/
1644 i++;
1645 if (i > strat->tl)
1646 break;
1647 if (li==1)
1648 break;
1649 if ((strat->T[i].pLength < li)
1650 && n_DivBy(pGetCoeff(h_p),pGetCoeff(strat->T[i].p),currRing->cf)
1651 && p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1652 h_p, not_sev, strat->tailRing))
1653 {
1654 /*
1655 * the polynomial to reduce with is now;
1656 */
1657 li = strat->T[i].pLength;
1658 if (li<=0) li=strat->T[i].GetpLength();
1659 ii = i;
1660 }
1661 }
1662
1663 start = ii+1;
1664
1665 /*
1666 * end of search: have to reduce with pi
1667 */
1668#ifdef KDEBUG
1669 if (TEST_OPT_DEBUG)
1670 {
1671 PrintS("red:");
1672 h->wrp();
1673 PrintS(" with ");
1674 strat->T[ii].wrp();
1675 }
1676#endif
1677 assume(strat->fromT == FALSE);
1678//#if 1
1679#ifdef DEBUGF5
1680 Print("BEFORE REDUCTION WITH %d:\n",ii);
1681 Print("--------------------------------\n");
1682 pWrite(h->sig);
1683 pWrite(strat->T[ii].sig);
1684 pWrite(h->GetLmCurrRing());
1685 pWrite(pHead(h->p1));
1686 pWrite(pHead(h->p2));
1687 pWrite(pHead(strat->T[ii].p));
1688 Print("--------------------------------\n");
1689 printf("INDEX OF REDUCER T: %d\n",ii);
1690#endif
1691 sigSafe = ksReducePolySigRing(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1692 if(h->p == NULL && h->sig == NULL)
1693 {
1694 //Trivial case catch
1695 strat->sigdrop = FALSE;
1696 }
1697 #if 0
1698 //If the reducer has the same lt (+ or -) as the other one, reduce it via redRing
1699 //In some cases this proves to be very bad
1700 if(rField_is_Ring(currRing) && h->p != NULL && pLmCmp(h->p,strat->T[ii].p)==0)
1701 {
1702 int red_result = redRing(h,strat);
1703 if(red_result == 0)
1704 {
1705 pDelete(&h->sig);h->sig = NULL;
1706 return 0;
1707 }
1708 else
1709 {
1710 strat->sigdrop = TRUE;
1711 return 1;
1712 }
1713 }
1714 #endif
1715 if(strat->sigdrop)
1716 return 1;
1717#if SBA_PRINT_REDUCTION_STEPS
1718 if (sigSafe != 3)
1719 sba_reduction_steps++;
1720#endif
1721#if SBA_PRINT_OPERATIONS
1722 if (sigSafe != 3)
1723 sba_operations += pLength(strat->T[ii].p);
1724#endif
1725 // if reduction has taken place, i.e. the reduction was sig-safe
1726 // otherwise start is already at the next position and the loop
1727 // searching reducers in T goes on from index start
1728//#if 1
1729#ifdef DEBUGF5
1730 Print("SigSAFE: %d\n",sigSafe);
1731#endif
1732 if (sigSafe != 3)
1733 {
1734 // start the next search for reducers in T from the beginning
1735 start = 0;
1736#ifdef KDEBUG
1737 if (TEST_OPT_DEBUG)
1738 {
1739 PrintS("\nto ");
1740 h->wrp();
1741 PrintLn();
1742 }
1743#endif
1744
1745 h_p = h->GetLmTailRing();
1746 if (h_p == NULL)
1747 {
1748 kDeleteLcm(h);
1749 return 0;
1750 }
1751 h->SetShortExpVector();
1752 not_sev = ~ h->sev;
1753 /*
1754 * try to reduce the s-polynomial h
1755 *test first whether h should go to the lazyset L
1756 *-if the degree jumps
1757 *-if the number of pre-defined reductions jumps
1758 */
1759 pass++;
1760 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1761 {
1762 h->SetLmCurrRing();
1763 at = strat->posInL(strat->L,strat->Ll,h,strat);
1764 if (at <= strat->Ll)
1765 {
1766 int dummy=strat->sl;
1767 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1768 {
1769 return 1;
1770 }
1771 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1772#ifdef KDEBUG
1773 if (TEST_OPT_DEBUG)
1774 Print(" lazy: -> L%d\n",at);
1775#endif
1776 h->Clear();
1777 return -1;
1778 }
1779 }
1780 }
1781 }
1782}
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:943
void postReduceByMonSig(LObject *h, kStrategy strat)
Definition kutil.cc:10758
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition kutil.cc:1688

◆ redtail() [1/2]

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

Definition at line 6836 of file kutil.cc.

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

◆ redtail() [2/2]

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

Definition at line 6906 of file kutil.cc.

6907{
6908 LObject L(p, currRing);
6909 return redtail(&L, end_pos, strat);
6910}

◆ redtailBba() [1/3]

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

Definition at line 6912 of file kutil.cc.

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

KINLINE poly redtailBba ( poly p,
int end_pos,
kStrategy strat,
BOOLEAN normalize = FALSE )

Definition at line 1212 of file kInline.h.

1213{
1214 LObject L(p);
1215 return redtailBba(&L, pos, strat,FALSE, normalize);
1216}

◆ redtailBba() [3/3]

poly redtailBba ( TObject * T,
int end_pos,
kStrategy strat )

◆ redtailBba_NF()

poly redtailBba_NF ( poly p,
kStrategy strat )

Definition at line 7350 of file kutil.cc.

7351{
7352 strat->redTailChange=FALSE;
7353 if (strat->noTailReduction) return p;
7354 if ((p==NULL) || (pNext(p)==NULL))
7355 return p;
7356
7357 int max_ind;
7358 poly h=p;
7359 p=pNext(p);
7360 pNext(h)=NULL;
7361 while(p!=NULL)
7362 {
7363 p=redNF(p,max_ind,1,strat);
7364 if (p!=NULL)
7365 {
7366 poly hh=p;
7367 p=pNext(p);
7368 pNext(hh)=NULL;
7369 h=p_Add_q(h,hh,currRing);
7370 }
7371 }
7372 return h;
7373}

◆ redtailBba_Ring() [1/2]

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

Definition at line 7375 of file kutil.cc.

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

◆ redtailBba_Ring() [2/2]

KINLINE poly redtailBba_Ring ( poly p,
int end_pos,
kStrategy strat )

Definition at line 1224 of file kInline.h.

1225{
1226 LObject L(p, currRing, strat->tailRing);
1227 return redtailBba_Ring(&L, pos, strat);
1228}

◆ redtailBba_Z() [1/2]

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

Definition at line 7269 of file kutil.cc.

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

◆ redtailBba_Z() [2/2]

KINLINE poly redtailBba_Z ( poly p,
int end_pos,
kStrategy strat )

Definition at line 1229 of file kInline.h.

1230{
1231 LObject L(p, currRing, strat->tailRing);
1232 return redtailBba_Z(&L, pos, strat);
1233}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7140 of file kutil.cc.

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

◆ redtailBbaBound() [1/2]

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

Definition at line 7025 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

KINLINE poly redtailBbaBound ( poly p,
int end_pos,
kStrategy strat,
int bound,
BOOLEAN normalize = FALSE )

Definition at line 1218 of file kInline.h.

1219{
1220 LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1221 return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1222}

◆ redtailBbaShift()

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

Definition at line 12980 of file kutil.cc.

12981{
12982 /* for the shift case need to run it with withT = TRUE */
12983 strat->redTailChange=FALSE;
12984 if (strat->noTailReduction) return L->GetLmCurrRing();
12985 poly h, p;
12986 p = h = L->GetLmTailRing();
12987 if ((h==NULL) || (pNext(h)==NULL))
12988 return L->GetLmCurrRing();
12989
12990 TObject* With;
12991 // placeholder in case strat->tl < 0
12992 TObject With_s(strat->tailRing);
12993
12994 LObject Ln(pNext(h), strat->tailRing);
12995 Ln.pLength = L->GetpLength() - 1;
12996
12997 pNext(h) = NULL;
12998 if (L->p != NULL) pNext(L->p) = NULL;
12999 L->pLength = 1;
13000
13001 Ln.PrepareRed(strat->use_buckets);
13002
13003 while(!Ln.IsNull())
13004 {
13005 loop
13006 {
13007 Ln.SetShortExpVector();
13008 if (withT)
13009 {
13010 int j;
13011 j = kFindDivisibleByInT(strat, &Ln);
13012 if (j < 0) break;
13013 With = &(strat->T[j]);
13014 }
13015 else
13016 {
13017 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13018 if (With == NULL) break;
13019 }
13020 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13021 {
13022 With->pNorm();
13023 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13024 }
13025 strat->redTailChange=TRUE;
13026 if (ksReducePolyTail(L, With, &Ln))
13027 {
13028 // reducing the tail would violate the exp bound
13029 // set a flag and hope for a retry (in bba)
13031 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13032 do
13033 {
13034 pNext(h) = Ln.LmExtractAndIter();
13035 pIter(h);
13036 L->pLength++;
13037 } while (!Ln.IsNull());
13038 goto all_done;
13039 }
13040 if (Ln.IsNull()) goto all_done;
13041 if (! withT) With_s.Init(currRing);
13042 }
13043 pNext(h) = Ln.LmExtractAndIter();
13044 pIter(h);
13045 L->pLength++;
13046 }
13047
13048 all_done:
13049 Ln.Delete();
13050 if (L->p != NULL) pNext(L->p) = pNext(p);
13051
13052 if (strat->redTailChange)
13053 {
13054 L->length = 0;
13055 }
13056 L->Normalize(); // HANNES: should have a test
13057 kTest_L(L,strat);
13058 return L->GetLmCurrRing();
13059}

◆ redtailSba()

poly redtailSba ( LObject * L,
int end_pos,
kStrategy strat,
BOOLEAN withT = FALSE,
BOOLEAN normalize = FALSE )

Definition at line 1785 of file kstd2.cc.

1786{
1787 strat->redTailChange=FALSE;
1788 if (strat->noTailReduction) return L->GetLmCurrRing();
1789 poly h, p;
1790 p = h = L->GetLmTailRing();
1791 if ((h==NULL) || (pNext(h)==NULL))
1792 return L->GetLmCurrRing();
1793
1794 TObject* With;
1795 // placeholder in case strat->tl < 0
1796 TObject With_s(strat->tailRing);
1797
1798 LObject Ln(pNext(h), strat->tailRing);
1799 Ln.sig = L->sig;
1800 Ln.sevSig = L->sevSig;
1801 Ln.pLength = L->GetpLength() - 1;
1802
1803 pNext(h) = NULL;
1804 if (L->p != NULL) pNext(L->p) = NULL;
1805 L->pLength = 1;
1806
1807 Ln.PrepareRed(strat->use_buckets);
1808
1809 int cnt=REDTAIL_CANONICALIZE;
1810 while(!Ln.IsNull())
1811 {
1812 loop
1813 {
1814 if(rField_is_Ring(currRing) && strat->sigdrop)
1815 break;
1816 Ln.SetShortExpVector();
1817 if (withT)
1818 {
1819 int j;
1820 j = kFindDivisibleByInT(strat, &Ln);
1821 if (j < 0) break;
1822 With = &(strat->T[j]);
1823 }
1824 else
1825 {
1826 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1827 if (With == NULL) break;
1828 }
1829 cnt--;
1830 if (cnt==0)
1831 {
1833 /*poly tmp=*/Ln.CanonicalizeP();
1835 {
1836 Ln.Normalize();
1837 //pNormalize(tmp);
1838 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1839 }
1840 }
1842 {
1843 With->pNorm();
1844 }
1845 strat->redTailChange=TRUE;
1846 int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1848 L->sig = Ln.sig;
1849 //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1850 // I delete it an then set Ln.sig. Hence L->sig is lost
1851#if SBA_PRINT_REDUCTION_STEPS
1852 if (ret != 3)
1853 sba_reduction_steps++;
1854#endif
1855#if SBA_PRINT_OPERATIONS
1856 if (ret != 3)
1857 sba_operations += pLength(With->p);
1858#endif
1859 if (ret)
1860 {
1861 // reducing the tail would violate the exp bound
1862 // set a flag and hope for a retry (in bba)
1864 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1865 do
1866 {
1867 pNext(h) = Ln.LmExtractAndIter();
1868 pIter(h);
1869 L->pLength++;
1870 } while (!Ln.IsNull());
1871 goto all_done;
1872 }
1873 if (Ln.IsNull()) goto all_done;
1874 if (! withT) With_s.Init(currRing);
1875 if(rField_is_Ring(currRing) && strat->sigdrop)
1876 {
1877 //Cannot break the loop here so easily
1878 break;
1879 }
1880 }
1881 pNext(h) = Ln.LmExtractAndIter();
1882 pIter(h);
1884 pNormalize(h);
1885 L->pLength++;
1886 }
1887 all_done:
1888 Ln.Delete();
1889 if (L->p != NULL) pNext(L->p) = pNext(p);
1890
1891 if (strat->redTailChange)
1892 {
1893 L->length = 0;
1894 }
1895 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1896 //L->Normalize(); // HANNES: should have a test
1897 kTest_L(L,strat);
1898 return L->GetLmCurrRing();
1899}
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition kstd2.cc:1331

◆ reorderS()

void reorderS ( int * suc,
kStrategy strat )

Definition at line 4610 of file kutil.cc.

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

◆ sba()

ideal sba ( ideal F,
ideal Q,
intvec * w,
bigintmat * hilb,
kStrategy strat )

Definition at line 2971 of file kstd2.cc.

2972{
2973 // ring order stuff:
2974 // in sba we have (until now) two possibilities:
2975 // 1. an incremental computation w.r.t. (C,monomial order)
2976 // 2. a (possibly non-incremental) computation w.r.t. the
2977 // induced Schreyer order.
2978 // The corresponding orders are computed in sbaRing(), depending
2979 // on the flag strat->sbaOrder
2980#if SBA_PRINT_ZERO_REDUCTIONS
2981 long zeroreductions = 0;
2982#endif
2983#if SBA_PRINT_PRODUCT_CRITERION
2984 long product_criterion = 0;
2985#endif
2986#if SBA_PRINT_SIZE_G
2987 int size_g = 0;
2988 int size_g_non_red = 0;
2989#endif
2990#if SBA_PRINT_SIZE_SYZ
2991 long size_syz = 0;
2992#endif
2993 // global variable
2994#if SBA_PRINT_REDUCTION_STEPS
2995 sba_reduction_steps = 0;
2996 sba_interreduction_steps = 0;
2997#endif
2998#if SBA_PRINT_OPERATIONS
2999 sba_operations = 0;
3000 sba_interreduction_operations = 0;
3001#endif
3002
3003 ideal F1 = F0;
3004 ring currRingOld = currRing;
3005 ring sRing = currRing;
3006 if (strat->sbaOrder == 1 || strat->sbaOrder == 3)
3007 {
3008 sRing = sbaRing(strat);
3009 if (sRing!=currRingOld)
3010 {
3011 rChangeCurrRing (sRing);
3012 F1 = idrMoveR (F0, currRingOld, currRing);
3013 }
3014 }
3015 ideal F;
3016 // sort ideal F
3017 //Put the SigDrop element on the correct position (think of sbaEnterS)
3018 //We also sort them
3019 if(rField_is_Ring(currRing) && strat->sigdrop)
3020 {
3021 #if 1
3022 F = idInit(IDELEMS(F1),F1->rank);
3023 for (int i=0; i<IDELEMS(F1);++i)
3024 F->m[i] = F1->m[i];
3025 if(strat->sbaEnterS >= 0)
3026 {
3027 poly dummy;
3028 dummy = pCopy(F->m[0]); //the sigdrop element
3029 for(int i = 0;i<strat->sbaEnterS;i++)
3030 F->m[i] = F->m[i+1];
3031 F->m[strat->sbaEnterS] = dummy;
3032 }
3033 #else
3034 F = idInit(1,F1->rank);
3035 //printf("\nBefore the initial block sorting:\n");idPrint(F1);
3036 F->m[0] = F1->m[0];
3037 int pos;
3038 if(strat->sbaEnterS >= 0)
3039 {
3040 for(int i=1;i<=strat->sbaEnterS;i++)
3041 {
3042 pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS);
3043 idInsertPolyOnPos(F,F1->m[i],pos);
3044 }
3045 for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++)
3046 {
3047 pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F));
3048 idInsertPolyOnPos(F,F1->m[i],pos);
3049 }
3050 poly dummy;
3051 dummy = pCopy(F->m[0]); //the sigdrop element
3052 for(int i = 0;i<strat->sbaEnterS;i++)
3053 F->m[i] = F->m[i+1];
3054 F->m[strat->sbaEnterS] = dummy;
3055 }
3056 else
3057 {
3058 for(int i=1;i<IDELEMS(F1);i++)
3059 {
3060 pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F));
3061 idInsertPolyOnPos(F,F1->m[i],pos);
3062 }
3063 }
3064 #endif
3065 //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar();
3066 }
3067 else
3068 {
3069 F = idInit(IDELEMS(F1),F1->rank);
3070 intvec *sort = idSort(F1);
3071 for (int i=0; i<sort->length();++i)
3072 F->m[i] = F1->m[(*sort)[i]-1];
3074 {
3075 // put the monomials after the sbaEnterS polynomials
3076 //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F);
3077 int nrmon = 0;
3078 for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--)
3079 {
3080 //pWrite(F->m[i]);
3081 if(F->m[i] != NULL && pNext(F->m[i]) == NULL)
3082 {
3083 poly mon = F->m[i];
3084 for(j = i;j>strat->sbaEnterS+nrmon+1;j--)
3085 {
3086 F->m[j] = F->m[j-1];
3087 }
3088 F->m[j] = mon;
3089 nrmon++;
3090 }
3091 //idPrint(F);
3092 }
3093 }
3094 }
3095 //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar();
3097 strat->sigdrop = FALSE;
3098 strat->nrsyzcrit = 0;
3099 strat->nrrewcrit = 0;
3100#if SBA_INTERRED_START
3101 F = kInterRed(F,NULL);
3102#endif
3103#if F5DEBUG
3104 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
3105 rWrite (currRing);
3106 printf("ordSgn = %d\n",currRing->OrdSgn);
3107 printf("\n");
3108#endif
3109 int srmax,lrmax, red_result = 1;
3110 int olddeg,reduc;
3111 int hilbeledeg=1,hilbcount=0,minimcnt=0;
3112 LObject L;
3113 BOOLEAN withT = TRUE;
3114 strat->max_lower_index = 0;
3115 //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
3116 initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/
3117 initSbaPos(strat);
3118 initHilbCrit(F,Q,&hilb,strat);
3119 initSba(F,strat);
3120 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
3121 /*Shdl=*/initSbaBuchMora(F, Q,strat);
3122 idTest(strat->Shdl);
3123 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
3124 srmax = strat->sl;
3125 reduc = olddeg = lrmax = 0;
3126#ifndef NO_BUCKETS
3128 strat->use_buckets = 1;
3129#endif
3130
3131 // redtailBBa against T for inhomogeneous input
3132 // if (!TEST_OPT_OLDSTD)
3133 // withT = ! strat->homog;
3134
3135 // strat->posInT = posInT_pLength;
3136 kTest_TS(strat);
3137
3138#ifdef HAVE_TAIL_RING
3139 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
3141#endif
3142 // We add the elements directly in S from the previous loop
3143 if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0)
3144 {
3145 for(int i = 0;i<strat->sbaEnterS;i++)
3146 {
3147 //Update: now the element is at the correct place
3148 //i+1 because on the 0 position is the sigdrop element
3149 enterT(&strat->L[strat->Ll-(i)],strat);
3150 strat->enterS(&strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl);
3151 }
3152 strat->Ll = strat->Ll - strat->sbaEnterS;
3153 strat->sbaEnterS = -1;
3154 }
3155 kTest_TS(strat);
3156#ifdef KDEBUG
3157 //kDebugPrint(strat);
3158#endif
3159 /* compute------------------------------------------------------- */
3160 while (strat->Ll >= 0)
3161 {
3162 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
3163 #ifdef KDEBUG
3164 if (TEST_OPT_DEBUG) messageSets(strat);
3165 #endif
3166 if (strat->Ll== 0) strat->interpt=TRUE;
3167 /*
3168 if (TEST_OPT_DEGBOUND
3169 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
3170 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
3171 {
3172
3173 //stops computation if
3174 // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
3175 //a predefined number Kstd1_deg
3176 while ((strat->Ll >= 0)
3177 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
3178 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
3179 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
3180 )
3181 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
3182 if (strat->Ll<0) break;
3183 else strat->noClearS=TRUE;
3184 }
3185 */
3186 if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)
3187 {
3188 strat->currIdx = pGetComp(strat->L[strat->Ll].sig);
3189#if F5C
3190 // 1. interreduction of the current standard basis
3191 // 2. generation of new principal syzygy rules for syzCriterion
3192 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
3193 lrmax, reduc, Q, w, hilb );
3194#endif
3195 // initialize new syzygy rules for the next iteration step
3196 initSyzRules(strat);
3197 }
3198 /*********************************************************************
3199 * interrreduction step is done, we can go on with the next iteration
3200 * step of the signature-based algorithm
3201 ********************************************************************/
3202 /* picks the last element from the lazyset L */
3203 strat->P = strat->L[strat->Ll];
3204 strat->Ll--;
3205
3207 strat->sbaEnterS = pGetComp(strat->P.sig) - 1;
3208 /* reduction of the element chosen from L */
3209 if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1))
3210 {
3211 //#if 1
3212#ifdef DEBUGF5
3213 PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
3214 PrintS("-------------------------------------------------\n");
3215 pWrite(strat->P.sig);
3216 pWrite(pHead(strat->P.p));
3217 pWrite(pHead(strat->P.p1));
3218 pWrite(pHead(strat->P.p2));
3219 PrintS("-------------------------------------------------\n");
3220#endif
3221 if (pNext(strat->P.p) == strat->tail)
3222 {
3223 // deletes the short spoly
3224 /*
3225 if (rField_is_Ring(currRing))
3226 pLmDelete(strat->P.p);
3227 else
3228 pLmFree(strat->P.p);
3229*/
3230 // TODO: needs some masking
3231 // TODO: masking needs to vanish once the signature
3232 // stuff is completely implemented
3233 strat->P.p = NULL;
3234 poly m1 = NULL, m2 = NULL;
3235
3236 // check that spoly creation is ok
3237 while (strat->tailRing != currRing &&
3238 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
3239 {
3240 assume(m1 == NULL && m2 == NULL);
3241 // if not, change to a ring where exponents are at least
3242 // large enough
3243 if (!kStratChangeTailRing(strat))
3244 {
3245 WerrorS("OVERFLOW...");
3246 break;
3247 }
3248 }
3249 // create the real one
3250 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
3251 strat->tailRing, m1, m2, strat->R);
3252
3253 }
3254 else if (strat->P.p1 == NULL)
3255 {
3256 if (strat->minim > 0)
3257 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
3258 // for input polys, prepare reduction
3260 strat->P.PrepareRed(strat->use_buckets);
3261 }
3262 if (strat->P.p == NULL && strat->P.t_p == NULL)
3263 {
3264 red_result = 0;
3265 }
3266 else
3267 {
3268 //#if 1
3269#ifdef DEBUGF5
3270 PrintS("Poly before red: ");
3271 pWrite(pHead(strat->P.p));
3272 pWrite(strat->P.sig);
3273#endif
3274#if SBA_PRODUCT_CRITERION
3275 if (strat->P.prod_crit)
3276 {
3277#if SBA_PRINT_PRODUCT_CRITERION
3278 product_criterion++;
3279#endif
3280 int pos = posInSyz(strat, strat->P.sig);
3281 enterSyz(strat->P, strat, pos);
3282 kDeleteLcm(&strat->P);
3283 red_result = 2;
3284 }
3285 else
3286 {
3287 red_result = strat->red(&strat->P,strat);
3288 }
3289#else
3290 red_result = strat->red(&strat->P,strat);
3291#endif
3292 }
3293 }
3294 else
3295 {
3296 /*
3297 if (strat->P.lcm != NULL)
3298 pLmFree(strat->P.lcm);
3299 */
3300 red_result = 2;
3301 }
3303 {
3304 if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig)))
3305 {
3306 strat->P.p = pNeg(strat->P.p);
3307 strat->P.sig = pNeg(strat->P.sig);
3308 }
3309 strat->P.pLength = pLength(strat->P.p);
3310 if(strat->P.sig != NULL)
3311 strat->P.sevSig = pGetShortExpVector(strat->P.sig);
3312 if(strat->P.p != NULL)
3313 strat->P.sev = pGetShortExpVector(strat->P.p);
3314 }
3315 //sigdrop case
3316 if(rField_is_Ring(currRing) && strat->sigdrop)
3317 {
3318 //First reduce it as much as one can
3319 red_result = redRing(&strat->P,strat);
3320 if(red_result == 0)
3321 {
3322 strat->sigdrop = FALSE;
3323 pDelete(&strat->P.sig);
3324 strat->P.sig = NULL;
3325 }
3326 else
3327 {
3328 strat->enterS(&strat->P, 0, strat, strat->tl);
3329 if (TEST_OPT_PROT)
3330 PrintS("-");
3331 break;
3332 }
3333 }
3334 if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax)
3335 {
3336 strat->sigdrop = TRUE;
3337 break;
3338 }
3339
3340 if (errorreported) break;
3341
3342//#if 1
3343#ifdef DEBUGF5
3344 if (red_result != 0)
3345 {
3346 PrintS("Poly after red: ");
3347 pWrite(pHead(strat->P.p));
3348 pWrite(strat->P.GetLmCurrRing());
3349 pWrite(strat->P.sig);
3350 printf("%d\n",red_result);
3351 }
3352#endif
3353 if (TEST_OPT_PROT)
3354 {
3355 if(strat->P.p != NULL)
3356 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
3357 &olddeg,&reduc,strat, red_result);
3358 else
3359 message((strat->honey ? strat->P.ecart : 0),
3360 &olddeg,&reduc,strat, red_result);
3361 }
3362
3363 if (strat->overflow)
3364 {
3365 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
3366 }
3367 // reduction to non-zero new poly
3368 if (red_result == 1)
3369 {
3370 // get the polynomial (canonicalize bucket, make sure P.p is set)
3371 strat->P.GetP(strat->lmBin);
3372
3373 // sig-safe computations may lead to wrong FDeg computation, thus we need
3374 // to recompute it to make sure everything is alright
3375 (strat->P).FDeg = (strat->P).pFDeg();
3376 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
3377 // but now, for entering S, T, we reset it
3378 // in the inhomogeneous case: FDeg == pFDeg
3379 if (strat->homog) strat->initEcart(&(strat->P));
3380
3381 /* statistic */
3382 if (TEST_OPT_PROT) PrintS("s");
3383
3384 //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3385 // in F5E we know that the last reduced element is already the
3386 // the one with highest signature
3387 int pos = strat->sl+1;
3388
3389 // reduce the tail and normalize poly
3390 // in the ring case we cannot expect LC(f) = 1,
3391 poly beforetailred;
3393 beforetailred = pCopy(strat->P.sig);
3394#if SBA_TAIL_RED
3396 {
3398 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3399 }
3400 else
3401 {
3402 if (strat->sbaOrder != 2)
3403 {
3405 {
3406 strat->P.pCleardenom();
3408 {
3409 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3410 strat->P.pCleardenom();
3411 }
3412 }
3413 else
3414 {
3415 strat->P.pNorm();
3417 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3418 }
3419 }
3420 }
3421 // It may happen that we have lost the sig in redtailsba
3422 // It cannot reduce to 0 since here we are doing just tail reduction.
3423 // Best case scenario: remains the leading term
3424 if(rField_is_Ring(currRing) && strat->sigdrop)
3425 {
3426 strat->enterS(&strat->P, 0, strat, strat->tl);
3427 break;
3428 }
3429#endif
3431 {
3432 if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1)
3433 {
3434 strat->sigdrop = TRUE;
3435 //Reduce it as much as you can
3436 red_result = redRing(&strat->P,strat);
3437 if(red_result == 0)
3438 {
3439 //It reduced to 0, cancel the sigdrop
3440 strat->sigdrop = FALSE;
3441 p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL;
3442 }
3443 else
3444 {
3445 strat->enterS(&strat->P, 0, strat, strat->tl);
3446 break;
3447 }
3448 }
3449 p_Delete(&beforetailred,currRing);
3450 // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing
3451 if(strat->P.p == NULL)
3452 goto case_when_red_result_changed;
3453 }
3454 // remove sigsafe label since it is no longer valid for the next element to
3455 // be reduced
3456 if (strat->sbaOrder == 1)
3457 {
3458 for (int jj = 0; jj<strat->tl+1; jj++)
3459 {
3460 if (pGetComp(strat->T[jj].sig) == strat->currIdx)
3461 {
3462 strat->T[jj].is_sigsafe = FALSE;
3463 }
3464 }
3465 }
3466 else
3467 {
3468 for (int jj = 0; jj<strat->tl+1; jj++)
3469 {
3470 strat->T[jj].is_sigsafe = FALSE;
3471 }
3472 }
3473#ifdef KDEBUG
3474 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3475#endif /* KDEBUG */
3476
3477 // min_std stuff
3478 if ((strat->P.p1==NULL) && (strat->minim>0))
3479 {
3480 if (strat->minim==1)
3481 {
3482 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
3483 p_Delete(&strat->P.p2, currRing, strat->tailRing);
3484 }
3485 else
3486 {
3487 strat->M->m[minimcnt]=strat->P.p2;
3488 strat->P.p2=NULL;
3489 }
3490 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
3491 pNext(strat->M->m[minimcnt])
3492 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
3493 strat->tailRing, currRing,
3494 currRing->PolyBin);
3495 minimcnt++;
3496 }
3497
3498 // enter into S, L, and T
3499 //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3500 enterT(&strat->P, strat);
3501 strat->T[strat->tl].is_sigsafe = FALSE;
3502 /*
3503 printf("hier\n");
3504 pWrite(strat->P.GetLmCurrRing());
3505 pWrite(strat->P.sig);
3506 */
3508 superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3509 else
3510 enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3511 if(rField_is_Ring(currRing) && strat->sigdrop)
3512 break;
3514 strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing);
3515 strat->enterS(&strat->P, pos, strat, strat->tl);
3516 if(strat->sbaOrder != 1)
3517 {
3518 BOOLEAN overwrite = FALSE;
3519 for (int tk=0; tk<strat->sl+1; tk++)
3520 {
3521 if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))
3522 {
3523 //printf("TK %d / %d\n",tk,strat->sl);
3524 overwrite = FALSE;
3525 break;
3526 }
3527 }
3528 //printf("OVERWRITE %d\n",overwrite);
3529 if (overwrite)
3530 {
3531 int cmp = pGetComp(strat->P.sig);
3532 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3533 p_GetExpV (strat->P.p,vv,currRing);
3534 p_SetExpV (strat->P.sig, vv,currRing);
3535 p_SetComp (strat->P.sig,cmp,currRing);
3536
3537 strat->P.sevSig = pGetShortExpVector (strat->P.sig);
3538 int i;
3539 LObject Q;
3540 for(int ps=0;ps<strat->sl+1;ps++)
3541 {
3542
3543 strat->newt = TRUE;
3544 if (strat->syzl == strat->syzmax)
3545 {
3546 pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);
3547 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
3548 (strat->syzmax)*sizeof(unsigned long),
3549 ((strat->syzmax)+setmaxTinc)
3550 *sizeof(unsigned long));
3551 strat->syzmax += setmaxTinc;
3552 }
3553 Q.sig = pCopy(strat->P.sig);
3554 // add LM(F->m[i]) to the signature to get a Schreyer order
3555 // without changing the underlying polynomial ring at all
3556 if (strat->sbaOrder == 0)
3557 p_ExpVectorAdd (Q.sig,strat->S[ps],currRing);
3558 // since p_Add_q() destroys all input
3559 // data we need to recreate help
3560 // each time
3561 // ----------------------------------------------------------
3562 // in the Schreyer order we always know that the multiplied
3563 // module monomial strat->P.sig gives the leading monomial of
3564 // the corresponding principal syzygy
3565 // => we do not need to compute the "real" syzygy completely
3566 poly help = p_Copy(strat->sig[ps],currRing);
3567 p_ExpVectorAdd (help,strat->P.p,currRing);
3568 Q.sig = p_Add_q(Q.sig,help,currRing);
3569 //printf("%d. SYZ ",i+1);
3570 //pWrite(strat->syz[i]);
3571 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
3572 i = posInSyz(strat, Q.sig);
3573 enterSyz(Q, strat, i);
3574 }
3575 }
3576 }
3577 // deg - idx - lp/rp
3578 // => we need to add syzygies with indices > pGetComp(strat->P.sig)
3579 if(strat->sbaOrder == 0 || strat->sbaOrder == 3)
3580 {
3581 int cmp = pGetComp(strat->P.sig);
3582 unsigned max_cmp = IDELEMS(F);
3583 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3584 p_GetExpV (strat->P.p,vv,currRing);
3585 LObject Q;
3586 int pos;
3587 int idx = __p_GetComp(strat->P.sig,currRing);
3588 //printf("++ -- adding syzygies -- ++\n");
3589 // if new element is the first one in this index
3590 if (strat->currIdx < idx)
3591 {
3592 for (int i=0; i<strat->sl; ++i)
3593 {
3594 Q.sig = p_Copy(strat->P.sig,currRing);
3595 p_ExpVectorAdd(Q.sig,strat->S[i],currRing);
3596 poly help = p_Copy(strat->sig[i],currRing);
3597 p_ExpVectorAdd(help,strat->P.p,currRing);
3598 Q.sig = p_Add_q(Q.sig,help,currRing);
3599 //pWrite(Q.sig);
3600 pos = posInSyz(strat, Q.sig);
3601 enterSyz(Q, strat, pos);
3602 }
3603 strat->currIdx = idx;
3604 }
3605 else
3606 {
3607 // if the element is not the first one in the given index we build all
3608 // possible syzygies with elements of higher index
3609 for (unsigned i=cmp+1; i<=max_cmp; ++i)
3610 {
3611 pos = -1;
3612 for (int j=0; j<strat->sl; ++j)
3613 {
3614 if (__p_GetComp(strat->sig[j],currRing) == i)
3615 {
3616 pos = j;
3617 break;
3618 }
3619 }
3620 if (pos != -1)
3621 {
3622 Q.sig = p_One(currRing);
3623 p_SetExpV(Q.sig, vv, currRing);
3624 // F->m[i-1] corresponds to index i
3625 p_ExpVectorAdd(Q.sig,F->m[i-1],currRing);
3626 p_SetComp(Q.sig, i, currRing);
3627 poly help = p_Copy(strat->P.sig,currRing);
3628 p_ExpVectorAdd(help,strat->S[pos],currRing);
3629 Q.sig = p_Add_q(Q.sig,help,currRing);
3630 if (strat->sbaOrder == 0)
3631 {
3632 if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn)
3633 {
3634 pos = posInSyz(strat, Q.sig);
3635 enterSyz(Q, strat, pos);
3636 }
3637 }
3638 else
3639 {
3640 pos = posInSyz(strat, Q.sig);
3641 enterSyz(Q, strat, pos);
3642 }
3643 }
3644 }
3645 //printf("++ -- done adding syzygies -- ++\n");
3646 }
3647 }
3648//#if 1
3649#if DEBUGF50
3650 printf("---------------------------\n");
3651 Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);
3652 PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl]));
3653 PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]);
3654#endif
3655 /*
3656 if (newrules)
3657 {
3658 newrules = FALSE;
3659 }
3660 */
3661#if 0
3662 int pl=pLength(strat->P.p);
3663 if (pl==1)
3664 {
3665 //if (TEST_OPT_PROT)
3666 //PrintS("<1>");
3667 }
3668 else if (pl==2)
3669 {
3670 //if (TEST_OPT_PROT)
3671 //PrintS("<2>");
3672 }
3673#endif
3674 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
3675// Print("[%d]",hilbeledeg);
3676 kDeleteLcm(&strat->P);
3677 if (strat->sl>srmax) srmax = strat->sl;
3678 }
3679 else
3680 {
3681 case_when_red_result_changed:
3682 // adds signature of the zero reduction to
3683 // strat->syz. This is the leading term of
3684 // syzygy and can be used in syzCriterion()
3685 // the signature is added if and only if the
3686 // pair was not detected by the rewritten criterion in strat->red = redSig
3687 if (red_result!=2)
3688 {
3689#if SBA_PRINT_ZERO_REDUCTIONS
3690 zeroreductions++;
3691#endif
3692 if(rField_is_Ring(currRing) && strat->P.p == NULL && strat->P.sig == NULL)
3693 {
3694 //Catch the case when p = 0, sig = 0
3695 }
3696 else
3697 {
3698 int pos = posInSyz(strat, strat->P.sig);
3699 enterSyz(strat->P, strat, pos);
3700 //#if 1
3701 #ifdef DEBUGF5
3702 Print("ADDING STUFF TO SYZ : ");
3703 //pWrite(strat->P.p);
3704 pWrite(strat->P.sig);
3705 #endif
3706 }
3707 }
3708 if (strat->P.p1 == NULL && strat->minim > 0)
3709 {
3710 p_Delete(&strat->P.p2, currRing, strat->tailRing);
3711 }
3712 }
3713
3714#ifdef KDEBUG
3715 strat->P.Init();
3716#endif /* KDEBUG */
3717 kTest_TS(strat);
3718 }
3719 #if 0
3720 if(strat->sigdrop)
3721 printf("\nSigDrop!\n");
3722 else
3723 printf("\nEnded with no SigDrop\n");
3724 #endif
3725// Clean strat->P for the next sba call
3726 if(rField_is_Ring(currRing) && strat->sigdrop)
3727 {
3728 //This is used to know how many elements can we directly add to S in the next run
3729 if(strat->P.sig != NULL)
3730 strat->sbaEnterS = pGetComp(strat->P.sig)-1;
3731 //else we already set it at the beginning of the loop
3732 #ifdef KDEBUG
3733 strat->P.Init();
3734 #endif /* KDEBUG */
3735 }
3736#ifdef KDEBUG
3737 if (TEST_OPT_DEBUG) messageSets(strat);
3738#endif /* KDEBUG */
3739
3740 if (TEST_OPT_SB_1)
3741 {
3743 {
3744 int k=1;
3745 int j;
3746 while(k<=strat->sl)
3747 {
3748 j=0;
3749 loop
3750 {
3751 if (j>=k) break;
3752 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
3753 j++;
3754 }
3755 k++;
3756 }
3757 }
3758 }
3759 /* complete reduction of the standard basis--------- */
3760 if (TEST_OPT_REDSB)
3761 {
3762 completeReduce(strat);
3763 if (strat->completeReduce_retry)
3764 {
3765 // completeReduce needed larger exponents, retry
3766 // to reduce with S (instead of T)
3767 // and in currRing (instead of strat->tailRing)
3768#ifdef HAVE_TAIL_RING
3769 if(currRing->bitmask>strat->tailRing->bitmask)
3770 {
3772 cleanT(strat);strat->tailRing=currRing;
3773 int i;
3774 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3775 completeReduce(strat);
3776 }
3777 if (strat->completeReduce_retry)
3778#endif
3779 Werror("exponent bound is %ld",currRing->bitmask);
3780 }
3781 }
3782 else if (TEST_OPT_PROT) PrintLn();
3783
3784#if SBA_PRINT_SIZE_SYZ
3785 // that is correct, syzl is counting one too far
3786 size_syz = strat->syzl;
3787#endif
3788// if (TEST_OPT_WEIGHTM)
3789// {
3790// pRestoreDegProcs(pFDegOld, pLDegOld);
3791// if (ecartWeights)
3792// {
3793// omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
3794// ecartWeights=NULL;
3795// }
3796// }
3797 if (TEST_OPT_PROT) messageStatSBA(hilbcount,strat);
3798 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3799#if SBA_PRINT_SIZE_G
3800 size_g_non_red = IDELEMS(strat->Shdl);
3801#endif
3803 exitSba(strat);
3804 // I have to add the initial input polynomials which where not used (p1 and p2 = NULL)
3805 int k;
3807 {
3808 //for(k = strat->sl;k>=0;k--)
3809 // {printf("\nS[%i] = %p\n",k,strat->Shdl->m[k]);pWrite(strat->Shdl->m[k]);}
3810 k = strat->Ll;
3811 #if 1
3812 // 1 - adds just the unused ones, 0 - adds everything
3813 for(;k>=0 && (strat->L[k].p1 != NULL || strat->L[k].p2 != NULL);k--)
3814 {
3815 //printf("\nDeleted k = %i, %p\n",k,strat->L[k].p);pWrite(strat->L[k].p);pWrite(strat->L[k].p1);pWrite(strat->L[k].p2);
3816 deleteInL(strat->L,&strat->Ll,k,strat);
3817 }
3818 #endif
3819 //for(int kk = strat->sl;kk>=0;kk--)
3820 // {printf("\nS[%i] = %p\n",kk,strat->Shdl->m[kk]);pWrite(strat->Shdl->m[kk]);}
3821 //idPrint(strat->Shdl);
3822 //printf("\nk = %i\n",k);
3823 for(;k>=0 && strat->L[k].p1 == NULL && strat->L[k].p2 == NULL;k--)
3824 {
3825 //printf("\nAdded k = %i\n",k);
3826 strat->enterS(&strat->L[k], strat->sl+1, strat, strat->tl);
3827 //printf("\nThis elements was added from L on pos %i\n",strat->sl);pWrite(strat->S[strat->sl]);pWrite(strat->sig[strat->sl]);
3828 }
3829 }
3830 // Find the "sigdrop element" and put the same signature as the previous one - do we really need this?? - now i put it on the 0 position - no more comparing needed
3831 #if 0
3832 if(strat->sigdrop && rField_is_Ring(currRing))
3833 {
3834 for(k=strat->sl;k>=0;k--)
3835 {
3836 printf("\nsig[%i] = ",i);pWrite(strat->sig[k]);
3837 if(strat->sig[k] == NULL)
3838 strat->sig[k] = pCopy(strat->sig[k-1]);
3839 }
3840 }
3841 #endif
3842 //Never do this - you will damage S
3843 //idSkipZeroes(strat->Shdl);
3844 //idPrint(strat->Shdl);
3845
3846 if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld)
3847 {
3848 rChangeCurrRing (currRingOld);
3849 F0 = idrMoveR (F1, sRing, currRing);
3850 strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing);
3851 rChangeCurrRing (sRing);
3853 exitSba(strat);
3854 rChangeCurrRing (currRingOld);
3855 if(strat->tailRing == sRing)
3856 strat->tailRing = currRing;
3857 rDelete (sRing);
3858 }
3859 if(rField_is_Ring(currRing) && !strat->sigdrop)
3860 id_DelDiv(strat->Shdl, currRing);
3862 id_DelDiv(strat->Shdl, currRing);
3863 idSkipZeroes(strat->Shdl);
3864 idTest(strat->Shdl);
3865
3866#if SBA_PRINT_SIZE_G
3867 size_g = IDELEMS(strat->Shdl);
3868#endif
3869#ifdef DEBUGF5
3870 printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));
3871 int oo = 0;
3872 while (oo<IDELEMS(strat->Shdl))
3873 {
3874 printf(" %d. ",oo+1);
3875 pWrite(pHead(strat->Shdl->m[oo]));
3876 oo++;
3877 }
3878#endif
3879#if SBA_PRINT_ZERO_REDUCTIONS
3880 printf("----------------------------------------------------------\n");
3881 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3882 zeroreductions = 0;
3883#endif
3884#if SBA_PRINT_REDUCTION_STEPS
3885 printf("----------------------------------------------------------\n");
3886 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3887#endif
3888#if SBA_PRINT_OPERATIONS
3889 printf("OPERATIONS: %ld\n",sba_operations);
3890#endif
3891#if SBA_PRINT_REDUCTION_STEPS
3892 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3893 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3894#endif
3895#if SBA_PRINT_OPERATIONS
3896 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3897#endif
3898#if SBA_PRINT_REDUCTION_STEPS
3899 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3900 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3901 sba_interreduction_steps = 0;
3902 sba_reduction_steps = 0;
3903#endif
3904#if SBA_PRINT_OPERATIONS
3905 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3906 sba_interreduction_operations = 0;
3907 sba_operations = 0;
3908#endif
3909#if SBA_PRINT_SIZE_G
3910 printf("----------------------------------------------------------\n");
3911 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3912 size_g = 0;
3913 size_g_non_red = 0;
3914#endif
3915#if SBA_PRINT_SIZE_SYZ
3916 printf("SIZE OF SYZ: %ld\n",size_syz);
3917 printf("----------------------------------------------------------\n");
3918 size_syz = 0;
3919#endif
3920#if SBA_PRINT_PRODUCT_CRITERION
3921 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3922 product_criterion = 0;
3923#endif
3924 return (strat->Shdl);
3925}
static void sort(int **points, int sizePoints)
int blockredmax
Definition kutil.h:363
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:293
int sbaEnterS
Definition kutil.h:360
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:188
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3803
void initSba(ideal F, kStrategy strat)
Definition kstd1.cc:1750
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kstd2.cc:1785
void f5c(kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, bigintmat *hilb)
Definition kstd2.cc:4265
void initSbaPos(kStrategy strat)
Definition kutil.cc:9863
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4513
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4470
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
Definition kutil.cc:11064
void messageStatSBA(int hilbcount, kStrategy strat)
Definition kutil.cc:7517
void initSyzRules(kStrategy strat)
Definition kutil.cc:7933
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9936
void exitSba(kStrategy strat)
Definition kutil.cc:10011
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
Definition kutil.cc:4841
void initSbaCrit(kStrategy strat)
Definition kutil.cc:9498
#define help
Definition libparse.cc:1230
static void p_SetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1565
static void p_GetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1541
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:261
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
int F1(int a1, int &r1)
F1.

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject * h,
kStrategy strat )

Definition at line 1688 of file kutil.cc.

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

◆ sbaRing()

ring sbaRing ( kStrategy strat,
const ring r = currRing,
BOOLEAN complete = TRUE,
int sgn = 1 )

Definition at line 11064 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4457 of file kutil.cc.

4458{
4460#if HAVE_SHIFTBBA
4461 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4462#endif
4463 // enter also zero divisor * poly, if this is non zero and of smaller degree
4465 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4466 initenterpairs(h, k, ecart, 0, strat, atR);
4467 clearSbatch(h, k, pos, strat);
4468}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition kutil.cc:4433
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4152
void enterExtendedSpoly(poly h, kStrategy strat)
Definition kutil.cc:4232

◆ superenterpairsShift()

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

◆ superenterpairsSig()

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

Definition at line 4470 of file kutil.cc.

4471{
4473 // enter also zero divisor * poly, if this is non zero and of smaller degree
4474 if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4475 if(strat->sigdrop) return;
4476 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4477 if(strat->sigdrop) return;
4478 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4479 if(strat->sigdrop) return;
4480 clearSbatch(h, k, pos, strat);
4481}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3934
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4207
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition kutil.cc:4316

◆ syzCriterion()

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

Definition at line 6478 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6513 of file kutil.cc.

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

10052{
10053 int l;
10054 if (strat->ak>0)
10055 {
10056 for (l=IDELEMS(r)-1;l>=0;l--)
10057 {
10058 if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10059 {
10060 pDelete(&r->m[l]); // and set it to NULL
10061 }
10062 }
10063 int q;
10064 poly p;
10066 {
10067 for (l=IDELEMS(r)-1;l>=0;l--)
10068 {
10069 if ((r->m[l]!=NULL)
10070 //&& (strat->syzComp>0)
10071 //&& (pGetComp(r->m[l])<=strat->syzComp)
10072 )
10073 {
10074 for(q=IDELEMS(Q)-1; q>=0;q--)
10075 {
10076 if ((Q->m[q]!=NULL)
10077 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10078 {
10079 if (TEST_OPT_REDSB)
10080 {
10081 p=r->m[l];
10082 r->m[l]=kNF(Q,NULL,p);
10083 pDelete(&p);
10084 }
10085 else
10086 {
10087 pDelete(&r->m[l]); // and set it to NULL
10088 }
10089 break;
10090 }
10091 }
10092 }
10093 }
10094 }
10095 else
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(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10110 {
10111 if (TEST_OPT_REDSB)
10112 {
10113 p=r->m[l];
10114 r->m[l]=kNF(Q,NULL,p);
10115 pDelete(&p);
10116 }
10117 else
10118 {
10119 pDelete(&r->m[l]); // and set it to NULL
10120 }
10121 break;
10122 }
10123 }
10124 }
10125 }
10126 }
10127 }
10128 }
10129 else
10130 {
10131 int q;
10132 poly p;
10133 BOOLEAN reduction_found=FALSE;
10135 {
10136 for (l=IDELEMS(r)-1;l>=0;l--)
10137 {
10138 if (r->m[l]!=NULL)
10139 {
10140 for(q=IDELEMS(Q)-1; q>=0;q--)
10141 {
10142 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10143 {
10144 if (TEST_OPT_REDSB)
10145 {
10146 p=r->m[l];
10147 r->m[l]=kNF(Q,NULL,p);
10148 pDelete(&p);
10149 reduction_found=TRUE;
10150 }
10151 else
10152 {
10153 pDelete(&r->m[l]); // and set it to NULL
10154 }
10155 break;
10156 }
10157 }
10158 }
10159 }
10160 }
10161 //Also need divisibility of the leading coefficients
10162 else
10163 {
10164 for (l=IDELEMS(r)-1;l>=0;l--)
10165 {
10166 if (r->m[l]!=NULL)
10167 {
10168 for(q=IDELEMS(Q)-1; q>=0;q--)
10169 {
10170 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10171 {
10172 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(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 }
10192 if (/*TEST_OPT_REDSB &&*/ reduction_found)
10193 {
10195 {
10196 for (l=IDELEMS(r)-1;l>=0;l--)
10197 {
10198 if (r->m[l]!=NULL)
10199 {
10200 for(q=IDELEMS(r)-1;q>=0;q--)
10201 {
10202 if ((l!=q)
10203 && (r->m[q]!=NULL)
10204 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10205 &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10206 )
10207 {
10208 //If they are equal then take the one with the smallest length
10209 if(pLmDivisibleBy(r->m[q],r->m[l])
10210 && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10211 && (pLength(r->m[q]) < pLength(r->m[l]) ||
10212 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10213 {
10214 pDelete(&r->m[l]);
10215 break;
10216 }
10217 else
10218 pDelete(&r->m[q]);
10219 }
10220 }
10221 }
10222 }
10223 }
10224 else
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 )
10236 {
10237 //If they are equal then take the one with the smallest length
10238 if(pLmDivisibleBy(r->m[q],r->m[l])
10239 &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10240 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10241 {
10242 pDelete(&r->m[l]);
10243 break;
10244 }
10245 else
10246 pDelete(&r->m[q]);
10247 }
10248 }
10249 }
10250 }
10251 }
10252 }
10253 }
10254 idSkipZeroes(r);
10255}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3230

◆ updateS()

void updateS ( BOOLEAN toT,
kStrategy strat )

Definition at line 8557 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 67 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 270 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 182 of file kutil.h.