My Project
Loading...
Searching...
No Matches
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 redHoneyM (LObject *h, kStrategy strat)
 
int redLiftstd (LObject *h, kStrategy strat)
 
int redRing (LObject *h, kStrategy strat)
 
int redRing_Z (LObject *h, kStrategy strat)
 
int redRiloc (LObject *h, kStrategy strat)
 
void enterExtendedSpoly (poly h, kStrategy strat)
 
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
 
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
int redLazy (LObject *h, kStrategy strat)
 
int redHomog (LObject *h, kStrategy strat)
 
int redSig (LObject *h, kStrategy strat)
 
int redSigRing (LObject *h, kStrategy strat)
 
void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void enterpairs (poly h, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void entersets (LObject h)
 
void pairs ()
 
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
 
void message (int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
 
void messageStat (int hilbcount, kStrategy strat)
 
void messageStatSBA (int hilbcount, kStrategy strat)
 
void messageSets (kStrategy strat)
 
void initEcartNormal (TObject *h)
 
void initEcartBBA (TObject *h)
 
void initS (ideal F, ideal Q, kStrategy strat)
 
void initSL (ideal F, ideal Q, kStrategy strat)
 
void initSLSba (ideal F, ideal Q, kStrategy strat)
 
void initSyzRules (kStrategy strat)
 
void updateS (BOOLEAN toT, kStrategy strat)
 
void enterSyz (LObject &p, kStrategy strat, int atT)
 
void enterT (LObject &p, kStrategy strat, int atT=-1)
 
void replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
void enterT_strong (LObject &p, kStrategy strat, int atT=-1)
 
void cancelunit (LObject *p, BOOLEAN inNF=FALSE)
 
void HEckeTest (poly pp, kStrategy strat)
 
void initBuchMoraCrit (kStrategy strat)
 
void initSbaCrit (kStrategy strat)
 
void initHilbCrit (ideal F, ideal Q, intvec **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindDivisibleByInT (const kStrategy strat, const LObject *L, const int start=0)
 return -1 if no divisor is found number of first divisor in T, otherwise
 
int kFindDivisibleByInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kFindSameLMInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kTestDivisibleByT0_Z (const kStrategy strat, const LObject *L)
 tests if T[0] divides the leading monomial of L, returns -1 if not
 
int kFindDivisibleByInS (const kStrategy strat, int *max_ind, LObject *L)
 return -1 if no divisor is found number of first divisor in S, otherwise
 
int kFindNextDivisibleByInS (const kStrategy strat, int start, int max_ind, LObject *L)
 
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart=LONG_MAX)
 
KINLINE TSet initT ()
 
KINLINE TObject ** initR ()
 
KINLINE unsigned long * initsevT ()
 
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing)
 
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing)
 
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing)
 
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing)
 
KINLINE BOOLEAN k_GetLeadTerms (const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
 
KINLINE void k_GetStrongLeadTerms (const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring taiRing)
 
BOOLEAN kTest (kStrategy strat)
 
BOOLEAN kTest_TS (kStrategy strat)
 
BOOLEAN kTest_L (LObject *L, kStrategy strat, BOOLEAN testp=FALSE, int lpos=-1, TSet T=NULL, int tlength=-1)
 
BOOLEAN kTest_T (TObject *T, kStrategy strat, int tpos=-1, char TN='?')
 
BOOLEAN kTest_S (kStrategy strat)
 
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
 
ideal bba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
 
ideal kNF2 (ideal F, ideal Q, ideal q, kStrategy strat, int lazyReduce)
 
poly kNF2Bound (ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
 
ideal kNF2Bound (ideal F, ideal Q, ideal q, int bound, kStrategy strat, int lazyReduce)
 
void initBba (kStrategy strat)
 
void initSba (ideal F, kStrategy strat)
 
void f5c (kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, intvec *hilb)
 
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL)
 
int ksReducePolyZ (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyLC (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyGCD (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyBound (LObject *PR, TObject *PW, int bound, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySig (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySigRing (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyTail (LObject *PR, TObject *PW, poly Current, poly spNoether=NULL)
 
KINLINE int ksReducePolyTail (LObject *PR, TObject *PW, LObject *Red)
 
void ksCreateSpoly (LObject *Pair, poly spNoether=NULL, int use_buckets=0, ring tailRing=currRing, poly m1=NULL, poly m2=NULL, TObject **R=NULL)
 
poly ksCreateShortSpoly (poly p1, poly p2, ring tailRing)
 
KINLINE poly ksOldSpolyRed (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldSpolyRedNew (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldCreateSpoly (poly p1, poly p2, poly spNoether=NULL, ring r=currRing)
 
KINLINE void ksOldSpolyTail (poly p1, poly q, poly q2, poly spNoether, ring r=currRing)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
poly preIntegerCheck (ideal F, ideal Q)
 used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L=NULL, TObject *T=NULL, unsigned long new_expbound=0)
 
void kStratInitChangeTailRing (kStrategy strat)
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
 
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
 
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
 
static int kFindInL1 (const poly p, const kStrategy strat)
 
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 6929 of file kutil.cc.

6930{
6932 return FALSE;
6933 poly p1 = pOne();
6934 poly p2 = pOne();
6935 for (int ii=strat->sl; ii>start; ii--)
6936 {
6937 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6938 {
6939 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6940 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6941 if (!(pLmCmp(p1,p2) == 1))
6942 {
6943 pDelete(&p1);
6944 pDelete(&p2);
6945 return TRUE;
6946 }
6947 }
6948 }
6949 pDelete(&p1);
6950 pDelete(&p2);
6951 return FALSE;
6952}
#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:1427
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1931
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 6954 of file kutil.cc.

6955{
6956 //Over Rings, there are still some changes to do: considering coeffs
6958 return FALSE;
6959 int found = -1;
6960 for (int i=strat->Bl; i>-1; i--)
6961 {
6962 if (pLmEqual(strat->B[i].sig,sig))
6963 {
6964 found = i;
6965 break;
6966 }
6967 }
6968 if (found != -1)
6969 {
6970 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6971 {
6972 deleteInL(strat->B,&strat->Bl,found,strat);
6973 }
6974 else
6975 {
6976 return TRUE;
6977 }
6978 }
6979 poly p1 = pOne();
6980 poly p2 = pOne();
6981 for (int ii=strat->sl; ii>-1; ii--)
6982 {
6983 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6984 {
6985 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6986 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6987 if (!(pLmCmp(p1,p2) == 1))
6988 {
6989 pDelete(&p1);
6990 pDelete(&p2);
6991 return TRUE;
6992 }
6993 }
6994 }
6995 pDelete(&p1);
6996 pDelete(&p2);
6997 return FALSE;
6998}
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 2390 of file kstd2.cc.

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

◆ bbaShift()

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

Definition at line 4358 of file kstd2.cc.

4359{
4360 int red_result = 1;
4361 int olddeg,reduc;
4362 int hilbeledeg=1,hilbcount=0,minimcnt=0;
4363 BOOLEAN withT = TRUE; // currently only T contains the shifts
4364 BITSET save;
4365 SI_SAVE_OPT1(save);
4366
4367 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
4369 initBuchMoraPosRing(strat);
4370 else
4371 initBuchMoraPos(strat);
4372 initHilbCrit(F,Q,&hilb,strat);
4373 initBba(strat);
4374 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
4375 /*Shdl=*/initBuchMora(F, Q,strat);
4376 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
4377 reduc = olddeg = 0;
4378
4379#ifndef NO_BUCKETS
4381 strat->use_buckets = 1;
4382#endif
4383 // redtailBBa against T for inhomogenous input
4384 // if (!TEST_OPT_OLDSTD)
4385 // withT = ! strat->homog;
4386
4387 // strat->posInT = posInT_pLength;
4388 kTest_TS(strat);
4389
4390#ifdef HAVE_TAIL_RING
4391 // if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4392 // kStratInitChangeTailRing(strat);
4393 strat->tailRing=currRing;
4394#endif
4395 if (BVERBOSE(23))
4396 {
4397 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
4398 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
4399 kDebugPrint(strat);
4400 }
4401
4402#ifdef KDEBUG
4403 //kDebugPrint(strat);
4404#endif
4405 /* compute------------------------------------------------------- */
4406 while (strat->Ll >= 0)
4407 {
4408 #ifdef KDEBUG
4409 if (TEST_OPT_DEBUG) messageSets(strat);
4410 #endif
4411 if (siCntrlc)
4412 {
4413 while (strat->Ll >= 0)
4414 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4415 strat->noClearS=TRUE;
4416 }
4418 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4419 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
4420 {
4421 /*
4422 *stops computation if
4423 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
4424 *a predefined number Kstd1_deg
4425 */
4426 while ((strat->Ll >= 0)
4427 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
4428 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4429 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
4430 )
4431 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4432 if (strat->Ll<0) break;
4433 else strat->noClearS=TRUE;
4434 }
4435 if (strat->Ll== 0) strat->interpt=TRUE;
4436 /* picks the last element from the lazyset L */
4437 strat->P = strat->L[strat->Ll];
4438 strat->Ll--;
4439
4440 if (pNext(strat->P.p) == strat->tail)
4441 {
4442 // deletes the short spoly
4444 pLmDelete(strat->P.p);
4445 else
4446 pLmFree(strat->P.p);
4447 strat->P.p = NULL;
4448 poly m1 = NULL, m2 = NULL;
4449
4450 // check that spoly creation is ok
4451 while (strat->tailRing != currRing &&
4452 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4453 {
4454 assume(m1 == NULL && m2 == NULL);
4455 // if not, change to a ring where exponents are at least
4456 // large enough
4457 if (!kStratChangeTailRing(strat))
4458 {
4459 WerrorS("OVERFLOW...");
4460 break;
4461 }
4462 }
4463 // create the real one
4464 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4465 strat->tailRing, m1, m2, strat->R);
4466 }
4467 else if (strat->P.p1 == NULL)
4468 {
4469 if (strat->minim > 0)
4470 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4471 // for input polys, prepare reduction
4472 strat->P.PrepareRed(strat->use_buckets);
4473 }
4474
4475 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
4476 {
4477 red_result = 0;
4478 }
4479 else
4480 {
4481 if (TEST_OPT_PROT)
4482 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4483 &olddeg,&reduc,strat, red_result);
4484
4485 /* reduction of the element chosen from L */
4486 red_result = strat->red(&strat->P,strat);
4487 if (errorreported) break;
4488 }
4489
4490 if (strat->overflow)
4491 {
4492 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4493 }
4494
4495 // reduction to non-zero new poly
4496 if (red_result == 1)
4497 {
4498 // get the polynomial (canonicalize bucket, make sure P.p is set)
4499 strat->P.GetP(strat->lmBin);
4500 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4501 // but now, for entering S, T, we reset it
4502 // in the inhomogeneous case: FDeg == pFDeg
4503 if (strat->homog) strat->initEcart(&(strat->P));
4504
4505 /* statistic */
4506 if (TEST_OPT_PROT) PrintS("s");
4507
4508 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4509
4510 // reduce the tail and normalize poly
4511 // in the ring case we cannot expect LC(f) = 1,
4512 strat->redTailChange=FALSE;
4513
4514 /* if we are computing over Z we always want to try and cut down
4515 * the coefficients in the tail terms */
4517 {
4518 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
4519 }
4520
4522 {
4523 strat->P.pCleardenom();
4525 {
4526 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
4527 strat->P.pCleardenom();
4528 if (strat->redTailChange)
4529 {
4530 strat->P.t_p=NULL;
4531 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4532 }
4533 }
4534 }
4535 else
4536 {
4537 strat->P.pNorm();
4539 {
4540 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4541 if (strat->redTailChange)
4542 {
4543 strat->P.t_p=NULL;
4544 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4545 }
4546 }
4547 }
4548
4549#ifdef KDEBUG
4550 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4551#endif /* KDEBUG */
4552
4553 // min_std stuff
4554 if ((strat->P.p1==NULL) && (strat->minim>0))
4555 {
4556 if (strat->minim==1)
4557 {
4558 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4559 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4560 }
4561 else
4562 {
4563 strat->M->m[minimcnt]=strat->P.p2;
4564 strat->P.p2=NULL;
4565 }
4566 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4567 pNext(strat->M->m[minimcnt])
4568 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4569 strat->tailRing, currRing,
4570 currRing->PolyBin);
4571 minimcnt++;
4572 }
4573
4574
4575 // enter into S, L, and T
4576 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4577 {
4578 enterT(strat->P, strat);
4579 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4580 // posInS only depends on the leading term
4581 strat->enterS(strat->P, pos, strat, strat->tl);
4582 if (!strat->rightGB)
4583 enterTShift(strat->P, strat);
4584 }
4585
4586 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4587// Print("[%d]",hilbeledeg);
4588 kDeleteLcm(&strat->P);
4589 if (strat->s_poly!=NULL)
4590 {
4591 // the only valid entries are: strat->P.p,
4592 // strat->tailRing (read-only, keep it)
4593 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
4594 if (strat->s_poly(strat))
4595 {
4596 // we are called AFTER enterS, i.e. if we change P
4597 // we have to add it also to S/T
4598 // and add pairs
4599 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4600 enterT(strat->P, strat);
4601 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4602 strat->enterS(strat->P, pos, strat, strat->tl);
4603 if (!strat->rightGB)
4604 enterTShift(strat->P,strat);
4605 }
4606 }
4607 }
4608 else if (strat->P.p1 == NULL && strat->minim > 0)
4609 {
4610 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4611 }
4612#ifdef KDEBUG
4613 memset(&(strat->P), 0, sizeof(strat->P));
4614#endif /* KDEBUG */
4615 kTest_TS(strat);
4616 }
4617#ifdef KDEBUG
4618 if (TEST_OPT_DEBUG) messageSets(strat);
4619#endif /* KDEBUG */
4620 /* shift case: look for elt's in S such that they are divisible by elt in T */
4621 if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
4622 {
4624 {
4625 for (int k = 0; k <= strat->sl; ++k)
4626 {
4627 if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
4628 for (int j = 0; j<=strat->tl; ++j)
4629 {
4630 if (strat->T[j].p!=NULL)
4631 {
4632 // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
4633 assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
4634 assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
4635 if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
4636 {
4637 if (pLmCmp(strat->T[j].p, strat->S[k]) != 0)
4638 { // check whether LM is different
4639 deleteInS(k, strat);
4640 --k;
4641 break;
4642 }
4643 }
4644 }
4645 }
4646 }
4647 }
4648 }
4649 /* complete reduction of the standard basis--------- */
4650 if (TEST_OPT_REDSB)
4651 {
4652 completeReduce(strat, TRUE); //shift: withT = TRUE
4653 if (strat->completeReduce_retry)
4654 {
4655 // completeReduce needed larger exponents, retry
4656 // to reduce with S (instead of T)
4657 // and in currRing (instead of strat->tailRing)
4658#ifdef HAVE_TAIL_RING
4659 if(currRing->bitmask>strat->tailRing->bitmask)
4660 {
4662 cleanT(strat);strat->tailRing=currRing;
4663 int i;
4664 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
4665 WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know
4666 completeReduce(strat);
4667 }
4668 if (strat->completeReduce_retry)
4669#endif
4670 Werror("exponent bound is %ld",currRing->bitmask);
4671 }
4672 }
4673 else if (TEST_OPT_PROT) PrintLn();
4674
4675 /* release temp data-------------------------------- */
4676 exitBuchMora(strat);
4677 /* postprocessing for GB over ZZ --------------------*/
4678 if (!errorreported)
4679 {
4681 {
4682 for(int i = 0;i<=strat->sl;i++)
4683 {
4684 if(!nGreaterZero(pGetCoeff(strat->S[i])))
4685 {
4686 strat->S[i] = pNeg(strat->S[i]);
4687 }
4688 }
4689 finalReduceByMon(strat);
4690 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
4691 {
4692 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
4693 {
4694 strat->S[i] = pNeg(strat->Shdl->m[i]);
4695 }
4696 }
4697 }
4698 //else if (rField_is_Ring(currRing))
4699 // finalReduceByMon(strat);
4700 }
4701// if (TEST_OPT_WEIGHTM)
4702// {
4703// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
4704// if (ecartWeights)
4705// {
4706// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
4707// ecartWeights=NULL;
4708// }
4709// }
4710 if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
4711 SI_RESTORE_OPT1(save);
4712 /* postprocessing for GB over Q-rings ------------------*/
4713 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
4714
4715 idTest(strat->Shdl);
4716
4717 return (strat->Shdl);
4718}
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:13450
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:13420
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:4077
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:471
#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:685
poly(* pShallowCopyDeleteProc)(poly s_p, ring source_r, ring dest_r, omBin dest_bin)
returns a poly from dest_r which is a ShallowCopy of s_p from source_r assumes that source_r->N == de...
Definition: ring.h: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 10613 of file kutil.cc.

10614{
10615 int i;
10616 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10617 LObject L;
10618
10619#ifdef KDEBUG
10620 // need to set this: during tailreductions of T[i], T[i].max is out of
10621 // sync
10622 sloppy_max = TRUE;
10623#endif
10624
10625 strat->noTailReduction = FALSE;
10626 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10627 if (TEST_OPT_PROT)
10628 {
10629 PrintLn();
10630// if (timerv) writeTime("standard base computed:");
10631 }
10632 if (TEST_OPT_PROT)
10633 {
10634 Print("(S:%d)",strat->sl);mflush();
10635 }
10636 for (i=strat->sl; i>=low; i--)
10637 {
10638 int end_pos=strat->sl;
10639 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10640 if (strat->ak==0) end_pos=i-1;
10641 TObject* T_j = strat->s_2_t(i);
10642 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10643 {
10644 L = *T_j;
10645 #ifdef KDEBUG
10646 if (TEST_OPT_DEBUG)
10647 {
10648 Print("test S[%d]:",i);
10649 p_wrp(L.p,currRing,strat->tailRing);
10650 PrintLn();
10651 }
10652 #endif
10654 strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10655 else
10656 strat->S[i] = redtail(&L, strat->sl, strat);
10657 #ifdef KDEBUG
10658 if (TEST_OPT_DEBUG)
10659 {
10660 Print("to (tailR) S[%d]:",i);
10661 p_wrp(strat->S[i],currRing,strat->tailRing);
10662 PrintLn();
10663 }
10664 #endif
10665
10666 if (strat->redTailChange)
10667 {
10668 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10669 if (pNext(T_j->p) != NULL)
10670 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10671 else
10672 T_j->max_exp = NULL;
10673 }
10675 T_j->pCleardenom();
10676 }
10677 else
10678 {
10679 assume(currRing == strat->tailRing);
10680 #ifdef KDEBUG
10681 if (TEST_OPT_DEBUG)
10682 {
10683 Print("test S[%d]:",i);
10684 p_wrp(strat->S[i],currRing,strat->tailRing);
10685 PrintLn();
10686 }
10687 #endif
10689 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10690 else
10691 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10693 {
10695 {
10696 number n;
10697 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10698 if (!nIsOne(n))
10699 {
10701 denom->n=nInvers(n);
10702 denom->next=DENOMINATOR_LIST;
10703 DENOMINATOR_LIST=denom;
10704 }
10705 nDelete(&n);
10706 }
10707 else
10708 {
10709 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10710 }
10711 }
10712 #ifdef KDEBUG
10713 if (TEST_OPT_DEBUG)
10714 {
10715 Print("to (-tailR) S[%d]:",i);
10716 p_wrp(strat->S[i],currRing,strat->tailRing);
10717 PrintLn();
10718 }
10719 #endif
10720 }
10721 if (TEST_OPT_PROT)
10722 PrintS("-");
10723 }
10724 if (TEST_OPT_PROT) PrintLn();
10725#ifdef KDEBUG
10726 sloppy_max = FALSE;
10727#endif
10728}
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:7147
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7223
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:1729
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1582

◆ 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:1004
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:249
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:235
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:713
#define p_Test(p, r)
Definition: p_polys.h: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 12625 of file kutil.cc.

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

13421{
13422 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
13423 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
13424 int j=pos;
13425
13426 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
13427 initenterpairsShift(h,k,ecart,0,strat, atR);
13428 if ( (!strat->fromT)
13429 && ((strat->syzComp==0)
13430 ||(pGetComp(h)<=strat->syzComp)))
13431 {
13432 unsigned long h_sev = pGetShortExpVector(h);
13433 loop
13434 {
13435 if (j > k) break;
13436 // TODO this currently doesn't clear all possible elements because of commutative division
13437 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
13438 clearS(h,h_sev, &j,&k,strat);
13439 j++;
13440 }
13441 }
13442}
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:12968

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

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

◆ enterSBbaShift()

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

Definition at line 9201 of file kutil.cc.

9202{
9203 enterSBba(p, atS, strat, atR);
9204
9205 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
9206 for (int i = maxPossibleShift; i > 0; i--)
9207 {
9208 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
9209 // in `kNF2` because of lazy poly normalizations.
9210 LObject qq(p_Copy(p.p, strat->tailRing));
9211 p_mLPshift(qq.p, i, strat->tailRing);
9212 qq.shift = i;
9213 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
9214 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
9215 enterSBba(qq, atS, strat, -1);
9216 }
9217}
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9101
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 9224 of file kutil.cc.

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

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

9451{
9452 int i;
9453
9454#ifdef PDEBUG
9455#ifdef HAVE_SHIFTBBA
9456 if (currRing->isLPring && p.shift > 0)
9457 {
9458 // in this case, the order is not correct. test LM and tail separately
9459 p_LmTest(p.p, currRing);
9460 p_Test(pNext(p.p), currRing);
9461 }
9462 else
9463#endif
9464 {
9465 pp_Test(p.p, currRing, p.tailRing);
9466 }
9467#endif
9468 assume(strat->tailRing == p.tailRing);
9469 // redMoraNF complains about this -- but, we don't really
9470 // neeed this so far
9471 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9472 assume(!strat->homog || (p.FDeg == p.pFDeg()));
9473 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9474
9475#ifdef KDEBUG
9476 // do not put an LObject twice into T:
9477 for(i=strat->tl;i>=0;i--)
9478 {
9479 if (p.p==strat->T[i].p)
9480 {
9481 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9482 return;
9483 }
9484 }
9485#endif
9486
9487#ifdef HAVE_TAIL_RING
9488 if (currRing!=strat->tailRing)
9489 {
9490 p.t_p=p.GetLmTailRing();
9491 }
9492#endif
9493 strat->newt = TRUE;
9494 if (atT < 0)
9495 atT = strat->posInT(strat->T, strat->tl, p);
9496 if (strat->tl == strat->tmax-1)
9497 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9498 if (atT <= strat->tl)
9499 {
9500#ifdef ENTER_USE_MEMMOVE
9501 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9502 (strat->tl-atT+1)*sizeof(TObject));
9503 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9504 (strat->tl-atT+1)*sizeof(unsigned long));
9505#endif
9506 for (i=strat->tl+1; i>=atT+1; i--)
9507 {
9508#ifndef ENTER_USE_MEMMOVE
9509 strat->T[i] = strat->T[i-1];
9510 strat->sevT[i] = strat->sevT[i-1];
9511#endif
9512 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9513 }
9514 }
9515
9516 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9517 {
9518#ifdef HAVE_SHIFTBBA
9519 // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9520 if (!(currRing->isLPring && p.shift > 0))
9521#endif
9522 {
9524 (strat->tailRing != NULL ?
9525 strat->tailRing : currRing),
9526 strat->tailBin);
9527 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9528 }
9529 }
9530 strat->T[atT] = (TObject) p;
9531 //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9532
9533 if ((pNext(p.p) != NULL) && (!rIsLPRing(currRing)))
9534 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9535 else
9536 strat->T[atT].max_exp = NULL;
9537
9538 strat->tl++;
9539 strat->R[strat->tl] = &(strat->T[atT]);
9540 strat->T[atT].i_r = strat->tl;
9541 assume((p.sev == 0) || (pGetShortExpVector(p.p) == p.sev));
9542 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9543 kTest_T(&(strat->T[atT]),strat);
9544}
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:930
#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 9550 of file kutil.cc.

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

13451{
13452 /* determine how many elements we have to insert */
13453 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
13454 /* hence, a total number of elt's to add is: */
13455 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
13456 pAssume(p.p != NULL);
13457
13458 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
13459
13460 for (int i = 1; i <= maxPossibleShift; i++)
13461 {
13462 LObject qq;
13463 qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
13464 qq.shift = i;
13465 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
13466
13467 enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13468 }
13469}
#define pAssume(cond)
Definition: monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 10158 of file kutil.cc.

10159{
10160 /*- release temp data -*/
10161 cleanT(strat);
10162 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10163 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10164 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10165 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10166 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10167 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10168 /*- set L: should be empty -*/
10169 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10170 /*- set B: should be empty -*/
10171 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10172 pLmFree(&strat->tail);
10173 strat->syzComp=0;
10174
10175#ifdef HAVE_SHIFTBBA
10176 if (rIsLPRing(currRing) && strat->rightGB)
10177 {
10178 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10179 strat->fromQ=NULL;
10180 }
10181#endif
10182}
void * ADDRESS
Definition: auxiliary.h:119

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10361 of file kutil.cc.

10362{
10363 /*- release temp data -*/
10365 cleanTSbaRing(strat);
10366 else
10367 cleanT(strat);
10368 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10369 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10370 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10371 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10372 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10373 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10374 if(strat->syzmax>0)
10375 {
10376 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10377 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10378 if (strat->sbaOrder == 1)
10379 {
10380 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10381 }
10382 }
10383 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10384 /*- set L: should be empty -*/
10385 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10386 /*- set B: should be empty -*/
10387 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10388 /*- set sig: no need for the signatures anymore -*/
10389 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10390 pLmDelete(&strat->tail);
10391 strat->syzComp=0;
10392}
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 4046 of file kstd2.cc.

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

6871{
6872 //printf("Faugere Rewritten Criterion\n");
6874 return FALSE;
6875//#if 1
6876#ifdef DEBUGF5
6877 PrintS("rewritten criterion checks: ");
6878 pWrite(sig);
6879#endif
6880 for(int k = strat->sl; k>=start; k--)
6881 {
6882//#if 1
6883#ifdef DEBUGF5
6884 PrintS("checking with: ");
6885 pWrite(strat->sig[k]);
6886 pWrite(pHead(strat->S[k]));
6887#endif
6888 if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6889 {
6890//#if 1
6891#ifdef DEBUGF5
6892 PrintS("DELETE!\n");
6893#endif
6894 strat->nrrewcrit++;
6895 return TRUE;
6896 }
6897 //k--;
6898 }
6899#ifdef DEBUGF5
6900 PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6901 for(int kk = 0; kk<strat->sl+1; kk++)
6902 {
6903 pWrite(pHead(strat->S[kk]));
6904 }
6905 PrintS("------------------------------\n");
6906#endif
6907 return FALSE;
6908}
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 11201 of file kutil.cc.

11202{
11203 assume(strat->tl<0); /* can only be called with no elements in T:
11204 i.e. after exitBuchMora */
11205 /* do not use strat->S, strat->sl as they may be out of sync*/
11206 if(!nCoeff_is_Z(currRing->cf))
11207 return;
11208 poly p,pp;
11209 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
11210 {
11211 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
11212 {
11213 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
11214 {
11215 if((i != j) && (strat->Shdl->m[i] != NULL))
11216 {
11217 p = strat->Shdl->m[i];
11218 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
11219#if HAVE_SHIFTBBA
11220 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
11221#endif
11222 ))
11223 {
11224 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
11225 if (!nEqual(dummy,p->coef))
11226 {
11227 if (nIsZero(dummy))
11228 {
11229 nDelete(&dummy);
11230 pLmDelete(&strat->Shdl->m[i]);
11231 p=strat->Shdl->m[i];
11232 }
11233 else
11234 {
11235 p_SetCoeff(p,dummy,currRing);
11236 break;
11237 }
11238 }
11239 else
11240 {
11241 nDelete(&dummy);
11242 break;
11243 }
11244 }
11245 if (p!=NULL)
11246 {
11247 pp = pNext(p);
11248 while(pp != NULL)
11249 {
11250 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
11251#if HAVE_SHIFTBBA
11252 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
11253#endif
11254 )
11255 {
11256 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
11257 if (!nEqual(dummy,pp->coef))
11258 {
11259 p_SetCoeff(pp,dummy,currRing);
11260 if(nIsZero(pp->coef))
11261 {
11262 pLmDelete(&pNext(p));
11263 pp = pNext(p);
11264 }
11265 else
11266 {
11267 p = pp;
11268 pp = pNext(p);
11269 }
11270 }
11271 else
11272 {
11273 nDelete(&dummy);
11274 p = pp;
11275 pp = pNext(p);
11276 }
11277 }
11278 else
11279 {
11280 p = pp;
11281 pp = pNext(p);
11282 }
11283 }
11284 }
11285 }
11286 }
11287 //idPrint(strat->Shdl);
11288 }
11289 }
11290 idSkipZeroes(strat->Shdl);
11291}
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:414
#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:1905
int redHomog(LObject *h, kStrategy strat)
Definition: kstd2.cc:938
int redLazy(LObject *h, kStrategy strat)
Definition: kstd2.cc:1698
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 10073 of file kutil.cc.

10074{
10075 strat->interpt = BTEST1(OPT_INTERRUPT);
10076 /*- creating temp data structures------------------- -*/
10077 //strat->cp = 0; // already by skStragy()
10078 //strat->c3 = 0; // already by skStragy()
10079#ifdef HAVE_SHIFTBBA
10080 strat->cv = 0; // already by skStragy()
10081#endif
10082 strat->tail = pInit();
10083 /*- set s -*/
10084 strat->sl = -1;
10085 /*- set L -*/
10086 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10087 strat->Ll = -1;
10088 strat->L = initL(strat->Lmax);
10089 /*- set B -*/
10090 strat->Bmax = setmaxL;
10091 strat->Bl = -1;
10092 strat->B = initL();
10093 /*- set T -*/
10094 strat->tl = -1;
10095 strat->tmax = setmaxT;
10096 strat->T = initT();
10097 strat->R = initR();
10098 strat->sevT = initsevT();
10099 /*- init local data struct.---------------------------------------- -*/
10100 //strat->P.ecart=0; // already by skStragy()
10101 //strat->P.length=0; // already by skStragy()
10102 //strat->P.pLength=0; // already by skStragy()
10104 {
10105 if (strat->kNoether!=NULL)
10106 {
10107 pSetComp(strat->kNoether, strat->ak);
10108 pSetComp(strat->kNoetherTail(), strat->ak);
10109 }
10110 }
10112 {
10113 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10114 }
10115 else
10116 {
10117 if(TEST_OPT_SB_1)
10118 {
10119 int i;
10120 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10121 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10122 {
10123 P->m[i-strat->newIdeal] = F->m[i];
10124 F->m[i] = NULL;
10125 }
10126 initSSpecial(F,Q,P,strat);
10127 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10128 {
10129 F->m[i] = P->m[i-strat->newIdeal];
10130 P->m[i-strat->newIdeal] = NULL;
10131 }
10132 idDelete(&P);
10133 }
10134 else
10135 {
10136 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10137 // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
10138 }
10139 }
10140 strat->fromT = FALSE;
10142 if ((!TEST_OPT_SB_1)
10144 )
10145 {
10146 updateS(TRUE,strat);
10147 }
10148#ifdef HAVE_SHIFTBBA
10149 if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
10150#endif
10151 {
10152 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10153 strat->fromQ=NULL;
10154 }
10155 assume(kTest_TS(strat));
10156}
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:8403
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:8866
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8001
#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 9748 of file kutil.cc.

9749{
9752 if (TEST_OPT_SB_1)
9754#ifdef HAVE_RINGS
9756 {
9758 strat->chainCrit=chainCritRing;
9759 }
9760#endif
9761#ifdef HAVE_RATGRING
9762 if (rIsRatGRing(currRing))
9763 {
9764 strat->chainCrit=chainCritPart;
9765 /* enterOnePairNormal get rational part in it */
9766 }
9767#endif
9768 if (TEST_OPT_IDLIFT
9769 && (strat->syzComp==1)
9770 && (!rIsPluralRing(currRing)))
9772
9774 strat->Gebauer = strat->homog || strat->sugarCrit;
9775 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9776 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9777 strat->pairtest = NULL;
9778 /* alway use tailreduction, except:
9779 * - in local rings, - in lex order case, -in ring over extensions */
9781 //if(rHasMixedOrdering(currRing)==2)
9782 //{
9783 // strat->noTailReduction =TRUE;
9784 //}
9785
9786#ifdef HAVE_PLURAL
9787 // and r is plural_ring
9788 // hence this holds for r a rational_plural_ring
9789 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9790 { //or it has non-quasi-comm type... later
9791 strat->sugarCrit = FALSE;
9792 strat->Gebauer = FALSE;
9793 strat->honey = FALSE;
9794 }
9795#endif
9796
9797 // Coefficient ring?
9799 {
9800 strat->sugarCrit = FALSE;
9801 strat->Gebauer = FALSE;
9802 strat->honey = FALSE;
9803 }
9804 #ifdef KDEBUG
9805 if (TEST_OPT_DEBUG)
9806 {
9807 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9808 else PrintS("ideal/module is not homogeneous\n");
9809 }
9810 #endif
9811}
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 9900 of file kutil.cc.

9901{
9903 {
9904 if (strat->honey)
9905 {
9906 strat->posInL = posInL15;
9907 // ok -- here is the deal: from my experiments for Singular-2-0
9908 // I conclude that that posInT_EcartpLength is the best of
9909 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9910 // see the table at the end of this file
9911 if (TEST_OPT_OLDSTD)
9912 strat->posInT = posInT15;
9913 else
9914 strat->posInT = posInT_EcartpLength;
9915 }
9916 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9917 {
9918 strat->posInL = posInL11;
9919 strat->posInT = posInT11;
9920 }
9921 else if (TEST_OPT_INTSTRATEGY)
9922 {
9923 strat->posInL = posInL11;
9924 strat->posInT = posInT11;
9925 }
9926 else
9927 {
9928 strat->posInL = posInL0;
9929 strat->posInT = posInT0;
9930 }
9931 //if (strat->minim>0) strat->posInL =posInLSpecial;
9932 if (strat->homog)
9933 {
9934 strat->posInL = posInL110;
9935 strat->posInT = posInT110;
9936 }
9937 }
9938 else /* local/mixed ordering */
9939 {
9940 if (strat->homog)
9941 {
9942 strat->posInL = posInL11;
9943 strat->posInT = posInT11;
9944 }
9945 else
9946 {
9947 if ((currRing->order[0]==ringorder_c)
9948 ||(currRing->order[0]==ringorder_C))
9949 {
9950 strat->posInL = posInL17_c;
9951 strat->posInT = posInT17_c;
9952 }
9953 else
9954 {
9955 strat->posInL = posInL17;
9956 strat->posInT = posInT17;
9957 }
9958 }
9959 }
9960 if (strat->minim>0) strat->posInL =posInLSpecial;
9961 // for further tests only
9962 if ((BTEST1(11)) || (BTEST1(12)))
9963 strat->posInL = posInL11;
9964 else if ((BTEST1(13)) || (BTEST1(14)))
9965 strat->posInL = posInL13;
9966 else if ((BTEST1(15)) || (BTEST1(16)))
9967 strat->posInL = posInL15;
9968 else if ((BTEST1(17)) || (BTEST1(18)))
9969 strat->posInL = posInL17;
9970 if (BTEST1(11))
9971 strat->posInT = posInT11;
9972 else if (BTEST1(13))
9973 strat->posInT = posInT13;
9974 else if (BTEST1(15))
9975 strat->posInT = posInT15;
9976 else if ((BTEST1(17)))
9977 strat->posInT = posInT17;
9978 else if ((BTEST1(19)))
9979 strat->posInT = posInT19;
9980 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9981 strat->posInT = posInT1;
9983}
char posInLDependsOnLength
Definition: kutil.h:389
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6358
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5460
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5053
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:5326
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:6447
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:9884
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5297
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5797
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6482
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5568
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5364
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5753
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6559
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5207
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5696
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6654
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6059
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9986 of file kutil.cc.

9987{
9989 {
9990 if (strat->honey)
9991 {
9992 strat->posInL = posInL15Ring;
9993 // ok -- here is the deal: from my experiments for Singular-2-0
9994 // I conclude that that posInT_EcartpLength is the best of
9995 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9996 // see the table at the end of this file
9997 if (TEST_OPT_OLDSTD)
9998 strat->posInT = posInT15Ring;
9999 else
10000 strat->posInT = posInT_EcartpLength;
10001 }
10002 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10003 {
10004 strat->posInL = posInL11Ring;
10005 strat->posInT = posInT11;
10006 }
10007 else if (TEST_OPT_INTSTRATEGY)
10008 {
10009 strat->posInL = posInL11Ring;
10010 strat->posInT = posInT11;
10011 }
10012 else
10013 {
10014 strat->posInL = posInL0Ring;
10015 strat->posInT = posInT0;
10016 }
10017 //if (strat->minim>0) strat->posInL =posInLSpecial;
10018 if (strat->homog)
10019 {
10020 strat->posInL = posInL110Ring;
10021 strat->posInT = posInT110Ring;
10022 }
10023 }
10024 else
10025 {
10026 if (strat->homog)
10027 {
10028 //printf("\nHere 3\n");
10029 strat->posInL = posInL11Ring;
10030 strat->posInT = posInT11Ring;
10031 }
10032 else
10033 {
10034 if ((currRing->order[0]==ringorder_c)
10035 ||(currRing->order[0]==ringorder_C))
10036 {
10037 strat->posInL = posInL17_cRing;
10038 strat->posInT = posInT17_cRing;
10039 }
10040 else
10041 {
10042 strat->posInL = posInL11Ringls;
10043 strat->posInT = posInT17Ring;
10044 }
10045 }
10046 }
10047 if (strat->minim>0) strat->posInL =posInLSpecial;
10048 // for further tests only
10049 if ((BTEST1(11)) || (BTEST1(12)))
10050 strat->posInL = posInL11Ring;
10051 else if ((BTEST1(13)) || (BTEST1(14)))
10052 strat->posInL = posInL13;
10053 else if ((BTEST1(15)) || (BTEST1(16)))
10054 strat->posInL = posInL15Ring;
10055 else if ((BTEST1(17)) || (BTEST1(18)))
10056 strat->posInL = posInL17Ring;
10057 if (BTEST1(11))
10058 strat->posInT = posInT11Ring;
10059 else if (BTEST1(13))
10060 strat->posInT = posInT13;
10061 else if (BTEST1(15))
10062 strat->posInT = posInT15Ring;
10063 else if ((BTEST1(17)))
10064 strat->posInT = posInT17Ring;
10065 else if ((BTEST1(19)))
10066 strat->posInT = posInT19;
10067 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10068 strat->posInT = posInT1;
10070}
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6604
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6719
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6102
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5250
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6400
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5825
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5090
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6172
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6518
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5419
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5522
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5630

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

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

9731{
9732
9733 //if the ordering is local, then hilb criterion
9734 //can be used also if the ideal is not homogenous
9736 {
9738 *hilb=NULL;
9739 else
9740 return;
9741 }
9742 if (strat->homog!=isHomog)
9743 {
9744 *hilb=NULL;
9745 }
9746}
@ 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 7907 of file kutil.cc.

7908{
7909 int i,pos;
7910
7912 else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7913 strat->ecartS=initec(i);
7914 strat->sevS=initsevS(i);
7915 strat->S_2_R=initS_2_R(i);
7916 strat->fromQ=NULL;
7917 strat->Shdl=idInit(i,F->rank);
7918 strat->S=strat->Shdl->m;
7919 /*- put polys into S -*/
7920 if (Q!=NULL)
7921 {
7922 strat->fromQ=initec(i);
7923 memset(strat->fromQ,0,i*sizeof(int));
7924 for (i=0; i<IDELEMS(Q); i++)
7925 {
7926 if (Q->m[i]!=NULL)
7927 {
7928 LObject h;
7929 h.p = pCopy(Q->m[i]);
7931 {
7932 h.pCleardenom(); // also does remove Content
7933 }
7934 else
7935 {
7936 h.pNorm();
7937 }
7939 {
7940 deleteHC(&h, strat);
7941 }
7942 if (h.p!=NULL)
7943 {
7944 strat->initEcart(&h);
7945 if (strat->sl==-1)
7946 pos =0;
7947 else
7948 {
7949 pos = posInS(strat,strat->sl,h.p,h.ecart);
7950 }
7951 h.sev = pGetShortExpVector(h.p);
7952 strat->enterS(h,pos,strat,-1);
7953 strat->fromQ[pos]=1;
7954 }
7955 }
7956 }
7957 }
7958 for (i=0; i<IDELEMS(F); i++)
7959 {
7960 if (F->m[i]!=NULL)
7961 {
7962 LObject h;
7963 h.p = pCopy(F->m[i]);
7965 {
7966 cancelunit(&h); /*- tries to cancel a unit -*/
7967 deleteHC(&h, strat);
7968 }
7969 if (h.p!=NULL)
7970 // do not rely on the input being a SB!
7971 {
7973 {
7974 h.pCleardenom(); // also does remove Content
7975 }
7976 else
7977 {
7978 h.pNorm();
7979 }
7980 strat->initEcart(&h);
7981 if (strat->sl==-1)
7982 pos =0;
7983 else
7984 pos = posInS(strat,strat->sl,h.p,h.ecart);
7985 h.sev = pGetShortExpVector(h.p);
7986 strat->enterS(h,pos,strat,-1);
7987 }
7988 }
7989 }
7990 /*- test, if a unit is in F -*/
7991 if ((strat->sl>=0)
7992#ifdef HAVE_RINGS
7993 && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7994#endif
7995 && pIsConstant(strat->S[0]))
7996 {
7997 while (strat->sl>0) deleteInS(strat->sl,strat);
7998 }
7999}
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:1328
int redSig(LObject *h, kStrategy strat)
Definition: kstd2.cc:1160
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9224
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3765
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 10286 of file kutil.cc.

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

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9813 of file kutil.cc.

9814{
9815 //strat->enterOnePair=enterOnePairNormal;
9817 //strat->chainCrit=chainCritNormal;
9818 strat->chainCrit = chainCritSig;
9819 /******************************************
9820 * rewCrit1 and rewCrit2 are already set in
9821 * kSba() in kstd1.cc
9822 *****************************************/
9823 //strat->rewCrit1 = faugereRewCriterion;
9824 if (strat->sbaOrder == 1)
9825 {
9826 strat->syzCrit = syzCriterionInc;
9827 }
9828 else
9829 {
9830 strat->syzCrit = syzCriterion;
9831 }
9832#ifdef HAVE_RINGS
9834 {
9836 strat->chainCrit=chainCritRing;
9837 }
9838#endif
9839#ifdef HAVE_RATGRING
9840 if (rIsRatGRing(currRing))
9841 {
9842 strat->chainCrit=chainCritPart;
9843 /* enterOnePairNormal get rational part in it */
9844 }
9845#endif
9846
9848 strat->Gebauer = strat->homog || strat->sugarCrit;
9849 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9850 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9851 strat->pairtest = NULL;
9852 /* alway use tailreduction, except:
9853 * - in local rings, - in lex order case, -in ring over extensions */
9856
9857#ifdef HAVE_PLURAL
9858 // and r is plural_ring
9859 // hence this holds for r a rational_plural_ring
9860 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9861 { //or it has non-quasi-comm type... later
9862 strat->sugarCrit = FALSE;
9863 strat->Gebauer = FALSE;
9864 strat->honey = FALSE;
9865 }
9866#endif
9867
9868 // Coefficient ring?
9870 {
9871 strat->sugarCrit = FALSE;
9872 strat->Gebauer = FALSE ;
9873 strat->honey = FALSE;
9874 }
9875 #ifdef KDEBUG
9876 if (TEST_OPT_DEBUG)
9877 {
9878 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9879 else PrintS("ideal/module is not homogeneous\n");
9880 }
9881 #endif
9882}
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:6821
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3554
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6786

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 10184 of file kutil.cc.

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

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

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

◆ initSLSba()

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

Definition at line 8098 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8248 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

85{
86 TSet T = (TSet)omAlloc0(setmaxT*sizeof(TObject));
87 for (int i=setmaxT-1; i>=0; i--)
88 {
89 T[i].tailRing = currRing;
90 T[i].i_r = -1;
91 }
92 return T;
93}
STATIC_VAR jList * T
Definition: janet.cc:30
TObject * TSet
Definition: kutil.h: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:4081
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:637
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc: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:490
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1322

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

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

10808{
10809 if (strat->overflow) return FALSE;
10810 assume(L->p1 != NULL && L->p2 != NULL);
10811 // shift changes: from 0 to -1
10812 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10813 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10814
10815 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10816 return FALSE;
10817 // shift changes: extra case inserted
10818 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10819 {
10820 return TRUE;
10821 }
10822 poly p1_max=NULL;
10823 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10824 poly p2_max=NULL;
10825 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10826
10827 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10828 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10829 {
10830 p_LmFree(m1, strat->tailRing);
10831 p_LmFree(m2, strat->tailRing);
10832 m1 = NULL;
10833 m2 = NULL;
10834 return FALSE;
10835 }
10836 return TRUE;
10837}
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:2040

◆ kCheckStrongCreation()

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

Definition at line 10846 of file kutil.cc.

10847{
10848 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10849 //assume(strat->tailRing != currRing);
10850
10851 poly p1_max = (strat->R[atR])->max_exp;
10852 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10853
10854 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10855 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10856 {
10857 return FALSE;
10858 }
10859 return TRUE;
10860}

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11833 of file kutil.cc.

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

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 7005 of file kutil.cc.

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

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

◆ kFindInT()

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

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

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

◆ 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:1116
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1053
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:757

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3871 of file kstd2.cc.

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

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

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

◆ kNF2Bound() [2/2]

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

Definition at line 3797 of file kstd2.cc.

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

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

◆ ksCreateSpoly()

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

Definition at line 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:1442
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1906
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:294
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition: pDebug.cc: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:1458

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

11295{
11296 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11297 /* initial setup or extending */
11298
11299 if (rIsLPRing(currRing)) return TRUE;
11300 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11301 if (expbound >= currRing->bitmask) return FALSE;
11302 strat->overflow=FALSE;
11303 ring new_tailRing = rModifyRing(currRing,
11304 // Hmmm .. the condition pFDeg == p_Deg
11305 // might be too strong
11306 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11307 (strat->ak==0), // omit_comp if the input is an ideal
11308 expbound); // exp_limit
11309
11310 if (new_tailRing == currRing) return TRUE;
11311
11312 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11313 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11314
11315 if (currRing->pFDeg != currRing->pFDegOrig)
11316 {
11317 new_tailRing->pFDeg = currRing->pFDeg;
11318 new_tailRing->pLDeg = currRing->pLDeg;
11319 }
11320
11321 if (TEST_OPT_PROT)
11322 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11323 kTest_TS(strat);
11324 assume(new_tailRing != strat->tailRing);
11325 pShallowCopyDeleteProc p_shallow_copy_delete
11326 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11327
11328 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11329
11330 int i;
11331 for (i=0; i<=strat->tl; i++)
11332 {
11333 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11334 p_shallow_copy_delete);
11335 }
11336 for (i=0; i<=strat->Ll; i++)
11337 {
11338 assume(strat->L[i].p != NULL);
11339 if (pNext(strat->L[i].p) != strat->tail)
11340 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11341 }
11342 if ((strat->P.t_p != NULL) ||
11343 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11344 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11345
11346 if ((L != NULL) && (L->tailRing != new_tailRing))
11347 {
11348 if (L->i_r < 0)
11349 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11350 else
11351 {
11352 assume(L->i_r <= strat->tl);
11353 TObject* t_l = strat->R[L->i_r];
11354 assume(t_l != NULL);
11355 L->tailRing = new_tailRing;
11356 L->p = t_l->p;
11357 L->t_p = t_l->t_p;
11358 L->max_exp = t_l->max_exp;
11359 }
11360 }
11361
11362 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11363 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11364
11365 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11366 if (strat->tailRing != currRing)
11368
11369 strat->tailRing = new_tailRing;
11370 strat->tailBin = new_tailBin;
11372 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11373
11374 if (strat->kNoether != NULL)
11375 {
11376 if (strat->t_kNoether != NULL)
11377 p_LmFree(strat->t_kNoether, strat->tailRing);
11378 strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_tailRing);
11379 }
11380
11381 kTest_TS(strat);
11382 if (TEST_OPT_PROT)
11383 PrintS("]");
11384 return TRUE;
11385}
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 11387 of file kutil.cc.

11388{
11389 unsigned long l = 0;
11390 int i;
11391 long e;
11392
11393 assume(strat->tailRing == currRing);
11394
11395 for (i=0; i<= strat->Ll; i++)
11396 {
11397 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11398 }
11399 for (i=0; i<=strat->tl; i++)
11400 {
11401 // Hmm ... this we could do in one Step
11402 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11403 }
11405 {
11406 l *= 2;
11407 }
11408 e = p_GetMaxExp(l, currRing);
11409 if (e <= 1) e = 2;
11410 if (rIsLPRing(currRing)) e = 1;
11411
11412 kStratChangeTailRing(strat, NULL, NULL, e);
11413}
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:783

◆ 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:390
#define pFalseReturn(cond)
Definition: monomials.h:139
#define nTest(a)
Definition: numbers.h:35

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

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

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

7785{
7786 if (i != *olddeg)
7787 {
7788 Print("%d",i);
7789 *olddeg = i;
7790 }
7791 if (TEST_OPT_OLDSTD)
7792 {
7793 if (strat->Ll != *reduc)
7794 {
7795 if (strat->Ll != *reduc-1)
7796 Print("(%d)",strat->Ll+1);
7797 else
7798 PrintS("-");
7799 *reduc = strat->Ll;
7800 }
7801 else
7802 PrintS(".");
7803 mflush();
7804 }
7805 else
7806 {
7807 if (red_result == 0)
7808 PrintS("-");
7809 else if (red_result < 0)
7810 PrintS(".");
7811 if ((red_result > 0) || ((strat->Ll % 100)==99))
7812 {
7813 if (strat->Ll != *reduc && strat->Ll > 0)
7814 {
7815 Print("(%d)",strat->Ll+1);
7816 *reduc = strat->Ll;
7817 }
7818 }
7819 }
7820}

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7857 of file kutil.cc.

7858{
7859 int i;
7860 if (strat->news)
7861 {
7862 PrintS("set S");
7863 for (i=0; i<=strat->sl; i++)
7864 {
7865 Print("\n %d:",i);
7866 p_wrp(strat->S[i], currRing, strat->tailRing);
7867 if (strat->fromQ!=NULL && strat->fromQ[i])
7868 Print(" (from Q)");
7869 }
7870 strat->news = FALSE;
7871 }
7872 if (strat->newt)
7873 {
7874 PrintS("\nset T");
7875 for (i=0; i<=strat->tl; i++)
7876 {
7877 Print("\n %d:",i);
7878 strat->T[i].wrp();
7879 if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7880 Print(" o:%ld e:%d l:%d",
7881 strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7882 }
7883 strat->newt = FALSE;
7884 }
7885 PrintS("\nset L");
7886 for (i=strat->Ll; i>=0; i--)
7887 {
7888 Print("\n%d:",i);
7889 p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7890 PrintS(" ");
7891 p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7892 PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7893 PrintS("\n p : ");
7894 strat->L[i].wrp();
7895 Print(" o:%ld e:%d l:%d",
7896 strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7897 }
7898 PrintLn();
7899}

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7825 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7838 of file kutil.cc.

7839{
7840 //PrintS("\nUsage/Allocation of temporary storage:\n");
7841 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7842 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7843 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7844 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7845 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7846 #ifdef HAVE_SHIFTBBA
7847 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7848 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7849 #endif
7850}
int nrsyzcrit
Definition: kutil.h:360

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10735 of file kutil.cc.

10736{
10737 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10738 return FALSE;
10739 int i,j;
10740 poly newNoether;
10741
10742#if 0
10743 if (currRing->weight_all_1)
10744 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10745 else
10746 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10747#else
10748 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10749#endif
10750 if (strat->kNoether==NULL) return FALSE;
10751 if (strat->t_kNoether != NULL)
10752 {
10753 p_LmFree(strat->t_kNoether, strat->tailRing);
10754 strat->t_kNoether=NULL;
10755 }
10756 if (strat->tailRing != currRing)
10758 /* compare old and new noether*/
10759 newNoether = pLmInit(strat->kNoether);
10760 pSetCoeff0(newNoether,nInit(1));
10761 j = p_FDeg(newNoether,currRing);
10762 for (i=1; i<=(currRing->N); i++)
10763 {
10764 if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10765 }
10766 pSetm(newNoether);
10767 if (j < HCord) /*- statistics -*/
10768 {
10769 if (TEST_OPT_PROT)
10770 {
10771 Print("H(%d)",j);
10772 mflush();
10773 }
10774 HCord=j;
10775 #ifdef KDEBUG
10776 if (TEST_OPT_DEBUG)
10777 {
10778 Print("H(%d):",j);
10779 wrp(strat->kNoether);
10780 PrintLn();
10781 }
10782 #endif
10783 }
10784 if (pCmp(strat->kNoether,newNoether)!=1)
10785 {
10786 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10787 strat->kNoether=newNoether;
10788 if (strat->t_kNoether != NULL)
10789 {
10790 p_LmFree(strat->t_kNoether, strat->tailRing);
10791 strat->t_kNoether=NULL;
10792 }
10793 if (strat->tailRing != currRing)
10795
10796 return TRUE;
10797 }
10798 pLmDelete(newNoether);
10799 return FALSE;
10800}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition: hdegree.cc:1101
VAR int HCord
Definition: kutil.cc:246
static void p_LmDelete0(poly p, const ring r)
Definition: p_polys.h:735
#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 12002 of file kutil.cc.

12003{
12004 /* restores a poly in currRing from LObject */
12005 LObject h = H;
12006 h.Copy();
12007 poly p;
12008 if (h.p == NULL)
12009 {
12010 if (h.t_p != NULL)
12011 {
12012 p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
12013 return(p);
12014 }
12015 else
12016 {
12017 /* h.tp == NULL -> the object is NULL */
12018 return(NULL);
12019 }
12020 }
12021 /* we're here if h.p != NULL */
12022 if (h.t_p == NULL)
12023 {
12024 /* then h.p is the whole poly in currRing */
12025 p = h.p;
12026 return(p);
12027 }
12028 /* we're here if h.p != NULL and h.t_p != NULL */
12029 // clean h.p, get poly from t_p
12030 pNext(h.p)=NULL;
12031 pLmDelete(&h.p);
12032 p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
12033 /* dest. ring: */ currRing);
12034 // no need to clean h: we re-used the polys
12035 return(p);
12036}
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 11971 of file kutil.cc.

11972{
11973 /* assume: p is completely in currRing */
11974 /* produces an object with LM in curring
11975 and TAIL in tailring */
11976 if (pNext(p)!=NULL)
11977 {
11978 pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
11979 }
11980 return(p);
11981}

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 11985 of file kutil.cc.

11986{
11987 /* assume: p has LM in curring and TAIL in tailring */
11988 /* convert it to complete currRing */
11989
11990 /* check that LM is in currRing */
11992
11993 if (pNext(p)!=NULL)
11994 {
11995 pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
11996 }
11997 return(p);
11998}

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

5799{
5800 if (length<0) return 0;
5801
5802 int cmp_int=currRing->OrdSgn;
5803
5804 if (pLmCmp(set[length].p,p->p)== cmp_int)
5805 return length+1;
5806
5807 int i;
5808 int an = 0;
5809 int en= length;
5810 loop
5811 {
5812 if (an >= en-1)
5813 {
5814 if (pLmCmp(set[an].p,p->p) == cmp_int) return en;
5815 return an;
5816 }
5817 i=(an+en) / 2;
5818 if (pLmCmp(set[i].p,p->p) == cmp_int) an=i;
5819 else en=i;
5820 /*aend. fuer lazy == in !=- machen */
5821 }
5822}

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

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

◆ posInL110()

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

Definition at line 6358 of file kutil.cc.

6360{
6361 if (length<0) return 0;
6362
6363 int o = p->GetpFDeg();
6364 int op = set[length].GetpFDeg();
6365 int cmp_int= -currRing->OrdSgn;
6366
6367 if ((op > o)
6368 || ((op == o) && (set[length].length >p->length))
6369 || ((op == o) && (set[length].length <= p->length)
6370 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6371 return length+1;
6372 int i;
6373 int an = 0;
6374 int en= length;
6375 loop
6376 {
6377 if (an >= en-1)
6378 {
6379 op = set[an].GetpFDeg();
6380 if ((op > o)
6381 || ((op == o) && (set[an].length >p->length))
6382 || ((op == o) && (set[an].length <=p->length)
6383 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6384 return en;
6385 return an;
6386 }
6387 i=(an+en) / 2;
6388 op = set[i].GetpFDeg();
6389 if ((op > o)
6390 || ((op == o) && (set[i].length > p->length))
6391 || ((op == o) && (set[i].length <= p->length)
6392 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6393 an=i;
6394 else
6395 en=i;
6396 }
6397}

◆ posInL11Ring()

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

Definition at line 6102 of file kutil.cc.

6104{
6105 if (length<0) return 0;
6106
6107 int o = p->GetpFDeg();
6108 int op = set[length].GetpFDeg();
6109
6110 if ((op > o)
6111 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6112 return length+1;
6113 int i;
6114 int an = 0;
6115 int en= length;
6116 loop
6117 {
6118 if (an >= en-1)
6119 {
6120 op = set[an].GetpFDeg();
6121 if ((op > o)
6122 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6123 return en;
6124 return an;
6125 }
6126 i=(an+en) / 2;
6127 op = set[i].GetpFDeg();
6128 if ((op > o)
6129 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6130 an=i;
6131 else
6132 en=i;
6133 }
6134}
#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 6172 of file kutil.cc.

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

6449{
6450 if (length<0) return 0;
6451
6452 int o = p->GetpFDeg();
6453
6454 if (set[length].GetpFDeg() > o)
6455 return length+1;
6456
6457 int i;
6458 int an = 0;
6459 int en= length;
6460 loop
6461 {
6462 if (an >= en-1)
6463 {
6464 if (set[an].GetpFDeg() >= o)
6465 return en;
6466 return an;
6467 }
6468 i=(an+en) / 2;
6469 if (set[i].GetpFDeg() >= o)
6470 an=i;
6471 else
6472 en=i;
6473 }
6474}

◆ posInL15()

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

Definition at line 6482 of file kutil.cc.

6484{
6485 if (length<0) return 0;
6486
6487 int o = p->GetpFDeg() + p->ecart;
6488 int op = set[length].GetpFDeg() + set[length].ecart;
6489 int cmp_int= -currRing->OrdSgn;
6490
6491 if ((op > o)
6492 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
6493 return length+1;
6494 int i;
6495 int an = 0;
6496 int en= length;
6497 loop
6498 {
6499 if (an >= en-1)
6500 {
6501 op = set[an].GetpFDeg() + set[an].ecart;
6502 if ((op > o)
6503 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
6504 return en;
6505 return an;
6506 }
6507 i=(an+en) / 2;
6508 op = set[i].GetpFDeg() + set[i].ecart;
6509 if ((op > o)
6510 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
6511 an=i;
6512 else
6513 en=i;
6514 }
6515}

◆ posInL15Ring()

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

Definition at line 6518 of file kutil.cc.

6520{
6521 if (length<0) return 0;
6522
6523 int o = p->GetpFDeg() + p->ecart;
6524 int op = set[length].GetpFDeg() + set[length].ecart;
6525
6526 if ((op > o)
6527 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6528 return length+1;
6529 int i;
6530 int an = 0;
6531 int en= length;
6532 loop
6533 {
6534 if (an >= en-1)
6535 {
6536 op = set[an].GetpFDeg() + set[an].ecart;
6537 if ((op > o)
6538 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6539 return en;
6540 return an;
6541 }
6542 i=(an+en) / 2;
6543 op = set[i].GetpFDeg() + set[i].ecart;
6544 if ((op > o)
6545 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6546 an=i;
6547 else
6548 en=i;
6549 }
6550}

◆ posInL17()

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

Definition at line 6559 of file kutil.cc.

6561{
6562 if (length<0) return 0;
6563
6564 int o = p->GetpFDeg() + p->ecart;
6565 int cmp_int= -currRing->OrdSgn;
6566
6567 if ((set[length].GetpFDeg() + set[length].ecart > o)
6568 || ((set[length].GetpFDeg() + set[length].ecart == o)
6569 && (set[length].ecart > p->ecart))
6570 || ((set[length].GetpFDeg() + set[length].ecart == o)
6571 && (set[length].ecart == p->ecart)
6572 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6573 return length+1;
6574 int i;
6575 int an = 0;
6576 int en= length;
6577 loop
6578 {
6579 if (an >= en-1)
6580 {
6581 if ((set[an].GetpFDeg() + set[an].ecart > o)
6582 || ((set[an].GetpFDeg() + set[an].ecart == o)
6583 && (set[an].ecart > p->ecart))
6584 || ((set[an].GetpFDeg() + set[an].ecart == o)
6585 && (set[an].ecart == p->ecart)
6586 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6587 return en;
6588 return an;
6589 }
6590 i=(an+en) / 2;
6591 if ((set[i].GetpFDeg() + set[i].ecart > o)
6592 || ((set[i].GetpFDeg() + set[i].ecart == o)
6593 && (set[i].ecart > p->ecart))
6594 || ((set[i].GetpFDeg() +set[i].ecart == o)
6595 && (set[i].ecart == p->ecart)
6596 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6597 an=i;
6598 else
6599 en=i;
6600 }
6601}

◆ posInLF5C()

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

Definition at line 6047 of file kutil.cc.

6049{
6050 return strat->Ll+1;
6051}

◆ posInLF5CRing()

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

Definition at line 6136 of file kutil.cc.

6138{
6139 if (length<0) return 0;
6140 if(start == (length +1)) return (length+1);
6141 int o = p->GetpFDeg();
6142 int op = set[length].GetpFDeg();
6143
6144 if ((op > o)
6145 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6146 return length+1;
6147 int i;
6148 int an = start;
6149 int en= length;
6150 loop
6151 {
6152 if (an >= en-1)
6153 {
6154 op = set[an].GetpFDeg();
6155 if ((op > o)
6156 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6157 return en;
6158 return an;
6159 }
6160 i=(an+en) / 2;
6161 op = set[i].GetpFDeg();
6162 if ((op > o)
6163 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6164 an=i;
6165 else
6166 en=i;
6167 }
6168}

◆ posInLRing()

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

Definition at line 5945 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5857 of file kutil.cc.

5859{
5860 if (length<0) return 0;
5861 int cmp_int=currRing->OrdSgn;
5862 if (pLtCmp(set[length].sig,p->sig)==cmp_int)
5863 return length+1;
5864
5865 int i;
5866 int an = 0;
5867 int en= length;
5868 loop
5869 {
5870 if (an >= en-1)
5871 {
5872 if (pLtCmp(set[an].sig,p->sig) == cmp_int) return en;
5873 return an;
5874 }
5875 i=(an+en) / 2;
5876 if (pLtCmp(set[i].sig,p->sig) == cmp_int) an=i;
5877 else en=i;
5878 /*aend. fuer lazy == in !=- machen */
5879 }
5880}

◆ posInLSigRing()

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

Definition at line 5882 of file kutil.cc.

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

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

6019{
6020 if (strat->syzl==0) return 0;
6021 int cmp_int=currRing->OrdSgn;
6022 if (pLtCmp(strat->syz[strat->syzl-1],sig) != cmp_int)
6023 return strat->syzl;
6024 int i;
6025 int an = 0;
6026 int en= strat->syzl-1;
6027 loop
6028 {
6029 if (an >= en-1)
6030 {
6031 if (pLtCmp(strat->syz[an],sig) != cmp_int) return en;
6032 return an;
6033 }
6034 i=(an+en) / 2;
6035 if (pLtCmp(strat->syz[i],sig) != cmp_int) an=i;
6036 else en=i;
6037 /*aend. fuer lazy == in !=- machen */
6038 }
6039}

◆ 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 int cmp_int=currRing->OrdSgn;
5006
5007 loop
5008 {
5009 if (an >= en-1)
5010 {
5011 if (pLmCmp(set[an].p,p.p) == cmp_int) return an;
5012 return en;
5013 }
5014 i=(an+en) / 2;
5015 if (pLmCmp(set[i].p,p.p) == cmp_int) en=i;
5016 else an=i;
5017 }
5018}

◆ posInT11()

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

Definition at line 5053 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5207 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5297 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5364 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5460 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5568 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5696 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 5025 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11708 of file kutil.cc.

11709{
11710
11711 if (length==-1) return 0;
11712
11713 int o = p.ecart;
11714 int op=p.GetpFDeg();
11715 int ol = p.GetpLength();
11716
11717 if (set[length].ecart < o)
11718 return length+1;
11719 if (set[length].ecart == o)
11720 {
11721 int oo=set[length].GetpFDeg();
11722 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11723 return length+1;
11724 }
11725
11726 int i;
11727 int an = 0;
11728 int en= length;
11729 loop
11730 {
11731 if (an >= en-1)
11732 {
11733 if (set[an].ecart > o)
11734 return an;
11735 if (set[an].ecart == o)
11736 {
11737 int oo=set[an].GetpFDeg();
11738 if((oo > op)
11739 || ((oo==op) && (set[an].pLength > ol)))
11740 return an;
11741 }
11742 return en;
11743 }
11744 i=(an+en) / 2;
11745 if (set[i].ecart > o)
11746 en=i;
11747 else if (set[i].ecart == o)
11748 {
11749 int oo=set[i].GetpFDeg();
11750 if ((oo > op)
11751 || ((oo == op) && (set[i].pLength > ol)))
11752 en=i;
11753 else
11754 an=i;
11755 }
11756 else
11757 an=i;
11758 }
11759}

◆ posInT_EcartpLength()

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

Definition at line 5326 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11762 of file kutil.cc.

11763{
11764
11765 if (length==-1) return 0;
11766
11767 int op=p.GetpFDeg();
11768 int ol = p.GetpLength();
11769
11770 int oo=set[length].GetpFDeg();
11771 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11772 return length+1;
11773
11774 int i;
11775 int an = 0;
11776 int en= length;
11777 loop
11778 {
11779 if (an >= en-1)
11780 {
11781 int oo=set[an].GetpFDeg();
11782 if((oo > op)
11783 || ((oo==op) && (set[an].pLength > ol)))
11784 return an;
11785 return en;
11786 }
11787 i=(an+en) / 2;
11788 int oo=set[i].GetpFDeg();
11789 if ((oo > op)
11790 || ((oo == op) && (set[i].pLength > ol)))
11791 en=i;
11792 else
11793 an=i;
11794 }
11795}

◆ posInT_pLength()

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

Definition at line 11799 of file kutil.cc.

11800{
11801 int ol = p.GetpLength();
11802 if (length==-1)
11803 return 0;
11804 if (set[length].length<p.length)
11805 return length+1;
11806
11807 int i;
11808 int an = 0;
11809 int en= length;
11810
11811 loop
11812 {
11813 if (an >= en-1)
11814 {
11815 if (set[an].pLength>ol) return an;
11816 return en;
11817 }
11818 i=(an+en) / 2;
11819 if (set[i].pLength>ol) en=i;
11820 else an=i;
11821 }
11822}

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

11037{
11038 if(!nCoeff_is_Z(currRing->cf))
11039 return;
11040 poly pH = h->GetP();
11041 poly p,pp;
11042 p = pH;
11043 bool deleted = FALSE, ok = FALSE;
11044 for(int i = 0; i<=strat->sl; i++)
11045 {
11046 p = pH;
11047 if(pNext(strat->S[i]) == NULL)
11048 {
11049 //pWrite(p);
11050 //pWrite(strat->S[i]);
11051 while(ok == FALSE && p != NULL)
11052 {
11053 if(pLmDivisibleBy(strat->S[i], p)
11054#ifdef HAVE_SHIFTBBA
11055 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
11056#endif
11057 )
11058 {
11059 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11060 p_SetCoeff(p,dummy,currRing);
11061 }
11062 if(nIsZero(p->coef))
11063 {
11064 pLmDelete(&p);
11065 h->p = p;
11066 deleted = TRUE;
11067 }
11068 else
11069 {
11070 ok = TRUE;
11071 }
11072 }
11073 if (p!=NULL)
11074 {
11075 pp = pNext(p);
11076 while(pp != NULL)
11077 {
11078 if(pLmDivisibleBy(strat->S[i], pp)
11079#ifdef HAVE_SHIFTBBA
11080 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
11081#endif
11082 )
11083 {
11084 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11085 p_SetCoeff(pp,dummy,currRing);
11086 if(nIsZero(pp->coef))
11087 {
11088 pLmDelete(&pNext(p));
11089 pp = pNext(p);
11090 deleted = TRUE;
11091 }
11092 else
11093 {
11094 p = pp;
11095 pp = pNext(p);
11096 }
11097 }
11098 else
11099 {
11100 p = pp;
11101 pp = pNext(p);
11102 }
11103 }
11104 }
11105 }
11106 }
11107 h->SetLmCurrRing();
11108 if((deleted)&&(h->p!=NULL))
11109 strat->initEcart(h);
11110}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 11112 of file kutil.cc.

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

10870{
10871 if(!nCoeff_is_Z(currRing->cf))
10872 return NULL;
10873 ideal F = idCopy(Forig);
10874 idSkipZeroes(F);
10875 poly pmon;
10876 ring origR = currRing;
10877 ideal monred = idInit(1,1);
10878 for(int i=0; i<idElem(F); i++)
10879 {
10880 if(pNext(F->m[i]) == NULL)
10881 idInsertPoly(monred, pCopy(F->m[i]));
10882 }
10883 int posconst = idPosConstant(F);
10884 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10885 {
10886 idDelete(&F);
10887 idDelete(&monred);
10888 return NULL;
10889 }
10890 int idelemQ = 0;
10891 if(Q!=NULL)
10892 {
10893 idelemQ = IDELEMS(Q);
10894 for(int i=0; i<idelemQ; i++)
10895 {
10896 if(pNext(Q->m[i]) == NULL)
10897 idInsertPoly(monred, pCopy(Q->m[i]));
10898 }
10899 idSkipZeroes(monred);
10900 posconst = idPosConstant(monred);
10901 //the constant, if found, will be from Q
10902 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10903 {
10904 pmon = pCopy(monred->m[posconst]);
10905 idDelete(&F);
10906 idDelete(&monred);
10907 return pmon;
10908 }
10909 }
10910 ring QQ_ring = rCopy0(currRing,FALSE);
10911 nKillChar(QQ_ring->cf);
10912 QQ_ring->cf = nInitChar(n_Q, NULL);
10913 rComplete(QQ_ring,1);
10914 QQ_ring = rAssure_c_dp(QQ_ring);
10915 rChangeCurrRing(QQ_ring);
10916 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10917 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10918 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10919 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10920 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10921 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10922 ideal one = kStd(II, NULL, isNotHomog, NULL);
10923 idSkipZeroes(one);
10924 if(idIsConstant(one))
10925 {
10926 //one should be <1>
10927 for(int i = IDELEMS(II)-1; i>=0; i--)
10928 if(II->m[i] != NULL)
10929 II->m[i+1] = II->m[i];
10930 II->m[0] = pOne();
10931 ideal syz = idSyzygies(II, isNotHomog, NULL);
10932 poly integer = NULL;
10933 for(int i = IDELEMS(syz)-1;i>=0; i--)
10934 {
10935 if(pGetComp(syz->m[i]) == 1)
10936 {
10937 pSetComp(syz->m[i],0);
10938 if(pIsConstant(pHead(syz->m[i])))
10939 {
10940 integer = pHead(syz->m[i]);
10941 break;
10942 }
10943 }
10944 }
10945 rChangeCurrRing(origR);
10946 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10947 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10948 idDelete(&monred);
10949 idDelete(&F);
10950 id_Delete(&II,QQ_ring);
10951 id_Delete(&one,QQ_ring);
10952 id_Delete(&syz,QQ_ring);
10953 p_Delete(&integer,QQ_ring);
10954 rDelete(QQ_ring);
10955 return pmon;
10956 }
10957 else
10958 {
10959 if(idIs0(monred))
10960 {
10961 poly mindegmon = NULL;
10962 for(int i = 0; i<IDELEMS(one); i++)
10963 {
10964 if(pNext(one->m[i]) == NULL)
10965 {
10966 if(mindegmon == NULL)
10967 mindegmon = pCopy(one->m[i]);
10968 else
10969 {
10970 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10971 mindegmon = pCopy(one->m[i]);
10972 }
10973 }
10974 }
10975 if(mindegmon != NULL)
10976 {
10977 for(int i = IDELEMS(II)-1; i>=0; i--)
10978 if(II->m[i] != NULL)
10979 II->m[i+1] = II->m[i];
10980 II->m[0] = pCopy(mindegmon);
10981 ideal syz = idSyzygies(II, isNotHomog, NULL);
10982 bool found = FALSE;
10983 for(int i = IDELEMS(syz)-1;i>=0; i--)
10984 {
10985 if(pGetComp(syz->m[i]) == 1)
10986 {
10987 pSetComp(syz->m[i],0);
10988 if(pIsConstant(pHead(syz->m[i])))
10989 {
10990 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10991 found = TRUE;
10992 break;
10993 }
10994 }
10995 }
10996 id_Delete(&syz,QQ_ring);
10997 if (found == FALSE)
10998 {
10999 rChangeCurrRing(origR);
11000 idDelete(&monred);
11001 idDelete(&F);
11002 id_Delete(&II,QQ_ring);
11003 id_Delete(&one,QQ_ring);
11004 rDelete(QQ_ring);
11005 return NULL;
11006 }
11007 rChangeCurrRing(origR);
11008 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
11009 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
11010 idDelete(&monred);
11011 idDelete(&F);
11012 id_Delete(&II,QQ_ring);
11013 id_Delete(&one,QQ_ring);
11014 id_Delete(&syz,QQ_ring);
11015 rDelete(QQ_ring);
11016 return pmon;
11017 }
11018 }
11019 }
11020 rChangeCurrRing(origR);
11021 idDelete(&monred);
11022 idDelete(&F);
11023 id_Delete(&II,QQ_ring);
11024 id_Delete(&one,QQ_ring);
11025 rDelete(QQ_ring);
11026 return NULL;
11027}
@ 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:392
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:547
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 4738 of file kstd2.cc.

4739{
4740 if (h->IsNull()) return 0;
4741
4742 int at, reddeg,d;
4743 int pass = 0;
4744 int j = 0;
4745
4746 if (! strat->homog)
4747 {
4748 d = h->GetpFDeg() + h->ecart;
4749 reddeg = strat->LazyDegree+d;
4750 }
4751 h->SetShortExpVector();
4752 loop
4753 {
4754 j = kFindDivisibleByInT(strat, h);
4755 if (j < 0)
4756 {
4757 h->SetDegStuffReturnLDeg(strat->LDegLast);
4758 return 1;
4759 }
4760
4762 strat->T[j].pNorm();
4763#ifdef KDEBUG
4764 if (TEST_OPT_DEBUG)
4765 {
4766 PrintS("reduce ");
4767 h->wrp();
4768 PrintS(" with ");
4769 strat->T[j].wrp();
4770 }
4771#endif
4772 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
4773
4774#ifdef KDEBUG
4775 if (TEST_OPT_DEBUG)
4776 {
4777 PrintS("\nto ");
4778 wrp(h->p);
4779 PrintLn();
4780 }
4781#endif
4782 if (h->IsNull())
4783 {
4784 kDeleteLcm(h);
4785 h->Clear();
4786 return 0;
4787 }
4788 h->SetShortExpVector();
4789
4790#if 0
4791 if ((strat->syzComp!=0) && !strat->honey)
4792 {
4793 if ((strat->syzComp>0) &&
4794 (h->Comp() > strat->syzComp))
4795 {
4796 assume(h->MinComp() > strat->syzComp);
4797#ifdef KDEBUG
4798 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
4799#endif
4800 if (strat->homog)
4801 h->SetDegStuffReturnLDeg(strat->LDegLast);
4802 return -2;
4803 }
4804 }
4805#endif
4806 if (!strat->homog)
4807 {
4808 if (!TEST_OPT_OLDSTD && strat->honey)
4809 {
4810 h->SetpFDeg();
4811 if (strat->T[j].ecart <= h->ecart)
4812 h->ecart = d - h->GetpFDeg();
4813 else
4814 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
4815
4816 d = h->GetpFDeg() + h->ecart;
4817 }
4818 else
4819 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
4820 /*- try to reduce the s-polynomial -*/
4821 pass++;
4822 /*
4823 *test whether the polynomial should go to the lazyset L
4824 *-if the degree jumps
4825 *-if the number of pre-defined reductions jumps
4826 */
4827 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
4828 && ((d >= reddeg) || (pass > strat->LazyPass)))
4829 {
4830 h->SetLmCurrRing();
4831 if (strat->posInLDependsOnLength)
4832 h->SetLength(strat->length_pLength);
4833 at = strat->posInL(strat->L,strat->Ll,h,strat);
4834 if (at <= strat->Ll)
4835 {
4836 //int dummy=strat->sl;
4837 /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
4838 //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
4839 if (kFindDivisibleByInT(strat, h) < 0)
4840 return 1;
4841 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
4842#ifdef KDEBUG
4843 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
4844#endif
4845 h->Clear();
4846 return -1;
4847 }
4848 }
4849 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
4850 {
4851 reddeg = d+1;
4852 Print(".%d",d);mflush();
4853 }
4854 }
4855 }
4856}
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 }
1036 #if 0 // red is redLiftstd if OPT_IDLIFT
1038 {
1039 if (h->p!=NULL)
1040 {
1041 if(p_GetComp(h->p,currRing)>strat->syzComp)
1042 {
1043 h->Delete();
1044 return 0;
1045 }
1046 }
1047 else if (h->t_p!=NULL)
1048 {
1049 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1050 {
1051 h->Delete();
1052 return 0;
1053 }
1054 }
1055 }
1056 #endif
1057 #if 0
1058 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1059 {
1060 if (h->p!=NULL)
1061 {
1062 if(p_GetComp(h->p,currRing)>strat->syzComp)
1063 {
1064 return 1;
1065 }
1066 }
1067 else if (h->t_p!=NULL)
1068 {
1069 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1070 {
1071 return 1;
1072 }
1073 }
1074 }
1075 #endif
1076 h->SetShortExpVector();
1077 /*
1078 * try to reduce the s-polynomial h
1079 *test first whether h should go to the lazyset L
1080 *-if the degree jumps
1081 *-if the number of pre-defined reductions jumps
1082 */
1083 cnt--;
1084 pass++;
1085 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1086 {
1087 h->SetLmCurrRing();
1088 at = strat->posInL(strat->L,strat->Ll,h,strat);
1089 if (at <= strat->Ll)
1090 {
1091#ifdef HAVE_SHIFTBBA
1092 if (rIsLPRing(currRing))
1093 {
1094 if (kFindDivisibleByInT(strat, h) < 0)
1095 return 1;
1096 }
1097 else
1098#endif
1099 {
1100 int dummy=strat->sl;
1101 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1102 return 1;
1103 }
1104 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1105#ifdef KDEBUG
1106 if (TEST_OPT_DEBUG)
1107 Print(" lazy: -> L%d\n",at);
1108#endif
1109 h->Clear();
1110 return -1;
1111 }
1112 }
1113 else if (UNLIKELY(cnt==0))
1114 {
1115 h->CanonicalizeP();
1116 cnt=RED_CANONICALIZE;
1117 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
1118 }
1119 }
1120}
#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 1905 of file kstd2.cc.

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

◆ redHoneyM()

int redHoneyM ( LObject h,
kStrategy  strat 
)

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1698 of file kstd2.cc.

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

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

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

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

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 1160 of file kstd2.cc.

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

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

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

◆ redtail() [2/2]

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

Definition at line 7217 of file kutil.cc.

7218{
7219 LObject L(p, currRing);
7220 return redtail(&L, end_pos, strat);
7221}

◆ redtailBba() [1/3]

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

Definition at line 7223 of file kutil.cc.

7224{
7225 strat->redTailChange=FALSE;
7226 if (strat->noTailReduction) return L->GetLmCurrRing();
7227 poly h, p;
7228 p = h = L->GetLmTailRing();
7229 if ((h==NULL) || (pNext(h)==NULL))
7230 return L->GetLmCurrRing();
7231
7232 TObject* With;
7233 // placeholder in case strat->tl < 0
7234 TObject With_s(strat->tailRing);
7235
7236 LObject Ln(pNext(h), strat->tailRing);
7237 Ln.GetpLength();
7238
7239 pNext(h) = NULL;
7240 if (L->p != NULL)
7241 {
7242 pNext(L->p) = NULL;
7243 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7244 }
7245 L->pLength = 1;
7246
7247 Ln.PrepareRed(strat->use_buckets);
7248
7249 int cnt=REDTAIL_CANONICALIZE;
7250 while(!Ln.IsNull())
7251 {
7252 loop
7253 {
7254 if (TEST_OPT_IDLIFT)
7255 {
7256 if (Ln.p!=NULL)
7257 {
7258 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7259 }
7260 else
7261 {
7262 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7263 }
7264 }
7265 Ln.SetShortExpVector();
7266 if (withT)
7267 {
7268 int j;
7269 j = kFindDivisibleByInT(strat, &Ln);
7270 if (j < 0) break;
7271 With = &(strat->T[j]);
7272 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7273 }
7274 else
7275 {
7276 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7277 if (With == NULL) break;
7278 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7279 }
7280 cnt--;
7281 if (cnt==0)
7282 {
7284 /*poly tmp=*/Ln.CanonicalizeP();
7285 if (normalize)
7286 {
7287 Ln.Normalize();
7288 //pNormalize(tmp);
7289 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7290 }
7291 }
7292 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7293 {
7294 With->pNorm();
7295 }
7296 strat->redTailChange=TRUE;
7297 if (ksReducePolyTail(L, With, &Ln))
7298 {
7299 // reducing the tail would violate the exp bound
7300 // set a flag and hope for a retry (in bba)
7302 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7303 do
7304 {
7305 pNext(h) = Ln.LmExtractAndIter();
7306 pIter(h);
7307 L->pLength++;
7308 } while (!Ln.IsNull());
7309 goto all_done;
7310 }
7311 if (Ln.IsNull()) goto all_done;
7312 if (! withT) With_s.Init(currRing);
7313 }
7314 pNext(h) = Ln.LmExtractAndIter();
7315 pIter(h);
7316 pNormalize(h);
7317 L->pLength++;
7318 }
7319
7320 all_done:
7321 Ln.Delete();
7322 if (L->p != NULL) pNext(L->p) = pNext(p);
7323
7324 if (strat->redTailChange)
7325 {
7326 L->length = 0;
7327 L->pLength = 0;
7328 }
7329
7330 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7331 //L->Normalize(); // HANNES: should have a test
7332 kTest_L(L,strat);
7333 return L->GetLmCurrRing();
7334}
#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 7695 of file kutil.cc.

7697{
7698 strat->redTailChange=FALSE;
7699 if (strat->noTailReduction) return L->GetLmCurrRing();
7700 poly h, p;
7701 p = h = L->GetLmTailRing();
7702 if ((h==NULL) || (pNext(h)==NULL))
7703 return L->GetLmCurrRing();
7704
7705 TObject* With;
7706 // placeholder in case strat->tl < 0
7707 TObject With_s(strat->tailRing);
7708
7709 LObject Ln(pNext(h), strat->tailRing);
7710 Ln.pLength = L->GetpLength() - 1;
7711
7712 pNext(h) = NULL;
7713 if (L->p != NULL) pNext(L->p) = NULL;
7714 L->pLength = 1;
7715
7716 Ln.PrepareRed(strat->use_buckets);
7717
7718 int cnt=REDTAIL_CANONICALIZE;
7719 while(!Ln.IsNull())
7720 {
7721 loop
7722 {
7723 Ln.SetShortExpVector();
7724 With_s.Init(currRing);
7725 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7726 if (With == NULL) break;
7727 cnt--;
7728 if (cnt==0)
7729 {
7731 /*poly tmp=*/Ln.CanonicalizeP();
7732 }
7733 // we are in a ring, do not call pNorm
7734 // test divisibility of coefs:
7735 poly p_Ln=Ln.GetLmCurrRing();
7736 poly p_With=With->GetLmCurrRing();
7737 if (n_DivBy(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf))
7738 {
7739 strat->redTailChange=TRUE;
7740
7741 if (ksReducePolyTail_Z(L, With, &Ln))
7742 {
7743 // reducing the tail would violate the exp bound
7744 // set a flag and hope for a retry (in bba)
7746 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7747 do
7748 {
7749 pNext(h) = Ln.LmExtractAndIter();
7750 pIter(h);
7751 L->pLength++;
7752 } while (!Ln.IsNull());
7753 goto all_done;
7754 }
7755 }
7756 else break; /*proceed to next monomial*/
7757 if (Ln.IsNull()) goto all_done;
7758 }
7759 pNext(h) = Ln.LmExtractAndIter();
7760 pIter(h);
7761 pNormalize(h);
7762 L->pLength++;
7763 }
7764
7765 all_done:
7766 Ln.Delete();
7767 if (L->p != NULL) pNext(L->p) = pNext(p);
7768
7769 if (strat->redTailChange)
7770 {
7771 L->length = 0;
7772 }
7773
7774 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7775 //L->Normalize(); // HANNES: should have a test
7776 kTest_L(L,strat);
7777 return L->GetLmCurrRing();
7778}
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 7581 of file kutil.cc.

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

7454{
7455 strat->redTailChange=FALSE;
7456
7457 poly h, p;
7458 p = h = L->GetLmTailRing();
7459 if ((h==NULL) || (pNext(h)==NULL))
7460 return;
7461
7462 TObject* With;
7463 LObject Ln(pNext(h), strat->tailRing);
7464 Ln.GetpLength();
7465
7466 pNext(h) = NULL;
7467 if (L->p != NULL)
7468 {
7469 pNext(L->p) = NULL;
7470 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7471 }
7472 L->pLength = 1;
7473
7474 Ln.PrepareRed(strat->use_buckets);
7475
7476 int cnt=REDTAIL_CANONICALIZE;
7477
7478 while(!Ln.IsNull())
7479 {
7480 loop
7481 {
7482 if (TEST_OPT_IDLIFT)
7483 {
7484 if (Ln.p!=NULL)
7485 {
7486 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7487 }
7488 else
7489 {
7490 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7491 }
7492 }
7493 Ln.SetShortExpVector();
7494 int j;
7495 j = kFindDivisibleByInT(strat, &Ln);
7496 if (j < 0)
7497 {
7498 j = kFindDivisibleByInT_Z(strat, &Ln);
7499 if (j < 0)
7500 {
7501 break;
7502 }
7503 else
7504 {
7505 /* reduction not cancelling a tail term, but reducing its coefficient */
7506 With = &(strat->T[j]);
7507 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7508 cnt--;
7509 if (cnt==0)
7510 {
7512 /*poly tmp=*/Ln.CanonicalizeP();
7513 }
7514 strat->redTailChange=TRUE;
7515 /* reduction cancelling a tail term */
7516 if (ksReducePolyTailLC_Z(L, With, &Ln))
7517 {
7518 // reducing the tail would violate the exp bound
7519 // set a flag and hope for a retry (in bba)
7521 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7522 do
7523 {
7524 pNext(h) = Ln.LmExtractAndIter();
7525 pIter(h);
7526 L->pLength++;
7527 } while (!Ln.IsNull());
7528 goto all_done;
7529 }
7530 /* we have to break since we did not cancel the term, but only decreased
7531 * its coefficient. */
7532 break;
7533 }
7534 } else {
7535 With = &(strat->T[j]);
7536 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7537 cnt--;
7538 if (cnt==0)
7539 {
7541 /*poly tmp=*/Ln.CanonicalizeP();
7542 }
7543 strat->redTailChange=TRUE;
7544 /* reduction cancelling a tail term */
7545 if (ksReducePolyTail_Z(L, With, &Ln))
7546 {
7547 // reducing the tail would violate the exp bound
7548 // set a flag and hope for a retry (in bba)
7550 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7551 do
7552 {
7553 pNext(h) = Ln.LmExtractAndIter();
7554 pIter(h);
7555 L->pLength++;
7556 } while (!Ln.IsNull());
7557 goto all_done;
7558 }
7559 }
7560 if (Ln.IsNull()) goto all_done;
7561 }
7562 pNext(h) = Ln.LmExtractAndIter();
7563 pIter(h);
7564 L->pLength++;
7565 }
7566
7567 all_done:
7568 Ln.Delete();
7569 if (L->p != NULL) pNext(L->p) = pNext(p);
7570
7571 if (strat->redTailChange)
7572 {
7573 L->length = 0;
7574 L->pLength = 0;
7575 }
7576
7577 kTest_L(L, strat);
7578 return;
7579}
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 7336 of file kutil.cc.

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

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

◆ redtailSba()

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

Definition at line 1578 of file kstd2.cc.

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

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

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

◆ sba()

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

Definition at line 2749 of file kstd2.cc.

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

◆ sbaRing()

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

Definition at line 11415 of file kutil.cc.

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

6787{
6788//#if 1
6789#ifdef DEBUGF5
6790 PrintS("syzygy criterion checks: ");
6791 pWrite(sig);
6792#endif
6793 for (int k=0; k<strat->syzl; k++)
6794 {
6795 //printf("-%d",k);
6796//#if 1
6797#ifdef DEBUGF5
6798 Print("checking with: %d / %d -- \n",k,strat->syzl);
6799 pWrite(pHead(strat->syz[k]));
6800#endif
6801 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6802 && (!rField_is_Ring(currRing) ||
6803 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6804 {
6805//#if 1
6806#ifdef DEBUGF5
6807 PrintS("DELETE!\n");
6808#endif
6809 strat->nrsyzcrit++;
6810 //printf("- T -\n\n");
6811 return TRUE;
6812 }
6813 }
6814 //printf("- F -\n\n");
6815 return FALSE;
6816}

◆ syzCriterionInc()

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

Definition at line 6821 of file kutil.cc.

6822{
6823//#if 1
6824 if(sig == NULL)
6825 return FALSE;
6826#ifdef DEBUGF5
6827 PrintS("--- syzygy criterion checks: ");
6828 pWrite(sig);
6829#endif
6830 int comp = __p_GetComp(sig, currRing);
6831 int min, max;
6832 if (comp<=1)
6833 return FALSE;
6834 else
6835 {
6836 min = strat->syzIdx[comp-2];
6837 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6838 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6839 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6840 if (comp == strat->currIdx)
6841 {
6842 max = strat->syzl;
6843 }
6844 else
6845 {
6846 max = strat->syzIdx[comp-1];
6847 }
6848 for (int k=min; k<max; k++)
6849 {
6850#ifdef F5DEBUG
6851 Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6852 Print("checking with: %d -- ",k);
6853 pWrite(pHead(strat->syz[k]));
6854#endif
6855 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6856 && (!rField_is_Ring(currRing) ||
6857 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6858 {
6859 strat->nrsyzcrit++;
6860 return TRUE;
6861 }
6862 }
6863 return FALSE;
6864 }
6865}
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 10401 of file kutil.cc.

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

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

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