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 deleteInSSba (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 posInLRing (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_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 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)
 
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)
 
poly pMove2CurrTail (poly p, kStrategy strat)
 
poly pMoveCurrTail2poly (poly p, kStrategy strat)
 
poly pCopyL2p (LObject h, 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 6913 of file kutil.cc.

6914{
6916 return FALSE;
6917 poly p1 = pOne();
6918 poly p2 = pOne();
6919 for (int ii=strat->sl; ii>start; ii--)
6920 {
6921 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6922 {
6923 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6924 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6925 if (!(pLmCmp(p1,p2) == 1))
6926 {
6927 pDelete(&p1);
6928 pDelete(&p2);
6929 return TRUE;
6930 }
6931 }
6932 }
6933 pDelete(&p1);
6934 pDelete(&p2);
6935 return FALSE;
6936}
#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:1425
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1937
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:486

◆ arriRewCriterionPre()

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

Definition at line 6938 of file kutil.cc.

6939{
6940 //Over Rings, there are still some changes to do: considering coeffs
6942 return FALSE;
6943 int found = -1;
6944 for (int i=strat->Bl; i>-1; i--)
6945 {
6946 if (pLmEqual(strat->B[i].sig,sig))
6947 {
6948 found = i;
6949 break;
6950 }
6951 }
6952 if (found != -1)
6953 {
6954 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6955 {
6956 deleteInL(strat->B,&strat->Bl,found,strat);
6957 }
6958 else
6959 {
6960 return TRUE;
6961 }
6962 }
6963 poly p1 = pOne();
6964 poly p2 = pOne();
6965 for (int ii=strat->sl; ii>-1; ii--)
6966 {
6967 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6968 {
6969 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6970 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6971 if (!(pLmCmp(p1,p2) == 1))
6972 {
6973 pDelete(&p1);
6974 pDelete(&p2);
6975 return TRUE;
6976 }
6977 }
6978 }
6979 pDelete(&p1);
6980 pDelete(&p2);
6981 return FALSE;
6982}
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:1295
#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 1273 of file kInline.h.

1274{
1275 return FALSE;
1276}

◆ bba()

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

Definition at line 2383 of file kstd2.cc.

2384{
2385 int red_result = 1;
2386 int olddeg,reduc;
2387 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2388 BOOLEAN withT = FALSE;
2389 BITSET save;
2390 SI_SAVE_OPT1(save);
2391
2392 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2394 initBuchMoraPosRing(strat);
2395 else
2396 initBuchMoraPos(strat);
2397 initHilbCrit(F,Q,&hilb,strat);
2398 initBba(strat);
2399 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2400 /*Shdl=*/initBuchMora(F, Q,strat);
2401 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2402 reduc = olddeg = 0;
2403
2404#ifndef NO_BUCKETS
2406 strat->use_buckets = 1;
2407#endif
2408 // redtailBBa against T for inhomogenous input
2409 if (!TEST_OPT_OLDSTD)
2410 withT = ! strat->homog;
2411
2412 // strat->posInT = posInT_pLength;
2413 kTest_TS(strat);
2414
2415#ifdef HAVE_TAIL_RING
2416 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2418#endif
2419 if (BVERBOSE(23))
2420 {
2421 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2422 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2423 kDebugPrint(strat);
2424 }
2425
2426
2427#ifdef KDEBUG
2428 //kDebugPrint(strat);
2429#endif
2430 /* compute------------------------------------------------------- */
2431 while (strat->Ll >= 0)
2432 {
2433 #ifdef KDEBUG
2434 if (TEST_OPT_DEBUG) messageSets(strat);
2435 #endif
2436 if (siCntrlc)
2437 {
2438 while (strat->Ll >= 0)
2439 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2440 strat->noClearS=TRUE;
2441 }
2443 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2444 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2445 {
2446 /*
2447 *stops computation if
2448 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2449 *a predefined number Kstd1_deg
2450 */
2451 while ((strat->Ll >= 0)
2452 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2453 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2454 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2455 )
2456 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2457 if (strat->Ll<0) break;
2458 else strat->noClearS=TRUE;
2459 }
2460 if (strat->Ll== 0) strat->interpt=TRUE;
2461 /* picks the last element from the lazyset L */
2462 strat->P = strat->L[strat->Ll];
2463 strat->Ll--;
2464
2465 if (pNext(strat->P.p) == strat->tail)
2466 {
2467 // deletes the short spoly
2469 pLmDelete(strat->P.p);
2470 else
2471 pLmFree(strat->P.p);
2472 strat->P.p = NULL;
2473 poly m1 = NULL, m2 = NULL;
2474
2475 // check that spoly creation is ok
2476 while (strat->tailRing != currRing &&
2477 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2478 {
2479 assume(m1 == NULL && m2 == NULL);
2480 // if not, change to a ring where exponents are at least
2481 // large enough
2482 if (!kStratChangeTailRing(strat))
2483 {
2484 WerrorS("OVERFLOW...");
2485 break;
2486 }
2487 }
2488 // create the real one
2489 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2490 strat->tailRing, m1, m2, strat->R);
2491 }
2492 else if (strat->P.p1 == NULL)
2493 {
2494 if (strat->minim > 0)
2495 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2496 // for input polys, prepare reduction
2497 strat->P.PrepareRed(strat->use_buckets);
2498 }
2499
2500 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2501 {
2502 red_result = 0;
2503 }
2504 else
2505 {
2506 if (TEST_OPT_PROT)
2507 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2508 &olddeg,&reduc,strat, red_result);
2509
2510 /* reduction of the element chosen from L */
2511 red_result = strat->red(&strat->P,strat);
2512 if (errorreported) break;
2513 }
2514
2515 if (strat->overflow)
2516 {
2517 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2518 }
2519
2520 // reduction to non-zero new poly
2521 if (red_result == 1)
2522 {
2523 // get the polynomial (canonicalize bucket, make sure P.p is set)
2524 strat->P.GetP(strat->lmBin);
2525 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2526 // but now, for entering S, T, we reset it
2527 // in the inhomogeneous case: FDeg == pFDeg
2528 if (strat->homog) strat->initEcart(&(strat->P));
2529
2530 /* statistic */
2531 if (TEST_OPT_PROT) PrintS("s");
2532
2533 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2534
2535 // reduce the tail and normalize poly
2536 // in the ring case we cannot expect LC(f) = 1,
2537 strat->redTailChange=FALSE;
2538
2539 /* if we are computing over Z we always want to try and cut down
2540 * the coefficients in the tail terms */
2542 {
2543 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2544 }
2545
2547 {
2548 strat->P.pCleardenom();
2550 {
2551 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2552 strat->P.pCleardenom();
2553 if (strat->redTailChange) { strat->P.t_p=NULL; }
2554 }
2555 }
2556 else
2557 {
2558 strat->P.pNorm();
2560 {
2561 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2562 if (strat->redTailChange) { strat->P.t_p=NULL; }
2563 }
2564 }
2565
2566#ifdef KDEBUG
2567 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2568#endif /* KDEBUG */
2569
2570 // min_std stuff
2571 if ((strat->P.p1==NULL) && (strat->minim>0))
2572 {
2573 if (strat->minim==1)
2574 {
2575 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2576 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2577 }
2578 else
2579 {
2580 strat->M->m[minimcnt]=strat->P.p2;
2581 strat->P.p2=NULL;
2582 }
2583 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2584 pNext(strat->M->m[minimcnt])
2585 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2586 strat->tailRing, currRing,
2587 currRing->PolyBin);
2588 minimcnt++;
2589 }
2590
2591 // enter into S, L, and T
2592 if (((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2593 && ((!TEST_OPT_IDELIM) || (p_Deg(strat->P.p,currRing) > 0)))
2594 {
2595 strat->P.SetShortExpVector();
2596 enterT(strat->P, strat);
2598 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2599 else
2600 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2601 // posInS only depends on the leading term
2602 strat->enterS(strat->P, pos, strat, strat->tl);
2603#if 0
2604 int pl=pLength(strat->P.p);
2605 if (pl==1)
2606 {
2607 //if (TEST_OPT_PROT)
2608 //PrintS("<1>");
2609 }
2610 else if (pl==2)
2611 {
2612 //if (TEST_OPT_PROT)
2613 //PrintS("<2>");
2614 }
2615#endif
2616 }
2617 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2618// Print("[%d]",hilbeledeg);
2619 kDeleteLcm(&strat->P);
2620 if (strat->s_poly!=NULL)
2621 {
2622 // the only valid entries are: strat->P.p,
2623 // strat->tailRing (read-only, keep it)
2624 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2625 if (strat->s_poly(strat))
2626 {
2627 // we are called AFTER enterS, i.e. if we change P
2628 // we have to add it also to S/T
2629 // and add pairs
2630 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2631 enterT(strat->P, strat);
2633 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2634 else
2635 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2636 strat->enterS(strat->P, pos, strat, strat->tl);
2637 }
2638 }
2639 }
2640 else if (strat->P.p1 == NULL && strat->minim > 0)
2641 {
2642 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2643 }
2644
2645#ifdef KDEBUG
2646 memset(&(strat->P), 0, sizeof(strat->P));
2647#endif /* KDEBUG */
2648 kTest_TS(strat);
2649 }
2650#ifdef KDEBUG
2651 if (TEST_OPT_DEBUG) messageSets(strat);
2652#endif /* KDEBUG */
2653
2654 if (TEST_OPT_SB_1)
2655 {
2657 {
2658 int k=1;
2659 int j;
2660 while(k<=strat->sl)
2661 {
2662 j=0;
2663 loop
2664 {
2665 if (j>=k) break;
2666 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2667 j++;
2668 }
2669 k++;
2670 }
2671 }
2672 }
2673 /* complete reduction of the standard basis--------- */
2674 if (TEST_OPT_REDSB)
2675 {
2676 completeReduce(strat);
2677 if (strat->completeReduce_retry)
2678 {
2679 // completeReduce needed larger exponents, retry
2680 // to reduce with S (instead of T)
2681 // and in currRing (instead of strat->tailRing)
2682#ifdef HAVE_TAIL_RING
2683 if(currRing->bitmask>strat->tailRing->bitmask)
2684 {
2686 cleanT(strat);strat->tailRing=currRing;
2687 int i;
2688 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2689 completeReduce(strat);
2690 }
2691 if (strat->completeReduce_retry)
2692#endif
2693 Werror("exponent bound is %ld",currRing->bitmask);
2694 }
2695 }
2696 else if (TEST_OPT_PROT) PrintLn();
2697 /* release temp data-------------------------------- */
2698 exitBuchMora(strat);
2699 /* postprocessing for GB over ZZ --------------------*/
2700 if (!errorreported)
2701 {
2703 {
2704 for(int i = 0;i<=strat->sl;i++)
2705 {
2706 if(!nGreaterZero(pGetCoeff(strat->S[i])))
2707 {
2708 strat->S[i] = pNeg(strat->S[i]);
2709 }
2710 }
2711 finalReduceByMon(strat);
2712 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2713 {
2714 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2715 {
2716 strat->S[i] = pNeg(strat->Shdl->m[i]);
2717 }
2718 }
2719 }
2720 //else if (rField_is_Ring(currRing))
2721 // finalReduceByMon(strat);
2722 }
2723// if (TEST_OPT_WEIGHTM)
2724// {
2725// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2726// if (ecartWeights)
2727// {
2728// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2729// ecartWeights=NULL;
2730// }
2731// }
2732 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
2733 SI_RESTORE_OPT1(save);
2734 /* postprocessing for GB over Q-rings ------------------*/
2735 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2736
2737 idTest(strat->Shdl);
2738
2739 return (strat->Shdl);
2740}
int BOOLEAN
Definition: auxiliary.h:87
int k
Definition: cfEzgcd.cc:99
int syzComp
Definition: kutil.h:354
int * S_2_R
Definition: kutil.h:342
ring tailRing
Definition: kutil.h:343
int Ll
Definition: kutil.h:351
omBin lmBin
Definition: kutil.h:344
char honey
Definition: kutil.h:377
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:1223
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1248
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:1185
void initBba(kStrategy strat)
Definition: kstd1.cc:1676
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:11817
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:7768
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:10057
void enterT(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9434
BOOLEAN kTest_TS(kStrategy strat)
Definition: kutil.cc:1097
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4587
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition: kutil.cc:7436
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
Definition: kutil.cc:9714
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:9884
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition: kutil.cc:11278
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:10142
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:4763
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition: kutil.cc:10791
void cleanT(kStrategy strat)
Definition: kutil.cc:569
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10385
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4556
void kStratInitChangeTailRing(kStrategy strat)
Definition: kutil.cc:11371
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9732
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition: kutil.cc:10597
void initBuchMoraPosRing(kStrategy strat)
Definition: kutil.cc:9970
void messageSets(kStrategy strat)
Definition: kutil.cc:7841
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7809
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition: kutil.cc:11185
static void kDeleteLcm(LObject *P)
Definition: kutil.h:885
#define assume(x)
Definition: mod2.h:387
#define pNext(p)
Definition: monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
#define nGreaterZero(n)
Definition: numbers.h:27
#define NULL
Definition: omList.c:12
VAR BOOLEAN siCntrlc
Definition: options.c:14
#define TEST_OPT_IDLIFT
Definition: options.h:129
#define TEST_OPT_INTSTRATEGY
Definition: options.h:110
#define BVERBOSE(a)
Definition: options.h:34
#define TEST_OPT_REDTAIL
Definition: options.h:116
#define SI_SAVE_OPT1(A)
Definition: options.h:21
#define SI_RESTORE_OPT1(A)
Definition: options.h:24
#define TEST_OPT_OLDSTD
Definition: options.h:123
#define TEST_OPT_REDSB
Definition: options.h:104
#define TEST_OPT_DEGBOUND
Definition: options.h:113
#define TEST_OPT_SB_1
Definition: options.h:119
#define TEST_OPT_PROT
Definition: options.h:103
#define TEST_OPT_IDELIM
Definition: options.h:130
#define TEST_OPT_DEBUG
Definition: options.h:108
#define TEST_OPT_CONTENTSB
Definition: options.h:127
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:105
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
static unsigned pLength(poly a)
Definition: p_polys.h:191
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:846
#define pNeg(p)
Definition: polys.h:198
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition: polys.h:70
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
void Werror(const char *fmt,...)
Definition: reporter.cc:189
static BOOLEAN rField_is_Z(const ring r)
Definition: ring.h:510
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:761
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 4351 of file kstd2.cc.

4352{
4353 int red_result = 1;
4354 int olddeg,reduc;
4355 int hilbeledeg=1,hilbcount=0,minimcnt=0;
4356 BOOLEAN withT = TRUE; // currently only T contains the shifts
4357 BITSET save;
4358 SI_SAVE_OPT1(save);
4359
4360 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
4362 initBuchMoraPosRing(strat);
4363 else
4364 initBuchMoraPos(strat);
4365 initHilbCrit(F,Q,&hilb,strat);
4366 initBba(strat);
4367 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
4368 /*Shdl=*/initBuchMora(F, Q,strat);
4369 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
4370 reduc = olddeg = 0;
4371
4372#ifndef NO_BUCKETS
4374 strat->use_buckets = 1;
4375#endif
4376 // redtailBBa against T for inhomogenous input
4377 // if (!TEST_OPT_OLDSTD)
4378 // withT = ! strat->homog;
4379
4380 // strat->posInT = posInT_pLength;
4381 kTest_TS(strat);
4382
4383#ifdef HAVE_TAIL_RING
4384 // if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4385 // kStratInitChangeTailRing(strat);
4386 strat->tailRing=currRing;
4387#endif
4388 if (BVERBOSE(23))
4389 {
4390 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
4391 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
4392 kDebugPrint(strat);
4393 }
4394
4395#ifdef KDEBUG
4396 //kDebugPrint(strat);
4397#endif
4398 /* compute------------------------------------------------------- */
4399 while (strat->Ll >= 0)
4400 {
4401 #ifdef KDEBUG
4402 if (TEST_OPT_DEBUG) messageSets(strat);
4403 #endif
4404 if (siCntrlc)
4405 {
4406 while (strat->Ll >= 0)
4407 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4408 strat->noClearS=TRUE;
4409 }
4411 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4412 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
4413 {
4414 /*
4415 *stops computation if
4416 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
4417 *a predefined number Kstd1_deg
4418 */
4419 while ((strat->Ll >= 0)
4420 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
4421 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4422 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
4423 )
4424 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4425 if (strat->Ll<0) break;
4426 else strat->noClearS=TRUE;
4427 }
4428 if (strat->Ll== 0) strat->interpt=TRUE;
4429 /* picks the last element from the lazyset L */
4430 strat->P = strat->L[strat->Ll];
4431 strat->Ll--;
4432
4433 if (pNext(strat->P.p) == strat->tail)
4434 {
4435 // deletes the short spoly
4437 pLmDelete(strat->P.p);
4438 else
4439 pLmFree(strat->P.p);
4440 strat->P.p = NULL;
4441 poly m1 = NULL, m2 = NULL;
4442
4443 // check that spoly creation is ok
4444 while (strat->tailRing != currRing &&
4445 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4446 {
4447 assume(m1 == NULL && m2 == NULL);
4448 // if not, change to a ring where exponents are at least
4449 // large enough
4450 if (!kStratChangeTailRing(strat))
4451 {
4452 WerrorS("OVERFLOW...");
4453 break;
4454 }
4455 }
4456 // create the real one
4457 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4458 strat->tailRing, m1, m2, strat->R);
4459 }
4460 else if (strat->P.p1 == NULL)
4461 {
4462 if (strat->minim > 0)
4463 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4464 // for input polys, prepare reduction
4465 strat->P.PrepareRed(strat->use_buckets);
4466 }
4467
4468 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
4469 {
4470 red_result = 0;
4471 }
4472 else
4473 {
4474 if (TEST_OPT_PROT)
4475 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4476 &olddeg,&reduc,strat, red_result);
4477
4478 /* reduction of the element chosen from L */
4479 red_result = strat->red(&strat->P,strat);
4480 if (errorreported) break;
4481 }
4482
4483 if (strat->overflow)
4484 {
4485 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4486 }
4487
4488 // reduction to non-zero new poly
4489 if (red_result == 1)
4490 {
4491 // get the polynomial (canonicalize bucket, make sure P.p is set)
4492 strat->P.GetP(strat->lmBin);
4493 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4494 // but now, for entering S, T, we reset it
4495 // in the inhomogeneous case: FDeg == pFDeg
4496 if (strat->homog) strat->initEcart(&(strat->P));
4497
4498 /* statistic */
4499 if (TEST_OPT_PROT) PrintS("s");
4500
4501 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4502
4503 // reduce the tail and normalize poly
4504 // in the ring case we cannot expect LC(f) = 1,
4505 strat->redTailChange=FALSE;
4506
4507 /* if we are computing over Z we always want to try and cut down
4508 * the coefficients in the tail terms */
4510 {
4511 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
4512 }
4513
4515 {
4516 strat->P.pCleardenom();
4518 {
4519 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
4520 strat->P.pCleardenom();
4521 if (strat->redTailChange)
4522 {
4523 strat->P.t_p=NULL;
4524 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4525 }
4526 }
4527 }
4528 else
4529 {
4530 strat->P.pNorm();
4532 {
4533 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4534 if (strat->redTailChange)
4535 {
4536 strat->P.t_p=NULL;
4537 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4538 }
4539 }
4540 }
4541
4542#ifdef KDEBUG
4543 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4544#endif /* KDEBUG */
4545
4546 // min_std stuff
4547 if ((strat->P.p1==NULL) && (strat->minim>0))
4548 {
4549 if (strat->minim==1)
4550 {
4551 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4552 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4553 }
4554 else
4555 {
4556 strat->M->m[minimcnt]=strat->P.p2;
4557 strat->P.p2=NULL;
4558 }
4559 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4560 pNext(strat->M->m[minimcnt])
4561 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4562 strat->tailRing, currRing,
4563 currRing->PolyBin);
4564 minimcnt++;
4565 }
4566
4567
4568 // enter into S, L, and T
4569 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4570 {
4571 enterT(strat->P, strat);
4572 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4573 // posInS only depends on the leading term
4574 strat->enterS(strat->P, pos, strat, strat->tl);
4575 if (!strat->rightGB)
4576 enterTShift(strat->P, strat);
4577 }
4578
4579 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4580// Print("[%d]",hilbeledeg);
4581 kDeleteLcm(&strat->P);
4582 if (strat->s_poly!=NULL)
4583 {
4584 // the only valid entries are: strat->P.p,
4585 // strat->tailRing (read-only, keep it)
4586 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
4587 if (strat->s_poly(strat))
4588 {
4589 // we are called AFTER enterS, i.e. if we change P
4590 // we have to add it also to S/T
4591 // and add pairs
4592 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4593 enterT(strat->P, strat);
4594 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4595 strat->enterS(strat->P, pos, strat, strat->tl);
4596 if (!strat->rightGB)
4597 enterTShift(strat->P,strat);
4598 }
4599 }
4600 }
4601 else if (strat->P.p1 == NULL && strat->minim > 0)
4602 {
4603 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4604 }
4605#ifdef KDEBUG
4606 memset(&(strat->P), 0, sizeof(strat->P));
4607#endif /* KDEBUG */
4608 kTest_TS(strat);
4609 }
4610#ifdef KDEBUG
4611 if (TEST_OPT_DEBUG) messageSets(strat);
4612#endif /* KDEBUG */
4613 /* shift case: look for elt's in S such that they are divisible by elt in T */
4614 if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
4615 {
4617 {
4618 for (int k = 0; k <= strat->sl; ++k)
4619 {
4620 if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
4621 for (int j = 0; j<=strat->tl; ++j)
4622 {
4623 if (strat->T[j].p!=NULL)
4624 {
4625 // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
4626 assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
4627 assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
4628 if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
4629 {
4630 if (pLmCmp(strat->T[j].p, strat->S[k]) != 0)
4631 { // check whether LM is different
4632 deleteInS(k, strat);
4633 --k;
4634 break;
4635 }
4636 }
4637 }
4638 }
4639 }
4640 }
4641 }
4642 /* complete reduction of the standard basis--------- */
4643 if (TEST_OPT_REDSB)
4644 {
4645 completeReduce(strat, TRUE); //shift: withT = TRUE
4646 if (strat->completeReduce_retry)
4647 {
4648 // completeReduce needed larger exponents, retry
4649 // to reduce with S (instead of T)
4650 // and in currRing (instead of strat->tailRing)
4651#ifdef HAVE_TAIL_RING
4652 if(currRing->bitmask>strat->tailRing->bitmask)
4653 {
4655 cleanT(strat);strat->tailRing=currRing;
4656 int i;
4657 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
4658 WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know
4659 completeReduce(strat);
4660 }
4661 if (strat->completeReduce_retry)
4662#endif
4663 Werror("exponent bound is %ld",currRing->bitmask);
4664 }
4665 }
4666 else if (TEST_OPT_PROT) PrintLn();
4667
4668 /* release temp data-------------------------------- */
4669 exitBuchMora(strat);
4670 /* postprocessing for GB over ZZ --------------------*/
4671 if (!errorreported)
4672 {
4674 {
4675 for(int i = 0;i<=strat->sl;i++)
4676 {
4677 if(!nGreaterZero(pGetCoeff(strat->S[i])))
4678 {
4679 strat->S[i] = pNeg(strat->S[i]);
4680 }
4681 }
4682 finalReduceByMon(strat);
4683 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
4684 {
4685 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
4686 {
4687 strat->S[i] = pNeg(strat->Shdl->m[i]);
4688 }
4689 }
4690 }
4691 //else if (rField_is_Ring(currRing))
4692 // finalReduceByMon(strat);
4693 }
4694// if (TEST_OPT_WEIGHTM)
4695// {
4696// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
4697// if (ecartWeights)
4698// {
4699// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
4700// ecartWeights=NULL;
4701// }
4702// }
4703 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
4704 SI_RESTORE_OPT1(save);
4705 /* postprocessing for GB over Q-rings ------------------*/
4706 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
4707
4708 idTest(strat->Shdl);
4709
4710 return (strat->Shdl);
4711}
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:13434
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:13404
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:1163
#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// for(i=r->N;i>0;i--)
392// {
393// if ((p_GetExp(p,i,r)>0) && (rIsPolyVar(i, r)==TRUE)) return;
394// }
395 poly h = pNext(p);
396 int i;
397
399 {
400 loop
401 {
402 if (h==NULL)
403 {
404 p_Delete(&pNext(p), r);
405 if (!inNF)
406 {
407 number eins= nCopy(lc);
408 if (L->p != NULL)
409 {
410 pSetCoeff(L->p,eins);
411 if (L->t_p != NULL)
412 pSetCoeff0(L->t_p,eins);
413 }
414 else
415 pSetCoeff(L->t_p,eins);
416 /* p and t_p share the same coeff, if both are !=NULL */
417 /* p==NULL==t_p cannot happen here */
418 }
419 L->ecart = 0;
420 L->length = 1;
421 //if (L->pLength > 0)
422 L->pLength = 1;
423 L->max_exp = NULL;
424
425 if (L->t_p != NULL && pNext(L->t_p) != NULL)
426 p_Delete(&pNext(L->t_p),r);
427 if (L->p != NULL && pNext(L->p) != NULL)
428 pNext(L->p) = NULL;
429 return;
430 }
431 i = rVar(r);
432 loop
433 {
434 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
435 i--;
436 if (i == 0) break; // does divide, try next monom
437 }
438 //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
439 // Note: As long as qring j forbidden if j contains integer (i.e. ground rings are
440 // domains), no zerodivisor test needed CAUTION
441 if (!n_DivBy(pGetCoeff(h),lc,r->cf))
442 {
443 return;
444 }
445 pIter(h);
446 }
447 }
448 else
449 {
450 loop
451 {
452 if (h==NULL)
453 {
454 p_Delete(&pNext(p), r);
455 if (!inNF)
456 {
457 number eins=nInit(1);
458 if (L->p != NULL)
459 {
460 pSetCoeff(L->p,eins);
461 if (L->t_p != NULL)
462 pSetCoeff0(L->t_p,eins);
463 }
464 else
465 pSetCoeff(L->t_p,eins);
466 /* p and t_p share the same coeff, if both are !=NULL */
467 /* p==NULL==t_p cannot happen here */
468 }
469 L->ecart = 0;
470 L->length = 1;
471 //if (L->pLength > 0)
472 L->pLength = 1;
473 L->max_exp = NULL;
474
475 if (L->t_p != NULL && pNext(L->t_p) != NULL)
476 p_Delete(&pNext(L->t_p),r);
477 if (L->p != NULL && pNext(L->p) != NULL)
478 pNext(L->p) = NULL;
479
480 return;
481 }
482 i = rVar(r);
483 loop
484 {
485 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
486 i--;
487 if (i == 0) break; // does divide, try next monom
488 }
489 //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
490 pIter(h);
491 }
492 }
493}
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:753
STATIC_VAR Poly * h
Definition: janet.cc:971
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define nCopy(n)
Definition: numbers.h:15
#define nInit(i)
Definition: numbers.h:24
#define TEST_OPT_CANCELUNIT
Definition: options.h:128
BOOLEAN p_OneComp(poly p, const ring r)
return TRUE if all monoms have the same component
Definition: p_polys.cc: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:469
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:760

◆ chainCritNormal()

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

Definition at line 3297 of file kutil.cc.

3298{
3299 int i,j,l;
3300
3301 /*
3302 *pairtest[i] is TRUE if spoly(S[i],p) == 0.
3303 *In this case all elements in B such
3304 *that their lcm is divisible by the leading term of S[i] can be canceled
3305 */
3306 if (strat->pairtest!=NULL)
3307 {
3308#ifdef HAVE_SHIFTBBA
3309 // only difference is pLPDivisibleBy instead of pDivisibleBy
3310 if (rIsLPRing(currRing))
3311 {
3312 for (j=0; j<=strat->sl; j++)
3313 {
3314 if (strat->pairtest[j])
3315 {
3316 for (i=strat->Bl; i>=0; i--)
3317 {
3318 if (pLPDivisibleBy(strat->S[j],strat->B[i].lcm))
3319 {
3320 deleteInL(strat->B,&strat->Bl,i,strat);
3321 strat->c3++;
3322 }
3323 }
3324 }
3325 }
3326 }
3327 else
3328#endif
3329 {
3330 /*- i.e. there is an i with pairtest[i]==TRUE -*/
3331 for (j=0; j<=strat->sl; j++)
3332 {
3333 if (strat->pairtest[j])
3334 {
3335 for (i=strat->Bl; i>=0; i--)
3336 {
3337 if (pDivisibleBy(strat->S[j],strat->B[i].lcm))
3338 {
3339 deleteInL(strat->B,&strat->Bl,i,strat);
3340 strat->c3++;
3341 }
3342 }
3343 }
3344 }
3345 }
3346 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3347 strat->pairtest=NULL;
3348 }
3349 if (strat->Gebauer || strat->fromT)
3350 {
3351 if (strat->sugarCrit)
3352 {
3353 /*
3354 *suppose L[j] == (s,r) and p/lcm(s,r)
3355 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3356 *and in case the sugar is o.k. then L[j] can be canceled
3357 */
3358 for (j=strat->Ll; j>=0; j--)
3359 {
3360 if (sugarDivisibleBy(ecart,strat->L[j].ecart)
3361 && ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
3362 && pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3363 {
3364 if (strat->L[j].p == strat->tail)
3365 {
3366 deleteInL(strat->L,&strat->Ll,j,strat);
3367 strat->c3++;
3368 }
3369 }
3370 }
3371 /*
3372 *this is GEBAUER-MOELLER:
3373 *in B all elements with the same lcm except the "best"
3374 *(i.e. the last one in B with this property) will be canceled
3375 */
3376 j = strat->Bl;
3377 loop /*cannot be changed into a for !!! */
3378 {
3379 if (j <= 0) break;
3380 i = j-1;
3381 loop
3382 {
3383 if (i < 0) break;
3384 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3385 {
3386 strat->c3++;
3387 if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart))
3388 {
3389 deleteInL(strat->B,&strat->Bl,i,strat);
3390 j--;
3391 }
3392 else
3393 {
3394 deleteInL(strat->B,&strat->Bl,j,strat);
3395 break;
3396 }
3397 }
3398 i--;
3399 }
3400 j--;
3401 }
3402 }
3403 else /*sugarCrit*/
3404 {
3405 /*
3406 *suppose L[j] == (s,r) and p/lcm(s,r)
3407 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3408 *and in case the sugar is o.k. then L[j] can be canceled
3409 */
3410 for (j=strat->Ll; j>=0; j--)
3411 {
3412 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3413 {
3414 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3415 {
3416 deleteInL(strat->L,&strat->Ll,j,strat);
3417 strat->c3++;
3418 }
3419 }
3420 }
3421 /*
3422 *this is GEBAUER-MOELLER:
3423 *in B all elements with the same lcm except the "best"
3424 *(i.e. the last one in B with this property) will be canceled
3425 */
3426 j = strat->Bl;
3427 loop /*cannot be changed into a for !!! */
3428 {
3429 if (j <= 0) break;
3430 for(i=j-1; i>=0; i--)
3431 {
3432 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3433 {
3434 strat->c3++;
3435 deleteInL(strat->B,&strat->Bl,i,strat);
3436 j--;
3437 }
3438 }
3439 j--;
3440 }
3441 }
3442 /*
3443 *the elements of B enter L
3444 */
3445 kMergeBintoL(strat);
3446 }
3447 else
3448 {
3449 for (j=strat->Ll; j>=0; j--)
3450 {
3451 #ifdef HAVE_SHIFTBBA
3452 if ((strat->L[j].p1!=NULL) &&
3453 pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3454 #else
3455 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3456 #endif
3457 {
3458 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3459 {
3460 deleteInL(strat->L,&strat->Ll,j,strat);
3461 strat->c3++;
3462 }
3463 }
3464 }
3465 /*
3466 *this is our MODIFICATION of GEBAUER-MOELLER:
3467 *First the elements of B enter L,
3468 *then we fix a lcm and the "best" element in L
3469 *(i.e the last in L with this lcm and of type (s,p))
3470 *and cancel all the other elements of type (r,p) with this lcm
3471 *except the case the element (s,r) has also the same lcm
3472 *and is on the worst position with respect to (s,p) and (r,p)
3473 */
3474 /*
3475 *B enters to L/their order with respect to B is permutated for elements
3476 *B[i].p with the same leading term
3477 */
3478 kMergeBintoL(strat);
3479 j = strat->Ll;
3480 loop /*cannot be changed into a for !!! */
3481 {
3482 if (j <= 0)
3483 {
3484 /*now L[0] cannot be canceled any more and the tail can be removed*/
3485 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3486 break;
3487 }
3488 if (strat->L[j].p2 == p)
3489 {
3490 i = j-1;
3491 loop
3492 {
3493 if (i < 0) break;
3494 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3495 {
3496 /*L[i] could be canceled but we search for a better one to cancel*/
3497 strat->c3++;
3498 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3499 && (pNext(strat->L[l].p) == strat->tail)
3500 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3501 && pDivisibleBy(p,strat->L[l].lcm))
3502 {
3503 /*
3504 *"NOT equal(...)" because in case of "equal" the element L[l]
3505 *is "older" and has to be from theoretical point of view behind
3506 *L[i], but we do not want to reorder L
3507 */
3508 strat->L[i].p2 = strat->tail;
3509 /*
3510 *L[l] will be canceled, we cannot cancel L[i] later on,
3511 *so we mark it with "tail"
3512 */
3513 deleteInL(strat->L,&strat->Ll,l,strat);
3514 i--;
3515 }
3516 else
3517 {
3518 deleteInL(strat->L,&strat->Ll,i,strat);
3519 }
3520 j--;
3521 }
3522 i--;
3523 }
3524 }
3525 else if (strat->L[j].p2 == strat->tail)
3526 {
3527 /*now L[j] cannot be canceled any more and the tail can be removed*/
3528 strat->L[j].p2 = p;
3529 }
3530 j--;
3531 }
3532 }
3533}
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:3254
static BOOLEAN sugarDivisibleBy(int ecart1, int ecart2)
Definition: kutil.cc:1417
BOOLEAN isInPairsetL(int length, poly p1, poly p2, int *k, kStrategy strat)
Definition: kutil.cc:706
#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 3538 of file kutil.cc.

3539{
3540 if (strat->pairtest!=NULL)
3541 {
3542 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3543 strat->pairtest=NULL;
3544 }
3545 /*
3546 *the elements of B enter L
3547 */
3548 kMergeBintoL(strat);
3549}

◆ chainCritSig()

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

Definition at line 3554 of file kutil.cc.

3555{
3556 int i,j,l;
3557 kMergeBintoLSba(strat);
3558 j = strat->Ll;
3559 loop /*cannot be changed into a for !!! */
3560 {
3561 if (j <= 0)
3562 {
3563 /*now L[0] cannot be canceled any more and the tail can be removed*/
3564 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3565 break;
3566 }
3567 if (strat->L[j].p2 == p)
3568 {
3569 i = j-1;
3570 loop
3571 {
3572 if (i < 0) break;
3573 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3574 {
3575 /*L[i] could be canceled but we search for a better one to cancel*/
3576 strat->c3++;
3577 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3578 && (pNext(strat->L[l].p) == strat->tail)
3579 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3580 && pDivisibleBy(p,strat->L[l].lcm))
3581 {
3582 /*
3583 *"NOT equal(...)" because in case of "equal" the element L[l]
3584 *is "older" and has to be from theoretical point of view behind
3585 *L[i], but we do not want to reorder L
3586 */
3587 strat->L[i].p2 = strat->tail;
3588 /*
3589 *L[l] will be canceled, we cannot cancel L[i] later on,
3590 *so we mark it with "tail"
3591 */
3592 deleteInL(strat->L,&strat->Ll,l,strat);
3593 i--;
3594 }
3595 else
3596 {
3597 deleteInL(strat->L,&strat->Ll,i,strat);
3598 }
3599 j--;
3600 }
3601 i--;
3602 }
3603 }
3604 else if (strat->L[j].p2 == strat->tail)
3605 {
3606 /*now L[j] cannot be canceled any more and the tail can be removed*/
3607 strat->L[j].p2 = p;
3608 }
3609 j--;
3610 }
3611}
void kMergeBintoLSba(kStrategy strat)
Definition: kutil.cc:3275

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 569 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1248 of file kInline.h.

1250{
1251 assume(p_sev == pGetShortExpVector(p));
1252 if (strat->noClearS) return;
1253 #ifdef HAVE_RINGS
1255 {
1256 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1257 return;
1258 if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1259 return;
1260 }
1261 else
1262 #endif
1263 {
1264 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1265 }
1266 deleteInS((*at),strat);
1267 (*at)--;
1268 (*k)--;
1269}

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10597 of file kutil.cc.

10598{
10599 int i;
10600 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10601 LObject L;
10602
10603#ifdef KDEBUG
10604 // need to set this: during tailreductions of T[i], T[i].max is out of
10605 // sync
10606 sloppy_max = TRUE;
10607#endif
10608
10609 strat->noTailReduction = FALSE;
10610 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10611 if (TEST_OPT_PROT)
10612 {
10613 PrintLn();
10614// if (timerv) writeTime("standard base computed:");
10615 }
10616 if (TEST_OPT_PROT)
10617 {
10618 Print("(S:%d)",strat->sl);mflush();
10619 }
10620 for (i=strat->sl; i>=low; i--)
10621 {
10622 int end_pos=strat->sl;
10623 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10624 if (strat->ak==0) end_pos=i-1;
10625 TObject* T_j = strat->s_2_t(i);
10626 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10627 {
10628 L = *T_j;
10629 #ifdef KDEBUG
10630 if (TEST_OPT_DEBUG)
10631 {
10632 Print("test S[%d]:",i);
10633 p_wrp(L.p,currRing,strat->tailRing);
10634 PrintLn();
10635 }
10636 #endif
10638 strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10639 else
10640 strat->S[i] = redtail(&L, strat->sl, strat);
10641 #ifdef KDEBUG
10642 if (TEST_OPT_DEBUG)
10643 {
10644 Print("to (tailR) S[%d]:",i);
10645 p_wrp(strat->S[i],currRing,strat->tailRing);
10646 PrintLn();
10647 }
10648 #endif
10649
10650 if (strat->redTailChange)
10651 {
10652 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10653 if (pNext(T_j->p) != NULL)
10654 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10655 else
10656 T_j->max_exp = NULL;
10657 }
10659 T_j->pCleardenom();
10660 }
10661 else
10662 {
10663 assume(currRing == strat->tailRing);
10664 #ifdef KDEBUG
10665 if (TEST_OPT_DEBUG)
10666 {
10667 Print("test S[%d]:",i);
10668 p_wrp(strat->S[i],currRing,strat->tailRing);
10669 PrintLn();
10670 }
10671 #endif
10673 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10674 else
10675 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10677 {
10679 {
10680 number n;
10681 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10682 if (!nIsOne(n))
10683 {
10685 denom->n=nInvers(n);
10686 denom->next=DENOMINATOR_LIST;
10687 DENOMINATOR_LIST=denom;
10688 }
10689 nDelete(&n);
10690 }
10691 else
10692 {
10693 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10694 }
10695 }
10696 #ifdef KDEBUG
10697 if (TEST_OPT_DEBUG)
10698 {
10699 Print("to (-tailR) S[%d]:",i);
10700 p_wrp(strat->S[i],currRing,strat->tailRing);
10701 PrintLn();
10702 }
10703 #endif
10704 }
10705 if (TEST_OPT_PROT)
10706 PrintS("-");
10707 }
10708 if (TEST_OPT_PROT) PrintLn();
10709#ifdef KDEBUG
10710 sloppy_max = FALSE;
10711#endif
10712}
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:7131
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7207
STATIC_VAR BOOLEAN sloppy_max
Definition: kutil.cc:824
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:3019
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2910
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:950
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1735
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1580

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

1296{
1297 if (set[j].lcm!=NULL)
1298 {
1299 kDeleteLcm(&set[j]);
1300 }
1301 if (set[j].sig!=NULL)
1302 {
1303#ifdef HAVE_RINGS
1304 if (pGetCoeff(set[j].sig) != NULL)
1305 pLmDelete(set[j].sig);
1306 else
1307#endif
1308 pLmFree(set[j].sig);
1309 }
1310 if (set[j].p!=NULL)
1311 {
1312 if (pNext(set[j].p) == strat->tail)
1313 {
1314#ifdef HAVE_RINGS
1315 if (pGetCoeff(set[j].p) != NULL)
1316 pLmDelete(set[j].p);
1317 else
1318#endif
1319 pLmFree(set[j].p);
1320 /*- tail belongs to several int spolys -*/
1321 }
1322 else
1323 {
1324 // search p in T, if it is there, do not delete it
1325 if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1326 {
1327 // assure that for global orderings kFindInT fails
1328 //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1329 set[j].Delete();
1330 }
1331 }
1332 }
1333 #ifdef HAVE_SHIFTBBA
1334 if (is_shifted_p1(strat->P.p1,strat))
1335 {
1336 // clean up strat->P.p1: may be shifted
1337 pLmDelete(strat->P.p1);
1338 strat->P.p1=NULL;
1339 }
1340 #endif
1341 if (*length > 0 && j < *length)
1342 {
1343#ifdef ENTER_USE_MEMMOVE
1344 memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1345#else
1346 int i;
1347 for (i=j; i < (*length); i++)
1348 set[i] = set[i+1];
1349#endif
1350 }
1351#ifdef KDEBUG
1352 memset(&(set[*length]),0,sizeof(LObject));
1353#endif
1354 (*length)--;
1355}
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:742
static BOOLEAN is_shifted_p1(const poly p, const kStrategy strat)
Definition: kutil.cc:1268
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 1163 of file kutil.cc.

1164{
1165#ifdef ENTER_USE_MEMMOVE
1166 memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1167 memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1168 memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1169 memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1170#else
1171 int j;
1172 for (j=i; j<strat->sl; j++)
1173 {
1174 strat->S[j] = strat->S[j+1];
1175 strat->ecartS[j] = strat->ecartS[j+1];
1176 strat->sevS[j] = strat->sevS[j+1];
1177 strat->S_2_R[j] = strat->S_2_R[j+1];
1178 }
1179#endif
1180 if (strat->lenS!=NULL)
1181 {
1182#ifdef ENTER_USE_MEMMOVE
1183 memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1184#else
1185 for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1186#endif
1187 }
1188 if (strat->lenSw!=NULL)
1189 {
1190#ifdef ENTER_USE_MEMMOVE
1191 memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1192#else
1193 for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1194#endif
1195 }
1196 if (strat->fromQ!=NULL)
1197 {
1198#ifdef ENTER_USE_MEMMOVE
1199 memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1200#else
1201 for (j=i; j<strat->sl; j++)
1202 {
1203 strat->fromQ[j] = strat->fromQ[j+1];
1204 }
1205#endif
1206 }
1207 strat->S[strat->sl] = NULL;
1208 strat->sl--;
1209}
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

◆ deleteInSSba()

void deleteInSSba ( int  i,
kStrategy  strat 
)

Definition at line 1215 of file kutil.cc.

1216{
1217#ifdef ENTER_USE_MEMMOVE
1218 memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1219 memmove(&(strat->sig[i]), &(strat->sig[i+1]), (strat->sl - i)*sizeof(poly));
1220 memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1221 memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1222 memmove(&(strat->sevSig[i]),&(strat->sevSig[i+1]),(strat->sl - i)*sizeof(unsigned long));
1223 memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1224#else
1225 int j;
1226 for (j=i; j<strat->sl; j++)
1227 {
1228 strat->S[j] = strat->S[j+1];
1229 strat->sig[j] = strat->sig[j+1];
1230 strat->ecartS[j] = strat->ecartS[j+1];
1231 strat->sevS[j] = strat->sevS[j+1];
1232 strat->sevSig[j] = strat->sevSig[j+1];
1233 strat->S_2_R[j] = strat->S_2_R[j+1];
1234 }
1235#endif
1236 if (strat->lenS!=NULL)
1237 {
1238#ifdef ENTER_USE_MEMMOVE
1239 memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1240#else
1241 for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1242#endif
1243 }
1244 if (strat->lenSw!=NULL)
1245 {
1246#ifdef ENTER_USE_MEMMOVE
1247 memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1248#else
1249 for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1250#endif
1251 }
1252 if (strat->fromQ!=NULL)
1253 {
1254#ifdef ENTER_USE_MEMMOVE
1255 memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1256#else
1257 for (j=i; j<strat->sl; j++)
1258 {
1259 strat->fromQ[j] = strat->fromQ[j+1];
1260 }
1261#endif
1262 }
1263 strat->S[strat->sl] = NULL;
1264 strat->sl--;
1265}

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4329 of file kutil.cc.

4330{
4331 if (nIsOne(pGetCoeff(h))) return;
4332 number gcd;
4333 bool go = false;
4334 if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4335 {
4336 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4337 go = true;
4338 }
4339 else
4340 gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4341 if (go || !nIsOne(gcd))
4342 {
4343 poly p = h->next;
4344 if (!go)
4345 {
4346 number tmp = gcd;
4347 gcd = n_Ann(gcd,currRing->cf);
4348 nDelete(&tmp);
4349 }
4350 p_Test(p,strat->tailRing);
4351 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4352 nDelete(&gcd);
4353
4354 if (p != NULL)
4355 {
4356 if (TEST_OPT_PROT)
4357 {
4358 PrintS("Z");
4359 }
4360#ifdef KDEBUG
4361 if (TEST_OPT_DEBUG)
4362 {
4363 PrintS("--- create zero spoly: ");
4364 p_wrp(h,currRing,strat->tailRing);
4365 PrintS(" ---> ");
4366 }
4367#endif
4368 poly tmp = pInit();
4369 pSetCoeff0(tmp, pGetCoeff(p));
4370 for (int i = 1; i <= rVar(currRing); i++)
4371 {
4372 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4373 }
4375 {
4376 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4377 }
4378 p_Setm(tmp, currRing);
4379 p = p_LmFreeAndNext(p, strat->tailRing);
4380 pNext(tmp) = p;
4381 LObject Lp;
4382 Lp.Init();
4383 Lp.p = tmp;
4384 Lp.tailRing = strat->tailRing;
4385 int posx;
4386 if (Lp.p!=NULL)
4387 {
4388 strat->initEcart(&Lp);
4389 if (strat->Ll==-1)
4390 posx =0;
4391 else
4392 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4393 Lp.sev = pGetShortExpVector(Lp.p);
4394 if (strat->tailRing != currRing)
4395 {
4396 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4397 }
4398#ifdef KDEBUG
4399 if (TEST_OPT_DEBUG)
4400 {
4401 p_wrp(tmp,currRing,strat->tailRing);
4402 PrintLn();
4403 }
4404#endif
4405 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4406 }
4407 }
4408 }
4409 nDelete(&gcd);
4410}
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:664
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:679
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:970
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1360
#define __p_GetComp(p, r)
Definition: monomials.h:63
#define rRing_has_Comp(r)
Definition: monomials.h:266
#define __pp_Mult_nn(p, n, r)
Definition: p_polys.h:1002
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:711
#define p_Test(p, r)
Definition: p_polys.h:162
#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 4412 of file kutil.cc.

4413{
4414 if (nIsOne(pGetCoeff(h))) return;
4415 number gcd;
4416 bool go = false;
4417 if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4418 {
4419 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4420 go = true;
4421 }
4422 else
4423 gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4424 if (go || !nIsOne(gcd))
4425 {
4426 poly p = h->next;
4427 if (!go)
4428 {
4429 number tmp = gcd;
4430 gcd = n_Ann(gcd,currRing->cf);
4431 nDelete(&tmp);
4432 }
4433 p_Test(p,strat->tailRing);
4434 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4435
4436 if (p != NULL)
4437 {
4438 if (TEST_OPT_PROT)
4439 {
4440 PrintS("Z");
4441 }
4442#ifdef KDEBUG
4443 if (TEST_OPT_DEBUG)
4444 {
4445 PrintS("--- create zero spoly: ");
4446 p_wrp(h,currRing,strat->tailRing);
4447 PrintS(" ---> ");
4448 }
4449#endif
4450 poly tmp = pInit();
4451 pSetCoeff0(tmp, pGetCoeff(p));
4452 for (int i = 1; i <= rVar(currRing); i++)
4453 {
4454 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4455 }
4457 {
4458 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4459 }
4460 p_Setm(tmp, currRing);
4461 p = p_LmFreeAndNext(p, strat->tailRing);
4462 pNext(tmp) = p;
4463 LObject Lp;
4464 Lp.Init();
4465 Lp.p = tmp;
4466 //printf("\nOld\n");pWrite(h);pWrite(hSig);
4467 #if EXT_POLY_NEW
4468 Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4469 if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4470 {
4471 strat->sigdrop = TRUE;
4472 //Try to reduce it as far as we can via redRing
4473 int red_result = redRing(&Lp,strat);
4474 if(red_result == 0)
4475 {
4476 // Cancel the sigdrop
4477 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4478 strat->sigdrop = FALSE;
4479 return;
4480 }
4481 else
4482 {
4483 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4484 #if 1
4485 strat->enterS(Lp,0,strat,strat->tl);
4486 #endif
4487 return;
4488 }
4489
4490 }
4491 #else
4492 Lp.sig = pOne();
4493 if(strat->Ll >= 0)
4494 p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4495 else
4496 p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4497 #endif
4498 Lp.tailRing = strat->tailRing;
4499 int posx;
4500 if (Lp.p!=NULL)
4501 {
4502 strat->initEcart(&Lp);
4503 if (strat->Ll==-1)
4504 posx =0;
4505 else
4506 posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4507 Lp.sev = pGetShortExpVector(Lp.p);
4508 if (strat->tailRing != currRing)
4509 {
4510 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4511 }
4512#ifdef KDEBUG
4513 if (TEST_OPT_DEBUG)
4514 {
4515 p_wrp(tmp,currRing,strat->tailRing);
4516 PrintLn();
4517 }
4518#endif
4519 //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4520 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4521 }
4522 }
4523 nDelete(&gcd);
4524 }
4525 nDelete(&gcd);
4526}
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:831
#define nIsZero(n)
Definition: numbers.h:19

◆ enterL()

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

Definition at line 1360 of file kutil.cc.

1361{
1362 // this should be corrected
1363 assume(p.FDeg == p.pFDeg());
1364
1365 if ((*length)>=0)
1366 {
1367 if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1368 if (at <= (*length))
1369#ifdef ENTER_USE_MEMMOVE
1370 memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1371#else
1372 for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1373#endif
1374 }
1375 else at = 0;
1376 (*set)[at] = p;
1377 (*length)++;
1378}
static void enlargeL(LSet *L, int *length, const int incr)
Definition: kutil.cc:687
#define setmaxLinc
Definition: kutil.h:31

◆ enterOnePairNormal()

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

Definition at line 2032 of file kutil.cc.

2033{
2034 assume(i<=strat->sl);
2035
2036 int l,j,compare;
2037 LObject Lp;
2038 Lp.i_r = -1;
2039
2040#ifdef KDEBUG
2041 Lp.ecart=0; Lp.length=0;
2042#endif
2043 /*- computes the lcm(s[i],p) -*/
2044 Lp.lcm = pInit();
2045
2046#ifndef HAVE_RATGRING
2047 pLcm(p,strat->S[i],Lp.lcm);
2048#elif defined(HAVE_RATGRING)
2049 if (rIsRatGRing(currRing))
2050 pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
2051 else
2052 pLcm(p,strat->S[i],Lp.lcm);
2053#endif
2054 pSetm(Lp.lcm);
2055
2056
2057 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
2058 {
2059 if (strat->fromT && (strat->ecartS[i]>ecart))
2060 {
2061 pLmFree(Lp.lcm);
2062 return;
2063 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2064 }
2065 if((!((strat->ecartS[i]>0)&&(ecart>0)))
2066 && pHasNotCF(p,strat->S[i]))
2067 {
2068 /*
2069 *the product criterion has applied for (s,p),
2070 *i.e. lcm(s,p)=product of the leading terms of s and p.
2071 *Suppose (s,r) is in L and the leading term
2072 *of p divides lcm(s,r)
2073 *(==> the leading term of p divides the leading term of r)
2074 *but the leading term of s does not divide the leading term of r
2075 *(notice that tis condition is automatically satisfied if r is still
2076 *in S), then (s,r) can be cancelled.
2077 *This should be done here because the
2078 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2079 *
2080 *Moreover, skipping (s,r) holds also for the noncommutative case.
2081 */
2082 strat->cp++;
2083 pLmFree(Lp.lcm);
2084 return;
2085 }
2086 Lp.ecart = si_max(ecart,strat->ecartS[i]);
2087 /*
2088 *the set B collects the pairs of type (S[j],p)
2089 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2090 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2091 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2092 */
2093 {
2094 j = strat->Bl;
2095 loop
2096 {
2097 if (j < 0) break;
2098 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2099 if ((compare==1)
2100 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
2101 {
2102 strat->c3++;
2103 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2104 {
2105 pLmFree(Lp.lcm);
2106 return;
2107 }
2108 break;
2109 }
2110 else
2111 if ((compare ==-1)
2112 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
2113 {
2114 deleteInL(strat->B,&strat->Bl,j,strat);
2115 strat->c3++;
2116 }
2117 j--;
2118 }
2119 }
2120 }
2121 else /*sugarcrit*/
2122 {
2123 if (ALLOW_PROD_CRIT(strat))
2124 {
2125 if (strat->fromT && (strat->ecartS[i]>ecart))
2126 {
2127 pLmFree(Lp.lcm);
2128 return;
2129 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2130 }
2131 // if currRing->nc_type!=quasi (or skew)
2132 // TODO: enable productCrit for super commutative algebras...
2133 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
2134 pHasNotCF(p,strat->S[i]))
2135 {
2136 /*
2137 *the product criterion has applied for (s,p),
2138 *i.e. lcm(s,p)=product of the leading terms of s and p.
2139 *Suppose (s,r) is in L and the leading term
2140 *of p divides lcm(s,r)
2141 *(==> the leading term of p divides the leading term of r)
2142 *but the leading term of s does not divide the leading term of r
2143 *(notice that tis condition is automatically satisfied if r is still
2144 *in S), then (s,r) can be canceled.
2145 *This should be done here because the
2146 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2147 */
2148 strat->cp++;
2149 pLmFree(Lp.lcm);
2150 return;
2151 }
2152 /*
2153 *the set B collects the pairs of type (S[j],p)
2154 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2155 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2156 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2157 */
2158 for(j = strat->Bl;j>=0;j--)
2159 {
2160 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2161 if (compare==1)
2162 {
2163 strat->c3++;
2164 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2165 {
2166 pLmFree(Lp.lcm);
2167 return;
2168 }
2169 break;
2170 }
2171 else
2172 if (compare ==-1)
2173 {
2174 deleteInL(strat->B,&strat->Bl,j,strat);
2175 strat->c3++;
2176 }
2177 }
2178 }
2179 }
2180 /*
2181 *the pair (S[i],p) enters B if the spoly != 0
2182 */
2183 /*- compute the short s-polynomial -*/
2184 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2185 pNorm(p);
2186
2187 if ((strat->S[i]==NULL) || (p==NULL))
2188 return;
2189
2190 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2191 Lp.p=NULL;
2192 else
2193 {
2194 #ifdef HAVE_PLURAL
2195 if ( rIsPluralRing(currRing) )
2196 {
2197 if(pHasNotCF(p, strat->S[i]))
2198 {
2199 if(ncRingType(currRing) == nc_lie)
2200 {
2201 // generalized prod-crit for lie-type
2202 strat->cp++;
2203 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2204 }
2205 else
2206 if( ALLOW_PROD_CRIT(strat) )
2207 {
2208 // product criterion for homogeneous case in SCA
2209 strat->cp++;
2210 Lp.p = NULL;
2211 }
2212 else
2213 {
2214 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2215 nc_CreateShortSpoly(strat->S[i], p, currRing);
2216 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2217 pNext(Lp.p) = strat->tail; // !!!
2218 }
2219 }
2220 else
2221 {
2222 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2223 nc_CreateShortSpoly(strat->S[i], p, currRing);
2224
2225 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2226 pNext(Lp.p) = strat->tail; // !!!
2227 }
2228 }
2229 else
2230 #endif
2231 {
2233 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2234 }
2235 }
2236 if (Lp.p == NULL)
2237 {
2238 /*- the case that the s-poly is 0 -*/
2239 if (strat->pairtest==NULL) initPairtest(strat);
2240 strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
2241 strat->pairtest[strat->sl+1] = TRUE;
2242 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
2243 /*
2244 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
2245 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
2246 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
2247 *term of p divides the lcm(s,r)
2248 *(this canceling should be done here because
2249 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
2250 *the first case is handeled in chainCrit
2251 */
2252 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2253 }
2254 else
2255 {
2256 /*- the pair (S[i],p) enters B -*/
2257 Lp.p1 = strat->S[i];
2258 Lp.p2 = p;
2259
2260 if (
2262// || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
2263 )
2264 {
2265 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2266 pNext(Lp.p) = strat->tail; // !!!
2267 }
2268
2269 if (atR >= 0)
2270 {
2271 Lp.i_r1 = strat->S_2_R[i];
2272 Lp.i_r2 = atR;
2273 }
2274 else
2275 {
2276 Lp.i_r1 = -1;
2277 Lp.i_r2 = -1;
2278 }
2279 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2280
2282 {
2285 && (Lp.p->coef!=NULL))
2286 nDelete(&(Lp.p->coef));
2287 }
2288
2289 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
2290 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2291 }
2292}
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:1430
void initPairtest(kStrategy strat)
Definition: kutil.cc:697
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:2243
#define pSetm(p)
Definition: polys.h:271
#define pHasNotCF(p1, p2)
Definition: polys.h:263
void pNorm(poly p)
Definition: polys.h:363
#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 12609 of file kutil.cc.

12610{
12611#ifdef CRITERION_DEBUG
12612 if (TEST_OPT_DEBUG)
12613 {
12614 PrintS("Consider pair ("); wrp(q); PrintS(", "); wrp(p); PrintS(")"); PrintLn();
12615 // also write the LMs in separate lines:
12616 poly lmq = pHead(q);
12617 poly lmp = pHead(p);
12618 pSetCoeff(lmq, n_Init(1, currRing->cf));
12619 pSetCoeff(lmp, n_Init(1, currRing->cf));
12620 Print(" %s\n", pString(lmq));
12621 Print(" %s\n", pString(lmp));
12622 pLmDelete(lmq);
12623 pLmDelete(lmp);
12624 }
12625#endif
12626
12627 /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
12628
12629 /* check this Formats: */
12634
12635 /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
12636
12637 int qfromQ = qisFromQ;
12638
12639 /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */
12640
12641 int l,j,compare;
12642 LObject Lp;
12643 Lp.i_r = -1;
12644
12645#ifdef KDEBUG
12646 Lp.ecart=0; Lp.length=0;
12647#endif
12648 /*- computes the lcm(s[i],p) -*/
12649 Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
12650
12651 /* the V criterion */
12652 if (!pmIsInV(Lp.lcm))
12653 {
12654 strat->cv++; // counter for applying the V criterion
12655 pLmFree(Lp.lcm);
12656#ifdef CRITERION_DEBUG
12657 if (TEST_OPT_DEBUG) PrintS("--- V crit\n");
12658#endif
12659 return TRUE;
12660 }
12661
12662 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
12663 {
12664 if((!((ecartq>0)&&(ecart>0)))
12665 && pHasNotCF(p,q))
12666 {
12667 /*
12668 *the product criterion has applied for (s,p),
12669 *i.e. lcm(s,p)=product of the leading terms of s and p.
12670 *Suppose (s,r) is in L and the leading term
12671 *of p divides lcm(s,r)
12672 *(==> the leading term of p divides the leading term of r)
12673 *but the leading term of s does not divide the leading term of r
12674 *(notice that this condition is automatically satisfied if r is still
12675 *in S), then (s,r) can be cancelled.
12676 *This should be done here because the
12677 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12678 *
12679 *Moreover, skipping (s,r) holds also for the noncommutative case.
12680 */
12681 strat->cp++;
12682 pLmFree(Lp.lcm);
12683#ifdef CRITERION_DEBUG
12684 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12685#endif
12686 return TRUE;
12687 }
12688 else
12689 Lp.ecart = si_max(ecart,ecartq);
12690 if (strat->fromT && (ecartq>ecart))
12691 {
12692 pLmFree(Lp.lcm);
12693#ifdef CRITERION_DEBUG
12694 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12695#endif
12696 return TRUE;
12697 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12698 }
12699 /*
12700 *the set B collects the pairs of type (S[j],p)
12701 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12702 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12703 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12704 */
12705 {
12706 j = strat->Bl;
12707 loop
12708 {
12709 if (j < 0) break;
12710 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12711 if ((compare==1)
12712 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
12713 {
12714 strat->c3++;
12715 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12716 {
12717 pLmFree(Lp.lcm);
12718#ifdef CRITERION_DEBUG
12719 if (TEST_OPT_DEBUG)
12720 {
12721 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12722 }
12723#endif
12724 return TRUE;
12725 }
12726 break;
12727 }
12728 else
12729 if ((compare ==-1)
12730 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
12731 {
12732#ifdef CRITERION_DEBUG
12733 if (TEST_OPT_DEBUG)
12734 {
12735 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12736 }
12737#endif
12738 deleteInL(strat->B,&strat->Bl,j,strat);
12739 strat->c3++;
12740 }
12741 j--;
12742 }
12743 }
12744 }
12745 else /*sugarcrit*/
12746 {
12747 if (ALLOW_PROD_CRIT(strat))
12748 {
12749 // if currRing->nc_type!=quasi (or skew)
12750 // TODO: enable productCrit for super commutative algebras...
12751 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
12752 pHasNotCF(p,q))
12753 {
12754 /*
12755 *the product criterion has applied for (s,p),
12756 *i.e. lcm(s,p)=product of the leading terms of s and p.
12757 *Suppose (s,r) is in L and the leading term
12758 *of p divides lcm(s,r)
12759 *(==> the leading term of p divides the leading term of r)
12760 *but the leading term of s does not divide the leading term of r
12761 *(notice that tis condition is automatically satisfied if r is still
12762 *in S), then (s,r) can be canceled.
12763 *This should be done here because the
12764 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12765 */
12766 strat->cp++;
12767 pLmFree(Lp.lcm);
12768#ifdef CRITERION_DEBUG
12769 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12770#endif
12771 return TRUE;
12772 }
12773 if (strat->fromT && (ecartq>ecart))
12774 {
12775 pLmFree(Lp.lcm);
12776#ifdef CRITERION_DEBUG
12777 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12778#endif
12779 return TRUE;
12780 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12781 }
12782 /*
12783 *the set B collects the pairs of type (S[j],p)
12784 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12785 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12786 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12787 */
12788 for(j = strat->Bl;j>=0;j--)
12789 {
12790 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12791 if (compare==1)
12792 {
12793 strat->c3++;
12794 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12795 {
12796 pLmFree(Lp.lcm);
12797#ifdef CRITERION_DEBUG
12798 if (TEST_OPT_DEBUG)
12799 {
12800 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12801 }
12802#endif
12803 return TRUE;
12804 }
12805 break;
12806 }
12807 else
12808 if (compare ==-1)
12809 {
12810#ifdef CRITERION_DEBUG
12811 if (TEST_OPT_DEBUG)
12812 {
12813 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12814 }
12815#endif
12816 deleteInL(strat->B,&strat->Bl,j,strat);
12817 strat->c3++;
12818 }
12819 }
12820 }
12821 }
12822 /*
12823 *the pair (S[i],p) enters B if the spoly != 0
12824 */
12825 /*- compute the short s-polynomial -*/
12826 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
12827 pNorm(p);
12828 if ((q==NULL) || (p==NULL))
12829 {
12830#ifdef CRITERION_DEBUG
12831 if (TEST_OPT_DEBUG) PrintS("--- q == NULL || p == NULL\n");
12832#endif
12833 return FALSE;
12834 }
12835 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
12836 {
12837 Lp.p=NULL;
12838#ifdef CRITERION_DEBUG
12839 if (TEST_OPT_DEBUG) PrintS("--- pair is from Q\n");
12840#endif
12841 }
12842 else
12843 {
12844// if ( rIsPluralRing(currRing) )
12845// {
12846// if(pHasNotCF(p, q))
12847// {
12848// if(ncRingType(currRing) == nc_lie)
12849// {
12850// // generalized prod-crit for lie-type
12851// strat->cp++;
12852// Lp.p = nc_p_Bracket_qq(pCopy(p),q, currRing);
12853// }
12854// else
12855// if( ALLOW_PROD_CRIT(strat) )
12856// {
12857// // product criterion for homogeneous case in SCA
12858// strat->cp++;
12859// Lp.p = NULL;
12860// }
12861// else
12862// Lp.p = nc_CreateSpoly(q,p,currRing); // ?
12863// }
12864// else Lp.p = nc_CreateSpoly(q,p,currRing);
12865// }
12866// else
12867// {
12868
12869 /* ksCreateShortSpoly needs two Lobject-kind presentations */
12870 /* p is already in this form, so convert q */
12871 // q = pMove2CurrTail(q, strat);
12872 Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
12873 // }
12874 }
12875 if (Lp.p == NULL)
12876 {
12877 /*- the case that the s-poly is 0 -*/
12878 // TODO: currently ifromS is only > 0 if called from enterOnePairWithShifts
12879 if (ifromS > 0)
12880 {
12881 if (strat->pairtest==NULL) initPairtest(strat);
12882 strat->pairtest[ifromS] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
12883 strat->pairtest[strat->sl+1] = TRUE;
12884 }
12885 //if (TEST_OPT_DEBUG){Print("!");} // option teach
12886 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12887 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
12888 /*
12889 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
12890 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
12891 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
12892 *term of p divides the lcm(s,r)
12893 *(this canceling should be done here because
12894 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
12895 *the first case is handeled in chainCrit
12896 */
12897 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
12898#ifdef CRITERION_DEBUG
12899 if (TEST_OPT_DEBUG) PrintS("--- S-poly = 0\n");
12900#endif
12901 return TRUE;
12902 }
12903 else
12904 {
12905 /*- the pair (S[i],p) enters B -*/
12906 /* both of them should have their LM in currRing and TAIL in tailring */
12907 Lp.p1 = q; // already in the needed form
12908 Lp.p2 = p; // already in the needed form
12909
12910 if ( !rIsPluralRing(currRing) )
12911 pNext(Lp.p) = strat->tail;
12912
12913 /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12914 /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12915 if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
12916 {
12917 Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
12918 Lp.i_r2 = atR;
12919 }
12920 else
12921 {
12922 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12923 Lp.i_r1 = -1;
12924 Lp.i_r2 = -1;
12925 }
12926 strat->initEcartPair(&Lp,q,p,ecartq,ecart);
12927
12929 {
12932 && (Lp.p->coef!=NULL))
12933 nDelete(&(Lp.p->coef));
12934 }
12935
12936 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
12937 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
12938#ifdef CRITERION_DEBUG
12939 if (TEST_OPT_DEBUG) PrintS("+++ Entered pair\n");
12940#endif
12941 }
12942 return FALSE;
12943}
int cv
Definition: kutil.h:368
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:538
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 4587 of file kutil.cc.

4588{
4589 int j=pos;
4590
4592 initenterpairs(h,k,ecart,0,strat, atR);
4593 if ( (!strat->fromT)
4594 && ((strat->syzComp==0)
4595 ||(pGetComp(h)<=strat->syzComp)))
4596 {
4597 unsigned long h_sev = pGetShortExpVector(h);
4598 loop
4599 {
4600 if (j > k) break;
4601 clearS(h,h_sev, &j,&k,strat);
4602 j++;
4603 }
4604 }
4605}
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:3902

◆ enterpairsShift()

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

Definition at line 13404 of file kutil.cc.

13405{
13406 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
13407 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
13408 int j=pos;
13409
13410 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
13411 initenterpairsShift(h,k,ecart,0,strat, atR);
13412 if ( (!strat->fromT)
13413 && ((strat->syzComp==0)
13414 ||(pGetComp(h)<=strat->syzComp)))
13415 {
13416 unsigned long h_sev = pGetShortExpVector(h);
13417 loop
13418 {
13419 if (j > k) break;
13420 // TODO this currently doesn't clear all possible elements because of commutative division
13421 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
13422 clearS(h,h_sev, &j,&k,strat);
13423 j++;
13424 }
13425 }
13426}
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:12952

◆ enterpairsSig()

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

Definition at line 4613 of file kutil.cc.

4614{
4615 int j=pos;
4617 initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4618 if ( (!strat->fromT)
4619 && ((strat->syzComp==0)
4620 ||(pGetComp(h)<=strat->syzComp)))
4621 {
4622 unsigned long h_sev = pGetShortExpVector(h);
4623 loop
4624 {
4625 if (j > k) break;
4626 clearS(h,h_sev, &j,&k,strat);
4627 j++;
4628 }
4629 }
4630}
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3967

◆ enterSBba()

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

Definition at line 9085 of file kutil.cc.

9086{
9087 strat->news = TRUE;
9088 /*- puts p to the standardbasis s at position at -*/
9089 if (strat->sl == IDELEMS(strat->Shdl)-1)
9090 {
9091 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9092 IDELEMS(strat->Shdl)*sizeof(unsigned long),
9093 (IDELEMS(strat->Shdl)+setmaxTinc)
9094 *sizeof(unsigned long));
9095 strat->ecartS = (intset)omReallocSize(strat->ecartS,
9096 IDELEMS(strat->Shdl)*sizeof(int),
9097 (IDELEMS(strat->Shdl)+setmaxTinc)
9098 *sizeof(int));
9099 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9100 IDELEMS(strat->Shdl)*sizeof(int),
9101 (IDELEMS(strat->Shdl)+setmaxTinc)
9102 *sizeof(int));
9103 if (strat->lenS!=NULL)
9104 strat->lenS=(int*)omRealloc0Size(strat->lenS,
9105 IDELEMS(strat->Shdl)*sizeof(int),
9106 (IDELEMS(strat->Shdl)+setmaxTinc)
9107 *sizeof(int));
9108 if (strat->lenSw!=NULL)
9109 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9110 IDELEMS(strat->Shdl)*sizeof(wlen_type),
9111 (IDELEMS(strat->Shdl)+setmaxTinc)
9112 *sizeof(wlen_type));
9113 if (strat->fromQ!=NULL)
9114 {
9115 strat->fromQ = (intset)omReallocSize(strat->fromQ,
9116 IDELEMS(strat->Shdl)*sizeof(int),
9117 (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
9118 }
9119 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
9120 IDELEMS(strat->Shdl)+=setmaxTinc;
9121 strat->Shdl->m=strat->S;
9122 }
9123 if (atS <= strat->sl)
9124 {
9125#ifdef ENTER_USE_MEMMOVE
9126 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9127 (strat->sl - atS + 1)*sizeof(poly));
9128 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9129 (strat->sl - atS + 1)*sizeof(int));
9130 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9131 (strat->sl - atS + 1)*sizeof(unsigned long));
9132 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9133 (strat->sl - atS + 1)*sizeof(int));
9134 if (strat->lenS!=NULL)
9135 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9136 (strat->sl - atS + 1)*sizeof(int));
9137 if (strat->lenSw!=NULL)
9138 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9139 (strat->sl - atS + 1)*sizeof(wlen_type));
9140#else
9141 for (i=strat->sl+1; i>=atS+1; i--)
9142 {
9143 strat->S[i] = strat->S[i-1];
9144 strat->ecartS[i] = strat->ecartS[i-1];
9145 strat->sevS[i] = strat->sevS[i-1];
9146 strat->S_2_R[i] = strat->S_2_R[i-1];
9147 }
9148 if (strat->lenS!=NULL)
9149 for (i=strat->sl+1; i>=atS+1; i--)
9150 strat->lenS[i] = strat->lenS[i-1];
9151 if (strat->lenSw!=NULL)
9152 for (i=strat->sl+1; i>=atS+1; i--)
9153 strat->lenSw[i] = strat->lenSw[i-1];
9154#endif
9155 }
9156 if (strat->fromQ!=NULL)
9157 {
9158#ifdef ENTER_USE_MEMMOVE
9159 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9160 (strat->sl - atS + 1)*sizeof(int));
9161#else
9162 for (i=strat->sl+1; i>=atS+1; i--)
9163 {
9164 strat->fromQ[i] = strat->fromQ[i-1];
9165 }
9166#endif
9167 strat->fromQ[atS]=0;
9168 }
9169
9170 /*- save result -*/
9171 poly pp=p.p;
9172 strat->S[atS] = pp;
9173 if (strat->honey) strat->ecartS[atS] = p.ecart;
9174 if (p.sev == 0)
9175 p.sev = pGetShortExpVector(pp);
9176 else
9177 assume(p.sev == pGetShortExpVector(pp));
9178 strat->sevS[atS] = p.sev;
9179 strat->ecartS[atS] = p.ecart;
9180 strat->S_2_R[atS] = atR;
9181 strat->sl++;
9182}
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:3774

◆ enterSBbaShift()

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

Definition at line 9185 of file kutil.cc.

9186{
9187 enterSBba(p, atS, strat, atR);
9188
9189 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
9190 for (int i = maxPossibleShift; i > 0; i--)
9191 {
9192 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
9193 // in `kNF2` because of lazy poly normalizations.
9194 LObject qq(p_Copy(p.p, strat->tailRing));
9195 p_mLPshift(qq.p, i, strat->tailRing);
9196 qq.shift = i;
9197 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
9198 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
9199 enterSBba(qq, atS, strat, -1);
9200 }
9201}
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9085
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 9208 of file kutil.cc.

9209{
9210 strat->news = TRUE;
9211 /*- puts p to the standardbasis s at position at -*/
9212 if (strat->sl == IDELEMS(strat->Shdl)-1)
9213 {
9214 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9215 IDELEMS(strat->Shdl)*sizeof(unsigned long),
9216 (IDELEMS(strat->Shdl)+setmax)
9217 *sizeof(unsigned long));
9218 strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
9219 IDELEMS(strat->Shdl)*sizeof(unsigned long),
9220 (IDELEMS(strat->Shdl)+setmax)
9221 *sizeof(unsigned long));
9222 strat->ecartS = (intset)omReallocSize(strat->ecartS,
9223 IDELEMS(strat->Shdl)*sizeof(int),
9224 (IDELEMS(strat->Shdl)+setmax)
9225 *sizeof(int));
9226 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9227 IDELEMS(strat->Shdl)*sizeof(int),
9228 (IDELEMS(strat->Shdl)+setmax)
9229 *sizeof(int));
9230 if (strat->lenS!=NULL)
9231 strat->lenS=(int*)omRealloc0Size(strat->lenS,
9232 IDELEMS(strat->Shdl)*sizeof(int),
9233 (IDELEMS(strat->Shdl)+setmax)
9234 *sizeof(int));
9235 if (strat->lenSw!=NULL)
9236 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9237 IDELEMS(strat->Shdl)*sizeof(wlen_type),
9238 (IDELEMS(strat->Shdl)+setmax)
9239 *sizeof(wlen_type));
9240 if (strat->fromQ!=NULL)
9241 {
9242 strat->fromQ = (intset)omReallocSize(strat->fromQ,
9243 IDELEMS(strat->Shdl)*sizeof(int),
9244 (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
9245 }
9246 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
9247 pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
9248 IDELEMS(strat->Shdl)+=setmax;
9249 strat->Shdl->m=strat->S;
9250 }
9251 // in a signature-based algorithm the following situation will never
9252 // appear due to the fact that the critical pairs are already sorted
9253 // by increasing signature.
9254 // True. However, in the case of integers we need to put the element
9255 // that caused the signature drop on the first position
9256 if (atS <= strat->sl)
9257 {
9258#ifdef ENTER_USE_MEMMOVE
9259 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9260 (strat->sl - atS + 1)*sizeof(poly));
9261 memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
9262 (strat->sl - atS + 1)*sizeof(poly));
9263 memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
9264 (strat->sl - atS + 1)*sizeof(unsigned long));
9265 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9266 (strat->sl - atS + 1)*sizeof(int));
9267 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9268 (strat->sl - atS + 1)*sizeof(unsigned long));
9269 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9270 (strat->sl - atS + 1)*sizeof(int));
9271 if (strat->lenS!=NULL)
9272 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9273 (strat->sl - atS + 1)*sizeof(int));
9274 if (strat->lenSw!=NULL)
9275 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9276 (strat->sl - atS + 1)*sizeof(wlen_type));
9277#else
9278 for (i=strat->sl+1; i>=atS+1; i--)
9279 {
9280 strat->S[i] = strat->S[i-1];
9281 strat->ecartS[i] = strat->ecartS[i-1];
9282 strat->sevS[i] = strat->sevS[i-1];
9283 strat->S_2_R[i] = strat->S_2_R[i-1];
9284 strat->sig[i] = strat->sig[i-1];
9285 strat->sevSig[i] = strat->sevSig[i-1];
9286 }
9287 if (strat->lenS!=NULL)
9288 for (i=strat->sl+1; i>=atS+1; i--)
9289 strat->lenS[i] = strat->lenS[i-1];
9290 if (strat->lenSw!=NULL)
9291 for (i=strat->sl+1; i>=atS+1; i--)
9292 strat->lenSw[i] = strat->lenSw[i-1];
9293#endif
9294 }
9295 if (strat->fromQ!=NULL)
9296 {
9297#ifdef ENTER_USE_MEMMOVE
9298 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9299 (strat->sl - atS + 1)*sizeof(int));
9300#else
9301 for (i=strat->sl+1; i>=atS+1; i--)
9302 {
9303 strat->fromQ[i] = strat->fromQ[i-1];
9304 }
9305#endif
9306 strat->fromQ[atS]=0;
9307 }
9308
9309 /*- save result -*/
9310 strat->S[atS] = p.p;
9311 strat->sig[atS] = p.sig; // TODO: get ths correct signature in here!
9312 if (strat->honey) strat->ecartS[atS] = p.ecart;
9313 if (p.sev == 0)
9314 p.sev = pGetShortExpVector(p.p);
9315 else
9316 assume(p.sev == pGetShortExpVector(p.p));
9317 strat->sevS[atS] = p.sev;
9318 // during the interreduction process of a signature-based algorithm we do not
9319 // compute the signature at this point, but when the whole interreduction
9320 // process finishes, i.e. f5c terminates!
9321 if (p.sig != NULL)
9322 {
9323 if (p.sevSig == 0)
9324 p.sevSig = pGetShortExpVector(p.sig);
9325 else
9326 assume(p.sevSig == pGetShortExpVector(p.sig));
9327 strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9328 }
9329 strat->ecartS[atS] = p.ecart;
9330 strat->S_2_R[atS] = atR;
9331 strat->sl++;
9332#ifdef DEBUGF5
9333 int k;
9334 Print("--- LIST S: %d ---\n",strat->sl);
9335 for(k=0;k<=strat->sl;k++)
9336 {
9337 pWrite(strat->sig[k]);
9338 }
9339 PrintS("--- LIST S END ---\n");
9340#endif
9341}
#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 9636 of file kutil.cc.

9637{
9638 int i;
9639 strat->newt = TRUE;
9640 if (strat->syzl == strat->syzmax-1)
9641 {
9642 pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9643 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9644 (strat->syzmax)*sizeof(unsigned long),
9645 ((strat->syzmax)+setmax)
9646 *sizeof(unsigned long));
9647 strat->syzmax += setmax;
9648 }
9649 if (atT < strat->syzl)
9650 {
9651#ifdef ENTER_USE_MEMMOVE
9652 memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9653 (strat->syzl-atT+1)*sizeof(poly));
9654 memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9655 (strat->syzl-atT+1)*sizeof(unsigned long));
9656#endif
9657 for (i=strat->syzl; i>=atT+1; i--)
9658 {
9659#ifndef ENTER_USE_MEMMOVE
9660 strat->syz[i] = strat->syz[i-1];
9661 strat->sevSyz[i] = strat->sevSyz[i-1];
9662#endif
9663 }
9664 }
9665 //i = strat->syzl;
9666 i = atT;
9667 //Makes sure the syz saves just the signature
9668 #ifdef HAVE_RINGS
9670 pNext(p.sig) = NULL;
9671 #endif
9672 strat->syz[atT] = p.sig;
9673 strat->sevSyz[atT] = p.sevSig;
9674 strat->syzl++;
9675#if F5DEBUG
9676 Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9677 pWrite(strat->syz[atT]);
9678#endif
9679 // recheck pairs in strat->L with new rule and delete correspondingly
9680 int cc = strat->Ll;
9681 while (cc>-1)
9682 {
9683 //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9684 //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);
9685 if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9686 strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9687 #ifdef HAVE_RINGS
9689 || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9690 #endif
9691 )
9692 {
9693 //printf("\nYES!\n");
9694 deleteInL(strat->L,&strat->Ll,cc,strat);
9695 }
9696 cc--;
9697 }
9698//#if 1
9699#ifdef DEBUGF5
9700 PrintS("--- Syzygies ---\n");
9701 Print("syzl %d\n",strat->syzl);
9702 Print("syzmax %d\n",strat->syzmax);
9703 PrintS("--------------------------------\n");
9704 for(i=0;i<=strat->syzl-1;i++)
9705 {
9706 Print("%d - ",i);
9707 pWrite(strat->syz[i]);
9708 }
9709 PrintS("--------------------------------\n");
9710#endif
9711}
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 9434 of file kutil.cc.

9435{
9436 int i;
9437
9438#ifdef PDEBUG
9439#ifdef HAVE_SHIFTBBA
9440 if (currRing->isLPring && p.shift > 0)
9441 {
9442 // in this case, the order is not correct. test LM and tail separately
9443 p_LmTest(p.p, currRing);
9444 p_Test(pNext(p.p), currRing);
9445 }
9446 else
9447#endif
9448 {
9449 pp_Test(p.p, currRing, p.tailRing);
9450 }
9451#endif
9452 assume(strat->tailRing == p.tailRing);
9453 // redMoraNF complains about this -- but, we don't really
9454 // neeed this so far
9455 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9456 assume(!strat->homog || (p.FDeg == p.pFDeg()));
9457 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9458
9459#ifdef KDEBUG
9460 // do not put an LObject twice into T:
9461 for(i=strat->tl;i>=0;i--)
9462 {
9463 if (p.p==strat->T[i].p)
9464 {
9465 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9466 return;
9467 }
9468 }
9469#endif
9470
9471#ifdef HAVE_TAIL_RING
9472 if (currRing!=strat->tailRing)
9473 {
9474 p.t_p=p.GetLmTailRing();
9475 }
9476#endif
9477 strat->newt = TRUE;
9478 if (atT < 0)
9479 atT = strat->posInT(strat->T, strat->tl, p);
9480 if (strat->tl == strat->tmax-1)
9481 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9482 if (atT <= strat->tl)
9483 {
9484#ifdef ENTER_USE_MEMMOVE
9485 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9486 (strat->tl-atT+1)*sizeof(TObject));
9487 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9488 (strat->tl-atT+1)*sizeof(unsigned long));
9489#endif
9490 for (i=strat->tl+1; i>=atT+1; i--)
9491 {
9492#ifndef ENTER_USE_MEMMOVE
9493 strat->T[i] = strat->T[i-1];
9494 strat->sevT[i] = strat->sevT[i-1];
9495#endif
9496 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9497 }
9498 }
9499
9500 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9501 {
9502#ifdef HAVE_SHIFTBBA
9503 // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9504 if (!(currRing->isLPring && p.shift > 0))
9505#endif
9506 {
9508 (strat->tailRing != NULL ?
9509 strat->tailRing : currRing),
9510 strat->tailBin);
9511 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9512 }
9513 }
9514 strat->T[atT] = (TObject) p;
9515 //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9516
9517 if ((pNext(p.p) != NULL) && (!rIsLPRing(currRing)))
9518 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9519 else
9520 strat->T[atT].max_exp = NULL;
9521
9522 strat->tl++;
9523 strat->R[strat->tl] = &(strat->T[atT]);
9524 strat->T[atT].i_r = strat->tl;
9525 assume((p.sev == 0) || (pGetShortExpVector(p.p) == p.sev));
9526 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9527 kTest_T(&(strat->T[atT]),strat);
9528}
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:548
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition: kutil.cc:825
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:164
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition: p_polys.h:928
#define p_LmTest(p, r)
Definition: p_polys.h:163
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:721

◆ enterT_strong()

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

Definition at line 9534 of file kutil.cc.

9535{
9537 int i;
9538
9539 pp_Test(p.p, currRing, p.tailRing);
9540 assume(strat->tailRing == p.tailRing);
9541 // redMoraNF complains about this -- but, we don't really
9542 // neeed this so far
9543 assume(p.pLength == 0 || (int)pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9544 assume(p.FDeg == p.pFDeg());
9545 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9546
9547#ifdef KDEBUG
9548 // do not put an LObject twice into T:
9549 for(i=strat->tl;i>=0;i--)
9550 {
9551 if (p.p==strat->T[i].p)
9552 {
9553 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9554 return;
9555 }
9556 }
9557#endif
9558
9559#ifdef HAVE_TAIL_RING
9560 if (currRing!=strat->tailRing)
9561 {
9562 p.t_p=p.GetLmTailRing();
9563 }
9564#endif
9565 strat->newt = TRUE;
9566 if (atT < 0)
9567 atT = strat->posInT(strat->T, strat->tl, p);
9568 if (strat->tl == strat->tmax-1)
9569 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9570 if (atT <= strat->tl)
9571 {
9572#ifdef ENTER_USE_MEMMOVE
9573 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9574 (strat->tl-atT+1)*sizeof(TObject));
9575 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9576 (strat->tl-atT+1)*sizeof(unsigned long));
9577#endif
9578 for (i=strat->tl+1; i>=atT+1; i--)
9579 {
9580#ifndef ENTER_USE_MEMMOVE
9581 strat->T[i] = strat->T[i-1];
9582 strat->sevT[i] = strat->sevT[i-1];
9583#endif
9584 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9585 }
9586 }
9587
9588 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9589 {
9591 (strat->tailRing != NULL ?
9592 strat->tailRing : currRing),
9593 strat->tailBin);
9594 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9595 }
9596 strat->T[atT] = (TObject) p;
9597 //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9598
9599 if (pNext(p.p) != NULL)
9600 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9601 else
9602 strat->T[atT].max_exp = NULL;
9603
9604 strat->tl++;
9605 strat->R[strat->tl] = &(strat->T[atT]);
9606 strat->T[atT].i_r = strat->tl;
9607 assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9608 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9609 #if 1
9611 && !n_IsUnit(p.p->coef, currRing->cf))
9612 {
9613 for(i=strat->tl;i>=0;i--)
9614 {
9615 if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9616 {
9617 enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9618 }
9619 }
9620 }
9621 /*
9622 printf("\nThis is T:\n");
9623 for(i=strat->tl;i>=0;i--)
9624 {
9625 pWrite(strat->T[i].p);
9626 }
9627 //getchar();*/
9628 #endif
9629 kTest_T(&(strat->T[atT]),strat);
9630}
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:515
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1630
#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 13434 of file kutil.cc.

13435{
13436 /* determine how many elements we have to insert */
13437 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
13438 /* hence, a total number of elt's to add is: */
13439 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
13440 pAssume(p.p != NULL);
13441
13442 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
13443
13444 for (int i = 1; i <= maxPossibleShift; i++)
13445 {
13446 LObject qq;
13447 qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
13448 qq.shift = i;
13449 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
13450
13451 enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13452 }
13453}
#define pAssume(cond)
Definition: monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 10142 of file kutil.cc.

10143{
10144 /*- release temp data -*/
10145 cleanT(strat);
10146 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10147 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10148 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10149 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10150 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10151 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10152 /*- set L: should be empty -*/
10153 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10154 /*- set B: should be empty -*/
10155 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10156 pLmFree(&strat->tail);
10157 strat->syzComp=0;
10158
10159#ifdef HAVE_SHIFTBBA
10160 if (rIsLPRing(currRing) && strat->rightGB)
10161 {
10162 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10163 strat->fromQ=NULL;
10164 }
10165#endif
10166}
void * ADDRESS
Definition: auxiliary.h:119

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10345 of file kutil.cc.

10346{
10347 /*- release temp data -*/
10349 cleanTSbaRing(strat);
10350 else
10351 cleanT(strat);
10352 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10353 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10354 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10355 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10356 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10357 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10358 if(strat->syzmax>0)
10359 {
10360 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10361 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10362 if (strat->sbaOrder == 1)
10363 {
10364 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10365 }
10366 }
10367 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10368 /*- set L: should be empty -*/
10369 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10370 /*- set B: should be empty -*/
10371 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10372 /*- set sig: no need for the signatures anymore -*/
10373 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10374 pLmDelete(&strat->tail);
10375 strat->syzComp=0;
10376}
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:628

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

4042{
4043 int Ll_old, red_result = 1;
4044 int pos = 0;
4045 hilbeledeg=1;
4046 hilbcount=0;
4047 minimcnt=0;
4048 srmax = 0; // strat->sl is 0 at this point
4049 reduc = olddeg = lrmax = 0;
4050 // we cannot use strat->T anymore
4051 //cleanT(strat);
4052 //strat->tl = -1;
4053 Ll_old = strat->Ll;
4054 while (strat->tl >= 0)
4055 {
4056 if(!strat->T[strat->tl].is_redundant)
4057 {
4058 LObject h;
4059 h.p = strat->T[strat->tl].p;
4060 h.tailRing = strat->T[strat->tl].tailRing;
4061 h.t_p = strat->T[strat->tl].t_p;
4062 if (h.p!=NULL)
4063 {
4064 if (currRing->OrdSgn==-1)
4065 {
4066 cancelunit(&h);
4067 deleteHC(&h, strat);
4068 }
4069 if (h.p!=NULL)
4070 {
4072 {
4073 h.pCleardenom(); // also does remove Content
4074 }
4075 else
4076 {
4077 h.pNorm();
4078 }
4079 strat->initEcart(&h);
4081 pos = posInLF5CRing(strat->L, Ll_old+1,strat->Ll,&h,strat);
4082 else
4083 pos = strat->Ll+1;
4084 h.sev = pGetShortExpVector(h.p);
4085 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
4086 }
4087 }
4088 }
4089 strat->tl--;
4090 }
4091 strat->sl = -1;
4092#if 0
4093//#ifdef HAVE_TAIL_RING
4094 if(!rField_is_Ring()) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4096#endif
4097 //enterpairs(pOne(),0,0,-1,strat,strat->tl);
4098 //strat->sl = -1;
4099 /* picks the last element from the lazyset L */
4100 while (strat->Ll>Ll_old)
4101 {
4102 strat->P = strat->L[strat->Ll];
4103 strat->Ll--;
4104//#if 1
4105#ifdef DEBUGF5
4106 PrintS("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
4107 PrintS("-------------------------------------------------\n");
4108 pWrite(pHead(strat->P.p));
4109 pWrite(pHead(strat->P.p1));
4110 pWrite(pHead(strat->P.p2));
4111 printf("%d\n",strat->tl);
4112 PrintS("-------------------------------------------------\n");
4113#endif
4114 if (pNext(strat->P.p) == strat->tail)
4115 {
4116 // deletes the short spoly
4118 pLmDelete(strat->P.p);
4119 else
4120 pLmFree(strat->P.p);
4121
4122 // TODO: needs some masking
4123 // TODO: masking needs to vanish once the signature
4124 // sutff is completely implemented
4125 strat->P.p = NULL;
4126 poly m1 = NULL, m2 = NULL;
4127
4128 // check that spoly creation is ok
4129 while (strat->tailRing != currRing &&
4130 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4131 {
4132 assume(m1 == NULL && m2 == NULL);
4133 // if not, change to a ring where exponents are at least
4134 // large enough
4135 if (!kStratChangeTailRing(strat))
4136 {
4137 WerrorS("OVERFLOW...");
4138 break;
4139 }
4140 }
4141 // create the real one
4142 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4143 strat->tailRing, m1, m2, strat->R);
4144 }
4145 else if (strat->P.p1 == NULL)
4146 {
4147 if (strat->minim > 0)
4148 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4149 // for input polys, prepare reduction
4151 strat->P.PrepareRed(strat->use_buckets);
4152 }
4153
4154 if (strat->P.p == NULL && strat->P.t_p == NULL)
4155 {
4156 red_result = 0;
4157 }
4158 else
4159 {
4160 if (TEST_OPT_PROT)
4161 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4162 &olddeg,&reduc,strat, red_result);
4163
4164#ifdef DEBUGF5
4165 PrintS("Poly before red: ");
4166 pWrite(strat->P.p);
4167#endif
4168 /* complete reduction of the element chosen from L */
4169 red_result = strat->red2(&strat->P,strat);
4170 if (errorreported) break;
4171 }
4172
4173 if (strat->overflow)
4174 {
4175 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4176 }
4177
4178 // reduction to non-zero new poly
4179 if (red_result == 1)
4180 {
4181 // get the polynomial (canonicalize bucket, make sure P.p is set)
4182 strat->P.GetP(strat->lmBin);
4183 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4184 // but now, for entering S, T, we reset it
4185 // in the inhomogeneous case: FDeg == pFDeg
4186 if (strat->homog) strat->initEcart(&(strat->P));
4187
4188 /* statistic */
4189 if (TEST_OPT_PROT) PrintS("s");
4190 int pos;
4191 #if 1
4193 pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4194 else
4195 pos = posInSMonFirst(strat,strat->sl,strat->P.p);
4196 #else
4197 pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4198 #endif
4199 // reduce the tail and normalize poly
4200 // in the ring case we cannot expect LC(f) = 1,
4201#if F5CTAILRED
4202 BOOLEAN withT = TRUE;
4204 {
4205 strat->P.pCleardenom();
4207 {
4208 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4209 strat->P.pCleardenom();
4210 }
4211 }
4212 else
4213 {
4214 strat->P.pNorm();
4216 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4217 }
4218#endif
4219#ifdef KDEBUG
4220 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4221#endif /* KDEBUG */
4222
4223 // min_std stuff
4224 if ((strat->P.p1==NULL) && (strat->minim>0))
4225 {
4226 if (strat->minim==1)
4227 {
4228 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4229 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4230 }
4231 else
4232 {
4233 strat->M->m[minimcnt]=strat->P.p2;
4234 strat->P.p2=NULL;
4235 }
4236 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4237 pNext(strat->M->m[minimcnt])
4238 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4239 strat->tailRing, currRing,
4240 currRing->PolyBin);
4241 minimcnt++;
4242 }
4243
4244 // enter into S, L, and T
4245 // here we need to recompute new signatures, but those are trivial ones
4246 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4247 {
4248 enterT(strat->P, strat);
4249 // posInS only depends on the leading term
4250 strat->enterS(strat->P, pos, strat, strat->tl);
4251//#if 1
4252#ifdef DEBUGF5
4253 PrintS("ELEMENT ADDED TO GCURR DURING INTERRED: ");
4254 pWrite(pHead(strat->S[strat->sl]));
4255 pWrite(strat->sig[strat->sl]);
4256#endif
4257 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4258 }
4259 // Print("[%d]",hilbeledeg);
4260 kDeleteLcm(&strat->P);
4261 if (strat->sl>srmax) srmax = strat->sl;
4262 }
4263 else
4264 {
4265 // adds signature of the zero reduction to
4266 // strat->syz. This is the leading term of
4267 // syzygy and can be used in syzCriterion()
4268 // the signature is added if and only if the
4269 // pair was not detected by the rewritten criterion in strat->red = redSig
4270 if (strat->P.p1 == NULL && strat->minim > 0)
4271 {
4272 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4273 }
4274 }
4275
4276#ifdef KDEBUG
4277 memset(&(strat->P), 0, sizeof(strat->P));
4278#endif /* KDEBUG */
4279 }
4280 int cc = 0;
4281 while (cc<strat->tl+1)
4282 {
4283 strat->T[cc].sig = pOne();
4284 p_SetComp(strat->T[cc].sig,cc+1,currRing);
4285 strat->T[cc].sevSig = pGetShortExpVector(strat->T[cc].sig);
4286 strat->sig[cc] = strat->T[cc].sig;
4287 strat->sevSig[cc] = strat->T[cc].sevSig;
4288 strat->T[cc].is_sigsafe = TRUE;
4289 cc++;
4290 }
4291 strat->max_lower_index = strat->tl;
4292 // set current signature index of upcoming iteration step
4293 // NOTE: this needs to be set here, as otherwise initSyzRules cannot compute
4294 // the corresponding syzygy rules correctly
4295 strat->currIdx = cc+1;
4296 for (int cd=strat->Ll; cd>=0; cd--)
4297 {
4298 p_SetComp(strat->L[cd].sig,cc+1,currRing);
4299 cc++;
4300 }
4301 for (cc=strat->sl+1; cc<IDELEMS(strat->Shdl); ++cc)
4302 strat->Shdl->m[cc] = NULL;
4303 #if 0
4304 printf("\nAfter f5c sorting\n");
4305 for(int i=0;i<=strat->sl;i++)
4306 pWrite(pHead(strat->S[i]));
4307 getchar();
4308 #endif
4309//#if 1
4310#if DEBUGF5
4311 PrintS("------------------- STRAT S ---------------------\n");
4312 cc = 0;
4313 while (cc<strat->tl+1)
4314 {
4315 pWrite(pHead(strat->S[cc]));
4316 pWrite(strat->sig[cc]);
4317 printf("- - - - - -\n");
4318 cc++;
4319 }
4320 PrintS("-------------------------------------------------\n");
4321 PrintS("------------------- STRAT T ---------------------\n");
4322 cc = 0;
4323 while (cc<strat->tl+1)
4324 {
4325 pWrite(pHead(strat->T[cc].p));
4326 pWrite(strat->T[cc].sig);
4327 printf("- - - - - -\n");
4328 cc++;
4329 }
4330 PrintS("-------------------------------------------------\n");
4331 PrintS("------------------- STRAT L ---------------------\n");
4332 cc = 0;
4333 while (cc<strat->Ll+1)
4334 {
4335 pWrite(pHead(strat->L[cc].p));
4336 pWrite(pHead(strat->L[cc].p1));
4337 pWrite(pHead(strat->L[cc].p2));
4338 pWrite(strat->L[cc].sig);
4339 printf("- - - - - -\n");
4340 cc++;
4341 }
4342 PrintS("-------------------------------------------------\n");
4343 printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx);
4344#endif
4345
4346}
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:4864
int posInLF5CRing(const LSet set, int start, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6124
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 6854 of file kutil.cc.

6855{
6856 //printf("Faugere Rewritten Criterion\n");
6858 return FALSE;
6859//#if 1
6860#ifdef DEBUGF5
6861 PrintS("rewritten criterion checks: ");
6862 pWrite(sig);
6863#endif
6864 for(int k = strat->sl; k>=start; k--)
6865 {
6866//#if 1
6867#ifdef DEBUGF5
6868 PrintS("checking with: ");
6869 pWrite(strat->sig[k]);
6870 pWrite(pHead(strat->S[k]));
6871#endif
6872 if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6873 {
6874//#if 1
6875#ifdef DEBUGF5
6876 PrintS("DELETE!\n");
6877#endif
6878 strat->nrrewcrit++;
6879 return TRUE;
6880 }
6881 //k--;
6882 }
6883#ifdef DEBUGF5
6884 PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6885 for(int kk = 0; kk<strat->sl+1; kk++)
6886 {
6887 pWrite(pHead(strat->S[kk]));
6888 }
6889 PrintS("------------------------------\n");
6890#endif
6891 return FALSE;
6892}
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 11185 of file kutil.cc.

11186{
11187 assume(strat->tl<0); /* can only be called with no elements in T:
11188 i.e. after exitBuchMora */
11189 /* do not use strat->S, strat->sl as they may be out of sync*/
11190 if(!nCoeff_is_Z(currRing->cf))
11191 return;
11192 poly p,pp;
11193 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
11194 {
11195 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
11196 {
11197 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
11198 {
11199 if((i != j) && (strat->Shdl->m[i] != NULL))
11200 {
11201 p = strat->Shdl->m[i];
11202 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
11203#if HAVE_SHIFTBBA
11204 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
11205#endif
11206 ))
11207 {
11208 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
11209 if (!nEqual(dummy,p->coef))
11210 {
11211 if (nIsZero(dummy))
11212 {
11213 nDelete(&dummy);
11214 pLmDelete(&strat->Shdl->m[i]);
11215 p=strat->Shdl->m[i];
11216 }
11217 else
11218 {
11219 p_SetCoeff(p,dummy,currRing);
11220 break;
11221 }
11222 }
11223 else
11224 {
11225 nDelete(&dummy);
11226 break;
11227 }
11228 }
11229 if (p!=NULL)
11230 {
11231 pp = pNext(p);
11232 while(pp != NULL)
11233 {
11234 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
11235#if HAVE_SHIFTBBA
11236 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
11237#endif
11238 )
11239 {
11240 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
11241 if (!nEqual(dummy,pp->coef))
11242 {
11243 p_SetCoeff(pp,dummy,currRing);
11244 if(nIsZero(pp->coef))
11245 {
11246 pLmDelete(&pNext(p));
11247 pp = pNext(p);
11248 }
11249 else
11250 {
11251 p = pp;
11252 pp = pNext(p);
11253 }
11254 }
11255 else
11256 {
11257 nDelete(&dummy);
11258 p = pp;
11259 pp = pNext(p);
11260 }
11261 }
11262 else
11263 {
11264 p = pp;
11265 pp = pNext(p);
11266 }
11267 }
11268 }
11269 }
11270 }
11271 //idPrint(strat->Shdl);
11272 }
11273 }
11274 idSkipZeroes(strat->Shdl);
11275}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:816
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:628
#define nEqual(n1, n2)
Definition: numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
#define pLPLmDivisibleBy(a, b)
Definition: shiftop.h:58
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 505 of file kutil.cc.

506{
507 int j,/*k,*/p;
508
509 if (currRing->pLexOrder
511 || (strat->ak >1)
513 {
514 return;
515 }
517 if (p!=0)
518 strat->NotUsedAxis[p] = FALSE;
519 /*- the leading term of pp is a power of the p-th variable -*/
520 for (j=(currRing->N);j>0; j--)
521 {
522 if (strat->NotUsedAxis[j])
523 {
524 strat->kAllAxis=FALSE;
525 return;
526 }
527 }
528 strat->kAllAxis=TRUE;
529}
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:762

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1676 of file kstd1.cc.

1677{
1678 /* setting global variables ------------------- */
1679 strat->enterS = enterSBba;
1680 strat->red = redHoney;
1681 if (strat->honey)
1682 strat->red = redHoney;
1683 else if (currRing->pLexOrder && !strat->homog)
1684 strat->red = redLazy;
1685 else
1686 {
1687 strat->LazyPass *=4;
1688 strat->red = redHomog;
1689 }
1691 {
1692 if (rField_is_Z(currRing))
1693 strat->red = redRing_Z;
1694 else
1695 strat->red = redRing;
1696 }
1697 if (TEST_OPT_IDLIFT)
1698 strat->red=redLiftstd;
1699 if (currRing->pLexOrder && strat->honey)
1700 strat->initEcart = initEcartNormal;
1701 else
1702 strat->initEcart = initEcartBBA;
1703 if (strat->honey)
1705 else
1707// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1708// {
1709// //interred machen Aenderung
1710// strat->pOrigFDeg=pFDeg;
1711// strat->pOrigLDeg=pLDeg;
1712// //h=ggetid("ecart");
1713// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1714// //{
1715// // ecartWeights=iv2array(IDINTVEC(h));
1716// //}
1717// //else
1718// {
1719// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1720// /*uses automatic computation of the ecartWeights to set them*/
1721// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1722// }
1723// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1724// if (TEST_OPT_PROT)
1725// {
1726// for(i=1; i<=(currRing->N); i++)
1727// Print(" %d",ecartWeights[i]);
1728// PrintLn();
1729// mflush();
1730// }
1731// }
1732}
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:673
int redHoney(LObject *h, kStrategy strat)
Definition: kstd2.cc:1901
int redHomog(LObject *h, kStrategy strat)
Definition: kstd2.cc:938
int redLazy(LObject *h, kStrategy strat)
Definition: kstd2.cc:1696
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition: kutil.cc:1406
void initEcartNormal(TObject *h)
Definition: kutil.cc:1384
void initEcartBBA(TObject *h)
Definition: kutil.cc:1392
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition: kutil.cc:1399

◆ initBuchMora()

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

Definition at line 10057 of file kutil.cc.

10058{
10059 strat->interpt = BTEST1(OPT_INTERRUPT);
10060 /*- creating temp data structures------------------- -*/
10061 //strat->cp = 0; // already by skStragy()
10062 //strat->c3 = 0; // already by skStragy()
10063#ifdef HAVE_SHIFTBBA
10064 strat->cv = 0; // already by skStragy()
10065#endif
10066 strat->tail = pInit();
10067 /*- set s -*/
10068 strat->sl = -1;
10069 /*- set L -*/
10070 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10071 strat->Ll = -1;
10072 strat->L = initL(strat->Lmax);
10073 /*- set B -*/
10074 strat->Bmax = setmaxL;
10075 strat->Bl = -1;
10076 strat->B = initL();
10077 /*- set T -*/
10078 strat->tl = -1;
10079 strat->tmax = setmaxT;
10080 strat->T = initT();
10081 strat->R = initR();
10082 strat->sevT = initsevT();
10083 /*- init local data struct.---------------------------------------- -*/
10084 //strat->P.ecart=0; // already by skStragy()
10085 //strat->P.length=0; // already by skStragy()
10086 //strat->P.pLength=0; // already by skStragy()
10088 {
10089 if (strat->kNoether!=NULL)
10090 {
10091 pSetComp(strat->kNoether, strat->ak);
10092 pSetComp(strat->kNoetherTail(), strat->ak);
10093 }
10094 }
10096 {
10097 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10098 }
10099 else
10100 {
10101 if(TEST_OPT_SB_1)
10102 {
10103 int i;
10104 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10105 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10106 {
10107 P->m[i-strat->newIdeal] = F->m[i];
10108 F->m[i] = NULL;
10109 }
10110 initSSpecial(F,Q,P,strat);
10111 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10112 {
10113 F->m[i] = P->m[i-strat->newIdeal];
10114 P->m[i-strat->newIdeal] = NULL;
10115 }
10116 idDelete(&P);
10117 }
10118 else
10119 {
10120 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10121 // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
10122 }
10123 }
10124 strat->fromT = FALSE;
10126 if ((!TEST_OPT_SB_1)
10128 )
10129 {
10130 updateS(TRUE,strat);
10131 }
10132#ifdef HAVE_SHIFTBBA
10133 if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
10134#endif
10135 {
10136 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10137 strat->fromQ=NULL;
10138 }
10139 assume(kTest_TS(strat));
10140}
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:8387
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:8850
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7985
#define setmaxL
Definition: kutil.h:30
static LSet initL(int nr=setmaxL)
Definition: kutil.h:421
#define setmaxT
Definition: kutil.h:33
#define OPT_INTERRUPT
Definition: options.h:79
#define BTEST1(a)
Definition: options.h:33
#define pSetComp(p, v)
Definition: polys.h:38

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9732 of file kutil.cc.

9733{
9736 if (TEST_OPT_SB_1)
9738#ifdef HAVE_RINGS
9740 {
9742 strat->chainCrit=chainCritRing;
9743 }
9744#endif
9745#ifdef HAVE_RATGRING
9746 if (rIsRatGRing(currRing))
9747 {
9748 strat->chainCrit=chainCritPart;
9749 /* enterOnePairNormal get rational part in it */
9750 }
9751#endif
9752 if (TEST_OPT_IDLIFT
9753 && (strat->syzComp==1)
9754 && (!rIsPluralRing(currRing)))
9756
9758 strat->Gebauer = strat->homog || strat->sugarCrit;
9759 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9760 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9761 strat->pairtest = NULL;
9762 /* alway use tailreduction, except:
9763 * - in local rings, - in lex order case, -in ring over extensions */
9765 //if(rHasMixedOrdering(currRing)==2)
9766 //{
9767 // strat->noTailReduction =TRUE;
9768 //}
9769
9770#ifdef HAVE_PLURAL
9771 // and r is plural_ring
9772 // hence this holds for r a rational_plural_ring
9773 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9774 { //or it has non-quasi-comm type... later
9775 strat->sugarCrit = FALSE;
9776 strat->Gebauer = FALSE;
9777 strat->honey = FALSE;
9778 }
9779#endif
9780
9781 // Coefficient ring?
9783 {
9784 strat->sugarCrit = FALSE;
9785 strat->Gebauer = FALSE;
9786 strat->honey = FALSE;
9787 }
9788 #ifdef KDEBUG
9789 if (TEST_OPT_DEBUG)
9790 {
9791 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9792 else PrintS("ideal/module is not homogeneous\n");
9793 }
9794 #endif
9795}
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:2032
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3538
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1426
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2314
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3613
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3297
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:4089
static bool rIsSCA(const ring r)
Definition: nc.h:190
#define TEST_OPT_WEIGHTM
Definition: options.h:121
#define TEST_OPT_SUGARCRIT
Definition: options.h:107
#define TEST_OPT_NOT_SUGAR
Definition: options.h:106

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9884 of file kutil.cc.

9885{
9887 {
9888 if (strat->honey)
9889 {
9890 strat->posInL = posInL15;
9891 // ok -- here is the deal: from my experiments for Singular-2-0
9892 // I conclude that that posInT_EcartpLength is the best of
9893 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9894 // see the table at the end of this file
9895 if (TEST_OPT_OLDSTD)
9896 strat->posInT = posInT15;
9897 else
9898 strat->posInT = posInT_EcartpLength;
9899 }
9900 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9901 {
9902 strat->posInL = posInL11;
9903 strat->posInT = posInT11;
9904 }
9905 else if (TEST_OPT_INTSTRATEGY)
9906 {
9907 strat->posInL = posInL11;
9908 strat->posInT = posInT11;
9909 }
9910 else
9911 {
9912 strat->posInL = posInL0;
9913 strat->posInT = posInT0;
9914 }
9915 //if (strat->minim>0) strat->posInL =posInLSpecial;
9916 if (strat->homog)
9917 {
9918 strat->posInL = posInL110;
9919 strat->posInT = posInT110;
9920 }
9921 }
9922 else /* local/mixed ordering */
9923 {
9924 if (strat->homog)
9925 {
9926 strat->posInL = posInL11;
9927 strat->posInT = posInT11;
9928 }
9929 else
9930 {
9931 if ((currRing->order[0]==ringorder_c)
9932 ||(currRing->order[0]==ringorder_C))
9933 {
9934 strat->posInL = posInL17_c;
9935 strat->posInT = posInT17_c;
9936 }
9937 else
9938 {
9939 strat->posInL = posInL17;
9940 strat->posInT = posInT17;
9941 }
9942 }
9943 }
9944 if (strat->minim>0) strat->posInL =posInLSpecial;
9945 // for further tests only
9946 if ((BTEST1(11)) || (BTEST1(12)))
9947 strat->posInL = posInL11;
9948 else if ((BTEST1(13)) || (BTEST1(14)))
9949 strat->posInL = posInL13;
9950 else if ((BTEST1(15)) || (BTEST1(16)))
9951 strat->posInL = posInL15;
9952 else if ((BTEST1(17)) || (BTEST1(18)))
9953 strat->posInL = posInL17;
9954 if (BTEST1(11))
9955 strat->posInT = posInT11;
9956 else if (BTEST1(13))
9957 strat->posInT = posInT13;
9958 else if (BTEST1(15))
9959 strat->posInT = posInT15;
9960 else if ((BTEST1(17)))
9961 strat->posInT = posInT17;
9962 else if ((BTEST1(19)))
9963 strat->posInT = posInT19;
9964 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9965 strat->posInT = posInT1;
9967}
char posInLDependsOnLength
Definition: kutil.h:389
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6346
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5456
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5052
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4996
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5323
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:4985
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6434
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:9868
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5294
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5790
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6469
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5563
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5361
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5747
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6545
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5205
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5690
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6639
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6048
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9970 of file kutil.cc.

9971{
9973 {
9974 if (strat->honey)
9975 {
9976 strat->posInL = posInL15Ring;
9977 // ok -- here is the deal: from my experiments for Singular-2-0
9978 // I conclude that that posInT_EcartpLength is the best of
9979 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9980 // see the table at the end of this file
9981 if (TEST_OPT_OLDSTD)
9982 strat->posInT = posInT15Ring;
9983 else
9984 strat->posInT = posInT_EcartpLength;
9985 }
9986 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9987 {
9988 strat->posInL = posInL11Ring;
9989 strat->posInT = posInT11;
9990 }
9991 else if (TEST_OPT_INTSTRATEGY)
9992 {
9993 strat->posInL = posInL11Ring;
9994 strat->posInT = posInT11;
9995 }
9996 else
9997 {
9998 strat->posInL = posInL0Ring;
9999 strat->posInT = posInT0;
10000 }
10001 //if (strat->minim>0) strat->posInL =posInLSpecial;
10002 if (strat->homog)
10003 {
10004 strat->posInL = posInL110Ring;
10005 strat->posInT = posInT110Ring;
10006 }
10007 }
10008 else
10009 {
10010 if (strat->homog)
10011 {
10012 //printf("\nHere 3\n");
10013 strat->posInL = posInL11Ring;
10014 strat->posInT = posInT11Ring;
10015 }
10016 else
10017 {
10018 if ((currRing->order[0]==ringorder_c)
10019 ||(currRing->order[0]==ringorder_C))
10020 {
10021 strat->posInL = posInL17_cRing;
10022 strat->posInT = posInT17_cRing;
10023 }
10024 else
10025 {
10026 strat->posInL = posInL11Ringls;
10027 strat->posInT = posInT17Ring;
10028 }
10029 }
10030 }
10031 if (strat->minim>0) strat->posInL =posInLSpecial;
10032 // for further tests only
10033 if ((BTEST1(11)) || (BTEST1(12)))
10034 strat->posInL = posInL11Ring;
10035 else if ((BTEST1(13)) || (BTEST1(14)))
10036 strat->posInL = posInL13;
10037 else if ((BTEST1(15)) || (BTEST1(16)))
10038 strat->posInL = posInL15Ring;
10039 else if ((BTEST1(17)) || (BTEST1(18)))
10040 strat->posInL = posInL17Ring;
10041 if (BTEST1(11))
10042 strat->posInT = posInT11Ring;
10043 else if (BTEST1(13))
10044 strat->posInT = posInT13;
10045 else if (BTEST1(15))
10046 strat->posInT = posInT15Ring;
10047 else if ((BTEST1(17)))
10048 strat->posInT = posInT17Ring;
10049 else if ((BTEST1(19)))
10050 strat->posInT = posInT19;
10051 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10052 strat->posInT = posInT1;
10054}
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6589
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6703
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6090
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5247
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6387
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5816
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5088
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6160
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6504
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5415
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5517
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5624

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1392 of file kutil.cc.

1393{
1394 h->FDeg = h->pFDeg();
1395 (*h).ecart = 0;
1396 h->length=h->pLength=pLength(h->p);
1397}

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1384 of file kutil.cc.

1385{
1386 h->FDeg = h->pFDeg();
1387 h->ecart = h->pLDeg() - h->FDeg;
1388 // h->length is set by h->pLDeg
1389 h->length=h->pLength=pLength(h->p);
1390}

◆ initEcartPairBba()

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

Definition at line 1399 of file kutil.cc.

1400{
1401 Lp->FDeg = Lp->pFDeg();
1402 (*Lp).ecart = 0;
1403 (*Lp).length = 0;
1404}

◆ initEcartPairMora()

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

Definition at line 1406 of file kutil.cc.

1407{
1408 Lp->FDeg = Lp->pFDeg();
1409 (*Lp).ecart = si_max(ecartF,ecartG);
1410 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1411 (*Lp).length = 0;
1412}
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:380

◆ initenterpairs()

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

Definition at line 3902 of file kutil.cc.

3903{
3904
3905 if ((strat->syzComp==0)
3906 || (pGetComp(h)<=strat->syzComp))
3907 {
3908 int j;
3909 BOOLEAN new_pair=FALSE;
3910
3911 if (pGetComp(h)==0)
3912 {
3913 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3914 if ((isFromQ)&&(strat->fromQ!=NULL))
3915 {
3916 for (j=0; j<=k; j++)
3917 {
3918 if (!strat->fromQ[j])
3919 {
3920 new_pair=TRUE;
3921 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3922 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3923 }
3924 }
3925 }
3926 else
3927 {
3928 new_pair=TRUE;
3929 for (j=0; j<=k; j++)
3930 {
3931 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3932 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3933 }
3934 }
3935 }
3936 else
3937 {
3938 for (j=0; j<=k; j++)
3939 {
3940 if ((pGetComp(h)==pGetComp(strat->S[j]))
3941 || (pGetComp(strat->S[j])==0))
3942 {
3943 new_pair=TRUE;
3944 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3945 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3946 }
3947 }
3948 }
3949 if (new_pair)
3950 {
3951 #ifdef HAVE_RATGRING
3952 if (currRing->real_var_start>0)
3953 chainCritPart(h,ecart,strat);
3954 else
3955 #endif
3956 strat->chainCrit(h,ecart,strat);
3957 }
3958 kMergeBintoL(strat);
3959 }
3960}

◆ initHilbCrit()

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

Definition at line 9714 of file kutil.cc.

9715{
9716
9717 //if the ordering is local, then hilb criterion
9718 //can be used also if the ideal is not homogenous
9720 {
9722 *hilb=NULL;
9723 else
9724 return;
9725 }
9726 if (strat->homog!=isHomog)
9727 {
9728 *hilb=NULL;
9729 }
9730}
@ isHomog
Definition: structs.h:37

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 421 of file kutil.h.

422{ 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 7891 of file kutil.cc.

7892{
7893 int i,pos;
7894
7896 else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7897 strat->ecartS=initec(i);
7898 strat->sevS=initsevS(i);
7899 strat->S_2_R=initS_2_R(i);
7900 strat->fromQ=NULL;
7901 strat->Shdl=idInit(i,F->rank);
7902 strat->S=strat->Shdl->m;
7903 /*- put polys into S -*/
7904 if (Q!=NULL)
7905 {
7906 strat->fromQ=initec(i);
7907 memset(strat->fromQ,0,i*sizeof(int));
7908 for (i=0; i<IDELEMS(Q); i++)
7909 {
7910 if (Q->m[i]!=NULL)
7911 {
7912 LObject h;
7913 h.p = pCopy(Q->m[i]);
7915 {
7916 h.pCleardenom(); // also does remove Content
7917 }
7918 else
7919 {
7920 h.pNorm();
7921 }
7923 {
7924 deleteHC(&h, strat);
7925 }
7926 if (h.p!=NULL)
7927 {
7928 strat->initEcart(&h);
7929 if (strat->sl==-1)
7930 pos =0;
7931 else
7932 {
7933 pos = posInS(strat,strat->sl,h.p,h.ecart);
7934 }
7935 h.sev = pGetShortExpVector(h.p);
7936 strat->enterS(h,pos,strat,-1);
7937 strat->fromQ[pos]=1;
7938 }
7939 }
7940 }
7941 }
7942 for (i=0; i<IDELEMS(F); i++)
7943 {
7944 if (F->m[i]!=NULL)
7945 {
7946 LObject h;
7947 h.p = pCopy(F->m[i]);
7949 {
7950 cancelunit(&h); /*- tries to cancel a unit -*/
7951 deleteHC(&h, strat);
7952 }
7953 if (h.p!=NULL)
7954 // do not rely on the input being a SB!
7955 {
7957 {
7958 h.pCleardenom(); // also does remove Content
7959 }
7960 else
7961 {
7962 h.pNorm();
7963 }
7964 strat->initEcart(&h);
7965 if (strat->sl==-1)
7966 pos =0;
7967 else
7968 pos = posInS(strat,strat->sl,h.p,h.ecart);
7969 h.sev = pGetShortExpVector(h.p);
7970 strat->enterS(h,pos,strat,-1);
7971 }
7972 }
7973 }
7974 /*- test, if a unit is in F -*/
7975 if ((strat->sl>=0)
7976#ifdef HAVE_RINGS
7977 && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7978#endif
7979 && pIsConstant(strat->S[0]))
7980 {
7981 while (strat->sl>0) deleteInS(strat->sl,strat);
7982 }
7983}
static intset initec(const int maxnr)
Definition: kutil.cc:534
static int * initS_2_R(const int maxnr)
Definition: kutil.cc:543
static unsigned long * initsevS(const int maxnr)
Definition: kutil.cc:539
#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 1734 of file kstd1.cc.

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

10271{
10272 strat->interpt = BTEST1(OPT_INTERRUPT);
10273 //strat->kNoether=NULL; // done by skStrategy
10274 /*- creating temp data structures------------------- -*/
10275 //strat->cp = 0; // done by skStrategy
10276 //strat->c3 = 0; // done by skStrategy
10277 strat->tail = pInit();
10278 /*- set s -*/
10279 strat->sl = -1;
10280 /*- set ps -*/
10281 strat->syzl = -1;
10282 /*- set L -*/
10283 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10284 strat->Ll = -1;
10285 strat->L = initL(strat->Lmax);
10286 /*- set B -*/
10287 strat->Bmax = setmaxL;
10288 strat->Bl = -1;
10289 strat->B = initL();
10290 /*- set T -*/
10291 strat->tl = -1;
10292 strat->tmax = setmaxT;
10293 strat->T = initT();
10294 strat->R = initR();
10295 strat->sevT = initsevT();
10296 /*- init local data struct.---------------------------------------- -*/
10297 //strat->P.ecart=0; // done by skStrategy
10298 //strat->P.length=0; // done by skStrategy
10300 {
10301 if (strat->kNoether!=NULL)
10302 {
10303 pSetComp(strat->kNoether, strat->ak);
10304 pSetComp(strat->kNoetherTail(), strat->ak);
10305 }
10306 }
10308 {
10309 /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10310 }
10311 else
10312 {
10313 if(TEST_OPT_SB_1)
10314 {
10315 int i;
10316 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10317 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10318 {
10319 P->m[i-strat->newIdeal] = F->m[i];
10320 F->m[i] = NULL;
10321 }
10322 initSSpecialSba(F,Q,P,strat);
10323 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10324 {
10325 F->m[i] = P->m[i-strat->newIdeal];
10326 P->m[i-strat->newIdeal] = NULL;
10327 }
10328 idDelete(&P);
10329 }
10330 else
10331 {
10332 initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10333 }
10334 }
10335 //strat->fromT = FALSE; // done by skStrategy
10336 if (!TEST_OPT_SB_1)
10337 {
10338 if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10339 }
10340 //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10341 //strat->fromQ=NULL;
10342 assume(kTest_TS(strat));
10343}
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8082
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8531

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9797 of file kutil.cc.

9798{
9799 //strat->enterOnePair=enterOnePairNormal;
9801 //strat->chainCrit=chainCritNormal;
9802 strat->chainCrit = chainCritSig;
9803 /******************************************
9804 * rewCrit1 and rewCrit2 are already set in
9805 * kSba() in kstd1.cc
9806 *****************************************/
9807 //strat->rewCrit1 = faugereRewCriterion;
9808 if (strat->sbaOrder == 1)
9809 {
9810 strat->syzCrit = syzCriterionInc;
9811 }
9812 else
9813 {
9814 strat->syzCrit = syzCriterion;
9815 }
9816#ifdef HAVE_RINGS
9818 {
9820 strat->chainCrit=chainCritRing;
9821 }
9822#endif
9823#ifdef HAVE_RATGRING
9824 if (rIsRatGRing(currRing))
9825 {
9826 strat->chainCrit=chainCritPart;
9827 /* enterOnePairNormal get rational part in it */
9828 }
9829#endif
9830
9832 strat->Gebauer = strat->homog || strat->sugarCrit;
9833 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9834 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9835 strat->pairtest = NULL;
9836 /* alway use tailreduction, except:
9837 * - in local rings, - in lex order case, -in ring over extensions */
9840
9841#ifdef HAVE_PLURAL
9842 // and r is plural_ring
9843 // hence this holds for r a rational_plural_ring
9844 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9845 { //or it has non-quasi-comm type... later
9846 strat->sugarCrit = FALSE;
9847 strat->Gebauer = FALSE;
9848 strat->honey = FALSE;
9849 }
9850#endif
9851
9852 // Coefficient ring?
9854 {
9855 strat->sugarCrit = FALSE;
9856 strat->Gebauer = FALSE ;
9857 strat->honey = FALSE;
9858 }
9859 #ifdef KDEBUG
9860 if (TEST_OPT_DEBUG)
9861 {
9862 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9863 else PrintS("ideal/module is not homogeneous\n");
9864 }
9865 #endif
9866}
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:6805
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3554
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6770

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 10168 of file kutil.cc.

10169{
10171 {
10172 if (strat->honey)
10173 {
10174 strat->posInL = posInL15;
10175 // ok -- here is the deal: from my experiments for Singular-2-0
10176 // I conclude that that posInT_EcartpLength is the best of
10177 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10178 // see the table at the end of this file
10179 if (TEST_OPT_OLDSTD)
10180 strat->posInT = posInT15;
10181 else
10182 strat->posInT = posInT_EcartpLength;
10183 }
10184 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10185 {
10186 strat->posInL = posInL11;
10187 strat->posInT = posInT11;
10188 }
10189 else if (TEST_OPT_INTSTRATEGY)
10190 {
10191 strat->posInL = posInL11;
10192 strat->posInT = posInT11;
10193 }
10194 else
10195 {
10196 strat->posInL = posInL0;
10197 strat->posInT = posInT0;
10198 }
10199 //if (strat->minim>0) strat->posInL =posInLSpecial;
10200 if (strat->homog)
10201 {
10202 strat->posInL = posInL110;
10203 strat->posInT = posInT110;
10204 }
10205 }
10206 else
10207 {
10208 if (strat->homog)
10209 {
10210 strat->posInL = posInL11;
10211 strat->posInT = posInT11;
10212 }
10213 else
10214 {
10215 if ((currRing->order[0]==ringorder_c)
10216 ||(currRing->order[0]==ringorder_C))
10217 {
10218 strat->posInL = posInL17_c;
10219 strat->posInT = posInT17_c;
10220 }
10221 else
10222 {
10223 strat->posInL = posInL17;
10224 strat->posInT = posInT17;
10225 }
10226 }
10227 }
10228 if (strat->minim>0) strat->posInL =posInLSpecial;
10229 // for further tests only
10230 if ((BTEST1(11)) || (BTEST1(12)))
10231 strat->posInL = posInL11;
10232 else if ((BTEST1(13)) || (BTEST1(14)))
10233 strat->posInL = posInL13;
10234 else if ((BTEST1(15)) || (BTEST1(16)))
10235 strat->posInL = posInL15;
10236 else if ((BTEST1(17)) || (BTEST1(18)))
10237 strat->posInL = posInL17;
10238 if (BTEST1(11))
10239 strat->posInT = posInT11;
10240 else if (BTEST1(13))
10241 strat->posInT = posInT13;
10242 else if (BTEST1(15))
10243 strat->posInT = posInT15;
10244 else if ((BTEST1(17)))
10245 strat->posInT = posInT17;
10246 else if ((BTEST1(19)))
10247 strat->posInT = posInT19;
10248 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10249 strat->posInT = posInT1;
10251 {
10252 strat->posInL = posInL11Ring;
10253 if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
10254 strat->posInL = posInL11Ringls;
10255 strat->posInT = posInT11;
10256 }
10258 strat->posInLSba = posInLSig;
10259 //strat->posInL = posInLSig;
10260 strat->posInL = posInLF5C;
10261 /*
10262 if (rField_is_Ring(currRing))
10263 {
10264 strat->posInLSba = posInLSigRing;
10265 strat->posInL = posInL11Ring;
10266 }*/
10267 //strat->posInT = posInTSig;
10268}
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5848
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:6036

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

7986{
7987 int i,pos;
7988
7990 else i=setmaxT;
7991 strat->ecartS=initec(i);
7992 strat->sevS=initsevS(i);
7993 strat->S_2_R=initS_2_R(i);
7994 strat->fromQ=NULL;
7995 strat->Shdl=idInit(i,F->rank);
7996 strat->S=strat->Shdl->m;
7997 /*- put polys into S -*/
7998 if (Q!=NULL)
7999 {
8000 strat->fromQ=initec(i);
8001 memset(strat->fromQ,0,i*sizeof(int));
8002 for (i=0; i<IDELEMS(Q); i++)
8003 {
8004 if (Q->m[i]!=NULL)
8005 {
8006 LObject h;
8007 h.p = pCopy(Q->m[i]);
8009 {
8010 deleteHC(&h,strat);
8011 }
8013 {
8014 h.pCleardenom(); // also does remove Content
8015 }
8016 else
8017 {
8018 h.pNorm();
8019 }
8020 if (h.p!=NULL)
8021 {
8022 strat->initEcart(&h);
8023 if (strat->sl==-1)
8024 pos =0;
8025 else
8026 {
8027 pos = posInS(strat,strat->sl,h.p,h.ecart);
8028 }
8029 h.sev = pGetShortExpVector(h.p);
8030 strat->enterS(h,pos,strat,-1);
8031 strat->fromQ[pos]=1;
8032 }
8033 }
8034 }
8035 }
8036 for (i=0; i<IDELEMS(F); i++)
8037 {
8038 if (F->m[i]!=NULL)
8039 {
8040 LObject h;
8041 h.p = pCopy(F->m[i]);
8042 if (h.p!=NULL)
8043 {
8045 {
8046 cancelunit(&h); /*- tries to cancel a unit -*/
8047 deleteHC(&h, strat);
8048 }
8049 if (h.p!=NULL)
8050 {
8052 {
8053 h.pCleardenom(); // also does remove Content
8054 }
8055 else
8056 {
8057 h.pNorm();
8058 }
8059 strat->initEcart(&h);
8060 if (strat->Ll==-1)
8061 pos =0;
8062 else
8063 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
8064 h.sev = pGetShortExpVector(h.p);
8065 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8066 }
8067 }
8068 }
8069 }
8070 /*- test, if a unit is in F -*/
8071
8072 if ((strat->Ll>=0)
8073#ifdef HAVE_RINGS
8074 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8075#endif
8076 && pIsConstant(strat->L[strat->Ll].p))
8077 {
8078 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8079 }
8080}

◆ initSLSba()

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

Definition at line 8082 of file kutil.cc.

8083{
8084 int i,pos;
8086 else i=setmaxT;
8087 strat->ecartS = initec(i);
8088 strat->sevS = initsevS(i);
8089 strat->sevSig = initsevS(i);
8090 strat->S_2_R = initS_2_R(i);
8091 strat->fromQ = NULL;
8092 strat->Shdl = idInit(i,F->rank);
8093 strat->S = strat->Shdl->m;
8094 strat->sig = (poly *)omAlloc0(i*sizeof(poly));
8095 if (strat->sbaOrder != 1)
8096 {
8097 strat->syz = (poly *)omAlloc0(i*sizeof(poly));
8098 strat->sevSyz = initsevS(i);
8099 strat->syzmax = i;
8100 strat->syzl = 0;
8101 }
8102 /*- put polys into S -*/
8103 if (Q!=NULL)
8104 {
8105 strat->fromQ=initec(i);
8106 memset(strat->fromQ,0,i*sizeof(int));
8107 for (i=0; i<IDELEMS(Q); i++)
8108 {
8109 if (Q->m[i]!=NULL)
8110 {
8111 LObject h;
8112 h.p = pCopy(Q->m[i]);
8114 {
8115 deleteHC(&h,strat);
8116 }
8118 {
8119 h.pCleardenom(); // also does remove Content
8120 }
8121 else
8122 {
8123 h.pNorm();
8124 }
8125 if (h.p!=NULL)
8126 {
8127 strat->initEcart(&h);
8128 if (strat->sl==-1)
8129 pos =0;
8130 else
8131 {
8132 pos = posInS(strat,strat->sl,h.p,h.ecart);
8133 }
8134 h.sev = pGetShortExpVector(h.p);
8135 strat->enterS(h,pos,strat,-1);
8136 strat->fromQ[pos]=1;
8137 }
8138 }
8139 }
8140 }
8141 for (i=0; i<IDELEMS(F); i++)
8142 {
8143 if (F->m[i]!=NULL)
8144 {
8145 LObject h;
8146 h.p = pCopy(F->m[i]);
8147 h.sig = pOne();
8148 //h.sig = pInit();
8149 //p_SetCoeff(h.sig,nInit(1),currRing);
8150 p_SetComp(h.sig,i+1,currRing);
8151 // if we are working with the Schreyer order we generate it
8152 // by multiplying the initial signatures with the leading monomial
8153 // of the corresponding initial polynomials generating the ideal
8154 // => we can keep the underlying monomial order and get a Schreyer
8155 // order without any bigger overhead
8156 if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
8157 {
8158 p_ExpVectorAdd (h.sig,F->m[i],currRing);
8159 }
8160 h.sevSig = pGetShortExpVector(h.sig);
8161#ifdef DEBUGF5
8162 pWrite(h.p);
8163 pWrite(h.sig);
8164#endif
8165 if (h.p!=NULL)
8166 {
8168 {
8169 cancelunit(&h); /*- tries to cancel a unit -*/
8170 deleteHC(&h, strat);
8171 }
8172 if (h.p!=NULL)
8173 {
8175 {
8176 h.pCleardenom(); // also does remove Content
8177 }
8178 else
8179 {
8180 h.pNorm();
8181 }
8182 strat->initEcart(&h);
8183 if (strat->Ll==-1)
8184 pos =0;
8185 else
8186 pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
8187 h.sev = pGetShortExpVector(h.p);
8188 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8189 }
8190 }
8191 /*
8192 if (strat->sbaOrder != 1)
8193 {
8194 for(j=0;j<i;j++)
8195 {
8196 strat->syz[ctr] = pCopy(F->m[j]);
8197 p_SetCompP(strat->syz[ctr],i+1,currRing);
8198 // add LM(F->m[i]) to the signature to get a Schreyer order
8199 // without changing the underlying polynomial ring at all
8200 p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
8201 // since p_Add_q() destroys all input
8202 // data we need to recreate help
8203 // each time
8204 poly help = pCopy(F->m[i]);
8205 p_SetCompP(help,j+1,currRing);
8206 pWrite(strat->syz[ctr]);
8207 pWrite(help);
8208 printf("%d\n",pLmCmp(strat->syz[ctr],help));
8209 strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
8210 printf("%d. SYZ ",ctr);
8211 pWrite(strat->syz[ctr]);
8212 strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
8213 ctr++;
8214 }
8215 strat->syzl = ps;
8216 }
8217 */
8218 }
8219 }
8220 /*- test, if a unit is in F -*/
8221
8222 if ((strat->Ll>=0)
8223#ifdef HAVE_RINGS
8224 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8225#endif
8226 && pIsConstant(strat->L[strat->Ll].p))
8227 {
8228 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8229 }
8230}
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1411

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8232 of file kutil.cc.

8233{
8234 if( strat->S[0] )
8235 {
8236 if( strat->S[1] && !rField_is_Ring(currRing))
8237 {
8238 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
8239 omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
8240 omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
8241 }
8242 int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
8243 /************************************************************
8244 * computing the length of the syzygy array needed
8245 ***********************************************************/
8246 for(i=1; i<=strat->sl; i++)
8247 {
8248 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8249 {
8250 ps += i;
8251 }
8252 }
8253 ps += strat->sl+1;
8254 //comp = pGetComp (strat->P.sig);
8255 comp = strat->currIdx;
8256 strat->syzIdx = initec(comp);
8257 strat->sevSyz = initsevS(ps);
8258 strat->syz = (poly *)omAlloc(ps*sizeof(poly));
8259 strat->syzmax = ps;
8260 strat->syzl = 0;
8261 strat->syzidxmax = comp;
8262#if defined(DEBUGF5) || defined(DEBUGF51)
8263 PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
8264#endif
8265 i = 1;
8266 j = 0;
8267 /************************************************************
8268 * generating the leading terms of the principal syzygies
8269 ***********************************************************/
8270 while (i <= strat->sl)
8271 {
8272 /**********************************************************
8273 * principal syzygies start with component index 2
8274 * the array syzIdx starts with index 0
8275 * => the rules for a signature with component comp start
8276 * at strat->syz[strat->syzIdx[comp-2]] !
8277 *********************************************************/
8278 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8279 {
8280 comp = pGetComp(strat->sig[i]);
8281 comp_old = pGetComp(strat->sig[i-1]);
8282 diff = comp - comp_old - 1;
8283 // diff should be zero, but sometimes also the initial generating
8284 // elements of the input ideal reduce to zero. then there is an
8285 // index-gap between the signatures. for these inbetween signatures we
8286 // can safely set syzIdx[j] = 0 as no such element will be ever computed
8287 // in the following.
8288 // doing this, we keep the relation "j = comp - 2" alive, which makes
8289 // jumps way easier when checking criteria
8290 while (diff>0)
8291 {
8292 strat->syzIdx[j] = 0;
8293 diff--;
8294 j++;
8295 }
8296 strat->syzIdx[j] = ctr;
8297 j++;
8298 LObject Q;
8299 int pos;
8300 for (k = 0; k<i; k++)
8301 {
8302 Q.sig = pOne();
8305 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8306 p_SetCompP (Q.sig, comp, currRing);
8307 poly q = p_One(currRing);
8310 p_ExpVectorCopy(q,strat->S[i],currRing);
8311 q = p_Neg (q, currRing);
8312 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8313 Q.sig = p_Add_q (Q.sig, q, currRing);
8314 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8315 pos = posInSyz(strat, Q.sig);
8316 enterSyz(Q, strat, pos);
8317 ctr++;
8318 }
8319 }
8320 i++;
8321 }
8322 /**************************************************************
8323 * add syzygies for upcoming first element of new iteration step
8324 **************************************************************/
8325 comp = strat->currIdx;
8326 comp_old = pGetComp(strat->sig[i-1]);
8327 diff = comp - comp_old - 1;
8328 // diff should be zero, but sometimes also the initial generating
8329 // elements of the input ideal reduce to zero. then there is an
8330 // index-gap between the signatures. for these inbetween signatures we
8331 // can safely set syzIdx[j] = 0 as no such element will be ever computed
8332 // in the following.
8333 // doing this, we keep the relation "j = comp - 2" alive, which makes
8334 // jumps way easier when checking criteria
8335 while (diff>0)
8336 {
8337 strat->syzIdx[j] = 0;
8338 diff--;
8339 j++;
8340 }
8341 strat->syzIdx[j] = ctr;
8342 LObject Q;
8343 int pos;
8344 for (k = 0; k<strat->sl+1; k++)
8345 {
8346 Q.sig = pOne();
8349 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8350 p_SetCompP (Q.sig, comp, currRing);
8351 poly q = p_One(currRing);
8353 p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8354 p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8355 q = p_Neg (q, currRing);
8356 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8357 Q.sig = p_Add_q (Q.sig, q, currRing);
8358 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8359 pos = posInSyz(strat, Q.sig);
8360 enterSyz(Q, strat, pos);
8361 ctr++;
8362 }
8363//#if 1
8364#ifdef DEBUGF5
8365 PrintS("Principal syzygies:\n");
8366 Print("syzl %d\n",strat->syzl);
8367 Print("syzmax %d\n",strat->syzmax);
8368 Print("ps %d\n",ps);
8369 PrintS("--------------------------------\n");
8370 for(i=0;i<=strat->syzl-1;i++)
8371 {
8372 Print("%d - ",i);
8373 pWrite(strat->syz[i]);
8374 }
8375 for(i=0;i<strat->currIdx;i++)
8376 {
8377 Print("%d - %d\n",i,strat->syzIdx[i]);
8378 }
8379 PrintS("--------------------------------\n");
8380#endif
8381 }
8382}
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9636
int posInSyz(const kStrategy strat, poly sig)
Definition: kutil.cc:6008
#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:4846
poly p_One(const ring r)
Definition: p_polys.cc:1313
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1107
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:936
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition: p_polys.h:1313
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

◆ k_GetLeadTerms()

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

Definition at line 1029 of file kInline.h.

1031{
1032 p_LmCheckPolyRing(p1, p_r);
1033 p_LmCheckPolyRing(p2, p_r);
1034
1035 int i;
1036 long x;
1037 m1 = p_Init(m_r,m_r->PolyBin);
1038 m2 = p_Init(m_r,m_r->PolyBin);
1039
1040 for (i = p_r->N; i; i--)
1041 {
1042 x = p_GetExpDiff(p1, p2, i, p_r);
1043 if (x > 0)
1044 {
1045 if (x > (long) m_r->bitmask) goto false_return;
1046 p_SetExp(m2,i,x, m_r);
1047 p_SetExp(m1,i,0, m_r);
1048 }
1049 else
1050 {
1051 if (-x > (long) m_r->bitmask) goto false_return;
1052 p_SetExp(m1,i,-x, m_r);
1053 p_SetExp(m2,i,0, m_r);
1054 }
1055 }
1056
1057 p_Setm(m1, m_r);
1058 p_Setm(m2, m_r);
1059 return TRUE;
1060
1061 false_return:
1062 p_LmFree(m1, m_r);
1063 p_LmFree(m2, m_r);
1064 m1 = m2 = NULL;
1065 return FALSE;
1066}
Variable x
Definition: cfModGcd.cc:4082
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:635
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc: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:488
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1320

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

1074{
1075 p_LmCheckPolyRing(p1, leadRing);
1076 p_LmCheckPolyRing(p2, leadRing);
1077
1078 int i;
1079 int x;
1080 int e1;
1081 int e2;
1082 int s;
1083 m1 = p_Init(tailRing,tailRing->PolyBin);
1084 m2 = p_Init(tailRing,tailRing->PolyBin);
1085 lcm = p_Init(leadRing,leadRing->PolyBin);
1086
1087 for (i = leadRing->N; i>=0; i--)
1088 {
1089 e1 = p_GetExp(p1,i,leadRing);
1090 e2 = p_GetExp(p2,i,leadRing);
1091 x = e1 - e2;
1092 if (x > 0)
1093 {
1094 p_SetExp(m2,i,x, tailRing);
1095 //p_SetExp(m1,i,0, tailRing); // done by p_Init
1096 s = e1;
1097 }
1098 else if (x<0)
1099 {
1100 p_SetExp(m1,i,-x, tailRing);
1101 //p_SetExp(m2,i,0, tailRing); // done by p_Init
1102 s = e2;
1103 }
1104 else
1105 s = e1; // e1==e2
1106 p_SetExp(lcm,i,s, leadRing);
1107 }
1108
1109 p_Setm(m1, tailRing);
1110 p_Setm(m2, tailRing);
1111 p_Setm(lcm, leadRing);
1112}
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 1002 of file kInline.h.

1003{
1004 return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
1005}

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 970 of file kInline.h.

971{
972
973 poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
974 pNext(t_p) = pNext(p);
975 pSetCoeff0(t_p, pGetCoeff(p));
976 return t_p;
977}
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1335

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1007 of file kInline.h.

1008{
1009 return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
1010}
KINLINE poly k_LmInit_tailRing_2_currRing(poly t_p, ring tailRing, omBin lmBin)
Definition: kInline.h:979

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 979 of file kInline.h.

980{
981 poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
982 pNext(p) = pNext(t_p);
983 pSetCoeff0(p, pGetCoeff(t_p));
984 return p;
985}

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 1012 of file kInline.h.

1013{
1014 return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
1015}
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:988

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 988 of file kInline.h.

989{
990 poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
992 return np;
993}

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1017 of file kInline.h.

1018{
1019 return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
1020}
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:995

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 995 of file kInline.h.

996{
997 poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
998 p_LmFree(p, tailRing);
999 return np;
1000}

◆ kCheckSpolyCreation()

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

Definition at line 10791 of file kutil.cc.

10792{
10793 if (strat->overflow) return FALSE;
10794 assume(L->p1 != NULL && L->p2 != NULL);
10795 // shift changes: from 0 to -1
10796 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10797 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10798
10799 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10800 return FALSE;
10801 // shift changes: extra case inserted
10802 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10803 {
10804 return TRUE;
10805 }
10806 poly p1_max=NULL;
10807 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10808 poly p2_max=NULL;
10809 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10810
10811 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10812 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10813 {
10814 p_LmFree(m1, strat->tailRing);
10815 p_LmFree(m2, strat->tailRing);
10816 m1 = NULL;
10817 m2 = NULL;
10818 return FALSE;
10819 }
10820 return TRUE;
10821}
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:1029
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:2046

◆ kCheckStrongCreation()

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

Definition at line 10830 of file kutil.cc.

10831{
10832 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10833 //assume(strat->tailRing != currRing);
10834
10835 poly p1_max = (strat->R[atR])->max_exp;
10836 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10837
10838 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10839 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10840 {
10841 return FALSE;
10842 }
10843 return TRUE;
10844}

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11817 of file kutil.cc.

11818{
11819 PrintS("red: ");
11820 if (strat->red==redFirst) PrintS("redFirst\n");
11821 else if (strat->red==redHoney) PrintS("redHoney\n");
11822 else if (strat->red==redEcart) PrintS("redEcart\n");
11823 else if (strat->red==redHomog) PrintS("redHomog\n");
11824 else if (strat->red==redLazy) PrintS("redLazy\n");
11825 else if (strat->red==redLiftstd) PrintS("redLiftstd\n");
11826 else Print("%p\n",(void*)strat->red);
11827 PrintS("posInT: ");
11828 if (strat->posInT==posInT0) PrintS("posInT0\n");
11829 else if (strat->posInT==posInT1) PrintS("posInT1\n");
11830 else if (strat->posInT==posInT11) PrintS("posInT11\n");
11831 else if (strat->posInT==posInT110) PrintS("posInT110\n");
11832 else if (strat->posInT==posInT13) PrintS("posInT13\n");
11833 else if (strat->posInT==posInT15) PrintS("posInT15\n");
11834 else if (strat->posInT==posInT17) PrintS("posInT17\n");
11835 else if (strat->posInT==posInT17_c) PrintS("posInT17_c\n");
11836 else if (strat->posInT==posInT19) PrintS("posInT19\n");
11837 else if (strat->posInT==posInT2) PrintS("posInT2\n");
11838 #ifdef HAVE_RINGS
11839 else if (strat->posInT==posInT11Ring) PrintS("posInT11Ring\n");
11840 else if (strat->posInT==posInT110Ring) PrintS("posInT110Ring\n");
11841 else if (strat->posInT==posInT15Ring) PrintS("posInT15Ring\n");
11842 else if (strat->posInT==posInT17Ring) PrintS("posInT17Ring\n");
11843 else if (strat->posInT==posInT17_cRing) PrintS("posInT17_cRing\n");
11844 #endif
11845#ifdef HAVE_MORE_POS_IN_T
11846 else if (strat->posInT==posInT_EcartFDegpLength) PrintS("posInT_EcartFDegpLength\n");
11847 else if (strat->posInT==posInT_FDegpLength) PrintS("posInT_FDegpLength\n");
11848 else if (strat->posInT==posInT_pLength) PrintS("posInT_pLength\n");
11849#endif
11850 else if (strat->posInT==posInT_EcartpLength) PrintS("posInT_EcartpLength\n");
11851 else if (strat->posInT==posInTrg0) PrintS("posInTrg0\n");
11852 else Print("%p\n",(void*)strat->posInT);
11853 PrintS("posInL: ");
11854 if (strat->posInL==posInL0) PrintS("posInL0\n");
11855 else if (strat->posInL==posInL10) PrintS("posInL10\n");
11856 else if (strat->posInL==posInL11) PrintS("posInL11\n");
11857 else if (strat->posInL==posInL110) PrintS("posInL110\n");
11858 else if (strat->posInL==posInL13) PrintS("posInL13\n");
11859 else if (strat->posInL==posInL15) PrintS("posInL15\n");
11860 else if (strat->posInL==posInL17) PrintS("posInL17\n");
11861 else if (strat->posInL==posInL17_c) PrintS("posInL17_c\n");
11862 #ifdef HAVE_RINGS
11863 else if (strat->posInL==posInL0) PrintS("posInL0Ring\n");
11864 else if (strat->posInL==posInL11Ring) PrintS("posInL11Ring\n");
11865 else if (strat->posInL==posInL11Ringls) PrintS("posInL11Ringls\n");
11866 else if (strat->posInL==posInL110Ring) PrintS("posInL110Ring\n");
11867 else if (strat->posInL==posInL15Ring) PrintS("posInL15Ring\n");
11868 else if (strat->posInL==posInL17Ring) PrintS("posInL17Ring\n");
11869 else if (strat->posInL==posInL17_cRing) PrintS("posInL17_cRing\n");
11870 #endif
11871 else if (strat->posInL==posInLSpecial) PrintS("posInLSpecial\n");
11872 else if (strat->posInL==posInLrg0) PrintS("posInLrg0\n");
11873 else Print("%p\n",(void*)strat->posInL);
11874 PrintS("enterS: ");
11875 if (strat->enterS==enterSBba) PrintS("enterSBba\n");
11876 else if (strat->enterS==enterSMora) PrintS("enterSMora\n");
11877 else if (strat->enterS==enterSMoraNF) PrintS("enterSMoraNF\n");
11878 else Print("%p\n",(void*)strat->enterS);
11879 PrintS("initEcart: ");
11880 if (strat->initEcart==initEcartBBA) PrintS("initEcartBBA\n");
11881 else if (strat->initEcart==initEcartNormal) PrintS("initEcartNormal\n");
11882 else Print("%p\n",(void*)strat->initEcart);
11883 PrintS("initEcartPair: ");
11884 if (strat->initEcartPair==initEcartPairBba) PrintS("initEcartPairBba\n");
11885 else if (strat->initEcartPair==initEcartPairMora) PrintS("initEcartPairMora\n");
11886 else Print("%p\n",(void*)strat->initEcartPair);
11887 Print("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11888 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11889 Print("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11890 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11891 PrintS("chainCrit: ");
11892 if (strat->chainCrit==chainCritNormal) PrintS("chainCritNormal\n");
11893 else if (strat->chainCrit==chainCritOpt_1) PrintS("chainCritOpt_1\n");
11894 else Print("%p\n",(void*)strat->chainCrit);
11895 Print("posInLDependsOnLength=%d\n",
11896 strat->posInLDependsOnLength);
11898 PrintS("LDeg: ");
11899 if (currRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11900 else if (currRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11901 else if (currRing->pLDeg==pLDegb) PrintS("pLDegb");
11902 else if (currRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11903 else if (currRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11904 else if (currRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11905 else if (currRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11906 else if (currRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11907 else if (currRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11908 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11909 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11910 else if (currRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11911 else Print("? (%lx)", (long)currRing->pLDeg);
11912 PrintS(" / ");
11913 if (strat->tailRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11914 else if (strat->tailRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11915 else if (strat->tailRing->pLDeg==pLDegb) PrintS("pLDegb");
11916 else if (strat->tailRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11917 else if (strat->tailRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11918 else if (strat->tailRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11919 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11920 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11921 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11922 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11923 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11924 else if (strat->tailRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11925 else Print("? (%lx)", (long)strat->tailRing->pLDeg);
11926 PrintLn();
11927 PrintS("currRing->pFDeg: ");
11928 if (currRing->pFDeg==p_Totaldegree) PrintS("p_Totaldegree");
11929 else if (currRing->pFDeg==p_WFirstTotalDegree) PrintS("pWFirstTotalDegree");
11930 else if (currRing->pFDeg==p_Deg) PrintS("p_Deg");
11931 else if (currRing->pFDeg==kHomModDeg) PrintS("kHomModDeg");
11932 else if (currRing->pFDeg==totaldegreeWecart) PrintS("totaldegreeWecart");
11933 else if (currRing->pFDeg==p_WTotaldegree) PrintS("p_WTotaldegree");
11934 else Print("? (%lx)", (long)currRing->pFDeg);
11935 PrintLn();
11936 Print(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11938 Print(" degBound: %d\n", Kstd1_deg);
11939
11940 if( ecartWeights != NULL )
11941 {
11942 PrintS("ecartWeights: ");
11943 for (int i = rVar(currRing); i > 0; i--)
11944 Print("%hd ", ecartWeights[i]);
11945 PrintLn();
11947 }
11948
11949#ifndef SING_NDEBUG
11951#endif
11952}
int LazyDegree
Definition: kutil.h:353
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1352
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2420
int posInTrg0(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5129
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:1668
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5024
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11783
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11692
VAR int Kstd1_deg
Definition: kutil.cc:247
int posInLrg0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6262
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1615
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11746
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:1507
void rDebugPrint(const ring r)
Definition: ring.cc:4164
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:724

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 885 of file kutil.h.

886{
887 if (P->lcm!=NULL)
888 {
889 #ifdef HAVE_RINGS
891 pLmDelete(P->lcm);
892 else
893 #endif
894 pLmFree(P->lcm);
895 P->lcm=NULL;
896 }
897}

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6989 of file kutil.cc.

6990{
6991 int j = 0;
6992 const unsigned long not_sev = ~L->sev;
6993 const unsigned long* sev = strat->sevS;
6994 poly p;
6995 ring r;
6996 L->GetLm(p, r);
6997
6998 assume(~not_sev == p_GetShortExpVector(p, r));
6999
7000 if (r == currRing)
7001 {
7002 if(!rField_is_Ring(r))
7003 {
7004 loop
7005 {
7006 if (j > end_pos) return NULL;
7007 #if defined(PDEBUG) || defined(PDIV_DEBUG)
7008 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7009 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7010 {
7011 break;
7012 }
7013 #else
7014 if (!(sev[j] & not_sev) &&
7015 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7016 p_LmDivisibleBy(strat->S[j], p, r))
7017 {
7018 break;
7019 }
7020 #endif
7021 j++;
7022 }
7023 }
7024 #ifdef HAVE_RINGS
7025 else
7026 {
7027 loop
7028 {
7029 if (j > end_pos) return NULL;
7030 #if defined(PDEBUG) || defined(PDIV_DEBUG)
7031 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7032 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7033 {
7034 break;
7035 }
7036 #else
7037 if (!(sev[j] & not_sev) &&
7038 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7039 p_LmDivisibleBy(strat->S[j], p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7040 {
7041 break;
7042 }
7043 #endif
7044 j++;
7045 }
7046 }
7047 #endif
7048 // if called from NF, T objects do not exist:
7049 if (strat->tl < 0 || strat->S_2_R[j] == -1)
7050 {
7051 T->Set(strat->S[j], r, strat->tailRing);
7052 assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
7053 return T;
7054 }
7055 else
7056 {
7057///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
7058///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
7059// assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
7060 return strat->S_2_T(j);
7061 }
7062 }
7063 else
7064 {
7065 TObject* t;
7066 if(!rField_is_Ring(r))
7067 {
7068 loop
7069 {
7070 if (j > end_pos) return NULL;
7071 assume(strat->S_2_R[j] != -1);
7072 #if defined(PDEBUG) || defined(PDIV_DEBUG)
7073 t = strat->S_2_T(j);
7074 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7075 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7076 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7077 {
7078 t->pLength=pLength(t->t_p);
7079 return t;
7080 }
7081 #else
7082 if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7083 {
7084 t = strat->S_2_T(j);
7085 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7086 if (p_LmDivisibleBy(t->t_p, p, r))
7087 {
7088 t->pLength=pLength(t->t_p);
7089 return t;
7090 }
7091 }
7092 #endif
7093 j++;
7094 }
7095 }
7096 #ifdef HAVE_RINGS
7097 else
7098 {
7099 loop
7100 {
7101 if (j > end_pos) return NULL;
7102 assume(strat->S_2_R[j] != -1);
7103 #if defined(PDEBUG) || defined(PDIV_DEBUG)
7104 t = strat->S_2_T(j);
7105 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7106 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7107 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7108 {
7109 t->pLength=pLength(t->t_p);
7110 return t;
7111 }
7112 #else
7113 if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7114 {
7115 t = strat->S_2_T(j);
7116 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7117 if (p_LmDivisibleBy(t->t_p, p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7118 {
7119 t->pLength=pLength(t->t_p);
7120 return t;
7121 }
7122 }
7123 #endif
7124 j++;
7125 }
7126 }
7127 #endif
7128 }
7129}
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 290 of file kstd2.cc.

291{
292 unsigned long not_sev = ~L->sev;
293 int j = start;
294
295 const TSet T=strat->T;
296 const unsigned long* sevT=strat->sevT;
297 const ring r=currRing;
298 const BOOLEAN is_Ring=rField_is_Ring(r);
299 if (L->p!=NULL)
300 {
301 const poly p=L->p;
302
303 pAssume(~not_sev == p_GetShortExpVector(p, r));
304
305 if(is_Ring)
306 {
307 loop
308 {
309 if (j > strat->tl) return -1;
310#if defined(PDEBUG) || defined(PDIV_DEBUG)
311 if ((T[j].p!=NULL)
312 && p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
313 {
314 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
315 return j;
316 }
317#else
318 if (!(sevT[j] & not_sev)
319 && (T[j].p!=NULL)
320 && p_LmDivisibleBy(T[j].p, p, r))
321 {
322 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
323 return j;
324 }
325#endif
326 j++;
327 }
328 }
329 else
330 {
331 loop
332 {
333 if (j > strat->tl) return -1;
334#if defined(PDEBUG) || defined(PDIV_DEBUG)
335 if ((T[j].p!=NULL)
336 && p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
337 {
338 return j;
339 }
340#else
341 if (!(sevT[j] & not_sev)
342 && (T[j].p!=NULL)
343 && p_LmDivisibleBy(T[j].p, p, r))
344 {
345 return j;
346 }
347#endif
348 j++;
349 }
350 }
351 }
352 else
353 {
354 const poly p=L->t_p;
355 const ring r=strat->tailRing;
356 if(is_Ring)
357 {
358 loop
359 {
360 if (j > strat->tl) return -1;
361#if defined(PDEBUG) || defined(PDIV_DEBUG)
362 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
363 p, not_sev, r))
364 {
365 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
366 return j;
367 }
368#else
369 if (!(sevT[j] & not_sev) &&
370 p_LmDivisibleBy(T[j].t_p, p, r))
371 {
372 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
373 return j;
374 }
375#endif
376 j++;
377 }
378 }
379 else
380 {
381 loop
382 {
383 if (j > strat->tl) return -1;
384#if defined(PDEBUG) || defined(PDIV_DEBUG)
385 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
386 p, not_sev, r))
387 {
388 return j;
389 }
390#else
391 if (!(sevT[j] & not_sev) &&
392 p_LmDivisibleBy(T[j].t_p, p, r))
393 {
394 return j;
395 }
396#endif
397 j++;
398 }
399 }
400 }
401}

◆ kFindDivisibleByInT_Z()

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

Definition at line 209 of file kstd2.cc.

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

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

◆ kFindInT()

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

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

Definition at line 742 of file kutil.cc.

743{
744 int i;
745
746 for (i=0; i<=tlength; i++)
747 {
748 if (T[i].p == p) return i;
749 }
750 return -1;
751}

◆ kFindInTShift()

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

Definition at line 767 of file kutil.cc.

768{
769 int i;
770
771 for (i=0; i<=tlength; i++)
772 {
773 // in the Letterplace ring the LMs in T and L are copies thus we have to use pEqualPolys() instead of ==
774 if (pEqualPolys(T[i].p, p)) return i;
775 }
776 return -1;
777}
#define pEqualPolys(p1, p2)
Definition: polys.h:400

◆ kFindNextDivisibleByInS()

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

Definition at line 473 of file kstd2.cc.

474{
475 unsigned long not_sev = ~L->sev;
476 poly p = L->GetLmCurrRing();
477 int j = start;
478
479 pAssume(~not_sev == p_GetShortExpVector(p, currRing));
480#if 1
481 int ende=max_ind;
482#else
483 int ende=strat->sl;
484#endif
486 {
487 loop
488 {
489 if (j > ende) return -1;
490#if defined(PDEBUG) || defined(PDIV_DEBUG)
491 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
492 p, not_sev, currRing))
493 {
494 if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
495 return j;
496 }
497#else
498 if ( !(strat->sevS[j] & not_sev) &&
499 p_LmDivisibleBy(strat->S[j], p, currRing))
500 {
501 if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
502 return j;
503 }
504#endif
505 j++;
506 }
507 }
508 else
509 {
510 loop
511 {
512 if (j > ende) return -1;
513#if defined(PDEBUG) || defined(PDIV_DEBUG)
514 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
515 p, not_sev, currRing))
516 {
517 return j;
518 }
519#else
520 if ( !(strat->sevS[j] & not_sev) &&
521 p_LmDivisibleBy(strat->S[j], p, currRing))
522 {
523 return j;
524 }
525#endif
526 j++;
527 }
528 }
529}

◆ kFindSameLMInT_Z()

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

Definition at line 86 of file kstd2.cc.

87{
88 unsigned long not_sev = ~L->sev;
89 int j = start;
90 int o = -1;
91
92 const TSet T=strat->T;
93 const unsigned long* sevT=strat->sevT;
94 number gcd, ogcd;
95 if (L->p!=NULL)
96 {
97 const ring r=currRing;
98 const poly p=L->p;
99 ogcd = pGetCoeff(p);
100
101 pAssume(~not_sev == p_GetShortExpVector(p, r));
102
103 loop
104 {
105 if (j > strat->tl) return o;
106 if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r) && p_LmEqual(T[j].p, p, r))
107 {
108 gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf);
109 if (o == -1
110 || n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf))
111 {
112 ogcd = gcd;
113 o = j;
114 }
115 }
116 j++;
117 }
118 }
119 else
120 {
121 const ring r=strat->tailRing;
122 const poly p=L->t_p;
123 ogcd = pGetCoeff(p);
124 loop
125 {
126 if (j > strat->tl) return o;
127 if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r) && p_LmEqual(T[j].p, p, r))
128 {
129 gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf);
130 if (o == -1
131 || n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf))
132 {
133 ogcd = gcd;
134 o = j;
135 }
136 }
137 j++;
138 }
139 }
140}
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1731

◆ kFindZeroPoly()

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

Definition at line 559 of file kstd2.cc.

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

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3864 of file kstd2.cc.

3865{
3866 assume(!idIs0(q));
3867 assume(!(idIs0(F)&&(Q==NULL)));
3868// lazy_reduce flags: can be combined by |
3869//#define KSTD_NF_LAZY 1
3870 // do only a reduction of the leading term
3871//#define KSTD_NF_NONORM 4
3872 // only global: avoid normalization, return a multiply of NF
3873 poly p;
3874 int i;
3875 ideal res;
3876 int max_ind;
3877
3878 //if (idIs0(q))
3879 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
3880 //if ((idIs0(F))&&(Q==NULL))
3881 // return idCopy(q); /*F=0*/
3882 //strat->ak = idRankFreeModule(F);
3883 /*- creating temp data structures------------------- -*/
3884 BITSET save1;
3885 SI_SAVE_OPT1(save1);
3887 initBuchMoraCrit(strat);
3888 strat->initEcart = initEcartBBA;
3889#ifdef HAVE_SHIFTBBA
3890 if (rIsLPRing(currRing))
3891 {
3892 strat->enterS = enterSBbaShift;
3893 }
3894 else
3895#endif
3896 {
3897 strat->enterS = enterSBba;
3898 }
3899 /*- set S -*/
3900 strat->sl = -1;
3901#ifndef NO_BUCKETS
3903#endif
3904 /*- init local data struct.---------------------------------------- -*/
3905 /*Shdl=*/initS(F,Q,strat);
3906 /*- compute------------------------------------------------------- -*/
3907 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
3908 for (i=IDELEMS(q)-1; i>=0; i--)
3909 {
3910 if (q->m[i]!=NULL)
3911 {
3912 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
3913 p = redNF(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat);
3914 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3915 {
3916 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3918 {
3919 p = redtailBba_Z(p,max_ind,strat);
3920 }
3921 else if (rField_is_Ring(currRing))
3922 {
3923 p = redtailBba_Ring(p,max_ind,strat);
3924 }
3925 else
3926 {
3927 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
3928 p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3929 }
3930 }
3931 res->m[i]=p;
3932 }
3933 //else
3934 // res->m[i]=NULL;
3935 }
3936 /*- release temp data------------------------------- -*/
3937 assume(strat->L==NULL); /* strat->L unused */
3938 assume(strat->B==NULL); /* strat->B unused */
3939 omFree(strat->sevS);
3940 omFree(strat->ecartS);
3941 assume(strat->T==NULL);//omfree(strat->T);
3942 assume(strat->sevT==NULL);//omfree(strat->sevT);
3943 assume(strat->R==NULL);//omfree(strat->R);
3944 omfree(strat->S_2_R);
3945 omfree(strat->fromQ);
3946 idDelete(&strat->Shdl);
3947 SI_RESTORE_OPT1(save1);
3948 if (TEST_OPT_PROT) PrintLn();
3949 return res;
3950}
CanonicalForm res
Definition: facAbsFact.cc:60
KINLINE poly redtailBba_Ring(poly p, int pos, kStrategy strat)
Definition: kInline.h:1236
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition: kInline.h:1241
#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:2135
void initS(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7891
void enterSBbaShift(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9185
#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:92
#define OPT_REDTAIL
Definition: options.h:91
#define Sy_bit(x)
Definition: options.h:31
static BOOLEAN rField_is_Zn(const ring r)
Definition: ring.h:513

◆ kNF2() [2/2]

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

Definition at line 3708 of file kstd2.cc.

3709{
3710 assume(q!=NULL);
3711 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3712
3713// lazy_reduce flags: can be combined by |
3714//#define KSTD_NF_LAZY 1
3715 // do only a reduction of the leading term
3716//#define KSTD_NF_NONORM 4
3717 // only global: avoid normalization, return a multiply of NF
3718 poly p;
3719
3720 //if ((idIs0(F))&&(Q==NULL))
3721 // return pCopy(q); /*F=0*/
3722 //strat->ak = idRankFreeModule(F);
3723 /*- creating temp data structures------------------- -*/
3724 BITSET save1;
3725 SI_SAVE_OPT1(save1);
3727 initBuchMoraCrit(strat);
3728 strat->initEcart = initEcartBBA;
3729#ifdef HAVE_SHIFTBBA
3730 if (rIsLPRing(currRing))
3731 {
3732 strat->enterS = enterSBbaShift;
3733 }
3734 else
3735#endif
3736 {
3737 strat->enterS = enterSBba;
3738 }
3739#ifndef NO_BUCKETS
3741#endif
3742 /*- set S -*/
3743 strat->sl = -1;
3744 /*- init local data struct.---------------------------------------- -*/
3745 /*Shdl=*/initS(F,Q,strat);
3746 /*- compute------------------------------------------------------- -*/
3747 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3748 //{
3749 // for (i=strat->sl;i>=0;i--)
3750 // pNorm(strat->S[i]);
3751 //}
3752 kTest(strat);
3753 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3754 if (BVERBOSE(23)) kDebugPrint(strat);
3755 int max_ind;
3756 p = redNF(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat);
3757 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3758 {
3759 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3761 {
3762 p = redtailBba_Z(p,max_ind,strat);
3763 }
3764 else if (rField_is_Ring(currRing))
3765 {
3766 p = redtailBba_Ring(p,max_ind,strat);
3767 }
3768 else
3769 {
3770 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
3771 p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3772 }
3773 }
3774 /*- release temp data------------------------------- -*/
3775 assume(strat->L==NULL); /* strat->L unused */
3776 assume(strat->B==NULL); /* strat->B unused */
3777 omFree(strat->sevS);
3778 omFree(strat->ecartS);
3779 assume(strat->T==NULL);//omfree(strat->T);
3780 assume(strat->sevT==NULL);//omfree(strat->sevT);
3781 assume(strat->R==NULL);//omfree(strat->R);
3782 omfree(strat->S_2_R);
3783 omfree(strat->fromQ);
3784 idDelete(&strat->Shdl);
3785 SI_RESTORE_OPT1(save1);
3786 if (TEST_OPT_PROT) PrintLn();
3787 return p;
3788}
BOOLEAN kTest(kStrategy strat)
Definition: kutil.cc:1036

◆ kNF2Bound() [1/2]

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

Definition at line 3952 of file kstd2.cc.

3953{
3954 assume(!idIs0(q));
3955 assume(!(idIs0(F)&&(Q==NULL)));
3956// lazy_reduce flags: can be combined by |
3957//#define KSTD_NF_LAZY 1
3958 // do only a reduction of the leading term
3959//#define KSTD_NF_NONORM 4
3960 // only global: avoid normalization, return a multiply of NF
3961 poly p;
3962 int i;
3963 ideal res;
3964 int max_ind;
3965
3966 //if (idIs0(q))
3967 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
3968 //if ((idIs0(F))&&(Q==NULL))
3969 // return idCopy(q); /*F=0*/
3970 //strat->ak = idRankFreeModule(F);
3971 /*- creating temp data structures------------------- -*/
3972 BITSET save1;
3973 SI_SAVE_OPT1(save1);
3975 initBuchMoraCrit(strat);
3976 strat->initEcart = initEcartBBA;
3977 strat->enterS = enterSBba;
3978 /*- set S -*/
3979 strat->sl = -1;
3980#ifndef NO_BUCKETS
3982#endif
3983 /*- init local data struct.---------------------------------------- -*/
3984 /*Shdl=*/initS(F,Q,strat);
3985 /*- compute------------------------------------------------------- -*/
3986 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
3987 for (i=IDELEMS(q)-1; i>=0; i--)
3988 {
3989 if (q->m[i]!=NULL)
3990 {
3991 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
3992 p = redNFBound(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
3993 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3994 {
3995 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3997 {
3998 p = redtailBba_Z(p,max_ind,strat);
3999 }
4000 else if (rField_is_Ring(currRing))
4001 {
4002 p = redtailBba_Ring(p,max_ind,strat);
4003 }
4004 else
4005 {
4006 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4007 p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
4008 }
4009 }
4010 res->m[i]=p;
4011 }
4012 //else
4013 // res->m[i]=NULL;
4014 }
4015 /*- release temp data------------------------------- -*/
4016 assume(strat->L==NULL); /* strat->L unused */
4017 assume(strat->B==NULL); /* strat->B unused */
4018 omFree(strat->sevS);
4019 omFree(strat->ecartS);
4020 assume(strat->T==NULL);//omfree(strat->T);
4021 assume(strat->sevT==NULL);//omfree(strat->sevT);
4022 assume(strat->R==NULL);//omfree(strat->R);
4023 omfree(strat->S_2_R);
4024 omfree(strat->fromQ);
4025 idDelete(&strat->Shdl);
4026 SI_RESTORE_OPT1(save1);
4027 if (TEST_OPT_PROT) PrintLn();
4028 return res;
4029}
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:1229
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
Definition: kstd2.cc:2264

◆ kNF2Bound() [2/2]

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

Definition at line 3790 of file kstd2.cc.

3791{
3792 assume(q!=NULL);
3793 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3794
3795// lazy_reduce flags: can be combined by |
3796//#define KSTD_NF_LAZY 1
3797 // do only a reduction of the leading term
3798//#define KSTD_NF_NONORM 4
3799 // only global: avoid normalization, return a multiply of NF
3800 poly p;
3801
3802 //if ((idIs0(F))&&(Q==NULL))
3803 // return pCopy(q); /*F=0*/
3804 //strat->ak = idRankFreeModule(F);
3805 /*- creating temp data structures------------------- -*/
3806 BITSET save1;
3807 SI_SAVE_OPT1(save1);
3809 initBuchMoraCrit(strat);
3810 strat->initEcart = initEcartBBA;
3811 strat->enterS = enterSBba;
3812#ifndef NO_BUCKETS
3814#endif
3815 /*- set S -*/
3816 strat->sl = -1;
3817 /*- init local data struct.---------------------------------------- -*/
3818 /*Shdl=*/initS(F,Q,strat);
3819 /*- compute------------------------------------------------------- -*/
3820 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3821 //{
3822 // for (i=strat->sl;i>=0;i--)
3823 // pNorm(strat->S[i]);
3824 //}
3825 kTest(strat);
3826 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3827 if (BVERBOSE(23)) kDebugPrint(strat);
3828 int max_ind;
3829 p = redNFBound(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
3830 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3831 {
3832 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3834 {
3835 p = redtailBba_Z(p,max_ind,strat);
3836 }
3837 else if (rField_is_Ring(currRing))
3838 {
3839 p = redtailBba_Ring(p,max_ind,strat);
3840 }
3841 else
3842 {
3843 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
3844 p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
3845 //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3846 }
3847 }
3848 /*- release temp data------------------------------- -*/
3849 assume(strat->L==NULL); /* strat->L unused */
3850 assume(strat->B==NULL); /* strat->B unused */
3851 omFree(strat->sevS);
3852 omFree(strat->ecartS);
3853 assume(strat->T==NULL);//omfree(strat->T);
3854 assume(strat->sevT==NULL);//omfree(strat->sevT);
3855 assume(strat->R==NULL);//omfree(strat->R);
3856 omfree(strat->S_2_R);
3857 omfree(strat->fromQ);
3858 idDelete(&strat->Shdl);
3859 SI_RESTORE_OPT1(save1);
3860 if (TEST_OPT_PROT) PrintLn();
3861 return p;
3862}

◆ ksCreateShortSpoly()

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

Definition at line 1430 of file kspoly.cc.

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

◆ ksCreateSpoly()

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

Definition at line 1185 of file kspoly.cc.

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

1206{
1207 LObject L(r);
1208 L.p1 = p1;
1209 L.p2 = p2;
1210
1211 ksCreateSpoly(&L, spNoether);
1212 return L.GetLmCurrRing();
1213}

◆ ksOldSpolyRed()

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

Definition at line 1185 of file kInline.h.

1186{
1187 LObject L(p2);
1188 TObject T(p1);
1189
1190 ksReducePoly(&L, &T, spNoether);
1191
1192 return L.GetLmCurrRing();
1193}
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat)
Definition: kspoly.cc:187

◆ ksOldSpolyRedNew()

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

Definition at line 1195 of file kInline.h.

1196{
1197 LObject L(p_Copy(p2, currRing));
1198 TObject T(p1);
1199
1200 ksReducePoly(&L, &T, spNoether);
1201
1202 return L.GetLmCurrRing();
1203}

◆ ksOldSpolyTail()

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

Definition at line 1215 of file kInline.h.

1216{
1217 LObject L(q, currRing, r);
1218 TObject T(p1, currRing, r);
1219
1220 ksReducePolyTail(&L, &T, q2, spNoether);
1221}
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1158

◆ ksReducePoly()

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

Definition at line 187 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 572 of file kspoly.cc.

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

◆ ksReducePolyGCD()

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

Definition at line 325 of file kspoly.cc.

330{
331#ifdef KDEBUG
332 red_count++;
333#ifdef TEST_OPT_DEBUG_RED
334// if (TEST_OPT_DEBUG)
335// {
336// Print("Red %d:", red_count); PR->wrp(); Print(" with:");
337// PW->wrp();
338// //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
339// //pWrite(PR->p);
340// }
341#endif
342#endif
343 int ret = 0;
344 ring tailRing = PR->tailRing;
345 if (strat!=NULL)
346 {
347 kTest_L(PR,strat);
348 kTest_T(PW,strat);
349 }
350
351 poly p1 = PR->GetLmTailRing();
352 poly p2 = PW->GetLmTailRing();
353 poly t2 = pNext(p2), lm = pOne();
354 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
355 p_CheckPolyRing(p1, tailRing);
356 p_CheckPolyRing(p2, tailRing);
357
358 pAssume1(p2 != NULL && p1 != NULL &&
359 p_DivisibleBy(p2, p1, tailRing));
360
361 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
362 (p_GetComp(p2, tailRing) == 0 &&
363 p_MaxComp(pNext(p2),tailRing) == 0));
364
365#ifdef HAVE_PLURAL
367 {
368 // for the time being: we know currRing==strat->tailRing
369 // no exp-bound checking needed
370 // (only needed if exp-bound(tailring)<exp-b(currRing))
371 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef);
372 else
373 {
374 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
375 assume(_p != NULL);
376 nc_PolyPolyRed(_p, p2,coef, currRing);
377 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
378 PR->pLength=0; // usually not used, GetpLength re-computes it if needed
379 }
380 return 0;
381 }
382#endif
383 // check that reduction does not violate exp bound
384 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
385 {
386 // undo changes of lm
387 p_ExpVectorAdd(lm, p2, tailRing);
388 if (strat == NULL) return 2;
389 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
390 tailRing = strat->tailRing;
391 p1 = PR->GetLmTailRing();
392 p2 = PW->GetLmTailRing();
393 t2 = pNext(p2);
394 lm = p1;
395 p_ExpVectorSub(lm, p2, tailRing);
396 ret = 1;
397 }
398
399#ifdef HAVE_SHIFTBBA
400 poly lmRight;
401 if (tailRing->isLPring)
402 {
403 assume(PR->shift == 0);
404 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
405 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
406 }
407#endif
408
409 number ct, an, bn;
410 // take care of coef buisness
411 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
412 {
413 ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing->cf); // Calculate GCD
414 if (n_IsZero(an, tailRing->cf) || n_IsZero(bn, tailRing->cf))
415 {
416 n_Delete(&an, tailRing->cf);
417 n_Delete(&bn, tailRing->cf);
418 n_Delete(&ct, tailRing->cf);
419 return ret;
420 }
421 /* negate bn since we subtract in Tail_Minus_mm_Mult_qq */
422 bn = n_InpNeg(bn, tailRing->cf);
423 p_SetCoeff(lm, bn, tailRing);
424 p_Test(lm,tailRing);
425 PR->Tail_Mult_nn(an);
426 }
427 else
428 {
429 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
430 }
431
432
433 // and finally,
434#ifdef HAVE_SHIFTBBA
435 if (tailRing->isLPring)
436 {
437 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
438 }
439 else
440#endif
441 {
442 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
443 }
444 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
445 pSetCoeff(PR->p, ct);
446
447 return ret;
448}
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:557
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:671

◆ ksReducePolyLC()

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

Definition at line 458 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 719 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 925 of file kspoly.cc.

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

1159{
1160 BOOLEAN ret;
1161 number coef;
1162
1163 assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1164 Red->HeadNormalize();
1165 ret = ksReducePoly(Red, PW, NULL, &coef);
1166
1167 if (!ret)
1168 {
1169 if (! n_IsOne(coef, currRing->cf))
1170 {
1171 PR->Mult_nn(coef);
1172 // HANNES: mark for Normalize
1173 }
1174 n_Delete(&coef, currRing->cf);
1175 }
1176 return ret;
1177}

◆ ksReducePolyTail() [2/2]

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

Definition at line 1334 of file kspoly.cc.

1335{
1336 BOOLEAN ret;
1337 number coef;
1338 poly Lp = PR->GetLmCurrRing();
1339 poly Save = PW->GetLmCurrRing();
1340
1341 pAssume(pIsMonomOf(Lp, Current));
1342
1343 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
1344 assume(PR->bucket == NULL);
1345
1346 LObject Red(pNext(Current), PR->tailRing);
1347 TObject With(PW, Lp == Save);
1348
1349 pAssume(!pHaveCommonMonoms(Red.p, With.p));
1350 ret = ksReducePoly(&Red, &With, spNoether, &coef);
1351
1352 if (!ret)
1353 {
1354 if (! n_IsOne(coef, currRing->cf))
1355 {
1356 pNext(Current) = NULL;
1357 if (Current == PR->p && PR->t_p != NULL)
1358 pNext(PR->t_p) = NULL;
1359 PR->Mult_nn(coef);
1360 }
1361
1362 n_Delete(&coef, currRing->cf);
1363 pNext(Current) = Red.GetLmTailRing();
1364 if (Current == PR->p && PR->t_p != NULL)
1365 pNext(PR->t_p) = pNext(Current);
1366 }
1367
1368 if (Lp == Save)
1369 With.Delete();
1370
1371 return ret;
1372}
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 
)

Definition at line 44 of file kspoly.cc.

49{
50#ifdef KDEBUG
51 red_count++;
52#ifdef TEST_OPT_DEBUG_RED
53// if (TEST_OPT_DEBUG)
54// {
55// Print("Red %d:", red_count); PR->wrp(); Print(" with:");
56// PW->wrp();
57// //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
58// //pWrite(PR->p);
59// }
60#endif
61#endif
62 int ret = 0;
63 ring tailRing = PR->tailRing;
64 if (strat!=NULL)
65 {
66 kTest_L(PR,strat);
67 kTest_T(PW,strat);
68 }
69 poly p1 = PR->GetLmTailRing(); // p2 | p1
70 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
71 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
72 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
73 p_CheckPolyRing(p1, tailRing);
74 p_CheckPolyRing(p2, tailRing);
75
76 pAssume1(p2 != NULL && p1 != NULL &&
77 p_DivisibleBy(p2, p1, tailRing));
78
79 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
80 (p_GetComp(p2, tailRing) == 0 &&
81 p_MaxComp(pNext(p2),tailRing) == 0));
82
83#ifdef HAVE_PLURAL
85 {
86 // for the time being: we know currRing==strat->tailRing
87 // no exp-bound checking needed
88 // (only needed if exp-bound(tailring)<exp-b(currRing))
89 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef);
90 else
91 {
92 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
93 assume(_p != NULL);
94 nc_PolyPolyRed(_p, p2,coef, currRing);
95 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
96 PR->pLength=0; // usually not used, GetpLength re-computes it if needed
97 }
98 return 0;
99 }
100#endif
101
102 if (t2==NULL) // Divisor is just one term, therefore it will
103 { // just cancel the leading term
104 // adjust lead coefficient if needed
105 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
106 {
107 number bn = pGetCoeff(lm);
108 number an = pGetCoeff(p2);
109 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
110 p_SetCoeff(lm, bn, tailRing);
111 if ((ct == 0) || (ct == 2))
112 PR->Tail_Mult_nn(an);
113 if (coef != NULL) *coef = an;
114 else n_Delete(&an, tailRing->cf);
115 }
116 PR->LmDeleteAndIter();
117 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
118 return 0;
119 }
120
121 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
122
123 //if (tailRing != currRing)
124 {
125 // check that reduction does not violate exp bound
126 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
127 {
128 // undo changes of lm
129 p_ExpVectorAdd(lm, p2, tailRing);
130 if (strat == NULL) return 2;
131 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
132 tailRing = strat->tailRing;
133 p1 = PR->GetLmTailRing();
134 p2 = PW->GetLmTailRing();
135 t2 = pNext(p2);
136 lm = p1;
137 p_ExpVectorSub(lm, p2, tailRing);
138 ret = 1;
139 }
140 }
141
142#ifdef HAVE_SHIFTBBA
143 poly lmRight;
144 if (tailRing->isLPring)
145 {
146 assume(PR->shift == 0);
147 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
148 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
149 }
150#endif
151
152 // take care of coef buisness
153 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
154 {
155 number bn = pGetCoeff(lm);
156 number an = pGetCoeff(p2);
157 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
158 p_SetCoeff(lm, bn, tailRing);
159 if ((ct == 0) || (ct == 2))
160 PR->Tail_Mult_nn(an);
161 if (coef != NULL) *coef = an;
162 else n_Delete(&an, tailRing->cf);
163 }
164 else
165 {
166 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
167 }
168
169
170 // and finally,
171#ifdef HAVE_SHIFTBBA
172 if (tailRing->isLPring)
173 {
174 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
175 }
176 else
177#endif
178 {
179 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
180 }
181 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
182 PR->LmDeleteAndIter();
183
184 return ret;
185}

◆ kStratChangeTailRing()

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

Definition at line 11278 of file kutil.cc.

11279{
11280 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11281 /* initial setup or extending */
11282
11283 if (rIsLPRing(currRing)) return TRUE;
11284 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11285 if (expbound >= currRing->bitmask) return FALSE;
11286 strat->overflow=FALSE;
11287 ring new_tailRing = rModifyRing(currRing,
11288 // Hmmm .. the condition pFDeg == p_Deg
11289 // might be too strong
11290 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11291 (strat->ak==0), // omit_comp if the input is an ideal
11292 expbound); // exp_limit
11293
11294 if (new_tailRing == currRing) return TRUE;
11295
11296 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11297 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11298
11299 if (currRing->pFDeg != currRing->pFDegOrig)
11300 {
11301 new_tailRing->pFDeg = currRing->pFDeg;
11302 new_tailRing->pLDeg = currRing->pLDeg;
11303 }
11304
11305 if (TEST_OPT_PROT)
11306 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11307 kTest_TS(strat);
11308 assume(new_tailRing != strat->tailRing);
11309 pShallowCopyDeleteProc p_shallow_copy_delete
11310 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11311
11312 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11313
11314 int i;
11315 for (i=0; i<=strat->tl; i++)
11316 {
11317 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11318 p_shallow_copy_delete);
11319 }
11320 for (i=0; i<=strat->Ll; i++)
11321 {
11322 assume(strat->L[i].p != NULL);
11323 if (pNext(strat->L[i].p) != strat->tail)
11324 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11325 }
11326 if ((strat->P.t_p != NULL) ||
11327 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11328 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11329
11330 if ((L != NULL) && (L->tailRing != new_tailRing))
11331 {
11332 if (L->i_r < 0)
11333 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11334 else
11335 {
11336 assume(L->i_r <= strat->tl);
11337 TObject* t_l = strat->R[L->i_r];
11338 assume(t_l != NULL);
11339 L->tailRing = new_tailRing;
11340 L->p = t_l->p;
11341 L->t_p = t_l->t_p;
11342 L->max_exp = t_l->max_exp;
11343 }
11344 }
11345
11346 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11347 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11348
11349 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11350 if (strat->tailRing != currRing)
11352
11353 strat->tailRing = new_tailRing;
11354 strat->tailBin = new_tailBin;
11356 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11357
11358 if (strat->kNoether != NULL)
11359 {
11360 if (strat->t_kNoether != NULL)
11361 p_LmFree(strat->t_kNoether, strat->tailRing);
11362 strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_tailRing);
11363 }
11364
11365 kTest_TS(strat);
11366 if (TEST_OPT_PROT)
11367 PrintS("]");
11368 return TRUE;
11369}
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:3101
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2740
#define omGetStickyBinOfBin(B)
Definition: xalloc.h:247
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:275

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11371 of file kutil.cc.

11372{
11373 unsigned long l = 0;
11374 int i;
11375 long e;
11376
11377 assume(strat->tailRing == currRing);
11378
11379 for (i=0; i<= strat->Ll; i++)
11380 {
11381 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11382 }
11383 for (i=0; i<=strat->tl; i++)
11384 {
11385 // Hmm ... this we could do in one Step
11386 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11387 }
11389 {
11390 l *= 2;
11391 }
11392 e = p_GetMaxExp(l, currRing);
11393 if (e <= 1) e = 2;
11394 if (rIsLPRing(currRing)) e = 1;
11395
11396 kStratChangeTailRing(strat, NULL, NULL, e);
11397}
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:781

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1036 of file kutil.cc.

1037{
1038 int i;
1039 // test P
1040 kFalseReturn(kTest_L(&(strat->P), strat,
1041 (strat->P.p != NULL && pNext(strat->P.p)!=strat->tail),
1042 -1, strat->T, strat->tl));
1043
1044 // test T
1045 if (strat->T != NULL)
1046 {
1047 for (i=0; i<=strat->tl; i++)
1048 {
1049 kFalseReturn(kTest_T(&(strat->T[i]), strat, i, 'T'));
1050 if (strat->sevT[i] != pGetShortExpVector(strat->T[i].p))
1051 return dReportError("strat->sevT[%d] out of sync", i);
1052 }
1053 }
1054
1055 // test L
1056 if (strat->L != NULL)
1057 {
1058 for (i=0; i<=strat->Ll; i++)
1059 {
1060 kFalseReturn(kTest_L(&(strat->L[i]), strat,
1061 strat->L[i].Next() != strat->tail, i,
1062 strat->T, strat->tl));
1063 // may be unused
1064 //if (strat->use_buckets && strat->L[i].Next() != strat->tail &&
1065 // strat->L[i].Next() != NULL && strat->L[i].p1 != NULL)
1066 //{
1067 // assume(strat->L[i].bucket != NULL);
1068 //}
1069 }
1070 }
1071
1072 // test S
1073 if (strat->S != NULL)
1074 kFalseReturn(kTest_S(strat));
1075
1076 return TRUE;
1077}
#define kFalseReturn(x)
Definition: kutil.cc:804
BOOLEAN kTest_S(kStrategy strat)
Definition: kutil.cc:1079
int dReportError(const char *fmt,...)
Definition: dError.cc:43

◆ kTest_L()

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

Definition at line 950 of file kutil.cc.

952{
953 ring strat_tailRing=strat->tailRing;
954 if (L->p!=NULL)
955 {
956 if ((L->t_p==NULL)
957 &&(pNext(L->p)!=NULL)
958 &&(pGetCoeff(pNext(L->p))!=NULL)) /* !=strat->tail*/
959 {
960 p_Test(pNext(L->p),currRing);
961 nTest(pGetCoeff(L->p));
962 }
963 }
964 if (L->t_p!=NULL)
965 {
966 if ((pNext(L->t_p)!=NULL)
967 &&(pGetCoeff(pNext(L->t_p))!=NULL)) /* !=strat->tail*/
968 {
969 p_Test(pNext(L->t_p),strat_tailRing);
970 nTest(pGetCoeff(L->t_p));
971 }
972 }
973 if ((L->p!=NULL)&&(L->t_p!=NULL)) assume(pGetCoeff(L->p)==pGetCoeff(L->t_p));
974
975 if (testp)
976 {
977 poly pn = NULL;
978 if (L->bucket != NULL)
979 {
980 kFalseReturn(kbTest(L->bucket));
981 r_assume(L->bucket->bucket_ring == L->tailRing);
982 if (L->p != NULL && pNext(L->p) != NULL)
983 {
984 pn = pNext(L->p);
985 pNext(L->p) = NULL;
986 }
987 }
988 kFalseReturn(kTest_T(L, strat, lpos, 'L'));
989 if (pn != NULL)
990 pNext(L->p) = pn;
991
992 ring r;
993 poly p;
994 L->GetLm(p, r);
995 if (L->sev != 0L)
996 {
997 if (p_GetShortExpVector(p, r) != L->sev)
998 {
999 return dReportError("L[%d] wrong sev: has %lo, specified to have %lo",
1000 lpos, p_GetShortExpVector(p, r), L->sev);
1001 }
1002 }
1003 }
1004 if (L->p1 == NULL)
1005 {
1006 // L->p2 either NULL or "normal" poly
1007 pFalseReturn(pp_Test(L->p2, currRing, L->tailRing));
1008 }
1009 else if (tlength > 0 && T != NULL && (lpos >=0))
1010 {
1011 // now p1 and p2 must be != NULL and must be contained in T
1012 int i;
1013#ifdef HAVE_SHIFTBBA
1014 if (rIsLPRing(currRing))
1015 i = kFindInTShift(L->p1, T, tlength);
1016 else
1017#endif
1018 i = kFindInT(L->p1, T, tlength);
1019 if (i < 0)
1020 return dReportError("L[%d].p1 not in T",lpos);
1021#ifdef HAVE_SHIFTBBA
1022 if (rIsLPRing(currRing))
1023 {
1024 if (rField_is_Ring(currRing)) return TRUE; // m*shift(q) is not in T
1025 i = kFindInTShift(L->p2, T, tlength);
1026 }
1027 else
1028#endif
1029 i = kFindInT(L->p2, T, tlength);
1030 if (i < 0)
1031 return dReportError("L[%d].p2 not in T",lpos);
1032 }
1033 return TRUE;
1034}
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:197
int kFindInTShift(poly p, TSet T, int tlength)
Definition: kutil.cc:767
#define r_assume(x)
Definition: mod2.h:388
#define pFalseReturn(cond)
Definition: monomials.h:139
#define nTest(a)
Definition: numbers.h:35

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1079 of file kutil.cc.

1080{
1081 int i;
1082 BOOLEAN ret = TRUE;
1083 for (i=0; i<=strat->sl; i++)
1084 {
1085 if (strat->S[i] != NULL &&
1086 strat->sevS[i] != pGetShortExpVector(strat->S[i]))
1087 {
1088 return dReportError("S[%d] wrong sev: has %o, specified to have %o",
1089 i , pGetShortExpVector(strat->S[i]), strat->sevS[i]);
1090 }
1091 }
1092 return ret;
1093}

◆ kTest_T()

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

Definition at line 825 of file kutil.cc.

826{
827 ring tailRing = T->tailRing;
828 ring strat_tailRing = strat->tailRing;
829 if (strat_tailRing == NULL) strat_tailRing = tailRing;
830 r_assume(strat_tailRing == tailRing);
831
832 poly p = T->p;
833 // ring r = currRing;
834
835 if (T->p == NULL && T->t_p == NULL && i >= 0)
836 return dReportError("%c[%d].poly is NULL", TN, i);
837
838 if (T->p!=NULL)
839 {
840 nTest(pGetCoeff(T->p));
841 if ((T->t_p==NULL)&&(pNext(T->p)!=NULL)) p_Test(pNext(T->p),currRing);
842 }
843 if (T->t_p!=NULL)
844 {
845 nTest(pGetCoeff(T->t_p));
846 if (pNext(T->t_p)!=NULL) p_Test(pNext(T->t_p),strat_tailRing);
847 }
848 if ((T->p!=NULL)&&(T->t_p!=NULL)) assume(pGetCoeff(T->p)==pGetCoeff(T->t_p));
849
850 if (T->tailRing != currRing)
851 {
852 if (T->t_p == NULL && i > 0)
853 return dReportError("%c[%d].t_p is NULL", TN, i);
854 pFalseReturn(p_Test(T->t_p, T->tailRing));
855 if (T->p != NULL) pFalseReturn(p_LmTest(T->p, currRing));
856 if ((T->p != NULL) && (T->t_p != NULL))
857 {
858 const char* msg = kTest_LmEqual(T->p, T->t_p, T->tailRing);
859 if (msg != NULL)
860 return dReportError("%c[%d] %s", TN, i, msg);
861 // r = T->tailRing;
862 p = T->t_p;
863 }
864 if (T->p == NULL)
865 {
866 p = T->t_p;
867 // r = T->tailRing;
868 }
869 if (T->t_p != NULL && i >= 0 && TN == 'T')
870 {
871 if (pNext(T->t_p) == NULL)
872 {
873 if (T->max_exp != NULL)
874 return dReportError("%c[%d].max_exp is not NULL as it should be", TN, i);
875 }
876 else
877 {
878 if (T->max_exp == NULL)
879 return dReportError("%c[%d].max_exp is NULL", TN, i);
880 if (pNext(T->max_exp) != NULL)
881 return dReportError("pNext(%c[%d].max_exp) != NULL", TN, i);
882
883 pFalseReturn(p_CheckPolyRing(T->max_exp, tailRing));
884 omCheckBinAddrSize(T->max_exp, (omSizeWOfBin(tailRing->PolyBin))*SIZEOF_LONG);
885#if KDEBUG > 0
886 if (! sloppy_max)
887 {
888 poly test_max = p_GetMaxExpP(pNext(T->t_p), tailRing);
889 p_Setm(T->max_exp, tailRing);
890 p_Setm(test_max, tailRing);
891 BOOLEAN equal = p_ExpVectorEqual(T->max_exp, test_max, tailRing);
892 if (! equal)
893 return dReportError("%c[%d].max out of sync", TN, i);
894 p_LmFree(test_max, tailRing);
895 }
896#endif
897 }
898 }
899 }
900 else
901 {
902 if (T->p == NULL && i > 0)
903 return dReportError("%c[%d].p is NULL", TN, i);
904#ifdef HAVE_SHIFTBBA
905 if (currRing->isLPring && T->shift > 0)
906 {
907 // in this case, the order is not correct. test LM and tail separately
910 }
911 else
912#endif
913 {
915 }
916 }
917
918 if ((i >= 0) && (T->pLength != 0)
919 && (! rIsSyzIndexRing(currRing)) && (T->pLength != pLength(p)))
920 {
921 int l=T->pLength;
922 T->pLength=pLength(p);
923 return dReportError("%c[%d] pLength error: has %d, specified to have %d",
924 TN, i , pLength(p), l);
925 }
926
927 // check FDeg, for elements in L and T
928 if (i >= 0 && (TN == 'T' || TN == 'L'))
929 {
930 // FDeg has ir element from T of L set
931 if (strat->homog && (T->FDeg != T->pFDeg()))
932 {
933 int d=T->FDeg;
934 T->FDeg=T->pFDeg();
935 return dReportError("%c[%d] FDeg error: has %d, specified to have %d",
936 TN, i , T->pFDeg(), d);
937 }
938 }
939
940 // check is_normalized for elements in T
941 if (i >= 0 && TN == 'T')
942 {
943 if (T->is_normalized && ! nIsOne(pGetCoeff(p)))
944 return dReportError("T[%d] is_normalized error", i);
945
946 }
947 return TRUE;
948}
static const char * kTest_LmEqual(poly p, poly t_p, ring tailRing)
Definition: kutil.cc:807
#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:4591

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1097 of file kutil.cc.

1098{
1099 int i, j;
1100 // BOOLEAN ret = TRUE;
1101 kFalseReturn(kTest(strat));
1102
1103 // test strat->R, strat->T[i].i_r
1104 for (i=0; i<=strat->tl; i++)
1105 {
1106 if (strat->T[i].i_r < 0 || strat->T[i].i_r > strat->tl)
1107 return dReportError("strat->T[%d].i_r == %d out of bounds", i,
1108 strat->T[i].i_r);
1109 if (strat->R[strat->T[i].i_r] != &(strat->T[i]))
1110 return dReportError("T[%d].i_r with R out of sync", i);
1111 }
1112 // test containment of S inT
1113 if ((strat->S != NULL)&&(strat->tl>=0))
1114 {
1115 for (i=0; i<=strat->sl; i++)
1116 {
1117 j = kFindInT(strat->S[i], strat->T, strat->tl);
1118 if (j < 0)
1119 return dReportError("S[%d] not in T", i);
1120 if (strat->S_2_R[i] != strat->T[j].i_r)
1121 return dReportError("S_2_R[%d]=%d != T[%d].i_r=%d\n",
1122 i, strat->S_2_R[i], j, strat->T[j].i_r);
1123 }
1124 }
1125 // test strat->L[i].i_r1
1126 #ifdef HAVE_SHIFTBBA
1127 if (!rIsLPRing(currRing)) // in the Letterplace ring we currently don't set/use i_r1 and i_r2
1128 #endif
1129 if (strat->L!=NULL)
1130 {
1131 for (i=0; i<=strat->Ll; i++)
1132 {
1133 if (strat->L[i].p1 != NULL && strat->L[i].p2)
1134 {
1135 if (strat->L[i].i_r1 < 0 ||
1136 strat->L[i].i_r1 > strat->tl ||
1137 strat->L[i].T_1(strat)->p != strat->L[i].p1)
1138 return dReportError("L[%d].i_r1 out of sync", i);
1139 if (strat->L[i].i_r2 < 0 ||
1140 strat->L[i].i_r2 > strat->tl ||
1141 strat->L[i].T_2(strat)->p != strat->L[i].p2)
1142 return dReportError("L[%d].i_r2 out of sync", i);
1143 }
1144 else
1145 {
1146 if (strat->L[i].i_r1 != -1)
1147 return dReportError("L[%d].i_r1 out of sync", i);
1148 if (strat->L[i].i_r2 != -1)
1149 return dReportError("L[%d].i_r2 out of sync", i);
1150 }
1151 if (strat->L[i].i_r != -1)
1152 return dReportError("L[%d].i_r out of sync", i);
1153 }
1154 }
1155 return TRUE;
1156}

◆ kTestDivisibleByT0_Z()

int kTestDivisibleByT0_Z ( const kStrategy  strat,
const LObject L 
)

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

Definition at line 142 of file kstd2.cc.

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

◆ message()

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

Definition at line 7768 of file kutil.cc.

7769{
7770 if (i != *olddeg)
7771 {
7772 Print("%d",i);
7773 *olddeg = i;
7774 }
7775 if (TEST_OPT_OLDSTD)
7776 {
7777 if (strat->Ll != *reduc)
7778 {
7779 if (strat->Ll != *reduc-1)
7780 Print("(%d)",strat->Ll+1);
7781 else
7782 PrintS("-");
7783 *reduc = strat->Ll;
7784 }
7785 else
7786 PrintS(".");
7787 mflush();
7788 }
7789 else
7790 {
7791 if (red_result == 0)
7792 PrintS("-");
7793 else if (red_result < 0)
7794 PrintS(".");
7795 if ((red_result > 0) || ((strat->Ll % 100)==99))
7796 {
7797 if (strat->Ll != *reduc && strat->Ll > 0)
7798 {
7799 Print("(%d)",strat->Ll+1);
7800 *reduc = strat->Ll;
7801 }
7802 }
7803 }
7804}

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7841 of file kutil.cc.

7842{
7843 int i;
7844 if (strat->news)
7845 {
7846 PrintS("set S");
7847 for (i=0; i<=strat->sl; i++)
7848 {
7849 Print("\n %d:",i);
7850 p_wrp(strat->S[i], currRing, strat->tailRing);
7851 if (strat->fromQ!=NULL && strat->fromQ[i])
7852 Print(" (from Q)");
7853 }
7854 strat->news = FALSE;
7855 }
7856 if (strat->newt)
7857 {
7858 PrintS("\nset T");
7859 for (i=0; i<=strat->tl; i++)
7860 {
7861 Print("\n %d:",i);
7862 strat->T[i].wrp();
7863 if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7864 Print(" o:%ld e:%d l:%d",
7865 strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7866 }
7867 strat->newt = FALSE;
7868 }
7869 PrintS("\nset L");
7870 for (i=strat->Ll; i>=0; i--)
7871 {
7872 Print("\n%d:",i);
7873 p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7874 PrintS(" ");
7875 p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7876 PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7877 PrintS("\n p : ");
7878 strat->L[i].wrp();
7879 Print(" o:%ld e:%d l:%d",
7880 strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7881 }
7882 PrintLn();
7883}

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7809 of file kutil.cc.

7810{
7811 //PrintS("\nUsage/Allocation of temporary storage:\n");
7812 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7813 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7814 Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7815 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7816 #ifdef HAVE_SHIFTBBA
7817 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7818 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7819 #endif
7820}

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7822 of file kutil.cc.

7823{
7824 //PrintS("\nUsage/Allocation of temporary storage:\n");
7825 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7826 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7827 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7828 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7829 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7830 #ifdef HAVE_SHIFTBBA
7831 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7832 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7833 #endif
7834}
int nrsyzcrit
Definition: kutil.h:360

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10719 of file kutil.cc.

10720{
10721 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10722 return FALSE;
10723 int i,j;
10724 poly newNoether;
10725
10726#if 0
10727 if (currRing->weight_all_1)
10728 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether, strat->tailRing);
10729 else
10730 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether, strat->tailRing);
10731#else
10732 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether, strat->tailRing);
10733#endif
10734 if (strat->kNoether==NULL) return FALSE;
10735 if (strat->t_kNoether != NULL)
10736 {
10737 p_LmFree(strat->t_kNoether, strat->tailRing);
10738 strat->t_kNoether=NULL;
10739 }
10740 if (strat->tailRing != currRing)
10742 /* compare old and new noether*/
10743 newNoether = pLmInit(strat->kNoether);
10744 pSetCoeff0(newNoether,nInit(1));
10745 j = p_FDeg(newNoether,currRing);
10746 for (i=1; i<=(currRing->N); i++)
10747 {
10748 if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10749 }
10750 pSetm(newNoether);
10751 if (j < HCord) /*- statistics -*/
10752 {
10753 if (TEST_OPT_PROT)
10754 {
10755 Print("H(%d)",j);
10756 mflush();
10757 }
10758 HCord=j;
10759 #ifdef KDEBUG
10760 if (TEST_OPT_DEBUG)
10761 {
10762 Print("H(%d):",j);
10763 wrp(strat->kNoether);
10764 PrintLn();
10765 }
10766 #endif
10767 }
10768 if (pCmp(strat->kNoether,newNoether)!=1)
10769 {
10770 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10771 strat->kNoether=newNoether;
10772 if (strat->t_kNoether != NULL)
10773 {
10774 p_LmFree(strat->t_kNoether, strat->tailRing);
10775 strat->t_kNoether=NULL;
10776 }
10777 if (strat->tailRing != currRing)
10779
10780 return TRUE;
10781 }
10782 pLmDelete(newNoether);
10783 return FALSE;
10784}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1079
VAR int HCord
Definition: kutil.cc:246
static void p_LmDelete0(poly p, const ring r)
Definition: p_polys.h:733
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition: polys.h:115
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pDecrExp(p, i)
Definition: polys.h:44

◆ pairs()

void pairs ( )

◆ pCopyL2p()

poly pCopyL2p ( LObject  h,
kStrategy  strat 
)

Definition at line 11986 of file kutil.cc.

11987{
11988 /* restores a poly in currRing from LObject */
11989 LObject h = H;
11990 h.Copy();
11991 poly p;
11992 if (h.p == NULL)
11993 {
11994 if (h.t_p != NULL)
11995 {
11996 p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
11997 return(p);
11998 }
11999 else
12000 {
12001 /* h.tp == NULL -> the object is NULL */
12002 return(NULL);
12003 }
12004 }
12005 /* we're here if h.p != NULL */
12006 if (h.t_p == NULL)
12007 {
12008 /* then h.p is the whole poly in currRing */
12009 p = h.p;
12010 return(p);
12011 }
12012 /* we're here if h.p != NULL and h.t_p != NULL */
12013 // clean h.p, get poly from t_p
12014 pNext(h.p)=NULL;
12015 pLmDelete(&h.p);
12016 p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
12017 /* dest. ring: */ currRing);
12018 // no need to clean h: we re-used the polys
12019 return(p);
12020}
CanonicalForm H
Definition: facAbsFact.cc:60
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:90

◆ pMove2CurrTail()

poly pMove2CurrTail ( poly  p,
kStrategy  strat 
)

Definition at line 11955 of file kutil.cc.

11956{
11957 /* assume: p is completely in currRing */
11958 /* produces an object with LM in curring
11959 and TAIL in tailring */
11960 if (pNext(p)!=NULL)
11961 {
11962 pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
11963 }
11964 return(p);
11965}

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 11969 of file kutil.cc.

11970{
11971 /* assume: p has LM in curring and TAIL in tailring */
11972 /* convert it to complete currRing */
11973
11974 /* check that LM is in currRing */
11976
11977 if (pNext(p)!=NULL)
11978 {
11979 pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
11980 }
11981 return(p);
11982}

◆ posInIdealMonFirst()

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

Definition at line 4941 of file kutil.cc.

4942{
4943 if(end < 0 || end >= IDELEMS(F))
4944 end = IDELEMS(F);
4945 if (end<0) return 0;
4946 if(pNext(p) == NULL) return start;
4947 polyset set=F->m;
4948 int o = p_Deg(p,currRing);
4949 int op;
4950 int i;
4951 int an = start;
4952 for(i=start;i<end;i++)
4953 if(set[i] != NULL && pNext(set[i]) == NULL)
4954 an++;
4955 if(an == end-1)
4956 return end;
4957 int en= end;
4958 loop
4959 {
4960 if(an>=en)
4961 return en;
4962 if (an == en-1)
4963 {
4964 op = p_Deg(set[an],currRing);
4965 if ((op < o)
4966 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4967 return en;
4968 return an;
4969 }
4970 i=(an+en) / 2;
4971 op = p_Deg(set[i],currRing);
4972 if ((op < o)
4973 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4974 an=i;
4975 else
4976 en=i;
4977 }
4978}
poly * polyset
Definition: polys.h:259

◆ posInL0()

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

Definition at line 5790 of file kutil.cc.

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

◆ posInL10()

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

Definition at line 1352 of file kstd1.cc.

1353{
1354 int j,dp,dL;
1355
1356 if (length<0) return 0;
1357 if (hasPurePower(p,strat->lastAxis,&dp,strat))
1358 {
1359 int op= p->GetpFDeg() +p->ecart;
1360 for (j=length; j>=0; j--)
1361 {
1362 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1363 return j+1;
1364 if (dp < dL)
1365 return j+1;
1366 if ((dp == dL)
1367 && (set[j].GetpFDeg()+set[j].ecart >= op))
1368 return j+1;
1369 }
1370 }
1371 j=length;
1372 loop
1373 {
1374 if (j<0) break;
1375 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1376 j--;
1377 }
1378 return strat->posInLOld(set,j,p,strat);
1379}
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:1304

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

6050{
6051 if (length<0) return 0;
6052
6053 int o = p->GetpFDeg();
6054 int op = set[length].GetpFDeg();
6055
6056 if ((op > o)
6057 || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6058 return length+1;
6059 int i;
6060 int an = 0;
6061 int en= length;
6062 loop
6063 {
6064 if (an >= en-1)
6065 {
6066 op = set[an].GetpFDeg();
6067 if ((op > o)
6068 || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6069 return en;
6070 return an;
6071 }
6072 i=(an+en) / 2;
6073 op = set[i].GetpFDeg();
6074 if ((op > o)
6075 || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6076 an=i;
6077 else
6078 en=i;
6079 }
6080}

◆ posInL110()

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

Definition at line 6346 of file kutil.cc.

6348{
6349 if (length<0) return 0;
6350
6351 int o = p->GetpFDeg();
6352 int op = set[length].GetpFDeg();
6353
6354 if ((op > o)
6355 || ((op == o) && (set[length].length >p->length))
6356 || ((op == o) && (set[length].length <= p->length)
6357 && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6358 return length+1;
6359 int i;
6360 int an = 0;
6361 int en= length;
6362 loop
6363 {
6364 if (an >= en-1)
6365 {
6366 op = set[an].GetpFDeg();
6367 if ((op > o)
6368 || ((op == o) && (set[an].length >p->length))
6369 || ((op == o) && (set[an].length <=p->length)
6370 && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6371 return en;
6372 return an;
6373 }
6374 i=(an+en) / 2;
6375 op = set[i].GetpFDeg();
6376 if ((op > o)
6377 || ((op == o) && (set[i].length > p->length))
6378 || ((op == o) && (set[i].length <= p->length)
6379 && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6380 an=i;
6381 else
6382 en=i;
6383 }
6384}

◆ posInL11Ring()

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

Definition at line 6090 of file kutil.cc.

6092{
6093 if (length<0) return 0;
6094
6095 int o = p->GetpFDeg();
6096 int op = set[length].GetpFDeg();
6097
6098 if ((op > o)
6099 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6100 return length+1;
6101 int i;
6102 int an = 0;
6103 int en= length;
6104 loop
6105 {
6106 if (an >= en-1)
6107 {
6108 op = set[an].GetpFDeg();
6109 if ((op > o)
6110 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6111 return en;
6112 return an;
6113 }
6114 i=(an+en) / 2;
6115 op = set[i].GetpFDeg();
6116 if ((op > o)
6117 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6118 an=i;
6119 else
6120 en=i;
6121 }
6122}
#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 6160 of file kutil.cc.

6162{
6163 if (length < 0) return 0;
6164 int an,en,i;
6165 an = 0;
6166 en = length+1;
6167 loop
6168 {
6169 if (an >= en-1)
6170 {
6171 if(an == en)
6172 return en;
6173 if (set[an].FDeg > p->FDeg)
6174 return en;
6175 if (set[an].FDeg < p->FDeg)
6176 return an;
6177 if (set[an].FDeg == p->FDeg)
6178 {
6179 number lcset,lcp;
6180 lcset = pGetCoeff(set[an].p);
6181 lcp = pGetCoeff(p->p);
6182 if(!nGreaterZero(lcset))
6183 {
6184 set[an].p=p_Neg(set[an].p,currRing);
6185 if (set[an].t_p!=NULL)
6186 pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
6187 lcset=pGetCoeff(set[an].p);
6188 }
6189 if(!nGreaterZero(lcp))
6190 {
6191 p->p=p_Neg(p->p,currRing);
6192 if (p->t_p!=NULL)
6193 pSetCoeff0(p->t_p,pGetCoeff(p->p));
6194 lcp=pGetCoeff(p->p);
6195 }
6196 if(nGreater(lcset, lcp))
6197 {
6198 return en;
6199 }
6200 else
6201 {
6202 return an;
6203 }
6204 }
6205 }
6206 i=(an+en) / 2;
6207 if (set[i].FDeg > p->FDeg)
6208 an=i;
6209 if (set[i].FDeg < p->FDeg)
6210 en=i;
6211 if (set[i].FDeg == p->FDeg)
6212 {
6213 number lcset,lcp;
6214 lcset = pGetCoeff(set[i].p);
6215 lcp = pGetCoeff(p->p);
6216 if(!nGreaterZero(lcset))
6217 {
6218 set[i].p=p_Neg(set[i].p,currRing);
6219 if (set[i].t_p!=NULL)
6220 pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6221 lcset=pGetCoeff(set[i].p);
6222 }
6223 if(!nGreaterZero(lcp))
6224 {
6225 p->p=p_Neg(p->p,currRing);
6226 if (p->t_p!=NULL)
6227 pSetCoeff0(p->t_p,pGetCoeff(p->p));
6228 lcp=pGetCoeff(p->p);
6229 }
6230 if(nGreater(lcset, lcp))
6231 {
6232 an = i;
6233 }
6234 else
6235 {
6236 en = i;
6237 }
6238 }
6239 }
6240}
#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 6434 of file kutil.cc.

6436{
6437 if (length<0) return 0;
6438
6439 int o = p->GetpFDeg();
6440
6441 if (set[length].GetpFDeg() > o)
6442 return length+1;
6443
6444 int i;
6445 int an = 0;
6446 int en= length;
6447 loop
6448 {
6449 if (an >= en-1)
6450 {
6451 if (set[an].GetpFDeg() >= o)
6452 return en;
6453 return an;
6454 }
6455 i=(an+en) / 2;
6456 if (set[i].GetpFDeg() >= o)
6457 an=i;
6458 else
6459 en=i;
6460 }
6461}

◆ posInL15()

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

Definition at line 6469 of file kutil.cc.

6471{
6472 if (length<0) return 0;
6473
6474 int o = p->GetpFDeg() + p->ecart;
6475 int op = set[length].GetpFDeg() + set[length].ecart;
6476
6477 if ((op > o)
6478 || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6479 return length+1;
6480 int i;
6481 int an = 0;
6482 int en= length;
6483 loop
6484 {
6485 if (an >= en-1)
6486 {
6487 op = set[an].GetpFDeg() + set[an].ecart;
6488 if ((op > o)
6489 || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6490 return en;
6491 return an;
6492 }
6493 i=(an+en) / 2;
6494 op = set[i].GetpFDeg() + set[i].ecart;
6495 if ((op > o)
6496 || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6497 an=i;
6498 else
6499 en=i;
6500 }
6501}

◆ posInL15Ring()

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

Definition at line 6504 of file kutil.cc.

6506{
6507 if (length<0) return 0;
6508
6509 int o = p->GetpFDeg() + p->ecart;
6510 int op = set[length].GetpFDeg() + set[length].ecart;
6511
6512 if ((op > o)
6513 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6514 return length+1;
6515 int i;
6516 int an = 0;
6517 int en= length;
6518 loop
6519 {
6520 if (an >= en-1)
6521 {
6522 op = set[an].GetpFDeg() + set[an].ecart;
6523 if ((op > o)
6524 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6525 return en;
6526 return an;
6527 }
6528 i=(an+en) / 2;
6529 op = set[i].GetpFDeg() + set[i].ecart;
6530 if ((op > o)
6531 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6532 an=i;
6533 else
6534 en=i;
6535 }
6536}

◆ posInL17()

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

Definition at line 6545 of file kutil.cc.

6547{
6548 if (length<0) return 0;
6549
6550 int o = p->GetpFDeg() + p->ecart;
6551
6552 if ((set[length].GetpFDeg() + set[length].ecart > o)
6553 || ((set[length].GetpFDeg() + set[length].ecart == o)
6554 && (set[length].ecart > p->ecart))
6555 || ((set[length].GetpFDeg() + set[length].ecart == o)
6556 && (set[length].ecart == p->ecart)
6557 && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6558 return length+1;
6559 int i;
6560 int an = 0;
6561 int en= length;
6562 loop
6563 {
6564 if (an >= en-1)
6565 {
6566 if ((set[an].GetpFDeg() + set[an].ecart > o)
6567 || ((set[an].GetpFDeg() + set[an].ecart == o)
6568 && (set[an].ecart > p->ecart))
6569 || ((set[an].GetpFDeg() + set[an].ecart == o)
6570 && (set[an].ecart == p->ecart)
6571 && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6572 return en;
6573 return an;
6574 }
6575 i=(an+en) / 2;
6576 if ((set[i].GetpFDeg() + set[i].ecart > o)
6577 || ((set[i].GetpFDeg() + set[i].ecart == o)
6578 && (set[i].ecart > p->ecart))
6579 || ((set[i].GetpFDeg() +set[i].ecart == o)
6580 && (set[i].ecart == p->ecart)
6581 && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6582 an=i;
6583 else
6584 en=i;
6585 }
6586}

◆ posInLF5C()

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

Definition at line 6036 of file kutil.cc.

6038{
6039 return strat->Ll+1;
6040}

◆ posInLF5CRing()

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

Definition at line 6124 of file kutil.cc.

6126{
6127 if (length<0) return 0;
6128 if(start == (length +1)) return (length+1);
6129 int o = p->GetpFDeg();
6130 int op = set[length].GetpFDeg();
6131
6132 if ((op > o)
6133 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6134 return length+1;
6135 int i;
6136 int an = start;
6137 int en= length;
6138 loop
6139 {
6140 if (an >= en-1)
6141 {
6142 op = set[an].GetpFDeg();
6143 if ((op > o)
6144 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6145 return en;
6146 return an;
6147 }
6148 i=(an+en) / 2;
6149 op = set[i].GetpFDeg();
6150 if ((op > o)
6151 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6152 an=i;
6153 else
6154 en=i;
6155 }
6156}

◆ posInLRing()

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

Definition at line 5935 of file kutil.cc.

5937{
5938 if (length < 0) return 0;
5939 if (set[length].FDeg > p->FDeg)
5940 return length+1;
5941 if (set[length].FDeg == p->FDeg)
5942 if(set[length].GetpLength() > p->GetpLength())
5943 return length+1;
5944 int i;
5945 int an = 0;
5946 int en= length+1;
5947 loop
5948 {
5949 if (an >= en-1)
5950 {
5951 if(an == en)
5952 return en;
5953 if (set[an].FDeg > p->FDeg)
5954 return en;
5955 if(set[an].FDeg == p->FDeg)
5956 {
5957 if(set[an].GetpLength() > p->GetpLength())
5958 return en;
5959 else
5960 {
5961 if(set[an].GetpLength() == p->GetpLength())
5962 {
5963 if(nGreater(set[an].p->coef, p->p->coef))
5964 return en;
5965 else
5966 return an;
5967 }
5968 else
5969 {
5970 return an;
5971 }
5972 }
5973 }
5974 else
5975 return an;
5976 }
5977 i=(an+en) / 2;
5978 if (set[i].FDeg > p->FDeg)
5979 an=i;
5980 else
5981 {
5982 if(set[i].FDeg == p->FDeg)
5983 {
5984 if(set[i].GetpLength() > p->GetpLength())
5985 an=i;
5986 else
5987 {
5988 if(set[i].GetpLength() == p->GetpLength())
5989 {
5990 if(nGreater(set[i].p->coef, p->p->coef))
5991 an = i;
5992 else
5993 en = i;
5994 }
5995 else
5996 {
5997 en=i;
5998 }
5999 }
6000 }
6001 else
6002 en=i;
6003 }
6004 }
6005}

◆ posInLSig()

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

Definition at line 5848 of file kutil.cc.

5850{
5851 if (length<0) return 0;
5852 if (pLtCmp(set[length].sig,p->sig)== currRing->OrdSgn)
5853 return length+1;
5854
5855 int i;
5856 int an = 0;
5857 int en= length;
5858 loop
5859 {
5860 if (an >= en-1)
5861 {
5862 if (pLtCmp(set[an].sig,p->sig) == currRing->OrdSgn) return en;
5863 return an;
5864 }
5865 i=(an+en) / 2;
5866 if (pLtCmp(set[i].sig,p->sig) == currRing->OrdSgn) an=i;
5867 else en=i;
5868 /*aend. fuer lazy == in !=- machen */
5869 }
5870}

◆ posInLSigRing()

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

Definition at line 5872 of file kutil.cc.

5874{
5875 assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
5876 if (length<0) return 0;
5877 if (pLtCmp(set[length].sig,p->sig)== 1)
5878 return length+1;
5879
5880 int an,en,i;
5881 an = 0;
5882 en = length+1;
5883 int cmp;
5884 loop
5885 {
5886 if (an >= en-1)
5887 {
5888 if(an == en)
5889 return en;
5890 cmp = pLtCmp(set[an].sig,p->sig);
5891 if (cmp == 1)
5892 return en;
5893 if (cmp == -1)
5894 return an;
5895 if (cmp == 0)
5896 {
5897 if (set[an].FDeg > p->FDeg)
5898 return en;
5899 if (set[an].FDeg < p->FDeg)
5900 return an;
5901 if (set[an].FDeg == p->FDeg)
5902 {
5903 cmp = pLtCmp(set[an].p,p->p);
5904 if(cmp == 1)
5905 return en;
5906 else
5907 return an;
5908 }
5909 }
5910 }
5911 i=(an+en) / 2;
5912 cmp = pLtCmp(set[i].sig,p->sig);
5913 if (cmp == 1)
5914 an = i;
5915 if (cmp == -1)
5916 en = i;
5917 if (cmp == 0)
5918 {
5919 if (set[i].FDeg > p->FDeg)
5920 an = i;
5921 if (set[i].FDeg < p->FDeg)
5922 en = i;
5923 if (set[i].FDeg == p->FDeg)
5924 {
5925 cmp = pLtCmp(set[i].p,p->p);
5926 if(cmp == 1)
5927 an = i;
5928 else
5929 en = i;
5930 }
5931 }
5932 }
5933}

◆ posInS()

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

Definition at line 4763 of file kutil.cc.

4765{
4766 if(length==-1) return 0;
4767 polyset set=strat->S;
4768 int i;
4769 int an = 0;
4770 int en = length;
4771 int cmp_int = currRing->OrdSgn;
4773#ifdef HAVE_PLURAL
4774 && (currRing->real_var_start==0)
4775#endif
4776#if 0
4777 || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
4778#endif
4779 )
4780 {
4781 int o=p_Deg(p,currRing);
4782 int oo=p_Deg(set[length],currRing);
4783
4784 if ((oo<o)
4785 || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
4786 return length+1;
4787
4788 loop
4789 {
4790 if (an >= en-1)
4791 {
4792 if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
4793 {
4794 return an;
4795 }
4796 return en;
4797 }
4798 i=(an+en) / 2;
4799 if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
4800 else an=i;
4801 }
4802 }
4803 else
4804 {
4806 {
4807 if (pLmCmp(set[length],p)== -cmp_int)
4808 return length+1;
4809 int cmp;
4810 loop
4811 {
4812 if (an >= en-1)
4813 {
4814 cmp = pLmCmp(set[an],p);
4815 if (cmp == cmp_int) return an;
4816 if (cmp == -cmp_int) return en;
4817 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
4818 return an;
4819 }
4820 i = (an+en) / 2;
4821 cmp = pLmCmp(set[i],p);
4822 if (cmp == cmp_int) en = i;
4823 else if (cmp == -cmp_int) an = i;
4824 else
4825 {
4826 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
4827 else en = i;
4828 }
4829 }
4830 }
4831 else
4832 if (pLmCmp(set[length],p)== -cmp_int)
4833 return length+1;
4834
4835 loop
4836 {
4837 if (an >= en-1)
4838 {
4839 if (pLmCmp(set[an],p) == cmp_int) return an;
4840 if (pLmCmp(set[an],p) == -cmp_int) return en;
4841 if ((cmp_int!=1)
4842 && ((strat->ecartS[an])>ecart_p))
4843 return an;
4844 return en;
4845 }
4846 i=(an+en) / 2;
4847 if (pLmCmp(set[i],p) == cmp_int) en=i;
4848 else if (pLmCmp(set[i],p) == -cmp_int) an=i;
4849 else
4850 {
4851 if ((cmp_int!=1)
4852 &&((strat->ecartS[i])<ecart_p))
4853 en=i;
4854 else
4855 an=i;
4856 }
4857 }
4858 }
4859}

◆ posInSMonFirst()

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

Definition at line 4864 of file kutil.cc.

4865{
4866 if (length<0) return 0;
4867 polyset set=strat->S;
4868 if(pNext(p) == NULL)
4869 {
4870 int mon = 0;
4871 for(int i = 0;i<=length;i++)
4872 {
4873 if(set[i] != NULL && pNext(set[i]) == NULL)
4874 mon++;
4875 }
4876 int o = p_Deg(p,currRing);
4877 int op = p_Deg(set[mon],currRing);
4878
4879 if ((op < o)
4880 || ((op == o) && (pLtCmp(set[mon],p) == -1)))
4881 return length+1;
4882 int i;
4883 int an = 0;
4884 int en= mon;
4885 loop
4886 {
4887 if (an >= en-1)
4888 {
4889 op = p_Deg(set[an],currRing);
4890 if ((op < o)
4891 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4892 return en;
4893 return an;
4894 }
4895 i=(an+en) / 2;
4896 op = p_Deg(set[i],currRing);
4897 if ((op < o)
4898 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4899 an=i;
4900 else
4901 en=i;
4902 }
4903 }
4904 else /*if(pNext(p) != NULL)*/
4905 {
4906 int o = p_Deg(p,currRing);
4907 int op = p_Deg(set[length],currRing);
4908
4909 if ((op < o)
4910 || ((op == o) && (pLtCmp(set[length],p) == -1)))
4911 return length+1;
4912 int i;
4913 int an = 0;
4914 for(i=0;i<=length;i++)
4915 if(set[i] != NULL && pNext(set[i]) == NULL)
4916 an++;
4917 int en= length;
4918 loop
4919 {
4920 if (an >= en-1)
4921 {
4922 op = p_Deg(set[an],currRing);
4923 if ((op < o)
4924 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4925 return en;
4926 return an;
4927 }
4928 i=(an+en) / 2;
4929 op = p_Deg(set[i],currRing);
4930 if ((op < o)
4931 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4932 an=i;
4933 else
4934 en=i;
4935 }
4936 }
4937}

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 6008 of file kutil.cc.

6009{
6010 if (strat->syzl==0) return 0;
6011 if (pLtCmp(strat->syz[strat->syzl-1],sig) != currRing->OrdSgn)
6012 return strat->syzl;
6013 int i;
6014 int an = 0;
6015 int en= strat->syzl-1;
6016 loop
6017 {
6018 if (an >= en-1)
6019 {
6020 if (pLtCmp(strat->syz[an],sig) != currRing->OrdSgn) return en;
6021 return an;
6022 }
6023 i=(an+en) / 2;
6024 if (pLtCmp(strat->syz[i],sig) != currRing->OrdSgn) an=i;
6025 else en=i;
6026 /*aend. fuer lazy == in !=- machen */
6027 }
6028}

◆ posInT0()

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

Definition at line 4985 of file kutil.cc.

4986{
4987 return (length+1);
4988}

◆ posInT1()

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

Definition at line 4996 of file kutil.cc.

4997{
4998 if (length==-1) return 0;
4999
5000 if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
5001
5002 int i;
5003 int an = 0;
5004 int en= length;
5005
5006 loop
5007 {
5008 if (an >= en-1)
5009 {
5010 if (pLmCmp(set[an].p,p.p) == currRing->OrdSgn) return an;
5011 return en;
5012 }
5013 i=(an+en) / 2;
5014 if (pLmCmp(set[i].p,p.p) == currRing->OrdSgn) en=i;
5015 else an=i;
5016 }
5017}

◆ posInT11()

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

Definition at line 5052 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5205 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5294 of file kutil.cc.

5295{
5296 if (length==-1) return 0;
5297
5298 int o = p.GetpFDeg();
5299
5300 if (set[length].GetpFDeg() <= o)
5301 return length+1;
5302
5303 int i;
5304 int an = 0;
5305 int en= length;
5306 loop
5307 {
5308 if (an >= en-1)
5309 {
5310 if (set[an].GetpFDeg() > o)
5311 return an;
5312 return en;
5313 }
5314 i=(an+en) / 2;
5315 if (set[i].GetpFDeg() > o)
5316 en=i;
5317 else
5318 an=i;
5319 }
5320}

◆ posInT15()

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

Definition at line 5361 of file kutil.cc.

5380{
5381 if (length==-1) return 0;
5382
5383 int o = p.GetpFDeg() + p.ecart;
5384 int op = set[length].GetpFDeg()+set[length].ecart;
5385
5386 if ((op < o)
5387 || ((op == o)
5388 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5389 return length+1;
5390
5391 int i;
5392 int an = 0;
5393 int en= length;
5394 loop
5395 {
5396 if (an >= en-1)
5397 {
5398 op = set[an].GetpFDeg()+set[an].ecart;
5399 if (( op > o)
5400 || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5401 return an;
5402 return en;
5403 }
5404 i=(an+en) / 2;
5405 op = set[i].GetpFDeg()+set[i].ecart;
5406 if (( op > o)
5407 || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5408 en=i;
5409 else
5410 an=i;
5411 }
5412}

◆ posInT17()

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

Definition at line 5456 of file kutil.cc.

5477{
5478 if (length==-1) return 0;
5479
5480 int o = p.GetpFDeg() + p.ecart;
5481 int op = set[length].GetpFDeg()+set[length].ecart;
5482
5483 if ((op < o)
5484 || (( op == o) && (set[length].ecart > p.ecart))
5485 || (( op == o) && (set[length].ecart==p.ecart)
5486 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5487 return length+1;
5488
5489 int i;
5490 int an = 0;
5491 int en= length;
5492 loop
5493 {
5494 if (an >= en-1)
5495 {
5496 op = set[an].GetpFDeg()+set[an].ecart;
5497 if (( op > o)
5498 || (( op == o) && (set[an].ecart < p.ecart))
5499 || (( op == o) && (set[an].ecart==p.ecart)
5500 && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5501 return an;
5502 return en;
5503 }
5504 i=(an+en) / 2;
5505 op = set[i].GetpFDeg()+set[i].ecart;
5506 if ((op > o)
5507 || (( op == o) && (set[i].ecart < p.ecart))
5508 || (( op == o) && (set[i].ecart == p.ecart)
5509 && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5510 en=i;
5511 else
5512 an=i;
5513 }
5514}

◆ posInT17_c()

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

Definition at line 5563 of file kutil.cc.

5564{
5565 if (length==-1) return 0;
5566
5567 int cc = (-1+2*currRing->order[0]==ringorder_c);
5568 /* cc==1 for (c,..), cc==-1 for (C,..) */
5569 int o = p.GetpFDeg() + p.ecart;
5570 int c = pGetComp(p.p)*cc;
5571
5572 if (pGetComp(set[length].p)*cc < c)
5573 return length+1;
5574 if (pGetComp(set[length].p)*cc == c)
5575 {
5576 int op = set[length].GetpFDeg()+set[length].ecart;
5577 if ((op < o)
5578 || ((op == o) && (set[length].ecart > p.ecart))
5579 || ((op == o) && (set[length].ecart==p.ecart)
5580 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5581 return length+1;
5582 }
5583
5584 int i;
5585 int an = 0;
5586 int en= length;
5587 loop
5588 {
5589 if (an >= en-1)
5590 {
5591 if (pGetComp(set[an].p)*cc < c)
5592 return en;
5593 if (pGetComp(set[an].p)*cc == c)
5594 {
5595 int op = set[an].GetpFDeg()+set[an].ecart;
5596 if ((op > o)
5597 || ((op == o) && (set[an].ecart < p.ecart))
5598 || ((op == o) && (set[an].ecart==p.ecart)
5599 && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5600 return an;
5601 }
5602 return en;
5603 }
5604 i=(an+en) / 2;
5605 if (pGetComp(set[i].p)*cc > c)
5606 en=i;
5607 else if (pGetComp(set[i].p)*cc == c)
5608 {
5609 int op = set[i].GetpFDeg()+set[i].ecart;
5610 if ((op > o)
5611 || ((op == o) && (set[i].ecart < p.ecart))
5612 || ((op == o) && (set[i].ecart == p.ecart)
5613 && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5614 en=i;
5615 else
5616 an=i;
5617 }
5618 else
5619 an=i;
5620 }
5621}

◆ posInT19()

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

Definition at line 5690 of file kutil.cc.

5691{
5692 p.GetpLength();
5693 if (length==-1) return 0;
5694
5695 int o = p.ecart;
5696 int op=p.GetpFDeg();
5697
5698 if (set[length].ecart < o)
5699 return length+1;
5700 if (set[length].ecart == o)
5701 {
5702 int oo=set[length].GetpFDeg();
5703 if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5704 return length+1;
5705 }
5706
5707 int i;
5708 int an = 0;
5709 int en= length;
5710 loop
5711 {
5712 if (an >= en-1)
5713 {
5714 if (set[an].ecart > o)
5715 return an;
5716 if (set[an].ecart == o)
5717 {
5718 int oo=set[an].GetpFDeg();
5719 if((oo > op)
5720 || ((oo==op) && (set[an].length > p.length)))
5721 return an;
5722 }
5723 return en;
5724 }
5725 i=(an+en) / 2;
5726 if (set[i].ecart > o)
5727 en=i;
5728 else if (set[i].ecart == o)
5729 {
5730 int oo=set[i].GetpFDeg();
5731 if ((oo > op)
5732 || ((oo == op) && (set[i].length > p.length)))
5733 en=i;
5734 else
5735 an=i;
5736 }
5737 else
5738 an=i;
5739 }
5740}

◆ posInT2()

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

Definition at line 5024 of file kutil.cc.

5025{
5026 if (length==-1) return 0;
5027 p.GetpLength();
5028 if (set[length].length<p.length) return length+1;
5029
5030 int i;
5031 int an = 0;
5032 int en= length;
5033
5034 loop
5035 {
5036 if (an >= en-1)
5037 {
5038 if (set[an].length>p.length) return an;
5039 return en;
5040 }
5041 i=(an+en) / 2;
5042 if (set[i].length>p.length) en=i;
5043 else an=i;
5044 }
5045}

◆ posInT_EcartFDegpLength()

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

Definition at line 11692 of file kutil.cc.

11693{
11694
11695 if (length==-1) return 0;
11696
11697 int o = p.ecart;
11698 int op=p.GetpFDeg();
11699 int ol = p.GetpLength();
11700
11701 if (set[length].ecart < o)
11702 return length+1;
11703 if (set[length].ecart == o)
11704 {
11705 int oo=set[length].GetpFDeg();
11706 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11707 return length+1;
11708 }
11709
11710 int i;
11711 int an = 0;
11712 int en= length;
11713 loop
11714 {
11715 if (an >= en-1)
11716 {
11717 if (set[an].ecart > o)
11718 return an;
11719 if (set[an].ecart == o)
11720 {
11721 int oo=set[an].GetpFDeg();
11722 if((oo > op)
11723 || ((oo==op) && (set[an].pLength > ol)))
11724 return an;
11725 }
11726 return en;
11727 }
11728 i=(an+en) / 2;
11729 if (set[i].ecart > o)
11730 en=i;
11731 else if (set[i].ecart == o)
11732 {
11733 int oo=set[i].GetpFDeg();
11734 if ((oo > op)
11735 || ((oo == op) && (set[i].pLength > ol)))
11736 en=i;
11737 else
11738 an=i;
11739 }
11740 else
11741 an=i;
11742 }
11743}

◆ posInT_EcartpLength()

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

Definition at line 5323 of file kutil.cc.

5324{
5325 if (length==-1) return 0;
5326 int ol = p.GetpLength();
5327 int op=p.ecart;
5328 int oo=set[length].ecart;
5329
5330 if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5331 return length+1;
5332
5333 int i;
5334 int an = 0;
5335 int en= length;
5336 loop
5337 {
5338 if (an >= en-1)
5339 {
5340 int oo=set[an].ecart;
5341 if((oo > op)
5342 || ((oo==op) && (set[an].pLength > ol)))
5343 return an;
5344 return en;
5345 }
5346 i=(an+en) / 2;
5347 int oo=set[i].ecart;
5348 if ((oo > op)
5349 || ((oo == op) && (set[i].pLength > ol)))
5350 en=i;
5351 else
5352 an=i;
5353 }
5354}

◆ posInT_FDegpLength()

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

Definition at line 11746 of file kutil.cc.

11747{
11748
11749 if (length==-1) return 0;
11750
11751 int op=p.GetpFDeg();
11752 int ol = p.GetpLength();
11753
11754 int oo=set[length].GetpFDeg();
11755 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11756 return length+1;
11757
11758 int i;
11759 int an = 0;
11760 int en= length;
11761 loop
11762 {
11763 if (an >= en-1)
11764 {
11765 int oo=set[an].GetpFDeg();
11766 if((oo > op)
11767 || ((oo==op) && (set[an].pLength > ol)))
11768 return an;
11769 return en;
11770 }
11771 i=(an+en) / 2;
11772 int oo=set[i].GetpFDeg();
11773 if ((oo > op)
11774 || ((oo == op) && (set[i].pLength > ol)))
11775 en=i;
11776 else
11777 an=i;
11778 }
11779}

◆ posInT_pLength()

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

Definition at line 11783 of file kutil.cc.

11784{
11785 int ol = p.GetpLength();
11786 if (length==-1)
11787 return 0;
11788 if (set[length].length<p.length)
11789 return length+1;
11790
11791 int i;
11792 int an = 0;
11793 int en= length;
11794
11795 loop
11796 {
11797 if (an >= en-1)
11798 {
11799 if (set[an].pLength>ol) return an;
11800 return en;
11801 }
11802 i=(an+en) / 2;
11803 if (set[i].pLength>ol) en=i;
11804 else an=i;
11805 }
11806}

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

11021{
11022 if(!nCoeff_is_Z(currRing->cf))
11023 return;
11024 poly pH = h->GetP();
11025 poly p,pp;
11026 p = pH;
11027 bool deleted = FALSE, ok = FALSE;
11028 for(int i = 0; i<=strat->sl; i++)
11029 {
11030 p = pH;
11031 if(pNext(strat->S[i]) == NULL)
11032 {
11033 //pWrite(p);
11034 //pWrite(strat->S[i]);
11035 while(ok == FALSE && p != NULL)
11036 {
11037 if(pLmDivisibleBy(strat->S[i], p)
11038#ifdef HAVE_SHIFTBBA
11039 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
11040#endif
11041 )
11042 {
11043 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11044 p_SetCoeff(p,dummy,currRing);
11045 }
11046 if(nIsZero(p->coef))
11047 {
11048 pLmDelete(&p);
11049 h->p = p;
11050 deleted = TRUE;
11051 }
11052 else
11053 {
11054 ok = TRUE;
11055 }
11056 }
11057 if (p!=NULL)
11058 {
11059 pp = pNext(p);
11060 while(pp != NULL)
11061 {
11062 if(pLmDivisibleBy(strat->S[i], pp)
11063#ifdef HAVE_SHIFTBBA
11064 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
11065#endif
11066 )
11067 {
11068 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11069 p_SetCoeff(pp,dummy,currRing);
11070 if(nIsZero(pp->coef))
11071 {
11072 pLmDelete(&pNext(p));
11073 pp = pNext(p);
11074 deleted = TRUE;
11075 }
11076 else
11077 {
11078 p = pp;
11079 pp = pNext(p);
11080 }
11081 }
11082 else
11083 {
11084 p = pp;
11085 pp = pNext(p);
11086 }
11087 }
11088 }
11089 }
11090 }
11091 h->SetLmCurrRing();
11092 if((deleted)&&(h->p!=NULL))
11093 strat->initEcart(h);
11094}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 11096 of file kutil.cc.

11097{
11098 if(!nCoeff_is_Z(currRing->cf))
11099 return;
11100 poly hSig = h->sig;
11101 poly pH = h->GetP();
11102 poly p,pp;
11103 p = pH;
11104 bool deleted = FALSE, ok = FALSE;
11105 for(int i = 0; i<=strat->sl; i++)
11106 {
11107 p = pH;
11108 if(pNext(strat->S[i]) == NULL)
11109 {
11110 while(ok == FALSE && p!=NULL)
11111 {
11112 if(pLmDivisibleBy(strat->S[i], p))
11113 {
11114 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11115 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11116 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11117 {
11118 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11119 p_SetCoeff(p,dummy,currRing);
11120 }
11121 pDelete(&sigMult);
11122 }
11123 if(nIsZero(p->coef))
11124 {
11125 pLmDelete(&p);
11126 h->p = p;
11127 deleted = TRUE;
11128 }
11129 else
11130 {
11131 ok = TRUE;
11132 }
11133 }
11134 if(p == NULL)
11135 return;
11136 pp = pNext(p);
11137 while(pp != NULL)
11138 {
11139 if(pLmDivisibleBy(strat->S[i], pp))
11140 {
11141 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11142 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11143 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11144 {
11145 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11146 p_SetCoeff(pp,dummy,currRing);
11147 if(nIsZero(pp->coef))
11148 {
11149 pLmDelete(&pNext(p));
11150 pp = pNext(p);
11151 deleted = TRUE;
11152 }
11153 else
11154 {
11155 p = pp;
11156 pp = pNext(p);
11157 }
11158 }
11159 else
11160 {
11161 p = pp;
11162 pp = pNext(p);
11163 }
11164 pDelete(&sigMult);
11165 }
11166 else
11167 {
11168 p = pp;
11169 pp = pNext(p);
11170 }
11171 }
11172 }
11173 }
11174 h->SetLmCurrRing();
11175 if(deleted)
11176 strat->initEcart(h);
11177
11178}
#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 10853 of file kutil.cc.

10854{
10855 if(!nCoeff_is_Z(currRing->cf))
10856 return NULL;
10857 ideal F = idCopy(Forig);
10858 idSkipZeroes(F);
10859 poly pmon;
10860 ring origR = currRing;
10861 ideal monred = idInit(1,1);
10862 for(int i=0; i<idElem(F); i++)
10863 {
10864 if(pNext(F->m[i]) == NULL)
10865 idInsertPoly(monred, pCopy(F->m[i]));
10866 }
10867 int posconst = idPosConstant(F);
10868 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10869 {
10870 idDelete(&F);
10871 idDelete(&monred);
10872 return NULL;
10873 }
10874 int idelemQ = 0;
10875 if(Q!=NULL)
10876 {
10877 idelemQ = IDELEMS(Q);
10878 for(int i=0; i<idelemQ; i++)
10879 {
10880 if(pNext(Q->m[i]) == NULL)
10881 idInsertPoly(monred, pCopy(Q->m[i]));
10882 }
10883 idSkipZeroes(monred);
10884 posconst = idPosConstant(monred);
10885 //the constant, if found, will be from Q
10886 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10887 {
10888 pmon = pCopy(monred->m[posconst]);
10889 idDelete(&F);
10890 idDelete(&monred);
10891 return pmon;
10892 }
10893 }
10894 ring QQ_ring = rCopy0(currRing,FALSE);
10895 nKillChar(QQ_ring->cf);
10896 QQ_ring->cf = nInitChar(n_Q, NULL);
10897 rComplete(QQ_ring,1);
10898 QQ_ring = rAssure_c_dp(QQ_ring);
10899 rChangeCurrRing(QQ_ring);
10900 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10901 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10902 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10903 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10904 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10905 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10906 ideal one = kStd(II, NULL, isNotHomog, NULL);
10907 idSkipZeroes(one);
10908 if(idIsConstant(one))
10909 {
10910 //one should be <1>
10911 for(int i = IDELEMS(II)-1; i>=0; i--)
10912 if(II->m[i] != NULL)
10913 II->m[i+1] = II->m[i];
10914 II->m[0] = pOne();
10915 ideal syz = idSyzygies(II, isNotHomog, NULL);
10916 poly integer = NULL;
10917 for(int i = IDELEMS(syz)-1;i>=0; i--)
10918 {
10919 if(pGetComp(syz->m[i]) == 1)
10920 {
10921 pSetComp(syz->m[i],0);
10922 if(pIsConstant(pHead(syz->m[i])))
10923 {
10924 integer = pHead(syz->m[i]);
10925 break;
10926 }
10927 }
10928 }
10929 rChangeCurrRing(origR);
10930 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10931 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10932 idDelete(&monred);
10933 idDelete(&F);
10934 id_Delete(&II,QQ_ring);
10935 id_Delete(&one,QQ_ring);
10936 id_Delete(&syz,QQ_ring);
10937 p_Delete(&integer,QQ_ring);
10938 rDelete(QQ_ring);
10939 return pmon;
10940 }
10941 else
10942 {
10943 if(idIs0(monred))
10944 {
10945 poly mindegmon = NULL;
10946 for(int i = 0; i<IDELEMS(one); i++)
10947 {
10948 if(pNext(one->m[i]) == NULL)
10949 {
10950 if(mindegmon == NULL)
10951 mindegmon = pCopy(one->m[i]);
10952 else
10953 {
10954 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10955 mindegmon = pCopy(one->m[i]);
10956 }
10957 }
10958 }
10959 if(mindegmon != NULL)
10960 {
10961 for(int i = IDELEMS(II)-1; i>=0; i--)
10962 if(II->m[i] != NULL)
10963 II->m[i+1] = II->m[i];
10964 II->m[0] = pCopy(mindegmon);
10965 ideal syz = idSyzygies(II, isNotHomog, NULL);
10966 bool found = FALSE;
10967 for(int i = IDELEMS(syz)-1;i>=0; i--)
10968 {
10969 if(pGetComp(syz->m[i]) == 1)
10970 {
10971 pSetComp(syz->m[i],0);
10972 if(pIsConstant(pHead(syz->m[i])))
10973 {
10974 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10975 found = TRUE;
10976 break;
10977 }
10978 }
10979 }
10980 id_Delete(&syz,QQ_ring);
10981 if (found == FALSE)
10982 {
10983 rChangeCurrRing(origR);
10984 idDelete(&monred);
10985 idDelete(&F);
10986 id_Delete(&II,QQ_ring);
10987 id_Delete(&one,QQ_ring);
10988 rDelete(QQ_ring);
10989 return NULL;
10990 }
10991 rChangeCurrRing(origR);
10992 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10993 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10994 idDelete(&monred);
10995 idDelete(&F);
10996 id_Delete(&II,QQ_ring);
10997 id_Delete(&one,QQ_ring);
10998 id_Delete(&syz,QQ_ring);
10999 rDelete(QQ_ring);
11000 return pmon;
11001 }
11002 }
11003 }
11004 rChangeCurrRing(origR);
11005 idDelete(&monred);
11006 idDelete(&F);
11007 id_Delete(&II,QQ_ring);
11008 id_Delete(&one,QQ_ring);
11009 rDelete(QQ_ring);
11010 return NULL;
11011}
@ 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:700
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:354
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:522
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:2433
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:3492
ring rAssure_c_dp(const ring r)
Definition: ring.cc:5070
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
int idElem(const ideal F)
count non-zero elements
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
@ isNotHomog
Definition: structs.h:36

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4731 of file kstd2.cc.

4732{
4733 if (h->IsNull()) return 0;
4734
4735 int at, reddeg,d;
4736 int pass = 0;
4737 int j = 0;
4738
4739 if (! strat->homog)
4740 {
4741 d = h->GetpFDeg() + h->ecart;
4742 reddeg = strat->LazyDegree+d;
4743 }
4744 h->SetShortExpVector();
4745 loop
4746 {
4747 j = kFindDivisibleByInT(strat, h);
4748 if (j < 0)
4749 {
4750 h->SetDegStuffReturnLDeg(strat->LDegLast);
4751 return 1;
4752 }
4753
4755 strat->T[j].pNorm();
4756#ifdef KDEBUG
4757 if (TEST_OPT_DEBUG)
4758 {
4759 PrintS("reduce ");
4760 h->wrp();
4761 PrintS(" with ");
4762 strat->T[j].wrp();
4763 }
4764#endif
4765 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
4766
4767#ifdef KDEBUG
4768 if (TEST_OPT_DEBUG)
4769 {
4770 PrintS("\nto ");
4771 wrp(h->p);
4772 PrintLn();
4773 }
4774#endif
4775 if (h->IsNull())
4776 {
4777 kDeleteLcm(h);
4778 h->Clear();
4779 return 0;
4780 }
4781 h->SetShortExpVector();
4782
4783#if 0
4784 if ((strat->syzComp!=0) && !strat->honey)
4785 {
4786 if ((strat->syzComp>0) &&
4787 (h->Comp() > strat->syzComp))
4788 {
4789 assume(h->MinComp() > strat->syzComp);
4790#ifdef KDEBUG
4791 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
4792#endif
4793 if (strat->homog)
4794 h->SetDegStuffReturnLDeg(strat->LDegLast);
4795 return -2;
4796 }
4797 }
4798#endif
4799 if (!strat->homog)
4800 {
4801 if (!TEST_OPT_OLDSTD && strat->honey)
4802 {
4803 h->SetpFDeg();
4804 if (strat->T[j].ecart <= h->ecart)
4805 h->ecart = d - h->GetpFDeg();
4806 else
4807 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
4808
4809 d = h->GetpFDeg() + h->ecart;
4810 }
4811 else
4812 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
4813 /*- try to reduce the s-polynomial -*/
4814 pass++;
4815 /*
4816 *test whether the polynomial should go to the lazyset L
4817 *-if the degree jumps
4818 *-if the number of pre-defined reductions jumps
4819 */
4820 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
4821 && ((d >= reddeg) || (pass > strat->LazyPass)))
4822 {
4823 h->SetLmCurrRing();
4824 if (strat->posInLDependsOnLength)
4825 h->SetLength(strat->length_pLength);
4826 at = strat->posInL(strat->L,strat->Ll,h,strat);
4827 if (at <= strat->Ll)
4828 {
4829 //int dummy=strat->sl;
4830 /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
4831 //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
4832 if (kFindDivisibleByInT(strat, h) < 0)
4833 return 1;
4834 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
4835#ifdef KDEBUG
4836 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
4837#endif
4838 h->Clear();
4839 return -1;
4840 }
4841 }
4842 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
4843 {
4844 reddeg = d+1;
4845 Print(".%d",d);mflush();
4846 }
4847 }
4848 }
4849}
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:290
#define TEST_OPT_REDTHROUGH
Definition: options.h:122

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 938 of file kstd2.cc.

939{
940 if (strat->tl<0) return 1;
941 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
942 assume(h->FDeg == h->pFDeg());
943
944 poly h_p;
945 int i,j,at,pass,cnt,ii;
946 // long reddeg,d;
947 int li;
948 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
949
950 pass = j = 0;
951 cnt = RED_CANONICALIZE;
952 // d = reddeg = h->GetpFDeg();
953 h->SetShortExpVector();
954 h_p = h->GetLmTailRing();
955 h->PrepareRed(strat->use_buckets);
956 loop
957 {
958 j = kFindDivisibleByInT(strat, h);
959 if (j < 0) return 1;
960
961 li = strat->T[j].pLength;
962 ii = j;
963 /*
964 * the polynomial to reduce with (up to the moment) is;
965 * pi with length li
966 */
967 i = j;
968#if 1
969 if (test_opt_length)
970 {
971 if (li<=0) li=strat->T[j].GetpLength();
972 if (li>2)
973 {
974 unsigned long not_sev = ~ h->sev;
975 loop
976 {
977 /*- search the shortest possible with respect to length -*/
978 i++;
979 if (i > strat->tl)
980 break;
981 if ((strat->T[i].pLength < li)
982 &&
983 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
984 h_p, not_sev, strat->tailRing))
985 {
986 /*
987 * the polynomial to reduce with is now;
988 */
989 li = strat->T[i].pLength;
990 if (li<=0) li=strat->T[i].GetpLength();
991 ii = i;
992 if (li<3) break;
993 }
994 }
995 }
996 }
997#endif
998
999 /*
1000 * end of search: have to reduce with pi
1001 */
1002#ifdef KDEBUG
1003 if (TEST_OPT_DEBUG)
1004 {
1005 PrintS("red:");
1006 h->wrp();
1007 PrintS(" with ");
1008 strat->T[ii].wrp();
1009 }
1010#endif
1011 assume(strat->fromT == FALSE);
1012
1013 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1014#if SBA_PRINT_REDUCTION_STEPS
1015 sba_interreduction_steps++;
1016#endif
1017#if SBA_PRINT_OPERATIONS
1018 sba_interreduction_operations += pLength(strat->T[ii].p);
1019#endif
1020
1021#ifdef KDEBUG
1022 if (TEST_OPT_DEBUG)
1023 {
1024 PrintS("\nto ");
1025 h->wrp();
1026 PrintLn();
1027 }
1028#endif
1029
1030 h_p = h->GetLmTailRing();
1031 if (h_p == NULL)
1032 {
1033 kDeleteLcm(h);
1034 return 0;
1035 }
1037 {
1038 if (h->p!=NULL)
1039 {
1040 if(p_GetComp(h->p,currRing)>strat->syzComp)
1041 {
1042 h->Delete();
1043 return 0;
1044 }
1045 }
1046 else if (h->t_p!=NULL)
1047 {
1048 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1049 {
1050 h->Delete();
1051 return 0;
1052 }
1053 }
1054 }
1055 #if 0
1056 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1057 {
1058 if (h->p!=NULL)
1059 {
1060 if(p_GetComp(h->p,currRing)>strat->syzComp)
1061 {
1062 return 1;
1063 }
1064 }
1065 else if (h->t_p!=NULL)
1066 {
1067 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1068 {
1069 return 1;
1070 }
1071 }
1072 }
1073 #endif
1074 h->SetShortExpVector();
1075 /*
1076 * try to reduce the s-polynomial h
1077 *test first whether h should go to the lazyset L
1078 *-if the degree jumps
1079 *-if the number of pre-defined reductions jumps
1080 */
1081 cnt--;
1082 pass++;
1083 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1084 {
1085 h->SetLmCurrRing();
1086 at = strat->posInL(strat->L,strat->Ll,h,strat);
1087 if (at <= strat->Ll)
1088 {
1089#ifdef HAVE_SHIFTBBA
1090 if (rIsLPRing(currRing))
1091 {
1092 if (kFindDivisibleByInT(strat, h) < 0)
1093 return 1;
1094 }
1095 else
1096#endif
1097 {
1098 int dummy=strat->sl;
1099 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1100 return 1;
1101 }
1102 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1103#ifdef KDEBUG
1104 if (TEST_OPT_DEBUG)
1105 Print(" lazy: -> L%d\n",at);
1106#endif
1107 h->Clear();
1108 return -1;
1109 }
1110 }
1111 else if (UNLIKELY(cnt==0))
1112 {
1113 h->CanonicalizeP();
1114 cnt=RED_CANONICALIZE;
1115 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
1116 }
1117 }
1118}
#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:404
#define RED_CANONICALIZE
Definition: kutil.h:36
#define TEST_OPT_LENGTH
Definition: options.h:131
#define TEST_OPT_REDTAIL_SYZ
Definition: options.h:117

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 1901 of file kstd2.cc.

1902{
1903 if (strat->tl<0) return 1;
1904 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1905 assume(h->FDeg == h->pFDeg());
1906 poly h_p;
1907 int i,j,at,pass,ei, ii, h_d;
1908 long reddeg,d;
1909 int li;
1910 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1911
1912 pass = j = 0;
1913 d = reddeg = h->GetpFDeg() + h->ecart;
1914 h->SetShortExpVector();
1915 h_p = h->GetLmTailRing();
1916
1917 h->PrepareRed(strat->use_buckets);
1918 loop
1919 {
1920 j=kFindDivisibleByInT(strat, h);
1921 if (j < 0) return 1;
1922
1923 ei = strat->T[j].ecart;
1924 li = strat->T[j].pLength;
1925 ii = j;
1926 /*
1927 * the polynomial to reduce with (up to the moment) is;
1928 * pi with ecart ei (T[ii])
1929 */
1930 i = j;
1931 if (test_opt_length)
1932 {
1933 if (li<=0) li=strat->T[j].GetpLength();
1934 if (li>2)
1935 {
1936 unsigned long not_sev = ~ h->sev;
1937 loop
1938 {
1939 /*- takes the first possible with respect to ecart -*/
1940 i++;
1941 if (i > strat->tl) break;
1942 if (ei <= h->ecart) break;
1943 if(p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1944 h_p, not_sev, strat->tailRing))
1945 {
1946 strat->T[i].GetpLength();
1947 if (((strat->T[i].ecart < ei) && (ei> h->ecart))
1948 || ((strat->T[i].ecart <= h->ecart) && (strat->T[i].pLength < li)))
1949 {
1950 /*
1951 * the polynomial to reduce with is now;
1952 */
1953 ei = strat->T[i].ecart;
1954 li = strat->T[i].pLength;
1955 ii = i;
1956 if (li==1) break;
1957 if (ei<=h->ecart) break;
1958 }
1959 }
1960 }
1961 }
1962 }
1963
1964 /*
1965 * end of search: have to reduce with pi
1966 */
1967 if (UNLIKELY(!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart)))
1968 {
1969 h->GetTP(); // clears bucket
1970 h->SetLmCurrRing();
1971 /*
1972 * It is not possible to reduce h with smaller ecart;
1973 * if possible h goes to the lazy-set L,i.e
1974 * if its position in L would be not the last one
1975 */
1976 if (strat->Ll >= 0) /* L is not empty */
1977 {
1978 at = strat->posInL(strat->L,strat->Ll,h,strat);
1979 if(at <= strat->Ll)
1980 /*- h will not become the next element to reduce -*/
1981 {
1982 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1983#ifdef KDEBUG
1984 if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
1985#endif
1986 h->Clear();
1987 return -1;
1988 }
1989 }
1990 }
1991#ifdef KDEBUG
1992 if (TEST_OPT_DEBUG)
1993 {
1994 PrintS("red:");
1995 h->wrp();
1996 Print("\nwith T[%d]:",ii);
1997 strat->T[ii].wrp();
1998 }
1999#endif
2000 assume(strat->fromT == FALSE);
2001
2002 ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,NULL, strat);
2003#if SBA_PRINT_REDUCTION_STEPS
2004 sba_interreduction_steps++;
2005#endif
2006#if SBA_PRINT_OPERATIONS
2007 sba_interreduction_operations += strat->T[ii].pLength;
2008#endif
2009#ifdef KDEBUG
2010 if (TEST_OPT_DEBUG)
2011 {
2012 PrintS("\nto:");
2013 h->wrp();
2014 PrintLn();
2015 }
2016#endif
2017 if(h->IsNull())
2018 {
2019 kDeleteLcm(h);
2020 h->Clear();
2021 return 0;
2022 }
2024 {
2025 if (h->p!=NULL)
2026 {
2027 if(p_GetComp(h->p,currRing)>strat->syzComp)
2028 {
2029 h->Delete();
2030 return 0;
2031 }
2032 }
2033 else if (h->t_p!=NULL)
2034 {
2035 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2036 {
2037 h->Delete();
2038 return 0;
2039 }
2040 }
2041 }
2042 else if (UNLIKELY((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ)))
2043 {
2044 if (h->p!=NULL)
2045 {
2046 if(p_GetComp(h->p,currRing)>strat->syzComp)
2047 {
2048 return 1;
2049 }
2050 }
2051 else if (h->t_p!=NULL)
2052 {
2053 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2054 {
2055 return 1;
2056 }
2057 }
2058 }
2059 h->SetShortExpVector();
2060 h_d = h->SetpFDeg();
2061 /* compute the ecart */
2062 if (ei <= h->ecart)
2063 h->ecart = d-h_d;
2064 else
2065 h->ecart = d-h_d+ei-h->ecart;
2066
2067 /*
2068 * try to reduce the s-polynomial h
2069 *test first whether h should go to the lazyset L
2070 *-if the degree jumps
2071 *-if the number of pre-defined reductions jumps
2072 */
2073 pass++;
2074 d = h_d + h->ecart;
2076 && (strat->Ll >= 0)
2077 && ((d > reddeg) || (pass > strat->LazyPass))))
2078 {
2079 h->GetTP(); // clear bucket
2080 h->SetLmCurrRing();
2081 at = strat->posInL(strat->L,strat->Ll,h,strat);
2082 if (at <= strat->Ll)
2083 {
2084#ifdef HAVE_SHIFTBBA
2085 if (rIsLPRing(currRing))
2086 {
2087 if (kFindDivisibleByInT(strat, h) < 0)
2088 return 1;
2089 }
2090 else
2091#endif
2092 {
2093 int dummy=strat->sl;
2094 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2095 return 1;
2096 }
2097 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2098#ifdef KDEBUG
2099 if (TEST_OPT_DEBUG)
2100 Print(" degree jumped: -> L%d\n",at);
2101#endif
2102 h->Clear();
2103 return -1;
2104 }
2105 }
2106 else if (d > reddeg)
2107 {
2108 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
2109 {
2110 if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask)
2111 {
2112 strat->overflow=TRUE;
2113 //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2114 h->GetP();
2115 at = strat->posInL(strat->L,strat->Ll,h,strat);
2116 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2117 h->Clear();
2118 return -1;
2119 }
2120 }
2121 else if (UNLIKELY(TEST_OPT_PROT && (strat->Ll < 0) ))
2122 {
2123 //h->wrp(); Print("<%d>\n",h->GetpLength());
2124 reddeg = d;
2125 Print(".%ld",d); mflush();
2126 }
2127 }
2128 }
2129}

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1696 of file kstd2.cc.

1697{
1698 if (strat->tl<0) return 1;
1699 int at,i,ii,li;
1700 int j = 0;
1701 int pass = 0;
1702 int cnt = RED_CANONICALIZE;
1703 assume(h->pFDeg() == h->FDeg);
1704 long reddeg = h->GetpFDeg();
1705 long d;
1706 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1707
1708 h->SetShortExpVector();
1709 poly h_p = h->GetLmTailRing();
1710 h->PrepareRed(strat->use_buckets);
1711 loop
1712 {
1713 j = kFindDivisibleByInT(strat, h);
1714 if (j < 0) return 1;
1715
1716 li = strat->T[j].pLength;
1717 ii = j;
1718 /*
1719 * the polynomial to reduce with (up to the moment) is;
1720 * pi with length li
1721 */
1722
1723 i = j;
1724#if 1
1725 if (test_opt_length)
1726 {
1727 if (li<=0) li=strat->T[j].GetpLength();
1728 if(li>2)
1729 {
1730 unsigned long not_sev = ~ h->sev;
1731 loop
1732 {
1733 /*- search the shortest possible with respect to length -*/
1734 i++;
1735 if (i > strat->tl)
1736 break;
1737 if ((strat->T[i].pLength < li)
1738 &&
1739 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1740 h_p, not_sev, strat->tailRing))
1741 {
1742 /*
1743 * the polynomial to reduce with is now;
1744 */
1745 li = strat->T[i].pLength;
1746 if (li<=0) li=strat->T[i].GetpLength();
1747 ii = i;
1748 if (li<3) break;
1749 }
1750 }
1751 }
1752 }
1753#endif
1754
1755 /*
1756 * end of search: have to reduce with pi
1757 */
1758
1759
1760#ifdef KDEBUG
1761 if (TEST_OPT_DEBUG)
1762 {
1763 PrintS("red:");
1764 h->wrp();
1765 PrintS(" with ");
1766 strat->T[ii].wrp();
1767 }
1768#endif
1769
1770 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1771#if SBA_PRINT_REDUCTION_STEPS
1772 sba_interreduction_steps++;
1773#endif
1774#if SBA_PRINT_OPERATIONS
1775 sba_interreduction_operations += pLength(strat->T[ii].p);
1776#endif
1777
1778#ifdef KDEBUG
1779 if (TEST_OPT_DEBUG)
1780 {
1781 PrintS("\nto ");
1782 h->wrp();
1783 PrintLn();
1784 }
1785#endif
1786
1787 h_p=h->GetLmTailRing();
1788
1789 if (h_p == NULL)
1790 {
1791 kDeleteLcm(h);
1792 return 0;
1793 }
1795 {
1796 if (h->p!=NULL)
1797 {
1798 if(p_GetComp(h->p,currRing)>strat->syzComp)
1799 {
1800 h->Delete();
1801 return 0;
1802 }
1803 }
1804 else if (h->t_p!=NULL)
1805 {
1806 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1807 {
1808 h->Delete();
1809 return 0;
1810 }
1811 }
1812 }
1813 #if 0
1814 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1815 {
1816 if (h->p!=NULL)
1817 {
1818 if(p_GetComp(h->p,currRing)>strat->syzComp)
1819 {
1820 return 1;
1821 }
1822 }
1823 else if (h->t_p!=NULL)
1824 {
1825 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1826 {
1827 return 1;
1828 }
1829 }
1830 }
1831 #endif
1832 h->SetShortExpVector();
1833 d = h->SetpFDeg();
1834 /*- try to reduce the s-polynomial -*/
1835 cnt--;
1836 pass++;
1837 if (//!TEST_OPT_REDTHROUGH &&
1838 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1839 {
1840 h->SetLmCurrRing();
1841 at = strat->posInL(strat->L,strat->Ll,h,strat);
1842 if (at <= strat->Ll)
1843 {
1844#if 1
1845#ifdef HAVE_SHIFTBBA
1846 if (rIsLPRing(currRing))
1847 {
1848 if (kFindDivisibleByInT(strat, h) < 0)
1849 return 1;
1850 }
1851 else
1852#endif
1853 {
1854 int dummy=strat->sl;
1855 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1856 return 1;
1857 }
1858#endif
1859#ifdef KDEBUG
1860 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1861#endif
1862 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1863 h->Clear();
1864 return -1;
1865 }
1866 }
1867 else if (d != reddeg)
1868 {
1869 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
1870 {
1871 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1872 {
1873 strat->overflow=TRUE;
1874 //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1875 h->GetP();
1876 at = strat->posInL(strat->L,strat->Ll,h,strat);
1877 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1878 h->Clear();
1879 return -1;
1880 }
1881 }
1882 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1883 {
1884 Print(".%ld",d);mflush();
1885 reddeg = d;
1886 }
1887 }
1888 else if (UNLIKELY(cnt==0))
1889 {
1890 h->CanonicalizeP();
1891 cnt=RED_CANONICALIZE;
1892 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
1893 }
1894 }
1895}

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

2136{
2137 if (h==NULL) return NULL;
2138 int j;
2139 int cnt=REDNF_CANONICALIZE;
2140 max_ind=strat->sl;
2141
2142 if (0 > strat->sl)
2143 {
2144 return h;
2145 }
2146 LObject P(h);
2147 P.SetShortExpVector();
2148 P.bucket = kBucketCreate(currRing);
2149 kBucketInit(P.bucket,P.p,pLength(P.p));
2150 kbTest(P.bucket);
2151#ifdef HAVE_RINGS
2152 BOOLEAN is_ring = rField_is_Ring(currRing);
2153#endif
2154#ifdef KDEBUG
2155// if (TEST_OPT_DEBUG)
2156// {
2157// PrintS("redNF: starting S:\n");
2158// for( j = 0; j <= max_ind; j++ )
2159// {
2160// Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2161// pWrite(strat->S[j]);
2162// }
2163// };
2164#endif
2165
2166 loop
2167 {
2168 j=kFindDivisibleByInS(strat,&max_ind,&P);
2169 if (j>=0)
2170 {
2171#ifdef HAVE_RINGS
2172 if (!is_ring)
2173 {
2174#endif
2175 int sl=pSize(strat->S[j]);
2176 int jj=j;
2177 loop
2178 {
2179 int sll;
2180 jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
2181 if (jj<0) break;
2182 sll=pSize(strat->S[jj]);
2183 if (sll<sl)
2184 {
2185 #ifdef KDEBUG
2186 if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2187 #endif
2188 //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2189 j=jj;
2190 sl=sll;
2191 }
2192 }
2193 if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2194 {
2195 pNorm(strat->S[j]);
2196 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2197 }
2198#ifdef HAVE_RINGS
2199 }
2200#endif
2201 nNormalize(pGetCoeff(P.p));
2202#ifdef KDEBUG
2203 if (TEST_OPT_DEBUG)
2204 {
2205 PrintS("red:");
2206 wrp(h);
2207 PrintS(" with ");
2208 wrp(strat->S[j]);
2209 }
2210#endif
2211#ifdef HAVE_PLURAL
2213 {
2214 number coef;
2215 nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef);
2216 nDelete(&coef);
2217 }
2218 else
2219#endif
2220 {
2221 number coef;
2222 coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
2223 nDelete(&coef);
2224 }
2225 cnt--;
2226 if (cnt==0)
2227 {
2228 kBucketCanonicalize(P.bucket);
2230 }
2231 h = kBucketGetLm(P.bucket); // FRAGE OLIVER
2232 if (h==NULL)
2233 {
2234 kBucketDestroy(&P.bucket);
2235 return NULL;
2236 }
2237 kbTest(P.bucket);
2238 P.p=h;
2239 P.t_p=NULL;
2240 P.SetShortExpVector();
2241#ifdef KDEBUG
2242 if (TEST_OPT_DEBUG)
2243 {
2244 PrintS("\nto:");
2245 wrp(h);
2246 PrintLn();
2247 }
2248#endif
2249 }
2250 else
2251 {
2252 P.p=kBucketClear(P.bucket);
2253 kBucketDestroy(&P.bucket);
2254 pNormalize(P.p);
2255 return P.p;
2256 }
2257 }
2258}
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:521
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
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition: kbuckets.cc:1085
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:473
#define REDNF_CANONICALIZE
Definition: kutil.h:37
static void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c)
Definition: nc.h:275
#define nNormalize(n)
Definition: numbers.h:30
#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:11020

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 831 of file kstd2.cc.

832{
833 if (strat->tl<0) return 1;
834 if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors)
835
836 int at/*,i*/;
837 long d;
838 int j = 0;
839 int pass = 0;
840 // poly zeroPoly = NULL;
841
842// TODO warum SetpFDeg notwendig?
843 h->SetpFDeg();
844 assume(h->pFDeg() == h->FDeg);
845 long reddeg = h->GetpFDeg();
846
847 h->SetShortExpVector();
848 loop
849 {
850 j = kFindDivisibleByInT(strat, h);
851 if (j < 0)
852 {
853 // over ZZ: cleanup coefficients by complete reduction with monomials
854 postReduceByMon(h, strat);
855 if(h->p == NULL)
856 {
857 kDeleteLcm(h);
858 h->Clear();
859 return 0;
860 }
861 if(nIsZero(pGetCoeff(h->p))) return 2;
862 j = kFindDivisibleByInT(strat, h);
863 if(j < 0)
864 {
865 if(strat->tl >= 0)
866 h->i_r1 = strat->tl;
867 else
868 h->i_r1 = -1;
869 if (h->GetLmTailRing() == NULL)
870 {
871 kDeleteLcm(h);
872 h->Clear();
873 return 0;
874 }
875 return 1;
876 }
877 }
878 //printf("\nFound one: ");pWrite(strat->T[j].p);
879 //enterT(*h, strat);
880 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat); // with debug output
881 //printf("\nAfter small red: ");pWrite(h->p);
882 if (h->GetLmTailRing() == NULL)
883 {
884 kDeleteLcm(h);
885 h->Clear();
886 return 0;
887 }
888 h->SetShortExpVector();
889 d = h->SetpFDeg();
890 /*- try to reduce the s-polynomial -*/
891 pass++;
892 if (!TEST_OPT_REDTHROUGH &&
893 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
894 {
895 h->SetLmCurrRing();
896 if (strat->posInLDependsOnLength)
897 h->SetLength(strat->length_pLength);
898 at = strat->posInL(strat->L,strat->Ll,h,strat);
899 if (at <= strat->Ll)
900 {
901#ifdef KDEBUG
902 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
903#endif
904 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
905 h->Clear();
906 return -1;
907 }
908 }
909 if (d != reddeg)
910 {
911 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
912 {
913 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
914 {
915 strat->overflow=TRUE;
916 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
917 h->GetP();
918 at = strat->posInL(strat->L,strat->Ll,h,strat);
919 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
920 h->Clear();
921 return -1;
922 }
923 }
924 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
925 {
926 Print(".%ld",d);mflush();
927 reddeg = d;
928 }
929 }
930 }
931}

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 673 of file kstd2.cc.

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

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 1158 of file kstd2.cc.

1159{
1160 if (strat->tl<0) return 1;
1161 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1162 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1163 assume(h->FDeg == h->pFDeg());
1164//#if 1
1165#ifdef DEBUGF5
1166 PrintS("------- IN REDSIG -------\n");
1167 Print("p: ");
1168 pWrite(pHead(h->p));
1169 PrintS("p1: ");
1170 pWrite(pHead(h->p1));
1171 PrintS("p2: ");
1172 pWrite(pHead(h->p2));
1173 PrintS("---------------------------\n");
1174#endif
1175 poly h_p;
1176 int i,j,at,pass, ii;
1177 int start=0;
1178 int sigSafe;
1179 unsigned long not_sev;
1180 // long reddeg,d;
1181 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1182 int li;
1183
1184 pass = j = 0;
1185 // d = reddeg = h->GetpFDeg();
1186 h->SetShortExpVector();
1187 h_p = h->GetLmTailRing();
1188 not_sev = ~ h->sev;
1189 loop
1190 {
1191 j = kFindDivisibleByInT(strat, h, start);
1192 if (j < 0)
1193 {
1194 return 1;
1195 }
1196
1197 li = strat->T[j].pLength;
1198 if (li<=0) li=strat->T[j].GetpLength();
1199 ii = j;
1200 /*
1201 * the polynomial to reduce with (up to the moment) is;
1202 * pi with length li
1203 */
1204 i = j;
1205#if 1
1206 if (test_opt_length)
1207 loop
1208 {
1209 /*- search the shortest possible with respect to length -*/
1210 i++;
1211 if (i > strat->tl)
1212 break;
1213 if (li==1)
1214 break;
1215 if ((strat->T[i].pLength < li)
1216 &&
1217 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1218 h_p, not_sev, strat->tailRing))
1219 {
1220 /*
1221 * the polynomial to reduce with is now;
1222 */
1223 li = strat->T[i].pLength;
1224 if (li<=0) li=strat->T[i].GetpLength();
1225 ii = i;
1226 }
1227 }
1228 start = ii+1;
1229#endif
1230
1231 /*
1232 * end of search: have to reduce with pi
1233 */
1234#ifdef KDEBUG
1235 if (TEST_OPT_DEBUG)
1236 {
1237 PrintS("red:");
1238 h->wrp();
1239 PrintS(" with ");
1240 strat->T[ii].wrp();
1241 }
1242#endif
1243 assume(strat->fromT == FALSE);
1244//#if 1
1245#ifdef DEBUGF5
1246 Print("BEFORE REDUCTION WITH %d:\n",ii);
1247 PrintS("--------------------------------\n");
1248 pWrite(h->sig);
1249 pWrite(strat->T[ii].sig);
1250 pWrite(h->GetLmCurrRing());
1251 pWrite(pHead(h->p1));
1252 pWrite(pHead(h->p2));
1253 pWrite(pHead(strat->T[ii].p));
1254 PrintS("--------------------------------\n");
1255 printf("INDEX OF REDUCER T: %d\n",ii);
1256#endif
1257 sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1258#if SBA_PRINT_REDUCTION_STEPS
1259 if (sigSafe != 3)
1260 sba_reduction_steps++;
1261#endif
1262#if SBA_PRINT_OPERATIONS
1263 if (sigSafe != 3)
1264 sba_operations += pLength(strat->T[ii].p);
1265#endif
1266 // if reduction has taken place, i.e. the reduction was sig-safe
1267 // otherwise start is already at the next position and the loop
1268 // searching reducers in T goes on from index start
1269//#if 1
1270#ifdef DEBUGF5
1271 Print("SigSAFE: %d\n",sigSafe);
1272#endif
1273 if (sigSafe != 3)
1274 {
1275 // start the next search for reducers in T from the beginning
1276 start = 0;
1277#ifdef KDEBUG
1278 if (TEST_OPT_DEBUG)
1279 {
1280 PrintS("\nto ");
1281 h->wrp();
1282 PrintLn();
1283 }
1284#endif
1285
1286 h_p = h->GetLmTailRing();
1287 if (h_p == NULL)
1288 {
1289 kDeleteLcm(h);
1290 return 0;
1291 }
1292 h->SetShortExpVector();
1293 not_sev = ~ h->sev;
1294 /*
1295 * try to reduce the s-polynomial h
1296 *test first whether h should go to the lazyset L
1297 *-if the degree jumps
1298 *-if the number of pre-defined reductions jumps
1299 */
1300 pass++;
1301 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1302 {
1303 h->SetLmCurrRing();
1304 at = strat->posInL(strat->L,strat->Ll,h,strat);
1305 if (at <= strat->Ll)
1306 {
1307 int dummy=strat->sl;
1308 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1309 {
1310 return 1;
1311 }
1312 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1313#ifdef KDEBUG
1314 if (TEST_OPT_DEBUG)
1315 Print(" lazy: -> L%d\n",at);
1316#endif
1317 h->Clear();
1318 return -1;
1319 }
1320 }
1321 }
1322 }
1323}
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:719

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1326 of file kstd2.cc.

1327{
1328 //Since reduce is really bad for SBA we use the following idea:
1329 // We first check if we can build a gcd pair between h and S
1330 //where the sig remains the same and replace h by this gcd poly
1332 #if GCD_SBA
1333 while(sbaCheckGcdPair(h,strat))
1334 {
1335 h->sev = pGetShortExpVector(h->p);
1336 }
1337 #endif
1338 poly beforeredsig;
1339 beforeredsig = pCopy(h->sig);
1340
1341 if (strat->tl<0) return 1;
1342 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1343 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1344 assume(h->FDeg == h->pFDeg());
1345//#if 1
1346#ifdef DEBUGF5
1347 Print("------- IN REDSIG -------\n");
1348 Print("p: ");
1349 pWrite(pHead(h->p));
1350 Print("p1: ");
1351 pWrite(pHead(h->p1));
1352 Print("p2: ");
1353 pWrite(pHead(h->p2));
1354 Print("---------------------------\n");
1355#endif
1356 poly h_p;
1357 int i,j,at,pass, ii;
1358 int start=0;
1359 int sigSafe;
1360 unsigned long not_sev;
1361 // long reddeg,d;
1362 int li;
1363 BOOLEAN test_opt_length=TEST_OPT_LENGTH;
1364
1365 pass = j = 0;
1366 // d = reddeg = h->GetpFDeg();
1367 h->SetShortExpVector();
1368 h_p = h->GetLmTailRing();
1369 not_sev = ~ h->sev;
1370 loop
1371 {
1372 j = kFindDivisibleByInT(strat, h, start);
1373 if (j < 0)
1374 {
1375 #if GCD_SBA
1376 while(sbaCheckGcdPair(h,strat))
1377 {
1378 h->sev = pGetShortExpVector(h->p);
1379 h->is_redundant = FALSE;
1380 start = 0;
1381 }
1382 #endif
1383 // over ZZ: cleanup coefficients by complete reduction with monomials
1384 postReduceByMonSig(h, strat);
1385 if(h->p == NULL || nIsZero(pGetCoeff(h->p))) return 2;
1386 j = kFindDivisibleByInT(strat, h,start);
1387 if(j < 0)
1388 {
1389 if(strat->tl >= 0)
1390 h->i_r1 = strat->tl;
1391 else
1392 h->i_r1 = -1;
1393 if (h->GetLmTailRing() == NULL)
1394 {
1395 kDeleteLcm(h);
1396 h->Clear();
1397 return 0;
1398 }
1399 //Check for sigdrop after reduction
1400 if(pLtCmp(beforeredsig,h->sig) == 1)
1401 {
1402 strat->sigdrop = TRUE;
1403 //Reduce it as much as you can
1404 int red_result = redRing(h,strat);
1405 if(red_result == 0)
1406 {
1407 //It reduced to 0, cancel the sigdrop
1408 strat->sigdrop = FALSE;
1409 p_Delete(&h->sig,currRing);h->sig = NULL;
1410 return 0;
1411 }
1412 else
1413 {
1414 //strat->enterS(*h, strat->sl+1, strat, strat->tl);
1415 return 0;
1416 }
1417 }
1418 p_Delete(&beforeredsig,currRing);
1419 return 1;
1420 }
1421 }
1422
1423 li = strat->T[j].pLength;
1424 if (li<=0) li=strat->T[j].GetpLength();
1425 ii = j;
1426 /*
1427 * the polynomial to reduce with (up to the moment) is;
1428 * pi with length li
1429 */
1430 i = j;
1431 if (test_opt_length)
1432 loop
1433 {
1434 /*- search the shortest possible with respect to length -*/
1435 i++;
1436 if (i > strat->tl)
1437 break;
1438 if (li==1)
1439 break;
1440 if ((strat->T[i].pLength < li)
1441 && n_DivBy(pGetCoeff(h_p),pGetCoeff(strat->T[i].p),currRing->cf)
1442 && p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1443 h_p, not_sev, strat->tailRing))
1444 {
1445 /*
1446 * the polynomial to reduce with is now;
1447 */
1448 li = strat->T[i].pLength;
1449 if (li<=0) li=strat->T[i].GetpLength();
1450 ii = i;
1451 }
1452 }
1453
1454 start = ii+1;
1455
1456 /*
1457 * end of search: have to reduce with pi
1458 */
1459#ifdef KDEBUG
1460 if (TEST_OPT_DEBUG)
1461 {
1462 PrintS("red:");
1463 h->wrp();
1464 PrintS(" with ");
1465 strat->T[ii].wrp();
1466 }
1467#endif
1468 assume(strat->fromT == FALSE);
1469//#if 1
1470#ifdef DEBUGF5
1471 Print("BEFORE REDUCTION WITH %d:\n",ii);
1472 Print("--------------------------------\n");
1473 pWrite(h->sig);
1474 pWrite(strat->T[ii].sig);
1475 pWrite(h->GetLmCurrRing());
1476 pWrite(pHead(h->p1));
1477 pWrite(pHead(h->p2));
1478 pWrite(pHead(strat->T[ii].p));
1479 Print("--------------------------------\n");
1480 printf("INDEX OF REDUCER T: %d\n",ii);
1481#endif
1482 sigSafe = ksReducePolySigRing(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1483 if(h->p == NULL && h->sig == NULL)
1484 {
1485 //Trivial case catch
1486 strat->sigdrop = FALSE;
1487 }
1488 #if 0
1489 //If the reducer has the same lt (+ or -) as the other one, reduce it via redRing
1490 //In some cases this proves to be very bad
1491 if(rField_is_Ring(currRing) && h->p != NULL && pLmCmp(h->p,strat->T[ii].p)==0)
1492 {
1493 int red_result = redRing(h,strat);
1494 if(red_result == 0)
1495 {
1496 pDelete(&h->sig);h->sig = NULL;
1497 return 0;
1498 }
1499 else
1500 {
1501 strat->sigdrop = TRUE;
1502 return 1;
1503 }
1504 }
1505 #endif
1506 if(strat->sigdrop)
1507 return 1;
1508#if SBA_PRINT_REDUCTION_STEPS
1509 if (sigSafe != 3)
1510 sba_reduction_steps++;
1511#endif
1512#if SBA_PRINT_OPERATIONS
1513 if (sigSafe != 3)
1514 sba_operations += pLength(strat->T[ii].p);
1515#endif
1516 // if reduction has taken place, i.e. the reduction was sig-safe
1517 // otherwise start is already at the next position and the loop
1518 // searching reducers in T goes on from index start
1519//#if 1
1520#ifdef DEBUGF5
1521 Print("SigSAFE: %d\n",sigSafe);
1522#endif
1523 if (sigSafe != 3)
1524 {
1525 // start the next search for reducers in T from the beginning
1526 start = 0;
1527#ifdef KDEBUG
1528 if (TEST_OPT_DEBUG)
1529 {
1530 PrintS("\nto ");
1531 h->wrp();
1532 PrintLn();
1533 }
1534#endif
1535
1536 h_p = h->GetLmTailRing();
1537 if (h_p == NULL)
1538 {
1539 kDeleteLcm(h);
1540 return 0;
1541 }
1542 h->SetShortExpVector();
1543 not_sev = ~ h->sev;
1544 /*
1545 * try to reduce the s-polynomial h
1546 *test first whether h should go to the lazyset L
1547 *-if the degree jumps
1548 *-if the number of pre-defined reductions jumps
1549 */
1550 pass++;
1551 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1552 {
1553 h->SetLmCurrRing();
1554 at = strat->posInL(strat->L,strat->Ll,h,strat);
1555 if (at <= strat->Ll)
1556 {
1557 int dummy=strat->sl;
1558 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1559 {
1560 return 1;
1561 }
1562 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1563#ifdef KDEBUG
1564 if (TEST_OPT_DEBUG)
1565 Print(" lazy: -> L%d\n",at);
1566#endif
1567 h->Clear();
1568 return -1;
1569 }
1570 }
1571 }
1572 }
1573}
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:925
void postReduceByMonSig(LObject *h, kStrategy strat)
Definition: kutil.cc:11096
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition: kutil.cc:1780

◆ redtail() [1/2]

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

Definition at line 7131 of file kutil.cc.

7132{
7133 poly h, hn;
7134 strat->redTailChange=FALSE;
7135
7136 L->GetP();
7137 poly p = L->p;
7138 if (strat->noTailReduction || pNext(p) == NULL)
7139 return p;
7140
7141 LObject Ln(strat->tailRing);
7142 TObject* With;
7143 // placeholder in case strat->tl < 0
7144 TObject With_s(strat->tailRing);
7145 h = p;
7146 hn = pNext(h);
7147 long op = strat->tailRing->pFDeg(hn, strat->tailRing);
7148 long e;
7149 int l;
7150 BOOLEAN save_HE=strat->kAllAxis;
7151 strat->kAllAxis |=
7152 ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
7153
7154 while(hn != NULL)
7155 {
7156 op = strat->tailRing->pFDeg(hn, strat->tailRing);
7157 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7158 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7159 loop
7160 {
7161 Ln.Set(hn, strat->tailRing);
7162 Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
7163 if (strat->kAllAxis)
7164 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7165 else
7166 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
7167 if (With == NULL) break;
7168 With->length=0;
7169 With->pLength=0;
7170 strat->redTailChange=TRUE;
7171 if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
7172 {
7173 // reducing the tail would violate the exp bound
7174 if (kStratChangeTailRing(strat, L))
7175 {
7176 strat->kAllAxis = save_HE;
7177 return redtail(L, end_pos, strat);
7178 }
7179 else
7180 return NULL;
7181 }
7182 hn = pNext(h);
7183 if (hn == NULL) goto all_done;
7184 op = strat->tailRing->pFDeg(hn, strat->tailRing);
7185 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7186 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7187 }
7188 h = hn;
7189 hn = pNext(h);
7190 }
7191
7192 all_done:
7193 if (strat->redTailChange)
7194 {
7195 L->pLength = 0;
7196 }
7197 strat->kAllAxis = save_HE;
7198 return p;
7199}
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:6989
#define TEST_OPT_INFREDTAIL
Definition: options.h:118

◆ redtail() [2/2]

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

Definition at line 7201 of file kutil.cc.

7202{
7203 LObject L(p, currRing);
7204 return redtail(&L, end_pos, strat);
7205}

◆ redtailBba() [1/3]

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

Definition at line 7207 of file kutil.cc.

7208{
7209 strat->redTailChange=FALSE;
7210 if (strat->noTailReduction) return L->GetLmCurrRing();
7211 poly h, p;
7212 p = h = L->GetLmTailRing();
7213 if ((h==NULL) || (pNext(h)==NULL))
7214 return L->GetLmCurrRing();
7215
7216 TObject* With;
7217 // placeholder in case strat->tl < 0
7218 TObject With_s(strat->tailRing);
7219
7220 LObject Ln(pNext(h), strat->tailRing);
7221 Ln.GetpLength();
7222
7223 pNext(h) = NULL;
7224 if (L->p != NULL)
7225 {
7226 pNext(L->p) = NULL;
7227 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7228 }
7229 L->pLength = 1;
7230
7231 Ln.PrepareRed(strat->use_buckets);
7232
7233 int cnt=REDTAIL_CANONICALIZE;
7234 while(!Ln.IsNull())
7235 {
7236 loop
7237 {
7238 if (TEST_OPT_IDLIFT)
7239 {
7240 if (Ln.p!=NULL)
7241 {
7242 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7243 }
7244 else
7245 {
7246 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7247 }
7248 }
7249 Ln.SetShortExpVector();
7250 if (withT)
7251 {
7252 int j;
7253 j = kFindDivisibleByInT(strat, &Ln);
7254 if (j < 0) break;
7255 With = &(strat->T[j]);
7256 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7257 }
7258 else
7259 {
7260 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7261 if (With == NULL) break;
7262 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7263 }
7264 cnt--;
7265 if (cnt==0)
7266 {
7268 /*poly tmp=*/Ln.CanonicalizeP();
7269 if (normalize)
7270 {
7271 Ln.Normalize();
7272 //pNormalize(tmp);
7273 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7274 }
7275 }
7276 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7277 {
7278 With->pNorm();
7279 }
7280 strat->redTailChange=TRUE;
7281 if (ksReducePolyTail(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 if (Ln.IsNull()) goto all_done;
7296 if (! withT) With_s.Init(currRing);
7297 }
7298 pNext(h) = Ln.LmExtractAndIter();
7299 pIter(h);
7300 pNormalize(h);
7301 L->pLength++;
7302 }
7303
7304 all_done:
7305 Ln.Delete();
7306 if (L->p != NULL) pNext(L->p) = pNext(p);
7307
7308 if (strat->redTailChange)
7309 {
7310 L->length = 0;
7311 L->pLength = 0;
7312 }
7313
7314 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7315 //L->Normalize(); // HANNES: should have a test
7316 kTest_L(L,strat);
7317 return L->GetLmCurrRing();
7318}
#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:1026

◆ redtailBba() [2/3]

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

Definition at line 1223 of file kInline.h.

1224{
1225 LObject L(p);
1226 return redtailBba(&L, pos, strat,FALSE, normalize);
1227}

◆ redtailBba() [3/3]

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7679 of file kutil.cc.

7681{
7682 strat->redTailChange=FALSE;
7683 if (strat->noTailReduction) return L->GetLmCurrRing();
7684 poly h, p;
7685 p = h = L->GetLmTailRing();
7686 if ((h==NULL) || (pNext(h)==NULL))
7687 return L->GetLmCurrRing();
7688
7689 TObject* With;
7690 // placeholder in case strat->tl < 0
7691 TObject With_s(strat->tailRing);
7692
7693 LObject Ln(pNext(h), strat->tailRing);
7694 Ln.pLength = L->GetpLength() - 1;
7695
7696 pNext(h) = NULL;
7697 if (L->p != NULL) pNext(L->p) = NULL;
7698 L->pLength = 1;
7699
7700 Ln.PrepareRed(strat->use_buckets);
7701
7702 int cnt=REDTAIL_CANONICALIZE;
7703 while(!Ln.IsNull())
7704 {
7705 loop
7706 {
7707 Ln.SetShortExpVector();
7708 With_s.Init(currRing);
7709 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7710 if (With == NULL) break;
7711 cnt--;
7712 if (cnt==0)
7713 {
7715 /*poly tmp=*/Ln.CanonicalizeP();
7716 }
7717 // we are in a ring, do not call pNorm
7718 // test divisibility of coefs:
7719 poly p_Ln=Ln.GetLmCurrRing();
7720 poly p_With=With->GetLmCurrRing();
7721 if (n_DivBy(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf))
7722 {
7723 strat->redTailChange=TRUE;
7724
7725 if (ksReducePolyTail_Z(L, With, &Ln))
7726 {
7727 // reducing the tail would violate the exp bound
7728 // set a flag and hope for a retry (in bba)
7730 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7731 do
7732 {
7733 pNext(h) = Ln.LmExtractAndIter();
7734 pIter(h);
7735 L->pLength++;
7736 } while (!Ln.IsNull());
7737 goto all_done;
7738 }
7739 }
7740 else break; /*proceed to next monomial*/
7741 if (Ln.IsNull()) goto all_done;
7742 }
7743 pNext(h) = Ln.LmExtractAndIter();
7744 pIter(h);
7745 pNormalize(h);
7746 L->pLength++;
7747 }
7748
7749 all_done:
7750 Ln.Delete();
7751 if (L->p != NULL) pNext(L->p) = pNext(p);
7752
7753 if (strat->redTailChange)
7754 {
7755 L->length = 0;
7756 }
7757
7758 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7759 //L->Normalize(); // HANNES: should have a test
7760 kTest_L(L,strat);
7761 return L->GetLmCurrRing();
7762}
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1138

◆ redtailBba_Ring() [2/2]

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

Definition at line 1236 of file kInline.h.

1237{
1238 LObject L(p, currRing, strat->tailRing);
1239 return redtailBba_Ring(&L, pos, strat);
1240}

◆ redtailBba_Z() [1/2]

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

Definition at line 7565 of file kutil.cc.

7567{
7568 strat->redTailChange=FALSE;
7569 if (strat->noTailReduction) return L->GetLmCurrRing();
7570 poly h, p;
7571 p = h = L->GetLmTailRing();
7572 if ((h==NULL) || (pNext(h)==NULL))
7573 return L->GetLmCurrRing();
7574
7575 TObject* With;
7576 // placeholder in case strat->tl < 0
7577 TObject With_s(strat->tailRing);
7578
7579 LObject Ln(pNext(h), strat->tailRing);
7580 Ln.pLength = L->GetpLength() - 1;
7581
7582 pNext(h) = NULL;
7583 if (L->p != NULL) pNext(L->p) = NULL;
7584 L->pLength = 1;
7585
7586 Ln.PrepareRed(strat->use_buckets);
7587
7588 int cnt=REDTAIL_CANONICALIZE;
7589 while(!Ln.IsNull())
7590 {
7591 loop
7592 {
7593 Ln.SetShortExpVector();
7594 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7595 if (With == NULL) break;
7596 cnt--;
7597 if (cnt==0)
7598 {
7600 /*poly tmp=*/Ln.CanonicalizeP();
7601 }
7602 // we are in Z, do not call pNorm
7603 strat->redTailChange=TRUE;
7604 // test divisibility of coefs:
7605 poly p_Ln=Ln.GetLmCurrRing();
7606 poly p_With=With->GetLmCurrRing();
7607 number z=n_IntMod(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf);
7608 if (!nIsZero(z))
7609 {
7610 // subtract z*Ln, add z.Ln to L
7611 poly m=pHead(p_Ln);
7612 pSetCoeff(m,z);
7613 poly mm=pHead(m);
7614 pNext(h) = m;
7615 pIter(h);
7616 L->pLength++;
7617 mm=pNeg(mm);
7618 if (Ln.bucket!=NULL)
7619 {
7620 int dummy=1;
7621 kBucket_Add_q(Ln.bucket,mm,&dummy);
7622 }
7623 else
7624 {
7625 if ((Ln.t_p!=NULL)&&(Ln.p==NULL))
7626 Ln.GetP();
7627 if (Ln.p!=NULL)
7628 {
7629 Ln.p=pAdd(Ln.p,mm);
7630 if (Ln.t_p!=NULL)
7631 {
7632 pNext(Ln.t_p)=NULL;
7633 p_LmDelete(Ln.t_p,strat->tailRing);
7634 }
7635 }
7636 }
7637 }
7638 else
7639 nDelete(&z);
7640
7641 if (ksReducePolyTail_Z(L, With, &Ln))
7642 {
7643 // reducing the tail would violate the exp bound
7644 // set a flag and hope for a retry (in bba)
7646 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7647 do
7648 {
7649 pNext(h) = Ln.LmExtractAndIter();
7650 pIter(h);
7651 L->pLength++;
7652 } while (!Ln.IsNull());
7653 goto all_done;
7654 }
7655 if (Ln.IsNull()) goto all_done;
7656 With_s.Init(currRing);
7657 }
7658 pNext(h) = Ln.LmExtractAndIter();
7659 pIter(h);
7660 pNormalize(h);
7661 L->pLength++;
7662 }
7663
7664 all_done:
7665 Ln.Delete();
7666 if (L->p != NULL) pNext(L->p) = pNext(p);
7667
7668 if (strat->redTailChange)
7669 {
7670 L->length = 0;
7671 }
7672
7673 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7674 //L->Normalize(); // HANNES: should have a test
7675 kTest_L(L,strat);
7676 return L->GetLmCurrRing();
7677}
int m
Definition: cfEzgcd.cc:128
#define pAdd(p, q)
Definition: polys.h:203

◆ redtailBba_Z() [2/2]

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

Definition at line 1241 of file kInline.h.

1242{
1243 LObject L(p, currRing, strat->tailRing);
1244 return redtailBba_Z(&L, pos, strat);
1245}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7436 of file kutil.cc.

7438{
7439 strat->redTailChange=FALSE;
7440
7441 poly h, p;
7442 p = h = L->GetLmTailRing();
7443 if ((h==NULL) || (pNext(h)==NULL))
7444 return;
7445
7446 TObject* With;
7447 LObject Ln(pNext(h), strat->tailRing);
7448 Ln.GetpLength();
7449
7450 pNext(h) = NULL;
7451 if (L->p != NULL)
7452 {
7453 pNext(L->p) = NULL;
7454 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7455 }
7456 L->pLength = 1;
7457
7458 Ln.PrepareRed(strat->use_buckets);
7459
7460 int cnt=REDTAIL_CANONICALIZE;
7461
7462 while(!Ln.IsNull())
7463 {
7464 loop
7465 {
7466 if (TEST_OPT_IDLIFT)
7467 {
7468 if (Ln.p!=NULL)
7469 {
7470 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7471 }
7472 else
7473 {
7474 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7475 }
7476 }
7477 Ln.SetShortExpVector();
7478 int j;
7479 j = kFindDivisibleByInT(strat, &Ln);
7480 if (j < 0)
7481 {
7482 j = kFindDivisibleByInT_Z(strat, &Ln);
7483 if (j < 0)
7484 {
7485 break;
7486 }
7487 else
7488 {
7489 /* reduction not cancelling a tail term, but reducing its coefficient */
7490 With = &(strat->T[j]);
7491 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7492 cnt--;
7493 if (cnt==0)
7494 {
7496 /*poly tmp=*/Ln.CanonicalizeP();
7497 }
7498 strat->redTailChange=TRUE;
7499 /* reduction cancelling a tail term */
7500 if (ksReducePolyTailLC_Z(L, With, &Ln))
7501 {
7502 // reducing the tail would violate the exp bound
7503 // set a flag and hope for a retry (in bba)
7505 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7506 do
7507 {
7508 pNext(h) = Ln.LmExtractAndIter();
7509 pIter(h);
7510 L->pLength++;
7511 } while (!Ln.IsNull());
7512 goto all_done;
7513 }
7514 /* we have to break since we did not cancel the term, but only decreased
7515 * its coefficient. */
7516 break;
7517 }
7518 } else {
7519 With = &(strat->T[j]);
7520 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7521 cnt--;
7522 if (cnt==0)
7523 {
7525 /*poly tmp=*/Ln.CanonicalizeP();
7526 }
7527 strat->redTailChange=TRUE;
7528 /* reduction cancelling a tail term */
7529 if (ksReducePolyTail_Z(L, With, &Ln))
7530 {
7531 // reducing the tail would violate the exp bound
7532 // set a flag and hope for a retry (in bba)
7534 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7535 do
7536 {
7537 pNext(h) = Ln.LmExtractAndIter();
7538 pIter(h);
7539 L->pLength++;
7540 } while (!Ln.IsNull());
7541 goto all_done;
7542 }
7543 }
7544 if (Ln.IsNull()) goto all_done;
7545 }
7546 pNext(h) = Ln.LmExtractAndIter();
7547 pIter(h);
7548 L->pLength++;
7549 }
7550
7551 all_done:
7552 Ln.Delete();
7553 if (L->p != NULL) pNext(L->p) = pNext(p);
7554
7555 if (strat->redTailChange)
7556 {
7557 L->length = 0;
7558 L->pLength = 0;
7559 }
7560
7561 kTest_L(L, strat);
7562 return;
7563}
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1120

◆ redtailBbaBound() [1/2]

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

Definition at line 7320 of file kutil.cc.

7321{
7322 strat->redTailChange=FALSE;
7323 if (strat->noTailReduction) return L->GetLmCurrRing();
7324 poly h, p;
7325 p = h = L->GetLmTailRing();
7326 if ((h==NULL) || (pNext(h)==NULL))
7327 return L->GetLmCurrRing();
7328
7329 TObject* With;
7330 // placeholder in case strat->tl < 0
7331 TObject With_s(strat->tailRing);
7332
7333 LObject Ln(pNext(h), strat->tailRing);
7334 Ln.pLength = L->GetpLength() - 1;
7335
7336 pNext(h) = NULL;
7337 if (L->p != NULL) pNext(L->p) = NULL;
7338 L->pLength = 1;
7339
7340 Ln.PrepareRed(strat->use_buckets);
7341
7342 int cnt=REDTAIL_CANONICALIZE;
7343 while(!Ln.IsNull())
7344 {
7345 loop
7346 {
7347 if (TEST_OPT_IDLIFT)
7348 {
7349 if (Ln.p!=NULL)
7350 {
7351 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7352 }
7353 else
7354 {
7355 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7356 }
7357 }
7358 Ln.SetShortExpVector();
7359 if (withT)
7360 {
7361 int j;
7362 j = kFindDivisibleByInT(strat, &Ln);
7363 if (j < 0) break;
7364 With = &(strat->T[j]);
7365 }
7366 else
7367 {
7368 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7369 if (With == NULL) break;
7370 }
7371 cnt--;
7372 if (cnt==0)
7373 {
7375 /*poly tmp=*/Ln.CanonicalizeP();
7376 if (normalize)
7377 {
7378 Ln.Normalize();
7379 //pNormalize(tmp);
7380 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7381 }
7382 }
7383 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7384 {
7385 With->pNorm();
7386 }
7387 strat->redTailChange=TRUE;
7388 if (ksReducePolyTail(L, With, &Ln))
7389 {
7390 // reducing the tail would violate the exp bound
7391 // set a flag and hope for a retry (in bba)
7393 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7394 do
7395 {
7396 pNext(h) = Ln.LmExtractAndIter();
7397 pIter(h);
7398 L->pLength++;
7399 } while (!Ln.IsNull());
7400 goto all_done;
7401 }
7402 if(!Ln.IsNull())
7403 {
7404 Ln.GetP();
7405 Ln.p = pJet(Ln.p,bound);
7406 }
7407 if (Ln.IsNull())
7408 {
7409 goto all_done;
7410 }
7411 if (! withT) With_s.Init(currRing);
7412 }
7413 pNext(h) = Ln.LmExtractAndIter();
7414 pIter(h);
7415 pNormalize(h);
7416 L->pLength++;
7417 }
7418
7419 all_done:
7420 Ln.Delete();
7421 if (L->p != NULL) pNext(L->p) = pNext(p);
7422
7423 if (strat->redTailChange)
7424 {
7425 L->length = 0;
7426 L->pLength = 0;
7427 }
7428
7429 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7430 //L->Normalize(); // HANNES: should have a test
7431 kTest_L(L,strat);
7432 return L->GetLmCurrRing();
7433}
#define pJet(p, m)
Definition: polys.h:368

◆ redtailBbaBound() [2/2]

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

Definition at line 1229 of file kInline.h.

1230{
1231 LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1232 return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1233}

◆ redtailBbaShift()

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

Definition at line 13457 of file kutil.cc.

13458{
13459 /* for the shift case need to run it with withT = TRUE */
13460 strat->redTailChange=FALSE;
13461 if (strat->noTailReduction) return L->GetLmCurrRing();
13462 poly h, p;
13463 p = h = L->GetLmTailRing();
13464 if ((h==NULL) || (pNext(h)==NULL))
13465 return L->GetLmCurrRing();
13466
13467 TObject* With;
13468 // placeholder in case strat->tl < 0
13469 TObject With_s(strat->tailRing);
13470
13471 LObject Ln(pNext(h), strat->tailRing);
13472 Ln.pLength = L->GetpLength() - 1;
13473
13474 pNext(h) = NULL;
13475 if (L->p != NULL) pNext(L->p) = NULL;
13476 L->pLength = 1;
13477
13478 Ln.PrepareRed(strat->use_buckets);
13479
13480 while(!Ln.IsNull())
13481 {
13482 loop
13483 {
13484 Ln.SetShortExpVector();
13485 if (withT)
13486 {
13487 int j;
13488 j = kFindDivisibleByInT(strat, &Ln);
13489 if (j < 0) break;
13490 With = &(strat->T[j]);
13491 }
13492 else
13493 {
13494 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13495 if (With == NULL) break;
13496 }
13497 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13498 {
13499 With->pNorm();
13500 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13501 }
13502 strat->redTailChange=TRUE;
13503 if (ksReducePolyTail(L, With, &Ln))
13504 {
13505 // reducing the tail would violate the exp bound
13506 // set a flag and hope for a retry (in bba)
13508 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13509 do
13510 {
13511 pNext(h) = Ln.LmExtractAndIter();
13512 pIter(h);
13513 L->pLength++;
13514 } while (!Ln.IsNull());
13515 goto all_done;
13516 }
13517 if (Ln.IsNull()) goto all_done;
13518 if (! withT) With_s.Init(currRing);
13519 }
13520 pNext(h) = Ln.LmExtractAndIter();
13521 pIter(h);
13522 L->pLength++;
13523 }
13524
13525 all_done:
13526 Ln.Delete();
13527 if (L->p != NULL) pNext(L->p) = pNext(p);
13528
13529 if (strat->redTailChange)
13530 {
13531 L->length = 0;
13532 }
13533 L->Normalize(); // HANNES: should have a test
13534 kTest_L(L,strat);
13535 return L->GetLmCurrRing();
13536}

◆ redtailSba()

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

Definition at line 1576 of file kstd2.cc.

1577{
1578 strat->redTailChange=FALSE;
1579 if (strat->noTailReduction) return L->GetLmCurrRing();
1580 poly h, p;
1581 p = h = L->GetLmTailRing();
1582 if ((h==NULL) || (pNext(h)==NULL))
1583 return L->GetLmCurrRing();
1584
1585 TObject* With;
1586 // placeholder in case strat->tl < 0
1587 TObject With_s(strat->tailRing);
1588
1589 LObject Ln(pNext(h), strat->tailRing);
1590 Ln.sig = L->sig;
1591 Ln.sevSig = L->sevSig;
1592 Ln.pLength = L->GetpLength() - 1;
1593
1594 pNext(h) = NULL;
1595 if (L->p != NULL) pNext(L->p) = NULL;
1596 L->pLength = 1;
1597
1598 Ln.PrepareRed(strat->use_buckets);
1599
1600 int cnt=REDTAIL_CANONICALIZE;
1601 while(!Ln.IsNull())
1602 {
1603 loop
1604 {
1605 if(rField_is_Ring(currRing) && strat->sigdrop)
1606 break;
1607 Ln.SetShortExpVector();
1608 if (withT)
1609 {
1610 int j;
1611 j = kFindDivisibleByInT(strat, &Ln);
1612 if (j < 0) break;
1613 With = &(strat->T[j]);
1614 }
1615 else
1616 {
1617 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1618 if (With == NULL) break;
1619 }
1620 cnt--;
1621 if (cnt==0)
1622 {
1624 /*poly tmp=*/Ln.CanonicalizeP();
1626 {
1627 Ln.Normalize();
1628 //pNormalize(tmp);
1629 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1630 }
1631 }
1633 {
1634 With->pNorm();
1635 }
1636 strat->redTailChange=TRUE;
1637 int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1639 L->sig = Ln.sig;
1640 //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1641 // I delete it an then set Ln.sig. Hence L->sig is lost
1642#if SBA_PRINT_REDUCTION_STEPS
1643 if (ret != 3)
1644 sba_reduction_steps++;
1645#endif
1646#if SBA_PRINT_OPERATIONS
1647 if (ret != 3)
1648 sba_operations += pLength(With->p);
1649#endif
1650 if (ret)
1651 {
1652 // reducing the tail would violate the exp bound
1653 // set a flag and hope for a retry (in bba)
1655 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1656 do
1657 {
1658 pNext(h) = Ln.LmExtractAndIter();
1659 pIter(h);
1660 L->pLength++;
1661 } while (!Ln.IsNull());
1662 goto all_done;
1663 }
1664 if (Ln.IsNull()) goto all_done;
1665 if (! withT) With_s.Init(currRing);
1666 if(rField_is_Ring(currRing) && strat->sigdrop)
1667 {
1668 //Cannot break the loop here so easily
1669 break;
1670 }
1671 }
1672 pNext(h) = Ln.LmExtractAndIter();
1673 pIter(h);
1675 pNormalize(h);
1676 L->pLength++;
1677 }
1678 all_done:
1679 Ln.Delete();
1680 if (L->p != NULL) pNext(L->p) = pNext(p);
1681
1682 if (strat->redTailChange)
1683 {
1684 L->length = 0;
1685 }
1686 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1687 //L->Normalize(); // HANNES: should have a test
1688 kTest_L(L,strat);
1689 return L->GetLmCurrRing();
1690}
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition: kstd2.cc:1120

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 4710 of file kutil.cc.

4711{
4712 int i,j,at,ecart, s2r;
4713 int fq=0;
4714 unsigned long sev;
4715 poly p;
4716 int new_suc=strat->sl+1;
4717 i= *suc;
4718 if (i<0) i=0;
4719
4720 for (; i<=strat->sl; i++)
4721 {
4722 at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4723 if (at != i)
4724 {
4725 if (new_suc > at) new_suc = at;
4726 p = strat->S[i];
4727 ecart = strat->ecartS[i];
4728 sev = strat->sevS[i];
4729 s2r = strat->S_2_R[i];
4730 if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4731 for (j=i; j>=at+1; j--)
4732 {
4733 strat->S[j] = strat->S[j-1];
4734 strat->ecartS[j] = strat->ecartS[j-1];
4735 strat->sevS[j] = strat->sevS[j-1];
4736 strat->S_2_R[j] = strat->S_2_R[j-1];
4737 }
4738 strat->S[at] = p;
4739 strat->ecartS[at] = ecart;
4740 strat->sevS[at] = sev;
4741 strat->S_2_R[at] = s2r;
4742 if (strat->fromQ!=NULL)
4743 {
4744 for (j=i; j>=at+1; j--)
4745 {
4746 strat->fromQ[j] = strat->fromQ[j-1];
4747 }
4748 strat->fromQ[at]=fq;
4749 }
4750 }
4751 }
4752 if (new_suc <= strat->sl) *suc=new_suc;
4753 else *suc=-1;
4754}

◆ replaceInLAndSAndT()

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

Definition at line 9343 of file kutil.cc.

9344{
9345 p.GetP(strat->lmBin);
9346 if (strat->homog) strat->initEcart(&p);
9347 strat->redTailChange=FALSE;
9349 {
9350 p.pCleardenom();
9352 {
9353#ifdef HAVE_SHIFTBBA
9354 if (rIsLPRing(currRing))
9355 p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9356 else
9357#endif
9358 {
9359 p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9360 }
9361 p.pCleardenom();
9362 if (strat->redTailChange)
9363 p.t_p=NULL;
9364 if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9365 else strat->P.sev=0;
9366 }
9367 }
9368
9369 assume(strat->tailRing == p.tailRing);
9370 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9371
9372 int i, j, pos;
9373 poly tp = strat->T[tj].p;
9374
9375 /* enter p to T set */
9376 enterT(p, strat);
9377
9378 for (j = 0; j <= strat->sl; ++j)
9379 {
9380 if (pLtCmp(tp, strat->S[j]) == 0)
9381 {
9382 break;
9383 }
9384 }
9385 /* it may be that the exchanged element
9386 * is until now only in T and not in S */
9387 if (j <= strat->sl)
9388 {
9389 deleteInS(j, strat);
9390 }
9391
9392 pos = posInS(strat, strat->sl, p.p, p.ecart);
9393
9394 pp_Test(p.p, currRing, p.tailRing);
9395 assume(p.FDeg == p.pFDeg());
9396
9397 /* remove useless pairs from L set */
9398 for (i = 0; i <= strat->Ll; ++i)
9399 {
9400 if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9401 {
9402 deleteInL(strat->L, &(strat->Ll), i, strat);
9403 i--;
9404 continue;
9405 }
9406 if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9407 {
9408 deleteInL(strat->L, &(strat->Ll), i, strat);
9409 i--;
9410 }
9411 }
9412#ifdef HAVE_SHIFTBBA
9413 if (rIsLPRing(currRing))
9414 enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9415 else
9416#endif
9417 {
9418 /* generate new pairs with p, probably removing older, now useless pairs */
9419 superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9420 }
9421 /* enter p to S set */
9422 strat->enterS(p, pos, strat, strat->tl);
9423
9424#ifdef HAVE_SHIFTBBA
9425 /* do this after enterS so that the index in R (which is strat->tl) is correct */
9426 if (rIsLPRing(currRing) && !strat->rightGB)
9427 enterTShift(p,strat);
9428#endif
9429}

◆ sba()

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

Definition at line 2742 of file kstd2.cc.

2743{
2744 // ring order stuff:
2745 // in sba we have (until now) two possibilities:
2746 // 1. an incremental computation w.r.t. (C,monomial order)
2747 // 2. a (possibly non-incremental) computation w.r.t. the
2748 // induced Schreyer order.
2749 // The corresponding orders are computed in sbaRing(), depending
2750 // on the flag strat->sbaOrder
2751#if SBA_PRINT_ZERO_REDUCTIONS
2752 long zeroreductions = 0;
2753#endif
2754#if SBA_PRINT_PRODUCT_CRITERION
2755 long product_criterion = 0;
2756#endif
2757#if SBA_PRINT_SIZE_G
2758 int size_g = 0;
2759 int size_g_non_red = 0;
2760#endif
2761#if SBA_PRINT_SIZE_SYZ
2762 long size_syz = 0;
2763#endif
2764 // global variable
2765#if SBA_PRINT_REDUCTION_STEPS
2766 sba_reduction_steps = 0;
2767 sba_interreduction_steps = 0;
2768#endif
2769#if SBA_PRINT_OPERATIONS
2770 sba_operations = 0;
2771 sba_interreduction_operations = 0;
2772#endif
2773
2774 ideal F1 = F0;
2775 ring sRing, currRingOld;
2776 currRingOld = currRing;
2777 if (strat->sbaOrder == 1 || strat->sbaOrder == 3)
2778 {
2779 sRing = sbaRing(strat);
2780 if (sRing!=currRingOld)
2781 {
2782 rChangeCurrRing (sRing);
2783 F1 = idrMoveR (F0, currRingOld, currRing);
2784 }
2785 }
2786 ideal F;
2787 // sort ideal F
2788 //Put the SigDrop element on the correct position (think of sbaEnterS)
2789 //We also sort them
2790 if(rField_is_Ring(currRing) && strat->sigdrop)
2791 {
2792 #if 1
2793 F = idInit(IDELEMS(F1),F1->rank);
2794 for (int i=0; i<IDELEMS(F1);++i)
2795 F->m[i] = F1->m[i];
2796 if(strat->sbaEnterS >= 0)
2797 {
2798 poly dummy;
2799 dummy = pCopy(F->m[0]); //the sigdrop element
2800 for(int i = 0;i<strat->sbaEnterS;i++)
2801 F->m[i] = F->m[i+1];
2802 F->m[strat->sbaEnterS] = dummy;
2803 }
2804 #else
2805 F = idInit(1,F1->rank);
2806 //printf("\nBefore the initial block sorting:\n");idPrint(F1);
2807 F->m[0] = F1->m[0];
2808 int pos;
2809 if(strat->sbaEnterS >= 0)
2810 {
2811 for(int i=1;i<=strat->sbaEnterS;i++)
2812 {
2813 pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS);
2814 idInsertPolyOnPos(F,F1->m[i],pos);
2815 }
2816 for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++)
2817 {
2818 pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F));
2819 idInsertPolyOnPos(F,F1->m[i],pos);
2820 }
2821 poly dummy;
2822 dummy = pCopy(F->m[0]); //the sigdrop element
2823 for(int i = 0;i<strat->sbaEnterS;i++)
2824 F->m[i] = F->m[i+1];
2825 F->m[strat->sbaEnterS] = dummy;
2826 }
2827 else
2828 {
2829 for(int i=1;i<IDELEMS(F1);i++)
2830 {
2831 pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F));
2832 idInsertPolyOnPos(F,F1->m[i],pos);
2833 }
2834 }
2835 #endif
2836 //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar();
2837 }
2838 else
2839 {
2840 F = idInit(IDELEMS(F1),F1->rank);
2841 intvec *sort = idSort(F1);
2842 for (int i=0; i<sort->length();++i)
2843 F->m[i] = F1->m[(*sort)[i]-1];
2845 {
2846 // put the monomials after the sbaEnterS polynomials
2847 //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F);
2848 int nrmon = 0;
2849 for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--)
2850 {
2851 //pWrite(F->m[i]);
2852 if(F->m[i] != NULL && pNext(F->m[i]) == NULL)
2853 {
2854 poly mon = F->m[i];
2855 for(j = i;j>strat->sbaEnterS+nrmon+1;j--)
2856 {
2857 F->m[j] = F->m[j-1];
2858 }
2859 F->m[j] = mon;
2860 nrmon++;
2861 }
2862 //idPrint(F);
2863 }
2864 }
2865 }
2866 //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar();
2868 strat->sigdrop = FALSE;
2869 strat->nrsyzcrit = 0;
2870 strat->nrrewcrit = 0;
2871#if SBA_INTERRED_START
2872 F = kInterRed(F,NULL);
2873#endif
2874#if F5DEBUG
2875 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
2876 rWrite (currRing);
2877 printf("ordSgn = %d\n",currRing->OrdSgn);
2878 printf("\n");
2879#endif
2880 int srmax,lrmax, red_result = 1;
2881 int olddeg,reduc;
2882 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2883 LObject L;
2884 BOOLEAN withT = TRUE;
2885 strat->max_lower_index = 0;
2886 //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2887 initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/
2888 initSbaPos(strat);
2889 initHilbCrit(F,Q,&hilb,strat);
2890 initSba(F,strat);
2891 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2892 /*Shdl=*/initSbaBuchMora(F, Q,strat);
2893 idTest(strat->Shdl);
2894 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2895 srmax = strat->sl;
2896 reduc = olddeg = lrmax = 0;
2897#ifndef NO_BUCKETS
2899 strat->use_buckets = 1;
2900#endif
2901
2902 // redtailBBa against T for inhomogenous input
2903 // if (!TEST_OPT_OLDSTD)
2904 // withT = ! strat->homog;
2905
2906 // strat->posInT = posInT_pLength;
2907 kTest_TS(strat);
2908
2909#ifdef HAVE_TAIL_RING
2910 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2912#endif
2913 if (BVERBOSE(23))
2914 {
2915 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2916 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2917 kDebugPrint(strat);
2918 }
2919 // We add the elements directly in S from the previous loop
2920 if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0)
2921 {
2922 for(int i = 0;i<strat->sbaEnterS;i++)
2923 {
2924 //Update: now the element is at the corect place
2925 //i+1 because on the 0 position is the sigdrop element
2926 enterT(strat->L[strat->Ll-(i)],strat);
2927 strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl);
2928 }
2929 strat->Ll = strat->Ll - strat->sbaEnterS;
2930 strat->sbaEnterS = -1;
2931 }
2932 kTest_TS(strat);
2933#ifdef KDEBUG
2934 //kDebugPrint(strat);
2935#endif
2936 /* compute------------------------------------------------------- */
2937 while (strat->Ll >= 0)
2938 {
2939 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
2940 #ifdef KDEBUG
2941 if (TEST_OPT_DEBUG) messageSets(strat);
2942 #endif
2943 if (strat->Ll== 0) strat->interpt=TRUE;
2944 /*
2945 if (TEST_OPT_DEGBOUND
2946 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2947 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2948 {
2949
2950 //stops computation if
2951 // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2952 //a predefined number Kstd1_deg
2953 while ((strat->Ll >= 0)
2954 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2955 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2956 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2957 )
2958 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2959 if (strat->Ll<0) break;
2960 else strat->noClearS=TRUE;
2961 }
2962 */
2963 if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)
2964 {
2965 strat->currIdx = pGetComp(strat->L[strat->Ll].sig);
2966#if F5C
2967 // 1. interreduction of the current standard basis
2968 // 2. generation of new principal syzygy rules for syzCriterion
2969 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
2970 lrmax, reduc, Q, w, hilb );
2971#endif
2972 // initialize new syzygy rules for the next iteration step
2973 initSyzRules(strat);
2974 }
2975 /*********************************************************************
2976 * interrreduction step is done, we can go on with the next iteration
2977 * step of the signature-based algorithm
2978 ********************************************************************/
2979 /* picks the last element from the lazyset L */
2980 strat->P = strat->L[strat->Ll];
2981 strat->Ll--;
2982
2984 strat->sbaEnterS = pGetComp(strat->P.sig) - 1;
2985 /* reduction of the element chosen from L */
2986 if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1))
2987 {
2988 //#if 1
2989#ifdef DEBUGF5
2990 PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
2991 PrintS("-------------------------------------------------\n");
2992 pWrite(strat->P.sig);
2993 pWrite(pHead(strat->P.p));
2994 pWrite(pHead(strat->P.p1));
2995 pWrite(pHead(strat->P.p2));
2996 PrintS("-------------------------------------------------\n");
2997#endif
2998 if (pNext(strat->P.p) == strat->tail)
2999 {
3000 // deletes the short spoly
3001 /*
3002 if (rField_is_Ring(currRing))
3003 pLmDelete(strat->P.p);
3004 else
3005 pLmFree(strat->P.p);
3006*/
3007 // TODO: needs some masking
3008 // TODO: masking needs to vanish once the signature
3009 // sutff is completely implemented
3010 strat->P.p = NULL;
3011 poly m1 = NULL, m2 = NULL;
3012
3013 // check that spoly creation is ok
3014 while (strat->tailRing != currRing &&
3015 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
3016 {
3017 assume(m1 == NULL && m2 == NULL);
3018 // if not, change to a ring where exponents are at least
3019 // large enough
3020 if (!kStratChangeTailRing(strat))
3021 {
3022 WerrorS("OVERFLOW...");
3023 break;
3024 }
3025 }
3026 // create the real one
3027 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
3028 strat->tailRing, m1, m2, strat->R);
3029
3030 }
3031 else if (strat->P.p1 == NULL)
3032 {
3033 if (strat->minim > 0)
3034 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
3035 // for input polys, prepare reduction
3037 strat->P.PrepareRed(strat->use_buckets);
3038 }
3039 if (strat->P.p == NULL && strat->P.t_p == NULL)
3040 {
3041 red_result = 0;
3042 }
3043 else
3044 {
3045 //#if 1
3046#ifdef DEBUGF5
3047 PrintS("Poly before red: ");
3048 pWrite(pHead(strat->P.p));
3049 pWrite(strat->P.sig);
3050#endif
3051#if SBA_PRODUCT_CRITERION
3052 if (strat->P.prod_crit)
3053 {
3054#if SBA_PRINT_PRODUCT_CRITERION
3055 product_criterion++;
3056#endif
3057 int pos = posInSyz(strat, strat->P.sig);
3058 enterSyz(strat->P, strat, pos);
3059 kDeleteLcm(&strat->P);
3060 red_result = 2;
3061 }
3062 else
3063 {
3064 red_result = strat->red(&strat->P,strat);
3065 }
3066#else
3067 red_result = strat->red(&strat->P,strat);
3068#endif
3069 }
3070 }
3071 else
3072 {
3073 /*
3074 if (strat->P.lcm != NULL)
3075 pLmFree(strat->P.lcm);
3076 */
3077 red_result = 2;
3078 }
3080 {
3081 if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig)))
3082 {
3083 strat->P.p = pNeg(strat->P.p);
3084 strat->P.sig = pNeg(strat->P.sig);
3085 }
3086 strat->P.pLength = pLength(strat->P.p);
3087 if(strat->P.sig != NULL)
3088 strat->P.sevSig = pGetShortExpVector(strat->P.sig);
3089 if(strat->P.p != NULL)
3090 strat->P.sev = pGetShortExpVector(strat->P.p);
3091 }
3092 //sigdrop case
3093 if(rField_is_Ring(currRing) && strat->sigdrop)
3094 {
3095 //First reduce it as much as one can
3096 red_result = redRing(&strat->P,strat);
3097 if(red_result == 0)
3098 {
3099 strat->sigdrop = FALSE;
3100 pDelete(&strat->P.sig);
3101 strat->P.sig = NULL;
3102 }
3103 else
3104 {
3105 strat->enterS(strat->P, 0, strat, strat->tl);
3106 if (TEST_OPT_PROT)
3107 PrintS("-");
3108 break;
3109 }
3110 }
3111 if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax)
3112 {
3113 strat->sigdrop = TRUE;
3114 break;
3115 }
3116
3117 if (errorreported) break;
3118
3119//#if 1
3120#ifdef DEBUGF5
3121 if (red_result != 0)
3122 {
3123 PrintS("Poly after red: ");
3124 pWrite(pHead(strat->P.p));
3125 pWrite(strat->P.GetLmCurrRing());
3126 pWrite(strat->P.sig);
3127 printf("%d\n",red_result);
3128 }
3129#endif
3130 if (TEST_OPT_PROT)
3131 {
3132 if(strat->P.p != NULL)
3133 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
3134 &olddeg,&reduc,strat, red_result);
3135 else
3136 message((strat->honey ? strat->P.ecart : 0),
3137 &olddeg,&reduc,strat, red_result);
3138 }
3139
3140 if (strat->overflow)
3141 {
3142 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
3143 }
3144 // reduction to non-zero new poly
3145 if (red_result == 1)
3146 {
3147 // get the polynomial (canonicalize bucket, make sure P.p is set)
3148 strat->P.GetP(strat->lmBin);
3149
3150 // sig-safe computations may lead to wrong FDeg computation, thus we need
3151 // to recompute it to make sure everything is alright
3152 (strat->P).FDeg = (strat->P).pFDeg();
3153 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
3154 // but now, for entering S, T, we reset it
3155 // in the inhomogeneous case: FDeg == pFDeg
3156 if (strat->homog) strat->initEcart(&(strat->P));
3157
3158 /* statistic */
3159 if (TEST_OPT_PROT) PrintS("s");
3160
3161 //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3162 // in F5E we know that the last reduced element is already the
3163 // the one with highest signature
3164 int pos = strat->sl+1;
3165
3166 // reduce the tail and normalize poly
3167 // in the ring case we cannot expect LC(f) = 1,
3168 #ifdef HAVE_RINGS
3169 poly beforetailred;
3171 beforetailred = pCopy(strat->P.sig);
3172 #endif
3173#if SBA_TAIL_RED
3175 {
3177 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3178 }
3179 else
3180 {
3181 if (strat->sbaOrder != 2)
3182 {
3184 {
3185 strat->P.pCleardenom();
3187 {
3188 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3189 strat->P.pCleardenom();
3190 }
3191 }
3192 else
3193 {
3194 strat->P.pNorm();
3196 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3197 }
3198 }
3199 }
3200 // It may happen that we have lost the sig in redtailsba
3201 // It cannot reduce to 0 since here we are doing just tail reduction.
3202 // Best case scenerio: remains the leading term
3203 if(rField_is_Ring(currRing) && strat->sigdrop)
3204 {
3205 strat->enterS(strat->P, 0, strat, strat->tl);
3206 break;
3207 }
3208#endif
3210 {
3211 if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1)
3212 {
3213 strat->sigdrop = TRUE;
3214 //Reduce it as much as you can
3215 red_result = redRing(&strat->P,strat);
3216 if(red_result == 0)
3217 {
3218 //It reduced to 0, cancel the sigdrop
3219 strat->sigdrop = FALSE;
3220 p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL;
3221 }
3222 else
3223 {
3224 strat->enterS(strat->P, 0, strat, strat->tl);
3225 break;
3226 }
3227 }
3228 p_Delete(&beforetailred,currRing);
3229 // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing
3230 if(strat->P.p == NULL)
3231 goto case_when_red_result_changed;
3232 }
3233 // remove sigsafe label since it is no longer valid for the next element to
3234 // be reduced
3235 if (strat->sbaOrder == 1)
3236 {
3237 for (int jj = 0; jj<strat->tl+1; jj++)
3238 {
3239 if (pGetComp(strat->T[jj].sig) == strat->currIdx)
3240 {
3241 strat->T[jj].is_sigsafe = FALSE;
3242 }
3243 }
3244 }
3245 else
3246 {
3247 for (int jj = 0; jj<strat->tl+1; jj++)
3248 {
3249 strat->T[jj].is_sigsafe = FALSE;
3250 }
3251 }
3252#ifdef KDEBUG
3253 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3254#endif /* KDEBUG */
3255
3256 // min_std stuff
3257 if ((strat->P.p1==NULL) && (strat->minim>0))
3258 {
3259 if (strat->minim==1)
3260 {
3261 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
3262 p_Delete(&strat->P.p2, currRing, strat->tailRing);
3263 }
3264 else
3265 {
3266 strat->M->m[minimcnt]=strat->P.p2;
3267 strat->P.p2=NULL;
3268 }
3269 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
3270 pNext(strat->M->m[minimcnt])
3271 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
3272 strat->tailRing, currRing,
3273 currRing->PolyBin);
3274 minimcnt++;
3275 }
3276
3277 // enter into S, L, and T
3278 //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3279 enterT(strat->P, strat);
3280 strat->T[strat->tl].is_sigsafe = FALSE;
3281 /*
3282 printf("hier\n");
3283 pWrite(strat->P.GetLmCurrRing());
3284 pWrite(strat->P.sig);
3285 */
3287 superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3288 else
3289 enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3290 if(rField_is_Ring(currRing) && strat->sigdrop)
3291 break;
3293 strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing);
3294 strat->enterS(strat->P, pos, strat, strat->tl);
3295 if(strat->sbaOrder != 1)
3296 {
3297 BOOLEAN overwrite = FALSE;
3298 for (int tk=0; tk<strat->sl+1; tk++)
3299 {
3300 if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))
3301 {
3302 //printf("TK %d / %d\n",tk,strat->sl);
3303 overwrite = FALSE;
3304 break;
3305 }
3306 }
3307 //printf("OVERWRITE %d\n",overwrite);
3308 if (overwrite)
3309 {
3310 int cmp = pGetComp(strat->P.sig);
3311 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3312 p_GetExpV (strat->P.p,vv,currRing);
3313 p_SetExpV (strat->P.sig, vv,currRing);
3314 p_SetComp (strat->P.sig,cmp,currRing);
3315
3316 strat->P.sevSig = pGetShortExpVector (strat->P.sig);
3317 int i;
3318 LObject Q;
3319 for(int ps=0;ps<strat->sl+1;ps++)
3320 {
3321
3322 strat->newt = TRUE;
3323 if (strat->syzl == strat->syzmax)
3324 {
3325 pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);
3326 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
3327 (strat->syzmax)*sizeof(unsigned long),
3328 ((strat->syzmax)+setmaxTinc)
3329 *sizeof(unsigned long));
3330 strat->syzmax += setmaxTinc;
3331 }
3332 Q.sig = pCopy(strat->P.sig);
3333 // add LM(F->m[i]) to the signature to get a Schreyer order
3334 // without changing the underlying polynomial ring at all
3335 if (strat->sbaOrder == 0)
3336 p_ExpVectorAdd (Q.sig,strat->S[ps],currRing);
3337 // since p_Add_q() destroys all input
3338 // data we need to recreate help
3339 // each time
3340 // ----------------------------------------------------------
3341 // in the Schreyer order we always know that the multiplied
3342 // module monomial strat->P.sig gives the leading monomial of
3343 // the corresponding principal syzygy
3344 // => we do not need to compute the "real" syzygy completely
3345 poly help = p_Copy(strat->sig[ps],currRing);
3346 p_ExpVectorAdd (help,strat->P.p,currRing);
3347 Q.sig = p_Add_q(Q.sig,help,currRing);
3348 //printf("%d. SYZ ",i+1);
3349 //pWrite(strat->syz[i]);
3350 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
3351 i = posInSyz(strat, Q.sig);
3352 enterSyz(Q, strat, i);
3353 }
3354 }
3355 }
3356 // deg - idx - lp/rp
3357 // => we need to add syzygies with indices > pGetComp(strat->P.sig)
3358 if(strat->sbaOrder == 0 || strat->sbaOrder == 3)
3359 {
3360 int cmp = pGetComp(strat->P.sig);
3361 unsigned max_cmp = IDELEMS(F);
3362 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3363 p_GetExpV (strat->P.p,vv,currRing);
3364 LObject Q;
3365 int pos;
3366 int idx = __p_GetComp(strat->P.sig,currRing);
3367 //printf("++ -- adding syzygies -- ++\n");
3368 // if new element is the first one in this index
3369 if (strat->currIdx < idx)
3370 {
3371 for (int i=0; i<strat->sl; ++i)
3372 {
3373 Q.sig = p_Copy(strat->P.sig,currRing);
3374 p_ExpVectorAdd(Q.sig,strat->S[i],currRing);
3375 poly help = p_Copy(strat->sig[i],currRing);
3376 p_ExpVectorAdd(help,strat->P.p,currRing);
3377 Q.sig = p_Add_q(Q.sig,help,currRing);
3378 //pWrite(Q.sig);
3379 pos = posInSyz(strat, Q.sig);
3380 enterSyz(Q, strat, pos);
3381 }
3382 strat->currIdx = idx;
3383 }
3384 else
3385 {
3386 // if the element is not the first one in the given index we build all
3387 // possible syzygies with elements of higher index
3388 for (unsigned i=cmp+1; i<=max_cmp; ++i)
3389 {
3390 pos = -1;
3391 for (int j=0; j<strat->sl; ++j)
3392 {
3393 if (__p_GetComp(strat->sig[j],currRing) == i)
3394 {
3395 pos = j;
3396 break;
3397 }
3398 }
3399 if (pos != -1)
3400 {
3401 Q.sig = p_One(currRing);
3402 p_SetExpV(Q.sig, vv, currRing);
3403 // F->m[i-1] corresponds to index i
3404 p_ExpVectorAdd(Q.sig,F->m[i-1],currRing);
3405 p_SetComp(Q.sig, i, currRing);
3406 poly help = p_Copy(strat->P.sig,currRing);
3407 p_ExpVectorAdd(help,strat->S[pos],currRing);
3408 Q.sig = p_Add_q(Q.sig,help,currRing);
3409 if (strat->sbaOrder == 0)
3410 {
3411 if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn)
3412 {
3413 pos = posInSyz(strat, Q.sig);
3414 enterSyz(Q, strat, pos);
3415 }
3416 }
3417 else
3418 {
3419 pos = posInSyz(strat, Q.sig);
3420 enterSyz(Q, strat, pos);
3421 }
3422 }
3423 }
3424 //printf("++ -- done adding syzygies -- ++\n");
3425 }
3426 }
3427//#if 1
3428#if DEBUGF50
3429 printf("---------------------------\n");
3430 Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);
3431 PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl]));
3432 PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]);
3433#endif
3434 /*
3435 if (newrules)
3436 {
3437 newrules = FALSE;
3438 }
3439 */
3440#if 0
3441 int pl=pLength(strat->P.p);
3442 if (pl==1)
3443 {
3444 //if (TEST_OPT_PROT)
3445 //PrintS("<1>");
3446 }
3447 else if (pl==2)
3448 {
3449 //if (TEST_OPT_PROT)
3450 //PrintS("<2>");
3451 }
3452#endif
3453 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
3454// Print("[%d]",hilbeledeg);
3455 kDeleteLcm(&strat->P);
3456 if (strat->sl>srmax) srmax = strat->sl;
3457 }
3458 else
3459 {
3460 case_when_red_result_changed:
3461 // adds signature of the zero reduction to
3462 // strat->syz. This is the leading term of
3463 // syzygy and can be used in syzCriterion()
3464 // the signature is added if and only if the
3465 // pair was not detected by the rewritten criterion in strat->red = redSig
3466 if (red_result!=2)
3467 {
3468#if SBA_PRINT_ZERO_REDUCTIONS
3469 zeroreductions++;
3470#endif
3471 if(rField_is_Ring(currRing) && strat->P.p == NULL && strat->P.sig == NULL)
3472 {
3473 //Catch the case when p = 0, sig = 0
3474 }
3475 else
3476 {
3477 int pos = posInSyz(strat, strat->P.sig);
3478 enterSyz(strat->P, strat, pos);
3479 //#if 1
3480 #ifdef DEBUGF5
3481 Print("ADDING STUFF TO SYZ : ");
3482 //pWrite(strat->P.p);
3483 pWrite(strat->P.sig);
3484 #endif
3485 }
3486 }
3487 if (strat->P.p1 == NULL && strat->minim > 0)
3488 {
3489 p_Delete(&strat->P.p2, currRing, strat->tailRing);
3490 }
3491 }
3492
3493#ifdef KDEBUG
3494 memset(&(strat->P), 0, sizeof(strat->P));
3495#endif /* KDEBUG */
3496 kTest_TS(strat);
3497 }
3498 #if 0
3499 if(strat->sigdrop)
3500 printf("\nSigDrop!\n");
3501 else
3502 printf("\nEnded with no SigDrop\n");
3503 #endif
3504// Clean strat->P for the next sba call
3505 if(rField_is_Ring(currRing) && strat->sigdrop)
3506 {
3507 //This is used to know how many elements can we directly add to S in the next run
3508 if(strat->P.sig != NULL)
3509 strat->sbaEnterS = pGetComp(strat->P.sig)-1;
3510 //else we already set it at the beggining of the loop
3511 #ifdef KDEBUG
3512 memset(&(strat->P), 0, sizeof(strat->P));
3513 #endif /* KDEBUG */
3514 }
3515#ifdef KDEBUG
3516 if (TEST_OPT_DEBUG) messageSets(strat);
3517#endif /* KDEBUG */
3518
3519 if (TEST_OPT_SB_1)
3520 {
3522 {
3523 int k=1;
3524 int j;
3525 while(k<=strat->sl)
3526 {
3527 j=0;
3528 loop
3529 {
3530 if (j>=k) break;
3531 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
3532 j++;
3533 }
3534 k++;
3535 }
3536 }
3537 }
3538 /* complete reduction of the standard basis--------- */
3539 if (TEST_OPT_REDSB)
3540 {
3541 completeReduce(strat);
3542 if (strat->completeReduce_retry)
3543 {
3544 // completeReduce needed larger exponents, retry
3545 // to reduce with S (instead of T)
3546 // and in currRing (instead of strat->tailRing)
3547#ifdef HAVE_TAIL_RING
3548 if(currRing->bitmask>strat->tailRing->bitmask)
3549 {
3551 cleanT(strat);strat->tailRing=currRing;
3552 int i;
3553 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3554 completeReduce(strat);
3555 }
3556 if (strat->completeReduce_retry)
3557#endif
3558 Werror("exponent bound is %ld",currRing->bitmask);
3559 }
3560 }
3561 else if (TEST_OPT_PROT) PrintLn();
3562
3563#if SBA_PRINT_SIZE_SYZ
3564 // that is correct, syzl is counting one too far
3565 size_syz = strat->syzl;
3566#endif
3567// if (TEST_OPT_WEIGHTM)
3568// {
3569// pRestoreDegProcs(pFDegOld, pLDegOld);
3570// if (ecartWeights)
3571// {
3572// omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
3573// ecartWeights=NULL;
3574// }
3575// }
3576 if (TEST_OPT_PROT) messageStatSBA(hilbcount,strat);
3577 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3578#if SBA_PRINT_SIZE_G
3579 size_g_non_red = IDELEMS(strat->Shdl);
3580#endif
3582 exitSba(strat);
3583 // I have to add the initial input polynomials which where not used (p1 and p2 = NULL)
3584 #ifdef HAVE_RINGS
3585 int k;
3587 {
3588 //for(k = strat->sl;k>=0;k--)
3589 // {printf("\nS[%i] = %p\n",k,strat->Shdl->m[k]);pWrite(strat->Shdl->m[k]);}
3590 k = strat->Ll;
3591 #if 1
3592 // 1 - adds just the unused ones, 0 - adds everthing
3593 for(;k>=0 && (strat->L[k].p1 != NULL || strat->L[k].p2 != NULL);k--)
3594 {
3595 //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);
3596 deleteInL(strat->L,&strat->Ll,k,strat);
3597 }
3598 #endif
3599 //for(int kk = strat->sl;kk>=0;kk--)
3600 // {printf("\nS[%i] = %p\n",kk,strat->Shdl->m[kk]);pWrite(strat->Shdl->m[kk]);}
3601 //idPrint(strat->Shdl);
3602 //printf("\nk = %i\n",k);
3603 for(;k>=0 && strat->L[k].p1 == NULL && strat->L[k].p2 == NULL;k--)
3604 {
3605 //printf("\nAdded k = %i\n",k);
3606 strat->enterS(strat->L[k], strat->sl+1, strat, strat->tl);
3607 //printf("\nThis elements was added from L on pos %i\n",strat->sl);pWrite(strat->S[strat->sl]);pWrite(strat->sig[strat->sl]);
3608 }
3609 }
3610 // 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
3611 #if 0
3612 if(strat->sigdrop && rField_is_Ring(currRing))
3613 {
3614 for(k=strat->sl;k>=0;k--)
3615 {
3616 printf("\nsig[%i] = ",i);pWrite(strat->sig[k]);
3617 if(strat->sig[k] == NULL)
3618 strat->sig[k] = pCopy(strat->sig[k-1]);
3619 }
3620 }
3621 #endif
3622 #endif
3623 //Never do this - you will damage S
3624 //idSkipZeroes(strat->Shdl);
3625 //idPrint(strat->Shdl);
3626
3627 if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld)
3628 {
3629 rChangeCurrRing (currRingOld);
3630 F0 = idrMoveR (F1, sRing, currRing);
3631 strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing);
3632 rChangeCurrRing (sRing);
3634 exitSba(strat);
3635 rChangeCurrRing (currRingOld);
3636 if(strat->tailRing == sRing)
3637 strat->tailRing = currRing;
3638 rDelete (sRing);
3639 }
3640 if(rField_is_Ring(currRing) && !strat->sigdrop)
3641 id_DelDiv(strat->Shdl, currRing);
3643 id_DelDiv(strat->Shdl, currRing);
3644 idSkipZeroes(strat->Shdl);
3645 idTest(strat->Shdl);
3646
3647#if SBA_PRINT_SIZE_G
3648 size_g = IDELEMS(strat->Shdl);
3649#endif
3650#ifdef DEBUGF5
3651 printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));
3652 int oo = 0;
3653 while (oo<IDELEMS(strat->Shdl))
3654 {
3655 printf(" %d. ",oo+1);
3656 pWrite(pHead(strat->Shdl->m[oo]));
3657 oo++;
3658 }
3659#endif
3660#if SBA_PRINT_ZERO_REDUCTIONS
3661 printf("----------------------------------------------------------\n");
3662 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3663 zeroreductions = 0;
3664#endif
3665#if SBA_PRINT_REDUCTION_STEPS
3666 printf("----------------------------------------------------------\n");
3667 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3668#endif
3669#if SBA_PRINT_OPERATIONS
3670 printf("OPERATIONS: %ld\n",sba_operations);
3671#endif
3672#if SBA_PRINT_REDUCTION_STEPS
3673 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3674 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3675#endif
3676#if SBA_PRINT_OPERATIONS
3677 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3678#endif
3679#if SBA_PRINT_REDUCTION_STEPS
3680 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3681 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3682 sba_interreduction_steps = 0;
3683 sba_reduction_steps = 0;
3684#endif
3685#if SBA_PRINT_OPERATIONS
3686 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3687 sba_interreduction_operations = 0;
3688 sba_operations = 0;
3689#endif
3690#if SBA_PRINT_SIZE_G
3691 printf("----------------------------------------------------------\n");
3692 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3693 size_g = 0;
3694 size_g_non_red = 0;
3695#endif
3696#if SBA_PRINT_SIZE_SYZ
3697 printf("SIZE OF SYZ: %ld\n",size_syz);
3698 printf("----------------------------------------------------------\n");
3699 size_syz = 0;
3700#endif
3701#if SBA_PRINT_PRODUCT_CRITERION
3702 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3703 product_criterion = 0;
3704#endif
3705 return (strat->Shdl);
3706}
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:3743
void initSba(ideal F, kStrategy strat)
Definition: kstd1.cc:1734
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kstd2.cc:1576
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:4039
void initSbaPos(kStrategy strat)
Definition: kutil.cc:10168
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4613
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4569
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
Definition: kutil.cc:11399
void messageStatSBA(int hilbcount, kStrategy strat)
Definition: kutil.cc:7822
void initSyzRules(kStrategy strat)
Definition: kutil.cc:8232
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:10270
void exitSba(kStrategy strat)
Definition: kutil.cc:10345
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
Definition: kutil.cc:4941
void initSbaCrit(kStrategy strat)
Definition: kutil.cc:9797
#define help
Definition: libparse.cc:1230
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1544
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1520
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 1780 of file kutil.cc.

1781{
1782 if(strat->sl < 0) return FALSE;
1783 int i;
1784 for(i=0;i<strat->sl;i++)
1785 {
1786 //Construct the gcd pair between h and S[i]
1787 number d, s, t;
1788 poly m1, m2, gcd;
1789 d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1790 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1791 {
1792 nDelete(&d);
1793 nDelete(&s);
1794 nDelete(&t);
1795 }
1796 else
1797 {
1798 k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1799 pSetCoeff0(m1, s);
1800 pSetCoeff0(m2, t);
1801 pSetCoeff0(gcd, d);
1802 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);
1803 poly pSigMult = p_Copy(h->sig,currRing);
1804 poly sSigMult = p_Copy(strat->sig[i],currRing);
1805 pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1806 sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1807 p_LmDelete(m1, strat->tailRing);
1808 p_LmDelete(m2, strat->tailRing);
1809 poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1810 if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1811 {
1812 pDelete(&h->p);
1813 h->p = gcd;
1814 pDelete(&h->sig);
1815 h->sig = pairsig;
1816 pNext(h->sig) = NULL;
1817 strat->initEcart(h);
1818 h->sev = pGetShortExpVector(h->p);
1819 h->sevSig = pGetShortExpVector(h->sig);
1820 h->i_r1 = -1;h->i_r2 = -1;
1821 if(h->lcm != NULL)
1822 {
1823 pLmDelete(h->lcm);
1824 h->lcm = NULL;
1825 }
1826 if (currRing!=strat->tailRing)
1827 h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1828 return TRUE;
1829 }
1830 //Delete what you didn't use
1831 pDelete(&gcd);
1832 pDelete(&pairsig);
1833 }
1834 }
1835 return FALSE;
1836}
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:1072
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1031

◆ sbaRing()

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

Definition at line 11399 of file kutil.cc.

11400{
11401 int n = rBlocks(r); // Including trailing zero!
11402 // if sbaOrder == 1 => use (C,monomial order from r)
11403 if (strat->sbaOrder == 1)
11404 {
11405 if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11406 {
11407 return r;
11408 }
11409 ring res = rCopy0(r, TRUE, FALSE);
11410 res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11411 res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11412 res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11413 int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11414 res->wvhdl = wvhdl;
11415 for (int i=1; i<n; i++)
11416 {
11417 res->order[i] = r->order[i-1];
11418 res->block0[i] = r->block0[i-1];
11419 res->block1[i] = r->block1[i-1];
11420 res->wvhdl[i] = r->wvhdl[i-1];
11421 }
11422
11423 // new 1st block
11424 res->order[0] = ringorder_C; // Prefix
11425 // removes useless secondary component order if defined in old ring
11426 for (int i=rBlocks(res); i>0; --i)
11427 {
11428 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11429 {
11430 res->order[i] = (rRingOrder_t)0;
11431 }
11432 }
11433 rComplete(res, 1);
11434#ifdef HAVE_PLURAL
11435 if (rIsPluralRing(r))
11436 {
11437 if ( nc_rComplete(r, res, false) ) // no qideal!
11438 {
11439#ifndef SING_NDEBUG
11440 WarnS("error in nc_rComplete");
11441#endif
11442 // cleanup?
11443
11444 // rDelete(res);
11445 // return r;
11446
11447 // just go on..
11448 }
11449 }
11450#endif
11451 strat->tailRing = res;
11452 return (res);
11453 }
11454 // if sbaOrder == 3 => degree - position - ring order
11455 if (strat->sbaOrder == 3)
11456 {
11457 ring res = rCopy0(r, TRUE, FALSE);
11458 res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11459 res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11460 res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11461 int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11462 res->wvhdl = wvhdl;
11463 for (int i=2; i<n+2; i++)
11464 {
11465 res->order[i] = r->order[i-2];
11466 res->block0[i] = r->block0[i-2];
11467 res->block1[i] = r->block1[i-2];
11468 res->wvhdl[i] = r->wvhdl[i-2];
11469 }
11470
11471 // new 1st block
11472 res->order[0] = ringorder_a; // Prefix
11473 res->block0[0] = 1;
11474 res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11475 for (int i=0; i<res->N; ++i)
11476 res->wvhdl[0][i] = 1;
11477 res->block1[0] = si_min(res->N, rVar(res));
11478 // new 2nd block
11479 res->order[1] = ringorder_C; // Prefix
11480 res->wvhdl[1] = NULL;
11481 // removes useless secondary component order if defined in old ring
11482 for (int i=rBlocks(res); i>1; --i)
11483 {
11484 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11485 {
11486 res->order[i] = (rRingOrder_t)0;
11487 }
11488 }
11489 rComplete(res, 1);
11490#ifdef HAVE_PLURAL
11491 if (rIsPluralRing(r))
11492 {
11493 if ( nc_rComplete(r, res, false) ) // no qideal!
11494 {
11495#ifndef SING_NDEBUG
11496 WarnS("error in nc_rComplete");
11497#endif
11498 // cleanup?
11499
11500 // rDelete(res);
11501 // return r;
11502
11503 // just go on..
11504 }
11505 }
11506#endif
11507 strat->tailRing = res;
11508 return (res);
11509 }
11510
11511 // not sbaOrder == 1 => use Schreyer order
11512 // this is done by a trick when initializing the signatures
11513 // in initSLSba():
11514 // Instead of using the signature 1e_i for F->m[i], we start
11515 // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11516 // Schreyer order w.r.t. the underlying monomial order.
11517 // => we do not need to change the underlying polynomial ring at all!
11518
11519 // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11520
11521 /*
11522 else
11523 {
11524 ring res = rCopy0(r, FALSE, FALSE);
11525 // Create 2 more blocks for prefix/suffix:
11526 res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11527 res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11528 res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11529 int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11530
11531 // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11532 // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11533
11534 // new 1st block
11535 int j = 0;
11536 res->order[j] = ringorder_IS; // Prefix
11537 res->block0[j] = res->block1[j] = 0;
11538 // wvhdl[j] = NULL;
11539 j++;
11540
11541 for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11542 {
11543 res->order [j] = r->order [i];
11544 res->block0[j] = r->block0[i];
11545 res->block1[j] = r->block1[i];
11546
11547 if (r->wvhdl[i] != NULL)
11548 {
11549 wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11550 } // else wvhdl[j] = NULL;
11551 }
11552
11553 // new last block
11554 res->order [j] = ringorder_IS; // Suffix
11555 res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11556 // wvhdl[j] = NULL;
11557 j++;
11558
11559 // res->order [j] = 0; // The End!
11560 res->wvhdl = wvhdl;
11561
11562 // j == the last zero block now!
11563 assume(j == (n+1));
11564 assume(res->order[0]==ringorder_IS);
11565 assume(res->order[j-1]==ringorder_IS);
11566 assume(res->order[j]==0);
11567
11568 if (complete)
11569 {
11570 rComplete(res, 1);
11571
11572#ifdef HAVE_PLURAL
11573 if (rIsPluralRing(r))
11574 {
11575 if ( nc_rComplete(r, res, false) ) // no qideal!
11576 {
11577 }
11578 }
11579 assume(rIsPluralRing(r) == rIsPluralRing(res));
11580#endif
11581
11582
11583#ifdef HAVE_PLURAL
11584 ring old_ring = r;
11585
11586#endif
11587
11588 if (r->qideal!=NULL)
11589 {
11590 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11591
11592 assume(idRankFreeModule(res->qideal, res) == 0);
11593
11594#ifdef HAVE_PLURAL
11595 if( rIsPluralRing(res) )
11596 if( nc_SetupQuotient(res, r, true) )
11597 {
11598 // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11599 }
11600
11601#endif
11602 assume(idRankFreeModule(res->qideal, res) == 0);
11603 }
11604
11605#ifdef HAVE_PLURAL
11606 assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11607 assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11608 assume(rIsSCA(res) == rIsSCA(old_ring));
11609 assume(ncRingType(res) == ncRingType(old_ring));
11610#endif
11611 }
11612 strat->tailRing = res;
11613 return res;
11614 }
11615 */
11616
11617 assume(FALSE);
11618 return(NULL);
11619}
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:5786
static int rBlocks(ring r)
Definition: ring.h:569
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 4556 of file kutil.cc.

4557{
4559#if HAVE_SHIFTBBA
4560 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4561#endif
4562 // enter also zero divisor * poly, if this is non zero and of smaller degree
4564 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4565 initenterpairs(h, k, ecart, 0, strat, atR);
4566 clearSbatch(h, k, pos, strat);
4567}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4530
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4247
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4329

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

4570{
4572 // enter also zero divisor * poly, if this is non zero and of smaller degree
4573 if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4574 if(strat->sigdrop) return;
4575 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4576 if(strat->sigdrop) return;
4577 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4578 if(strat->sigdrop) return;
4579 clearSbatch(h, k, pos, strat);
4580}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4027
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4302
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4412

◆ syzCriterion()

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

Definition at line 6770 of file kutil.cc.

6771{
6772//#if 1
6773#ifdef DEBUGF5
6774 PrintS("syzygy criterion checks: ");
6775 pWrite(sig);
6776#endif
6777 for (int k=0; k<strat->syzl; k++)
6778 {
6779 //printf("-%d",k);
6780//#if 1
6781#ifdef DEBUGF5
6782 Print("checking with: %d / %d -- \n",k,strat->syzl);
6783 pWrite(pHead(strat->syz[k]));
6784#endif
6785 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6786 && (!rField_is_Ring(currRing) ||
6787 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6788 {
6789//#if 1
6790#ifdef DEBUGF5
6791 PrintS("DELETE!\n");
6792#endif
6793 strat->nrsyzcrit++;
6794 //printf("- T -\n\n");
6795 return TRUE;
6796 }
6797 }
6798 //printf("- F -\n\n");
6799 return FALSE;
6800}

◆ syzCriterionInc()

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

Definition at line 6805 of file kutil.cc.

6806{
6807//#if 1
6808 if(sig == NULL)
6809 return FALSE;
6810#ifdef DEBUGF5
6811 PrintS("--- syzygy criterion checks: ");
6812 pWrite(sig);
6813#endif
6814 int comp = __p_GetComp(sig, currRing);
6815 int min, max;
6816 if (comp<=1)
6817 return FALSE;
6818 else
6819 {
6820 min = strat->syzIdx[comp-2];
6821 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6822 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6823 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6824 if (comp == strat->currIdx)
6825 {
6826 max = strat->syzl;
6827 }
6828 else
6829 {
6830 max = strat->syzIdx[comp-1];
6831 }
6832 for (int k=min; k<max; k++)
6833 {
6834#ifdef F5DEBUG
6835 Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6836 Print("checking with: %d -- ",k);
6837 pWrite(pHead(strat->syz[k]));
6838#endif
6839 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6840 && (!rField_is_Ring(currRing) ||
6841 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6842 {
6843 strat->nrsyzcrit++;
6844 return TRUE;
6845 }
6846 }
6847 return FALSE;
6848 }
6849}
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 10385 of file kutil.cc.

10386{
10387 int l;
10388 if (strat->ak>0)
10389 {
10390 for (l=IDELEMS(r)-1;l>=0;l--)
10391 {
10392 if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10393 {
10394 pDelete(&r->m[l]); // and set it to NULL
10395 }
10396 }
10397 int q;
10398 poly p;
10400 {
10401 for (l=IDELEMS(r)-1;l>=0;l--)
10402 {
10403 if ((r->m[l]!=NULL)
10404 //&& (strat->syzComp>0)
10405 //&& (pGetComp(r->m[l])<=strat->syzComp)
10406 )
10407 {
10408 for(q=IDELEMS(Q)-1; q>=0;q--)
10409 {
10410 if ((Q->m[q]!=NULL)
10411 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10412 {
10413 if (TEST_OPT_REDSB)
10414 {
10415 p=r->m[l];
10416 r->m[l]=kNF(Q,NULL,p);
10417 pDelete(&p);
10418 }
10419 else
10420 {
10421 pDelete(&r->m[l]); // and set it to NULL
10422 }
10423 break;
10424 }
10425 }
10426 }
10427 }
10428 }
10429 #ifdef HAVE_RINGS
10430 else
10431 {
10432 for (l=IDELEMS(r)-1;l>=0;l--)
10433 {
10434 if ((r->m[l]!=NULL)
10435 //&& (strat->syzComp>0)
10436 //&& (pGetComp(r->m[l])<=strat->syzComp)
10437 )
10438 {
10439 for(q=IDELEMS(Q)-1; q>=0;q--)
10440 {
10441 if ((Q->m[q]!=NULL)
10442 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10443 {
10444 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10445 {
10446 if (TEST_OPT_REDSB)
10447 {
10448 p=r->m[l];
10449 r->m[l]=kNF(Q,NULL,p);
10450 pDelete(&p);
10451 }
10452 else
10453 {
10454 pDelete(&r->m[l]); // and set it to NULL
10455 }
10456 break;
10457 }
10458 }
10459 }
10460 }
10461 }
10462 }
10463 #endif
10464 }
10465 else
10466 {
10467 int q;
10468 poly p;
10469 BOOLEAN reduction_found=FALSE;
10471 {
10472 for (l=IDELEMS(r)-1;l>=0;l--)
10473 {
10474 if (r->m[l]!=NULL)
10475 {
10476 for(q=IDELEMS(Q)-1; q>=0;q--)
10477 {
10478 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10479 {
10480 if (TEST_OPT_REDSB)
10481 {
10482 p=r->m[l];
10483 r->m[l]=kNF(Q,NULL,p);
10484 pDelete(&p);
10485 reduction_found=TRUE;
10486 }
10487 else
10488 {
10489 pDelete(&r->m[l]); // and set it to NULL
10490 }
10491 break;
10492 }
10493 }
10494 }
10495 }
10496 }
10497 #ifdef HAVE_RINGS
10498 //Also need divisibility of the leading coefficients
10499 else
10500 {
10501 for (l=IDELEMS(r)-1;l>=0;l--)
10502 {
10503 if (r->m[l]!=NULL)
10504 {
10505 for(q=IDELEMS(Q)-1; q>=0;q--)
10506 {
10507 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10508 {
10509 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10510 {
10511 if (TEST_OPT_REDSB)
10512 {
10513 p=r->m[l];
10514 r->m[l]=kNF(Q,NULL,p);
10515 pDelete(&p);
10516 reduction_found=TRUE;
10517 }
10518 else
10519 {
10520 pDelete(&r->m[l]); // and set it to NULL
10521 }
10522 break;
10523 }
10524 }
10525 }
10526 }
10527 }
10528 }
10529 #endif
10530 if (/*TEST_OPT_REDSB &&*/ reduction_found)
10531 {
10532 #ifdef HAVE_RINGS
10534 {
10535 for (l=IDELEMS(r)-1;l>=0;l--)
10536 {
10537 if (r->m[l]!=NULL)
10538 {
10539 for(q=IDELEMS(r)-1;q>=0;q--)
10540 {
10541 if ((l!=q)
10542 && (r->m[q]!=NULL)
10543 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10544 &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10545 )
10546 {
10547 //If they are equal then take the one with the smallest length
10548 if(pLmDivisibleBy(r->m[q],r->m[l])
10549 && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10550 && (pLength(r->m[q]) < pLength(r->m[l]) ||
10551 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10552 {
10553 pDelete(&r->m[l]);
10554 break;
10555 }
10556 else
10557 pDelete(&r->m[q]);
10558 }
10559 }
10560 }
10561 }
10562 }
10563 else
10564 #endif
10565 {
10566 for (l=IDELEMS(r)-1;l>=0;l--)
10567 {
10568 if (r->m[l]!=NULL)
10569 {
10570 for(q=IDELEMS(r)-1;q>=0;q--)
10571 {
10572 if ((l!=q)
10573 && (r->m[q]!=NULL)
10574 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10575 )
10576 {
10577 //If they are equal then take the one with the smallest length
10578 if(pLmDivisibleBy(r->m[q],r->m[l])
10579 &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10580 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10581 {
10582 pDelete(&r->m[l]);
10583 break;
10584 }
10585 else
10586 pDelete(&r->m[q]);
10587 }
10588 }
10589 }
10590 }
10591 }
10592 }
10593 }
10594 idSkipZeroes(r);
10595}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3167

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8850 of file kutil.cc.

8851{
8852 LObject h;
8853 int i, suc=0;
8854 poly redSi=NULL;
8855 BOOLEAN change,any_change;
8856// Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
8857// for (i=0; i<=(strat->sl); i++)
8858// {
8859// Print("s%d:",i);
8860// if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
8861// pWrite(strat->S[i]);
8862// }
8863// Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
8864 any_change=FALSE;
8866 {
8867 while (suc != -1)
8868 {
8869 i=suc+1;
8870 while (i<=strat->sl)
8871 {
8872 change=FALSE;
8874 any_change = FALSE;
8875 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8876 {
8877 redSi = pHead(strat->S[i]);
8878 strat->S[i] = redBba(strat->S[i],i-1,strat);
8879 //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
8880 // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
8881 if (pCmp(redSi,strat->S[i])!=0)
8882 {
8883 change=TRUE;
8884 any_change=TRUE;
8885 #ifdef KDEBUG
8886 if (TEST_OPT_DEBUG)
8887 {
8888 PrintS("reduce:");
8889 wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
8890 }
8891 #endif
8892 if (TEST_OPT_PROT)
8893 {
8894 if (strat->S[i]==NULL)
8895 PrintS("V");
8896 else
8897 PrintS("v");
8898 mflush();
8899 }
8900 }
8901 pLmDelete(&redSi);
8902 if (strat->S[i]==NULL)
8903 {
8904 deleteInS(i,strat);
8905 i--;
8906 }
8907 else if (change)
8908 {
8910 {
8912 {
8913 number n;
8914 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8915 if (!nIsOne(n))
8916 {
8918 denom->n=nInvers(n);
8919 denom->next=DENOMINATOR_LIST;
8920 DENOMINATOR_LIST=denom;
8921 }
8922 nDelete(&n);
8923 }
8924 else
8925 {
8926 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8927 }
8928 }
8929 else
8930 {
8931 pNorm(strat->S[i]);
8932 }
8933 strat->sevS[i] = pGetShortExpVector(strat->S[i]);
8934 }
8935 }
8936 i++;
8937 }
8938 if (any_change) reorderS(&suc,strat);
8939 else break;
8940 }
8941 if (toT)
8942 {
8943 for (i=0; i<=strat->sl; i++)
8944 {
8945 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8946 {
8947 h.p = redtailBba(strat->S[i],i-1,strat);
8949 {
8950 h.pCleardenom();// also does remove Content
8951 }
8952 }
8953 else
8954 {
8955 h.p = strat->S[i];
8956 }
8957 strat->initEcart(&h);
8958 if (strat->honey)
8959 {
8960 strat->ecartS[i] = h.ecart;
8961 }
8962 if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
8963 else assume(strat->sevS[i] == pGetShortExpVector(h.p));
8964 h.sev = strat->sevS[i];
8965 /*puts the elements of S also to T*/
8966 strat->initEcart(&h);
8967 /*if (toT) - already checked*/ enterT(h,strat);
8968 strat->S_2_R[i] = strat->tl;
8969#ifdef HAVE_SHIFTBBA
8970 if (/*(toT) && */(currRing->isLPring))
8971 enterTShift(h, strat);
8972#endif
8973 }
8974 }
8975 }
8976 else
8977 {
8978 while (suc != -1)
8979 {
8980 i=suc;
8981 while (i<=strat->sl)
8982 {
8983 change=FALSE;
8984 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8985 {
8986 redSi=pHead((strat->S)[i]);
8987 (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
8988 if ((strat->S)[i]==NULL)
8989 {
8990 deleteInS(i,strat);
8991 i--;
8992 }
8993 else if (pCmp((strat->S)[i],redSi)!=0)
8994 {
8995 any_change=TRUE;
8996 h.p = strat->S[i];
8997 strat->initEcart(&h);
8998 strat->ecartS[i] = h.ecart;
9000 {
9002 {
9003 number n;
9004 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
9005 if (!nIsOne(n))
9006 {
9008 denom->n=nInvers(n);
9009 denom->next=DENOMINATOR_LIST;
9010 DENOMINATOR_LIST=denom;
9011 }
9012 nDelete(&n);
9013 }
9014 else
9015 {
9016 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
9017 }
9018 }
9019 else
9020 {
9021 pNorm(strat->S[i]); // == h.p
9022 }
9023 h.sev = pGetShortExpVector(h.p);
9024 strat->sevS[i] = h.sev;
9025 }
9026 pLmDelete(&redSi);
9027 kTest(strat);
9028 }
9029 i++;
9030 }
9031#ifdef KDEBUG
9032 kTest(strat);
9033#endif
9034 if (any_change) reorderS(&suc,strat);
9035 else { suc=-1; break; }
9036 if (h.p!=NULL)
9037 {
9038 if (!strat->kAllAxis)
9039 {
9040 /*strat->kAllAxis =*/ HEckeTest(h.p,strat);
9041 }
9042 if (strat->kAllAxis)
9043 newHEdge(strat);
9044 }
9045 }
9046 for (i=0; i<=strat->sl; i++)
9047 {
9048 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9049 {
9050 strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
9051 strat->initEcart(&h);
9052 strat->ecartS[i] = h.ecart;
9053 h.sev = pGetShortExpVector(h.p);
9054 strat->sevS[i] = h.sev;
9055 }
9056 else
9057 {
9058 h.p = strat->S[i];
9059 h.ecart=strat->ecartS[i];
9060 h.sev = strat->sevS[i];
9061 h.length = h.pLength = pLength(h.p);
9062 }
9063 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9064 cancelunit1(&h,&suc,strat->sl,strat);
9065 h.SetpFDeg();
9066 /*puts the elements of S also to T*/
9067 enterT(h,strat);
9068 strat->S_2_R[i] = strat->tl;
9069#ifdef HAVE_SHIFTBBA
9070 if (currRing->isLPring)
9071 enterTShift(h, strat);
9072#endif
9073 }
9074 if (suc!= -1) updateS(toT,strat);
9075 }
9076#ifdef KDEBUG
9077 kTest(strat);
9078#endif
9079}
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8805
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8781
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition: kutil.cc:8693
void HEckeTest(poly pp, kStrategy strat)
Definition: kutil.cc:505
void reorderS(int *suc, kStrategy strat)
Definition: kutil.cc:4710
BOOLEAN newHEdge(kStrategy strat)
Definition: kutil.cc:10719

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 882 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 881 of file kutil.h.