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

Go to the source code of this file.

Data Structures

struct  denominator_list_s
 
class  sTObject
 
class  sLObject
 
class  skStrategy
 

Macros

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

Typedefs

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

Functions

void deleteHC (poly *p, int *e, int *l, kStrategy strat)
 
void deleteHC (LObject *L, kStrategy strat, BOOLEAN fromNext=FALSE)
 
void deleteInS (int i, kStrategy strat)
 
void cleanT (kStrategy strat)
 
static LSet initL (int nr=setmaxL)
 
void deleteInL (LSet set, int *length, int j, kStrategy strat)
 
void enterL (LSet *set, int *length, int *LSetmax, LObject p, int at)
 
void enterSBba (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSBbaShift (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSSba (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void initEcartPairBba (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
 
void initEcartPairMora (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
 
int posInS (const kStrategy strat, const int length, const poly p, const int ecart_p)
 
int posInSMonFirst (const kStrategy strat, const int length, const poly p)
 
int posInIdealMonFirst (const ideal F, const poly p, int start=0, int end=-1)
 
int posInT0 (const TSet set, const int length, LObject &p)
 
int posInT1 (const TSet set, const int length, LObject &p)
 
int posInT2 (const TSet set, const int length, LObject &p)
 
int posInT11 (const TSet set, const int length, LObject &p)
 
int posInTSig (const TSet set, const int length, LObject &p)
 
int posInT110 (const TSet set, const int length, LObject &p)
 
int posInT13 (const TSet set, const int length, LObject &p)
 
int posInT15 (const TSet set, const int length, LObject &p)
 
int posInT17 (const TSet set, const int length, LObject &p)
 
int posInT17_c (const TSet set, const int length, LObject &p)
 
int posInT19 (const TSet set, const int length, LObject &p)
 
int posInT_EcartpLength (const TSet set, const int length, LObject &p)
 
int posInT_EcartFDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_FDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_pLength (const TSet set, const int length, LObject &p)
 
void reorderS (int *suc, kStrategy strat)
 
int 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, bigintmat **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindDivisibleByInT (const kStrategy strat, const LObject *L, const int start=0)
 return -1 if no divisor is found number of first divisor in T, otherwise
 
int kFindDivisibleByInT_ecart (const kStrategy strat, const LObject *L, const int ecart)
 
int kFindDivisibleByInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kFindSameLMInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kTestDivisibleByT0_Z (const kStrategy strat, const LObject *L)
 tests if T[0] divides the leading monomial of L, returns -1 if not
 
int kFindDivisibleByInS (const kStrategy strat, int *max_ind, LObject *L)
 return -1 if no divisor is found number of first divisor in S, otherwise
 
int kFindNextDivisibleByInS (const kStrategy strat, int start, int max_ind, LObject *L)
 
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart=LONG_MAX)
 
KINLINE TSet initT ()
 
KINLINE TObject ** initR ()
 
KINLINE unsigned long * initsevT ()
 
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing)
 
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing)
 
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing)
 
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing)
 
KINLINE BOOLEAN k_GetLeadTerms (const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
 
KINLINE void k_GetStrongLeadTerms (const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring taiRing)
 
BOOLEAN kTest (kStrategy strat)
 
BOOLEAN kTest_TS (kStrategy strat)
 
BOOLEAN kTest_L (LObject *L, kStrategy strat, BOOLEAN testp=FALSE, int lpos=-1, TSet T=NULL, int tlength=-1)
 
BOOLEAN kTest_T (TObject *T, kStrategy strat, int tpos=-1, char TN='?')
 
BOOLEAN kTest_S (kStrategy strat)
 
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
 
ideal bba (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
 
poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
 
ideal kNF2 (ideal F, ideal Q, ideal q, kStrategy strat, int lazyReduce)
 
poly kNF2Bound (ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
 
ideal kNF2Bound (ideal F, ideal Q, ideal q, int bound, kStrategy strat, int lazyReduce)
 
void initBba (kStrategy strat)
 
void initSba (ideal F, kStrategy strat)
 
void f5c (kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, bigintmat *hilb)
 
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL, BOOLEAN redtail=FALSE)
 
int ksReducePolyZ (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyLC (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyGCD (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyBound (LObject *PR, TObject *PW, int bound, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySig (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySigRing (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyTail (LObject *PR, TObject *PW, poly Current, poly spNoether=NULL)
 
KINLINE int ksReducePolyTail (LObject *PR, TObject *PW, LObject *Red)
 
void ksCreateSpoly (LObject *Pair, poly spNoether=NULL, int use_buckets=0, ring tailRing=currRing, poly m1=NULL, poly m2=NULL, TObject **R=NULL)
 
poly ksCreateShortSpoly (poly p1, poly p2, ring tailRing)
 
KINLINE poly ksOldSpolyRed (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldSpolyRedNew (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldCreateSpoly (poly p1, poly p2, poly spNoether=NULL, ring r=currRing)
 
KINLINE void ksOldSpolyTail (poly p1, poly q, poly q2, poly spNoether, ring r=currRing)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
poly preIntegerCheck (ideal F, ideal Q)
 used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L=NULL, TObject *T=NULL, unsigned long new_expbound=0)
 
void kStratInitChangeTailRing (kStrategy strat)
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
 
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
 
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
 
static int kFindInL1 (const poly p, const kStrategy strat)
 
void enterTShift (LObject p, kStrategy strat, int atT=-1)
 
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
int redFirstShift (LObject *h, kStrategy strat)
 
ideal bbaShift (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
 
static void kDeleteLcm (LObject *P)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 

Variables

EXTERN_VAR denominator_list DENOMINATOR_LIST
 
EXTERN_VAR int strat_nr
 
EXTERN_VAR int HCord
 
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 66 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

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

Definition at line 394 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 28 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 50 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 51 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 37 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 38 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 39 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 30 of file kutil.h.

◆ setmaxL

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

Definition at line 31 of file kutil.h.

◆ setmaxLinc

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

Definition at line 32 of file kutil.h.

◆ setmaxT

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

Definition at line 34 of file kutil.h.

◆ setmaxTinc

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

Definition at line 35 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 64 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 54 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 59 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 61 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 58 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 60 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 56 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 55 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6625 of file kutil.cc.

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

◆ arriRewCriterionPre()

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

Definition at line 6650 of file kutil.cc.

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

◆ 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,
bigintmat * hilb,
kStrategy strat )

Definition at line 2622 of file kstd2.cc.

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

◆ bbaShift()

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

Definition at line 4594 of file kstd2.cc.

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

◆ cancelunit()

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

Definition at line 365 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3211 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly ,
int ,
kStrategy strat )

Definition at line 3452 of file kutil.cc.

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

◆ chainCritSig()

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

Definition at line 3468 of file kutil.cc.

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

◆ cleanT()

void cleanT ( kStrategy strat)

Definition at line 557 of file kutil.cc.

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

◆ clearS()

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

Definition at line 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 10287 of file kutil.cc.

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

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

◆ deleteHC() [2/2]

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

Definition at line 351 of file kutil.cc.

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

◆ deleteInL()

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

Definition at line 1215 of file kutil.cc.

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

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly h,
kStrategy strat )

Definition at line 4239 of file kutil.cc.

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

◆ enterExtendedSpolySig()

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

Definition at line 4323 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1276 of file kutil.cc.

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

◆ enterOnePairNormal()

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

Definition at line 1946 of file kutil.cc.

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

◆ enterOnePairShift()

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

Definition at line 12169 of file kutil.cc.

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

◆ enterpairs()

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

Definition at line 4494 of file kutil.cc.

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

◆ enterpairsShift()

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

Definition at line 12953 of file kutil.cc.

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

◆ enterpairsSig()

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

Definition at line 4520 of file kutil.cc.

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

◆ enterSBba()

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

Definition at line 8794 of file kutil.cc.

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

◆ enterSBbaShift()

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

Definition at line 8894 of file kutil.cc.

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

◆ entersets()

void entersets ( LObject h)

◆ enterSSba()

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

Definition at line 8917 of file kutil.cc.

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

◆ enterSyz()

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

Definition at line 9343 of file kutil.cc.

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

◆ enterT()

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

Definition at line 9143 of file kutil.cc.

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

◆ enterT_strong()

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

Definition at line 9242 of file kutil.cc.

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

◆ enterTShift()

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

Definition at line 12983 of file kutil.cc.

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

◆ exitBuchMora()

void exitBuchMora ( kStrategy strat)

Definition at line 9838 of file kutil.cc.

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

◆ exitSba()

void exitSba ( kStrategy strat)

Definition at line 10041 of file kutil.cc.

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

◆ f5c()

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

Definition at line 4282 of file kstd2.cc.

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

◆ faugereRewCriterion()

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

Definition at line 6566 of file kutil.cc.

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

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy strat)

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

Definition at line 10869 of file kutil.cc.

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

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly pp,
kStrategy strat )

Definition at line 493 of file kutil.cc.

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

◆ homogTest()

BOOLEAN homogTest ( polyset F,
int Fmax )

◆ initBba()

void initBba ( kStrategy strat)

Definition at line 1681 of file kstd1.cc.

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

◆ initBuchMora()

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

Definition at line 9751 of file kutil.cc.

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

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy strat)

Definition at line 9435 of file kutil.cc.

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

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy strat)

Definition at line 9580 of file kutil.cc.

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

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy strat)

Definition at line 9665 of file kutil.cc.

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

◆ initEcartBBA()

void initEcartBBA ( TObject * h)

Definition at line 1308 of file kutil.cc.

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

◆ initEcartNormal()

void initEcartNormal ( TObject * h)

Definition at line 1300 of file kutil.cc.

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

◆ initEcartPairBba()

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

Definition at line 1315 of file kutil.cc.

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

◆ initEcartPairMora()

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

Definition at line 1322 of file kutil.cc.

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

◆ initenterpairs()

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

Definition at line 3816 of file kutil.cc.

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

◆ initHilbCrit()

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

Definition at line 9417 of file kutil.cc.

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

◆ initL()

static LSet initL ( int nr = setmaxL)
inlinestatic

Definition at line 419 of file kutil.h.

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

◆ initR()

KINLINE TObject ** initR ( )

Definition at line 95 of file kInline.h.

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

◆ initS()

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

Definition at line 7590 of file kutil.cc.

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

◆ initSba()

void initSba ( ideal F,
kStrategy strat )

Definition at line 1741 of file kstd1.cc.

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

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

◆ initSbaCrit()

void initSbaCrit ( kStrategy strat)

Definition at line 9498 of file kutil.cc.

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

◆ initSbaPos()

void initSbaPos ( kStrategy strat)

Definition at line 9864 of file kutil.cc.

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

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

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

◆ initSLSba()

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

Definition at line 7783 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy strat)

Definition at line 7935 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

◆ k_GetLeadTerms()

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

Definition at line 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:637
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition pDebug.cc:123
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1336

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

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

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

◆ kCheckStrongCreation()

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

Definition at line 10519 of file kutil.cc.

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

◆ kDebugPrint()

void kDebugPrint ( kStrategy strat)

Output some debug info about a given strategy.

Definition at line 11505 of file kutil.cc.

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

◆ kDeleteLcm()

static void kDeleteLcm ( LObject * P)
inlinestatic

Definition at line 870 of file kutil.h.

871{
872 if (P->lcm!=NULL)
873 {
875 pLmDelete(P->lcm);
876 else
877 pLmFree(P->lcm);
878 P->lcm=NULL;
879 }
880}

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6701 of file kutil.cc.

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

◆ 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_ecart()

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

Definition at line 420 of file kstd2.cc.

421{
422 if (TEST_OPT_LENGTH)
423 {
424 int r=-1; // found, but bad ecart
425 int j=-2; // found, good ecart
426 int jj=-1; // current search
427 loop
428 {
429 jj=kFindDivisibleByInT(strat,L,jj+1);
430 if (jj== -1)
431 {
432 if (j<0) return r; // nothing with good ecart
433 else return j; // end of search, return best found
434 }
435 else if (r<0) r=jj; // save bad ecart found
436 if (strat->T[jj].ecart<=ecart) // good enough
437 {
438 if (strat->T[jj].pLength<=0)
439 strat->T[jj].pLength=strat->T[jj].GetpLength();
440 if (j== -2) j=jj; // first found
441 else if (strat->T[j].pLength > strat->T[jj].pLength) // jj better then j
442 j=jj;
443 if (strat->T[j].pLength<=2) return j; // length already minimal
444 }
445 }
446 }
447 else
448 {
449 int r=-1;
450 int jj=-1;
451 loop
452 {
453 jj=kFindDivisibleByInT(strat,L,jj+1);
454 if (jj== -1)
455 {
456 return r; // nothing found
457 }
458 else if (r== -1) r=jj;
459 if (strat->T[jj].ecart<=ecart) // good enough
460 {
461 return jj;
462 }
463 }
464 }
465}
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_LENGTH
Definition options.h:132

◆ 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 841 of file kutil.h.

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

◆ kFindInT()

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

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

Definition at line 710 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 735 of file kutil.cc.

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

◆ kFindNextDivisibleByInS()

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

Definition at line 571 of file kstd2.cc.

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

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

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

◆ kFreeStrat()

void kFreeStrat ( kStrategy strat)

◆ kNF2() [1/2]

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

Definition at line 4107 of file kstd2.cc.

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

◆ kNF2() [2/2]

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

Definition at line 3944 of file kstd2.cc.

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

◆ kNF2Bound() [1/2]

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

Definition at line 4193 of file kstd2.cc.

4194{
4195 assume(!idIs0(q));
4196 assume(!(idIs0(F)&&(Q==NULL)));
4197// lazy_reduce flags: can be combined by |
4198//#define KSTD_NF_LAZY 1
4199 // do only a reduction of the leading term
4200//#define KSTD_NF_NONORM 4
4201 // only global: avoid normalization, return a multiply of NF
4202 poly p;
4203 int i;
4204 ideal res;
4205 int max_ind;
4206
4207 //if (idIs0(q))
4208 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4209 //if ((idIs0(F))&&(Q==NULL))
4210 // return idCopy(q); /*F=0*/
4211 //strat->ak = idRankFreeModule(F);
4212 /*- creating temp data structures------------------- -*/
4213 BITSET save1;
4214 SI_SAVE_OPT1(save1);
4216 initBuchMoraCrit(strat);
4217 strat->initEcart = initEcartBBA;
4218 strat->enterS = enterSBba;
4219 /*- set S -*/
4220 strat->sl = -1;
4221#ifndef NO_BUCKETS
4223#endif
4224 /*- init local data struct.---------------------------------------- -*/
4225 /*Shdl=*/initS(F,Q,strat);
4226 /*- compute------------------------------------------------------- -*/
4227 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4228 for (i=IDELEMS(q)-1; i>=0; i--)
4229 {
4230 if (q->m[i]!=NULL)
4231 {
4232 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4233 p = redNFBound(pCopy(q->m[i]),max_ind,
4234 (lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat,bound);
4235 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4236 {
4237 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4239 {
4240 p = redtailBba_Z(p,max_ind,strat);
4241 }
4242 else if (rField_is_Ring(currRing))
4243 {
4244 p = redtailBba_Ring(p,max_ind,strat);
4245 }
4246 else
4247 {
4249 p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
4250 }
4251 }
4252 res->m[i]=p;
4253 }
4254 //else
4255 // res->m[i]=NULL;
4256 }
4257 /*- release temp data------------------------------- -*/
4258 assume(strat->L==NULL); /* strat->L unused */
4259 assume(strat->B==NULL); /* strat->B unused */
4260 omFree(strat->sevS);
4261 omFree(strat->ecartS);
4262 assume(strat->T==NULL);//omfree(strat->T);
4263 assume(strat->sevT==NULL);//omfree(strat->sevT);
4264 assume(strat->R==NULL);//omfree(strat->R);
4265 omfree(strat->S_2_R);
4266 omfree(strat->fromQ);
4267 strat->fromQ=NULL;
4268 idDelete(&strat->Shdl);
4269 SI_RESTORE_OPT1(save1);
4270 if (TEST_OPT_PROT) PrintLn();
4271 return res;
4272}
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:2511

◆ kNF2Bound() [2/2]

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

Definition at line 4032 of file kstd2.cc.

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

◆ ksCreateShortSpoly()

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

Definition at line 1446 of file kspoly.cc.

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

◆ ksCreateSpoly()

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

Definition at line 1203 of file kspoly.cc.

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

◆ ksOldCreateSpoly()

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

Definition at line 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:1456
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1916
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:294
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition pDebug.cc:115
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151

◆ ksReducePolyBound()

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

Definition at line 590 of file kspoly.cc.

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

◆ ksReducePolyGCD()

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

◆ ksReducePolyLC()

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

Definition at line 477 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 737 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 943 of file kspoly.cc.

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

◆ ksReducePolyTail() [1/2]

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

Definition at line 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 1350 of file kspoly.cc.

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

◆ ksReducePolyZ()

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

◆ kStratChangeTailRing()

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

Definition at line 10961 of file kutil.cc.

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

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy strat)

Definition at line 11058 of file kutil.cc.

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

◆ kTest()

BOOLEAN kTest ( kStrategy strat)

Definition at line 1011 of file kutil.cc.

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

◆ kTest_L()

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

Definition at line 923 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy strat)

Definition at line 1056 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 796 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy strat)

Definition at line 1074 of file kutil.cc.

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

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

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

◆ messageSets()

void messageSets ( kStrategy strat)

Definition at line 7540 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int hilbcount,
kStrategy strat )

Definition at line 7508 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int hilbcount,
kStrategy strat )

Definition at line 7521 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy strat)

Definition at line 10409 of file kutil.cc.

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

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

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

Definition at line 4848 of file kutil.cc.

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

◆ posInL0()

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

Definition at line 5618 of file kutil.cc.

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

◆ posInL10()

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

Definition at line 1360 of file kstd1.cc.

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

◆ posInL10Ring()

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

◆ posInL11()

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

Definition at line 5806 of file kutil.cc.

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

◆ posInL110()

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

Definition at line 6062 of file kutil.cc.

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

◆ posInL11Ring()

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

Definition at line 5848 of file kutil.cc.

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

◆ posInL11Ringls()

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

Definition at line 5916 of file kutil.cc.

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

◆ posInL13()

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

Definition at line 6149 of file kutil.cc.

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

◆ posInL15()

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

Definition at line 6184 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6219 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6259 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 5794 of file kutil.cc.

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

◆ posInLF5CRing()

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

Definition at line 5882 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5676 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5701 of file kutil.cc.

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

◆ posInS()

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

Definition at line 4670 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4771 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy strat,
const poly sig )

Definition at line 5765 of file kutil.cc.

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

◆ posInT0()

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

Definition at line 4892 of file kutil.cc.

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

◆ posInT1()

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

Definition at line 4903 of file kutil.cc.

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

◆ posInT11()

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

Definition at line 4960 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5036 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5124 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5191 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5285 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5391 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5517 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4932 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11380 of file kutil.cc.

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

◆ posInT_EcartpLength()

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

Definition at line 5153 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11434 of file kutil.cc.

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

◆ posInT_pLength()

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

Definition at line 11471 of file kutil.cc.

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

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

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

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject * h,
kStrategy strat )

Definition at line 10780 of file kutil.cc.

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

◆ preIntegerCheck()

poly preIntegerCheck ( 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 10540 of file kutil.cc.

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

◆ redFirstShift()

int redFirstShift ( LObject * h,
kStrategy strat )

Definition at line 4974 of file kstd2.cc.

4975{
4976 if (h->IsNull()) return 0;
4977
4978 int at, reddeg,d;
4979 int pass = 0;
4980 int j = 0;
4981
4982 if (! strat->homog)
4983 {
4984 d = h->GetpFDeg() + h->ecart;
4985 reddeg = strat->LazyDegree+d;
4986 }
4987 h->SetShortExpVector();
4988 loop
4989 {
4990 j = kFindDivisibleByInT(strat, h);
4991 if (j < 0)
4992 {
4993 h->SetDegStuffReturnLDeg(strat->LDegLast);
4994 return 1;
4995 }
4996
4998 strat->T[j].pNorm();
4999#ifdef KDEBUG
5000 if (TEST_OPT_DEBUG)
5001 {
5002 PrintS("reduce ");
5003 h->wrp();
5004 PrintS(" with ");
5005 strat->T[j].wrp();
5006 }
5007#endif
5008 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
5009
5010#ifdef KDEBUG
5011 if (TEST_OPT_DEBUG)
5012 {
5013 PrintS("\nto ");
5014 wrp(h->p);
5015 PrintLn();
5016 }
5017#endif
5018 if (h->IsNull())
5019 {
5020 kDeleteLcm(h);
5021 h->Clear();
5022 return 0;
5023 }
5024 h->SetShortExpVector();
5025
5026#if 0
5027 if ((strat->syzComp!=0) && !strat->honey)
5028 {
5029 if ((strat->syzComp>0) &&
5030 (h->Comp() > strat->syzComp))
5031 {
5032 assume(h->MinComp() > strat->syzComp);
5033#ifdef KDEBUG
5034 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
5035#endif
5036 if (strat->homog)
5037 h->SetDegStuffReturnLDeg(strat->LDegLast);
5038 return -2;
5039 }
5040 }
5041#endif
5042 if (!strat->homog)
5043 {
5044 if (!TEST_OPT_OLDSTD && strat->honey)
5045 {
5046 h->SetpFDeg();
5047 if (strat->T[j].ecart <= h->ecart)
5048 h->ecart = d - h->GetpFDeg();
5049 else
5050 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
5051
5052 d = h->GetpFDeg() + h->ecart;
5053 }
5054 else
5055 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
5056 /*- try to reduce the s-polynomial -*/
5057 pass++;
5058 /*
5059 *test whether the polynomial should go to the lazyset L
5060 *-if the degree jumps
5061 *-if the number of pre-defined reductions jumps
5062 */
5063 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
5064 && ((d >= reddeg) || (pass > strat->LazyPass)))
5065 {
5066 h->SetLmCurrRing();
5067 if (strat->posInLDependsOnLength)
5068 h->SetLength(strat->length_pLength);
5069 at = strat->posInL(strat->L,strat->Ll,h,strat);
5070 if (at <= strat->Ll)
5071 {
5072 //int dummy=strat->sl;
5073 /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
5074 //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
5075 if (kFindDivisibleByInT(strat, h) < 0)
5076 return 1;
5077 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
5078#ifdef KDEBUG
5079 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
5080#endif
5081 h->Clear();
5082 return -1;
5083 }
5084 }
5085 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
5086 {
5087 reddeg = d+1;
5088 Print(".%d",d);mflush();
5089 }
5090 }
5091 }
5092}
char length_pLength
Definition kutil.h:386
#define TEST_OPT_REDTHROUGH
Definition options.h:124

◆ redHomog()

int redHomog ( LObject * h,
kStrategy strat )

Definition at line 1154 of file kstd2.cc.

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

◆ redHoney()

int redHoney ( LObject * h,
kStrategy strat )

Definition at line 2114 of file kstd2.cc.

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

◆ redHoneyM()

int redHoneyM ( LObject * h,
kStrategy strat )

◆ redLazy()

int redLazy ( LObject * h,
kStrategy strat )

TEST_OPT_REDTHROUGH &&

Definition at line 1909 of file kstd2.cc.

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

◆ redLiftstd()

int redLiftstd ( LObject * h,
kStrategy strat )

Definition at line 167 of file kLiftstd.cc.

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

◆ redNF()

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

Definition at line 2315 of file kstd2.cc.

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

◆ redNF0()

int redNF0 ( LObject * P,
kStrategy strat )

◆ redNFTail()

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

◆ redRiloc()

int redRiloc ( LObject * h,
kStrategy strat )

Definition at line 385 of file kstd1.cc.

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

◆ redRing()

int redRing ( LObject * h,
kStrategy strat )

Definition at line 992 of file kstd2.cc.

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

◆ redRing_Z()

int redRing_Z ( LObject * h,
kStrategy strat )

Definition at line 724 of file kstd2.cc.

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

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

◆ redSigRing()

int redSigRing ( LObject * h,
kStrategy strat )

Definition at line 1540 of file kstd2.cc.

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

◆ redtail() [1/2]

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

Definition at line 6840 of file kutil.cc.

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

◆ redtail() [2/2]

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

Definition at line 6910 of file kutil.cc.

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

◆ redtailBba() [1/3]

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

Definition at line 6916 of file kutil.cc.

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

◆ redtailBba() [2/3]

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

Definition at line 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 7354 of file kutil.cc.

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7379 of file kutil.cc.

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

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

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

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

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

◆ redtailBbaBound() [1/2]

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

Definition at line 7029 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

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

Definition at line 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 13006 of file kutil.cc.

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

◆ redtailSba()

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

Definition at line 1789 of file kstd2.cc.

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

◆ reorderS()

void reorderS ( int * suc,
kStrategy strat )

Definition at line 4617 of file kutil.cc.

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

◆ replaceInLAndSAndT()

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

Definition at line 9052 of file kutil.cc.

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

◆ sba()

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

Definition at line 2982 of file kstd2.cc.

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

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

◆ sbaRing()

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

Definition at line 11086 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4464 of file kutil.cc.

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

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

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

◆ syzCriterion()

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

Definition at line 6482 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6517 of file kutil.cc.

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

◆ updateResult()

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

Definition at line 10081 of file kutil.cc.

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

◆ updateS()

void updateS ( BOOLEAN toT,
kStrategy strat )

Definition at line 8559 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 67 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 270 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 182 of file kutil.h.

◆ 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 867 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 866 of file kutil.h.