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   ((4096-12)/sizeof(LObject))
 
#define setmaxLinc   ((4096)/sizeof(LObject))
 
#define setmaxT   ((4096-12)/sizeof(TObject))
 
#define setmaxTinc   ((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)   (!(A)->no_prod_crit)
 

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 posInLF5C (const LSet set, const int length, LObject *L, const 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 *reduc, int *olddeg, kStrategy strat, int red_result)
 
void messageStat (int hilbcount, kStrategy strat)
 
void messageStatSBA (int hilbcount, kStrategy strat)
 
void messageSets (kStrategy strat)
 
void 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 replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
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, intvec **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_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)
 
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
 
ideal bba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, intvec *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, intvec *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, intvec *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
 
EXTERN_VAR int(* test_PosInT )(const TSet T, const int tl, LObject &h)
 
EXTERN_VAR int(* test_PosInL )(const LSet set, const int length, LObject *L, const kStrategy strat)
 

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 65 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

#define ALLOW_PROD_CRIT ( A)    (!(A)->no_prod_crit)

Definition at line 393 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 27 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 49 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 50 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 36 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 37 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 38 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 29 of file kutil.h.

◆ setmaxL

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

Definition at line 30 of file kutil.h.

◆ setmaxLinc

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

Definition at line 31 of file kutil.h.

◆ setmaxT

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

Definition at line 33 of file kutil.h.

◆ setmaxTinc

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

Definition at line 34 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 63 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 53 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 58 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 60 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 57 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 59 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 55 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 54 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6623 of file kutil.cc.

6624{
6626 return FALSE;
6627 poly p1 = pOne();
6628 poly p2 = pOne();
6629 for (int ii=strat->sl; ii>start; ii--)
6630 {
6631 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6632 {
6633 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6634 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6635 if (!(pLmCmp(p1,p2) == 1))
6636 {
6637 pDelete(&p1);
6638 pDelete(&p2);
6639 return TRUE;
6640 }
6641 }
6642 }
6643 pDelete(&p1);
6644 pDelete(&p2);
6645 return FALSE;
6646}
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
polyset S
Definition kutil.h:306
unsigned long * sevSig
Definition kutil.h:324
polyset sig
Definition kutil.h:308
LObject P
Definition kutil.h:302
int sl
Definition kutil.h:348
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1439
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1924
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:186
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:105
#define pOne()
Definition polys.h:315
#define rField_is_Ring(R)
Definition ring.h:490

◆ arriRewCriterionPre()

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

Definition at line 6648 of file kutil.cc.

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

◆ arriRewDummy()

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

Definition at line 1255 of file kInline.h.

1256{
1257 return FALSE;
1258}

◆ bba()

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

Definition at line 2609 of file kstd2.cc.

2610{
2611 int red_result = 1;
2612 int olddeg,reduc;
2613 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2614 BOOLEAN withT = FALSE;
2615 BITSET save;
2616 SI_SAVE_OPT1(save);
2617
2618 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2620 initBuchMoraPosRing(strat);
2621 else
2622 initBuchMoraPos(strat);
2623 initHilbCrit(F,Q,&hilb,strat);
2624 initBba(strat);
2625 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2626 /*Shdl=*/initBuchMora(F, Q,strat);
2627 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2628 reduc = olddeg = 0;
2629
2630#ifndef NO_BUCKETS
2632 strat->use_buckets = 1;
2633#endif
2634 // redtailBBa against T for inhomogeneous input
2635 if (!TEST_OPT_OLDSTD)
2636 withT = ! strat->homog;
2637
2638 // strat->posInT = posInT_pLength;
2639 kTest_TS(strat);
2640
2641#ifdef HAVE_TAIL_RING
2642 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2644#endif
2645 if (BVERBOSE(23))
2646 {
2647 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2648 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2649 kDebugPrint(strat);
2650 }
2651
2652
2653#ifdef KDEBUG
2654 //kDebugPrint(strat);
2655#endif
2656 /* compute------------------------------------------------------- */
2657 while (strat->Ll >= 0)
2658 {
2659 #ifdef KDEBUG
2660 if (TEST_OPT_DEBUG) messageSets(strat);
2661 #endif
2662 if (siCntrlc)
2663 {
2664 while (strat->Ll >= 0)
2665 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2666 strat->noClearS=TRUE;
2667 }
2669 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2670 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2671 {
2672 /*
2673 *stops computation if
2674 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2675 *a predefined number Kstd1_deg
2676 */
2677 while ((strat->Ll >= 0)
2678 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2679 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2680 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2681 )
2682 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2683 if (strat->Ll<0) break;
2684 else strat->noClearS=TRUE;
2685 }
2686 if (strat->Ll== 0) strat->interpt=TRUE;
2687 /* picks the last element from the lazyset L */
2688 strat->P = strat->L[strat->Ll];
2689 strat->Ll--;
2690
2691 if (pNext(strat->P.p) == strat->tail)
2692 {
2693 // deletes the short spoly
2695 pLmDelete(strat->P.p);
2696 else
2697 pLmFree(strat->P.p);
2698 strat->P.p = NULL;
2699 poly m1 = NULL, m2 = NULL;
2700
2701 // check that spoly creation is ok
2702 while (strat->tailRing != currRing &&
2703 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2704 {
2705 assume(m1 == NULL && m2 == NULL);
2706 // if not, change to a ring where exponents are at least
2707 // large enough
2708 if (!kStratChangeTailRing(strat))
2709 {
2710 WerrorS("OVERFLOW...");
2711 break;
2712 }
2713 }
2714 // create the real one
2715 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2716 strat->tailRing, m1, m2, strat->R);
2717 }
2718 else if (strat->P.p1 == NULL)
2719 {
2720 if (strat->minim > 0)
2721 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2722 // for input polys, prepare reduction
2723 strat->P.PrepareRed(strat->use_buckets);
2724 }
2725
2726 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2727 {
2728 red_result = 0;
2729 }
2730 else
2731 {
2732 if (TEST_OPT_PROT)
2733 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2734 &olddeg,&reduc,strat, red_result);
2735
2736 /* reduction of the element chosen from L */
2737 red_result = strat->red(&strat->P,strat);
2738 if (errorreported) break;
2739 }
2740
2741 if (strat->overflow)
2742 {
2743 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2744 }
2745
2746 // reduction to non-zero new poly
2747 if (red_result == 1)
2748 {
2749 // get the polynomial (canonicalize bucket, make sure P.p is set)
2750 strat->P.GetP(strat->lmBin);
2751 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2752 // but now, for entering S, T, we reset it
2753 // in the inhomogeneous case: FDeg == pFDeg
2754 if (strat->homog) strat->initEcart(&(strat->P));
2755
2756 /* statistic */
2757 if (TEST_OPT_PROT) PrintS("s");
2758
2759 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2760
2761 // reduce the tail and normalize poly
2762 // in the ring case we cannot expect LC(f) = 1,
2763 strat->redTailChange=FALSE;
2764
2765 /* if we are computing over Z we always want to try and cut down
2766 * the coefficients in the tail terms */
2768 {
2769 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2770 }
2771
2773 {
2774 strat->P.pCleardenom();
2776 {
2777 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2778 strat->P.pCleardenom();
2779 if (strat->redTailChange) { strat->P.t_p=NULL; }
2780 }
2781 }
2782 else
2783 {
2784 strat->P.pNorm();
2786 {
2787 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2788 if (strat->redTailChange) { strat->P.t_p=NULL; }
2789 }
2790 }
2791
2792#ifdef KDEBUG
2793 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2794#endif /* KDEBUG */
2795
2796 // min_std stuff
2797 if ((strat->P.p1==NULL) && (strat->minim>0))
2798 {
2799 if (strat->minim==1)
2800 {
2801 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2802 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2803 }
2804 else
2805 {
2806 strat->M->m[minimcnt]=strat->P.p2;
2807 strat->P.p2=NULL;
2808 }
2809 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2810 pNext(strat->M->m[minimcnt])
2811 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2812 strat->tailRing, currRing,
2813 currRing->PolyBin);
2814 minimcnt++;
2815 }
2816
2817 // enter into S, L, and T
2818 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2819 {
2820 strat->P.SetShortExpVector();
2821 enterT(strat->P, strat);
2823 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2824 else
2825 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2826 // posInS only depends on the leading term
2827 strat->enterS(strat->P, pos, strat, strat->tl);
2828#if 0
2829 int pl=pLength(strat->P.p);
2830 if (pl==1)
2831 {
2832 //if (TEST_OPT_PROT)
2833 //PrintS("<1>");
2834 }
2835 else if (pl==2)
2836 {
2837 //if (TEST_OPT_PROT)
2838 //PrintS("<2>");
2839 }
2840#endif
2841 }
2842 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2843// Print("[%d]",hilbeledeg);
2844 kDeleteLcm(&strat->P);
2845 if (strat->s_poly!=NULL)
2846 {
2847 // the only valid entries are: strat->P.p,
2848 // strat->tailRing (read-only, keep it)
2849 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2850 if (strat->s_poly(strat))
2851 {
2852 // we are called AFTER enterS, i.e. if we change P
2853 // we have to add it also to S/T
2854 // and add pairs
2855 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2856 enterT(strat->P, strat);
2858 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2859 else
2860 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2861 strat->enterS(strat->P, pos, strat, strat->tl);
2862 }
2863 }
2864 }
2865 else if (strat->P.p1 == NULL && strat->minim > 0)
2866 {
2867 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2868 }
2869
2870#ifdef KDEBUG
2871 strat->P.Init();
2872#endif /* KDEBUG */
2873 kTest_TS(strat);
2874 }
2875#ifdef KDEBUG
2876 if (TEST_OPT_DEBUG) messageSets(strat);
2877#endif /* KDEBUG */
2878
2879 if (TEST_OPT_SB_1)
2880 {
2882 {
2883 int k=1;
2884 int j;
2885 while(k<=strat->sl)
2886 {
2887 j=0;
2888 loop
2889 {
2890 if (j>=k) break;
2891 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2892 j++;
2893 }
2894 k++;
2895 }
2896 }
2897 }
2898 /* complete reduction of the standard basis--------- */
2899 if (TEST_OPT_REDSB)
2900 {
2901 completeReduce(strat);
2902 if (strat->completeReduce_retry)
2903 {
2904 // completeReduce needed larger exponents, retry
2905 // to reduce with S (instead of T)
2906 // and in currRing (instead of strat->tailRing)
2907#ifdef HAVE_TAIL_RING
2908 if(currRing->bitmask>strat->tailRing->bitmask)
2909 {
2911 cleanT(strat);strat->tailRing=currRing;
2912 int i;
2913 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2914 completeReduce(strat);
2915 }
2916 if (strat->completeReduce_retry)
2917#endif
2918 Werror("exponent bound is %ld",currRing->bitmask);
2919 }
2920 }
2921 else if (TEST_OPT_PROT) PrintLn();
2922 /* release temp data-------------------------------- */
2923 exitBuchMora(strat);
2924 /* postprocessing for GB over ZZ --------------------*/
2925 if (!errorreported)
2926 {
2928 {
2929 for(int i = 0;i<=strat->sl;i++)
2930 {
2931 if(!nGreaterZero(pGetCoeff(strat->S[i])))
2932 {
2933 strat->S[i] = pNeg(strat->S[i]);
2934 }
2935 }
2936 finalReduceByMon(strat);
2937 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2938 {
2939 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2940 {
2941 strat->S[i] = pNeg(strat->Shdl->m[i]);
2942 }
2943 }
2944 }
2945 //else if (rField_is_Ring(currRing))
2946 // finalReduceByMon(strat);
2947 }
2948// if (TEST_OPT_WEIGHTM)
2949// {
2950// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2951// if (ecartWeights)
2952// {
2953// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2954// ecartWeights=NULL;
2955// }
2956// }
2957 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
2958 SI_RESTORE_OPT1(save);
2959 /* postprocessing for GB over Q-rings ------------------*/
2960 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2961
2962 idTest(strat->Shdl);
2963
2964 return (strat->Shdl);
2965}
int BOOLEAN
Definition auxiliary.h:87
int k
Definition cfEzgcd.cc:99
int syzComp
Definition kutil.h:354
int * S_2_R
Definition kutil.h:342
ring tailRing
Definition kutil.h:343
int Ll
Definition kutil.h:351
omBin lmBin
Definition kutil.h:344
char honey
Definition kutil.h:375
int minim
Definition kutil.h:357
TObject ** R
Definition kutil.h:340
ideal M
Definition kutil.h:305
int tl
Definition kutil.h:350
poly tail
Definition kutil.h:334
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:284
ideal Shdl
Definition kutil.h:303
pShallowCopyDeleteProc p_shallow_copy_delete
Definition kutil.h:338
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:286
char use_buckets
Definition kutil.h:381
char interpt
Definition kutil.h:369
char redTailChange
Definition kutil.h:397
char completeReduce_retry
Definition kutil.h:401
void(* initEcart)(TObject *L)
Definition kutil.h:280
char noClearS
Definition kutil.h:400
char overflow
Definition kutil.h:402
LSet L
Definition kutil.h:327
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:281
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:278
unsigned long * sevS
Definition kutil.h:322
char homog
Definition kutil.h:370
s_poly_proc_t s_poly
Definition kutil.h:300
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:1209
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition kInline.h:1232
void khCheck(ideal Q, intvec *w, intvec *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:1204
void initBba(kStrategy strat)
Definition kstd1.cc:1685
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:50
VAR int(* test_PosInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kstd2.cc:83
void kDebugPrint(kStrategy strat)
Definition kutil.cc:11496
VAR int(* test_PosInT)(const TSet T, const int tl, LObject &h)
Definition kstd2.cc:82
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition kutil.cc:7465
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9748
void enterT(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9140
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1071
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4492
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:7142
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
Definition kutil.cc:9414
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9577
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10957
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9833
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4668
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10476
void cleanT(kStrategy strat)
Definition kutil.cc:563
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10076
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4462
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11050
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9432
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10282
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9662
void messageSets(kStrategy strat)
Definition kutil.cc:7538
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7506
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10865
static void kDeleteLcm(LObject *P)
Definition kutil.h:868
#define assume(x)
Definition mod2.h:387
#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:129
#define TEST_OPT_INTSTRATEGY
Definition options.h:110
#define BVERBOSE(a)
Definition options.h:35
#define TEST_OPT_REDTAIL
Definition options.h:116
#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:123
#define TEST_OPT_REDSB
Definition options.h:104
#define TEST_OPT_DEGBOUND
Definition options.h:113
#define TEST_OPT_SB_1
Definition options.h:119
#define TEST_OPT_PROT
Definition options.h:103
#define TEST_OPT_DEBUG
Definition options.h:108
#define TEST_OPT_CONTENTSB
Definition options.h:127
#define TEST_OPT_NOT_BUCKETS
Definition options.h:105
static int pLength(poly a)
Definition p_polys.h:190
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:901
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:846
#define pNeg(p)
Definition polys.h:198
#define pGetComp(p)
Component.
Definition polys.h:37
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:76
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:70
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310
void Werror(const char *fmt,...)
Definition reporter.cc:189
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:514
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:767
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define IDELEMS(i)
#define Q
Definition sirandom.c:26
#define BITSET
Definition structs.h:16
#define loop
Definition structs.h:75

◆ bbaShift()

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

Definition at line 4574 of file kstd2.cc.

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

◆ cancelunit()

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

Definition at line 370 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3209 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly ,
int ,
kStrategy strat )

Definition at line 3450 of file kutil.cc.

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

◆ chainCritSig()

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

Definition at line 3466 of file kutil.cc.

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

◆ cleanT()

void cleanT ( kStrategy strat)

Definition at line 563 of file kutil.cc.

564{
565 int i,j;
566 poly p;
567 assume(currRing == strat->tailRing || strat->tailRing != NULL);
568
569 pShallowCopyDeleteProc p_shallow_copy_delete =
570 (strat->tailRing != currRing ?
572 NULL);
573 for (j=0; j<=strat->tl; j++)
574 {
575 p = strat->T[j].p;
576 strat->T[j].p=NULL;
577 if (strat->T[j].max_exp != NULL)
578 {
579 p_LmFree(strat->T[j].max_exp, strat->tailRing);
580 }
581 i = -1;
582 loop
583 {
584 i++;
585 if (i>strat->sl)
586 {
587 if (strat->T[j].t_p != NULL)
588 {
589 p_Delete(&(strat->T[j].t_p), strat->tailRing);
591 }
592 else
593 {
594#ifdef HAVE_SHIFTBBA
595 if (currRing->isLPring && strat->T[j].shift > 0)
596 {
597 pNext(p) = NULL; // pNext(p) points to the unshifted tail, don't try to delete it here
598 }
599#endif
600 pDelete(&p);
601 }
602 break;
603 }
604 if (p == strat->S[i])
605 {
606 if (strat->T[j].t_p != NULL)
607 {
608 if (p_shallow_copy_delete!=NULL)
609 {
610 pNext(p) = p_shallow_copy_delete(pNext(p),strat->tailRing,currRing,
611 currRing->PolyBin);
612 }
613 p_LmFree(strat->T[j].t_p, strat->tailRing);
614 }
615 break;
616 }
617 }
618 }
619 strat->tl=-1;
620}
pShallowCopyDeleteProc pGetShallowCopyDeleteProc(ring, ring)
static void p_LmFree(poly p, ring)
Definition p_polys.h:683
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:44

◆ clearS()

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

Definition at line 1232 of file kInline.h.

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

◆ completeReduce()

void completeReduce ( kStrategy strat,
BOOLEAN withT = FALSE )

Definition at line 10282 of file kutil.cc.

10283{
10284 int i;
10285 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10286 LObject L;
10287
10288#ifdef KDEBUG
10289 // need to set this: during tailreductions of T[i], T[i].max is out of
10290 // sync
10291 sloppy_max = TRUE;
10292#endif
10293
10294 strat->noTailReduction = FALSE;
10295 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10296 if (TEST_OPT_PROT)
10297 {
10298 PrintLn();
10299// if (timerv) writeTime("standard base computed:");
10300 }
10301 if (TEST_OPT_PROT)
10302 {
10303 Print("(S:%d)",strat->sl);mflush();
10304 }
10305 for (i=strat->sl; i>=low; i--)
10306 {
10307 int end_pos=strat->sl;
10308 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10309 if (strat->ak==0) end_pos=i-1;
10310 TObject* T_j = strat->s_2_t(i);
10311 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10312 {
10313 L = *T_j;
10314 #ifdef KDEBUG
10315 if (TEST_OPT_DEBUG)
10316 {
10317 Print("test S[%d]:",i);
10318 p_wrp(L.p,currRing,strat->tailRing);
10319 PrintLn();
10320 }
10321 #endif
10323 strat->S[i] = redtailBba(&L, end_pos, strat, withT,FALSE /*no normalize*/);
10324 else
10325 strat->S[i] = redtail(&L, strat->sl, strat);
10326 #ifdef KDEBUG
10327 if (TEST_OPT_DEBUG)
10328 {
10329 Print("to (tailR) S[%d]:",i);
10330 p_wrp(strat->S[i],currRing,strat->tailRing);
10331 PrintLn();
10332 }
10333 #endif
10334
10335 if (strat->redTailChange)
10336 {
10337 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10338 if (pNext(T_j->p) != NULL)
10339 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10340 else
10341 T_j->max_exp = NULL;
10342 }
10344 T_j->pCleardenom();
10345 }
10346 else
10347 {
10348 assume(currRing == strat->tailRing);
10349 #ifdef KDEBUG
10350 if (TEST_OPT_DEBUG)
10351 {
10352 Print("test S[%d]:",i);
10353 p_wrp(strat->S[i],currRing,strat->tailRing);
10354 PrintLn();
10355 }
10356 #endif
10358 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10359 else
10360 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10362 {
10364 {
10365 number n;
10366 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10367 if (!nIsOne(n))
10368 {
10370 denom->n=nInvers(n);
10371 denom->next=DENOMINATOR_LIST;
10372 DENOMINATOR_LIST=denom;
10373 }
10374 nDelete(&n);
10375 }
10376 else
10377 {
10378 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10379 }
10380 }
10381 #ifdef KDEBUG
10382 if (TEST_OPT_DEBUG)
10383 {
10384 Print("to (-tailR) S[%d]:",i);
10385 p_wrp(strat->S[i],currRing,strat->tailRing);
10386 PrintLn();
10387 }
10388 #endif
10389 }
10390 if (TEST_OPT_PROT)
10391 PrintS("-");
10392 }
10393 if (TEST_OPT_PROT) PrintLn();
10394#ifdef KDEBUG
10395 sloppy_max = FALSE;
10396#endif
10397}
char noTailReduction
Definition kutil.h:376
int ak
Definition kutil.h:353
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:6838
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kutil.cc:6914
STATIC_VAR BOOLEAN sloppy_max
Definition kutil.cc:798
VAR denominator_list DENOMINATOR_LIST
Definition kutil.cc:84
denominator_list_s * denominator_list
Definition kutil.h:63
denominator_list next
Definition kutil.h:65
class sTObject TObject
Definition kutil.h:57
class sLObject LObject
Definition kutil.h:58
#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:2958
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
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 291 of file kutil.cc.

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

◆ deleteHC() [2/2]

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

Definition at line 356 of file kutil.cc.

357{
358 LObject L(*p, currRing, strat->tailRing);
359
360 deleteHC(&L, strat);
361 *p = L.p;
362 *e = L.ecart;
363 *l = L.length;
364 if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
365}
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition kutil.cc:291

◆ deleteInL()

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

Definition at line 1213 of file kutil.cc.

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

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly h,
kStrategy strat )

Definition at line 4237 of file kutil.cc.

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

◆ enterExtendedSpolySig()

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

Definition at line 4321 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1274 of file kutil.cc.

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

◆ enterOnePairNormal()

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

Definition at line 1944 of file kutil.cc.

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

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

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

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

◆ enterpairsShift()

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

Definition at line 12944 of file kutil.cc.

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

◆ enterpairsSig()

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

Definition at line 4518 of file kutil.cc.

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

◆ enterSBba()

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

Definition at line 8791 of file kutil.cc.

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

◆ enterSBbaShift()

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

Definition at line 8891 of file kutil.cc.

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

◆ enterSSba()

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

Definition at line 8914 of file kutil.cc.

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

◆ enterSyz()

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

Definition at line 9340 of file kutil.cc.

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

◆ enterT()

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

Definition at line 9140 of file kutil.cc.

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

◆ enterT_strong()

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

Definition at line 9239 of file kutil.cc.

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

◆ enterTShift()

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

Definition at line 12974 of file kutil.cc.

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

◆ exitBuchMora()

void exitBuchMora ( kStrategy strat)

Definition at line 9833 of file kutil.cc.

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

◆ exitSba()

void exitSba ( kStrategy strat)

Definition at line 10036 of file kutil.cc.

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

◆ f5c()

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

Definition at line 4262 of file kstd2.cc.

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

◆ faugereRewCriterion()

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

Definition at line 6564 of file kutil.cc.

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

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

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

499{
500 int j,p;
501
502 if (currRing->pLexOrder
504 || (strat->ak >1)
506 {
507 return;
508 }
510 if (p!=0)
511 strat->NotUsedAxis[p] = FALSE;
512 else return; /*nothing new*/
513 /*- the leading term of pp is a power of the p-th variable -*/
514 for (j=(currRing->N);j>0; j--)
515 {
516 if (strat->NotUsedAxis[j])
517 {
518 strat->kAllAxis=FALSE;
519 return;
520 }
521 }
522 strat->kAllAxis=TRUE;
523}
BOOLEAN * NotUsedAxis
Definition kutil.h:332
char kAllAxis
Definition kutil.h:374
#define pIsPurePower(p)
Definition polys.h:248
BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:768

◆ homogTest()

BOOLEAN homogTest ( polyset F,
int Fmax )

◆ initBba()

void initBba ( kStrategy strat)

Definition at line 1685 of file kstd1.cc.

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

◆ initBuchMora()

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

Definition at line 9748 of file kutil.cc.

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

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy strat)

Definition at line 9432 of file kutil.cc.

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

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy strat)

Definition at line 9577 of file kutil.cc.

9578{
9580 {
9581 if (strat->honey)
9582 {
9583 strat->posInL = posInL15;
9584 // ok -- here is the deal: from my experiments for Singular-2-0
9585 // I conclude that that posInT_EcartpLength is the best of
9586 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9587 // see the table at the end of this file
9588 if (TEST_OPT_OLDSTD)
9589 strat->posInT = posInT15;
9590 else
9591 strat->posInT = posInT_EcartpLength;
9592 }
9593 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9594 {
9595 strat->posInL = posInL11;
9596 strat->posInT = posInT11;
9597 }
9598 else if (TEST_OPT_INTSTRATEGY)
9599 {
9600 strat->posInL = posInL11;
9601 strat->posInT = posInT11;
9602 }
9603 else
9604 {
9605 strat->posInL = posInL0;
9606 strat->posInT = posInT0;
9607 }
9608 //if (strat->minim>0) strat->posInL =posInLSpecial;
9609 if (strat->homog)
9610 {
9611 strat->posInL = posInL110;
9612 strat->posInT = posInT110;
9613 }
9614 }
9615 else /* local/mixed ordering */
9616 {
9617 if (strat->homog)
9618 {
9619 strat->posInL = posInL11;
9620 strat->posInT = posInT11;
9621 }
9622 else
9623 {
9624 if ((currRing->order[0]==ringorder_c)
9625 ||(currRing->order[0]==ringorder_C))
9626 {
9627 strat->posInL = posInL17_c;
9628 strat->posInT = posInT17_c;
9629 }
9630 else
9631 {
9632 strat->posInL = posInL17;
9633 strat->posInT = posInT17;
9634 }
9635 }
9636 }
9637 if (strat->minim>0) strat->posInL =posInLSpecial;
9638 // for further tests only
9639 if ((BTEST1(11)) || (BTEST1(12)))
9640 strat->posInL = posInL11;
9641 else if ((BTEST1(13)) || (BTEST1(14)))
9642 strat->posInL = posInL13;
9643 else if ((BTEST1(15)) || (BTEST1(16)))
9644 strat->posInL = posInL15;
9645 else if ((BTEST1(17)) || (BTEST1(18)))
9646 strat->posInL = posInL17;
9647 if (BTEST1(11))
9648 strat->posInT = posInT11;
9649 else if (BTEST1(13))
9650 strat->posInT = posInT13;
9651 else if (BTEST1(15))
9652 strat->posInT = posInT15;
9653 else if ((BTEST1(17)))
9654 strat->posInT = posInT17;
9655 else if ((BTEST1(19)))
9656 strat->posInT = posInT19;
9657 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9658 strat->posInT = posInT1;
9660}
char posInLDependsOnLength
Definition kutil.h:387
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6060
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5283
int posInT11(const TSet set, const int length, LObject &p)
Definition kutil.cc:4958
int posInT1(const TSet set, const int length, LObject &p)
Definition kutil.cc:4901
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:5151
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4890
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6147
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition kutil.cc:9564
int posInT13(const TSet set, const int length, LObject &p)
Definition kutil.cc:5122
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5616
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6182
int posInT17_c(const TSet set, const int length, LObject &p)
Definition kutil.cc:5389
int posInT15(const TSet set, const int length, LObject &p)
Definition kutil.cc:5189
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5572
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6257
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5034
int posInT19(const TSet set, const int length, LObject &p)
Definition kutil.cc:5515
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6350
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5804
@ ringorder_C
Definition ring.h:73
@ ringorder_c
Definition ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy strat)

Definition at line 9662 of file kutil.cc.

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

◆ initEcartBBA()

void initEcartBBA ( TObject * h)

Definition at line 1306 of file kutil.cc.

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

◆ initEcartNormal()

void initEcartNormal ( TObject * h)

Definition at line 1298 of file kutil.cc.

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

◆ initEcartPairBba()

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

Definition at line 1313 of file kutil.cc.

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

◆ initEcartPairMora()

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

Definition at line 1320 of file kutil.cc.

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

◆ initenterpairs()

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

Definition at line 3814 of file kutil.cc.

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

◆ initHilbCrit()

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

Definition at line 9414 of file kutil.cc.

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

◆ initL()

static LSet initL ( int nr = setmaxL)
inlinestatic

Definition at line 418 of file kutil.h.

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

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

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

◆ initSba()

void initSba ( ideal F,
kStrategy strat )

Definition at line 1745 of file kstd1.cc.

1746{
1747 int i;
1748 //idhdl h;
1749 /* setting global variables ------------------- */
1750 strat->enterS = enterSSba;
1751 strat->red2 = redHoney;
1752 if (strat->honey)
1753 strat->red2 = redHoney;
1754 else if (currRing->pLexOrder && !strat->homog)
1755 strat->red2 = redLazy;
1756 else
1757 {
1758 strat->LazyPass *=4;
1759 strat->red2 = redHomog;
1760 }
1762 {
1764 {strat->red2 = redRiloc;}
1765 else
1766 {strat->red2 = redRing;}
1767 }
1768 if (currRing->pLexOrder && strat->honey)
1769 strat->initEcart = initEcartNormal;
1770 else
1771 strat->initEcart = initEcartBBA;
1772 if (strat->honey)
1774 else
1776 //strat->kIdeal = NULL;
1777 //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1778 //else strat->kIdeal->rtyp=MODUL_CMD;
1779 //strat->kIdeal->data=(void *)strat->Shdl;
1780 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1781 {
1782 //interred machen Aenderung
1783 strat->pOrigFDeg = currRing->pFDeg;
1784 strat->pOrigLDeg = currRing->pLDeg;
1785 //h=ggetid("ecart");
1786 //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1787 //{
1788 // ecartWeights=iv2array(IDINTVEC(h));
1789 //}
1790 //else
1791 {
1792 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1793 /*uses automatic computation of the ecartWeights to set them*/
1795 }
1797 if (TEST_OPT_PROT)
1798 {
1799 for(i=1; i<=(currRing->N); i++)
1800 Print(" %d",ecartWeights[i]);
1801 PrintLn();
1802 mflush();
1803 }
1804 }
1805 // for sig-safe reductions in signature-based
1806 // standard basis computations
1808 strat->red = redSigRing;
1809 else
1810 strat->red = redSig;
1811 //strat->sbaOrder = 1;
1812 strat->currIdx = 1;
1813}
pFDegProc pOrigFDeg
Definition kutil.h:296
pLDegProc pOrigLDeg
Definition kutil.h:297
int redRiloc(LObject *h, kStrategy strat)
Definition kstd1.cc:386
int redSigRing(LObject *h, kStrategy strat)
Definition kstd2.cc:1493
int redSig(LObject *h, kStrategy strat)
Definition kstd2.cc:1326
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8914
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3670
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 9961 of file kutil.cc.

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

◆ initSbaCrit()

void initSbaCrit ( kStrategy strat)

Definition at line 9495 of file kutil.cc.

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

◆ initSbaPos()

void initSbaPos ( kStrategy strat)

Definition at line 9859 of file kutil.cc.

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

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

7682{
7683 int i,pos;
7684
7685 if (Q!=NULL)
7686 {
7688 if (i<setmaxTinc) i=setmaxT;
7689 }
7690 else i=setmaxT;
7691 strat->ecartS=initec(i);
7692 strat->sevS=initsevS(i);
7693 strat->S_2_R=initS_2_R(i);
7694 strat->fromQ=NULL;
7695 strat->Shdl=idInit(i,F->rank);
7696 strat->S=strat->Shdl->m;
7697 /*- put polys into S -*/
7698 if (Q!=NULL)
7699 {
7700 strat->fromQ=initec(i);
7701 memset(strat->fromQ,0,i*sizeof(int));
7702 for (i=0; i<IDELEMS(Q); i++)
7703 {
7704 if (Q->m[i]!=NULL)
7705 {
7706 LObject h;
7707 h.p = pCopy(Q->m[i]);
7709 {
7710 deleteHC(&h,strat);
7711 }
7713 {
7714 h.pCleardenom(); // also does remove Content
7715 }
7716 else
7717 {
7718 h.pNorm();
7719 }
7720 if (h.p!=NULL)
7721 {
7722 strat->initEcart(&h);
7723 if (strat->sl==-1)
7724 pos =0;
7725 else
7726 {
7727 pos = posInS(strat,strat->sl,h.p,h.ecart);
7728 }
7729 h.sev = pGetShortExpVector(h.p);
7730 strat->enterS(h,pos,strat,-1);
7731 strat->fromQ[pos]=1;
7732 }
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 strat->initEcart(&h);
7760 if (strat->Ll==-1)
7761 pos =0;
7762 else
7763 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
7764 h.sev = pGetShortExpVector(h.p);
7765 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7766 }
7767 }
7768 }
7769 }
7770 /*- test, if a unit is in F -*/
7771
7772 if ((strat->Ll>=0)
7773 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7774 && pIsConstant(strat->L[strat->Ll].p))
7775 {
7776 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7777 }
7778}

◆ initSLSba()

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

Definition at line 7780 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy strat)

Definition at line 7932 of file kutil.cc.

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

◆ 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:59

◆ 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 1015 of file kInline.h.

1017{
1018 p_LmCheckPolyRing(p1, p_r);
1019 p_LmCheckPolyRing(p2, p_r);
1020
1021 int i;
1022 long x;
1023 m1 = p_Init(m_r,m_r->PolyBin);
1024 m2 = p_Init(m_r,m_r->PolyBin);
1025
1026 for (i = p_r->N; i; i--)
1027 {
1028 x = p_GetExpDiff(p1, p2, i, p_r);
1029 if (x > 0)
1030 {
1031 if (x > (long) m_r->bitmask) goto false_return;
1032 p_SetExp(m2,i,x, m_r);
1033 p_SetExp(m1,i,0, m_r);
1034 }
1035 else
1036 {
1037 if (-x > (long) m_r->bitmask) goto false_return;
1038 p_SetExp(m1,i,-x, m_r);
1039 p_SetExp(m2,i,0, m_r);
1040 }
1041 }
1042
1043 p_Setm(m1, m_r);
1044 p_Setm(m2, m_r);
1045 return TRUE;
1046
1047 false_return:
1048 p_LmFree(m1, m_r);
1049 p_LmFree(m2, m_r);
1050 m1 = m2 = NULL;
1051 return FALSE;
1052}
Variable x
Definition cfModGcd.cc:4090
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition p_polys.h:635
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:488
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1334

◆ 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 1057 of file kInline.h.

1059{
1060 p_LmCheckPolyRing(p1, leadRing);
1061 p_LmCheckPolyRing(p2, leadRing);
1062
1063 int i;
1064 int x;
1065 int e1;
1066 int e2;
1067 int s;
1068 m1 = p_Init(tailRing,tailRing->PolyBin);
1069 m2 = p_Init(tailRing,tailRing->PolyBin);
1070 lcm = p_Init(leadRing,leadRing->PolyBin);
1071
1072 for (i = leadRing->N; i>=0; i--)
1073 {
1074 e1 = p_GetExp(p1,i,leadRing);
1075 e2 = p_GetExp(p2,i,leadRing);
1076 x = e1 - e2;
1077 if (x > 0)
1078 {
1079 p_SetExp(m2,i,x, tailRing);
1080 //p_SetExp(m1,i,0, tailRing); // done by p_Init
1081 s = e1;
1082 }
1083 else if (x<0)
1084 {
1085 p_SetExp(m1,i,-x, tailRing);
1086 //p_SetExp(m2,i,0, tailRing); // done by p_Init
1087 s = e2;
1088 }
1089 else
1090 s = e1; // e1==e2
1091 p_SetExp(lcm,i,s, leadRing);
1092 }
1093
1094 p_Setm(m1, tailRing);
1095 p_Setm(m2, tailRing);
1096 p_Setm(lcm, leadRing);
1097}
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 988 of file kInline.h.

989{
990 return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
991}

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 956 of file kInline.h.

957{
958
959 poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
960 pNext(t_p) = pNext(p);
961 pSetCoeff0(t_p, pGetCoeff(p));
962 return t_p;
963}
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1349

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly p,
ring tailRing )

Definition at line 993 of file kInline.h.

994{
995 return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
996}
KINLINE poly k_LmInit_tailRing_2_currRing(poly t_p, ring tailRing, omBin lmBin)
Definition kInline.h:965

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 965 of file kInline.h.

966{
967 poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
968 pNext(p) = pNext(t_p);
969 pSetCoeff0(p, pGetCoeff(t_p));
970 return p;
971}

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly p,
ring tailRing )

Definition at line 998 of file kInline.h.

999{
1000 return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
1001}
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:974

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 974 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly p,
ring tailRing )

Definition at line 1003 of file kInline.h.

1004{
1005 return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
1006}
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition kInline.h:981

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 981 of file kInline.h.

982{
983 poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
984 p_LmFree(p, tailRing);
985 return np;
986}

◆ kCheckSpolyCreation()

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

Definition at line 10476 of file kutil.cc.

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

◆ kCheckStrongCreation()

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

Definition at line 10514 of file kutil.cc.

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

◆ kDebugPrint()

void kDebugPrint ( kStrategy strat)

Output some debug info about a given strategy.

Definition at line 11496 of file kutil.cc.

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

◆ kDeleteLcm()

static void kDeleteLcm ( LObject * P)
inlinestatic

Definition at line 868 of file kutil.h.

869{
870 if (P->lcm!=NULL)
871 {
873 pLmDelete(P->lcm);
874 else
875 pLmFree(P->lcm);
876 P->lcm=NULL;
877 }
878}

◆ 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 421 of file kstd2.cc.

422{
423 unsigned long not_sev = ~L->sev;
424 poly p = L->GetLmCurrRing();
425 int j = 0;
426
427 pAssume(~not_sev == p_GetShortExpVector(p, currRing));
428
430#if 1
431 int ende;
432 if (is_Ring
433 || (strat->ak>0)
434 || currRing->pLexOrder)
435 ende=strat->sl;
436 else
437 {
438 ende=posInS(strat,*max_ind,p,0)+1;
439 if (ende>(*max_ind)) ende=(*max_ind);
440 }
441#else
442 int ende=strat->sl;
443#endif
444 if(is_Ring)
445 {
446 loop
447 {
448 if (j > ende) return -1;
449#if defined(PDEBUG) || defined(PDIV_DEBUG)
450 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
451 p, not_sev, currRing))
452#else
453 if ( !(strat->sevS[j] & not_sev) &&
454 p_LmDivisibleBy(strat->S[j], p, currRing))
455#endif
456 {
457 if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
458 return j;
459 }
460 j++;
461 }
462 }
463 else
464 {
465 loop
466 {
467 if (j > ende) return -1;
468#if defined(PDEBUG) || defined(PDIV_DEBUG)
469 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
470 p, not_sev, currRing))
471#else
472 if ( !(strat->sevS[j] & not_sev) &&
473 p_LmDivisibleBy(strat->S[j], p, currRing))
474#endif
475 {
476 return j;
477 }
478 j++;
479 }
480 }
481}
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1905

◆ kFindDivisibleByInS_T()

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

Definition at line 6699 of file kutil.cc.

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

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

◆ kFindDivisibleByInT_Z()

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

Definition at line 213 of file kstd2.cc.

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

◆ kFindInL1()

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

Definition at line 839 of file kutil.h.

840{
841 for(int i=strat->Ll;i>=0;i--)
842 {
843 if (p==strat->L[i].p1) return i;
844 }
845 return -1;
846}

◆ kFindInT()

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

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

Definition at line 716 of file kutil.cc.

717{
718 int i;
719
720 for (i=0; i<=tlength; i++)
721 {
722 if (T[i].p == p) return i;
723 }
724 return -1;
725}

◆ kFindInTShift()

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

Definition at line 741 of file kutil.cc.

742{
743 int i;
744
745 for (i=0; i<=tlength; i++)
746 {
747 // in the Letterplace ring the LMs in T and L are copies thus we have to use pEqualPolys() instead of ==
748 if (pEqualPolys(T[i].p, p)) return i;
749 }
750 return -1;
751}
#define pEqualPolys(p1, p2)
Definition polys.h:399

◆ kFindNextDivisibleByInS()

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

Definition at line 524 of file kstd2.cc.

525{
526 unsigned long not_sev = ~L->sev;
527 poly p = L->GetLmCurrRing();
528 int j = start;
529
530 pAssume(~not_sev == p_GetShortExpVector(p, currRing));
531#if 1
532 int ende=max_ind;
533#else
534 int ende=strat->sl;
535#endif
536 loop
537 {
538 if (j > ende) return -1;
539#if defined(PDEBUG) || defined(PDIV_DEBUG)
540 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
541 p, not_sev, currRing))
542#else
543 if ( !(strat->sevS[j] & not_sev) &&
544 p_LmDivisibleBy(strat->S[j], p, currRing))
545#endif
546 {
547 return j;
548 }
549 j++;
550 }
551}

◆ 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 566 of file kstd2.cc.

567{
568 // m = currRing->ch
569
570 if (input_p == NULL) return NULL;
571
572 poly p = input_p;
573 poly zeroPoly = NULL;
574 unsigned long a = (unsigned long) pGetCoeff(p);
575
576 int k_ind2 = 0;
577 int a_ind2 = SI_LOG2_LONG(a);
578
579 // unsigned long k = 1;
580 // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
581 for (int i = 1; i <= leadRing->N; i++)
582 {
583 k_ind2 = k_ind2 + ind_fact_2(p_GetExp(p, i, leadRing));
584 }
585
586 a = (unsigned long) pGetCoeff(p);
587
588 number tmp1;
589 poly tmp2, tmp3;
590 poly lead_mult = p_ISet(1, tailRing);
591 if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
592 {
593 int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf);
594 int s_exp;
595 zeroPoly = p_ISet(a, tailRing);
596 for (int i = 1; i <= leadRing->N; i++)
597 {
598 s_exp = p_GetExp(p, i,leadRing);
599 if (s_exp % 2 != 0)
600 {
601 s_exp = s_exp - 1;
602 }
603 while ( (0 < SI_LOG2_LONG(s_exp)) && (SI_LOG2_LONG(s_exp) <= too_much) )
604 {
605 too_much = too_much - SI_LOG2_LONG(s_exp);
606 s_exp = s_exp - 2;
607 }
608 p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
609 for (int j = 1; j <= s_exp; j++)
610 {
611 tmp1 = nInit(j);
612 tmp2 = p_ISet(1, tailRing);
613 p_SetExp(tmp2, i, 1, tailRing);
614 p_Setm(tmp2, tailRing);
615 if (nIsZero(tmp1))
616 { // should nowbe obsolet, test ! TODO OLIVER
617 zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
618 }
619 else
620 {
621 tmp3 = p_NSet(nCopy(tmp1), tailRing);
622 zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
623 }
624 }
625 }
626 p_Setm(lead_mult, tailRing);
627 zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing);
628 tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
629 for (int i = 1; i <= leadRing->N; i++)
630 {
631 pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
632 }
633 p_Setm(tmp2, leadRing);
634 zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
635 pNext(tmp2) = zeroPoly;
636 return tmp2;
637 }
638/* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
639 if (1 == 0 && alpha_k <= a)
640 { // Temporarily disabled, reducing coefficients not compatible with std TODO Oliver
641 zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
642 for (int i = 1; i <= leadRing->N; i++)
643 {
644 for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
645 {
646 tmp1 = nInit(j);
647 tmp2 = p_ISet(1, tailRing);
648 p_SetExp(tmp2, i, 1, tailRing);
649 p_Setm(tmp2, tailRing);
650 if (nIsZero(tmp1))
651 {
652 zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
653 }
654 else
655 {
656 tmp3 = p_ISet((unsigned long) tmp1, tailRing);
657 zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
658 }
659 }
660 }
661 tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing);
662 for (int i = 1; i <= leadRing->N; i++)
663 {
664 pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
665 }
666 p_Setm(tmp2, leadRing);
667 zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
668 pNext(tmp2) = zeroPoly;
669 return tmp2;
670 } */
671 return NULL;
672}
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:448
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
static long ind_fact_2(long arg)
Definition kstd2.cc:553
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:1118
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1051
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:755
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 4087 of file kstd2.cc.

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

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

◆ kNF2Bound() [1/2]

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

Definition at line 4173 of file kstd2.cc.

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

◆ kNF2Bound() [2/2]

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

Definition at line 4012 of file kstd2.cc.

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

◆ ksCreateShortSpoly()

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

Definition at line 1447 of file kspoly.cc.

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

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

1192{
1193 LObject L(r);
1194 L.p1 = p1;
1195 L.p2 = p2;
1196
1197 ksCreateSpoly(&L, spNoether);
1198 return L.GetLmCurrRing();
1199}

◆ ksOldSpolyRed()

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

Definition at line 1171 of file kInline.h.

1172{
1173 LObject L(p2);
1174 TObject T(p1);
1175
1176 ksReducePoly(&L, &T, spNoether);
1177
1178 return L.GetLmCurrRing();
1179}
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 1181 of file kInline.h.

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

◆ ksOldSpolyTail()

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

Definition at line 1201 of file kInline.h.

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

◆ 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:476
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:558
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:592
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472
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:1454
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1914
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:292
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 591 of file kspoly.cc.

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

◆ 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 t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); 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 t2 = pNext(p2);
550 lm = p1;
551 p_ExpVectorSub(lm, p2, tailRing);
552 ret = 1;
553 }
554
555#ifdef HAVE_SHIFTBBA
556 poly lmRight;
557 if (tailRing->isLPring)
558 {
559 assume(PR->shift == 0);
560 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
561 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
562 }
563#endif
564
565 // and finally,
566#ifdef HAVE_SHIFTBBA
567 if (tailRing->isLPring)
568 {
569 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing), pLength(p2), spNoether);
570 }
571 else
572#endif
573 {
574 PR->Tail_Minus_mm_Mult_qq(lm, p2, pLength(p2) /*PW->GetpLength() - 1*/, spNoether);
575 }
576 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
577
578 PR->LmDeleteAndIter();
579 p_SetCoeff(PR->p, *coef, currRing);
580
581#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
582 if (TEST_OPT_DEBUG)
583 {
584 Print(" to: "); PR->wrp(); Print("\n");
585 //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
586 }
587#endif
588 return ret;
589}

◆ ksReducePolySig()

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

Definition at line 738 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 944 of file kspoly.cc.

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

◆ ksReducePolyTail() [1/2]

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

Definition at line 1144 of file kInline.h.

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

◆ ksReducePolyTail() [2/2]

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

Definition at line 1351 of file kspoly.cc.

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

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

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy strat)

Definition at line 11050 of file kutil.cc.

11051{
11052 unsigned long l = 0;
11053 int i;
11054 long e;
11055
11056 assume(strat->tailRing == currRing);
11057
11058 for (i=0; i<= strat->Ll; i++)
11059 {
11060 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11061 }
11062 for (i=0; i<=strat->tl; i++)
11063 {
11064 // Hmm ... this we could do in one Step
11065 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11066 }
11068 {
11069 l *= 2;
11070 }
11071 e = p_GetMaxExp(l, currRing);
11072 if (e <= 1) e = 2;
11073 if (rIsLPRing(currRing)) e = 1;
11074
11075 kStratChangeTailRing(strat, NULL, NULL, e);
11076}
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:781

◆ kTest()

BOOLEAN kTest ( kStrategy strat)

Definition at line 1010 of file kutil.cc.

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

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy strat)

Definition at line 1053 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 799 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy strat)

Definition at line 1071 of file kutil.cc.

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

◆ 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 146 of file kstd2.cc.

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

◆ message()

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

Definition at line 7465 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy strat)

Definition at line 7538 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int hilbcount,
kStrategy strat )

Definition at line 7506 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int hilbcount,
kStrategy strat )

Definition at line 7519 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy strat)

Definition at line 10404 of file kutil.cc.

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

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

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

Definition at line 4846 of file kutil.cc.

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

◆ posInL0()

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

Definition at line 5616 of file kutil.cc.

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

◆ posInL10()

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

Definition at line 1361 of file kstd1.cc.

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

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

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

◆ posInL110()

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

Definition at line 6060 of file kutil.cc.

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

◆ posInL11Ring()

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

Definition at line 5846 of file kutil.cc.

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

◆ posInL11Ringls()

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

Definition at line 5914 of file kutil.cc.

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

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

◆ posInL15()

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

Definition at line 6182 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6217 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6257 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 5792 of file kutil.cc.

5794{
5795 return strat->Ll+1;
5796}

◆ posInLF5CRing()

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

Definition at line 5880 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5674 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5699 of file kutil.cc.

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

◆ posInS()

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

Definition at line 4668 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4769 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy strat,
const poly sig )

Definition at line 5763 of file kutil.cc.

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

◆ posInT0()

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

Definition at line 4890 of file kutil.cc.

4891{
4892 return (length+1);
4893}

◆ posInT1()

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

Definition at line 4901 of file kutil.cc.

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

◆ posInT11()

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

Definition at line 4958 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5034 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5122 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5189 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5283 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5389 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5515 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4930 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11371 of file kutil.cc.

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

◆ posInT_EcartpLength()

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

Definition at line 5151 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11425 of file kutil.cc.

11426{
11427
11428 if (length==-1) return 0;
11429
11430 int op=p.GetpFDeg();
11431 int ol = p.GetpLength();
11432
11433 int oo=set[length].GetpFDeg();
11434 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11435 return length+1;
11436
11437 int i;
11438 int an = 0;
11439 int en= length;
11440 loop
11441 {
11442 if (an >= en-1)
11443 {
11444 int oo=set[an].GetpFDeg();
11445 if((oo > op)
11446 || ((oo==op) && (set[an].pLength > ol)))
11447 return an;
11448 return en;
11449 }
11450 i=(an+en) / 2;
11451 int oo=set[i].GetpFDeg();
11452 if ((oo > op)
11453 || ((oo == op) && (set[i].pLength > ol)))
11454 en=i;
11455 else
11456 an=i;
11457 }
11458}

◆ posInT_pLength()

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

Definition at line 11462 of file kutil.cc.

11463{
11464 int ol = p.GetpLength();
11465 if (length==-1)
11466 return 0;
11467 if (set[length].length<p.length)
11468 return length+1;
11469
11470 int i;
11471 int an = 0;
11472 int en= length;
11473
11474 loop
11475 {
11476 if (an >= en-1)
11477 {
11478 if (set[an].pLength>ol) return an;
11479 return en;
11480 }
11481 i=(an+en) / 2;
11482 if (set[i].pLength>ol) en=i;
11483 else an=i;
11484 }
11485}

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

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

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject * h,
kStrategy strat )

Definition at line 10776 of file kutil.cc.

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

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

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

◆ redFirstShift()

int redFirstShift ( LObject * h,
kStrategy strat )

Definition at line 4954 of file kstd2.cc.

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

◆ redHomog()

int redHomog ( LObject * h,
kStrategy strat )

Definition at line 1107 of file kstd2.cc.

1108{
1109 if (strat->tl<0) return 1;
1110 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1111 assume(h->FDeg == h->pFDeg());
1112
1113 poly h_p;
1114 int i,j,at,pass,cnt,ii;
1115 // long reddeg,d;
1116 int li;
1117 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1118
1119 pass = j = 0;
1120 cnt = RED_CANONICALIZE;
1121 h->SetShortExpVector();
1122 h_p = h->GetLmTailRing();
1123 h->PrepareRed(strat->use_buckets);
1124 loop
1125 {
1126 j = kFindDivisibleByInT(strat, h);
1127 if (j < 0) return 1;
1128
1129 li = strat->T[j].pLength;
1130 ii = j;
1131 /*
1132 * the polynomial to reduce with (up to the moment) is;
1133 * pi with length li
1134 */
1135 i = j;
1136#if 1
1137 if (test_opt_length)
1138 {
1139 if (li<=0) li=strat->T[j].GetpLength();
1140 if (li>2)
1141 {
1142 unsigned long not_sev = ~ h->sev;
1143 loop
1144 {
1145 /*- search the shortest possible with respect to length -*/
1146 i++;
1147 if (i > strat->tl)
1148 break;
1149 if ((strat->T[i].pLength < li)
1150 &&
1151 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1152 h_p, not_sev, strat->tailRing))
1153 {
1154 /*
1155 * the polynomial to reduce with is now;
1156 */
1157 li = strat->T[i].pLength;
1158 if (li<=0) li=strat->T[i].GetpLength();
1159 ii = i;
1160 if (li<3) break;
1161 }
1162 }
1163 }
1164 }
1165#endif
1166
1167 /*
1168 * end of search: have to reduce with pi
1169 */
1170#ifdef KDEBUG
1171 if (TEST_OPT_DEBUG)
1172 {
1173 PrintS("red:");
1174 h->wrp();
1175 PrintS(" with ");
1176 strat->T[ii].wrp();
1177 }
1178#endif
1179 assume(strat->fromT == FALSE);
1180
1181 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1182#if SBA_PRINT_REDUCTION_STEPS
1183 sba_interreduction_steps++;
1184#endif
1185#if SBA_PRINT_OPERATIONS
1186 sba_interreduction_operations += pLength(strat->T[ii].p);
1187#endif
1188
1189#ifdef KDEBUG
1190 if (TEST_OPT_DEBUG)
1191 {
1192 PrintS("\nto ");
1193 h->wrp();
1194 PrintLn();
1195 }
1196#endif
1197
1198 h_p = h->GetLmTailRing();
1199 if (h_p == NULL)
1200 {
1201 kDeleteLcm(h);
1202 return 0;
1203 }
1205 {
1206 if (h->p!=NULL)
1207 {
1208 if(p_GetComp(h->p,currRing)>strat->syzComp)
1209 {
1210 h->Delete();
1211 return 0;
1212 }
1213 }
1214 else if (h->t_p!=NULL)
1215 {
1216 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1217 {
1218 h->Delete();
1219 return 0;
1220 }
1221 }
1222 }
1223 #if 0
1224 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1225 {
1226 if (h->p!=NULL)
1227 {
1228 if(p_GetComp(h->p,currRing)>strat->syzComp)
1229 {
1230 return 1;
1231 }
1232 }
1233 else if (h->t_p!=NULL)
1234 {
1235 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1236 {
1237 return 1;
1238 }
1239 }
1240 }
1241 #endif
1242 h->SetShortExpVector();
1243 /*
1244 * try to reduce the s-polynomial h
1245 *test first whether h should go to the lazyset L
1246 *-if the degree jumps
1247 *-if the number of pre-defined reductions jumps
1248 */
1249 cnt--;
1250 pass++;
1251 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1252 {
1253 h->SetLmCurrRing();
1254 at = strat->posInL(strat->L,strat->Ll,h,strat);
1255 if (at <= strat->Ll)
1256 {
1257#ifdef HAVE_SHIFTBBA
1258 if (rIsLPRing(currRing))
1259 {
1260 if (kFindDivisibleByInT(strat, h) < 0)
1261 return 1;
1262 }
1263 else
1264#endif
1265 {
1266 int dummy=strat->sl;
1267 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1268 return 1;
1269 }
1270 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1271#ifdef KDEBUG
1272 if (TEST_OPT_DEBUG)
1273 Print(" lazy: -> L%d\n",at);
1274#endif
1275 h->Clear();
1276 return -1;
1277 }
1278 }
1279 else if (UNLIKELY(cnt==0))
1280 {
1281 h->CanonicalizeP();
1282 cnt=RED_CANONICALIZE;
1283 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
1284 }
1285 }
1286}
#define UNLIKELY(X)
Definition auxiliary.h:404
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:421
#define RED_CANONICALIZE
Definition kutil.h:36
#define TEST_OPT_LENGTH
Definition options.h:130
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:117

◆ redHoney()

int redHoney ( LObject * h,
kStrategy strat )

Definition at line 2067 of file kstd2.cc.

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

◆ redHoneyM()

int redHoneyM ( LObject * h,
kStrategy strat )

◆ redLazy()

int redLazy ( LObject * h,
kStrategy strat )

TEST_OPT_REDTHROUGH &&

Definition at line 1862 of file kstd2.cc.

1863{
1864 if (strat->tl<0) return 1;
1865 int at,i,ii,li;
1866 int j = 0;
1867 int pass = 0;
1868 int cnt = RED_CANONICALIZE;
1869 assume(h->pFDeg() == h->FDeg);
1870 long reddeg = h->GetpFDeg();
1871 long d;
1872 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1873
1874 h->SetShortExpVector();
1875 poly h_p = h->GetLmTailRing();
1876 h->PrepareRed(strat->use_buckets);
1877 loop
1878 {
1879 j = kFindDivisibleByInT(strat, h);
1880 if (j < 0) return 1;
1881
1882 li = strat->T[j].pLength;
1883 ii = j;
1884 /*
1885 * the polynomial to reduce with (up to the moment) is;
1886 * pi with length li
1887 */
1888
1889 i = j;
1890#if 1
1891 if (test_opt_length)
1892 {
1893 if (li<=0) li=strat->T[j].GetpLength();
1894 if(li>2)
1895 {
1896 unsigned long not_sev = ~ h->sev;
1897 loop
1898 {
1899 /*- search the shortest possible with respect to length -*/
1900 i++;
1901 if (i > strat->tl)
1902 break;
1903 if ((strat->T[i].pLength < li)
1904 &&
1905 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1906 h_p, not_sev, strat->tailRing))
1907 {
1908 /*
1909 * the polynomial to reduce with is now;
1910 */
1911 li = strat->T[i].pLength;
1912 if (li<=0) li=strat->T[i].GetpLength();
1913 ii = i;
1914 if (li<3) break;
1915 }
1916 }
1917 }
1918 }
1919#endif
1920
1921 /*
1922 * end of search: have to reduce with pi
1923 */
1924
1925
1926#ifdef KDEBUG
1927 if (TEST_OPT_DEBUG)
1928 {
1929 PrintS("red:");
1930 h->wrp();
1931 PrintS(" with ");
1932 strat->T[ii].wrp();
1933 }
1934#endif
1935
1936 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1937#if SBA_PRINT_REDUCTION_STEPS
1938 sba_interreduction_steps++;
1939#endif
1940#if SBA_PRINT_OPERATIONS
1941 sba_interreduction_operations += pLength(strat->T[ii].p);
1942#endif
1943
1944#ifdef KDEBUG
1945 if (TEST_OPT_DEBUG)
1946 {
1947 PrintS("\nto ");
1948 h->wrp();
1949 PrintLn();
1950 }
1951#endif
1952
1953 h_p=h->GetLmTailRing();
1954
1955 if (h_p == NULL)
1956 {
1957 kDeleteLcm(h);
1958 return 0;
1959 }
1961 {
1962 if (h->p!=NULL)
1963 {
1964 if(p_GetComp(h->p,currRing)>strat->syzComp)
1965 {
1966 h->Delete();
1967 return 0;
1968 }
1969 }
1970 else if (h->t_p!=NULL)
1971 {
1972 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1973 {
1974 h->Delete();
1975 return 0;
1976 }
1977 }
1978 }
1979 #if 0
1980 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1981 {
1982 if (h->p!=NULL)
1983 {
1984 if(p_GetComp(h->p,currRing)>strat->syzComp)
1985 {
1986 return 1;
1987 }
1988 }
1989 else if (h->t_p!=NULL)
1990 {
1991 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1992 {
1993 return 1;
1994 }
1995 }
1996 }
1997 #endif
1998 h->SetShortExpVector();
1999 d = h->SetpFDeg();
2000 /*- try to reduce the s-polynomial -*/
2001 cnt--;
2002 pass++;
2003 if (//!TEST_OPT_REDTHROUGH &&
2004 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
2005 {
2006 h->SetLmCurrRing();
2007 at = strat->posInL(strat->L,strat->Ll,h,strat);
2008 if (at <= strat->Ll)
2009 {
2010#if 1
2011#ifdef HAVE_SHIFTBBA
2012 if (rIsLPRing(currRing))
2013 {
2014 if (kFindDivisibleByInT(strat, h) < 0)
2015 return 1;
2016 }
2017 else
2018#endif
2019 {
2020 int dummy=strat->sl;
2021 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2022 return 1;
2023 }
2024#endif
2025#ifdef KDEBUG
2026 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
2027#endif
2028 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2029 h->Clear();
2030 return -1;
2031 }
2032 }
2033 else if (d != reddeg)
2034 {
2035 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
2036 {
2037 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
2038 {
2039 strat->overflow=TRUE;
2040 //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2041 h->GetP();
2042 at = strat->posInL(strat->L,strat->Ll,h,strat);
2043 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2044 h->Clear();
2045 return -1;
2046 }
2047 }
2048 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
2049 {
2050 Print(".%ld",d);mflush();
2051 reddeg = d;
2052 }
2053 }
2054 else if (UNLIKELY(cnt==0))
2055 {
2056 h->CanonicalizeP();
2057 cnt=RED_CANONICALIZE;
2058 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
2059 }
2060 }
2061}

◆ 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
#define A
Definition sirandom.c:24

◆ redNF()

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

Definition at line 2302 of file kstd2.cc.

2303{
2304 if (h==NULL) return NULL;
2305 int j,j_ring;
2306 int cnt=REDNF_CANONICALIZE;
2307 max_ind=strat->sl;
2308
2309 if (0 > strat->sl)
2310 {
2311 return h;
2312 }
2313 LObject P(h);
2314 P.SetShortExpVector();
2315 P.t_p=NULL;
2316 BOOLEAN is_ring = rField_is_Ring(currRing);
2317 if(is_ring) nonorm=TRUE;
2318#ifdef KDEBUG
2319// if (TEST_OPT_DEBUG)
2320// {
2321// PrintS("redNF: starting S:\n");
2322// for( j = 0; j <= max_ind; j++ )
2323// {
2324// Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2325// pWrite(strat->S[j]);
2326// }
2327// };
2328#endif
2329 if (rField_is_Z(currRing))
2330 {
2331 redRing_Z_S(&P,strat);
2332 if (P.bucket!=NULL)
2333 {
2334 P.p=kBucketClear(P.bucket);
2335 kBucketDestroy(&P.bucket);
2336 }
2337 return P.p;
2338 }
2339 else if (rField_is_Ring(currRing))
2340 {
2341 redRing_S(&P,strat);
2342 if (P.bucket!=NULL)
2343 {
2344 P.p=kBucketClear(P.bucket);
2345 kBucketDestroy(&P.bucket);
2346 }
2347 return P.p;
2348 }
2349
2350 P.bucket = kBucketCreate(currRing);
2351 kBucketInit(P.bucket,P.p,pLength(P.p));
2352 kbTest(P.bucket);
2353 P.p=kBucketGetLm(P.bucket);
2354 loop
2355 {
2356 j_ring=j=kFindDivisibleByInS_noCF(strat,&max_ind,&P);
2357 while ((j>=0)
2358 && (nonorm)
2359 && (!n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[j]),currRing->cf)))
2360 j=kFindNextDivisibleByInS(strat,j+1,max_ind,&P);
2361 if (j>=0)
2362 {
2363 int sl=pSize(strat->S[j]);
2364 int jj=j;
2365 loop
2366 {
2367 int sll;
2368 jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
2369 if (jj<0) break;
2370 if ((!nonorm)
2371 || (n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[jj]),currRing->cf)))
2372 {
2373 sll=pSize(strat->S[jj]);
2374 if (sll<sl)
2375 {
2376 #ifdef KDEBUG
2377 if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2378 #endif
2379 //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2380 j=jj;
2381 sl=sll;
2382 }
2383 }
2384 }
2385 if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2386 {
2387 pNorm(strat->S[j]);
2388 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2389 }
2390 nNormalize(pGetCoeff(P.p));
2391#ifdef KDEBUG
2392 if (TEST_OPT_DEBUG)
2393 {
2394 PrintS("red:");
2395 wrp(P.p);
2396 PrintS(" with ");
2397 wrp(strat->S[j]);
2398 }
2399#endif
2400#ifdef HAVE_PLURAL
2402 {
2403 number coef;
2404 nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
2405 nDelete(&coef);
2406 }
2407 else
2408#endif
2409 {
2410 kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),
2411 strat->kNoether);
2412 }
2413 cnt--;
2414 if (cnt==0)
2415 {
2416 kBucketCanonicalize(P.bucket);
2418 }
2419 P.p=kBucketGetLm(P.bucket);
2420 //P.t_p=NULL;
2421#ifdef KDEBUG
2422 if (TEST_OPT_DEBUG)
2423 {
2424 PrintS("\nto:");
2425 wrp(P.p);
2426 PrintLn();
2427 }
2428#endif
2429 if (P.p==NULL)
2430 {
2431 kBucketDestroy(&P.bucket);
2432 return NULL;
2433 }
2434 kbTest(P.bucket);
2435 P.SetShortExpVector();
2436 }
2437 else if (is_ring && (j_ring>=0) && (currRing->cf->cfQuotRem!=ndQuotRem))
2438 {
2439 number r;
2440 number n=n_QuotRem(pGetCoeff(P.p),pGetCoeff(strat->S[j_ring]),&r,currRing->cf);
2441 if(!n_IsZero(n,currRing->cf))
2442 {
2443 poly lm=kBucketGetLm(P.bucket);
2444 poly m=p_Head(lm,currRing);
2445 p_ExpVectorSub(m,strat->S[j_ring],currRing);
2446 if (p_GetComp(strat->S[j_ring], currRing) != p_GetComp(lm, currRing))
2447 {
2449 }
2451 p_Setm(m,currRing);
2452#ifdef KDEBUG
2453 if (TEST_OPT_DEBUG)
2454 {
2455 PrintS("redi (coeff):");
2456 wrp(P.p);
2457 PrintS(" with ");
2458 wrp(strat->S[j]);
2459 }
2460#endif
2461 int l=-1;
2462 kBucket_Minus_m_Mult_p(P.bucket,m,strat->S[j_ring],&l);
2463 P.p=kBucketGetLm(P.bucket);
2465#ifdef KDEBUG
2466 if (TEST_OPT_DEBUG)
2467 {
2468 PrintS("\nto:");
2469 wrp(P.p);
2470 PrintLn();
2471 }
2472#endif
2473 }
2474 else
2475 {
2476 n_Delete(&n,currRing->cf);
2477 }
2478 n_Delete(&r,currRing->cf);
2479 P.p=kBucketClear(P.bucket);
2480 kBucketDestroy(&P.bucket);
2481 pNormalize(P.p);
2482 return P.p;
2483 }
2484 else
2485 {
2486 P.p=kBucketClear(P.bucket);
2487 kBucketDestroy(&P.bucket);
2488 pNormalize(P.p);
2489 return P.p;
2490 }
2491 }
2492}
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:524
int kFindDivisibleByInS_noCF(const kStrategy strat, int *max_ind, LObject *L)
Definition kstd2.cc:484
static int redRing_S(LObject *h, kStrategy strat)
Definition kstd2.cc:1047
static int redRing_Z_S(LObject *h, kStrategy strat)
Definition kstd2.cc:835
#define REDNF_CANONICALIZE
Definition kutil.h:37
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:860
#define pNormalize(p)
Definition polys.h:317
#define pSize(p)
Definition polys.h:318

◆ 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 386 of file kstd1.cc.

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

◆ redRing()

int redRing ( LObject * h,
kStrategy strat )

Definition at line 945 of file kstd2.cc.

946{
947 if (strat->tl<0) return 1;
948 if (h->IsNull()) return 0; // spoly is zero (can only occur with zero divisors)
949
950 int at/*,i*/;
951 long d;
952 int j = 0;
953 int pass = 0;
954 // poly zeroPoly = NULL;
955
956// TODO warum SetpFDeg notwendig?
957 h->SetpFDeg();
958 assume(h->pFDeg() == h->FDeg);
959 long reddeg = h->GetpFDeg();
960
961 h->SetShortExpVector();
962 loop
963 {
964 j = kFindDivisibleByInT(strat, h);
965 if (j < 0)
966 {
967 // over ZZ: cleanup coefficients by complete reduction with monomials
968 postReduceByMon(h, strat);
969 if(h->p == NULL)
970 {
971 kDeleteLcm(h);
972 h->Clear();
973 return 0;
974 }
975 if(nIsZero(pGetCoeff(h->p))) return 2;
976 j = kFindDivisibleByInT(strat, h);
977 if(j < 0)
978 {
979 if(strat->tl >= 0)
980 h->i_r1 = strat->tl;
981 else
982 h->i_r1 = -1;
983 if (h->GetLmTailRing() == NULL)
984 {
985 kDeleteLcm(h);
986 h->Clear();
987 return 0;
988 }
989 return 1;
990 }
991 }
992 //printf("\nFound one: ");pWrite(strat->T[j].p);
993 //enterT(*h, strat);
994 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat); // with debug output
995 //printf("\nAfter small red: ");pWrite(h->p);
996 if (h->GetLmTailRing() == NULL)
997 {
998 kDeleteLcm(h);
999 h->Clear();
1000 return 0;
1001 }
1002 h->SetShortExpVector();
1003 d = h->SetpFDeg();
1004 /*- try to reduce the s-polynomial -*/
1005 pass++;
1006 if (!TEST_OPT_REDTHROUGH &&
1007 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1008 {
1009 h->SetLmCurrRing();
1010 if (strat->posInLDependsOnLength)
1011 h->SetLength(strat->length_pLength);
1012 at = strat->posInL(strat->L,strat->Ll,h,strat);
1013 if (at <= strat->Ll)
1014 {
1015#ifdef KDEBUG
1016 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1017#endif
1018 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
1019 h->Clear();
1020 return -1;
1021 }
1022 }
1023 if (d != reddeg)
1024 {
1025 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
1026 {
1027 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1028 {
1029 strat->overflow=TRUE;
1030 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1031 h->GetP();
1032 at = strat->posInL(strat->L,strat->Ll,h,strat);
1033 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1034 h->Clear();
1035 return -1;
1036 }
1037 }
1038 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1039 {
1040 Print(".%ld",d);mflush();
1041 reddeg = d;
1042 }
1043 }
1044 }
1045}

◆ redRing_Z()

int redRing_Z ( LObject * h,
kStrategy strat )

Definition at line 677 of file kstd2.cc.

678{
679 if (h->IsNull()) return 0; // spoly is zero (can only occur with zero divisors)
680 if (strat->tl<0) return 1;
681
682 int at;
683 long d;
684 int j = 0;
685 int pass = 0;
686
687// TODO warum SetpFDeg notwendig?
688 h->SetpFDeg();
689 assume(h->pFDeg() == h->FDeg);
690 long reddeg = h->GetpFDeg();
691
692 h->SetShortExpVector();
693 loop
694 {
695 /* check if a reducer of the lead term exists */
696 j = kFindDivisibleByInT(strat, h);
697 if (j < 0)
698 {
699#if STDZ_EXCHANGE_DURING_REDUCTION
700 /* check if a reducer with the same lead monomial exists */
701 j = kFindSameLMInT_Z(strat, h);
702 if (j < 0)
703 {
704#endif
705 /* check if a reducer of the lead monomial exists, by the above
706 * check this is a real divisor of the lead monomial */
707 j = kFindDivisibleByInT_Z(strat, h);
708 if (j < 0)
709 {
710 // over ZZ: cleanup coefficients by complete reduction with monomials
712 postReduceByMon(h, strat);
713 if(h->p == NULL)
714 {
715 if (h->lcm!=NULL) pLmDelete(h->lcm);
716 h->Clear();
717 return 0;
718 }
719 if(nIsZero(pGetCoeff(h->p))) return 2;
720 j = kFindDivisibleByInT(strat, h);
721 if(j < 0)
722 {
723 if(strat->tl >= 0)
724 h->i_r1 = strat->tl;
725 else
726 h->i_r1 = -1;
727 if (h->GetLmTailRing() == NULL)
728 {
729 if (h->lcm!=NULL) pLmDelete(h->lcm);
730 h->Clear();
731 return 0;
732 }
733 return 1;
734 }
735 }
736 else
737 {
738 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
739 * => we try to cut down the lead coefficient at least */
740 /* first copy T[j] in order to multiply it with a coefficient later on */
741 number mult, rest;
742 TObject tj = strat->T[j];
743 tj.Copy();
744 /* tj.max_exp = strat->T[j].max_exp; */
745 /* compute division with remainder of lc(h) and lc(T[j]) */
746 mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
747 &rest, currRing->cf);
748 /* set corresponding new lead coefficient already. we do not
749 * remove the lead term in ksReducePolyLC, but only apply
750 * a lead coefficient reduction */
751 tj.Mult_nn(mult);
752 ksReducePolyLC(h, &tj, NULL, &rest, strat);
753 tj.Delete();
754 tj.Clear();
755 }
756#if STDZ_EXCHANGE_DURING_REDUCTION
757 }
758 else
759 {
760 /* same lead monomial but lead coefficients do not divide each other:
761 * change the polys to h <- spoly(h,tj) and h2 <- gpoly(h,tj). */
762 LObject h2 = *h;
763 h2.Copy();
764
765 ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat);
766 ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat);
768 {
769 redtailBbaAlsoLC_Z(&h2, j, strat);
770 }
771 /* replace h2 for tj in L (already generated pairs with tj), S and T */
772 replaceInLAndSAndT(h2, j, strat);
773 }
774#endif
775 }
776 else
777 {
778 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat);
779 }
780 /* printf("\nAfter small red: ");pWrite(h->p); */
781 if (h->GetLmTailRing() == NULL)
782 {
783 if (h->lcm!=NULL) pLmDelete(h->lcm);
784#ifdef KDEBUG
785 h->lcm=NULL;
786#endif
787 h->Clear();
788 return 0;
789 }
790 h->SetShortExpVector();
791 d = h->SetpFDeg();
792 /*- try to reduce the s-polynomial -*/
793 pass++;
794 if (!TEST_OPT_REDTHROUGH &&
795 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
796 {
797 h->SetLmCurrRing();
798 if (strat->posInLDependsOnLength)
799 h->SetLength(strat->length_pLength);
800 at = strat->posInL(strat->L,strat->Ll,h,strat);
801 if (at <= strat->Ll)
802 {
803#ifdef KDEBUG
804 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
805#endif
806 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
807 h->Clear();
808 return -1;
809 }
810 }
811 if (d != reddeg)
812 {
813 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
814 {
815 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
816 {
817 strat->overflow=TRUE;
818 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
819 h->GetP();
820 at = strat->posInL(strat->L,strat->Ll,h,strat);
821 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
822 h->Clear();
823 return -1;
824 }
825 }
826 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
827 {
828 Print(".%ld",d);mflush();
829 reddeg = d;
830 }
831 }
832 }
833}
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:213
void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat)
Definition kutil.cc:9049
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 1326 of file kstd2.cc.

1327{
1328 if (strat->tl<0) return 1;
1329 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1330 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1331 assume(h->FDeg == h->pFDeg());
1332//#if 1
1333#ifdef DEBUGF5
1334 PrintS("------- IN REDSIG -------\n");
1335 Print("p: ");
1336 pWrite(pHead(h->p));
1337 PrintS("p1: ");
1338 pWrite(pHead(h->p1));
1339 PrintS("p2: ");
1340 pWrite(pHead(h->p2));
1341 PrintS("---------------------------\n");
1342#endif
1343 poly h_p;
1344 int i,j,at,pass, ii;
1345 int start=0;
1346 int sigSafe;
1347 unsigned long not_sev;
1348 // long reddeg,d;
1349 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1350 int li;
1351
1352 pass = j = 0;
1353 h->SetShortExpVector();
1354 h_p = h->GetLmTailRing();
1355 not_sev = ~ h->sev;
1356 loop
1357 {
1358 j = kFindDivisibleByInT(strat, h, start);
1359 if (j < 0)
1360 {
1361 return 1;
1362 }
1363
1364 li = strat->T[j].pLength;
1365 if (li<=0) li=strat->T[j].GetpLength();
1366 ii = j;
1367 /*
1368 * the polynomial to reduce with (up to the moment) is;
1369 * pi with length li
1370 */
1371 i = j;
1372#if 1
1373 if (test_opt_length)
1374 loop
1375 {
1376 /*- search the shortest possible with respect to length -*/
1377 i++;
1378 if (i > strat->tl)
1379 break;
1380 if (li==1)
1381 break;
1382 if ((strat->T[i].pLength < li)
1383 &&
1384 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1385 h_p, not_sev, strat->tailRing))
1386 {
1387 /*
1388 * the polynomial to reduce with is now;
1389 */
1390 li = strat->T[i].pLength;
1391 if (li<=0) li=strat->T[i].GetpLength();
1392 ii = i;
1393 }
1394 }
1395 start = ii+1;
1396#endif
1397
1398 /*
1399 * end of search: have to reduce with pi
1400 */
1401#ifdef KDEBUG
1402 if (TEST_OPT_DEBUG)
1403 {
1404 PrintS("red:");
1405 h->wrp();
1406 PrintS(" with ");
1407 strat->T[ii].wrp();
1408 }
1409#endif
1410 assume(strat->fromT == FALSE);
1411//#if 1
1412#ifdef DEBUGF5
1413 Print("BEFORE REDUCTION WITH %d:\n",ii);
1414 PrintS("--------------------------------\n");
1415 pWrite(h->sig);
1416 pWrite(strat->T[ii].sig);
1417 pWrite(h->GetLmCurrRing());
1418 pWrite(pHead(h->p1));
1419 pWrite(pHead(h->p2));
1420 pWrite(pHead(strat->T[ii].p));
1421 PrintS("--------------------------------\n");
1422 printf("INDEX OF REDUCER T: %d\n",ii);
1423#endif
1424 sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1425#if SBA_PRINT_REDUCTION_STEPS
1426 if (sigSafe != 3)
1427 sba_reduction_steps++;
1428#endif
1429#if SBA_PRINT_OPERATIONS
1430 if (sigSafe != 3)
1431 sba_operations += pLength(strat->T[ii].p);
1432#endif
1433 // if reduction has taken place, i.e. the reduction was sig-safe
1434 // otherwise start is already at the next position and the loop
1435 // searching reducers in T goes on from index start
1436//#if 1
1437#ifdef DEBUGF5
1438 Print("SigSAFE: %d\n",sigSafe);
1439#endif
1440 if (sigSafe != 3)
1441 {
1442 // start the next search for reducers in T from the beginning
1443 start = 0;
1444#ifdef KDEBUG
1445 if (TEST_OPT_DEBUG)
1446 {
1447 PrintS("\nto ");
1448 h->wrp();
1449 PrintLn();
1450 }
1451#endif
1452
1453 h_p = h->GetLmTailRing();
1454 if (h_p == NULL)
1455 {
1456 kDeleteLcm(h);
1457 return 0;
1458 }
1459 h->SetShortExpVector();
1460 not_sev = ~ h->sev;
1461 /*
1462 * try to reduce the s-polynomial h
1463 *test first whether h should go to the lazyset L
1464 *-if the degree jumps
1465 *-if the number of pre-defined reductions jumps
1466 */
1467 pass++;
1468 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1469 {
1470 h->SetLmCurrRing();
1471 at = strat->posInL(strat->L,strat->Ll,h,strat);
1472 if (at <= strat->Ll)
1473 {
1474 int dummy=strat->sl;
1475 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1476 {
1477 return 1;
1478 }
1479 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1480#ifdef KDEBUG
1481 if (TEST_OPT_DEBUG)
1482 Print(" lazy: -> L%d\n",at);
1483#endif
1484 h->Clear();
1485 return -1;
1486 }
1487 }
1488 }
1489 }
1490}
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:738

◆ redSigRing()

int redSigRing ( LObject * h,
kStrategy strat )

Definition at line 1493 of file kstd2.cc.

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

◆ redtail() [1/2]

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

Definition at line 6838 of file kutil.cc.

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

◆ redtail() [2/2]

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

Definition at line 6908 of file kutil.cc.

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

◆ redtailBba() [1/3]

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

Definition at line 6914 of file kutil.cc.

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

1210{
1211 LObject L(p);
1212 return redtailBba(&L, pos, strat,FALSE, normalize);
1213}

◆ redtailBba() [3/3]

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

◆ redtailBba_NF()

poly redtailBba_NF ( poly p,
kStrategy strat )

Definition at line 7352 of file kutil.cc.

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7377 of file kutil.cc.

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

◆ redtailBba_Ring() [2/2]

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

Definition at line 1221 of file kInline.h.

1222{
1223 LObject L(p, currRing, strat->tailRing);
1224 return redtailBba_Ring(&L, pos, strat);
1225}

◆ redtailBba_Z() [1/2]

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

Definition at line 7271 of file kutil.cc.

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

◆ redtailBba_Z() [2/2]

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

Definition at line 1226 of file kInline.h.

1227{
1228 LObject L(p, currRing, strat->tailRing);
1229 return redtailBba_Z(&L, pos, strat);
1230}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7142 of file kutil.cc.

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

◆ redtailBbaBound() [1/2]

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

Definition at line 7027 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

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

Definition at line 1215 of file kInline.h.

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

◆ redtailBbaShift()

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

Definition at line 12997 of file kutil.cc.

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

◆ redtailSba()

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

Definition at line 1742 of file kstd2.cc.

1743{
1744 strat->redTailChange=FALSE;
1745 if (strat->noTailReduction) return L->GetLmCurrRing();
1746 poly h, p;
1747 p = h = L->GetLmTailRing();
1748 if ((h==NULL) || (pNext(h)==NULL))
1749 return L->GetLmCurrRing();
1750
1751 TObject* With;
1752 // placeholder in case strat->tl < 0
1753 TObject With_s(strat->tailRing);
1754
1755 LObject Ln(pNext(h), strat->tailRing);
1756 Ln.sig = L->sig;
1757 Ln.sevSig = L->sevSig;
1758 Ln.pLength = L->GetpLength() - 1;
1759
1760 pNext(h) = NULL;
1761 if (L->p != NULL) pNext(L->p) = NULL;
1762 L->pLength = 1;
1763
1764 Ln.PrepareRed(strat->use_buckets);
1765
1766 int cnt=REDTAIL_CANONICALIZE;
1767 while(!Ln.IsNull())
1768 {
1769 loop
1770 {
1771 if(rField_is_Ring(currRing) && strat->sigdrop)
1772 break;
1773 Ln.SetShortExpVector();
1774 if (withT)
1775 {
1776 int j;
1777 j = kFindDivisibleByInT(strat, &Ln);
1778 if (j < 0) break;
1779 With = &(strat->T[j]);
1780 }
1781 else
1782 {
1783 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1784 if (With == NULL) break;
1785 }
1786 cnt--;
1787 if (cnt==0)
1788 {
1790 /*poly tmp=*/Ln.CanonicalizeP();
1792 {
1793 Ln.Normalize();
1794 //pNormalize(tmp);
1795 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1796 }
1797 }
1799 {
1800 With->pNorm();
1801 }
1802 strat->redTailChange=TRUE;
1803 int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1805 L->sig = Ln.sig;
1806 //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1807 // I delete it an then set Ln.sig. Hence L->sig is lost
1808#if SBA_PRINT_REDUCTION_STEPS
1809 if (ret != 3)
1810 sba_reduction_steps++;
1811#endif
1812#if SBA_PRINT_OPERATIONS
1813 if (ret != 3)
1814 sba_operations += pLength(With->p);
1815#endif
1816 if (ret)
1817 {
1818 // reducing the tail would violate the exp bound
1819 // set a flag and hope for a retry (in bba)
1821 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1822 do
1823 {
1824 pNext(h) = Ln.LmExtractAndIter();
1825 pIter(h);
1826 L->pLength++;
1827 } while (!Ln.IsNull());
1828 goto all_done;
1829 }
1830 if (Ln.IsNull()) goto all_done;
1831 if (! withT) With_s.Init(currRing);
1832 if(rField_is_Ring(currRing) && strat->sigdrop)
1833 {
1834 //Cannot break the loop here so easily
1835 break;
1836 }
1837 }
1838 pNext(h) = Ln.LmExtractAndIter();
1839 pIter(h);
1841 pNormalize(h);
1842 L->pLength++;
1843 }
1844 all_done:
1845 Ln.Delete();
1846 if (L->p != NULL) pNext(L->p) = pNext(p);
1847
1848 if (strat->redTailChange)
1849 {
1850 L->length = 0;
1851 }
1852 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1853 //L->Normalize(); // HANNES: should have a test
1854 kTest_L(L,strat);
1855 return L->GetLmCurrRing();
1856}
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition kstd2.cc:1288

◆ reorderS()

void reorderS ( int * suc,
kStrategy strat )

Definition at line 4615 of file kutil.cc.

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

◆ replaceInLAndSAndT()

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

Definition at line 9049 of file kutil.cc.

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

◆ sba()

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

Definition at line 2967 of file kstd2.cc.

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

1694{
1695 if(strat->sl < 0) return FALSE;
1696 int i;
1697 for(i=0;i<strat->sl;i++)
1698 {
1699 //Construct the gcd pair between h and S[i]
1700 number d, s, t;
1701 poly m1, m2, gcd;
1702 d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1703 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1704 {
1705 nDelete(&d);
1706 nDelete(&s);
1707 nDelete(&t);
1708 }
1709 else
1710 {
1711 k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1712 pSetCoeff0(m1, s);
1713 pSetCoeff0(m2, t);
1714 pSetCoeff0(gcd, d);
1715 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);
1716 poly pSigMult = p_Copy(h->sig,currRing);
1717 poly sSigMult = p_Copy(strat->sig[i],currRing);
1718 pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1719 sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1720 p_LmDelete(m1, strat->tailRing);
1721 p_LmDelete(m2, strat->tailRing);
1722 poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1723 if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1724 {
1725 pDelete(&h->p);
1726 h->p = gcd;
1727 pDelete(&h->sig);
1728 h->sig = pairsig;
1729 pNext(h->sig) = NULL;
1730 strat->initEcart(h);
1731 h->sev = pGetShortExpVector(h->p);
1732 h->sevSig = pGetShortExpVector(h->sig);
1733 h->i_r1 = -1;h->i_r2 = -1;
1734 if(h->lcm != NULL)
1735 {
1736 pLmDelete(h->lcm);
1737 h->lcm = NULL;
1738 }
1739 if (currRing!=strat->tailRing)
1740 h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1741 return TRUE;
1742 }
1743 //Delete what you didn't use
1744 pDelete(&gcd);
1745 pDelete(&pairsig);
1746 }
1747 }
1748 return FALSE;
1749}
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:672
KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring tailRing)
Definition kInline.h:1057
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1031

◆ sbaRing()

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

Definition at line 11078 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4462 of file kutil.cc.

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

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

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

◆ syzCriterion()

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

Definition at line 6480 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6515 of file kutil.cc.

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

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

◆ updateS()

void updateS ( BOOLEAN toT,
kStrategy strat )

Definition at line 8556 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 66 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 269 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 181 of file kutil.h.

◆ test_PosInL

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

Definition at line 865 of file kutil.h.

◆ test_PosInT

EXTERN_VAR int(* test_PosInT) (const TSet T, const int tl, LObject &h) ( const TSet T,
const int tl,
LObject & h )

Definition at line 864 of file kutil.h.