My Project
Data Structures | Macros | Typedefs | Functions | Variables
kutil.h File Reference
#include <string.h>
#include "omalloc/omalloc.h"
#include "omalloc/omallocClass.h"
#include "misc/mylimits.h"
#include "kernel/polys.h"
#include "polys/operations/pShallowCopyDelete.h"
#include "kernel/structs.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/kInline.h"
#include "kernel/GBEngine/shiftgb.h"

Go to the source code of this file.

Data Structures

struct  denominator_list_s
 
class  sTObject
 
class  sLObject
 
class  skStrategy
 

Macros

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

Typedefs

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

Functions

void deleteHC (poly *p, int *e, int *l, kStrategy strat)
 
void deleteHC (LObject *L, kStrategy strat, BOOLEAN fromNext=FALSE)
 
void deleteInS (int i, kStrategy strat)
 
void cleanT (kStrategy strat)
 
static LSet initL (int nr=setmaxL)
 
void deleteInL (LSet set, int *length, int j, kStrategy strat)
 
void enterL (LSet *set, int *length, int *LSetmax, LObject p, int at)
 
void enterSBba (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSBbaShift (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSSba (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void initEcartPairBba (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
 
void initEcartPairMora (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
 
int posInS (const kStrategy strat, const int length, const poly p, const int ecart_p)
 
int posInSMonFirst (const kStrategy strat, const int length, const poly p)
 
int posInIdealMonFirst (const ideal F, const poly p, int start=0, int end=-1)
 
int posInT0 (const TSet set, const int length, LObject &p)
 
int posInT1 (const TSet set, const int length, LObject &p)
 
int posInT2 (const TSet set, const int length, LObject &p)
 
int posInT11 (const TSet set, const int length, LObject &p)
 
int posInTSig (const TSet set, const int length, LObject &p)
 
int posInT110 (const TSet set, const int length, LObject &p)
 
int posInT13 (const TSet set, const int length, LObject &p)
 
int posInT15 (const TSet set, const int length, LObject &p)
 
int posInT17 (const TSet set, const int length, LObject &p)
 
int posInT17_c (const TSet set, const int length, LObject &p)
 
int posInT19 (const TSet set, const int length, LObject &p)
 
int posInT_EcartpLength (const TSet set, const int length, LObject &p)
 
int posInT_EcartFDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_FDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_pLength (const TSet set, const int length, LObject &p)
 
void reorderS (int *suc, kStrategy strat)
 
int posInLF5C (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLSig (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLSigRing (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInSyz (const kStrategy strat, const poly sig)
 
int posInL0 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL11 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL11Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLF5CRing (const LSet set, int start, const int length, LObject *L, const kStrategy strat)
 
int posInL11Ringls (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL13 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL15 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL15Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL17 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL10 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL10Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL110 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
KINLINE poly redtailBba (poly p, int end_pos, kStrategy strat, BOOLEAN normalize=FALSE)
 
KINLINE poly redtailBbaBound (poly p, int end_pos, kStrategy strat, int bound, BOOLEAN normalize=FALSE)
 
KINLINE poly redtailBba_Ring (poly p, int end_pos, kStrategy strat)
 
KINLINE poly redtailBba_Z (poly p, int end_pos, kStrategy strat)
 
poly redtailBba_NF (poly p, kStrategy strat)
 
poly redtailBba_Ring (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_Z (LObject *L, int end_pos, kStrategy strat)
 
void redtailBbaAlsoLC_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailBbaBound (LObject *L, int end_pos, kStrategy strat, int bound, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailSba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailBba (TObject *T, int end_pos, kStrategy strat)
 
poly redtail (poly p, int end_pos, kStrategy strat)
 
poly redtail (LObject *L, int end_pos, kStrategy strat)
 
poly redNF (poly h, int &max_ind, int nonorm, kStrategy strat)
 
int redNF0 (LObject *P, kStrategy strat)
 
poly redNFTail (poly h, const int sl, kStrategy strat)
 
int redHoney (LObject *h, kStrategy strat)
 
int redHoneyM (LObject *h, kStrategy strat)
 
int redLiftstd (LObject *h, kStrategy strat)
 
int redRing (LObject *h, kStrategy strat)
 
int redRing_Z (LObject *h, kStrategy strat)
 
int redRiloc (LObject *h, kStrategy strat)
 
void enterExtendedSpoly (poly h, kStrategy strat)
 
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
 
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
int redLazy (LObject *h, kStrategy strat)
 
int redHomog (LObject *h, kStrategy strat)
 
int redSig (LObject *h, kStrategy strat)
 
int redSigRing (LObject *h, kStrategy strat)
 
void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void enterpairs (poly h, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void entersets (LObject h)
 
void pairs ()
 
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
 
void message (int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
 
void messageStat (int hilbcount, kStrategy strat)
 
void messageStatSBA (int hilbcount, kStrategy strat)
 
void messageSets (kStrategy strat)
 
void initEcartNormal (TObject *h)
 
void initEcartBBA (TObject *h)
 
void initS (ideal F, ideal Q, kStrategy strat)
 
void initSL (ideal F, ideal Q, kStrategy strat)
 
void initSLSba (ideal F, ideal Q, kStrategy strat)
 
void initSyzRules (kStrategy strat)
 
void updateS (BOOLEAN toT, kStrategy strat)
 
void enterSyz (LObject &p, kStrategy strat, int atT)
 
void enterT (LObject &p, kStrategy strat, int atT=-1)
 
void replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
void enterT_strong (LObject &p, kStrategy strat, int atT=-1)
 
void cancelunit (LObject *p, BOOLEAN inNF=FALSE)
 
void HEckeTest (poly pp, kStrategy strat)
 
void initBuchMoraCrit (kStrategy strat)
 
void initSbaCrit (kStrategy strat)
 
void initHilbCrit (ideal F, ideal Q, intvec **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found More...
 
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 More...
 
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 More...
 
int kFindDivisibleByInS (const kStrategy strat, int *max_ind, LObject *L)
 return -1 if no divisor is found number of first divisor in S, otherwise More...
 
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 More...
 
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 More...
 
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 More...
 
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. More...
 
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
 
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
 
static int kFindInL1 (const poly p, const kStrategy strat)
 
void enterTShift (LObject p, kStrategy strat, int atT=-1)
 
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
int redFirstShift (LObject *h, kStrategy strat)
 
ideal bbaShift (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
static void kDeleteLcm (LObject *P)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 

Variables

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

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 65 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

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

Definition at line 395 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 27 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 49 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 50 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 36 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 37 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 38 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 29 of file kutil.h.

◆ setmaxL

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

Definition at line 30 of file kutil.h.

◆ setmaxLinc

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

Definition at line 31 of file kutil.h.

◆ setmaxT

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

Definition at line 33 of file kutil.h.

◆ setmaxTinc

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

Definition at line 34 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 63 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 53 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 58 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 60 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 57 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 59 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 55 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 54 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6664 of file kutil.cc.

6665{
6667 return FALSE;
6668 poly p1 = pOne();
6669 poly p2 = pOne();
6670 for (int ii=strat->sl; ii>start; ii--)
6671 {
6672 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6673 {
6674 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6675 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6676 if (!(pLmCmp(p1,p2) == 1))
6677 {
6678 pDelete(&p1);
6679 pDelete(&p2);
6680 return TRUE;
6681 }
6682 }
6683 }
6684 pDelete(&p1);
6685 pDelete(&p2);
6686 return FALSE;
6687}
#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:1423
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1908
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:485

◆ arriRewCriterionPre()

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

Definition at line 6689 of file kutil.cc.

6690{
6691 //Over Rings, there are still some changes to do: considering coeffs
6693 return FALSE;
6694 int found = -1;
6695 for (int i=strat->Bl; i>-1; i--)
6696 {
6697 if (pLmEqual(strat->B[i].sig,sig))
6698 {
6699 found = i;
6700 break;
6701 }
6702 }
6703 if (found != -1)
6704 {
6705 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6706 {
6707 deleteInL(strat->B,&strat->Bl,found,strat);
6708 }
6709 else
6710 {
6711 return TRUE;
6712 }
6713 }
6714 poly p1 = pOne();
6715 poly p2 = pOne();
6716 for (int ii=strat->sl; ii>-1; ii--)
6717 {
6718 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6719 {
6720 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6721 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6722 if (!(pLmCmp(p1,p2) == 1))
6723 {
6724 pDelete(&p1);
6725 pDelete(&p2);
6726 return TRUE;
6727 }
6728 }
6729 }
6730 pDelete(&p1);
6731 pDelete(&p2);
6732 return FALSE;
6733}
int i
Definition: cfEzgcd.cc:132
int Bl
Definition: kutil.h:352
LSet B
Definition: kutil.h:328
bool found
Definition: facFactorize.cc:55
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1215
#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 1264 of file kInline.h.

1265{
1266 return FALSE;
1267}

◆ bba()

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

Definition at line 2642 of file kstd2.cc.

2643{
2644 int red_result = 1;
2645 int olddeg,reduc;
2646 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2647 BOOLEAN withT = FALSE;
2648 BITSET save;
2649 SI_SAVE_OPT1(save);
2650
2651 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2653 initBuchMoraPosRing(strat);
2654 else
2655 initBuchMoraPos(strat);
2656 initHilbCrit(F,Q,&hilb,strat);
2657 initBba(strat);
2658 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2659 /*Shdl=*/initBuchMora(F, Q,strat);
2660 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2661 reduc = olddeg = 0;
2662
2663#ifndef NO_BUCKETS
2665 strat->use_buckets = 1;
2666#endif
2667 // redtailBBa against T for inhomogeneous input
2668 if (!TEST_OPT_OLDSTD)
2669 withT = ! strat->homog;
2670
2671 // strat->posInT = posInT_pLength;
2672 kTest_TS(strat);
2673
2674#ifdef HAVE_TAIL_RING
2675 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2677#endif
2678 if (BVERBOSE(23))
2679 {
2680 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2681 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2682 kDebugPrint(strat);
2683 }
2684
2685
2686#ifdef KDEBUG
2687 //kDebugPrint(strat);
2688#endif
2689 /* compute------------------------------------------------------- */
2690 while (strat->Ll >= 0)
2691 {
2692 #ifdef KDEBUG
2693 if (TEST_OPT_DEBUG) messageSets(strat);
2694 #endif
2695 if (siCntrlc)
2696 {
2697 while (strat->Ll >= 0)
2698 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2699 strat->noClearS=TRUE;
2700 }
2702 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2703 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2704 {
2705 /*
2706 *stops computation if
2707 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2708 *a predefined number Kstd1_deg
2709 */
2710 while ((strat->Ll >= 0)
2711 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2712 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2713 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2714 )
2715 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2716 if (strat->Ll<0) break;
2717 else strat->noClearS=TRUE;
2718 }
2719 if (strat->Ll== 0) strat->interpt=TRUE;
2720 /* picks the last element from the lazyset L */
2721 strat->P = strat->L[strat->Ll];
2722 strat->Ll--;
2723
2724 if (pNext(strat->P.p) == strat->tail)
2725 {
2726 // deletes the short spoly
2728 pLmDelete(strat->P.p);
2729 else
2730 pLmFree(strat->P.p);
2731 strat->P.p = NULL;
2732 poly m1 = NULL, m2 = NULL;
2733
2734 // check that spoly creation is ok
2735 while (strat->tailRing != currRing &&
2736 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2737 {
2738 assume(m1 == NULL && m2 == NULL);
2739 // if not, change to a ring where exponents are at least
2740 // large enough
2741 if (!kStratChangeTailRing(strat))
2742 {
2743 WerrorS("OVERFLOW...");
2744 break;
2745 }
2746 }
2747 // create the real one
2748 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2749 strat->tailRing, m1, m2, strat->R);
2750 }
2751 else if (strat->P.p1 == NULL)
2752 {
2753 if (strat->minim > 0)
2754 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2755 // for input polys, prepare reduction
2756 strat->P.PrepareRed(strat->use_buckets);
2757 }
2758
2759 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2760 {
2761 red_result = 0;
2762 }
2763 else
2764 {
2765 if (TEST_OPT_PROT)
2766 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2767 &olddeg,&reduc,strat, red_result);
2768
2769 /* reduction of the element chosen from L */
2770 red_result = strat->red(&strat->P,strat);
2771 if (errorreported) break;
2772 }
2773
2774 if (strat->overflow)
2775 {
2776 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2777 }
2778
2779 // reduction to non-zero new poly
2780 if (red_result == 1)
2781 {
2782 // get the polynomial (canonicalize bucket, make sure P.p is set)
2783 strat->P.GetP(strat->lmBin);
2784 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2785 // but now, for entering S, T, we reset it
2786 // in the inhomogeneous case: FDeg == pFDeg
2787 if (strat->homog) strat->initEcart(&(strat->P));
2788
2789 /* statistic */
2790 if (TEST_OPT_PROT) PrintS("s");
2791
2792 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2793
2794 // reduce the tail and normalize poly
2795 // in the ring case we cannot expect LC(f) = 1,
2796 strat->redTailChange=FALSE;
2797
2798 /* if we are computing over Z we always want to try and cut down
2799 * the coefficients in the tail terms */
2801 {
2802 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2803 }
2804
2806 {
2807 strat->P.pCleardenom();
2809 {
2810 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2811 strat->P.pCleardenom();
2812 if (strat->redTailChange) { strat->P.t_p=NULL; }
2813 }
2814 }
2815 else
2816 {
2817 strat->P.pNorm();
2819 {
2820 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2821 if (strat->redTailChange) { strat->P.t_p=NULL; }
2822 }
2823 }
2824
2825#ifdef KDEBUG
2826 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2827#endif /* KDEBUG */
2828
2829 // min_std stuff
2830 if ((strat->P.p1==NULL) && (strat->minim>0))
2831 {
2832 if (strat->minim==1)
2833 {
2834 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2835 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2836 }
2837 else
2838 {
2839 strat->M->m[minimcnt]=strat->P.p2;
2840 strat->P.p2=NULL;
2841 }
2842 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2843 pNext(strat->M->m[minimcnt])
2844 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2845 strat->tailRing, currRing,
2846 currRing->PolyBin);
2847 minimcnt++;
2848 }
2849
2850 // enter into S, L, and T
2851 if (((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2852 && ((!TEST_OPT_IDELIM) || (p_Deg(strat->P.p,currRing) > 0)))
2853 {
2854 strat->P.SetShortExpVector();
2855 enterT(strat->P, strat);
2857 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2858 else
2859 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2860 // posInS only depends on the leading term
2861 strat->enterS(strat->P, pos, strat, strat->tl);
2862#if 0
2863 int pl=pLength(strat->P.p);
2864 if (pl==1)
2865 {
2866 //if (TEST_OPT_PROT)
2867 //PrintS("<1>");
2868 }
2869 else if (pl==2)
2870 {
2871 //if (TEST_OPT_PROT)
2872 //PrintS("<2>");
2873 }
2874#endif
2875 }
2876 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2877// Print("[%d]",hilbeledeg);
2878 kDeleteLcm(&strat->P);
2879 if (strat->s_poly!=NULL)
2880 {
2881 // the only valid entries are: strat->P.p,
2882 // strat->tailRing (read-only, keep it)
2883 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2884 if (strat->s_poly(strat))
2885 {
2886 // we are called AFTER enterS, i.e. if we change P
2887 // we have to add it also to S/T
2888 // and add pairs
2889 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2890 enterT(strat->P, strat);
2892 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2893 else
2894 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2895 strat->enterS(strat->P, pos, strat, strat->tl);
2896 }
2897 }
2898 }
2899 else if (strat->P.p1 == NULL && strat->minim > 0)
2900 {
2901 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2902 }
2903
2904#ifdef KDEBUG
2905 memset(&(strat->P), 0, sizeof(strat->P));
2906#endif /* KDEBUG */
2907 kTest_TS(strat);
2908 }
2909#ifdef KDEBUG
2910 if (TEST_OPT_DEBUG) messageSets(strat);
2911#endif /* KDEBUG */
2912
2913 if (TEST_OPT_SB_1)
2914 {
2916 {
2917 int k=1;
2918 int j;
2919 while(k<=strat->sl)
2920 {
2921 j=0;
2922 loop
2923 {
2924 if (j>=k) break;
2925 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2926 j++;
2927 }
2928 k++;
2929 }
2930 }
2931 }
2932 /* complete reduction of the standard basis--------- */
2933 if (TEST_OPT_REDSB)
2934 {
2935 completeReduce(strat);
2936 if (strat->completeReduce_retry)
2937 {
2938 // completeReduce needed larger exponents, retry
2939 // to reduce with S (instead of T)
2940 // and in currRing (instead of strat->tailRing)
2941#ifdef HAVE_TAIL_RING
2942 if(currRing->bitmask>strat->tailRing->bitmask)
2943 {
2945 cleanT(strat);strat->tailRing=currRing;
2946 int i;
2947 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2948 completeReduce(strat);
2949 }
2950 if (strat->completeReduce_retry)
2951#endif
2952 Werror("exponent bound is %ld",currRing->bitmask);
2953 }
2954 }
2955 else if (TEST_OPT_PROT) PrintLn();
2956 /* release temp data-------------------------------- */
2957 exitBuchMora(strat);
2958 /* postprocessing for GB over ZZ --------------------*/
2959 if (!errorreported)
2960 {
2962 {
2963 for(int i = 0;i<=strat->sl;i++)
2964 {
2965 if(!nGreaterZero(pGetCoeff(strat->S[i])))
2966 {
2967 strat->S[i] = pNeg(strat->S[i]);
2968 }
2969 }
2970 finalReduceByMon(strat);
2971 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2972 {
2973 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2974 {
2975 strat->S[i] = pNeg(strat->Shdl->m[i]);
2976 }
2977 }
2978 }
2979 //else if (rField_is_Ring(currRing))
2980 // finalReduceByMon(strat);
2981 }
2982// if (TEST_OPT_WEIGHTM)
2983// {
2984// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2985// if (ecartWeights)
2986// {
2987// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2988// ecartWeights=NULL;
2989// }
2990// }
2991 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
2992 SI_RESTORE_OPT1(save);
2993 /* postprocessing for GB over Q-rings ------------------*/
2994 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2995
2996 idTest(strat->Shdl);
2997
2998 return (strat->Shdl);
2999}
int BOOLEAN
Definition: auxiliary.h:87
int k
Definition: cfEzgcd.cc:99
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:377
unsigned syzComp
Definition: kutil.h:354
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:383
char interpt
Definition: kutil.h:371
char redTailChange
Definition: kutil.h:399
char completeReduce_retry
Definition: kutil.h:403
void(* initEcart)(TObject *L)
Definition: kutil.h:280
char noClearS
Definition: kutil.h:402
char overflow
Definition: kutil.h:404
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:372
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
STATIC_VAR jList * Q
Definition: janet.cc:30
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1214
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1239
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:1208
void initBba(kStrategy strat)
Definition: kstd1.cc:1689
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:49
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:11560
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:7512
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:9800
void enterT(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9178
BOOLEAN kTest_TS(kStrategy strat)
Definition: kutil.cc:1073
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4509
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition: kutil.cc:7188
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
Definition: kutil.cc:9458
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:9627
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition: kutil.cc:11021
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:9885
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:4685
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition: kutil.cc:10534
void cleanT(kStrategy strat)
Definition: kutil.cc:565
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10128
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4478
void kStratInitChangeTailRing(kStrategy strat)
Definition: kutil.cc:11114
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9476
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition: kutil.cc:10340
void initBuchMoraPosRing(kStrategy strat)
Definition: kutil.cc:9713
void messageSets(kStrategy strat)
Definition: kutil.cc:7585
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7553
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition: kutil.cc:10928
static void kDeleteLcm(LObject *P)
Definition: kutil.h:880
#define assume(x)
Definition: mod2.h:389
#define pNext(p)
Definition: monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
#define nGreaterZero(n)
Definition: numbers.h:27
#define NULL
Definition: omList.c:12
VAR BOOLEAN siCntrlc
Definition: options.c:14
#define TEST_OPT_IDLIFT
Definition: options.h:130
#define TEST_OPT_INTSTRATEGY
Definition: options.h:111
#define BVERBOSE(a)
Definition: options.h:35
#define TEST_OPT_REDTAIL
Definition: options.h:117
#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:124
#define TEST_OPT_REDSB
Definition: options.h:105
#define TEST_OPT_DEGBOUND
Definition: options.h:114
#define TEST_OPT_SB_1
Definition: options.h:120
#define TEST_OPT_PROT
Definition: options.h:104
#define TEST_OPT_IDELIM
Definition: options.h:131
#define TEST_OPT_DEBUG
Definition: options.h:109
#define TEST_OPT_CONTENTSB
Definition: options.h:128
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:106
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587
static int pLength(poly a)
Definition: p_polys.h:188
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
#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:509
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:760
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define IDELEMS(i)
Definition: simpleideals.h:23
#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 4608 of file kstd2.cc.

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

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

◆ chainCritNormal()

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

Definition at line 3217 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3458 of file kutil.cc.

3459{
3460 if (strat->pairtest!=NULL)
3461 {
3462 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3463 strat->pairtest=NULL;
3464 }
3465 /*
3466 *the elements of B enter L
3467 */
3468 kMergeBintoL(strat);
3469}

◆ chainCritSig()

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

Definition at line 3474 of file kutil.cc.

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

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 565 of file kutil.cc.

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

1241{
1242 assume(p_sev == pGetShortExpVector(p));
1243 if (strat->noClearS) return;
1244 #ifdef HAVE_RINGS
1246 {
1247 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1248 return;
1249 if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1250 return;
1251 }
1252 else
1253 #endif
1254 {
1255 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1256 }
1257 deleteInS((*at),strat);
1258 (*at)--;
1259 (*k)--;
1260}

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10340 of file kutil.cc.

10341{
10342 int i;
10343 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10344 LObject L;
10345
10346#ifdef KDEBUG
10347 // need to set this: during tailreductions of T[i], T[i].max is out of
10348 // sync
10349 sloppy_max = TRUE;
10350#endif
10351
10352 strat->noTailReduction = FALSE;
10353 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10354 if (TEST_OPT_PROT)
10355 {
10356 PrintLn();
10357// if (timerv) writeTime("standard base computed:");
10358 }
10359 if (TEST_OPT_PROT)
10360 {
10361 Print("(S:%d)",strat->sl);mflush();
10362 }
10363 for (i=strat->sl; i>=low; i--)
10364 {
10365 int end_pos=strat->sl;
10366 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10367 if (strat->ak==0) end_pos=i-1;
10368 TObject* T_j = strat->s_2_t(i);
10369 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10370 {
10371 L = *T_j;
10372 #ifdef KDEBUG
10373 if (TEST_OPT_DEBUG)
10374 {
10375 Print("test S[%d]:",i);
10376 p_wrp(L.p,currRing,strat->tailRing);
10377 PrintLn();
10378 }
10379 #endif
10381 strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10382 else
10383 strat->S[i] = redtail(&L, strat->sl, strat);
10384 #ifdef KDEBUG
10385 if (TEST_OPT_DEBUG)
10386 {
10387 Print("to (tailR) S[%d]:",i);
10388 p_wrp(strat->S[i],currRing,strat->tailRing);
10389 PrintLn();
10390 }
10391 #endif
10392
10393 if (strat->redTailChange)
10394 {
10395 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10396 if (pNext(T_j->p) != NULL)
10397 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10398 else
10399 T_j->max_exp = NULL;
10400 }
10402 T_j->pCleardenom();
10403 }
10404 else
10405 {
10406 assume(currRing == strat->tailRing);
10407 #ifdef KDEBUG
10408 if (TEST_OPT_DEBUG)
10409 {
10410 Print("test S[%d]:",i);
10411 p_wrp(strat->S[i],currRing,strat->tailRing);
10412 PrintLn();
10413 }
10414 #endif
10416 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10417 else
10418 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10420 {
10422 {
10423 number n;
10424 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10425 if (!nIsOne(n))
10426 {
10428 denom->n=nInvers(n);
10429 denom->next=DENOMINATOR_LIST;
10430 DENOMINATOR_LIST=denom;
10431 }
10432 nDelete(&n);
10433 }
10434 else
10435 {
10436 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10437 }
10438 }
10439 #ifdef KDEBUG
10440 if (TEST_OPT_DEBUG)
10441 {
10442 Print("to (-tailR) S[%d]:",i);
10443 p_wrp(strat->S[i],currRing,strat->tailRing);
10444 PrintLn();
10445 }
10446 #endif
10447 }
10448 if (TEST_OPT_PROT)
10449 PrintS("-");
10450 }
10451 if (TEST_OPT_PROT) PrintLn();
10452#ifdef KDEBUG
10453 sloppy_max = FALSE;
10454#endif
10455}
char noTailReduction
Definition: kutil.h:378
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:6883
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:6959
STATIC_VAR BOOLEAN sloppy_max
Definition: kutil.cc:800
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)
Definition: omAllocDecl.h:210
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:1138
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:2950
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2841
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 294 of file kutil.cc.

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

◆ deleteHC() [2/2]

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

Definition at line 359 of file kutil.cc.

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

◆ deleteInL()

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

Definition at line 1215 of file kutil.cc.

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

◆ deleteInS()

void deleteInS ( int  i,
kStrategy  strat 
)

Definition at line 1139 of file kutil.cc.

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

4250{
4251 if (nIsOne(pGetCoeff(h))) return;
4252 number gcd;
4253 number zero=n_Init(0,currRing->cf);
4254 bool go = false;
4255 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4256 {
4257 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4258 go = true;
4259 }
4260 else
4261 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4262 if (go || !nIsOne(gcd))
4263 {
4264 poly p = h->next;
4265 if (!go)
4266 {
4267 number tmp = gcd;
4268 gcd = n_Ann(gcd,currRing->cf);
4269 nDelete(&tmp);
4270 }
4271 p_Test(p,strat->tailRing);
4272 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4273
4274 if (p != NULL)
4275 {
4276 if (TEST_OPT_PROT)
4277 {
4278 PrintS("Z");
4279 }
4280#ifdef KDEBUG
4281 if (TEST_OPT_DEBUG)
4282 {
4283 PrintS("--- create zero spoly: ");
4284 p_wrp(h,currRing,strat->tailRing);
4285 PrintS(" ---> ");
4286 }
4287#endif
4288 poly tmp = pInit();
4289 pSetCoeff0(tmp, pGetCoeff(p));
4290 for (int i = 1; i <= rVar(currRing); i++)
4291 {
4292 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4293 }
4295 {
4296 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4297 }
4298 p_Setm(tmp, currRing);
4299 p = p_LmFreeAndNext(p, strat->tailRing);
4300 pNext(tmp) = p;
4301 LObject Lp;
4302 Lp.Init();
4303 Lp.p = tmp;
4304 Lp.tailRing = strat->tailRing;
4305 int posx;
4306 if (Lp.p!=NULL)
4307 {
4308 strat->initEcart(&Lp);
4309 if (strat->Ll==-1)
4310 posx =0;
4311 else
4312 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4313 Lp.sev = pGetShortExpVector(Lp.p);
4314 if (strat->tailRing != currRing)
4315 {
4316 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4317 }
4318#ifdef KDEBUG
4319 if (TEST_OPT_DEBUG)
4320 {
4321 p_wrp(tmp,currRing,strat->tailRing);
4322 PrintLn();
4323 }
4324#endif
4325 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4326 }
4327 }
4328 }
4329 nDelete(&zero);
4330 nDelete(&gcd);
4331}
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:661
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:676
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:535
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:959
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1280
#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:1000
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:245
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:709
#define p_Test(p, r)
Definition: p_polys.h:159
#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)
Definition: walkSupport.cc:836

◆ enterExtendedSpolySig()

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

Definition at line 4333 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1280 of file kutil.cc.

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

◆ enterOnePairNormal()

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

Definition at line 1952 of file kutil.cc.

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

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

12235{
12236#ifdef CRITERION_DEBUG
12237 if (TEST_OPT_DEBUG)
12238 {
12239 PrintS("Consider pair ("); wrp(q); PrintS(", "); wrp(p); PrintS(")"); PrintLn();
12240 // also write the LMs in separate lines:
12241 poly lmq = pHead(q);
12242 poly lmp = pHead(p);
12243 pSetCoeff(lmq, n_Init(1, currRing->cf));
12244 pSetCoeff(lmp, n_Init(1, currRing->cf));
12245 Print(" %s\n", pString(lmq));
12246 Print(" %s\n", pString(lmp));
12247 pLmDelete(lmq);
12248 pLmDelete(lmp);
12249 }
12250#endif
12251
12252 /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
12253
12254 /* check this Formats: */
12259
12260 /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
12261
12262 int qfromQ = qisFromQ;
12263
12264 /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */
12265
12266 int l,j,compare;
12267 LObject Lp;
12268 Lp.i_r = -1;
12269
12270#ifdef KDEBUG
12271 Lp.ecart=0; Lp.length=0;
12272#endif
12273 /*- computes the lcm(s[i],p) -*/
12274 Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
12275
12276 /* the V criterion */
12277 if (!pmIsInV(Lp.lcm))
12278 {
12279 strat->cv++; // counter for applying the V criterion
12280 pLmFree(Lp.lcm);
12281#ifdef CRITERION_DEBUG
12282 if (TEST_OPT_DEBUG) PrintS("--- V crit\n");
12283#endif
12284 return TRUE;
12285 }
12286
12287 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
12288 {
12289 if((!((ecartq>0)&&(ecart>0)))
12290 && pHasNotCF(p,q))
12291 {
12292 /*
12293 *the product criterion has applied for (s,p),
12294 *i.e. lcm(s,p)=product of the leading terms of s and p.
12295 *Suppose (s,r) is in L and the leading term
12296 *of p divides lcm(s,r)
12297 *(==> the leading term of p divides the leading term of r)
12298 *but the leading term of s does not divide the leading term of r
12299 *(notice that this condition is automatically satisfied if r is still
12300 *in S), then (s,r) can be cancelled.
12301 *This should be done here because the
12302 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12303 *
12304 *Moreover, skipping (s,r) holds also for the noncommutative case.
12305 */
12306 strat->cp++;
12307 pLmFree(Lp.lcm);
12308#ifdef CRITERION_DEBUG
12309 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12310#endif
12311 return TRUE;
12312 }
12313 else
12314 Lp.ecart = si_max(ecart,ecartq);
12315 if (strat->fromT && (ecartq>ecart))
12316 {
12317 pLmFree(Lp.lcm);
12318#ifdef CRITERION_DEBUG
12319 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12320#endif
12321 return TRUE;
12322 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12323 }
12324 /*
12325 *the set B collects the pairs of type (S[j],p)
12326 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12327 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12328 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12329 */
12330 {
12331 j = strat->Bl;
12332 loop
12333 {
12334 if (j < 0) break;
12335 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12336 if ((compare==1)
12337 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
12338 {
12339 strat->c3++;
12340 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12341 {
12342 pLmFree(Lp.lcm);
12343#ifdef CRITERION_DEBUG
12344 if (TEST_OPT_DEBUG)
12345 {
12346 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12347 }
12348#endif
12349 return TRUE;
12350 }
12351 break;
12352 }
12353 else
12354 if ((compare ==-1)
12355 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
12356 {
12357#ifdef CRITERION_DEBUG
12358 if (TEST_OPT_DEBUG)
12359 {
12360 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12361 }
12362#endif
12363 deleteInL(strat->B,&strat->Bl,j,strat);
12364 strat->c3++;
12365 }
12366 j--;
12367 }
12368 }
12369 }
12370 else /*sugarcrit*/
12371 {
12372 if (ALLOW_PROD_CRIT(strat))
12373 {
12374 // if currRing->nc_type!=quasi (or skew)
12375 // TODO: enable productCrit for super commutative algebras...
12376 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
12377 pHasNotCF(p,q))
12378 {
12379 /*
12380 *the product criterion has applied for (s,p),
12381 *i.e. lcm(s,p)=product of the leading terms of s and p.
12382 *Suppose (s,r) is in L and the leading term
12383 *of p divides lcm(s,r)
12384 *(==> the leading term of p divides the leading term of r)
12385 *but the leading term of s does not divide the leading term of r
12386 *(notice that tis condition is automatically satisfied if r is still
12387 *in S), then (s,r) can be canceled.
12388 *This should be done here because the
12389 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12390 */
12391 strat->cp++;
12392 pLmFree(Lp.lcm);
12393#ifdef CRITERION_DEBUG
12394 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12395#endif
12396 return TRUE;
12397 }
12398 if (strat->fromT && (ecartq>ecart))
12399 {
12400 pLmFree(Lp.lcm);
12401#ifdef CRITERION_DEBUG
12402 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12403#endif
12404 return TRUE;
12405 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12406 }
12407 /*
12408 *the set B collects the pairs of type (S[j],p)
12409 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12410 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12411 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12412 */
12413 for(j = strat->Bl;j>=0;j--)
12414 {
12415 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12416 if (compare==1)
12417 {
12418 strat->c3++;
12419 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12420 {
12421 pLmFree(Lp.lcm);
12422#ifdef CRITERION_DEBUG
12423 if (TEST_OPT_DEBUG)
12424 {
12425 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12426 }
12427#endif
12428 return TRUE;
12429 }
12430 break;
12431 }
12432 else
12433 if (compare ==-1)
12434 {
12435#ifdef CRITERION_DEBUG
12436 if (TEST_OPT_DEBUG)
12437 {
12438 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12439 }
12440#endif
12441 deleteInL(strat->B,&strat->Bl,j,strat);
12442 strat->c3++;
12443 }
12444 }
12445 }
12446 }
12447 /*
12448 *the pair (S[i],p) enters B if the spoly != 0
12449 */
12450 /*- compute the short s-polynomial -*/
12451 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
12452 pNorm(p);
12453 if ((q==NULL) || (p==NULL))
12454 {
12455#ifdef CRITERION_DEBUG
12456 if (TEST_OPT_DEBUG) PrintS("--- q == NULL || p == NULL\n");
12457#endif
12458 return FALSE;
12459 }
12460 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
12461 {
12462 Lp.p=NULL;
12463#ifdef CRITERION_DEBUG
12464 if (TEST_OPT_DEBUG) PrintS("--- pair is from Q\n");
12465#endif
12466 }
12467 else
12468 {
12469// if ( rIsPluralRing(currRing) )
12470// {
12471// if(pHasNotCF(p, q))
12472// {
12473// if(ncRingType(currRing) == nc_lie)
12474// {
12475// // generalized prod-crit for lie-type
12476// strat->cp++;
12477// Lp.p = nc_p_Bracket_qq(pCopy(p),q, currRing);
12478// }
12479// else
12480// if( ALLOW_PROD_CRIT(strat) )
12481// {
12482// // product criterion for homogeneous case in SCA
12483// strat->cp++;
12484// Lp.p = NULL;
12485// }
12486// else
12487// Lp.p = nc_CreateSpoly(q,p,currRing); // ?
12488// }
12489// else Lp.p = nc_CreateSpoly(q,p,currRing);
12490// }
12491// else
12492// {
12493
12494 /* ksCreateShortSpoly needs two Lobject-kind presentations */
12495 /* p is already in this form, so convert q */
12496 Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
12497 // }
12498 }
12499 if (Lp.p == NULL)
12500 {
12501 /*- the case that the s-poly is 0 -*/
12502 // TODO: currently ifromS is only > 0 if called from enterOnePairWithShifts
12503 if (ifromS > 0)
12504 {
12505 if (strat->pairtest==NULL) initPairtest(strat);
12506 strat->pairtest[ifromS] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
12507 strat->pairtest[strat->sl+1] = TRUE;
12508 }
12509 //if (TEST_OPT_DEBUG){Print("!");} // option teach
12510 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12511 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
12512 /*
12513 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
12514 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
12515 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
12516 *term of p divides the lcm(s,r)
12517 *(this canceling should be done here because
12518 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
12519 *the first case is handled in chainCrit
12520 */
12521 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
12522#ifdef CRITERION_DEBUG
12523 if (TEST_OPT_DEBUG) PrintS("--- S-poly = 0\n");
12524#endif
12525 return TRUE;
12526 }
12527 else
12528 {
12529 /*- the pair (S[i],p) enters B -*/
12530 /* both of them should have their LM in currRing and TAIL in tailring */
12531 Lp.p1 = q; // already in the needed form
12532 Lp.p2 = p; // already in the needed form
12533
12534 if ( !rIsPluralRing(currRing) )
12535 pNext(Lp.p) = strat->tail;
12536
12537 /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12538 /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12539 if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
12540 {
12541 Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
12542 Lp.i_r2 = atR;
12543 }
12544 else
12545 {
12546 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12547 Lp.i_r1 = -1;
12548 Lp.i_r2 = -1;
12549 }
12550 strat->initEcartPair(&Lp,q,p,ecartq,ecart);
12551
12553 {
12556 && (Lp.p->coef!=NULL))
12557 nDelete(&(Lp.p->coef));
12558 }
12559
12560 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
12561 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
12562#ifdef CRITERION_DEBUG
12563 if (TEST_OPT_DEBUG) PrintS("+++ Entered pair\n");
12564#endif
12565 }
12566 return FALSE;
12567}
int cv
Definition: kutil.h:368
static int pLPDivComp(poly p, poly q)
Definition: kutil.cc:232
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1651
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:102
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:71
#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 4509 of file kutil.cc.

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

◆ enterpairsShift()

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

Definition at line 13028 of file kutil.cc.

13029{
13030 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
13031 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
13032 int j=pos;
13033
13034 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
13035 initenterpairsShift(h,k,ecart,0,strat, atR);
13036 if ( (!strat->fromT)
13037 && ((strat->syzComp==0)
13038 ||(pGetComp(h)<=strat->syzComp)))
13039 {
13040 unsigned long h_sev = pGetShortExpVector(h);
13041 loop
13042 {
13043 if (j > k) break;
13044 // TODO this currently doesn't clear all possible elements because of commutative division
13045 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
13046 clearS(h,h_sev, &j,&k,strat);
13047 j++;
13048 }
13049 }
13050}
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:12576

◆ enterpairsSig()

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

Definition at line 4535 of file kutil.cc.

4536{
4537 int j=pos;
4539 initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4540 if ( (!strat->fromT)
4541 && ((strat->syzComp==0)
4542 ||(pGetComp(h)<=strat->syzComp)))
4543 {
4544 unsigned long h_sev = pGetShortExpVector(h);
4545 loop
4546 {
4547 if (j > k) break;
4548 clearS(h,h_sev, &j,&k,strat);
4549 j++;
4550 }
4551 }
4552}
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3887

◆ enterSBba()

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

Definition at line 8829 of file kutil.cc.

8830{
8831 strat->news = TRUE;
8832 /*- puts p to the standardbasis s at position at -*/
8833 if (strat->sl == IDELEMS(strat->Shdl)-1)
8834 {
8835 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
8836 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8837 (IDELEMS(strat->Shdl)+setmaxTinc)
8838 *sizeof(unsigned long));
8839 strat->ecartS = (intset)omReallocSize(strat->ecartS,
8840 IDELEMS(strat->Shdl)*sizeof(int),
8841 (IDELEMS(strat->Shdl)+setmaxTinc)
8842 *sizeof(int));
8843 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
8844 IDELEMS(strat->Shdl)*sizeof(int),
8845 (IDELEMS(strat->Shdl)+setmaxTinc)
8846 *sizeof(int));
8847 if (strat->lenS!=NULL)
8848 strat->lenS=(int*)omRealloc0Size(strat->lenS,
8849 IDELEMS(strat->Shdl)*sizeof(int),
8850 (IDELEMS(strat->Shdl)+setmaxTinc)
8851 *sizeof(int));
8852 if (strat->lenSw!=NULL)
8853 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
8854 IDELEMS(strat->Shdl)*sizeof(wlen_type),
8855 (IDELEMS(strat->Shdl)+setmaxTinc)
8856 *sizeof(wlen_type));
8857 if (strat->fromQ!=NULL)
8858 {
8859 strat->fromQ = (intset)omReallocSize(strat->fromQ,
8860 IDELEMS(strat->Shdl)*sizeof(int),
8861 (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
8862 }
8863 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
8864 IDELEMS(strat->Shdl)+=setmaxTinc;
8865 strat->Shdl->m=strat->S;
8866 }
8867 if (atS <= strat->sl)
8868 {
8869#ifdef ENTER_USE_MEMMOVE
8870 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
8871 (strat->sl - atS + 1)*sizeof(poly));
8872 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
8873 (strat->sl - atS + 1)*sizeof(int));
8874 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
8875 (strat->sl - atS + 1)*sizeof(unsigned long));
8876 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
8877 (strat->sl - atS + 1)*sizeof(int));
8878 if (strat->lenS!=NULL)
8879 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
8880 (strat->sl - atS + 1)*sizeof(int));
8881 if (strat->lenSw!=NULL)
8882 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
8883 (strat->sl - atS + 1)*sizeof(wlen_type));
8884#else
8885 for (i=strat->sl+1; i>=atS+1; i--)
8886 {
8887 strat->S[i] = strat->S[i-1];
8888 strat->ecartS[i] = strat->ecartS[i-1];
8889 strat->sevS[i] = strat->sevS[i-1];
8890 strat->S_2_R[i] = strat->S_2_R[i-1];
8891 }
8892 if (strat->lenS!=NULL)
8893 for (i=strat->sl+1; i>=atS+1; i--)
8894 strat->lenS[i] = strat->lenS[i-1];
8895 if (strat->lenSw!=NULL)
8896 for (i=strat->sl+1; i>=atS+1; i--)
8897 strat->lenSw[i] = strat->lenSw[i-1];
8898#endif
8899 }
8900 if (strat->fromQ!=NULL)
8901 {
8902#ifdef ENTER_USE_MEMMOVE
8903 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
8904 (strat->sl - atS + 1)*sizeof(int));
8905#else
8906 for (i=strat->sl+1; i>=atS+1; i--)
8907 {
8908 strat->fromQ[i] = strat->fromQ[i-1];
8909 }
8910#endif
8911 strat->fromQ[atS]=0;
8912 }
8913
8914 /*- save result -*/
8915 poly pp=p.p;
8916 strat->S[atS] = pp;
8917 if (strat->honey) strat->ecartS[atS] = p.ecart;
8918 if (p.sev == 0)
8919 p.sev = pGetShortExpVector(pp);
8920 else
8921 assume(p.sev == pGetShortExpVector(pp));
8922 strat->sevS[atS] = p.sev;
8923 strat->ecartS[atS] = p.ecart;
8924 strat->S_2_R[atS] = atR;
8925 strat->sl++;
8926}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
char news
Definition: kutil.h:400
#define setmaxTinc
Definition: kutil.h:34
int * intset
Definition: kutil.h:53
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3692

◆ enterSBbaShift()

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

Definition at line 8929 of file kutil.cc.

8930{
8931 enterSBba(p, atS, strat, atR);
8932
8933 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
8934 for (int i = maxPossibleShift; i > 0; i--)
8935 {
8936 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
8937 // in `kNF2` because of lazy poly normalizations.
8938 LObject qq(p_Copy(p.p, strat->tailRing));
8939 p_mLPshift(qq.p, i, strat->tailRing);
8940 qq.shift = i;
8941 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
8942 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
8943 enterSBba(qq, atS, strat, -1);
8944 }
8945}
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:8829
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 8952 of file kutil.cc.

8953{
8954 strat->news = TRUE;
8955 /*- puts p to the standardbasis s at position at -*/
8956 if (strat->sl == IDELEMS(strat->Shdl)-1)
8957 {
8958 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
8959 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8960 (IDELEMS(strat->Shdl)+setmax)
8961 *sizeof(unsigned long));
8962 strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
8963 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8964 (IDELEMS(strat->Shdl)+setmax)
8965 *sizeof(unsigned long));
8966 strat->ecartS = (intset)omReallocSize(strat->ecartS,
8967 IDELEMS(strat->Shdl)*sizeof(int),
8968 (IDELEMS(strat->Shdl)+setmax)
8969 *sizeof(int));
8970 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
8971 IDELEMS(strat->Shdl)*sizeof(int),
8972 (IDELEMS(strat->Shdl)+setmax)
8973 *sizeof(int));
8974 if (strat->lenS!=NULL)
8975 strat->lenS=(int*)omRealloc0Size(strat->lenS,
8976 IDELEMS(strat->Shdl)*sizeof(int),
8977 (IDELEMS(strat->Shdl)+setmax)
8978 *sizeof(int));
8979 if (strat->lenSw!=NULL)
8980 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
8981 IDELEMS(strat->Shdl)*sizeof(wlen_type),
8982 (IDELEMS(strat->Shdl)+setmax)
8983 *sizeof(wlen_type));
8984 if (strat->fromQ!=NULL)
8985 {
8986 strat->fromQ = (intset)omReallocSize(strat->fromQ,
8987 IDELEMS(strat->Shdl)*sizeof(int),
8988 (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
8989 }
8990 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
8991 pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
8992 IDELEMS(strat->Shdl)+=setmax;
8993 strat->Shdl->m=strat->S;
8994 }
8995 // in a signature-based algorithm the following situation will never
8996 // appear due to the fact that the critical pairs are already sorted
8997 // by increasing signature.
8998 // True. However, in the case of integers we need to put the element
8999 // that caused the signature drop on the first position
9000 if (atS <= strat->sl)
9001 {
9002#ifdef ENTER_USE_MEMMOVE
9003 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9004 (strat->sl - atS + 1)*sizeof(poly));
9005 memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
9006 (strat->sl - atS + 1)*sizeof(poly));
9007 memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
9008 (strat->sl - atS + 1)*sizeof(unsigned long));
9009 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9010 (strat->sl - atS + 1)*sizeof(int));
9011 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9012 (strat->sl - atS + 1)*sizeof(unsigned long));
9013 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9014 (strat->sl - atS + 1)*sizeof(int));
9015 if (strat->lenS!=NULL)
9016 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9017 (strat->sl - atS + 1)*sizeof(int));
9018 if (strat->lenSw!=NULL)
9019 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9020 (strat->sl - atS + 1)*sizeof(wlen_type));
9021#else
9022 for (i=strat->sl+1; i>=atS+1; i--)
9023 {
9024 strat->S[i] = strat->S[i-1];
9025 strat->ecartS[i] = strat->ecartS[i-1];
9026 strat->sevS[i] = strat->sevS[i-1];
9027 strat->S_2_R[i] = strat->S_2_R[i-1];
9028 strat->sig[i] = strat->sig[i-1];
9029 strat->sevSig[i] = strat->sevSig[i-1];
9030 }
9031 if (strat->lenS!=NULL)
9032 for (i=strat->sl+1; i>=atS+1; i--)
9033 strat->lenS[i] = strat->lenS[i-1];
9034 if (strat->lenSw!=NULL)
9035 for (i=strat->sl+1; i>=atS+1; i--)
9036 strat->lenSw[i] = strat->lenSw[i-1];
9037#endif
9038 }
9039 if (strat->fromQ!=NULL)
9040 {
9041#ifdef ENTER_USE_MEMMOVE
9042 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9043 (strat->sl - atS + 1)*sizeof(int));
9044#else
9045 for (i=strat->sl+1; i>=atS+1; i--)
9046 {
9047 strat->fromQ[i] = strat->fromQ[i-1];
9048 }
9049#endif
9050 strat->fromQ[atS]=0;
9051 }
9052
9053 /*- save result -*/
9054 strat->S[atS] = p.p;
9055 strat->sig[atS] = p.sig; // TODO: get the correct signature in here!
9056 if (strat->honey) strat->ecartS[atS] = p.ecart;
9057 if (p.sev == 0)
9058 p.sev = pGetShortExpVector(p.p);
9059 else
9060 assume(p.sev == pGetShortExpVector(p.p));
9061 strat->sevS[atS] = p.sev;
9062 // during the interreduction process of a signature-based algorithm we do not
9063 // compute the signature at this point, but when the whole interreduction
9064 // process finishes, i.e. f5c terminates!
9065 if (p.sig != NULL)
9066 {
9067 if (p.sevSig == 0)
9068 p.sevSig = pGetShortExpVector(p.sig);
9069 else
9070 assume(p.sevSig == pGetShortExpVector(p.sig));
9071 strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9072 }
9073 strat->ecartS[atS] = p.ecart;
9074 strat->S_2_R[atS] = atR;
9075 strat->sl++;
9076#ifdef DEBUGF5
9077 int k;
9078 Print("--- LIST S: %d ---\n",strat->sl);
9079 for(k=0;k<=strat->sl;k++)
9080 {
9081 pWrite(strat->sig[k]);
9082 }
9083 PrintS("--- LIST S END ---\n");
9084#endif
9085}
#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 9380 of file kutil.cc.

9381{
9382 int i;
9383 strat->newt = TRUE;
9384 if (strat->syzl == strat->syzmax-1)
9385 {
9386 pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9387 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9388 (strat->syzmax)*sizeof(unsigned long),
9389 ((strat->syzmax)+setmax)
9390 *sizeof(unsigned long));
9391 strat->syzmax += setmax;
9392 }
9393 if (atT < strat->syzl)
9394 {
9395#ifdef ENTER_USE_MEMMOVE
9396 memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9397 (strat->syzl-atT+1)*sizeof(poly));
9398 memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9399 (strat->syzl-atT+1)*sizeof(unsigned long));
9400#endif
9401 for (i=strat->syzl; i>=atT+1; i--)
9402 {
9403#ifndef ENTER_USE_MEMMOVE
9404 strat->syz[i] = strat->syz[i-1];
9405 strat->sevSyz[i] = strat->sevSyz[i-1];
9406#endif
9407 }
9408 }
9409 //i = strat->syzl;
9410 i = atT;
9411 //Makes sure the syz saves just the signature
9412 #ifdef HAVE_RINGS
9414 pNext(p.sig) = NULL;
9415 #endif
9416 strat->syz[atT] = p.sig;
9417 strat->sevSyz[atT] = p.sevSig;
9418 strat->syzl++;
9419#if F5DEBUG
9420 Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9421 pWrite(strat->syz[atT]);
9422#endif
9423 // recheck pairs in strat->L with new rule and delete correspondingly
9424 int cc = strat->Ll;
9425 while (cc>-1)
9426 {
9427 //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9428 //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);
9429 if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9430 strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9431 #ifdef HAVE_RINGS
9433 || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9434 #endif
9435 )
9436 {
9437 //printf("\nYES!\n");
9438 deleteInL(strat->L,&strat->Ll,cc,strat);
9439 }
9440 cc--;
9441 }
9442//#if 1
9443#ifdef DEBUGF5
9444 PrintS("--- Syzygies ---\n");
9445 Print("syzl %d\n",strat->syzl);
9446 Print("syzmax %d\n",strat->syzmax);
9447 PrintS("--------------------------------\n");
9448 for(i=0;i<=strat->syzl-1;i++)
9449 {
9450 Print("%d - ",i);
9451 pWrite(strat->syz[i]);
9452 }
9453 PrintS("--------------------------------\n");
9454#endif
9455}
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:401
#define pLtCmp(p, q)
Definition: polys.h:123

◆ enterT()

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

Definition at line 9178 of file kutil.cc.

9179{
9180 int i;
9181
9182#ifdef PDEBUG
9183#ifdef HAVE_SHIFTBBA
9184 if (currRing->isLPring && p.shift > 0)
9185 {
9186 // in this case, the order is not correct. test LM and tail separately
9187 p_LmTest(p.p, currRing);
9188 p_Test(pNext(p.p), currRing);
9189 }
9190 else
9191#endif
9192 {
9193 pp_Test(p.p, currRing, p.tailRing);
9194 }
9195#endif
9196 assume(strat->tailRing == p.tailRing);
9197 // redMoraNF complains about this -- but, we don't really
9198 // need this so far
9199 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9200 assume(!strat->homog || (p.FDeg == p.pFDeg()));
9201 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9202
9203#ifdef KDEBUG
9204 // do not put an LObject twice into T:
9205 for(i=strat->tl;i>=0;i--)
9206 {
9207 if (p.p==strat->T[i].p)
9208 {
9209 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9210 return;
9211 }
9212 }
9213#endif
9214
9215#ifdef HAVE_TAIL_RING
9216 if (currRing!=strat->tailRing)
9217 {
9218 p.t_p=p.GetLmTailRing();
9219 }
9220#endif
9221 strat->newt = TRUE;
9222 if (atT < 0)
9223 atT = strat->posInT(strat->T, strat->tl, p);
9224 if (strat->tl == strat->tmax-1)
9225 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9226 if (atT <= strat->tl)
9227 {
9228#ifdef ENTER_USE_MEMMOVE
9229 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9230 (strat->tl-atT+1)*sizeof(TObject));
9231 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9232 (strat->tl-atT+1)*sizeof(unsigned long));
9233#endif
9234 for (i=strat->tl+1; i>=atT+1; i--)
9235 {
9236#ifndef ENTER_USE_MEMMOVE
9237 strat->T[i] = strat->T[i-1];
9238 strat->sevT[i] = strat->sevT[i-1];
9239#endif
9240 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9241 }
9242 }
9243
9244 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9245 {
9246#ifdef HAVE_SHIFTBBA
9247 // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9248 if (!(currRing->isLPring && p.shift > 0))
9249#endif
9250 {
9252 (strat->tailRing != NULL ?
9253 strat->tailRing : currRing),
9254 strat->tailBin);
9255 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9256 }
9257 }
9258 strat->T[atT] = (TObject) p;
9259 //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9260
9261 if ((pNext(p.p) != NULL) && (!rIsLPRing(currRing)))
9262 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9263 else
9264 strat->T[atT].max_exp = NULL;
9265
9266 strat->tl++;
9267 strat->R[strat->tl] = &(strat->T[atT]);
9268 strat->T[atT].i_r = strat->tl;
9269 assume((p.sev == 0) || (pGetShortExpVector(p.p) == p.sev));
9270 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9271 kTest_T(&(strat->T[atT]),strat);
9272}
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:544
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition: kutil.cc:801
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:161
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition: p_polys.h:926
#define p_LmTest(p, r)
Definition: p_polys.h:160
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:720

◆ enterT_strong()

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

Definition at line 9278 of file kutil.cc.

9279{
9281 int i;
9282
9283 pp_Test(p.p, currRing, p.tailRing);
9284 assume(strat->tailRing == p.tailRing);
9285 // redMoraNF complains about this -- but, we don't really
9286 // need this so far
9287 assume(p.pLength == 0 || (int)pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9288 assume(p.FDeg == p.pFDeg());
9289 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9290
9291#ifdef KDEBUG
9292 // do not put an LObject twice into T:
9293 for(i=strat->tl;i>=0;i--)
9294 {
9295 if (p.p==strat->T[i].p)
9296 {
9297 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9298 return;
9299 }
9300 }
9301#endif
9302
9303#ifdef HAVE_TAIL_RING
9304 if (currRing!=strat->tailRing)
9305 {
9306 p.t_p=p.GetLmTailRing();
9307 }
9308#endif
9309 strat->newt = TRUE;
9310 if (atT < 0)
9311 atT = strat->posInT(strat->T, strat->tl, p);
9312 if (strat->tl == strat->tmax-1)
9313 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9314 if (atT <= strat->tl)
9315 {
9316#ifdef ENTER_USE_MEMMOVE
9317 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9318 (strat->tl-atT+1)*sizeof(TObject));
9319 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9320 (strat->tl-atT+1)*sizeof(unsigned long));
9321#endif
9322 for (i=strat->tl+1; i>=atT+1; i--)
9323 {
9324#ifndef ENTER_USE_MEMMOVE
9325 strat->T[i] = strat->T[i-1];
9326 strat->sevT[i] = strat->sevT[i-1];
9327#endif
9328 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9329 }
9330 }
9331
9332 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9333 {
9335 (strat->tailRing != NULL ?
9336 strat->tailRing : currRing),
9337 strat->tailBin);
9338 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9339 }
9340 strat->T[atT] = (TObject) p;
9341 //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9342
9343 if (pNext(p.p) != NULL)
9344 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9345 else
9346 strat->T[atT].max_exp = NULL;
9347
9348 strat->tl++;
9349 strat->R[strat->tl] = &(strat->T[atT]);
9350 strat->T[atT].i_r = strat->tl;
9351 assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9352 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9353 #if 1
9355 && !n_IsUnit(p.p->coef, currRing->cf))
9356 {
9357 for(i=strat->tl;i>=0;i--)
9358 {
9359 if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9360 {
9361 enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9362 }
9363 }
9364 }
9365 /*
9366 printf("\nThis is T:\n");
9367 for(i=strat->tl;i>=0;i--)
9368 {
9369 pWrite(strat->T[i].p);
9370 }
9371 //getchar();*/
9372 #endif
9373 kTest_T(&(strat->T[atT]),strat);
9374}
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:512
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1550
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition: polys.h:140

◆ enterTShift()

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

Definition at line 13058 of file kutil.cc.

13059{
13060 /* determine how many elements we have to insert */
13061 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
13062 /* hence, a total number of elt's to add is: */
13063 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
13064 pAssume(p.p != NULL);
13065
13066 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
13067
13068 for (int i = 1; i <= maxPossibleShift; i++)
13069 {
13070 LObject qq;
13071 qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
13072 qq.shift = i;
13073 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
13074
13075 enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13076 }
13077}
#define pAssume(cond)
Definition: monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 9885 of file kutil.cc.

9886{
9887 /*- release temp data -*/
9888 cleanT(strat);
9889 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
9890 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
9891 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
9892 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
9893 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
9894 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
9895 /*- set L: should be empty -*/
9896 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
9897 /*- set B: should be empty -*/
9898 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
9899 pLmFree(&strat->tail);
9900 strat->syzComp=0;
9901
9902#ifdef HAVE_SHIFTBBA
9903 if (rIsLPRing(currRing) && strat->rightGB)
9904 {
9905 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
9906 strat->fromQ=NULL;
9907 }
9908#endif
9909}
void * ADDRESS
Definition: auxiliary.h:119

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10088 of file kutil.cc.

10089{
10090 /*- release temp data -*/
10092 cleanTSbaRing(strat);
10093 else
10094 cleanT(strat);
10095 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10096 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10097 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10098 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10099 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10100 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10101 if(strat->syzmax>0)
10102 {
10103 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10104 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10105 if (strat->sbaOrder == 1)
10106 {
10107 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10108 }
10109 }
10110 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10111 /*- set L: should be empty -*/
10112 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10113 /*- set B: should be empty -*/
10114 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10115 /*- set sig: no need for the signatures anymore -*/
10116 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10117 pLmDelete(&strat->tail);
10118 strat->syzComp=0;
10119}
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:624

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

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

◆ faugereRewCriterion()

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

Definition at line 6605 of file kutil.cc.

6606{
6607 //printf("Faugere Rewritten Criterion\n");
6609 return FALSE;
6610//#if 1
6611#ifdef DEBUGF5
6612 PrintS("rewritten criterion checks: ");
6613 pWrite(sig);
6614#endif
6615 for(int k = strat->sl; k>=start; k--)
6616 {
6617//#if 1
6618#ifdef DEBUGF5
6619 PrintS("checking with: ");
6620 pWrite(strat->sig[k]);
6621 pWrite(pHead(strat->S[k]));
6622#endif
6623 if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6624 {
6625//#if 1
6626#ifdef DEBUGF5
6627 PrintS("DELETE!\n");
6628#endif
6629 strat->nrrewcrit++;
6630 return TRUE;
6631 }
6632 //k--;
6633 }
6634#ifdef DEBUGF5
6635 PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6636 for(int kk = 0; kk<strat->sl+1; kk++)
6637 {
6638 pWrite(pHead(strat->S[kk]));
6639 }
6640 PrintS("------------------------------\n");
6641#endif
6642 return FALSE;
6643}
int nrrewcrit
Definition: kutil.h:361

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy  strat)

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

Definition at line 10928 of file kutil.cc.

10929{
10930 assume(strat->tl<0); /* can only be called with no elements in T:
10931 i.e. after exitBuchMora */
10932 /* do not use strat->S, strat->sl as they may be out of sync*/
10933 if(!nCoeff_is_Z(currRing->cf))
10934 return;
10935 poly p,pp;
10936 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
10937 {
10938 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
10939 {
10940 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
10941 {
10942 if((i != j) && (strat->Shdl->m[i] != NULL))
10943 {
10944 p = strat->Shdl->m[i];
10945 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
10946#if HAVE_SHIFTBBA
10947 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
10948#endif
10949 ))
10950 {
10951 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
10952 if (!nEqual(dummy,p->coef))
10953 {
10954 if (nIsZero(dummy))
10955 {
10956 nDelete(&dummy);
10957 pLmDelete(&strat->Shdl->m[i]);
10958 p=strat->Shdl->m[i];
10959 }
10960 else
10961 {
10962 p_SetCoeff(p,dummy,currRing);
10963 break;
10964 }
10965 }
10966 else
10967 {
10968 nDelete(&dummy);
10969 break;
10970 }
10971 }
10972 if (p!=NULL)
10973 {
10974 pp = pNext(p);
10975 while(pp != NULL)
10976 {
10977 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
10978#if HAVE_SHIFTBBA
10979 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
10980#endif
10981 )
10982 {
10983 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
10984 if (!nEqual(dummy,pp->coef))
10985 {
10986 p_SetCoeff(pp,dummy,currRing);
10987 if(nIsZero(pp->coef))
10988 {
10989 pLmDelete(&pNext(p));
10990 pp = pNext(p);
10991 }
10992 else
10993 {
10994 p = pp;
10995 pp = pNext(p);
10996 }
10997 }
10998 else
10999 {
11000 nDelete(&dummy);
11001 p = pp;
11002 pp = pNext(p);
11003 }
11004 }
11005 else
11006 {
11007 p = pp;
11008 pp = pNext(p);
11009 }
11010 }
11011 }
11012 }
11013 }
11014 //idPrint(strat->Shdl);
11015 }
11016 }
11017 idSkipZeroes(strat->Shdl);
11018}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:813
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:625
#define nEqual(n1, n2)
Definition: numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:410
#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 501 of file kutil.cc.

502{
503 int j,/*k,*/p;
504
505 if (currRing->pLexOrder
507 || (strat->ak >1)
509 {
510 return;
511 }
513 if (p!=0)
514 strat->NotUsedAxis[p] = FALSE;
515 /*- the leading term of pp is a power of the p-th variable -*/
516 for (j=(currRing->N);j>0; j--)
517 {
518 if (strat->NotUsedAxis[j])
519 {
520 strat->kAllAxis=FALSE;
521 return;
522 }
523 }
524 strat->kAllAxis=TRUE;
525}
BOOLEAN * NotUsedAxis
Definition: kutil.h:332
char kAllAxis
Definition: kutil.h:376
#define pIsPurePower(p)
Definition: polys.h:248
BOOLEAN rHasMixedOrdering(const ring r)
Definition: ring.h:761

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1689 of file kstd1.cc.

1690{
1691 /* setting global variables ------------------- */
1692 strat->enterS = enterSBba;
1693 strat->red = redHoney;
1694 if (strat->honey)
1695 strat->red = redHoney;
1696 else if (currRing->pLexOrder && !strat->homog)
1697 strat->red = redLazy;
1698 else
1699 {
1700 strat->LazyPass *=4;
1701 strat->red = redHomog;
1702 }
1704 {
1705 if (rField_is_Z(currRing))
1706 strat->red = redRing_Z;
1707 else
1708 strat->red = redRing;
1709 }
1710 if (TEST_OPT_IDLIFT)
1711 strat->red=redLiftstd;
1712 if (currRing->pLexOrder && strat->honey)
1713 strat->initEcart = initEcartNormal;
1714 else
1715 strat->initEcart = initEcartBBA;
1716 if (strat->honey)
1718 else
1720// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1721// {
1722// //interred machen Aenderung
1723// strat->pOrigFDeg=pFDeg;
1724// strat->pOrigLDeg=pLDeg;
1725// //h=ggetid("ecart");
1726// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1727// //{
1728// // ecartWeights=iv2array(IDINTVEC(h));
1729// //}
1730// //else
1731// {
1732// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1733// /*uses automatic computation of the ecartWeights to set them*/
1734// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1735// }
1736// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1737// if (TEST_OPT_PROT)
1738// {
1739// for(i=1; i<=(currRing->N); i++)
1740// Print(" %d",ecartWeights[i]);
1741// PrintLn();
1742// mflush();
1743// }
1744// }
1745}
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:683
int redHoney(LObject *h, kStrategy strat)
Definition: kstd2.cc:2088
int redHomog(LObject *h, kStrategy strat)
Definition: kstd2.cc:1121
int redLazy(LObject *h, kStrategy strat)
Definition: kstd2.cc:1881
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition: kutil.cc:1326
void initEcartNormal(TObject *h)
Definition: kutil.cc:1304
void initEcartBBA(TObject *h)
Definition: kutil.cc:1312
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition: kutil.cc:1319

◆ initBuchMora()

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

Definition at line 9800 of file kutil.cc.

9801{
9802 strat->interpt = BTEST1(OPT_INTERRUPT);
9803 /*- creating temp data structures------------------- -*/
9804 //strat->cp = 0; // already by skStragy()
9805 //strat->c3 = 0; // already by skStragy()
9806#ifdef HAVE_SHIFTBBA
9807 strat->cv = 0; // already by skStragy()
9808#endif
9809 strat->tail = pInit();
9810 /*- set s -*/
9811 strat->sl = -1;
9812 /*- set L -*/
9813 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9814 strat->Ll = -1;
9815 strat->L = initL(strat->Lmax);
9816 /*- set B -*/
9817 strat->Bmax = setmaxL;
9818 strat->Bl = -1;
9819 strat->B = initL();
9820 /*- set T -*/
9821 strat->tl = -1;
9822 strat->tmax = setmaxT;
9823 strat->T = initT();
9824 strat->R = initR();
9825 strat->sevT = initsevT();
9826 /*- init local data struct.---------------------------------------- -*/
9827 //strat->P.ecart=0; // already by skStragy()
9828 //strat->P.length=0; // already by skStragy()
9829 //strat->P.pLength=0; // already by skStragy()
9831 {
9832 if (strat->kNoether!=NULL)
9833 {
9834 pSetComp(strat->kNoether, strat->ak);
9835 pSetComp(strat->kNoetherTail(), strat->ak);
9836 }
9837 }
9839 {
9840 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9841 }
9842 else
9843 {
9844 if(TEST_OPT_SB_1)
9845 {
9846 int i;
9847 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
9848 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9849 {
9850 P->m[i-strat->newIdeal] = F->m[i];
9851 F->m[i] = NULL;
9852 }
9853 initSSpecial(F,Q,P,strat);
9854 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9855 {
9856 F->m[i] = P->m[i-strat->newIdeal];
9857 P->m[i-strat->newIdeal] = NULL;
9858 }
9859 idDelete(&P);
9860 }
9861 else
9862 {
9863 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9864 // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
9865 }
9866 }
9867 strat->fromT = FALSE;
9869 if ((!TEST_OPT_SB_1)
9871 )
9872 {
9873 updateS(TRUE,strat);
9874 }
9875#ifdef HAVE_SHIFTBBA
9876 if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
9877#endif
9878 {
9879 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
9880 strat->fromQ=NULL;
9881 }
9882 assume(kTest_TS(strat));
9883}
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:8131
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:8594
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7729
#define setmaxL
Definition: kutil.h:30
static LSet initL(int nr=setmaxL)
Definition: kutil.h:420
#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 9476 of file kutil.cc.

9477{
9480 if (TEST_OPT_SB_1)
9482#ifdef HAVE_RINGS
9484 {
9486 strat->chainCrit=chainCritRing;
9487 }
9488#endif
9489#ifdef HAVE_RATGRING
9490 if (rIsRatGRing(currRing))
9491 {
9492 strat->chainCrit=chainCritPart;
9493 /* enterOnePairNormal get rational part in it */
9494 }
9495#endif
9496 if (TEST_OPT_IDLIFT
9497 && (strat->syzComp==1)
9498 && (!rIsPluralRing(currRing)))
9500
9502 strat->Gebauer = strat->homog || strat->sugarCrit;
9503 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9504 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9505 strat->pairtest = NULL;
9506 /* always use tailreduction, except:
9507 * - in local rings, - in lex order case, -in ring over extensions */
9509 //if(rHasMixedOrdering(currRing)==2)
9510 //{
9511 // strat->noTailReduction =TRUE;
9512 //}
9513
9514#ifdef HAVE_PLURAL
9515 // and r is plural_ring
9516 // hence this holds for r a rational_plural_ring
9517 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9518 { //or it has non-quasi-comm type... later
9519 strat->sugarCrit = FALSE;
9520 strat->Gebauer = FALSE;
9521 strat->honey = FALSE;
9522 }
9523#endif
9524
9525 // Coefficient ring?
9527 {
9528 strat->sugarCrit = FALSE;
9529 strat->Gebauer = FALSE;
9530 strat->honey = FALSE;
9531 }
9532 #ifdef KDEBUG
9533 if (TEST_OPT_DEBUG)
9534 {
9535 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9536 else PrintS("ideal/module is not homogeneous\n");
9537 }
9538 #endif
9539}
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:291
char z2homog
Definition: kutil.h:374
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:1952
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3458
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1346
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2234
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3533
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3217
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:4009
static bool rIsSCA(const ring r)
Definition: nc.h:190
#define TEST_OPT_WEIGHTM
Definition: options.h:122
#define TEST_OPT_SUGARCRIT
Definition: options.h:108
#define TEST_OPT_NOT_SUGAR
Definition: options.h:107

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9627 of file kutil.cc.

9628{
9630 {
9631 if (strat->honey)
9632 {
9633 strat->posInL = posInL15;
9634 // ok -- here is the deal: from my experiments for Singular-2-0
9635 // I conclude that that posInT_EcartpLength is the best of
9636 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9637 // see the table at the end of this file
9638 if (TEST_OPT_OLDSTD)
9639 strat->posInT = posInT15;
9640 else
9641 strat->posInT = posInT_EcartpLength;
9642 }
9643 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9644 {
9645 strat->posInL = posInL11;
9646 strat->posInT = posInT11;
9647 }
9648 else if (TEST_OPT_INTSTRATEGY)
9649 {
9650 strat->posInL = posInL11;
9651 strat->posInT = posInT11;
9652 }
9653 else
9654 {
9655 strat->posInL = posInL0;
9656 strat->posInT = posInT0;
9657 }
9658 //if (strat->minim>0) strat->posInL =posInLSpecial;
9659 if (strat->homog)
9660 {
9661 strat->posInL = posInL110;
9662 strat->posInT = posInT110;
9663 }
9664 }
9665 else /* local/mixed ordering */
9666 {
9667 if (strat->homog)
9668 {
9669 strat->posInL = posInL11;
9670 strat->posInT = posInT11;
9671 }
9672 else
9673 {
9674 if ((currRing->order[0]==ringorder_c)
9675 ||(currRing->order[0]==ringorder_C))
9676 {
9677 strat->posInL = posInL17_c;
9678 strat->posInT = posInT17_c;
9679 }
9680 else
9681 {
9682 strat->posInL = posInL17;
9683 strat->posInT = posInT17;
9684 }
9685 }
9686 }
9687 if (strat->minim>0) strat->posInL =posInLSpecial;
9688 // for further tests only
9689 if ((BTEST1(11)) || (BTEST1(12)))
9690 strat->posInL = posInL11;
9691 else if ((BTEST1(13)) || (BTEST1(14)))
9692 strat->posInL = posInL13;
9693 else if ((BTEST1(15)) || (BTEST1(16)))
9694 strat->posInL = posInL15;
9695 else if ((BTEST1(17)) || (BTEST1(18)))
9696 strat->posInL = posInL17;
9697 if (BTEST1(11))
9698 strat->posInT = posInT11;
9699 else if (BTEST1(13))
9700 strat->posInT = posInT13;
9701 else if (BTEST1(15))
9702 strat->posInT = posInT15;
9703 else if ((BTEST1(17)))
9704 strat->posInT = posInT17;
9705 else if ((BTEST1(19)))
9706 strat->posInT = posInT19;
9707 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9708 strat->posInT = posInT1;
9710}
char posInLDependsOnLength
Definition: kutil.h:389
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6093
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5306
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4975
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4918
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5172
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:4907
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6182
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:9612
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5143
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5643
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6217
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5414
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5210
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5599
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6294
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5053
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5542
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6389
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5833
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9713 of file kutil.cc.

9714{
9716 {
9717 if (strat->honey)
9718 {
9719 strat->posInL = posInL15Ring;
9720 // ok -- here is the deal: from my experiments for Singular-2-0
9721 // I conclude that that posInT_EcartpLength is the best of
9722 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9723 // see the table at the end of this file
9724 if (TEST_OPT_OLDSTD)
9725 strat->posInT = posInT15Ring;
9726 else
9727 strat->posInT = posInT_EcartpLength;
9728 }
9729 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9730 {
9731 strat->posInL = posInL11Ring;
9732 strat->posInT = posInT11;
9733 }
9734 else if (TEST_OPT_INTSTRATEGY)
9735 {
9736 strat->posInL = posInL11Ring;
9737 strat->posInT = posInT11;
9738 }
9739 else
9740 {
9741 strat->posInL = posInL0Ring;
9742 strat->posInT = posInT0;
9743 }
9744 //if (strat->minim>0) strat->posInL =posInLSpecial;
9745 if (strat->homog)
9746 {
9747 strat->posInL = posInL110Ring;
9748 strat->posInT = posInT110Ring;
9749 }
9750 }
9751 else
9752 {
9753 if (strat->homog)
9754 {
9755 //printf("\nHere 3\n");
9756 strat->posInL = posInL11Ring;
9757 strat->posInT = posInT11Ring;
9758 }
9759 else
9760 {
9761 if ((currRing->order[0]==ringorder_c)
9762 ||(currRing->order[0]==ringorder_C))
9763 {
9764 strat->posInL = posInL17_cRing;
9765 strat->posInT = posInT17_cRing;
9766 }
9767 else
9768 {
9769 strat->posInL = posInL11Ringls;
9770 strat->posInT = posInT17Ring;
9771 }
9772 }
9773 }
9774 if (strat->minim>0) strat->posInL =posInLSpecial;
9775 // for further tests only
9776 if ((BTEST1(11)) || (BTEST1(12)))
9777 strat->posInL = posInL11Ring;
9778 else if ((BTEST1(13)) || (BTEST1(14)))
9779 strat->posInL = posInL13;
9780 else if ((BTEST1(15)) || (BTEST1(16)))
9781 strat->posInL = posInL15Ring;
9782 else if ((BTEST1(17)) || (BTEST1(18)))
9783 strat->posInL = posInL17Ring;
9784 if (BTEST1(11))
9785 strat->posInT = posInT11Ring;
9786 else if (BTEST1(13))
9787 strat->posInT = posInT13;
9788 else if (BTEST1(15))
9789 strat->posInT = posInT15Ring;
9790 else if ((BTEST1(17)))
9791 strat->posInT = posInT17Ring;
9792 else if ((BTEST1(19)))
9793 strat->posInT = posInT19;
9794 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9795 strat->posInT = posInT1;
9797}
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6339
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6454
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5876
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5096
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6135
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5671
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5012
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5946
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6253
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5265
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5368
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5476

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1312 of file kutil.cc.

1313{
1314 h->FDeg = h->pFDeg();
1315 (*h).ecart = 0;
1316 h->length=h->pLength=pLength(h->p);
1317}

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1304 of file kutil.cc.

1305{
1306 h->FDeg = h->pFDeg();
1307 h->ecart = h->pLDeg() - h->FDeg;
1308 // h->length is set by h->pLDeg
1309 h->length=h->pLength=pLength(h->p);
1310}

◆ initEcartPairBba()

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

Definition at line 1319 of file kutil.cc.

1320{
1321 Lp->FDeg = Lp->pFDeg();
1322 (*Lp).ecart = 0;
1323 (*Lp).length = 0;
1324}

◆ initEcartPairMora()

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

Definition at line 1326 of file kutil.cc.

1327{
1328 Lp->FDeg = Lp->pFDeg();
1329 (*Lp).ecart = si_max(ecartF,ecartG);
1330 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1331 (*Lp).length = 0;
1332}
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:378

◆ initenterpairs()

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

Definition at line 3822 of file kutil.cc.

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

◆ initHilbCrit()

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

Definition at line 9458 of file kutil.cc.

9459{
9460
9461 //if the ordering is local, then hilb criterion
9462 //can be used also if the ideal is not homogeneous
9464 {
9466 *hilb=NULL;
9467 else
9468 return;
9469 }
9470 if (strat->homog!=isHomog)
9471 {
9472 *hilb=NULL;
9473 }
9474}
@ isHomog
Definition: structs.h:37

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 420 of file kutil.h.

421{ 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)
Definition: omAllocDecl.h:211

◆ initS()

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

Definition at line 7635 of file kutil.cc.

7636{
7637 int i,pos;
7638
7640 else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7641 strat->ecartS=initec(i);
7642 strat->sevS=initsevS(i);
7643 strat->S_2_R=initS_2_R(i);
7644 strat->fromQ=NULL;
7645 strat->Shdl=idInit(i,F->rank);
7646 strat->S=strat->Shdl->m;
7647 /*- put polys into S -*/
7648 if (Q!=NULL)
7649 {
7650 strat->fromQ=initec(i);
7651 memset(strat->fromQ,0,i*sizeof(int));
7652 for (i=0; i<IDELEMS(Q); i++)
7653 {
7654 if (Q->m[i]!=NULL)
7655 {
7656 LObject h;
7657 h.p = pCopy(Q->m[i]);
7659 {
7660 h.pCleardenom(); // also does remove Content
7661 }
7662 else
7663 {
7664 h.pNorm();
7665 }
7667 {
7668 deleteHC(&h, strat);
7669 }
7670 if (h.p!=NULL)
7671 {
7672 strat->initEcart(&h);
7673 if (strat->sl==-1)
7674 pos =0;
7675 else
7676 {
7677 pos = posInS(strat,strat->sl,h.p,h.ecart);
7678 }
7679 h.sev = pGetShortExpVector(h.p);
7680 strat->enterS(h,pos,strat,-1);
7681 strat->fromQ[pos]=1;
7682 }
7683 }
7684 }
7685 }
7686 for (i=0; i<IDELEMS(F); i++)
7687 {
7688 if (F->m[i]!=NULL)
7689 {
7690 LObject h;
7691 h.p = pCopy(F->m[i]);
7693 {
7694 cancelunit(&h); /*- tries to cancel a unit -*/
7695 deleteHC(&h, strat);
7696 }
7697 if (h.p!=NULL)
7698 // do not rely on the input being a SB!
7699 {
7701 {
7702 h.pCleardenom(); // also does remove Content
7703 }
7704 else
7705 {
7706 h.pNorm();
7707 }
7708 strat->initEcart(&h);
7709 if (strat->sl==-1)
7710 pos =0;
7711 else
7712 pos = posInS(strat,strat->sl,h.p,h.ecart);
7713 h.sev = pGetShortExpVector(h.p);
7714 strat->enterS(h,pos,strat,-1);
7715 }
7716 }
7717 }
7718 /*- test, if a unit is in F -*/
7719 if ((strat->sl>=0)
7720#ifdef HAVE_RINGS
7721 && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7722#endif
7723 && pIsConstant(strat->S[0]))
7724 {
7725 while (strat->sl>0) deleteInS(strat->sl,strat);
7726 }
7727}
static intset initec(const int maxnr)
Definition: kutil.cc:530
static int * initS_2_R(const int maxnr)
Definition: kutil.cc:539
static unsigned long * initsevS(const int maxnr)
Definition: kutil.cc:535
#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 1747 of file kstd1.cc.

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

10014{
10015 strat->interpt = BTEST1(OPT_INTERRUPT);
10016 //strat->kNoether=NULL; // done by skStrategy
10017 /*- creating temp data structures------------------- -*/
10018 //strat->cp = 0; // done by skStrategy
10019 //strat->c3 = 0; // done by skStrategy
10020 strat->tail = pInit();
10021 /*- set s -*/
10022 strat->sl = -1;
10023 /*- set ps -*/
10024 strat->syzl = -1;
10025 /*- set L -*/
10026 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10027 strat->Ll = -1;
10028 strat->L = initL(strat->Lmax);
10029 /*- set B -*/
10030 strat->Bmax = setmaxL;
10031 strat->Bl = -1;
10032 strat->B = initL();
10033 /*- set T -*/
10034 strat->tl = -1;
10035 strat->tmax = setmaxT;
10036 strat->T = initT();
10037 strat->R = initR();
10038 strat->sevT = initsevT();
10039 /*- init local data struct.---------------------------------------- -*/
10040 //strat->P.ecart=0; // done by skStrategy
10041 //strat->P.length=0; // done by skStrategy
10043 {
10044 if (strat->kNoether!=NULL)
10045 {
10046 pSetComp(strat->kNoether, strat->ak);
10047 pSetComp(strat->kNoetherTail(), strat->ak);
10048 }
10049 }
10051 {
10052 /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10053 }
10054 else
10055 {
10056 if(TEST_OPT_SB_1)
10057 {
10058 int i;
10059 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10060 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10061 {
10062 P->m[i-strat->newIdeal] = F->m[i];
10063 F->m[i] = NULL;
10064 }
10065 initSSpecialSba(F,Q,P,strat);
10066 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10067 {
10068 F->m[i] = P->m[i-strat->newIdeal];
10069 P->m[i-strat->newIdeal] = NULL;
10070 }
10071 idDelete(&P);
10072 }
10073 else
10074 {
10075 initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10076 }
10077 }
10078 //strat->fromT = FALSE; // done by skStrategy
10079 if (!TEST_OPT_SB_1)
10080 {
10081 if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10082 }
10083 //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10084 //strat->fromQ=NULL;
10085 assume(kTest_TS(strat));
10086}
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7826
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8275

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9541 of file kutil.cc.

9542{
9543 //strat->enterOnePair=enterOnePairNormal;
9545 //strat->chainCrit=chainCritNormal;
9546 strat->chainCrit = chainCritSig;
9547 /******************************************
9548 * rewCrit1 and rewCrit2 are already set in
9549 * kSba() in kstd1.cc
9550 *****************************************/
9551 //strat->rewCrit1 = faugereRewCriterion;
9552 if (strat->sbaOrder == 1)
9553 {
9554 strat->syzCrit = syzCriterionInc;
9555 }
9556 else
9557 {
9558 strat->syzCrit = syzCriterion;
9559 }
9560#ifdef HAVE_RINGS
9562 {
9564 strat->chainCrit=chainCritRing;
9565 }
9566#endif
9567#ifdef HAVE_RATGRING
9568 if (rIsRatGRing(currRing))
9569 {
9570 strat->chainCrit=chainCritPart;
9571 /* enterOnePairNormal get rational part in it */
9572 }
9573#endif
9574
9576 strat->Gebauer = strat->homog || strat->sugarCrit;
9577 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9578 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9579 strat->pairtest = NULL;
9580 /* always use tailreduction, except:
9581 * - in local rings, - in lex order case, -in ring over extensions */
9584
9585#ifdef HAVE_PLURAL
9586 // and r is plural_ring
9587 // hence this holds for r a rational_plural_ring
9588 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9589 { //or it has non-quasi-comm type... later
9590 strat->sugarCrit = FALSE;
9591 strat->Gebauer = FALSE;
9592 strat->honey = FALSE;
9593 }
9594#endif
9595
9596 // Coefficient ring?
9598 {
9599 strat->sugarCrit = FALSE;
9600 strat->Gebauer = FALSE ;
9601 strat->honey = FALSE;
9602 }
9603 #ifdef KDEBUG
9604 if (TEST_OPT_DEBUG)
9605 {
9606 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9607 else PrintS("ideal/module is not homogeneous\n");
9608 }
9609 #endif
9610}
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:6556
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3474
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6521

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 9911 of file kutil.cc.

9912{
9914 {
9915 if (strat->honey)
9916 {
9917 strat->posInL = posInL15;
9918 // ok -- here is the deal: from my experiments for Singular-2-0
9919 // I conclude that that posInT_EcartpLength is the best of
9920 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9921 // see the table at the end of this file
9922 if (TEST_OPT_OLDSTD)
9923 strat->posInT = posInT15;
9924 else
9925 strat->posInT = posInT_EcartpLength;
9926 }
9927 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9928 {
9929 strat->posInL = posInL11;
9930 strat->posInT = posInT11;
9931 }
9932 else if (TEST_OPT_INTSTRATEGY)
9933 {
9934 strat->posInL = posInL11;
9935 strat->posInT = posInT11;
9936 }
9937 else
9938 {
9939 strat->posInL = posInL0;
9940 strat->posInT = posInT0;
9941 }
9942 //if (strat->minim>0) strat->posInL =posInLSpecial;
9943 if (strat->homog)
9944 {
9945 strat->posInL = posInL110;
9946 strat->posInT = posInT110;
9947 }
9948 }
9949 else
9950 {
9951 if (strat->homog)
9952 {
9953 strat->posInL = posInL11;
9954 strat->posInT = posInT11;
9955 }
9956 else
9957 {
9958 if ((currRing->order[0]==ringorder_c)
9959 ||(currRing->order[0]==ringorder_C))
9960 {
9961 strat->posInL = posInL17_c;
9962 strat->posInT = posInT17_c;
9963 }
9964 else
9965 {
9966 strat->posInL = posInL17;
9967 strat->posInT = posInT17;
9968 }
9969 }
9970 }
9971 if (strat->minim>0) strat->posInL =posInLSpecial;
9972 // for further tests only
9973 if ((BTEST1(11)) || (BTEST1(12)))
9974 strat->posInL = posInL11;
9975 else if ((BTEST1(13)) || (BTEST1(14)))
9976 strat->posInL = posInL13;
9977 else if ((BTEST1(15)) || (BTEST1(16)))
9978 strat->posInL = posInL15;
9979 else if ((BTEST1(17)) || (BTEST1(18)))
9980 strat->posInL = posInL17;
9981 if (BTEST1(11))
9982 strat->posInT = posInT11;
9983 else if (BTEST1(13))
9984 strat->posInT = posInT13;
9985 else if (BTEST1(15))
9986 strat->posInT = posInT15;
9987 else if ((BTEST1(17)))
9988 strat->posInT = posInT17;
9989 else if ((BTEST1(19)))
9990 strat->posInT = posInT19;
9991 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9992 strat->posInT = posInT1;
9994 {
9995 strat->posInL = posInL11Ring;
9996 if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
9997 strat->posInL = posInL11Ringls;
9998 strat->posInT = posInT11;
9999 }
10001 strat->posInLSba = posInLSig;
10002 //strat->posInL = posInLSig;
10003 strat->posInL = posInLF5C;
10004 /*
10005 if (rField_is_Ring(currRing))
10006 {
10007 strat->posInLSba = posInLSigRing;
10008 strat->posInL = posInL11Ring;
10009 }*/
10010 //strat->posInT = posInTSig;
10011}
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5703
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:5821

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

7730{
7731 int i,pos;
7732
7734 else i=setmaxT;
7735 strat->ecartS=initec(i);
7736 strat->sevS=initsevS(i);
7737 strat->S_2_R=initS_2_R(i);
7738 strat->fromQ=NULL;
7739 strat->Shdl=idInit(i,F->rank);
7740 strat->S=strat->Shdl->m;
7741 /*- put polys into S -*/
7742 if (Q!=NULL)
7743 {
7744 strat->fromQ=initec(i);
7745 memset(strat->fromQ,0,i*sizeof(int));
7746 for (i=0; i<IDELEMS(Q); i++)
7747 {
7748 if (Q->m[i]!=NULL)
7749 {
7750 LObject h;
7751 h.p = pCopy(Q->m[i]);
7753 {
7754 deleteHC(&h,strat);
7755 }
7757 {
7758 h.pCleardenom(); // also does remove Content
7759 }
7760 else
7761 {
7762 h.pNorm();
7763 }
7764 if (h.p!=NULL)
7765 {
7766 strat->initEcart(&h);
7767 if (strat->sl==-1)
7768 pos =0;
7769 else
7770 {
7771 pos = posInS(strat,strat->sl,h.p,h.ecart);
7772 }
7773 h.sev = pGetShortExpVector(h.p);
7774 strat->enterS(h,pos,strat,-1);
7775 strat->fromQ[pos]=1;
7776 }
7777 }
7778 }
7779 }
7780 for (i=0; i<IDELEMS(F); i++)
7781 {
7782 if (F->m[i]!=NULL)
7783 {
7784 LObject h;
7785 h.p = pCopy(F->m[i]);
7786 if (h.p!=NULL)
7787 {
7789 {
7790 cancelunit(&h); /*- tries to cancel a unit -*/
7791 deleteHC(&h, strat);
7792 }
7793 if (h.p!=NULL)
7794 {
7796 {
7797 h.pCleardenom(); // also does remove Content
7798 }
7799 else
7800 {
7801 h.pNorm();
7802 }
7803 strat->initEcart(&h);
7804 if (strat->Ll==-1)
7805 pos =0;
7806 else
7807 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
7808 h.sev = pGetShortExpVector(h.p);
7809 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7810 }
7811 }
7812 }
7813 }
7814 /*- test, if a unit is in F -*/
7815
7816 if ((strat->Ll>=0)
7817#ifdef HAVE_RINGS
7818 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7819#endif
7820 && pIsConstant(strat->L[strat->Ll].p))
7821 {
7822 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7823 }
7824}

◆ initSLSba()

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

Definition at line 7826 of file kutil.cc.

7827{
7828 int i,pos;
7830 else i=setmaxT;
7831 strat->ecartS = initec(i);
7832 strat->sevS = initsevS(i);
7833 strat->sevSig = initsevS(i);
7834 strat->S_2_R = initS_2_R(i);
7835 strat->fromQ = NULL;
7836 strat->Shdl = idInit(i,F->rank);
7837 strat->S = strat->Shdl->m;
7838 strat->sig = (poly *)omAlloc0(i*sizeof(poly));
7839 if (strat->sbaOrder != 1)
7840 {
7841 strat->syz = (poly *)omAlloc0(i*sizeof(poly));
7842 strat->sevSyz = initsevS(i);
7843 strat->syzmax = i;
7844 strat->syzl = 0;
7845 }
7846 /*- put polys into S -*/
7847 if (Q!=NULL)
7848 {
7849 strat->fromQ=initec(i);
7850 memset(strat->fromQ,0,i*sizeof(int));
7851 for (i=0; i<IDELEMS(Q); i++)
7852 {
7853 if (Q->m[i]!=NULL)
7854 {
7855 LObject h;
7856 h.p = pCopy(Q->m[i]);
7858 {
7859 deleteHC(&h,strat);
7860 }
7862 {
7863 h.pCleardenom(); // also does remove Content
7864 }
7865 else
7866 {
7867 h.pNorm();
7868 }
7869 if (h.p!=NULL)
7870 {
7871 strat->initEcart(&h);
7872 if (strat->sl==-1)
7873 pos =0;
7874 else
7875 {
7876 pos = posInS(strat,strat->sl,h.p,h.ecart);
7877 }
7878 h.sev = pGetShortExpVector(h.p);
7879 strat->enterS(h,pos,strat,-1);
7880 strat->fromQ[pos]=1;
7881 }
7882 }
7883 }
7884 }
7885 for (i=0; i<IDELEMS(F); i++)
7886 {
7887 if (F->m[i]!=NULL)
7888 {
7889 LObject h;
7890 h.p = pCopy(F->m[i]);
7891 h.sig = pOne();
7892 //h.sig = pInit();
7893 //p_SetCoeff(h.sig,nInit(1),currRing);
7894 p_SetComp(h.sig,i+1,currRing);
7895 // if we are working with the Schreyer order we generate it
7896 // by multiplying the initial signatures with the leading monomial
7897 // of the corresponding initial polynomials generating the ideal
7898 // => we can keep the underlying monomial order and get a Schreyer
7899 // order without any bigger overhead
7900 if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
7901 {
7902 p_ExpVectorAdd (h.sig,F->m[i],currRing);
7903 }
7904 h.sevSig = pGetShortExpVector(h.sig);
7905#ifdef DEBUGF5
7906 pWrite(h.p);
7907 pWrite(h.sig);
7908#endif
7909 if (h.p!=NULL)
7910 {
7912 {
7913 cancelunit(&h); /*- tries to cancel a unit -*/
7914 deleteHC(&h, strat);
7915 }
7916 if (h.p!=NULL)
7917 {
7919 {
7920 h.pCleardenom(); // also does remove Content
7921 }
7922 else
7923 {
7924 h.pNorm();
7925 }
7926 strat->initEcart(&h);
7927 if (strat->Ll==-1)
7928 pos =0;
7929 else
7930 pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
7931 h.sev = pGetShortExpVector(h.p);
7932 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7933 }
7934 }
7935 /*
7936 if (strat->sbaOrder != 1)
7937 {
7938 for(j=0;j<i;j++)
7939 {
7940 strat->syz[ctr] = pCopy(F->m[j]);
7941 p_SetCompP(strat->syz[ctr],i+1,currRing);
7942 // add LM(F->m[i]) to the signature to get a Schreyer order
7943 // without changing the underlying polynomial ring at all
7944 p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
7945 // since p_Add_q() destroys all input
7946 // data we need to recreate help
7947 // each time
7948 poly help = pCopy(F->m[i]);
7949 p_SetCompP(help,j+1,currRing);
7950 pWrite(strat->syz[ctr]);
7951 pWrite(help);
7952 printf("%d\n",pLmCmp(strat->syz[ctr],help));
7953 strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
7954 printf("%d. SYZ ",ctr);
7955 pWrite(strat->syz[ctr]);
7956 strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
7957 ctr++;
7958 }
7959 strat->syzl = ps;
7960 }
7961 */
7962 }
7963 }
7964 /*- test, if a unit is in F -*/
7965
7966 if ((strat->Ll>=0)
7967#ifdef HAVE_RINGS
7968 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7969#endif
7970 && pIsConstant(strat->L[strat->Ll].p))
7971 {
7972 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7973 }
7974}
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1409

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 7976 of file kutil.cc.

7977{
7978 if( strat->S[0] )
7979 {
7980 if( strat->S[1] && !rField_is_Ring(currRing))
7981 {
7982 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
7983 omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
7984 omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
7985 }
7986 int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
7987 /************************************************************
7988 * computing the length of the syzygy array needed
7989 ***********************************************************/
7990 for(i=1; i<=strat->sl; i++)
7991 {
7992 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
7993 {
7994 ps += i;
7995 }
7996 }
7997 ps += strat->sl+1;
7998 //comp = pGetComp (strat->P.sig);
7999 comp = strat->currIdx;
8000 strat->syzIdx = initec(comp);
8001 strat->sevSyz = initsevS(ps);
8002 strat->syz = (poly *)omAlloc(ps*sizeof(poly));
8003 strat->syzmax = ps;
8004 strat->syzl = 0;
8005 strat->syzidxmax = comp;
8006#if defined(DEBUGF5) || defined(DEBUGF51)
8007 PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
8008#endif
8009 i = 1;
8010 j = 0;
8011 /************************************************************
8012 * generating the leading terms of the principal syzygies
8013 ***********************************************************/
8014 while (i <= strat->sl)
8015 {
8016 /**********************************************************
8017 * principal syzygies start with component index 2
8018 * the array syzIdx starts with index 0
8019 * => the rules for a signature with component comp start
8020 * at strat->syz[strat->syzIdx[comp-2]] !
8021 *********************************************************/
8022 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8023 {
8024 comp = pGetComp(strat->sig[i]);
8025 comp_old = pGetComp(strat->sig[i-1]);
8026 diff = comp - comp_old - 1;
8027 // diff should be zero, but sometimes also the initial generating
8028 // elements of the input ideal reduce to zero. then there is an
8029 // index-gap between the signatures. for these in-between signatures we
8030 // can safely set syzIdx[j] = 0 as no such element will be ever computed
8031 // in the following.
8032 // doing this, we keep the relation "j = comp - 2" alive, which makes
8033 // jumps way easier when checking criteria
8034 while (diff>0)
8035 {
8036 strat->syzIdx[j] = 0;
8037 diff--;
8038 j++;
8039 }
8040 strat->syzIdx[j] = ctr;
8041 j++;
8042 LObject Q;
8043 int pos;
8044 for (k = 0; k<i; k++)
8045 {
8046 Q.sig = pOne();
8049 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8050 p_SetCompP (Q.sig, comp, currRing);
8051 poly q = p_One(currRing);
8054 p_ExpVectorCopy(q,strat->S[i],currRing);
8055 q = p_Neg (q, currRing);
8056 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8057 Q.sig = p_Add_q (Q.sig, q, currRing);
8058 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8059 pos = posInSyz(strat, Q.sig);
8060 enterSyz(Q, strat, pos);
8061 ctr++;
8062 }
8063 }
8064 i++;
8065 }
8066 /**************************************************************
8067 * add syzygies for upcoming first element of new iteration step
8068 **************************************************************/
8069 comp = strat->currIdx;
8070 comp_old = pGetComp(strat->sig[i-1]);
8071 diff = comp - comp_old - 1;
8072 // diff should be zero, but sometimes also the initial generating
8073 // elements of the input ideal reduce to zero. then there is an
8074 // index-gap between the signatures. for these in-between signatures we
8075 // can safely set syzIdx[j] = 0 as no such element will be ever computed
8076 // in the following.
8077 // doing this, we keep the relation "j = comp - 2" alive, which makes
8078 // jumps way easier when checking criteria
8079 while (diff>0)
8080 {
8081 strat->syzIdx[j] = 0;
8082 diff--;
8083 j++;
8084 }
8085 strat->syzIdx[j] = ctr;
8086 LObject Q;
8087 int pos;
8088 for (k = 0; k<strat->sl+1; k++)
8089 {
8090 Q.sig = pOne();
8093 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8094 p_SetCompP (Q.sig, comp, currRing);
8095 poly q = p_One(currRing);
8097 p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8098 p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8099 q = p_Neg (q, currRing);
8100 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8101 Q.sig = p_Add_q (Q.sig, q, currRing);
8102 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8103 pos = posInSyz(strat, Q.sig);
8104 enterSyz(Q, strat, pos);
8105 ctr++;
8106 }
8107//#if 1
8108#ifdef DEBUGF5
8109 PrintS("Principal syzygies:\n");
8110 Print("syzl %d\n",strat->syzl);
8111 Print("syzmax %d\n",strat->syzmax);
8112 Print("ps %d\n",ps);
8113 PrintS("--------------------------------\n");
8114 for(i=0;i<=strat->syzl-1;i++)
8115 {
8116 Print("%d - ",i);
8117 pWrite(strat->syz[i]);
8118 }
8119 for(i=0;i<strat->currIdx;i++)
8120 {
8121 Print("%d - %d\n",i,strat->syzIdx[i]);
8122 }
8123 PrintS("--------------------------------\n");
8124#endif
8125 }
8126}
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9380
int posInSyz(const kStrategy strat, poly sig)
Definition: kutil.cc:5792
#define p_GetCoeff(p, r)
Definition: monomials.h:50
STATIC_VAR gmp_float * diff
Definition: mpr_complex.cc:45
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4776
poly p_One(const ring r)
Definition: p_polys.cc:1313
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1105
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition: p_polys.h:1311
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:252

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

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

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

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

◆ k_LmInit_currRing_2_tailRing() [1/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 991 of file kInline.h.

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

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 959 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 996 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 968 of file kInline.h.

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

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 1001 of file kInline.h.

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

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 977 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1006 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 984 of file kInline.h.

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

◆ kCheckSpolyCreation()

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

Definition at line 10534 of file kutil.cc.

10535{
10536 if (strat->overflow) return FALSE;
10537 assume(L->p1 != NULL && L->p2 != NULL);
10538 // shift changes: from 0 to -1
10539 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10540 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10541
10542 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10543 return FALSE;
10544 // shift changes: extra case inserted
10545 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10546 {
10547 return TRUE;
10548 }
10549 poly p1_max=NULL;
10550 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10551 poly p2_max=NULL;
10552 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10553
10554 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10555 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10556 {
10557 p_LmFree(m1, strat->tailRing);
10558 p_LmFree(m2, strat->tailRing);
10559 m1 = NULL;
10560 m2 = NULL;
10561 return FALSE;
10562 }
10563 return TRUE;
10564}
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
Definition: kInline.h:1018
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:1997

◆ kCheckStrongCreation()

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

Definition at line 10573 of file kutil.cc.

10574{
10575 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10576 //assume(strat->tailRing != currRing);
10577
10578 poly p1_max = (strat->R[atR])->max_exp;
10579 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10580
10581 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10582 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10583 {
10584 return FALSE;
10585 }
10586 return TRUE;
10587}

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11560 of file kutil.cc.

11561{
11562 printf("red: ");
11563 if (strat->red==redFirst) printf("redFirst\n");
11564 else if (strat->red==redHoney) printf("redHoney\n");
11565 else if (strat->red==redEcart) printf("redEcart\n");
11566 else if (strat->red==redHomog) printf("redHomog\n");
11567 else if (strat->red==redLazy) printf("redLazy\n");
11568 else if (strat->red==redLiftstd) printf("redLiftstd\n");
11569 else printf("%p\n",(void*)strat->red);
11570 printf("posInT: ");
11571 if (strat->posInT==posInT0) printf("posInT0\n");
11572 else if (strat->posInT==posInT1) printf("posInT1\n");
11573 else if (strat->posInT==posInT11) printf("posInT11\n");
11574 else if (strat->posInT==posInT110) printf("posInT110\n");
11575 else if (strat->posInT==posInT13) printf("posInT13\n");
11576 else if (strat->posInT==posInT15) printf("posInT15\n");
11577 else if (strat->posInT==posInT17) printf("posInT17\n");
11578 else if (strat->posInT==posInT17_c) printf("posInT17_c\n");
11579 else if (strat->posInT==posInT19) printf("posInT19\n");
11580 else if (strat->posInT==posInT2) printf("posInT2\n");
11581 #ifdef HAVE_RINGS
11582 else if (strat->posInT==posInT11Ring) printf("posInT11Ring\n");
11583 else if (strat->posInT==posInT110Ring) printf("posInT110Ring\n");
11584 else if (strat->posInT==posInT15Ring) printf("posInT15Ring\n");
11585 else if (strat->posInT==posInT17Ring) printf("posInT17Ring\n");
11586 else if (strat->posInT==posInT17_cRing) printf("posInT17_cRing\n");
11587 #endif
11588#ifdef HAVE_MORE_POS_IN_T
11589 else if (strat->posInT==posInT_EcartFDegpLength) printf("posInT_EcartFDegpLength\n");
11590 else if (strat->posInT==posInT_FDegpLength) printf("posInT_FDegpLength\n");
11591 else if (strat->posInT==posInT_pLength) printf("posInT_pLength\n");
11592#endif
11593 else if (strat->posInT==posInT_EcartpLength) printf("posInT_EcartpLength\n");
11594 else printf("%p\n",(void*)strat->posInT);
11595 printf("posInL: ");
11596 if (strat->posInL==posInL0) printf("posInL0\n");
11597 else if (strat->posInL==posInL10) printf("posInL10\n");
11598 else if (strat->posInL==posInL11) printf("posInL11\n");
11599 else if (strat->posInL==posInL110) printf("posInL110\n");
11600 else if (strat->posInL==posInL13) printf("posInL13\n");
11601 else if (strat->posInL==posInL15) printf("posInL15\n");
11602 else if (strat->posInL==posInL17) printf("posInL17\n");
11603 else if (strat->posInL==posInL17_c) printf("posInL17_c\n");
11604 #ifdef HAVE_RINGS
11605 else if (strat->posInL==posInL0) printf("posInL0Ring\n");
11606 else if (strat->posInL==posInL11Ring) printf("posInL11Ring\n");
11607 else if (strat->posInL==posInL11Ringls) printf("posInL11Ringls\n");
11608 else if (strat->posInL==posInL110Ring) printf("posInL110Ring\n");
11609 else if (strat->posInL==posInL15Ring) printf("posInL15Ring\n");
11610 else if (strat->posInL==posInL17Ring) printf("posInL17Ring\n");
11611 else if (strat->posInL==posInL17_cRing) printf("posInL17_cRing\n");
11612 #endif
11613 else if (strat->posInL==posInLSpecial) printf("posInLSpecial\n");
11614 else printf("%p\n",(void*)strat->posInL);
11615 printf("enterS: ");
11616 if (strat->enterS==enterSBba) printf("enterSBba\n");
11617 else if (strat->enterS==enterSMora) printf("enterSMora\n");
11618 else if (strat->enterS==enterSMoraNF) printf("enterSMoraNF\n");
11619 else printf("%p\n",(void*)strat->enterS);
11620 printf("initEcart: ");
11621 if (strat->initEcart==initEcartBBA) printf("initEcartBBA\n");
11622 else if (strat->initEcart==initEcartNormal) printf("initEcartNormal\n");
11623 else printf("%p\n",(void*)strat->initEcart);
11624 printf("initEcartPair: ");
11625 if (strat->initEcartPair==initEcartPairBba) printf("initEcartPairBba\n");
11626 else if (strat->initEcartPair==initEcartPairMora) printf("initEcartPairMora\n");
11627 else printf("%p\n",(void*)strat->initEcartPair);
11628 printf("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11629 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11630 printf("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11631 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11632 printf("chainCrit: ");
11633 if (strat->chainCrit==chainCritNormal) printf("chainCritNormal\n");
11634 else if (strat->chainCrit==chainCritOpt_1) printf("chainCritOpt_1\n");
11635 else printf("%p\n",(void*)strat->chainCrit);
11636 printf("posInLDependsOnLength=%d\n",
11637 strat->posInLDependsOnLength);
11638 printf("%s\n",showOption());
11639 printf("LDeg: ");
11640 if (currRing->pLDeg==pLDeg0) printf("pLDeg0");
11641 else if (currRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11642 else if (currRing->pLDeg==pLDegb) printf("pLDegb");
11643 else if (currRing->pLDeg==pLDeg1) printf("pLDeg1");
11644 else if (currRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11645 else if (currRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11646 else if (currRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11647 else if (currRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11648 else if (currRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11649 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11650 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11651 else if (currRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11652 else printf("? (%lx)", (long)currRing->pLDeg);
11653 printf(" / ");
11654 if (strat->tailRing->pLDeg==pLDeg0) printf("pLDeg0");
11655 else if (strat->tailRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11656 else if (strat->tailRing->pLDeg==pLDegb) printf("pLDegb");
11657 else if (strat->tailRing->pLDeg==pLDeg1) printf("pLDeg1");
11658 else if (strat->tailRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11659 else if (strat->tailRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11660 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11661 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11662 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11663 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11664 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11665 else if (strat->tailRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11666 else printf("? (%lx)", (long)strat->tailRing->pLDeg);
11667 printf("\n");
11668 printf("currRing->pFDeg: ");
11669 if (currRing->pFDeg==p_Totaldegree) printf("p_Totaldegree");
11670 else if (currRing->pFDeg==p_WFirstTotalDegree) printf("pWFirstTotalDegree");
11671 else if (currRing->pFDeg==p_Deg) printf("p_Deg");
11672 else if (currRing->pFDeg==kHomModDeg) printf("kHomModDeg");
11673 else if (currRing->pFDeg==totaldegreeWecart) printf("totaldegreeWecart");
11674 else if (currRing->pFDeg==p_WTotaldegree) printf("p_WTotaldegree");
11675 else printf("? (%lx)", (long)currRing->pFDeg);
11676 printf("\n");
11677 printf(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11679 printf(" degBound: %d\n", Kstd1_deg);
11680
11681 if( ecartWeights != NULL )
11682 {
11683 printf("ecartWeights: ");
11684 for (int i = rVar(currRing); i > 0; i--)
11685 printf("%hd ", ecartWeights[i]);
11686 printf("\n");
11688 }
11689
11690#ifndef SING_NDEBUG
11692#endif
11693}
int LazyDegree
Definition: kutil.h:353
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1365
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2434
int redFirst(LObject *h, kStrategy strat)
Definition: kstd1.cc:797
int redEcart(LObject *h, kStrategy strat)
Definition: kstd1.cc:169
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1681
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4947
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11526
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11435
VAR int Kstd1_deg
Definition: kutil.cc:247
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1628
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11489
char * showOption()
Definition: misc_ip.cc:709
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:811
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:975
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:596
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1038
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1068
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:941
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:841
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:910
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:613
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:877
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1005
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:770
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:739
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1505
void rDebugPrint(const ring r)
Definition: ring.cc:4122
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:723

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 880 of file kutil.h.

881{
882 if (P->lcm!=NULL)
883 {
884 #ifdef HAVE_RINGS
886 pLmDelete(P->lcm);
887 else
888 #endif
889 pLmFree(P->lcm);
890 P->lcm=NULL;
891 }
892}

◆ kFindDivisibleByInS()

int kFindDivisibleByInS ( const kStrategy  strat,
int *  max_ind,
LObject L 
)

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

Definition at line 421 of file kstd2.cc.

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6740 of file kutil.cc.

6741{
6742 int j = 0;
6743 const unsigned long not_sev = ~L->sev;
6744 const unsigned long* sev = strat->sevS;
6745 poly p;
6746 ring r;
6747 L->GetLm(p, r);
6748
6749 assume(~not_sev == p_GetShortExpVector(p, r));
6750
6751 if (r == currRing)
6752 {
6753 if(!rField_is_Ring(r))
6754 {
6755 loop
6756 {
6757 if (j > end_pos) return NULL;
6758 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6759 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6760 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6761 #else
6762 if (!(sev[j] & not_sev) &&
6763 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
6764 p_LmDivisibleBy(strat->S[j], p, r))
6765 #endif
6766 {
6767 break;
6768 }
6769 j++;
6770 }
6771 }
6772 #ifdef HAVE_RINGS
6773 else
6774 {
6775 loop
6776 {
6777 if (j > end_pos) return NULL;
6778 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6779 if (strat->S[j]!= NULL
6780 && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r)
6781 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6782 && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6783 #else
6784 if (!(sev[j] & not_sev)
6785 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6786 && p_LmDivisibleBy(strat->S[j], p, r)
6787 && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6788 #endif
6789 {
6790 break; // found
6791 }
6792 j++;
6793 }
6794 }
6795 #endif
6796 // if called from NF, T objects do not exist:
6797 if (strat->tl < 0 || strat->S_2_R[j] == -1)
6798 {
6799 T->Set(strat->S[j], r, strat->tailRing);
6800 assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
6801 return T;
6802 }
6803 else
6804 {
6805///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
6806///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
6807// assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
6808 return strat->S_2_T(j);
6809 }
6810 }
6811 else
6812 {
6813 TObject* t;
6814 if(!rField_is_Ring(r))
6815 {
6816 loop
6817 {
6818 if (j > end_pos) return NULL;
6819 assume(strat->S_2_R[j] != -1);
6820 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6821 t = strat->S_2_T(j);
6822 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
6823 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r)
6824 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6825 {
6826 t->pLength=pLength(t->t_p);
6827 return t;
6828 }
6829 #else
6830 if (! (sev[j] & not_sev)
6831 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6832 {
6833 t = strat->S_2_T(j);
6834 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
6835 if (p_LmDivisibleBy(t->t_p, p, r))
6836 {
6837 t->pLength=pLength(t->t_p);
6838 return t;
6839 }
6840 }
6841 #endif
6842 j++;
6843 }
6844 }
6845 #ifdef HAVE_RINGS
6846 else
6847 {
6848 loop
6849 {
6850 if (j > end_pos) return NULL;
6851 assume(strat->S_2_R[j] != -1);
6852 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6853 t = strat->S_2_T(j);
6854 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
6855 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r)
6856 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6857 && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
6858 {
6859 t->pLength=pLength(t->t_p);
6860 return t;
6861 }
6862 #else
6863 if (! (sev[j] & not_sev)
6864 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6865 {
6866 t = strat->S_2_T(j);
6867 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
6868 if (p_LmDivisibleBy(t->t_p, p, r)
6869 && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
6870 {
6871 t->pLength=pLength(t->t_p);
6872 return t;
6873 }
6874 }
6875 #endif
6876 j++;
6877 }
6878 }
6879 #endif
6880 }
6881}
KINLINE TObject * S_2_T(int i)
Definition: kInline.h:38

◆ kFindDivisibleByInT()

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

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

Definition at line 321 of file kstd2.cc.

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

◆ kFindDivisibleByInT_Z()

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

Definition at line 213 of file kstd2.cc.

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

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

◆ kFindInT()

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

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

Definition at line 718 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 743 of file kutil.cc.

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

◆ kFindNextDivisibleByInS()

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

Definition at line 524 of file kstd2.cc.

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

◆ kFindSameLMInT_Z()

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

◆ kFindZeroPoly()

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

Definition at line 569 of file kstd2.cc.

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

4124{
4125 assume(!idIs0(q));
4126 assume(!(idIs0(F)&&(Q==NULL)));
4127// lazy_reduce flags: can be combined by |
4128//#define KSTD_NF_LAZY 1
4129 // do only a reduction of the leading term
4130//#define KSTD_NF_NONORM 4
4131 // only global: avoid normalization, return a multiply of NF
4132 poly p;
4133 int i;
4134 ideal res;
4135 int max_ind;
4136
4137 //if (idIs0(q))
4138 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4139 //if ((idIs0(F))&&(Q==NULL))
4140 // return idCopy(q); /*F=0*/
4141 //strat->ak = idRankFreeModule(F);
4142 /*- creating temp data structures------------------- -*/
4143 BITSET save1;
4144 SI_SAVE_OPT1(save1);
4146 initBuchMoraCrit(strat);
4147 strat->initEcart = initEcartBBA;
4148#ifdef HAVE_SHIFTBBA
4149 if (rIsLPRing(currRing))
4150 {
4151 strat->enterS = enterSBbaShift;
4152 }
4153 else
4154#endif
4155 {
4156 strat->enterS = enterSBba;
4157 }
4158 /*- set S -*/
4159 strat->sl = -1;
4160#ifndef NO_BUCKETS
4162#endif
4163 /*- init local data struct.---------------------------------------- -*/
4164 /*Shdl=*/initS(F,Q,strat);
4165 /*- compute------------------------------------------------------- -*/
4166 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4167 for (i=IDELEMS(q)-1; i>=0; i--)
4168 {
4169 if (q->m[i]!=NULL)
4170 {
4171 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4172 p = redNF(pCopy(q->m[i]),max_ind,
4173 (lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat);
4174 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4175 {
4176 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4178 {
4179 p = redtailBba_NF(p,strat);
4180 }
4181 else
4182 {
4183 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4184 p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
4185 }
4186 }
4187 res->m[i]=p;
4188 }
4189 //else
4190 // res->m[i]=NULL;
4191 }
4192 /*- release temp data------------------------------- -*/
4193 assume(strat->L==NULL); /* strat->L unused */
4194 assume(strat->B==NULL); /* strat->B unused */
4195 omFree(strat->sevS);
4196 omFree(strat->ecartS);
4197 assume(strat->T==NULL);//omfree(strat->T);
4198 assume(strat->sevT==NULL);//omfree(strat->sevT);
4199 assume(strat->R==NULL);//omfree(strat->R);
4200 omfree(strat->S_2_R);
4201 omfree(strat->fromQ);
4202 idDelete(&strat->Shdl);
4203 SI_RESTORE_OPT1(save1);
4204 if (TEST_OPT_PROT) PrintLn();
4205 return res;
4206}
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:2325
void initS(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7635
poly redtailBba_NF(poly p, kStrategy strat)
Definition: kutil.cc:7398
void enterSBbaShift(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:8929
#define omfree(addr)
Definition: omAllocDecl.h:237
#define omFree(addr)
Definition: omAllocDecl.h:261
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 3967 of file kstd2.cc.

3968{
3969 assume(q!=NULL);
3970 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3971
3972// lazy_reduce flags: can be combined by |
3973//#define KSTD_NF_LAZY 1
3974 // do only a reduction of the leading term
3975//#define KSTD_NF_NONORM 4
3976 // only global: avoid normalization, return a multiply of NF
3977 poly p;
3978
3979 //if ((idIs0(F))&&(Q==NULL))
3980 // return pCopy(q); /*F=0*/
3981 //strat->ak = idRankFreeModule(F);
3982 /*- creating temp data structures------------------- -*/
3983 BITSET save1;
3984 SI_SAVE_OPT1(save1);
3986 initBuchMoraCrit(strat);
3987 strat->initEcart = initEcartBBA;
3988#ifdef HAVE_SHIFTBBA
3989 if (rIsLPRing(currRing))
3990 {
3991 strat->enterS = enterSBbaShift;
3992 }
3993 else
3994#endif
3995 {
3996 strat->enterS = enterSBba;
3997 }
3998#ifndef NO_BUCKETS
4000#endif
4001 /*- set S -*/
4002 strat->sl = -1;
4003 /*- init local data struct.---------------------------------------- -*/
4004 /*Shdl=*/initS(F,Q,strat);
4005 /*- compute------------------------------------------------------- -*/
4006 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
4007 //{
4008 // for (i=strat->sl;i>=0;i--)
4009 // pNorm(strat->S[i]);
4010 //}
4011 kTest(strat);
4012 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
4013 if (BVERBOSE(23)) kDebugPrint(strat);
4014 int max_ind;
4015 p = redNF(pCopy(q),max_ind,(lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat);
4016 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4017 {
4018 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4020 {
4021 p = redtailBba_NF(p,strat);
4022 }
4023 else if (rField_is_Ring(currRing))
4024 {
4025 p = redtailBba_Ring(p,max_ind,strat);
4026 }
4027 else
4028 {
4029 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4030 p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
4031 }
4032 }
4033 /*- release temp data------------------------------- -*/
4034 assume(strat->L==NULL); /* strat->L unused */
4035 assume(strat->B==NULL); /* strat->B unused */
4036 omFree(strat->sevS);
4037 omFree(strat->ecartS);
4038 assume(strat->T==NULL);//omfree(strat->T);
4039 assume(strat->sevT==NULL);//omfree(strat->sevT);
4040 assume(strat->R==NULL);//omfree(strat->R);
4041 omfree(strat->S_2_R);
4042 omfree(strat->fromQ);
4043 idDelete(&strat->Shdl);
4044 SI_RESTORE_OPT1(save1);
4045 if (TEST_OPT_PROT) PrintLn();
4046 return p;
4047}
KINLINE poly redtailBba_Ring(poly p, int pos, kStrategy strat)
Definition: kInline.h:1227
BOOLEAN kTest(kStrategy strat)
Definition: kutil.cc:1012
static BOOLEAN rField_is_Zn(const ring r)
Definition: ring.h:512

◆ kNF2Bound() [1/2]

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

Definition at line 4208 of file kstd2.cc.

4209{
4210 assume(!idIs0(q));
4211 assume(!(idIs0(F)&&(Q==NULL)));
4212// lazy_reduce flags: can be combined by |
4213//#define KSTD_NF_LAZY 1
4214 // do only a reduction of the leading term
4215//#define KSTD_NF_NONORM 4
4216 // only global: avoid normalization, return a multiply of NF
4217 poly p;
4218 int i;
4219 ideal res;
4220 int max_ind;
4221
4222 //if (idIs0(q))
4223 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4224 //if ((idIs0(F))&&(Q==NULL))
4225 // return idCopy(q); /*F=0*/
4226 //strat->ak = idRankFreeModule(F);
4227 /*- creating temp data structures------------------- -*/
4228 BITSET save1;
4229 SI_SAVE_OPT1(save1);
4231 initBuchMoraCrit(strat);
4232 strat->initEcart = initEcartBBA;
4233 strat->enterS = enterSBba;
4234 /*- set S -*/
4235 strat->sl = -1;
4236#ifndef NO_BUCKETS
4238#endif
4239 /*- init local data struct.---------------------------------------- -*/
4240 /*Shdl=*/initS(F,Q,strat);
4241 /*- compute------------------------------------------------------- -*/
4242 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4243 for (i=IDELEMS(q)-1; i>=0; i--)
4244 {
4245 if (q->m[i]!=NULL)
4246 {
4247 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4248 p = redNFBound(pCopy(q->m[i]),max_ind,
4249 (lazyReduce & KSTD_NF_NONORM)==KSTD_NF_NONORM,strat,bound);
4250 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4251 {
4252 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4254 {
4255 p = redtailBba_Z(p,max_ind,strat);
4256 }
4257 else if (rField_is_Ring(currRing))
4258 {
4259 p = redtailBba_Ring(p,max_ind,strat);
4260 }
4261 else
4262 {
4263 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4264 p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
4265 }
4266 }
4267 res->m[i]=p;
4268 }
4269 //else
4270 // res->m[i]=NULL;
4271 }
4272 /*- release temp data------------------------------- -*/
4273 assume(strat->L==NULL); /* strat->L unused */
4274 assume(strat->B==NULL); /* strat->B unused */
4275 omFree(strat->sevS);
4276 omFree(strat->ecartS);
4277 assume(strat->T==NULL);//omfree(strat->T);
4278 assume(strat->sevT==NULL);//omfree(strat->sevT);
4279 assume(strat->R==NULL);//omfree(strat->R);
4280 omfree(strat->S_2_R);
4281 omfree(strat->fromQ);
4282 idDelete(&strat->Shdl);
4283 SI_RESTORE_OPT1(save1);
4284 if (TEST_OPT_PROT) PrintLn();
4285 return res;
4286}
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:1220
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition: kInline.h:1232
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
Definition: kstd2.cc:2525

◆ kNF2Bound() [2/2]

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

Definition at line 4049 of file kstd2.cc.

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

◆ ksCreateShortSpoly()

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

Definition at line 1453 of file kspoly.cc.

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

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

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

◆ ksOldSpolyRed()

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

Definition at line 1176 of file kInline.h.

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

◆ ksOldSpolyRedNew()

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

Definition at line 1186 of file kInline.h.

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

◆ ksOldSpolyTail()

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

Definition at line 1206 of file kInline.h.

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

◆ 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 189 of file kspoly.cc.

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

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

◆ 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 481 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 742 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 948 of file kspoly.cc.

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

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

◆ ksReducePolyTail() [2/2]

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

Definition at line 1357 of file kspoly.cc.

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

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

11022{
11023 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11024 /* initial setup or extending */
11025
11026 if (rIsLPRing(currRing)) return TRUE;
11027 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11028 if (expbound >= currRing->bitmask) return FALSE;
11029 strat->overflow=FALSE;
11030 ring new_tailRing = rModifyRing(currRing,
11031 // Hmmm .. the condition pFDeg == p_Deg
11032 // might be too strong
11033 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11034 (strat->ak==0), // omit_comp if the input is an ideal
11035 expbound); // exp_limit
11036
11037 if (new_tailRing == currRing) return TRUE;
11038
11039 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11040 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11041
11042 if (currRing->pFDeg != currRing->pFDegOrig)
11043 {
11044 new_tailRing->pFDeg = currRing->pFDeg;
11045 new_tailRing->pLDeg = currRing->pLDeg;
11046 }
11047
11048 if (TEST_OPT_PROT)
11049 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11050 kTest_TS(strat);
11051 assume(new_tailRing != strat->tailRing);
11052 pShallowCopyDeleteProc p_shallow_copy_delete
11053 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11054
11055 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11056
11057 int i;
11058 for (i=0; i<=strat->tl; i++)
11059 {
11060 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11061 p_shallow_copy_delete);
11062 }
11063 for (i=0; i<=strat->Ll; i++)
11064 {
11065 assume(strat->L[i].p != NULL);
11066 if (pNext(strat->L[i].p) != strat->tail)
11067 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11068 }
11069 if ((strat->P.t_p != NULL) ||
11070 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11071 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11072
11073 if ((L != NULL) && (L->tailRing != new_tailRing))
11074 {
11075 if (L->i_r < 0)
11076 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11077 else
11078 {
11079 assume(L->i_r <= strat->tl);
11080 TObject* t_l = strat->R[L->i_r];
11081 assume(t_l != NULL);
11082 L->tailRing = new_tailRing;
11083 L->p = t_l->p;
11084 L->t_p = t_l->t_p;
11085 L->max_exp = t_l->max_exp;
11086 }
11087 }
11088
11089 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11090 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11091
11092 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11093 if (strat->tailRing != currRing)
11095
11096 strat->tailRing = new_tailRing;
11097 strat->tailBin = new_tailBin;
11099 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11100
11101 if (strat->kNoether != NULL)
11102 {
11103 if (strat->t_kNoether != NULL)
11104 p_LmFree(strat->t_kNoether, strat->tailRing);
11105 strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_tailRing);
11106 }
11107
11108 kTest_TS(strat);
11109 if (TEST_OPT_PROT)
11110 PrintS("]");
11111 return TRUE;
11112}
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:3059
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2698
#define omGetStickyBinOfBin(B)
Definition: xalloc.h:247
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:275

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11114 of file kutil.cc.

11115{
11116 unsigned long l = 0;
11117 int i;
11118 long e;
11119
11120 assume(strat->tailRing == currRing);
11121
11122 for (i=0; i<= strat->Ll; i++)
11123 {
11124 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11125 }
11126 for (i=0; i<=strat->tl; i++)
11127 {
11128 // Hmm ... this we could do in one Step
11129 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11130 }
11132 {
11133 l *= 2;
11134 }
11135 e = p_GetMaxExp(l, currRing);
11136 if (e <= 1) e = 2;
11137 if (rIsLPRing(currRing)) e = 1;
11138
11139 kStratChangeTailRing(strat, NULL, NULL, e);
11140}
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:1175
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:779

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1012 of file kutil.cc.

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

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1055 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 801 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1073 of file kutil.cc.

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

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

◆ message()

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

Definition at line 7512 of file kutil.cc.

7513{
7514 if (i != *olddeg)
7515 {
7516 Print("%d",i);
7517 *olddeg = i;
7518 }
7519 if (TEST_OPT_OLDSTD)
7520 {
7521 if (strat->Ll != *reduc)
7522 {
7523 if (strat->Ll != *reduc-1)
7524 Print("(%d)",strat->Ll+1);
7525 else
7526 PrintS("-");
7527 *reduc = strat->Ll;
7528 }
7529 else
7530 PrintS(".");
7531 mflush();
7532 }
7533 else
7534 {
7535 if (red_result == 0)
7536 PrintS("-");
7537 else if (red_result < 0)
7538 PrintS(".");
7539 if ((red_result > 0) || ((strat->Ll % 100)==99))
7540 {
7541 if (strat->Ll != *reduc && strat->Ll > 0)
7542 {
7543 Print("(%d)",strat->Ll+1);
7544 *reduc = strat->Ll;
7545 }
7546 }
7547 }
7548}

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7585 of file kutil.cc.

7586{
7587 int i;
7588 if (strat->news)
7589 {
7590 PrintS("set S");
7591 for (i=0; i<=strat->sl; i++)
7592 {
7593 Print("\n %d:",i);
7594 p_wrp(strat->S[i], currRing, strat->tailRing);
7595 if (strat->fromQ!=NULL && strat->fromQ[i])
7596 Print(" (from Q)");
7597 }
7598 strat->news = FALSE;
7599 }
7600 if (strat->newt)
7601 {
7602 PrintS("\nset T");
7603 for (i=0; i<=strat->tl; i++)
7604 {
7605 Print("\n %d:",i);
7606 strat->T[i].wrp();
7607 if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7608 Print(" o:%ld e:%d l:%d",
7609 strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7610 }
7611 strat->newt = FALSE;
7612 }
7613 PrintS("\nset L");
7614 for (i=strat->Ll; i>=0; i--)
7615 {
7616 Print("\n%d:",i);
7617 p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7618 PrintS(" ");
7619 p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7620 PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7621 PrintS("\n p : ");
7622 strat->L[i].wrp();
7623 Print(" o:%ld e:%d l:%d",
7624 strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7625 }
7626 PrintLn();
7627}

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7553 of file kutil.cc.

7554{
7555 //PrintS("\nUsage/Allocation of temporary storage:\n");
7556 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7557 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7558 Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7559 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7560 #ifdef HAVE_SHIFTBBA
7561 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7562 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7563 #endif
7564}

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7566 of file kutil.cc.

7567{
7568 //PrintS("\nUsage/Allocation of temporary storage:\n");
7569 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7570 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7571 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7572 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7573 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7574 #ifdef HAVE_SHIFTBBA
7575 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7576 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7577 #endif
7578}
int nrsyzcrit
Definition: kutil.h:360

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10462 of file kutil.cc.

10463{
10464 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10465 return FALSE;
10466 int i,j;
10467 poly newNoether;
10468
10469#if 0
10470 if (currRing->weight_all_1)
10471 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10472 else
10473 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10474#else
10475 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10476#endif
10477 if (strat->kNoether==NULL) return FALSE;
10478 if (strat->t_kNoether != NULL)
10479 {
10480 p_LmFree(strat->t_kNoether, strat->tailRing);
10481 strat->t_kNoether=NULL;
10482 }
10483 if (strat->tailRing != currRing)
10485 /* compare old and new noether*/
10486 newNoether = pLmInit(strat->kNoether);
10487 pSetCoeff0(newNoether,nInit(1));
10488 j = p_FDeg(newNoether,currRing);
10489 for (i=1; i<=(currRing->N); i++)
10490 {
10491 if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10492 }
10493 pSetm(newNoether);
10494 if (j < HCord) /*- statistics -*/
10495 {
10496 if (TEST_OPT_PROT)
10497 {
10498 Print("H(%d)",j);
10499 mflush();
10500 }
10501 HCord=j;
10502 #ifdef KDEBUG
10503 if (TEST_OPT_DEBUG)
10504 {
10505 Print("H(%d):",j);
10506 wrp(strat->kNoether);
10507 PrintLn();
10508 }
10509 #endif
10510 }
10511 if (pCmp(strat->kNoether,newNoether)!=1)
10512 {
10513 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10514 strat->kNoether=newNoether;
10515 if (strat->t_kNoether != NULL)
10516 {
10517 p_LmFree(strat->t_kNoether, strat->tailRing);
10518 strat->t_kNoether=NULL;
10519 }
10520 if (strat->tailRing != currRing)
10522
10523 return TRUE;
10524 }
10525 pLmDelete(newNoether);
10526 return FALSE;
10527}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition: hdegree.cc:1101
VAR int HCord
Definition: kutil.cc:246
static void p_LmDelete0(poly p, const ring r)
Definition: p_polys.h:731
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition: polys.h:115
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pDecrExp(p, i)
Definition: polys.h:44

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

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

Definition at line 4863 of file kutil.cc.

4864{
4865 if(end < 0 || end >= IDELEMS(F))
4866 end = IDELEMS(F);
4867 if (end<0) return 0;
4868 if(pNext(p) == NULL) return start;
4869 polyset set=F->m;
4870 int o = p_Deg(p,currRing);
4871 int op;
4872 int i;
4873 int an = start;
4874 for(i=start;i<end;i++)
4875 if(set[i] != NULL && pNext(set[i]) == NULL)
4876 an++;
4877 if(an == end-1)
4878 return end;
4879 int en= end;
4880 loop
4881 {
4882 if(an>=en)
4883 return en;
4884 if (an == en-1)
4885 {
4886 op = p_Deg(set[an],currRing);
4887 if ((op < o)
4888 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4889 return en;
4890 return an;
4891 }
4892 i=(an+en) / 2;
4893 op = p_Deg(set[i],currRing);
4894 if ((op < o)
4895 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4896 an=i;
4897 else
4898 en=i;
4899 }
4900}
poly * polyset
Definition: polys.h:259

◆ posInL0()

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

Definition at line 5643 of file kutil.cc.

5645{
5646 if (length<0) return 0;
5647
5648 int cmp_int=currRing->OrdSgn;
5649
5650 if (pLmCmp(set[length].p,p->p)== cmp_int)
5651 return length+1;
5652
5653 int i;
5654 int an = 0;
5655 int en= length;
5656 loop
5657 {
5658 if (an >= en-1)
5659 {
5660 if (pLmCmp(set[an].p,p->p) == cmp_int) return en;
5661 return an;
5662 }
5663 i=(an+en) / 2;
5664 if (pLmCmp(set[i].p,p->p) == cmp_int) an=i;
5665 else en=i;
5666 /*aend. fuer lazy == in !=- machen */
5667 }
5668}

◆ posInL10()

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

Definition at line 1365 of file kstd1.cc.

1366{
1367 int j,dp,dL;
1368
1369 if (length<0) return 0;
1370 if (hasPurePower(p,strat->lastAxis,&dp,strat))
1371 {
1372 int op= p->GetpFDeg() +p->ecart;
1373 for (j=length; j>=0; j--)
1374 {
1375 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1376 return j+1;
1377 if (dp < dL)
1378 return j+1;
1379 if ((dp == dL)
1380 && (set[j].GetpFDeg()+set[j].ecart >= op))
1381 return j+1;
1382 }
1383 }
1384 j=length;
1385 loop
1386 {
1387 if (j<0) break;
1388 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1389 j--;
1390 }
1391 return strat->posInLOld(set,j,p,strat);
1392}
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:1317

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

5835{
5836 if (length<0) return 0;
5837
5838 int o = p->GetpFDeg();
5839 int op = set[length].GetpFDeg();
5840 int cmp_int= -currRing->OrdSgn;
5841
5842 if ((op > o)
5843 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
5844 return length+1;
5845 int i;
5846 int an = 0;
5847 int en= length;
5848 loop
5849 {
5850 if (an >= en-1)
5851 {
5852 op = set[an].GetpFDeg();
5853 if ((op > o)
5854 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
5855 return en;
5856 return an;
5857 }
5858 i=(an+en) / 2;
5859 op = set[i].GetpFDeg();
5860 if ((op > o)
5861 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
5862 an=i;
5863 else
5864 en=i;
5865 }
5866}

◆ posInL110()

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

Definition at line 6093 of file kutil.cc.

6095{
6096 if (length<0) return 0;
6097
6098 int o = p->GetpFDeg();
6099 int op = set[length].GetpFDeg();
6100 int cmp_int= -currRing->OrdSgn;
6101
6102 if ((op > o)
6103 || ((op == o) && (set[length].length >p->length))
6104 || ((op == o) && (set[length].length <= p->length)
6105 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6106 return length+1;
6107 int i;
6108 int an = 0;
6109 int en= length;
6110 loop
6111 {
6112 if (an >= en-1)
6113 {
6114 op = set[an].GetpFDeg();
6115 if ((op > o)
6116 || ((op == o) && (set[an].length >p->length))
6117 || ((op == o) && (set[an].length <=p->length)
6118 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6119 return en;
6120 return an;
6121 }
6122 i=(an+en) / 2;
6123 op = set[i].GetpFDeg();
6124 if ((op > o)
6125 || ((op == o) && (set[i].length > p->length))
6126 || ((op == o) && (set[i].length <= p->length)
6127 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6128 an=i;
6129 else
6130 en=i;
6131 }
6132}

◆ posInL11Ring()

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

Definition at line 5876 of file kutil.cc.

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

5948{
5949 if (length < 0) return 0;
5950 int an,en,i;
5951 an = 0;
5952 en = length+1;
5953 loop
5954 {
5955 if (an >= en-1)
5956 {
5957 if(an == en)
5958 return en;
5959 if (set[an].FDeg > p->FDeg)
5960 return en;
5961 if (set[an].FDeg < p->FDeg)
5962 return an;
5963 if (set[an].FDeg == p->FDeg)
5964 {
5965 number lcset,lcp;
5966 lcset = pGetCoeff(set[an].p);
5967 lcp = pGetCoeff(p->p);
5968 if(!nGreaterZero(lcset))
5969 {
5970 set[an].p=p_Neg(set[an].p,currRing);
5971 if (set[an].t_p!=NULL)
5972 pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
5973 lcset=pGetCoeff(set[an].p);
5974 }
5975 if(!nGreaterZero(lcp))
5976 {
5977 p->p=p_Neg(p->p,currRing);
5978 if (p->t_p!=NULL)
5979 pSetCoeff0(p->t_p,pGetCoeff(p->p));
5980 lcp=pGetCoeff(p->p);
5981 }
5982 if(nGreater(lcset, lcp))
5983 {
5984 return en;
5985 }
5986 else
5987 {
5988 return an;
5989 }
5990 }
5991 }
5992 i=(an+en) / 2;
5993 if (set[i].FDeg > p->FDeg)
5994 an=i;
5995 if (set[i].FDeg < p->FDeg)
5996 en=i;
5997 if (set[i].FDeg == p->FDeg)
5998 {
5999 number lcset,lcp;
6000 lcset = pGetCoeff(set[i].p);
6001 lcp = pGetCoeff(p->p);
6002 if(!nGreaterZero(lcset))
6003 {
6004 set[i].p=p_Neg(set[i].p,currRing);
6005 if (set[i].t_p!=NULL)
6006 pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6007 lcset=pGetCoeff(set[i].p);
6008 }
6009 if(!nGreaterZero(lcp))
6010 {
6011 p->p=p_Neg(p->p,currRing);
6012 if (p->t_p!=NULL)
6013 pSetCoeff0(p->t_p,pGetCoeff(p->p));
6014 lcp=pGetCoeff(p->p);
6015 }
6016 if(nGreater(lcset, lcp))
6017 {
6018 an = i;
6019 }
6020 else
6021 {
6022 en = i;
6023 }
6024 }
6025 }
6026}
#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 6182 of file kutil.cc.

6184{
6185 if (length<0) return 0;
6186
6187 int o = p->GetpFDeg();
6188
6189 if (set[length].GetpFDeg() > o)
6190 return length+1;
6191
6192 int i;
6193 int an = 0;
6194 int en= length;
6195 loop
6196 {
6197 if (an >= en-1)
6198 {
6199 if (set[an].GetpFDeg() >= o)
6200 return en;
6201 return an;
6202 }
6203 i=(an+en) / 2;
6204 if (set[i].GetpFDeg() >= o)
6205 an=i;
6206 else
6207 en=i;
6208 }
6209}

◆ posInL15()

int posInL15 ( 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 int cmp_int= -currRing->OrdSgn;
6225
6226 if ((op > o)
6227 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
6228 return length+1;
6229 int i;
6230 int an = 0;
6231 int en= length;
6232 loop
6233 {
6234 if (an >= en-1)
6235 {
6236 op = set[an].GetpFDeg() + set[an].ecart;
6237 if ((op > o)
6238 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
6239 return en;
6240 return an;
6241 }
6242 i=(an+en) / 2;
6243 op = set[i].GetpFDeg() + set[i].ecart;
6244 if ((op > o)
6245 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
6246 an=i;
6247 else
6248 en=i;
6249 }
6250}

◆ posInL15Ring()

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

Definition at line 6253 of file kutil.cc.

6255{
6256 if (length<0) return 0;
6257
6258 int o = p->GetpFDeg() + p->ecart;
6259 int op = set[length].GetpFDeg() + set[length].ecart;
6260
6261 if ((op > o)
6262 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6263 return length+1;
6264 int i;
6265 int an = 0;
6266 int en= length;
6267 loop
6268 {
6269 if (an >= en-1)
6270 {
6271 op = set[an].GetpFDeg() + set[an].ecart;
6272 if ((op > o)
6273 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6274 return en;
6275 return an;
6276 }
6277 i=(an+en) / 2;
6278 op = set[i].GetpFDeg() + set[i].ecart;
6279 if ((op > o)
6280 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6281 an=i;
6282 else
6283 en=i;
6284 }
6285}

◆ posInL17()

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

Definition at line 6294 of file kutil.cc.

6296{
6297 if (length<0) return 0;
6298
6299 int o = p->GetpFDeg() + p->ecart;
6300 int cmp_int= -currRing->OrdSgn;
6301
6302 if ((set[length].GetpFDeg() + set[length].ecart > o)
6303 || ((set[length].GetpFDeg() + set[length].ecart == o)
6304 && (set[length].ecart > p->ecart))
6305 || ((set[length].GetpFDeg() + set[length].ecart == o)
6306 && (set[length].ecart == p->ecart)
6307 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6308 return length+1;
6309 int i;
6310 int an = 0;
6311 int en= length;
6312 loop
6313 {
6314 if (an >= en-1)
6315 {
6316 if ((set[an].GetpFDeg() + set[an].ecart > o)
6317 || ((set[an].GetpFDeg() + set[an].ecart == o)
6318 && (set[an].ecart > p->ecart))
6319 || ((set[an].GetpFDeg() + set[an].ecart == o)
6320 && (set[an].ecart == p->ecart)
6321 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6322 return en;
6323 return an;
6324 }
6325 i=(an+en) / 2;
6326 if ((set[i].GetpFDeg() + set[i].ecart > o)
6327 || ((set[i].GetpFDeg() + set[i].ecart == o)
6328 && (set[i].ecart > p->ecart))
6329 || ((set[i].GetpFDeg() +set[i].ecart == o)
6330 && (set[i].ecart == p->ecart)
6331 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6332 an=i;
6333 else
6334 en=i;
6335 }
6336}

◆ posInLF5C()

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

Definition at line 5821 of file kutil.cc.

5823{
5824 return strat->Ll+1;
5825}

◆ posInLF5CRing()

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

Definition at line 5910 of file kutil.cc.

5912{
5913 if (length<0) return 0;
5914 if(start == (length +1)) return (length+1);
5915 int o = p->GetpFDeg();
5916 int op = set[length].GetpFDeg();
5917
5918 if ((op > o)
5919 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
5920 return length+1;
5921 int i;
5922 int an = start;
5923 int en= length;
5924 loop
5925 {
5926 if (an >= en-1)
5927 {
5928 op = set[an].GetpFDeg();
5929 if ((op > o)
5930 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
5931 return en;
5932 return an;
5933 }
5934 i=(an+en) / 2;
5935 op = set[i].GetpFDeg();
5936 if ((op > o)
5937 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
5938 an=i;
5939 else
5940 en=i;
5941 }
5942}

◆ posInLSig()

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

Definition at line 5703 of file kutil.cc.

5705{
5706 if (length<0) return 0;
5707 int cmp_int=currRing->OrdSgn;
5708 if (pLtCmp(set[length].sig,p->sig)==cmp_int)
5709 return length+1;
5710
5711 int i;
5712 int an = 0;
5713 int en= length;
5714 loop
5715 {
5716 if (an >= en-1)
5717 {
5718 if (pLtCmp(set[an].sig,p->sig) == cmp_int) return en;
5719 return an;
5720 }
5721 i=(an+en) / 2;
5722 if (pLtCmp(set[i].sig,p->sig) == cmp_int) an=i;
5723 else en=i;
5724 /*aend. fuer lazy == in !=- machen */
5725 }
5726}

◆ posInLSigRing()

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

Definition at line 5728 of file kutil.cc.

5730{
5731 assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
5732 if (length<0) return 0;
5733 if (pLtCmp(set[length].sig,p->sig)== 1)
5734 return length+1;
5735
5736 int an,en,i;
5737 an = 0;
5738 en = length+1;
5739 int cmp;
5740 loop
5741 {
5742 if (an >= en-1)
5743 {
5744 if(an == en)
5745 return en;
5746 cmp = pLtCmp(set[an].sig,p->sig);
5747 if (cmp == 1)
5748 return en;
5749 if (cmp == -1)
5750 return an;
5751 if (cmp == 0)
5752 {
5753 if (set[an].FDeg > p->FDeg)
5754 return en;
5755 if (set[an].FDeg < p->FDeg)
5756 return an;
5757 if (set[an].FDeg == p->FDeg)
5758 {
5759 cmp = pLtCmp(set[an].p,p->p);
5760 if(cmp == 1)
5761 return en;
5762 else
5763 return an;
5764 }
5765 }
5766 }
5767 i=(an+en) / 2;
5768 cmp = pLtCmp(set[i].sig,p->sig);
5769 if (cmp == 1)
5770 an = i;
5771 if (cmp == -1)
5772 en = i;
5773 if (cmp == 0)
5774 {
5775 if (set[i].FDeg > p->FDeg)
5776 an = i;
5777 if (set[i].FDeg < p->FDeg)
5778 en = i;
5779 if (set[i].FDeg == p->FDeg)
5780 {
5781 cmp = pLtCmp(set[i].p,p->p);
5782 if(cmp == 1)
5783 an = i;
5784 else
5785 en = i;
5786 }
5787 }
5788 }
5789}

◆ posInS()

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

Definition at line 4685 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4786 of file kutil.cc.

4787{
4788 if (length<0) return 0;
4789 polyset set=strat->S;
4790 if(pNext(p) == NULL)
4791 {
4792 int mon = 0;
4793 for(int i = 0;i<=length;i++)
4794 {
4795 if(set[i] != NULL && pNext(set[i]) == NULL)
4796 mon++;
4797 }
4798 int o = p_Deg(p,currRing);
4799 int op = p_Deg(set[mon],currRing);
4800
4801 if ((op < o)
4802 || ((op == o) && (pLtCmp(set[mon],p) == -1)))
4803 return length+1;
4804 int i;
4805 int an = 0;
4806 int en= mon;
4807 loop
4808 {
4809 if (an >= en-1)
4810 {
4811 op = p_Deg(set[an],currRing);
4812 if ((op < o)
4813 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4814 return en;
4815 return an;
4816 }
4817 i=(an+en) / 2;
4818 op = p_Deg(set[i],currRing);
4819 if ((op < o)
4820 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4821 an=i;
4822 else
4823 en=i;
4824 }
4825 }
4826 else /*if(pNext(p) != NULL)*/
4827 {
4828 int o = p_Deg(p,currRing);
4829 int op = p_Deg(set[length],currRing);
4830
4831 if ((op < o)
4832 || ((op == o) && (pLtCmp(set[length],p) == -1)))
4833 return length+1;
4834 int i;
4835 int an = 0;
4836 for(i=0;i<=length;i++)
4837 if(set[i] != NULL && pNext(set[i]) == NULL)
4838 an++;
4839 int en= length;
4840 loop
4841 {
4842 if (an >= en-1)
4843 {
4844 op = p_Deg(set[an],currRing);
4845 if ((op < o)
4846 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4847 return en;
4848 return an;
4849 }
4850 i=(an+en) / 2;
4851 op = p_Deg(set[i],currRing);
4852 if ((op < o)
4853 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4854 an=i;
4855 else
4856 en=i;
4857 }
4858 }
4859}

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 5792 of file kutil.cc.

5793{
5794 if (strat->syzl==0) return 0;
5795 int cmp_int=currRing->OrdSgn;
5796 if (pLtCmp(strat->syz[strat->syzl-1],sig) != cmp_int)
5797 return strat->syzl;
5798 int i;
5799 int an = 0;
5800 int en= strat->syzl-1;
5801 loop
5802 {
5803 if (an >= en-1)
5804 {
5805 if (pLtCmp(strat->syz[an],sig) != cmp_int) return en;
5806 return an;
5807 }
5808 i=(an+en) / 2;
5809 if (pLtCmp(strat->syz[i],sig) != cmp_int) an=i;
5810 else en=i;
5811 /*aend. fuer lazy == in !=- machen */
5812 }
5813}

◆ posInT0()

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

Definition at line 4907 of file kutil.cc.

4908{
4909 return (length+1);
4910}

◆ posInT1()

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

Definition at line 4918 of file kutil.cc.

4919{
4920 if (length==-1) return 0;
4921
4922 if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
4923
4924 int i;
4925 int an = 0;
4926 int en= length;
4927 int cmp_int=currRing->OrdSgn;
4928
4929 loop
4930 {
4931 if (an >= en-1)
4932 {
4933 if (pLmCmp(set[an].p,p.p) == cmp_int) return an;
4934 return en;
4935 }
4936 i=(an+en) / 2;
4937 if (pLmCmp(set[i].p,p.p) == cmp_int) en=i;
4938 else an=i;
4939 }
4940}

◆ posInT11()

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

Definition at line 4975 of file kutil.cc.

4976{
4977 if (length==-1) return 0;
4978
4979 int o = p.GetpFDeg();
4980 int op = set[length].GetpFDeg();
4981 int cmp_int=currRing->OrdSgn;
4982
4983 if ((op < o)
4984 || ((op == o) && (pLmCmp(set[length].p,p.p) != cmp_int)))
4985 return length+1;
4986
4987 int i;
4988 int an = 0;
4989 int en= length;
4990
4991 loop
4992 {
4993 if (an >= en-1)
4994 {
4995 op= set[an].GetpFDeg();
4996 if ((op > o)
4997 || (( op == o) && (pLmCmp(set[an].p,p.p) == cmp_int)))
4998 return an;
4999 return en;
5000 }
5001 i=(an+en) / 2;
5002 op = set[i].GetpFDeg();
5003 if (( op > o)
5004 || (( op == o) && (pLmCmp(set[i].p,p.p) == cmp_int)))
5005 en=i;
5006 else
5007 an=i;
5008 }
5009}

◆ posInT110()

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

Definition at line 5053 of file kutil.cc.

5054{
5055 if (length==-1) return 0;
5056 p.GetpLength();
5057
5058 int o = p.GetpFDeg();
5059 int op = set[length].GetpFDeg();
5060 int cmp_int=currRing->OrdSgn;
5061
5062 if (( op < o)
5063 || (( op == o) && (set[length].length<p.length))
5064 || (( op == o) && (set[length].length == p.length)
5065 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5066 return length+1;
5067
5068 int i;
5069 int an = 0;
5070 int en= length;
5071 loop
5072 {
5073 if (an >= en-1)
5074 {
5075 op = set[an].GetpFDeg();
5076 if (( op > o)
5077 || (( op == o) && (set[an].length > p.length))
5078 || (( op == o) && (set[an].length == p.length)
5079 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5080 return an;
5081 return en;
5082 }
5083 i=(an+en) / 2;
5084 op = set[i].GetpFDeg();
5085 if (( op > o)
5086 || (( op == o) && (set[i].length > p.length))
5087 || (( op == o) && (set[i].length == p.length)
5088 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5089 en=i;
5090 else
5091 an=i;
5092 }
5093}

◆ posInT13()

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

Definition at line 5143 of file kutil.cc.

5144{
5145 if (length==-1) return 0;
5146
5147 int o = p.GetpFDeg();
5148
5149 if (set[length].GetpFDeg() <= o)
5150 return length+1;
5151
5152 int i;
5153 int an = 0;
5154 int en= length;
5155 loop
5156 {
5157 if (an >= en-1)
5158 {
5159 if (set[an].GetpFDeg() > o)
5160 return an;
5161 return en;
5162 }
5163 i=(an+en) / 2;
5164 if (set[i].GetpFDeg() > o)
5165 en=i;
5166 else
5167 an=i;
5168 }
5169}

◆ posInT15()

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

Definition at line 5210 of file kutil.cc.

5229{
5230 if (length==-1) return 0;
5231
5232 int o = p.GetpFDeg() + p.ecart;
5233 int op = set[length].GetpFDeg()+set[length].ecart;
5234 int cmp_int=currRing->OrdSgn;
5235
5236 if ((op < o)
5237 || ((op == o)
5238 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5239 return length+1;
5240
5241 int i;
5242 int an = 0;
5243 int en= length;
5244 loop
5245 {
5246 if (an >= en-1)
5247 {
5248 op = set[an].GetpFDeg()+set[an].ecart;
5249 if (( op > o)
5250 || (( op == o) && (pLmCmp(set[an].p,p.p) == cmp_int)))
5251 return an;
5252 return en;
5253 }
5254 i=(an+en) / 2;
5255 op = set[i].GetpFDeg()+set[i].ecart;
5256 if (( op > o)
5257 || (( op == o) && (pLmCmp(set[i].p,p.p) == cmp_int)))
5258 en=i;
5259 else
5260 an=i;
5261 }
5262}

◆ posInT17()

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

Definition at line 5306 of file kutil.cc.

5327{
5328 if (length==-1) return 0;
5329
5330 int o = p.GetpFDeg() + p.ecart;
5331 int op = set[length].GetpFDeg()+set[length].ecart;
5332 int cmp_int=currRing->OrdSgn;
5333
5334 if ((op < o)
5335 || (( op == o) && (set[length].ecart > p.ecart))
5336 || (( op == o) && (set[length].ecart==p.ecart)
5337 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5338 return length+1;
5339
5340 int i;
5341 int an = 0;
5342 int en= length;
5343 loop
5344 {
5345 if (an >= en-1)
5346 {
5347 op = set[an].GetpFDeg()+set[an].ecart;
5348 if (( op > o)
5349 || (( op == o) && (set[an].ecart < p.ecart))
5350 || (( op == o) && (set[an].ecart==p.ecart)
5351 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5352 return an;
5353 return en;
5354 }
5355 i=(an+en) / 2;
5356 op = set[i].GetpFDeg()+set[i].ecart;
5357 if ((op > o)
5358 || (( op == o) && (set[i].ecart < p.ecart))
5359 || (( op == o) && (set[i].ecart == p.ecart)
5360 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5361 en=i;
5362 else
5363 an=i;
5364 }
5365}

◆ posInT17_c()

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

Definition at line 5414 of file kutil.cc.

5415{
5416 if (length==-1) return 0;
5417
5418 int cc = (-1+2*currRing->order[0]==ringorder_c);
5419 /* cc==1 for (c,..), cc==-1 for (C,..) */
5420 int o = p.GetpFDeg() + p.ecart;
5421 int c = pGetComp(p.p)*cc;
5422 int cmp_int=currRing->OrdSgn;
5423
5424 if (pGetComp(set[length].p)*cc < c)
5425 return length+1;
5426 if (pGetComp(set[length].p)*cc == c)
5427 {
5428 int op = set[length].GetpFDeg()+set[length].ecart;
5429 if ((op < o)
5430 || ((op == o) && (set[length].ecart > p.ecart))
5431 || ((op == o) && (set[length].ecart==p.ecart)
5432 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5433 return length+1;
5434 }
5435
5436 int i;
5437 int an = 0;
5438 int en= length;
5439 loop
5440 {
5441 if (an >= en-1)
5442 {
5443 if (pGetComp(set[an].p)*cc < c)
5444 return en;
5445 if (pGetComp(set[an].p)*cc == c)
5446 {
5447 int op = set[an].GetpFDeg()+set[an].ecart;
5448 if ((op > o)
5449 || ((op == o) && (set[an].ecart < p.ecart))
5450 || ((op == o) && (set[an].ecart==p.ecart)
5451 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5452 return an;
5453 }
5454 return en;
5455 }
5456 i=(an+en) / 2;
5457 if (pGetComp(set[i].p)*cc > c)
5458 en=i;
5459 else if (pGetComp(set[i].p)*cc == c)
5460 {
5461 int op = set[i].GetpFDeg()+set[i].ecart;
5462 if ((op > o)
5463 || ((op == o) && (set[i].ecart < p.ecart))
5464 || ((op == o) && (set[i].ecart == p.ecart)
5465 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5466 en=i;
5467 else
5468 an=i;
5469 }
5470 else
5471 an=i;
5472 }
5473}

◆ posInT19()

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

Definition at line 5542 of file kutil.cc.

5543{
5544 p.GetpLength();
5545 if (length==-1) return 0;
5546
5547 int o = p.ecart;
5548 int op=p.GetpFDeg();
5549
5550 if (set[length].ecart < o)
5551 return length+1;
5552 if (set[length].ecart == o)
5553 {
5554 int oo=set[length].GetpFDeg();
5555 if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5556 return length+1;
5557 }
5558
5559 int i;
5560 int an = 0;
5561 int en= length;
5562 loop
5563 {
5564 if (an >= en-1)
5565 {
5566 if (set[an].ecart > o)
5567 return an;
5568 if (set[an].ecart == o)
5569 {
5570 int oo=set[an].GetpFDeg();
5571 if((oo > op)
5572 || ((oo==op) && (set[an].length > p.length)))
5573 return an;
5574 }
5575 return en;
5576 }
5577 i=(an+en) / 2;
5578 if (set[i].ecart > o)
5579 en=i;
5580 else if (set[i].ecart == o)
5581 {
5582 int oo=set[i].GetpFDeg();
5583 if ((oo > op)
5584 || ((oo == op) && (set[i].length > p.length)))
5585 en=i;
5586 else
5587 an=i;
5588 }
5589 else
5590 an=i;
5591 }
5592}

◆ posInT2()

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

Definition at line 4947 of file kutil.cc.

4948{
4949 if (length==-1) return 0;
4950 p.GetpLength();
4951 if (set[length].length<p.length) return length+1;
4952
4953 int i;
4954 int an = 0;
4955 int en= length;
4956
4957 loop
4958 {
4959 if (an >= en-1)
4960 {
4961 if (set[an].length>p.length) return an;
4962 return en;
4963 }
4964 i=(an+en) / 2;
4965 if (set[i].length>p.length) en=i;
4966 else an=i;
4967 }
4968}

◆ posInT_EcartFDegpLength()

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

Definition at line 11435 of file kutil.cc.

11436{
11437
11438 if (length==-1) return 0;
11439
11440 int o = p.ecart;
11441 int op=p.GetpFDeg();
11442 int ol = p.GetpLength();
11443
11444 if (set[length].ecart < o)
11445 return length+1;
11446 if (set[length].ecart == o)
11447 {
11448 int oo=set[length].GetpFDeg();
11449 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11450 return length+1;
11451 }
11452
11453 int i;
11454 int an = 0;
11455 int en= length;
11456 loop
11457 {
11458 if (an >= en-1)
11459 {
11460 if (set[an].ecart > o)
11461 return an;
11462 if (set[an].ecart == o)
11463 {
11464 int oo=set[an].GetpFDeg();
11465 if((oo > op)
11466 || ((oo==op) && (set[an].pLength > ol)))
11467 return an;
11468 }
11469 return en;
11470 }
11471 i=(an+en) / 2;
11472 if (set[i].ecart > o)
11473 en=i;
11474 else if (set[i].ecart == o)
11475 {
11476 int oo=set[i].GetpFDeg();
11477 if ((oo > op)
11478 || ((oo == op) && (set[i].pLength > ol)))
11479 en=i;
11480 else
11481 an=i;
11482 }
11483 else
11484 an=i;
11485 }
11486}

◆ posInT_EcartpLength()

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

Definition at line 5172 of file kutil.cc.

5173{
5174 if (length==-1) return 0;
5175 int ol = p.GetpLength();
5176 int op=p.ecart;
5177 int oo=set[length].ecart;
5178
5179 if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5180 return length+1;
5181
5182 int i;
5183 int an = 0;
5184 int en= length;
5185 loop
5186 {
5187 if (an >= en-1)
5188 {
5189 int oo=set[an].ecart;
5190 if((oo > op)
5191 || ((oo==op) && (set[an].pLength > ol)))
5192 return an;
5193 return en;
5194 }
5195 i=(an+en) / 2;
5196 int oo=set[i].ecart;
5197 if ((oo > op)
5198 || ((oo == op) && (set[i].pLength > ol)))
5199 en=i;
5200 else
5201 an=i;
5202 }
5203}

◆ posInT_FDegpLength()

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

Definition at line 11489 of file kutil.cc.

11490{
11491
11492 if (length==-1) return 0;
11493
11494 int op=p.GetpFDeg();
11495 int ol = p.GetpLength();
11496
11497 int oo=set[length].GetpFDeg();
11498 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11499 return length+1;
11500
11501 int i;
11502 int an = 0;
11503 int en= length;
11504 loop
11505 {
11506 if (an >= en-1)
11507 {
11508 int oo=set[an].GetpFDeg();
11509 if((oo > op)
11510 || ((oo==op) && (set[an].pLength > ol)))
11511 return an;
11512 return en;
11513 }
11514 i=(an+en) / 2;
11515 int oo=set[i].GetpFDeg();
11516 if ((oo > op)
11517 || ((oo == op) && (set[i].pLength > ol)))
11518 en=i;
11519 else
11520 an=i;
11521 }
11522}

◆ posInT_pLength()

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

Definition at line 11526 of file kutil.cc.

11527{
11528 int ol = p.GetpLength();
11529 if (length==-1)
11530 return 0;
11531 if (set[length].length<p.length)
11532 return length+1;
11533
11534 int i;
11535 int an = 0;
11536 int en= length;
11537
11538 loop
11539 {
11540 if (an >= en-1)
11541 {
11542 if (set[an].pLength>ol) return an;
11543 return en;
11544 }
11545 i=(an+en) / 2;
11546 if (set[i].pLength>ol) en=i;
11547 else an=i;
11548 }
11549}

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

10764{
10765 if(!nCoeff_is_Z(currRing->cf))
10766 return;
10767 poly pH = h->GetP();
10768 poly p,pp;
10769 p = pH;
10770 bool deleted = FALSE, ok = FALSE;
10771 for(int i = 0; i<=strat->sl; i++)
10772 {
10773 p = pH;
10774 if(pNext(strat->S[i]) == NULL)
10775 {
10776 //pWrite(p);
10777 //pWrite(strat->S[i]);
10778 while(ok == FALSE && p != NULL)
10779 {
10780 if(pLmDivisibleBy(strat->S[i], p)
10781#ifdef HAVE_SHIFTBBA
10782 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
10783#endif
10784 )
10785 {
10786 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10787 p_SetCoeff(p,dummy,currRing);
10788 }
10789 if(nIsZero(p->coef))
10790 {
10791 pLmDelete(&p);
10792 h->p = p;
10793 deleted = TRUE;
10794 }
10795 else
10796 {
10797 ok = TRUE;
10798 }
10799 }
10800 if (p!=NULL)
10801 {
10802 pp = pNext(p);
10803 while(pp != NULL)
10804 {
10805 if(pLmDivisibleBy(strat->S[i], pp)
10806#ifdef HAVE_SHIFTBBA
10807 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
10808#endif
10809 )
10810 {
10811 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10812 p_SetCoeff(pp,dummy,currRing);
10813 if(nIsZero(pp->coef))
10814 {
10815 pLmDelete(&pNext(p));
10816 pp = pNext(p);
10817 deleted = TRUE;
10818 }
10819 else
10820 {
10821 p = pp;
10822 pp = pNext(p);
10823 }
10824 }
10825 else
10826 {
10827 p = pp;
10828 pp = pNext(p);
10829 }
10830 }
10831 }
10832 }
10833 }
10834 h->SetLmCurrRing();
10835 if((deleted)&&(h->p!=NULL))
10836 strat->initEcart(h);
10837}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 10839 of file kutil.cc.

10840{
10841 if(!nCoeff_is_Z(currRing->cf))
10842 return;
10843 poly hSig = h->sig;
10844 poly pH = h->GetP();
10845 poly p,pp;
10846 p = pH;
10847 bool deleted = FALSE, ok = FALSE;
10848 for(int i = 0; i<=strat->sl; i++)
10849 {
10850 p = pH;
10851 if(pNext(strat->S[i]) == NULL)
10852 {
10853 while(ok == FALSE && p!=NULL)
10854 {
10855 if(pLmDivisibleBy(strat->S[i], p))
10856 {
10857 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10858 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10859 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10860 {
10861 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10862 p_SetCoeff(p,dummy,currRing);
10863 }
10864 pDelete(&sigMult);
10865 }
10866 if(nIsZero(p->coef))
10867 {
10868 pLmDelete(&p);
10869 h->p = p;
10870 deleted = TRUE;
10871 }
10872 else
10873 {
10874 ok = TRUE;
10875 }
10876 }
10877 if(p == NULL)
10878 return;
10879 pp = pNext(p);
10880 while(pp != NULL)
10881 {
10882 if(pLmDivisibleBy(strat->S[i], pp))
10883 {
10884 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10885 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10886 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10887 {
10888 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10889 p_SetCoeff(pp,dummy,currRing);
10890 if(nIsZero(pp->coef))
10891 {
10892 pLmDelete(&pNext(p));
10893 pp = pNext(p);
10894 deleted = TRUE;
10895 }
10896 else
10897 {
10898 p = pp;
10899 pp = pNext(p);
10900 }
10901 }
10902 else
10903 {
10904 p = pp;
10905 pp = pNext(p);
10906 }
10907 pDelete(&sigMult);
10908 }
10909 else
10910 {
10911 p = pp;
10912 pp = pNext(p);
10913 }
10914 }
10915 }
10916 }
10917 h->SetLmCurrRing();
10918 if(deleted)
10919 strat->initEcart(h);
10920
10921}
#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 10596 of file kutil.cc.

10597{
10598 if(!nCoeff_is_Z(currRing->cf))
10599 return NULL;
10600 ideal F = idCopy(Forig);
10601 idSkipZeroes(F);
10602 poly pmon;
10603 ring origR = currRing;
10604 ideal monred = idInit(1,1);
10605 for(int i=0; i<idElem(F); i++)
10606 {
10607 if(pNext(F->m[i]) == NULL)
10608 idInsertPoly(monred, pCopy(F->m[i]));
10609 }
10610 int posconst = idPosConstant(F);
10611 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10612 {
10613 idDelete(&F);
10614 idDelete(&monred);
10615 return NULL;
10616 }
10617 int idelemQ = 0;
10618 if(Q!=NULL)
10619 {
10620 idelemQ = IDELEMS(Q);
10621 for(int i=0; i<idelemQ; i++)
10622 {
10623 if(pNext(Q->m[i]) == NULL)
10624 idInsertPoly(monred, pCopy(Q->m[i]));
10625 }
10626 idSkipZeroes(monred);
10627 posconst = idPosConstant(monred);
10628 //the constant, if found, will be from Q
10629 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10630 {
10631 pmon = pCopy(monred->m[posconst]);
10632 idDelete(&F);
10633 idDelete(&monred);
10634 return pmon;
10635 }
10636 }
10637 ring QQ_ring = rCopy0(currRing,FALSE);
10638 nKillChar(QQ_ring->cf);
10639 QQ_ring->cf = nInitChar(n_Q, NULL);
10640 rComplete(QQ_ring,1);
10641 QQ_ring = rAssure_c_dp(QQ_ring);
10642 rChangeCurrRing(QQ_ring);
10643 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10644 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10645 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10646 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10647 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10648 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10649 ideal one = kStd(II, NULL, isNotHomog, NULL);
10650 idSkipZeroes(one);
10651 if(idIsConstant(one))
10652 {
10653 //one should be <1>
10654 for(int i = IDELEMS(II)-1; i>=0; i--)
10655 if(II->m[i] != NULL)
10656 II->m[i+1] = II->m[i];
10657 II->m[0] = pOne();
10658 ideal syz = idSyzygies(II, isNotHomog, NULL);
10659 poly integer = NULL;
10660 for(int i = IDELEMS(syz)-1;i>=0; i--)
10661 {
10662 if(pGetComp(syz->m[i]) == 1)
10663 {
10664 pSetComp(syz->m[i],0);
10665 if(pIsConstant(pHead(syz->m[i])))
10666 {
10667 integer = pHead(syz->m[i]);
10668 break;
10669 }
10670 }
10671 }
10672 rChangeCurrRing(origR);
10673 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10674 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10675 idDelete(&monred);
10676 idDelete(&F);
10677 id_Delete(&II,QQ_ring);
10678 id_Delete(&one,QQ_ring);
10679 id_Delete(&syz,QQ_ring);
10680 p_Delete(&integer,QQ_ring);
10681 rDelete(QQ_ring);
10682 return pmon;
10683 }
10684 else
10685 {
10686 if(idIs0(monred))
10687 {
10688 poly mindegmon = NULL;
10689 for(int i = 0; i<IDELEMS(one); i++)
10690 {
10691 if(pNext(one->m[i]) == NULL)
10692 {
10693 if(mindegmon == NULL)
10694 mindegmon = pCopy(one->m[i]);
10695 else
10696 {
10697 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10698 mindegmon = pCopy(one->m[i]);
10699 }
10700 }
10701 }
10702 if(mindegmon != NULL)
10703 {
10704 for(int i = IDELEMS(II)-1; i>=0; i--)
10705 if(II->m[i] != NULL)
10706 II->m[i+1] = II->m[i];
10707 II->m[0] = pCopy(mindegmon);
10708 ideal syz = idSyzygies(II, isNotHomog, NULL);
10709 bool found = FALSE;
10710 for(int i = IDELEMS(syz)-1;i>=0; i--)
10711 {
10712 if(pGetComp(syz->m[i]) == 1)
10713 {
10714 pSetComp(syz->m[i],0);
10715 if(pIsConstant(pHead(syz->m[i])))
10716 {
10717 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10718 found = TRUE;
10719 break;
10720 }
10721 }
10722 }
10723 id_Delete(&syz,QQ_ring);
10724 if (found == FALSE)
10725 {
10726 rChangeCurrRing(origR);
10727 idDelete(&monred);
10728 idDelete(&F);
10729 id_Delete(&II,QQ_ring);
10730 id_Delete(&one,QQ_ring);
10731 rDelete(QQ_ring);
10732 return NULL;
10733 }
10734 rChangeCurrRing(origR);
10735 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10736 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10737 idDelete(&monred);
10738 idDelete(&F);
10739 id_Delete(&II,QQ_ring);
10740 id_Delete(&one,QQ_ring);
10741 id_Delete(&syz,QQ_ring);
10742 rDelete(QQ_ring);
10743 return pmon;
10744 }
10745 }
10746 }
10747 rChangeCurrRing(origR);
10748 idDelete(&monred);
10749 idDelete(&F);
10750 id_Delete(&II,QQ_ring);
10751 id_Delete(&one,QQ_ring);
10752 rDelete(QQ_ring);
10753 return NULL;
10754}
@ 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:697
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:413
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:568
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:2447
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:3450
ring rAssure_c_dp(const ring r)
Definition: ring.cc:4990
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1421
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
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
Definition: simpleideals.h:67
@ isNotHomog
Definition: structs.h:36

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4988 of file kstd2.cc.

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

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 1121 of file kstd2.cc.

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

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 2088 of file kstd2.cc.

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

◆ redHoneyM()

int redHoneyM ( LObject h,
kStrategy  strat 
)

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1881 of file kstd2.cc.

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

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

◆ redNF()

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

Definition at line 2325 of file kstd2.cc.

2326{
2327 if (h==NULL) return NULL;
2328 int j,j_ring;
2329 int cnt=REDNF_CANONICALIZE;
2330 max_ind=strat->sl;
2331
2332 if (0 > strat->sl)
2333 {
2334 return h;
2335 }
2336 LObject P(h);
2337 P.SetShortExpVector();
2338 P.t_p=NULL;
2339#ifdef HAVE_RINGS
2340 BOOLEAN is_ring = rField_is_Ring(currRing);
2341 if(is_ring) nonorm=TRUE;
2342#endif
2343#ifdef KDEBUG
2344// if (TEST_OPT_DEBUG)
2345// {
2346// PrintS("redNF: starting S:\n");
2347// for( j = 0; j <= max_ind; j++ )
2348// {
2349// Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2350// pWrite(strat->S[j]);
2351// }
2352// };
2353#endif
2354 if (rField_is_Z(currRing))
2355 {
2356 redRing_Z_S(&P,strat);
2357 if (P.bucket!=NULL)
2358 {
2359 P.p=kBucketClear(P.bucket);
2360 kBucketDestroy(&P.bucket);
2361 }
2362 return P.p;
2363 }
2364 else if (rField_is_Ring(currRing))
2365 {
2366 redRing_S(&P,strat);
2367 if (P.bucket!=NULL)
2368 {
2369 P.p=kBucketClear(P.bucket);
2370 kBucketDestroy(&P.bucket);
2371 }
2372 return P.p;
2373 }
2374
2375 P.bucket = kBucketCreate(currRing);
2376 kBucketInit(P.bucket,P.p,pLength(P.p));
2377 kbTest(P.bucket);
2378 P.p=kBucketGetLm(P.bucket);
2379 loop
2380 {
2381 j_ring=j=kFindDivisibleByInS_noCF(strat,&max_ind,&P);
2382 while ((j>=0)
2383 && (nonorm)
2384 && (!n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[j]),currRing->cf)))
2385 j=kFindNextDivisibleByInS(strat,j+1,max_ind,&P);
2386 if (j>=0)
2387 {
2388 int sl=pSize(strat->S[j]);
2389 int jj=j;
2390 loop
2391 {
2392 int sll;
2393 jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
2394 if (jj<0) break;
2395 if ((!nonorm)
2396 || (n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[jj]),currRing->cf)))
2397 {
2398 sll=pSize(strat->S[jj]);
2399 if (sll<sl)
2400 {
2401 #ifdef KDEBUG
2402 if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2403 #endif
2404 //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2405 j=jj;
2406 sl=sll;
2407 }
2408 }
2409 }
2410 if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2411 {
2412 pNorm(strat->S[j]);
2413 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2414 }
2415 nNormalize(pGetCoeff(P.p));
2416#ifdef KDEBUG
2417 if (TEST_OPT_DEBUG)
2418 {
2419 PrintS("red:");
2420 wrp(P.p);
2421 PrintS(" with ");
2422 wrp(strat->S[j]);
2423 }
2424#endif
2425#ifdef HAVE_PLURAL
2427 {
2428 number coef;
2429 nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
2430 nDelete(&coef);
2431 }
2432 else
2433#endif
2434 {
2435 kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),
2436 strat->kNoether);
2437 }
2438 cnt--;
2439 if (cnt==0)
2440 {
2441 kBucketCanonicalize(P.bucket);
2443 }
2444 P.p=kBucketGetLm(P.bucket);
2445 //P.t_p=NULL;
2446#ifdef KDEBUG
2447 if (TEST_OPT_DEBUG)
2448 {
2449 PrintS("\nto:");
2450 wrp(P.p);
2451 PrintLn();
2452 }
2453#endif
2454 if (P.p==NULL)
2455 {
2456 kBucketDestroy(&P.bucket);
2457 return NULL;
2458 }
2459 kbTest(P.bucket);
2460 P.SetShortExpVector();
2461 }
2462#ifdef HAVE_RINGS
2463 else if (is_ring && (j_ring>=0) && (currRing->cf->cfQuotRem!=ndQuotRem))
2464 {
2465 number r;
2466 number n=n_QuotRem(pGetCoeff(P.p),pGetCoeff(strat->S[j_ring]),&r,currRing->cf);
2467 if(!n_IsZero(n,currRing->cf))
2468 {
2469 poly lm=kBucketGetLm(P.bucket);
2470 poly m=p_Head(lm,currRing);
2471 p_ExpVectorSub(m,strat->S[j_ring],currRing);
2472 if (p_GetComp(strat->S[j_ring], currRing) != p_GetComp(lm, currRing))
2473 {
2475 }
2477 p_Setm(m,currRing);
2478#ifdef KDEBUG
2479 if (TEST_OPT_DEBUG)
2480 {
2481 PrintS("redi (coeff):");
2482 wrp(P.p);
2483 PrintS(" with ");
2484 wrp(strat->S[j]);
2485 }
2486#endif
2487 int l=-1;
2488 kBucket_Minus_m_Mult_p(P.bucket,m,strat->S[j_ring],&l);
2489 P.p=kBucketGetLm(P.bucket);
2491#ifdef KDEBUG
2492 if (TEST_OPT_DEBUG)
2493 {
2494 PrintS("\nto:");
2495 wrp(P.p);
2496 PrintLn();
2497 }
2498#endif
2499 }
2500 else
2501 {
2502 n_Delete(&n,currRing->cf);
2503 }
2504 n_Delete(&r,currRing->cf);
2505 P.p=kBucketClear(P.bucket);
2506 kBucketDestroy(&P.bucket);
2507 pNormalize(P.p);
2508 return P.p;
2509 }
2510#endif
2511 else
2512 {
2513 P.p=kBucketClear(P.bucket);
2514 kBucketDestroy(&P.bucket);
2515 pNormalize(P.p);
2516 return P.p;
2517 }
2518 }
2519}
int m
Definition: cfEzgcd.cc:128
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:521
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *l...
Definition: kbuckets.cc:722
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:493
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:209
void kBucketPolyRedNF(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition: kbuckets.cc:1188
const poly kBucketGetLm(kBucket_pt bucket)
Definition: kbuckets.cc:506
int kFindNextDivisibleByInS(const kStrategy strat, int start, int max_ind, LObject *L)
Definition: kstd2.cc:524
int kFindDivisibleByInS_noCF(const kStrategy strat, int *max_ind, LObject *L)
Definition: kstd2.cc:484
static int redRing_S(LObject *h, kStrategy strat)
Definition: kstd2.cc:1056
static int redRing_Z_S(LObject *h, kStrategy strat)
Definition: kstd2.cc:841
#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:858
#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 387 of file kstd1.cc.

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

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 954 of file kstd2.cc.

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

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 683 of file kstd2.cc.

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

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

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1511 of file kstd2.cc.

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

◆ redtail() [1/2]

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

Definition at line 6883 of file kutil.cc.

6884{
6885 poly h, hn;
6886 strat->redTailChange=FALSE;
6887
6888 L->GetP();
6889 poly p = L->p;
6890 if (strat->noTailReduction || pNext(p) == NULL)
6891 return p;
6892
6893 LObject Ln(strat->tailRing);
6894 TObject* With;
6895 // placeholder in case strat->tl < 0
6896 TObject With_s(strat->tailRing);
6897 h = p;
6898 hn = pNext(h);
6899 long op = strat->tailRing->pFDeg(hn, strat->tailRing);
6900 long e;
6901 int l;
6902 BOOLEAN save_HE=strat->kAllAxis;
6903 strat->kAllAxis |=
6904 ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
6905
6906 while(hn != NULL)
6907 {
6908 op = strat->tailRing->pFDeg(hn, strat->tailRing);
6909 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
6910 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
6911 loop
6912 {
6913 Ln.Set(hn, strat->tailRing);
6914 Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
6915 if (strat->kAllAxis)
6916 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
6917 else
6918 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
6919 if (With == NULL) break;
6920 With->length=0;
6921 With->pLength=0;
6922 strat->redTailChange=TRUE;
6923 if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
6924 {
6925 // reducing the tail would violate the exp bound
6926 if (kStratChangeTailRing(strat, L))
6927 {
6928 strat->kAllAxis = save_HE;
6929 return redtail(L, end_pos, strat);
6930 }
6931 else
6932 return NULL;
6933 }
6934 hn = pNext(h);
6935 if (hn == NULL) goto all_done;
6936 op = strat->tailRing->pFDeg(hn, strat->tailRing);
6937 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
6938 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
6939 }
6940 h = hn;
6941 hn = pNext(h);
6942 }
6943
6944 all_done:
6945 if (strat->redTailChange)
6946 {
6947 L->pLength = 0;
6948 }
6949 strat->kAllAxis = save_HE;
6950 return p;
6951}
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:6740
#define TEST_OPT_INFREDTAIL
Definition: options.h:119

◆ redtail() [2/2]

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

Definition at line 6953 of file kutil.cc.

6954{
6955 LObject L(p, currRing);
6956 return redtail(&L, end_pos, strat);
6957}

◆ redtailBba() [1/3]

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

Definition at line 6959 of file kutil.cc.

6960{
6961 strat->redTailChange=FALSE;
6962 if (strat->noTailReduction) return L->GetLmCurrRing();
6963 poly h, p;
6964 p = h = L->GetLmTailRing();
6965 if ((h==NULL) || (pNext(h)==NULL))
6966 return L->GetLmCurrRing();
6967
6968 TObject* With;
6969 // placeholder in case strat->tl < 0
6970 TObject With_s(strat->tailRing);
6971
6972 LObject Ln(pNext(h), strat->tailRing);
6973 Ln.GetpLength();
6974
6975 pNext(h) = NULL;
6976 if (L->p != NULL)
6977 {
6978 pNext(L->p) = NULL;
6979 if (L->t_p != NULL) pNext(L->t_p) = NULL;
6980 }
6981 L->pLength = 1;
6982
6983 Ln.PrepareRed(strat->use_buckets);
6984
6985 int cnt=REDTAIL_CANONICALIZE;
6986 while(!Ln.IsNull())
6987 {
6988 loop
6989 {
6990 if (TEST_OPT_IDLIFT)
6991 {
6992 if (Ln.p!=NULL)
6993 {
6994 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
6995 }
6996 else
6997 {
6998 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
6999 }
7000 }
7001 Ln.SetShortExpVector();
7002 if (withT)
7003 {
7004 int j;
7005 j = kFindDivisibleByInT(strat, &Ln);
7006 if (j < 0) break;
7007 With = &(strat->T[j]);
7008 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7009 }
7010 else
7011 {
7012 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7013 if (With == NULL) break;
7014 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7015 }
7016 cnt--;
7017 if (cnt==0)
7018 {
7020 /*poly tmp=*/Ln.CanonicalizeP();
7021 if (normalize)
7022 {
7023 Ln.Normalize();
7024 //pNormalize(tmp);
7025 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7026 }
7027 }
7028 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7029 {
7030 With->pNorm();
7031 }
7032 strat->redTailChange=TRUE;
7033 if (ksReducePolyTail(L, With, &Ln))
7034 {
7035 // reducing the tail would violate the exp bound
7036 // set a flag and hope for a retry (in bba)
7038 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7039 do
7040 {
7041 pNext(h) = Ln.LmExtractAndIter();
7042 pIter(h);
7043 L->pLength++;
7044 } while (!Ln.IsNull());
7045 goto all_done;
7046 }
7047 if (Ln.IsNull()) goto all_done;
7048 if (! withT) With_s.Init(currRing);
7049 }
7050 pNext(h) = Ln.LmExtractAndIter();
7051 pIter(h);
7052 pNormalize(h);
7053 L->pLength++;
7054 }
7055
7056 all_done:
7057 Ln.Delete();
7058 if (L->p != NULL) pNext(L->p) = pNext(p);
7059
7060 if (strat->redTailChange)
7061 {
7062 L->length = 0;
7063 L->pLength = 0;
7064 }
7065
7066 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7067 //L->Normalize(); // HANNES: should have a test
7068 kTest_L(L,strat);
7069 return L->GetLmCurrRing();
7070}
#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 1214 of file kInline.h.

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

◆ redtailBba() [3/3]

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

◆ redtailBba_NF()

poly redtailBba_NF ( poly  p,
kStrategy  strat 
)

Definition at line 7398 of file kutil.cc.

7399{
7400 strat->redTailChange=FALSE;
7401 if (strat->noTailReduction) return p;
7402 if ((p==NULL) || (pNext(p)==NULL))
7403 return p;
7404
7405 int max_ind;
7406 poly h=p;
7407 p=pNext(p);
7408 pNext(h)=NULL;
7409 while(p!=NULL)
7410 {
7411 p=redNF(p,max_ind,1,strat);
7412 if (p!=NULL)
7413 {
7414 poly hh=p;
7415 p=pNext(p);
7416 pNext(hh)=NULL;
7417 h=p_Add_q(h,hh,currRing);
7418 }
7419 }
7420 return h;
7421}

◆ redtailBba_Ring() [1/2]

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

Definition at line 7423 of file kutil.cc.

7425{
7426 strat->redTailChange=FALSE;
7427 if (strat->noTailReduction) return L->GetLmCurrRing();
7428 poly h, p;
7429 p = h = L->GetLmTailRing();
7430 if ((h==NULL) || (pNext(h)==NULL))
7431 return L->GetLmCurrRing();
7432
7433 TObject* With;
7434 // placeholder in case strat->tl < 0
7435 TObject With_s(strat->tailRing);
7436
7437 LObject Ln(pNext(h), strat->tailRing);
7438 Ln.pLength = L->GetpLength() - 1;
7439
7440 pNext(h) = NULL;
7441 if (L->p != NULL) pNext(L->p) = NULL;
7442 L->pLength = 1;
7443
7444 Ln.PrepareRed(strat->use_buckets);
7445
7446 int cnt=REDTAIL_CANONICALIZE;
7447 while(!Ln.IsNull())
7448 {
7449 loop
7450 {
7451 Ln.SetShortExpVector();
7452 With_s.Init(currRing);
7453 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7454 if (With == NULL) break;
7455 cnt--;
7456 if (cnt==0)
7457 {
7459 /*poly tmp=*/Ln.CanonicalizeP();
7460 }
7461 // we are in a ring, do not call pNorm
7462 // test divisibility of coefs:
7463 poly p_Ln=Ln.GetLmCurrRing();
7464 poly p_With=With->GetLmCurrRing();
7465 if (n_DivBy(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf))
7466 {
7467 strat->redTailChange=TRUE;
7468
7469 if (ksReducePolyTail_Z(L, With, &Ln))
7470 {
7471 // reducing the tail would violate the exp bound
7472 // set a flag and hope for a retry (in bba)
7474 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7475 do
7476 {
7477 pNext(h) = Ln.LmExtractAndIter();
7478 pIter(h);
7479 L->pLength++;
7480 } while (!Ln.IsNull());
7481 goto all_done;
7482 }
7483 }
7484 else break; /*proceed to next monomial*/
7485 if (Ln.IsNull()) goto all_done;
7486 }
7487 pNext(h) = Ln.LmExtractAndIter();
7488 pIter(h);
7489 pNormalize(h);
7490 L->pLength++;
7491 }
7492
7493 all_done:
7494 Ln.Delete();
7495 if (L->p != NULL) pNext(L->p) = pNext(p);
7496
7497 if (strat->redTailChange)
7498 {
7499 L->length = 0;
7500 }
7501
7502 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7503 //L->Normalize(); // HANNES: should have a test
7504 kTest_L(L,strat);
7505 return L->GetLmCurrRing();
7506}
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1127

◆ redtailBba_Ring() [2/2]

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

Definition at line 1227 of file kInline.h.

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

◆ redtailBba_Z() [1/2]

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

Definition at line 7317 of file kutil.cc.

7319{
7320 strat->redTailChange=FALSE;
7321 if (strat->noTailReduction) return L->GetLmCurrRing();
7322 poly h, p;
7323 p = h = L->GetLmTailRing();
7324 if ((h==NULL) || (pNext(h)==NULL))
7325 return L->GetLmCurrRing();
7326
7327 TObject* With;
7328 // placeholder in case strat->tl < 0
7329 TObject With_s(strat->tailRing);
7330
7331 LObject Ln(pNext(h), strat->tailRing);
7332 Ln.pLength = L->GetpLength() - 1;
7333
7334 pNext(h) = NULL;
7335 if (L->p != NULL) pNext(L->p) = NULL;
7336 L->pLength = 1;
7337
7338 Ln.PrepareRed(strat->use_buckets);
7339
7340 int cnt=REDTAIL_CANONICALIZE;
7341 while(!Ln.IsNull())
7342 {
7343 loop
7344 {
7345 Ln.SetShortExpVector();
7346 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7347 if (With == NULL) break;
7348 cnt--;
7349 if (cnt==0)
7350 {
7352 /*poly tmp=*/Ln.CanonicalizeP();
7353 }
7354 // we are in Z, do not call pNorm
7355 strat->redTailChange=TRUE;
7356 // test divisibility of coefs:
7357 poly p_Ln=Ln.GetLmCurrRing();
7358 poly p_With=With->GetLmCurrRing();
7359
7360 if (ksReducePolyTail_Z(L, With, &Ln))
7361 {
7362 // reducing the tail would violate the exp bound
7363 // set a flag and hope for a retry (in bba)
7365 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7366 do
7367 {
7368 pNext(h) = Ln.LmExtractAndIter();
7369 pIter(h);
7370 L->pLength++;
7371 } while (!Ln.IsNull());
7372 goto all_done;
7373 }
7374 if (Ln.IsNull()) goto all_done;
7375 With_s.Init(currRing);
7376 }
7377 pNext(h) = Ln.LmExtractAndIter();
7378 pIter(h);
7379 pNormalize(h);
7380 L->pLength++;
7381 }
7382
7383 all_done:
7384 Ln.Delete();
7385 if (L->p != NULL) pNext(L->p) = pNext(p);
7386
7387 if (strat->redTailChange)
7388 {
7389 L->length = 0;
7390 }
7391
7392 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7393 //L->Normalize(); // HANNES: should have a test
7394 kTest_L(L,strat);
7395 return L->GetLmCurrRing();
7396}

◆ redtailBba_Z() [2/2]

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

Definition at line 1232 of file kInline.h.

1233{
1234 LObject L(p, currRing, strat->tailRing);
1235 return redtailBba_Z(&L, pos, strat);
1236}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7188 of file kutil.cc.

7190{
7191 strat->redTailChange=FALSE;
7192
7193 poly h, p;
7194 p = h = L->GetLmTailRing();
7195 if ((h==NULL) || (pNext(h)==NULL))
7196 return;
7197
7198 TObject* With;
7199 LObject Ln(pNext(h), strat->tailRing);
7200 Ln.GetpLength();
7201
7202 pNext(h) = NULL;
7203 if (L->p != NULL)
7204 {
7205 pNext(L->p) = NULL;
7206 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7207 }
7208 L->pLength = 1;
7209
7210 Ln.PrepareRed(strat->use_buckets);
7211
7212 int cnt=REDTAIL_CANONICALIZE;
7213
7214 while(!Ln.IsNull())
7215 {
7216 loop
7217 {
7218 if (TEST_OPT_IDLIFT)
7219 {
7220 if (Ln.p!=NULL)
7221 {
7222 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7223 }
7224 else
7225 {
7226 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7227 }
7228 }
7229 Ln.SetShortExpVector();
7230 int j;
7231 j = kFindDivisibleByInT(strat, &Ln);
7232 if (j < 0)
7233 {
7234 j = kFindDivisibleByInT_Z(strat, &Ln);
7235 if (j < 0)
7236 {
7237 break;
7238 }
7239 else
7240 {
7241 /* reduction not cancelling a tail term, but reducing its coefficient */
7242 With = &(strat->T[j]);
7243 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7244 cnt--;
7245 if (cnt==0)
7246 {
7248 /*poly tmp=*/Ln.CanonicalizeP();
7249 }
7250 strat->redTailChange=TRUE;
7251 /* reduction cancelling a tail term */
7252 if (ksReducePolyTailLC_Z(L, With, &Ln))
7253 {
7254 // reducing the tail would violate the exp bound
7255 // set a flag and hope for a retry (in bba)
7257 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7258 do
7259 {
7260 pNext(h) = Ln.LmExtractAndIter();
7261 pIter(h);
7262 L->pLength++;
7263 } while (!Ln.IsNull());
7264 goto all_done;
7265 }
7266 /* we have to break since we did not cancel the term, but only decreased
7267 * its coefficient. */
7268 break;
7269 }
7270 } else {
7271 With = &(strat->T[j]);
7272 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7273 cnt--;
7274 if (cnt==0)
7275 {
7277 /*poly tmp=*/Ln.CanonicalizeP();
7278 }
7279 strat->redTailChange=TRUE;
7280 /* reduction cancelling a tail term */
7281 if (ksReducePolyTail_Z(L, With, &Ln))
7282 {
7283 // reducing the tail would violate the exp bound
7284 // set a flag and hope for a retry (in bba)
7286 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7287 do
7288 {
7289 pNext(h) = Ln.LmExtractAndIter();
7290 pIter(h);
7291 L->pLength++;
7292 } while (!Ln.IsNull());
7293 goto all_done;
7294 }
7295 }
7296 if (Ln.IsNull()) goto all_done;
7297 }
7298 pNext(h) = Ln.LmExtractAndIter();
7299 pIter(h);
7300 L->pLength++;
7301 }
7302
7303 all_done:
7304 Ln.Delete();
7305 if (L->p != NULL) pNext(L->p) = pNext(p);
7306
7307 if (strat->redTailChange)
7308 {
7309 L->length = 0;
7310 L->pLength = 0;
7311 }
7312
7313 kTest_L(L, strat);
7314 return;
7315}
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1109

◆ redtailBbaBound() [1/2]

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

Definition at line 7072 of file kutil.cc.

7073{
7074 strat->redTailChange=FALSE;
7075 if (strat->noTailReduction) return L->GetLmCurrRing();
7076 poly h, p;
7077 p = h = L->GetLmTailRing();
7078 if ((h==NULL) || (pNext(h)==NULL))
7079 return L->GetLmCurrRing();
7080
7081 TObject* With;
7082 // placeholder in case strat->tl < 0
7083 TObject With_s(strat->tailRing);
7084
7085 LObject Ln(pNext(h), strat->tailRing);
7086 Ln.pLength = L->GetpLength() - 1;
7087
7088 pNext(h) = NULL;
7089 if (L->p != NULL) pNext(L->p) = NULL;
7090 L->pLength = 1;
7091
7092 Ln.PrepareRed(strat->use_buckets);
7093
7094 int cnt=REDTAIL_CANONICALIZE;
7095 while(!Ln.IsNull())
7096 {
7097 loop
7098 {
7099 if (TEST_OPT_IDLIFT)
7100 {
7101 if (Ln.p!=NULL)
7102 {
7103 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7104 }
7105 else
7106 {
7107 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7108 }
7109 }
7110 Ln.SetShortExpVector();
7111 if (withT)
7112 {
7113 int j;
7114 j = kFindDivisibleByInT(strat, &Ln);
7115 if (j < 0) break;
7116 With = &(strat->T[j]);
7117 }
7118 else
7119 {
7120 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7121 if (With == NULL) break;
7122 }
7123 cnt--;
7124 if (cnt==0)
7125 {
7127 /*poly tmp=*/Ln.CanonicalizeP();
7128 if (normalize)
7129 {
7130 Ln.Normalize();
7131 //pNormalize(tmp);
7132 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7133 }
7134 }
7135 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7136 {
7137 With->pNorm();
7138 }
7139 strat->redTailChange=TRUE;
7140 if (ksReducePolyTail(L, With, &Ln))
7141 {
7142 // reducing the tail would violate the exp bound
7143 // set a flag and hope for a retry (in bba)
7145 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7146 do
7147 {
7148 pNext(h) = Ln.LmExtractAndIter();
7149 pIter(h);
7150 L->pLength++;
7151 } while (!Ln.IsNull());
7152 goto all_done;
7153 }
7154 if(!Ln.IsNull())
7155 {
7156 Ln.GetP();
7157 Ln.p = pJet(Ln.p,bound);
7158 }
7159 if (Ln.IsNull())
7160 {
7161 goto all_done;
7162 }
7163 if (! withT) With_s.Init(currRing);
7164 }
7165 pNext(h) = Ln.LmExtractAndIter();
7166 pIter(h);
7167 pNormalize(h);
7168 L->pLength++;
7169 }
7170
7171 all_done:
7172 Ln.Delete();
7173 if (L->p != NULL) pNext(L->p) = pNext(p);
7174
7175 if (strat->redTailChange)
7176 {
7177 L->length = 0;
7178 L->pLength = 0;
7179 }
7180
7181 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7182 //L->Normalize(); // HANNES: should have a test
7183 kTest_L(L,strat);
7184 return L->GetLmCurrRing();
7185}
#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 1220 of file kInline.h.

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

◆ redtailBbaShift()

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

Definition at line 13081 of file kutil.cc.

13082{
13083 /* for the shift case need to run it with withT = TRUE */
13084 strat->redTailChange=FALSE;
13085 if (strat->noTailReduction) return L->GetLmCurrRing();
13086 poly h, p;
13087 p = h = L->GetLmTailRing();
13088 if ((h==NULL) || (pNext(h)==NULL))
13089 return L->GetLmCurrRing();
13090
13091 TObject* With;
13092 // placeholder in case strat->tl < 0
13093 TObject With_s(strat->tailRing);
13094
13095 LObject Ln(pNext(h), strat->tailRing);
13096 Ln.pLength = L->GetpLength() - 1;
13097
13098 pNext(h) = NULL;
13099 if (L->p != NULL) pNext(L->p) = NULL;
13100 L->pLength = 1;
13101
13102 Ln.PrepareRed(strat->use_buckets);
13103
13104 while(!Ln.IsNull())
13105 {
13106 loop
13107 {
13108 Ln.SetShortExpVector();
13109 if (withT)
13110 {
13111 int j;
13112 j = kFindDivisibleByInT(strat, &Ln);
13113 if (j < 0) break;
13114 With = &(strat->T[j]);
13115 }
13116 else
13117 {
13118 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13119 if (With == NULL) break;
13120 }
13121 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13122 {
13123 With->pNorm();
13124 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13125 }
13126 strat->redTailChange=TRUE;
13127 if (ksReducePolyTail(L, With, &Ln))
13128 {
13129 // reducing the tail would violate the exp bound
13130 // set a flag and hope for a retry (in bba)
13132 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13133 do
13134 {
13135 pNext(h) = Ln.LmExtractAndIter();
13136 pIter(h);
13137 L->pLength++;
13138 } while (!Ln.IsNull());
13139 goto all_done;
13140 }
13141 if (Ln.IsNull()) goto all_done;
13142 if (! withT) With_s.Init(currRing);
13143 }
13144 pNext(h) = Ln.LmExtractAndIter();
13145 pIter(h);
13146 L->pLength++;
13147 }
13148
13149 all_done:
13150 Ln.Delete();
13151 if (L->p != NULL) pNext(L->p) = pNext(p);
13152
13153 if (strat->redTailChange)
13154 {
13155 L->length = 0;
13156 }
13157 L->Normalize(); // HANNES: should have a test
13158 kTest_L(L,strat);
13159 return L->GetLmCurrRing();
13160}

◆ redtailSba()

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

Definition at line 1761 of file kstd2.cc.

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

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 4632 of file kutil.cc.

4633{
4634 int i,j,at,ecart, s2r;
4635 int fq=0;
4636 unsigned long sev;
4637 poly p;
4638 int new_suc=strat->sl+1;
4639 i= *suc;
4640 if (i<0) i=0;
4641
4642 for (; i<=strat->sl; i++)
4643 {
4644 at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4645 if (at != i)
4646 {
4647 if (new_suc > at) new_suc = at;
4648 p = strat->S[i];
4649 ecart = strat->ecartS[i];
4650 sev = strat->sevS[i];
4651 s2r = strat->S_2_R[i];
4652 if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4653 for (j=i; j>=at+1; j--)
4654 {
4655 strat->S[j] = strat->S[j-1];
4656 strat->ecartS[j] = strat->ecartS[j-1];
4657 strat->sevS[j] = strat->sevS[j-1];
4658 strat->S_2_R[j] = strat->S_2_R[j-1];
4659 }
4660 strat->S[at] = p;
4661 strat->ecartS[at] = ecart;
4662 strat->sevS[at] = sev;
4663 strat->S_2_R[at] = s2r;
4664 if (strat->fromQ!=NULL)
4665 {
4666 for (j=i; j>=at+1; j--)
4667 {
4668 strat->fromQ[j] = strat->fromQ[j-1];
4669 }
4670 strat->fromQ[at]=fq;
4671 }
4672 }
4673 }
4674 if (new_suc <= strat->sl) *suc=new_suc;
4675 else *suc=-1;
4676}

◆ replaceInLAndSAndT()

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

Definition at line 9087 of file kutil.cc.

9088{
9089 p.GetP(strat->lmBin);
9090 if (strat->homog) strat->initEcart(&p);
9091 strat->redTailChange=FALSE;
9093 {
9094 p.pCleardenom();
9096 {
9097#ifdef HAVE_SHIFTBBA
9098 if (rIsLPRing(currRing))
9099 p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9100 else
9101#endif
9102 {
9103 p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9104 }
9105 p.pCleardenom();
9106 if (strat->redTailChange)
9107 p.t_p=NULL;
9108 if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9109 else strat->P.sev=0;
9110 }
9111 }
9112
9113 assume(strat->tailRing == p.tailRing);
9114 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9115
9116 int i, j, pos;
9117 poly tp = strat->T[tj].p;
9118
9119 /* enter p to T set */
9120 enterT(p, strat);
9121
9122 for (j = 0; j <= strat->sl; ++j)
9123 {
9124 if (pLtCmp(tp, strat->S[j]) == 0)
9125 {
9126 break;
9127 }
9128 }
9129 /* it may be that the exchanged element
9130 * is until now only in T and not in S */
9131 if (j <= strat->sl)
9132 {
9133 deleteInS(j, strat);
9134 }
9135
9136 pos = posInS(strat, strat->sl, p.p, p.ecart);
9137
9138 pp_Test(p.p, currRing, p.tailRing);
9139 assume(p.FDeg == p.pFDeg());
9140
9141 /* remove useless pairs from L set */
9142 for (i = 0; i <= strat->Ll; ++i)
9143 {
9144 if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9145 {
9146 deleteInL(strat->L, &(strat->Ll), i, strat);
9147 i--;
9148 continue;
9149 }
9150 if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9151 {
9152 deleteInL(strat->L, &(strat->Ll), i, strat);
9153 i--;
9154 }
9155 }
9156#ifdef HAVE_SHIFTBBA
9157 if (rIsLPRing(currRing))
9158 enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9159 else
9160#endif
9161 {
9162 /* generate new pairs with p, probably removing older, now useless pairs */
9163 superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9164 }
9165 /* enter p to S set */
9166 strat->enterS(p, pos, strat, strat->tl);
9167
9168#ifdef HAVE_SHIFTBBA
9169 /* do this after enterS so that the index in R (which is strat->tl) is correct */
9170 if (rIsLPRing(currRing) && !strat->rightGB)
9171 enterTShift(p,strat);
9172#endif
9173}

◆ sba()

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

Definition at line 3001 of file kstd2.cc.

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

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject h,
kStrategy  strat 
)

Definition at line 1700 of file kutil.cc.

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

◆ sbaRing()

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

Definition at line 11142 of file kutil.cc.

11143{
11144 int n = rBlocks(r); // Including trailing zero!
11145 // if sbaOrder == 1 => use (C,monomial order from r)
11146 if (strat->sbaOrder == 1)
11147 {
11148 if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11149 {
11150 return r;
11151 }
11152 ring res = rCopy0(r, TRUE, FALSE);
11153 res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11154 res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11155 res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11156 int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11157 res->wvhdl = wvhdl;
11158 for (int i=1; i<n; i++)
11159 {
11160 res->order[i] = r->order[i-1];
11161 res->block0[i] = r->block0[i-1];
11162 res->block1[i] = r->block1[i-1];
11163 res->wvhdl[i] = r->wvhdl[i-1];
11164 }
11165
11166 // new 1st block
11167 res->order[0] = ringorder_C; // Prefix
11168 // removes useless secondary component order if defined in old ring
11169 for (int i=rBlocks(res); i>0; --i)
11170 {
11171 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11172 {
11173 res->order[i] = (rRingOrder_t)0;
11174 }
11175 }
11176 rComplete(res, 1);
11177#ifdef HAVE_PLURAL
11178 if (rIsPluralRing(r))
11179 {
11180 if ( nc_rComplete(r, res, false) ) // no qideal!
11181 {
11182#ifndef SING_NDEBUG
11183 WarnS("error in nc_rComplete");
11184#endif
11185 // cleanup?
11186
11187 // rDelete(res);
11188 // return r;
11189
11190 // just go on..
11191 }
11192 }
11193#endif
11194 strat->tailRing = res;
11195 return (res);
11196 }
11197 // if sbaOrder == 3 => degree - position - ring order
11198 if (strat->sbaOrder == 3)
11199 {
11200 ring res = rCopy0(r, TRUE, FALSE);
11201 res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11202 res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11203 res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11204 int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11205 res->wvhdl = wvhdl;
11206 for (int i=2; i<n+2; i++)
11207 {
11208 res->order[i] = r->order[i-2];
11209 res->block0[i] = r->block0[i-2];
11210 res->block1[i] = r->block1[i-2];
11211 res->wvhdl[i] = r->wvhdl[i-2];
11212 }
11213
11214 // new 1st block
11215 res->order[0] = ringorder_a; // Prefix
11216 res->block0[0] = 1;
11217 res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11218 for (int i=0; i<res->N; ++i)
11219 res->wvhdl[0][i] = 1;
11220 res->block1[0] = si_min(res->N, rVar(res));
11221 // new 2nd block
11222 res->order[1] = ringorder_C; // Prefix
11223 res->wvhdl[1] = NULL;
11224 // removes useless secondary component order if defined in old ring
11225 for (int i=rBlocks(res); i>1; --i)
11226 {
11227 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11228 {
11229 res->order[i] = (rRingOrder_t)0;
11230 }
11231 }
11232 rComplete(res, 1);
11233#ifdef HAVE_PLURAL
11234 if (rIsPluralRing(r))
11235 {
11236 if ( nc_rComplete(r, res, false) ) // no qideal!
11237 {
11238#ifndef SING_NDEBUG
11239 WarnS("error in nc_rComplete");
11240#endif
11241 // cleanup?
11242
11243 // rDelete(res);
11244 // return r;
11245
11246 // just go on..
11247 }
11248 }
11249#endif
11250 strat->tailRing = res;
11251 return (res);
11252 }
11253
11254 // not sbaOrder == 1 => use Schreyer order
11255 // this is done by a trick when initializing the signatures
11256 // in initSLSba():
11257 // Instead of using the signature 1e_i for F->m[i], we start
11258 // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11259 // Schreyer order w.r.t. the underlying monomial order.
11260 // => we do not need to change the underlying polynomial ring at all!
11261
11262 // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11263
11264 /*
11265 else
11266 {
11267 ring res = rCopy0(r, FALSE, FALSE);
11268 // Create 2 more blocks for prefix/suffix:
11269 res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11270 res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11271 res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11272 int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11273
11274 // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11275 // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11276
11277 // new 1st block
11278 int j = 0;
11279 res->order[j] = ringorder_IS; // Prefix
11280 res->block0[j] = res->block1[j] = 0;
11281 // wvhdl[j] = NULL;
11282 j++;
11283
11284 for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11285 {
11286 res->order [j] = r->order [i];
11287 res->block0[j] = r->block0[i];
11288 res->block1[j] = r->block1[i];
11289
11290 if (r->wvhdl[i] != NULL)
11291 {
11292 wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11293 } // else wvhdl[j] = NULL;
11294 }
11295
11296 // new last block
11297 res->order [j] = ringorder_IS; // Suffix
11298 res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11299 // wvhdl[j] = NULL;
11300 j++;
11301
11302 // res->order [j] = 0; // The End!
11303 res->wvhdl = wvhdl;
11304
11305 // j == the last zero block now!
11306 assume(j == (n+1));
11307 assume(res->order[0]==ringorder_IS);
11308 assume(res->order[j-1]==ringorder_IS);
11309 assume(res->order[j]==0);
11310
11311 if (complete)
11312 {
11313 rComplete(res, 1);
11314
11315#ifdef HAVE_PLURAL
11316 if (rIsPluralRing(r))
11317 {
11318 if ( nc_rComplete(r, res, false) ) // no qideal!
11319 {
11320 }
11321 }
11322 assume(rIsPluralRing(r) == rIsPluralRing(res));
11323#endif
11324
11325
11326#ifdef HAVE_PLURAL
11327 ring old_ring = r;
11328
11329#endif
11330
11331 if (r->qideal!=NULL)
11332 {
11333 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11334
11335 assume(idRankFreeModule(res->qideal, res) == 0);
11336
11337#ifdef HAVE_PLURAL
11338 if( rIsPluralRing(res) )
11339 if( nc_SetupQuotient(res, r, true) )
11340 {
11341 // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11342 }
11343
11344#endif
11345 assume(idRankFreeModule(res->qideal, res) == 0);
11346 }
11347
11348#ifdef HAVE_PLURAL
11349 assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11350 assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11351 assume(rIsSCA(res) == rIsSCA(old_ring));
11352 assume(ncRingType(res) == ncRingType(old_ring));
11353#endif
11354 }
11355 strat->tailRing = res;
11356 return res;
11357 }
11358 */
11359
11360 assume(FALSE);
11361 return(NULL);
11362}
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:5685
static int rBlocks(const ring r)
Definition: ring.h:568
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 4478 of file kutil.cc.

4479{
4481#if HAVE_SHIFTBBA
4482 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4483#endif
4484 // enter also zero divisor * poly, if this is non zero and of smaller degree
4486 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4487 initenterpairs(h, k, ecart, 0, strat, atR);
4488 clearSbatch(h, k, pos, strat);
4489}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4452
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4167
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4249

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

4492{
4494 // enter also zero divisor * poly, if this is non zero and of smaller degree
4495 if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4496 if(strat->sigdrop) return;
4497 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4498 if(strat->sigdrop) return;
4499 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4500 if(strat->sigdrop) return;
4501 clearSbatch(h, k, pos, strat);
4502}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3947
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4222
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4333

◆ syzCriterion()

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

Definition at line 6521 of file kutil.cc.

6522{
6523//#if 1
6524#ifdef DEBUGF5
6525 PrintS("syzygy criterion checks: ");
6526 pWrite(sig);
6527#endif
6528 for (int k=0; k<strat->syzl; k++)
6529 {
6530 //printf("-%d",k);
6531//#if 1
6532#ifdef DEBUGF5
6533 Print("checking with: %d / %d -- \n",k,strat->syzl);
6534 pWrite(pHead(strat->syz[k]));
6535#endif
6536 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6537 && (!rField_is_Ring(currRing) ||
6538 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6539 {
6540//#if 1
6541#ifdef DEBUGF5
6542 PrintS("DELETE!\n");
6543#endif
6544 strat->nrsyzcrit++;
6545 //printf("- T -\n\n");
6546 return TRUE;
6547 }
6548 }
6549 //printf("- F -\n\n");
6550 return FALSE;
6551}

◆ syzCriterionInc()

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

Definition at line 6556 of file kutil.cc.

6557{
6558//#if 1
6559 if(sig == NULL)
6560 return FALSE;
6561#ifdef DEBUGF5
6562 PrintS("--- syzygy criterion checks: ");
6563 pWrite(sig);
6564#endif
6565 int comp = __p_GetComp(sig, currRing);
6566 int min, max;
6567 if (comp<=1)
6568 return FALSE;
6569 else
6570 {
6571 min = strat->syzIdx[comp-2];
6572 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6573 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6574 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6575 if (comp == strat->currIdx)
6576 {
6577 max = strat->syzl;
6578 }
6579 else
6580 {
6581 max = strat->syzIdx[comp-1];
6582 }
6583 for (int k=min; k<max; k++)
6584 {
6585#ifdef F5DEBUG
6586 Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6587 Print("checking with: %d -- ",k);
6588 pWrite(pHead(strat->syz[k]));
6589#endif
6590 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6591 && (!rField_is_Ring(currRing) ||
6592 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6593 {
6594 strat->nrsyzcrit++;
6595 return TRUE;
6596 }
6597 }
6598 return FALSE;
6599 }
6600}
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 10128 of file kutil.cc.

10129{
10130 int l;
10131 if (strat->ak>0)
10132 {
10133 for (l=IDELEMS(r)-1;l>=0;l--)
10134 {
10135 if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10136 {
10137 pDelete(&r->m[l]); // and set it to NULL
10138 }
10139 }
10140 int q;
10141 poly p;
10143 {
10144 for (l=IDELEMS(r)-1;l>=0;l--)
10145 {
10146 if ((r->m[l]!=NULL)
10147 //&& (strat->syzComp>0)
10148 //&& (pGetComp(r->m[l])<=strat->syzComp)
10149 )
10150 {
10151 for(q=IDELEMS(Q)-1; q>=0;q--)
10152 {
10153 if ((Q->m[q]!=NULL)
10154 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10155 {
10156 if (TEST_OPT_REDSB)
10157 {
10158 p=r->m[l];
10159 r->m[l]=kNF(Q,NULL,p);
10160 pDelete(&p);
10161 }
10162 else
10163 {
10164 pDelete(&r->m[l]); // and set it to NULL
10165 }
10166 break;
10167 }
10168 }
10169 }
10170 }
10171 }
10172 #ifdef HAVE_RINGS
10173 else
10174 {
10175 for (l=IDELEMS(r)-1;l>=0;l--)
10176 {
10177 if ((r->m[l]!=NULL)
10178 //&& (strat->syzComp>0)
10179 //&& (pGetComp(r->m[l])<=strat->syzComp)
10180 )
10181 {
10182 for(q=IDELEMS(Q)-1; q>=0;q--)
10183 {
10184 if ((Q->m[q]!=NULL)
10185 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10186 {
10187 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10188 {
10189 if (TEST_OPT_REDSB)
10190 {
10191 p=r->m[l];
10192 r->m[l]=kNF(Q,NULL,p);
10193 pDelete(&p);
10194 }
10195 else
10196 {
10197 pDelete(&r->m[l]); // and set it to NULL
10198 }
10199 break;
10200 }
10201 }
10202 }
10203 }
10204 }
10205 }
10206 #endif
10207 }
10208 else
10209 {
10210 int q;
10211 poly p;
10212 BOOLEAN reduction_found=FALSE;
10214 {
10215 for (l=IDELEMS(r)-1;l>=0;l--)
10216 {
10217 if (r->m[l]!=NULL)
10218 {
10219 for(q=IDELEMS(Q)-1; q>=0;q--)
10220 {
10221 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10222 {
10223 if (TEST_OPT_REDSB)
10224 {
10225 p=r->m[l];
10226 r->m[l]=kNF(Q,NULL,p);
10227 pDelete(&p);
10228 reduction_found=TRUE;
10229 }
10230 else
10231 {
10232 pDelete(&r->m[l]); // and set it to NULL
10233 }
10234 break;
10235 }
10236 }
10237 }
10238 }
10239 }
10240 #ifdef HAVE_RINGS
10241 //Also need divisibility of the leading coefficients
10242 else
10243 {
10244 for (l=IDELEMS(r)-1;l>=0;l--)
10245 {
10246 if (r->m[l]!=NULL)
10247 {
10248 for(q=IDELEMS(Q)-1; q>=0;q--)
10249 {
10250 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10251 {
10252 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10253 {
10254 if (TEST_OPT_REDSB)
10255 {
10256 p=r->m[l];
10257 r->m[l]=kNF(Q,NULL,p);
10258 pDelete(&p);
10259 reduction_found=TRUE;
10260 }
10261 else
10262 {
10263 pDelete(&r->m[l]); // and set it to NULL
10264 }
10265 break;
10266 }
10267 }
10268 }
10269 }
10270 }
10271 }
10272 #endif
10273 if (/*TEST_OPT_REDSB &&*/ reduction_found)
10274 {
10275 #ifdef HAVE_RINGS
10277 {
10278 for (l=IDELEMS(r)-1;l>=0;l--)
10279 {
10280 if (r->m[l]!=NULL)
10281 {
10282 for(q=IDELEMS(r)-1;q>=0;q--)
10283 {
10284 if ((l!=q)
10285 && (r->m[q]!=NULL)
10286 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10287 &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10288 )
10289 {
10290 //If they are equal then take the one with the smallest length
10291 if(pLmDivisibleBy(r->m[q],r->m[l])
10292 && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10293 && (pLength(r->m[q]) < pLength(r->m[l]) ||
10294 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10295 {
10296 pDelete(&r->m[l]);
10297 break;
10298 }
10299 else
10300 pDelete(&r->m[q]);
10301 }
10302 }
10303 }
10304 }
10305 }
10306 else
10307 #endif
10308 {
10309 for (l=IDELEMS(r)-1;l>=0;l--)
10310 {
10311 if (r->m[l]!=NULL)
10312 {
10313 for(q=IDELEMS(r)-1;q>=0;q--)
10314 {
10315 if ((l!=q)
10316 && (r->m[q]!=NULL)
10317 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10318 )
10319 {
10320 //If they are equal then take the one with the smallest length
10321 if(pLmDivisibleBy(r->m[q],r->m[l])
10322 &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10323 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10324 {
10325 pDelete(&r->m[l]);
10326 break;
10327 }
10328 else
10329 pDelete(&r->m[q]);
10330 }
10331 }
10332 }
10333 }
10334 }
10335 }
10336 }
10337 idSkipZeroes(r);
10338}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3182

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8594 of file kutil.cc.

8595{
8596 LObject h;
8597 int i, suc=0;
8598 poly redSi=NULL;
8599 BOOLEAN change,any_change;
8600// Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
8601// for (i=0; i<=(strat->sl); i++)
8602// {
8603// Print("s%d:",i);
8604// if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
8605// pWrite(strat->S[i]);
8606// }
8607// Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
8608 any_change=FALSE;
8610 {
8611 while (suc != -1)
8612 {
8613 i=suc+1;
8614 while (i<=strat->sl)
8615 {
8616 change=FALSE;
8618 any_change = FALSE;
8619 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8620 {
8621 redSi = pHead(strat->S[i]);
8622 strat->S[i] = redBba(strat->S[i],i-1,strat);
8623 //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
8624 // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
8625 if (pCmp(redSi,strat->S[i])!=0)
8626 {
8627 change=TRUE;
8628 any_change=TRUE;
8629 #ifdef KDEBUG
8630 if (TEST_OPT_DEBUG)
8631 {
8632 PrintS("reduce:");
8633 wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
8634 }
8635 #endif
8636 if (TEST_OPT_PROT)
8637 {
8638 if (strat->S[i]==NULL)
8639 PrintS("V");
8640 else
8641 PrintS("v");
8642 mflush();
8643 }
8644 }
8645 pLmDelete(&redSi);
8646 if (strat->S[i]==NULL)
8647 {
8648 deleteInS(i,strat);
8649 i--;
8650 }
8651 else if (change)
8652 {
8654 {
8656 {
8657 number n;
8658 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8659 if (!nIsOne(n))
8660 {
8662 denom->n=nInvers(n);
8663 denom->next=DENOMINATOR_LIST;
8664 DENOMINATOR_LIST=denom;
8665 }
8666 nDelete(&n);
8667 }
8668 else
8669 {
8670 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8671 }
8672 }
8673 else
8674 {
8675 pNorm(strat->S[i]);
8676 }
8677 strat->sevS[i] = pGetShortExpVector(strat->S[i]);
8678 }
8679 }
8680 i++;
8681 }
8682 if (any_change) reorderS(&suc,strat);
8683 else break;
8684 }
8685 if (toT)
8686 {
8687 for (i=0; i<=strat->sl; i++)
8688 {
8689 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8690 {
8691 h.p = redtailBba(strat->S[i],i-1,strat);
8693 {
8694 h.pCleardenom();// also does remove Content
8695 }
8696 }
8697 else
8698 {
8699 h.p = strat->S[i];
8700 }
8701 strat->initEcart(&h);
8702 if (strat->honey)
8703 {
8704 strat->ecartS[i] = h.ecart;
8705 }
8706 if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
8707 else assume(strat->sevS[i] == pGetShortExpVector(h.p));
8708 h.sev = strat->sevS[i];
8709 /*puts the elements of S also to T*/
8710 strat->initEcart(&h);
8711 /*if (toT) - already checked*/ enterT(h,strat);
8712 strat->S_2_R[i] = strat->tl;
8713#ifdef HAVE_SHIFTBBA
8714 if (/*(toT) && */(currRing->isLPring))
8715 enterTShift(h, strat);
8716#endif
8717 }
8718 }
8719 }
8720 else
8721 {
8722 while (suc != -1)
8723 {
8724 i=suc;
8725 while (i<=strat->sl)
8726 {
8727 change=FALSE;
8728 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8729 {
8730 redSi=pHead((strat->S)[i]);
8731 (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
8732 if ((strat->S)[i]==NULL)
8733 {
8734 deleteInS(i,strat);
8735 i--;
8736 }
8737 else if (pCmp((strat->S)[i],redSi)!=0)
8738 {
8739 any_change=TRUE;
8740 h.p = strat->S[i];
8741 strat->initEcart(&h);
8742 strat->ecartS[i] = h.ecart;
8744 {
8746 {
8747 number n;
8748 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8749 if (!nIsOne(n))
8750 {
8752 denom->n=nInvers(n);
8753 denom->next=DENOMINATOR_LIST;
8754 DENOMINATOR_LIST=denom;
8755 }
8756 nDelete(&n);
8757 }
8758 else
8759 {
8760 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8761 }
8762 }
8763 else
8764 {
8765 pNorm(strat->S[i]); // == h.p
8766 }
8767 h.sev = pGetShortExpVector(h.p);
8768 strat->sevS[i] = h.sev;
8769 }
8770 pLmDelete(&redSi);
8771 kTest(strat);
8772 }
8773 i++;
8774 }
8775#ifdef KDEBUG
8776 kTest(strat);
8777#endif
8778 if (any_change) reorderS(&suc,strat);
8779 else { suc=-1; break; }
8780 if (h.p!=NULL)
8781 {
8782 if (!strat->kAllAxis)
8783 {
8784 /*strat->kAllAxis =*/ HEckeTest(h.p,strat);
8785 }
8786 if (strat->kAllAxis)
8787 newHEdge(strat);
8788 }
8789 }
8790 for (i=0; i<=strat->sl; i++)
8791 {
8792 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8793 {
8794 strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
8795 strat->initEcart(&h);
8796 strat->ecartS[i] = h.ecart;
8797 h.sev = pGetShortExpVector(h.p);
8798 strat->sevS[i] = h.sev;
8799 }
8800 else
8801 {
8802 h.p = strat->S[i];
8803 h.ecart=strat->ecartS[i];
8804 h.sev = strat->sevS[i];
8805 h.length = h.pLength = pLength(h.p);
8806 }
8807 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8808 cancelunit1(&h,&suc,strat->sl,strat);
8809 h.SetpFDeg();
8810 /*puts the elements of S also to T*/
8811 enterT(h,strat);
8812 strat->S_2_R[i] = strat->tl;
8813#ifdef HAVE_SHIFTBBA
8814 if (currRing->isLPring)
8815 enterTShift(h, strat);
8816#endif
8817 }
8818 if (suc!= -1) updateS(toT,strat);
8819 }
8820#ifdef KDEBUG
8821 kTest(strat);
8822#endif
8823}
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8549
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8525
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition: kutil.cc:8437
void HEckeTest(poly pp, kStrategy strat)
Definition: kutil.cc:501
void reorderS(int *suc, kStrategy strat)
Definition: kutil.cc:4632
BOOLEAN newHEdge(kStrategy strat)
Definition: kutil.cc:10462

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 877 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 876 of file kutil.h.