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, intvec **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindDivisibleByInT (const kStrategy strat, const LObject *L, const int start=0)
 return -1 if no divisor is found number of first divisor in T, otherwise
 
int kFindDivisibleByInT_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, intvec *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
 
ideal kNF2 (ideal F, ideal Q, ideal q, kStrategy strat, int lazyReduce)
 
poly kNF2Bound (ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
 
ideal kNF2Bound (ideal F, ideal Q, ideal q, int bound, kStrategy strat, int lazyReduce)
 
void initBba (kStrategy strat)
 
void initSba (ideal F, kStrategy strat)
 
void f5c (kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, intvec *hilb)
 
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL, BOOLEAN redtail=FALSE)
 
int ksReducePolyZ (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyLC (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyGCD (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyBound (LObject *PR, TObject *PW, int bound, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySig (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySigRing (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyTail (LObject *PR, TObject *PW, poly Current, poly spNoether=NULL)
 
KINLINE int ksReducePolyTail (LObject *PR, TObject *PW, LObject *Red)
 
void ksCreateSpoly (LObject *Pair, poly spNoether=NULL, int use_buckets=0, ring tailRing=currRing, poly m1=NULL, poly m2=NULL, TObject **R=NULL)
 
poly ksCreateShortSpoly (poly p1, poly p2, ring tailRing)
 
KINLINE poly ksOldSpolyRed (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldSpolyRedNew (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldCreateSpoly (poly p1, poly p2, poly spNoether=NULL, ring r=currRing)
 
KINLINE void ksOldSpolyTail (poly p1, poly q, poly q2, poly spNoether, ring r=currRing)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
poly preIntegerCheck (ideal F, ideal Q)
 used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L=NULL, TObject *T=NULL, unsigned long new_expbound=0)
 
void kStratInitChangeTailRing (kStrategy strat)
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
 
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
 
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
 
static int kFindInL1 (const poly p, const kStrategy strat)
 
void enterTShift (LObject p, kStrategy strat, int atT=-1)
 
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
int redFirstShift (LObject *h, kStrategy strat)
 
ideal bbaShift (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
static void kDeleteLcm (LObject *P)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 

Variables

EXTERN_VAR denominator_list DENOMINATOR_LIST
 
EXTERN_VAR int strat_nr
 
EXTERN_VAR int HCord
 
EXTERN_VAR int(* test_PosInT )(const TSet T, const int tl, LObject &h)
 
EXTERN_VAR int(* test_PosInL )(const LSet set, const int length, LObject *L, const kStrategy strat)
 

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 65 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

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

Definition at line 393 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 27 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 49 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 50 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 36 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 37 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 38 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 29 of file kutil.h.

◆ setmaxL

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

Definition at line 30 of file kutil.h.

◆ setmaxLinc

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

Definition at line 31 of file kutil.h.

◆ setmaxT

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

Definition at line 33 of file kutil.h.

◆ setmaxTinc

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

Definition at line 34 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 63 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 53 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 58 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 60 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 57 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 59 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 55 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 54 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6623 of file kutil.cc.

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

◆ arriRewCriterionPre()

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

Definition at line 6648 of file kutil.cc.

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

◆ arriRewDummy()

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

Definition at line 1255 of file kInline.h.

1256{
1257 return FALSE;
1258}

◆ bba()

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

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

◆ bbaShift()

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

Definition at line 4590 of file kstd2.cc.

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

◆ cancelunit()

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

Definition at line 370 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3209 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly ,
int ,
kStrategy strat )

Definition at line 3450 of file kutil.cc.

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

◆ chainCritSig()

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

Definition at line 3466 of file kutil.cc.

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

◆ cleanT()

void cleanT ( kStrategy strat)

Definition at line 563 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1232 of file kInline.h.

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

◆ completeReduce()

void completeReduce ( kStrategy strat,
BOOLEAN withT = FALSE )

Definition at line 10279 of file kutil.cc.

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

◆ deleteHC() [1/2]

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

Definition at line 291 of file kutil.cc.

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

◆ deleteHC() [2/2]

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

Definition at line 356 of file kutil.cc.

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

◆ deleteInL()

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

Definition at line 1213 of file kutil.cc.

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

◆ deleteInS()

void deleteInS ( int i,
kStrategy strat )

Definition at line 1137 of file kutil.cc.

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly h,
kStrategy strat )

Definition at line 4237 of file kutil.cc.

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

◆ enterExtendedSpolySig()

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

Definition at line 4321 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1274 of file kutil.cc.

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

◆ enterOnePairNormal()

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

Definition at line 1944 of file kutil.cc.

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

◆ enterOnePairShift()

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

Definition at line 12164 of file kutil.cc.

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

◆ enterpairs()

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

Definition at line 4492 of file kutil.cc.

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

◆ enterpairsShift()

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

Definition at line 12948 of file kutil.cc.

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

◆ enterpairsSig()

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

Definition at line 4518 of file kutil.cc.

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

◆ enterSBba()

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

Definition at line 8788 of file kutil.cc.

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

◆ enterSBbaShift()

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

Definition at line 8888 of file kutil.cc.

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

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

◆ enterSyz()

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

Definition at line 9337 of file kutil.cc.

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

◆ enterT()

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

Definition at line 9137 of file kutil.cc.

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

◆ enterT_strong()

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

Definition at line 9236 of file kutil.cc.

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

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

◆ exitBuchMora()

void exitBuchMora ( kStrategy strat)

Definition at line 9830 of file kutil.cc.

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

◆ exitSba()

void exitSba ( kStrategy strat)

Definition at line 10033 of file kutil.cc.

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

◆ f5c()

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

Definition at line 4278 of file kstd2.cc.

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

◆ faugereRewCriterion()

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

Definition at line 6564 of file kutil.cc.

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

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy strat)

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

Definition at line 10868 of file kutil.cc.

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

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly pp,
kStrategy strat )

Definition at line 498 of file kutil.cc.

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

◆ homogTest()

BOOLEAN homogTest ( polyset F,
int Fmax )

◆ initBba()

void initBba ( kStrategy strat)

Definition at line 1682 of file kstd1.cc.

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

◆ initBuchMora()

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

Definition at line 9745 of file kutil.cc.

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

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy strat)

Definition at line 9429 of file kutil.cc.

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

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

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy strat)

Definition at line 9659 of file kutil.cc.

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

◆ initEcartBBA()

void initEcartBBA ( TObject * h)

Definition at line 1306 of file kutil.cc.

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

◆ initEcartNormal()

void initEcartNormal ( TObject * h)

Definition at line 1298 of file kutil.cc.

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

◆ initEcartPairBba()

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

Definition at line 1313 of file kutil.cc.

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

◆ initEcartPairMora()

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

Definition at line 1320 of file kutil.cc.

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

◆ initenterpairs()

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

Definition at line 3814 of file kutil.cc.

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

◆ initHilbCrit()

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

Definition at line 9411 of file kutil.cc.

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

◆ initL()

static LSet initL ( int nr = setmaxL)
inlinestatic

Definition at line 418 of file kutil.h.

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

◆ initR()

KINLINE TObject ** initR ( )

Definition at line 95 of file kInline.h.

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

◆ initS()

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

Definition at line 7588 of file kutil.cc.

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

◆ initSba()

void initSba ( ideal F,
kStrategy strat )

Definition at line 1742 of file kstd1.cc.

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

◆ initSbaBuchMora()

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

Definition at line 9958 of file kutil.cc.

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

◆ initSbaCrit()

void initSbaCrit ( kStrategy strat)

Definition at line 9492 of file kutil.cc.

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

◆ initSbaPos()

void initSbaPos ( kStrategy strat)

Definition at line 9856 of file kutil.cc.

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

◆ initsevT()

KINLINE unsigned long * initsevT ( )

Definition at line 100 of file kInline.h.

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

◆ initSL()

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

Definition at line 7681 of file kutil.cc.

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

◆ initSLSba()

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

Definition at line 7777 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy strat)

Definition at line 7929 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

◆ k_GetLeadTerms()

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

Definition at line 1015 of file kInline.h.

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

◆ k_GetStrongLeadTerms()

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

Definition at line 1057 of file kInline.h.

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

◆ k_LmInit_currRing_2_tailRing() [1/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly p,
ring tailRing )

Definition at line 988 of file kInline.h.

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

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 956 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly p,
ring tailRing )

Definition at line 993 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 965 of file kInline.h.

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

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly p,
ring tailRing )

Definition at line 998 of file kInline.h.

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

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 974 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly p,
ring tailRing )

Definition at line 1003 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 981 of file kInline.h.

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

◆ kCheckSpolyCreation()

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

Definition at line 10479 of file kutil.cc.

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

◆ kCheckStrongCreation()

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

Definition at line 10517 of file kutil.cc.

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

◆ kDebugPrint()

void kDebugPrint ( kStrategy strat)

Output some debug info about a given strategy.

Definition at line 11500 of file kutil.cc.

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

◆ kDeleteLcm()

static void kDeleteLcm ( LObject * P)
inlinestatic

Definition at line 869 of file kutil.h.

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6699 of file kutil.cc.

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

◆ kFindDivisibleByInT()

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

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

Definition at line 321 of file kstd2.cc.

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

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

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

◆ kFindInT()

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

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

Definition at line 716 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 741 of file kutil.cc.

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

◆ kFindNextDivisibleByInS()

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

Definition at line 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:1118
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1051
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:755
static int SI_LOG2_LONG(long v)
Definition si_log2.h:22

◆ kFreeStrat()

void kFreeStrat ( kStrategy strat)

◆ kNF2() [1/2]

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

Definition at line 4103 of file kstd2.cc.

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

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

◆ kNF2Bound() [1/2]

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

Definition at line 4189 of file kstd2.cc.

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

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

◆ 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:723
poly p_LPCopyAndShiftLM(poly p, int sh, const ring r)
Definition shiftgb.cc:35
int p_mFirstVblock(poly p, const ring ri)
Definition shiftop.cc:478
int p_FirstVblock(poly p, const ring r)
Definition shiftop.cc:456

◆ ksCreateSpoly()

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

Definition at line 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:492
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)
Definition shiftop.cc:600
#define R
Definition sirandom.c:27

◆ ksOldCreateSpoly()

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

Definition at line 1191 of file kInline.h.

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

◆ ksOldSpolyRed()

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

Definition at line 1171 of file kInline.h.

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

◆ ksOldSpolyRedNew()

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

Definition at line 1181 of file kInline.h.

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

◆ ksOldSpolyTail()

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

Definition at line 1201 of file kInline.h.

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

◆ ksReducePoly()

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

Definition at line 187 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 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:1470

◆ 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:363
#define nDiv(a, b)
Definition numbers.h:32
#define pSub(a, b)
Definition polys.h:287

◆ ksReducePolyTail() [1/2]

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

Definition at line 1144 of file kInline.h.

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

◆ ksReducePolyTail() [2/2]

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

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

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

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy strat)

Definition at line 11053 of file kutil.cc.

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

◆ kTest()

BOOLEAN kTest ( kStrategy strat)

Definition at line 1010 of file kutil.cc.

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

◆ kTest_L()

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

Definition at line 924 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy strat)

Definition at line 1053 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 799 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy strat)

Definition at line 1071 of file kutil.cc.

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

◆ kTestDivisibleByT0_Z()

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

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

Definition at line 146 of file kstd2.cc.

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

◆ message()

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

Definition at line 7465 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy strat)

Definition at line 7538 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int hilbcount,
kStrategy strat )

Definition at line 7506 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int hilbcount,
kStrategy strat )

Definition at line 7519 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy strat)

Definition at line 10401 of file kutil.cc.

10402{
10403 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10404 return FALSE;
10405 int i,newHCord;
10406 poly oldNoether=strat->kNoether; // to keep previous kNoether
10407 strat->kNoether=NULL;
10408
10409#if 0
10410 if (currRing->weight_all_1)
10411 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10412 else
10413 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10414#else
10415 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10416#endif
10417 if (strat->kNoether==NULL)
10418 {
10419 strat->kNoether=oldNoether;
10420 return FALSE;
10421 }
10422 // now a new kNoether, defined by scComputeHC
10423 pSetCoeff0(strat->kNoether,NULL);
10424 newHCord = p_FDeg(strat->kNoether,currRing);
10425 for(int i=currRing->N; i>0;i--)
10426 {
10427 int j=pGetExp(strat->kNoether,i);
10428 if (j>0)
10429 {
10430 j--;
10431 pSetExp(strat->kNoether,i,j);
10432 }
10433 }
10434 pSetm(strat->kNoether);
10435 if (strat->t_kNoether != NULL)
10436 {
10437 p_LmFree(strat->t_kNoether, strat->tailRing);
10438 strat->t_kNoether=NULL;
10439 }
10440 if (strat->tailRing != currRing)
10442 /* compare old and new noether*/
10443 if (newHCord < HCord) /*- statistics -*/
10444 {
10445 if (TEST_OPT_PROT)
10446 {
10447 Print("H(%d)",newHCord);
10448 mflush();
10449 }
10450 HCord=newHCord;
10451 #ifdef KDEBUG
10452 if (TEST_OPT_DEBUG)
10453 {
10454 Print("H(%d):",newHCord);
10455 wrp(strat->kNoether);
10456 PrintLn();
10457 }
10458 #endif
10459 if (oldNoether!=NULL) pLmFree(oldNoether);
10460 return TRUE;
10461 }
10462 else // no change for HCord -> no change for kNoether
10463 {
10464 p_LmFree(strat->kNoether,currRing);
10465 strat->kNoether=oldNoether;
10466 assume(strat->t_kNoether == NULL);
10467 if (strat->tailRing != currRing)
10469
10470 }
10471 return FALSE;
10472}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition hdegree.cc:1074
VAR int HCord
Definition kutil.cc:244
#define pGetExp(p, i)
Exponent.
Definition polys.h:41

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

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

Definition at line 4846 of file kutil.cc.

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

◆ posInL0()

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

Definition at line 5616 of file kutil.cc.

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

◆ posInL10()

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

Definition at line 1361 of file kstd1.cc.

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

◆ posInL10Ring()

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

◆ posInL11()

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

Definition at line 5804 of file kutil.cc.

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

◆ posInL110()

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

Definition at line 6060 of file kutil.cc.

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

◆ posInL11Ring()

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

Definition at line 5846 of file kutil.cc.

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

◆ posInL11Ringls()

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

Definition at line 5914 of file kutil.cc.

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

◆ posInL13()

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

Definition at line 6147 of file kutil.cc.

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

◆ posInL15()

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

Definition at line 6182 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6217 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6257 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 5792 of file kutil.cc.

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

◆ posInLF5CRing()

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

Definition at line 5880 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5674 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5699 of file kutil.cc.

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

◆ posInS()

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

Definition at line 4668 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4769 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy strat,
const poly sig )

Definition at line 5763 of file kutil.cc.

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

◆ posInT0()

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

Definition at line 4890 of file kutil.cc.

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

◆ posInT1()

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

Definition at line 4901 of file kutil.cc.

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

◆ posInT11()

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

Definition at line 4958 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5034 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5122 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5189 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5283 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5389 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5515 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4930 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11375 of file kutil.cc.

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

◆ posInT_EcartpLength()

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

Definition at line 5151 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11429 of file kutil.cc.

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

◆ posInT_pLength()

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

Definition at line 11466 of file kutil.cc.

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

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

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

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject * h,
kStrategy strat )

Definition at line 10779 of file kutil.cc.

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

◆ preIntegerCheck()

poly preIntegerCheck ( ideal F,
ideal Q )

used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell

Definition at line 10538 of file kutil.cc.

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

◆ redFirstShift()

int redFirstShift ( LObject * h,
kStrategy strat )

Definition at line 4970 of file kstd2.cc.

4971{
4972 if (h->IsNull()) return 0;
4973
4974 int at, reddeg,d;
4975 int pass = 0;
4976 int j = 0;
4977
4978 if (! strat->homog)
4979 {
4980 d = h->GetpFDeg() + h->ecart;
4981 reddeg = strat->LazyDegree+d;
4982 }
4983 h->SetShortExpVector();
4984 loop
4985 {
4986 j = kFindDivisibleByInT(strat, h);
4987 if (j < 0)
4988 {
4989 h->SetDegStuffReturnLDeg(strat->LDegLast);
4990 return 1;
4991 }
4992
4994 strat->T[j].pNorm();
4995#ifdef KDEBUG
4996 if (TEST_OPT_DEBUG)
4997 {
4998 PrintS("reduce ");
4999 h->wrp();
5000 PrintS(" with ");
5001 strat->T[j].wrp();
5002 }
5003#endif
5004 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
5005
5006#ifdef KDEBUG
5007 if (TEST_OPT_DEBUG)
5008 {
5009 PrintS("\nto ");
5010 wrp(h->p);
5011 PrintLn();
5012 }
5013#endif
5014 if (h->IsNull())
5015 {
5016 kDeleteLcm(h);
5017 h->Clear();
5018 return 0;
5019 }
5020 h->SetShortExpVector();
5021
5022#if 0
5023 if ((strat->syzComp!=0) && !strat->honey)
5024 {
5025 if ((strat->syzComp>0) &&
5026 (h->Comp() > strat->syzComp))
5027 {
5028 assume(h->MinComp() > strat->syzComp);
5029#ifdef KDEBUG
5030 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
5031#endif
5032 if (strat->homog)
5033 h->SetDegStuffReturnLDeg(strat->LDegLast);
5034 return -2;
5035 }
5036 }
5037#endif
5038 if (!strat->homog)
5039 {
5040 if (!TEST_OPT_OLDSTD && strat->honey)
5041 {
5042 h->SetpFDeg();
5043 if (strat->T[j].ecart <= h->ecart)
5044 h->ecart = d - h->GetpFDeg();
5045 else
5046 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
5047
5048 d = h->GetpFDeg() + h->ecart;
5049 }
5050 else
5051 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
5052 /*- try to reduce the s-polynomial -*/
5053 pass++;
5054 /*
5055 *test whether the polynomial should go to the lazyset L
5056 *-if the degree jumps
5057 *-if the number of pre-defined reductions jumps
5058 */
5059 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
5060 && ((d >= reddeg) || (pass > strat->LazyPass)))
5061 {
5062 h->SetLmCurrRing();
5063 if (strat->posInLDependsOnLength)
5064 h->SetLength(strat->length_pLength);
5065 at = strat->posInL(strat->L,strat->Ll,h,strat);
5066 if (at <= strat->Ll)
5067 {
5068 //int dummy=strat->sl;
5069 /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
5070 //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
5071 if (kFindDivisibleByInT(strat, h) < 0)
5072 return 1;
5073 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
5074#ifdef KDEBUG
5075 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
5076#endif
5077 h->Clear();
5078 return -1;
5079 }
5080 }
5081 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
5082 {
5083 reddeg = d+1;
5084 Print(".%d",d);mflush();
5085 }
5086 }
5087 }
5088}
char length_pLength
Definition kutil.h:385
#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:404
int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject *L)
return -1 if no divisor is found number of first divisor in S, otherwise
Definition kstd2.cc:468
#define RED_CANONICALIZE
Definition kutil.h:36
#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:37
static void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition nc.h:275
#define nNormalize(n)
Definition numbers.h:30
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:860
#define pNormalize(p)
Definition polys.h:317
#define pSize(p)
Definition polys.h:318

◆ redNF0()

int redNF0 ( LObject * P,
kStrategy strat )

◆ redNFTail()

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

◆ redRiloc()

int redRiloc ( LObject * h,
kStrategy strat )

Definition at line 386 of file kstd1.cc.

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

◆ 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:9046
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:10779
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition kutil.cc:1693

◆ redtail() [1/2]

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

Definition at line 6838 of file kutil.cc.

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

◆ redtail() [2/2]

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

Definition at line 6908 of file kutil.cc.

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

◆ redtailBba() [1/3]

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

Definition at line 6914 of file kutil.cc.

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

◆ redtailBba() [2/3]

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

Definition at line 1209 of file kInline.h.

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

◆ redtailBba() [3/3]

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

◆ redtailBba_NF()

poly redtailBba_NF ( poly p,
kStrategy strat )

Definition at line 7352 of file kutil.cc.

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7377 of file kutil.cc.

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

◆ redtailBba_Ring() [2/2]

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

Definition at line 1221 of file kInline.h.

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

◆ redtailBba_Z() [1/2]

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

Definition at line 7271 of file kutil.cc.

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

◆ redtailBba_Z() [2/2]

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

Definition at line 1226 of file kInline.h.

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

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7142 of file kutil.cc.

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

◆ redtailBbaBound() [1/2]

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

Definition at line 7027 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

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

Definition at line 1215 of file kInline.h.

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

◆ redtailBbaShift()

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

Definition at line 13001 of file kutil.cc.

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

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

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

◆ replaceInLAndSAndT()

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

Definition at line 9046 of file kutil.cc.

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

◆ sba()

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

Definition at line 2980 of file kstd2.cc.

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

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject * h,
kStrategy strat )

Definition at line 1693 of file kutil.cc.

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

◆ sbaRing()

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

Definition at line 11081 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4462 of file kutil.cc.

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

◆ superenterpairsShift()

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

◆ superenterpairsSig()

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

Definition at line 4475 of file kutil.cc.

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

◆ syzCriterion()

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

Definition at line 6480 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6515 of file kutil.cc.

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

◆ updateResult()

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

Definition at line 10073 of file kutil.cc.

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

◆ updateS()

void updateS ( BOOLEAN toT,
kStrategy strat )

Definition at line 8553 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 66 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 269 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 181 of file kutil.h.

◆ test_PosInL

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

Definition at line 866 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 865 of file kutil.h.