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

Go to the source code of this file.

Data Structures

struct  denominator_list_s
 
class  sTObject
 
class  sLObject
 
class  skStrategy
 

Macros

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

◆ NO_KINLINE

#define NO_KINLINE   1

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

◆ intset

typedef int* intset

Definition at line 49 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 51 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 56 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 51 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 55 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 51 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 50 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 7262 of file kutil.cc.

7263 {
7265  return FALSE;
7266  poly p1 = pOne();
7267  poly p2 = pOne();
7268  for (int ii=strat->sl; ii>start; ii--)
7269  {
7270  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
7271  {
7272  p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
7273  p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
7274  if (!(pLmCmp(p1,p2) == 1))
7275  {
7276  pDelete(&p1);
7277  pDelete(&p2);
7278  return TRUE;
7279  }
7280  }
7281  }
7282  pDelete(&p1);
7283  pDelete(&p2);
7284  return FALSE;
7285 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
polyset S
Definition: kutil.h:303
unsigned long * sevSig
Definition: kutil.h:321
polyset sig
Definition: kutil.h:305
LObject P
Definition: kutil.h:299
int sl
Definition: kutil.h:347
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1385
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1897
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
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:489

◆ arriRewCriterionPre()

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

Definition at line 7287 of file kutil.cc.

7288 {
7289  //Over Rings, there are still some changes to do: considering coeffs
7291  return FALSE;
7292  int found = -1;
7293  for (int i=strat->Bl; i>-1; i--)
7294  {
7295  if (pLmEqual(strat->B[i].sig,sig))
7296  {
7297  found = i;
7298  break;
7299  }
7300  }
7301  if (found != -1)
7302  {
7303  if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
7304  {
7305  deleteInL(strat->B,&strat->Bl,found,strat);
7306  }
7307  else
7308  {
7309  return TRUE;
7310  }
7311  }
7312  poly p1 = pOne();
7313  poly p2 = pOne();
7314  for (int ii=strat->sl; ii>-1; ii--)
7315  {
7316  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
7317  {
7318  p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
7319  p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
7320  if (!(pLmCmp(p1,p2) == 1))
7321  {
7322  pDelete(&p1);
7323  pDelete(&p2);
7324  return TRUE;
7325  }
7326  }
7327  }
7328  pDelete(&p1);
7329  pDelete(&p2);
7330  return FALSE;
7331 }
int i
Definition: cfEzgcd.cc:132
int Bl
Definition: kutil.h:351
LSet B
Definition: kutil.h:325
bool found
Definition: facFactorize.cc:55
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1244
#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 1225 of file kInline.h.

1226 {
1227  return FALSE;
1228 }

◆ bba()

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

Definition at line 2383 of file kstd2.cc.

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

◆ bbaShift()

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

Definition at line 4340 of file kstd2.cc.

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

◆ cancelunit()

void cancelunit ( LObject p,
BOOLEAN  inNF = FALSE 
)

Definition at line 343 of file kutil.cc.

344 {
345  if(rHasGlobalOrdering (currRing)) return;
346  if(TEST_OPT_CANCELUNIT) return;
347 
348  ring r = L->tailRing;
349  poly p = L->GetLmTailRing();
350  if(p_GetComp(p, r) != 0 && !p_OneComp(p, r)) return;
351 
352  number lc=NULL; /*dummy, is always set if rField_is_Ring(r) */
353  if (rField_is_Ring(r) /*&& (rHasLocalOrMixedOrdering(r))*/)
354  lc = pGetCoeff(p);
355 
356  // Leading coef have to be a unit
357  // example 2x+4x2 should be simplified to 2x*(1+2x)
358  // and 2 is not a unit in Z
359  //if ( !(n_IsUnit(pGetCoeff(p), r->cf)) ) return;
360 
361 // for(i=r->N;i>0;i--)
362 // {
363 // if ((p_GetExp(p,i,r)>0) && (rIsPolyVar(i, r)==TRUE)) return;
364 // }
365  poly h = pNext(p);
366  int i;
367 
369  {
370  loop
371  {
372  if (h==NULL)
373  {
374  p_Delete(&pNext(p), r);
375  if (!inNF)
376  {
377  number eins= nCopy(lc);
378  if (L->p != NULL)
379  {
380  pSetCoeff(L->p,eins);
381  if (L->t_p != NULL)
382  pSetCoeff0(L->t_p,eins);
383  }
384  else
385  pSetCoeff(L->t_p,eins);
386  /* p and t_p share the same coeff, if both are !=NULL */
387  /* p==NULL==t_p cannot happen here */
388  }
389  L->ecart = 0;
390  L->length = 1;
391  //if (L->pLength > 0)
392  L->pLength = 1;
393  L->max_exp = NULL;
394 
395  if (L->t_p != NULL && pNext(L->t_p) != NULL)
396  p_Delete(&pNext(L->t_p),r);
397  if (L->p != NULL && pNext(L->p) != NULL)
398  pNext(L->p) = NULL;
399  return;
400  }
401  i = rVar(r);
402  loop
403  {
404  if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
405  i--;
406  if (i == 0) break; // does divide, try next monom
407  }
408  //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
409  // Note: As long as qring j forbidden if j contains integer (i.e. ground rings are
410  // domains), no zerodivisor test needed CAUTION
411  if (!n_DivBy(pGetCoeff(h),lc,r->cf))
412  {
413  return;
414  }
415  pIter(h);
416  }
417  }
418  else
419  {
420  loop
421  {
422  if (h==NULL)
423  {
424  p_Delete(&pNext(p), r);
425  if (!inNF)
426  {
427  number eins=nInit(1);
428  if (L->p != NULL)
429  {
430  pSetCoeff(L->p,eins);
431  if (L->t_p != NULL)
432  pSetCoeff0(L->t_p,eins);
433  }
434  else
435  pSetCoeff(L->t_p,eins);
436  /* p and t_p share the same coeff, if both are !=NULL */
437  /* p==NULL==t_p cannot happen here */
438  }
439  L->ecart = 0;
440  L->length = 1;
441  //if (L->pLength > 0)
442  L->pLength = 1;
443  L->max_exp = NULL;
444 
445  if (L->t_p != NULL && pNext(L->t_p) != NULL)
446  p_Delete(&pNext(L->t_p),r);
447  if (L->p != NULL && pNext(L->p) != NULL)
448  pNext(L->p) = NULL;
449 
450  return;
451  }
452  i = rVar(r);
453  loop
454  {
455  if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
456  i--;
457  if (i == 0) break; // does divide, try next monom
458  }
459  //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
460  pIter(h);
461  }
462  }
463 }
CanonicalForm lc(const CanonicalForm &f)
int p
Definition: cfModGcd.cc:4080
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:777
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:127
BOOLEAN p_OneComp(poly p, const ring r)
return TRUE if all monoms have the same component
Definition: p_polys.cc:1203
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:597
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:764

◆ chainCritNormal()

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

Definition at line 3240 of file kutil.cc.

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

3477 {
3478  if (strat->pairtest!=NULL)
3479  {
3480  omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3481  strat->pairtest=NULL;
3482  }
3483  /*
3484  *the elements of B enter L
3485  */
3486  kMergeBintoL(strat);
3487 }

◆ chainCritSig()

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

Definition at line 3492 of file kutil.cc.

3493 {
3494  int i,j,l;
3495  kMergeBintoLSba(strat);
3496  j = strat->Ll;
3497  loop /*cannot be changed into a for !!! */
3498  {
3499  if (j <= 0)
3500  {
3501  /*now L[0] cannot be canceled any more and the tail can be removed*/
3502  if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3503  break;
3504  }
3505  if (strat->L[j].p2 == p)
3506  {
3507  i = j-1;
3508  loop
3509  {
3510  if (i < 0) break;
3511  if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3512  {
3513  /*L[i] could be canceled but we search for a better one to cancel*/
3514  strat->c3++;
3515  if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3516  && (pNext(strat->L[l].p) == strat->tail)
3517  && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3518  && pDivisibleBy(p,strat->L[l].lcm))
3519  {
3520  /*
3521  *"NOT equal(...)" because in case of "equal" the element L[l]
3522  *is "older" and has to be from theoretical point of view behind
3523  *L[i], but we do not want to reorder L
3524  */
3525  strat->L[i].p2 = strat->tail;
3526  /*
3527  *L[l] will be canceled, we cannot cancel L[i] later on,
3528  *so we mark it with "tail"
3529  */
3530  deleteInL(strat->L,&strat->Ll,l,strat);
3531  i--;
3532  }
3533  else
3534  {
3535  deleteInL(strat->L,&strat->Ll,i,strat);
3536  }
3537  j--;
3538  }
3539  i--;
3540  }
3541  }
3542  else if (strat->L[j].p2 == strat->tail)
3543  {
3544  /*now L[j] cannot be canceled any more and the tail can be removed*/
3545  strat->L[j].p2 = p;
3546  }
3547  j--;
3548  }
3549 }
void kMergeBintoLSba(kStrategy strat)
Definition: kutil.cc:3218

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 545 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1200 of file kInline.h.

1202 {
1203  assume(p_sev == pGetShortExpVector(p));
1204  if (strat->noClearS) return;
1205  #ifdef HAVE_RINGS
1207  {
1208  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1209  return;
1210  if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1211  return;
1212  }
1213  else
1214  #endif
1215  {
1216  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1217  }
1218  deleteInS((*at),strat);
1219  (*at)--;
1220  (*k)--;
1221 }

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10859 of file kutil.cc.

10860 {
10861  int i;
10862  int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10863  LObject L;
10864 
10865 #ifdef KDEBUG
10866  // need to set this: during tailreductions of T[i], T[i].max is out of
10867  // sync
10868  sloppy_max = TRUE;
10869 #endif
10870 
10871  strat->noTailReduction = FALSE;
10872  //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10873  if (TEST_OPT_PROT)
10874  {
10875  PrintLn();
10876 // if (timerv) writeTime("standard base computed:");
10877  }
10878  if (TEST_OPT_PROT)
10879  {
10880  Print("(S:%d)",strat->sl);mflush();
10881  }
10882  for (i=strat->sl; i>=low; i--)
10883  {
10884  int end_pos=strat->sl;
10885  if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10886  if (strat->ak==0) end_pos=i-1;
10887  TObject* T_j = strat->s_2_t(i);
10888  if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10889  {
10890  L = *T_j;
10891  #ifdef KDEBUG
10892  if (TEST_OPT_DEBUG)
10893  {
10894  Print("test S[%d]:",i);
10895  p_wrp(L.p,currRing,strat->tailRing);
10896  PrintLn();
10897  }
10898  #endif
10900  strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10901  else
10902  strat->S[i] = redtail(&L, strat->sl, strat);
10903  #ifdef KDEBUG
10904  if (TEST_OPT_DEBUG)
10905  {
10906  Print("to (tailR) S[%d]:",i);
10907  p_wrp(strat->S[i],currRing,strat->tailRing);
10908  PrintLn();
10909  }
10910  #endif
10911 
10912  if (strat->redTailChange)
10913  {
10914  if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10915  if (pNext(T_j->p) != NULL)
10916  T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10917  else
10918  T_j->max_exp = NULL;
10919  }
10921  T_j->pCleardenom();
10922  }
10923  else
10924  {
10925  assume(currRing == strat->tailRing);
10926  #ifdef KDEBUG
10927  if (TEST_OPT_DEBUG)
10928  {
10929  Print("test S[%d]:",i);
10930  p_wrp(strat->S[i],currRing,strat->tailRing);
10931  PrintLn();
10932  }
10933  #endif
10935  strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10936  else
10937  strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10939  {
10940  if (TEST_OPT_CONTENTSB)
10941  {
10942  number n;
10943  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10944  if (!nIsOne(n))
10945  {
10947  denom->n=nInvers(n);
10948  denom->next=DENOMINATOR_LIST;
10949  DENOMINATOR_LIST=denom;
10950  }
10951  nDelete(&n);
10952  }
10953  else
10954  {
10955  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10956  }
10957  }
10958  #ifdef KDEBUG
10959  if (TEST_OPT_DEBUG)
10960  {
10961  Print("to (-tailR) S[%d]:",i);
10962  p_wrp(strat->S[i],currRing,strat->tailRing);
10963  PrintLn();
10964  }
10965  #endif
10966  }
10967  if (TEST_OPT_PROT)
10968  PrintS("-");
10969  }
10970  if (TEST_OPT_PROT) PrintLn();
10971 #ifdef KDEBUG
10972  sloppy_max = FALSE;
10973 #endif
10974 }
char noTailReduction
Definition: kutil.h:378
int ak
Definition: kutil.h:352
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:7480
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7556
STATIC_VAR BOOLEAN sloppy_max
Definition: kutil.cc:800
VAR denominator_list DENOMINATOR_LIST
Definition: kutil.cc:84
denominator_list_s * denominator_list
Definition: kutil.h:59
denominator_list next
Definition: kutil.h:61
class sTObject TObject
Definition: kutil.h:53
class sLObject LObject
Definition: kutil.h:54
#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:1133
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:3009
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2900
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
#define mflush()
Definition: reporter.h:58

◆ createG0()

ideal createG0 ( )

Definition at line 4527 of file kutil.cc.

4528 {
4529  // Initialize
4530  long exp[50]; // The exponent of \hat{X} (basepoint)
4531  long cexp[50]; // The current exponent for iterating over all
4532  long ind[50]; // The power of 2 in the i-th component of exp
4533  long cind[50]; // analog for cexp
4534  long mult[50]; // How to multiply the elements of G
4535  long cabsind = 0; // The abs. index of cexp, i.e. the sum of cind
4536  long habsind = 0; // The abs. index of the coefficient of h
4537  long step[50]; // The last increases
4538  for (int i = 1; i <= currRing->N; i++)
4539  {
4540  exp[i] = 0;
4541  cexp[i] = exp[i];
4542  ind[i] = 0;
4543  step[i] = 500000;
4544  cind[i] = ind[i];
4545  }
4546  long bound = currRing->ch;
4547  step[1] = 500000;
4548 #ifdef OLI_DEBUG
4549  PrintS("-------------\npoly :");
4550 // wrp(p);
4551  Print("\nexp : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
4552  Print("cexp : (%d, %d)\n", cexp[1], cexp[2]);
4553  Print("cind : (%d, %d)\n", cind[1], cind[2]);
4554  Print("bound : %d\n", bound);
4555  Print("cind : %d\n", cabsind);
4556 #endif
4557  if (cabsind == 0)
4558  {
4559  if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N)))
4560  {
4561  return idInit(1, 1);
4562  }
4563  }
4564  ideal G0 = idInit(1, 1);
4565  // Now the whole simplex
4566  do
4567  {
4568  // Build s-polynomial
4569  // 2**ind-def * mult * g - exp-def * h
4570  poly t_p;
4571  poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, currRing);
4572 #ifdef OLI_DEBUG
4573  Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
4574  PrintS("zPoly : ");
4575  wrp(zeroPoly);
4576  PrintLn();
4577 #endif
4578  // Add to ideal
4579  pEnlargeSet(&(G0->m), IDELEMS(G0), 1);
4580  IDELEMS(G0) += 1;
4581  G0->m[IDELEMS(G0) - 1] = zeroPoly;
4582  }
4583  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) );
4584  idSkipZeroes(G0);
4585  return G0;
4586 }
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
poly kCreateZeroPoly(long exp[], long cabsind, poly *t_p, ring leadRing, ring tailRing)
Definition: kutil.cc:4398
int nextZeroSimplexExponent(long exp[], long ind[], long cexp[], long cind[], long *cabsind, long step[], long bound, long N)
Definition: kutil.cc:4332
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:647
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3766
void wrp(poly p)
Definition: polys.h:310
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ deleteHC() [1/2]

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

Definition at line 254 of file kutil.cc.

255 {
256  if (strat->kHEdgeFound)
257  {
258  kTest_L(L,strat->tailRing);
259  poly p1;
260  poly p = L->GetLmTailRing();
261  int l = 1;
262  kBucket_pt bucket = NULL;
263  if (L->bucket != NULL)
264  {
265  kBucketClear(L->bucket, &pNext(p), &L->pLength);
266  L->pLength++;
267  bucket = L->bucket;
268  L->bucket = NULL;
269  }
270 
271  if (!fromNext && p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
272  {
273  L->Delete();
274  L->Clear();
275  L->ecart = -1;
276  if (bucket != NULL) kBucketDestroy(&bucket);
277  return;
278  }
279  p1 = p;
280  while (pNext(p1)!=NULL)
281  {
282  if (p_LmCmp(pNext(p1), strat->kNoetherTail(), L->tailRing) == -1)
283  {
284  p_Delete(&pNext(p1), L->tailRing);
285  if (p1 == p)
286  {
287  if (L->t_p != NULL)
288  {
289  assume(L->p != NULL && p == L->t_p);
290  pNext(L->p) = NULL;
291  }
292  L->max_exp = NULL;
293  }
294  else if (fromNext)
295  L->max_exp = p_GetMaxExpP(pNext(L->p), L->tailRing ); // p1;
296  //if (L->pLength != 0)
297  L->pLength = l;
298  // Hmmm when called from updateT, then only
299  // reset ecart when cut
300  if (fromNext)
301  L->ecart = L->pLDeg() - L->GetpFDeg();
302  break;
303  }
304  l++;
305  pIter(p1);
306  }
307  if (! fromNext)
308  {
309  L->SetpFDeg();
310  L->ecart = L->pLDeg(strat->LDegLast) - L->GetpFDeg();
311  }
312  if (bucket != NULL)
313  {
314  if (L->pLength > 1)
315  {
316  kBucketInit(bucket, pNext(p), L->pLength - 1);
317  pNext(p) = NULL;
318  if (L->t_p != NULL) pNext(L->t_p) = NULL;
319  L->pLength = 0;
320  L->bucket = bucket;
321  }
322  else
323  kBucketDestroy(&bucket);
324  }
325  kTest_L(L,strat->tailRing);
326  }
327 }
KINLINE poly kNoetherTail()
Definition: kInline.h:66
char LDegLast
Definition: kutil.h:385
char kHEdgeFound
Definition: kutil.h:376
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:521
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:216
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:493
BOOLEAN kTest_L(LObject *L, ring strat_tailRing, BOOLEAN testp, int lpos, TSet T, int tlength)
Definition: kutil.cc:925
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1695
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1540

◆ deleteHC() [2/2]

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

Definition at line 329 of file kutil.cc.

330 {
331  LObject L(*p, currRing, strat->tailRing);
332 
333  deleteHC(&L, strat);
334  *p = L.p;
335  *e = L.ecart;
336  *l = L.length;
337  if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
338 }
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition: kutil.cc:254

◆ deleteInL()

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

Definition at line 1244 of file kutil.cc.

1245 {
1246  if (set[j].lcm!=NULL)
1247  {
1248  kDeleteLcm(&set[j]);
1249  }
1250  if (set[j].sig!=NULL)
1251  {
1252 #ifdef HAVE_RINGS
1253  if (pGetCoeff(set[j].sig) != NULL)
1254  pLmDelete(set[j].sig);
1255  else
1256 #endif
1257  pLmFree(set[j].sig);
1258  }
1259  if (set[j].p!=NULL)
1260  {
1261  if (pNext(set[j].p) == strat->tail)
1262  {
1263 #ifdef HAVE_RINGS
1264  if (pGetCoeff(set[j].p) != NULL)
1265  pLmDelete(set[j].p);
1266  else
1267 #endif
1268  pLmFree(set[j].p);
1269  /*- tail belongs to several int spolys -*/
1270  }
1271  else
1272  {
1273  // search p in T, if it is there, do not delete it
1274  if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1275  {
1276  // assure that for global orderings kFindInT fails
1277  //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1278  set[j].Delete();
1279  }
1280  }
1281  }
1282  if (*length > 0 && j < *length)
1283  {
1284 #ifdef ENTER_USE_MEMMOVE
1285  memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1286 #else
1287  int i;
1288  for (i=j; i < (*length); i++)
1289  set[i] = set[i+1];
1290 #endif
1291  }
1292 #ifdef KDEBUG
1293  memset(&(set[*length]),0,sizeof(LObject));
1294 #endif
1295  (*length)--;
1296 }
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
int kFindInT(poly p, TSet T, int tlength)
returns index of p in TSet, or -1 if not found
Definition: kutil.cc:718
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:709

◆ deleteInS()

void deleteInS ( int  i,
kStrategy  strat 
)

Definition at line 1137 of file kutil.cc.

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

◆ deleteInSSba()

void deleteInSSba ( int  i,
kStrategy  strat 
)

Definition at line 1189 of file kutil.cc.

1190 {
1191 #ifdef ENTER_USE_MEMMOVE
1192  memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1193  memmove(&(strat->sig[i]), &(strat->sig[i+1]), (strat->sl - i)*sizeof(poly));
1194  memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1195  memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1196  memmove(&(strat->sevSig[i]),&(strat->sevSig[i+1]),(strat->sl - i)*sizeof(unsigned long));
1197  memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1198 #else
1199  int j;
1200  for (j=i; j<strat->sl; j++)
1201  {
1202  strat->S[j] = strat->S[j+1];
1203  strat->sig[j] = strat->sig[j+1];
1204  strat->ecartS[j] = strat->ecartS[j+1];
1205  strat->sevS[j] = strat->sevS[j+1];
1206  strat->sevSig[j] = strat->sevSig[j+1];
1207  strat->S_2_R[j] = strat->S_2_R[j+1];
1208  }
1209 #endif
1210  if (strat->lenS!=NULL)
1211  {
1212 #ifdef ENTER_USE_MEMMOVE
1213  memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1214 #else
1215  for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1216 #endif
1217  }
1218  if (strat->lenSw!=NULL)
1219  {
1220 #ifdef ENTER_USE_MEMMOVE
1221  memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1222 #else
1223  for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1224 #endif
1225  }
1226  if (strat->fromQ!=NULL)
1227  {
1228 #ifdef ENTER_USE_MEMMOVE
1229  memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1230 #else
1231  for (j=i; j<strat->sl; j++)
1232  {
1233  strat->fromQ[j] = strat->fromQ[j+1];
1234  }
1235 #endif
1236  }
1237  strat->S[strat->sl] = NULL;
1238  strat->sl--;
1239 }

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4675 of file kutil.cc.

4676 {
4677  if (nIsOne(pGetCoeff(h))) return;
4678  number gcd;
4679  bool go = false;
4680  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4681  {
4682  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4683  go = true;
4684  }
4685  else
4686  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4687  if (go || !nIsOne(gcd))
4688  {
4689  poly p = h->next;
4690  if (!go)
4691  {
4692  number tmp = gcd;
4693  gcd = n_Ann(gcd,currRing->cf);
4694  nDelete(&tmp);
4695  }
4696  p_Test(p,strat->tailRing);
4697  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4698  nDelete(&gcd);
4699 
4700  if (p != NULL)
4701  {
4702  if (TEST_OPT_PROT)
4703  {
4704  PrintS("Z");
4705  }
4706 #ifdef KDEBUG
4707  if (TEST_OPT_DEBUG)
4708  {
4709  PrintS("--- create zero spoly: ");
4710  p_wrp(h,currRing,strat->tailRing);
4711  PrintS(" ---> ");
4712  }
4713 #endif
4714  poly tmp = pInit();
4715  pSetCoeff0(tmp, pGetCoeff(p));
4716  for (int i = 1; i <= rVar(currRing); i++)
4717  {
4718  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4719  }
4721  {
4722  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4723  }
4724  p_Setm(tmp, currRing);
4725  p = p_LmFreeAndNext(p, strat->tailRing);
4726  pNext(tmp) = p;
4727  LObject Lp;
4728  Lp.Init();
4729  Lp.p = tmp;
4730  Lp.tailRing = strat->tailRing;
4731  int posx;
4732  if (Lp.p!=NULL)
4733  {
4734  strat->initEcart(&Lp);
4735  if (strat->Ll==-1)
4736  posx =0;
4737  else
4738  posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4739  Lp.sev = pGetShortExpVector(Lp.p);
4740  if (strat->tailRing != currRing)
4741  {
4742  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4743  }
4744 #ifdef KDEBUG
4745  if (TEST_OPT_DEBUG)
4746  {
4747  p_wrp(tmp,currRing,strat->tailRing);
4748  PrintLn();
4749  }
4750 #endif
4751  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4752  }
4753  }
4754  }
4755  nDelete(&gcd);
4756 }
int Lmax
Definition: kutil.h:350
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:687
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:702
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:927
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1301
#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:962
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:703
#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 4758 of file kutil.cc.

4759 {
4760  if (nIsOne(pGetCoeff(h))) return;
4761  number gcd;
4762  bool go = false;
4763  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4764  {
4765  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4766  go = true;
4767  }
4768  else
4769  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4770  if (go || !nIsOne(gcd))
4771  {
4772  poly p = h->next;
4773  if (!go)
4774  {
4775  number tmp = gcd;
4776  gcd = n_Ann(gcd,currRing->cf);
4777  nDelete(&tmp);
4778  }
4779  p_Test(p,strat->tailRing);
4780  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4781 
4782  if (p != NULL)
4783  {
4784  if (TEST_OPT_PROT)
4785  {
4786  PrintS("Z");
4787  }
4788 #ifdef KDEBUG
4789  if (TEST_OPT_DEBUG)
4790  {
4791  PrintS("--- create zero spoly: ");
4792  p_wrp(h,currRing,strat->tailRing);
4793  PrintS(" ---> ");
4794  }
4795 #endif
4796  poly tmp = pInit();
4797  pSetCoeff0(tmp, pGetCoeff(p));
4798  for (int i = 1; i <= rVar(currRing); i++)
4799  {
4800  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4801  }
4803  {
4804  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4805  }
4806  p_Setm(tmp, currRing);
4807  p = p_LmFreeAndNext(p, strat->tailRing);
4808  pNext(tmp) = p;
4809  LObject Lp;
4810  Lp.Init();
4811  Lp.p = tmp;
4812  //printf("\nOld\n");pWrite(h);pWrite(hSig);
4813  #if EXT_POLY_NEW
4814  Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4815  if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4816  {
4817  strat->sigdrop = TRUE;
4818  //Try to reduce it as far as we can via redRing
4819  int red_result = redRing(&Lp,strat);
4820  if(red_result == 0)
4821  {
4822  // Cancel the sigdrop
4823  p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4824  strat->sigdrop = FALSE;
4825  return;
4826  }
4827  else
4828  {
4829  strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4830  #if 1
4831  strat->enterS(Lp,0,strat,strat->tl);
4832  #endif
4833  return;
4834  }
4835 
4836  }
4837  #else
4838  Lp.sig = pOne();
4839  if(strat->Ll >= 0)
4840  p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4841  else
4842  p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4843  #endif
4844  Lp.tailRing = strat->tailRing;
4845  int posx;
4846  if (Lp.p!=NULL)
4847  {
4848  strat->initEcart(&Lp);
4849  if (strat->Ll==-1)
4850  posx =0;
4851  else
4852  posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4853  Lp.sev = pGetShortExpVector(Lp.p);
4854  if (strat->tailRing != currRing)
4855  {
4856  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4857  }
4858 #ifdef KDEBUG
4859  if (TEST_OPT_DEBUG)
4860  {
4861  p_wrp(tmp,currRing,strat->tailRing);
4862  PrintLn();
4863  }
4864 #endif
4865  //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4866  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4867  }
4868  }
4869  nDelete(&gcd);
4870  }
4871  nDelete(&gcd);
4872 }
bool sigdrop
Definition: kutil.h:359
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:279
int redRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:795
#define nIsZero(n)
Definition: numbers.h:19

◆ enterL()

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

Definition at line 1301 of file kutil.cc.

1302 {
1303  // this should be corrected
1304  assume(p.FDeg == p.pFDeg());
1305 
1306  if ((*length)>=0)
1307  {
1308  if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1309  if (at <= (*length))
1310 #ifdef ENTER_USE_MEMMOVE
1311  memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1312 #else
1313  for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1314 #endif
1315  }
1316  else at = 0;
1317  (*set)[at] = p;
1318  (*length)++;
1319 }
static void enlargeL(LSet *L, int *length, const int incr)
Definition: kutil.cc:663
#define setmaxLinc
Definition: kutil.h:31

◆ enterOnePairNormal()

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

Definition at line 1975 of file kutil.cc.

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

◆ enterOnePairShift()

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

Definition at line 12862 of file kutil.cc.

12863 {
12864 #ifdef CRITERION_DEBUG
12865  if (TEST_OPT_DEBUG)
12866  {
12867  PrintS("Consider pair ("); wrp(q); PrintS(", "); wrp(p); PrintS(")"); PrintLn();
12868  // also write the LMs in separate lines:
12869  poly lmq = pHead(q);
12870  poly lmp = pHead(p);
12871  pSetCoeff(lmq, n_Init(1, currRing->cf));
12872  pSetCoeff(lmp, n_Init(1, currRing->cf));
12873  Print(" %s\n", pString(lmq));
12874  Print(" %s\n", pString(lmp));
12875  pLmDelete(lmq);
12876  pLmDelete(lmp);
12877  }
12878 #endif
12879 
12880  /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
12881 
12882  /* check this Formats: */
12884  assume(p_CheckIsFromRing(pNext(q),strat->tailRing));
12887 
12888  /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
12889 
12890  int qfromQ = qisFromQ;
12891 
12892  /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */
12893 
12894  int l,j,compare;
12895  LObject Lp;
12896  Lp.i_r = -1;
12897 
12898 #ifdef KDEBUG
12899  Lp.ecart=0; Lp.length=0;
12900 #endif
12901  /*- computes the lcm(s[i],p) -*/
12902  Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
12903 
12904  /* the V criterion */
12905  if (!pmIsInV(Lp.lcm))
12906  {
12907  strat->cv++; // counter for applying the V criterion
12908  pLmFree(Lp.lcm);
12909 #ifdef CRITERION_DEBUG
12910  if (TEST_OPT_DEBUG) PrintS("--- V crit\n");
12911 #endif
12912  return;
12913  }
12914 
12915  if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
12916  {
12917  if((!((ecartq>0)&&(ecart>0)))
12918  && pHasNotCF(p,q))
12919  {
12920  /*
12921  *the product criterion has applied for (s,p),
12922  *i.e. lcm(s,p)=product of the leading terms of s and p.
12923  *Suppose (s,r) is in L and the leading term
12924  *of p divides lcm(s,r)
12925  *(==> the leading term of p divides the leading term of r)
12926  *but the leading term of s does not divide the leading term of r
12927  *(notice that this condition is automatically satisfied if r is still
12928  *in S), then (s,r) can be cancelled.
12929  *This should be done here because the
12930  *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12931  *
12932  *Moreover, skipping (s,r) holds also for the noncommutative case.
12933  */
12934  strat->cp++;
12935  pLmFree(Lp.lcm);
12936 #ifdef CRITERION_DEBUG
12937  if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12938 #endif
12939  return;
12940  }
12941  else
12942  Lp.ecart = si_max(ecart,ecartq);
12943  if (strat->fromT && (ecartq>ecart))
12944  {
12945  pLmFree(Lp.lcm);
12946 #ifdef CRITERION_DEBUG
12947  if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12948 #endif
12949  return;
12950  /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12951  }
12952  /*
12953  *the set B collects the pairs of type (S[j],p)
12954  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12955  *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12956  *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12957  */
12958  {
12959  j = strat->Bl;
12960  loop
12961  {
12962  if (j < 0) break;
12963  compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12964  if ((compare==1)
12965  &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
12966  {
12967  strat->c3++;
12968  if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12969  {
12970  pLmFree(Lp.lcm);
12971 #ifdef CRITERION_DEBUG
12972  if (TEST_OPT_DEBUG)
12973  {
12974  Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12975  }
12976 #endif
12977  return;
12978  }
12979  break;
12980  }
12981  else
12982  if ((compare ==-1)
12983  && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
12984  {
12985 #ifdef CRITERION_DEBUG
12986  if (TEST_OPT_DEBUG)
12987  {
12988  Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12989  }
12990 #endif
12991  deleteInL(strat->B,&strat->Bl,j,strat);
12992  strat->c3++;
12993  }
12994  j--;
12995  }
12996  }
12997  }
12998  else /*sugarcrit*/
12999  {
13000  if (ALLOW_PROD_CRIT(strat))
13001  {
13002  // if currRing->nc_type!=quasi (or skew)
13003  // TODO: enable productCrit for super commutative algebras...
13004  if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
13005  pHasNotCF(p,q))
13006  {
13007  /*
13008  *the product criterion has applied for (s,p),
13009  *i.e. lcm(s,p)=product of the leading terms of s and p.
13010  *Suppose (s,r) is in L and the leading term
13011  *of p divides lcm(s,r)
13012  *(==> the leading term of p divides the leading term of r)
13013  *but the leading term of s does not divide the leading term of r
13014  *(notice that tis condition is automatically satisfied if r is still
13015  *in S), then (s,r) can be canceled.
13016  *This should be done here because the
13017  *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
13018  */
13019  strat->cp++;
13020  pLmFree(Lp.lcm);
13021 #ifdef CRITERION_DEBUG
13022  if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
13023 #endif
13024  return;
13025  }
13026  if (strat->fromT && (ecartq>ecart))
13027  {
13028  pLmFree(Lp.lcm);
13029 #ifdef CRITERION_DEBUG
13030  if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
13031 #endif
13032  return;
13033  /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
13034  }
13035  /*
13036  *the set B collects the pairs of type (S[j],p)
13037  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
13038  *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
13039  *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
13040  */
13041  for(j = strat->Bl;j>=0;j--)
13042  {
13043  compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
13044  if (compare==1)
13045  {
13046  strat->c3++;
13047  if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
13048  {
13049  pLmFree(Lp.lcm);
13050 #ifdef CRITERION_DEBUG
13051  if (TEST_OPT_DEBUG)
13052  {
13053  Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
13054  }
13055 #endif
13056  return;
13057  }
13058  break;
13059  }
13060  else
13061  if (compare ==-1)
13062  {
13063 #ifdef CRITERION_DEBUG
13064  if (TEST_OPT_DEBUG)
13065  {
13066  Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
13067  }
13068 #endif
13069  deleteInL(strat->B,&strat->Bl,j,strat);
13070  strat->c3++;
13071  }
13072  }
13073  }
13074  }
13075  /*
13076  *the pair (S[i],p) enters B if the spoly != 0
13077  */
13078  /*- compute the short s-polynomial -*/
13079  if (strat->fromT && !TEST_OPT_INTSTRATEGY)
13080  pNorm(p);
13081  if ((q==NULL) || (p==NULL))
13082  {
13083 #ifdef CRITERION_DEBUG
13084  if (TEST_OPT_DEBUG) PrintS("--- q == NULL || p == NULL\n");
13085 #endif
13086  return;
13087  }
13088  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
13089  {
13090  Lp.p=NULL;
13091 #ifdef CRITERION_DEBUG
13092  if (TEST_OPT_DEBUG) PrintS("--- pair is from Q\n");
13093 #endif
13094  }
13095  else
13096  {
13097 // if ( rIsPluralRing(currRing) )
13098 // {
13099 // if(pHasNotCF(p, q))
13100 // {
13101 // if(ncRingType(currRing) == nc_lie)
13102 // {
13103 // // generalized prod-crit for lie-type
13104 // strat->cp++;
13105 // Lp.p = nc_p_Bracket_qq(pCopy(p),q, currRing);
13106 // }
13107 // else
13108 // if( ALLOW_PROD_CRIT(strat) )
13109 // {
13110 // // product criterion for homogeneous case in SCA
13111 // strat->cp++;
13112 // Lp.p = NULL;
13113 // }
13114 // else
13115 // Lp.p = nc_CreateSpoly(q,p,currRing); // ?
13116 // }
13117 // else Lp.p = nc_CreateSpoly(q,p,currRing);
13118 // }
13119 // else
13120 // {
13121 
13122  /* ksCreateShortSpoly needs two Lobject-kind presentations */
13123  /* p is already in this form, so convert q */
13124  // q = pMove2CurrTail(q, strat);
13125  Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
13126  // }
13127  }
13128  if (Lp.p == NULL)
13129  {
13130  /*- the case that the s-poly is 0 -*/
13131  // TODO: currently ifromS is only > 0 if called from enterOnePairWithShifts
13132  if (ifromS > 0)
13133  {
13134  if (strat->pairtest==NULL) initPairtest(strat);
13135  strat->pairtest[ifromS] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
13136  strat->pairtest[strat->sl+1] = TRUE;
13137  }
13138  //if (TEST_OPT_DEBUG){Print("!");} // option teach
13139  /* END _ TEMPORARILY DISABLED FOR SHIFTS */
13140  /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
13141  /*
13142  *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
13143  *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
13144  *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
13145  *term of p divides the lcm(s,r)
13146  *(this canceling should be done here because
13147  *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
13148  *the first case is handeled in chainCrit
13149  */
13150  if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
13151 #ifdef CRITERION_DEBUG
13152  if (TEST_OPT_DEBUG) PrintS("--- S-poly = 0\n");
13153 #endif
13154  }
13155  else
13156  {
13157  /*- the pair (S[i],p) enters B -*/
13158  /* both of them should have their LM in currRing and TAIL in tailring */
13159  Lp.p1 = q; // already in the needed form
13160  Lp.p2 = p; // already in the needed form
13161 
13162  if ( !rIsPluralRing(currRing) )
13163  pNext(Lp.p) = strat->tail;
13164 
13165  /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
13166  /* at the beginning we DO NOT set atR = -1 ANYMORE*/
13167  if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
13168  {
13169  Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
13170  Lp.i_r2 = atR;
13171  }
13172  else
13173  {
13174  /* END _ TEMPORARILY DISABLED FOR SHIFTS */
13175  Lp.i_r1 = -1;
13176  Lp.i_r2 = -1;
13177  }
13178  strat->initEcartPair(&Lp,q,p,ecartq,ecart);
13179 
13181  {
13182  if (!rIsPluralRing(currRing)
13184  && (Lp.p->coef!=NULL))
13185  nDelete(&(Lp.p->coef));
13186  }
13187 
13188  l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
13189  enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
13190 #ifdef CRITERION_DEBUG
13191  if (TEST_OPT_DEBUG) PrintS("+++ Entered pair\n");
13192 #endif
13193  }
13194 }
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:539
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:1642
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:100
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:69
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
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 4933 of file kutil.cc.

4934 {
4935  int j=pos;
4936 
4938  initenterpairs(h,k,ecart,0,strat, atR);
4939  if ( (!strat->fromT)
4940  && ((strat->syzComp==0)
4941  ||(pGetComp(h)<=strat->syzComp)))
4942  {
4943  unsigned long h_sev = pGetShortExpVector(h);
4944  loop
4945  {
4946  if (j > k) break;
4947  clearS(h,h_sev, &j,&k,strat);
4948  j++;
4949  }
4950  }
4951 }
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:3840

◆ enterpairsShift()

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

Definition at line 13636 of file kutil.cc.

13637 {
13638  /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
13639  /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
13640  int j=pos;
13641 
13642  /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
13643  initenterpairsShift(h,k,ecart,0,strat, atR);
13644  if ( (!strat->fromT)
13645  && ((strat->syzComp==0)
13646  ||(pGetComp(h)<=strat->syzComp)))
13647  {
13648  unsigned long h_sev = pGetShortExpVector(h);
13649  loop
13650  {
13651  if (j > k) break;
13652  // TODO this currently doesn't clear all possible elements because of commutative division
13653  if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
13654  clearS(h,h_sev, &j,&k,strat);
13655  j++;
13656  }
13657  }
13658 }
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:13203

◆ enterpairsSig()

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

Definition at line 4959 of file kutil.cc.

4960 {
4961  int j=pos;
4963  initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4964  if ( (!strat->fromT)
4965  && ((strat->syzComp==0)
4966  ||(pGetComp(h)<=strat->syzComp)))
4967  {
4968  unsigned long h_sev = pGetShortExpVector(h);
4969  loop
4970  {
4971  if (j > k) break;
4972  clearS(h,h_sev, &j,&k,strat);
4973  j++;
4974  }
4975  }
4976 }
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3905

◆ enterSBba()

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

Definition at line 9350 of file kutil.cc.

9351 {
9352  strat->news = TRUE;
9353  /*- puts p to the standardbasis s at position at -*/
9354  if (strat->sl == IDELEMS(strat->Shdl)-1)
9355  {
9356  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9357  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9358  (IDELEMS(strat->Shdl)+setmaxTinc)
9359  *sizeof(unsigned long));
9360  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9361  IDELEMS(strat->Shdl)*sizeof(int),
9362  (IDELEMS(strat->Shdl)+setmaxTinc)
9363  *sizeof(int));
9364  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9365  IDELEMS(strat->Shdl)*sizeof(int),
9366  (IDELEMS(strat->Shdl)+setmaxTinc)
9367  *sizeof(int));
9368  if (strat->lenS!=NULL)
9369  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9370  IDELEMS(strat->Shdl)*sizeof(int),
9371  (IDELEMS(strat->Shdl)+setmaxTinc)
9372  *sizeof(int));
9373  if (strat->lenSw!=NULL)
9374  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9375  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9376  (IDELEMS(strat->Shdl)+setmaxTinc)
9377  *sizeof(wlen_type));
9378  if (strat->fromQ!=NULL)
9379  {
9380  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9381  IDELEMS(strat->Shdl)*sizeof(int),
9382  (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
9383  }
9384  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
9385  IDELEMS(strat->Shdl)+=setmaxTinc;
9386  strat->Shdl->m=strat->S;
9387  }
9388  if (atS <= strat->sl)
9389  {
9390 #ifdef ENTER_USE_MEMMOVE
9391  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9392  (strat->sl - atS + 1)*sizeof(poly));
9393  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9394  (strat->sl - atS + 1)*sizeof(int));
9395  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9396  (strat->sl - atS + 1)*sizeof(unsigned long));
9397  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9398  (strat->sl - atS + 1)*sizeof(int));
9399  if (strat->lenS!=NULL)
9400  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9401  (strat->sl - atS + 1)*sizeof(int));
9402  if (strat->lenSw!=NULL)
9403  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9404  (strat->sl - atS + 1)*sizeof(wlen_type));
9405 #else
9406  for (i=strat->sl+1; i>=atS+1; i--)
9407  {
9408  strat->S[i] = strat->S[i-1];
9409  strat->ecartS[i] = strat->ecartS[i-1];
9410  strat->sevS[i] = strat->sevS[i-1];
9411  strat->S_2_R[i] = strat->S_2_R[i-1];
9412  }
9413  if (strat->lenS!=NULL)
9414  for (i=strat->sl+1; i>=atS+1; i--)
9415  strat->lenS[i] = strat->lenS[i-1];
9416  if (strat->lenSw!=NULL)
9417  for (i=strat->sl+1; i>=atS+1; i--)
9418  strat->lenSw[i] = strat->lenSw[i-1];
9419 #endif
9420  }
9421  if (strat->fromQ!=NULL)
9422  {
9423 #ifdef ENTER_USE_MEMMOVE
9424  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9425  (strat->sl - atS + 1)*sizeof(int));
9426 #else
9427  for (i=strat->sl+1; i>=atS+1; i--)
9428  {
9429  strat->fromQ[i] = strat->fromQ[i-1];
9430  }
9431 #endif
9432  strat->fromQ[atS]=0;
9433  }
9434 
9435  /*- save result -*/
9436  poly pp=p.p;
9437  strat->S[atS] = pp;
9438  if (strat->honey) strat->ecartS[atS] = p.ecart;
9439  if (p.sev == 0)
9440  p.sev = pGetShortExpVector(pp);
9441  else
9442  assume(p.sev == pGetShortExpVector(pp));
9443  strat->sevS[atS] = p.sev;
9444  strat->ecartS[atS] = p.ecart;
9445  strat->S_2_R[atS] = atR;
9446  strat->sl++;
9447 }
CanonicalForm 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:49
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221

◆ enterSBbaShift()

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

Definition at line 9450 of file kutil.cc.

9451 {
9452  enterSBba(p, atS, strat, atR);
9453 
9454  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
9455  for (int i = maxPossibleShift; i > 0; i--)
9456  {
9457  // NOTE: don't use "shared tails" here. In rare cases it can cause problems
9458  // in `kNF2` because of lazy poly normalizations.
9459  LObject qq(p_Copy(p.p, strat->tailRing));
9460  p_mLPshift(qq.p, i, strat->tailRing);
9461  qq.shift = i;
9462  strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
9463  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
9464  enterSBba(qq, atS, strat, -1);
9465  }
9466 }
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9350
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:359

◆ entersets()

void entersets ( LObject  h)

◆ enterSSba()

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

Definition at line 9473 of file kutil.cc.

9474 {
9475  strat->news = TRUE;
9476  /*- puts p to the standardbasis s at position at -*/
9477  if (strat->sl == IDELEMS(strat->Shdl)-1)
9478  {
9479  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9480  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9481  (IDELEMS(strat->Shdl)+setmax)
9482  *sizeof(unsigned long));
9483  strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
9484  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9485  (IDELEMS(strat->Shdl)+setmax)
9486  *sizeof(unsigned long));
9487  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9488  IDELEMS(strat->Shdl)*sizeof(int),
9489  (IDELEMS(strat->Shdl)+setmax)
9490  *sizeof(int));
9491  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9492  IDELEMS(strat->Shdl)*sizeof(int),
9493  (IDELEMS(strat->Shdl)+setmax)
9494  *sizeof(int));
9495  if (strat->lenS!=NULL)
9496  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9497  IDELEMS(strat->Shdl)*sizeof(int),
9498  (IDELEMS(strat->Shdl)+setmax)
9499  *sizeof(int));
9500  if (strat->lenSw!=NULL)
9501  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9502  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9503  (IDELEMS(strat->Shdl)+setmax)
9504  *sizeof(wlen_type));
9505  if (strat->fromQ!=NULL)
9506  {
9507  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9508  IDELEMS(strat->Shdl)*sizeof(int),
9509  (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
9510  }
9511  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
9512  pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
9513  IDELEMS(strat->Shdl)+=setmax;
9514  strat->Shdl->m=strat->S;
9515  }
9516  // in a signature-based algorithm the following situation will never
9517  // appear due to the fact that the critical pairs are already sorted
9518  // by increasing signature.
9519  // True. However, in the case of integers we need to put the element
9520  // that caused the signature drop on the first position
9521  if (atS <= strat->sl)
9522  {
9523 #ifdef ENTER_USE_MEMMOVE
9524  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9525  (strat->sl - atS + 1)*sizeof(poly));
9526  memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
9527  (strat->sl - atS + 1)*sizeof(poly));
9528  memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
9529  (strat->sl - atS + 1)*sizeof(unsigned long));
9530  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9531  (strat->sl - atS + 1)*sizeof(int));
9532  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9533  (strat->sl - atS + 1)*sizeof(unsigned long));
9534  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9535  (strat->sl - atS + 1)*sizeof(int));
9536  if (strat->lenS!=NULL)
9537  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9538  (strat->sl - atS + 1)*sizeof(int));
9539  if (strat->lenSw!=NULL)
9540  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9541  (strat->sl - atS + 1)*sizeof(wlen_type));
9542 #else
9543  for (i=strat->sl+1; i>=atS+1; i--)
9544  {
9545  strat->S[i] = strat->S[i-1];
9546  strat->ecartS[i] = strat->ecartS[i-1];
9547  strat->sevS[i] = strat->sevS[i-1];
9548  strat->S_2_R[i] = strat->S_2_R[i-1];
9549  strat->sig[i] = strat->sig[i-1];
9550  strat->sevSig[i] = strat->sevSig[i-1];
9551  }
9552  if (strat->lenS!=NULL)
9553  for (i=strat->sl+1; i>=atS+1; i--)
9554  strat->lenS[i] = strat->lenS[i-1];
9555  if (strat->lenSw!=NULL)
9556  for (i=strat->sl+1; i>=atS+1; i--)
9557  strat->lenSw[i] = strat->lenSw[i-1];
9558 #endif
9559  }
9560  if (strat->fromQ!=NULL)
9561  {
9562 #ifdef ENTER_USE_MEMMOVE
9563  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9564  (strat->sl - atS + 1)*sizeof(int));
9565 #else
9566  for (i=strat->sl+1; i>=atS+1; i--)
9567  {
9568  strat->fromQ[i] = strat->fromQ[i-1];
9569  }
9570 #endif
9571  strat->fromQ[atS]=0;
9572  }
9573 
9574  /*- save result -*/
9575  strat->S[atS] = p.p;
9576  strat->sig[atS] = p.sig; // TODO: get ths correct signature in here!
9577  if (strat->honey) strat->ecartS[atS] = p.ecart;
9578  if (p.sev == 0)
9579  p.sev = pGetShortExpVector(p.p);
9580  else
9581  assume(p.sev == pGetShortExpVector(p.p));
9582  strat->sevS[atS] = p.sev;
9583  // during the interreduction process of a signature-based algorithm we do not
9584  // compute the signature at this point, but when the whole interreduction
9585  // process finishes, i.e. f5c terminates!
9586  if (p.sig != NULL)
9587  {
9588  if (p.sevSig == 0)
9589  p.sevSig = pGetShortExpVector(p.sig);
9590  else
9591  assume(p.sevSig == pGetShortExpVector(p.sig));
9592  strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9593  }
9594  strat->ecartS[atS] = p.ecart;
9595  strat->S_2_R[atS] = atR;
9596  strat->sl++;
9597 #ifdef DEBUGF5
9598  int k;
9599  Print("--- LIST S: %d ---\n",strat->sl);
9600  for(k=0;k<=strat->sl;k++)
9601  {
9602  pWrite(strat->sig[k]);
9603  }
9604  PrintS("--- LIST S END ---\n");
9605 #endif
9606 }
#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 9901 of file kutil.cc.

9902 {
9903  int i;
9904  strat->newt = TRUE;
9905  if (strat->syzl == strat->syzmax-1)
9906  {
9907  pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9908  strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9909  (strat->syzmax)*sizeof(unsigned long),
9910  ((strat->syzmax)+setmax)
9911  *sizeof(unsigned long));
9912  strat->syzmax += setmax;
9913  }
9914  if (atT < strat->syzl)
9915  {
9916 #ifdef ENTER_USE_MEMMOVE
9917  memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9918  (strat->syzl-atT+1)*sizeof(poly));
9919  memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9920  (strat->syzl-atT+1)*sizeof(unsigned long));
9921 #endif
9922  for (i=strat->syzl; i>=atT+1; i--)
9923  {
9924 #ifndef ENTER_USE_MEMMOVE
9925  strat->syz[i] = strat->syz[i-1];
9926  strat->sevSyz[i] = strat->sevSyz[i-1];
9927 #endif
9928  }
9929  }
9930  //i = strat->syzl;
9931  i = atT;
9932  //Makes sure the syz saves just the signature
9933  #ifdef HAVE_RINGS
9935  pNext(p.sig) = NULL;
9936  #endif
9937  strat->syz[atT] = p.sig;
9938  strat->sevSyz[atT] = p.sevSig;
9939  strat->syzl++;
9940 #if F5DEBUG
9941  Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9942  pWrite(strat->syz[atT]);
9943 #endif
9944  // recheck pairs in strat->L with new rule and delete correspondingly
9945  int cc = strat->Ll;
9946  while (cc>-1)
9947  {
9948  //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9949  //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);
9950  if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9951  strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9952  #ifdef HAVE_RINGS
9953  &&((!rField_is_Ring(currRing))
9954  || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9955  #endif
9956  )
9957  {
9958  //printf("\nYES!\n");
9959  deleteInL(strat->L,&strat->Ll,cc,strat);
9960  }
9961  cc--;
9962  }
9963 //#if 1
9964 #ifdef DEBUGF5
9965  PrintS("--- Syzygies ---\n");
9966  Print("syzl %d\n",strat->syzl);
9967  Print("syzmax %d\n",strat->syzmax);
9968  PrintS("--------------------------------\n");
9969  for(i=0;i<=strat->syzl-1;i++)
9970  {
9971  Print("%d - ",i);
9972  pWrite(strat->syz[i]);
9973  }
9974  PrintS("--------------------------------\n");
9975 #endif
9976 }
unsigned long * sevSyz
Definition: kutil.h:320
int syzmax
Definition: kutil.h:348
int syzl
Definition: kutil.h:348
polyset syz
Definition: kutil.h:304
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 9699 of file kutil.cc.

9700 {
9701  int i;
9702 
9703 #ifdef PDEBUG
9704 #ifdef HAVE_SHIFTBBA
9705  if (currRing->isLPring && p.shift > 0)
9706  {
9707  // in this case, the order is not correct. test LM and tail separately
9708  p_LmTest(p.p, currRing);
9709  p_Test(pNext(p.p), currRing);
9710  }
9711  else
9712 #endif
9713  {
9714  pp_Test(p.p, currRing, p.tailRing);
9715  }
9716 #endif
9717  assume(strat->tailRing == p.tailRing);
9718  // redMoraNF complains about this -- but, we don't really
9719  // neeed this so far
9720  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9721  assume(p.FDeg == p.pFDeg());
9722  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9723 
9724 #ifdef KDEBUG
9725  // do not put an LObject twice into T:
9726  for(i=strat->tl;i>=0;i--)
9727  {
9728  if (p.p==strat->T[i].p)
9729  {
9730  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9731  return;
9732  }
9733  }
9734 #endif
9735 
9736 #ifdef HAVE_TAIL_RING
9737  if (currRing!=strat->tailRing)
9738  {
9739  p.t_p=p.GetLmTailRing();
9740  }
9741 #endif
9742  strat->newt = TRUE;
9743  if (atT < 0)
9744  atT = strat->posInT(strat->T, strat->tl, p);
9745  if (strat->tl == strat->tmax-1)
9746  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9747  if (atT <= strat->tl)
9748  {
9749 #ifdef ENTER_USE_MEMMOVE
9750  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9751  (strat->tl-atT+1)*sizeof(TObject));
9752  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9753  (strat->tl-atT+1)*sizeof(unsigned long));
9754 #endif
9755  for (i=strat->tl+1; i>=atT+1; i--)
9756  {
9757 #ifndef ENTER_USE_MEMMOVE
9758  strat->T[i] = strat->T[i-1];
9759  strat->sevT[i] = strat->sevT[i-1];
9760 #endif
9761  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9762  }
9763  }
9764 
9765  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9766  {
9767 #ifdef HAVE_SHIFTBBA
9768  // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9769  if (!(currRing->isLPring && p.shift > 0))
9770 #endif
9771  {
9773  (strat->tailRing != NULL ?
9774  strat->tailRing : currRing),
9775  strat->tailBin);
9776  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9777  }
9778  }
9779  strat->T[atT] = (TObject) p;
9780  //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9781 
9782  if (pNext(p.p) != NULL)
9783  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9784  else
9785  strat->T[atT].max_exp = NULL;
9786 
9787  strat->tl++;
9788  strat->R[strat->tl] = &(strat->T[atT]);
9789  strat->T[atT].i_r = strat->tl;
9790  assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9791  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9792  kTest_T(&(strat->T[atT]));
9793 }
int tmax
Definition: kutil.h:349
omBin tailBin
Definition: kutil.h:344
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition: kutil.cc:524
BOOLEAN kTest_T(TObject *T, ring strat_tailRing, int i, char TN)
Definition: kutil.cc:801
#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:888
#define p_LmTest(p, r)
Definition: p_polys.h:163
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:725

◆ enterT_strong()

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

Definition at line 9799 of file kutil.cc.

9800 {
9802  int i;
9803 
9804  pp_Test(p.p, currRing, p.tailRing);
9805  assume(strat->tailRing == p.tailRing);
9806  // redMoraNF complains about this -- but, we don't really
9807  // neeed this so far
9808  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9809  assume(p.FDeg == p.pFDeg());
9810  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9811 
9812 #ifdef KDEBUG
9813  // do not put an LObject twice into T:
9814  for(i=strat->tl;i>=0;i--)
9815  {
9816  if (p.p==strat->T[i].p)
9817  {
9818  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9819  return;
9820  }
9821  }
9822 #endif
9823 
9824 #ifdef HAVE_TAIL_RING
9825  if (currRing!=strat->tailRing)
9826  {
9827  p.t_p=p.GetLmTailRing();
9828  }
9829 #endif
9830  strat->newt = TRUE;
9831  if (atT < 0)
9832  atT = strat->posInT(strat->T, strat->tl, p);
9833  if (strat->tl == strat->tmax-1)
9834  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9835  if (atT <= strat->tl)
9836  {
9837 #ifdef ENTER_USE_MEMMOVE
9838  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9839  (strat->tl-atT+1)*sizeof(TObject));
9840  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9841  (strat->tl-atT+1)*sizeof(unsigned long));
9842 #endif
9843  for (i=strat->tl+1; i>=atT+1; i--)
9844  {
9845 #ifndef ENTER_USE_MEMMOVE
9846  strat->T[i] = strat->T[i-1];
9847  strat->sevT[i] = strat->sevT[i-1];
9848 #endif
9849  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9850  }
9851  }
9852 
9853  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9854  {
9856  (strat->tailRing != NULL ?
9857  strat->tailRing : currRing),
9858  strat->tailBin);
9859  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9860  }
9861  strat->T[atT] = (TObject) p;
9862  //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9863 
9864  if (pNext(p.p) != NULL)
9865  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9866  else
9867  strat->T[atT].max_exp = NULL;
9868 
9869  strat->tl++;
9870  strat->R[strat->tl] = &(strat->T[atT]);
9871  strat->T[atT].i_r = strat->tl;
9872  assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9873  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9874  #if 1
9876  && !n_IsUnit(p.p->coef, currRing->cf))
9877  {
9878  for(i=strat->tl;i>=0;i--)
9879  {
9880  if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9881  {
9882  enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9883  }
9884  }
9885  }
9886  /*
9887  printf("\nThis is T:\n");
9888  for(i=strat->tl;i>=0;i--)
9889  {
9890  pWrite(strat->T[i].p);
9891  }
9892  //getchar();*/
9893  #endif
9894  kTest_T(&(strat->T[atT]));
9895 }
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:516
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1571
#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 13666 of file kutil.cc.

13667 {
13668  /* determine how many elements we have to insert */
13669  /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
13670  /* hence, a total number of elt's to add is: */
13671  /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
13672  pAssume(p.p != NULL);
13673 
13674  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
13675 
13676  for (int i = 1; i <= maxPossibleShift; i++)
13677  {
13678  LObject qq;
13679  qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
13680  qq.shift = i;
13681  strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
13682 
13683  enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13684  }
13685 }
#define pAssume(cond)
Definition: monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 10406 of file kutil.cc.

10407 {
10408  /*- release temp data -*/
10409  cleanT(strat);
10410  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10411  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10412  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10413  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10414  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10415  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10416  /*- set L: should be empty -*/
10417  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10418  /*- set B: should be empty -*/
10419  omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10420  pLmFree(&strat->tail);
10421  strat->syzComp=0;
10422 
10423 #ifdef HAVE_SHIFTBBA
10424  if (rIsLPRing(currRing) && strat->rightGB)
10425  {
10426  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10427  strat->fromQ=NULL;
10428  }
10429 #endif
10430 }
void * ADDRESS
Definition: auxiliary.h:119

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10607 of file kutil.cc.

10608 {
10609  /*- release temp data -*/
10611  cleanTSbaRing(strat);
10612  else
10613  cleanT(strat);
10614  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10615  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10616  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10617  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10618  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10619  omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10620  if(strat->syzmax>0)
10621  {
10622  omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10623  omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10624  if (strat->sbaOrder == 1)
10625  {
10626  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10627  }
10628  }
10629  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10630  /*- set L: should be empty -*/
10631  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10632  /*- set B: should be empty -*/
10633  omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10634  /*- set sig: no need for the signatures anymore -*/
10635  omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10636  pLmDelete(&strat->tail);
10637  strat->syzComp=0;
10638 }
int syzidxmax
Definition: kutil.h:348
intset syzIdx
Definition: kutil.h:310
unsigned sbaOrder
Definition: kutil.h:313
void cleanTSbaRing(kStrategy strat)
Definition: kutil.cc:604

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

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

◆ faugereRewCriterion()

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

Definition at line 7203 of file kutil.cc.

7204 {
7205  //printf("Faugere Rewritten Criterion\n");
7207  return FALSE;
7208 //#if 1
7209 #ifdef DEBUGF5
7210  PrintS("rewritten criterion checks: ");
7211  pWrite(sig);
7212 #endif
7213  for(int k = strat->sl; k>=start; k--)
7214  {
7215 //#if 1
7216 #ifdef DEBUGF5
7217  PrintS("checking with: ");
7218  pWrite(strat->sig[k]);
7219  pWrite(pHead(strat->S[k]));
7220 #endif
7221  if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
7222  {
7223 //#if 1
7224 #ifdef DEBUGF5
7225  PrintS("DELETE!\n");
7226 #endif
7227  strat->nrrewcrit++;
7228  return TRUE;
7229  }
7230  //k--;
7231  }
7232 #ifdef DEBUGF5
7233  PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
7234  for(int kk = 0; kk<strat->sl+1; kk++)
7235  {
7236  pWrite(pHead(strat->S[kk]));
7237  }
7238  PrintS("------------------------------\n");
7239 #endif
7240  return FALSE;
7241 }
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 11439 of file kutil.cc.

11440 {
11441  assume(strat->tl<0); /* can only be called with no elements in T:
11442  i.e. after exitBuchMora */
11443  /* do not use strat->S, strat->sl as they may be out of sync*/
11444  if(!nCoeff_is_Z(currRing->cf))
11445  return;
11446  poly p,pp;
11447  for(int j = 0; j<IDELEMS(strat->Shdl); j++)
11448  {
11449  if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
11450  {
11451  for(int i = 0; i<IDELEMS(strat->Shdl); i++)
11452  {
11453  if((i != j) && (strat->Shdl->m[i] != NULL))
11454  {
11455  p = strat->Shdl->m[i];
11456  while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
11457 #if HAVE_SHIFTBBA
11458  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
11459 #endif
11460  ))
11461  {
11462  number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
11463  if (!nEqual(dummy,p->coef))
11464  {
11465  if (nIsZero(dummy))
11466  {
11467  nDelete(&dummy);
11468  pLmDelete(&strat->Shdl->m[i]);
11469  p=strat->Shdl->m[i];
11470  }
11471  else
11472  {
11473  p_SetCoeff(p,dummy,currRing);
11474  break;
11475  }
11476  }
11477  else
11478  {
11479  nDelete(&dummy);
11480  break;
11481  }
11482  }
11483  if (p!=NULL)
11484  {
11485  pp = pNext(p);
11486  while(pp != NULL)
11487  {
11488  if(pLmDivisibleBy(strat->Shdl->m[j], pp)
11489 #if HAVE_SHIFTBBA
11490  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
11491 #endif
11492  )
11493  {
11494  number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
11495  if (!nEqual(dummy,pp->coef))
11496  {
11497  p_SetCoeff(pp,dummy,currRing);
11498  if(nIsZero(pp->coef))
11499  {
11500  pLmDelete(&pNext(p));
11501  pp = pNext(p);
11502  }
11503  else
11504  {
11505  p = pp;
11506  pp = pNext(p);
11507  }
11508  }
11509  else
11510  {
11511  nDelete(&dummy);
11512  p = pp;
11513  pp = pNext(p);
11514  }
11515  }
11516  else
11517  {
11518  p = pp;
11519  pp = pNext(p);
11520  }
11521  }
11522  }
11523  }
11524  }
11525  //idPrint(strat->Shdl);
11526  }
11527  }
11528  idSkipZeroes(strat->Shdl);
11529 }
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:840
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition: coeffs.h:629
#define nEqual(n1, n2)
Definition: numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
#define pLPLmDivisibleBy(a, b)
Definition: shiftop.h:58

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 475 of file kutil.cc.

476 {
477  int j,/*k,*/p;
478 
479  strat->kHEdgeFound=FALSE;
480  if (currRing->pLexOrder || rHasMixedOrdering(currRing))
481  {
482  return;
483  }
484  if (strat->ak > 1) /*we are in the module case*/
485  {
486  return; // until ....
487  //if (!pVectorOut) /*pVectorOut <=> order = c,* */
488  // return FALSE;
489  //if (pGetComp(pp) < strat->ak) /* ak is the number of the last component */
490  // return FALSE;
491  }
492  // k = 0;
493  p=pIsPurePower(pp);
494  if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(pp),currRing->cf))) return;
495  if (p!=0) strat->NotUsedAxis[p] = FALSE;
496  /*- the leading term of pp is a power of the p-th variable -*/
497  for (j=(currRing->N);j>0; j--)
498  {
499  if (strat->NotUsedAxis[j])
500  {
501  return;
502  }
503  }
504  strat->kHEdgeFound=TRUE;
505 }
BOOLEAN * NotUsedAxis
Definition: kutil.h:331
#define pIsPurePower(p)
Definition: polys.h:248
BOOLEAN rHasMixedOrdering(const ring r)
Definition: ring.h:766

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ ind2()

long ind2 ( long  arg)

Definition at line 4182 of file kutil.cc.

4183 {
4184  long ind = 0;
4185  if (arg <= 0) return 0;
4186  while (arg%2 == 0)
4187  {
4188  arg = arg / 2;
4189  ind++;
4190  }
4191  return ind;
4192 }

◆ ind_fact_2()

long ind_fact_2 ( long  arg)

Definition at line 4194 of file kutil.cc.

4195 {
4196  long ind = 0;
4197  if (arg <= 0) return 0;
4198  if (arg%2 == 1) { arg--; }
4199  while (arg > 0)
4200  {
4201  ind += ind2(arg);
4202  arg = arg - 2;
4203  }
4204  return ind;
4205 }
long ind2(long arg)
Definition: kutil.cc:4182

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1659 of file kstd1.cc.

1660 {
1661  /* setting global variables ------------------- */
1662  strat->enterS = enterSBba;
1663  strat->red = redHoney;
1664  if (strat->honey)
1665  strat->red = redHoney;
1666  else if (currRing->pLexOrder && !strat->homog)
1667  strat->red = redLazy;
1668  else
1669  {
1670  strat->LazyPass *=4;
1671  strat->red = redHomog;
1672  }
1673  if (rField_is_Ring(currRing))
1674  {
1675  if (rField_is_Z(currRing))
1676  strat->red = redRing_Z;
1677  else
1678  strat->red = redRing;
1679  }
1680  if (TEST_OPT_IDLIFT)
1681  strat->red=redLiftstd;
1682  if (currRing->pLexOrder && strat->honey)
1683  strat->initEcart = initEcartNormal;
1684  else
1685  strat->initEcart = initEcartBBA;
1686  if (strat->honey)
1688  else
1690 // if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1691 // {
1692 // //interred machen Aenderung
1693 // strat->pOrigFDeg=pFDeg;
1694 // strat->pOrigLDeg=pLDeg;
1695 // //h=ggetid("ecart");
1696 // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1697 // //{
1698 // // ecartWeights=iv2array(IDINTVEC(h));
1699 // //}
1700 // //else
1701 // {
1702 // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1703 // /*uses automatic computation of the ecartWeights to set them*/
1704 // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1705 // }
1706 // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1707 // if (TEST_OPT_PROT)
1708 // {
1709 // for(i=1; i<=(currRing->N); i++)
1710 // Print(" %d",ecartWeights[i]);
1711 // PrintLn();
1712 // mflush();
1713 // }
1714 // }
1715 }
int LazyPass
Definition: kutil.h:352
int redLiftstd(LObject *h, kStrategy strat)
Definition: kLiftstd.cc:161
int redRing_Z(LObject *h, kStrategy strat)
Definition: kstd2.cc:640
int redHoney(LObject *h, kStrategy strat)
Definition: kstd2.cc:1842
int redHomog(LObject *h, kStrategy strat)
Definition: kstd2.cc:902
int redLazy(LObject *h, kStrategy strat)
Definition: kstd2.cc:1648
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition: kutil.cc:1347
void initEcartNormal(TObject *h)
Definition: kutil.cc:1325
void initEcartBBA(TObject *h)
Definition: kutil.cc:1333
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition: kutil.cc:1340

◆ initBuchMora()

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

Definition at line 10322 of file kutil.cc.

10323 {
10324  strat->interpt = BTEST1(OPT_INTERRUPT);
10325  strat->kHEdge=NULL;
10327  /*- creating temp data structures------------------- -*/
10328  strat->cp = 0;
10329  strat->c3 = 0;
10330 #ifdef HAVE_SHIFTBBA
10331  strat->cv = 0;
10332 #endif
10333  strat->tail = pInit();
10334  /*- set s -*/
10335  strat->sl = -1;
10336  /*- set L -*/
10337  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10338  strat->Ll = -1;
10339  strat->L = initL(strat->Lmax);
10340  /*- set B -*/
10341  strat->Bmax = setmaxL;
10342  strat->Bl = -1;
10343  strat->B = initL();
10344  /*- set T -*/
10345  strat->tl = -1;
10346  strat->tmax = setmaxT;
10347  strat->T = initT();
10348  strat->R = initR();
10349  strat->sevT = initsevT();
10350  /*- init local data struct.---------------------------------------- -*/
10351  strat->P.ecart=0;
10352  strat->P.length=0;
10353  strat->P.pLength=0;
10355  {
10356  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10357  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10358  }
10360  {
10361  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10362  }
10363  else
10364  {
10365  if(TEST_OPT_SB_1)
10366  {
10367  int i;
10368  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10369  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10370  {
10371  P->m[i-strat->newIdeal] = F->m[i];
10372  F->m[i] = NULL;
10373  }
10374  initSSpecial(F,Q,P,strat);
10375  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10376  {
10377  F->m[i] = P->m[i-strat->newIdeal];
10378  P->m[i-strat->newIdeal] = NULL;
10379  }
10380  idDelete(&P);
10381  }
10382  else
10383  {
10384  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10385  // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
10386  }
10387  }
10388  strat->fromT = FALSE;
10390  if ((!TEST_OPT_SB_1)
10391  || (rField_is_Ring(currRing))
10392  )
10393  {
10394  updateS(TRUE,strat);
10395  }
10396 #ifdef HAVE_SHIFTBBA
10397  if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
10398 #endif
10399  {
10400  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10401  strat->fromQ=NULL;
10402  }
10403  assume(kTest_TS(strat));
10404 }
poly kNoether
Definition: kutil.h:327
poly kHEdge
Definition: kutil.h:326
int newIdeal
Definition: kutil.h:356
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
KINLINE unsigned long * initsevT()
Definition: kInline.h:100
KINLINE TSet initT()
Definition: kInline.h:84
KINLINE TObject ** initR()
Definition: kInline.h:95
void initSSpecial(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8652
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:9115
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8250
#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:78
#define BTEST1(a)
Definition: options.h:33
#define pSetComp(p, v)
Definition: polys.h:38

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9997 of file kutil.cc.

9998 {
10000  strat->chainCrit=chainCritNormal;
10001  if (TEST_OPT_SB_1)
10002  strat->chainCrit=chainCritOpt_1;
10003 #ifdef HAVE_RINGS
10004  if (rField_is_Ring(currRing))
10005  {
10007  strat->chainCrit=chainCritRing;
10008  }
10009 #endif
10010 #ifdef HAVE_RATGRING
10011  if (rIsRatGRing(currRing))
10012  {
10013  strat->chainCrit=chainCritPart;
10014  /* enterOnePairNormal get rational part in it */
10015  }
10016 #endif
10017  if (TEST_OPT_IDLIFT
10018  && (strat->syzComp==1)
10019  && (!rIsPluralRing(currRing)))
10021 
10022  strat->sugarCrit = TEST_OPT_SUGARCRIT;
10023  strat->Gebauer = strat->homog || strat->sugarCrit;
10024  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
10025  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
10026  strat->pairtest = NULL;
10027  /* alway use tailreduction, except:
10028  * - in local rings, - in lex order case, -in ring over extensions */
10030  //if(rHasMixedOrdering(currRing)==2)
10031  //{
10032  // strat->noTailReduction =TRUE;
10033  //}
10034 
10035 #ifdef HAVE_PLURAL
10036  // and r is plural_ring
10037  // hence this holds for r a rational_plural_ring
10038  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
10039  { //or it has non-quasi-comm type... later
10040  strat->sugarCrit = FALSE;
10041  strat->Gebauer = FALSE;
10042  strat->honey = FALSE;
10043  }
10044 #endif
10045 
10046  // Coefficient ring?
10047  if (rField_is_Ring(currRing))
10048  {
10049  strat->sugarCrit = FALSE;
10050  strat->Gebauer = FALSE ;
10051  strat->honey = FALSE;
10052  }
10053  #ifdef KDEBUG
10054  if (TEST_OPT_DEBUG)
10055  {
10056  if (strat->homog) PrintS("ideal/module is homogeneous\n");
10057  else PrintS("ideal/module is not homogeneous\n");
10058  }
10059  #endif
10060 }
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:288
char z2homog
Definition: kutil.h:374
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.h:287
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:1975
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3476
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1367
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2257
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3551
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3240
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:4027
static bool rIsSCA(const ring r)
Definition: nc.h:190
#define TEST_OPT_WEIGHTM
Definition: options.h:120
#define TEST_OPT_SUGARCRIT
Definition: options.h:106
#define TEST_OPT_NOT_SUGAR
Definition: options.h:105

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 10149 of file kutil.cc.

10150 {
10152  {
10153  if (strat->honey)
10154  {
10155  strat->posInL = posInL15;
10156  // ok -- here is the deal: from my experiments for Singular-2-0
10157  // I conclude that that posInT_EcartpLength is the best of
10158  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10159  // see the table at the end of this file
10160  if (TEST_OPT_OLDSTD)
10161  strat->posInT = posInT15;
10162  else
10163  strat->posInT = posInT_EcartpLength;
10164  }
10165  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10166  {
10167  strat->posInL = posInL11;
10168  strat->posInT = posInT11;
10169  }
10170  else if (TEST_OPT_INTSTRATEGY)
10171  {
10172  strat->posInL = posInL11;
10173  strat->posInT = posInT11;
10174  }
10175  else
10176  {
10177  strat->posInL = posInL0;
10178  strat->posInT = posInT0;
10179  }
10180  //if (strat->minim>0) strat->posInL =posInLSpecial;
10181  if (strat->homog)
10182  {
10183  strat->posInL = posInL110;
10184  strat->posInT = posInT110;
10185  }
10186  }
10187  else
10188  {
10189  if (strat->homog)
10190  {
10191  strat->posInL = posInL11;
10192  strat->posInT = posInT11;
10193  }
10194  else
10195  {
10196  if ((currRing->order[0]==ringorder_c)
10197  ||(currRing->order[0]==ringorder_C))
10198  {
10199  strat->posInL = posInL17_c;
10200  strat->posInT = posInT17_c;
10201  }
10202  else
10203  {
10204  strat->posInL = posInL17;
10205  strat->posInT = posInT17;
10206  }
10207  }
10208  }
10209  if (strat->minim>0) strat->posInL =posInLSpecial;
10210  // for further tests only
10211  if ((BTEST1(11)) || (BTEST1(12)))
10212  strat->posInL = posInL11;
10213  else if ((BTEST1(13)) || (BTEST1(14)))
10214  strat->posInL = posInL13;
10215  else if ((BTEST1(15)) || (BTEST1(16)))
10216  strat->posInL = posInL15;
10217  else if ((BTEST1(17)) || (BTEST1(18)))
10218  strat->posInL = posInL17;
10219  if (BTEST1(11))
10220  strat->posInT = posInT11;
10221  else if (BTEST1(13))
10222  strat->posInT = posInT13;
10223  else if (BTEST1(15))
10224  strat->posInT = posInT15;
10225  else if ((BTEST1(17)))
10226  strat->posInT = posInT17;
10227  else if ((BTEST1(19)))
10228  strat->posInT = posInT19;
10229  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10230  strat->posInT = posInT1;
10232 }
char posInLDependsOnLength
Definition: kutil.h:389
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6695
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5805
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5400
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5342
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5671
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:5331
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6783
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:10133
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5642
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6139
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6818
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5912
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5710
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6096
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6894
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5553
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:6039
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6988
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6397
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 10235 of file kutil.cc.

10236 {
10238  {
10239  if (strat->honey)
10240  {
10241  strat->posInL = posInL15Ring;
10242  // ok -- here is the deal: from my experiments for Singular-2-0
10243  // I conclude that that posInT_EcartpLength is the best of
10244  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10245  // see the table at the end of this file
10246  if (TEST_OPT_OLDSTD)
10247  strat->posInT = posInT15Ring;
10248  else
10249  strat->posInT = posInT_EcartpLength;
10250  }
10251  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10252  {
10253  strat->posInL = posInL11Ring;
10254  strat->posInT = posInT11;
10255  }
10256  else if (TEST_OPT_INTSTRATEGY)
10257  {
10258  strat->posInL = posInL11Ring;
10259  strat->posInT = posInT11;
10260  }
10261  else
10262  {
10263  strat->posInL = posInL0Ring;
10264  strat->posInT = posInT0;
10265  }
10266  //if (strat->minim>0) strat->posInL =posInLSpecial;
10267  if (strat->homog)
10268  {
10269  strat->posInL = posInL110Ring;
10270  strat->posInT = posInT110Ring;
10271  }
10272  }
10273  else
10274  {
10275  if (strat->homog)
10276  {
10277  //printf("\nHere 3\n");
10278  strat->posInL = posInL11Ring;
10279  strat->posInT = posInT11Ring;
10280  }
10281  else
10282  {
10283  if ((currRing->order[0]==ringorder_c)
10284  ||(currRing->order[0]==ringorder_C))
10285  {
10286  strat->posInL = posInL17_cRing;
10287  strat->posInT = posInT17_cRing;
10288  }
10289  else
10290  {
10291  strat->posInL = posInL11Ringls;
10292  strat->posInT = posInT17Ring;
10293  }
10294  }
10295  }
10296  if (strat->minim>0) strat->posInL =posInLSpecial;
10297  // for further tests only
10298  if ((BTEST1(11)) || (BTEST1(12)))
10299  strat->posInL = posInL11Ring;
10300  else if ((BTEST1(13)) || (BTEST1(14)))
10301  strat->posInL = posInL13;
10302  else if ((BTEST1(15)) || (BTEST1(16)))
10303  strat->posInL = posInL15Ring;
10304  else if ((BTEST1(17)) || (BTEST1(18)))
10305  strat->posInL = posInL17Ring;
10306  if (BTEST1(11))
10307  strat->posInT = posInT11Ring;
10308  else if (BTEST1(13))
10309  strat->posInT = posInT13;
10310  else if (BTEST1(15))
10311  strat->posInT = posInT15Ring;
10312  else if ((BTEST1(17)))
10313  strat->posInT = posInT17Ring;
10314  else if ((BTEST1(19)))
10315  strat->posInT = posInT19;
10316  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10317  strat->posInT = posInT1;
10319 }
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6938
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:7052
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6439
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5595
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6736
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6165
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5436
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6509
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6853
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5764
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5866
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5973

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1333 of file kutil.cc.

1334 {
1335  h->FDeg = h->pFDeg();
1336  (*h).ecart = 0;
1337  h->length=h->pLength=pLength(h->p);
1338 }

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1325 of file kutil.cc.

1326 {
1327  h->FDeg = h->pFDeg();
1328  h->ecart = h->pLDeg() - h->FDeg;
1329  // h->length is set by h->pLDeg
1330  h->length=h->pLength=pLength(h->p);
1331 }

◆ initEcartPairBba()

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

Definition at line 1340 of file kutil.cc.

1341 {
1342  Lp->FDeg = Lp->pFDeg();
1343  (*Lp).ecart = 0;
1344  (*Lp).length = 0;
1345 }

◆ initEcartPairMora()

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

Definition at line 1347 of file kutil.cc.

1348 {
1349  Lp->FDeg = Lp->pFDeg();
1350  (*Lp).ecart = si_max(ecartF,ecartG);
1351  (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1352  (*Lp).length = 0;
1353 }
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:380

◆ initenterpairs()

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

Definition at line 3840 of file kutil.cc.

3841 {
3842 
3843  if ((strat->syzComp==0)
3844  || (pGetComp(h)<=strat->syzComp))
3845  {
3846  int j;
3847  BOOLEAN new_pair=FALSE;
3848 
3849  if (pGetComp(h)==0)
3850  {
3851  /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3852  if ((isFromQ)&&(strat->fromQ!=NULL))
3853  {
3854  for (j=0; j<=k; j++)
3855  {
3856  if (!strat->fromQ[j])
3857  {
3858  new_pair=TRUE;
3859  strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3860  //Print("j:%d, Ll:%d\n",j,strat->Ll);
3861  }
3862  }
3863  }
3864  else
3865  {
3866  new_pair=TRUE;
3867  for (j=0; j<=k; j++)
3868  {
3869  strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3870  //Print("j:%d, Ll:%d\n",j,strat->Ll);
3871  }
3872  }
3873  }
3874  else
3875  {
3876  for (j=0; j<=k; j++)
3877  {
3878  if ((pGetComp(h)==pGetComp(strat->S[j]))
3879  || (pGetComp(strat->S[j])==0))
3880  {
3881  new_pair=TRUE;
3882  strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3883  //Print("j:%d, Ll:%d\n",j,strat->Ll);
3884  }
3885  }
3886  }
3887  if (new_pair)
3888  {
3889  #ifdef HAVE_RATGRING
3890  if (currRing->real_var_start>0)
3891  chainCritPart(h,ecart,strat);
3892  else
3893  #endif
3894  strat->chainCrit(h,ecart,strat);
3895  }
3896  kMergeBintoL(strat);
3897  }
3898 }

◆ initHilbCrit()

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

Definition at line 9979 of file kutil.cc.

9980 {
9981 
9982  //if the ordering is local, then hilb criterion
9983  //can be used also if the ideal is not homogenous
9985  {
9987  *hilb=NULL;
9988  else
9989  return;
9990  }
9991  if (strat->homog!=isHomog)
9992  {
9993  *hilb=NULL;
9994  }
9995 }
@ isHomog
Definition: structs.h:42

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

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

8157 {
8158  int i,pos;
8159 
8160  if (Q!=NULL) i=((IDELEMS(F)+IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8161  else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8162  strat->ecartS=initec(i);
8163  strat->sevS=initsevS(i);
8164  strat->S_2_R=initS_2_R(i);
8165  strat->fromQ=NULL;
8166  strat->Shdl=idInit(i,F->rank);
8167  strat->S=strat->Shdl->m;
8168  /*- put polys into S -*/
8169  if (Q!=NULL)
8170  {
8171  strat->fromQ=initec(i);
8172  memset(strat->fromQ,0,i*sizeof(int));
8173  for (i=0; i<IDELEMS(Q); i++)
8174  {
8175  if (Q->m[i]!=NULL)
8176  {
8177  LObject h;
8178  h.p = pCopy(Q->m[i]);
8180  {
8181  h.pCleardenom(); // also does remove Content
8182  }
8183  else
8184  {
8185  h.pNorm();
8186  }
8188  {
8189  deleteHC(&h, strat);
8190  }
8191  if (h.p!=NULL)
8192  {
8193  strat->initEcart(&h);
8194  if (strat->sl==-1)
8195  pos =0;
8196  else
8197  {
8198  pos = posInS(strat,strat->sl,h.p,h.ecart);
8199  }
8200  h.sev = pGetShortExpVector(h.p);
8201  strat->enterS(h,pos,strat,-1);
8202  strat->fromQ[pos]=1;
8203  }
8204  }
8205  }
8206  }
8207  for (i=0; i<IDELEMS(F); i++)
8208  {
8209  if (F->m[i]!=NULL)
8210  {
8211  LObject h;
8212  h.p = pCopy(F->m[i]);
8214  {
8215  cancelunit(&h); /*- tries to cancel a unit -*/
8216  deleteHC(&h, strat);
8217  }
8218  if (h.p!=NULL)
8219  // do not rely on the input being a SB!
8220  {
8222  {
8223  h.pCleardenom(); // also does remove Content
8224  }
8225  else
8226  {
8227  h.pNorm();
8228  }
8229  strat->initEcart(&h);
8230  if (strat->sl==-1)
8231  pos =0;
8232  else
8233  pos = posInS(strat,strat->sl,h.p,h.ecart);
8234  h.sev = pGetShortExpVector(h.p);
8235  strat->enterS(h,pos,strat,-1);
8236  }
8237  }
8238  }
8239  /*- test, if a unit is in F -*/
8240  if ((strat->sl>=0)
8241 #ifdef HAVE_RINGS
8242  && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
8243 #endif
8244  && pIsConstant(strat->S[0]))
8245  {
8246  while (strat->sl>0) deleteInS(strat->sl,strat);
8247  }
8248 }
static intset initec(const int maxnr)
Definition: kutil.cc:510
static unsigned long * initsevS(const int maxnr)
Definition: kutil.cc:515
static int * initS_2_R(const int maxnr)
Definition: kutil.cc:519
#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 1717 of file kstd1.cc.

1718 {
1719  int i;
1720  //idhdl h;
1721  /* setting global variables ------------------- */
1722  strat->enterS = enterSSba;
1723  strat->red2 = redHoney;
1724  if (strat->honey)
1725  strat->red2 = redHoney;
1726  else if (currRing->pLexOrder && !strat->homog)
1727  strat->red2 = redLazy;
1728  else
1729  {
1730  strat->LazyPass *=4;
1731  strat->red2 = redHomog;
1732  }
1733  if (rField_is_Ring(currRing))
1734  {
1736  {strat->red2 = redRiloc;}
1737  else
1738  {strat->red2 = redRing;}
1739  }
1740  if (currRing->pLexOrder && strat->honey)
1741  strat->initEcart = initEcartNormal;
1742  else
1743  strat->initEcart = initEcartBBA;
1744  if (strat->honey)
1746  else
1748  //strat->kIdeal = NULL;
1749  //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1750  //else strat->kIdeal->rtyp=MODUL_CMD;
1751  //strat->kIdeal->data=(void *)strat->Shdl;
1752  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1753  {
1754  //interred machen Aenderung
1755  strat->pOrigFDeg = currRing->pFDeg;
1756  strat->pOrigLDeg = currRing->pLDeg;
1757  //h=ggetid("ecart");
1758  //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1759  //{
1760  // ecartWeights=iv2array(IDINTVEC(h));
1761  //}
1762  //else
1763  {
1764  ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1765  /*uses automatic computation of the ecartWeights to set them*/
1767  }
1769  if (TEST_OPT_PROT)
1770  {
1771  for(i=1; i<=(currRing->N); i++)
1772  Print(" %d",ecartWeights[i]);
1773  PrintLn();
1774  mflush();
1775  }
1776  }
1777  // for sig-safe reductions in signature-based
1778  // standard basis computations
1780  strat->red = redSigRing;
1781  else
1782  strat->red = redSig;
1783  //strat->sbaOrder = 1;
1784  strat->currIdx = 1;
1785 }
pFDegProc pOrigFDeg
Definition: kutil.h:293
pLDegProc pOrigLDeg
Definition: kutil.h:294
int redRiloc(LObject *h, kStrategy strat)
Definition: kstd1.cc:383
int redSigRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:1278
int redSig(LObject *h, kStrategy strat)
Definition: kstd2.cc:1111
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9473
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3719
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 10534 of file kutil.cc.

10535 {
10536  strat->interpt = BTEST1(OPT_INTERRUPT);
10537  strat->kHEdge=NULL;
10539  /*- creating temp data structures------------------- -*/
10540  strat->cp = 0;
10541  strat->c3 = 0;
10542  strat->tail = pInit();
10543  /*- set s -*/
10544  strat->sl = -1;
10545  /*- set ps -*/
10546  strat->syzl = -1;
10547  /*- set L -*/
10548  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10549  strat->Ll = -1;
10550  strat->L = initL(strat->Lmax);
10551  /*- set B -*/
10552  strat->Bmax = setmaxL;
10553  strat->Bl = -1;
10554  strat->B = initL();
10555  /*- set T -*/
10556  strat->tl = -1;
10557  strat->tmax = setmaxT;
10558  strat->T = initT();
10559  strat->R = initR();
10560  strat->sevT = initsevT();
10561  /*- init local data struct.---------------------------------------- -*/
10562  strat->P.ecart=0;
10563  strat->P.length=0;
10565  {
10566  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10567  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10568  }
10570  {
10571  /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10572  }
10573  else
10574  {
10575  if(TEST_OPT_SB_1)
10576  {
10577  int i;
10578  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10579  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10580  {
10581  P->m[i-strat->newIdeal] = F->m[i];
10582  F->m[i] = NULL;
10583  }
10584  initSSpecialSba(F,Q,P,strat);
10585  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10586  {
10587  F->m[i] = P->m[i-strat->newIdeal];
10588  P->m[i-strat->newIdeal] = NULL;
10589  }
10590  idDelete(&P);
10591  }
10592  else
10593  {
10594  initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10595  }
10596  }
10597  strat->fromT = FALSE;
10598  if (!TEST_OPT_SB_1)
10599  {
10600  if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10601  }
10602  //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10603  //strat->fromQ=NULL;
10604  assume(kTest_TS(strat));
10605 }
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8347
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8796

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 10062 of file kutil.cc.

10063 {
10064  //strat->enterOnePair=enterOnePairNormal;
10066  //strat->chainCrit=chainCritNormal;
10067  strat->chainCrit = chainCritSig;
10068  /******************************************
10069  * rewCrit1 and rewCrit2 are already set in
10070  * kSba() in kstd1.cc
10071  *****************************************/
10072  //strat->rewCrit1 = faugereRewCriterion;
10073  if (strat->sbaOrder == 1)
10074  {
10075  strat->syzCrit = syzCriterionInc;
10076  }
10077  else
10078  {
10079  strat->syzCrit = syzCriterion;
10080  }
10081 #ifdef HAVE_RINGS
10082  if (rField_is_Ring(currRing))
10083  {
10085  strat->chainCrit=chainCritRing;
10086  }
10087 #endif
10088 #ifdef HAVE_RATGRING
10089  if (rIsRatGRing(currRing))
10090  {
10091  strat->chainCrit=chainCritPart;
10092  /* enterOnePairNormal get rational part in it */
10093  }
10094 #endif
10095 
10096  strat->sugarCrit = TEST_OPT_SUGARCRIT;
10097  strat->Gebauer = strat->homog || strat->sugarCrit;
10098  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
10099  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
10100  strat->pairtest = NULL;
10101  /* alway use tailreduction, except:
10102  * - in local rings, - in lex order case, -in ring over extensions */
10105 
10106 #ifdef HAVE_PLURAL
10107  // and r is plural_ring
10108  // hence this holds for r a rational_plural_ring
10109  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
10110  { //or it has non-quasi-comm type... later
10111  strat->sugarCrit = FALSE;
10112  strat->Gebauer = FALSE;
10113  strat->honey = FALSE;
10114  }
10115 #endif
10116 
10117  // Coefficient ring?
10118  if (rField_is_Ring(currRing))
10119  {
10120  strat->sugarCrit = FALSE;
10121  strat->Gebauer = FALSE ;
10122  strat->honey = FALSE;
10123  }
10124  #ifdef KDEBUG
10125  if (TEST_OPT_DEBUG)
10126  {
10127  if (strat->homog) PrintS("ideal/module is homogeneous\n");
10128  else PrintS("ideal/module is not homogeneous\n");
10129  }
10130  #endif
10131 }
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.h:289
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:7154
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3492
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:7119

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 10432 of file kutil.cc.

10433 {
10435  {
10436  if (strat->honey)
10437  {
10438  strat->posInL = posInL15;
10439  // ok -- here is the deal: from my experiments for Singular-2-0
10440  // I conclude that that posInT_EcartpLength is the best of
10441  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10442  // see the table at the end of this file
10443  if (TEST_OPT_OLDSTD)
10444  strat->posInT = posInT15;
10445  else
10446  strat->posInT = posInT_EcartpLength;
10447  }
10448  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10449  {
10450  strat->posInL = posInL11;
10451  strat->posInT = posInT11;
10452  }
10453  else if (TEST_OPT_INTSTRATEGY)
10454  {
10455  strat->posInL = posInL11;
10456  strat->posInT = posInT11;
10457  }
10458  else
10459  {
10460  strat->posInL = posInL0;
10461  strat->posInT = posInT0;
10462  }
10463  //if (strat->minim>0) strat->posInL =posInLSpecial;
10464  if (strat->homog)
10465  {
10466  strat->posInL = posInL110;
10467  strat->posInT = posInT110;
10468  }
10469  }
10470  else
10471  {
10472  if (strat->homog)
10473  {
10474  strat->posInL = posInL11;
10475  strat->posInT = posInT11;
10476  }
10477  else
10478  {
10479  if ((currRing->order[0]==ringorder_c)
10480  ||(currRing->order[0]==ringorder_C))
10481  {
10482  strat->posInL = posInL17_c;
10483  strat->posInT = posInT17_c;
10484  }
10485  else
10486  {
10487  strat->posInL = posInL17;
10488  strat->posInT = posInT17;
10489  }
10490  }
10491  }
10492  if (strat->minim>0) strat->posInL =posInLSpecial;
10493  // for further tests only
10494  if ((BTEST1(11)) || (BTEST1(12)))
10495  strat->posInL = posInL11;
10496  else if ((BTEST1(13)) || (BTEST1(14)))
10497  strat->posInL = posInL13;
10498  else if ((BTEST1(15)) || (BTEST1(16)))
10499  strat->posInL = posInL15;
10500  else if ((BTEST1(17)) || (BTEST1(18)))
10501  strat->posInL = posInL17;
10502  if (BTEST1(11))
10503  strat->posInT = posInT11;
10504  else if (BTEST1(13))
10505  strat->posInT = posInT13;
10506  else if (BTEST1(15))
10507  strat->posInT = posInT15;
10508  else if ((BTEST1(17)))
10509  strat->posInT = posInT17;
10510  else if ((BTEST1(19)))
10511  strat->posInT = posInT19;
10512  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10513  strat->posInT = posInT1;
10514  if (rField_is_Ring(currRing))
10515  {
10516  strat->posInL = posInL11Ring;
10517  if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
10518  strat->posInL = posInL11Ringls;
10519  strat->posInT = posInT11;
10520  }
10521  strat->posInLDependsOnLength = FALSE;
10522  strat->posInLSba = posInLSig;
10523  //strat->posInL = posInLSig;
10524  strat->posInL = posInLF5C;
10525  /*
10526  if (rField_is_Ring(currRing))
10527  {
10528  strat->posInLSba = posInLSigRing;
10529  strat->posInL = posInL11Ring;
10530  }*/
10531  //strat->posInT = posInTSig;
10532 }
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6197
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:6385

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

8251 {
8252  int i,pos;
8253 
8254  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8255  else i=setmaxT;
8256  strat->ecartS=initec(i);
8257  strat->sevS=initsevS(i);
8258  strat->S_2_R=initS_2_R(i);
8259  strat->fromQ=NULL;
8260  strat->Shdl=idInit(i,F->rank);
8261  strat->S=strat->Shdl->m;
8262  /*- put polys into S -*/
8263  if (Q!=NULL)
8264  {
8265  strat->fromQ=initec(i);
8266  memset(strat->fromQ,0,i*sizeof(int));
8267  for (i=0; i<IDELEMS(Q); i++)
8268  {
8269  if (Q->m[i]!=NULL)
8270  {
8271  LObject h;
8272  h.p = pCopy(Q->m[i]);
8274  {
8275  deleteHC(&h,strat);
8276  }
8278  {
8279  h.pCleardenom(); // also does remove Content
8280  }
8281  else
8282  {
8283  h.pNorm();
8284  }
8285  if (h.p!=NULL)
8286  {
8287  strat->initEcart(&h);
8288  if (strat->sl==-1)
8289  pos =0;
8290  else
8291  {
8292  pos = posInS(strat,strat->sl,h.p,h.ecart);
8293  }
8294  h.sev = pGetShortExpVector(h.p);
8295  strat->enterS(h,pos,strat,-1);
8296  strat->fromQ[pos]=1;
8297  }
8298  }
8299  }
8300  }
8301  for (i=0; i<IDELEMS(F); i++)
8302  {
8303  if (F->m[i]!=NULL)
8304  {
8305  LObject h;
8306  h.p = pCopy(F->m[i]);
8307  if (h.p!=NULL)
8308  {
8310  {
8311  cancelunit(&h); /*- tries to cancel a unit -*/
8312  deleteHC(&h, strat);
8313  }
8314  if (h.p!=NULL)
8315  {
8317  {
8318  h.pCleardenom(); // also does remove Content
8319  }
8320  else
8321  {
8322  h.pNorm();
8323  }
8324  strat->initEcart(&h);
8325  if (strat->Ll==-1)
8326  pos =0;
8327  else
8328  pos = strat->posInL(strat->L,strat->Ll,&h,strat);
8329  h.sev = pGetShortExpVector(h.p);
8330  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8331  }
8332  }
8333  }
8334  }
8335  /*- test, if a unit is in F -*/
8336 
8337  if ((strat->Ll>=0)
8338 #ifdef HAVE_RINGS
8339  && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8340 #endif
8341  && pIsConstant(strat->L[strat->Ll].p))
8342  {
8343  while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8344  }
8345 }

◆ initSLSba()

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

Definition at line 8347 of file kutil.cc.

8348 {
8349  int i,pos;
8350  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8351  else i=setmaxT;
8352  strat->ecartS = initec(i);
8353  strat->sevS = initsevS(i);
8354  strat->sevSig = initsevS(i);
8355  strat->S_2_R = initS_2_R(i);
8356  strat->fromQ = NULL;
8357  strat->Shdl = idInit(i,F->rank);
8358  strat->S = strat->Shdl->m;
8359  strat->sig = (poly *)omAlloc0(i*sizeof(poly));
8360  if (strat->sbaOrder != 1)
8361  {
8362  strat->syz = (poly *)omAlloc0(i*sizeof(poly));
8363  strat->sevSyz = initsevS(i);
8364  strat->syzmax = i;
8365  strat->syzl = 0;
8366  }
8367  /*- put polys into S -*/
8368  if (Q!=NULL)
8369  {
8370  strat->fromQ=initec(i);
8371  memset(strat->fromQ,0,i*sizeof(int));
8372  for (i=0; i<IDELEMS(Q); i++)
8373  {
8374  if (Q->m[i]!=NULL)
8375  {
8376  LObject h;
8377  h.p = pCopy(Q->m[i]);
8379  {
8380  deleteHC(&h,strat);
8381  }
8383  {
8384  h.pCleardenom(); // also does remove Content
8385  }
8386  else
8387  {
8388  h.pNorm();
8389  }
8390  if (h.p!=NULL)
8391  {
8392  strat->initEcart(&h);
8393  if (strat->sl==-1)
8394  pos =0;
8395  else
8396  {
8397  pos = posInS(strat,strat->sl,h.p,h.ecart);
8398  }
8399  h.sev = pGetShortExpVector(h.p);
8400  strat->enterS(h,pos,strat,-1);
8401  strat->fromQ[pos]=1;
8402  }
8403  }
8404  }
8405  }
8406  for (i=0; i<IDELEMS(F); i++)
8407  {
8408  if (F->m[i]!=NULL)
8409  {
8410  LObject h;
8411  h.p = pCopy(F->m[i]);
8412  h.sig = pOne();
8413  //h.sig = pInit();
8414  //p_SetCoeff(h.sig,nInit(1),currRing);
8415  p_SetComp(h.sig,i+1,currRing);
8416  // if we are working with the Schreyer order we generate it
8417  // by multiplying the initial signatures with the leading monomial
8418  // of the corresponding initial polynomials generating the ideal
8419  // => we can keep the underlying monomial order and get a Schreyer
8420  // order without any bigger overhead
8421  if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
8422  {
8423  p_ExpVectorAdd (h.sig,F->m[i],currRing);
8424  }
8425  h.sevSig = pGetShortExpVector(h.sig);
8426 #ifdef DEBUGF5
8427  pWrite(h.p);
8428  pWrite(h.sig);
8429 #endif
8430  if (h.p!=NULL)
8431  {
8433  {
8434  cancelunit(&h); /*- tries to cancel a unit -*/
8435  deleteHC(&h, strat);
8436  }
8437  if (h.p!=NULL)
8438  {
8440  {
8441  h.pCleardenom(); // also does remove Content
8442  }
8443  else
8444  {
8445  h.pNorm();
8446  }
8447  strat->initEcart(&h);
8448  if (strat->Ll==-1)
8449  pos =0;
8450  else
8451  pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
8452  h.sev = pGetShortExpVector(h.p);
8453  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8454  }
8455  }
8456  /*
8457  if (strat->sbaOrder != 1)
8458  {
8459  for(j=0;j<i;j++)
8460  {
8461  strat->syz[ctr] = pCopy(F->m[j]);
8462  p_SetCompP(strat->syz[ctr],i+1,currRing);
8463  // add LM(F->m[i]) to the signature to get a Schreyer order
8464  // without changing the underlying polynomial ring at all
8465  p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
8466  // since p_Add_q() destroys all input
8467  // data we need to recreate help
8468  // each time
8469  poly help = pCopy(F->m[i]);
8470  p_SetCompP(help,j+1,currRing);
8471  pWrite(strat->syz[ctr]);
8472  pWrite(help);
8473  printf("%d\n",pLmCmp(strat->syz[ctr],help));
8474  strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
8475  printf("%d. SYZ ",ctr);
8476  pWrite(strat->syz[ctr]);
8477  strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
8478  ctr++;
8479  }
8480  strat->syzl = ps;
8481  }
8482  */
8483  }
8484  }
8485  /*- test, if a unit is in F -*/
8486 
8487  if ((strat->Ll>=0)
8488 #ifdef HAVE_RINGS
8489  && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8490 #endif
8491  && pIsConstant(strat->L[strat->Ll].p))
8492  {
8493  while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8494  }
8495 }
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1371

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8497 of file kutil.cc.

8498 {
8499  if( strat->S[0] )
8500  {
8501  if( strat->S[1] && !rField_is_Ring(currRing))
8502  {
8503  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
8504  omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
8505  omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
8506  }
8507  int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
8508  /************************************************************
8509  * computing the length of the syzygy array needed
8510  ***********************************************************/
8511  for(i=1; i<=strat->sl; i++)
8512  {
8513  if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8514  {
8515  ps += i;
8516  }
8517  }
8518  ps += strat->sl+1;
8519  //comp = pGetComp (strat->P.sig);
8520  comp = strat->currIdx;
8521  strat->syzIdx = initec(comp);
8522  strat->sevSyz = initsevS(ps);
8523  strat->syz = (poly *)omAlloc(ps*sizeof(poly));
8524  strat->syzmax = ps;
8525  strat->syzl = 0;
8526  strat->syzidxmax = comp;
8527 #if defined(DEBUGF5) || defined(DEBUGF51)
8528  PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
8529 #endif
8530  i = 1;
8531  j = 0;
8532  /************************************************************
8533  * generating the leading terms of the principal syzygies
8534  ***********************************************************/
8535  while (i <= strat->sl)
8536  {
8537  /**********************************************************
8538  * principal syzygies start with component index 2
8539  * the array syzIdx starts with index 0
8540  * => the rules for a signature with component comp start
8541  * at strat->syz[strat->syzIdx[comp-2]] !
8542  *********************************************************/
8543  if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8544  {
8545  comp = pGetComp(strat->sig[i]);
8546  comp_old = pGetComp(strat->sig[i-1]);
8547  diff = comp - comp_old - 1;
8548  // diff should be zero, but sometimes also the initial generating
8549  // elements of the input ideal reduce to zero. then there is an
8550  // index-gap between the signatures. for these inbetween signatures we
8551  // can safely set syzIdx[j] = 0 as no such element will be ever computed
8552  // in the following.
8553  // doing this, we keep the relation "j = comp - 2" alive, which makes
8554  // jumps way easier when checking criteria
8555  while (diff>0)
8556  {
8557  strat->syzIdx[j] = 0;
8558  diff--;
8559  j++;
8560  }
8561  strat->syzIdx[j] = ctr;
8562  j++;
8563  LObject Q;
8564  int pos;
8565  for (k = 0; k<i; k++)
8566  {
8567  Q.sig = pOne();
8569  p_SetCoeff(Q.sig,nCopy(p_GetCoeff(strat->S[k],currRing)),currRing);
8570  p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8571  p_SetCompP (Q.sig, comp, currRing);
8572  poly q = p_One(currRing);
8575  p_ExpVectorCopy(q,strat->S[i],currRing);
8576  q = p_Neg (q, currRing);
8577  p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8578  Q.sig = p_Add_q (Q.sig, q, currRing);
8579  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8580  pos = posInSyz(strat, Q.sig);
8581  enterSyz(Q, strat, pos);
8582  ctr++;
8583  }
8584  }
8585  i++;
8586  }
8587  /**************************************************************
8588  * add syzygies for upcoming first element of new iteration step
8589  **************************************************************/
8590  comp = strat->currIdx;
8591  comp_old = pGetComp(strat->sig[i-1]);
8592  diff = comp - comp_old - 1;
8593  // diff should be zero, but sometimes also the initial generating
8594  // elements of the input ideal reduce to zero. then there is an
8595  // index-gap between the signatures. for these inbetween signatures we
8596  // can safely set syzIdx[j] = 0 as no such element will be ever computed
8597  // in the following.
8598  // doing this, we keep the relation "j = comp - 2" alive, which makes
8599  // jumps way easier when checking criteria
8600  while (diff>0)
8601  {
8602  strat->syzIdx[j] = 0;
8603  diff--;
8604  j++;
8605  }
8606  strat->syzIdx[j] = ctr;
8607  LObject Q;
8608  int pos;
8609  for (k = 0; k<strat->sl+1; k++)
8610  {
8611  Q.sig = pOne();
8613  p_SetCoeff(Q.sig,nCopy(p_GetCoeff(strat->S[k],currRing)),currRing);
8614  p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8615  p_SetCompP (Q.sig, comp, currRing);
8616  poly q = p_One(currRing);
8618  p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8619  p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8620  q = p_Neg (q, currRing);
8621  p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8622  Q.sig = p_Add_q (Q.sig, q, currRing);
8623  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8624  pos = posInSyz(strat, Q.sig);
8625  enterSyz(Q, strat, pos);
8626  ctr++;
8627  }
8628 //#if 1
8629 #ifdef DEBUGF5
8630  PrintS("Principal syzygies:\n");
8631  Print("syzl %d\n",strat->syzl);
8632  Print("syzmax %d\n",strat->syzmax);
8633  Print("ps %d\n",ps);
8634  PrintS("--------------------------------\n");
8635  for(i=0;i<=strat->syzl-1;i++)
8636  {
8637  Print("%d - ",i);
8638  pWrite(strat->syz[i]);
8639  }
8640  for(i=0;i<strat->currIdx;i++)
8641  {
8642  Print("%d - %d\n",i,strat->syzIdx[i]);
8643  }
8644  PrintS("--------------------------------\n");
8645 #endif
8646  }
8647 }
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9901
int posInSyz(const kStrategy strat, poly sig)
Definition: kutil.cc:6357
#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:4807
poly p_One(const ring r)
Definition: p_polys.cc:1308
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1067
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:896
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition: p_polys.h:1273
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

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

988 {
989  p_LmCheckPolyRing(p1, p_r);
990  p_LmCheckPolyRing(p2, p_r);
991 
992  int i;
993  long x;
994  m1 = p_Init(m_r,m_r->PolyBin);
995  m2 = p_Init(m_r,m_r->PolyBin);
996 
997  for (i = p_r->N; i; i--)
998  {
999  x = p_GetExpDiff(p1, p2, i, p_r);
1000  if (x > 0)
1001  {
1002  if (x > (long) m_r->bitmask) goto false_return;
1003  p_SetExp(m2,i,x, m_r);
1004  p_SetExp(m1,i,0, m_r);
1005  }
1006  else
1007  {
1008  if (-x > (long) m_r->bitmask) goto false_return;
1009  p_SetExp(m1,i,-x, m_r);
1010  p_SetExp(m2,i,0, m_r);
1011  }
1012  }
1013 
1014  p_Setm(m1, m_r);
1015  p_Setm(m2, m_r);
1016  return TRUE;
1017 
1018  false_return:
1019  p_LmFree(m1, m_r);
1020  p_LmFree(m2, m_r);
1021  m1 = m2 = NULL;
1022  return FALSE;
1023 }
Variable x
Definition: cfModGcd.cc:4084
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:635
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:118
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1280

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

1031 {
1032  p_LmCheckPolyRing(p1, leadRing);
1033  p_LmCheckPolyRing(p2, leadRing);
1034 
1035  int i;
1036  int x;
1037  int e1;
1038  int e2;
1039  int s;
1040  m1 = p_Init(tailRing,tailRing->PolyBin);
1041  m2 = p_Init(tailRing,tailRing->PolyBin);
1042  lcm = p_Init(leadRing,leadRing->PolyBin);
1043 
1044  for (i = leadRing->N; i>=0; i--)
1045  {
1046  e1 = p_GetExp(p1,i,leadRing);
1047  e2 = p_GetExp(p2,i,leadRing);
1048  x = e1 - e2;
1049  if (x > 0)
1050  {
1051  p_SetExp(m2,i,x, tailRing);
1052  //p_SetExp(m1,i,0, tailRing); // done by p_Init
1053  s = e1;
1054  }
1055  else if (x<0)
1056  {
1057  p_SetExp(m1,i,-x, tailRing);
1058  //p_SetExp(m2,i,0, tailRing); // done by p_Init
1059  s = e2;
1060  }
1061  else
1062  s = e1; // e1==e2
1063  p_SetExp(lcm,i,s, leadRing);
1064  }
1065 
1066  p_Setm(m1, tailRing);
1067  p_Setm(m2, tailRing);
1068  p_Setm(lcm, leadRing);
1069 }
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 959 of file kInline.h.

960 {
961  return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
962 }

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 927 of file kInline.h.

928 {
929 
930  poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
931  pNext(t_p) = pNext(p);
932  pSetCoeff0(t_p, pGetCoeff(p));
933  return t_p;
934 }
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1295

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 964 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 936 of file kInline.h.

937 {
938  poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
939  pNext(p) = pNext(t_p);
940  pSetCoeff0(p, pGetCoeff(t_p));
941  return p;
942 }

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 969 of file kInline.h.

970 {
971  return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
972 }
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:945

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 945 of file kInline.h.

946 {
947  poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
948  p_LmFree(p, currRing);
949  return np;
950 }

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 974 of file kInline.h.

975 {
976  return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
977 }
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:952

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 952 of file kInline.h.

953 {
954  poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
955  p_LmFree(p, tailRing);
956  return np;
957 }

◆ kCheckSpolyCreation()

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

Definition at line 11045 of file kutil.cc.

11046 {
11047  if (strat->overflow) return FALSE;
11048  assume(L->p1 != NULL && L->p2 != NULL);
11049  // shift changes: from 0 to -1
11050  assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
11051  assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
11052 
11053  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
11054  return FALSE;
11055  // shift changes: extra case inserted
11056  if ((L->i_r1 == -1) || (L->i_r2 == -1) )
11057  {
11058  return TRUE;
11059  }
11060  poly p1_max=NULL;
11061  if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
11062  poly p2_max=NULL;
11063  if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
11064 
11065  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
11066  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
11067  {
11068  p_LmFree(m1, strat->tailRing);
11069  p_LmFree(m2, strat->tailRing);
11070  m1 = NULL;
11071  m2 = NULL;
11072  return FALSE;
11073  }
11074  return TRUE;
11075 }
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:986
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:2007

◆ kCheckStrongCreation()

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

Definition at line 11084 of file kutil.cc.

11085 {
11086  assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
11087  //assume(strat->tailRing != currRing);
11088 
11089  poly p1_max = (strat->R[atR])->max_exp;
11090  poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
11091 
11092  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
11093  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
11094  {
11095  return FALSE;
11096  }
11097  return TRUE;
11098 }

◆ kCreateZeroPoly()

poly kCreateZeroPoly ( long  exp[],
long  cabsind,
poly *  t_p,
ring  leadRing,
ring  tailRing 
)

Definition at line 4398 of file kutil.cc.

4399 {
4400 
4401  poly zeroPoly = NULL;
4402 
4403  number tmp1;
4404  poly tmp2, tmp3;
4405 
4406  if (cabsind == -1)
4407  {
4408  cabsind = 0;
4409  for (int i = 1; i <= leadRing->N; i++)
4410  {
4411  cabsind += ind_fact_2(exp[i]);
4412  }
4413 // Print("cabsind: %d\n", cabsind);
4414  }
4415  if (cabsind < leadRing->ch)
4416  {
4417  zeroPoly = p_ISet(twoPow(leadRing->ch - cabsind), tailRing);
4418  }
4419  else
4420  {
4421  zeroPoly = p_ISet(1, tailRing);
4422  }
4423  for (int i = 1; i <= leadRing->N; i++)
4424  {
4425  for (long j = 1; j <= exp[i]; j++)
4426  {
4427  tmp1 = nInit(j);
4428  tmp2 = p_ISet(1, tailRing);
4429  p_SetExp(tmp2, i, 1, tailRing);
4430  p_Setm(tmp2, tailRing);
4431  if (nIsZero(tmp1))
4432  { // should nowbe obsolet, test ! TODO OLIVER
4433  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
4434  }
4435  else
4436  {
4437  tmp3 = p_NSet(nCopy(tmp1), tailRing);
4438  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
4439  }
4440  }
4441  }
4442  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
4443  for (int i = 1; i <= leadRing->N; i++)
4444  {
4445  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
4446  }
4447  p_Setm(tmp2, leadRing);
4448  *t_p = zeroPoly;
4449  zeroPoly = pNext(zeroPoly);
4450  pNext(*t_p) = NULL;
4451  pNext(tmp2) = zeroPoly;
4452  return tmp2;
4453 }
CFList tmp1
Definition: facFqBivar.cc:72
CFList tmp2
Definition: facFqBivar.cc:72
long ind_fact_2(long arg)
Definition: kutil.cc:4194
long twoPow(long arg)
Definition: kutil.cc:4209
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1292
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1460
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1074

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 12080 of file kutil.cc.

12081 {
12082  PrintS("red: ");
12083  if (strat->red==redFirst) PrintS("redFirst\n");
12084  else if (strat->red==redHoney) PrintS("redHoney\n");
12085  else if (strat->red==redEcart) PrintS("redEcart\n");
12086  else if (strat->red==redHomog) PrintS("redHomog\n");
12087  else if (strat->red==redLazy) PrintS("redLazy\n");
12088  else if (strat->red==redLiftstd) PrintS("redLiftstd\n");
12089  else Print("%p\n",(void*)strat->red);
12090  PrintS("posInT: ");
12091  if (strat->posInT==posInT0) PrintS("posInT0\n");
12092  else if (strat->posInT==posInT1) PrintS("posInT1\n");
12093  else if (strat->posInT==posInT11) PrintS("posInT11\n");
12094  else if (strat->posInT==posInT110) PrintS("posInT110\n");
12095  else if (strat->posInT==posInT13) PrintS("posInT13\n");
12096  else if (strat->posInT==posInT15) PrintS("posInT15\n");
12097  else if (strat->posInT==posInT17) PrintS("posInT17\n");
12098  else if (strat->posInT==posInT17_c) PrintS("posInT17_c\n");
12099  else if (strat->posInT==posInT19) PrintS("posInT19\n");
12100  else if (strat->posInT==posInT2) PrintS("posInT2\n");
12101  #ifdef HAVE_RINGS
12102  else if (strat->posInT==posInT11Ring) PrintS("posInT11Ring\n");
12103  else if (strat->posInT==posInT110Ring) PrintS("posInT110Ring\n");
12104  else if (strat->posInT==posInT15Ring) PrintS("posInT15Ring\n");
12105  else if (strat->posInT==posInT17Ring) PrintS("posInT17Ring\n");
12106  else if (strat->posInT==posInT17_cRing) PrintS("posInT17_cRing\n");
12107  #endif
12108 #ifdef HAVE_MORE_POS_IN_T
12109  else if (strat->posInT==posInT_EcartFDegpLength) PrintS("posInT_EcartFDegpLength\n");
12110  else if (strat->posInT==posInT_FDegpLength) PrintS("posInT_FDegpLength\n");
12111  else if (strat->posInT==posInT_pLength) PrintS("posInT_pLength\n");
12112 #endif
12113  else if (strat->posInT==posInT_EcartpLength) PrintS("posInT_EcartpLength\n");
12114  else if (strat->posInT==posInTrg0) PrintS("posInTrg0\n");
12115  else Print("%p\n",(void*)strat->posInT);
12116  PrintS("posInL: ");
12117  if (strat->posInL==posInL0) PrintS("posInL0\n");
12118  else if (strat->posInL==posInL10) PrintS("posInL10\n");
12119  else if (strat->posInL==posInL11) PrintS("posInL11\n");
12120  else if (strat->posInL==posInL110) PrintS("posInL110\n");
12121  else if (strat->posInL==posInL13) PrintS("posInL13\n");
12122  else if (strat->posInL==posInL15) PrintS("posInL15\n");
12123  else if (strat->posInL==posInL17) PrintS("posInL17\n");
12124  else if (strat->posInL==posInL17_c) PrintS("posInL17_c\n");
12125  #ifdef HAVE_RINGS
12126  else if (strat->posInL==posInL0) PrintS("posInL0Ring\n");
12127  else if (strat->posInL==posInL11Ring) PrintS("posInL11Ring\n");
12128  else if (strat->posInL==posInL11Ringls) PrintS("posInL11Ringls\n");
12129  else if (strat->posInL==posInL110Ring) PrintS("posInL110Ring\n");
12130  else if (strat->posInL==posInL15Ring) PrintS("posInL15Ring\n");
12131  else if (strat->posInL==posInL17Ring) PrintS("posInL17Ring\n");
12132  else if (strat->posInL==posInL17_cRing) PrintS("posInL17_cRing\n");
12133  #endif
12134  else if (strat->posInL==posInLSpecial) PrintS("posInLSpecial\n");
12135  else if (strat->posInL==posInLrg0) PrintS("posInLrg0\n");
12136  else Print("%p\n",(void*)strat->posInL);
12137  PrintS("enterS: ");
12138  if (strat->enterS==enterSBba) PrintS("enterSBba\n");
12139  else if (strat->enterS==enterSMora) PrintS("enterSMora\n");
12140  else if (strat->enterS==enterSMoraNF) PrintS("enterSMoraNF\n");
12141  else Print("%p\n",(void*)strat->enterS);
12142  PrintS("initEcart: ");
12143  if (strat->initEcart==initEcartBBA) PrintS("initEcartBBA\n");
12144  else if (strat->initEcart==initEcartNormal) PrintS("initEcartNormal\n");
12145  else Print("%p\n",(void*)strat->initEcart);
12146  PrintS("initEcartPair: ");
12147  if (strat->initEcartPair==initEcartPairBba) PrintS("initEcartPairBba\n");
12148  else if (strat->initEcartPair==initEcartPairMora) PrintS("initEcartPairMora\n");
12149  else Print("%p\n",(void*)strat->initEcartPair);
12150  Print("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
12151  strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
12152  Print("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
12153  strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
12154  PrintS("chainCrit: ");
12155  if (strat->chainCrit==chainCritNormal) PrintS("chainCritNormal\n");
12156  else if (strat->chainCrit==chainCritOpt_1) PrintS("chainCritOpt_1\n");
12157  else Print("%p\n",(void*)strat->chainCrit);
12158  Print("posInLDependsOnLength=%d\n",
12159  strat->posInLDependsOnLength);
12160  PrintS(showOption());PrintLn();
12161  PrintS("LDeg: ");
12162  if (currRing->pLDeg==pLDeg0) PrintS("pLDeg0");
12163  else if (currRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
12164  else if (currRing->pLDeg==pLDegb) PrintS("pLDegb");
12165  else if (currRing->pLDeg==pLDeg1) PrintS("pLDeg1");
12166  else if (currRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
12167  else if (currRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
12168  else if (currRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
12169  else if (currRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
12170  else if (currRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
12171  else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
12172  else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
12173  else if (currRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
12174  else Print("? (%lx)", (long)currRing->pLDeg);
12175  PrintS(" / ");
12176  if (strat->tailRing->pLDeg==pLDeg0) PrintS("pLDeg0");
12177  else if (strat->tailRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
12178  else if (strat->tailRing->pLDeg==pLDegb) PrintS("pLDegb");
12179  else if (strat->tailRing->pLDeg==pLDeg1) PrintS("pLDeg1");
12180  else if (strat->tailRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
12181  else if (strat->tailRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
12182  else if (strat->tailRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
12183  else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
12184  else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
12185  else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
12186  else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
12187  else if (strat->tailRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
12188  else Print("? (%lx)", (long)strat->tailRing->pLDeg);
12189  PrintLn();
12190  PrintS("currRing->pFDeg: ");
12191  if (currRing->pFDeg==p_Totaldegree) PrintS("p_Totaldegree");
12192  else if (currRing->pFDeg==p_WFirstTotalDegree) PrintS("pWFirstTotalDegree");
12193  else if (currRing->pFDeg==p_Deg) PrintS("p_Deg");
12194  else if (currRing->pFDeg==kHomModDeg) PrintS("kHomModDeg");
12195  else if (currRing->pFDeg==totaldegreeWecart) PrintS("totaldegreeWecart");
12196  else if (currRing->pFDeg==p_WTotaldegree) PrintS("p_WTotaldegree");
12197  else Print("? (%lx)", (long)currRing->pFDeg);
12198  PrintLn();
12199  Print(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
12200  if(TEST_OPT_DEGBOUND)
12201  Print(" degBound: %d\n", Kstd1_deg);
12202 
12203  if( ecartWeights != NULL )
12204  {
12205  PrintS("ecartWeights: ");
12206  for (int i = rVar(currRing); i > 0; i--)
12207  Print("%hd ", ecartWeights[i]);
12208  PrintLn();
12210  }
12211 
12212 #ifndef SING_NDEBUG
12214 #endif
12215 }
int LazyDegree
Definition: kutil.h:352
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1331
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2406
int posInTrg0(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5477
int redFirst(LObject *h, kStrategy strat)
Definition: kstd1.cc:784
int redEcart(LObject *h, kStrategy strat)
Definition: kstd1.cc:169
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1649
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5370
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:12046
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11955
VAR int Kstd1_deg
Definition: kutil.cc:247
char * showOption()
Definition: misc_ip.cc:721
int posInLrg0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6611
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1595
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:12009
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:806
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:970
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:591
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1033
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1063
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:936
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:836
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:905
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:608
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:872
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1000
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:765
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:734
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:582
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1467
void rDebugPrint(const ring r)
Definition: ring.cc:4075
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:728

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 877 of file kutil.h.

878 {
879  if (P->lcm!=NULL)
880  {
881  #ifdef HAVE_RINGS
883  pLmDelete(P->lcm);
884  else
885  #endif
886  pLmFree(P->lcm);
887  P->lcm=NULL;
888  }
889 }

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 7338 of file kutil.cc.

7339 {
7340  int j = 0;
7341  const unsigned long not_sev = ~L->sev;
7342  const unsigned long* sev = strat->sevS;
7343  poly p;
7344  ring r;
7345  L->GetLm(p, r);
7346 
7347  assume(~not_sev == p_GetShortExpVector(p, r));
7348 
7349  if (r == currRing)
7350  {
7351  if(!rField_is_Ring(r))
7352  {
7353  loop
7354  {
7355  if (j > end_pos) return NULL;
7356  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7357  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7358  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7359  {
7360  break;
7361  }
7362  #else
7363  if (!(sev[j] & not_sev) &&
7364  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7365  p_LmDivisibleBy(strat->S[j], p, r))
7366  {
7367  break;
7368  }
7369  #endif
7370  j++;
7371  }
7372  }
7373  #ifdef HAVE_RINGS
7374  else
7375  {
7376  loop
7377  {
7378  if (j > end_pos) return NULL;
7379  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7380  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7381  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7382  {
7383  break;
7384  }
7385  #else
7386  if (!(sev[j] & not_sev) &&
7387  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7388  p_LmDivisibleBy(strat->S[j], p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7389  {
7390  break;
7391  }
7392  #endif
7393  j++;
7394  }
7395  }
7396  #endif
7397  // if called from NF, T objects do not exist:
7398  if (strat->tl < 0 || strat->S_2_R[j] == -1)
7399  {
7400  T->Set(strat->S[j], r, strat->tailRing);
7401  assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
7402  return T;
7403  }
7404  else
7405  {
7406 ///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
7407 ///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
7408 // assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
7409  return strat->S_2_T(j);
7410  }
7411  }
7412  else
7413  {
7414  TObject* t;
7415  if(!rField_is_Ring(r))
7416  {
7417  loop
7418  {
7419  if (j > end_pos) return NULL;
7420  assume(strat->S_2_R[j] != -1);
7421  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7422  t = strat->S_2_T(j);
7423  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7424  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7425  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7426  {
7427  t->pLength=pLength(t->t_p);
7428  return t;
7429  }
7430  #else
7431  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7432  {
7433  t = strat->S_2_T(j);
7434  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7435  if (p_LmDivisibleBy(t->t_p, p, r))
7436  {
7437  t->pLength=pLength(t->t_p);
7438  return t;
7439  }
7440  }
7441  #endif
7442  j++;
7443  }
7444  }
7445  #ifdef HAVE_RINGS
7446  else
7447  {
7448  loop
7449  {
7450  if (j > end_pos) return NULL;
7451  assume(strat->S_2_R[j] != -1);
7452  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7453  t = strat->S_2_T(j);
7454  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7455  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7456  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7457  {
7458  t->pLength=pLength(t->t_p);
7459  return t;
7460  }
7461  #else
7462  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7463  {
7464  t = strat->S_2_T(j);
7465  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7466  if (p_LmDivisibleBy(t->t_p, p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7467  {
7468  t->pLength=pLength(t->t_p);
7469  return t;
7470  }
7471  }
7472  #endif
7473  j++;
7474  }
7475  }
7476  #endif
7477  }
7478 }
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 288 of file kstd2.cc.

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

◆ kFindDivisibleByInT_Z()

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

Definition at line 207 of file kstd2.cc.

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

◆ kFindInT()

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

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

Definition at line 718 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 743 of file kutil.cc.

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

◆ kFindNextDivisibleByInS()

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

Definition at line 467 of file kstd2.cc.

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

◆ kFindSameLMInT_Z()

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

Definition at line 84 of file kstd2.cc.

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

◆ kFindZeroPoly()

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

Definition at line 526 of file kstd2.cc.

527 {
528  // m = currRing->ch
529 
530  if (input_p == NULL) return NULL;
531 
532  poly p = input_p;
533  poly zeroPoly = NULL;
534  unsigned long a = (unsigned long) pGetCoeff(p);
535 
536  int k_ind2 = 0;
537  int a_ind2 = ind2(a);
538 
539  // unsigned long k = 1;
540  // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
541  for (int i = 1; i <= leadRing->N; i++)
542  {
543  k_ind2 = k_ind2 + ind_fact_2(p_GetExp(p, i, leadRing));
544  }
545 
546  a = (unsigned long) pGetCoeff(p);
547 
548  number tmp1;
549  poly tmp2, tmp3;
550  poly lead_mult = p_ISet(1, tailRing);
551  if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
552  {
553  int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf);
554  int s_exp;
555  zeroPoly = p_ISet(a, tailRing);
556  for (int i = 1; i <= leadRing->N; i++)
557  {
558  s_exp = p_GetExp(p, i,leadRing);
559  if (s_exp % 2 != 0)
560  {
561  s_exp = s_exp - 1;
562  }
563  while ( (0 < ind2(s_exp)) && (ind2(s_exp) <= too_much) )
564  {
565  too_much = too_much - ind2(s_exp);
566  s_exp = s_exp - 2;
567  }
568  p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
569  for (int j = 1; j <= s_exp; j++)
570  {
571  tmp1 = nInit(j);
572  tmp2 = p_ISet(1, tailRing);
573  p_SetExp(tmp2, i, 1, tailRing);
574  p_Setm(tmp2, tailRing);
575  if (nIsZero(tmp1))
576  { // should nowbe obsolet, test ! TODO OLIVER
577  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
578  }
579  else
580  {
581  tmp3 = p_NSet(nCopy(tmp1), tailRing);
582  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
583  }
584  }
585  }
586  p_Setm(lead_mult, tailRing);
587  zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing);
588  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
589  for (int i = 1; i <= leadRing->N; i++)
590  {
591  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
592  }
593  p_Setm(tmp2, leadRing);
594  zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
595  pNext(tmp2) = zeroPoly;
596  return tmp2;
597  }
598 /* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
599  if (1 == 0 && alpha_k <= a)
600  { // Temporarly disabled, reducing coefficients not compatible with std TODO Oliver
601  zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
602  for (int i = 1; i <= leadRing->N; i++)
603  {
604  for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
605  {
606  tmp1 = nInit(j);
607  tmp2 = p_ISet(1, tailRing);
608  p_SetExp(tmp2, i, 1, tailRing);
609  p_Setm(tmp2, tailRing);
610  if (nIsZero(tmp1))
611  {
612  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
613  }
614  else
615  {
616  tmp3 = p_ISet((unsigned long) tmp1, tailRing);
617  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
618  }
619  }
620  }
621  tmp2 = p_ISet((unsigned long) 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  return NULL;
632 }
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1011
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:725

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3860 of file kstd2.cc.

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

◆ kNF2() [2/2]

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

Definition at line 3712 of file kstd2.cc.

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

◆ kNF2Bound() [1/2]

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

Definition at line 3944 of file kstd2.cc.

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

◆ kNF2Bound() [2/2]

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

Definition at line 3790 of file kstd2.cc.

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

◆ ksCreateShortSpoly()

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

Definition at line 1415 of file kspoly.cc.

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

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

1170 {
1171 #ifdef KDEBUG
1172  create_count++;
1173 #endif
1174  kTest_L(Pair,tailRing);
1175  poly p1 = Pair->p1;
1176  poly p2 = Pair->p2;
1177  Pair->tailRing = tailRing;
1178 
1179  assume(p1 != NULL);
1180  assume(p2 != NULL);
1181  assume(tailRing != NULL);
1182 
1183  poly a1 = pNext(p1), a2 = pNext(p2);
1184  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
1185  int co=0/*, ct = ksCheckCoeff(&lc1, &lc2, currRing->cf)*/; // gcd and zero divisors
1186  (void) ksCheckCoeff(&lc1, &lc2, currRing->cf);
1187 
1188  int l1=0, l2=0;
1189 
1190  if (currRing->pCompIndex >= 0)
1191  {
1192  if (__p_GetComp(p1, currRing)!=__p_GetComp(p2, currRing))
1193  {
1194  if (__p_GetComp(p1, currRing)==0)
1195  {
1196  co=1;
1197  p_SetCompP(p1,__p_GetComp(p2, currRing), currRing, tailRing);
1198  }
1199  else
1200  {
1201  co=2;
1202  p_SetCompP(p2, __p_GetComp(p1, currRing), currRing, tailRing);
1203  }
1204  }
1205  }
1206 
1207  // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
1208  // m2 = LCM(LM(p1), LM(p2))/LM(p2)
1209  if (m1 == NULL)
1210  k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing);
1211 
1212 #ifdef HAVE_SHIFTBBA
1213  poly m12, m22;
1214  if (tailRing->isLPring)
1215  {
1216  assume(p_mFirstVblock(p1, tailRing) <= 1 || p_mFirstVblock(p2, tailRing) <= 1);
1217  k_SplitFrame(m1, m12, si_max(p_mFirstVblock(p1, tailRing), 1), tailRing);
1218  k_SplitFrame(m2, m22, si_max(p_mFirstVblock(p2, tailRing), 1), tailRing);
1219  // manually free the coeffs, because pSetCoeff0 is used in the next step
1220  n_Delete(&(m1->coef), tailRing->cf);
1221  n_Delete(&(m2->coef), tailRing->cf);
1222  }
1223 #endif
1224 
1225  pSetCoeff0(m1, lc2);
1226  pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2)
1227 
1228  if (R != NULL)
1229  {
1230  if (Pair->i_r1 == -1)
1231  {
1232  l1 = pLength(p1) - 1;
1233  }
1234  else
1235  {
1236  l1 = (R[Pair->i_r1])->GetpLength() - 1;
1237  }
1238  if ((Pair->i_r2 == -1)||(R[Pair->i_r2]==NULL))
1239  {
1240  l2 = pLength(p2) - 1;
1241  }
1242  else
1243  {
1244  l2 = (R[Pair->i_r2])->GetpLength() - 1;
1245  }
1246  }
1247 
1248  // get m2 * a2
1249  if (spNoether != NULL)
1250  {
1251  l2 = -1;
1252  a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1253  assume(l2 == pLength(a2));
1254  }
1255  else
1256 #ifdef HAVE_SHIFTBBA
1257  if (tailRing->isLPring)
1258  {
1259  // m2*a2*m22
1260  a2 = tailRing->p_Procs->pp_Mult_mm(tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing), m22, tailRing);
1261  }
1262  else
1263 #endif
1264  {
1265  a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1266  }
1267 #ifdef HAVE_RINGS
1268  if (!(rField_is_Domain(currRing))) l2 = pLength(a2);
1269 #endif
1270 
1271  Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1272 
1273 #ifdef HAVE_SHIFTBBA
1274  if (tailRing->isLPring)
1275  {
1276  // get m2*a2*m22 - m1*a1*m12
1277  Pair->Tail_Minus_mm_Mult_qq(m1, tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing), l1, spNoether);
1278  }
1279  else
1280 #endif
1281  {
1282  // get m2*a2 - m1*a1
1283  Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1284  }
1285 
1286  // Clean-up time
1287  Pair->LmDeleteAndIter();
1288  p_LmDelete(m1, tailRing);
1289 #ifdef HAVE_SHIFTBBA
1290  if (tailRing->isLPring)
1291  {
1292  // just to be sure, check that the shift is correct
1293  assume(Pair->shift == 0);
1294  assume(si_max(p_mFirstVblock(Pair->p, tailRing) - 1, 0) == Pair->shift); // == 0
1295 
1296  p_LmDelete(m12, tailRing);
1297  p_LmDelete(m22, tailRing);
1298  // m2 is already deleted
1299  }
1300 #endif
1301 
1302  if (co != 0)
1303  {
1304  if (co==1)
1305  {
1306  p_SetCompP(p1,0, currRing, tailRing);
1307  }
1308  else
1309  {
1310  p_SetCompP(p2,0, currRing, tailRing);
1311  }
1312  }
1313 }
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
VAR int create_count
Definition: kspoly.cc:28
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:711
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:492
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)
Definition: shiftop.cc:597
#define R
Definition: sirandom.c:27

◆ ksOldCreateSpoly()

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

Definition at line 1162 of file kInline.h.

1163 {
1164  LObject L(r);
1165  L.p1 = p1;
1166  L.p2 = p2;
1167 
1168  ksCreateSpoly(&L, spNoether);
1169  return L.GetLmCurrRing();
1170 }

◆ ksOldSpolyRed()

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

Definition at line 1142 of file kInline.h.

1143 {
1144  LObject L(p2);
1145  TObject T(p1);
1146 
1147  ksReducePoly(&L, &T, spNoether);
1148 
1149  return L.GetLmCurrRing();
1150 }
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat)
Definition: kspoly.cc:185

◆ ksOldSpolyRedNew()

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

Definition at line 1152 of file kInline.h.

1153 {
1154  LObject L(p_Copy(p2, currRing));
1155  TObject T(p1);
1156 
1157  ksReducePoly(&L, &T, spNoether);
1158 
1159  return L.GetLmCurrRing();
1160 }

◆ ksOldSpolyTail()

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

Definition at line 1172 of file kInline.h.

1173 {
1174  LObject L(q, currRing, r);
1175  TObject T(p1, currRing, r);
1176 
1177  ksReducePolyTail(&L, &T, q2, spNoether);
1178 }
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1115

◆ ksReducePoly()

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

Definition at line 185 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 563 of file kspoly.cc.

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

◆ ksReducePolyGCD()

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

Definition at line 316 of file kspoly.cc.

321 {
322 #ifdef KDEBUG
323  red_count++;
324 #ifdef TEST_OPT_DEBUG_RED
325 // if (TEST_OPT_DEBUG)
326 // {
327 // Print("Red %d:", red_count); PR->wrp(); Print(" with:");
328 // PW->wrp();
329 // //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
330 // //pWrite(PR->p);
331 // }
332 #endif
333 #endif
334  int ret = 0;
335  ring tailRing = PR->tailRing;
336  kTest_L(PR, tailRing);
337  kTest_T(PW);
338 
339  poly p1 = PR->GetLmTailRing();
340  poly p2 = PW->GetLmTailRing();
341  poly t2 = pNext(p2), lm = pOne();
342  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
343  p_CheckPolyRing(p1, tailRing);
344  p_CheckPolyRing(p2, tailRing);
345 
346  pAssume1(p2 != NULL && p1 != NULL &&
347  p_DivisibleBy(p2, p1, tailRing));
348 
349  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
350  (p_GetComp(p2, tailRing) == 0 &&
351  p_MaxComp(pNext(p2),tailRing) == 0));
352 
353 #ifdef HAVE_PLURAL
354  if (rIsPluralRing(currRing))
355  {
356  // for the time being: we know currRing==strat->tailRing
357  // no exp-bound checking needed
358  // (only needed if exp-bound(tailring)<exp-b(currRing))
359  if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef);
360  else
361  {
362  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
363  assume(_p != NULL);
364  nc_PolyPolyRed(_p, p2,coef, currRing);
365  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
366  PR->pLength=0; // usually not used, GetpLength re-computes it if needed
367  }
368  return 0;
369  }
370 #endif
371  // check that reduction does not violate exp bound
372  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
373  {
374  // undo changes of lm
375  p_ExpVectorAdd(lm, p2, tailRing);
376  if (strat == NULL) return 2;
377  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
378  tailRing = strat->tailRing;
379  p1 = PR->GetLmTailRing();
380  p2 = PW->GetLmTailRing();
381  t2 = pNext(p2);
382  lm = p1;
383  p_ExpVectorSub(lm, p2, tailRing);
384  ret = 1;
385  }
386 
387 #ifdef HAVE_SHIFTBBA
388  poly lmRight;
389  if (tailRing->isLPring)
390  {
391  assume(PR->shift == 0);
392  assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
393  k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
394  }
395 #endif
396 
397  number ct, an, bn;
398  // take care of coef buisness
399  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
400  {
401  ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing->cf); // Calculate GCD
402 #ifdef HAVE_SHIFTBBA
403  if(rIsLPRing(tailRing)) /* with this test: error at New/stdZtests.tst, infinite : Long/primdecint.tst */
404  {
405  if (n_IsZero(an, tailRing->cf) || n_IsZero(bn, tailRing->cf))
406  {
407  // NOTE: not sure why this is not checked in the commutative case, this *does* happen and then zero coeff errors are reported
408  // NOTE: we are probably leaking memory of lm=pOne(), but we cannot delete it since it could also be lm=p1
409  n_Delete(&an, tailRing->cf);
410  n_Delete(&bn, tailRing->cf);
411  n_Delete(&ct, tailRing->cf);
412  return ret;
413  }
414  }
415 #endif
416  /* negate bn since we subtract in Tail_Minus_mm_Mult_qq */
417  bn = n_InpNeg(bn, tailRing->cf);
418  p_SetCoeff(lm, bn, tailRing);
419  PR->Tail_Mult_nn(an);
420  }
421  else
422  {
423  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
424  }
425 
426 
427  // and finally,
428 #ifdef HAVE_SHIFTBBA
429  if (tailRing->isLPring)
430  {
431  PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
432  }
433  else
434 #endif
435  {
436  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
437  }
438  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
439  pSetCoeff(PR->p, ct);
440 
441  return ret;
442 }
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
static FORCE_INLINE 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:694

◆ ksReducePolyLC()

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

Definition at line 452 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 707 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 910 of file kspoly.cc.

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

1116 {
1117  BOOLEAN ret;
1118  number coef;
1119 
1120  assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1121  Red->HeadNormalize();
1122  ret = ksReducePoly(Red, PW, NULL, &coef);
1123 
1124  if (!ret)
1125  {
1126  if (! n_IsOne(coef, currRing->cf))
1127  {
1128  PR->Mult_nn(coef);
1129  // HANNES: mark for Normalize
1130  }
1131  n_Delete(&coef, currRing->cf);
1132  }
1133  return ret;
1134 }

◆ ksReducePolyTail() [2/2]

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

Definition at line 1315 of file kspoly.cc.

1316 {
1317  BOOLEAN ret;
1318  number coef;
1319  poly Lp = PR->GetLmCurrRing();
1320  poly Save = PW->GetLmCurrRing();
1321 
1322  kTest_L(PR,PR->tailRing);
1323  kTest_T(PW);
1324  pAssume(pIsMonomOf(Lp, Current));
1325 
1326  assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
1327  assume(PR->bucket == NULL);
1328 
1329  LObject Red(pNext(Current), PR->tailRing);
1330  TObject With(PW, Lp == Save);
1331 
1332  pAssume(!pHaveCommonMonoms(Red.p, With.p));
1333  ret = ksReducePoly(&Red, &With, spNoether, &coef);
1334 
1335  if (!ret)
1336  {
1337  if (! n_IsOne(coef, currRing->cf))
1338  {
1339  pNext(Current) = NULL;
1340  if (Current == PR->p && PR->t_p != NULL)
1341  pNext(PR->t_p) = NULL;
1342  PR->Mult_nn(coef);
1343  }
1344 
1345  n_Delete(&coef, currRing->cf);
1346  pNext(Current) = Red.GetLmTailRing();
1347  if (Current == PR->p && PR->t_p != NULL)
1348  pNext(PR->t_p) = pNext(Current);
1349  }
1350 
1351  if (Lp == Save)
1352  With.Delete();
1353 
1354  return ret;
1355 }
BOOLEAN pIsMonomOf(poly p, poly m)
Definition: pDebug.cc:163
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition: pDebug.cc:173

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

◆ kStratChangeTailRing()

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

Definition at line 11532 of file kutil.cc.

11533 {
11534  assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11535  /* initial setup or extending */
11536 
11537  if (rIsLPRing(currRing)) return TRUE;
11538  if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11539  if (expbound >= currRing->bitmask) return FALSE;
11540  strat->overflow=FALSE;
11541  ring new_tailRing = rModifyRing(currRing,
11542  // Hmmm .. the condition pFDeg == p_Deg
11543  // might be too strong
11544  (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11545  (strat->ak==0), // omit_comp if the input is an ideal
11546  expbound); // exp_limit
11547 
11548  if (new_tailRing == currRing) return TRUE;
11549 
11550  strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11551  strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11552 
11553  if (currRing->pFDeg != currRing->pFDegOrig)
11554  {
11555  new_tailRing->pFDeg = currRing->pFDeg;
11556  new_tailRing->pLDeg = currRing->pLDeg;
11557  }
11558 
11559  if (TEST_OPT_PROT)
11560  Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11561  kTest_TS(strat);
11562  assume(new_tailRing != strat->tailRing);
11563  pShallowCopyDeleteProc p_shallow_copy_delete
11564  = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11565 
11566  omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11567 
11568  int i;
11569  for (i=0; i<=strat->tl; i++)
11570  {
11571  strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11572  p_shallow_copy_delete);
11573  }
11574  for (i=0; i<=strat->Ll; i++)
11575  {
11576  assume(strat->L[i].p != NULL);
11577  if (pNext(strat->L[i].p) != strat->tail)
11578  strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11579  }
11580  if ((strat->P.t_p != NULL) ||
11581  ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11582  strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11583 
11584  if ((L != NULL) && (L->tailRing != new_tailRing))
11585  {
11586  if (L->i_r < 0)
11587  L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11588  else
11589  {
11590  assume(L->i_r <= strat->tl);
11591  TObject* t_l = strat->R[L->i_r];
11592  assume(t_l != NULL);
11593  L->tailRing = new_tailRing;
11594  L->p = t_l->p;
11595  L->t_p = t_l->t_p;
11596  L->max_exp = t_l->max_exp;
11597  }
11598  }
11599 
11600  if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11601  T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11602 
11603  omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11604  if (strat->tailRing != currRing)
11605  rKillModifiedRing(strat->tailRing);
11606 
11607  strat->tailRing = new_tailRing;
11608  strat->tailBin = new_tailBin;
11609  strat->p_shallow_copy_delete
11610  = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11611 
11612  if (strat->kHEdge != NULL)
11613  {
11614  if (strat->t_kHEdge != NULL)
11615  p_LmFree(strat->t_kHEdge, strat->tailRing);
11616  strat->t_kHEdge=k_LmInit_currRing_2_tailRing(strat->kHEdge, new_tailRing);
11617  }
11618 
11619  if (strat->kNoether != NULL)
11620  {
11621  if (strat->t_kNoether != NULL)
11622  p_LmFree(strat->t_kNoether, strat->tailRing);
11624  new_tailRing);
11625  }
11626  kTest_TS(strat);
11627  if (TEST_OPT_PROT)
11628  PrintS("]");
11629  return TRUE;
11630 }
poly t_kNoether
Definition: kutil.h:330
pFDegProc pOrigFDeg_TailRing
Definition: kutil.h:295
poly t_kHEdge
Definition: kutil.h:328
pLDegProc pOrigLDeg_TailRing
Definition: kutil.h:296
omBin_t * omBin
Definition: omStructs.h:12
void rKillModifiedRing(ring r)
Definition: ring.cc:3007
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2646
#define omGetStickyBinOfBin(B)
Definition: xalloc.h:294
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:323

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11632 of file kutil.cc.

11633 {
11634  unsigned long l = 0;
11635  int i;
11636  long e;
11637 
11638  assume(strat->tailRing == currRing);
11639 
11640  for (i=0; i<= strat->Ll; i++)
11641  {
11642  l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11643  }
11644  for (i=0; i<=strat->tl; i++)
11645  {
11646  // Hmm ... this we could do in one Step
11647  l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11648  }
11649  if (rField_is_Ring(currRing))
11650  {
11651  l *= 2;
11652  }
11653  e = p_GetMaxExp(l, currRing);
11654  if (e <= 1) e = 2;
11655  if (rIsLPRing(currRing)) e = 1;
11656 
11657  kStratChangeTailRing(strat, NULL, NULL, e);
11658 }
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:1170
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:747

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1010 of file kutil.cc.

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

◆ kTest_L()

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

Definition at line 925 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1053 of file kutil.cc.

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

◆ kTest_T()

BOOLEAN kTest_T ( TObject T,
ring  tailRing = NULL,
int  tpos = -1,
char  TN = '?' 
)

Definition at line 801 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1071 of file kutil.cc.

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

◆ kTestDivisibleByT0_Z()

int kTestDivisibleByT0_Z ( const kStrategy  strat,
const LObject L 
)

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

Definition at line 140 of file kstd2.cc.

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

◆ message()

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

Definition at line 8033 of file kutil.cc.

8034 {
8035  if (i != *olddeg)
8036  {
8037  Print("%d",i);
8038  *olddeg = i;
8039  }
8040  if (TEST_OPT_OLDSTD)
8041  {
8042  if (strat->Ll != *reduc)
8043  {
8044  if (strat->Ll != *reduc-1)
8045  Print("(%d)",strat->Ll+1);
8046  else
8047  PrintS("-");
8048  *reduc = strat->Ll;
8049  }
8050  else
8051  PrintS(".");
8052  mflush();
8053  }
8054  else
8055  {
8056  if (red_result == 0)
8057  PrintS("-");
8058  else if (red_result < 0)
8059  PrintS(".");
8060  if ((red_result > 0) || ((strat->Ll % 100)==99))
8061  {
8062  if (strat->Ll != *reduc && strat->Ll > 0)
8063  {
8064  Print("(%d)",strat->Ll+1);
8065  *reduc = strat->Ll;
8066  }
8067  }
8068  }
8069 }

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 8106 of file kutil.cc.

8107 {
8108  int i;
8109  if (strat->news)
8110  {
8111  PrintS("set S");
8112  for (i=0; i<=strat->sl; i++)
8113  {
8114  Print("\n %d:",i);
8115  p_wrp(strat->S[i], currRing, strat->tailRing);
8116  if (strat->fromQ!=NULL && strat->fromQ[i])
8117  Print(" (from Q)");
8118  }
8119  strat->news = FALSE;
8120  }
8121  if (strat->newt)
8122  {
8123  PrintS("\nset T");
8124  for (i=0; i<=strat->tl; i++)
8125  {
8126  Print("\n %d:",i);
8127  strat->T[i].wrp();
8128  if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
8129  Print(" o:%ld e:%d l:%d",
8130  strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
8131  }
8132  strat->newt = FALSE;
8133  }
8134  PrintS("\nset L");
8135  for (i=strat->Ll; i>=0; i--)
8136  {
8137  Print("\n%d:",i);
8138  p_wrp(strat->L[i].p1, currRing, strat->tailRing);
8139  PrintS(" ");
8140  p_wrp(strat->L[i].p2, currRing, strat->tailRing);
8141  PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
8142  PrintS("\n p : ");
8143  strat->L[i].wrp();
8144  Print(" o:%ld e:%d l:%d",
8145  strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
8146  }
8147  PrintLn();
8148 }

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 8074 of file kutil.cc.

8075 {
8076  //PrintS("\nUsage/Allocation of temporary storage:\n");
8077  //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
8078  //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
8079  Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
8080  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
8081  #ifdef HAVE_SHIFTBBA
8082  /* in usual case strat->cv is 0, it gets changed only in shift routines */
8083  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
8084  #endif
8085 }

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 8087 of file kutil.cc.

8088 {
8089  //PrintS("\nUsage/Allocation of temporary storage:\n");
8090  //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
8091  //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
8092  Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
8093  //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
8094  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
8095  #ifdef HAVE_SHIFTBBA
8096  /* in usual case strat->cv is 0, it gets changed only in shift routines */
8097  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
8098  #endif
8099 }
int nrsyzcrit
Definition: kutil.h:360

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10981 of file kutil.cc.

10982 {
10983  if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10984  return FALSE;
10985  int i,j;
10986  poly newNoether;
10987 
10988 #if 0
10989  if (currRing->weight_all_1)
10990  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10991  else
10992  scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10993 #else
10994  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10995 #endif
10996  if (strat->kHEdge==NULL) return FALSE;
10997  if (strat->t_kHEdge != NULL) p_LmFree(strat->t_kHEdge, strat->tailRing);
10998  if (strat->tailRing != currRing)
10999  strat->t_kHEdge = k_LmInit_currRing_2_tailRing(strat->kHEdge, strat->tailRing);
11000  /* compare old and new noether*/
11001  newNoether = pLmInit(strat->kHEdge);
11002  pSetCoeff0(newNoether,nInit(1));
11003  j = p_FDeg(newNoether,currRing);
11004  for (i=1; i<=(currRing->N); i++)
11005  {
11006  if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
11007  }
11008  pSetm(newNoether);
11009  if (j < strat->HCord) /*- statistics -*/
11010  {
11011  if (TEST_OPT_PROT)
11012  {
11013  Print("H(%d)",j);
11014  mflush();
11015  }
11016  strat->HCord=j;
11017  #ifdef KDEBUG
11018  if (TEST_OPT_DEBUG)
11019  {
11020  Print("H(%d):",j);
11021  wrp(strat->kHEdge);
11022  PrintLn();
11023  }
11024  #endif
11025  }
11026  if (pCmp(strat->kNoether,newNoether)!=1)
11027  {
11028  if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether);
11029  strat->kNoether=newNoether;
11030  if (strat->t_kNoether != NULL) p_LmFree(strat->t_kNoether, strat->tailRing);
11031  if (strat->tailRing != currRing)
11032  strat->t_kNoether = k_LmInit_currRing_2_tailRing(strat->kNoether, strat->tailRing);
11033 
11034  return TRUE;
11035  }
11036  pLmDelete(newNoether);
11037  return FALSE;
11038 }
int HCord
Definition: kutil.h:354
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1078
VAR int HCord
Definition: kutil.cc:246
#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 12249 of file kutil.cc.

12250 {
12251  /* restores a poly in currRing from LObject */
12252  LObject h = H;
12253  h.Copy();
12254  poly p;
12255  if (h.p == NULL)
12256  {
12257  if (h.t_p != NULL)
12258  {
12259  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
12260  return(p);
12261  }
12262  else
12263  {
12264  /* h.tp == NULL -> the object is NULL */
12265  return(NULL);
12266  }
12267  }
12268  /* we're here if h.p != NULL */
12269  if (h.t_p == NULL)
12270  {
12271  /* then h.p is the whole poly in currRing */
12272  p = h.p;
12273  return(p);
12274  }
12275  /* we're here if h.p != NULL and h.t_p != NULL */
12276  // clean h.p, get poly from t_p
12277  pNext(h.p)=NULL;
12278  pLmDelete(&h.p);
12279  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
12280  /* dest. ring: */ currRing);
12281  // no need to clean h: we re-used the polys
12282  return(p);
12283 }
CanonicalForm H
Definition: facAbsFact.cc:60
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89

◆ pMove2CurrTail()

poly pMove2CurrTail ( poly  p,
kStrategy  strat 
)

Definition at line 12218 of file kutil.cc.

12219 {
12220  /* assume: p is completely in currRing */
12221  /* produces an object with LM in curring
12222  and TAIL in tailring */
12223  if (pNext(p)!=NULL)
12224  {
12225  pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
12226  }
12227  return(p);
12228 }

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 12232 of file kutil.cc.

12233 {
12234  /* assume: p has LM in curring and TAIL in tailring */
12235  /* convert it to complete currRing */
12236 
12237  /* check that LM is in currRing */
12239 
12240  if (pNext(p)!=NULL)
12241  {
12242  pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
12243  }
12244  return(p);
12245 }

◆ posInIdealMonFirst()

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

Definition at line 5287 of file kutil.cc.

5288 {
5289  if(end < 0 || end >= IDELEMS(F))
5290  end = IDELEMS(F);
5291  if (end<0) return 0;
5292  if(pNext(p) == NULL) return start;
5293  polyset set=F->m;
5294  int o = p_Deg(p,currRing);
5295  int op;
5296  int i;
5297  int an = start;
5298  for(i=start;i<end;i++)
5299  if(set[i] != NULL && pNext(set[i]) == NULL)
5300  an++;
5301  if(an == end-1)
5302  return end;
5303  int en= end;
5304  loop
5305  {
5306  if(an>=en)
5307  return en;
5308  if (an == en-1)
5309  {
5310  op = p_Deg(set[an],currRing);
5311  if ((op < o)
5312  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5313  return en;
5314  return an;
5315  }
5316  i=(an+en) / 2;
5317  op = p_Deg(set[i],currRing);
5318  if ((op < o)
5319  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5320  an=i;
5321  else
5322  en=i;
5323  }
5324 }
poly * polyset
Definition: polys.h:259

◆ posInL0()

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

Definition at line 6139 of file kutil.cc.

6141 {
6142  if (length<0) return 0;
6143 
6144  if (pLmCmp(set[length].p,p->p)== currRing->OrdSgn)
6145  return length+1;
6146 
6147  int i;
6148  int an = 0;
6149  int en= length;
6150  loop
6151  {
6152  if (an >= en-1)
6153  {
6154  if (pLmCmp(set[an].p,p->p) == currRing->OrdSgn) return en;
6155  return an;
6156  }
6157  i=(an+en) / 2;
6158  if (pLmCmp(set[i].p,p->p) == currRing->OrdSgn) an=i;
6159  else en=i;
6160  /*aend. fuer lazy == in !=- machen */
6161  }
6162 }

◆ posInL10()

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

Definition at line 1331 of file kstd1.cc.

1332 {
1333  int j,dp,dL;
1334 
1335  if (length<0) return 0;
1336  if (hasPurePower(p,strat->lastAxis,&dp,strat))
1337  {
1338  int op= p->GetpFDeg() +p->ecart;
1339  for (j=length; j>=0; j--)
1340  {
1341  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1342  return j+1;
1343  if (dp < dL)
1344  return j+1;
1345  if ((dp == dL)
1346  && (set[j].GetpFDeg()+set[j].ecart >= op))
1347  return j+1;
1348  }
1349  }
1350  j=length;
1351  loop
1352  {
1353  if (j<0) break;
1354  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1355  j--;
1356  }
1357  return strat->posInLOld(set,j,p,strat);
1358 }
int lastAxis
Definition: kutil.h:355
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition: kutil.h:285
BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition: kstd1.cc:1283

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

6399 {
6400  if (length<0) return 0;
6401 
6402  int o = p->GetpFDeg();
6403  int op = set[length].GetpFDeg();
6404 
6405  if ((op > o)
6406  || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6407  return length+1;
6408  int i;
6409  int an = 0;
6410  int en= length;
6411  loop
6412  {
6413  if (an >= en-1)
6414  {
6415  op = set[an].GetpFDeg();
6416  if ((op > o)
6417  || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6418  return en;
6419  return an;
6420  }
6421  i=(an+en) / 2;
6422  op = set[i].GetpFDeg();
6423  if ((op > o)
6424  || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6425  an=i;
6426  else
6427  en=i;
6428  }
6429 }

◆ posInL110()

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

Definition at line 6695 of file kutil.cc.

6697 {
6698  if (length<0) return 0;
6699 
6700  int o = p->GetpFDeg();
6701  int op = set[length].GetpFDeg();
6702 
6703  if ((op > o)
6704  || ((op == o) && (set[length].length >p->length))
6705  || ((op == o) && (set[length].length <= p->length)
6706  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6707  return length+1;
6708  int i;
6709  int an = 0;
6710  int en= length;
6711  loop
6712  {
6713  if (an >= en-1)
6714  {
6715  op = set[an].GetpFDeg();
6716  if ((op > o)
6717  || ((op == o) && (set[an].length >p->length))
6718  || ((op == o) && (set[an].length <=p->length)
6719  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6720  return en;
6721  return an;
6722  }
6723  i=(an+en) / 2;
6724  op = set[i].GetpFDeg();
6725  if ((op > o)
6726  || ((op == o) && (set[i].length > p->length))
6727  || ((op == o) && (set[i].length <= p->length)
6728  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6729  an=i;
6730  else
6731  en=i;
6732  }
6733 }

◆ posInL11Ring()

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

Definition at line 6439 of file kutil.cc.

6441 {
6442  if (length<0) return 0;
6443 
6444  int o = p->GetpFDeg();
6445  int op = set[length].GetpFDeg();
6446 
6447  if ((op > o)
6448  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6449  return length+1;
6450  int i;
6451  int an = 0;
6452  int en= length;
6453  loop
6454  {
6455  if (an >= en-1)
6456  {
6457  op = set[an].GetpFDeg();
6458  if ((op > o)
6459  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6460  return en;
6461  return an;
6462  }
6463  i=(an+en) / 2;
6464  op = set[i].GetpFDeg();
6465  if ((op > o)
6466  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6467  an=i;
6468  else
6469  en=i;
6470  }
6471 }
#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 6509 of file kutil.cc.

6511 {
6512  if (length < 0) return 0;
6513  int an,en,i;
6514  an = 0;
6515  en = length+1;
6516  loop
6517  {
6518  if (an >= en-1)
6519  {
6520  if(an == en)
6521  return en;
6522  if (set[an].FDeg > p->FDeg)
6523  return en;
6524  if (set[an].FDeg < p->FDeg)
6525  return an;
6526  if (set[an].FDeg == p->FDeg)
6527  {
6528  number lcset,lcp;
6529  lcset = pGetCoeff(set[an].p);
6530  lcp = pGetCoeff(p->p);
6531  if(!nGreaterZero(lcset))
6532  {
6533  set[an].p=p_Neg(set[an].p,currRing);
6534  if (set[an].t_p!=NULL)
6535  pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
6536  lcset=pGetCoeff(set[an].p);
6537  }
6538  if(!nGreaterZero(lcp))
6539  {
6540  p->p=p_Neg(p->p,currRing);
6541  if (p->t_p!=NULL)
6542  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6543  lcp=pGetCoeff(p->p);
6544  }
6545  if(nGreater(lcset, lcp))
6546  {
6547  return en;
6548  }
6549  else
6550  {
6551  return an;
6552  }
6553  }
6554  }
6555  i=(an+en) / 2;
6556  if (set[i].FDeg > p->FDeg)
6557  an=i;
6558  if (set[i].FDeg < p->FDeg)
6559  en=i;
6560  if (set[i].FDeg == p->FDeg)
6561  {
6562  number lcset,lcp;
6563  lcset = pGetCoeff(set[i].p);
6564  lcp = pGetCoeff(p->p);
6565  if(!nGreaterZero(lcset))
6566  {
6567  set[i].p=p_Neg(set[i].p,currRing);
6568  if (set[i].t_p!=NULL)
6569  pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6570  lcset=pGetCoeff(set[i].p);
6571  }
6572  if(!nGreaterZero(lcp))
6573  {
6574  p->p=p_Neg(p->p,currRing);
6575  if (p->t_p!=NULL)
6576  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6577  lcp=pGetCoeff(p->p);
6578  }
6579  if(nGreater(lcset, lcp))
6580  {
6581  an = i;
6582  }
6583  else
6584  {
6585  en = i;
6586  }
6587  }
6588  }
6589 }
#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 6783 of file kutil.cc.

6785 {
6786  if (length<0) return 0;
6787 
6788  int o = p->GetpFDeg();
6789 
6790  if (set[length].GetpFDeg() > o)
6791  return length+1;
6792 
6793  int i;
6794  int an = 0;
6795  int en= length;
6796  loop
6797  {
6798  if (an >= en-1)
6799  {
6800  if (set[an].GetpFDeg() >= o)
6801  return en;
6802  return an;
6803  }
6804  i=(an+en) / 2;
6805  if (set[i].GetpFDeg() >= o)
6806  an=i;
6807  else
6808  en=i;
6809  }
6810 }

◆ posInL15()

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

Definition at line 6818 of file kutil.cc.

6820 {
6821  if (length<0) return 0;
6822 
6823  int o = p->GetpFDeg() + p->ecart;
6824  int op = set[length].GetpFDeg() + set[length].ecart;
6825 
6826  if ((op > o)
6827  || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6828  return length+1;
6829  int i;
6830  int an = 0;
6831  int en= length;
6832  loop
6833  {
6834  if (an >= en-1)
6835  {
6836  op = set[an].GetpFDeg() + set[an].ecart;
6837  if ((op > o)
6838  || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6839  return en;
6840  return an;
6841  }
6842  i=(an+en) / 2;
6843  op = set[i].GetpFDeg() + set[i].ecart;
6844  if ((op > o)
6845  || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6846  an=i;
6847  else
6848  en=i;
6849  }
6850 }

◆ posInL15Ring()

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

Definition at line 6853 of file kutil.cc.

6855 {
6856  if (length<0) return 0;
6857 
6858  int o = p->GetpFDeg() + p->ecart;
6859  int op = set[length].GetpFDeg() + set[length].ecart;
6860 
6861  if ((op > o)
6862  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6863  return length+1;
6864  int i;
6865  int an = 0;
6866  int en= length;
6867  loop
6868  {
6869  if (an >= en-1)
6870  {
6871  op = set[an].GetpFDeg() + set[an].ecart;
6872  if ((op > o)
6873  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6874  return en;
6875  return an;
6876  }
6877  i=(an+en) / 2;
6878  op = set[i].GetpFDeg() + set[i].ecart;
6879  if ((op > o)
6880  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6881  an=i;
6882  else
6883  en=i;
6884  }
6885 }

◆ posInL17()

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

Definition at line 6894 of file kutil.cc.

6896 {
6897  if (length<0) return 0;
6898 
6899  int o = p->GetpFDeg() + p->ecart;
6900 
6901  if ((set[length].GetpFDeg() + set[length].ecart > o)
6902  || ((set[length].GetpFDeg() + set[length].ecart == o)
6903  && (set[length].ecart > p->ecart))
6904  || ((set[length].GetpFDeg() + set[length].ecart == o)
6905  && (set[length].ecart == p->ecart)
6906  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6907  return length+1;
6908  int i;
6909  int an = 0;
6910  int en= length;
6911  loop
6912  {
6913  if (an >= en-1)
6914  {
6915  if ((set[an].GetpFDeg() + set[an].ecart > o)
6916  || ((set[an].GetpFDeg() + set[an].ecart == o)
6917  && (set[an].ecart > p->ecart))
6918  || ((set[an].GetpFDeg() + set[an].ecart == o)
6919  && (set[an].ecart == p->ecart)
6920  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6921  return en;
6922  return an;
6923  }
6924  i=(an+en) / 2;
6925  if ((set[i].GetpFDeg() + set[i].ecart > o)
6926  || ((set[i].GetpFDeg() + set[i].ecart == o)
6927  && (set[i].ecart > p->ecart))
6928  || ((set[i].GetpFDeg() +set[i].ecart == o)
6929  && (set[i].ecart == p->ecart)
6930  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6931  an=i;
6932  else
6933  en=i;
6934  }
6935 }

◆ posInLF5C()

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

Definition at line 6385 of file kutil.cc.

6387 {
6388  return strat->Ll+1;
6389 }

◆ posInLF5CRing()

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

Definition at line 6473 of file kutil.cc.

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

◆ posInLRing()

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

Definition at line 6284 of file kutil.cc.

6286 {
6287  if (length < 0) return 0;
6288  if (set[length].FDeg > p->FDeg)
6289  return length+1;
6290  if (set[length].FDeg == p->FDeg)
6291  if(set[length].GetpLength() > p->GetpLength())
6292  return length+1;
6293  int i;
6294  int an = 0;
6295  int en= length+1;
6296  loop
6297  {
6298  if (an >= en-1)
6299  {
6300  if(an == en)
6301  return en;
6302  if (set[an].FDeg > p->FDeg)
6303  return en;
6304  if(set[an].FDeg == p->FDeg)
6305  {
6306  if(set[an].GetpLength() > p->GetpLength())
6307  return en;
6308  else
6309  {
6310  if(set[an].GetpLength() == p->GetpLength())
6311  {
6312  if(nGreater(set[an].p->coef, p->p->coef))
6313  return en;
6314  else
6315  return an;
6316  }
6317  else
6318  {
6319  return an;
6320  }
6321  }
6322  }
6323  else
6324  return an;
6325  }
6326  i=(an+en) / 2;
6327  if (set[i].FDeg > p->FDeg)
6328  an=i;
6329  else
6330  {
6331  if(set[i].FDeg == p->FDeg)
6332  {
6333  if(set[i].GetpLength() > p->GetpLength())
6334  an=i;
6335  else
6336  {
6337  if(set[i].GetpLength() == p->GetpLength())
6338  {
6339  if(nGreater(set[i].p->coef, p->p->coef))
6340  an = i;
6341  else
6342  en = i;
6343  }
6344  else
6345  {
6346  en=i;
6347  }
6348  }
6349  }
6350  else
6351  en=i;
6352  }
6353  }
6354 }

◆ posInLSig()

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

Definition at line 6197 of file kutil.cc.

6199 {
6200  if (length<0) return 0;
6201  if (pLtCmp(set[length].sig,p->sig)== currRing->OrdSgn)
6202  return length+1;
6203 
6204  int i;
6205  int an = 0;
6206  int en= length;
6207  loop
6208  {
6209  if (an >= en-1)
6210  {
6211  if (pLtCmp(set[an].sig,p->sig) == currRing->OrdSgn) return en;
6212  return an;
6213  }
6214  i=(an+en) / 2;
6215  if (pLtCmp(set[i].sig,p->sig) == currRing->OrdSgn) an=i;
6216  else en=i;
6217  /*aend. fuer lazy == in !=- machen */
6218  }
6219 }

◆ posInLSigRing()

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

Definition at line 6221 of file kutil.cc.

6223 {
6224  assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
6225  if (length<0) return 0;
6226  if (pLtCmp(set[length].sig,p->sig)== 1)
6227  return length+1;
6228 
6229  int an,en,i;
6230  an = 0;
6231  en = length+1;
6232  int cmp;
6233  loop
6234  {
6235  if (an >= en-1)
6236  {
6237  if(an == en)
6238  return en;
6239  cmp = pLtCmp(set[an].sig,p->sig);
6240  if (cmp == 1)
6241  return en;
6242  if (cmp == -1)
6243  return an;
6244  if (cmp == 0)
6245  {
6246  if (set[an].FDeg > p->FDeg)
6247  return en;
6248  if (set[an].FDeg < p->FDeg)
6249  return an;
6250  if (set[an].FDeg == p->FDeg)
6251  {
6252  cmp = pLtCmp(set[an].p,p->p);
6253  if(cmp == 1)
6254  return en;
6255  else
6256  return an;
6257  }
6258  }
6259  }
6260  i=(an+en) / 2;
6261  cmp = pLtCmp(set[i].sig,p->sig);
6262  if (cmp == 1)
6263  an = i;
6264  if (cmp == -1)
6265  en = i;
6266  if (cmp == 0)
6267  {
6268  if (set[i].FDeg > p->FDeg)
6269  an = i;
6270  if (set[i].FDeg < p->FDeg)
6271  en = i;
6272  if (set[i].FDeg == p->FDeg)
6273  {
6274  cmp = pLtCmp(set[i].p,p->p);
6275  if(cmp == 1)
6276  an = i;
6277  else
6278  en = i;
6279  }
6280  }
6281  }
6282 }

◆ posInS()

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

Definition at line 5109 of file kutil.cc.

5111 {
5112  if(length==-1) return 0;
5113  polyset set=strat->S;
5114  int i;
5115  int an = 0;
5116  int en = length;
5117  int cmp_int = currRing->OrdSgn;
5119 #ifdef HAVE_PLURAL
5120  && (currRing->real_var_start==0)
5121 #endif
5122 #if 0
5123  || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
5124 #endif
5125  )
5126  {
5127  int o=p_Deg(p,currRing);
5128  int oo=p_Deg(set[length],currRing);
5129 
5130  if ((oo<o)
5131  || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
5132  return length+1;
5133 
5134  loop
5135  {
5136  if (an >= en-1)
5137  {
5138  if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
5139  {
5140  return an;
5141  }
5142  return en;
5143  }
5144  i=(an+en) / 2;
5145  if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
5146  else an=i;
5147  }
5148  }
5149  else
5150  {
5151  if (rField_is_Ring(currRing))
5152  {
5153  if (pLmCmp(set[length],p)== -cmp_int)
5154  return length+1;
5155  int cmp;
5156  loop
5157  {
5158  if (an >= en-1)
5159  {
5160  cmp = pLmCmp(set[an],p);
5161  if (cmp == cmp_int) return an;
5162  if (cmp == -cmp_int) return en;
5163  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
5164  return an;
5165  }
5166  i = (an+en) / 2;
5167  cmp = pLmCmp(set[i],p);
5168  if (cmp == cmp_int) en = i;
5169  else if (cmp == -cmp_int) an = i;
5170  else
5171  {
5172  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
5173  else en = i;
5174  }
5175  }
5176  }
5177  else
5178  if (pLmCmp(set[length],p)== -cmp_int)
5179  return length+1;
5180 
5181  loop
5182  {
5183  if (an >= en-1)
5184  {
5185  if (pLmCmp(set[an],p) == cmp_int) return an;
5186  if (pLmCmp(set[an],p) == -cmp_int) return en;
5187  if ((cmp_int!=1)
5188  && ((strat->ecartS[an])>ecart_p))
5189  return an;
5190  return en;
5191  }
5192  i=(an+en) / 2;
5193  if (pLmCmp(set[i],p) == cmp_int) en=i;
5194  else if (pLmCmp(set[i],p) == -cmp_int) an=i;
5195  else
5196  {
5197  if ((cmp_int!=1)
5198  &&((strat->ecartS[i])<ecart_p))
5199  en=i;
5200  else
5201  an=i;
5202  }
5203  }
5204  }
5205 }

◆ posInSMonFirst()

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

Definition at line 5210 of file kutil.cc.

5211 {
5212  if (length<0) return 0;
5213  polyset set=strat->S;
5214  if(pNext(p) == NULL)
5215  {
5216  int mon = 0;
5217  for(int i = 0;i<=length;i++)
5218  {
5219  if(set[i] != NULL && pNext(set[i]) == NULL)
5220  mon++;
5221  }
5222  int o = p_Deg(p,currRing);
5223  int op = p_Deg(set[mon],currRing);
5224 
5225  if ((op < o)
5226  || ((op == o) && (pLtCmp(set[mon],p) == -1)))
5227  return length+1;
5228  int i;
5229  int an = 0;
5230  int en= mon;
5231  loop
5232  {
5233  if (an >= en-1)
5234  {
5235  op = p_Deg(set[an],currRing);
5236  if ((op < o)
5237  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5238  return en;
5239  return an;
5240  }
5241  i=(an+en) / 2;
5242  op = p_Deg(set[i],currRing);
5243  if ((op < o)
5244  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5245  an=i;
5246  else
5247  en=i;
5248  }
5249  }
5250  else /*if(pNext(p) != NULL)*/
5251  {
5252  int o = p_Deg(p,currRing);
5253  int op = p_Deg(set[length],currRing);
5254 
5255  if ((op < o)
5256  || ((op == o) && (pLtCmp(set[length],p) == -1)))
5257  return length+1;
5258  int i;
5259  int an = 0;
5260  for(i=0;i<=length;i++)
5261  if(set[i] != NULL && pNext(set[i]) == NULL)
5262  an++;
5263  int en= length;
5264  loop
5265  {
5266  if (an >= en-1)
5267  {
5268  op = p_Deg(set[an],currRing);
5269  if ((op < o)
5270  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5271  return en;
5272  return an;
5273  }
5274  i=(an+en) / 2;
5275  op = p_Deg(set[i],currRing);
5276  if ((op < o)
5277  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5278  an=i;
5279  else
5280  en=i;
5281  }
5282  }
5283 }

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 6357 of file kutil.cc.

6358 {
6359  if (strat->syzl==0) return 0;
6360  if (pLtCmp(strat->syz[strat->syzl-1],sig) != currRing->OrdSgn)
6361  return strat->syzl;
6362  int i;
6363  int an = 0;
6364  int en= strat->syzl-1;
6365  loop
6366  {
6367  if (an >= en-1)
6368  {
6369  if (pLtCmp(strat->syz[an],sig) != currRing->OrdSgn) return en;
6370  return an;
6371  }
6372  i=(an+en) / 2;
6373  if (pLtCmp(strat->syz[i],sig) != currRing->OrdSgn) an=i;
6374  else en=i;
6375  /*aend. fuer lazy == in !=- machen */
6376  }
6377 }

◆ posInT0()

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

Definition at line 5331 of file kutil.cc.

5332 {
5333  return (length+1);
5334 }

◆ posInT1()

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

Definition at line 5342 of file kutil.cc.

5343 {
5344  if (length==-1) return 0;
5345 
5346  if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
5347 
5348  int i;
5349  int an = 0;
5350  int en= length;
5351 
5352  loop
5353  {
5354  if (an >= en-1)
5355  {
5356  if (pLmCmp(set[an].p,p.p) == currRing->OrdSgn) return an;
5357  return en;
5358  }
5359  i=(an+en) / 2;
5360  if (pLmCmp(set[i].p,p.p) == currRing->OrdSgn) en=i;
5361  else an=i;
5362  }
5363 }

◆ posInT11()

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

Definition at line 5400 of file kutil.cc.

5401 {
5402  if (length==-1) return 0;
5403 
5404  int o = p.GetpFDeg();
5405  int op = set[length].GetpFDeg();
5406 
5407  if ((op < o)
5408  || ((op == o) && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5409  return length+1;
5410 
5411  int i;
5412  int an = 0;
5413  int en= length;
5414 
5415  loop
5416  {
5417  if (an >= en-1)
5418  {
5419  op= set[an].GetpFDeg();
5420  if ((op > o)
5421  || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5422  return an;
5423  return en;
5424  }
5425  i=(an+en) / 2;
5426  op = set[i].GetpFDeg();
5427  if (( op > o)
5428  || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5429  en=i;
5430  else
5431  an=i;
5432  }
5433 }

◆ posInT110()

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

Definition at line 5553 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5642 of file kutil.cc.

5643 {
5644  if (length==-1) return 0;
5645 
5646  int o = p.GetpFDeg();
5647 
5648  if (set[length].GetpFDeg() <= o)
5649  return length+1;
5650 
5651  int i;
5652  int an = 0;
5653  int en= length;
5654  loop
5655  {
5656  if (an >= en-1)
5657  {
5658  if (set[an].GetpFDeg() > o)
5659  return an;
5660  return en;
5661  }
5662  i=(an+en) / 2;
5663  if (set[i].GetpFDeg() > o)
5664  en=i;
5665  else
5666  an=i;
5667  }
5668 }

◆ posInT15()

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

Definition at line 5710 of file kutil.cc.

5729 {
5730  if (length==-1) return 0;
5731 
5732  int o = p.GetpFDeg() + p.ecart;
5733  int op = set[length].GetpFDeg()+set[length].ecart;
5734 
5735  if ((op < o)
5736  || ((op == o)
5737  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5738  return length+1;
5739 
5740  int i;
5741  int an = 0;
5742  int en= length;
5743  loop
5744  {
5745  if (an >= en-1)
5746  {
5747  op = set[an].GetpFDeg()+set[an].ecart;
5748  if (( op > o)
5749  || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5750  return an;
5751  return en;
5752  }
5753  i=(an+en) / 2;
5754  op = set[i].GetpFDeg()+set[i].ecart;
5755  if (( op > o)
5756  || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5757  en=i;
5758  else
5759  an=i;
5760  }
5761 }

◆ posInT17()

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

Definition at line 5805 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5912 of file kutil.cc.

5913 {
5914  if (length==-1) return 0;
5915 
5916  int cc = (-1+2*currRing->order[0]==ringorder_c);
5917  /* cc==1 for (c,..), cc==-1 for (C,..) */
5918  int o = p.GetpFDeg() + p.ecart;
5919  int c = pGetComp(p.p)*cc;
5920 
5921  if (pGetComp(set[length].p)*cc < c)
5922  return length+1;
5923  if (pGetComp(set[length].p)*cc == c)
5924  {
5925  int op = set[length].GetpFDeg()+set[length].ecart;
5926  if ((op < o)
5927  || ((op == o) && (set[length].ecart > p.ecart))
5928  || ((op == o) && (set[length].ecart==p.ecart)
5929  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5930  return length+1;
5931  }
5932 
5933  int i;
5934  int an = 0;
5935  int en= length;
5936  loop
5937  {
5938  if (an >= en-1)
5939  {
5940  if (pGetComp(set[an].p)*cc < c)
5941  return en;
5942  if (pGetComp(set[an].p)*cc == c)
5943  {
5944  int op = set[an].GetpFDeg()+set[an].ecart;
5945  if ((op > o)
5946  || ((op == o) && (set[an].ecart < p.ecart))
5947  || ((op == o) && (set[an].ecart==p.ecart)
5948  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5949  return an;
5950  }
5951  return en;
5952  }
5953  i=(an+en) / 2;
5954  if (pGetComp(set[i].p)*cc > c)
5955  en=i;
5956  else if (pGetComp(set[i].p)*cc == c)
5957  {
5958  int op = set[i].GetpFDeg()+set[i].ecart;
5959  if ((op > o)
5960  || ((op == o) && (set[i].ecart < p.ecart))
5961  || ((op == o) && (set[i].ecart == p.ecart)
5962  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5963  en=i;
5964  else
5965  an=i;
5966  }
5967  else
5968  an=i;
5969  }
5970 }

◆ posInT19()

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

Definition at line 6039 of file kutil.cc.

6040 {
6041  p.GetpLength();
6042  if (length==-1) return 0;
6043 
6044  int o = p.ecart;
6045  int op=p.GetpFDeg();
6046 
6047  if (set[length].ecart < o)
6048  return length+1;
6049  if (set[length].ecart == o)
6050  {
6051  int oo=set[length].GetpFDeg();
6052  if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
6053  return length+1;
6054  }
6055 
6056  int i;
6057  int an = 0;
6058  int en= length;
6059  loop
6060  {
6061  if (an >= en-1)
6062  {
6063  if (set[an].ecart > o)
6064  return an;
6065  if (set[an].ecart == o)
6066  {
6067  int oo=set[an].GetpFDeg();
6068  if((oo > op)
6069  || ((oo==op) && (set[an].length > p.length)))
6070  return an;
6071  }
6072  return en;
6073  }
6074  i=(an+en) / 2;
6075  if (set[i].ecart > o)
6076  en=i;
6077  else if (set[i].ecart == o)
6078  {
6079  int oo=set[i].GetpFDeg();
6080  if ((oo > op)
6081  || ((oo == op) && (set[i].length > p.length)))
6082  en=i;
6083  else
6084  an=i;
6085  }
6086  else
6087  an=i;
6088  }
6089 }

◆ posInT2()

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

Definition at line 5370 of file kutil.cc.

5371 {
5372  p.GetpLength();
5373  if (length==-1)
5374  return 0;
5375  if (set[length].length<p.length)
5376  return length+1;
5377 
5378  int i;
5379  int an = 0;
5380  int en= length;
5381 
5382  loop
5383  {
5384  if (an >= en-1)
5385  {
5386  if (set[an].length>p.length) return an;
5387  return en;
5388  }
5389  i=(an+en) / 2;
5390  if (set[i].length>p.length) en=i;
5391  else an=i;
5392  }
5393 }

◆ posInT_EcartFDegpLength()

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

Definition at line 11955 of file kutil.cc.

11956 {
11957 
11958  if (length==-1) return 0;
11959 
11960  int o = p.ecart;
11961  int op=p.GetpFDeg();
11962  int ol = p.GetpLength();
11963 
11964  if (set[length].ecart < o)
11965  return length+1;
11966  if (set[length].ecart == o)
11967  {
11968  int oo=set[length].GetpFDeg();
11969  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11970  return length+1;
11971  }
11972 
11973  int i;
11974  int an = 0;
11975  int en= length;
11976  loop
11977  {
11978  if (an >= en-1)
11979  {
11980  if (set[an].ecart > o)
11981  return an;
11982  if (set[an].ecart == o)
11983  {
11984  int oo=set[an].GetpFDeg();
11985  if((oo > op)
11986  || ((oo==op) && (set[an].pLength > ol)))
11987  return an;
11988  }
11989  return en;
11990  }
11991  i=(an+en) / 2;
11992  if (set[i].ecart > o)
11993  en=i;
11994  else if (set[i].ecart == o)
11995  {
11996  int oo=set[i].GetpFDeg();
11997  if ((oo > op)
11998  || ((oo == op) && (set[i].pLength > ol)))
11999  en=i;
12000  else
12001  an=i;
12002  }
12003  else
12004  an=i;
12005  }
12006 }

◆ posInT_EcartpLength()

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

Definition at line 5671 of file kutil.cc.

5672 {
5673  int ol = p.GetpLength();
5674  if (length==-1) return 0;
5675 
5676  int op=p.ecart;
5677 
5678  int oo=set[length].ecart;
5679  if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5680  return length+1;
5681 
5682  int i;
5683  int an = 0;
5684  int en= length;
5685  loop
5686  {
5687  if (an >= en-1)
5688  {
5689  int oo=set[an].ecart;
5690  if((oo > op)
5691  || ((oo==op) && (set[an].pLength > ol)))
5692  return an;
5693  return en;
5694  }
5695  i=(an+en) / 2;
5696  int oo=set[i].ecart;
5697  if ((oo > op)
5698  || ((oo == op) && (set[i].pLength > ol)))
5699  en=i;
5700  else
5701  an=i;
5702  }
5703 }

◆ posInT_FDegpLength()

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

Definition at line 12009 of file kutil.cc.

12010 {
12011 
12012  if (length==-1) return 0;
12013 
12014  int op=p.GetpFDeg();
12015  int ol = p.GetpLength();
12016 
12017  int oo=set[length].GetpFDeg();
12018  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
12019  return length+1;
12020 
12021  int i;
12022  int an = 0;
12023  int en= length;
12024  loop
12025  {
12026  if (an >= en-1)
12027  {
12028  int oo=set[an].GetpFDeg();
12029  if((oo > op)
12030  || ((oo==op) && (set[an].pLength > ol)))
12031  return an;
12032  return en;
12033  }
12034  i=(an+en) / 2;
12035  int oo=set[i].GetpFDeg();
12036  if ((oo > op)
12037  || ((oo == op) && (set[i].pLength > ol)))
12038  en=i;
12039  else
12040  an=i;
12041  }
12042 }

◆ posInT_pLength()

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

Definition at line 12046 of file kutil.cc.

12047 {
12048  int ol = p.GetpLength();
12049  if (length==-1)
12050  return 0;
12051  if (set[length].length<p.length)
12052  return length+1;
12053 
12054  int i;
12055  int an = 0;
12056  int en= length;
12057 
12058  loop
12059  {
12060  if (an >= en-1)
12061  {
12062  if (set[an].pLength>ol) return an;
12063  return en;
12064  }
12065  i=(an+en) / 2;
12066  if (set[i].pLength>ol) en=i;
12067  else an=i;
12068  }
12069 }

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

11275 {
11276  if(!nCoeff_is_Z(currRing->cf))
11277  return;
11278  poly pH = h->GetP();
11279  poly p,pp;
11280  p = pH;
11281  bool deleted = FALSE, ok = FALSE;
11282  for(int i = 0; i<=strat->sl; i++)
11283  {
11284  p = pH;
11285  if(pNext(strat->S[i]) == NULL)
11286  {
11287  //pWrite(p);
11288  //pWrite(strat->S[i]);
11289  while(ok == FALSE && p != NULL)
11290  {
11291  if(pLmDivisibleBy(strat->S[i], p)
11292 #ifdef HAVE_SHIFTBBA
11293  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
11294 #endif
11295  )
11296  {
11297  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11298  p_SetCoeff(p,dummy,currRing);
11299  }
11300  if(nIsZero(p->coef))
11301  {
11302  pLmDelete(&p);
11303  h->p = p;
11304  deleted = TRUE;
11305  }
11306  else
11307  {
11308  ok = TRUE;
11309  }
11310  }
11311  if (p!=NULL)
11312  {
11313  pp = pNext(p);
11314  while(pp != NULL)
11315  {
11316  if(pLmDivisibleBy(strat->S[i], pp)
11317 #ifdef HAVE_SHIFTBBA
11318  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
11319 #endif
11320  )
11321  {
11322  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11323  p_SetCoeff(pp,dummy,currRing);
11324  if(nIsZero(pp->coef))
11325  {
11326  pLmDelete(&pNext(p));
11327  pp = pNext(p);
11328  deleted = TRUE;
11329  }
11330  else
11331  {
11332  p = pp;
11333  pp = pNext(p);
11334  }
11335  }
11336  else
11337  {
11338  p = pp;
11339  pp = pNext(p);
11340  }
11341  }
11342  }
11343  }
11344  }
11345  h->SetLmCurrRing();
11346  if((deleted)&&(h->p!=NULL))
11347  strat->initEcart(h);
11348 }

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 11350 of file kutil.cc.

11351 {
11352  if(!nCoeff_is_Z(currRing->cf))
11353  return;
11354  poly hSig = h->sig;
11355  poly pH = h->GetP();
11356  poly p,pp;
11357  p = pH;
11358  bool deleted = FALSE, ok = FALSE;
11359  for(int i = 0; i<=strat->sl; i++)
11360  {
11361  p = pH;
11362  if(pNext(strat->S[i]) == NULL)
11363  {
11364  while(ok == FALSE && p!=NULL)
11365  {
11366  if(pLmDivisibleBy(strat->S[i], p))
11367  {
11368  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11369  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11370  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11371  {
11372  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11373  p_SetCoeff(p,dummy,currRing);
11374  }
11375  pDelete(&sigMult);
11376  }
11377  if(nIsZero(p->coef))
11378  {
11379  pLmDelete(&p);
11380  h->p = p;
11381  deleted = TRUE;
11382  }
11383  else
11384  {
11385  ok = TRUE;
11386  }
11387  }
11388  if(p == NULL)
11389  return;
11390  pp = pNext(p);
11391  while(pp != NULL)
11392  {
11393  if(pLmDivisibleBy(strat->S[i], pp))
11394  {
11395  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11396  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11397  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11398  {
11399  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11400  p_SetCoeff(pp,dummy,currRing);
11401  if(nIsZero(pp->coef))
11402  {
11403  pLmDelete(&pNext(p));
11404  pp = pNext(p);
11405  deleted = TRUE;
11406  }
11407  else
11408  {
11409  p = pp;
11410  pp = pNext(p);
11411  }
11412  }
11413  else
11414  {
11415  p = pp;
11416  pp = pNext(p);
11417  }
11418  pDelete(&sigMult);
11419  }
11420  else
11421  {
11422  p = pp;
11423  pp = pNext(p);
11424  }
11425  }
11426  }
11427  }
11428  h->SetLmCurrRing();
11429  if(deleted)
11430  strat->initEcart(h);
11431 
11432 }
#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 11107 of file kutil.cc.

11108 {
11109  if(!nCoeff_is_Z(currRing->cf))
11110  return NULL;
11111  ideal F = idCopy(Forig);
11112  idSkipZeroes(F);
11113  poly pmon;
11114  ring origR = currRing;
11115  ideal monred = idInit(1,1);
11116  for(int i=0; i<idElem(F); i++)
11117  {
11118  if(pNext(F->m[i]) == NULL)
11119  idInsertPoly(monred, pCopy(F->m[i]));
11120  }
11121  int posconst = idPosConstant(F);
11122  if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
11123  {
11124  idDelete(&F);
11125  idDelete(&monred);
11126  return NULL;
11127  }
11128  int idelemQ = 0;
11129  if(Q!=NULL)
11130  {
11131  idelemQ = IDELEMS(Q);
11132  for(int i=0; i<idelemQ; i++)
11133  {
11134  if(pNext(Q->m[i]) == NULL)
11135  idInsertPoly(monred, pCopy(Q->m[i]));
11136  }
11137  idSkipZeroes(monred);
11138  posconst = idPosConstant(monred);
11139  //the constant, if found, will be from Q
11140  if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
11141  {
11142  pmon = pCopy(monred->m[posconst]);
11143  idDelete(&F);
11144  idDelete(&monred);
11145  return pmon;
11146  }
11147  }
11148  ring QQ_ring = rCopy0(currRing,FALSE);
11149  nKillChar(QQ_ring->cf);
11150  QQ_ring->cf = nInitChar(n_Q, NULL);
11151  rComplete(QQ_ring,1);
11152  QQ_ring = rAssure_c_dp(QQ_ring);
11153  rChangeCurrRing(QQ_ring);
11154  nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
11155  ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
11156  for(int i = 0, j = 0; i<IDELEMS(F); i++)
11157  II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
11158  for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
11159  II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
11160  ideal one = kStd(II, NULL, isNotHomog, NULL);
11161  idSkipZeroes(one);
11162  if(idIsConstant(one))
11163  {
11164  //one should be <1>
11165  for(int i = IDELEMS(II)-1; i>=0; i--)
11166  if(II->m[i] != NULL)
11167  II->m[i+1] = II->m[i];
11168  II->m[0] = pOne();
11169  ideal syz = idSyzygies(II, isNotHomog, NULL);
11170  poly integer = NULL;
11171  for(int i = IDELEMS(syz)-1;i>=0; i--)
11172  {
11173  if(pGetComp(syz->m[i]) == 1)
11174  {
11175  pSetComp(syz->m[i],0);
11176  if(pIsConstant(pHead(syz->m[i])))
11177  {
11178  integer = pHead(syz->m[i]);
11179  break;
11180  }
11181  }
11182  }
11183  rChangeCurrRing(origR);
11184  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
11185  pmon = prMapR(integer, nMap2, QQ_ring, origR);
11186  idDelete(&monred);
11187  idDelete(&F);
11188  id_Delete(&II,QQ_ring);
11189  id_Delete(&one,QQ_ring);
11190  id_Delete(&syz,QQ_ring);
11191  p_Delete(&integer,QQ_ring);
11192  rDelete(QQ_ring);
11193  return pmon;
11194  }
11195  else
11196  {
11197  if(idIs0(monred))
11198  {
11199  poly mindegmon = NULL;
11200  for(int i = 0; i<IDELEMS(one); i++)
11201  {
11202  if(pNext(one->m[i]) == NULL)
11203  {
11204  if(mindegmon == NULL)
11205  mindegmon = pCopy(one->m[i]);
11206  else
11207  {
11208  if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
11209  mindegmon = pCopy(one->m[i]);
11210  }
11211  }
11212  }
11213  if(mindegmon != NULL)
11214  {
11215  for(int i = IDELEMS(II)-1; i>=0; i--)
11216  if(II->m[i] != NULL)
11217  II->m[i+1] = II->m[i];
11218  II->m[0] = pCopy(mindegmon);
11219  ideal syz = idSyzygies(II, isNotHomog, NULL);
11220  bool found = FALSE;
11221  for(int i = IDELEMS(syz)-1;i>=0; i--)
11222  {
11223  if(pGetComp(syz->m[i]) == 1)
11224  {
11225  pSetComp(syz->m[i],0);
11226  if(pIsConstant(pHead(syz->m[i])))
11227  {
11228  pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
11229  found = TRUE;
11230  break;
11231  }
11232  }
11233  }
11234  id_Delete(&syz,QQ_ring);
11235  if (found == FALSE)
11236  {
11237  rChangeCurrRing(origR);
11238  idDelete(&monred);
11239  idDelete(&F);
11240  id_Delete(&II,QQ_ring);
11241  id_Delete(&one,QQ_ring);
11242  rDelete(QQ_ring);
11243  return NULL;
11244  }
11245  rChangeCurrRing(origR);
11246  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
11247  pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
11248  idDelete(&monred);
11249  idDelete(&F);
11250  id_Delete(&II,QQ_ring);
11251  id_Delete(&one,QQ_ring);
11252  id_Delete(&syz,QQ_ring);
11253  rDelete(QQ_ring);
11254  return pmon;
11255  }
11256  }
11257  }
11258  rChangeCurrRing(origR);
11259  idDelete(&monred);
11260  idDelete(&F);
11261  id_Delete(&II,QQ_ring);
11262  id_Delete(&one,QQ_ring);
11263  rDelete(QQ_ring);
11264  return NULL;
11265 }
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
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:723
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:353
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:513
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:2419
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:3403
ring rAssure_c_dp(const ring r)
Definition: ring.cc:4940
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1366
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:449
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:41

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4719 of file kstd2.cc.

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

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 902 of file kstd2.cc.

903 {
904  if (strat->tl<0) return 1;
905  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
906  assume(h->FDeg == h->pFDeg());
907 
908  poly h_p;
909  int i,j,at,pass, ii;
910  unsigned long not_sev;
911  // long reddeg,d;
912 
913  pass = j = 0;
914  // d = reddeg = h->GetpFDeg();
915  h->SetShortExpVector();
916  int li;
917  h_p = h->GetLmTailRing();
918  not_sev = ~ h->sev;
919  h->PrepareRed(strat->use_buckets);
920  loop
921  {
922  j = kFindDivisibleByInT(strat, h);
923  if (j < 0) return 1;
924 
925  li = strat->T[j].pLength;
926  if (li<=0) li=strat->T[j].GetpLength();
927  ii = j;
928  /*
929  * the polynomial to reduce with (up to the moment) is;
930  * pi with length li
931  */
932  i = j;
933 #if 1
934  if (TEST_OPT_LENGTH)
935  loop
936  {
937  /*- search the shortest possible with respect to length -*/
938  i++;
939  if (i > strat->tl)
940  break;
941  if (li==1)
942  break;
943  if ((strat->T[i].pLength < li)
944  &&
945  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
946  h_p, not_sev, strat->tailRing))
947  {
948  /*
949  * the polynomial to reduce with is now;
950  */
951  li = strat->T[i].pLength;
952  if (li<=0) li=strat->T[i].GetpLength();
953  ii = i;
954  }
955  }
956 #endif
957 
958  /*
959  * end of search: have to reduce with pi
960  */
961 #ifdef KDEBUG
962  if (TEST_OPT_DEBUG)
963  {
964  PrintS("red:");
965  h->wrp();
966  PrintS(" with ");
967  strat->T[ii].wrp();
968  }
969 #endif
970  assume(strat->fromT == FALSE);
971 
972  ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
973 #if SBA_PRINT_REDUCTION_STEPS
974  sba_interreduction_steps++;
975 #endif
976 #if SBA_PRINT_OPERATIONS
977  sba_interreduction_operations += pLength(strat->T[ii].p);
978 #endif
979 
980 #ifdef KDEBUG
981  if (TEST_OPT_DEBUG)
982  {
983  PrintS("\nto ");
984  h->wrp();
985  PrintLn();
986  }
987 #endif
988 
989  h_p = h->GetLmTailRing();
990  if (h_p == NULL)
991  {
992  kDeleteLcm(h);
993  return 0;
994  }
995  if (TEST_OPT_IDLIFT)
996  {
997  if (h->p!=NULL)
998  {
999  if(p_GetComp(h->p,currRing)>strat->syzComp)
1000  {
1001  h->Delete();
1002  return 0;
1003  }
1004  }
1005  else if (h->t_p!=NULL)
1006  {
1007  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1008  {
1009  h->Delete();
1010  return 0;
1011  }
1012  }
1013  }
1014  #if 0
1015  else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1016  {
1017  if (h->p!=NULL)
1018  {
1019  if(p_GetComp(h->p,currRing)>strat->syzComp)
1020  {
1021  return 1;
1022  }
1023  }
1024  else if (h->t_p!=NULL)
1025  {
1026  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1027  {
1028  return 1;
1029  }
1030  }
1031  }
1032  #endif
1033  h->SetShortExpVector();
1034  not_sev = ~ h->sev;
1035  /*
1036  * try to reduce the s-polynomial h
1037  *test first whether h should go to the lazyset L
1038  *-if the degree jumps
1039  *-if the number of pre-defined reductions jumps
1040  */
1041  pass++;
1042  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1043  {
1044  h->SetLmCurrRing();
1045  at = strat->posInL(strat->L,strat->Ll,h,strat);
1046  if (at <= strat->Ll)
1047  {
1048 #ifdef HAVE_SHIFTBBA
1049  if (rIsLPRing(currRing))
1050  {
1051  if (kFindDivisibleByInT(strat, h) < 0)
1052  return 1;
1053  }
1054  else
1055 #endif
1056  {
1057  int dummy=strat->sl;
1058  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1059  return 1;
1060  }
1061  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1062 #ifdef KDEBUG
1063  if (TEST_OPT_DEBUG)
1064  Print(" lazy: -> L%d\n",at);
1065 #endif
1066  h->Clear();
1067  return -1;
1068  }
1069  }
1070  }
1071 }
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:398
#define TEST_OPT_LENGTH
Definition: options.h:129
#define TEST_OPT_REDTAIL_SYZ
Definition: options.h:116

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 1842 of file kstd2.cc.

1843 {
1844  if (strat->tl<0) return 1;
1845  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1846  assume(h->FDeg == h->pFDeg());
1847  poly h_p;
1848  int i,j,at,pass,ei, ii, h_d;
1849  unsigned long not_sev;
1850  long reddeg,d;
1851 
1852  pass = j = 0;
1853  d = reddeg = h->GetpFDeg() + h->ecart;
1854  h->SetShortExpVector();
1855  int li;
1856  h_p = h->GetLmTailRing();
1857  not_sev = ~ h->sev;
1858 
1859  h->PrepareRed(strat->use_buckets);
1860  loop
1861  {
1862  j=kFindDivisibleByInT(strat, h);
1863  if (j < 0) return 1;
1864 
1865  ei = strat->T[j].ecart;
1866  li = strat->T[j].pLength;
1867  if (li<=0) li=strat->T[j].GetpLength();
1868  ii = j;
1869  /*
1870  * the polynomial to reduce with (up to the moment) is;
1871  * pi with ecart ei (T[ii])
1872  */
1873  i = j;
1874  if (TEST_OPT_LENGTH)
1875  loop
1876  {
1877  /*- takes the first possible with respect to ecart -*/
1878  i++;
1879  if (i > strat->tl)
1880  break;
1881  //if (ei < h->ecart)
1882  // break;
1883  if (li==1)
1884  break;
1885  if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
1886  || ((strat->T[i].ecart <= h->ecart) && (strat->T[i].pLength < li)))
1887  &&
1888  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1889  h_p, not_sev, strat->tailRing))
1890  {
1891  /*
1892  * the polynomial to reduce with is now;
1893  */
1894  ei = strat->T[i].ecart;
1895  li = strat->T[i].pLength;
1896  if (li<=0) li=strat->T[i].GetpLength();
1897  ii = i;
1898  }
1899  }
1900 
1901  /*
1902  * end of search: have to reduce with pi
1903  */
1904  if (!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart))
1905  {
1906  h->GetTP(); // clears bucket
1907  h->SetLmCurrRing();
1908  /*
1909  * It is not possible to reduce h with smaller ecart;
1910  * if possible h goes to the lazy-set L,i.e
1911  * if its position in L would be not the last one
1912  */
1913  if (strat->Ll >= 0) /* L is not empty */
1914  {
1915  at = strat->posInL(strat->L,strat->Ll,h,strat);
1916  if(at <= strat->Ll)
1917  /*- h will not become the next element to reduce -*/
1918  {
1919  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1920 #ifdef KDEBUG
1921  if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
1922 #endif
1923  h->Clear();
1924  return -1;
1925  }
1926  }
1927  }
1928 #ifdef KDEBUG
1929  if (TEST_OPT_DEBUG)
1930  {
1931  PrintS("red:");
1932  h->wrp();
1933  Print("\nwith T[%d]:",ii);
1934  strat->T[ii].wrp();
1935  }
1936 #endif
1937  assume(strat->fromT == FALSE);
1938 
1939  ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,NULL, strat);
1940 #if SBA_PRINT_REDUCTION_STEPS
1941  sba_interreduction_steps++;
1942 #endif
1943 #if SBA_PRINT_OPERATIONS
1944  sba_interreduction_operations += pLength(strat->T[ii].p);
1945 #endif
1946 #ifdef KDEBUG
1947  if (TEST_OPT_DEBUG)
1948  {
1949  PrintS("\nto:");
1950  h->wrp();
1951  PrintLn();
1952  }
1953 #endif
1954  if(h->IsNull())
1955  {
1956  kDeleteLcm(h);
1957  h->Clear();
1958  return 0;
1959  }
1960  if (TEST_OPT_IDLIFT)
1961  {
1962  if (h->p!=NULL)
1963  {
1964  if(p_GetComp(h->p,currRing)>strat->syzComp)
1965  {
1966  h->Delete();
1967  return 0;
1968  }
1969  }
1970  else if (h->t_p!=NULL)
1971  {
1972  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1973  {
1974  h->Delete();
1975  return 0;
1976  }
1977  }
1978  }
1979  else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1980  {
1981  if (h->p!=NULL)
1982  {
1983  if(p_GetComp(h->p,currRing)>strat->syzComp)
1984  {
1985  return 1;
1986  }
1987  }
1988  else if (h->t_p!=NULL)
1989  {
1990  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1991  {
1992  return 1;
1993  }
1994  }
1995  }
1996  h->SetShortExpVector();
1997  not_sev = ~ h->sev;
1998  h_d = h->SetpFDeg();
1999  /* compute the ecart */
2000  if (ei <= h->ecart)
2001  h->ecart = d-h_d;
2002  else
2003  h->ecart = d-h_d+ei-h->ecart;
2004 
2005  /*
2006  * try to reduce the s-polynomial h
2007  *test first whether h should go to the lazyset L
2008  *-if the degree jumps
2009  *-if the number of pre-defined reductions jumps
2010  */
2011  pass++;
2012  d = h_d + h->ecart;
2013  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
2014  {
2015  h->GetTP(); // clear bucket
2016  h->SetLmCurrRing();
2017  at = strat->posInL(strat->L,strat->Ll,h,strat);
2018  if (at <= strat->Ll)
2019  {
2020 #ifdef HAVE_SHIFTBBA
2021  if (rIsLPRing(currRing))
2022  {
2023  if (kFindDivisibleByInT(strat, h) < 0)
2024  return 1;
2025  }
2026  else
2027 #endif
2028  {
2029  int dummy=strat->sl;
2030  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2031  return 1;
2032  }
2033  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2034 #ifdef KDEBUG
2035  if (TEST_OPT_DEBUG)
2036  Print(" degree jumped: -> L%d\n",at);
2037 #endif
2038  h->Clear();
2039  return -1;
2040  }
2041  }
2042  else if (d > reddeg)
2043  {
2044  if (d>=(long)strat->tailRing->bitmask)
2045  {
2046  if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask)
2047  {
2048  strat->overflow=TRUE;
2049  //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2050  h->GetP();
2051  at = strat->posInL(strat->L,strat->Ll,h,strat);
2052  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2053  h->Clear();
2054  return -1;
2055  }
2056  }
2057  else if (TEST_OPT_PROT && (strat->Ll < 0) )
2058  {
2059  //h->wrp(); Print("<%d>\n",h->GetpLength());
2060  reddeg = d;
2061  Print(".%ld",d); mflush();
2062  }
2063  }
2064  }
2065 }

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1648 of file kstd2.cc.

1649 {
1650  if (strat->tl<0) return 1;
1651  int at,i,ii,li;
1652  int j = 0;
1653  int pass = 0;
1654  assume(h->pFDeg() == h->FDeg);
1655  long reddeg = h->GetpFDeg();
1656  long d;
1657  unsigned long not_sev;
1658 
1659  h->SetShortExpVector();
1660  poly h_p = h->GetLmTailRing();
1661  not_sev = ~ h->sev;
1662  h->PrepareRed(strat->use_buckets);
1663  loop
1664  {
1665  j = kFindDivisibleByInT(strat, h);
1666  if (j < 0) return 1;
1667 
1668  li = strat->T[j].pLength;
1669  if (li<=0) li=strat->T[j].GetpLength();
1670  ii = j;
1671  /*
1672  * the polynomial to reduce with (up to the moment) is;
1673  * pi with length li
1674  */
1675 
1676  i = j;
1677 #if 1
1678  if (TEST_OPT_LENGTH)
1679  loop
1680  {
1681  /*- search the shortest possible with respect to length -*/
1682  i++;
1683  if (i > strat->tl)
1684  break;
1685  if (li==1)
1686  break;
1687  if ((strat->T[i].pLength < li)
1688  &&
1689  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1690  h_p, not_sev, strat->tailRing))
1691  {
1692  /*
1693  * the polynomial to reduce with is now;
1694  */
1695  li = strat->T[i].pLength;
1696  if (li<=0) li=strat->T[i].GetpLength();
1697  ii = i;
1698  }
1699  }
1700 #endif
1701 
1702  /*
1703  * end of search: have to reduce with pi
1704  */
1705 
1706 
1707 #ifdef KDEBUG
1708  if (TEST_OPT_DEBUG)
1709  {
1710  PrintS("red:");
1711  h->wrp();
1712  PrintS(" with ");
1713  strat->T[ii].wrp();
1714  }
1715 #endif
1716 
1717  ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1718 #if SBA_PRINT_REDUCTION_STEPS
1719  sba_interreduction_steps++;
1720 #endif
1721 #if SBA_PRINT_OPERATIONS
1722  sba_interreduction_operations += pLength(strat->T[ii].p);
1723 #endif
1724 
1725 #ifdef KDEBUG
1726  if (TEST_OPT_DEBUG)
1727  {
1728  PrintS("\nto ");
1729  h->wrp();
1730  PrintLn();
1731  }
1732 #endif
1733 
1734  h_p=h->GetLmTailRing();
1735 
1736  if (h_p == NULL)
1737  {
1738  kDeleteLcm(h);
1739  return 0;
1740  }
1741  if (TEST_OPT_IDLIFT)
1742  {
1743  if (h->p!=NULL)
1744  {
1745  if(p_GetComp(h->p,currRing)>strat->syzComp)
1746  {
1747  h->Delete();
1748  return 0;
1749  }
1750  }
1751  else if (h->t_p!=NULL)
1752  {
1753  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1754  {
1755  h->Delete();
1756  return 0;
1757  }
1758  }
1759  }
1760  #if 0
1761  else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1762  {
1763  if (h->p!=NULL)
1764  {
1765  if(p_GetComp(h->p,currRing)>strat->syzComp)
1766  {
1767  return 1;
1768  }
1769  }
1770  else if (h->t_p!=NULL)
1771  {
1772  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1773  {
1774  return 1;
1775  }
1776  }
1777  }
1778  #endif
1779  h->SetShortExpVector();
1780  not_sev = ~ h->sev;
1781  d = h->SetpFDeg();
1782  /*- try to reduce the s-polynomial -*/
1783  pass++;
1784  if (//!TEST_OPT_REDTHROUGH &&
1785  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1786  {
1787  h->SetLmCurrRing();
1788  at = strat->posInL(strat->L,strat->Ll,h,strat);
1789  if (at <= strat->Ll)
1790  {
1791 #if 1
1792 #ifdef HAVE_SHIFTBBA
1793  if (rIsLPRing(currRing))
1794  {
1795  if (kFindDivisibleByInT(strat, h) < 0)
1796  return 1;
1797  }
1798  else
1799 #endif
1800  {
1801  int dummy=strat->sl;
1802  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1803  return 1;
1804  }
1805 #endif
1806 #ifdef KDEBUG
1807  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1808 #endif
1809  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1810  h->Clear();
1811  return -1;
1812  }
1813  }
1814  else if (d != reddeg)
1815  {
1816  if (d>=(long)strat->tailRing->bitmask)
1817  {
1818  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1819  {
1820  strat->overflow=TRUE;
1821  //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1822  h->GetP();
1823  at = strat->posInL(strat->L,strat->Ll,h,strat);
1824  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1825  h->Clear();
1826  return -1;
1827  }
1828  }
1829  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1830  {
1831  Print(".%ld",d);mflush();
1832  reddeg = d;
1833  }
1834  }
1835  }
1836 }

◆ redLiftstd()

int redLiftstd ( LObject h,
kStrategy  strat 
)

Definition at line 161 of file kLiftstd.cc.

162 {
163  if (strat->tl<0) return 1;
164  assume(h->FDeg == h->pFDeg());
165  poly h_p;
166  int i,j,at,pass,ei, ii, h_d,ci;
167  unsigned long not_sev;
168  long reddeg,d;
169  number A[500];
170  poly C[500];
171  poly T[500];
172  memset(T,0,sizeof(T));
173  memset(C,0,sizeof(T));
174  const ring tailRing=strat->tailRing;
175 
176  pass = j = 0;
177  d = reddeg = h->GetpFDeg() + h->ecart;
178  h->SetShortExpVector();
179  int li;
180  h_p = h->GetLmTailRing();
181  not_sev = ~ h->sev;
182 
183  // split h into mina part (h) and tail (h_tail)
184  poly h_tail=kSplitAt(strat->syzComp,h,strat);
185  // fix h-pLength
186  h->pLength=0;
187  // remove content
188  //number cont;
189  //p_Content_n(h_p,cont,strat->tailRing);
190  //if (!n_IsOne(cont,strat->tailRing))
191  // h_tail=p_Div_nn(h_tail,cont,tailRing);
192 
193  h->PrepareRed(strat->use_buckets);
194  loop
195  {
196  j=kFindDivisibleByInT(strat, h);
197  if (j < 0)
198  {
199  // lazy computation:
200  int l;
201  poly p=lazyComp(A,C,T,pass,h_tail,&l,strat->tailRing);
202  kBucket_Add_q(h->bucket,p,&l);
203  return 1;
204  }
205 
206  ei = strat->T[j].ecart;
207  li = strat->T[j].pLength;
208  ci = nSize(pGetCoeff(strat->T[j].p));
209  if (li<=0) li=strat->T[j].GetpLength();
210  ii = j;
211  /*
212  * the polynomial to reduce with (up to the moment) is;
213  * pi with ecart ei (T[ii])
214  */
215  i = j;
216  if (TEST_OPT_LENGTH)
217  loop
218  {
219  /*- possible with respect to ecart, minimal nSize -*/
220  i++;
221  if (i > strat->tl)
222  break;
223  //if (ei < h->ecart)
224  // break;
225  if (li==1)
226  break;
227  if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
228  || ((strat->T[i].ecart <= h->ecart)
229  && (strat->T[i].pLength <= li)
230  && (nSize(pGetCoeff(strat->T[i].p)) <ci)))
231  &&
232  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
233  h_p, not_sev, tailRing))
234  {
235  /*
236  * the polynomial to reduce with is now;
237  */
238  ei = strat->T[i].ecart;
239  li = strat->T[i].pLength;
240  if (li<=0) li=strat->T[i].GetpLength();
241  ii = i;
242  }
243  }
244 
245  /*
246  * end of search: have to reduce with pi
247  */
248 #ifdef KDEBUG
249  if (TEST_OPT_DEBUG)
250  {
251  PrintS("red:");
252  h->wrp();
253  Print("\nwith T[%d]:",ii);
254  strat->T[ii].wrp();
255  }
256 #endif
257  assume(strat->fromT == FALSE);
258 
259  //strat->T[ii].pCleardenom();
260  // split T[ii]:
261  // remember pLength of strat->T[ii]
262  int l_orig=strat->T[ii].pLength;
263  // split strat->T[ii]
264  poly T_tail=kSplitAt(strat->syzComp,&strat->T[ii],&strat->T[ii].pLength,strat);
265  ksReducePoly(h,&(strat->T[ii]),NULL,&A[pass],&C[pass], strat);
266  // restore T[ii]:
267  kAppend(T_tail,&strat->T[ii]);
268  strat->T[ii].pLength=l_orig;
269  // store T_tail
270  T[pass]=T_tail;
271  // delayed computation: A[pass]*tail-M[pass]*T[pass]
272 #ifdef KDEBUG
273  if (TEST_OPT_DEBUG)
274  {
275  PrintS("\nto:");
276  h->wrp();
277  PrintLn();
278  }
279 #endif
280  if(h->IsNull())
281  {
282  // clean up A,C,h_tail:
283  for(int i=0;i<=pass;i++)
284  {
285  n_Delete(&A[i],tailRing->cf);
286  p_Delete(&C[i],tailRing);
287  }
288  p_Delete(&h_tail,tailRing);
289  kDeleteLcm(h);
290  h->Clear();
291  return 0;
292  }
293  h->SetShortExpVector();
294  not_sev = ~ h->sev;
295  h_d = h->SetpFDeg();
296  /* compute the ecart */
297  if (ei <= h->ecart)
298  h->ecart = d-h_d;
299  else
300  h->ecart = d-h_d+ei-h->ecart;
301 
302  /*
303  * try to reduce the s-polynomial h
304  *test first whether h should go to the lazyset L
305  *-if the degree jumps
306  *-if the number of pre-defined reductions jumps
307  */
308  pass++;
309  d = h_d + h->ecart;
310  if (pass%64==0) kBucketCanonicalize(h->bucket);
311  }
312 }
static poly lazyComp(number *A, poly *M, poly *T, int index, poly s, int *l, const ring tailR)
Definition: kLiftstd.cc:134
static void kAppend(poly t, TObject *h)
Definition: kLiftstd.cc:103
static poly kSplitAt(int k, poly p, const ring r)
Definition: kLiftstd.cc:27
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 2071 of file kstd2.cc.

2072 {
2073 #define REDNF_CANONICALIZE 60
2074  if (h==NULL) return NULL;
2075  int j;
2076  int cnt=REDNF_CANONICALIZE;
2077  max_ind=strat->sl;
2078 
2079  if (0 > strat->sl)
2080  {
2081  return h;
2082  }
2083  LObject P(h);
2084  P.SetShortExpVector();
2085  P.bucket = kBucketCreate(currRing);
2086  kBucketInit(P.bucket,P.p,pLength(P.p));
2087  kbTest(P.bucket);
2088 #ifdef HAVE_RINGS
2089  BOOLEAN is_ring = rField_is_Ring(currRing);
2090 #endif
2091 #ifdef KDEBUG
2092 // if (TEST_OPT_DEBUG)
2093 // {
2094 // PrintS("redNF: starting S:\n");
2095 // for( j = 0; j <= max_ind; j++ )
2096 // {
2097 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2098 // pWrite(strat->S[j]);
2099 // }
2100 // };
2101 #endif
2102 
2103  loop
2104  {
2105  j=kFindDivisibleByInS(strat,&max_ind,&P);
2106  if (j>=0)
2107  {
2108 #ifdef HAVE_RINGS
2109  if (!is_ring)
2110  {
2111 #endif
2112  int sl=pSize(strat->S[j]);
2113  int jj=j;
2114  loop
2115  {
2116  int sll;
2117  jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
2118  if (jj<0) break;
2119  sll=pSize(strat->S[jj]);
2120  if (sll<sl)
2121  {
2122  #ifdef KDEBUG
2123  if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2124  #endif
2125  //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2126  j=jj;
2127  sl=sll;
2128  }
2129  }
2130  if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2131  {
2132  pNorm(strat->S[j]);
2133  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2134  }
2135 #ifdef HAVE_RINGS
2136  }
2137 #endif
2138  nNormalize(pGetCoeff(P.p));
2139 #ifdef KDEBUG
2140  if (TEST_OPT_DEBUG)
2141  {
2142  PrintS("red:");
2143  wrp(h);
2144  PrintS(" with ");
2145  wrp(strat->S[j]);
2146  }
2147 #endif
2148 #ifdef HAVE_PLURAL
2149  if (rIsPluralRing(currRing))
2150  {
2151  number coef;
2152  nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef);
2153  nDelete(&coef);
2154  }
2155  else
2156 #endif
2157  {
2158  number coef;
2159  coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
2160  nDelete(&coef);
2161  }
2162  cnt--;
2163  if (cnt==0)
2164  {
2165  kBucketCanonicalize(P.bucket);
2166  cnt=REDNF_CANONICALIZE;
2167  }
2168  h = kBucketGetLm(P.bucket); // FRAGE OLIVER
2169  if (h==NULL)
2170  {
2171  kBucketDestroy(&P.bucket);
2172 
2173 #ifdef KDEBUG
2174 // if (TEST_OPT_DEBUG)
2175 // {
2176 // PrintS("redNF: starting S:\n");
2177 // for( j = 0; j <= max_ind; j++ )
2178 // {
2179 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2180 // pWrite(strat->S[j]);
2181 // }
2182 // };
2183 #endif
2184 
2185  return NULL;
2186  }
2187  kbTest(P.bucket);
2188  P.p=h;
2189  P.t_p=NULL;
2190  P.SetShortExpVector();
2191 #ifdef KDEBUG
2192  if (TEST_OPT_DEBUG)
2193  {
2194  PrintS("\nto:");
2195  wrp(h);
2196  PrintLn();
2197  }
2198 #endif
2199  }
2200  else
2201  {
2202  P.p=kBucketClear(P.bucket);
2203  kBucketDestroy(&P.bucket);
2204  pNormalize(P.p);
2205 
2206 #ifdef KDEBUG
2207 // if (TEST_OPT_DEBUG)
2208 // {
2209 // PrintS("redNF: starting S:\n");
2210 // for( j = 0; j <= max_ind; j++ )
2211 // {
2212 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2213 // pWrite(strat->S[j]);
2214 // }
2215 // };
2216 #endif
2217 
2218  return P.p;
2219  }
2220  }
2221 }
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
#define REDNF_CANONICALIZE
int kFindNextDivisibleByInS(const kStrategy strat, int start, int max_ind, LObject *L)
Definition: kstd2.cc:467
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 383 of file kstd1.cc.

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

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 795 of file kstd2.cc.

796 {
797  if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors)
798  if (strat->tl<0) return 1;
799 
800  int at/*,i*/;
801  long d;
802  int j = 0;
803  int pass = 0;
804  // poly zeroPoly = NULL;
805 
806 // TODO warum SetpFDeg notwendig?
807  h->SetpFDeg();
808  assume(h->pFDeg() == h->FDeg);
809  long reddeg = h->GetpFDeg();
810 
811  h->SetShortExpVector();
812  loop
813  {
814  j = kFindDivisibleByInT(strat, h);
815  if (j < 0)
816  {
817  // over ZZ: cleanup coefficients by complete reduction with monomials
818  postReduceByMon(h, strat);
819  if(h->p == NULL)
820  {
821  kDeleteLcm(h);
822  h->Clear();
823  return 0;
824  }
825  if(nIsZero(pGetCoeff(h->p))) return 2;
826  j = kFindDivisibleByInT(strat, h);
827  if(j < 0)
828  {
829  if(strat->tl >= 0)
830  h->i_r1 = strat->tl;
831  else
832  h->i_r1 = -1;
833  if (h->GetLmTailRing() == NULL)
834  {
835  kDeleteLcm(h);
836  h->Clear();
837  return 0;
838  }
839  return 1;
840  }
841  }
842  //printf("\nFound one: ");pWrite(strat->T[j].p);
843  //enterT(*h, strat);
844  ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat); // with debug output
845  //printf("\nAfter small red: ");pWrite(h->p);
846  if (h->GetLmTailRing() == NULL)
847  {
848  kDeleteLcm(h);
849  h->Clear();
850  return 0;
851  }
852  h->SetShortExpVector();
853  d = h->SetpFDeg();
854  /*- try to reduce the s-polynomial -*/
855  pass++;
856  if (!TEST_OPT_REDTHROUGH &&
857  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
858  {
859  h->SetLmCurrRing();
860  if (strat->posInLDependsOnLength)
861  h->SetLength(strat->length_pLength);
862  at = strat->posInL(strat->L,strat->Ll,h,strat);
863  if (at <= strat->Ll)
864  {
865 #ifdef KDEBUG
866  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
867 #endif
868  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
869  h->Clear();
870  return -1;
871  }
872  }
873  if (d != reddeg)
874  {
875  if (d >= (long)strat->tailRing->bitmask)
876  {
877  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
878  {
879  strat->overflow=TRUE;
880  //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
881  h->GetP();
882  at = strat->posInL(strat->L,strat->Ll,h,strat);
883  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
884  h->Clear();
885  return -1;
886  }
887  }
888  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
889  {
890  Print(".%ld",d);mflush();
891  reddeg = d;
892  }
893  }
894  }
895 }

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 640 of file kstd2.cc.

641 {
642  if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors)
643  if (strat->tl<0) return 1;
644 
645  int at;
646  long d;
647  int j = 0;
648  int pass = 0;
649 
650 // TODO warum SetpFDeg notwendig?
651  h->SetpFDeg();
652  assume(h->pFDeg() == h->FDeg);
653  long reddeg = h->GetpFDeg();
654 
655  h->SetShortExpVector();
656  loop
657  {
658  /* check if a reducer of the lead term exists */
659  j = kFindDivisibleByInT(strat, h);
660  if (j < 0)
661  {
662  /* check if a reducer with the same lead monomial exists */
663  j = kFindSameLMInT_Z(strat, h);
664  if (j < 0)
665  {
666  /* check if a reducer of the lead monomial exists, by the above
667  * check this is a real divisor of the lead monomial */
668  j = kFindDivisibleByInT_Z(strat, h);
669  if (j < 0)
670  {
671  // over ZZ: cleanup coefficients by complete reduction with monomials
673  postReduceByMon(h, strat);
674  if(h->p == NULL)
675  {
676  if (h->lcm!=NULL) pLmDelete(h->lcm);
677  h->Clear();
678  return 0;
679  }
680  if(nIsZero(pGetCoeff(h->p))) return 2;
681  j = kFindDivisibleByInT(strat, h);
682  if(j < 0)
683  {
684  if(strat->tl >= 0)
685  h->i_r1 = strat->tl;
686  else
687  h->i_r1 = -1;
688  if (h->GetLmTailRing() == NULL)
689  {
690  if (h->lcm!=NULL) pLmDelete(h->lcm);
691  h->Clear();
692  return 0;
693  }
694  return 1;
695  }
696  }
697  else
698  {
699  /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
700  * => we try to cut down the lead coefficient at least */
701  /* first copy T[j] in order to multiply it with a coefficient later on */
702  number mult, rest;
703  TObject tj = strat->T[j];
704  tj.Copy();
705  /* tj.max_exp = strat->T[j].max_exp; */
706  /* compute division with remainder of lc(h) and lc(T[j]) */
707  mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
708  &rest, currRing->cf);
709  /* set corresponding new lead coefficient already. we do not
710  * remove the lead term in ksReducePolyLC, but only apply
711  * a lead coefficient reduction */
712  tj.Mult_nn(mult);
713  ksReducePolyLC(h, &tj, NULL, &rest, strat);
714  tj.Delete();
715  tj.Clear();
716  }
717  }
718  else
719  {
720  /* same lead monomial but lead coefficients do not divide each other:
721  * change the polys to h <- spoly(h,tj) and h2 <- gpoly(h,tj). */
722  LObject h2 = *h;
723  h2.Copy();
724 
725  ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat);
726  ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat);
728  {
729  redtailBbaAlsoLC_Z(&h2, j, strat);
730  h2.pCleardenom();
731  }
732  /* replace h2 for tj in L (already generated pairs with tj), S and T */
733  replaceInLAndSAndT(h2, j, strat);
734  }
735  }
736  else
737  {
738  ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat);
739  }
740  /* printf("\nAfter small red: ");pWrite(h->p); */
741  if (h->GetLmTailRing() == NULL)
742  {
743  if (h->lcm!=NULL) pLmDelete(h->lcm);
744 #ifdef KDEBUG
745  h->lcm=NULL;
746 #endif
747  h->Clear();
748  return 0;
749  }
750  h->SetShortExpVector();
751  d = h->SetpFDeg();
752  /*- try to reduce the s-polynomial -*/
753  pass++;
754  if (!TEST_OPT_REDTHROUGH &&
755  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
756  {
757  h->SetLmCurrRing();
758  if (strat->posInLDependsOnLength)
759  h->SetLength(strat->length_pLength);
760  at = strat->posInL(strat->L,strat->Ll,h,strat);
761  if (at <= strat->Ll)
762  {
763 #ifdef KDEBUG
764  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
765 #endif
766  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
767  h->Clear();
768  return -1;
769  }
770  }
771  if (d != reddeg)
772  {
773  if (d >= (long)strat->tailRing->bitmask)
774  {
775  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
776  {
777  strat->overflow=TRUE;
778  //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
779  h->GetP();
780  at = strat->posInL(strat->L,strat->Ll,h,strat);
781  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
782  h->Clear();
783  return -1;
784  }
785  }
786  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
787  {
788  Print(".%ld",d);mflush();
789  reddeg = d;
790  }
791  }
792  }
793 }
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:452
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:316
int kFindSameLMInT_Z(const kStrategy strat, const LObject *L, const int start)
Definition: kstd2.cc:84
int kFindDivisibleByInT_Z(const kStrategy strat, const LObject *L, const int start)
Definition: kstd2.cc:207
void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat)
Definition: kutil.cc:9608

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 1111 of file kstd2.cc.

1112 {
1113  if (strat->tl<0) return 1;
1114  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1115  //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1116  assume(h->FDeg == h->pFDeg());
1117 //#if 1
1118 #ifdef DEBUGF5
1119  PrintS("------- IN REDSIG -------\n");
1120  Print("p: ");
1121  pWrite(pHead(h->p));
1122  PrintS("p1: ");
1123  pWrite(pHead(h->p1));
1124  PrintS("p2: ");
1125  pWrite(pHead(h->p2));
1126  PrintS("---------------------------\n");
1127 #endif
1128  poly h_p;
1129  int i,j,at,pass, ii;
1130  int start=0;
1131  int sigSafe;
1132  unsigned long not_sev;
1133  // long reddeg,d;
1134 
1135  pass = j = 0;
1136  // d = reddeg = h->GetpFDeg();
1137  h->SetShortExpVector();
1138  int li;
1139  h_p = h->GetLmTailRing();
1140  not_sev = ~ h->sev;
1141  loop
1142  {
1143  j = kFindDivisibleByInT(strat, h, start);
1144  if (j < 0)
1145  {
1146  return 1;
1147  }
1148 
1149  li = strat->T[j].pLength;
1150  if (li<=0) li=strat->T[j].GetpLength();
1151  ii = j;
1152  /*
1153  * the polynomial to reduce with (up to the moment) is;
1154  * pi with length li
1155  */
1156  i = j;
1157 #if 1
1158  if (TEST_OPT_LENGTH)
1159  loop
1160  {
1161  /*- search the shortest possible with respect to length -*/
1162  i++;
1163  if (i > strat->tl)
1164  break;
1165  if (li==1)
1166  break;
1167  if ((strat->T[i].pLength < li)
1168  &&
1169  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1170  h_p, not_sev, strat->tailRing))
1171  {
1172  /*
1173  * the polynomial to reduce with is now;
1174  */
1175  li = strat->T[i].pLength;
1176  if (li<=0) li=strat->T[i].GetpLength();
1177  ii = i;
1178  }
1179  }
1180  start = ii+1;
1181 #endif
1182 
1183  /*
1184  * end of search: have to reduce with pi
1185  */
1186 #ifdef KDEBUG
1187  if (TEST_OPT_DEBUG)
1188  {
1189  PrintS("red:");
1190  h->wrp();
1191  PrintS(" with ");
1192  strat->T[ii].wrp();
1193  }
1194 #endif
1195  assume(strat->fromT == FALSE);
1196 //#if 1
1197 #ifdef DEBUGF5
1198  Print("BEFORE REDUCTION WITH %d:\n",ii);
1199  PrintS("--------------------------------\n");
1200  pWrite(h->sig);
1201  pWrite(strat->T[ii].sig);
1202  pWrite(h->GetLmCurrRing());
1203  pWrite(pHead(h->p1));
1204  pWrite(pHead(h->p2));
1205  pWrite(pHead(strat->T[ii].p));
1206  PrintS("--------------------------------\n");
1207  printf("INDEX OF REDUCER T: %d\n",ii);
1208 #endif
1209  sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1210 #if SBA_PRINT_REDUCTION_STEPS
1211  if (sigSafe != 3)
1212  sba_reduction_steps++;
1213 #endif
1214 #if SBA_PRINT_OPERATIONS
1215  if (sigSafe != 3)
1216  sba_operations += pLength(strat->T[ii].p);
1217 #endif
1218  // if reduction has taken place, i.e. the reduction was sig-safe
1219  // otherwise start is already at the next position and the loop
1220  // searching reducers in T goes on from index start
1221 //#if 1
1222 #ifdef DEBUGF5
1223  Print("SigSAFE: %d\n",sigSafe);
1224 #endif
1225  if (sigSafe != 3)
1226  {
1227  // start the next search for reducers in T from the beginning
1228  start = 0;
1229 #ifdef KDEBUG
1230  if (TEST_OPT_DEBUG)
1231  {
1232  PrintS("\nto ");
1233  h->wrp();
1234  PrintLn();
1235  }
1236 #endif
1237 
1238  h_p = h->GetLmTailRing();
1239  if (h_p == NULL)
1240  {
1241  kDeleteLcm(h);
1242  return 0;
1243  }
1244  h->SetShortExpVector();
1245  not_sev = ~ h->sev;
1246  /*
1247  * try to reduce the s-polynomial h
1248  *test first whether h should go to the lazyset L
1249  *-if the degree jumps
1250  *-if the number of pre-defined reductions jumps
1251  */
1252  pass++;
1253  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1254  {
1255  h->SetLmCurrRing();
1256  at = strat->posInL(strat->L,strat->Ll,h,strat);
1257  if (at <= strat->Ll)
1258  {
1259  int dummy=strat->sl;
1260  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1261  {
1262  return 1;
1263  }
1264  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1265 #ifdef KDEBUG
1266  if (TEST_OPT_DEBUG)
1267  Print(" lazy: -> L%d\n",at);
1268 #endif
1269  h->Clear();
1270  return -1;
1271  }
1272  }
1273  }
1274  }
1275 }
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:707

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1278 of file kstd2.cc.

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

◆ redtail() [1/2]

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

Definition at line 7480 of file kutil.cc.

7481 {
7482  poly h, hn;
7483  strat->redTailChange=FALSE;
7484 
7485  L->GetP();
7486  poly p = L->p;
7487  if (strat->noTailReduction || pNext(p) == NULL)
7488  return p;
7489 
7490  LObject Ln(strat->tailRing);
7491  TObject* With;
7492  // placeholder in case strat->tl < 0
7493  TObject With_s(strat->tailRing);
7494  h = p;
7495  hn = pNext(h);
7496  long op = strat->tailRing->pFDeg(hn, strat->tailRing);
7497  long e;
7498  int l;
7499  BOOLEAN save_HE=strat->kHEdgeFound;
7500  strat->kHEdgeFound |=
7501  ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
7502 
7503  while(hn != NULL)
7504  {
7505  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7506  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7507  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7508  loop
7509  {
7510  Ln.Set(hn, strat->tailRing);
7511  Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
7512  if (strat->kHEdgeFound)
7513  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7514  else
7515  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
7516  if (With == NULL) break;
7517  With->length=0;
7518  With->pLength=0;
7519  strat->redTailChange=TRUE;
7520  if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
7521  {
7522  // reducing the tail would violate the exp bound
7523  if (kStratChangeTailRing(strat, L))
7524  {
7525  strat->kHEdgeFound = save_HE;
7526  return redtail(L, end_pos, strat);
7527  }
7528  else
7529  return NULL;
7530  }
7531  hn = pNext(h);
7532  if (hn == NULL) goto all_done;
7533  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7534  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7535  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7536  }
7537  h = hn;
7538  hn = pNext(h);
7539  }
7540 
7541  all_done:
7542  if (strat->redTailChange)
7543  {
7544  L->pLength = 0;
7545  }
7546  strat->kHEdgeFound = save_HE;
7547  return p;
7548 }
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:7338
#define TEST_OPT_INFREDTAIL
Definition: options.h:117

◆ redtail() [2/2]

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

Definition at line 7550 of file kutil.cc.

7551 {
7552  LObject L(p, currRing);
7553  return redtail(&L, end_pos, strat);
7554 }

◆ redtailBba() [1/3]

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

Definition at line 7556 of file kutil.cc.

7557 {
7558 #define REDTAIL_CANONICALIZE 100
7559  strat->redTailChange=FALSE;
7560  if (strat->noTailReduction) return L->GetLmCurrRing();
7561  poly h, p;
7562  p = h = L->GetLmTailRing();
7563  if ((h==NULL) || (pNext(h)==NULL))
7564  return L->GetLmCurrRing();
7565 
7566  TObject* With;
7567  // placeholder in case strat->tl < 0
7568  TObject With_s(strat->tailRing);
7569 
7570  LObject Ln(pNext(h), strat->tailRing);
7571  Ln.GetpLength();
7572 
7573  pNext(h) = NULL;
7574  if (L->p != NULL)
7575  {
7576  pNext(L->p) = NULL;
7577  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7578  }
7579  L->pLength = 1;
7580 
7581  Ln.PrepareRed(strat->use_buckets);
7582 
7583  int cnt=REDTAIL_CANONICALIZE;
7584  while(!Ln.IsNull())
7585  {
7586  loop
7587  {
7588  if (TEST_OPT_IDLIFT)
7589  {
7590  if (Ln.p!=NULL)
7591  {
7592  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7593  }
7594  else
7595  {
7596  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7597  }
7598  }
7599  Ln.SetShortExpVector();
7600  if (withT)
7601  {
7602  int j;
7603  j = kFindDivisibleByInT(strat, &Ln);
7604  if (j < 0) break;
7605  With = &(strat->T[j]);
7606  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7607  }
7608  else
7609  {
7610  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7611  if (With == NULL) break;
7612  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7613  }
7614  cnt--;
7615  if (cnt==0)
7616  {
7618  /*poly tmp=*/Ln.CanonicalizeP();
7619  if (normalize)
7620  {
7621  Ln.Normalize();
7622  //pNormalize(tmp);
7623  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7624  }
7625  }
7626  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7627  {
7628  With->pNorm();
7629  }
7630  strat->redTailChange=TRUE;
7631  if (ksReducePolyTail(L, With, &Ln))
7632  {
7633  // reducing the tail would violate the exp bound
7634  // set a flag and hope for a retry (in bba)
7635  strat->completeReduce_retry=TRUE;
7636  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7637  do
7638  {
7639  pNext(h) = Ln.LmExtractAndIter();
7640  pIter(h);
7641  L->pLength++;
7642  } while (!Ln.IsNull());
7643  goto all_done;
7644  }
7645  if (Ln.IsNull()) goto all_done;
7646  if (! withT) With_s.Init(currRing);
7647  }
7648  pNext(h) = Ln.LmExtractAndIter();
7649  pIter(h);
7650  pNormalize(h);
7651  L->pLength++;
7652  }
7653 
7654  all_done:
7655  Ln.Delete();
7656  if (L->p != NULL) pNext(L->p) = pNext(p);
7657 
7658  if (strat->redTailChange)
7659  {
7660  L->length = 0;
7661  L->pLength = 0;
7662  }
7663 
7664  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7665  //L->Normalize(); // HANNES: should have a test
7666  kTest_L(L,strat->tailRing);
7667  return L->GetLmCurrRing();
7668 }
#define REDTAIL_CANONICALIZE
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 1180 of file kInline.h.

1181 {
1182  LObject L(p);
1183  return redtailBba(&L, pos, strat,FALSE, normalize);
1184 }

◆ redtailBba() [3/3]

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

◆ redtailBba_Z() [1/2]

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

Definition at line 7915 of file kutil.cc.

7917 {
7918  strat->redTailChange=FALSE;
7919  if (strat->noTailReduction) return L->GetLmCurrRing();
7920  poly h, p;
7921  p = h = L->GetLmTailRing();
7922  if ((h==NULL) || (pNext(h)==NULL))
7923  return L->GetLmCurrRing();
7924 
7925  TObject* With;
7926  // placeholder in case strat->tl < 0
7927  TObject With_s(strat->tailRing);
7928 
7929  LObject Ln(pNext(h), strat->tailRing);
7930  Ln.pLength = L->GetpLength() - 1;
7931 
7932  pNext(h) = NULL;
7933  if (L->p != NULL) pNext(L->p) = NULL;
7934  L->pLength = 1;
7935 
7936  Ln.PrepareRed(strat->use_buckets);
7937 
7938  int cnt=REDTAIL_CANONICALIZE;
7939  while(!Ln.IsNull())
7940  {
7941  loop
7942  {
7943  Ln.SetShortExpVector();
7944  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7945  if (With == NULL) break;
7946  cnt--;
7947  if (cnt==0)
7948  {
7950  /*poly tmp=*/Ln.CanonicalizeP();
7951  }
7952  // we are in Z, do not call pNorm
7953  strat->redTailChange=TRUE;
7954  // test divisibility of coefs:
7955  poly p_Ln=Ln.GetLmCurrRing();
7956  poly p_With=With->GetLmCurrRing();
7957  number z=n_IntMod(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf);
7958  if (!nIsZero(z))
7959  {
7960  // subtract z*Ln, add z.Ln to L
7961  poly m=pHead(p_Ln);
7962  pSetCoeff(m,z);
7963  poly mm=pHead(m);
7964  pNext(h) = m;
7965  pIter(h);
7966  L->pLength++;
7967  mm=pNeg(mm);
7968  if (Ln.bucket!=NULL)
7969  {
7970  int dummy=1;
7971  kBucket_Add_q(Ln.bucket,mm,&dummy);
7972  }
7973  else
7974  {
7975  if ((Ln.t_p!=NULL)&&(Ln.p==NULL))
7976  Ln.GetP();
7977  if (Ln.p!=NULL)
7978  {
7979  Ln.p=pAdd(Ln.p,mm);
7980  if (Ln.t_p!=NULL)
7981  {
7982  pNext(Ln.t_p)=NULL;
7983  p_LmDelete(Ln.t_p,strat->tailRing);
7984  }
7985  }
7986  }
7987  }
7988  else
7989  nDelete(&z);
7990 
7991  if (ksReducePolyTail(L, With, &Ln))
7992  {
7993  // reducing the tail would violate the exp bound
7994  // set a flag and hope for a retry (in bba)
7995  strat->completeReduce_retry=TRUE;
7996  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7997  do
7998  {
7999  pNext(h) = Ln.LmExtractAndIter();
8000  pIter(h);
8001  L->pLength++;
8002  } while (!Ln.IsNull());
8003  goto all_done;
8004  }
8005  if (Ln.IsNull()) goto all_done;
8006  With_s.Init(currRing);
8007  }
8008  pNext(h) = Ln.LmExtractAndIter();
8009  pIter(h);
8010  pNormalize(h);
8011  L->pLength++;
8012  }
8013 
8014  all_done:
8015  Ln.Delete();
8016  if (L->p != NULL) pNext(L->p) = pNext(p);
8017 
8018  if (strat->redTailChange)
8019  {
8020  L->length = 0;
8021  }
8022 
8023  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
8024  //L->Normalize(); // HANNES: should have a test
8025  kTest_L(L,strat->tailRing);
8026  return L->GetLmCurrRing();
8027 }
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 1193 of file kInline.h.

1194 {
1195  LObject L(p, currRing, strat->tailRing);
1196  return redtailBba_Z(&L, pos, strat);
1197 }

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7786 of file kutil.cc.

7788 {
7789  strat->redTailChange=FALSE;
7790 
7791  poly h, p;
7792  p = h = L->GetLmTailRing();
7793  if ((h==NULL) || (pNext(h)==NULL))
7794  return;
7795 
7796  TObject* With;
7797  LObject Ln(pNext(h), strat->tailRing);
7798  Ln.GetpLength();
7799 
7800  pNext(h) = NULL;
7801  if (L->p != NULL)
7802  {
7803  pNext(L->p) = NULL;
7804  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7805  }
7806  L->pLength = 1;
7807 
7808  Ln.PrepareRed(strat->use_buckets);
7809 
7810  int cnt=REDTAIL_CANONICALIZE;
7811 
7812  while(!Ln.IsNull())
7813  {
7814  loop
7815  {
7816  if (TEST_OPT_IDLIFT)
7817  {
7818  if (Ln.p!=NULL)
7819  {
7820  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7821  }
7822  else
7823  {
7824  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7825  }
7826  }
7827  Ln.SetShortExpVector();
7828  int j;
7829  j = kFindDivisibleByInT(strat, &Ln);
7830  if (j < 0)
7831  {
7832  j = kFindDivisibleByInT_Z(strat, &Ln);
7833  if (j < 0)
7834  {
7835  break;
7836  }
7837  else
7838  {
7839  /* reduction not cancelling a tail term, but reducing its coefficient */
7840  With = &(strat->T[j]);
7841  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7842  cnt--;
7843  if (cnt==0)
7844  {
7846  /*poly tmp=*/Ln.CanonicalizeP();
7847  }
7848  strat->redTailChange=TRUE;
7849  /* reduction cancelling a tail term */
7850  if (ksReducePolyTailLC_Z(L, With, &Ln))
7851  {
7852  // reducing the tail would violate the exp bound
7853  // set a flag and hope for a retry (in bba)
7854  strat->completeReduce_retry=TRUE;
7855  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7856  do
7857  {
7858  pNext(h) = Ln.LmExtractAndIter();
7859  pIter(h);
7860  L->pLength++;
7861  } while (!Ln.IsNull());
7862  goto all_done;
7863  }
7864  /* we have to break since we did not cancel the term, but only decreased
7865  * its coefficient. */
7866  break;
7867  }
7868  } else {
7869  With = &(strat->T[j]);
7870  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7871  cnt--;
7872  if (cnt==0)
7873  {
7875  /*poly tmp=*/Ln.CanonicalizeP();
7876  }
7877  strat->redTailChange=TRUE;
7878  /* reduction cancelling a tail term */
7879  if (ksReducePolyTail_Z(L, With, &Ln))
7880  {
7881  // reducing the tail would violate the exp bound
7882  // set a flag and hope for a retry (in bba)
7883  strat->completeReduce_retry=TRUE;
7884  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7885  do
7886  {
7887  pNext(h) = Ln.LmExtractAndIter();
7888  pIter(h);
7889  L->pLength++;
7890  } while (!Ln.IsNull());
7891  goto all_done;
7892  }
7893  }
7894  if (Ln.IsNull()) goto all_done;
7895  }
7896  pNext(h) = Ln.LmExtractAndIter();
7897  pIter(h);
7898  L->pLength++;
7899  }
7900 
7901  all_done:
7902  Ln.Delete();
7903  if (L->p != NULL) pNext(L->p) = pNext(p);
7904 
7905  if (strat->redTailChange)
7906  {
7907  L->length = 0;
7908  L->pLength = 0;
7909  }
7910 
7911  kTest_L(L, strat->tailRing);
7912  return;
7913 }
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1077
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1095

◆ redtailBbaBound() [1/2]

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

Definition at line 7670 of file kutil.cc.

7671 {
7672  strat->redTailChange=FALSE;
7673  if (strat->noTailReduction) return L->GetLmCurrRing();
7674  poly h, p;
7675  p = h = L->GetLmTailRing();
7676  if ((h==NULL) || (pNext(h)==NULL))
7677  return L->GetLmCurrRing();
7678 
7679  TObject* With;
7680  // placeholder in case strat->tl < 0
7681  TObject With_s(strat->tailRing);
7682 
7683  LObject Ln(pNext(h), strat->tailRing);
7684  Ln.pLength = L->GetpLength() - 1;
7685 
7686  pNext(h) = NULL;
7687  if (L->p != NULL) pNext(L->p) = NULL;
7688  L->pLength = 1;
7689 
7690  Ln.PrepareRed(strat->use_buckets);
7691 
7692  int cnt=REDTAIL_CANONICALIZE;
7693  while(!Ln.IsNull())
7694  {
7695  loop
7696  {
7697  if (TEST_OPT_IDLIFT)
7698  {
7699  if (Ln.p!=NULL)
7700  {
7701  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7702  }
7703  else
7704  {
7705  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7706  }
7707  }
7708  Ln.SetShortExpVector();
7709  if (withT)
7710  {
7711  int j;
7712  j = kFindDivisibleByInT(strat, &Ln);
7713  if (j < 0) break;
7714  With = &(strat->T[j]);
7715  }
7716  else
7717  {
7718  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7719  if (With == NULL) break;
7720  }
7721  cnt--;
7722  if (cnt==0)
7723  {
7725  /*poly tmp=*/Ln.CanonicalizeP();
7726  if (normalize)
7727  {
7728  Ln.Normalize();
7729  //pNormalize(tmp);
7730  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7731  }
7732  }
7733  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7734  {
7735  With->pNorm();
7736  }
7737  strat->redTailChange=TRUE;
7738  if (ksReducePolyTail(L, With, &Ln))
7739  {
7740  // reducing the tail would violate the exp bound
7741  // set a flag and hope for a retry (in bba)
7742  strat->completeReduce_retry=TRUE;
7743  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7744  do
7745  {
7746  pNext(h) = Ln.LmExtractAndIter();
7747  pIter(h);
7748  L->pLength++;
7749  } while (!Ln.IsNull());
7750  goto all_done;
7751  }
7752  if(!Ln.IsNull())
7753  {
7754  Ln.GetP();
7755  Ln.p = pJet(Ln.p,bound);
7756  }
7757  if (Ln.IsNull())
7758  {
7759  goto all_done;
7760  }
7761  if (! withT) With_s.Init(currRing);
7762  }
7763  pNext(h) = Ln.LmExtractAndIter();
7764  pIter(h);
7765  pNormalize(h);
7766  L->pLength++;
7767  }
7768 
7769  all_done:
7770  Ln.Delete();
7771  if (L->p != NULL) pNext(L->p) = pNext(p);
7772 
7773  if (strat->redTailChange)
7774  {
7775  L->length = 0;
7776  L->pLength = 0;
7777  }
7778 
7779  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7780  //L->Normalize(); // HANNES: should have a test
7781  kTest_L(L,strat->tailRing);
7782  return L->GetLmCurrRing();
7783 }
#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 1186 of file kInline.h.

1187 {
1188  LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1189  return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1190 }

◆ redtailBbaShift()

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

Definition at line 13689 of file kutil.cc.

13690 {
13691  /* for the shift case need to run it with withT = TRUE */
13692  strat->redTailChange=FALSE;
13693  if (strat->noTailReduction) return L->GetLmCurrRing();
13694  poly h, p;
13695  p = h = L->GetLmTailRing();
13696  if ((h==NULL) || (pNext(h)==NULL))
13697  return L->GetLmCurrRing();
13698 
13699  TObject* With;
13700  // placeholder in case strat->tl < 0
13701  TObject With_s(strat->tailRing);
13702 
13703  LObject Ln(pNext(h), strat->tailRing);
13704  Ln.pLength = L->GetpLength() - 1;
13705 
13706  pNext(h) = NULL;
13707  if (L->p != NULL) pNext(L->p) = NULL;
13708  L->pLength = 1;
13709 
13710  Ln.PrepareRed(strat->use_buckets);
13711 
13712  while(!Ln.IsNull())
13713  {
13714  loop
13715  {
13716  Ln.SetShortExpVector();
13717  if (withT)
13718  {
13719  int j;
13720  j = kFindDivisibleByInT(strat, &Ln);
13721  if (j < 0) break;
13722  With = &(strat->T[j]);
13723  }
13724  else
13725  {
13726  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13727  if (With == NULL) break;
13728  }
13729  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13730  {
13731  With->pNorm();
13732  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13733  }
13734  strat->redTailChange=TRUE;
13735  if (ksReducePolyTail(L, With, &Ln))
13736  {
13737  // reducing the tail would violate the exp bound
13738  // set a flag and hope for a retry (in bba)
13739  strat->completeReduce_retry=TRUE;
13740  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13741  do
13742  {
13743  pNext(h) = Ln.LmExtractAndIter();
13744  pIter(h);
13745  L->pLength++;
13746  } while (!Ln.IsNull());
13747  goto all_done;
13748  }
13749  if (Ln.IsNull()) goto all_done;
13750  if (! withT) With_s.Init(currRing);
13751  }
13752  pNext(h) = Ln.LmExtractAndIter();
13753  pIter(h);
13754  L->pLength++;
13755  }
13756 
13757  all_done:
13758  Ln.Delete();
13759  if (L->p != NULL) pNext(L->p) = pNext(p);
13760 
13761  if (strat->redTailChange)
13762  {
13763  L->length = 0;
13764  }
13765  L->Normalize(); // HANNES: should have a test
13766  kTest_L(L,strat->tailRing);
13767  return L->GetLmCurrRing();
13768 }

◆ redtailSba()

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

Definition at line 1527 of file kstd2.cc.

1528 {
1529 #define REDTAIL_CANONICALIZE 100
1530  strat->redTailChange=FALSE;
1531  if (strat->noTailReduction) return L->GetLmCurrRing();
1532  poly h, p;
1533  p = h = L->GetLmTailRing();
1534  if ((h==NULL) || (pNext(h)==NULL))
1535  return L->GetLmCurrRing();
1536 
1537  TObject* With;
1538  // placeholder in case strat->tl < 0
1539  TObject With_s(strat->tailRing);
1540 
1541  LObject Ln(pNext(h), strat->tailRing);
1542  Ln.sig = L->sig;
1543  Ln.sevSig = L->sevSig;
1544  Ln.pLength = L->GetpLength() - 1;
1545 
1546  pNext(h) = NULL;
1547  if (L->p != NULL) pNext(L->p) = NULL;
1548  L->pLength = 1;
1549 
1550  Ln.PrepareRed(strat->use_buckets);
1551 
1552  int cnt=REDTAIL_CANONICALIZE;
1553  while(!Ln.IsNull())
1554  {
1555  loop
1556  {
1557  if(rField_is_Ring(currRing) && strat->sigdrop)
1558  break;
1559  Ln.SetShortExpVector();
1560  if (withT)
1561  {
1562  int j;
1563  j = kFindDivisibleByInT(strat, &Ln);
1564  if (j < 0) break;
1565  With = &(strat->T[j]);
1566  }
1567  else
1568  {
1569  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1570  if (With == NULL) break;
1571  }
1572  cnt--;
1573  if (cnt==0)
1574  {
1576  /*poly tmp=*/Ln.CanonicalizeP();
1578  {
1579  Ln.Normalize();
1580  //pNormalize(tmp);
1581  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1582  }
1583  }
1584  if (normalize && (!TEST_OPT_INTSTRATEGY) && !rField_is_Ring(currRing) && (!nIsOne(pGetCoeff(With->p))))
1585  {
1586  With->pNorm();
1587  }
1588  strat->redTailChange=TRUE;
1589  int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1591  L->sig = Ln.sig;
1592  //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1593  // I delete it an then set Ln.sig. Hence L->sig is lost
1594 #if SBA_PRINT_REDUCTION_STEPS
1595  if (ret != 3)
1596  sba_reduction_steps++;
1597 #endif
1598 #if SBA_PRINT_OPERATIONS
1599  if (ret != 3)
1600  sba_operations += pLength(With->p);
1601 #endif
1602  if (ret)
1603  {
1604  // reducing the tail would violate the exp bound
1605  // set a flag and hope for a retry (in bba)
1606  strat->completeReduce_retry=TRUE;
1607  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1608  do
1609  {
1610  pNext(h) = Ln.LmExtractAndIter();
1611  pIter(h);
1612  L->pLength++;
1613  } while (!Ln.IsNull());
1614  goto all_done;
1615  }
1616  if (Ln.IsNull()) goto all_done;
1617  if (! withT) With_s.Init(currRing);
1618  if(rField_is_Ring(currRing) && strat->sigdrop)
1619  {
1620  //Cannot break the loop here so easily
1621  break;
1622  }
1623  }
1624  pNext(h) = Ln.LmExtractAndIter();
1625  pIter(h);
1626  if(!rField_is_Ring(currRing))
1627  pNormalize(h);
1628  L->pLength++;
1629  }
1630  all_done:
1631  Ln.Delete();
1632  if (L->p != NULL) pNext(L->p) = pNext(p);
1633 
1634  if (strat->redTailChange)
1635  {
1636  L->length = 0;
1637  }
1638  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1639  //L->Normalize(); // HANNES: should have a test
1640  kTest_L(L,strat->tailRing);
1641  return L->GetLmCurrRing();
1642 }
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition: kstd2.cc:1073
#define REDTAIL_CANONICALIZE

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 5056 of file kutil.cc.

5057 {
5058  int i,j,at,ecart, s2r;
5059  int fq=0;
5060  unsigned long sev;
5061  poly p;
5062  int new_suc=strat->sl+1;
5063  i= *suc;
5064  if (i<0) i=0;
5065 
5066  for (; i<=strat->sl; i++)
5067  {
5068  at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
5069  if (at != i)
5070  {
5071  if (new_suc > at) new_suc = at;
5072  p = strat->S[i];
5073  ecart = strat->ecartS[i];
5074  sev = strat->sevS[i];
5075  s2r = strat->S_2_R[i];
5076  if (strat->fromQ!=NULL) fq=strat->fromQ[i];
5077  for (j=i; j>=at+1; j--)
5078  {
5079  strat->S[j] = strat->S[j-1];
5080  strat->ecartS[j] = strat->ecartS[j-1];
5081  strat->sevS[j] = strat->sevS[j-1];
5082  strat->S_2_R[j] = strat->S_2_R[j-1];
5083  }
5084  strat->S[at] = p;
5085  strat->ecartS[at] = ecart;
5086  strat->sevS[at] = sev;
5087  strat->S_2_R[at] = s2r;
5088  if (strat->fromQ!=NULL)
5089  {
5090  for (j=i; j>=at+1; j--)
5091  {
5092  strat->fromQ[j] = strat->fromQ[j-1];
5093  }
5094  strat->fromQ[at]=fq;
5095  }
5096  }
5097  }
5098  if (new_suc <= strat->sl) *suc=new_suc;
5099  else *suc=-1;
5100 }

◆ replaceInLAndSAndT()

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

Definition at line 9608 of file kutil.cc.

9609 {
9610  p.GetP(strat->lmBin);
9611  if (strat->homog) strat->initEcart(&p);
9612  strat->redTailChange=FALSE;
9614  {
9615  p.pCleardenom();
9617  {
9618 #ifdef HAVE_SHIFTBBA
9619  if (rIsLPRing(currRing))
9620  p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9621  else
9622 #endif
9623  {
9624  p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9625  }
9626  p.pCleardenom();
9627  if (strat->redTailChange)
9628  p.t_p=NULL;
9629  if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9630  else strat->P.sev=0;
9631  }
9632  }
9633 
9634  assume(strat->tailRing == p.tailRing);
9635  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9636 
9637  int i, j, pos;
9638  poly tp = strat->T[tj].p;
9639 
9640  /* enter p to T set */
9641  enterT(p, strat);
9642 
9643  for (j = 0; j <= strat->sl; ++j)
9644  {
9645  if (pLtCmp(tp, strat->S[j]) == 0)
9646  {
9647  break;
9648  }
9649  }
9650  /* it may be that the exchanged element
9651  * is until now only in T and not in S */
9652  if (j <= strat->sl)
9653  {
9654  deleteInS(j, strat);
9655  }
9656 
9657  pos = posInS(strat, strat->sl, p.p, p.ecart);
9658 
9659  pp_Test(p.p, currRing, p.tailRing);
9660  assume(p.FDeg == p.pFDeg());
9661 
9662  /* remove useless pairs from L set */
9663  for (i = 0; i <= strat->Ll; ++i)
9664  {
9665  if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9666  {
9667  deleteInL(strat->L, &(strat->Ll), i, strat);
9668  i--;
9669  continue;
9670  }
9671  if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9672  {
9673  deleteInL(strat->L, &(strat->Ll), i, strat);
9674  i--;
9675  }
9676  }
9677 #ifdef HAVE_SHIFTBBA
9678  if (rIsLPRing(currRing))
9679  enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9680  else
9681 #endif
9682  {
9683  /* generate new pairs with p, probably removing older, now useless pairs */
9684  superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9685  }
9686  /* enter p to S set */
9687  strat->enterS(p, pos, strat, strat->tl);
9688 
9689 #ifdef HAVE_SHIFTBBA
9690  /* do this after enterS so that the index in R (which is strat->tl) is correct */
9691  if (rIsLPRing(currRing) && !strat->rightGB)
9692  enterTShift(p,strat);
9693 #endif
9694 }

◆ sba()

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

Definition at line 2745 of file kstd2.cc.

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

1723 {
1724  if(strat->sl < 0) return FALSE;
1725  int i;
1726  for(i=0;i<strat->sl;i++)
1727  {
1728  //Construct the gcd pair between h and S[i]
1729  number d, s, t;
1730  poly m1, m2, gcd;
1731  d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1732  if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1733  {
1734  nDelete(&d);
1735  nDelete(&s);
1736  nDelete(&t);
1737  }
1738  else
1739  {
1740  k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1741  pSetCoeff0(m1, s);
1742  pSetCoeff0(m2, t);
1743  pSetCoeff0(gcd, d);
1744  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);
1745  poly pSigMult = p_Copy(h->sig,currRing);
1746  poly sSigMult = p_Copy(strat->sig[i],currRing);
1747  pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1748  sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1749  p_LmDelete(m1, strat->tailRing);
1750  p_LmDelete(m2, strat->tailRing);
1751  poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1752  if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1753  {
1754  pDelete(&h->p);
1755  h->p = gcd;
1756  pDelete(&h->sig);
1757  h->sig = pairsig;
1758  pNext(h->sig) = NULL;
1759  strat->initEcart(h);
1760  h->sev = pGetShortExpVector(h->p);
1761  h->sevSig = pGetShortExpVector(h->sig);
1762  h->i_r1 = -1;h->i_r2 = -1;
1763  if(h->lcm != NULL)
1764  {
1765  pLmDelete(h->lcm);
1766  h->lcm = NULL;
1767  }
1768  if (currRing!=strat->tailRing)
1769  h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1770  return TRUE;
1771  }
1772  //Delete what you didn't use
1773  pDelete(&gcd);
1774  pDelete(&pairsig);
1775  }
1776  }
1777  return FALSE;
1778 }
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:1029
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:991

◆ sbaRing()

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

Definition at line 11660 of file kutil.cc.

11661 {
11662  int n = rBlocks(r); // Including trailing zero!
11663  // if sbaOrder == 1 => use (C,monomial order from r)
11664  if (strat->sbaOrder == 1)
11665  {
11666  if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11667  {
11668  return r;
11669  }
11670  ring res = rCopy0(r, TRUE, FALSE);
11671  res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11672  res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11673  res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11674  int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11675  res->wvhdl = wvhdl;
11676  for (int i=1; i<n; i++)
11677  {
11678  res->order[i] = r->order[i-1];
11679  res->block0[i] = r->block0[i-1];
11680  res->block1[i] = r->block1[i-1];
11681  res->wvhdl[i] = r->wvhdl[i-1];
11682  }
11683 
11684  // new 1st block
11685  res->order[0] = ringorder_C; // Prefix
11686  // removes useless secondary component order if defined in old ring
11687  for (int i=rBlocks(res); i>0; --i)
11688  {
11689  if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11690  {
11691  res->order[i] = (rRingOrder_t)0;
11692  }
11693  }
11694  rComplete(res, 1);
11695 #ifdef HAVE_PLURAL
11696  if (rIsPluralRing(r))
11697  {
11698  if ( nc_rComplete(r, res, false) ) // no qideal!
11699  {
11700 #ifndef SING_NDEBUG
11701  WarnS("error in nc_rComplete");
11702 #endif
11703  // cleanup?
11704 
11705  // rDelete(res);
11706  // return r;
11707 
11708  // just go on..
11709  }
11710  }
11711 #endif
11712  strat->tailRing = res;
11713  return (res);
11714  }
11715  // if sbaOrder == 3 => degree - position - ring order
11716  if (strat->sbaOrder == 3)
11717  {
11718  ring res = rCopy0(r, TRUE, FALSE);
11719  res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11720  res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11721  res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11722  int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11723  res->wvhdl = wvhdl;
11724  for (int i=2; i<n+2; i++)
11725  {
11726  res->order[i] = r->order[i-2];
11727  res->block0[i] = r->block0[i-2];
11728  res->block1[i] = r->block1[i-2];
11729  res->wvhdl[i] = r->wvhdl[i-2];
11730  }
11731 
11732  // new 1st block
11733  res->order[0] = ringorder_a; // Prefix
11734  res->block0[0] = 1;
11735  res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11736  for (int i=0; i<res->N; ++i)
11737  res->wvhdl[0][i] = 1;
11738  res->block1[0] = si_min(res->N, rVar(res));
11739  // new 2nd block
11740  res->order[1] = ringorder_C; // Prefix
11741  res->wvhdl[1] = NULL;
11742  // removes useless secondary component order if defined in old ring
11743  for (int i=rBlocks(res); i>1; --i)
11744  {
11745  if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11746  {
11747  res->order[i] = (rRingOrder_t)0;
11748  }
11749  }
11750  rComplete(res, 1);
11751 #ifdef HAVE_PLURAL
11752  if (rIsPluralRing(r))
11753  {
11754  if ( nc_rComplete(r, res, false) ) // no qideal!
11755  {
11756 #ifndef SING_NDEBUG
11757  WarnS("error in nc_rComplete");
11758 #endif
11759  // cleanup?
11760 
11761  // rDelete(res);
11762  // return r;
11763 
11764  // just go on..
11765  }
11766  }
11767 #endif
11768  strat->tailRing = res;
11769  return (res);
11770  }
11771 
11772  // not sbaOrder == 1 => use Schreyer order
11773  // this is done by a trick when initializing the signatures
11774  // in initSLSba():
11775  // Instead of using the signature 1e_i for F->m[i], we start
11776  // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11777  // Schreyer order w.r.t. the underlying monomial order.
11778  // => we do not need to change the underlying polynomial ring at all!
11779 
11780  // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11781 
11782  /*
11783  else
11784  {
11785  ring res = rCopy0(r, FALSE, FALSE);
11786  // Create 2 more blocks for prefix/suffix:
11787  res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11788  res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11789  res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11790  int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11791 
11792  // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11793  // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11794 
11795  // new 1st block
11796  int j = 0;
11797  res->order[j] = ringorder_IS; // Prefix
11798  res->block0[j] = res->block1[j] = 0;
11799  // wvhdl[j] = NULL;
11800  j++;
11801 
11802  for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11803  {
11804  res->order [j] = r->order [i];
11805  res->block0[j] = r->block0[i];
11806  res->block1[j] = r->block1[i];
11807 
11808  if (r->wvhdl[i] != NULL)
11809  {
11810  wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11811  } // else wvhdl[j] = NULL;
11812  }
11813 
11814  // new last block
11815  res->order [j] = ringorder_IS; // Suffix
11816  res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11817  // wvhdl[j] = NULL;
11818  j++;
11819 
11820  // res->order [j] = 0; // The End!
11821  res->wvhdl = wvhdl;
11822 
11823  // j == the last zero block now!
11824  assume(j == (n+1));
11825  assume(res->order[0]==ringorder_IS);
11826  assume(res->order[j-1]==ringorder_IS);
11827  assume(res->order[j]==0);
11828 
11829  if (complete)
11830  {
11831  rComplete(res, 1);
11832 
11833 #ifdef HAVE_PLURAL
11834  if (rIsPluralRing(r))
11835  {
11836  if ( nc_rComplete(r, res, false) ) // no qideal!
11837  {
11838  }
11839  }
11840  assume(rIsPluralRing(r) == rIsPluralRing(res));
11841 #endif
11842 
11843 
11844 #ifdef HAVE_PLURAL
11845  ring old_ring = r;
11846 
11847 #endif
11848 
11849  if (r->qideal!=NULL)
11850  {
11851  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11852 
11853  assume(idRankFreeModule(res->qideal, res) == 0);
11854 
11855 #ifdef HAVE_PLURAL
11856  if( rIsPluralRing(res) )
11857  if( nc_SetupQuotient(res, r, true) )
11858  {
11859  // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11860  }
11861 
11862 #endif
11863  assume(idRankFreeModule(res->qideal, res) == 0);
11864  }
11865 
11866 #ifdef HAVE_PLURAL
11867  assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11868  assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11869  assume(rIsSCA(res) == rIsSCA(old_ring));
11870  assume(ncRingType(res) == ncRingType(old_ring));
11871 #endif
11872  }
11873  strat->tailRing = res;
11874  return res;
11875  }
11876  */
11877 
11878  assume(FALSE);
11879  return(NULL);
11880 }
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:5657
static int rBlocks(ring r)
Definition: ring.h:573
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_a
Definition: ring.h:70

◆ superenterpairs()

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

Definition at line 4902 of file kutil.cc.

4903 {
4905 #if HAVE_SHIFTBBA
4906  assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4907 #endif
4908  // enter also zero divisor * poly, if this is non zero and of smaller degree
4909  if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat);
4910  initenterstrongPairs(h, k, ecart, 0, strat, atR);
4911  initenterpairs(h, k, ecart, 0, strat, atR);
4912  clearSbatch(h, k, pos, strat);
4913 }
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4876
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4593
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4675

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

4916 {
4918  // enter also zero divisor * poly, if this is non zero and of smaller degree
4919  if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4920  if(strat->sigdrop) return;
4921  initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4922  if(strat->sigdrop) return;
4923  initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4924  if(strat->sigdrop) return;
4925  clearSbatch(h, k, pos, strat);
4926 }
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3965
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4648
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4758

◆ syzCriterion()

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

Definition at line 7119 of file kutil.cc.

7120 {
7121 //#if 1
7122 #ifdef DEBUGF5
7123  PrintS("syzygy criterion checks: ");
7124  pWrite(sig);
7125 #endif
7126  for (int k=0; k<strat->syzl; k++)
7127  {
7128  //printf("-%d",k);
7129 //#if 1
7130 #ifdef DEBUGF5
7131  Print("checking with: %d / %d -- \n",k,strat->syzl);
7132  pWrite(pHead(strat->syz[k]));
7133 #endif
7134  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
7135  && (!rField_is_Ring(currRing) ||
7136  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
7137  {
7138 //#if 1
7139 #ifdef DEBUGF5
7140  PrintS("DELETE!\n");
7141 #endif
7142  strat->nrsyzcrit++;
7143  //printf("- T -\n\n");
7144  return TRUE;
7145  }
7146  }
7147  //printf("- F -\n\n");
7148  return FALSE;
7149 }

◆ syzCriterionInc()

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

Definition at line 7154 of file kutil.cc.

7155 {
7156 //#if 1
7157  if(sig == NULL)
7158  return FALSE;
7159 #ifdef DEBUGF5
7160  PrintS("--- syzygy criterion checks: ");
7161  pWrite(sig);
7162 #endif
7163  int comp = __p_GetComp(sig, currRing);
7164  int min, max;
7165  if (comp<=1)
7166  return FALSE;
7167  else
7168  {
7169  min = strat->syzIdx[comp-2];
7170  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
7171  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
7172  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
7173  if (comp == strat->currIdx)
7174  {
7175  max = strat->syzl;
7176  }
7177  else
7178  {
7179  max = strat->syzIdx[comp-1];
7180  }
7181  for (int k=min; k<max; k++)
7182  {
7183 #ifdef F5DEBUG
7184  Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
7185  Print("checking with: %d -- ",k);
7186  pWrite(pHead(strat->syz[k]));
7187 #endif
7188  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
7189  && (!rField_is_Ring(currRing) ||
7190  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
7191  {
7192  strat->nrsyzcrit++;
7193  return TRUE;
7194  }
7195  }
7196  return FALSE;
7197  }
7198 }
static int min(int a, int b)
Definition: fast_mult.cc:268
static int max(int a, int b)
Definition: fast_mult.cc:264

◆ twoPow()

long twoPow ( long  arg)

Definition at line 4209 of file kutil.cc.

4210 {
4211  return 1L << arg;
4212 }

◆ updateResult()

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

Definition at line 10647 of file kutil.cc.

10648 {
10649  int l;
10650  if (strat->ak>0)
10651  {
10652  for (l=IDELEMS(r)-1;l>=0;l--)
10653  {
10654  if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10655  {
10656  pDelete(&r->m[l]); // and set it to NULL
10657  }
10658  }
10659  int q;
10660  poly p;
10661  if(!rField_is_Ring(currRing))
10662  {
10663  for (l=IDELEMS(r)-1;l>=0;l--)
10664  {
10665  if ((r->m[l]!=NULL)
10666  //&& (strat->syzComp>0)
10667  //&& (pGetComp(r->m[l])<=strat->syzComp)
10668  )
10669  {
10670  for(q=IDELEMS(Q)-1; q>=0;q--)
10671  {
10672  if ((Q->m[q]!=NULL)
10673  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10674  {
10675  if (TEST_OPT_REDSB)
10676  {
10677  p=r->m[l];
10678  r->m[l]=kNF(Q,NULL,p);
10679  pDelete(&p);
10680  }
10681  else
10682  {
10683  pDelete(&r->m[l]); // and set it to NULL
10684  }
10685  break;
10686  }
10687  }
10688  }
10689  }
10690  }
10691  #ifdef HAVE_RINGS
10692  else
10693  {
10694  for (l=IDELEMS(r)-1;l>=0;l--)
10695  {
10696  if ((r->m[l]!=NULL)
10697  //&& (strat->syzComp>0)
10698  //&& (pGetComp(r->m[l])<=strat->syzComp)
10699  )
10700  {
10701  for(q=IDELEMS(Q)-1; q>=0;q--)
10702  {
10703  if ((Q->m[q]!=NULL)
10704  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10705  {
10706  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10707  {
10708  if (TEST_OPT_REDSB)
10709  {
10710  p=r->m[l];
10711  r->m[l]=kNF(Q,NULL,p);
10712  pDelete(&p);
10713  }
10714  else
10715  {
10716  pDelete(&r->m[l]); // and set it to NULL
10717  }
10718  break;
10719  }
10720  }
10721  }
10722  }
10723  }
10724  }
10725  #endif
10726  }
10727  else
10728  {
10729  int q;
10730  poly p;
10731  BOOLEAN reduction_found=FALSE;
10732  if (!rField_is_Ring(currRing))
10733  {
10734  for (l=IDELEMS(r)-1;l>=0;l--)
10735  {
10736  if (r->m[l]!=NULL)
10737  {
10738  for(q=IDELEMS(Q)-1; q>=0;q--)
10739  {
10740  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10741  {
10742  if (TEST_OPT_REDSB)
10743  {
10744  p=r->m[l];
10745  r->m[l]=kNF(Q,NULL,p);
10746  pDelete(&p);
10747  reduction_found=TRUE;
10748  }
10749  else
10750  {
10751  pDelete(&r->m[l]); // and set it to NULL
10752  }
10753  break;
10754  }
10755  }
10756  }
10757  }
10758  }
10759  #ifdef HAVE_RINGS
10760  //Also need divisibility of the leading coefficients
10761  else
10762  {
10763  for (l=IDELEMS(r)-1;l>=0;l--)
10764  {
10765  if (r->m[l]!=NULL)
10766  {
10767  for(q=IDELEMS(Q)-1; q>=0;q--)
10768  {
10769  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10770  {
10771  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10772  {
10773  if (TEST_OPT_REDSB)
10774  {
10775  p=r->m[l];
10776  r->m[l]=kNF(Q,NULL,p);
10777  pDelete(&p);
10778  reduction_found=TRUE;
10779  }
10780  else
10781  {
10782  pDelete(&r->m[l]); // and set it to NULL
10783  }
10784  break;
10785  }
10786  }
10787  }
10788  }
10789  }
10790  }
10791  #endif
10792  if (/*TEST_OPT_REDSB &&*/ reduction_found)
10793  {
10794  #ifdef HAVE_RINGS
10796  {
10797  for (l=IDELEMS(r)-1;l>=0;l--)
10798  {
10799  if (r->m[l]!=NULL)
10800  {
10801  for(q=IDELEMS(r)-1;q>=0;q--)
10802  {
10803  if ((l!=q)
10804  && (r->m[q]!=NULL)
10805  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10806  &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10807  )
10808  {
10809  //If they are equal then take the one with the smallest length
10810  if(pLmDivisibleBy(r->m[q],r->m[l])
10811  && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10812  && (pLength(r->m[q]) < pLength(r->m[l]) ||
10813  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10814  {
10815  pDelete(&r->m[l]);
10816  break;
10817  }
10818  else
10819  pDelete(&r->m[q]);
10820  }
10821  }
10822  }
10823  }
10824  }
10825  else
10826  #endif
10827  {
10828  for (l=IDELEMS(r)-1;l>=0;l--)
10829  {
10830  if (r->m[l]!=NULL)
10831  {
10832  for(q=IDELEMS(r)-1;q>=0;q--)
10833  {
10834  if ((l!=q)
10835  && (r->m[q]!=NULL)
10836  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10837  )
10838  {
10839  //If they are equal then take the one with the smallest length
10840  if(pLmDivisibleBy(r->m[q],r->m[l])
10841  &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10842  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10843  {
10844  pDelete(&r->m[l]);
10845  break;
10846  }
10847  else
10848  pDelete(&r->m[q]);
10849  }
10850  }
10851  }
10852  }
10853  }
10854  }
10855  }
10856  idSkipZeroes(r);
10857 }
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3158

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 9115 of file kutil.cc.

9116 {
9117  LObject h;
9118  int i, suc=0;
9119  poly redSi=NULL;
9120  BOOLEAN change,any_change;
9121 // Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
9122 // for (i=0; i<=(strat->sl); i++)
9123 // {
9124 // Print("s%d:",i);
9125 // if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
9126 // pWrite(strat->S[i]);
9127 // }
9128 // Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
9129  any_change=FALSE;
9131  {
9132  while (suc != -1)
9133  {
9134  i=suc+1;
9135  while (i<=strat->sl)
9136  {
9137  change=FALSE;
9139  any_change = FALSE;
9140  if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
9141  {
9142  redSi = pHead(strat->S[i]);
9143  strat->S[i] = redBba(strat->S[i],i-1,strat);
9144  //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
9145  // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
9146  if (pCmp(redSi,strat->S[i])!=0)
9147  {
9148  change=TRUE;
9149  any_change=TRUE;
9150  #ifdef KDEBUG
9151  if (TEST_OPT_DEBUG)
9152  {
9153  PrintS("reduce:");
9154  wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
9155  }
9156  #endif
9157  if (TEST_OPT_PROT)
9158  {
9159  if (strat->S[i]==NULL)
9160  PrintS("V");
9161  else
9162  PrintS("v");
9163  mflush();
9164  }
9165  }
9166  pLmDelete(&redSi);
9167  if (strat->S[i]==NULL)
9168  {
9169  deleteInS(i,strat);
9170  i--;
9171  }
9172  else if (change)
9173  {
9175  {
9176  if (TEST_OPT_CONTENTSB)
9177  {
9178  number n;
9179  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
9180  if (!nIsOne(n))
9181  {
9183  denom->n=nInvers(n);
9184  denom->next=DENOMINATOR_LIST;
9185  DENOMINATOR_LIST=denom;
9186  }
9187  nDelete(&n);
9188  }
9189  else
9190  {
9191  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
9192  }
9193  }
9194  else
9195  {
9196  pNorm(strat->S[i]);
9197  }
9198  strat->sevS[i] = pGetShortExpVector(strat->S[i]);
9199  }
9200  }
9201  i++;
9202  }
9203  if (any_change) reorderS(&suc,strat);
9204  else break;
9205  }
9206  if (toT)
9207  {
9208  for (i=0; i<=strat->sl; i++)
9209  {
9210  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9211  {
9212  h.p = redtailBba(strat->S[i],i-1,strat);
9214  {
9215  h.pCleardenom();// also does remove Content
9216  }
9217  }
9218  else
9219  {
9220  h.p = strat->S[i];
9221  }
9222  strat->initEcart(&h);
9223  if (strat->honey)
9224  {
9225  strat->ecartS[i] = h.ecart;
9226  }
9227  if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
9228  else assume(strat->sevS[i] == pGetShortExpVector(h.p));
9229  h.sev = strat->sevS[i];
9230  /*puts the elements of S also to T*/
9231  strat->initEcart(&h);
9232  /*if (toT) - already checked*/ enterT(h,strat);
9233  strat->S_2_R[i] = strat->tl;
9234 #ifdef HAVE_SHIFTBBA
9235  if (/*(toT) && */(currRing->isLPring))
9236  enterTShift(h, strat);
9237 #endif
9238  }
9239  }
9240  }
9241  else
9242  {
9243  while (suc != -1)
9244  {
9245  i=suc;
9246  while (i<=strat->sl)
9247  {
9248  change=FALSE;
9249  if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
9250  {
9251  redSi=pHead((strat->S)[i]);
9252  (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
9253  if ((strat->S)[i]==NULL)
9254  {
9255  deleteInS(i,strat);
9256  i--;
9257  }
9258  else if (pCmp((strat->S)[i],redSi)!=0)
9259  {
9260  any_change=TRUE;
9261  h.p = strat->S[i];
9262  strat->initEcart(&h);
9263  strat->ecartS[i] = h.ecart;
9265  {
9266  if (TEST_OPT_CONTENTSB)
9267  {
9268  number n;
9269  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
9270  if (!nIsOne(n))
9271  {
9273  denom->n=nInvers(n);
9274  denom->next=DENOMINATOR_LIST;
9275  DENOMINATOR_LIST=denom;
9276  }
9277  nDelete(&n);
9278  }
9279  else
9280  {
9281  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
9282  }
9283  }
9284  else
9285  {
9286  pNorm(strat->S[i]); // == h.p
9287  }
9288  h.sev = pGetShortExpVector(h.p);
9289  strat->sevS[i] = h.sev;
9290  }
9291  pLmDelete(&redSi);
9292  kTest(strat);
9293  }
9294  i++;
9295  }
9296 #ifdef KDEBUG
9297  kTest(strat);
9298 #endif
9299  if (any_change) reorderS(&suc,strat);
9300  else { suc=-1; break; }
9301  if (h.p!=NULL)
9302  {
9303  if (!strat->kHEdgeFound)
9304  {
9305  /*strat->kHEdgeFound =*/ HEckeTest(h.p,strat);
9306  }
9307  if (strat->kHEdgeFound)
9308  newHEdge(strat);
9309  }
9310  }
9311  for (i=0; i<=strat->sl; i++)
9312  {
9313  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9314  {
9315  strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
9316  strat->initEcart(&h);
9317  strat->ecartS[i] = h.ecart;
9318  h.sev = pGetShortExpVector(h.p);
9319  strat->sevS[i] = h.sev;
9320  }
9321  else
9322  {
9323  h.p = strat->S[i];
9324  h.ecart=strat->ecartS[i];
9325  h.sev = strat->sevS[i];
9326  h.length = h.pLength = pLength(h.p);
9327  }
9328  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9329  cancelunit1(&h,&suc,strat->sl,strat);
9330  h.SetpFDeg();
9331  /*puts the elements of S also to T*/
9332  enterT(h,strat);
9333  strat->S_2_R[i] = strat->tl;
9334 #ifdef HAVE_SHIFTBBA
9335  if (currRing->isLPring)
9336  enterTShift(h, strat);
9337 #endif
9338  }
9339  if (suc!= -1) updateS(toT,strat);
9340  }
9341 #ifdef KDEBUG
9342  kTest(strat);
9343 #endif
9344 }
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:9070
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:9046
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition: kutil.cc:8958
void HEckeTest(poly pp, kStrategy strat)
Definition: kutil.cc:475
void reorderS(int *suc, kStrategy strat)
Definition: kutil.cc:5056
BOOLEAN newHEdge(kStrategy strat)
Definition: kutil.cc:10981

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 62 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 266 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 177 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 874 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 873 of file kutil.h.