My Project  debian-1:4.1.2-p1+ds-2
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 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 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 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, 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 initBbaShift (kStrategy strat)
 
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)
 

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 394 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 7188 of file kutil.cc.

7189 {
7191  return FALSE;
7192  poly p1 = pOne();
7193  poly p2 = pOne();
7194  for (int ii=strat->sl; ii>start; ii--)
7195  {
7196  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
7197  {
7198  p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
7199  p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
7200  if (!(pLmCmp(p1,p2) == 1))
7201  {
7202  pDelete(&p1);
7203  pDelete(&p2);
7204  return TRUE;
7205  }
7206  }
7207  }
7208  pDelete(&p1);
7209  pDelete(&p2);
7210  return FALSE;
7211 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
polyset S
Definition: kutil.h:302
unsigned long * sevSig
Definition: kutil.h:320
polyset sig
Definition: kutil.h:304
LObject P
Definition: kutil.h:298
int sl
Definition: kutil.h:346
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1364
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1857
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:182
#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:311
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:479

◆ arriRewCriterionPre()

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

Definition at line 7213 of file kutil.cc.

7214 {
7215  //Over Rings, there are still some changes to do: considering coeffs
7217  return FALSE;
7218  int found = -1;
7219  for (int i=strat->Bl; i>-1; i--) {
7220  if (pLmEqual(strat->B[i].sig,sig))
7221  {
7222  found = i;
7223  break;
7224  }
7225  }
7226  if (found != -1)
7227  {
7228  if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
7229  {
7230  deleteInL(strat->B,&strat->Bl,found,strat);
7231  }
7232  else
7233  {
7234  return TRUE;
7235  }
7236  }
7237  poly p1 = pOne();
7238  poly p2 = pOne();
7239  for (int ii=strat->sl; ii>-1; ii--)
7240  {
7241  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
7242  {
7243  p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
7244  p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
7245  if (!(pLmCmp(p1,p2) == 1))
7246  {
7247  pDelete(&p1);
7248  pDelete(&p2);
7249  return TRUE;
7250  }
7251  }
7252  }
7253  pDelete(&p1);
7254  pDelete(&p2);
7255  return FALSE;
7256 }
int i
Definition: cfEzgcd.cc:125
int Bl
Definition: kutil.h:350
LSet B
Definition: kutil.h:324
bool found
Definition: facFactorize.cc:56
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1203
#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 1203 of file kInline.h.

1204 {
1205  return FALSE;
1206 }

◆ bba()

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

Definition at line 2178 of file kstd2.cc.

2179 {
2180  int red_result = 1;
2181  int olddeg,reduc;
2182  int hilbeledeg=1,hilbcount=0,minimcnt=0;
2183  BOOLEAN withT = FALSE;
2184  BITSET save;
2185  SI_SAVE_OPT1(save);
2186 
2187  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2189  initBuchMoraPosRing(strat);
2190  else
2191  initBuchMoraPos(strat);
2192  initHilbCrit(F,Q,&hilb,strat);
2193  initBba(strat);
2194  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2195  /*Shdl=*/initBuchMora(F, Q,strat);
2196  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2197  reduc = olddeg = 0;
2198 
2199 #ifndef NO_BUCKETS
2200  if (!TEST_OPT_NOT_BUCKETS)
2201  strat->use_buckets = 1;
2202 #endif
2203  // redtailBBa against T for inhomogenous input
2204  if (!TEST_OPT_OLDSTD)
2205  withT = ! strat->homog;
2206 
2207  // strat->posInT = posInT_pLength;
2208  kTest_TS(strat);
2209 
2210 #ifdef HAVE_TAIL_RING
2211  if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2212  kStratInitChangeTailRing(strat);
2213 #endif
2214  if (BVERBOSE(23))
2215  {
2216  if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2217  if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2218  kDebugPrint(strat);
2219  }
2220 
2221 
2222 #ifdef KDEBUG
2223  //kDebugPrint(strat);
2224 #endif
2225  /* compute------------------------------------------------------- */
2226  while (strat->Ll >= 0)
2227  {
2228  #ifdef KDEBUG
2229  if (TEST_OPT_DEBUG) messageSets(strat);
2230  #endif
2231  if (siCntrlc)
2232  {
2233  while (strat->Ll >= 0)
2234  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2235  strat->noClearS=TRUE;
2236  }
2237  if (TEST_OPT_DEGBOUND
2238  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2239  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2240  {
2241  /*
2242  *stops computation if
2243  * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2244  *a predefined number Kstd1_deg
2245  */
2246  while ((strat->Ll >= 0)
2247  && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2248  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2249  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2250  )
2251  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2252  if (strat->Ll<0) break;
2253  else strat->noClearS=TRUE;
2254  }
2255  if (strat->Ll== 0) strat->interpt=TRUE;
2256  /* picks the last element from the lazyset L */
2257  strat->P = strat->L[strat->Ll];
2258  strat->Ll--;
2259 
2260  if (pNext(strat->P.p) == strat->tail)
2261  {
2262  // deletes the short spoly
2263  if (rField_is_Ring(currRing))
2264  pLmDelete(strat->P.p);
2265  else
2266  pLmFree(strat->P.p);
2267  strat->P.p = NULL;
2268  poly m1 = NULL, m2 = NULL;
2269 
2270  // check that spoly creation is ok
2271  while (strat->tailRing != currRing &&
2272  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2273  {
2274  assume(m1 == NULL && m2 == NULL);
2275  // if not, change to a ring where exponents are at least
2276  // large enough
2277  if (!kStratChangeTailRing(strat))
2278  {
2279  WerrorS("OVERFLOW...");
2280  break;
2281  }
2282  }
2283  // create the real one
2284  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2285  strat->tailRing, m1, m2, strat->R);
2286  }
2287  else if (strat->P.p1 == NULL)
2288  {
2289  if (strat->minim > 0)
2290  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2291  // for input polys, prepare reduction
2292  strat->P.PrepareRed(strat->use_buckets);
2293  }
2294 
2295  if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2296  {
2297  red_result = 0;
2298  }
2299  else
2300  {
2301  if (TEST_OPT_PROT)
2302  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2303  &olddeg,&reduc,strat, red_result);
2304 
2305  /* reduction of the element chosen from L */
2306  red_result = strat->red(&strat->P,strat);
2307  if (errorreported) break;
2308  }
2309 
2310  if (strat->overflow)
2311  {
2312  if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2313  }
2314 
2315  // reduction to non-zero new poly
2316  if (red_result == 1)
2317  {
2318  // get the polynomial (canonicalize bucket, make sure P.p is set)
2319  strat->P.GetP(strat->lmBin);
2320  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2321  // but now, for entering S, T, we reset it
2322  // in the inhomogeneous case: FDeg == pFDeg
2323  if (strat->homog) strat->initEcart(&(strat->P));
2324 
2325  /* statistic */
2326  if (TEST_OPT_PROT) PrintS("s");
2327 
2328  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2329 
2330  // reduce the tail and normalize poly
2331  // in the ring case we cannot expect LC(f) = 1,
2332  // therefore we call pCleardenom instead of pNorm
2333  strat->redTailChange=FALSE;
2334 
2335  /* if we are computing over Z we always want to try and cut down
2336  * the coefficients in the tail terms */
2338  redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2339  strat->P.pCleardenom();
2340  }
2341 
2343  {
2344  strat->P.pCleardenom();
2346  {
2347  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2348  strat->P.pCleardenom();
2349  if (strat->redTailChange) { strat->P.t_p=NULL; }
2350  }
2351  }
2352  else
2353  {
2354  strat->P.pNorm();
2356  {
2357  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2358  if (strat->redTailChange) { strat->P.t_p=NULL; }
2359  }
2360  }
2361 
2362 #ifdef KDEBUG
2363  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2364 #endif /* KDEBUG */
2365 
2366  // min_std stuff
2367  if ((strat->P.p1==NULL) && (strat->minim>0))
2368  {
2369  if (strat->minim==1)
2370  {
2371  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2372  p_Delete(&strat->P.p2, currRing, strat->tailRing);
2373  }
2374  else
2375  {
2376  strat->M->m[minimcnt]=strat->P.p2;
2377  strat->P.p2=NULL;
2378  }
2379  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2380  pNext(strat->M->m[minimcnt])
2381  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2382  strat->tailRing, currRing,
2383  currRing->PolyBin);
2384  minimcnt++;
2385  }
2386 
2387  // enter into S, L, and T
2388  if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2389  {
2390  enterT(strat->P, strat);
2391  if (rField_is_Ring(currRing))
2392  superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2393  else
2394  enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2395  // posInS only depends on the leading term
2396  strat->enterS(strat->P, pos, strat, strat->tl);
2397 #if 0
2398  int pl=pLength(strat->P.p);
2399  if (pl==1)
2400  {
2401  //if (TEST_OPT_PROT)
2402  //PrintS("<1>");
2403  }
2404  else if (pl==2)
2405  {
2406  //if (TEST_OPT_PROT)
2407  //PrintS("<2>");
2408  }
2409 #endif
2410  }
2411  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2412 // Print("[%d]",hilbeledeg);
2413  kDeleteLcm(&strat->P);
2414  if (strat->s_poly!=NULL)
2415  {
2416  // the only valid entries are: strat->P.p,
2417  // strat->tailRing (read-only, keep it)
2418  // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2419  if (strat->s_poly(strat))
2420  {
2421  // we are called AFTER enterS, i.e. if we change P
2422  // we have to add it also to S/T
2423  // and add pairs
2424  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2425  enterT(strat->P, strat);
2426  if (rField_is_Ring(currRing))
2427  superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2428  else
2429  enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2430  strat->enterS(strat->P, pos, strat, strat->tl);
2431  }
2432  }
2433  }
2434  else if (strat->P.p1 == NULL && strat->minim > 0)
2435  {
2436  p_Delete(&strat->P.p2, currRing, strat->tailRing);
2437  }
2438 
2439 #ifdef KDEBUG
2440  memset(&(strat->P), 0, sizeof(strat->P));
2441 #endif /* KDEBUG */
2442  kTest_TS(strat);
2443  }
2444 #ifdef KDEBUG
2445  if (TEST_OPT_DEBUG) messageSets(strat);
2446 #endif /* KDEBUG */
2447 
2448  if (TEST_OPT_SB_1)
2449  {
2450  if(!rField_is_Ring(currRing))
2451  {
2452  int k=1;
2453  int j;
2454  while(k<=strat->sl)
2455  {
2456  j=0;
2457  loop
2458  {
2459  if (j>=k) break;
2460  clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2461  j++;
2462  }
2463  k++;
2464  }
2465  }
2466  }
2467  /* complete reduction of the standard basis--------- */
2468  if (TEST_OPT_REDSB)
2469  {
2470  completeReduce(strat);
2471  if (strat->completeReduce_retry)
2472  {
2473  // completeReduce needed larger exponents, retry
2474  // to reduce with S (instead of T)
2475  // and in currRing (instead of strat->tailRing)
2476 #ifdef HAVE_TAIL_RING
2477  if(currRing->bitmask>strat->tailRing->bitmask)
2478  {
2479  strat->completeReduce_retry=FALSE;
2480  cleanT(strat);strat->tailRing=currRing;
2481  int i;
2482  for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2483  completeReduce(strat);
2484  }
2485  if (strat->completeReduce_retry)
2486 #endif
2487  Werror("exponent bound is %ld",currRing->bitmask);
2488  }
2489  }
2490  else if (TEST_OPT_PROT) PrintLn();
2491  /* release temp data-------------------------------- */
2492  exitBuchMora(strat);
2493  /* postprocessing for GB over ZZ --------------------*/
2494  if (!errorreported)
2495  {
2496  if(rField_is_Z(currRing))
2497  {
2498  for(int i = 0;i<=strat->sl;i++)
2499  {
2500  if(!nGreaterZero(pGetCoeff(strat->S[i])))
2501  {
2502  strat->S[i] = pNeg(strat->S[i]);
2503  }
2504  }
2505  finalReduceByMon(strat);
2506  for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2507  {
2508  if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2509  {
2510  strat->S[i] = pNeg(strat->Shdl->m[i]);
2511  }
2512  }
2513  }
2514  //else if (rField_is_Ring(currRing))
2515  // finalReduceByMon(strat);
2516  }
2517 // if (TEST_OPT_WEIGHTM)
2518 // {
2519 // pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2520 // if (ecartWeights)
2521 // {
2522 // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2523 // ecartWeights=NULL;
2524 // }
2525 // }
2526  if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
2527  SI_RESTORE_OPT1(save);
2528  /* postprocessing for GB over Q-rings ------------------*/
2529  if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2530 
2531  idTest(strat->Shdl);
2532 
2533  return (strat->Shdl);
2534 }
int BOOLEAN
Definition: auxiliary.h:87
int k
Definition: cfEzgcd.cc:92
int syzComp
Definition: kutil.h:352
int * S_2_R
Definition: kutil.h:340
ring tailRing
Definition: kutil.h:341
int Ll
Definition: kutil.h:349
omBin lmBin
Definition: kutil.h:342
char honey
Definition: kutil.h:376
int minim
Definition: kutil.h:356
TObject ** R
Definition: kutil.h:338
ideal M
Definition: kutil.h:301
int tl
Definition: kutil.h:348
poly tail
Definition: kutil.h:332
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:280
ideal Shdl
Definition: kutil.h:299
pShallowCopyDeleteProc p_shallow_copy_delete
Definition: kutil.h:336
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition: kutil.h:282
char use_buckets
Definition: kutil.h:382
char interpt
Definition: kutil.h:370
char redTailChange
Definition: kutil.h:398
char completeReduce_retry
Definition: kutil.h:402
void(* initEcart)(TObject *L)
Definition: kutil.h:276
char noClearS
Definition: kutil.h:401
char overflow
Definition: kutil.h:403
LSet L
Definition: kutil.h:323
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition: kutil.h:277
int(* red)(LObject *L, kStrategy strat)
Definition: kutil.h:274
unsigned long * sevS
Definition: kutil.h:318
char homog
Definition: kutil.h:371
s_poly_proc_t s_poly
Definition: kutil.h:296
const CanonicalForm & w
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
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:1158
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1178
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:1159
void initBba(kStrategy strat)
Definition: kstd1.cc:1334
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:50
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:11949
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:7954
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:10208
void enterT(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9586
BOOLEAN kTest_TS(kStrategy strat)
Definition: kutil.cc:1033
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4859
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition: kutil.cc:7711
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
Definition: kutil.cc:9866
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:10035
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition: kutil.cc:11403
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:10292
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:5035
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition: kutil.cc:10931
void cleanT(kStrategy strat)
Definition: kutil.cc:538
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10533
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4831
void kStratInitChangeTailRing(kStrategy strat)
Definition: kutil.cc:11502
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9884
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition: kutil.cc:10745
void initBuchMoraPosRing(kStrategy strat)
Definition: kutil.cc:10121
void messageSets(kStrategy strat)
Definition: kutil.cc:8027
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7995
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition: kutil.cc:11318
static void kDeleteLcm(LObject *P)
Definition: kutil.h:869
#define assume(x)
Definition: mod2.h:390
#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:126
#define TEST_OPT_INTSTRATEGY
Definition: options.h:108
#define BVERBOSE(a)
Definition: options.h:34
#define TEST_OPT_REDTAIL
Definition: options.h:114
#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:120
#define TEST_OPT_REDSB
Definition: options.h:102
#define TEST_OPT_DEGBOUND
Definition: options.h:111
#define TEST_OPT_SB_1
Definition: options.h:116
#define TEST_OPT_PROT
Definition: options.h:101
#define TEST_OPT_DEBUG
Definition: options.h:106
#define TEST_OPT_CONTENTSB
Definition: options.h:124
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:103
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
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:811
#define pNeg(p)
Definition: polys.h:194
#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:504
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:755
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 4163 of file kstd2.cc.

4164 {
4165  int red_result = 1;
4166  int olddeg,reduc;
4167  int hilbeledeg=1,hilbcount=0,minimcnt=0;
4168  BOOLEAN withT = TRUE; // currently only T contains the shifts
4169  BITSET save;
4170  SI_SAVE_OPT1(save);
4171 
4172  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit, NO CHANGES */
4174  initBuchMoraPosRing(strat);
4175  else
4176  initBuchMoraPos(strat); /*NO CHANGES YET: perhaps later*/
4177  initHilbCrit(F,Q,&hilb,strat); /*NO CHANGES*/
4178  initBbaShift(strat); /* DONE */
4179  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
4180  /*Shdl=*/initBuchMora(F, Q,strat);
4181  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
4182  reduc = olddeg = 0;
4183 
4184 #ifndef NO_BUCKETS
4185  if (!TEST_OPT_NOT_BUCKETS)
4186  strat->use_buckets = 1;
4187 #endif
4188  // redtailBBa against T for inhomogenous input
4189  // if (!TEST_OPT_OLDSTD)
4190  // withT = ! strat->homog;
4191 
4192  // strat->posInT = posInT_pLength;
4193  kTest_TS(strat);
4194 
4195 #ifdef HAVE_TAIL_RING
4196 // kStratInitChangeTailRing(strat);
4197  strat->tailRing=currRing;
4198 #endif
4199 
4200 
4201 #ifdef KDEBUG
4202  //kDebugPrint(strat);
4203 #endif
4204  /* compute------------------------------------------------------- */
4205  while (strat->Ll >= 0)
4206  {
4207 #ifdef KDEBUG
4208  if (TEST_OPT_DEBUG) messageSets(strat);
4209 #endif
4210  if (strat->Ll== 0) strat->interpt=TRUE;
4211  if (TEST_OPT_DEGBOUND
4212  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4213  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
4214  {
4215  /*
4216  *stops computation if
4217  * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
4218  *a predefined number Kstd1_deg
4219  */
4220  while ((strat->Ll >= 0)
4221  && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
4222  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4223  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
4224  )
4225  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4226  if (strat->Ll<0) break;
4227  else strat->noClearS=TRUE;
4228  }
4229  /* picks the last element from the lazyset L */
4230  strat->P = strat->L[strat->Ll];
4231  strat->Ll--;
4232 
4233  if (pNext(strat->P.p) == strat->tail)
4234  {
4235  // deletes the short spoly
4236  pLmFree(strat->P.p);
4237  strat->P.p = NULL;
4238  poly m1 = NULL, m2 = NULL;
4239 
4240  // check that spoly creation is ok
4241  while (strat->tailRing != currRing &&
4242  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4243  {
4244  assume(m1 == NULL && m2 == NULL);
4245  // if not, change to a ring where exponents are at least
4246  // large enough
4247  kStratChangeTailRing(strat);
4248  }
4249  // create the real one
4250  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4251  strat->tailRing, m1, m2, strat->R);
4252  }
4253  else if (strat->P.p1 == NULL)
4254  {
4255  if (strat->minim > 0)
4256  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4257  // for input polys, prepare reduction
4258  strat->P.PrepareRed(strat->use_buckets);
4259  }
4260 
4261  if (strat->P.p == NULL && strat->P.t_p == NULL)
4262  {
4263  red_result = 0;
4264  }
4265  else
4266  {
4267  if (TEST_OPT_PROT)
4268  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4269  &olddeg,&reduc,strat, red_result);
4270 
4271  /* reduction of the element chosen from L */
4272  red_result = strat->red(&strat->P,strat);
4273  if (errorreported) break;
4274  }
4275 
4276  // reduction to non-zero new poly
4277  if (red_result == 1)
4278  {
4279  // get the polynomial (canonicalize bucket, make sure P.p is set)
4280  strat->P.GetP(strat->lmBin);
4281  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4282  // but now, for entering S, T, we reset it
4283  // in the inhomogeneous case: FDeg == pFDeg
4284  if (strat->homog) strat->initEcart(&(strat->P));
4285 
4286  /* statistic */
4287  if (TEST_OPT_PROT) PrintS("s");
4288 
4289  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4290 
4291  // reduce the tail and normalize poly
4292  // in the ring case we cannot expect LC(f) = 1,
4293  // therefore we call pCleardenom instead of pNorm
4294  strat->redTailChange=FALSE;
4296  {
4297  strat->P.pCleardenom();
4299  {
4300  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4301  strat->P.pCleardenom();
4302  if (strat->redTailChange) {
4303  strat->P.t_p=NULL;
4304  strat->initEcart(&(strat->P));
4305  }
4306  }
4307  }
4308  else
4309  {
4310  strat->P.pNorm();
4311  if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) {
4312  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4313  if (strat->redTailChange) {
4314  strat->P.t_p=NULL;
4315  strat->initEcart(&(strat->P));
4316  }
4317  }
4318  }
4319 
4320 #ifdef KDEBUG
4321  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4322 #endif
4323 
4324  // min_std stuff
4325  if ((strat->P.p1==NULL) && (strat->minim>0))
4326  {
4327  if (strat->minim==1)
4328  {
4329  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4330  p_Delete(&strat->P.p2, currRing, strat->tailRing);
4331  }
4332  else
4333  {
4334  strat->M->m[minimcnt]=strat->P.p2;
4335  strat->P.p2=NULL;
4336  }
4337  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4338  pNext(strat->M->m[minimcnt])
4339  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4340  strat->tailRing, currRing,
4341  currRing->PolyBin);
4342  minimcnt++;
4343  }
4344 
4345 
4346  // enter into S, L, and T
4347  if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4348  {
4349  enterT(strat->P, strat);
4350  enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4351  // posInS only depends on the leading term
4352  strat->enterS(strat->P, pos, strat, strat->tl);
4353  if (!strat->rightGB)
4354  enterTShift(strat->P, strat);
4355  }
4356 
4357  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4358 // Print("[%d]",hilbeledeg);
4359  kDeleteLcm(&strat->P);
4360  if (strat->s_poly!=NULL)
4361  {
4362  // the only valid entries are: strat->P.p,
4363  // strat->tailRing (read-only, keep it)
4364  // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
4365  if (strat->s_poly(strat))
4366  {
4367  // we are called AFTER enterS, i.e. if we change P
4368  // we have to add it also to S/T
4369  // and add pairs
4370  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4371  enterT(strat->P, strat);
4372  enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4373  strat->enterS(strat->P, pos, strat, strat->tl);
4374  if (!strat->rightGB)
4375  enterTShift(strat->P,strat);
4376  }
4377  }
4378  }
4379  else if (strat->P.p1 == NULL && strat->minim > 0)
4380  {
4381  p_Delete(&strat->P.p2, currRing, strat->tailRing);
4382  }
4383 #ifdef KDEBUG
4384  memset(&(strat->P), 0, sizeof(strat->P));
4385 #endif
4386  kTest_TS(strat);
4387  }
4388 #ifdef KDEBUG
4389  if (TEST_OPT_DEBUG) messageSets(strat);
4390 #endif
4391  /* shift case: look for elt's in S such that they are divisible by elt in T */
4392  if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
4393  {
4394  for (int k = 0; k <= strat->sl; ++k)
4395  {
4396  if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
4397  for (int j = 0; j<=strat->tl; ++j)
4398  {
4399  // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
4400  assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
4401  assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
4402  if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
4403  {
4404  if (pLmCmp(strat->T[j].p, strat->S[k]) != 0) { // check whether LM is different
4405  deleteInS(k, strat);
4406  --k;
4407  break;
4408  }
4409  }
4410  }
4411  }
4412  }
4413  /* complete reduction of the standard basis--------- */
4414  if (TEST_OPT_REDSB)
4415  {
4416  completeReduce(strat, TRUE); //shift: withT = TRUE
4417  if (strat->completeReduce_retry)
4418  {
4419  // completeReduce needed larger exponents, retry
4420  // to reduce with S (instead of T)
4421  // and in currRing (instead of strat->tailRing)
4422 #ifdef HAVE_TAIL_RING
4423  if(currRing->bitmask>strat->tailRing->bitmask)
4424  {
4425  strat->completeReduce_retry=FALSE;
4426  cleanT(strat);strat->tailRing=currRing;
4427  int i;
4428  for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
4429  WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know
4430  completeReduce(strat);
4431  }
4432  if (strat->completeReduce_retry)
4433 #endif
4434  Werror("exponent bound is %ld",currRing->bitmask);
4435  }
4436  }
4437  else if (TEST_OPT_PROT) PrintLn();
4438 
4439  /* release temp data-------------------------------- */
4440  exitBuchMora(strat);
4441 // if (TEST_OPT_WEIGHTM)
4442 // {
4443 // pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
4444 // if (ecartWeights)
4445 // {
4446 // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
4447 // ecartWeights=NULL;
4448 // }
4449 // }
4450  if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
4451  SI_RESTORE_OPT1(save);
4452  /* postprocessing for GB over Q-rings ------------------*/
4453  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
4454 
4455  idTest(strat->Shdl);
4456 
4457  return (strat->Shdl);
4458 }
TSet T
Definition: kutil.h:322
char rightGB
Definition: kutil.h:368
unsigned long * sevT
Definition: kutil.h:321
intset fromQ
Definition: kutil.h:317
#define WarnS
Definition: emacs.cc:78
void initBbaShift(kStrategy strat)
Definition: kstd2.cc:4605
void enterTShift(LObject p, kStrategy strat, int atT)
Definition: kutil.cc:12807
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:12777
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:1096
#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 333 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3192 of file kutil.cc.

3193 {
3194  int i,j,l;
3195 
3196  /*
3197  *pairtest[i] is TRUE if spoly(S[i],p) == 0.
3198  *In this case all elements in B such
3199  *that their lcm is divisible by the leading term of S[i] can be canceled
3200  */
3201  if (strat->pairtest!=NULL)
3202  {
3203  /*- i.e. there is an i with pairtest[i]==TRUE -*/
3204  for (j=0; j<=strat->sl; j++)
3205  {
3206  if (strat->pairtest[j])
3207  {
3208  for (i=strat->Bl; i>=0; i--)
3209  {
3210  if (pDivisibleBy(strat->S[j],strat->B[i].lcm))
3211  {
3212  deleteInL(strat->B,&strat->Bl,i,strat);
3213  strat->c3++;
3214  }
3215  }
3216  }
3217  }
3218  omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3219  strat->pairtest=NULL;
3220  }
3221  if (strat->Gebauer || strat->fromT)
3222  {
3223  if (strat->sugarCrit)
3224  {
3225  /*
3226  *suppose L[j] == (s,r) and p/lcm(s,r)
3227  *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3228  *and in case the sugar is o.k. then L[j] can be canceled
3229  */
3230  for (j=strat->Ll; j>=0; j--)
3231  {
3232  if (sugarDivisibleBy(ecart,strat->L[j].ecart)
3233  && ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
3234  && pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3235  {
3236  if (strat->L[j].p == strat->tail)
3237  {
3238  deleteInL(strat->L,&strat->Ll,j,strat);
3239  strat->c3++;
3240  }
3241  }
3242  }
3243  /*
3244  *this is GEBAUER-MOELLER:
3245  *in B all elements with the same lcm except the "best"
3246  *(i.e. the last one in B with this property) will be canceled
3247  */
3248  j = strat->Bl;
3249  loop /*cannot be changed into a for !!! */
3250  {
3251  if (j <= 0) break;
3252  i = j-1;
3253  loop
3254  {
3255  if (i < 0) break;
3256  if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3257  {
3258  strat->c3++;
3259  if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart))
3260  {
3261  deleteInL(strat->B,&strat->Bl,i,strat);
3262  j--;
3263  }
3264  else
3265  {
3266  deleteInL(strat->B,&strat->Bl,j,strat);
3267  break;
3268  }
3269  }
3270  i--;
3271  }
3272  j--;
3273  }
3274  }
3275  else /*sugarCrit*/
3276  {
3277  /*
3278  *suppose L[j] == (s,r) and p/lcm(s,r)
3279  *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3280  *and in case the sugar is o.k. then L[j] can be canceled
3281  */
3282  for (j=strat->Ll; j>=0; j--)
3283  {
3284  if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3285  {
3286  if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3287  {
3288  deleteInL(strat->L,&strat->Ll,j,strat);
3289  strat->c3++;
3290  }
3291  }
3292  }
3293  /*
3294  *this is GEBAUER-MOELLER:
3295  *in B all elements with the same lcm except the "best"
3296  *(i.e. the last one in B with this property) will be canceled
3297  */
3298  j = strat->Bl;
3299  loop /*cannot be changed into a for !!! */
3300  {
3301  if (j <= 0) break;
3302  for(i=j-1; i>=0; i--)
3303  {
3304  if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3305  {
3306  strat->c3++;
3307  deleteInL(strat->B,&strat->Bl,i,strat);
3308  j--;
3309  }
3310  }
3311  j--;
3312  }
3313  }
3314  /*
3315  *the elements of B enter L
3316  */
3317  kMergeBintoL(strat);
3318  }
3319  else
3320  {
3321  for (j=strat->Ll; j>=0; j--)
3322  {
3323  if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3324  {
3325  if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3326  {
3327  deleteInL(strat->L,&strat->Ll,j,strat);
3328  strat->c3++;
3329  }
3330  }
3331  }
3332  /*
3333  *this is our MODIFICATION of GEBAUER-MOELLER:
3334  *First the elements of B enter L,
3335  *then we fix a lcm and the "best" element in L
3336  *(i.e the last in L with this lcm and of type (s,p))
3337  *and cancel all the other elements of type (r,p) with this lcm
3338  *except the case the element (s,r) has also the same lcm
3339  *and is on the worst position with respect to (s,p) and (r,p)
3340  */
3341  /*
3342  *B enters to L/their order with respect to B is permutated for elements
3343  *B[i].p with the same leading term
3344  */
3345  kMergeBintoL(strat);
3346  j = strat->Ll;
3347  loop /*cannot be changed into a for !!! */
3348  {
3349  if (j <= 0)
3350  {
3351  /*now L[0] cannot be canceled any more and the tail can be removed*/
3352  if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3353  break;
3354  }
3355  if (strat->L[j].p2 == p)
3356  {
3357  i = j-1;
3358  loop
3359  {
3360  if (i < 0) break;
3361  if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3362  {
3363  /*L[i] could be canceled but we search for a better one to cancel*/
3364  strat->c3++;
3365  if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3366  && (pNext(strat->L[l].p) == strat->tail)
3367  && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3368  && pDivisibleBy(p,strat->L[l].lcm))
3369  {
3370  /*
3371  *"NOT equal(...)" because in case of "equal" the element L[l]
3372  *is "older" and has to be from theoretical point of view behind
3373  *L[i], but we do not want to reorder L
3374  */
3375  strat->L[i].p2 = strat->tail;
3376  /*
3377  *L[l] will be canceled, we cannot cancel L[i] later on,
3378  *so we mark it with "tail"
3379  */
3380  deleteInL(strat->L,&strat->Ll,l,strat);
3381  i--;
3382  }
3383  else
3384  {
3385  deleteInL(strat->L,&strat->Ll,i,strat);
3386  }
3387  j--;
3388  }
3389  i--;
3390  }
3391  }
3392  else if (strat->L[j].p2 == strat->tail)
3393  {
3394  /*now L[j] cannot be canceled any more and the tail can be removed*/
3395  strat->L[j].p2 = p;
3396  }
3397  j--;
3398  }
3399  }
3400 }
int l
Definition: cfEzgcd.cc:93
BOOLEAN * pairtest
Definition: kutil.h:331
char sugarCrit
Definition: kutil.h:376
char Gebauer
Definition: kutil.h:377
char fromT
Definition: kutil.h:378
int c3
Definition: kutil.h:345
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:3150
static BOOLEAN sugarDivisibleBy(int ecart1, int ecart2)
Definition: kutil.cc:1317
BOOLEAN isInPairsetL(int length, poly p1, poly p2, int *k, kStrategy strat)
Definition: kutil.cc:675
#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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3405 of file kutil.cc.

3406 {
3407  if (strat->pairtest!=NULL)
3408  {
3409  omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3410  strat->pairtest=NULL;
3411  }
3412  /*
3413  *the elements of B enter L
3414  */
3415  kMergeBintoL(strat);
3416 }

◆ chainCritSig()

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

Definition at line 3421 of file kutil.cc.

3422 {
3423  int i,j,l;
3424  kMergeBintoLSba(strat);
3425  j = strat->Ll;
3426  loop /*cannot be changed into a for !!! */
3427  {
3428  if (j <= 0)
3429  {
3430  /*now L[0] cannot be canceled any more and the tail can be removed*/
3431  if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3432  break;
3433  }
3434  if (strat->L[j].p2 == p)
3435  {
3436  i = j-1;
3437  loop
3438  {
3439  if (i < 0) break;
3440  if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3441  {
3442  /*L[i] could be canceled but we search for a better one to cancel*/
3443  strat->c3++;
3444  if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3445  && (pNext(strat->L[l].p) == strat->tail)
3446  && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3447  && pDivisibleBy(p,strat->L[l].lcm))
3448  {
3449  /*
3450  *"NOT equal(...)" because in case of "equal" the element L[l]
3451  *is "older" and has to be from theoretical point of view behind
3452  *L[i], but we do not want to reorder L
3453  */
3454  strat->L[i].p2 = strat->tail;
3455  /*
3456  *L[l] will be canceled, we cannot cancel L[i] later on,
3457  *so we mark it with "tail"
3458  */
3459  deleteInL(strat->L,&strat->Ll,l,strat);
3460  i--;
3461  }
3462  else
3463  {
3464  deleteInL(strat->L,&strat->Ll,i,strat);
3465  }
3466  j--;
3467  }
3468  i--;
3469  }
3470  }
3471  else if (strat->L[j].p2 == strat->tail)
3472  {
3473  /*now L[j] cannot be canceled any more and the tail can be removed*/
3474  strat->L[j].p2 = p;
3475  }
3476  j--;
3477  }
3478 }
void kMergeBintoLSba(kStrategy strat)
Definition: kutil.cc:3171

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 538 of file kutil.cc.

539 {
540  int i,j;
541  poly p;
542  assume(currRing == strat->tailRing || strat->tailRing != NULL);
543 
544  pShallowCopyDeleteProc p_shallow_copy_delete =
545  (strat->tailRing != currRing ?
547  NULL);
548  for (j=0; j<=strat->tl; j++)
549  {
550  p = strat->T[j].p;
551  strat->T[j].p=NULL;
552  if (strat->T[j].max_exp != NULL)
553  {
554  p_LmFree(strat->T[j].max_exp, strat->tailRing);
555  }
556  i = -1;
557  loop
558  {
559  i++;
560  if (i>strat->sl)
561  {
562  if (strat->T[j].t_p != NULL)
563  {
564  p_Delete(&(strat->T[j].t_p), strat->tailRing);
565  p_LmFree(p, currRing);
566  }
567  else
568  {
569 #ifdef HAVE_SHIFTBBA
570  if (currRing->isLPring && strat->T[j].shift > 0)
571  {
572  pNext(p) = NULL; // pNext(p) points to the unshifted tail, don't try to delete it here
573  }
574 #endif
575  pDelete(&p);
576  }
577  break;
578  }
579  if (p == strat->S[i])
580  {
581  if (strat->T[j].t_p != NULL)
582  {
583  if (p_shallow_copy_delete!=NULL)
584  {
585  pNext(p) = p_shallow_copy_delete(pNext(p),strat->tailRing,currRing,
586  currRing->PolyBin);
587  }
588  p_LmFree(strat->T[j].t_p, strat->tailRing);
589  }
590  break;
591  }
592  }
593  }
594  strat->tl=-1;
595 }
pShallowCopyDeleteProc pGetShallowCopyDeleteProc(ring, ring)
static void p_LmFree(poly p, ring)
Definition: p_polys.h:682
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 1178 of file kInline.h.

1180 {
1181  assume(p_sev == pGetShortExpVector(p));
1182  if (strat->noClearS) return;
1183  #ifdef HAVE_RINGS
1185  {
1186  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1187  return;
1188  if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1189  return;
1190  }
1191  else
1192  #endif
1193  {
1194  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1195  }
1196  deleteInS((*at),strat);
1197  (*at)--;
1198  (*k)--;
1199 }

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10745 of file kutil.cc.

10746 {
10747  int i;
10748  int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10749  LObject L;
10750 
10751 #ifdef KDEBUG
10752  // need to set this: during tailreductions of T[i], T[i].max is out of
10753  // sync
10754  sloppy_max = TRUE;
10755 #endif
10756 
10757  strat->noTailReduction = FALSE;
10758  //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10759  if (TEST_OPT_PROT)
10760  {
10761  PrintLn();
10762 // if (timerv) writeTime("standard base computed:");
10763  }
10764  if (TEST_OPT_PROT)
10765  {
10766  Print("(S:%d)",strat->sl);mflush();
10767  }
10768  for (i=strat->sl; i>=low; i--)
10769  {
10770  int end_pos=strat->sl;
10771  if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10772  if (strat->ak==0) end_pos=i-1;
10773  TObject* T_j = strat->s_2_t(i);
10774  if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10775  {
10776  L = *T_j;
10777  #ifdef KDEBUG
10778  if (TEST_OPT_DEBUG)
10779  {
10780  Print("test S[%d]:",i);
10781  p_wrp(L.p,currRing,strat->tailRing);
10782  PrintLn();
10783  }
10784  #endif
10786  strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10787  else
10788  strat->S[i] = redtail(&L, strat->sl, strat);
10789  #ifdef KDEBUG
10790  if (TEST_OPT_DEBUG)
10791  {
10792  Print("to (tailR) S[%d]:",i);
10793  p_wrp(strat->S[i],currRing,strat->tailRing);
10794  PrintLn();
10795  }
10796  #endif
10797 
10798  if (strat->redTailChange)
10799  {
10800  if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10801  if (pNext(T_j->p) != NULL)
10802  T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10803  else
10804  T_j->max_exp = NULL;
10805  }
10807  T_j->pCleardenom();
10808  }
10809  else
10810  {
10811  assume(currRing == strat->tailRing);
10812  #ifdef KDEBUG
10813  if (TEST_OPT_DEBUG)
10814  {
10815  Print("test S[%d]:",i);
10816  p_wrp(strat->S[i],currRing,strat->tailRing);
10817  PrintLn();
10818  }
10819  #endif
10821  strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10822  else
10823  strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10825  {
10826  if (TEST_OPT_CONTENTSB)
10827  {
10828  number n;
10829  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10830  if (!nIsOne(n))
10831  {
10833  denom->n=nInvers(n);
10834  denom->next=DENOMINATOR_LIST;
10835  DENOMINATOR_LIST=denom;
10836  }
10837  nDelete(&n);
10838  }
10839  else
10840  {
10841  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10842  }
10843  }
10844  #ifdef KDEBUG
10845  if (TEST_OPT_DEBUG)
10846  {
10847  Print("to (-tailR) S[%d]:",i);
10848  p_wrp(strat->S[i],currRing,strat->tailRing);
10849  PrintLn();
10850  }
10851  #endif
10852  }
10853  if (TEST_OPT_PROT)
10854  PrintS("-");
10855  }
10856  if (TEST_OPT_PROT) PrintLn();
10857 #ifdef KDEBUG
10858  sloppy_max = FALSE;
10859 #endif
10860 }
char noTailReduction
Definition: kutil.h:377
int ak
Definition: kutil.h:351
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:7405
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7481
STATIC_VAR BOOLEAN sloppy_max
Definition: kutil.cc:764
VAR denominator_list DENOMINATOR_LIST
Definition: kutil.cc:88
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:1128
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:2900
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2791
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
#define mflush()
Definition: reporter.h:57

◆ createG0()

ideal createG0 ( )

Definition at line 4456 of file kutil.cc.

4457 {
4458  // Initialize
4459  long exp[50]; // The exponent of \hat{X} (basepoint)
4460  long cexp[50]; // The current exponent for iterating over all
4461  long ind[50]; // The power of 2 in the i-th component of exp
4462  long cind[50]; // analog for cexp
4463  long mult[50]; // How to multiply the elements of G
4464  long cabsind = 0; // The abs. index of cexp, i.e. the sum of cind
4465  long habsind = 0; // The abs. index of the coefficient of h
4466  long step[50]; // The last increases
4467  for (int i = 1; i <= currRing->N; i++)
4468  {
4469  exp[i] = 0;
4470  cexp[i] = exp[i];
4471  ind[i] = 0;
4472  step[i] = 500000;
4473  cind[i] = ind[i];
4474  }
4475  long bound = currRing->ch;
4476  step[1] = 500000;
4477 #ifdef OLI_DEBUG
4478  PrintS("-------------\npoly :");
4479 // wrp(p);
4480  Print("\nexp : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
4481  Print("cexp : (%d, %d)\n", cexp[1], cexp[2]);
4482  Print("cind : (%d, %d)\n", cind[1], cind[2]);
4483  Print("bound : %d\n", bound);
4484  Print("cind : %d\n", cabsind);
4485 #endif
4486  if (cabsind == 0)
4487  {
4488  if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N)))
4489  {
4490  return idInit(1, 1);
4491  }
4492  }
4493  ideal G0 = idInit(1, 1);
4494  // Now the whole simplex
4495  do
4496  {
4497  // Build s-polynomial
4498  // 2**ind-def * mult * g - exp-def * h
4499  poly t_p;
4500  poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, currRing);
4501 #ifdef OLI_DEBUG
4502  Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
4503  PrintS("zPoly : ");
4504  wrp(zeroPoly);
4505  PrintLn();
4506 #endif
4507  // Add to ideal
4508  pEnlargeSet(&(G0->m), IDELEMS(G0), 1);
4509  IDELEMS(G0) += 1;
4510  G0->m[IDELEMS(G0) - 1] = zeroPoly;
4511  }
4512  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) );
4513  idSkipZeroes(G0);
4514  return G0;
4515 }
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:4327
int nextZeroSimplexExponent(long exp[], long ind[], long cexp[], long cind[], long *cabsind, long step[], long bound, long N)
Definition: kutil.cc:4261
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:3656
void wrp(poly p)
Definition: polys.h:306
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 244 of file kutil.cc.

245 {
246  if (strat->kHEdgeFound)
247  {
248  kTest_L(L,strat->tailRing);
249  poly p1;
250  poly p = L->GetLmTailRing();
251  int l = 1;
252  kBucket_pt bucket = NULL;
253  if (L->bucket != NULL)
254  {
255  kBucketClear(L->bucket, &pNext(p), &L->pLength);
256  L->pLength++;
257  bucket = L->bucket;
258  L->bucket = NULL;
259  }
260 
261  if (!fromNext && p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
262  {
263  L->Delete();
264  L->Clear();
265  L->ecart = -1;
266  if (bucket != NULL) kBucketDestroy(&bucket);
267  return;
268  }
269  p1 = p;
270  while (pNext(p1)!=NULL)
271  {
272  if (p_LmCmp(pNext(p1), strat->kNoetherTail(), L->tailRing) == -1)
273  {
274  p_Delete(&pNext(p1), L->tailRing);
275  if (p1 == p)
276  {
277  if (L->t_p != NULL)
278  {
279  assume(L->p != NULL && p == L->t_p);
280  pNext(L->p) = NULL;
281  }
282  L->max_exp = NULL;
283  }
284  else if (fromNext)
285  L->max_exp = p_GetMaxExpP(pNext(L->p), L->tailRing ); // p1;
286  //if (L->pLength != 0)
287  L->pLength = l;
288  // Hmmm when called from updateT, then only
289  // reset ecart when cut
290  if (fromNext)
291  L->ecart = L->pLDeg() - L->GetpFDeg();
292  break;
293  }
294  l++;
295  pIter(p1);
296  }
297  if (! fromNext)
298  {
299  L->SetpFDeg();
300  L->ecart = L->pLDeg(strat->LDegLast) - L->GetpFDeg();
301  }
302  if (bucket != NULL)
303  {
304  if (L->pLength > 1)
305  {
306  kBucketInit(bucket, pNext(p), L->pLength - 1);
307  pNext(p) = NULL;
308  if (L->t_p != NULL) pNext(L->t_p) = NULL;
309  L->pLength = 0;
310  L->bucket = bucket;
311  }
312  else
313  kBucketDestroy(&bucket);
314  }
315  kTest_L(L,strat->tailRing);
316  }
317 }
KINLINE poly kNoetherTail()
Definition: kInline.h:66
char LDegLast
Definition: kutil.h:384
char kHEdgeFound
Definition: kutil.h:375
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:889
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1655
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1500

◆ deleteHC() [2/2]

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

Definition at line 319 of file kutil.cc.

320 {
321  LObject L(*p, currRing, strat->tailRing);
322 
323  deleteHC(&L, strat);
324  *p = L.p;
325  *e = L.ecart;
326  *l = L.length;
327  if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
328 }
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition: kutil.cc:244

◆ deleteInL()

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

Definition at line 1203 of file kutil.cc.

1204 {
1205  if (set[j].lcm!=NULL)
1206  {
1207  kDeleteLcm(&set[j]);
1208  }
1209  if (set[j].sig!=NULL)
1210  {
1211 #ifdef HAVE_RINGS
1212  if (pGetCoeff(set[j].sig) != NULL)
1213  pLmDelete(set[j].sig);
1214  else
1215 #endif
1216  pLmFree(set[j].sig);
1217  }
1218  if (set[j].p!=NULL)
1219  {
1220  if (pNext(set[j].p) == strat->tail)
1221  {
1222 #ifdef HAVE_RINGS
1223  if (pGetCoeff(set[j].p) != NULL)
1224  pLmDelete(set[j].p);
1225  else
1226 #endif
1227  pLmFree(set[j].p);
1228  /*- tail belongs to several int spolys -*/
1229  }
1230  else
1231  {
1232  // search p in T, if it is there, do not delete it
1233  if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1234  {
1235  // assure that for global orderings kFindInT fails
1236  //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1237  set[j].Delete();
1238  }
1239  }
1240  }
1241  if (*length > 0 && j < *length)
1242  {
1243 #ifdef ENTER_USE_MEMMOVE
1244  memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1245 #else
1246  int i;
1247  for (i=j; i < (*length); i++)
1248  set[i] = set[i+1];
1249 #endif
1250  }
1251 #ifdef KDEBUG
1252  memset(&(set[*length]),0,sizeof(LObject));
1253 #endif
1254  (*length)--;
1255 }
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
int kFindInT(poly p, TSet T, int tlength)
returns index of p in TSet, or -1 if not found
Definition: kutil.cc:711
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 1096 of file kutil.cc.

1097 {
1098 #ifdef ENTER_USE_MEMMOVE
1099  memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1100  memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1101  memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1102  memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1103 #else
1104  int j;
1105  for (j=i; j<strat->sl; j++)
1106  {
1107  strat->S[j] = strat->S[j+1];
1108  strat->ecartS[j] = strat->ecartS[j+1];
1109  strat->sevS[j] = strat->sevS[j+1];
1110  strat->S_2_R[j] = strat->S_2_R[j+1];
1111  }
1112 #endif
1113  if (strat->lenS!=NULL)
1114  {
1115 #ifdef ENTER_USE_MEMMOVE
1116  memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1117 #else
1118  for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1119 #endif
1120  }
1121  if (strat->lenSw!=NULL)
1122  {
1123 #ifdef ENTER_USE_MEMMOVE
1124  memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1125 #else
1126  for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1127 #endif
1128  }
1129  if (strat->fromQ!=NULL)
1130  {
1131 #ifdef ENTER_USE_MEMMOVE
1132  memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1133 #else
1134  for (j=i; j<strat->sl; j++)
1135  {
1136  strat->fromQ[j] = strat->fromQ[j+1];
1137  }
1138 #endif
1139  }
1140  strat->S[strat->sl] = NULL;
1141  strat->sl--;
1142 }
intset lenS
Definition: kutil.h:315
intset ecartS
Definition: kutil.h:305
wlen_set lenSw
Definition: kutil.h:316
int64 wlen_type
Definition: kutil.h:50

◆ deleteInSSba()

void deleteInSSba ( int  i,
kStrategy  strat 
)

Definition at line 1148 of file kutil.cc.

1149 {
1150 #ifdef ENTER_USE_MEMMOVE
1151  memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1152  memmove(&(strat->sig[i]), &(strat->sig[i+1]), (strat->sl - i)*sizeof(poly));
1153  memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1154  memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1155  memmove(&(strat->sevSig[i]),&(strat->sevSig[i+1]),(strat->sl - i)*sizeof(unsigned long));
1156  memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1157 #else
1158  int j;
1159  for (j=i; j<strat->sl; j++)
1160  {
1161  strat->S[j] = strat->S[j+1];
1162  strat->sig[j] = strat->sig[j+1];
1163  strat->ecartS[j] = strat->ecartS[j+1];
1164  strat->sevS[j] = strat->sevS[j+1];
1165  strat->sevSig[j] = strat->sevSig[j+1];
1166  strat->S_2_R[j] = strat->S_2_R[j+1];
1167  }
1168 #endif
1169  if (strat->lenS!=NULL)
1170  {
1171 #ifdef ENTER_USE_MEMMOVE
1172  memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1173 #else
1174  for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1175 #endif
1176  }
1177  if (strat->lenSw!=NULL)
1178  {
1179 #ifdef ENTER_USE_MEMMOVE
1180  memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1181 #else
1182  for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1183 #endif
1184  }
1185  if (strat->fromQ!=NULL)
1186  {
1187 #ifdef ENTER_USE_MEMMOVE
1188  memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1189 #else
1190  for (j=i; j<strat->sl; j++)
1191  {
1192  strat->fromQ[j] = strat->fromQ[j+1];
1193  }
1194 #endif
1195  }
1196  strat->S[strat->sl] = NULL;
1197  strat->sl--;
1198 }

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4604 of file kutil.cc.

4605 {
4606  if (nIsOne(pGetCoeff(h))) return;
4607  number gcd;
4608  bool go = false;
4609  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4610  {
4611  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4612  go = true;
4613  }
4614  else
4615  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4616  if (go || !nIsOne(gcd))
4617  {
4618  poly p = h->next;
4619  if (!go)
4620  {
4621  number tmp = gcd;
4622  gcd = n_Ann(gcd,currRing->cf);
4623  nDelete(&tmp);
4624  }
4625  p_Test(p,strat->tailRing);
4626  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4627  nDelete(&gcd);
4628 
4629  if (p != NULL)
4630  {
4631  if (TEST_OPT_PROT)
4632  {
4633  PrintS("Z");
4634  }
4635 #ifdef KDEBUG
4636  if (TEST_OPT_DEBUG)
4637  {
4638  PrintS("--- create zero spoly: ");
4639  p_wrp(h,currRing,strat->tailRing);
4640  PrintS(" ---> ");
4641  }
4642 #endif
4643  poly tmp = pInit();
4644  pSetCoeff0(tmp, pGetCoeff(p));
4645  for (int i = 1; i <= rVar(currRing); i++)
4646  {
4647  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4648  }
4650  {
4651  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4652  }
4653  p_Setm(tmp, currRing);
4654  p = p_LmFreeAndNext(p, strat->tailRing);
4655  pNext(tmp) = p;
4656  LObject Lp;
4657  Lp.Init();
4658  Lp.p = tmp;
4659  Lp.tailRing = strat->tailRing;
4660  int posx;
4661  if (Lp.p!=NULL)
4662  {
4663  strat->initEcart(&Lp);
4664  if (strat->Ll==-1)
4665  posx =0;
4666  else
4667  posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4668  Lp.sev = pGetShortExpVector(Lp.p);
4669  if (strat->tailRing != currRing)
4670  {
4671  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4672  }
4673 #ifdef KDEBUG
4674  if (TEST_OPT_DEBUG)
4675  {
4676  p_wrp(tmp,currRing,strat->tailRing);
4677  PrintLn();
4678  }
4679 #endif
4680  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4681  }
4682  }
4683  }
4684  nDelete(&gcd);
4685 }
int Lmax
Definition: kutil.h:349
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:686
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:701
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:905
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1260
#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:961
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:702
#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 4687 of file kutil.cc.

4688 {
4689  if (nIsOne(pGetCoeff(h))) return;
4690  number gcd;
4691  bool go = false;
4692  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4693  {
4694  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4695  go = true;
4696  }
4697  else
4698  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4699  if (go || !nIsOne(gcd))
4700  {
4701  poly p = h->next;
4702  if (!go)
4703  {
4704  number tmp = gcd;
4705  gcd = n_Ann(gcd,currRing->cf);
4706  nDelete(&tmp);
4707  }
4708  p_Test(p,strat->tailRing);
4709  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4710 
4711  if (p != NULL)
4712  {
4713  if (TEST_OPT_PROT)
4714  {
4715  PrintS("Z");
4716  }
4717 #ifdef KDEBUG
4718  if (TEST_OPT_DEBUG)
4719  {
4720  PrintS("--- create zero spoly: ");
4721  p_wrp(h,currRing,strat->tailRing);
4722  PrintS(" ---> ");
4723  }
4724 #endif
4725  poly tmp = pInit();
4726  pSetCoeff0(tmp, pGetCoeff(p));
4727  for (int i = 1; i <= rVar(currRing); i++)
4728  {
4729  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4730  }
4732  {
4733  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4734  }
4735  p_Setm(tmp, currRing);
4736  p = p_LmFreeAndNext(p, strat->tailRing);
4737  pNext(tmp) = p;
4738  LObject Lp;
4739  Lp.Init();
4740  Lp.p = tmp;
4741  //printf("\nOld\n");pWrite(h);pWrite(hSig);
4742  #if EXT_POLY_NEW
4743  Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4744  if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4745  {
4746  strat->sigdrop = TRUE;
4747  //Try to reduce it as far as we can via redRing
4748  int red_result = redRing(&Lp,strat);
4749  if(red_result == 0)
4750  {
4751  // Cancel the sigdrop
4752  p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4753  strat->sigdrop = FALSE;
4754  return;
4755  }
4756  else
4757  {
4758  strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4759  #if 1
4760  strat->enterS(Lp,0,strat,strat->tl);
4761  #endif
4762  return;
4763  }
4764 
4765  }
4766  #else
4767  Lp.sig = pOne();
4768  if(strat->Ll >= 0)
4769  p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4770  else
4771  p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4772  #endif
4773  Lp.tailRing = strat->tailRing;
4774  int posx;
4775  if (Lp.p!=NULL)
4776  {
4777  strat->initEcart(&Lp);
4778  if (strat->Ll==-1)
4779  posx =0;
4780  else
4781  posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4782  Lp.sev = pGetShortExpVector(Lp.p);
4783  if (strat->tailRing != currRing)
4784  {
4785  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4786  }
4787 #ifdef KDEBUG
4788  if (TEST_OPT_DEBUG)
4789  {
4790  p_wrp(tmp,currRing,strat->tailRing);
4791  PrintLn();
4792  }
4793 #endif
4794  //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4795  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4796  }
4797  }
4798  nDelete(&gcd);
4799  }
4800  nDelete(&gcd);
4801 }
bool sigdrop
Definition: kutil.h:358
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:278
int redRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:715
#define nIsZero(n)
Definition: numbers.h:19

◆ enterL()

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

Definition at line 1260 of file kutil.cc.

1261 {
1262  // this should be corrected
1263  assume(p.FDeg == p.pFDeg());
1264 
1265  if ((*length)>=0)
1266  {
1267  if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1268  if (at <= (*length))
1269 #ifdef ENTER_USE_MEMMOVE
1270  memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1271 #else
1272  for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1273 #endif
1274  }
1275  else at = 0;
1276  (*set)[at] = p;
1277  (*length)++;
1278 }
static void enlargeL(LSet *L, int *length, const int incr)
Definition: kutil.cc:656
#define setmaxLinc
Definition: kutil.h:31

◆ enterOnePairNormal()

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

Definition at line 1929 of file kutil.cc.

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

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

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

4860 {
4861  int j=pos;
4862 
4864  initenterpairs(h,k,ecart,0,strat, atR);
4865  if ( (!strat->fromT)
4866  && ((strat->syzComp==0)
4867  ||(pGetComp(h)<=strat->syzComp)))
4868  {
4869  unsigned long h_sev = pGetShortExpVector(h);
4870  loop
4871  {
4872  if (j > k) break;
4873  clearS(h,h_sev, &j,&k,strat);
4874  j++;
4875  }
4876  }
4877 }
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3769

◆ enterpairsShift()

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

Definition at line 12777 of file kutil.cc.

12778 {
12779  /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12780  /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
12781  int j=pos;
12782 
12784  initenterpairsShift(h,k,ecart,0,strat, atR);
12785  if ( (!strat->fromT)
12786  && ((strat->syzComp==0)
12787  ||(pGetComp(h)<=strat->syzComp)))
12788  {
12789  unsigned long h_sev = pGetShortExpVector(h);
12790  loop
12791  {
12792  if (j > k) break;
12793  // TODO this currently doesn't clear all possible elements because of commutative division
12794  if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
12795  clearS(h,h_sev, &j,&k,strat);
12796  j++;
12797  }
12798  }
12799 }
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:12600

◆ enterpairsSig()

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

Definition at line 4885 of file kutil.cc.

4886 {
4887  int j=pos;
4889  initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4890  if ( (!strat->fromT)
4891  && ((strat->syzComp==0)
4892  ||(pGetComp(h)<=strat->syzComp)))
4893  {
4894  unsigned long h_sev = pGetShortExpVector(h);
4895  loop
4896  {
4897  if (j > k) break;
4898  clearS(h,h_sev, &j,&k,strat);
4899  j++;
4900  }
4901  }
4902 }
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3834

◆ enterSBba()

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

Definition at line 9271 of file kutil.cc.

9272 {
9273  strat->news = TRUE;
9274  /*- puts p to the standardbasis s at position at -*/
9275  if (strat->sl == IDELEMS(strat->Shdl)-1)
9276  {
9277  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9278  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9279  (IDELEMS(strat->Shdl)+setmaxTinc)
9280  *sizeof(unsigned long));
9281  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9282  IDELEMS(strat->Shdl)*sizeof(int),
9283  (IDELEMS(strat->Shdl)+setmaxTinc)
9284  *sizeof(int));
9285  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9286  IDELEMS(strat->Shdl)*sizeof(int),
9287  (IDELEMS(strat->Shdl)+setmaxTinc)
9288  *sizeof(int));
9289  if (strat->lenS!=NULL)
9290  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9291  IDELEMS(strat->Shdl)*sizeof(int),
9292  (IDELEMS(strat->Shdl)+setmaxTinc)
9293  *sizeof(int));
9294  if (strat->lenSw!=NULL)
9295  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9296  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9297  (IDELEMS(strat->Shdl)+setmaxTinc)
9298  *sizeof(wlen_type));
9299  if (strat->fromQ!=NULL)
9300  {
9301  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9302  IDELEMS(strat->Shdl)*sizeof(int),
9303  (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
9304  }
9305  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
9306  IDELEMS(strat->Shdl)+=setmaxTinc;
9307  strat->Shdl->m=strat->S;
9308  }
9309  if (atS <= strat->sl)
9310  {
9311 #ifdef ENTER_USE_MEMMOVE
9312  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9313  (strat->sl - atS + 1)*sizeof(poly));
9314  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9315  (strat->sl - atS + 1)*sizeof(int));
9316  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9317  (strat->sl - atS + 1)*sizeof(unsigned long));
9318  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9319  (strat->sl - atS + 1)*sizeof(int));
9320  if (strat->lenS!=NULL)
9321  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9322  (strat->sl - atS + 1)*sizeof(int));
9323  if (strat->lenSw!=NULL)
9324  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9325  (strat->sl - atS + 1)*sizeof(wlen_type));
9326 #else
9327  for (i=strat->sl+1; i>=atS+1; i--)
9328  {
9329  strat->S[i] = strat->S[i-1];
9330  strat->ecartS[i] = strat->ecartS[i-1];
9331  strat->sevS[i] = strat->sevS[i-1];
9332  strat->S_2_R[i] = strat->S_2_R[i-1];
9333  }
9334  if (strat->lenS!=NULL)
9335  for (i=strat->sl+1; i>=atS+1; i--)
9336  strat->lenS[i] = strat->lenS[i-1];
9337  if (strat->lenSw!=NULL)
9338  for (i=strat->sl+1; i>=atS+1; i--)
9339  strat->lenSw[i] = strat->lenSw[i-1];
9340 #endif
9341  }
9342  if (strat->fromQ!=NULL)
9343  {
9344 #ifdef ENTER_USE_MEMMOVE
9345  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9346  (strat->sl - atS + 1)*sizeof(int));
9347 #else
9348  for (i=strat->sl+1; i>=atS+1; i--)
9349  {
9350  strat->fromQ[i] = strat->fromQ[i-1];
9351  }
9352 #endif
9353  strat->fromQ[atS]=0;
9354  }
9355 
9356  /*- save result -*/
9357  poly pp=p.p;
9358  strat->S[atS] = pp;
9359  if (strat->honey) strat->ecartS[atS] = p.ecart;
9360  if (p.sev == 0)
9361  p.sev = pGetShortExpVector(pp);
9362  else
9363  assume(p.sev == pGetShortExpVector(pp));
9364  strat->sevS[atS] = p.sev;
9365  strat->ecartS[atS] = p.ecart;
9366  strat->S_2_R[atS] = atR;
9367  strat->sl++;
9368 }
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
char news
Definition: kutil.h:399
#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 9371 of file kutil.cc.

9372 {
9373  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
9374  for (int i = maxPossibleShift; i > 0; i--)
9375  {
9376  LObject qq;
9377  qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
9378  qq.shift = i;
9379  strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
9380  enterSBba(qq, atS, strat, -1);
9381  }
9382  enterSBba(p, atS, strat, atR);
9383 }
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9271
int p_mLPmaxPossibleShift(poly p, const ring r)
Definition: shiftgb.cc:45
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ entersets()

void entersets ( LObject  h)

◆ enterSSba()

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

Definition at line 9390 of file kutil.cc.

9391 {
9392  strat->news = TRUE;
9393  /*- puts p to the standardbasis s at position at -*/
9394  if (strat->sl == IDELEMS(strat->Shdl)-1)
9395  {
9396  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9397  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9398  (IDELEMS(strat->Shdl)+setmax)
9399  *sizeof(unsigned long));
9400  strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
9401  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9402  (IDELEMS(strat->Shdl)+setmax)
9403  *sizeof(unsigned long));
9404  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9405  IDELEMS(strat->Shdl)*sizeof(int),
9406  (IDELEMS(strat->Shdl)+setmax)
9407  *sizeof(int));
9408  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9409  IDELEMS(strat->Shdl)*sizeof(int),
9410  (IDELEMS(strat->Shdl)+setmax)
9411  *sizeof(int));
9412  if (strat->lenS!=NULL)
9413  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9414  IDELEMS(strat->Shdl)*sizeof(int),
9415  (IDELEMS(strat->Shdl)+setmax)
9416  *sizeof(int));
9417  if (strat->lenSw!=NULL)
9418  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9419  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9420  (IDELEMS(strat->Shdl)+setmax)
9421  *sizeof(wlen_type));
9422  if (strat->fromQ!=NULL)
9423  {
9424  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9425  IDELEMS(strat->Shdl)*sizeof(int),
9426  (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
9427  }
9428  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
9429  pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
9430  IDELEMS(strat->Shdl)+=setmax;
9431  strat->Shdl->m=strat->S;
9432  }
9433  // in a signature-based algorithm the following situation will never
9434  // appear due to the fact that the critical pairs are already sorted
9435  // by increasing signature.
9436  // True. However, in the case of integers we need to put the element
9437  // that caused the signature drop on the first position
9438  if (atS <= strat->sl)
9439  {
9440 #ifdef ENTER_USE_MEMMOVE
9441  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9442  (strat->sl - atS + 1)*sizeof(poly));
9443  memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
9444  (strat->sl - atS + 1)*sizeof(poly));
9445  memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
9446  (strat->sl - atS + 1)*sizeof(unsigned long));
9447  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9448  (strat->sl - atS + 1)*sizeof(int));
9449  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9450  (strat->sl - atS + 1)*sizeof(unsigned long));
9451  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9452  (strat->sl - atS + 1)*sizeof(int));
9453  if (strat->lenS!=NULL)
9454  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9455  (strat->sl - atS + 1)*sizeof(int));
9456  if (strat->lenSw!=NULL)
9457  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9458  (strat->sl - atS + 1)*sizeof(wlen_type));
9459 #else
9460  for (i=strat->sl+1; i>=atS+1; i--)
9461  {
9462  strat->S[i] = strat->S[i-1];
9463  strat->ecartS[i] = strat->ecartS[i-1];
9464  strat->sevS[i] = strat->sevS[i-1];
9465  strat->S_2_R[i] = strat->S_2_R[i-1];
9466  strat->sig[i] = strat->sig[i-1];
9467  strat->sevSig[i] = strat->sevSig[i-1];
9468  }
9469  if (strat->lenS!=NULL)
9470  for (i=strat->sl+1; i>=atS+1; i--)
9471  strat->lenS[i] = strat->lenS[i-1];
9472  if (strat->lenSw!=NULL)
9473  for (i=strat->sl+1; i>=atS+1; i--)
9474  strat->lenSw[i] = strat->lenSw[i-1];
9475 #endif
9476  }
9477  if (strat->fromQ!=NULL)
9478  {
9479 #ifdef ENTER_USE_MEMMOVE
9480  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9481  (strat->sl - atS + 1)*sizeof(int));
9482 #else
9483  for (i=strat->sl+1; i>=atS+1; i--)
9484  {
9485  strat->fromQ[i] = strat->fromQ[i-1];
9486  }
9487 #endif
9488  strat->fromQ[atS]=0;
9489  }
9490 
9491  /*- save result -*/
9492  strat->S[atS] = p.p;
9493  strat->sig[atS] = p.sig; // TODO: get ths correct signature in here!
9494  if (strat->honey) strat->ecartS[atS] = p.ecart;
9495  if (p.sev == 0)
9496  p.sev = pGetShortExpVector(p.p);
9497  else
9498  assume(p.sev == pGetShortExpVector(p.p));
9499  strat->sevS[atS] = p.sev;
9500  // during the interreduction process of a signature-based algorithm we do not
9501  // compute the signature at this point, but when the whole interreduction
9502  // process finishes, i.e. f5c terminates!
9503  if (p.sig != NULL)
9504  {
9505  if (p.sevSig == 0)
9506  p.sevSig = pGetShortExpVector(p.sig);
9507  else
9508  assume(p.sevSig == pGetShortExpVector(p.sig));
9509  strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9510  }
9511  strat->ecartS[atS] = p.ecart;
9512  strat->S_2_R[atS] = atR;
9513  strat->sl++;
9514 #ifdef DEBUGF5
9515  int k;
9516  Print("--- LIST S: %d ---\n",strat->sl);
9517  for(k=0;k<=strat->sl;k++)
9518  {
9519  pWrite(strat->sig[k]);
9520  }
9521  PrintS("--- LIST S END ---\n");
9522 #endif
9523 }
#define setmax
Definition: kutil.h:29
void pWrite(poly p)
Definition: polys.h:304

◆ enterSyz()

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

Definition at line 9788 of file kutil.cc.

9789 {
9790  int i;
9791  strat->newt = TRUE;
9792  if (strat->syzl == strat->syzmax-1)
9793  {
9794  pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9795  strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9796  (strat->syzmax)*sizeof(unsigned long),
9797  ((strat->syzmax)+setmax)
9798  *sizeof(unsigned long));
9799  strat->syzmax += setmax;
9800  }
9801  if (atT < strat->syzl)
9802  {
9803 #ifdef ENTER_USE_MEMMOVE
9804  memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9805  (strat->syzl-atT+1)*sizeof(poly));
9806  memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9807  (strat->syzl-atT+1)*sizeof(unsigned long));
9808 #endif
9809  for (i=strat->syzl; i>=atT+1; i--)
9810  {
9811 #ifndef ENTER_USE_MEMMOVE
9812  strat->syz[i] = strat->syz[i-1];
9813  strat->sevSyz[i] = strat->sevSyz[i-1];
9814 #endif
9815  }
9816  }
9817  //i = strat->syzl;
9818  i = atT;
9819  //Makes sure the syz saves just the signature
9820  #ifdef HAVE_RINGS
9822  pNext(p.sig) = NULL;
9823  #endif
9824  strat->syz[atT] = p.sig;
9825  strat->sevSyz[atT] = p.sevSig;
9826  strat->syzl++;
9827 #if F5DEBUG
9828  Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9829  pWrite(strat->syz[atT]);
9830 #endif
9831  // recheck pairs in strat->L with new rule and delete correspondingly
9832  int cc = strat->Ll;
9833  while (cc>-1)
9834  {
9835  //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9836  //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);
9837  if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9838  strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9839  #ifdef HAVE_RINGS
9840  &&((!rField_is_Ring(currRing))
9841  || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9842  #endif
9843  )
9844  {
9845  //printf("\nYES!\n");
9846  deleteInL(strat->L,&strat->Ll,cc,strat);
9847  }
9848  cc--;
9849  }
9850 //#if 1
9851 #ifdef DEBUGF5
9852  PrintS("--- Syzygies ---\n");
9853  Print("syzl %d\n",strat->syzl);
9854  Print("syzmax %d\n",strat->syzmax);
9855  PrintS("--------------------------------\n");
9856  for(i=0;i<=strat->syzl-1;i++)
9857  {
9858  Print("%d - ",i);
9859  pWrite(strat->syz[i]);
9860  }
9861  PrintS("--------------------------------\n");
9862 #endif
9863 }
unsigned long * sevSyz
Definition: kutil.h:319
int syzmax
Definition: kutil.h:347
int syzl
Definition: kutil.h:347
polyset syz
Definition: kutil.h:303
char newt
Definition: kutil.h:400
#define pLtCmp(p, q)
Definition: polys.h:123

◆ enterT()

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

Definition at line 9586 of file kutil.cc.

9587 {
9588  int i;
9589 
9590 #ifdef PDEBUG
9591 #ifdef HAVE_SHIFTBBA
9592  if (currRing->isLPring && p.shift > 0)
9593  {
9594  // in this case, the order is not correct. test LM and tail separately
9595  p_LmTest(p.p, currRing);
9596  p_Test(pNext(p.p), currRing);
9597  }
9598  else
9599 #endif
9600  {
9601  pp_Test(p.p, currRing, p.tailRing);
9602  }
9603 #endif
9604  assume(strat->tailRing == p.tailRing);
9605  // redMoraNF complains about this -- but, we don't really
9606  // neeed this so far
9607  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9608  assume(p.FDeg == p.pFDeg());
9609  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9610 
9611 #ifdef KDEBUG
9612  // do not put an LObject twice into T:
9613  for(i=strat->tl;i>=0;i--)
9614  {
9615  if (p.p==strat->T[i].p)
9616  {
9617  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9618  return;
9619  }
9620  }
9621 #endif
9622 
9623 #ifdef HAVE_TAIL_RING
9624  if (currRing!=strat->tailRing)
9625  {
9626  p.t_p=p.GetLmTailRing();
9627  }
9628 #endif
9629  strat->newt = TRUE;
9630  if (atT < 0)
9631  atT = strat->posInT(strat->T, strat->tl, p);
9632  if (strat->tl == strat->tmax-1)
9633  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9634  if (atT <= strat->tl)
9635  {
9636 #ifdef ENTER_USE_MEMMOVE
9637  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9638  (strat->tl-atT+1)*sizeof(TObject));
9639  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9640  (strat->tl-atT+1)*sizeof(unsigned long));
9641 #endif
9642  for (i=strat->tl+1; i>=atT+1; i--)
9643  {
9644 #ifndef ENTER_USE_MEMMOVE
9645  strat->T[i] = strat->T[i-1];
9646  strat->sevT[i] = strat->sevT[i-1];
9647 #endif
9648  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9649  }
9650  }
9651 
9652  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9653  {
9654 #ifdef HAVE_SHIFTBBA
9655  // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9656  if (!(currRing->isLPring && p.shift > 0))
9657 #endif
9658  {
9660  (strat->tailRing != NULL ?
9661  strat->tailRing : currRing),
9662  strat->tailBin);
9663  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9664  }
9665  }
9666  strat->T[atT] = (TObject) p;
9667  //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9668 
9669  if (pNext(p.p) != NULL)
9670  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9671  else
9672  strat->T[atT].max_exp = NULL;
9673 
9674  strat->tl++;
9675  strat->R[strat->tl] = &(strat->T[atT]);
9676  strat->T[atT].i_r = strat->tl;
9677  assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9678  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9679  kTest_T(&(strat->T[atT]));
9680 }
int tmax
Definition: kutil.h:348
omBin tailBin
Definition: kutil.h:343
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition: kutil.cc:517
BOOLEAN kTest_T(TObject *T, ring strat_tailRing, int i, char TN)
Definition: kutil.cc:765
#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:887
#define p_LmTest(p, r)
Definition: p_polys.h:163
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:715

◆ enterT_strong()

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

Definition at line 9686 of file kutil.cc.

9687 {
9689  int i;
9690 
9691  pp_Test(p.p, currRing, p.tailRing);
9692  assume(strat->tailRing == p.tailRing);
9693  // redMoraNF complains about this -- but, we don't really
9694  // neeed this so far
9695  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9696  assume(p.FDeg == p.pFDeg());
9697  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9698 
9699 #ifdef KDEBUG
9700  // do not put an LObject twice into T:
9701  for(i=strat->tl;i>=0;i--)
9702  {
9703  if (p.p==strat->T[i].p)
9704  {
9705  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9706  return;
9707  }
9708  }
9709 #endif
9710 
9711 #ifdef HAVE_TAIL_RING
9712  if (currRing!=strat->tailRing)
9713  {
9714  p.t_p=p.GetLmTailRing();
9715  }
9716 #endif
9717  strat->newt = TRUE;
9718  if (atT < 0)
9719  atT = strat->posInT(strat->T, strat->tl, p);
9720  if (strat->tl == strat->tmax-1)
9721  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9722  if (atT <= strat->tl)
9723  {
9724 #ifdef ENTER_USE_MEMMOVE
9725  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9726  (strat->tl-atT+1)*sizeof(TObject));
9727  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9728  (strat->tl-atT+1)*sizeof(unsigned long));
9729 #endif
9730  for (i=strat->tl+1; i>=atT+1; i--)
9731  {
9732 #ifndef ENTER_USE_MEMMOVE
9733  strat->T[i] = strat->T[i-1];
9734  strat->sevT[i] = strat->sevT[i-1];
9735 #endif
9736  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9737  }
9738  }
9739 
9740  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9741  {
9743  (strat->tailRing != NULL ?
9744  strat->tailRing : currRing),
9745  strat->tailBin);
9746  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9747  }
9748  strat->T[atT] = (TObject) p;
9749  //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9750 
9751  if (pNext(p.p) != NULL)
9752  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9753  else
9754  strat->T[atT].max_exp = NULL;
9755 
9756  strat->tl++;
9757  strat->R[strat->tl] = &(strat->T[atT]);
9758  strat->T[atT].i_r = strat->tl;
9759  assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9760  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9761  #if 1
9763  && !n_IsUnit(p.p->coef, currRing->cf))
9764  {
9765  for(i=strat->tl;i>=0;i--)
9766  {
9767  if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9768  {
9769  enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9770  }
9771  }
9772  }
9773  /*
9774  printf("\nThis is T:\n");
9775  for(i=strat->tl;i>=0;i--)
9776  {
9777  pWrite(strat->T[i].p);
9778  }
9779  //getchar();*/
9780  #endif
9781  kTest_T(&(strat->T[atT]));
9782 }
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:515
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1528
#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 12807 of file kutil.cc.

12808 {
12809  /* determine how many elements we have to insert */
12810  /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
12811  /* hence, a total number of elt's to add is: */
12812  /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
12813  pAssume(p.p != NULL);
12814 
12815  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
12816 
12817  for (int i = 1; i <= maxPossibleShift; i++)
12818  {
12819  LObject qq;
12820  qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
12821  qq.shift = i;
12822  strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
12823 
12824  enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
12825  }
12826 }
#define pAssume(cond)
Definition: monomials.h:90

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 10292 of file kutil.cc.

10293 {
10294  /*- release temp data -*/
10295  cleanT(strat);
10296  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10297  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10298  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10299  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10300  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10301  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10302  /*- set L: should be empty -*/
10303  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10304  /*- set B: should be empty -*/
10305  omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10306  pLmFree(&strat->tail);
10307  strat->syzComp=0;
10308 
10309 #ifdef HAVE_SHIFTBBA
10310  if (rIsLPRing(currRing) && strat->rightGB)
10311  {
10312  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10313  strat->fromQ=NULL;
10314  }
10315 #endif
10316 }
void * ADDRESS
Definition: auxiliary.h:135
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:408

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10493 of file kutil.cc.

10494 {
10495  /*- release temp data -*/
10497  cleanTSbaRing(strat);
10498  else
10499  cleanT(strat);
10500  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10501  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10502  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10503  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10504  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10505  omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10506  if(strat->syzmax>0)
10507  {
10508  omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10509  omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10510  if (strat->sbaOrder == 1)
10511  {
10512  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10513  }
10514  }
10515  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10516  /*- set L: should be empty -*/
10517  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10518  /*- set B: should be empty -*/
10519  omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10520  /*- set sig: no need for the signatures anymore -*/
10521  omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10522  pLmDelete(&strat->tail);
10523  strat->syzComp=0;
10524 }
int syzidxmax
Definition: kutil.h:347
intset syzIdx
Definition: kutil.h:309
unsigned sbaOrder
Definition: kutil.h:312
void cleanTSbaRing(kStrategy strat)
Definition: kutil.cc:597

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

3851 {
3852  int Ll_old, red_result = 1;
3853  int pos = 0;
3854  hilbeledeg=1;
3855  hilbcount=0;
3856  minimcnt=0;
3857  srmax = 0; // strat->sl is 0 at this point
3858  reduc = olddeg = lrmax = 0;
3859  // we cannot use strat->T anymore
3860  //cleanT(strat);
3861  //strat->tl = -1;
3862  Ll_old = strat->Ll;
3863  while (strat->tl >= 0)
3864  {
3865  if(!strat->T[strat->tl].is_redundant)
3866  {
3867  LObject h;
3868  h.p = strat->T[strat->tl].p;
3869  h.tailRing = strat->T[strat->tl].tailRing;
3870  h.t_p = strat->T[strat->tl].t_p;
3871  if (h.p!=NULL)
3872  {
3873  if (currRing->OrdSgn==-1)
3874  {
3875  cancelunit(&h);
3876  deleteHC(&h, strat);
3877  }
3878  if (h.p!=NULL)
3879  {
3881  {
3882  h.pCleardenom(); // also does remove Content
3883  }
3884  else
3885  {
3886  h.pNorm();
3887  }
3888  strat->initEcart(&h);
3890  pos = posInLF5CRing(strat->L, Ll_old+1,strat->Ll,&h,strat);
3891  else
3892  pos = strat->Ll+1;
3893  h.sev = pGetShortExpVector(h.p);
3894  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
3895  }
3896  }
3897  }
3898  strat->tl--;
3899  }
3900  strat->sl = -1;
3901 #if 0
3902 //#ifdef HAVE_TAIL_RING
3903  if(!rField_is_Ring()) // create strong gcd poly computes with tailring and S[i] ->to be fixed
3904  kStratInitChangeTailRing(strat);
3905 #endif
3906  //enterpairs(pOne(),0,0,-1,strat,strat->tl);
3907  //strat->sl = -1;
3908  /* picks the last element from the lazyset L */
3909  while (strat->Ll>Ll_old)
3910  {
3911  strat->P = strat->L[strat->Ll];
3912  strat->Ll--;
3913 //#if 1
3914 #ifdef DEBUGF5
3915  PrintS("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
3916  PrintS("-------------------------------------------------\n");
3917  pWrite(pHead(strat->P.p));
3918  pWrite(pHead(strat->P.p1));
3919  pWrite(pHead(strat->P.p2));
3920  printf("%d\n",strat->tl);
3921  PrintS("-------------------------------------------------\n");
3922 #endif
3923  if (pNext(strat->P.p) == strat->tail)
3924  {
3925  // deletes the short spoly
3926  if (rField_is_Ring(currRing))
3927  pLmDelete(strat->P.p);
3928  else
3929  pLmFree(strat->P.p);
3930 
3931  // TODO: needs some masking
3932  // TODO: masking needs to vanish once the signature
3933  // sutff is completely implemented
3934  strat->P.p = NULL;
3935  poly m1 = NULL, m2 = NULL;
3936 
3937  // check that spoly creation is ok
3938  while (strat->tailRing != currRing &&
3939  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
3940  {
3941  assume(m1 == NULL && m2 == NULL);
3942  // if not, change to a ring where exponents are at least
3943  // large enough
3944  if (!kStratChangeTailRing(strat))
3945  {
3946  WerrorS("OVERFLOW...");
3947  break;
3948  }
3949  }
3950  // create the real one
3951  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
3952  strat->tailRing, m1, m2, strat->R);
3953  }
3954  else if (strat->P.p1 == NULL)
3955  {
3956  if (strat->minim > 0)
3957  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
3958  // for input polys, prepare reduction
3959  if(!rField_is_Ring(currRing))
3960  strat->P.PrepareRed(strat->use_buckets);
3961  }
3962 
3963  if (strat->P.p == NULL && strat->P.t_p == NULL)
3964  {
3965  red_result = 0;
3966  }
3967  else
3968  {
3969  if (TEST_OPT_PROT)
3970  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
3971  &olddeg,&reduc,strat, red_result);
3972 
3973 #ifdef DEBUGF5
3974  PrintS("Poly before red: ");
3975  pWrite(strat->P.p);
3976 #endif
3977  /* complete reduction of the element chosen from L */
3978  red_result = strat->red2(&strat->P,strat);
3979  if (errorreported) break;
3980  }
3981 
3982  if (strat->overflow)
3983  {
3984  if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
3985  }
3986 
3987  // reduction to non-zero new poly
3988  if (red_result == 1)
3989  {
3990  // get the polynomial (canonicalize bucket, make sure P.p is set)
3991  strat->P.GetP(strat->lmBin);
3992  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
3993  // but now, for entering S, T, we reset it
3994  // in the inhomogeneous case: FDeg == pFDeg
3995  if (strat->homog) strat->initEcart(&(strat->P));
3996 
3997  /* statistic */
3998  if (TEST_OPT_PROT) PrintS("s");
3999  int pos;
4000  #if 1
4001  if(!rField_is_Ring(currRing))
4002  pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4003  else
4004  pos = posInSMonFirst(strat,strat->sl,strat->P.p);
4005  #else
4006  pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4007  #endif
4008  // reduce the tail and normalize poly
4009  // in the ring case we cannot expect LC(f) = 1,
4010  // therefore we call pCleardenom instead of pNorm
4011 #if F5CTAILRED
4012  BOOLEAN withT = TRUE;
4014  {
4015  strat->P.pCleardenom();
4017  {
4018  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4019  strat->P.pCleardenom();
4020  }
4021  }
4022  else
4023  {
4024  strat->P.pNorm();
4026  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4027  }
4028 #endif
4029 #ifdef KDEBUG
4030  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4031 #endif /* KDEBUG */
4032 
4033  // min_std stuff
4034  if ((strat->P.p1==NULL) && (strat->minim>0))
4035  {
4036  if (strat->minim==1)
4037  {
4038  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4039  p_Delete(&strat->P.p2, currRing, strat->tailRing);
4040  }
4041  else
4042  {
4043  strat->M->m[minimcnt]=strat->P.p2;
4044  strat->P.p2=NULL;
4045  }
4046  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4047  pNext(strat->M->m[minimcnt])
4048  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4049  strat->tailRing, currRing,
4050  currRing->PolyBin);
4051  minimcnt++;
4052  }
4053 
4054  // enter into S, L, and T
4055  // here we need to recompute new signatures, but those are trivial ones
4056  if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4057  {
4058  enterT(strat->P, strat);
4059  // posInS only depends on the leading term
4060  strat->enterS(strat->P, pos, strat, strat->tl);
4061 //#if 1
4062 #ifdef DEBUGF5
4063  PrintS("ELEMENT ADDED TO GCURR DURING INTERRED: ");
4064  pWrite(pHead(strat->S[strat->sl]));
4065  pWrite(strat->sig[strat->sl]);
4066 #endif
4067  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4068  }
4069  // Print("[%d]",hilbeledeg);
4070  kDeleteLcm(&strat->P);
4071  if (strat->sl>srmax) srmax = strat->sl;
4072  }
4073  else
4074  {
4075  // adds signature of the zero reduction to
4076  // strat->syz. This is the leading term of
4077  // syzygy and can be used in syzCriterion()
4078  // the signature is added if and only if the
4079  // pair was not detected by the rewritten criterion in strat->red = redSig
4080  if (strat->P.p1 == NULL && strat->minim > 0)
4081  {
4082  p_Delete(&strat->P.p2, currRing, strat->tailRing);
4083  }
4084  }
4085 
4086 #ifdef KDEBUG
4087  memset(&(strat->P), 0, sizeof(strat->P));
4088 #endif /* KDEBUG */
4089  }
4090  int cc = 0;
4091  while (cc<strat->tl+1)
4092  {
4093  strat->T[cc].sig = pOne();
4094  p_SetComp(strat->T[cc].sig,cc+1,currRing);
4095  strat->T[cc].sevSig = pGetShortExpVector(strat->T[cc].sig);
4096  strat->sig[cc] = strat->T[cc].sig;
4097  strat->sevSig[cc] = strat->T[cc].sevSig;
4098  strat->T[cc].is_sigsafe = TRUE;
4099  cc++;
4100  }
4101  strat->max_lower_index = strat->tl;
4102  // set current signature index of upcoming iteration step
4103  // NOTE: this needs to be set here, as otherwise initSyzRules cannot compute
4104  // the corresponding syzygy rules correctly
4105  strat->currIdx = cc+1;
4106  for (int cd=strat->Ll; cd>=0; cd--)
4107  {
4108  p_SetComp(strat->L[cd].sig,cc+1,currRing);
4109  cc++;
4110  }
4111  for (cc=strat->sl+1; cc<IDELEMS(strat->Shdl); ++cc)
4112  strat->Shdl->m[cc] = NULL;
4113  #if 0
4114  printf("\nAfter f5c sorting\n");
4115  for(int i=0;i<=strat->sl;i++)
4116  pWrite(pHead(strat->S[i]));
4117  getchar();
4118  #endif
4119 //#if 1
4120 #if DEBUGF5
4121  PrintS("------------------- STRAT S ---------------------\n");
4122  cc = 0;
4123  while (cc<strat->tl+1)
4124  {
4125  pWrite(pHead(strat->S[cc]));
4126  pWrite(strat->sig[cc]);
4127  printf("- - - - - -\n");
4128  cc++;
4129  }
4130  PrintS("-------------------------------------------------\n");
4131  PrintS("------------------- STRAT T ---------------------\n");
4132  cc = 0;
4133  while (cc<strat->tl+1)
4134  {
4135  pWrite(pHead(strat->T[cc].p));
4136  pWrite(strat->T[cc].sig);
4137  printf("- - - - - -\n");
4138  cc++;
4139  }
4140  PrintS("-------------------------------------------------\n");
4141  PrintS("------------------- STRAT L ---------------------\n");
4142  cc = 0;
4143  while (cc<strat->Ll+1)
4144  {
4145  pWrite(pHead(strat->L[cc].p));
4146  pWrite(pHead(strat->L[cc].p1));
4147  pWrite(pHead(strat->L[cc].p2));
4148  pWrite(strat->L[cc].sig);
4149  printf("- - - - - -\n");
4150  cc++;
4151  }
4152  PrintS("-------------------------------------------------\n");
4153  printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx);
4154 #endif
4155 
4156 }
CanonicalForm cd(bCommonDen(FF))
Definition: cfModGcd.cc:4030
int currIdx
Definition: kutil.h:313
int(* red2)(LObject *L, kStrategy strat)
Definition: kutil.h:275
int max_lower_index
Definition: kutil.h:314
int posInSMonFirst(const kStrategy strat, const int length, const poly p)
Definition: kutil.cc:5136
int posInLF5CRing(const LSet set, int start, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6399
void cancelunit(LObject *L, BOOLEAN inNF)
Definition: kutil.cc:333

◆ faugereRewCriterion()

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

Definition at line 7129 of file kutil.cc.

7130 {
7131  //printf("Faugere Rewritten Criterion\n");
7133  return FALSE;
7134 //#if 1
7135 #ifdef DEBUGF5
7136  PrintS("rewritten criterion checks: ");
7137  pWrite(sig);
7138 #endif
7139  for(int k = strat->sl; k>=start; k--)
7140  {
7141 //#if 1
7142 #ifdef DEBUGF5
7143  PrintS("checking with: ");
7144  pWrite(strat->sig[k]);
7145  pWrite(pHead(strat->S[k]));
7146 #endif
7147  if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
7148  {
7149 //#if 1
7150 #ifdef DEBUGF5
7151  PrintS("DELETE!\n");
7152 #endif
7153  strat->nrrewcrit++;
7154  return TRUE;
7155  }
7156  //k--;
7157  }
7158 #ifdef DEBUGF5
7159  PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
7160  for(int kk = 0; kk<strat->sl+1; kk++)
7161  {
7162  pWrite(pHead(strat->S[kk]));
7163  }
7164  PrintS("------------------------------\n");
7165 #endif
7166  return FALSE;
7167 }
int nrrewcrit
Definition: kutil.h:360

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy  strat)

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

Definition at line 11318 of file kutil.cc.

11319 {
11320  assume(strat->tl<0); /* can only be called with no elements in T:
11321  i.e. after exitBuchMora */
11322  /* do not use strat->S, strat->sl as they may be out of sync*/
11323  if(!nCoeff_is_Z(currRing->cf))
11324  return;
11325  poly p,pp;
11326  for(int j = 0; j<IDELEMS(strat->Shdl); j++)
11327  {
11328  if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
11329  {
11330  for(int i = 0; i<IDELEMS(strat->Shdl); i++)
11331  {
11332  if((i != j) && (strat->Shdl->m[i] != NULL))
11333  {
11334  p = strat->Shdl->m[i];
11335  while((p!=NULL) && pLmDivisibleBy(strat->Shdl->m[j], p))
11336  {
11337  number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
11338  if (!nEqual(dummy,p->coef))
11339  {
11340  if (nIsZero(dummy))
11341  {
11342  nDelete(&dummy);
11343  pLmDelete(&strat->Shdl->m[i]);
11344  p=strat->Shdl->m[i];
11345  }
11346  else
11347  {
11348  p_SetCoeff(p,dummy,currRing);
11349  break;
11350  }
11351  }
11352  else
11353  {
11354  nDelete(&dummy);
11355  break;
11356  }
11357  }
11358  if (p!=NULL)
11359  {
11360  pp = pNext(p);
11361  while(pp != NULL)
11362  {
11363  if(pLmDivisibleBy(strat->Shdl->m[j], pp))
11364  {
11365  number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
11366  if (!nEqual(dummy,pp->coef))
11367  {
11368  p_SetCoeff(pp,dummy,currRing);
11369  if(nIsZero(pp->coef))
11370  {
11371  pLmDelete(&pNext(p));
11372  pp = pNext(p);
11373  }
11374  else
11375  {
11376  p = pp;
11377  pp = pNext(p);
11378  }
11379  }
11380  else
11381  {
11382  nDelete(&dummy);
11383  p = pp;
11384  pp = pNext(p);
11385  }
11386  }
11387  else
11388  {
11389  p = pp;
11390  pp = pNext(p);
11391  }
11392  }
11393  }
11394  }
11395  }
11396  //idPrint(strat->Shdl);
11397  }
11398  }
11399  idSkipZeroes(strat->Shdl);
11400 }
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:838
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition: coeffs.h:628
#define nEqual(n1, n2)
Definition: numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 468 of file kutil.cc.

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

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ ind2()

long ind2 ( long  arg)

Definition at line 4111 of file kutil.cc.

4112 {
4113  long ind = 0;
4114  if (arg <= 0) return 0;
4115  while (arg%2 == 0)
4116  {
4117  arg = arg / 2;
4118  ind++;
4119  }
4120  return ind;
4121 }

◆ ind_fact_2()

long ind_fact_2 ( long  arg)

Definition at line 4123 of file kutil.cc.

4124 {
4125  long ind = 0;
4126  if (arg <= 0) return 0;
4127  if (arg%2 == 1) { arg--; }
4128  while (arg > 0)
4129  {
4130  ind += ind2(arg);
4131  arg = arg - 2;
4132  }
4133  return ind;
4134 }
long ind2(long arg)
Definition: kutil.cc:4111

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1334 of file kstd1.cc.

1335 {
1336  /* setting global variables ------------------- */
1337  strat->enterS = enterSBba;
1338  strat->red = redHoney;
1339  if (strat->honey)
1340  strat->red = redHoney;
1341  else if (currRing->pLexOrder && !strat->homog)
1342  strat->red = redLazy;
1343  else
1344  {
1345  strat->LazyPass *=4;
1346  strat->red = redHomog;
1347  }
1348  if (rField_is_Ring(currRing))
1349  {
1350  if (rField_is_Z(currRing))
1351  strat->red = redRing_Z;
1352  else
1353  strat->red = redRing;
1354  }
1355  if (currRing->pLexOrder && strat->honey)
1356  strat->initEcart = initEcartNormal;
1357  else
1358  strat->initEcart = initEcartBBA;
1359  if (strat->honey)
1361  else
1363 // if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1364 // {
1365 // //interred machen Aenderung
1366 // strat->pOrigFDeg=pFDeg;
1367 // strat->pOrigLDeg=pLDeg;
1368 // //h=ggetid("ecart");
1369 // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1370 // //{
1371 // // ecartWeights=iv2array(IDINTVEC(h));
1372 // //}
1373 // //else
1374 // {
1375 // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1376 // /*uses automatic computation of the ecartWeights to set them*/
1377 // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1378 // }
1379 // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1380 // if (TEST_OPT_PROT)
1381 // {
1382 // for(i=1; i<=(currRing->N); i++)
1383 // Print(" %d",ecartWeights[i]);
1384 // PrintLn();
1385 // mflush();
1386 // }
1387 // }
1388 }
int LazyPass
Definition: kutil.h:351
int redRing_Z(LObject *h, kStrategy strat)
Definition: kstd2.cc:568
int redHoney(LObject *h, kStrategy strat)
Definition: kstd2.cc:1664
int redHomog(LObject *h, kStrategy strat)
Definition: kstd2.cc:822
int redLazy(LObject *h, kStrategy strat)
Definition: kstd2.cc:1519
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition: kutil.cc:1306
void initEcartNormal(TObject *h)
Definition: kutil.cc:1284
void initEcartBBA(TObject *h)
Definition: kutil.cc:1292
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition: kutil.cc:1299

◆ initBbaShift()

void initBbaShift ( kStrategy  strat)

Definition at line 4605 of file kstd2.cc.

4606 {
4607  /* setting global variables ------------------- */
4608  strat->enterS = enterSBba; /* remains as is, we change enterT! */
4609 
4610  strat->red = redFirstShift; /* no redHomog ! */
4611 
4612  if (currRing->pLexOrder && strat->honey)
4613  strat->initEcart = initEcartNormal;
4614  else
4615  strat->initEcart = initEcartBBA;
4616  if (strat->honey)
4618  else
4620 // if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
4621 // {
4622 // //interred machen Aenderung
4623 // pFDegOld=currRing->pFDeg;
4624 // pLDegOld=pLDeg;
4625 // //h=ggetid("ecart");
4626 // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
4627 // //{
4628 // // ecartWeights=iv2array(IDINTVEC(h));
4629 // //}
4630 // //else
4631 // {
4632 // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
4633 // /*uses automatic computation of the ecartWeights to set them*/
4634 // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights,currRing);
4635 // }
4636 // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
4637 // if (TEST_OPT_PROT)
4638 // {
4639 // for(int i=1; i<=rVar(currRing); i++)
4640 // Print(" %d",ecartWeights[i]);
4641 // PrintLn();
4642 // mflush();
4643 // }
4644 // }
4645 }
int redFirstShift(LObject *h, kStrategy strat)
Definition: kstd2.cc:4485

◆ initBuchMora()

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

Definition at line 10208 of file kutil.cc.

10209 {
10210  strat->interpt = BTEST1(OPT_INTERRUPT);
10211  strat->kHEdge=NULL;
10213  /*- creating temp data structures------------------- -*/
10214  strat->cp = 0;
10215  strat->c3 = 0;
10216 #ifdef HAVE_SHIFTBBA
10217  strat->cv = 0;
10218 #endif
10219  strat->tail = pInit();
10220  /*- set s -*/
10221  strat->sl = -1;
10222  /*- set L -*/
10223  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10224  strat->Ll = -1;
10225  strat->L = initL(strat->Lmax);
10226  /*- set B -*/
10227  strat->Bmax = setmaxL;
10228  strat->Bl = -1;
10229  strat->B = initL();
10230  /*- set T -*/
10231  strat->tl = -1;
10232  strat->tmax = setmaxT;
10233  strat->T = initT();
10234  strat->R = initR();
10235  strat->sevT = initsevT();
10236  /*- init local data struct.---------------------------------------- -*/
10237  strat->P.ecart=0;
10238  strat->P.length=0;
10239  strat->P.pLength=0;
10241  {
10242  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10243  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10244  }
10246  {
10247  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10248  }
10249  else
10250  {
10251  if(TEST_OPT_SB_1)
10252  {
10253  int i;
10254  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10255  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10256  {
10257  P->m[i-strat->newIdeal] = F->m[i];
10258  F->m[i] = NULL;
10259  }
10260  initSSpecial(F,Q,P,strat);
10261  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10262  {
10263  F->m[i] = P->m[i-strat->newIdeal];
10264  P->m[i-strat->newIdeal] = NULL;
10265  }
10266  idDelete(&P);
10267  }
10268  else
10269  {
10270  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10271  // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
10272  }
10273  }
10274  strat->fromT = FALSE;
10276  if ((!TEST_OPT_SB_1)
10277  || (rField_is_Ring(currRing))
10278  )
10279  {
10280  updateS(TRUE,strat);
10281  }
10282 #ifdef HAVE_SHIFTBBA
10283  if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
10284 #endif
10285  {
10286  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10287  strat->fromQ=NULL;
10288  }
10289  assume(kTest_TS(strat));
10290 }
poly kNoether
Definition: kutil.h:326
poly kHEdge
Definition: kutil.h:325
int newIdeal
Definition: kutil.h:355
#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:8573
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:9036
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8171
#define setmaxL
Definition: kutil.h:30
static LSet initL(int nr=setmaxL)
Definition: kutil.h:420
#define setmaxT
Definition: kutil.h:33
#define OPT_INTERRUPT
Definition: options.h:77
#define BTEST1(a)
Definition: options.h:33
#define pSetComp(p, v)
Definition: polys.h:38

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9884 of file kutil.cc.

9885 {
9887  strat->chainCrit=chainCritNormal;
9888  if (TEST_OPT_SB_1)
9889  strat->chainCrit=chainCritOpt_1;
9890 #ifdef HAVE_RINGS
9891  if (rField_is_Ring(currRing))
9892  {
9894  strat->chainCrit=chainCritRing;
9895  }
9896 #endif
9897 #ifdef HAVE_RATGRING
9898  if (rIsRatGRing(currRing))
9899  {
9900  strat->chainCrit=chainCritPart;
9901  /* enterOnePairNormal get rational part in it */
9902  }
9903 #endif
9904  if (TEST_OPT_IDLIFT /* i.e. also strat->syzComp==1 */
9905  && (!rIsPluralRing(currRing)))
9907 
9908  strat->sugarCrit = TEST_OPT_SUGARCRIT;
9909  strat->Gebauer = strat->homog || strat->sugarCrit;
9910  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9911  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9912  strat->pairtest = NULL;
9913  /* alway use tailreduction, except:
9914  * - in local rings, - in lex order case, -in ring over extensions */
9916  //if(rHasMixedOrdering(currRing)==2)
9917  //{
9918  // strat->noTailReduction =TRUE;
9919  //}
9920 
9921 #ifdef HAVE_PLURAL
9922  // and r is plural_ring
9923  // hence this holds for r a rational_plural_ring
9924  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9925  { //or it has non-quasi-comm type... later
9926  strat->sugarCrit = FALSE;
9927  strat->Gebauer = FALSE;
9928  strat->honey = FALSE;
9929  }
9930 #endif
9931 
9932  // Coefficient ring?
9933  if (rField_is_Ring(currRing))
9934  {
9935  strat->sugarCrit = FALSE;
9936  strat->Gebauer = FALSE ;
9937  strat->honey = FALSE;
9938  }
9939  #ifdef KDEBUG
9940  if (TEST_OPT_DEBUG)
9941  {
9942  if (strat->homog) PrintS("ideal/module is homogeneous\n");
9943  else PrintS("ideal/module is not homogeneous\n");
9944  }
9945  #endif
9946 }
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:287
char z2homog
Definition: kutil.h:373
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.h:286
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:1929
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3405
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1326
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2210
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3480
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3192
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:3956
static bool rIsSCA(const ring r)
Definition: nc.h:190
#define TEST_OPT_WEIGHTM
Definition: options.h:118
#define TEST_OPT_SUGARCRIT
Definition: options.h:105
#define TEST_OPT_NOT_SUGAR
Definition: options.h:104

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 10035 of file kutil.cc.

10036 {
10038  {
10039  if (strat->honey)
10040  {
10041  strat->posInL = posInL15;
10042  // ok -- here is the deal: from my experiments for Singular-2-0
10043  // I conclude that that posInT_EcartpLength is the best of
10044  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10045  // see the table at the end of this file
10046  if (TEST_OPT_OLDSTD)
10047  strat->posInT = posInT15;
10048  else
10049  strat->posInT = posInT_EcartpLength;
10050  }
10051  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10052  {
10053  strat->posInL = posInL11;
10054  strat->posInT = posInT11;
10055  }
10056  else if (TEST_OPT_INTSTRATEGY)
10057  {
10058  strat->posInL = posInL11;
10059  strat->posInT = posInT11;
10060  }
10061  else
10062  {
10063  strat->posInL = posInL0;
10064  strat->posInT = posInT0;
10065  }
10066  //if (strat->minim>0) strat->posInL =posInLSpecial;
10067  if (strat->homog)
10068  {
10069  strat->posInL = posInL110;
10070  strat->posInT = posInT110;
10071  }
10072  }
10073  else
10074  {
10075  if (strat->homog)
10076  {
10077  strat->posInL = posInL11;
10078  strat->posInT = posInT11;
10079  }
10080  else
10081  {
10082  if ((currRing->order[0]==ringorder_c)
10083  ||(currRing->order[0]==ringorder_C))
10084  {
10085  strat->posInL = posInL17_c;
10086  strat->posInT = posInT17_c;
10087  }
10088  else
10089  {
10090  strat->posInL = posInL17;
10091  strat->posInT = posInT17;
10092  }
10093  }
10094  }
10095  if (strat->minim>0) strat->posInL =posInLSpecial;
10096  // for further tests only
10097  if ((BTEST1(11)) || (BTEST1(12)))
10098  strat->posInL = posInL11;
10099  else if ((BTEST1(13)) || (BTEST1(14)))
10100  strat->posInL = posInL13;
10101  else if ((BTEST1(15)) || (BTEST1(16)))
10102  strat->posInL = posInL15;
10103  else if ((BTEST1(17)) || (BTEST1(18)))
10104  strat->posInL = posInL17;
10105  if (BTEST1(11))
10106  strat->posInT = posInT11;
10107  else if (BTEST1(13))
10108  strat->posInT = posInT13;
10109  else if (BTEST1(15))
10110  strat->posInT = posInT15;
10111  else if ((BTEST1(17)))
10112  strat->posInT = posInT17;
10113  else if ((BTEST1(19)))
10114  strat->posInT = posInT19;
10115  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10116  strat->posInT = posInT1;
10118 }
char posInLDependsOnLength
Definition: kutil.h:388
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6621
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5731
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5326
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5268
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5597
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:5257
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6709
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:10019
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5568
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6065
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6744
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5838
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5636
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6022
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6820
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5479
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5965
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6914
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6323
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 10121 of file kutil.cc.

10122 {
10124  {
10125  if (strat->honey)
10126  {
10127  strat->posInL = posInL15Ring;
10128  // ok -- here is the deal: from my experiments for Singular-2-0
10129  // I conclude that that posInT_EcartpLength is the best of
10130  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10131  // see the table at the end of this file
10132  if (TEST_OPT_OLDSTD)
10133  strat->posInT = posInT15Ring;
10134  else
10135  strat->posInT = posInT_EcartpLength;
10136  }
10137  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10138  {
10139  strat->posInL = posInL11Ring;
10140  strat->posInT = posInT11;
10141  }
10142  else if (TEST_OPT_INTSTRATEGY)
10143  {
10144  strat->posInL = posInL11Ring;
10145  strat->posInT = posInT11;
10146  }
10147  else
10148  {
10149  strat->posInL = posInL0Ring;
10150  strat->posInT = posInT0;
10151  }
10152  //if (strat->minim>0) strat->posInL =posInLSpecial;
10153  if (strat->homog)
10154  {
10155  strat->posInL = posInL110Ring;
10156  strat->posInT = posInT110Ring;
10157  }
10158  }
10159  else
10160  {
10161  if (strat->homog)
10162  {
10163  //printf("\nHere 3\n");
10164  strat->posInL = posInL11Ring;
10165  strat->posInT = posInT11Ring;
10166  }
10167  else
10168  {
10169  if ((currRing->order[0]==ringorder_c)
10170  ||(currRing->order[0]==ringorder_C))
10171  {
10172  strat->posInL = posInL17_cRing;
10173  strat->posInT = posInT17_cRing;
10174  }
10175  else
10176  {
10177  strat->posInL = posInL11Ringls;
10178  strat->posInT = posInT17Ring;
10179  }
10180  }
10181  }
10182  if (strat->minim>0) strat->posInL =posInLSpecial;
10183  // for further tests only
10184  if ((BTEST1(11)) || (BTEST1(12)))
10185  strat->posInL = posInL11Ring;
10186  else if ((BTEST1(13)) || (BTEST1(14)))
10187  strat->posInL = posInL13;
10188  else if ((BTEST1(15)) || (BTEST1(16)))
10189  strat->posInL = posInL15Ring;
10190  else if ((BTEST1(17)) || (BTEST1(18)))
10191  strat->posInL = posInL17Ring;
10192  if (BTEST1(11))
10193  strat->posInT = posInT11Ring;
10194  else if (BTEST1(13))
10195  strat->posInT = posInT13;
10196  else if (BTEST1(15))
10197  strat->posInT = posInT15Ring;
10198  else if ((BTEST1(17)))
10199  strat->posInT = posInT17Ring;
10200  else if ((BTEST1(19)))
10201  strat->posInT = posInT19;
10202  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10203  strat->posInT = posInT1;
10205 }
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6864
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6978
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6365
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5521
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6662
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6091
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5362
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6435
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6779
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5690
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5792
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5899

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1292 of file kutil.cc.

1293 {
1294  h->FDeg = h->pFDeg();
1295  (*h).ecart = 0;
1296  h->length=h->pLength=pLength(h->p);
1297 }

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1284 of file kutil.cc.

1285 {
1286  h->FDeg = h->pFDeg();
1287  h->ecart = h->pLDeg() - h->FDeg;
1288  // h->length is set by h->pLDeg
1289  h->length=h->pLength=pLength(h->p);
1290 }

◆ initEcartPairBba()

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

Definition at line 1299 of file kutil.cc.

1300 {
1301  Lp->FDeg = Lp->pFDeg();
1302  (*Lp).ecart = 0;
1303  (*Lp).length = 0;
1304 }

◆ initEcartPairMora()

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

Definition at line 1306 of file kutil.cc.

1307 {
1308  Lp->FDeg = Lp->pFDeg();
1309  (*Lp).ecart = si_max(ecartF,ecartG);
1310  (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1311  (*Lp).length = 0;
1312 }
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:379

◆ initHilbCrit()

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

Definition at line 9866 of file kutil.cc.

9867 {
9868 
9869  //if the ordering is local, then hilb criterion
9870  //can be used also if the ideal is not homogenous
9872  {
9874  *hilb=NULL;
9875  else
9876  return;
9877  }
9878  if (strat->homog!=isHomog)
9879  {
9880  *hilb=NULL;
9881  }
9882 }
@ isHomog
Definition: structs.h:42

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 420 of file kutil.h.

421 { return (LSet)omAlloc(nr*sizeof(LObject)); }
LObject * LSet
Definition: kutil.h: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 8077 of file kutil.cc.

8078 {
8079  int i,pos;
8080 
8081  if (Q!=NULL) i=((IDELEMS(F)+IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8082  else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8083  strat->ecartS=initec(i);
8084  strat->sevS=initsevS(i);
8085  strat->S_2_R=initS_2_R(i);
8086  strat->fromQ=NULL;
8087  strat->Shdl=idInit(i,F->rank);
8088  strat->S=strat->Shdl->m;
8089  /*- put polys into S -*/
8090  if (Q!=NULL)
8091  {
8092  strat->fromQ=initec(i);
8093  memset(strat->fromQ,0,i*sizeof(int));
8094  for (i=0; i<IDELEMS(Q); i++)
8095  {
8096  if (Q->m[i]!=NULL)
8097  {
8098  LObject h;
8099  h.p = pCopy(Q->m[i]);
8101  {
8102  h.pCleardenom(); // also does remove Content
8103  }
8104  else
8105  {
8106  h.pNorm();
8107  }
8109  {
8110  deleteHC(&h, strat);
8111  }
8112  if (h.p!=NULL)
8113  {
8114  strat->initEcart(&h);
8115  if (strat->sl==-1)
8116  pos =0;
8117  else
8118  {
8119  pos = posInS(strat,strat->sl,h.p,h.ecart);
8120  }
8121  h.sev = pGetShortExpVector(h.p);
8122  strat->enterS(h,pos,strat,-1);
8123  strat->fromQ[pos]=1;
8124  }
8125  }
8126  }
8127  }
8128  for (i=0; i<IDELEMS(F); i++)
8129  {
8130  if (F->m[i]!=NULL)
8131  {
8132  LObject h;
8133  h.p = pCopy(F->m[i]);
8135  {
8136  cancelunit(&h); /*- tries to cancel a unit -*/
8137  deleteHC(&h, strat);
8138  }
8139  if (h.p!=NULL)
8140  // do not rely on the input being a SB!
8141  {
8143  {
8144  h.pCleardenom(); // also does remove Content
8145  }
8146  else
8147  {
8148  h.pNorm();
8149  }
8150  strat->initEcart(&h);
8151  if (strat->sl==-1)
8152  pos =0;
8153  else
8154  pos = posInS(strat,strat->sl,h.p,h.ecart);
8155  h.sev = pGetShortExpVector(h.p);
8156  strat->enterS(h,pos,strat,-1);
8157  }
8158  }
8159  }
8160  /*- test, if a unit is in F -*/
8161  if ((strat->sl>=0)
8162 #ifdef HAVE_RINGS
8163  && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
8164 #endif
8165  && pIsConstant(strat->S[0]))
8166  {
8167  while (strat->sl>0) deleteInS(strat->sl,strat);
8168  }
8169 }
static intset initec(const int maxnr)
Definition: kutil.cc:503
static unsigned long * initsevS(const int maxnr)
Definition: kutil.cc:508
static int * initS_2_R(const int maxnr)
Definition: kutil.cc:512
#define pIsConstant(p)
like above, except that Comp must be 0
Definition: polys.h:234

◆ initSba()

void initSba ( ideal  F,
kStrategy  strat 
)

Definition at line 1390 of file kstd1.cc.

1391 {
1392  int i;
1393  //idhdl h;
1394  /* setting global variables ------------------- */
1395  strat->enterS = enterSSba;
1396  strat->red2 = redHoney;
1397  if (strat->honey)
1398  strat->red2 = redHoney;
1399  else if (currRing->pLexOrder && !strat->homog)
1400  strat->red2 = redLazy;
1401  else
1402  {
1403  strat->LazyPass *=4;
1404  strat->red2 = redHomog;
1405  }
1406  if (rField_is_Ring(currRing))
1407  {
1409  {strat->red2 = redRiloc;}
1410  else
1411  {strat->red2 = redRing;}
1412  }
1413  if (currRing->pLexOrder && strat->honey)
1414  strat->initEcart = initEcartNormal;
1415  else
1416  strat->initEcart = initEcartBBA;
1417  if (strat->honey)
1419  else
1421  //strat->kIdeal = NULL;
1422  //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1423  //else strat->kIdeal->rtyp=MODUL_CMD;
1424  //strat->kIdeal->data=(void *)strat->Shdl;
1425  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1426  {
1427  //interred machen Aenderung
1428  strat->pOrigFDeg = currRing->pFDeg;
1429  strat->pOrigLDeg = currRing->pLDeg;
1430  //h=ggetid("ecart");
1431  //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1432  //{
1433  // ecartWeights=iv2array(IDINTVEC(h));
1434  //}
1435  //else
1436  {
1437  ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1438  /*uses automatic computation of the ecartWeights to set them*/
1440  }
1442  if (TEST_OPT_PROT)
1443  {
1444  for(i=1; i<=(currRing->N); i++)
1445  Print(" %d",ecartWeights[i]);
1446  PrintLn();
1447  mflush();
1448  }
1449  }
1450  // for sig-safe reductions in signature-based
1451  // standard basis computations
1453  strat->red = redSigRing;
1454  else
1455  strat->red = redSig;
1456  //strat->sbaOrder = 1;
1457  strat->currIdx = 1;
1458 }
pFDegProc pOrigFDeg
Definition: kutil.h:292
pLDegProc pOrigLDeg
Definition: kutil.h:293
int redRiloc(LObject *h, kStrategy strat)
Definition: kstd1.cc:342
int redSigRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:1149
int redSig(LObject *h, kStrategy strat)
Definition: kstd2.cc:982
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9390
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3609
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 10420 of file kutil.cc.

10421 {
10422  strat->interpt = BTEST1(OPT_INTERRUPT);
10423  strat->kHEdge=NULL;
10425  /*- creating temp data structures------------------- -*/
10426  strat->cp = 0;
10427  strat->c3 = 0;
10428  strat->tail = pInit();
10429  /*- set s -*/
10430  strat->sl = -1;
10431  /*- set ps -*/
10432  strat->syzl = -1;
10433  /*- set L -*/
10434  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10435  strat->Ll = -1;
10436  strat->L = initL(strat->Lmax);
10437  /*- set B -*/
10438  strat->Bmax = setmaxL;
10439  strat->Bl = -1;
10440  strat->B = initL();
10441  /*- set T -*/
10442  strat->tl = -1;
10443  strat->tmax = setmaxT;
10444  strat->T = initT();
10445  strat->R = initR();
10446  strat->sevT = initsevT();
10447  /*- init local data struct.---------------------------------------- -*/
10448  strat->P.ecart=0;
10449  strat->P.length=0;
10451  {
10452  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10453  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10454  }
10456  {
10457  /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10458  }
10459  else
10460  {
10461  if(TEST_OPT_SB_1)
10462  {
10463  int i;
10464  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10465  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10466  {
10467  P->m[i-strat->newIdeal] = F->m[i];
10468  F->m[i] = NULL;
10469  }
10470  initSSpecialSba(F,Q,P,strat);
10471  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10472  {
10473  F->m[i] = P->m[i-strat->newIdeal];
10474  P->m[i-strat->newIdeal] = NULL;
10475  }
10476  idDelete(&P);
10477  }
10478  else
10479  {
10480  initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10481  }
10482  }
10483  strat->fromT = FALSE;
10484  if (!TEST_OPT_SB_1)
10485  {
10486  if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10487  }
10488  //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10489  //strat->fromQ=NULL;
10490  assume(kTest_TS(strat));
10491 }
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8268
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8717

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9948 of file kutil.cc.

9949 {
9950  //strat->enterOnePair=enterOnePairNormal;
9952  //strat->chainCrit=chainCritNormal;
9953  strat->chainCrit = chainCritSig;
9954  /******************************************
9955  * rewCrit1 and rewCrit2 are already set in
9956  * kSba() in kstd1.cc
9957  *****************************************/
9958  //strat->rewCrit1 = faugereRewCriterion;
9959  if (strat->sbaOrder == 1)
9960  {
9961  strat->syzCrit = syzCriterionInc;
9962  }
9963  else
9964  {
9965  strat->syzCrit = syzCriterion;
9966  }
9967 #ifdef HAVE_RINGS
9968  if (rField_is_Ring(currRing))
9969  {
9971  strat->chainCrit=chainCritRing;
9972  }
9973 #endif
9974 #ifdef HAVE_RATGRING
9975  if (rIsRatGRing(currRing))
9976  {
9977  strat->chainCrit=chainCritPart;
9978  /* enterOnePairNormal get rational part in it */
9979  }
9980 #endif
9981 
9982  strat->sugarCrit = TEST_OPT_SUGARCRIT;
9983  strat->Gebauer = strat->homog || strat->sugarCrit;
9984  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9985  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9986  strat->pairtest = NULL;
9987  /* alway use tailreduction, except:
9988  * - in local rings, - in lex order case, -in ring over extensions */
9991 
9992 #ifdef HAVE_PLURAL
9993  // and r is plural_ring
9994  // hence this holds for r a rational_plural_ring
9995  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9996  { //or it has non-quasi-comm type... later
9997  strat->sugarCrit = FALSE;
9998  strat->Gebauer = FALSE;
9999  strat->honey = FALSE;
10000  }
10001 #endif
10002 
10003  // Coefficient ring?
10004  if (rField_is_Ring(currRing))
10005  {
10006  strat->sugarCrit = FALSE;
10007  strat->Gebauer = FALSE ;
10008  strat->honey = FALSE;
10009  }
10010  #ifdef KDEBUG
10011  if (TEST_OPT_DEBUG)
10012  {
10013  if (strat->homog) PrintS("ideal/module is homogeneous\n");
10014  else PrintS("ideal/module is not homogeneous\n");
10015  }
10016  #endif
10017 }
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.h:288
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:7080
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3421
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:7045

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 10318 of file kutil.cc.

10319 {
10321  {
10322  if (strat->honey)
10323  {
10324  strat->posInL = posInL15;
10325  // ok -- here is the deal: from my experiments for Singular-2-0
10326  // I conclude that that posInT_EcartpLength is the best of
10327  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10328  // see the table at the end of this file
10329  if (TEST_OPT_OLDSTD)
10330  strat->posInT = posInT15;
10331  else
10332  strat->posInT = posInT_EcartpLength;
10333  }
10334  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10335  {
10336  strat->posInL = posInL11;
10337  strat->posInT = posInT11;
10338  }
10339  else if (TEST_OPT_INTSTRATEGY)
10340  {
10341  strat->posInL = posInL11;
10342  strat->posInT = posInT11;
10343  }
10344  else
10345  {
10346  strat->posInL = posInL0;
10347  strat->posInT = posInT0;
10348  }
10349  //if (strat->minim>0) strat->posInL =posInLSpecial;
10350  if (strat->homog)
10351  {
10352  strat->posInL = posInL110;
10353  strat->posInT = posInT110;
10354  }
10355  }
10356  else
10357  {
10358  if (strat->homog)
10359  {
10360  strat->posInL = posInL11;
10361  strat->posInT = posInT11;
10362  }
10363  else
10364  {
10365  if ((currRing->order[0]==ringorder_c)
10366  ||(currRing->order[0]==ringorder_C))
10367  {
10368  strat->posInL = posInL17_c;
10369  strat->posInT = posInT17_c;
10370  }
10371  else
10372  {
10373  strat->posInL = posInL17;
10374  strat->posInT = posInT17;
10375  }
10376  }
10377  }
10378  if (strat->minim>0) strat->posInL =posInLSpecial;
10379  // for further tests only
10380  if ((BTEST1(11)) || (BTEST1(12)))
10381  strat->posInL = posInL11;
10382  else if ((BTEST1(13)) || (BTEST1(14)))
10383  strat->posInL = posInL13;
10384  else if ((BTEST1(15)) || (BTEST1(16)))
10385  strat->posInL = posInL15;
10386  else if ((BTEST1(17)) || (BTEST1(18)))
10387  strat->posInL = posInL17;
10388  if (BTEST1(11))
10389  strat->posInT = posInT11;
10390  else if (BTEST1(13))
10391  strat->posInT = posInT13;
10392  else if (BTEST1(15))
10393  strat->posInT = posInT15;
10394  else if ((BTEST1(17)))
10395  strat->posInT = posInT17;
10396  else if ((BTEST1(19)))
10397  strat->posInT = posInT19;
10398  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10399  strat->posInT = posInT1;
10400  if (rField_is_Ring(currRing))
10401  {
10402  strat->posInL = posInL11Ring;
10403  if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
10404  strat->posInL = posInL11Ringls;
10405  strat->posInT = posInT11;
10406  }
10407  strat->posInLDependsOnLength = FALSE;
10408  strat->posInLSba = posInLSig;
10409  //strat->posInL = posInLSig;
10410  strat->posInL = posInLF5C;
10411  /*
10412  if (rField_is_Ring(currRing))
10413  {
10414  strat->posInLSba = posInLSigRing;
10415  strat->posInL = posInL11Ring;
10416  }*/
10417  //strat->posInT = posInTSig;
10418 }
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6123
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:6311

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

8172 {
8173  int i,pos;
8174 
8175  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8176  else i=setmaxT;
8177  strat->ecartS=initec(i);
8178  strat->sevS=initsevS(i);
8179  strat->S_2_R=initS_2_R(i);
8180  strat->fromQ=NULL;
8181  strat->Shdl=idInit(i,F->rank);
8182  strat->S=strat->Shdl->m;
8183  /*- put polys into S -*/
8184  if (Q!=NULL)
8185  {
8186  strat->fromQ=initec(i);
8187  memset(strat->fromQ,0,i*sizeof(int));
8188  for (i=0; i<IDELEMS(Q); i++)
8189  {
8190  if (Q->m[i]!=NULL)
8191  {
8192  LObject h;
8193  h.p = pCopy(Q->m[i]);
8195  {
8196  deleteHC(&h,strat);
8197  }
8199  {
8200  h.pCleardenom(); // also does remove Content
8201  }
8202  else
8203  {
8204  h.pNorm();
8205  }
8206  if (h.p!=NULL)
8207  {
8208  strat->initEcart(&h);
8209  if (strat->sl==-1)
8210  pos =0;
8211  else
8212  {
8213  pos = posInS(strat,strat->sl,h.p,h.ecart);
8214  }
8215  h.sev = pGetShortExpVector(h.p);
8216  strat->enterS(h,pos,strat,-1);
8217  strat->fromQ[pos]=1;
8218  }
8219  }
8220  }
8221  }
8222  for (i=0; i<IDELEMS(F); i++)
8223  {
8224  if (F->m[i]!=NULL)
8225  {
8226  LObject h;
8227  h.p = pCopy(F->m[i]);
8228  if (h.p!=NULL)
8229  {
8231  {
8232  cancelunit(&h); /*- tries to cancel a unit -*/
8233  deleteHC(&h, strat);
8234  }
8235  if (h.p!=NULL)
8236  {
8238  {
8239  h.pCleardenom(); // also does remove Content
8240  }
8241  else
8242  {
8243  h.pNorm();
8244  }
8245  strat->initEcart(&h);
8246  if (strat->Ll==-1)
8247  pos =0;
8248  else
8249  pos = strat->posInL(strat->L,strat->Ll,&h,strat);
8250  h.sev = pGetShortExpVector(h.p);
8251  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8252  }
8253  }
8254  }
8255  }
8256  /*- test, if a unit is in F -*/
8257 
8258  if ((strat->Ll>=0)
8259 #ifdef HAVE_RINGS
8260  && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8261 #endif
8262  && pIsConstant(strat->L[strat->Ll].p))
8263  {
8264  while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8265  }
8266 }

◆ initSLSba()

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

Definition at line 8268 of file kutil.cc.

8269 {
8270  int i,pos;
8271  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8272  else i=setmaxT;
8273  strat->ecartS = initec(i);
8274  strat->sevS = initsevS(i);
8275  strat->sevSig = initsevS(i);
8276  strat->S_2_R = initS_2_R(i);
8277  strat->fromQ = NULL;
8278  strat->Shdl = idInit(i,F->rank);
8279  strat->S = strat->Shdl->m;
8280  strat->sig = (poly *)omAlloc0(i*sizeof(poly));
8281  if (strat->sbaOrder != 1)
8282  {
8283  strat->syz = (poly *)omAlloc0(i*sizeof(poly));
8284  strat->sevSyz = initsevS(i);
8285  strat->syzmax = i;
8286  strat->syzl = 0;
8287  }
8288  /*- put polys into S -*/
8289  if (Q!=NULL)
8290  {
8291  strat->fromQ=initec(i);
8292  memset(strat->fromQ,0,i*sizeof(int));
8293  for (i=0; i<IDELEMS(Q); i++)
8294  {
8295  if (Q->m[i]!=NULL)
8296  {
8297  LObject h;
8298  h.p = pCopy(Q->m[i]);
8300  {
8301  deleteHC(&h,strat);
8302  }
8304  {
8305  h.pCleardenom(); // also does remove Content
8306  }
8307  else
8308  {
8309  h.pNorm();
8310  }
8311  if (h.p!=NULL)
8312  {
8313  strat->initEcart(&h);
8314  if (strat->sl==-1)
8315  pos =0;
8316  else
8317  {
8318  pos = posInS(strat,strat->sl,h.p,h.ecart);
8319  }
8320  h.sev = pGetShortExpVector(h.p);
8321  strat->enterS(h,pos,strat,-1);
8322  strat->fromQ[pos]=1;
8323  }
8324  }
8325  }
8326  }
8327  for (i=0; i<IDELEMS(F); i++)
8328  {
8329  if (F->m[i]!=NULL)
8330  {
8331  LObject h;
8332  h.p = pCopy(F->m[i]);
8333  h.sig = pOne();
8334  //h.sig = pInit();
8335  //p_SetCoeff(h.sig,nInit(1),currRing);
8336  p_SetComp(h.sig,i+1,currRing);
8337  // if we are working with the Schreyer order we generate it
8338  // by multiplying the initial signatures with the leading monomial
8339  // of the corresponding initial polynomials generating the ideal
8340  // => we can keep the underlying monomial order and get a Schreyer
8341  // order without any bigger overhead
8342  if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
8343  {
8344  p_ExpVectorAdd (h.sig,F->m[i],currRing);
8345  }
8346  h.sevSig = pGetShortExpVector(h.sig);
8347 #ifdef DEBUGF5
8348  pWrite(h.p);
8349  pWrite(h.sig);
8350 #endif
8351  if (h.p!=NULL)
8352  {
8354  {
8355  cancelunit(&h); /*- tries to cancel a unit -*/
8356  deleteHC(&h, strat);
8357  }
8358  if (h.p!=NULL)
8359  {
8361  {
8362  h.pCleardenom(); // also does remove Content
8363  }
8364  else
8365  {
8366  h.pNorm();
8367  }
8368  strat->initEcart(&h);
8369  if (strat->Ll==-1)
8370  pos =0;
8371  else
8372  pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
8373  h.sev = pGetShortExpVector(h.p);
8374  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8375  }
8376  }
8377  /*
8378  if (strat->sbaOrder != 1)
8379  {
8380  for(j=0;j<i;j++)
8381  {
8382  strat->syz[ctr] = pCopy(F->m[j]);
8383  p_SetCompP(strat->syz[ctr],i+1,currRing);
8384  // add LM(F->m[i]) to the signature to get a Schreyer order
8385  // without changing the underlying polynomial ring at all
8386  p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
8387  // since p_Add_q() destroys all input
8388  // data we need to recreate help
8389  // each time
8390  poly help = pCopy(F->m[i]);
8391  p_SetCompP(help,j+1,currRing);
8392  pWrite(strat->syz[ctr]);
8393  pWrite(help);
8394  printf("%d\n",pLmCmp(strat->syz[ctr],help));
8395  strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
8396  printf("%d. SYZ ",ctr);
8397  pWrite(strat->syz[ctr]);
8398  strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
8399  ctr++;
8400  }
8401  strat->syzl = ps;
8402  }
8403  */
8404  }
8405  }
8406  /*- test, if a unit is in F -*/
8407 
8408  if ((strat->Ll>=0)
8409 #ifdef HAVE_RINGS
8410  && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8411 #endif
8412  && pIsConstant(strat->L[strat->Ll].p))
8413  {
8414  while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8415  }
8416 }
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1350

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8418 of file kutil.cc.

8419 {
8420  if( strat->S[0] )
8421  {
8422  if( strat->S[1] && !rField_is_Ring(currRing))
8423  {
8424  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
8425  omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
8426  omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
8427  }
8428  int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
8429  /************************************************************
8430  * computing the length of the syzygy array needed
8431  ***********************************************************/
8432  for(i=1; i<=strat->sl; i++)
8433  {
8434  if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8435  {
8436  ps += i;
8437  }
8438  }
8439  ps += strat->sl+1;
8440  //comp = pGetComp (strat->P.sig);
8441  comp = strat->currIdx;
8442  strat->syzIdx = initec(comp);
8443  strat->sevSyz = initsevS(ps);
8444  strat->syz = (poly *)omAlloc(ps*sizeof(poly));
8445  strat->syzmax = ps;
8446  strat->syzl = 0;
8447  strat->syzidxmax = comp;
8448 #if defined(DEBUGF5) || defined(DEBUGF51)
8449  PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
8450 #endif
8451  i = 1;
8452  j = 0;
8453  /************************************************************
8454  * generating the leading terms of the principal syzygies
8455  ***********************************************************/
8456  while (i <= strat->sl)
8457  {
8458  /**********************************************************
8459  * principal syzygies start with component index 2
8460  * the array syzIdx starts with index 0
8461  * => the rules for a signature with component comp start
8462  * at strat->syz[strat->syzIdx[comp-2]] !
8463  *********************************************************/
8464  if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8465  {
8466  comp = pGetComp(strat->sig[i]);
8467  comp_old = pGetComp(strat->sig[i-1]);
8468  diff = comp - comp_old - 1;
8469  // diff should be zero, but sometimes also the initial generating
8470  // elements of the input ideal reduce to zero. then there is an
8471  // index-gap between the signatures. for these inbetween signatures we
8472  // can safely set syzIdx[j] = 0 as no such element will be ever computed
8473  // in the following.
8474  // doing this, we keep the relation "j = comp - 2" alive, which makes
8475  // jumps way easier when checking criteria
8476  while (diff>0)
8477  {
8478  strat->syzIdx[j] = 0;
8479  diff--;
8480  j++;
8481  }
8482  strat->syzIdx[j] = ctr;
8483  j++;
8484  LObject Q;
8485  int pos;
8486  for (k = 0; k<i; k++)
8487  {
8488  Q.sig = pOne();
8490  p_SetCoeff(Q.sig,nCopy(p_GetCoeff(strat->S[k],currRing)),currRing);
8491  p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8492  p_SetCompP (Q.sig, comp, currRing);
8493  poly q = p_One(currRing);
8496  p_ExpVectorCopy(q,strat->S[i],currRing);
8497  q = p_Neg (q, currRing);
8498  p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8499  Q.sig = p_Add_q (Q.sig, q, currRing);
8500  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8501  pos = posInSyz(strat, Q.sig);
8502  enterSyz(Q, strat, pos);
8503  ctr++;
8504  }
8505  }
8506  i++;
8507  }
8508  /**************************************************************
8509  * add syzygies for upcoming first element of new iteration step
8510  **************************************************************/
8511  comp = strat->currIdx;
8512  comp_old = pGetComp(strat->sig[i-1]);
8513  diff = comp - comp_old - 1;
8514  // diff should be zero, but sometimes also the initial generating
8515  // elements of the input ideal reduce to zero. then there is an
8516  // index-gap between the signatures. for these inbetween signatures we
8517  // can safely set syzIdx[j] = 0 as no such element will be ever computed
8518  // in the following.
8519  // doing this, we keep the relation "j = comp - 2" alive, which makes
8520  // jumps way easier when checking criteria
8521  while (diff>0)
8522  {
8523  strat->syzIdx[j] = 0;
8524  diff--;
8525  j++;
8526  }
8527  strat->syzIdx[j] = ctr;
8528  LObject Q;
8529  int pos;
8530  for (k = 0; k<strat->sl+1; k++)
8531  {
8532  Q.sig = pOne();
8534  p_SetCoeff(Q.sig,nCopy(p_GetCoeff(strat->S[k],currRing)),currRing);
8535  p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8536  p_SetCompP (Q.sig, comp, currRing);
8537  poly q = p_One(currRing);
8539  p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8540  p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8541  q = p_Neg (q, currRing);
8542  p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8543  Q.sig = p_Add_q (Q.sig, q, currRing);
8544  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8545  pos = posInSyz(strat, Q.sig);
8546  enterSyz(Q, strat, pos);
8547  ctr++;
8548  }
8549 //#if 1
8550 #ifdef DEBUGF5
8551  PrintS("Principal syzygies:\n");
8552  Print("syzl %d\n",strat->syzl);
8553  Print("syzmax %d\n",strat->syzmax);
8554  Print("ps %d\n",ps);
8555  PrintS("--------------------------------\n");
8556  for(i=0;i<=strat->syzl-1;i++)
8557  {
8558  Print("%d - ",i);
8559  pWrite(strat->syz[i]);
8560  }
8561  for(i=0;i<strat->currIdx;i++)
8562  {
8563  Print("%d - %d\n",i,strat->syzIdx[i]);
8564  }
8565  PrintS("--------------------------------\n");
8566 #endif
8567  }
8568 }
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9788
int posInSyz(const kStrategy strat, poly sig)
Definition: kutil.cc:6283
#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:4687
poly p_One(const ring r)
Definition: p_polys.cc:1303
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:895
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition: p_polys.h:1252
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:253

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

966 {
967  p_LmCheckPolyRing(p1, p_r);
968  p_LmCheckPolyRing(p2, p_r);
969 
970  int i;
971  long x;
972  m1 = p_Init(m_r,m_r->PolyBin);
973  m2 = p_Init(m_r,m_r->PolyBin);
974 
975  for (i = p_r->N; i; i--)
976  {
977  x = p_GetExpDiff(p1, p2, i, p_r);
978  if (x > 0)
979  {
980  if (x > (long) m_r->bitmask) goto false_return;
981  p_SetExp(m2,i,x, m_r);
982  p_SetExp(m1,i,0, m_r);
983  }
984  else
985  {
986  if (-x > (long) m_r->bitmask) goto false_return;
987  p_SetExp(m1,i,-x, m_r);
988  p_SetExp(m2,i,0, m_r);
989  }
990  }
991 
992  p_Setm(m1, m_r);
993  p_Setm(m2, m_r);
994  return TRUE;
995 
996  false_return:
997  p_LmFree(m1, m_r);
998  p_LmFree(m2, m_r);
999  m1 = m2 = NULL;
1000  return FALSE;
1001 }
Variable x
Definition: cfModGcd.cc:4023
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:634
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:487
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1259

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

1009 {
1010  p_LmCheckPolyRing(p1, leadRing);
1011  p_LmCheckPolyRing(p2, leadRing);
1012 
1013  int i;
1014  int x;
1015  int e1;
1016  int e2;
1017  int s;
1018  m1 = p_Init(tailRing,tailRing->PolyBin);
1019  m2 = p_Init(tailRing,tailRing->PolyBin);
1020  lcm = p_Init(leadRing,leadRing->PolyBin);
1021 
1022  for (i = leadRing->N; i>=0; i--)
1023  {
1024  e1 = p_GetExp(p1,i,leadRing);
1025  e2 = p_GetExp(p2,i,leadRing);
1026  x = e1 - e2;
1027  if (x > 0)
1028  {
1029  p_SetExp(m2,i,x, tailRing);
1030  //p_SetExp(m1,i,0, tailRing); // done by p_Init
1031  s = e1;
1032  }
1033  else if (x<0)
1034  {
1035  p_SetExp(m1,i,-x, tailRing);
1036  //p_SetExp(m2,i,0, tailRing); // done by p_Init
1037  s = e2;
1038  }
1039  else
1040  s = e1; // e1==e2
1041  p_SetExp(lcm,i,s, leadRing);
1042  }
1043 
1044  p_Setm(m1, tailRing);
1045  p_Setm(m2, tailRing);
1046  p_Setm(lcm, leadRing);
1047 }
const CanonicalForm int s
Definition: facAbsFact.cc:55

◆ k_LmInit_currRing_2_tailRing() [1/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 937 of file kInline.h.

938 {
939  return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
940 }

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 905 of file kInline.h.

906 {
907 
908  poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
909  pNext(t_p) = pNext(p);
910  pSetCoeff0(t_p, pGetCoeff(p));
911  return t_p;
912 }
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1274

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 942 of file kInline.h.

943 {
944  return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
945 }
KINLINE poly k_LmInit_tailRing_2_currRing(poly t_p, ring tailRing, omBin lmBin)
Definition: kInline.h:914

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 914 of file kInline.h.

915 {
916  poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
917  pNext(p) = pNext(t_p);
918  pSetCoeff0(p, pGetCoeff(t_p));
919  return p;
920 }

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 947 of file kInline.h.

948 {
949  return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
950 }
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:923

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 923 of file kInline.h.

924 {
925  poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
926  p_LmFree(p, currRing);
927  return np;
928 }

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 952 of file kInline.h.

953 {
954  return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
955 }
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:930

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 930 of file kInline.h.

931 {
932  poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
933  p_LmFree(p, tailRing);
934  return np;
935 }

◆ kCheckSpolyCreation()

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

Definition at line 10931 of file kutil.cc.

10932 {
10933  if (strat->overflow) return FALSE;
10934  assume(L->p1 != NULL && L->p2 != NULL);
10935  // shift changes: from 0 to -1
10936  assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10937  assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10938  assume(strat->tailRing != currRing);
10939 
10940  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10941  return FALSE;
10942  // shift changes: extra case inserted
10943  if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10944  {
10945  return TRUE;
10946  }
10947  poly p1_max=NULL;
10948  if (L->i_r1>=0) p1_max = (strat->R[L->i_r1])->max_exp;
10949  poly p2_max=NULL;
10950  if (L->i_r2>=0) p2_max = (strat->R[L->i_r2])->max_exp;
10951 
10952  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10953  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10954  {
10955  p_LmFree(m1, strat->tailRing);
10956  p_LmFree(m2, strat->tailRing);
10957  m1 = NULL;
10958  m2 = NULL;
10959  return FALSE;
10960  }
10961  return TRUE;
10962 }
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:964
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:1966

◆ kCheckStrongCreation()

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

Definition at line 10971 of file kutil.cc.

10972 {
10973  assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10974  //assume(strat->tailRing != currRing);
10975 
10976  poly p1_max = (strat->R[atR])->max_exp;
10977  poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10978 
10979  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10980  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10981  {
10982  return FALSE;
10983  }
10984  return TRUE;
10985 }

◆ kCreateZeroPoly()

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

Definition at line 4327 of file kutil.cc.

4328 {
4329 
4330  poly zeroPoly = NULL;
4331 
4332  number tmp1;
4333  poly tmp2, tmp3;
4334 
4335  if (cabsind == -1)
4336  {
4337  cabsind = 0;
4338  for (int i = 1; i <= leadRing->N; i++)
4339  {
4340  cabsind += ind_fact_2(exp[i]);
4341  }
4342 // Print("cabsind: %d\n", cabsind);
4343  }
4344  if (cabsind < leadRing->ch)
4345  {
4346  zeroPoly = p_ISet(twoPow(leadRing->ch - cabsind), tailRing);
4347  }
4348  else
4349  {
4350  zeroPoly = p_ISet(1, tailRing);
4351  }
4352  for (int i = 1; i <= leadRing->N; i++)
4353  {
4354  for (long j = 1; j <= exp[i]; j++)
4355  {
4356  tmp1 = nInit(j);
4357  tmp2 = p_ISet(1, tailRing);
4358  p_SetExp(tmp2, i, 1, tailRing);
4359  p_Setm(tmp2, tailRing);
4360  if (nIsZero(tmp1))
4361  { // should nowbe obsolet, test ! TODO OLIVER
4362  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
4363  }
4364  else
4365  {
4366  tmp3 = p_NSet(nCopy(tmp1), tailRing);
4367  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
4368  }
4369  }
4370  }
4371  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
4372  for (int i = 1; i <= leadRing->N; i++)
4373  {
4374  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
4375  }
4376  p_Setm(tmp2, leadRing);
4377  *t_p = zeroPoly;
4378  zeroPoly = pNext(zeroPoly);
4379  pNext(*t_p) = NULL;
4380  pNext(tmp2) = zeroPoly;
4381  return tmp2;
4382 }
CFList tmp1
Definition: facFqBivar.cc:70
CFList tmp2
Definition: facFqBivar.cc:70
long ind_fact_2(long arg)
Definition: kutil.cc:4123
long twoPow(long arg)
Definition: kutil.cc:4138
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1287
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1455
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1053

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11949 of file kutil.cc.

11950 {
11951  PrintS("red: ");
11952  if (strat->red==redFirst) PrintS("redFirst\n");
11953  else if (strat->red==redHoney) PrintS("redHoney\n");
11954  else if (strat->red==redEcart) PrintS("redEcart\n");
11955  else if (strat->red==redHomog) PrintS("redHomog\n");
11956  else Print("%p\n",(void*)strat->red);
11957  PrintS("posInT: ");
11958  if (strat->posInT==posInT0) PrintS("posInT0\n");
11959  else if (strat->posInT==posInT1) PrintS("posInT1\n");
11960  else if (strat->posInT==posInT11) PrintS("posInT11\n");
11961  else if (strat->posInT==posInT110) PrintS("posInT110\n");
11962  else if (strat->posInT==posInT13) PrintS("posInT13\n");
11963  else if (strat->posInT==posInT15) PrintS("posInT15\n");
11964  else if (strat->posInT==posInT17) PrintS("posInT17\n");
11965  else if (strat->posInT==posInT17_c) PrintS("posInT17_c\n");
11966  else if (strat->posInT==posInT19) PrintS("posInT19\n");
11967  else if (strat->posInT==posInT2) PrintS("posInT2\n");
11968  #ifdef HAVE_RINGS
11969  else if (strat->posInT==posInT11Ring) PrintS("posInT11Ring\n");
11970  else if (strat->posInT==posInT110Ring) PrintS("posInT110Ring\n");
11971  else if (strat->posInT==posInT15Ring) PrintS("posInT15Ring\n");
11972  else if (strat->posInT==posInT17Ring) PrintS("posInT17Ring\n");
11973  else if (strat->posInT==posInT17_cRing) PrintS("posInT17_cRing\n");
11974  #endif
11975 #ifdef HAVE_MORE_POS_IN_T
11976  else if (strat->posInT==posInT_EcartFDegpLength) PrintS("posInT_EcartFDegpLength\n");
11977  else if (strat->posInT==posInT_FDegpLength) PrintS("posInT_FDegpLength\n");
11978  else if (strat->posInT==posInT_pLength) PrintS("posInT_pLength\n");
11979 #endif
11980  else if (strat->posInT==posInT_EcartpLength) PrintS("posInT_EcartpLength\n");
11981  else if (strat->posInT==posInTrg0) PrintS("posInTrg0\n");
11982  else Print("%p\n",(void*)strat->posInT);
11983  PrintS("posInL: ");
11984  if (strat->posInL==posInL0) PrintS("posInL0\n");
11985  else if (strat->posInL==posInL10) PrintS("posInL10\n");
11986  else if (strat->posInL==posInL11) PrintS("posInL11\n");
11987  else if (strat->posInL==posInL110) PrintS("posInL110\n");
11988  else if (strat->posInL==posInL13) PrintS("posInL13\n");
11989  else if (strat->posInL==posInL15) PrintS("posInL15\n");
11990  else if (strat->posInL==posInL17) PrintS("posInL17\n");
11991  else if (strat->posInL==posInL17_c) PrintS("posInL17_c\n");
11992  #ifdef HAVE_RINGS
11993  else if (strat->posInL==posInL0) PrintS("posInL0Ring\n");
11994  else if (strat->posInL==posInL11Ring) PrintS("posInL11Ring\n");
11995  else if (strat->posInL==posInL11Ringls) PrintS("posInL11Ringls\n");
11996  else if (strat->posInL==posInL110Ring) PrintS("posInL110Ring\n");
11997  else if (strat->posInL==posInL15Ring) PrintS("posInL15Ring\n");
11998  else if (strat->posInL==posInL17Ring) PrintS("posInL17Ring\n");
11999  else if (strat->posInL==posInL17_cRing) PrintS("posInL17_cRing\n");
12000  #endif
12001  else if (strat->posInL==posInLSpecial) PrintS("posInLSpecial\n");
12002  else if (strat->posInL==posInLrg0) PrintS("posInLrg0\n");
12003  else Print("%p\n",(void*)strat->posInL);
12004  PrintS("enterS: ");
12005  if (strat->enterS==enterSBba) PrintS("enterSBba\n");
12006  else if (strat->enterS==enterSMora) PrintS("enterSMora\n");
12007  else if (strat->enterS==enterSMoraNF) PrintS("enterSMoraNF\n");
12008  else Print("%p\n",(void*)strat->enterS);
12009  PrintS("initEcart: ");
12010  if (strat->initEcart==initEcartBBA) PrintS("initEcartBBA\n");
12011  else if (strat->initEcart==initEcartNormal) PrintS("initEcartNormal\n");
12012  else Print("%p\n",(void*)strat->initEcart);
12013  PrintS("initEcartPair: ");
12014  if (strat->initEcartPair==initEcartPairBba) PrintS("initEcartPairBba\n");
12015  else if (strat->initEcartPair==initEcartPairMora) PrintS("initEcartPairMora\n");
12016  else Print("%p\n",(void*)strat->initEcartPair);
12017  Print("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
12018  strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
12019  Print("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
12020  strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
12021  PrintS("chainCrit: ");
12022  if (strat->chainCrit==chainCritNormal) PrintS("chainCritNormal\n");
12023  else if (strat->chainCrit==chainCritOpt_1) PrintS("chainCritOpt_1\n");
12024  else Print("%p\n",(void*)strat->chainCrit);
12025  Print("posInLDependsOnLength=%d\n",
12026  strat->posInLDependsOnLength);
12027  PrintS(showOption());PrintLn();
12028  PrintS("LDeg: ");
12029  if (currRing->pLDeg==pLDeg0) PrintS("pLDeg0");
12030  else if (currRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
12031  else if (currRing->pLDeg==pLDegb) PrintS("pLDegb");
12032  else if (currRing->pLDeg==pLDeg1) PrintS("pLDeg1");
12033  else if (currRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
12034  else if (currRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
12035  else if (currRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
12036  else if (currRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
12037  else if (currRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
12038  else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
12039  else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
12040  else if (currRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
12041  else Print("? (%lx)", (long)currRing->pLDeg);
12042  PrintS(" / ");
12043  if (strat->tailRing->pLDeg==pLDeg0) PrintS("pLDeg0");
12044  else if (strat->tailRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
12045  else if (strat->tailRing->pLDeg==pLDegb) PrintS("pLDegb");
12046  else if (strat->tailRing->pLDeg==pLDeg1) PrintS("pLDeg1");
12047  else if (strat->tailRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
12048  else if (strat->tailRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
12049  else if (strat->tailRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
12050  else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
12051  else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
12052  else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
12053  else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
12054  else if (strat->tailRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
12055  else Print("? (%lx)", (long)strat->tailRing->pLDeg);
12056  PrintLn();
12057  PrintS("currRing->pFDeg: ");
12058  if (currRing->pFDeg==p_Totaldegree) PrintS("p_Totaldegree");
12059  else if (currRing->pFDeg==p_WFirstTotalDegree) PrintS("pWFirstTotalDegree");
12060  else if (currRing->pFDeg==p_Deg) PrintS("p_Deg");
12061  else if (currRing->pFDeg==kHomModDeg) PrintS("kHomModDeg");
12062  else if (currRing->pFDeg==totaldegreeWecart) PrintS("totaldegreeWecart");
12063  else if (currRing->pFDeg==p_WTotaldegree) PrintS("p_WTotaldegree");
12064  else Print("? (%lx)", (long)currRing->pFDeg);
12065  PrintLn();
12066  Print(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
12067  if(TEST_OPT_DEGBOUND)
12068  Print(" degBound: %d\n", Kstd1_deg);
12069 
12070  if( ecartWeights != NULL )
12071  {
12072  PrintS("ecartWeights: ");
12073  for (int i = rVar(currRing); i > 0; i--)
12074  Print("%hd ", ecartWeights[i]);
12075  PrintLn();
12077  }
12078 
12079 #ifndef SING_NDEBUG
12081 #endif
12082 }
int LazyDegree
Definition: kutil.h:351
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1006
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2075
int posInTrg0(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5403
int redFirst(LObject *h, kStrategy strat)
Definition: kstd1.cc:528
int redEcart(LObject *h, kStrategy strat)
Definition: kstd1.cc:166
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1324
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5296
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11915
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11824
VAR int Kstd1_deg
Definition: kutil.cc:237
char * showOption()
Definition: misc_ip.cc:723
int posInLrg0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6537
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1270
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11878
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:801
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:965
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:586
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1028
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1058
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:931
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:831
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:900
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:603
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:867
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:995
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:760
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:729
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1446
void rDebugPrint(const ring r)
Definition: ring.cc:4045
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:718

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 869 of file kutil.h.

870 {
871  if (P->lcm!=NULL)
872  {
873  #ifdef HAVE_RINGS
875  pLmDelete(P->lcm);
876  else
877  #endif
878  pLmFree(P->lcm);
879  P->lcm=NULL;
880  }
881 }

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

327 {
328  unsigned long not_sev = ~L->sev;
329  poly p = L->GetLmCurrRing();
330  int j = 0;
331 
332  pAssume(~not_sev == p_GetShortExpVector(p, currRing));
333 
335 #if 1
336  int ende;
337  if (is_Ring
338  || (strat->ak>0)
339  || currRing->pLexOrder)
340  ende=strat->sl;
341  else
342  {
343  ende=posInS(strat,*max_ind,p,0)+1;
344  if (ende>(*max_ind)) ende=(*max_ind);
345  }
346 #else
347  int ende=strat->sl;
348 #endif
349  if(is_Ring)
350  {
351  loop
352  {
353  if (j > ende) return -1;
354 #if defined(PDEBUG) || defined(PDIV_DEBUG)
355  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
356  p, not_sev, currRing))
357  {
358  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
359  return j;
360  }
361 #else
362  if ( !(strat->sevS[j] & not_sev) &&
363  p_LmDivisibleBy(strat->S[j], p, currRing))
364  {
365  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
366  return j;
367  }
368 #endif
369  j++;
370  }
371  }
372  else
373  {
374  loop
375  {
376  if (j > ende) return -1;
377 #if defined(PDEBUG) || defined(PDIV_DEBUG)
378  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
379  p, not_sev, currRing))
380  {
381  return j;
382  }
383 #else
384  if ( !(strat->sevS[j] & not_sev) &&
385  p_LmDivisibleBy(strat->S[j], p, currRing))
386  {
387  return j;
388  }
389 #endif
390  j++;
391  }
392  }
393 }
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1823

◆ kFindDivisibleByInS_T()

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

Definition at line 7263 of file kutil.cc.

7264 {
7265  int j = 0;
7266  const unsigned long not_sev = ~L->sev;
7267  const unsigned long* sev = strat->sevS;
7268  poly p;
7269  ring r;
7270  L->GetLm(p, r);
7271 
7272  assume(~not_sev == p_GetShortExpVector(p, r));
7273 
7274  if (r == currRing)
7275  {
7276  if(!rField_is_Ring(r))
7277  {
7278  loop
7279  {
7280  if (j > end_pos) return NULL;
7281  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7282  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7283  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7284  {
7285  break;
7286  }
7287  #else
7288  if (!(sev[j] & not_sev) &&
7289  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7290  p_LmDivisibleBy(strat->S[j], p, r))
7291  {
7292  break;
7293  }
7294  #endif
7295  j++;
7296  }
7297  }
7298  #ifdef HAVE_RINGS
7299  else
7300  {
7301  loop
7302  {
7303  if (j > end_pos) return NULL;
7304  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7305  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7306  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7307  {
7308  break;
7309  }
7310  #else
7311  if (!(sev[j] & not_sev) &&
7312  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7313  p_LmDivisibleBy(strat->S[j], p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7314  {
7315  break;
7316  }
7317  #endif
7318  j++;
7319  }
7320  }
7321  #endif
7322  // if called from NF, T objects do not exist:
7323  if (strat->tl < 0 || strat->S_2_R[j] == -1)
7324  {
7325  T->Set(strat->S[j], r, strat->tailRing);
7326  assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
7327  return T;
7328  }
7329  else
7330  {
7331 ///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
7332 ///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
7333 // assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
7334  return strat->S_2_T(j);
7335  }
7336  }
7337  else
7338  {
7339  TObject* t;
7340  if(!rField_is_Ring(r))
7341  {
7342  loop
7343  {
7344  if (j > end_pos) return NULL;
7345  assume(strat->S_2_R[j] != -1);
7346  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7347  t = strat->S_2_T(j);
7348  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7349  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7350  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7351  {
7352  t->pLength=pLength(t->t_p);
7353  return t;
7354  }
7355  #else
7356  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7357  {
7358  t = strat->S_2_T(j);
7359  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7360  if (p_LmDivisibleBy(t->t_p, p, r))
7361  {
7362  t->pLength=pLength(t->t_p);
7363  return t;
7364  }
7365  }
7366  #endif
7367  j++;
7368  }
7369  }
7370  #ifdef HAVE_RINGS
7371  else
7372  {
7373  loop
7374  {
7375  if (j > end_pos) return NULL;
7376  assume(strat->S_2_R[j] != -1);
7377  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7378  t = strat->S_2_T(j);
7379  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7380  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7381  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7382  {
7383  t->pLength=pLength(t->t_p);
7384  return t;
7385  }
7386  #else
7387  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7388  {
7389  t = strat->S_2_T(j);
7390  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7391  if (p_LmDivisibleBy(t->t_p, p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7392  {
7393  t->pLength=pLength(t->t_p);
7394  return t;
7395  }
7396  }
7397  #endif
7398  j++;
7399  }
7400  }
7401  #endif
7402  }
7403 }
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 216 of file kstd2.cc.

217 {
218  unsigned long not_sev = ~L->sev;
219  int j = start;
220 
221  const TSet T=strat->T;
222  const unsigned long* sevT=strat->sevT;
223  const ring r=currRing;
224  const BOOLEAN is_Ring=rField_is_Ring(r);
225  if (L->p!=NULL)
226  {
227  const poly p=L->p;
228 
229  pAssume(~not_sev == p_GetShortExpVector(p, r));
230 
231  if(is_Ring)
232  {
233  loop
234  {
235  if (j > strat->tl) return -1;
236 #if defined(PDEBUG) || defined(PDIV_DEBUG)
237  if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
238  {
239  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
240  return j;
241  }
242 #else
243  if (!(sevT[j] & not_sev) &&
244  p_LmDivisibleBy(T[j].p, p, r))
245  {
246  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
247  return j;
248  }
249 #endif
250  j++;
251  }
252  }
253  else
254  {
255  loop
256  {
257  if (j > strat->tl) return -1;
258 #if defined(PDEBUG) || defined(PDIV_DEBUG)
259  if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
260  {
261  return j;
262  }
263 #else
264  if (!(sevT[j] & not_sev) &&
265  p_LmDivisibleBy(T[j].p, p, r))
266  {
267  return j;
268  }
269 #endif
270  j++;
271  }
272  }
273  }
274  else
275  {
276  const poly p=L->t_p;
277  const ring r=strat->tailRing;
278  if(is_Ring)
279  {
280  loop
281  {
282  if (j > strat->tl) return -1;
283 #if defined(PDEBUG) || defined(PDIV_DEBUG)
284  if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
285  p, not_sev, r))
286  {
287  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
288  return j;
289  }
290 #else
291  if (!(sevT[j] & not_sev) &&
292  p_LmDivisibleBy(T[j].t_p, p, r))
293  {
294  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
295  return j;
296  }
297 #endif
298  j++;
299  }
300  }
301  else
302  {
303  loop
304  {
305  if (j > strat->tl) return -1;
306 #if defined(PDEBUG) || defined(PDIV_DEBUG)
307  if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
308  p, not_sev, r))
309  {
310  return j;
311  }
312 #else
313  if (!(sevT[j] & not_sev) &&
314  p_LmDivisibleBy(T[j].t_p, p, r))
315  {
316  return j;
317  }
318 #endif
319  j++;
320  }
321  }
322  }
323 }

◆ kFindDivisibleByInT_Z()

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

Definition at line 139 of file kstd2.cc.

140 {
141  unsigned long not_sev = ~L->sev;
142  int j = start;
143  int o = -1;
144 
145  const TSet T=strat->T;
146  const unsigned long* sevT=strat->sevT;
147  number rest, orest, mult;
148  if (L->p!=NULL)
149  {
150  const ring r=currRing;
151  const poly p=L->p;
152  orest = pGetCoeff(p);
153 
154  pAssume(~not_sev == p_GetShortExpVector(p, r));
155 
156  loop
157  {
158  if (j > strat->tl) return o;
159 #if defined(PDEBUG) || defined(PDIV_DEBUG)
160  if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
161  {
162  mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
163  if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
164  o = j;
165  orest = rest;
166  }
167  }
168 #else
169  if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].p, p, r))
170  {
171  mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
172  if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
173  o = j;
174  orest = rest;
175  }
176  }
177 #endif
178  j++;
179  }
180  }
181  else
182  {
183  const ring r=strat->tailRing;
184  const poly p=L->t_p;
185  orest = pGetCoeff(p);
186  loop
187  {
188  if (j > strat->tl) return o;
189 #if defined(PDEBUG) || defined(PDIV_DEBUG)
190  if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
191  p, not_sev, r))
192  {
193  mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
194  if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
195  o = j;
196  orest = rest;
197  }
198  }
199 #else
200  if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].t_p, p, r))
201  {
202  mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
203  if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
204  o = j;
205  orest = rest;
206  }
207  }
208 #endif
209  j++;
210  }
211  }
212 }
static FORCE_INLINE number n_EucNorm(number a, const coeffs r)
Definition: coeffs.h:697
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:703
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:511
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464

◆ kFindInT()

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

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

Definition at line 711 of file kutil.cc.

712 {
713  int i;
714 
715  for (i=0; i<=tlength; i++)
716  {
717  if (T[i].p == p) return i;
718  }
719  return -1;
720 }

◆ kFindNextDivisibleByInS()

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

Definition at line 395 of file kstd2.cc.

396 {
397  unsigned long not_sev = ~L->sev;
398  poly p = L->GetLmCurrRing();
399  int j = start;
400 
401  pAssume(~not_sev == p_GetShortExpVector(p, currRing));
402 #if 1
403  int ende=max_ind;
404 #else
405  int ende=strat->sl;
406 #endif
408  {
409  loop
410  {
411  if (j > ende) return -1;
412 #if defined(PDEBUG) || defined(PDIV_DEBUG)
413  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
414  p, not_sev, currRing))
415  {
416  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
417  return j;
418  }
419 #else
420  if ( !(strat->sevS[j] & not_sev) &&
421  p_LmDivisibleBy(strat->S[j], p, currRing))
422  {
423  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
424  return j;
425  }
426 #endif
427  j++;
428  }
429  }
430  else
431  {
432  loop
433  {
434  if (j > ende) return -1;
435 #if defined(PDEBUG) || defined(PDIV_DEBUG)
436  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
437  p, not_sev, currRing))
438  {
439  return j;
440  }
441 #else
442  if ( !(strat->sevS[j] & not_sev) &&
443  p_LmDivisibleBy(strat->S[j], p, currRing))
444  {
445  return j;
446  }
447 #endif
448  j++;
449  }
450  }
451 }

◆ 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) == TRUE) {
109  ogcd = gcd;
110  o = j;
111  }
112  }
113  j++;
114  }
115  }
116  else
117  {
118  const ring r=strat->tailRing;
119  const poly p=L->t_p;
120  ogcd = pGetCoeff(p);
121  loop
122  {
123  if (j > strat->tl) return o;
124  if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r) && p_LmEqual(T[j].p, p, r))
125  {
126  gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf);
127  if (o == -1 ||
128  n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf) == TRUE) {
129  ogcd = gcd;
130  o = j;
131  }
132  }
133  j++;
134  }
135  }
136 }
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1651

◆ kFindZeroPoly()

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

Definition at line 454 of file kstd2.cc.

455 {
456  // m = currRing->ch
457 
458  if (input_p == NULL) return NULL;
459 
460  poly p = input_p;
461  poly zeroPoly = NULL;
462  unsigned long a = (unsigned long) pGetCoeff(p);
463 
464  int k_ind2 = 0;
465  int a_ind2 = ind2(a);
466 
467  // unsigned long k = 1;
468  // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
469  for (int i = 1; i <= leadRing->N; i++)
470  {
471  k_ind2 = k_ind2 + ind_fact_2(p_GetExp(p, i, leadRing));
472  }
473 
474  a = (unsigned long) pGetCoeff(p);
475 
476  number tmp1;
477  poly tmp2, tmp3;
478  poly lead_mult = p_ISet(1, tailRing);
479  if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
480  {
481  int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf);
482  int s_exp;
483  zeroPoly = p_ISet(a, tailRing);
484  for (int i = 1; i <= leadRing->N; i++)
485  {
486  s_exp = p_GetExp(p, i,leadRing);
487  if (s_exp % 2 != 0)
488  {
489  s_exp = s_exp - 1;
490  }
491  while ( (0 < ind2(s_exp)) && (ind2(s_exp) <= too_much) )
492  {
493  too_much = too_much - ind2(s_exp);
494  s_exp = s_exp - 2;
495  }
496  p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
497  for (int j = 1; j <= s_exp; j++)
498  {
499  tmp1 = nInit(j);
500  tmp2 = p_ISet(1, tailRing);
501  p_SetExp(tmp2, i, 1, tailRing);
502  p_Setm(tmp2, tailRing);
503  if (nIsZero(tmp1))
504  { // should nowbe obsolet, test ! TODO OLIVER
505  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
506  }
507  else
508  {
509  tmp3 = p_NSet(nCopy(tmp1), tailRing);
510  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
511  }
512  }
513  }
514  p_Setm(lead_mult, tailRing);
515  zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing);
516  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
517  for (int i = 1; i <= leadRing->N; i++)
518  {
519  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
520  }
521  p_Setm(tmp2, leadRing);
522  zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
523  pNext(tmp2) = zeroPoly;
524  return tmp2;
525  }
526 /* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
527  if (1 == 0 && alpha_k <= a)
528  { // Temporarly disabled, reducing coefficients not compatible with std TODO Oliver
529  zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
530  for (int i = 1; i <= leadRing->N; i++)
531  {
532  for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
533  {
534  tmp1 = nInit(j);
535  tmp2 = p_ISet(1, tailRing);
536  p_SetExp(tmp2, i, 1, tailRing);
537  p_Setm(tmp2, tailRing);
538  if (nIsZero(tmp1))
539  {
540  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
541  }
542  else
543  {
544  tmp3 = p_ISet((unsigned long) tmp1, tailRing);
545  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
546  }
547  }
548  }
549  tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing);
550  for (int i = 1; i <= leadRing->N; i++)
551  {
552  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
553  }
554  p_Setm(tmp2, leadRing);
555  zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
556  pNext(tmp2) = zeroPoly;
557  return tmp2;
558  } */
559  return NULL;
560 }
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1000
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:724

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3666 of file kstd2.cc.

3667 {
3668  assume(!idIs0(q));
3669  assume(!(idIs0(F)&&(Q==NULL)));
3670 // lazy_reduce flags: can be combined by |
3671 //#define KSTD_NF_LAZY 1
3672  // do only a reduction of the leading term
3673 //#define KSTD_NF_NONORM 4
3674  // only global: avoid normalization, return a multiply of NF
3675  poly p;
3676  int i;
3677  ideal res;
3678  int max_ind;
3679 
3680  //if (idIs0(q))
3681  // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
3682  //if ((idIs0(F))&&(Q==NULL))
3683  // return idCopy(q); /*F=0*/
3684  //strat->ak = idRankFreeModule(F);
3685  /*- creating temp data structures------------------- -*/
3686  BITSET save1;
3687  SI_SAVE_OPT1(save1);
3689  initBuchMoraCrit(strat);
3690  strat->initEcart = initEcartBBA;
3691 #ifdef HAVE_SHIFTBBA
3692  if (rIsLPRing(currRing))
3693  {
3694  strat->enterS = enterSBbaShift;
3695  }
3696  else
3697 #endif
3698  {
3699  strat->enterS = enterSBba;
3700  }
3701  /*- set S -*/
3702  strat->sl = -1;
3703 #ifndef NO_BUCKETS
3705 #endif
3706  /*- init local data struct.---------------------------------------- -*/
3707  /*Shdl=*/initS(F,Q,strat);
3708  /*- compute------------------------------------------------------- -*/
3709  res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
3711  for (i=IDELEMS(q)-1; i>=0; i--)
3712  {
3713  if (q->m[i]!=NULL)
3714  {
3715  if (TEST_OPT_PROT) { PrintS("r");mflush(); }
3716  p = redNF(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat);
3717  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3718  {
3719  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3720  if (rField_is_Ring(currRing))
3721  {
3722  p = redtailBba_Z(p,max_ind,strat);
3723  }
3724  else
3725  {
3726  p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3727  }
3728  }
3729  res->m[i]=p;
3730  }
3731  //else
3732  // res->m[i]=NULL;
3733  }
3734  /*- release temp data------------------------------- -*/
3735  assume(strat->L==NULL); /* strat->L unused */
3736  assume(strat->B==NULL); /* strat->B unused */
3737  omFree(strat->sevS);
3738  omFree(strat->ecartS);
3739  assume(strat->T==NULL);//omfree(strat->T);
3740  assume(strat->sevT==NULL);//omfree(strat->sevT);
3741  assume(strat->R==NULL);//omfree(strat->R);
3742  omfree(strat->S_2_R);
3743  omfree(strat->fromQ);
3744 #ifdef HAVE_SHIFTBBA
3745  // only LM of elements in S is shifted
3746  // necessary to prevent deleting the tail multiple times
3747  if (rIsLPRing(currRing))
3748  {
3749  for (int j = 0; j < IDELEMS(strat->Shdl); j++)
3750  {
3751  if (strat->Shdl->m[j]!=NULL && pmFirstVblock(strat->Shdl->m[j]) > 1)
3752  {
3753  // otherwise the tail would be freed multiple times
3754  pNext(strat->Shdl->m[j]) = NULL;
3755  }
3756  }
3757  }
3758 #endif
3759  idDelete(&strat->Shdl);
3760  SI_RESTORE_OPT1(save1);
3761  if (TEST_OPT_PROT) PrintLn();
3762  return res;
3763 }
CanonicalForm res
Definition: facAbsFact.cc:64
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition: kInline.h:1171
#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:1866
void initS(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8077
void enterSBbaShift(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9371
#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:90
#define OPT_REDTAIL
Definition: options.h:89
#define Sy_bit(x)
Definition: options.h:31
#define pmFirstVblock(p)
Definition: shiftop.h:35

◆ kNF2() [2/2]

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

Definition at line 3503 of file kstd2.cc.

3504 {
3505  assume(q!=NULL);
3506  assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3507 
3508 // lazy_reduce flags: can be combined by |
3509 //#define KSTD_NF_LAZY 1
3510  // do only a reduction of the leading term
3511 //#define KSTD_NF_NONORM 4
3512  // only global: avoid normalization, return a multiply of NF
3513  poly p;
3514 
3515  //if ((idIs0(F))&&(Q==NULL))
3516  // return pCopy(q); /*F=0*/
3517  //strat->ak = idRankFreeModule(F);
3518  /*- creating temp data structures------------------- -*/
3519  BITSET save1;
3520  SI_SAVE_OPT1(save1);
3522  initBuchMoraCrit(strat);
3523  strat->initEcart = initEcartBBA;
3524 #ifdef HAVE_SHIFTBBA
3525  if (rIsLPRing(currRing))
3526  {
3527  strat->enterS = enterSBbaShift;
3528  }
3529  else
3530 #endif
3531  {
3532  strat->enterS = enterSBba;
3533  }
3534 #ifndef NO_BUCKETS
3536 #endif
3537  /*- set S -*/
3538  strat->sl = -1;
3539  /*- init local data struct.---------------------------------------- -*/
3540  /*Shdl=*/initS(F,Q,strat);
3541  /*- compute------------------------------------------------------- -*/
3542  //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3543  //{
3544  // for (i=strat->sl;i>=0;i--)
3545  // pNorm(strat->S[i]);
3546  //}
3547  kTest(strat);
3548  if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3549  if (BVERBOSE(23)) kDebugPrint(strat);
3550  int max_ind;
3551  p = redNF(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat);
3552  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3553  {
3554  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3555  if (rField_is_Ring(currRing))
3556  {
3557  p = redtailBba_Z(p,max_ind,strat);
3558  }
3559  else
3560  {
3562  p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3563  }
3564  }
3565  /*- release temp data------------------------------- -*/
3566  assume(strat->L==NULL); /* strat->L unused */
3567  assume(strat->B==NULL); /* strat->B unused */
3568  omFree(strat->sevS);
3569  omFree(strat->ecartS);
3570  assume(strat->T==NULL);//omfree(strat->T);
3571  assume(strat->sevT==NULL);//omfree(strat->sevT);
3572  assume(strat->R==NULL);//omfree(strat->R);
3573  omfree(strat->S_2_R);
3574  omfree(strat->fromQ);
3575 #ifdef HAVE_SHIFTBBA
3576  // only LM of elements in S is shifted
3577  // necessary to prevent deleting the tail multiple times
3578  if (rIsLPRing(currRing))
3579  {
3580  for (int j = 0; j < IDELEMS(strat->Shdl); j++)
3581  {
3582  if (strat->Shdl->m[j]!=NULL && pmFirstVblock(strat->Shdl->m[j]) > 1)
3583  {
3584  // otherwise the tail would be freed multiple times
3585  pNext(strat->Shdl->m[j]) = NULL;
3586  }
3587  }
3588  }
3589 #endif
3590  idDelete(&strat->Shdl);
3591  SI_RESTORE_OPT1(save1);
3592  if (TEST_OPT_PROT) PrintLn();
3593  return p;
3594 }
BOOLEAN kTest(kStrategy strat)
Definition: kutil.cc:960

◆ kNF2Bound() [1/2]

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

Definition at line 3765 of file kstd2.cc.

3766 {
3767  assume(!idIs0(q));
3768  assume(!(idIs0(F)&&(Q==NULL)));
3769 // lazy_reduce flags: can be combined by |
3770 //#define KSTD_NF_LAZY 1
3771  // do only a reduction of the leading term
3772 //#define KSTD_NF_NONORM 4
3773  // only global: avoid normalization, return a multiply of NF
3774  poly p;
3775  int i;
3776  ideal res;
3777  int max_ind;
3778 
3779  //if (idIs0(q))
3780  // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
3781  //if ((idIs0(F))&&(Q==NULL))
3782  // return idCopy(q); /*F=0*/
3783  //strat->ak = idRankFreeModule(F);
3784  /*- creating temp data structures------------------- -*/
3785  BITSET save1;
3786  SI_SAVE_OPT1(save1);
3788  initBuchMoraCrit(strat);
3789  strat->initEcart = initEcartBBA;
3790  strat->enterS = enterSBba;
3791  /*- set S -*/
3792  strat->sl = -1;
3793 #ifndef NO_BUCKETS
3795 #endif
3796  /*- init local data struct.---------------------------------------- -*/
3797  /*Shdl=*/initS(F,Q,strat);
3798  /*- compute------------------------------------------------------- -*/
3799  res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
3801  for (i=IDELEMS(q)-1; i>=0; i--)
3802  {
3803  if (q->m[i]!=NULL)
3804  {
3805  if (TEST_OPT_PROT) { PrintS("r");mflush(); }
3806  p = redNFBound(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
3807  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3808  {
3809  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3810  if (rField_is_Ring(currRing))
3811  {
3812  p = redtailBba_Z(p,max_ind,strat);
3813  }
3814  else
3815  {
3816  p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
3817  }
3818  }
3819  res->m[i]=p;
3820  }
3821  //else
3822  // res->m[i]=NULL;
3823  }
3824  /*- release temp data------------------------------- -*/
3825  assume(strat->L==NULL); /* strat->L unused */
3826  assume(strat->B==NULL); /* strat->B unused */
3827  omFree(strat->sevS);
3828  omFree(strat->ecartS);
3829  assume(strat->T==NULL);//omfree(strat->T);
3830  assume(strat->sevT==NULL);//omfree(strat->sevT);
3831  assume(strat->R==NULL);//omfree(strat->R);
3832  omfree(strat->S_2_R);
3833  omfree(strat->fromQ);
3834  idDelete(&strat->Shdl);
3835  SI_RESTORE_OPT1(save1);
3836  if (TEST_OPT_PROT) PrintLn();
3837  return res;
3838 }
KINLINE poly redtailBbaBound(poly p, int pos, kStrategy strat, int bound, BOOLEAN normalize)
Definition: kInline.h:1164
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
Definition: kstd2.cc:2022

◆ kNF2Bound() [2/2]

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

Definition at line 3596 of file kstd2.cc.

3597 {
3598  assume(q!=NULL);
3599  assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3600 
3601 // lazy_reduce flags: can be combined by |
3602 //#define KSTD_NF_LAZY 1
3603  // do only a reduction of the leading term
3604 //#define KSTD_NF_NONORM 4
3605  // only global: avoid normalization, return a multiply of NF
3606  poly p;
3607 
3608  //if ((idIs0(F))&&(Q==NULL))
3609  // return pCopy(q); /*F=0*/
3610  //strat->ak = idRankFreeModule(F);
3611  /*- creating temp data structures------------------- -*/
3612  BITSET save1;
3613  SI_SAVE_OPT1(save1);
3615  initBuchMoraCrit(strat);
3616  strat->initEcart = initEcartBBA;
3617  strat->enterS = enterSBba;
3618 #ifndef NO_BUCKETS
3620 #endif
3621  /*- set S -*/
3622  strat->sl = -1;
3623  /*- init local data struct.---------------------------------------- -*/
3624  /*Shdl=*/initS(F,Q,strat);
3625  /*- compute------------------------------------------------------- -*/
3626  //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3627  //{
3628  // for (i=strat->sl;i>=0;i--)
3629  // pNorm(strat->S[i]);
3630  //}
3631  kTest(strat);
3632  if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3633  if (BVERBOSE(23)) kDebugPrint(strat);
3634  int max_ind;
3635  p = redNFBound(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
3636  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3637  {
3638  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3639  if (rField_is_Ring(currRing))
3640  {
3641  p = redtailBba_Z(p,max_ind,strat);
3642  }
3643  else
3644  {
3646  p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
3647  //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3648  }
3649  }
3650  /*- release temp data------------------------------- -*/
3651  assume(strat->L==NULL); /* strat->L unused */
3652  assume(strat->B==NULL); /* strat->B unused */
3653  omFree(strat->sevS);
3654  omFree(strat->ecartS);
3655  assume(strat->T==NULL);//omfree(strat->T);
3656  assume(strat->sevT==NULL);//omfree(strat->sevT);
3657  assume(strat->R==NULL);//omfree(strat->R);
3658  omfree(strat->S_2_R);
3659  omfree(strat->fromQ);
3660  idDelete(&strat->Shdl);
3661  SI_RESTORE_OPT1(save1);
3662  if (TEST_OPT_PROT) PrintLn();
3663  return p;
3664 }

◆ ksCreateShortSpoly()

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

Definition at line 1409 of file kspoly.cc.

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

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

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

◆ ksOldCreateSpoly()

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

Definition at line 1140 of file kInline.h.

1141 {
1142  LObject L(r);
1143  L.p1 = p1;
1144  L.p2 = p2;
1145 
1146  ksCreateSpoly(&L, spNoether);
1147  return L.GetLmCurrRing();
1148 }

◆ ksOldSpolyRed()

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

Definition at line 1120 of file kInline.h.

1121 {
1122  LObject L(p2);
1123  TObject T(p1);
1124 
1125  ksReducePoly(&L, &T, spNoether);
1126 
1127  return L.GetLmCurrRing();
1128 }
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:188

◆ ksOldSpolyRedNew()

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

Definition at line 1130 of file kInline.h.

1131 {
1132  LObject L(p_Copy(p2, currRing));
1133  TObject T(p1);
1134 
1135  ksReducePoly(&L, &T, spNoether);
1136 
1137  return L.GetLmCurrRing();
1138 }

◆ ksOldSpolyTail()

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

Definition at line 1150 of file kInline.h.

1151 {
1152  LObject L(q, currRing, r);
1153  TObject T(p1, currRing, r);
1154 
1155  ksReducePolyTail(&L, &T, q2, spNoether);
1156 }
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1093

◆ ksReducePoly()

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

Definition at line 188 of file kspoly.cc.

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

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

◆ ksReducePolyGCD()

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

Definition at line 320 of file kspoly.cc.

325 {
326 #ifdef KDEBUG
327  red_count++;
328 #ifdef TEST_OPT_DEBUG_RED
329 // if (TEST_OPT_DEBUG)
330 // {
331 // Print("Red %d:", red_count); PR->wrp(); Print(" with:");
332 // PW->wrp();
333 // //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
334 // //pWrite(PR->p);
335 // }
336 #endif
337 #endif
338  int ret = 0;
339  ring tailRing = PR->tailRing;
340  kTest_L(PR, tailRing);
341  kTest_T(PW);
342 
343  poly p1 = PR->GetLmTailRing();
344  poly p2 = PW->GetLmTailRing();
345  poly t2 = pNext(p2), lm = pOne();
346  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
347  p_CheckPolyRing(p1, tailRing);
348  p_CheckPolyRing(p2, tailRing);
349 
350  pAssume1(p2 != NULL && p1 != NULL &&
351  p_DivisibleBy(p2, p1, tailRing));
352 
353  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
354  (p_GetComp(p2, tailRing) == 0 &&
355  p_MaxComp(pNext(p2),tailRing) == 0));
356 
357 #ifdef HAVE_PLURAL
358  if (rIsPluralRing(currRing))
359  {
360  // for the time being: we know currRing==strat->tailRing
361  // no exp-bound checking needed
362  // (only needed if exp-bound(tailring)<exp-b(currRing))
363  if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef);
364  else
365  {
366  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
367  assume(_p != NULL);
368  nc_PolyPolyRed(_p, p2,coef, currRing);
369  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
370  PR->pLength=0; // usually not used, GetpLength re-computes it if needed
371  }
372  return 0;
373  }
374 #endif
375  // check that reduction does not violate exp bound
376  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
377  {
378  // undo changes of lm
379  p_ExpVectorAdd(lm, p2, tailRing);
380  if (strat == NULL) return 2;
381  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
382  tailRing = strat->tailRing;
383  p1 = PR->GetLmTailRing();
384  p2 = PW->GetLmTailRing();
385  t2 = pNext(p2);
386  lm = p1;
387  p_ExpVectorSub(lm, p2, tailRing);
388  ret = 1;
389  }
390 
391  number ct, an, bn;
392  // take care of coef buisness
393  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
394  {
395  ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing->cf); // Calculate GCD
396  /* negate bn since we subtract in Tail_Minus_mm_Mult_qq */
397  bn = n_InpNeg(bn, tailRing->cf);
398  p_SetCoeff(lm, bn, tailRing);
399  PR->Tail_Mult_nn(an);
400  }
401  else
402  {
403  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
404  }
405 
406 
407  // and finally,
408  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
409  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
410  pSetCoeff(PR->p, ct);
411 
412  // the following is commented out: shrinking
413 #ifdef HAVE_SHIFTBBA_NONEXISTENT
414  if ( (currRing->isLPring) && (!strat->homog) )
415  {
416  // assume? h->p in currRing
417  PR->GetP();
418  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
419  PR->Clear(); // does the right things
420  PR->p = qq;
421  PR->t_p = NULL;
422  PR->SetShortExpVector();
423  }
424 #endif
425 
426  return ret;
427 }
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:557
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition: coeffs.h:693

◆ ksReducePolyLC()

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

Definition at line 436 of file kspoly.cc.

441 {
442 #ifdef KDEBUG
443  red_count++;
444 #ifdef TEST_OPT_DEBUG_RED
445 // if (TEST_OPT_DEBUG)
446 // {
447 // Print("Red %d:", red_count); PR->wrp(); Print(" with:");
448 // PW->wrp();
449 // //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
450 // //pWrite(PR->p);
451 // }
452 #endif
453 #endif
454  /* printf("PR->P: ");
455  * p_Write(PR->p, currRing, PR->tailRing); */
456  int ret = 0;
457  ring tailRing = PR->tailRing;
458  kTest_L(PR,tailRing);
459  kTest_T(PW);
460 
461  poly p1 = PR->GetLmTailRing(); // p2 | p1
462  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
463  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
464  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
465  p_CheckPolyRing(p1, tailRing);
466  p_CheckPolyRing(p2, tailRing);
467 
468  pAssume1(p2 != NULL && p1 != NULL &&
469  p_DivisibleBy(p2, p1, tailRing));
470 
471  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
472  (p_GetComp(p2, tailRing) == 0 &&
473  p_MaxComp(pNext(p2),tailRing) == 0));
474 
475 #ifdef HAVE_PLURAL
476  if (rIsPluralRing(currRing))
477  {
478  // for the time being: we know currRing==strat->tailRing
479  // no exp-bound checking needed
480  // (only needed if exp-bound(tailring)<exp-b(currRing))
481  if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef);
482  else
483  {
484  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
485  assume(_p != NULL);
486  nc_PolyPolyRed(_p, p2,coef, currRing);
487  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
488  PR->pLength=0; // usually not used, GetpLength re-computes it if needed
489  }
490  return 0;
491  }
492 #endif
493 
494  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
495  p_SetCoeff(lm, n_Init(1, tailRing), tailRing);
496  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
497  {
498  // undo changes of lm
499  p_ExpVectorAdd(lm, p2, tailRing);
500  if (strat == NULL) return 2;
501  /* if (! kStratChangeTailRing(strat, PR, PW)) return -1; */
502  tailRing = strat->tailRing;
503  p1 = PR->GetLmTailRing();
504  p2 = PW->GetLmTailRing();
505  t2 = pNext(p2);
506  lm = p1;
507  p_ExpVectorSub(lm, p2, tailRing);
508  ret = 1;
509  }
510 
511  // and finally,
512  PR->Tail_Minus_mm_Mult_qq(lm, p2, pLength(p2) /*PW->GetpLength() - 1*/, spNoether);
513  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
514 
515  PR->LmDeleteAndIter();
516  p_SetCoeff(PR->p, *coef, currRing);
517 
518 
519  // the following is commented out: shrinking
520 #ifdef HAVE_SHIFTBBA_NONEXISTENT
521  if ( (currRing->isLPring) && (!strat->homog) )
522  {
523  // assume? h->p in currRing
524  PR->GetP();
525  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
526  PR->Clear(); // does the right things
527  PR->p = qq;
528  PR->t_p = NULL;
529  PR->SetShortExpVector();
530  }
531 #endif
532 
533 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
534  if (TEST_OPT_DEBUG)
535  {
536  Print(" to: "); PR->wrp(); Print("\n");
537  //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
538  }
539 #endif
540  return ret;
541 }

◆ ksReducePolySig()

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

Definition at line 690 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 896 of file kspoly.cc.

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

◆ ksReducePolyTail() [1/2]

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

Definition at line 1093 of file kInline.h.

1094 {
1095  BOOLEAN ret;
1096  number coef;
1097 
1098  assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1099  Red->HeadNormalize();
1100  ret = ksReducePoly(Red, PW, NULL, &coef);
1101 
1102  if (!ret)
1103  {
1104  if (! n_IsOne(coef, currRing->cf))
1105  {
1106  PR->Mult_nn(coef);
1107  // HANNES: mark for Normalize
1108  }
1109  n_Delete(&coef, currRing->cf);
1110  }
1111  return ret;
1112 }

◆ ksReducePolyTail() [2/2]

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

Definition at line 1309 of file kspoly.cc.

1310 {
1311  BOOLEAN ret;
1312  number coef;
1313  poly Lp = PR->GetLmCurrRing();
1314  poly Save = PW->GetLmCurrRing();
1315 
1316  kTest_L(PR,PR->tailRing);
1317  kTest_T(PW);
1318  pAssume(pIsMonomOf(Lp, Current));
1319 
1320  assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
1321  assume(PR->bucket == NULL);
1322 
1323  LObject Red(pNext(Current), PR->tailRing);
1324  TObject With(PW, Lp == Save);
1325 
1326  pAssume(!pHaveCommonMonoms(Red.p, With.p));
1327  ret = ksReducePoly(&Red, &With, spNoether, &coef);
1328 
1329  if (!ret)
1330  {
1331  if (! n_IsOne(coef, currRing->cf))
1332  {
1333  pNext(Current) = NULL;
1334  if (Current == PR->p && PR->t_p != NULL)
1335  pNext(PR->t_p) = NULL;
1336  PR->Mult_nn(coef);
1337  }
1338 
1339  n_Delete(&coef, currRing->cf);
1340  pNext(Current) = Red.GetLmTailRing();
1341  if (Current == PR->p && PR->t_p != NULL)
1342  pNext(PR->t_p) = pNext(Current);
1343  }
1344 
1345  if (Lp == Save)
1346  With.Delete();
1347 
1348  return ret;
1349 }
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 #ifdef HAVE_SHIFTBBA
158  if (tailRing->isLPring) pSetCoeff0(p1, bn); // lm doesn't point to p1 anymore, if the coef was a pointer, it has been deleted
159 #endif
160  if ((ct == 0) || (ct == 2))
161  PR->Tail_Mult_nn(an);
162  if (coef != NULL) *coef = an;
163  else n_Delete(&an, tailRing->cf);
164  }
165  else
166  {
167  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
168  }
169 
170 
171  // and finally,
172 #ifdef HAVE_SHIFTBBA
173  if (tailRing->isLPring)
174  {
175  PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
176  }
177  else
178 #endif
179  {
180  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
181  }
182  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
183  PR->LmDeleteAndIter();
184 
185  return ret;
186 }

◆ kStratChangeTailRing()

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

Definition at line 11403 of file kutil.cc.

11404 {
11405  assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11406  /* initial setup or extending */
11407 
11408  if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11409  if (expbound >= currRing->bitmask) return FALSE;
11410  strat->overflow=FALSE;
11411  ring new_tailRing = rModifyRing(currRing,
11412  // Hmmm .. the condition pFDeg == p_Deg
11413  // might be too strong
11414  (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11415  (strat->ak==0), // omit_comp if the input is an ideal
11416  expbound); // exp_limit
11417 
11418  if (new_tailRing == currRing) return TRUE;
11419 
11420  strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11421  strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11422 
11423  if (currRing->pFDeg != currRing->pFDegOrig)
11424  {
11425  new_tailRing->pFDeg = currRing->pFDeg;
11426  new_tailRing->pLDeg = currRing->pLDeg;
11427  }
11428 
11429  if (TEST_OPT_PROT)
11430  Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11431  kTest_TS(strat);
11432  assume(new_tailRing != strat->tailRing);
11433  pShallowCopyDeleteProc p_shallow_copy_delete
11434  = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11435 
11436  omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11437 
11438  int i;
11439  for (i=0; i<=strat->tl; i++)
11440  {
11441  strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11442  p_shallow_copy_delete);
11443  }
11444  for (i=0; i<=strat->Ll; i++)
11445  {
11446  assume(strat->L[i].p != NULL);
11447  if (pNext(strat->L[i].p) != strat->tail)
11448  strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11449  }
11450  if ((strat->P.t_p != NULL) ||
11451  ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11452  strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11453 
11454  if ((L != NULL) && (L->tailRing != new_tailRing))
11455  {
11456  if (L->i_r < 0)
11457  L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11458  else
11459  {
11460  assume(L->i_r <= strat->tl);
11461  TObject* t_l = strat->R[L->i_r];
11462  assume(t_l != NULL);
11463  L->tailRing = new_tailRing;
11464  L->p = t_l->p;
11465  L->t_p = t_l->t_p;
11466  L->max_exp = t_l->max_exp;
11467  }
11468  }
11469 
11470  if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11471  T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11472 
11473  omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11474  if (strat->tailRing != currRing)
11475  rKillModifiedRing(strat->tailRing);
11476 
11477  strat->tailRing = new_tailRing;
11478  strat->tailBin = new_tailBin;
11479  strat->p_shallow_copy_delete
11480  = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11481 
11482  if (strat->kHEdge != NULL)
11483  {
11484  if (strat->t_kHEdge != NULL)
11485  p_LmFree(strat->t_kHEdge, strat->tailRing);
11486  strat->t_kHEdge=k_LmInit_currRing_2_tailRing(strat->kHEdge, new_tailRing);
11487  }
11488 
11489  if (strat->kNoether != NULL)
11490  {
11491  if (strat->t_kNoether != NULL)
11492  p_LmFree(strat->t_kNoether, strat->tailRing);
11494  new_tailRing);
11495  }
11496  kTest_TS(strat);
11497  if (TEST_OPT_PROT)
11498  PrintS("]");
11499  return TRUE;
11500 }
poly t_kNoether
Definition: kutil.h:329
pFDegProc pOrigFDeg_TailRing
Definition: kutil.h:294
poly t_kHEdge
Definition: kutil.h:327
pLDegProc pOrigLDeg_TailRing
Definition: kutil.h:295
omBin_t * omBin
Definition: omStructs.h:12
void rKillModifiedRing(ring r)
Definition: ring.cc:3002
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2642
#define omGetStickyBinOfBin(B)
Definition: xalloc.h:290
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:319

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11502 of file kutil.cc.

11503 {
11504  unsigned long l = 0;
11505  int i;
11506  long e;
11507 
11508  assume(strat->tailRing == currRing);
11509 
11510  for (i=0; i<= strat->Ll; i++)
11511  {
11512  l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11513  }
11514  for (i=0; i<=strat->tl; i++)
11515  {
11516  // Hmm ... this we could do in one Step
11517  l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11518  }
11519  if (rField_is_Ring(currRing))
11520  {
11521  l *= 2;
11522  }
11523  e = p_GetMaxExp(l, currRing);
11524  if (e <= 1) e = 2;
11525 
11526  kStratChangeTailRing(strat, NULL, NULL, e);
11527 }
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:1165
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:746

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 960 of file kutil.cc.

961 {
962  int i;
963  // test P
964  kFalseReturn(kTest_L(&(strat->P), strat->tailRing,
965  (strat->P.p != NULL && pNext(strat->P.p)!=strat->tail),
966  -1, strat->T, strat->tl));
967 
968  // test T
969  if (strat->T != NULL)
970  {
971  for (i=0; i<=strat->tl; i++)
972  {
973  kFalseReturn(kTest_T(&(strat->T[i]), strat->tailRing, i, 'T'));
974  if (strat->sevT[i] != pGetShortExpVector(strat->T[i].p))
975  return dReportError("strat->sevT[%d] out of sync", i);
976  }
977  }
978 
979  // test L
980  if (strat->L != NULL)
981  {
982  #ifdef HAVE_SHIFTBBA
983  if (strat->red==redFirstShift) // is this in bbaShift ?
984  {
985  for (i=0; i<=strat->Ll; i++)
986  {
987  kFalseReturn(kTest_L(&(strat->L[i]), strat->tailRing,
988  2, i,
989  strat->T, strat->tl));
990  }
991  }
992  else
993  #endif
994  for (i=0; i<=strat->Ll; i++)
995  {
996  kFalseReturn(kTest_L(&(strat->L[i]), strat->tailRing,
997  strat->L[i].Next() != strat->tail, i,
998  strat->T, strat->tl));
999  // may be unused
1000  //if (strat->use_buckets && strat->L[i].Next() != strat->tail &&
1001  // strat->L[i].Next() != NULL && strat->L[i].p1 != NULL)
1002  //{
1003  // assume(strat->L[i].bucket != NULL);
1004  //}
1005  }
1006  }
1007 
1008  // test S
1009  if (strat->S != NULL)
1010  kFalseReturn(kTest_S(strat));
1011 
1012  return TRUE;
1013 }
#define kFalseReturn(x)
Definition: kutil.cc:744
BOOLEAN kTest_S(kStrategy strat)
Definition: kutil.cc:1015
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 889 of file kutil.cc.

891 {
892  if (L->p!=NULL)
893  {
894  if ((L->t_p==NULL)
895  &&(pNext(L->p)!=NULL)
896  &&(pGetCoeff(pNext(L->p))!=NULL)) /* !=strat->tail*/
897  {
898  p_Test(pNext(L->p),currRing);
899  nTest(pGetCoeff(L->p));
900  }
901  }
902  if (L->t_p!=NULL)
903  {
904  if ((pNext(L->t_p)!=NULL)
905  &&(pGetCoeff(pNext(L->t_p))!=NULL)) /* !=strat->tail*/
906  {
907  p_Test(pNext(L->t_p),strat_tailRing);
908  nTest(pGetCoeff(L->t_p));
909  }
910  }
911  if ((L->p!=NULL)&&(L->t_p!=NULL)) assume(pGetCoeff(L->p)==pGetCoeff(L->t_p));
912 
913  if (testp)
914  {
915  poly pn = NULL;
916  if (L->bucket != NULL)
917  {
918  kFalseReturn(kbTest(L->bucket));
919  r_assume(L->bucket->bucket_ring == L->tailRing);
920  if (L->p != NULL && pNext(L->p) != NULL)
921  {
922  pn = pNext(L->p);
923  pNext(L->p) = NULL;
924  }
925  }
926  if (testp!=2) kFalseReturn(kTest_T(L, strat_tailRing, lpos, 'L'));
927  if (pn != NULL)
928  pNext(L->p) = pn;
929 
930  ring r;
931  poly p;
932  L->GetLm(p, r);
933  if (L->sev != 0 && p_GetShortExpVector(p, r) != L->sev)
934  {
935  return dReportError("L[%d] wrong sev: has %o, specified to have %o",
936  lpos, p_GetShortExpVector(p, r), L->sev);
937  }
938  }
939  if (L->p1 == NULL)
940  {
941  // L->p2 either NULL or "normal" poly
942  pFalseReturn(pp_Test(L->p2, currRing, L->tailRing));
943  }
944  else if (tlength > 0 && T != NULL && (lpos >=0) && (testp!=2))
945  {
946  // now p1 and p2 must be != NULL and must be contained in T
947  // unless for SHIFTGB: here each p_i must be in T or
948  // be shifted from an element in T -> to difficult to test
949  int i;
950  i = kFindInT(L->p1, T, tlength);
951  if (i < 0)
952  return dReportError("L[%d].p1 not in T",lpos);
953  i = kFindInT(L->p2, T, tlength);
954  if (i < 0)
955  return dReportError("L[%d].p2 not in T",lpos);
956  }
957  return TRUE;
958 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:197
#define r_assume(x)
Definition: mod2.h:391
#define pFalseReturn(cond)
Definition: monomials.h:139
#define nTest(a)
Definition: numbers.h:35

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1015 of file kutil.cc.

1016 {
1017  int i;
1018  BOOLEAN ret = TRUE;
1019  for (i=0; i<=strat->sl; i++)
1020  {
1021  if (strat->S[i] != NULL &&
1022  strat->sevS[i] != pGetShortExpVector(strat->S[i]))
1023  {
1024  return dReportError("S[%d] wrong sev: has %o, specified to have %o",
1025  i , pGetShortExpVector(strat->S[i]), strat->sevS[i]);
1026  }
1027  }
1028  return ret;
1029 }

◆ kTest_T()

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

Definition at line 765 of file kutil.cc.

766 {
767  ring tailRing = T->tailRing;
768  if (strat_tailRing == NULL) strat_tailRing = tailRing;
769  r_assume(strat_tailRing == tailRing);
770 
771  poly p = T->p;
772  // ring r = currRing;
773 
774  if (T->p == NULL && T->t_p == NULL && i >= 0)
775  return dReportError("%c[%d].poly is NULL", TN, i);
776 
777  if (T->p!=NULL)
778  {
779  nTest(pGetCoeff(T->p));
780  if ((T->t_p==NULL)&&(pNext(T->p)!=NULL)) p_Test(pNext(T->p),currRing);
781  }
782  if (T->t_p!=NULL)
783  {
784  nTest(pGetCoeff(T->t_p));
785  if (pNext(T->t_p)!=NULL) p_Test(pNext(T->t_p),strat_tailRing);
786  }
787  if ((T->p!=NULL)&&(T->t_p!=NULL)) assume(pGetCoeff(T->p)==pGetCoeff(T->t_p));
788 
789  if (T->tailRing != currRing)
790  {
791  if (T->t_p == NULL && i > 0)
792  return dReportError("%c[%d].t_p is NULL", TN, i);
793  pFalseReturn(p_Test(T->t_p, T->tailRing));
794  if (T->p != NULL) pFalseReturn(p_LmTest(T->p, currRing));
795  if (T->p != NULL && T->t_p != NULL)
796  {
797  const char* msg = kTest_LmEqual(T->p, T->t_p, T->tailRing);
798  if (msg != NULL)
799  return dReportError("%c[%d] %s", TN, i, msg);
800  // r = T->tailRing;
801  p = T->t_p;
802  }
803  if (T->p == NULL)
804  {
805  p = T->t_p;
806  // r = T->tailRing;
807  }
808  if (T->t_p != NULL && i >= 0 && TN == 'T')
809  {
810  if (pNext(T->t_p) == NULL)
811  {
812  if (T->max_exp != NULL)
813  return dReportError("%c[%d].max_exp is not NULL as it should be", TN, i);
814  }
815  else
816  {
817  if (T->max_exp == NULL)
818  return dReportError("%c[%d].max_exp is NULL", TN, i);
819  if (pNext(T->max_exp) != NULL)
820  return dReportError("pNext(%c[%d].max_exp) != NULL", TN, i);
821 
822  pFalseReturn(p_CheckPolyRing(T->max_exp, tailRing));
823  omCheckBinAddrSize(T->max_exp, (omSizeWOfBin(tailRing->PolyBin))*SIZEOF_LONG);
824 #if KDEBUG > 0
825  if (! sloppy_max)
826  {
827  poly test_max = p_GetMaxExpP(pNext(T->t_p), tailRing);
828  p_Setm(T->max_exp, tailRing);
829  p_Setm(test_max, tailRing);
830  BOOLEAN equal = p_ExpVectorEqual(T->max_exp, test_max, tailRing);
831  if (! equal)
832  return dReportError("%c[%d].max out of sync", TN, i);
833  p_LmFree(test_max, tailRing);
834  }
835 #endif
836  }
837  }
838  }
839  else
840  {
841  if (T->p == NULL && i > 0)
842  return dReportError("%c[%d].p is NULL", TN, i);
843 #ifdef HAVE_SHIFTBBA
844  if (currRing->isLPring && T->shift > 0)
845  {
846  // in this case, the order is not correct. test LM and tail separately
849  }
850  else
851 #endif
852  {
854  }
855  }
856 
857  if ((i >= 0) && (T->pLength != 0)
858  && (! rIsSyzIndexRing(currRing)) && (T->pLength != pLength(p)))
859  {
860  int l=T->pLength;
861  T->pLength=pLength(p);
862  return dReportError("%c[%d] pLength error: has %d, specified to have %d",
863  TN, i , pLength(p), l);
864  }
865 
866  // check FDeg, for elements in L and T
867  if (i >= 0 && (TN == 'T' || TN == 'L'))
868  {
869  // FDeg has ir element from T of L set
870  if (T->FDeg != T->pFDeg())
871  {
872  int d=T->FDeg;
873  T->FDeg=T->pFDeg();
874  return dReportError("%c[%d] FDeg error: has %d, specified to have %d",
875  TN, i , T->pFDeg(), d);
876  }
877  }
878 
879  // check is_normalized for elements in T
880  if (i >= 0 && TN == 'T')
881  {
882  if (T->is_normalized && ! nIsOne(pGetCoeff(p)))
883  return dReportError("T[%d] is_normalized error", i);
884 
885  }
886  return TRUE;
887 }
static const char * kTest_LmEqual(poly p, poly t_p, ring tailRing)
Definition: kutil.cc:747
#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:4432

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1033 of file kutil.cc.

1034 {
1035  int i, j;
1036  // BOOLEAN ret = TRUE;
1037  kFalseReturn(kTest(strat));
1038 
1039  // test strat->R, strat->T[i].i_r
1040  for (i=0; i<=strat->tl; i++)
1041  {
1042  if (strat->T[i].i_r < 0 || strat->T[i].i_r > strat->tl)
1043  return dReportError("strat->T[%d].i_r == %d out of bounds", i,
1044  strat->T[i].i_r);
1045  if (strat->R[strat->T[i].i_r] != &(strat->T[i]))
1046  return dReportError("T[%d].i_r with R out of sync", i);
1047  }
1048  // test containment of S inT
1049  if (strat->S != NULL)
1050  {
1051  for (i=0; i<=strat->sl; i++)
1052  {
1053  j = kFindInT(strat->S[i], strat->T, strat->tl);
1054  if (j < 0)
1055  return dReportError("S[%d] not in T", i);
1056  if (strat->S_2_R[i] != strat->T[j].i_r)
1057  return dReportError("S_2_R[%d]=%d != T[%d].i_r=%d\n",
1058  i, strat->S_2_R[i], j, strat->T[j].i_r);
1059  }
1060  }
1061  // test strat->L[i].i_r1
1062  #ifdef HAVE_SHIFTBBA
1063  if (strat->red!=redFirstShift) // not from bbaShift
1064  #endif
1065  for (i=0; i<=strat->Ll; i++)
1066  {
1067  if (strat->L[i].p1 != NULL && strat->L[i].p2)
1068  {
1069  if (strat->L[i].i_r1 < 0 ||
1070  strat->L[i].i_r1 > strat->tl ||
1071  strat->L[i].T_1(strat)->p != strat->L[i].p1)
1072  return dReportError("L[%d].i_r1 out of sync", i);
1073  if (strat->L[i].i_r2 < 0 ||
1074  strat->L[i].i_r2 > strat->tl ||
1075  strat->L[i].T_2(strat)->p != strat->L[i].p2)
1076  return dReportError("L[%d].i_r2 out of sync", i);
1077  }
1078  else
1079  {
1080  if (strat->L[i].i_r1 != -1)
1081  return dReportError("L[%d].i_r1 out of sync", i);
1082  if (strat->L[i].i_r2 != -1)
1083  return dReportError("L[%d].i_r2 out of sync", i);
1084  }
1085  if (strat->L[i].i_r != -1)
1086  return dReportError("L[%d].i_r out of sync", i);
1087  }
1088  return TRUE;
1089 }

◆ message()

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

Definition at line 7954 of file kutil.cc.

7955 {
7956  if (i != *olddeg)
7957  {
7958  Print("%d",i);
7959  *olddeg = i;
7960  }
7961  if (TEST_OPT_OLDSTD)
7962  {
7963  if (strat->Ll != *reduc)
7964  {
7965  if (strat->Ll != *reduc-1)
7966  Print("(%d)",strat->Ll+1);
7967  else
7968  PrintS("-");
7969  *reduc = strat->Ll;
7970  }
7971  else
7972  PrintS(".");
7973  mflush();
7974  }
7975  else
7976  {
7977  if (red_result == 0)
7978  PrintS("-");
7979  else if (red_result < 0)
7980  PrintS(".");
7981  if ((red_result > 0) || ((strat->Ll % 100)==99))
7982  {
7983  if (strat->Ll != *reduc && strat->Ll > 0)
7984  {
7985  Print("(%d)",strat->Ll+1);
7986  *reduc = strat->Ll;
7987  }
7988  }
7989  }
7990 }

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 8027 of file kutil.cc.

8028 {
8029  int i;
8030  if (strat->news)
8031  {
8032  PrintS("set S");
8033  for (i=0; i<=strat->sl; i++)
8034  {
8035  Print("\n %d:",i);
8036  p_wrp(strat->S[i], currRing, strat->tailRing);
8037  if (strat->fromQ!=NULL && strat->fromQ[i])
8038  Print(" (from Q)");
8039  }
8040  strat->news = FALSE;
8041  }
8042  if (strat->newt)
8043  {
8044  PrintS("\nset T");
8045  for (i=0; i<=strat->tl; i++)
8046  {
8047  Print("\n %d:",i);
8048  strat->T[i].wrp();
8049  if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
8050  Print(" o:%ld e:%d l:%d",
8051  strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
8052  }
8053  strat->newt = FALSE;
8054  }
8055  PrintS("\nset L");
8056  for (i=strat->Ll; i>=0; i--)
8057  {
8058  Print("\n%d:",i);
8059  p_wrp(strat->L[i].p1, currRing, strat->tailRing);
8060  PrintS(" ");
8061  p_wrp(strat->L[i].p2, currRing, strat->tailRing);
8062  PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
8063  PrintS("\n p : ");
8064  strat->L[i].wrp();
8065  Print(" o:%ld e:%d l:%d",
8066  strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
8067  }
8068  PrintLn();
8069 }

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7995 of file kutil.cc.

7996 {
7997  //PrintS("\nUsage/Allocation of temporary storage:\n");
7998  //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7999  //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
8000  Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
8001  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
8002  #ifdef HAVE_SHIFTBBA
8003  /* in usual case strat->cv is 0, it gets changed only in shift routines */
8004  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
8005  #endif
8006 }

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 8008 of file kutil.cc.

8009 {
8010  //PrintS("\nUsage/Allocation of temporary storage:\n");
8011  //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
8012  //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
8013  Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
8014  //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
8015  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
8016  #ifdef HAVE_SHIFTBBA
8017  /* in usual case strat->cv is 0, it gets changed only in shift routines */
8018  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
8019  #endif
8020 }
int nrsyzcrit
Definition: kutil.h:359

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10867 of file kutil.cc.

10868 {
10869  if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10870  return FALSE;
10871  int i,j;
10872  poly newNoether;
10873 
10874 #if 0
10875  if (currRing->weight_all_1)
10876  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10877  else
10878  scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10879 #else
10880  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10881 #endif
10882  if (strat->kHEdge==NULL) return FALSE;
10883  if (strat->t_kHEdge != NULL) p_LmFree(strat->t_kHEdge, strat->tailRing);
10884  if (strat->tailRing != currRing)
10885  strat->t_kHEdge = k_LmInit_currRing_2_tailRing(strat->kHEdge, strat->tailRing);
10886  /* compare old and new noether*/
10887  newNoether = pLmInit(strat->kHEdge);
10888  pSetCoeff0(newNoether,nInit(1));
10889  j = p_FDeg(newNoether,currRing);
10890  for (i=1; i<=(currRing->N); i++)
10891  {
10892  if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10893  }
10894  pSetm(newNoether);
10895  if (j < strat->HCord) /*- statistics -*/
10896  {
10897  if (TEST_OPT_PROT)
10898  {
10899  Print("H(%d)",j);
10900  mflush();
10901  }
10902  strat->HCord=j;
10903  #ifdef KDEBUG
10904  if (TEST_OPT_DEBUG)
10905  {
10906  Print("H(%d):",j);
10907  wrp(strat->kHEdge);
10908  PrintLn();
10909  }
10910  #endif
10911  }
10912  if (pCmp(strat->kNoether,newNoether)!=1)
10913  {
10914  if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether);
10915  strat->kNoether=newNoether;
10916  if (strat->t_kNoether != NULL) p_LmFree(strat->t_kNoether, strat->tailRing);
10917  if (strat->tailRing != currRing)
10918  strat->t_kNoether = k_LmInit_currRing_2_tailRing(strat->kNoether, strat->tailRing);
10919 
10920  return TRUE;
10921  }
10922  pLmDelete(newNoether);
10923  return FALSE;
10924 }
int HCord
Definition: kutil.h:353
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1004
VAR int HCord
Definition: kutil.cc:236
#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 12116 of file kutil.cc.

12117 {
12118  /* restores a poly in currRing from LObject */
12119  LObject h = H;
12120  h.Copy();
12121  poly p;
12122  if (h.p == NULL)
12123  {
12124  if (h.t_p != NULL)
12125  {
12126  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
12127  return(p);
12128  }
12129  else
12130  {
12131  /* h.tp == NULL -> the object is NULL */
12132  return(NULL);
12133  }
12134  }
12135  /* we're here if h.p != NULL */
12136  if (h.t_p == NULL)
12137  {
12138  /* then h.p is the whole poly in currRing */
12139  p = h.p;
12140  return(p);
12141  }
12142  /* we're here if h.p != NULL and h.t_p != NULL */
12143  // clean h.p, get poly from t_p
12144  pNext(h.p)=NULL;
12145  pLmDelete(&h.p);
12146  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
12147  /* dest. ring: */ currRing);
12148  // no need to clean h: we re-used the polys
12149  return(p);
12150 }
CanonicalForm H
Definition: facAbsFact.cc:64
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89

◆ pMove2CurrTail()

poly pMove2CurrTail ( poly  p,
kStrategy  strat 
)

Definition at line 12085 of file kutil.cc.

12086 {
12087  /* assume: p is completely in currRing */
12088  /* produces an object with LM in curring
12089  and TAIL in tailring */
12090  if (pNext(p)!=NULL)
12091  {
12092  pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
12093  }
12094  return(p);
12095 }

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 12099 of file kutil.cc.

12100 {
12101  /* assume: p has LM in curring and TAIL in tailring */
12102  /* convert it to complete currRing */
12103 
12104  /* check that LM is in currRing */
12106 
12107  if (pNext(p)!=NULL)
12108  {
12109  pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
12110  }
12111  return(p);
12112 }

◆ posInIdealMonFirst()

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

Definition at line 5213 of file kutil.cc.

5214 {
5215  if(end < 0 || end >= IDELEMS(F))
5216  end = IDELEMS(F);
5217  if (end<0) return 0;
5218  if(pNext(p) == NULL) return start;
5219  polyset set=F->m;
5220  int o = p_Deg(p,currRing);
5221  int op;
5222  int i;
5223  int an = start;
5224  for(i=start;i<end;i++)
5225  if(set[i] != NULL && pNext(set[i]) == NULL)
5226  an++;
5227  if(an == end-1)
5228  return end;
5229  int en= end;
5230  loop
5231  {
5232  if(an>=en)
5233  return en;
5234  if (an == en-1)
5235  {
5236  op = p_Deg(set[an],currRing);
5237  if ((op < o)
5238  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5239  return en;
5240  return an;
5241  }
5242  i=(an+en) / 2;
5243  op = p_Deg(set[i],currRing);
5244  if ((op < o)
5245  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5246  an=i;
5247  else
5248  en=i;
5249  }
5250 }
poly * polyset
Definition: polys.h:255

◆ posInL0()

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

Definition at line 6065 of file kutil.cc.

6067 {
6068  if (length<0) return 0;
6069 
6070  if (pLmCmp(set[length].p,p->p)== currRing->OrdSgn)
6071  return length+1;
6072 
6073  int i;
6074  int an = 0;
6075  int en= length;
6076  loop
6077  {
6078  if (an >= en-1)
6079  {
6080  if (pLmCmp(set[an].p,p->p) == currRing->OrdSgn) return en;
6081  return an;
6082  }
6083  i=(an+en) / 2;
6084  if (pLmCmp(set[i].p,p->p) == currRing->OrdSgn) an=i;
6085  else en=i;
6086  /*aend. fuer lazy == in !=- machen */
6087  }
6088 }

◆ posInL10()

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

Definition at line 1006 of file kstd1.cc.

1007 {
1008  int j,dp,dL;
1009 
1010  if (length<0) return 0;
1011  if (hasPurePower(p,strat->lastAxis,&dp,strat))
1012  {
1013  int op= p->GetpFDeg() +p->ecart;
1014  for (j=length; j>=0; j--)
1015  {
1016  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1017  return j+1;
1018  if (dp < dL)
1019  return j+1;
1020  if ((dp == dL)
1021  && (set[j].GetpFDeg()+set[j].ecart >= op))
1022  return j+1;
1023  }
1024  }
1025  j=length;
1026  loop
1027  {
1028  if (j<0) break;
1029  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1030  j--;
1031  }
1032  return strat->posInLOld(set,j,p,strat);
1033 }
int lastAxis
Definition: kutil.h:354
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition: kutil.h:284
BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition: kstd1.cc:958

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

6325 {
6326  if (length<0) return 0;
6327 
6328  int o = p->GetpFDeg();
6329  int op = set[length].GetpFDeg();
6330 
6331  if ((op > o)
6332  || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6333  return length+1;
6334  int i;
6335  int an = 0;
6336  int en= length;
6337  loop
6338  {
6339  if (an >= en-1)
6340  {
6341  op = set[an].GetpFDeg();
6342  if ((op > o)
6343  || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6344  return en;
6345  return an;
6346  }
6347  i=(an+en) / 2;
6348  op = set[i].GetpFDeg();
6349  if ((op > o)
6350  || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6351  an=i;
6352  else
6353  en=i;
6354  }
6355 }

◆ posInL110()

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

Definition at line 6621 of file kutil.cc.

6623 {
6624  if (length<0) return 0;
6625 
6626  int o = p->GetpFDeg();
6627  int op = set[length].GetpFDeg();
6628 
6629  if ((op > o)
6630  || ((op == o) && (set[length].length >p->length))
6631  || ((op == o) && (set[length].length <= p->length)
6632  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6633  return length+1;
6634  int i;
6635  int an = 0;
6636  int en= length;
6637  loop
6638  {
6639  if (an >= en-1)
6640  {
6641  op = set[an].GetpFDeg();
6642  if ((op > o)
6643  || ((op == o) && (set[an].length >p->length))
6644  || ((op == o) && (set[an].length <=p->length)
6645  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6646  return en;
6647  return an;
6648  }
6649  i=(an+en) / 2;
6650  op = set[i].GetpFDeg();
6651  if ((op > o)
6652  || ((op == o) && (set[i].length > p->length))
6653  || ((op == o) && (set[i].length <= p->length)
6654  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6655  an=i;
6656  else
6657  en=i;
6658  }
6659 }

◆ posInL11Ring()

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

Definition at line 6365 of file kutil.cc.

6367 {
6368  if (length<0) return 0;
6369 
6370  int o = p->GetpFDeg();
6371  int op = set[length].GetpFDeg();
6372 
6373  if ((op > o)
6374  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6375  return length+1;
6376  int i;
6377  int an = 0;
6378  int en= length;
6379  loop
6380  {
6381  if (an >= en-1)
6382  {
6383  op = set[an].GetpFDeg();
6384  if ((op > o)
6385  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6386  return en;
6387  return an;
6388  }
6389  i=(an+en) / 2;
6390  op = set[i].GetpFDeg();
6391  if ((op > o)
6392  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6393  an=i;
6394  else
6395  en=i;
6396  }
6397 }
#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 6435 of file kutil.cc.

6437 {
6438  if (length < 0) return 0;
6439  int an,en,i;
6440  an = 0;
6441  en = length+1;
6442  loop
6443  {
6444  if (an >= en-1)
6445  {
6446  if(an == en)
6447  return en;
6448  if (set[an].FDeg > p->FDeg)
6449  return en;
6450  if (set[an].FDeg < p->FDeg)
6451  return an;
6452  if (set[an].FDeg == p->FDeg)
6453  {
6454  number lcset,lcp;
6455  lcset = pGetCoeff(set[an].p);
6456  lcp = pGetCoeff(p->p);
6457  if(!nGreaterZero(lcset))
6458  {
6459  set[an].p=p_Neg(set[an].p,currRing);
6460  if (set[an].t_p!=NULL)
6461  pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
6462  lcset=pGetCoeff(set[an].p);
6463  }
6464  if(!nGreaterZero(lcp))
6465  {
6466  p->p=p_Neg(p->p,currRing);
6467  if (p->t_p!=NULL)
6468  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6469  lcp=pGetCoeff(p->p);
6470  }
6471  if(nGreater(lcset, lcp))
6472  {
6473  return en;
6474  }
6475  else
6476  {
6477  return an;
6478  }
6479  }
6480  }
6481  i=(an+en) / 2;
6482  if (set[i].FDeg > p->FDeg)
6483  an=i;
6484  if (set[i].FDeg < p->FDeg)
6485  en=i;
6486  if (set[i].FDeg == p->FDeg)
6487  {
6488  number lcset,lcp;
6489  lcset = pGetCoeff(set[i].p);
6490  lcp = pGetCoeff(p->p);
6491  if(!nGreaterZero(lcset))
6492  {
6493  set[i].p=p_Neg(set[i].p,currRing);
6494  if (set[i].t_p!=NULL)
6495  pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6496  lcset=pGetCoeff(set[i].p);
6497  }
6498  if(!nGreaterZero(lcp))
6499  {
6500  p->p=p_Neg(p->p,currRing);
6501  if (p->t_p!=NULL)
6502  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6503  lcp=pGetCoeff(p->p);
6504  }
6505  if(nGreater(lcset, lcp))
6506  {
6507  an = i;
6508  }
6509  else
6510  {
6511  en = i;
6512  }
6513  }
6514  }
6515 }
#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 6709 of file kutil.cc.

6711 {
6712  if (length<0) return 0;
6713 
6714  int o = p->GetpFDeg();
6715 
6716  if (set[length].GetpFDeg() > o)
6717  return length+1;
6718 
6719  int i;
6720  int an = 0;
6721  int en= length;
6722  loop
6723  {
6724  if (an >= en-1)
6725  {
6726  if (set[an].GetpFDeg() >= o)
6727  return en;
6728  return an;
6729  }
6730  i=(an+en) / 2;
6731  if (set[i].GetpFDeg() >= o)
6732  an=i;
6733  else
6734  en=i;
6735  }
6736 }

◆ posInL15()

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

Definition at line 6744 of file kutil.cc.

6746 {
6747  if (length<0) return 0;
6748 
6749  int o = p->GetpFDeg() + p->ecart;
6750  int op = set[length].GetpFDeg() + set[length].ecart;
6751 
6752  if ((op > o)
6753  || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6754  return length+1;
6755  int i;
6756  int an = 0;
6757  int en= length;
6758  loop
6759  {
6760  if (an >= en-1)
6761  {
6762  op = set[an].GetpFDeg() + set[an].ecart;
6763  if ((op > o)
6764  || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6765  return en;
6766  return an;
6767  }
6768  i=(an+en) / 2;
6769  op = set[i].GetpFDeg() + set[i].ecart;
6770  if ((op > o)
6771  || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6772  an=i;
6773  else
6774  en=i;
6775  }
6776 }

◆ posInL15Ring()

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

Definition at line 6779 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6820 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 6311 of file kutil.cc.

6313 {
6314  return strat->Ll+1;
6315 }

◆ posInLF5CRing()

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

Definition at line 6399 of file kutil.cc.

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

◆ posInLRing()

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

Definition at line 6210 of file kutil.cc.

6212 {
6213  if (length < 0) return 0;
6214  if (set[length].FDeg > p->FDeg)
6215  return length+1;
6216  if (set[length].FDeg == p->FDeg)
6217  if(set[length].GetpLength() > p->GetpLength())
6218  return length+1;
6219  int i;
6220  int an = 0;
6221  int en= length+1;
6222  loop
6223  {
6224  if (an >= en-1)
6225  {
6226  if(an == en)
6227  return en;
6228  if (set[an].FDeg > p->FDeg)
6229  return en;
6230  if(set[an].FDeg == p->FDeg)
6231  {
6232  if(set[an].GetpLength() > p->GetpLength())
6233  return en;
6234  else
6235  {
6236  if(set[an].GetpLength() == p->GetpLength())
6237  {
6238  if(nGreater(set[an].p->coef, p->p->coef))
6239  return en;
6240  else
6241  return an;
6242  }
6243  else
6244  {
6245  return an;
6246  }
6247  }
6248  }
6249  else
6250  return an;
6251  }
6252  i=(an+en) / 2;
6253  if (set[i].FDeg > p->FDeg)
6254  an=i;
6255  else
6256  {
6257  if(set[i].FDeg == p->FDeg)
6258  {
6259  if(set[i].GetpLength() > p->GetpLength())
6260  an=i;
6261  else
6262  {
6263  if(set[i].GetpLength() == p->GetpLength())
6264  {
6265  if(nGreater(set[i].p->coef, p->p->coef))
6266  an = i;
6267  else
6268  en = i;
6269  }
6270  else
6271  {
6272  en=i;
6273  }
6274  }
6275  }
6276  else
6277  en=i;
6278  }
6279  }
6280 }

◆ posInLSig()

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

Definition at line 6123 of file kutil.cc.

6125 {
6126  if (length<0) return 0;
6127  if (pLtCmp(set[length].sig,p->sig)== currRing->OrdSgn)
6128  return length+1;
6129 
6130  int i;
6131  int an = 0;
6132  int en= length;
6133  loop
6134  {
6135  if (an >= en-1)
6136  {
6137  if (pLtCmp(set[an].sig,p->sig) == currRing->OrdSgn) return en;
6138  return an;
6139  }
6140  i=(an+en) / 2;
6141  if (pLtCmp(set[i].sig,p->sig) == currRing->OrdSgn) an=i;
6142  else en=i;
6143  /*aend. fuer lazy == in !=- machen */
6144  }
6145 }

◆ posInLSigRing()

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

Definition at line 6147 of file kutil.cc.

6149 {
6150  assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
6151  if (length<0) return 0;
6152  if (pLtCmp(set[length].sig,p->sig)== 1)
6153  return length+1;
6154 
6155  int an,en,i;
6156  an = 0;
6157  en = length+1;
6158  int cmp;
6159  loop
6160  {
6161  if (an >= en-1)
6162  {
6163  if(an == en)
6164  return en;
6165  cmp = pLtCmp(set[an].sig,p->sig);
6166  if (cmp == 1)
6167  return en;
6168  if (cmp == -1)
6169  return an;
6170  if (cmp == 0)
6171  {
6172  if (set[an].FDeg > p->FDeg)
6173  return en;
6174  if (set[an].FDeg < p->FDeg)
6175  return an;
6176  if (set[an].FDeg == p->FDeg)
6177  {
6178  cmp = pLtCmp(set[an].p,p->p);
6179  if(cmp == 1)
6180  return en;
6181  else
6182  return an;
6183  }
6184  }
6185  }
6186  i=(an+en) / 2;
6187  cmp = pLtCmp(set[i].sig,p->sig);
6188  if (cmp == 1)
6189  an = i;
6190  if (cmp == -1)
6191  en = i;
6192  if (cmp == 0)
6193  {
6194  if (set[i].FDeg > p->FDeg)
6195  an = i;
6196  if (set[i].FDeg < p->FDeg)
6197  en = i;
6198  if (set[i].FDeg == p->FDeg)
6199  {
6200  cmp = pLtCmp(set[i].p,p->p);
6201  if(cmp == 1)
6202  an = i;
6203  else
6204  en = i;
6205  }
6206  }
6207  }
6208 }

◆ posInS()

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

Definition at line 5035 of file kutil.cc.

5037 {
5038  if(length==-1) return 0;
5039  polyset set=strat->S;
5040  int i;
5041  int an = 0;
5042  int en = length;
5043  int cmp_int = currRing->OrdSgn;
5045 #ifdef HAVE_PLURAL
5046  && (currRing->real_var_start==0)
5047 #endif
5048 #if 0
5049  || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
5050 #endif
5051  )
5052  {
5053  int o=p_Deg(p,currRing);
5054  int oo=p_Deg(set[length],currRing);
5055 
5056  if ((oo<o)
5057  || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
5058  return length+1;
5059 
5060  loop
5061  {
5062  if (an >= en-1)
5063  {
5064  if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
5065  {
5066  return an;
5067  }
5068  return en;
5069  }
5070  i=(an+en) / 2;
5071  if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
5072  else an=i;
5073  }
5074  }
5075  else
5076  {
5077  if (rField_is_Ring(currRing))
5078  {
5079  if (pLmCmp(set[length],p)== -cmp_int)
5080  return length+1;
5081  int cmp;
5082  loop
5083  {
5084  if (an >= en-1)
5085  {
5086  cmp = pLmCmp(set[an],p);
5087  if (cmp == cmp_int) return an;
5088  if (cmp == -cmp_int) return en;
5089  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
5090  return an;
5091  }
5092  i = (an+en) / 2;
5093  cmp = pLmCmp(set[i],p);
5094  if (cmp == cmp_int) en = i;
5095  else if (cmp == -cmp_int) an = i;
5096  else
5097  {
5098  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
5099  else en = i;
5100  }
5101  }
5102  }
5103  else
5104  if (pLmCmp(set[length],p)== -cmp_int)
5105  return length+1;
5106 
5107  loop
5108  {
5109  if (an >= en-1)
5110  {
5111  if (pLmCmp(set[an],p) == cmp_int) return an;
5112  if (pLmCmp(set[an],p) == -cmp_int) return en;
5113  if ((cmp_int!=1)
5114  && ((strat->ecartS[an])>ecart_p))
5115  return an;
5116  return en;
5117  }
5118  i=(an+en) / 2;
5119  if (pLmCmp(set[i],p) == cmp_int) en=i;
5120  else if (pLmCmp(set[i],p) == -cmp_int) an=i;
5121  else
5122  {
5123  if ((cmp_int!=1)
5124  &&((strat->ecartS[i])<ecart_p))
5125  en=i;
5126  else
5127  an=i;
5128  }
5129  }
5130  }
5131 }

◆ posInSMonFirst()

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

Definition at line 5136 of file kutil.cc.

5137 {
5138  if (length<0) return 0;
5139  polyset set=strat->S;
5140  if(pNext(p) == NULL)
5141  {
5142  int mon = 0;
5143  for(int i = 0;i<=length;i++)
5144  {
5145  if(set[i] != NULL && pNext(set[i]) == NULL)
5146  mon++;
5147  }
5148  int o = p_Deg(p,currRing);
5149  int op = p_Deg(set[mon],currRing);
5150 
5151  if ((op < o)
5152  || ((op == o) && (pLtCmp(set[mon],p) == -1)))
5153  return length+1;
5154  int i;
5155  int an = 0;
5156  int en= mon;
5157  loop
5158  {
5159  if (an >= en-1)
5160  {
5161  op = p_Deg(set[an],currRing);
5162  if ((op < o)
5163  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5164  return en;
5165  return an;
5166  }
5167  i=(an+en) / 2;
5168  op = p_Deg(set[i],currRing);
5169  if ((op < o)
5170  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5171  an=i;
5172  else
5173  en=i;
5174  }
5175  }
5176  else /*if(pNext(p) != NULL)*/
5177  {
5178  int o = p_Deg(p,currRing);
5179  int op = p_Deg(set[length],currRing);
5180 
5181  if ((op < o)
5182  || ((op == o) && (pLtCmp(set[length],p) == -1)))
5183  return length+1;
5184  int i;
5185  int an = 0;
5186  for(i=0;i<=length;i++)
5187  if(set[i] != NULL && pNext(set[i]) == NULL)
5188  an++;
5189  int en= length;
5190  loop
5191  {
5192  if (an >= en-1)
5193  {
5194  op = p_Deg(set[an],currRing);
5195  if ((op < o)
5196  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5197  return en;
5198  return an;
5199  }
5200  i=(an+en) / 2;
5201  op = p_Deg(set[i],currRing);
5202  if ((op < o)
5203  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5204  an=i;
5205  else
5206  en=i;
5207  }
5208  }
5209 }

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 6283 of file kutil.cc.

6284 {
6285  if (strat->syzl==0) return 0;
6286  if (pLtCmp(strat->syz[strat->syzl-1],sig) != currRing->OrdSgn)
6287  return strat->syzl;
6288  int i;
6289  int an = 0;
6290  int en= strat->syzl-1;
6291  loop
6292  {
6293  if (an >= en-1)
6294  {
6295  if (pLtCmp(strat->syz[an],sig) != currRing->OrdSgn) return en;
6296  return an;
6297  }
6298  i=(an+en) / 2;
6299  if (pLtCmp(strat->syz[i],sig) != currRing->OrdSgn) an=i;
6300  else en=i;
6301  /*aend. fuer lazy == in !=- machen */
6302  }
6303 }

◆ posInT0()

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

Definition at line 5257 of file kutil.cc.

5258 {
5259  return (length+1);
5260 }

◆ posInT1()

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

Definition at line 5268 of file kutil.cc.

5269 {
5270  if (length==-1) return 0;
5271 
5272  if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
5273 
5274  int i;
5275  int an = 0;
5276  int en= length;
5277 
5278  loop
5279  {
5280  if (an >= en-1)
5281  {
5282  if (pLmCmp(set[an].p,p.p) == currRing->OrdSgn) return an;
5283  return en;
5284  }
5285  i=(an+en) / 2;
5286  if (pLmCmp(set[i].p,p.p) == currRing->OrdSgn) en=i;
5287  else an=i;
5288  }
5289 }

◆ posInT11()

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

Definition at line 5326 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5479 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5568 of file kutil.cc.

5569 {
5570  if (length==-1) return 0;
5571 
5572  int o = p.GetpFDeg();
5573 
5574  if (set[length].GetpFDeg() <= o)
5575  return length+1;
5576 
5577  int i;
5578  int an = 0;
5579  int en= length;
5580  loop
5581  {
5582  if (an >= en-1)
5583  {
5584  if (set[an].GetpFDeg() > o)
5585  return an;
5586  return en;
5587  }
5588  i=(an+en) / 2;
5589  if (set[i].GetpFDeg() > o)
5590  en=i;
5591  else
5592  an=i;
5593  }
5594 }

◆ posInT15()

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

Definition at line 5636 of file kutil.cc.

5655 {
5656  if (length==-1) return 0;
5657 
5658  int o = p.GetpFDeg() + p.ecart;
5659  int op = set[length].GetpFDeg()+set[length].ecart;
5660 
5661  if ((op < o)
5662  || ((op == o)
5663  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5664  return length+1;
5665 
5666  int i;
5667  int an = 0;
5668  int en= length;
5669  loop
5670  {
5671  if (an >= en-1)
5672  {
5673  op = set[an].GetpFDeg()+set[an].ecart;
5674  if (( op > o)
5675  || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5676  return an;
5677  return en;
5678  }
5679  i=(an+en) / 2;
5680  op = set[i].GetpFDeg()+set[i].ecart;
5681  if (( op > o)
5682  || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5683  en=i;
5684  else
5685  an=i;
5686  }
5687 }

◆ posInT17()

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

Definition at line 5731 of file kutil.cc.

5752 {
5753  if (length==-1) return 0;
5754 
5755  int o = p.GetpFDeg() + p.ecart;
5756  int op = set[length].GetpFDeg()+set[length].ecart;
5757 
5758  if ((op < o)
5759  || (( op == o) && (set[length].ecart > p.ecart))
5760  || (( op == o) && (set[length].ecart==p.ecart)
5761  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5762  return length+1;
5763 
5764  int i;
5765  int an = 0;
5766  int en= length;
5767  loop
5768  {
5769  if (an >= en-1)
5770  {
5771  op = set[an].GetpFDeg()+set[an].ecart;
5772  if (( op > o)
5773  || (( op == o) && (set[an].ecart < p.ecart))
5774  || (( op == o) && (set[an].ecart==p.ecart)
5775  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5776  return an;
5777  return en;
5778  }
5779  i=(an+en) / 2;
5780  op = set[i].GetpFDeg()+set[i].ecart;
5781  if ((op > o)
5782  || (( op == o) && (set[i].ecart < p.ecart))
5783  || (( op == o) && (set[i].ecart == p.ecart)
5784  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5785  en=i;
5786  else
5787  an=i;
5788  }
5789 }

◆ posInT17_c()

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

Definition at line 5838 of file kutil.cc.

5839 {
5840  if (length==-1) return 0;
5841 
5842  int cc = (-1+2*currRing->order[0]==ringorder_c);
5843  /* cc==1 for (c,..), cc==-1 for (C,..) */
5844  int o = p.GetpFDeg() + p.ecart;
5845  int c = pGetComp(p.p)*cc;
5846 
5847  if (pGetComp(set[length].p)*cc < c)
5848  return length+1;
5849  if (pGetComp(set[length].p)*cc == c)
5850  {
5851  int op = set[length].GetpFDeg()+set[length].ecart;
5852  if ((op < o)
5853  || ((op == o) && (set[length].ecart > p.ecart))
5854  || ((op == o) && (set[length].ecart==p.ecart)
5855  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5856  return length+1;
5857  }
5858 
5859  int i;
5860  int an = 0;
5861  int en= length;
5862  loop
5863  {
5864  if (an >= en-1)
5865  {
5866  if (pGetComp(set[an].p)*cc < c)
5867  return en;
5868  if (pGetComp(set[an].p)*cc == c)
5869  {
5870  int op = set[an].GetpFDeg()+set[an].ecart;
5871  if ((op > o)
5872  || ((op == o) && (set[an].ecart < p.ecart))
5873  || ((op == o) && (set[an].ecart==p.ecart)
5874  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5875  return an;
5876  }
5877  return en;
5878  }
5879  i=(an+en) / 2;
5880  if (pGetComp(set[i].p)*cc > c)
5881  en=i;
5882  else if (pGetComp(set[i].p)*cc == c)
5883  {
5884  int op = set[i].GetpFDeg()+set[i].ecart;
5885  if ((op > o)
5886  || ((op == o) && (set[i].ecart < p.ecart))
5887  || ((op == o) && (set[i].ecart == p.ecart)
5888  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5889  en=i;
5890  else
5891  an=i;
5892  }
5893  else
5894  an=i;
5895  }
5896 }

◆ posInT19()

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

Definition at line 5965 of file kutil.cc.

5966 {
5967  p.GetpLength();
5968  if (length==-1) return 0;
5969 
5970  int o = p.ecart;
5971  int op=p.GetpFDeg();
5972 
5973  if (set[length].ecart < o)
5974  return length+1;
5975  if (set[length].ecart == o)
5976  {
5977  int oo=set[length].GetpFDeg();
5978  if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5979  return length+1;
5980  }
5981 
5982  int i;
5983  int an = 0;
5984  int en= length;
5985  loop
5986  {
5987  if (an >= en-1)
5988  {
5989  if (set[an].ecart > o)
5990  return an;
5991  if (set[an].ecart == o)
5992  {
5993  int oo=set[an].GetpFDeg();
5994  if((oo > op)
5995  || ((oo==op) && (set[an].length > p.length)))
5996  return an;
5997  }
5998  return en;
5999  }
6000  i=(an+en) / 2;
6001  if (set[i].ecart > o)
6002  en=i;
6003  else if (set[i].ecart == o)
6004  {
6005  int oo=set[i].GetpFDeg();
6006  if ((oo > op)
6007  || ((oo == op) && (set[i].length > p.length)))
6008  en=i;
6009  else
6010  an=i;
6011  }
6012  else
6013  an=i;
6014  }
6015 }

◆ posInT2()

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

Definition at line 5296 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11824 of file kutil.cc.

11825 {
11826 
11827  if (length==-1) return 0;
11828 
11829  int o = p.ecart;
11830  int op=p.GetpFDeg();
11831  int ol = p.GetpLength();
11832 
11833  if (set[length].ecart < o)
11834  return length+1;
11835  if (set[length].ecart == o)
11836  {
11837  int oo=set[length].GetpFDeg();
11838  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11839  return length+1;
11840  }
11841 
11842  int i;
11843  int an = 0;
11844  int en= length;
11845  loop
11846  {
11847  if (an >= en-1)
11848  {
11849  if (set[an].ecart > o)
11850  return an;
11851  if (set[an].ecart == o)
11852  {
11853  int oo=set[an].GetpFDeg();
11854  if((oo > op)
11855  || ((oo==op) && (set[an].pLength > ol)))
11856  return an;
11857  }
11858  return en;
11859  }
11860  i=(an+en) / 2;
11861  if (set[i].ecart > o)
11862  en=i;
11863  else if (set[i].ecart == o)
11864  {
11865  int oo=set[i].GetpFDeg();
11866  if ((oo > op)
11867  || ((oo == op) && (set[i].pLength > ol)))
11868  en=i;
11869  else
11870  an=i;
11871  }
11872  else
11873  an=i;
11874  }
11875 }

◆ posInT_EcartpLength()

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

Definition at line 5597 of file kutil.cc.

5598 {
5599  int ol = p.GetpLength();
5600  if (length==-1) return 0;
5601 
5602  int op=p.ecart;
5603 
5604  int oo=set[length].ecart;
5605  if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5606  return length+1;
5607 
5608  int i;
5609  int an = 0;
5610  int en= length;
5611  loop
5612  {
5613  if (an >= en-1)
5614  {
5615  int oo=set[an].ecart;
5616  if((oo > op)
5617  || ((oo==op) && (set[an].pLength > ol)))
5618  return an;
5619  return en;
5620  }
5621  i=(an+en) / 2;
5622  int oo=set[i].ecart;
5623  if ((oo > op)
5624  || ((oo == op) && (set[i].pLength > ol)))
5625  en=i;
5626  else
5627  an=i;
5628  }
5629 }

◆ posInT_FDegpLength()

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

Definition at line 11878 of file kutil.cc.

11879 {
11880 
11881  if (length==-1) return 0;
11882 
11883  int op=p.GetpFDeg();
11884  int ol = p.GetpLength();
11885 
11886  int oo=set[length].GetpFDeg();
11887  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11888  return length+1;
11889 
11890  int i;
11891  int an = 0;
11892  int en= length;
11893  loop
11894  {
11895  if (an >= en-1)
11896  {
11897  int oo=set[an].GetpFDeg();
11898  if((oo > op)
11899  || ((oo==op) && (set[an].pLength > ol)))
11900  return an;
11901  return en;
11902  }
11903  i=(an+en) / 2;
11904  int oo=set[i].GetpFDeg();
11905  if ((oo > op)
11906  || ((oo == op) && (set[i].pLength > ol)))
11907  en=i;
11908  else
11909  an=i;
11910  }
11911 }

◆ posInT_pLength()

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

Definition at line 11915 of file kutil.cc.

11916 {
11917  int ol = p.GetpLength();
11918  if (length==-1)
11919  return 0;
11920  if (set[length].length<p.length)
11921  return length+1;
11922 
11923  int i;
11924  int an = 0;
11925  int en= length;
11926 
11927  loop
11928  {
11929  if (an >= en-1)
11930  {
11931  if (set[an].pLength>ol) return an;
11932  return en;
11933  }
11934  i=(an+en) / 2;
11935  if (set[i].pLength>ol) en=i;
11936  else an=i;
11937  }
11938 }

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

11162 {
11163  if(!nCoeff_is_Z(currRing->cf))
11164  return;
11165  poly pH = h->GetP();
11166  poly p,pp;
11167  p = pH;
11168  bool deleted = FALSE, ok = FALSE;
11169  for(int i = 0; i<=strat->sl; i++)
11170  {
11171  p = pH;
11172  if(pNext(strat->S[i]) == NULL)
11173  {
11174  //pWrite(p);
11175  //pWrite(strat->S[i]);
11176  while(ok == FALSE && p != NULL)
11177  {
11178  if(pLmDivisibleBy(strat->S[i], p))
11179  {
11180  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11181  p_SetCoeff(p,dummy,currRing);
11182  }
11183  if(nIsZero(p->coef))
11184  {
11185  pLmDelete(&p);
11186  h->p = p;
11187  deleted = TRUE;
11188  }
11189  else
11190  {
11191  ok = TRUE;
11192  }
11193  }
11194  if (p!=NULL)
11195  {
11196  pp = pNext(p);
11197  while(pp != NULL)
11198  {
11199  if(pLmDivisibleBy(strat->S[i], pp))
11200  {
11201  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11202  p_SetCoeff(pp,dummy,currRing);
11203  if(nIsZero(pp->coef))
11204  {
11205  pLmDelete(&pNext(p));
11206  pp = pNext(p);
11207  deleted = TRUE;
11208  }
11209  else
11210  {
11211  p = pp;
11212  pp = pNext(p);
11213  }
11214  }
11215  else
11216  {
11217  p = pp;
11218  pp = pNext(p);
11219  }
11220  }
11221  }
11222  }
11223  }
11224  h->SetLmCurrRing();
11225  if((deleted)&&(h->p!=NULL))
11226  strat->initEcart(h);
11227 }

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 11229 of file kutil.cc.

11230 {
11231  if(!nCoeff_is_Z(currRing->cf))
11232  return;
11233  poly hSig = h->sig;
11234  poly pH = h->GetP();
11235  poly p,pp;
11236  p = pH;
11237  bool deleted = FALSE, ok = FALSE;
11238  for(int i = 0; i<=strat->sl; i++)
11239  {
11240  p = pH;
11241  if(pNext(strat->S[i]) == NULL)
11242  {
11243  while(ok == FALSE && p!=NULL)
11244  {
11245  if(pLmDivisibleBy(strat->S[i], p))
11246  {
11247  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11248  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11249  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11250  {
11251  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11252  p_SetCoeff(p,dummy,currRing);
11253  }
11254  pDelete(&sigMult);
11255  }
11256  if(nIsZero(p->coef))
11257  {
11258  pLmDelete(&p);
11259  h->p = p;
11260  deleted = TRUE;
11261  }
11262  else
11263  {
11264  ok = TRUE;
11265  }
11266  }
11267  if(p == NULL)
11268  return;
11269  pp = pNext(p);
11270  while(pp != NULL)
11271  {
11272  if(pLmDivisibleBy(strat->S[i], pp))
11273  {
11274  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11275  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11276  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11277  {
11278  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11279  p_SetCoeff(pp,dummy,currRing);
11280  if(nIsZero(pp->coef))
11281  {
11282  pLmDelete(&pNext(p));
11283  pp = pNext(p);
11284  deleted = TRUE;
11285  }
11286  else
11287  {
11288  p = pp;
11289  pp = pNext(p);
11290  }
11291  }
11292  else
11293  {
11294  p = pp;
11295  pp = pNext(p);
11296  }
11297  pDelete(&sigMult);
11298  }
11299  else
11300  {
11301  p = pp;
11302  pp = pNext(p);
11303  }
11304  }
11305  }
11306  }
11307  h->SetLmCurrRing();
11308  if(deleted)
11309  strat->initEcart(h);
11310 
11311 }
#define ppMult_mm(p, m)
Definition: polys.h:197
#define pDivideM(a, b)
Definition: polys.h:290

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

10995 {
10996  if(!nCoeff_is_Z(currRing->cf))
10997  return NULL;
10998  ideal F = idCopy(Forig);
10999  idSkipZeroes(F);
11000  poly pmon;
11001  ring origR = currRing;
11002  ideal monred = idInit(1,1);
11003  for(int i=0; i<idElem(F); i++)
11004  {
11005  if(pNext(F->m[i]) == NULL)
11006  idInsertPoly(monred, pCopy(F->m[i]));
11007  }
11008  int posconst = idPosConstant(F);
11009  if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
11010  {
11011  idDelete(&F);
11012  idDelete(&monred);
11013  return NULL;
11014  }
11015  int idelemQ = 0;
11016  if(Q!=NULL)
11017  {
11018  idelemQ = IDELEMS(Q);
11019  for(int i=0; i<idelemQ; i++)
11020  {
11021  if(pNext(Q->m[i]) == NULL)
11022  idInsertPoly(monred, pCopy(Q->m[i]));
11023  }
11024  idSkipZeroes(monred);
11025  posconst = idPosConstant(monred);
11026  //the constant, if found, will be from Q
11027  if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
11028  {
11029  pmon = pCopy(monred->m[posconst]);
11030  idDelete(&F);
11031  idDelete(&monred);
11032  return pmon;
11033  }
11034  }
11035  ring QQ_ring = rCopy0(currRing,FALSE);
11036  nKillChar(QQ_ring->cf);
11037  QQ_ring->cf = nInitChar(n_Q, NULL);
11038  rComplete(QQ_ring,1);
11039  QQ_ring = rAssure_c_dp(QQ_ring);
11040  rChangeCurrRing(QQ_ring);
11041  nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
11042  ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
11043  for(int i = 0, j = 0; i<IDELEMS(F); i++)
11044  II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
11045  for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
11046  II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
11047  ideal one = kStd(II, NULL, isNotHomog, NULL);
11048  idSkipZeroes(one);
11049  if(idIsConstant(one))
11050  {
11051  //one should be <1>
11052  for(int i = IDELEMS(II)-1; i>=0; i--)
11053  if(II->m[i] != NULL)
11054  II->m[i+1] = II->m[i];
11055  II->m[0] = pOne();
11056  ideal syz = idSyzygies(II, isNotHomog, NULL);
11057  poly integer = NULL;
11058  for(int i = IDELEMS(syz)-1;i>=0; i--)
11059  {
11060  if(pGetComp(syz->m[i]) == 1)
11061  {
11062  pSetComp(syz->m[i],0);
11063  if(pIsConstant(pHead(syz->m[i])))
11064  {
11065  integer = pHead(syz->m[i]);
11066  break;
11067  }
11068  }
11069  }
11070  rChangeCurrRing(origR);
11071  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
11072  pmon = prMapR(integer, nMap2, QQ_ring, origR);
11073  idDelete(&monred);
11074  idDelete(&F);
11075  id_Delete(&II,QQ_ring);
11076  id_Delete(&one,QQ_ring);
11077  id_Delete(&syz,QQ_ring);
11078  p_Delete(&integer,QQ_ring);
11079  rDelete(QQ_ring);
11080  return pmon;
11081  }
11082  else
11083  {
11084  if(idIs0(monred))
11085  {
11086  poly mindegmon = NULL;
11087  for(int i = 0; i<IDELEMS(one); i++)
11088  {
11089  if(pNext(one->m[i]) == NULL)
11090  {
11091  if(mindegmon == NULL)
11092  mindegmon = pCopy(one->m[i]);
11093  else
11094  {
11095  if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
11096  mindegmon = pCopy(one->m[i]);
11097  }
11098  }
11099  }
11100  if(mindegmon != NULL)
11101  {
11102  for(int i = IDELEMS(II)-1; i>=0; i--)
11103  if(II->m[i] != NULL)
11104  II->m[i+1] = II->m[i];
11105  II->m[0] = pCopy(mindegmon);
11106  ideal syz = idSyzygies(II, isNotHomog, NULL);
11107  bool found = FALSE;
11108  for(int i = IDELEMS(syz)-1;i>=0; i--)
11109  {
11110  if(pGetComp(syz->m[i]) == 1)
11111  {
11112  pSetComp(syz->m[i],0);
11113  if(pIsConstant(pHead(syz->m[i])))
11114  {
11115  pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
11116  found = TRUE;
11117  break;
11118  }
11119  }
11120  }
11121  id_Delete(&syz,QQ_ring);
11122  if (found == FALSE)
11123  {
11124  rChangeCurrRing(origR);
11125  idDelete(&monred);
11126  idDelete(&F);
11127  id_Delete(&II,QQ_ring);
11128  id_Delete(&one,QQ_ring);
11129  rDelete(QQ_ring);
11130  return NULL;
11131  }
11132  rChangeCurrRing(origR);
11133  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
11134  pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
11135  idDelete(&monred);
11136  idDelete(&F);
11137  id_Delete(&II,QQ_ring);
11138  id_Delete(&one,QQ_ring);
11139  id_Delete(&syz,QQ_ring);
11140  rDelete(QQ_ring);
11141  return pmon;
11142  }
11143  }
11144  }
11145  rChangeCurrRing(origR);
11146  idDelete(&monred);
11147  idDelete(&F);
11148  id_Delete(&II,QQ_ring);
11149  id_Delete(&one,QQ_ring);
11150  rDelete(QQ_ring);
11151  return NULL;
11152 }
@ 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:721
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:349
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:510
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition: ideals.cc:728
#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:2088
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:3398
ring rAssure_c_dp(const ring r)
Definition: ring.cc:4910
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1365
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
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 4485 of file kstd2.cc.

4486 {
4487  if (h->IsNull()) return 0;
4488 
4489  int at, reddeg,d;
4490  int pass = 0;
4491  int j = 0;
4492 
4493  if (! strat->homog)
4494  {
4495  d = h->GetpFDeg() + h->ecart;
4496  reddeg = strat->LazyDegree+d;
4497  }
4498  h->SetShortExpVector();
4499  loop
4500  {
4501  j = kFindDivisibleByInT(strat, h);
4502  if (j < 0)
4503  {
4504  h->SetDegStuffReturnLDeg(strat->LDegLast);
4505  return 1;
4506  }
4507 
4508  if (!TEST_OPT_INTSTRATEGY)
4509  strat->T[j].pNorm();
4510 #ifdef KDEBUG
4511  if (TEST_OPT_DEBUG)
4512  {
4513  PrintS("reduce ");
4514  h->wrp();
4515  PrintS(" with ");
4516  strat->T[j].wrp();
4517  }
4518 #endif
4519  ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, strat);
4520 
4521 #ifdef KDEBUG
4522  if (TEST_OPT_DEBUG)
4523  {
4524  PrintS("\nto ");
4525  wrp(h->p);
4526  PrintLn();
4527  }
4528 #endif
4529  if (h->IsNull())
4530  {
4531  kDeleteLcm(h);
4532  h->Clear();
4533  return 0;
4534  }
4535  h->SetShortExpVector();
4536 
4537 #if 0
4538  if ((strat->syzComp!=0) && !strat->honey)
4539  {
4540  if ((strat->syzComp>0) &&
4541  (h->Comp() > strat->syzComp))
4542  {
4543  assume(h->MinComp() > strat->syzComp);
4544 #ifdef KDEBUG
4545  if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
4546 #endif
4547  if (strat->homog)
4548  h->SetDegStuffReturnLDeg(strat->LDegLast);
4549  return -2;
4550  }
4551  }
4552 #endif
4553  if (!strat->homog)
4554  {
4555  if (!TEST_OPT_OLDSTD && strat->honey)
4556  {
4557  h->SetpFDeg();
4558  if (strat->T[j].ecart <= h->ecart)
4559  h->ecart = d - h->GetpFDeg();
4560  else
4561  h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
4562 
4563  d = h->GetpFDeg() + h->ecart;
4564  }
4565  else
4566  d = h->SetDegStuffReturnLDeg(strat->LDegLast);
4567  /*- try to reduce the s-polynomial -*/
4568  pass++;
4569  /*
4570  *test whether the polynomial should go to the lazyset L
4571  *-if the degree jumps
4572  *-if the number of pre-defined reductions jumps
4573  */
4574  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
4575  && ((d >= reddeg) || (pass > strat->LazyPass)))
4576  {
4577  h->SetLmCurrRing();
4578  if (strat->posInLDependsOnLength)
4579  h->SetLength(strat->length_pLength);
4580  at = strat->posInL(strat->L,strat->Ll,h,strat);
4581  if (at <= strat->Ll)
4582  {
4583  //int dummy=strat->sl;
4584  /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
4585  //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
4586  if (kFindDivisibleByInT(strat, h) < 0)
4587  return 1;
4588  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
4589 #ifdef KDEBUG
4590  if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
4591 #endif
4592  h->Clear();
4593  return -1;
4594  }
4595  }
4596  if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
4597  {
4598  reddeg = d+1;
4599  Print(".%d",d);mflush();
4600  }
4601  }
4602  }
4603 }
char length_pLength
Definition: kutil.h:386
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:216
#define TEST_OPT_REDTHROUGH
Definition: options.h:119

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 822 of file kstd2.cc.

823 {
824  if (strat->tl<0) return 1;
825  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
826  assume(h->FDeg == h->pFDeg());
827 
828  poly h_p;
829  int i,j,at,pass, ii;
830  unsigned long not_sev;
831  // long reddeg,d;
832 
833  pass = j = 0;
834  // d = reddeg = h->GetpFDeg();
835  h->SetShortExpVector();
836  int li;
837  h_p = h->GetLmTailRing();
838  not_sev = ~ h->sev;
839  loop
840  {
841  j = kFindDivisibleByInT(strat, h);
842  if (j < 0) return 1;
843 
844  li = strat->T[j].pLength;
845  if (li<=0) li=strat->T[j].GetpLength();
846  ii = j;
847  /*
848  * the polynomial to reduce with (up to the moment) is;
849  * pi with length li
850  */
851  i = j;
852 #if 1
853  if (TEST_OPT_LENGTH)
854  loop
855  {
856  /*- search the shortest possible with respect to length -*/
857  i++;
858  if (i > strat->tl)
859  break;
860  if (li==1)
861  break;
862  if ((strat->T[i].pLength < li)
863  &&
864  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
865  h_p, not_sev, strat->tailRing))
866  {
867  /*
868  * the polynomial to reduce with is now;
869  */
870  li = strat->T[i].pLength;
871  if (li<=0) li=strat->T[i].GetpLength();
872  ii = i;
873  }
874  }
875 #endif
876 
877  /*
878  * end of search: have to reduce with pi
879  */
880 #ifdef KDEBUG
881  if (TEST_OPT_DEBUG)
882  {
883  PrintS("red:");
884  h->wrp();
885  PrintS(" with ");
886  strat->T[ii].wrp();
887  }
888 #endif
889  assume(strat->fromT == FALSE);
890 
891  ksReducePoly(h, &(strat->T[ii]), NULL, NULL, strat);
892 #if SBA_PRINT_REDUCTION_STEPS
893  sba_interreduction_steps++;
894 #endif
895 #if SBA_PRINT_OPERATIONS
896  sba_interreduction_operations += pLength(strat->T[ii].p);
897 #endif
898 
899 #ifdef KDEBUG
900  if (TEST_OPT_DEBUG)
901  {
902  PrintS("\nto ");
903  h->wrp();
904  PrintLn();
905  }
906 #endif
907 
908  h_p = h->GetLmTailRing();
909  if (h_p == NULL)
910  {
911  kDeleteLcm(h);
912  return 0;
913  }
914  h->SetShortExpVector();
915  not_sev = ~ h->sev;
916  /*
917  * try to reduce the s-polynomial h
918  *test first whether h should go to the lazyset L
919  *-if the degree jumps
920  *-if the number of pre-defined reductions jumps
921  */
922  pass++;
923  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
924  {
925  h->SetLmCurrRing();
926  at = strat->posInL(strat->L,strat->Ll,h,strat);
927  if (at <= strat->Ll)
928  {
929  int dummy=strat->sl;
930  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
931  return 1;
932  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
933 #ifdef KDEBUG
934  if (TEST_OPT_DEBUG)
935  Print(" lazy: -> L%d\n",at);
936 #endif
937  h->Clear();
938  return -1;
939  }
940  }
941  }
942 }
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:326
#define TEST_OPT_LENGTH
Definition: options.h:127

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 1664 of file kstd2.cc.

1665 {
1666  if (strat->tl<0) return 1;
1667  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1668  assume(h->FDeg == h->pFDeg());
1669  poly h_p;
1670  int i,j,at,pass,ei, ii, h_d;
1671  unsigned long not_sev;
1672  long reddeg,d;
1673 
1674  pass = j = 0;
1675  d = reddeg = h->GetpFDeg() + h->ecart;
1676  h->SetShortExpVector();
1677  int li;
1678  h_p = h->GetLmTailRing();
1679  not_sev = ~ h->sev;
1680 
1681  h->PrepareRed(strat->use_buckets);
1682  loop
1683  {
1684  j=kFindDivisibleByInT(strat, h);
1685  if (j < 0) return 1;
1686 
1687  ei = strat->T[j].ecart;
1688  li = strat->T[j].pLength;
1689  if (li<=0) li=strat->T[j].GetpLength();
1690  ii = j;
1691  /*
1692  * the polynomial to reduce with (up to the moment) is;
1693  * pi with ecart ei (T[ii])
1694  */
1695  i = j;
1696  if (TEST_OPT_LENGTH)
1697  loop
1698  {
1699  /*- takes the first possible with respect to ecart -*/
1700  i++;
1701  if (i > strat->tl)
1702  break;
1703  //if (ei < h->ecart)
1704  // break;
1705  if (li==1)
1706  break;
1707  if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
1708  || ((strat->T[i].ecart <= h->ecart) && (strat->T[i].pLength < li)))
1709  &&
1710  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1711  h_p, not_sev, strat->tailRing))
1712  {
1713  /*
1714  * the polynomial to reduce with is now;
1715  */
1716  ei = strat->T[i].ecart;
1717  li = strat->T[i].pLength;
1718  if (li<=0) li=strat->T[i].GetpLength();
1719  ii = i;
1720  }
1721  }
1722 
1723  /*
1724  * end of search: have to reduce with pi
1725  */
1726  if (!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart))
1727  {
1728  h->GetTP(); // clears bucket
1729  h->SetLmCurrRing();
1730  /*
1731  * It is not possible to reduce h with smaller ecart;
1732  * if possible h goes to the lazy-set L,i.e
1733  * if its position in L would be not the last one
1734  */
1735  if (strat->Ll >= 0) /* L is not empty */
1736  {
1737  at = strat->posInL(strat->L,strat->Ll,h,strat);
1738  if(at <= strat->Ll)
1739  /*- h will not become the next element to reduce -*/
1740  {
1741  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1742 #ifdef KDEBUG
1743  if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
1744 #endif
1745  h->Clear();
1746  return -1;
1747  }
1748  }
1749  }
1750 #ifdef KDEBUG
1751  if (TEST_OPT_DEBUG)
1752  {
1753  PrintS("red:");
1754  h->wrp();
1755  Print("\nwith T[%d]:",ii);
1756  strat->T[ii].wrp();
1757  }
1758 #endif
1759  assume(strat->fromT == FALSE);
1760 
1761  ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,strat);
1762 #if SBA_PRINT_REDUCTION_STEPS
1763  sba_interreduction_steps++;
1764 #endif
1765 #if SBA_PRINT_OPERATIONS
1766  sba_interreduction_operations += pLength(strat->T[ii].p);
1767 #endif
1768 #ifdef KDEBUG
1769  if (TEST_OPT_DEBUG)
1770  {
1771  PrintS("\nto:");
1772  h->wrp();
1773  PrintLn();
1774  }
1775 #endif
1776  if(h->IsNull())
1777  {
1778  kDeleteLcm(h);
1779  h->Clear();
1780  return 0;
1781  }
1782  if (TEST_OPT_IDLIFT)
1783  {
1784  if (h->p!=NULL)
1785  {
1786  if(p_GetComp(h->p,currRing)>strat->syzComp)
1787  {
1788  h->Delete();
1789  return 0;
1790  }
1791  }
1792  else if (h->t_p!=NULL)
1793  {
1794  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1795  {
1796  h->Delete();
1797  return 0;
1798  }
1799  }
1800  }
1801  h->SetShortExpVector();
1802  not_sev = ~ h->sev;
1803  h_d = h->SetpFDeg();
1804  /* compute the ecart */
1805  if (ei <= h->ecart)
1806  h->ecart = d-h_d;
1807  else
1808  h->ecart = d-h_d+ei-h->ecart;
1809 
1810  /*
1811  * try to reduce the s-polynomial h
1812  *test first whether h should go to the lazyset L
1813  *-if the degree jumps
1814  *-if the number of pre-defined reductions jumps
1815  */
1816  pass++;
1817  d = h_d + h->ecart;
1818  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1819  {
1820  h->GetTP(); // clear bucket
1821  h->SetLmCurrRing();
1822  at = strat->posInL(strat->L,strat->Ll,h,strat);
1823  if (at <= strat->Ll)
1824  {
1825  int dummy=strat->sl;
1826  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1827  return 1;
1828  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1829 #ifdef KDEBUG
1830  if (TEST_OPT_DEBUG)
1831  Print(" degree jumped: -> L%d\n",at);
1832 #endif
1833  h->Clear();
1834  return -1;
1835  }
1836  }
1837  else if (d > reddeg)
1838  {
1839  if (d>=(long)strat->tailRing->bitmask)
1840  {
1841  if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask)
1842  {
1843  strat->overflow=TRUE;
1844  //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1845  h->GetP();
1846  at = strat->posInL(strat->L,strat->Ll,h,strat);
1847  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1848  h->Clear();
1849  return -1;
1850  }
1851  }
1852  else if (TEST_OPT_PROT && (strat->Ll < 0) )
1853  {
1854  //h->wrp(); Print("<%d>\n",h->GetpLength());
1855  reddeg = d;
1856  Print(".%ld",d); mflush();
1857  }
1858  }
1859  }
1860 }

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1519 of file kstd2.cc.

1520 {
1521  if (strat->tl<0) return 1;
1522  int at,i,ii,li;
1523  int j = 0;
1524  int pass = 0;
1525  assume(h->pFDeg() == h->FDeg);
1526  long reddeg = h->GetpFDeg();
1527  long d;
1528  unsigned long not_sev;
1529 
1530  h->SetShortExpVector();
1531  poly h_p = h->GetLmTailRing();
1532  not_sev = ~ h->sev;
1533  loop
1534  {
1535  j = kFindDivisibleByInT(strat, h);
1536  if (j < 0) return 1;
1537 
1538  li = strat->T[j].pLength;
1539  if (li<=0) li=strat->T[j].GetpLength();
1540  ii = j;
1541  /*
1542  * the polynomial to reduce with (up to the moment) is;
1543  * pi with length li
1544  */
1545 
1546  i = j;
1547 #if 1
1548  if (TEST_OPT_LENGTH)
1549  loop
1550  {
1551  /*- search the shortest possible with respect to length -*/
1552  i++;
1553  if (i > strat->tl)
1554  break;
1555  if (li==1)
1556  break;
1557  if ((strat->T[i].pLength < li)
1558  &&
1559  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1560  h_p, not_sev, strat->tailRing))
1561  {
1562  /*
1563  * the polynomial to reduce with is now;
1564  */
1565  li = strat->T[i].pLength;
1566  if (li<=0) li=strat->T[i].GetpLength();
1567  ii = i;
1568  }
1569  }
1570 #endif
1571 
1572  /*
1573  * end of search: have to reduce with pi
1574  */
1575 
1576 
1577 #ifdef KDEBUG
1578  if (TEST_OPT_DEBUG)
1579  {
1580  PrintS("red:");
1581  h->wrp();
1582  PrintS(" with ");
1583  strat->T[ii].wrp();
1584  }
1585 #endif
1586 
1587  ksReducePoly(h, &(strat->T[ii]), NULL, NULL, strat);
1588 #if SBA_PRINT_REDUCTION_STEPS
1589  sba_interreduction_steps++;
1590 #endif
1591 #if SBA_PRINT_OPERATIONS
1592  sba_interreduction_operations += pLength(strat->T[ii].p);
1593 #endif
1594 
1595 #ifdef KDEBUG
1596  if (TEST_OPT_DEBUG)
1597  {
1598  PrintS("\nto ");
1599  h->wrp();
1600  PrintLn();
1601  }
1602 #endif
1603 
1604  h_p=h->GetLmTailRing();
1605 
1606  if (h_p == NULL)
1607  {
1608  kDeleteLcm(h);
1609  return 0;
1610  }
1611  h->SetShortExpVector();
1612  not_sev = ~ h->sev;
1613  d = h->SetpFDeg();
1614  /*- try to reduce the s-polynomial -*/
1615  pass++;
1616  if (//!TEST_OPT_REDTHROUGH &&
1617  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1618  {
1619  h->SetLmCurrRing();
1620  at = strat->posInL(strat->L,strat->Ll,h,strat);
1621  if (at <= strat->Ll)
1622  {
1623 #if 1
1624  int dummy=strat->sl;
1625  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1626  return 1;
1627 #endif
1628 #ifdef KDEBUG
1629  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1630 #endif
1631  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1632  h->Clear();
1633  return -1;
1634  }
1635  }
1636  else if (d != reddeg)
1637  {
1638  if (d>=(long)strat->tailRing->bitmask)
1639  {
1640  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1641  {
1642  strat->overflow=TRUE;
1643  //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1644  h->GetP();
1645  at = strat->posInL(strat->L,strat->Ll,h,strat);
1646  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1647  h->Clear();
1648  return -1;
1649  }
1650  }
1651  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1652  {
1653  Print(".%ld",d);mflush();
1654  reddeg = d;
1655  }
1656  }
1657  }
1658 }

◆ redNF()

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

Definition at line 1866 of file kstd2.cc.

1867 {
1868 #define REDNF_CANONICALIZE 60
1869  if (h==NULL) return NULL;
1870  int j;
1871  int cnt=REDNF_CANONICALIZE;
1872  max_ind=strat->sl;
1873 
1874  if (0 > strat->sl)
1875  {
1876  return h;
1877  }
1878  LObject P(h);
1879  P.SetShortExpVector();
1880  P.bucket = kBucketCreate(currRing);
1881  kBucketInit(P.bucket,P.p,pLength(P.p));
1882  kbTest(P.bucket);
1883 #ifdef HAVE_RINGS
1884  BOOLEAN is_ring = rField_is_Ring(currRing);
1885 #endif
1886 #ifdef KDEBUG
1887 // if (TEST_OPT_DEBUG)
1888 // {
1889 // PrintS("redNF: starting S:\n");
1890 // for( j = 0; j <= max_ind; j++ )
1891 // {
1892 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
1893 // pWrite(strat->S[j]);
1894 // }
1895 // };
1896 #endif
1897 
1898  loop
1899  {
1900  j=kFindDivisibleByInS(strat,&max_ind,&P);
1901  if (j>=0)
1902  {
1903 #ifdef HAVE_RINGS
1904  if (!is_ring)
1905  {
1906 #endif
1907  int sl=pSize(strat->S[j]);
1908  int jj=j;
1909  loop
1910  {
1911  int sll;
1912  jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
1913  if (jj<0) break;
1914  sll=pSize(strat->S[jj]);
1915  if (sll<sl)
1916  {
1917  #ifdef KDEBUG
1918  if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
1919  #endif
1920  //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
1921  j=jj;
1922  sl=sll;
1923  }
1924  }
1925  if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
1926  {
1927  pNorm(strat->S[j]);
1928  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1929  }
1930 #ifdef HAVE_RINGS
1931  }
1932 #endif
1933  nNormalize(pGetCoeff(P.p));
1934 #ifdef KDEBUG
1935  if (TEST_OPT_DEBUG)
1936  {
1937  PrintS("red:");
1938  wrp(h);
1939  PrintS(" with ");
1940  wrp(strat->S[j]);
1941  }
1942 #endif
1943 #ifdef HAVE_PLURAL
1944  if (rIsPluralRing(currRing))
1945  {
1946  number coef;
1947  nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef);
1948  nDelete(&coef);
1949  }
1950  else
1951 #endif
1952  {
1953  number coef;
1954  coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
1955  nDelete(&coef);
1956  }
1957  cnt--;
1958  if (cnt==0)
1959  {
1960  kBucketCanonicalize(P.bucket);
1961  cnt=REDNF_CANONICALIZE;
1962  }
1963  h = kBucketGetLm(P.bucket); // FRAGE OLIVER
1964  if (h==NULL)
1965  {
1966  kBucketDestroy(&P.bucket);
1967 
1968 #ifdef KDEBUG
1969 // if (TEST_OPT_DEBUG)
1970 // {
1971 // PrintS("redNF: starting S:\n");
1972 // for( j = 0; j <= max_ind; j++ )
1973 // {
1974 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
1975 // pWrite(strat->S[j]);
1976 // }
1977 // };
1978 #endif
1979 
1980  return NULL;
1981  }
1982  kbTest(P.bucket);
1983  P.p=h;
1984  P.t_p=NULL;
1985  P.SetShortExpVector();
1986 #ifdef KDEBUG
1987  if (TEST_OPT_DEBUG)
1988  {
1989  PrintS("\nto:");
1990  wrp(h);
1991  PrintLn();
1992  }
1993 #endif
1994  }
1995  else
1996  {
1997  P.p=kBucketClear(P.bucket);
1998  kBucketDestroy(&P.bucket);
1999  pNormalize(P.p);
2000 
2001 #ifdef KDEBUG
2002 // if (TEST_OPT_DEBUG)
2003 // {
2004 // PrintS("redNF: starting S:\n");
2005 // for( j = 0; j <= max_ind; j++ )
2006 // {
2007 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2008 // pWrite(strat->S[j]);
2009 // }
2010 // };
2011 #endif
2012 
2013  return P.p;
2014  }
2015  }
2016 }
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:1079
const poly kBucketGetLm(kBucket_pt bucket)
Definition: kbuckets.cc:506
int kBucketCanonicalize(kBucket_pt bucket)
Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in one bucket: Returns number of bu...
#define REDNF_CANONICALIZE
int kFindNextDivisibleByInS(const kStrategy strat, int start, int max_ind, LObject *L)
Definition: kstd2.cc:395
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:313
#define pSize(p)
Definition: polys.h:314

◆ 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 342 of file kstd1.cc.

343 {
344  int i,at,ei,li,ii;
345  int j = 0;
346  int pass = 0;
347  long d,reddeg;
348 
349  d = h->GetpFDeg()+ h->ecart;
350  reddeg = strat->LazyDegree+d;
351  h->SetShortExpVector();
352  loop
353  {
354  j = kFindDivisibleByInT(strat, h);
355  if (j < 0)
356  {
357  // over ZZ: cleanup coefficients by complete reduction with monomials
358  postReduceByMon(h, strat);
359  if(h->p == NULL)
360  {
361  kDeleteLcm(h);
362  h->Clear();
363  return 0;
364  }
365  if (strat->honey) h->SetLength(strat->length_pLength);
366  if(strat->tl >= 0)
367  h->i_r1 = strat->tl;
368  else
369  h->i_r1 = -1;
370  if (h->GetLmTailRing() == NULL)
371  {
372  kDeleteLcm(h);
373  h->Clear();
374  return 0;
375  }
376  return 1;
377  }
378 
379  ei = strat->T[j].ecart;
380  ii = j;
381  if (ei > h->ecart && ii < strat->tl)
382  {
383  li = strat->T[j].length;
384  // the polynomial to reduce with (up to the moment) is;
385  // pi with ecart ei and length li
386  // look for one with smaller ecart
387  i = j;
388  loop
389  {
390  /*- takes the first possible with respect to ecart -*/
391  i++;
392 #if 1
393  if (i > strat->tl) break;
394  if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
395  strat->T[i].length < li))
396  &&
397  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)
398  &&
399  n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf))
400 #else
401  j = kFindDivisibleByInT(strat, h, i);
402  if (j < 0) break;
403  i = j;
404  if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
405  strat->T[i].length < li))
406 #endif
407  {
408  // the polynomial to reduce with is now
409  ii = i;
410  ei = strat->T[i].ecart;
411  if (ei <= h->ecart) break;
412  li = strat->T[i].length;
413  }
414  }
415  }
416 
417  // end of search: have to reduce with pi
418  if (ei > h->ecart)
419  {
420  // It is not possible to reduce h with smaller ecart;
421  // if possible h goes to the lazy-set L,i.e
422  // if its position in L would be not the last one
423  strat->fromT = TRUE;
424  if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
425  {
426  h->SetLmCurrRing();
427  if (strat->honey && strat->posInLDependsOnLength)
428  h->SetLength(strat->length_pLength);
429  assume(h->FDeg == h->pFDeg());
430  at = strat->posInL(strat->L,strat->Ll,h,strat);
431  if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef))
432  {
433  /*- h will not become the next element to reduce -*/
434  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
435  #ifdef KDEBUG
436  if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
437  #endif
438  h->Clear();
439  strat->fromT = FALSE;
440  return -1;
441  }
442  }
443  doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE);
444  }
445  else
446  {
447  // now we finally can reduce
448  doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
449  }
450  strat->fromT=FALSE;
451  // are we done ???
452  if (h->IsNull())
453  {
454  kDeleteLcm(h);
455  h->Clear();
456  return 0;
457  }
458 
459  // NO!
460  h->SetShortExpVector();
461  h->SetpFDeg();
462  if (strat->honey)
463  {
464  if (ei <= h->ecart)
465  h->ecart = d-h->GetpFDeg();
466  else
467  h->ecart = d-h->GetpFDeg()+ei-h->ecart;
468  }
469  else
470  // this has the side effect of setting h->length
471  h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
472  /*- try to reduce the s-polynomial -*/
473  pass++;
474  d = h->GetpFDeg()+h->ecart;
475  /*
476  *test whether the polynomial should go to the lazyset L
477  *-if the degree jumps
478  *-if the number of pre-defined reductions jumps
479  */
480  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
481  && ((d >= reddeg) || (pass > strat->LazyPass)))
482  {
483  h->SetLmCurrRing();
484  if (strat->honey && strat->posInLDependsOnLength)
485  h->SetLength(strat->length_pLength);
486  assume(h->FDeg == h->pFDeg());
487  at = strat->posInL(strat->L,strat->Ll,h,strat);
488  if (at <= strat->Ll)
489  {
490  int dummy=strat->sl;
491  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
492  {
493  if (strat->honey && !strat->posInLDependsOnLength)
494  h->SetLength(strat->length_pLength);
495  return 1;
496  }
497  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
498 #ifdef KDEBUG
499  if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
500 #endif
501  h->Clear();
502  return -1;
503  }
504  }
505  else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
506  {
507  Print(".%ld",d);mflush();
508  reddeg = d+1;
509  if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
510  {
511  strat->overflow=TRUE;
512  //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
513  h->GetP();
514  at = strat->posInL(strat->L,strat->Ll,h,strat);
515  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
516  h->Clear();
517  return -1;
518  }
519  }
520  }
521 }
static int doRed(LObject *h, TObject *with, BOOLEAN intoT, kStrategy strat, bool redMoraNF)
Definition: kstd1.cc:116
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
Definition: kutil.cc:11161

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 715 of file kstd2.cc.

716 {
717  if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors)
718  if (strat->tl<0) return 1;
719 
720  int at/*,i*/;
721  long d;
722  int j = 0;
723  int pass = 0;
724  // poly zeroPoly = NULL;
725 
726 // TODO warum SetpFDeg notwendig?
727  h->SetpFDeg();
728  assume(h->pFDeg() == h->FDeg);
729  long reddeg = h->GetpFDeg();
730 
731  h->SetShortExpVector();
732  loop
733  {
734  j = kFindDivisibleByInT(strat, h);
735  if (j < 0)
736  {
737  // over ZZ: cleanup coefficients by complete reduction with monomials
738  postReduceByMon(h, strat);
739  if(h->p == NULL)
740  {
741  kDeleteLcm(h);
742  h->Clear();
743  return 0;
744  }
745  if(nIsZero(pGetCoeff(h->p))) return 2;
746  j = kFindDivisibleByInT(strat, h);
747  if(j < 0)
748  {
749  if(strat->tl >= 0)
750  h->i_r1 = strat->tl;
751  else
752  h->i_r1 = -1;
753  if (h->GetLmTailRing() == NULL)
754  {
755  kDeleteLcm(h);
756  h->Clear();
757  return 0;
758  }
759  return 1;
760  }
761  }
762  //printf("\nFound one: ");pWrite(strat->T[j].p);
763  //enterT(*h, strat);
764  ksReducePoly(h, &(strat->T[j]), NULL, NULL, strat); // with debug output
765  //printf("\nAfter small red: ");pWrite(h->p);
766  if (h->GetLmTailRing() == NULL)
767  {
768  kDeleteLcm(h);
769  h->Clear();
770  return 0;
771  }
772  h->SetShortExpVector();
773  d = h->SetpFDeg();
774  /*- try to reduce the s-polynomial -*/
775  pass++;
776  if (!TEST_OPT_REDTHROUGH &&
777  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
778  {
779  h->SetLmCurrRing();
780  if (strat->posInLDependsOnLength)
781  h->SetLength(strat->length_pLength);
782  at = strat->posInL(strat->L,strat->Ll,h,strat);
783  if (at <= strat->Ll)
784  {
785 #ifdef KDEBUG
786  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
787 #endif
788  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
789  h->Clear();
790  return -1;
791  }
792  }
793  if (d != reddeg)
794  {
795  if (d >= (long)strat->tailRing->bitmask)
796  {
797  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
798  {
799  strat->overflow=TRUE;
800  //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
801  h->GetP();
802  at = strat->posInL(strat->L,strat->Ll,h,strat);
803  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
804  h->Clear();
805  return -1;
806  }
807  }
808  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
809  {
810  Print(".%ld",d);mflush();
811  reddeg = d;
812  }
813  }
814  }
815 }

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 568 of file kstd2.cc.

569 {
570  if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors)
571  if (strat->tl<0) return 1;
572 
573  int at/*,i*/;
574  long d;
575  int j = 0;
576  int pass = 0;
577  // poly zeroPoly = NULL;
578 
579 // TODO warum SetpFDeg notwendig?
580  h->SetpFDeg();
581  assume(h->pFDeg() == h->FDeg);
582  long reddeg = h->GetpFDeg();
583 
584  h->SetShortExpVector();
585  loop
586  {
587  /* check if a reducer of the lead term exists */
588  j = kFindDivisibleByInT(strat, h);
589  if (j < 0) {
590  /* check if a reducer with the same lead monomial exists */
591  j = kFindSameLMInT_Z(strat, h);
592  if (j < 0) {
593  /* check if a reducer of the lead monomial exists, by the above
594  * check this is a real divisor of the lead monomial */
595  j = kFindDivisibleByInT_Z(strat, h);
596  if (j < 0)
597  {
598  // over ZZ: cleanup coefficients by complete reduction with monomials
600  postReduceByMon(h, strat);
601  if(h->p == NULL)
602  {
603  if (h->lcm!=NULL) pLmDelete(h->lcm);
604  h->Clear();
605  return 0;
606  }
607  if(nIsZero(pGetCoeff(h->p))) return 2;
608  j = kFindDivisibleByInT(strat, h);
609  if(j < 0)
610  {
611  if(strat->tl >= 0)
612  h->i_r1 = strat->tl;
613  else
614  h->i_r1 = -1;
615  if (h->GetLmTailRing() == NULL)
616  {
617  if (h->lcm!=NULL) pLmDelete(h->lcm);
618  h->Clear();
619  return 0;
620  }
621  return 1;
622  }
623  } else {
624  /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
625  * => we try to cut down the lead coefficient at least */
626  /* first copy T[j] in order to multiply it with a coefficient later on */
627  number mult, rest;
628  TObject tj = strat->T[j];
629  tj.Copy();
630  /* tj.max_exp = strat->T[j].max_exp; */
631  /* compute division with remainder of lc(h) and lc(T[j]) */
632  mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
633  &rest, currRing->cf);
634  /* set corresponding new lead coefficient already. we do not
635  * remove the lead term in ksReducePolyLC, but only apply
636  * a lead coefficient reduction */
637  tj.Mult_nn(mult);
638  ksReducePolyLC(h, &tj, NULL, &rest, strat);
639  tj.Delete();
640  tj.Clear();
641  }
642  } else {
643  /* same lead monomial but lead coefficients do not divide each other:
644  * change the polys to h <- spoly(h,tj) and h2 <- gpoly(h,tj). */
645  LObject h2 = *h;
646  h2.Copy();
647 
648  ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat);
649  ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat);
651  redtailBbaAlsoLC_Z(&h2, j, strat);
652  h2.pCleardenom();
653  }
654  /* replace h2 for tj in L (already generated pairs with tj), S and T */
655  replaceInLAndSAndT(h2, j, strat);
656  }
657  } else {
658  ksReducePoly(h, &(strat->T[j]), NULL, NULL, strat);
659  }
660  /* printf("\nAfter small red: ");pWrite(h->p); */
661  if (h->GetLmTailRing() == NULL)
662  {
663  if (h->lcm!=NULL) pLmDelete(h->lcm);
664 #ifdef KDEBUG
665  h->lcm=NULL;
666 #endif
667  h->Clear();
668  return 0;
669  }
670  h->SetShortExpVector();
671  d = h->SetpFDeg();
672  /*- try to reduce the s-polynomial -*/
673  pass++;
674  if (!TEST_OPT_REDTHROUGH &&
675  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
676  {
677  h->SetLmCurrRing();
678  if (strat->posInLDependsOnLength)
679  h->SetLength(strat->length_pLength);
680  at = strat->posInL(strat->L,strat->Ll,h,strat);
681  if (at <= strat->Ll)
682  {
683 #ifdef KDEBUG
684  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
685 #endif
686  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
687  h->Clear();
688  return -1;
689  }
690  }
691  if (d != reddeg)
692  {
693  if (d >= (long)strat->tailRing->bitmask)
694  {
695  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
696  {
697  strat->overflow=TRUE;
698  //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
699  h->GetP();
700  at = strat->posInL(strat->L,strat->Ll,h,strat);
701  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
702  h->Clear();
703  return -1;
704  }
705  }
706  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
707  {
708  Print(".%ld",d);mflush();
709  reddeg = d;
710  }
711  }
712  }
713 }
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:436
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:320
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:139
void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat)
Definition: kutil.cc:9525

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 982 of file kstd2.cc.

983 {
984  if (strat->tl<0) return 1;
985  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
986  //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
987  assume(h->FDeg == h->pFDeg());
988 //#if 1
989 #ifdef DEBUGF5
990  PrintS("------- IN REDSIG -------\n");
991  Print("p: ");
992  pWrite(pHead(h->p));
993  PrintS("p1: ");
994  pWrite(pHead(h->p1));
995  PrintS("p2: ");
996  pWrite(pHead(h->p2));
997  PrintS("---------------------------\n");
998 #endif
999  poly h_p;
1000  int i,j,at,pass, ii;
1001  int start=0;
1002  int sigSafe;
1003  unsigned long not_sev;
1004  // long reddeg,d;
1005 
1006  pass = j = 0;
1007  // d = reddeg = h->GetpFDeg();
1008  h->SetShortExpVector();
1009  int li;
1010  h_p = h->GetLmTailRing();
1011  not_sev = ~ h->sev;
1012  loop
1013  {
1014  j = kFindDivisibleByInT(strat, h, start);
1015  if (j < 0)
1016  {
1017  return 1;
1018  }
1019 
1020  li = strat->T[j].pLength;
1021  if (li<=0) li=strat->T[j].GetpLength();
1022  ii = j;
1023  /*
1024  * the polynomial to reduce with (up to the moment) is;
1025  * pi with length li
1026  */
1027  i = j;
1028 #if 1
1029  if (TEST_OPT_LENGTH)
1030  loop
1031  {
1032  /*- search the shortest possible with respect to length -*/
1033  i++;
1034  if (i > strat->tl)
1035  break;
1036  if (li==1)
1037  break;
1038  if ((strat->T[i].pLength < li)
1039  &&
1040  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1041  h_p, not_sev, strat->tailRing))
1042  {
1043  /*
1044  * the polynomial to reduce with is now;
1045  */
1046  li = strat->T[i].pLength;
1047  if (li<=0) li=strat->T[i].GetpLength();
1048  ii = i;
1049  }
1050  }
1051  start = ii+1;
1052 #endif
1053 
1054  /*
1055  * end of search: have to reduce with pi
1056  */
1057 #ifdef KDEBUG
1058  if (TEST_OPT_DEBUG)
1059  {
1060  PrintS("red:");
1061  h->wrp();
1062  PrintS(" with ");
1063  strat->T[ii].wrp();
1064  }
1065 #endif
1066  assume(strat->fromT == FALSE);
1067 //#if 1
1068 #ifdef DEBUGF5
1069  Print("BEFORE REDUCTION WITH %d:\n",ii);
1070  PrintS("--------------------------------\n");
1071  pWrite(h->sig);
1072  pWrite(strat->T[ii].sig);
1073  pWrite(h->GetLmCurrRing());
1074  pWrite(pHead(h->p1));
1075  pWrite(pHead(h->p2));
1076  pWrite(pHead(strat->T[ii].p));
1077  PrintS("--------------------------------\n");
1078  printf("INDEX OF REDUCER T: %d\n",ii);
1079 #endif
1080  sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1081 #if SBA_PRINT_REDUCTION_STEPS
1082  if (sigSafe != 3)
1083  sba_reduction_steps++;
1084 #endif
1085 #if SBA_PRINT_OPERATIONS
1086  if (sigSafe != 3)
1087  sba_operations += pLength(strat->T[ii].p);
1088 #endif
1089  // if reduction has taken place, i.e. the reduction was sig-safe
1090  // otherwise start is already at the next position and the loop
1091  // searching reducers in T goes on from index start
1092 //#if 1
1093 #ifdef DEBUGF5
1094  Print("SigSAFE: %d\n",sigSafe);
1095 #endif
1096  if (sigSafe != 3)
1097  {
1098  // start the next search for reducers in T from the beginning
1099  start = 0;
1100 #ifdef KDEBUG
1101  if (TEST_OPT_DEBUG)
1102  {
1103  PrintS("\nto ");
1104  h->wrp();
1105  PrintLn();
1106  }
1107 #endif
1108 
1109  h_p = h->GetLmTailRing();
1110  if (h_p == NULL)
1111  {
1112  kDeleteLcm(h);
1113  return 0;
1114  }
1115  h->SetShortExpVector();
1116  not_sev = ~ h->sev;
1117  /*
1118  * try to reduce the s-polynomial h
1119  *test first whether h should go to the lazyset L
1120  *-if the degree jumps
1121  *-if the number of pre-defined reductions jumps
1122  */
1123  pass++;
1124  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1125  {
1126  h->SetLmCurrRing();
1127  at = strat->posInL(strat->L,strat->Ll,h,strat);
1128  if (at <= strat->Ll)
1129  {
1130  int dummy=strat->sl;
1131  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1132  {
1133  return 1;
1134  }
1135  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1136 #ifdef KDEBUG
1137  if (TEST_OPT_DEBUG)
1138  Print(" lazy: -> L%d\n",at);
1139 #endif
1140  h->Clear();
1141  return -1;
1142  }
1143  }
1144  }
1145  }
1146 }
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:690

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1149 of file kstd2.cc.

1150 {
1151  //Since reduce is really bad for SBA we use the following idea:
1152  // We first check if we can build a gcd pair between h and S
1153  //where the sig remains the same and replace h by this gcd poly
1155  #if GCD_SBA
1156  while(sbaCheckGcdPair(h,strat))
1157  {
1158  h->sev = pGetShortExpVector(h->p);
1159  }
1160  #endif
1161  poly beforeredsig;
1162  beforeredsig = pCopy(h->sig);
1163 
1164  if (strat->tl<0) return 1;
1165  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1166  //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1167  assume(h->FDeg == h->pFDeg());
1168 //#if 1
1169 #ifdef DEBUGF5
1170  Print("------- IN REDSIG -------\n");
1171  Print("p: ");
1172  pWrite(pHead(h->p));
1173  Print("p1: ");
1174  pWrite(pHead(h->p1));
1175  Print("p2: ");
1176  pWrite(pHead(h->p2));
1177  Print("---------------------------\n");
1178 #endif
1179  poly h_p;
1180  int i,j,at,pass, ii;
1181  int start=0;
1182  int sigSafe;
1183  unsigned long not_sev;
1184  // long reddeg,d;
1185 
1186  pass = j = 0;
1187  // d = reddeg = h->GetpFDeg();
1188  h->SetShortExpVector();
1189  int li;
1190  h_p = h->GetLmTailRing();
1191  not_sev = ~ h->sev;
1192  loop
1193  {
1194  j = kFindDivisibleByInT(strat, h, start);
1195  if (j < 0)
1196  {
1197  #if GCD_SBA
1198  while(sbaCheckGcdPair(h,strat))
1199  {
1200  h->sev = pGetShortExpVector(h->p);
1201  h->is_redundant = FALSE;
1202  start = 0;
1203  }
1204  #endif
1205  // over ZZ: cleanup coefficients by complete reduction with monomials
1206  postReduceByMonSig(h, strat);
1207  if(h->p == NULL || nIsZero(pGetCoeff(h->p))) return 2;
1208  j = kFindDivisibleByInT(strat, h,start);
1209  if(j < 0)
1210  {
1211  if(strat->tl >= 0)
1212  h->i_r1 = strat->tl;
1213  else
1214  h->i_r1 = -1;
1215  if (h->GetLmTailRing() == NULL)
1216  {
1217  kDeleteLcm(h);
1218  h->Clear();
1219  return 0;
1220  }
1221  //Check for sigdrop after reduction
1222  if(pLtCmp(beforeredsig,h->sig) == 1)
1223  {
1224  strat->sigdrop = TRUE;
1225  //Reduce it as much as you can
1226  int red_result = redRing(h,strat);
1227  if(red_result == 0)
1228  {
1229  //It reduced to 0, cancel the sigdrop
1230  strat->sigdrop = FALSE;
1231  p_Delete(&h->sig,currRing);h->sig = NULL;
1232  return 0;
1233  }
1234  else
1235  {
1236  //strat->enterS(*h, strat->sl+1, strat, strat->tl);
1237  return 0;
1238  }
1239  }
1240  p_Delete(&beforeredsig,currRing);
1241  return 1;
1242  }
1243  }
1244 
1245  li = strat->T[j].pLength;
1246  if (li<=0) li=strat->T[j].GetpLength();
1247  ii = j;
1248  /*
1249  * the polynomial to reduce with (up to the moment) is;
1250  * pi with length li
1251  */
1252  i = j;
1253  if (TEST_OPT_LENGTH)
1254  loop
1255  {
1256  /*- search the shortest possible with respect to length -*/
1257  i++;
1258  if (i > strat->tl)
1259  break;
1260  if (li==1)
1261  break;
1262  if ((strat->T[i].pLength < li)
1263  && n_DivBy(pGetCoeff(h_p),pGetCoeff(strat->T[i].p),currRing->cf)
1264  && p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1265  h_p, not_sev, strat->tailRing))
1266  {
1267  /*
1268  * the polynomial to reduce with is now;
1269  */
1270  li = strat->T[i].pLength;
1271  if (li<=0) li=strat->T[i].GetpLength();
1272  ii = i;
1273  }
1274  }
1275 
1276  start = ii+1;
1277 
1278  /*
1279  * end of search: have to reduce with pi
1280  */
1281 #ifdef KDEBUG
1282  if (TEST_OPT_DEBUG)
1283  {
1284  PrintS("red:");
1285  h->wrp();
1286  PrintS(" with ");
1287  strat->T[ii].wrp();
1288  }
1289 #endif
1290  assume(strat->fromT == FALSE);
1291 //#if 1
1292 #ifdef DEBUGF5
1293  Print("BEFORE REDUCTION WITH %d:\n",ii);
1294  Print("--------------------------------\n");
1295  pWrite(h->sig);
1296  pWrite(strat->T[ii].sig);
1297  pWrite(h->GetLmCurrRing());
1298  pWrite(pHead(h->p1));
1299  pWrite(pHead(h->p2));
1300  pWrite(pHead(strat->T[ii].p));
1301  Print("--------------------------------\n");
1302  printf("INDEX OF REDUCER T: %d\n",ii);
1303 #endif
1304  sigSafe = ksReducePolySigRing(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1305  if(h->p == NULL && h->sig == NULL)
1306  {
1307  //Trivial case catch
1308  strat->sigdrop = FALSE;
1309  }
1310  #if 0
1311  //If the reducer has the same lt (+ or -) as the other one, reduce it via redRing
1312  //In some cases this proves to be very bad
1313  if(rField_is_Ring(currRing) && h->p != NULL && pLmCmp(h->p,strat->T[ii].p)==0)
1314  {
1315  int red_result = redRing(h,strat);
1316  if(red_result == 0)
1317  {
1318  pDelete(&h->sig);h->sig = NULL;
1319  return 0;
1320  }
1321  else
1322  {
1323  strat->sigdrop = TRUE;
1324  return 1;
1325  }
1326  }
1327  #endif
1328  if(strat->sigdrop)
1329  return 1;
1330 #if SBA_PRINT_REDUCTION_STEPS
1331  if (sigSafe != 3)
1332  sba_reduction_steps++;
1333 #endif
1334 #if SBA_PRINT_OPERATIONS
1335  if (sigSafe != 3)
1336  sba_operations += pLength(strat->T[ii].p);
1337 #endif
1338  // if reduction has taken place, i.e. the reduction was sig-safe
1339  // otherwise start is already at the next position and the loop
1340  // searching reducers in T goes on from index start
1341 //#if 1
1342 #ifdef DEBUGF5
1343  Print("SigSAFE: %d\n",sigSafe);
1344 #endif
1345  if (sigSafe != 3)
1346  {
1347  // start the next search for reducers in T from the beginning
1348  start = 0;
1349 #ifdef KDEBUG
1350  if (TEST_OPT_DEBUG)
1351  {
1352  PrintS("\nto ");
1353  h->wrp();
1354  PrintLn();
1355  }
1356 #endif
1357 
1358  h_p = h->GetLmTailRing();
1359  if (h_p == NULL)
1360  {
1361  kDeleteLcm(h);
1362  return 0;
1363  }
1364  h->SetShortExpVector();
1365  not_sev = ~ h->sev;
1366  /*
1367  * try to reduce the s-polynomial h
1368  *test first whether h should go to the lazyset L
1369  *-if the degree jumps
1370  *-if the number of pre-defined reductions jumps
1371  */
1372  pass++;
1373  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1374  {
1375  h->SetLmCurrRing();
1376  at = strat->posInL(strat->L,strat->Ll,h,strat);
1377  if (at <= strat->Ll)
1378  {
1379  int dummy=strat->sl;
1380  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1381  {
1382  return 1;
1383  }
1384  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1385 #ifdef KDEBUG
1386  if (TEST_OPT_DEBUG)
1387  Print(" lazy: -> L%d\n",at);
1388 #endif
1389  h->Clear();
1390  return -1;
1391  }
1392  }
1393  }
1394  }
1395 }
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:896
void postReduceByMonSig(LObject *h, kStrategy strat)
Definition: kutil.cc:11229
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition: kutil.cc:1676

◆ redtail() [1/2]

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

Definition at line 7405 of file kutil.cc.

7406 {
7407  poly h, hn;
7408  strat->redTailChange=FALSE;
7409 
7410  L->GetP();
7411  poly p = L->p;
7412  if (strat->noTailReduction || pNext(p) == NULL)
7413  return p;
7414 
7415  LObject Ln(strat->tailRing);
7416  TObject* With;
7417  // placeholder in case strat->tl < 0
7418  TObject With_s(strat->tailRing);
7419  h = p;
7420  hn = pNext(h);
7421  long op = strat->tailRing->pFDeg(hn, strat->tailRing);
7422  long e;
7423  int l;
7424  BOOLEAN save_HE=strat->kHEdgeFound;
7425  strat->kHEdgeFound |=
7426  ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
7427 
7428  while(hn != NULL)
7429  {
7430  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7431  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7432  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7433  loop
7434  {
7435  Ln.Set(hn, strat->tailRing);
7436  Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
7437  if (strat->kHEdgeFound)
7438  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7439  else
7440  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
7441  if (With == NULL) break;
7442  With->length=0;
7443  With->pLength=0;
7444  strat->redTailChange=TRUE;
7445  if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
7446  {
7447  // reducing the tail would violate the exp bound
7448  if (kStratChangeTailRing(strat, L))
7449  {
7450  strat->kHEdgeFound = save_HE;
7451  return redtail(L, end_pos, strat);
7452  }
7453  else
7454  return NULL;
7455  }
7456  hn = pNext(h);
7457  if (hn == NULL) goto all_done;
7458  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7459  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7460  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7461  }
7462  h = hn;
7463  hn = pNext(h);
7464  }
7465 
7466  all_done:
7467  if (strat->redTailChange)
7468  {
7469  L->pLength = 0;
7470  }
7471  strat->kHEdgeFound = save_HE;
7472  return p;
7473 }
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:7263
#define TEST_OPT_INFREDTAIL
Definition: options.h:115

◆ redtail() [2/2]

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

Definition at line 7475 of file kutil.cc.

7476 {
7477  LObject L(p, currRing);
7478  return redtail(&L, end_pos, strat);
7479 }

◆ redtailBba() [1/3]

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

Definition at line 7481 of file kutil.cc.

7482 {
7483 #define REDTAIL_CANONICALIZE 100
7484  strat->redTailChange=FALSE;
7485  if (strat->noTailReduction) return L->GetLmCurrRing();
7486  poly h, p;
7487  p = h = L->GetLmTailRing();
7488  if ((h==NULL) || (pNext(h)==NULL))
7489  return L->GetLmCurrRing();
7490 
7491  TObject* With;
7492  // placeholder in case strat->tl < 0
7493  TObject With_s(strat->tailRing);
7494 
7495  LObject Ln(pNext(h), strat->tailRing);
7496  Ln.GetpLength();
7497 
7498  pNext(h) = NULL;
7499  if (L->p != NULL)
7500  {
7501  pNext(L->p) = NULL;
7502  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7503  }
7504  L->pLength = 1;
7505 
7506  Ln.PrepareRed(strat->use_buckets);
7507 
7508  int cnt=REDTAIL_CANONICALIZE;
7509  while(!Ln.IsNull())
7510  {
7511  loop
7512  {
7513  if (TEST_OPT_IDLIFT)
7514  {
7515  if (Ln.p!=NULL)
7516  {
7517  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7518  }
7519  else
7520  {
7521  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7522  }
7523  }
7524  Ln.SetShortExpVector();
7525  if (withT)
7526  {
7527  int j;
7528  j = kFindDivisibleByInT(strat, &Ln);
7529  if (j < 0) break;
7530  With = &(strat->T[j]);
7531  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7532  }
7533  else
7534  {
7535  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7536  if (With == NULL) break;
7537  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7538  }
7539  cnt--;
7540  if (cnt==0)
7541  {
7543  /*poly tmp=*/Ln.CanonicalizeP();
7544  if (normalize)
7545  {
7546  Ln.Normalize();
7547  //pNormalize(tmp);
7548  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7549  }
7550  }
7551  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7552  {
7553  With->pNorm();
7554  }
7555  strat->redTailChange=TRUE;
7556  if (ksReducePolyTail(L, With, &Ln))
7557  {
7558  // reducing the tail would violate the exp bound
7559  // set a flag and hope for a retry (in bba)
7560  strat->completeReduce_retry=TRUE;
7561  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7562  do
7563  {
7564  pNext(h) = Ln.LmExtractAndIter();
7565  pIter(h);
7566  L->pLength++;
7567  } while (!Ln.IsNull());
7568  goto all_done;
7569  }
7570  if (Ln.IsNull()) goto all_done;
7571  if (! withT) With_s.Init(currRing);
7572  }
7573  pNext(h) = Ln.LmExtractAndIter();
7574  pIter(h);
7575  pNormalize(h);
7576  L->pLength++;
7577  }
7578 
7579  all_done:
7580  Ln.Delete();
7581  if (L->p != NULL) pNext(L->p) = pNext(p);
7582 
7583  if (strat->redTailChange)
7584  {
7585  L->length = 0;
7586  L->pLength = 0;
7587  }
7588 
7589  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7590  //L->Normalize(); // HANNES: should have a test
7591  kTest_L(L,strat->tailRing);
7592  return L->GetLmCurrRing();
7593 }
#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 1158 of file kInline.h.

1159 {
1160  LObject L(p);
1161  return redtailBba(&L, pos, strat,FALSE, normalize);
1162 }

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

7838 {
7839  strat->redTailChange=FALSE;
7840  if (strat->noTailReduction) return L->GetLmCurrRing();
7841  poly h, p;
7842  p = h = L->GetLmTailRing();
7843  if ((h==NULL) || (pNext(h)==NULL))
7844  return L->GetLmCurrRing();
7845 
7846  TObject* With;
7847  // placeholder in case strat->tl < 0
7848  TObject With_s(strat->tailRing);
7849 
7850  LObject Ln(pNext(h), strat->tailRing);
7851  Ln.pLength = L->GetpLength() - 1;
7852 
7853  pNext(h) = NULL;
7854  if (L->p != NULL) pNext(L->p) = NULL;
7855  L->pLength = 1;
7856 
7857  Ln.PrepareRed(strat->use_buckets);
7858 
7859  int cnt=REDTAIL_CANONICALIZE;
7860  while(!Ln.IsNull())
7861  {
7862  loop
7863  {
7864  Ln.SetShortExpVector();
7865  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7866  if (With == NULL) break;
7867  cnt--;
7868  if (cnt==0)
7869  {
7871  /*poly tmp=*/Ln.CanonicalizeP();
7872  }
7873  // we are in Z, do not call pNorm
7874  strat->redTailChange=TRUE;
7875  // test divisibility of coefs:
7876  poly p_Ln=Ln.GetLmCurrRing();
7877  poly p_With=With->GetLmCurrRing();
7878  number z=n_IntMod(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf);
7879  if (!nIsZero(z))
7880  {
7881  // subtract z*Ln, add z.Ln to L
7882  poly m=pHead(p_Ln);
7883  pSetCoeff(m,z);
7884  poly mm=pHead(m);
7885  pNext(h) = m;
7886  pIter(h);
7887  L->pLength++;
7888  mm=pNeg(mm);
7889  if (Ln.bucket!=NULL)
7890  {
7891  int dummy=1;
7892  kBucket_Add_q(Ln.bucket,mm,&dummy);
7893  }
7894  else
7895  {
7896  if ((Ln.t_p!=NULL)&&(Ln.p==NULL))
7897  Ln.GetP();
7898  if (Ln.p!=NULL)
7899  {
7900  Ln.p=pAdd(Ln.p,mm);
7901  if (Ln.t_p!=NULL)
7902  {
7903  pNext(Ln.t_p)=NULL;
7904  p_LmDelete(Ln.t_p,strat->tailRing);
7905  }
7906  }
7907  }
7908  }
7909  else
7910  nDelete(&z);
7911 
7912  if (ksReducePolyTail(L, With, &Ln))
7913  {
7914  // reducing the tail would violate the exp bound
7915  // set a flag and hope for a retry (in bba)
7916  strat->completeReduce_retry=TRUE;
7917  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7918  do
7919  {
7920  pNext(h) = Ln.LmExtractAndIter();
7921  pIter(h);
7922  L->pLength++;
7923  } while (!Ln.IsNull());
7924  goto all_done;
7925  }
7926  if (Ln.IsNull()) goto all_done;
7927  With_s.Init(currRing);
7928  }
7929  pNext(h) = Ln.LmExtractAndIter();
7930  pIter(h);
7931  pNormalize(h);
7932  L->pLength++;
7933  }
7934 
7935  all_done:
7936  Ln.Delete();
7937  if (L->p != NULL) pNext(L->p) = pNext(p);
7938 
7939  if (strat->redTailChange)
7940  {
7941  L->length = 0;
7942  }
7943 
7944  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7945  //L->Normalize(); // HANNES: should have a test
7946  kTest_L(L,strat->tailRing);
7947  return L->GetLmCurrRing();
7948 }
int m
Definition: cfEzgcd.cc:121
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition: kbuckets.cc:654
#define pAdd(p, q)
Definition: polys.h:199

◆ redtailBba_Z() [2/2]

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

Definition at line 1171 of file kInline.h.

1172 {
1173  LObject L(p, currRing, strat->tailRing);
1174  return redtailBba_Z(&L, pos, strat);
1175 }

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7711 of file kutil.cc.

7713 {
7714  strat->redTailChange=FALSE;
7715 
7716  poly h, p;
7717  p = h = L->GetLmTailRing();
7718  if ((h==NULL) || (pNext(h)==NULL))
7719  return;
7720 
7721  TObject* With;
7722  LObject Ln(pNext(h), strat->tailRing);
7723  Ln.GetpLength();
7724 
7725  pNext(h) = NULL;
7726  if (L->p != NULL)
7727  {
7728  pNext(L->p) = NULL;
7729  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7730  }
7731  L->pLength = 1;
7732 
7733  Ln.PrepareRed(strat->use_buckets);
7734 
7735  int cnt=REDTAIL_CANONICALIZE;
7736 
7737  while(!Ln.IsNull())
7738  {
7739  loop
7740  {
7741  if (TEST_OPT_IDLIFT)
7742  {
7743  if (Ln.p!=NULL)
7744  {
7745  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7746  }
7747  else
7748  {
7749  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7750  }
7751  }
7752  Ln.SetShortExpVector();
7753  int j;
7754  j = kFindDivisibleByInT(strat, &Ln);
7755  if (j < 0) {
7756  j = kFindDivisibleByInT_Z(strat, &Ln);
7757  if (j < 0) {
7758  break;
7759  } else {
7760  /* reduction not cancelling a tail term, but reducing its coefficient */
7761  With = &(strat->T[j]);
7762  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7763  cnt--;
7764  if (cnt==0)
7765  {
7767  /*poly tmp=*/Ln.CanonicalizeP();
7768  }
7769  strat->redTailChange=TRUE;
7770  /* reduction cancelling a tail term */
7771  if (ksReducePolyTailLC_Z(L, With, &Ln))
7772  {
7773  // reducing the tail would violate the exp bound
7774  // set a flag and hope for a retry (in bba)
7775  strat->completeReduce_retry=TRUE;
7776  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7777  do
7778  {
7779  pNext(h) = Ln.LmExtractAndIter();
7780  pIter(h);
7781  L->pLength++;
7782  } while (!Ln.IsNull());
7783  goto all_done;
7784  }
7785  /* we have to break since we did not cancel the term, but only decreased
7786  * its coefficient. */
7787  break;
7788  }
7789  } else {
7790  With = &(strat->T[j]);
7791  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7792  cnt--;
7793  if (cnt==0)
7794  {
7796  /*poly tmp=*/Ln.CanonicalizeP();
7797  }
7798  strat->redTailChange=TRUE;
7799  /* reduction cancelling a tail term */
7800  if (ksReducePolyTail_Z(L, With, &Ln))
7801  {
7802  // reducing the tail would violate the exp bound
7803  // set a flag and hope for a retry (in bba)
7804  strat->completeReduce_retry=TRUE;
7805  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7806  do
7807  {
7808  pNext(h) = Ln.LmExtractAndIter();
7809  pIter(h);
7810  L->pLength++;
7811  } while (!Ln.IsNull());
7812  goto all_done;
7813  }
7814  }
7815  if (Ln.IsNull()) goto all_done;
7816  }
7817  pNext(h) = Ln.LmExtractAndIter();
7818  pIter(h);
7819  L->pLength++;
7820  }
7821 
7822  all_done:
7823  Ln.Delete();
7824  if (L->p != NULL) pNext(L->p) = pNext(p);
7825 
7826  if (strat->redTailChange)
7827  {
7828  L->length = 0;
7829  L->pLength = 0;
7830  }
7831 
7832  kTest_L(L, strat->tailRing);
7833  return;
7834 }
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1055
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1073

◆ redtailBbaBound() [1/2]

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

Definition at line 7595 of file kutil.cc.

7596 {
7597  strat->redTailChange=FALSE;
7598  if (strat->noTailReduction) return L->GetLmCurrRing();
7599  poly h, p;
7600  p = h = L->GetLmTailRing();
7601  if ((h==NULL) || (pNext(h)==NULL))
7602  return L->GetLmCurrRing();
7603 
7604  TObject* With;
7605  // placeholder in case strat->tl < 0
7606  TObject With_s(strat->tailRing);
7607 
7608  LObject Ln(pNext(h), strat->tailRing);
7609  Ln.pLength = L->GetpLength() - 1;
7610 
7611  pNext(h) = NULL;
7612  if (L->p != NULL) pNext(L->p) = NULL;
7613  L->pLength = 1;
7614 
7615  Ln.PrepareRed(strat->use_buckets);
7616 
7617  int cnt=REDTAIL_CANONICALIZE;
7618  while(!Ln.IsNull())
7619  {
7620  loop
7621  {
7622  if (TEST_OPT_IDLIFT)
7623  {
7624  if (Ln.p!=NULL)
7625  {
7626  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7627  }
7628  else
7629  {
7630  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7631  }
7632  }
7633  Ln.SetShortExpVector();
7634  if (withT)
7635  {
7636  int j;
7637  j = kFindDivisibleByInT(strat, &Ln);
7638  if (j < 0) break;
7639  With = &(strat->T[j]);
7640  }
7641  else
7642  {
7643  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7644  if (With == NULL) break;
7645  }
7646  cnt--;
7647  if (cnt==0)
7648  {
7650  /*poly tmp=*/Ln.CanonicalizeP();
7651  if (normalize)
7652  {
7653  Ln.Normalize();
7654  //pNormalize(tmp);
7655  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7656  }
7657  }
7658  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7659  {
7660  With->pNorm();
7661  }
7662  strat->redTailChange=TRUE;
7663  if (ksReducePolyTail(L, With, &Ln))
7664  {
7665  // reducing the tail would violate the exp bound
7666  // set a flag and hope for a retry (in bba)
7667  strat->completeReduce_retry=TRUE;
7668  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7669  do
7670  {
7671  pNext(h) = Ln.LmExtractAndIter();
7672  pIter(h);
7673  L->pLength++;
7674  } while (!Ln.IsNull());
7675  goto all_done;
7676  }
7677  if(!Ln.IsNull())
7678  {
7679  Ln.GetP();
7680  Ln.p = pJet(Ln.p,bound);
7681  }
7682  if (Ln.IsNull())
7683  {
7684  goto all_done;
7685  }
7686  if (! withT) With_s.Init(currRing);
7687  }
7688  pNext(h) = Ln.LmExtractAndIter();
7689  pIter(h);
7690  pNormalize(h);
7691  L->pLength++;
7692  }
7693 
7694  all_done:
7695  Ln.Delete();
7696  if (L->p != NULL) pNext(L->p) = pNext(p);
7697 
7698  if (strat->redTailChange)
7699  {
7700  L->length = 0;
7701  L->pLength = 0;
7702  }
7703 
7704  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7705  //L->Normalize(); // HANNES: should have a test
7706  kTest_L(L,strat->tailRing);
7707  return L->GetLmCurrRing();
7708 }
#define pJet(p, m)
Definition: polys.h:364

◆ redtailBbaBound() [2/2]

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

Definition at line 1164 of file kInline.h.

1165 {
1166  LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1167  return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1168 }

◆ redtailBbaShift()

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

Definition at line 12830 of file kutil.cc.

12831 {
12832  /* for the shift case need to run it with withT = TRUE */
12833  strat->redTailChange=FALSE;
12834  if (strat->noTailReduction) return L->GetLmCurrRing();
12835  poly h, p;
12836  p = h = L->GetLmTailRing();
12837  if ((h==NULL) || (pNext(h)==NULL))
12838  return L->GetLmCurrRing();
12839 
12840  TObject* With;
12841  // placeholder in case strat->tl < 0
12842  TObject With_s(strat->tailRing);
12843 
12844  LObject Ln(pNext(h), strat->tailRing);
12845  Ln.pLength = L->GetpLength() - 1;
12846 
12847  pNext(h) = NULL;
12848  if (L->p != NULL) pNext(L->p) = NULL;
12849  L->pLength = 1;
12850 
12851  Ln.PrepareRed(strat->use_buckets);
12852 
12853  while(!Ln.IsNull())
12854  {
12855  loop
12856  {
12857  Ln.SetShortExpVector();
12858  if (withT)
12859  {
12860  int j;
12861  j = kFindDivisibleByInT(strat, &Ln);
12862  if (j < 0) break;
12863  With = &(strat->T[j]);
12864  }
12865  else
12866  {
12867  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
12868  if (With == NULL) break;
12869  }
12870  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
12871  {
12872  With->pNorm();
12873  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
12874  }
12875  strat->redTailChange=TRUE;
12876  if (ksReducePolyTail(L, With, &Ln))
12877  {
12878  // reducing the tail would violate the exp bound
12879  // set a flag and hope for a retry (in bba)
12880  strat->completeReduce_retry=TRUE;
12881  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
12882  do
12883  {
12884  pNext(h) = Ln.LmExtractAndIter();
12885  pIter(h);
12886  L->pLength++;
12887  } while (!Ln.IsNull());
12888  goto all_done;
12889  }
12890  if (Ln.IsNull()) goto all_done;
12891  if (! withT) With_s.Init(currRing);
12892  }
12893  pNext(h) = Ln.LmExtractAndIter();
12894  pIter(h);
12895  L->pLength++;
12896  }
12897 
12898  all_done:
12899  Ln.Delete();
12900  if (L->p != NULL) pNext(L->p) = pNext(p);
12901 
12902  if (strat->redTailChange)
12903  {
12904  L->length = 0;
12905  }
12906  L->Normalize(); // HANNES: should have a test
12907  kTest_L(L,strat->tailRing);
12908  return L->GetLmCurrRing();
12909 }

◆ redtailSba()

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

Definition at line 1398 of file kstd2.cc.

1399 {
1400 #define REDTAIL_CANONICALIZE 100
1401  strat->redTailChange=FALSE;
1402  if (strat->noTailReduction) return L->GetLmCurrRing();
1403  poly h, p;
1404  p = h = L->GetLmTailRing();
1405  if ((h==NULL) || (pNext(h)==NULL))
1406  return L->GetLmCurrRing();
1407 
1408  TObject* With;
1409  // placeholder in case strat->tl < 0
1410  TObject With_s(strat->tailRing);
1411 
1412  LObject Ln(pNext(h), strat->tailRing);
1413  Ln.sig = L->sig;
1414  Ln.sevSig = L->sevSig;
1415  Ln.pLength = L->GetpLength() - 1;
1416 
1417  pNext(h) = NULL;
1418  if (L->p != NULL) pNext(L->p) = NULL;
1419  L->pLength = 1;
1420 
1421  Ln.PrepareRed(strat->use_buckets);
1422 
1423  int cnt=REDTAIL_CANONICALIZE;
1424  while(!Ln.IsNull())
1425  {
1426  loop
1427  {
1428  if(rField_is_Ring(currRing) && strat->sigdrop)
1429  break;
1430  Ln.SetShortExpVector();
1431  if (withT)
1432  {
1433  int j;
1434  j = kFindDivisibleByInT(strat, &Ln);
1435  if (j < 0) break;
1436  With = &(strat->T[j]);
1437  }
1438  else
1439  {
1440  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1441  if (With == NULL) break;
1442  }
1443  cnt--;
1444  if (cnt==0)
1445  {
1447  /*poly tmp=*/Ln.CanonicalizeP();
1449  {
1450  Ln.Normalize();
1451  //pNormalize(tmp);
1452  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1453  }
1454  }
1455  if (normalize && (!TEST_OPT_INTSTRATEGY) && !rField_is_Ring(currRing) && (!nIsOne(pGetCoeff(With->p))))
1456  {
1457  With->pNorm();
1458  }
1459  strat->redTailChange=TRUE;
1460  int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1462  L->sig = Ln.sig;
1463  //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1464  // I delete it an then set Ln.sig. Hence L->sig is lost
1465 #if SBA_PRINT_REDUCTION_STEPS
1466  if (ret != 3)
1467  sba_reduction_steps++;
1468 #endif
1469 #if SBA_PRINT_OPERATIONS
1470  if (ret != 3)
1471  sba_operations += pLength(With->p);
1472 #endif
1473  if (ret)
1474  {
1475  // reducing the tail would violate the exp bound
1476  // set a flag and hope for a retry (in bba)
1477  strat->completeReduce_retry=TRUE;
1478  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1479  do
1480  {
1481  pNext(h) = Ln.LmExtractAndIter();
1482  pIter(h);
1483  L->pLength++;
1484  } while (!Ln.IsNull());
1485  goto all_done;
1486  }
1487  if (Ln.IsNull()) goto all_done;
1488  if (! withT) With_s.Init(currRing);
1489  if(rField_is_Ring(currRing) && strat->sigdrop)
1490  {
1491  //Cannot break the loop here so easily
1492  break;
1493  }
1494  }
1495  pNext(h) = Ln.LmExtractAndIter();
1496  pIter(h);
1497  if(!rField_is_Ring(currRing))
1498  pNormalize(h);
1499  L->pLength++;
1500  }
1501  all_done:
1502  Ln.Delete();
1503  if (L->p != NULL) pNext(L->p) = pNext(p);
1504 
1505  if (strat->redTailChange)
1506  {
1507  L->length = 0;
1508  }
1509  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1510  //L->Normalize(); // HANNES: should have a test
1511  kTest_L(L,strat->tailRing);
1512  return L->GetLmCurrRing();
1513 }
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition: kstd2.cc:944
#define REDTAIL_CANONICALIZE

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 4982 of file kutil.cc.

4983 {
4984  int i,j,at,ecart, s2r;
4985  int fq=0;
4986  unsigned long sev;
4987  poly p;
4988  int new_suc=strat->sl+1;
4989  i= *suc;
4990  if (i<0) i=0;
4991 
4992  for (; i<=strat->sl; i++)
4993  {
4994  at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4995  if (at != i)
4996  {
4997  if (new_suc > at) new_suc = at;
4998  p = strat->S[i];
4999  ecart = strat->ecartS[i];
5000  sev = strat->sevS[i];
5001  s2r = strat->S_2_R[i];
5002  if (strat->fromQ!=NULL) fq=strat->fromQ[i];
5003  for (j=i; j>=at+1; j--)
5004  {
5005  strat->S[j] = strat->S[j-1];
5006  strat->ecartS[j] = strat->ecartS[j-1];
5007  strat->sevS[j] = strat->sevS[j-1];
5008  strat->S_2_R[j] = strat->S_2_R[j-1];
5009  }
5010  strat->S[at] = p;
5011  strat->ecartS[at] = ecart;
5012  strat->sevS[at] = sev;
5013  strat->S_2_R[at] = s2r;
5014  if (strat->fromQ!=NULL)
5015  {
5016  for (j=i; j>=at+1; j--)
5017  {
5018  strat->fromQ[j] = strat->fromQ[j-1];
5019  }
5020  strat->fromQ[at]=fq;
5021  }
5022  }
5023  }
5024  if (new_suc <= strat->sl) *suc=new_suc;
5025  else *suc=-1;
5026 }

◆ replaceInLAndSAndT()

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

Definition at line 9525 of file kutil.cc.

9526 {
9527  p.GetP(strat->lmBin);
9528  if (strat->homog) strat->initEcart(&p);
9529  strat->redTailChange=FALSE;
9531  p.pCleardenom();
9532  if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) {
9533  p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9534  p.pCleardenom();
9535  if (strat->redTailChange)
9536  p.t_p=NULL;
9537  }
9538  }
9539 
9540  assume(strat->tailRing == p.tailRing);
9541  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9542 
9543  int i, j, pos;
9544  poly tp = strat->T[tj].p;
9545 
9546  /* enter p to T set */
9547  enterT(p, strat);
9548 
9549  for (j = 0; j <= strat->sl; ++j) {
9550  if (pLtCmp(tp, strat->S[j]) == 0) {
9551  break;
9552  }
9553  }
9554  /* it may be that the exchanged element
9555  * is until now only in T and not in S */
9556  if (j <= strat->sl) {
9557  deleteInS(j, strat);
9558  }
9559 
9560  pos = posInS(strat, strat->sl, p.p, p.ecart);
9561 
9562  pp_Test(p.p, currRing, p.tailRing);
9563  assume(p.FDeg == p.pFDeg());
9564 
9565  /* remove useless pairs from L set */
9566  for (i = 0; i <= strat->Ll; ++i) {
9567  if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0) {
9568  deleteInL(strat->L, &(strat->Ll), i, strat);
9569  i--;
9570  continue;
9571  }
9572  if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0) {
9573  deleteInL(strat->L, &(strat->Ll), i, strat);
9574  i--;
9575  }
9576  }
9577  /* generate new pairs with p, probably removing older, now useless pairs */
9578  superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9579  /* enter p to S set */
9580  strat->enterS(p, pos, strat, strat->tl);
9581 }

◆ sba()

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

Definition at line 2536 of file kstd2.cc.

2537 {
2538  // ring order stuff:
2539  // in sba we have (until now) two possibilities:
2540  // 1. an incremental computation w.r.t. (C,monomial order)
2541  // 2. a (possibly non-incremental) computation w.r.t. the
2542  // induced Schreyer order.
2543  // The corresponding orders are computed in sbaRing(), depending
2544  // on the flag strat->sbaOrder
2545 #if SBA_PRINT_ZERO_REDUCTIONS
2546  long zeroreductions = 0;
2547 #endif
2548 #if SBA_PRINT_PRODUCT_CRITERION
2549  long product_criterion = 0;
2550 #endif
2551 #if SBA_PRINT_SIZE_G
2552  int size_g = 0;
2553  int size_g_non_red = 0;
2554 #endif
2555 #if SBA_PRINT_SIZE_SYZ
2556  long size_syz = 0;
2557 #endif
2558  // global variable
2559 #if SBA_PRINT_REDUCTION_STEPS
2560  sba_reduction_steps = 0;
2561  sba_interreduction_steps = 0;
2562 #endif
2563 #if SBA_PRINT_OPERATIONS
2564  sba_operations = 0;
2565  sba_interreduction_operations = 0;
2566 #endif
2567 
2568  ideal F1 = F0;
2569  ring sRing, currRingOld;
2570  currRingOld = currRing;
2571  if (strat->sbaOrder == 1 || strat->sbaOrder == 3)
2572  {
2573  sRing = sbaRing(strat);
2574  if (sRing!=currRingOld)
2575  {
2576  rChangeCurrRing (sRing);
2577  F1 = idrMoveR (F0, currRingOld, currRing);
2578  }
2579  }
2580  ideal F;
2581  // sort ideal F
2582  //Put the SigDrop element on the correct position (think of sbaEnterS)
2583  //We also sort them
2584  if(rField_is_Ring(currRing) && strat->sigdrop)
2585  {
2586  #if 1
2587  F = idInit(IDELEMS(F1),F1->rank);
2588  for (int i=0; i<IDELEMS(F1);++i)
2589  F->m[i] = F1->m[i];
2590  if(strat->sbaEnterS >= 0)
2591  {
2592  poly dummy;
2593  dummy = pCopy(F->m[0]); //the sigdrop element
2594  for(int i = 0;i<strat->sbaEnterS;i++)
2595  F->m[i] = F->m[i+1];
2596  F->m[strat->sbaEnterS] = dummy;
2597  }
2598  #else
2599  F = idInit(1,F1->rank);
2600  //printf("\nBefore the initial block sorting:\n");idPrint(F1);
2601  F->m[0] = F1->m[0];
2602  int pos;
2603  if(strat->sbaEnterS >= 0)
2604  {
2605  for(int i=1;i<=strat->sbaEnterS;i++)
2606  {
2607  pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS);
2608  idInsertPolyOnPos(F,F1->m[i],pos);
2609  }
2610  for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++)
2611  {
2612  pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F));
2613  idInsertPolyOnPos(F,F1->m[i],pos);
2614  }
2615  poly dummy;
2616  dummy = pCopy(F->m[0]); //the sigdrop element
2617  for(int i = 0;i<strat->sbaEnterS;i++)
2618  F->m[i] = F->m[i+1];
2619  F->m[strat->sbaEnterS] = dummy;
2620  }
2621  else
2622  {
2623  for(int i=1;i<IDELEMS(F1);i++)
2624  {
2625  pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F));
2626  idInsertPolyOnPos(F,F1->m[i],pos);
2627  }
2628  }
2629  #endif
2630  //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar();
2631  }
2632  else
2633  {
2634  F = idInit(IDELEMS(F1),F1->rank);
2635  intvec *sort = idSort(F1);
2636  for (int i=0; i<sort->length();++i)
2637  F->m[i] = F1->m[(*sort)[i]-1];
2639  {
2640  // put the monomials after the sbaEnterS polynomials
2641  //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F);
2642  int nrmon = 0;
2643  for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--)
2644  {
2645  //pWrite(F->m[i]);
2646  if(F->m[i] != NULL && pNext(F->m[i]) == NULL)
2647  {
2648  poly mon = F->m[i];
2649  for(j = i;j>strat->sbaEnterS+nrmon+1;j--)
2650  {
2651  F->m[j] = F->m[j-1];
2652  }
2653  F->m[j] = mon;
2654  nrmon++;
2655  }
2656  //idPrint(F);
2657  }
2658  }
2659  }
2660  //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar();
2662  strat->sigdrop = FALSE;
2663  strat->nrsyzcrit = 0;
2664  strat->nrrewcrit = 0;
2665 #if SBA_INTERRED_START
2666  F = kInterRed(F,NULL);
2667 #endif
2668 #if F5DEBUG
2669  printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
2670  rWrite (currRing);
2671  printf("ordSgn = %d\n",currRing->OrdSgn);
2672  printf("\n");
2673 #endif
2674  int srmax,lrmax, red_result = 1;
2675  int olddeg,reduc;
2676  int hilbeledeg=1,hilbcount=0,minimcnt=0;
2677  LObject L;
2678  BOOLEAN withT = TRUE;
2679  strat->max_lower_index = 0;
2680  //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2681  initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/
2682  initSbaPos(strat);
2683  initHilbCrit(F,Q,&hilb,strat);
2684  initSba(F,strat);
2685  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2686  /*Shdl=*/initSbaBuchMora(F, Q,strat);
2687  idTest(strat->Shdl);
2688  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2689  srmax = strat->sl;
2690  reduc = olddeg = lrmax = 0;
2691 #ifndef NO_BUCKETS
2692  if (!TEST_OPT_NOT_BUCKETS)
2693  strat->use_buckets = 1;
2694 #endif
2695 
2696  // redtailBBa against T for inhomogenous input
2697  // if (!TEST_OPT_OLDSTD)
2698  // withT = ! strat->homog;
2699 
2700  // strat->posInT = posInT_pLength;
2701  kTest_TS(strat);
2702 
2703 #ifdef HAVE_TAIL_RING
2704  if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2705  kStratInitChangeTailRing(strat);
2706 #endif
2707  if (BVERBOSE(23))
2708  {
2709  if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2710  if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2711  kDebugPrint(strat);
2712  }
2713  // We add the elements directly in S from the previous loop
2714  if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0)
2715  {
2716  for(int i = 0;i<strat->sbaEnterS;i++)
2717  {
2718  //Update: now the element is at the corect place
2719  //i+1 because on the 0 position is the sigdrop element
2720  enterT(strat->L[strat->Ll-(i)],strat);
2721  strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl);
2722  }
2723  strat->Ll = strat->Ll - strat->sbaEnterS;
2724  strat->sbaEnterS = -1;
2725  }
2726  kTest_TS(strat);
2727 #ifdef KDEBUG
2728  //kDebugPrint(strat);
2729 #endif
2730  /* compute------------------------------------------------------- */
2731  while (strat->Ll >= 0)
2732  {
2733  if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
2734  #ifdef KDEBUG
2735  if (TEST_OPT_DEBUG) messageSets(strat);
2736  #endif
2737  if (strat->Ll== 0) strat->interpt=TRUE;
2738  /*
2739  if (TEST_OPT_DEGBOUND
2740  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2741  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2742  {
2743 
2744  //stops computation if
2745  // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2746  //a predefined number Kstd1_deg
2747  while ((strat->Ll >= 0)
2748  && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2749  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2750  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2751  )
2752  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2753  if (strat->Ll<0) break;
2754  else strat->noClearS=TRUE;
2755  }
2756  */
2757  if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)
2758  {
2759  strat->currIdx = pGetComp(strat->L[strat->Ll].sig);
2760 #if F5C
2761  // 1. interreduction of the current standard basis
2762  // 2. generation of new principal syzygy rules for syzCriterion
2763  f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
2764  lrmax, reduc, Q, w, hilb );
2765 #endif
2766  // initialize new syzygy rules for the next iteration step
2767  initSyzRules(strat);
2768  }
2769  /*********************************************************************
2770  * interrreduction step is done, we can go on with the next iteration
2771  * step of the signature-based algorithm
2772  ********************************************************************/
2773  /* picks the last element from the lazyset L */
2774  strat->P = strat->L[strat->Ll];
2775  strat->Ll--;
2776 
2778  strat->sbaEnterS = pGetComp(strat->P.sig) - 1;
2779  /* reduction of the element chosen from L */
2780  if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1))
2781  {
2782  //#if 1
2783 #ifdef DEBUGF5
2784  PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
2785  PrintS("-------------------------------------------------\n");
2786  pWrite(strat->P.sig);
2787  pWrite(pHead(strat->P.p));
2788  pWrite(pHead(strat->P.p1));
2789  pWrite(pHead(strat->P.p2));
2790  PrintS("-------------------------------------------------\n");
2791 #endif
2792  if (pNext(strat->P.p) == strat->tail)
2793  {
2794  // deletes the short spoly
2795  /*
2796  if (rField_is_Ring(currRing))
2797  pLmDelete(strat->P.p);
2798  else
2799  pLmFree(strat->P.p);
2800 */
2801  // TODO: needs some masking
2802  // TODO: masking needs to vanish once the signature
2803  // sutff is completely implemented
2804  strat->P.p = NULL;
2805  poly m1 = NULL, m2 = NULL;
2806 
2807  // check that spoly creation is ok
2808  while (strat->tailRing != currRing &&
2809  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2810  {
2811  assume(m1 == NULL && m2 == NULL);
2812  // if not, change to a ring where exponents are at least
2813  // large enough
2814  if (!kStratChangeTailRing(strat))
2815  {
2816  WerrorS("OVERFLOW...");
2817  break;
2818  }
2819  }
2820  // create the real one
2821  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2822  strat->tailRing, m1, m2, strat->R);
2823 
2824  }
2825  else if (strat->P.p1 == NULL)
2826  {
2827  if (strat->minim > 0)
2828  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2829  // for input polys, prepare reduction
2830  if(!rField_is_Ring(currRing))
2831  strat->P.PrepareRed(strat->use_buckets);
2832  }
2833  if (strat->P.p == NULL && strat->P.t_p == NULL)
2834  {
2835  red_result = 0;
2836  }
2837  else
2838  {
2839  //#if 1
2840 #ifdef DEBUGF5
2841  PrintS("Poly before red: ");
2842  pWrite(pHead(strat->P.p));
2843  pWrite(strat->P.sig);
2844 #endif
2845 #if SBA_PRODUCT_CRITERION
2846  if (strat->P.prod_crit)
2847  {
2848 #if SBA_PRINT_PRODUCT_CRITERION
2849  product_criterion++;
2850 #endif
2851  int pos = posInSyz(strat, strat->P.sig);
2852  enterSyz(strat->P, strat, pos);
2853  kDeleteLcm(&strat->P);
2854  red_result = 2;
2855  }
2856  else
2857  {
2858  red_result = strat->red(&strat->P,strat);
2859  }
2860 #else
2861  red_result = strat->red(&strat->P,strat);
2862 #endif
2863  }
2864  }
2865  else
2866  {
2867  /*
2868  if (strat->P.lcm != NULL)
2869  pLmFree(strat->P.lcm);
2870  */
2871  red_result = 2;
2872  }
2874  {
2875  if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig)))
2876  {
2877  strat->P.p = pNeg(strat->P.p);
2878  strat->P.sig = pNeg(strat->P.sig);
2879  }
2880  strat->P.pLength = pLength(strat->P.p);
2881  if(strat->P.sig != NULL)
2882  strat->P.sevSig = pGetShortExpVector(strat->P.sig);
2883  if(strat->P.p != NULL)
2884  strat->P.sev = pGetShortExpVector(strat->P.p);
2885  }
2886  //sigdrop case
2887  if(rField_is_Ring(currRing) && strat->sigdrop)
2888  {
2889  //First reduce it as much as one can
2890  red_result = redRing(&strat->P,strat);
2891  if(red_result == 0)
2892  {
2893  strat->sigdrop = FALSE;
2894  pDelete(&strat->P.sig);
2895  strat->P.sig = NULL;
2896  }
2897  else
2898  {
2899  strat->enterS(strat->P, 0, strat, strat->tl);
2900  if (TEST_OPT_PROT)
2901  PrintS("-");
2902  break;
2903  }
2904  }
2905  if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax)
2906  {
2907  strat->sigdrop = TRUE;
2908  break;
2909  }
2910 
2911  if (errorreported) break;
2912 
2913 //#if 1
2914 #ifdef DEBUGF5
2915  if (red_result != 0)
2916  {
2917  PrintS("Poly after red: ");
2918  pWrite(pHead(strat->P.p));
2919  pWrite(strat->P.GetLmCurrRing());
2920  pWrite(strat->P.sig);
2921  printf("%d\n",red_result);
2922  }
2923 #endif
2924  if (TEST_OPT_PROT)
2925  {
2926  if(strat->P.p != NULL)
2927  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2928  &olddeg,&reduc,strat, red_result);
2929  else
2930  message((strat->honey ? strat->P.ecart : 0),
2931  &olddeg,&reduc,strat, red_result);
2932  }
2933 
2934  if (strat->overflow)
2935  {
2936  if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2937  }
2938  // reduction to non-zero new poly
2939  if (red_result == 1)
2940  {
2941  // get the polynomial (canonicalize bucket, make sure P.p is set)
2942  strat->P.GetP(strat->lmBin);
2943 
2944  // sig-safe computations may lead to wrong FDeg computation, thus we need
2945  // to recompute it to make sure everything is alright
2946  (strat->P).FDeg = (strat->P).pFDeg();
2947  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2948  // but now, for entering S, T, we reset it
2949  // in the inhomogeneous case: FDeg == pFDeg
2950  if (strat->homog) strat->initEcart(&(strat->P));
2951 
2952  /* statistic */
2953  if (TEST_OPT_PROT) PrintS("s");
2954 
2955  //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2956  // in F5E we know that the last reduced element is already the
2957  // the one with highest signature
2958  int pos = strat->sl+1;
2959 
2960  // reduce the tail and normalize poly
2961  // in the ring case we cannot expect LC(f) = 1,
2962  // therefore we call pCleardenom instead of pNorm
2963  #ifdef HAVE_RINGS
2964  poly beforetailred;
2966  beforetailred = pCopy(strat->P.sig);
2967  #endif
2968 #if SBA_TAIL_RED
2970  {
2972  strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
2973  }
2974  else
2975  {
2976  if (strat->sbaOrder != 2)
2977  {
2979  {
2980  strat->P.pCleardenom();
2982  {
2983  strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
2984  strat->P.pCleardenom();
2985  }
2986  }
2987  else
2988  {
2989  strat->P.pNorm();
2991  strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
2992  }
2993  }
2994  }
2995  // It may happen that we have lost the sig in redtailsba
2996  // It cannot reduce to 0 since here we are doing just tail reduction.
2997  // Best case scenerio: remains the leading term
2998  if(rField_is_Ring(currRing) && strat->sigdrop)
2999  {
3000  strat->enterS(strat->P, 0, strat, strat->tl);
3001  break;
3002  }
3003 #endif
3005  {
3006  if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1)
3007  {
3008  strat->sigdrop = TRUE;
3009  //Reduce it as much as you can
3010  red_result = redRing(&strat->P,strat);
3011  if(red_result == 0)
3012  {
3013  //It reduced to 0, cancel the sigdrop
3014  strat->sigdrop = FALSE;
3015  p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL;
3016  }
3017  else
3018  {
3019  strat->enterS(strat->P, 0, strat, strat->tl);
3020  break;
3021  }
3022  }
3023  p_Delete(&beforetailred,currRing);
3024  // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing
3025  if(strat->P.p == NULL)
3026  goto case_when_red_result_changed;
3027  }
3028  // remove sigsafe label since it is no longer valid for the next element to
3029  // be reduced
3030  if (strat->sbaOrder == 1)
3031  {
3032  for (int jj = 0; jj<strat->tl+1; jj++)
3033  {
3034  if (pGetComp(strat->T[jj].sig) == strat->currIdx)
3035  {
3036  strat->T[jj].is_sigsafe = FALSE;
3037  }
3038  }
3039  }
3040  else
3041  {
3042  for (int jj = 0; jj<strat->tl+1; jj++)
3043  {
3044  strat->T[jj].is_sigsafe = FALSE;
3045  }
3046  }
3047 #ifdef KDEBUG
3048  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3049 #endif /* KDEBUG */
3050 
3051  // min_std stuff
3052  if ((strat->P.p1==NULL) && (strat->minim>0))
3053  {
3054  if (strat->minim==1)
3055  {
3056  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
3057  p_Delete(&strat->P.p2, currRing, strat->tailRing);
3058  }
3059  else
3060  {
3061  strat->M->m[minimcnt]=strat->P.p2;
3062  strat->P.p2=NULL;
3063  }
3064  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
3065  pNext(strat->M->m[minimcnt])
3066  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
3067  strat->tailRing, currRing,
3068  currRing->PolyBin);
3069  minimcnt++;
3070  }
3071 
3072  // enter into S, L, and T
3073  //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3074  enterT(strat->P, strat);
3075  strat->T[strat->tl].is_sigsafe = FALSE;
3076  /*
3077  printf("hier\n");
3078  pWrite(strat->P.GetLmCurrRing());
3079  pWrite(strat->P.sig);
3080  */
3081  if (rField_is_Ring(currRing))
3082  superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3083  else
3084  enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3085  if(rField_is_Ring(currRing) && strat->sigdrop)
3086  break;
3088  strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing);
3089  strat->enterS(strat->P, pos, strat, strat->tl);
3090  if(strat->sbaOrder != 1)
3091  {
3092  BOOLEAN overwrite = FALSE;
3093  for (int tk=0; tk<strat->sl+1; tk++)
3094  {
3095  if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))
3096  {
3097  //printf("TK %d / %d\n",tk,strat->sl);
3098  overwrite = FALSE;
3099  break;
3100  }
3101  }
3102  //printf("OVERWRITE %d\n",overwrite);
3103  if (overwrite)
3104  {
3105  int cmp = pGetComp(strat->P.sig);
3106  int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3107  p_GetExpV (strat->P.p,vv,currRing);
3108  p_SetExpV (strat->P.sig, vv,currRing);
3109  p_SetComp (strat->P.sig,cmp,currRing);
3110 
3111  strat->P.sevSig = pGetShortExpVector (strat->P.sig);
3112  int i;
3113  LObject Q;
3114  for(int ps=0;ps<strat->sl+1;ps++)
3115  {
3116 
3117  strat->newt = TRUE;
3118  if (strat->syzl == strat->syzmax)
3119  {
3120  pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);
3121  strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
3122  (strat->syzmax)*sizeof(unsigned long),
3123  ((strat->syzmax)+setmaxTinc)
3124  *sizeof(unsigned long));
3125  strat->syzmax += setmaxTinc;
3126  }
3127  Q.sig = pCopy(strat->P.sig);
3128  // add LM(F->m[i]) to the signature to get a Schreyer order
3129  // without changing the underlying polynomial ring at all
3130  if (strat->sbaOrder == 0)
3131  p_ExpVectorAdd (Q.sig,strat->S[ps],currRing);
3132  // since p_Add_q() destroys all input
3133  // data we need to recreate help
3134  // each time
3135  // ----------------------------------------------------------
3136  // in the Schreyer order we always know that the multiplied
3137  // module monomial strat->P.sig gives the leading monomial of
3138  // the corresponding principal syzygy
3139  // => we do not need to compute the "real" syzygy completely
3140  poly help = p_Copy(strat->sig[ps],currRing);
3141  p_ExpVectorAdd (help,strat->P.p,currRing);
3142  Q.sig = p_Add_q(Q.sig,help,currRing);
3143  //printf("%d. SYZ ",i+1);
3144  //pWrite(strat->syz[i]);
3145  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
3146  i = posInSyz(strat, Q.sig);
3147  enterSyz(Q, strat, i);
3148  }
3149  }
3150  }
3151  // deg - idx - lp/rp
3152  // => we need to add syzygies with indices > pGetComp(strat->P.sig)
3153  if(strat->sbaOrder == 0 || strat->sbaOrder == 3)
3154  {
3155  int cmp = pGetComp(strat->P.sig);
3156  unsigned max_cmp = IDELEMS(F);
3157  int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3158  p_GetExpV (strat->P.p,vv,currRing);
3159  LObject Q;
3160  int pos;
3161  int idx = __p_GetComp(strat->P.sig,currRing);
3162  //printf("++ -- adding syzygies -- ++\n");
3163  // if new element is the first one in this index
3164  if (strat->currIdx < idx)
3165  {
3166  for (int i=0; i<strat->sl; ++i)
3167  {
3168  Q.sig = p_Copy(strat->P.sig,currRing);
3169  p_ExpVectorAdd(Q.sig,strat->S[i],currRing);
3170  poly help = p_Copy(strat->sig[i],currRing);
3171  p_ExpVectorAdd(help,strat->P.p,currRing);
3172  Q.sig = p_Add_q(Q.sig,help,currRing);
3173  //pWrite(Q.sig);
3174  pos = posInSyz(strat, Q.sig);
3175  enterSyz(Q, strat, pos);
3176  }
3177  strat->currIdx = idx;
3178  }
3179  else
3180  {
3181  // if the element is not the first one in the given index we build all
3182  // possible syzygies with elements of higher index
3183  for (unsigned i=cmp+1; i<=max_cmp; ++i)
3184  {
3185  pos = -1;
3186  for (int j=0; j<strat->sl; ++j)
3187  {
3188  if (__p_GetComp(strat->sig[j],currRing) == i)
3189  {
3190  pos = j;
3191  break;
3192  }
3193  }
3194  if (pos != -1)
3195  {
3196  Q.sig = p_One(currRing);
3197  p_SetExpV(Q.sig, vv, currRing);
3198  // F->m[i-1] corresponds to index i
3199  p_ExpVectorAdd(Q.sig,F->m[i-1],currRing);
3200  p_SetComp(Q.sig, i, currRing);
3201  poly help = p_Copy(strat->P.sig,currRing);
3202  p_ExpVectorAdd(help,strat->S[pos],currRing);
3203  Q.sig = p_Add_q(Q.sig,help,currRing);
3204  if (strat->sbaOrder == 0)
3205  {
3206  if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn)
3207  {
3208  pos = posInSyz(strat, Q.sig);
3209  enterSyz(Q, strat, pos);
3210  }
3211  }
3212  else
3213  {
3214  pos = posInSyz(strat, Q.sig);
3215  enterSyz(Q, strat, pos);
3216  }
3217  }
3218  }
3219  //printf("++ -- done adding syzygies -- ++\n");
3220  }
3221  }
3222 //#if 1
3223 #if DEBUGF50
3224  printf("---------------------------\n");
3225  Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);
3226  PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl]));
3227  PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]);
3228 #endif
3229  /*
3230  if (newrules)
3231  {
3232  newrules = FALSE;
3233  }
3234  */
3235 #if 0
3236  int pl=pLength(strat->P.p);
3237  if (pl==1)
3238  {
3239  //if (TEST_OPT_PROT)
3240  //PrintS("<1>");
3241  }
3242  else if (pl==2)
3243  {
3244  //if (TEST_OPT_PROT)
3245  //PrintS("<2>");
3246  }
3247 #endif
3248  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
3249 // Print("[%d]",hilbeledeg);
3250  kDeleteLcm(&strat->P);
3251  if (strat->sl>srmax) srmax = strat->sl;
3252  }
3253  else
3254  {
3255  case_when_red_result_changed:
3256  // adds signature of the zero reduction to
3257  // strat->syz. This is the leading term of
3258  // syzygy and can be used in syzCriterion()
3259  // the signature is added if and only if the
3260  // pair was not detected by the rewritten criterion in strat->red = redSig
3261  if (red_result!=2)
3262  {
3263 #if SBA_PRINT_ZERO_REDUCTIONS
3264  zeroreductions++;
3265 #endif
3266  if(rField_is_Ring(currRing) && strat->P.p == NULL && strat->P.sig == NULL)
3267  {
3268  //Catch the case when p = 0, sig = 0
3269  }
3270  else
3271  {
3272  int pos = posInSyz(strat, strat->P.sig);
3273  enterSyz(strat->P, strat, pos);
3274  //#if 1
3275  #ifdef DEBUGF5
3276  Print("ADDING STUFF TO SYZ : ");
3277  //pWrite(strat->P.p);
3278  pWrite(strat->P.sig);
3279  #endif
3280  }
3281  }
3282  if (strat->P.p1 == NULL && strat->minim > 0)
3283  {
3284  p_Delete(&strat->P.p2, currRing, strat->tailRing);
3285  }
3286  }
3287 
3288 #ifdef KDEBUG
3289  memset(&(strat->P), 0, sizeof(strat->P));
3290 #endif /* KDEBUG */
3291  kTest_TS(strat);
3292  }
3293  #if 0
3294  if(strat->sigdrop)
3295  printf("\nSigDrop!\n");
3296  else
3297  printf("\nEnded with no SigDrop\n");
3298  #endif
3299 // Clean strat->P for the next sba call
3300  if(rField_is_Ring(currRing) && strat->sigdrop)
3301  {
3302  //This is used to know how many elements can we directly add to S in the next run
3303  if(strat->P.sig != NULL)
3304  strat->sbaEnterS = pGetComp(strat->P.sig)-1;
3305  //else we already set it at the beggining of the loop
3306  #ifdef KDEBUG
3307  memset(&(strat->P), 0, sizeof(strat->P));
3308  #endif /* KDEBUG */
3309  }
3310 #ifdef KDEBUG
3311  if (TEST_OPT_DEBUG) messageSets(strat);
3312 #endif /* KDEBUG */
3313 
3314  if (TEST_OPT_SB_1)
3315  {
3316  if(!rField_is_Ring(currRing))
3317  {
3318  int k=1;
3319  int j;
3320  while(k<=strat->sl)
3321  {
3322  j=0;
3323  loop
3324  {
3325  if (j>=k) break;
3326  clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
3327  j++;
3328  }
3329  k++;
3330  }
3331  }
3332  }
3333  /* complete reduction of the standard basis--------- */
3334  if (TEST_OPT_REDSB)
3335  {
3336  completeReduce(strat);
3337  if (strat->completeReduce_retry)
3338  {
3339  // completeReduce needed larger exponents, retry
3340  // to reduce with S (instead of T)
3341  // and in currRing (instead of strat->tailRing)
3342 #ifdef HAVE_TAIL_RING
3343  if(currRing->bitmask>strat->tailRing->bitmask)
3344  {
3345  strat->completeReduce_retry=FALSE;
3346  cleanT(strat);strat->tailRing=currRing;
3347  int i;
3348  for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3349  completeReduce(strat);
3350  }
3351  if (strat->completeReduce_retry)
3352 #endif
3353  Werror("exponent bound is %ld",currRing->bitmask);
3354  }
3355  }
3356  else if (TEST_OPT_PROT) PrintLn();
3357 
3358 #if SBA_PRINT_SIZE_SYZ
3359  // that is correct, syzl is counting one too far
3360  size_syz = strat->syzl;
3361 #endif
3362 // if (TEST_OPT_WEIGHTM)
3363 // {
3364 // pRestoreDegProcs(pFDegOld, pLDegOld);
3365 // if (ecartWeights)
3366 // {
3367 // omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
3368 // ecartWeights=NULL;
3369 // }
3370 // }
3371  if (TEST_OPT_PROT) messageStatSBA(hilbcount,strat);
3372  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3373 #if SBA_PRINT_SIZE_G
3374  size_g_non_red = IDELEMS(strat->Shdl);
3375 #endif
3376  if(!rField_is_Ring(currRing))
3377  exitSba(strat);
3378  // I have to add the initial input polynomials which where not used (p1 and p2 = NULL)
3379  #ifdef HAVE_RINGS
3380  int k;
3382  {
3383  //for(k = strat->sl;k>=0;k--)
3384  // {printf("\nS[%i] = %p\n",k,strat->Shdl->m[k]);pWrite(strat->Shdl->m[k]);}
3385  k = strat->Ll;
3386  #if 1
3387  // 1 - adds just the unused ones, 0 - adds everthing
3388  for(;k>=0 && (strat->L[k].p1 != NULL || strat->L[k].p2 != NULL);k--)
3389  {
3390  //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);
3391  deleteInL(strat->L,&strat->Ll,k,strat);
3392  }
3393  #endif
3394  //for(int kk = strat->sl;kk>=0;kk--)
3395  // {printf("\nS[%i] = %p\n",kk,strat->Shdl->m[kk]);pWrite(strat->Shdl->m[kk]);}
3396  //idPrint(strat->Shdl);
3397  //printf("\nk = %i\n",k);
3398  for(;k>=0 && strat->L[k].p1 == NULL && strat->L[k].p2 == NULL;k--)
3399  {
3400  //printf("\nAdded k = %i\n",k);
3401  strat->enterS(strat->L[k], strat->sl+1, strat, strat->tl);
3402  //printf("\nThis elements was added from L on pos %i\n",strat->sl);pWrite(strat->S[strat->sl]);pWrite(strat->sig[strat->sl]);
3403  }
3404  }
3405  // 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
3406  #if 0
3407  if(strat->sigdrop && rField_is_Ring(currRing))
3408  {
3409  for(k=strat->sl;k>=0;k--)
3410  {
3411  printf("\nsig[%i] = ",i);pWrite(strat->sig[k]);
3412  if(strat->sig[k] == NULL)
3413  strat->sig[k] = pCopy(strat->sig[k-1]);
3414  }
3415  }
3416  #endif
3417  #endif
3418  //Never do this - you will damage S
3419  //idSkipZeroes(strat->Shdl);
3420  //idPrint(strat->Shdl);
3421 
3422  if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld)
3423  {
3424  rChangeCurrRing (currRingOld);
3425  F0 = idrMoveR (F1, sRing, currRing);
3426  strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing);
3427  rChangeCurrRing (sRing);
3429  exitSba(strat);
3430  rChangeCurrRing (currRingOld);
3431  if(strat->tailRing == sRing)
3432  strat->tailRing = currRing;
3433  rDelete (sRing);
3434  }
3435  if(rField_is_Ring(currRing) && !strat->sigdrop)
3436  id_DelDiv(strat->Shdl, currRing);
3437  if(!rField_is_Ring(currRing))
3438  id_DelDiv(strat->Shdl, currRing);
3439  idSkipZeroes(strat->Shdl);
3440  idTest(strat->Shdl);
3441 
3442 #if SBA_PRINT_SIZE_G
3443  size_g = IDELEMS(strat->Shdl);
3444 #endif
3445 #ifdef DEBUGF5
3446  printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));
3447  int oo = 0;
3448  while (oo<IDELEMS(strat->Shdl))
3449  {
3450  printf(" %d. ",oo+1);
3451  pWrite(pHead(strat->Shdl->m[oo]));
3452  oo++;
3453  }
3454 #endif
3455 #if SBA_PRINT_ZERO_REDUCTIONS
3456  printf("----------------------------------------------------------\n");
3457  printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3458  zeroreductions = 0;
3459 #endif
3460 #if SBA_PRINT_REDUCTION_STEPS
3461  printf("----------------------------------------------------------\n");
3462  printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3463 #endif
3464 #if SBA_PRINT_OPERATIONS
3465  printf("OPERATIONS: %ld\n",sba_operations);
3466 #endif
3467 #if SBA_PRINT_REDUCTION_STEPS
3468  printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3469  printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3470 #endif
3471 #if SBA_PRINT_OPERATIONS
3472  printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3473 #endif
3474 #if SBA_PRINT_REDUCTION_STEPS
3475  printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3476  printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3477  sba_interreduction_steps = 0;
3478  sba_reduction_steps = 0;
3479 #endif
3480 #if SBA_PRINT_OPERATIONS
3481  printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3482  sba_interreduction_operations = 0;
3483  sba_operations = 0;
3484 #endif
3485 #if SBA_PRINT_SIZE_G
3486  printf("----------------------------------------------------------\n");
3487  printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3488  size_g = 0;
3489  size_g_non_red = 0;
3490 #endif
3491 #if SBA_PRINT_SIZE_SYZ
3492  printf("SIZE OF SYZ: %ld\n",size_syz);
3493  printf("----------------------------------------------------------\n");
3494  size_syz = 0;
3495 #endif
3496 #if SBA_PRINT_PRODUCT_CRITERION
3497  printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3498  product_criterion = 0;
3499 #endif
3500  return (strat->Shdl);
3501 }
Definition: intvec.h:23
int blockredmax
Definition: kutil.h:364
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition: kutil.h:290
int sbaEnterS
Definition: kutil.h:361
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:186
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3400
void initSba(ideal F, kStrategy strat)
Definition: kstd1.cc:1390
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kstd2.cc:1398
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:3848
void initSbaPos(kStrategy strat)
Definition: kutil.cc:10318
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4885
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4841
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
Definition: kutil.cc:11529
void messageStatSBA(int hilbcount, kStrategy strat)
Definition: kutil.cc:8008
void initSyzRules(kStrategy strat)
Definition: kutil.cc:8418
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:10420
void exitSba(kStrategy strat)
Definition: kutil.cc:10493
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
Definition: kutil.cc:5213
void initSbaCrit(kStrategy strat)
Definition: kutil.cc:9948
#define help
Definition: libparse.cc:1230
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1474
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1459
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 1676 of file kutil.cc.

1677 {
1678  if(strat->sl < 0) return FALSE;
1679  int i;
1680  for(i=0;i<strat->sl;i++)
1681  {
1682  //Construct the gcd pair between h and S[i]
1683  number d, s, t;
1684  poly m1, m2, gcd;
1685  d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1686  if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1687  {
1688  nDelete(&d);
1689  nDelete(&s);
1690  nDelete(&t);
1691  }
1692  else
1693  {
1694  k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1695  pSetCoeff0(m1, s);
1696  pSetCoeff0(m2, t);
1697  pSetCoeff0(gcd, d);
1698  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);
1699  poly pSigMult = p_Copy(h->sig,currRing);
1700  poly sSigMult = p_Copy(strat->sig[i],currRing);
1701  pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1702  sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1703  p_LmDelete(m1, strat->tailRing);
1704  p_LmDelete(m2, strat->tailRing);
1705  poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1706  if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1707  {
1708  pDelete(&h->p);
1709  h->p = gcd;
1710  pDelete(&h->sig);
1711  h->sig = pairsig;
1712  pNext(h->sig) = NULL;
1713  strat->initEcart(h);
1714  h->sev = pGetShortExpVector(h->p);
1715  h->sevSig = pGetShortExpVector(h->sig);
1716  h->i_r1 = -1;h->i_r2 = -1;
1717  if(h->lcm != NULL)
1718  {
1719  pLmDelete(h->lcm);
1720  h->lcm = NULL;
1721  }
1722  if (currRing!=strat->tailRing)
1723  h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1724  return TRUE;
1725  }
1726  //Delete what you didn't use
1727  pDelete(&gcd);
1728  pDelete(&pairsig);
1729  }
1730  }
1731  return FALSE;
1732 }
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:1007
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:990

◆ sbaRing()

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

Definition at line 11529 of file kutil.cc.

11530 {
11531  int n = rBlocks(r); // Including trailing zero!
11532  // if sbaOrder == 1 => use (C,monomial order from r)
11533  if (strat->sbaOrder == 1)
11534  {
11535  if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11536  {
11537  return r;
11538  }
11539  ring res = rCopy0(r, TRUE, FALSE);
11540  res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11541  res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11542  res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11543  int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11544  res->wvhdl = wvhdl;
11545  for (int i=1; i<n; i++)
11546  {
11547  res->order[i] = r->order[i-1];
11548  res->block0[i] = r->block0[i-1];
11549  res->block1[i] = r->block1[i-1];
11550  res->wvhdl[i] = r->wvhdl[i-1];
11551  }
11552 
11553  // new 1st block
11554  res->order[0] = ringorder_C; // Prefix
11555  // removes useless secondary component order if defined in old ring
11556  for (int i=rBlocks(res); i>0; --i)
11557  {
11558  if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11559  {
11560  res->order[i] = (rRingOrder_t)0;
11561  }
11562  }
11563  rComplete(res, 1);
11564 #ifdef HAVE_PLURAL
11565  if (rIsPluralRing(r))
11566  {
11567  if ( nc_rComplete(r, res, false) ) // no qideal!
11568  {
11569 #ifndef SING_NDEBUG
11570  WarnS("error in nc_rComplete");
11571 #endif
11572  // cleanup?
11573 
11574  // rDelete(res);
11575  // return r;
11576 
11577  // just go on..
11578  }
11579  }
11580 #endif
11581  strat->tailRing = res;
11582  return (res);
11583  }
11584  // if sbaOrder == 3 => degree - position - ring order
11585  if (strat->sbaOrder == 3)
11586  {
11587  ring res = rCopy0(r, TRUE, FALSE);
11588  res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11589  res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11590  res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11591  int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11592  res->wvhdl = wvhdl;
11593  for (int i=2; i<n+2; i++)
11594  {
11595  res->order[i] = r->order[i-2];
11596  res->block0[i] = r->block0[i-2];
11597  res->block1[i] = r->block1[i-2];
11598  res->wvhdl[i] = r->wvhdl[i-2];
11599  }
11600 
11601  // new 1st block
11602  res->order[0] = ringorder_a; // Prefix
11603  res->block0[0] = 1;
11604  res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11605  for (int i=0; i<res->N; ++i)
11606  res->wvhdl[0][i] = 1;
11607  res->block1[0] = si_min(res->N, rVar(res));
11608  // new 2nd block
11609  res->order[1] = ringorder_C; // Prefix
11610  res->wvhdl[1] = NULL;
11611  // removes useless secondary component order if defined in old ring
11612  for (int i=rBlocks(res); i>1; --i)
11613  {
11614  if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11615  {
11616  res->order[i] = (rRingOrder_t)0;
11617  }
11618  }
11619  rComplete(res, 1);
11620 #ifdef HAVE_PLURAL
11621  if (rIsPluralRing(r))
11622  {
11623  if ( nc_rComplete(r, res, false) ) // no qideal!
11624  {
11625 #ifndef SING_NDEBUG
11626  WarnS("error in nc_rComplete");
11627 #endif
11628  // cleanup?
11629 
11630  // rDelete(res);
11631  // return r;
11632 
11633  // just go on..
11634  }
11635  }
11636 #endif
11637  strat->tailRing = res;
11638  return (res);
11639  }
11640 
11641  // not sbaOrder == 1 => use Schreyer order
11642  // this is done by a trick when initializing the signatures
11643  // in initSLSba():
11644  // Instead of using the signature 1e_i for F->m[i], we start
11645  // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11646  // Schreyer order w.r.t. the underlying monomial order.
11647  // => we do not need to change the underlying polynomial ring at all!
11648 
11649  // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11650 
11651  /*
11652  else
11653  {
11654  ring res = rCopy0(r, FALSE, FALSE);
11655  // Create 2 more blocks for prefix/suffix:
11656  res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11657  res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11658  res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11659  int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11660 
11661  // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11662  // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11663 
11664  // new 1st block
11665  int j = 0;
11666  res->order[j] = ringorder_IS; // Prefix
11667  res->block0[j] = res->block1[j] = 0;
11668  // wvhdl[j] = NULL;
11669  j++;
11670 
11671  for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11672  {
11673  res->order [j] = r->order [i];
11674  res->block0[j] = r->block0[i];
11675  res->block1[j] = r->block1[i];
11676 
11677  if (r->wvhdl[i] != NULL)
11678  {
11679  wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11680  } // else wvhdl[j] = NULL;
11681  }
11682 
11683  // new last block
11684  res->order [j] = ringorder_IS; // Suffix
11685  res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11686  // wvhdl[j] = NULL;
11687  j++;
11688 
11689  // res->order [j] = 0; // The End!
11690  res->wvhdl = wvhdl;
11691 
11692  // j == the last zero block now!
11693  assume(j == (n+1));
11694  assume(res->order[0]==ringorder_IS);
11695  assume(res->order[j-1]==ringorder_IS);
11696  assume(res->order[j]==0);
11697 
11698  if (complete)
11699  {
11700  rComplete(res, 1);
11701 
11702 #ifdef HAVE_PLURAL
11703  if (rIsPluralRing(r))
11704  {
11705  if ( nc_rComplete(r, res, false) ) // no qideal!
11706  {
11707  }
11708  }
11709  assume(rIsPluralRing(r) == rIsPluralRing(res));
11710 #endif
11711 
11712 
11713 #ifdef HAVE_PLURAL
11714  ring old_ring = r;
11715 
11716 #endif
11717 
11718  if (r->qideal!=NULL)
11719  {
11720  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11721 
11722  assume(idRankFreeModule(res->qideal, res) == 0);
11723 
11724 #ifdef HAVE_PLURAL
11725  if( rIsPluralRing(res) )
11726  if( nc_SetupQuotient(res, r, true) )
11727  {
11728  // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11729  }
11730 
11731 #endif
11732  assume(idRankFreeModule(res->qideal, res) == 0);
11733  }
11734 
11735 #ifdef HAVE_PLURAL
11736  assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11737  assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11738  assume(rIsSCA(res) == rIsSCA(old_ring));
11739  assume(ncRingType(res) == ncRingType(old_ring));
11740 #endif
11741  }
11742  strat->tailRing = res;
11743  return res;
11744  }
11745  */
11746 
11747  assume(FALSE);
11748  return(NULL);
11749 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:141
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5534
static int rBlocks(ring r)
Definition: ring.h:563
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 4831 of file kutil.cc.

4832 {
4834  // enter also zero divisor * poly, if this is non zero and of smaller degree
4835  if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat);
4836  initenterstrongPairs(h, k, ecart, 0, strat, atR);
4837  initenterpairs(h, k, ecart, 0, strat, atR);
4838  clearSbatch(h, k, pos, strat);
4839 }
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4805
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4522
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4604

◆ superenterpairsSig()

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

Definition at line 4841 of file kutil.cc.

4842 {
4844  // enter also zero divisor * poly, if this is non zero and of smaller degree
4845  if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4846  if(strat->sigdrop) return;
4847  initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4848  if(strat->sigdrop) return;
4849  initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4850  if(strat->sigdrop) return;
4851  clearSbatch(h, k, pos, strat);
4852 }
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3894
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4577
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4687

◆ syzCriterion()

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

Definition at line 7045 of file kutil.cc.

7046 {
7047 //#if 1
7048 #ifdef DEBUGF5
7049  PrintS("syzygy criterion checks: ");
7050  pWrite(sig);
7051 #endif
7052  for (int k=0; k<strat->syzl; k++)
7053  {
7054  //printf("-%d",k);
7055 //#if 1
7056 #ifdef DEBUGF5
7057  Print("checking with: %d / %d -- \n",k,strat->syzl);
7058  pWrite(pHead(strat->syz[k]));
7059 #endif
7060  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
7061  && (!rField_is_Ring(currRing) ||
7062  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
7063  {
7064 //#if 1
7065 #ifdef DEBUGF5
7066  PrintS("DELETE!\n");
7067 #endif
7068  strat->nrsyzcrit++;
7069  //printf("- T -\n\n");
7070  return TRUE;
7071  }
7072  }
7073  //printf("- F -\n\n");
7074  return FALSE;
7075 }

◆ syzCriterionInc()

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

Definition at line 7080 of file kutil.cc.

7081 {
7082 //#if 1
7083  if(sig == NULL)
7084  return FALSE;
7085 #ifdef DEBUGF5
7086  PrintS("--- syzygy criterion checks: ");
7087  pWrite(sig);
7088 #endif
7089  int comp = __p_GetComp(sig, currRing);
7090  int min, max;
7091  if (comp<=1)
7092  return FALSE;
7093  else
7094  {
7095  min = strat->syzIdx[comp-2];
7096  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
7097  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
7098  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
7099  if (comp == strat->currIdx)
7100  {
7101  max = strat->syzl;
7102  }
7103  else
7104  {
7105  max = strat->syzIdx[comp-1];
7106  }
7107  for (int k=min; k<max; k++)
7108  {
7109 #ifdef F5DEBUG
7110  Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
7111  Print("checking with: %d -- ",k);
7112  pWrite(pHead(strat->syz[k]));
7113 #endif
7114  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
7115  && (!rField_is_Ring(currRing) ||
7116  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
7117  {
7118  strat->nrsyzcrit++;
7119  return TRUE;
7120  }
7121  }
7122  return FALSE;
7123  }
7124 }
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 4138 of file kutil.cc.

4139 {
4140  return 1L << arg;
4141 }

◆ updateResult()

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

Definition at line 10533 of file kutil.cc.

10534 {
10535  int l;
10536  if (strat->ak>0)
10537  {
10538  for (l=IDELEMS(r)-1;l>=0;l--)
10539  {
10540  if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10541  {
10542  pDelete(&r->m[l]); // and set it to NULL
10543  }
10544  }
10545  int q;
10546  poly p;
10547  if(!rField_is_Ring(currRing))
10548  {
10549  for (l=IDELEMS(r)-1;l>=0;l--)
10550  {
10551  if ((r->m[l]!=NULL)
10552  //&& (strat->syzComp>0)
10553  //&& (pGetComp(r->m[l])<=strat->syzComp)
10554  )
10555  {
10556  for(q=IDELEMS(Q)-1; q>=0;q--)
10557  {
10558  if ((Q->m[q]!=NULL)
10559  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10560  {
10561  if (TEST_OPT_REDSB)
10562  {
10563  p=r->m[l];
10564  r->m[l]=kNF(Q,NULL,p);
10565  pDelete(&p);
10566  }
10567  else
10568  {
10569  pDelete(&r->m[l]); // and set it to NULL
10570  }
10571  break;
10572  }
10573  }
10574  }
10575  }
10576  }
10577  #ifdef HAVE_RINGS
10578  else
10579  {
10580  for (l=IDELEMS(r)-1;l>=0;l--)
10581  {
10582  if ((r->m[l]!=NULL)
10583  //&& (strat->syzComp>0)
10584  //&& (pGetComp(r->m[l])<=strat->syzComp)
10585  )
10586  {
10587  for(q=IDELEMS(Q)-1; q>=0;q--)
10588  {
10589  if ((Q->m[q]!=NULL)
10590  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10591  {
10592  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10593  {
10594  if (TEST_OPT_REDSB)
10595  {
10596  p=r->m[l];
10597  r->m[l]=kNF(Q,NULL,p);
10598  pDelete(&p);
10599  }
10600  else
10601  {
10602  pDelete(&r->m[l]); // and set it to NULL
10603  }
10604  break;
10605  }
10606  }
10607  }
10608  }
10609  }
10610  }
10611  #endif
10612  }
10613  else
10614  {
10615  int q;
10616  poly p;
10617  BOOLEAN reduction_found=FALSE;
10618  if (!rField_is_Ring(currRing))
10619  {
10620  for (l=IDELEMS(r)-1;l>=0;l--)
10621  {
10622  if (r->m[l]!=NULL)
10623  {
10624  for(q=IDELEMS(Q)-1; q>=0;q--)
10625  {
10626  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10627  {
10628  if (TEST_OPT_REDSB)
10629  {
10630  p=r->m[l];
10631  r->m[l]=kNF(Q,NULL,p);
10632  pDelete(&p);
10633  reduction_found=TRUE;
10634  }
10635  else
10636  {
10637  pDelete(&r->m[l]); // and set it to NULL
10638  }
10639  break;
10640  }
10641  }
10642  }
10643  }
10644  }
10645  #ifdef HAVE_RINGS
10646  //Also need divisibility of the leading coefficients
10647  else
10648  {
10649  for (l=IDELEMS(r)-1;l>=0;l--)
10650  {
10651  if (r->m[l]!=NULL)
10652  {
10653  for(q=IDELEMS(Q)-1; q>=0;q--)
10654  {
10655  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10656  {
10657  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10658  {
10659  if (TEST_OPT_REDSB)
10660  {
10661  p=r->m[l];
10662  r->m[l]=kNF(Q,NULL,p);
10663  pDelete(&p);
10664  reduction_found=TRUE;
10665  }
10666  else
10667  {
10668  pDelete(&r->m[l]); // and set it to NULL
10669  }
10670  break;
10671  }
10672  }
10673  }
10674  }
10675  }
10676  }
10677  #endif
10678  if (/*TEST_OPT_REDSB &&*/ reduction_found)
10679  {
10680  #ifdef HAVE_RINGS
10682  {
10683  for (l=IDELEMS(r)-1;l>=0;l--)
10684  {
10685  if (r->m[l]!=NULL)
10686  {
10687  for(q=IDELEMS(r)-1;q>=0;q--)
10688  {
10689  if ((l!=q)
10690  && (r->m[q]!=NULL)
10691  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10692  &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10693  )
10694  {
10695  //If they are equal then take the one with the smallest length
10696  if(pLmDivisibleBy(r->m[q],r->m[l])
10697  && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10698  && (pLength(r->m[q]) < pLength(r->m[l]) ||
10699  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10700  {
10701  pDelete(&r->m[l]);
10702  break;
10703  }
10704  else
10705  pDelete(&r->m[q]);
10706  }
10707  }
10708  }
10709  }
10710  }
10711  else
10712  #endif
10713  {
10714  for (l=IDELEMS(r)-1;l>=0;l--)
10715  {
10716  if (r->m[l]!=NULL)
10717  {
10718  for(q=IDELEMS(r)-1;q>=0;q--)
10719  {
10720  if ((l!=q)
10721  && (r->m[q]!=NULL)
10722  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10723  )
10724  {
10725  //If they are equal then take the one with the smallest length
10726  if(pLmDivisibleBy(r->m[q],r->m[l])
10727  &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10728  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10729  {
10730  pDelete(&r->m[l]);
10731  break;
10732  }
10733  else
10734  pDelete(&r->m[q]);
10735  }
10736  }
10737  }
10738  }
10739  }
10740  }
10741  }
10742  idSkipZeroes(r);
10743 }
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2824

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 9036 of file kutil.cc.

9037 {
9038  LObject h;
9039  int i, suc=0;
9040  poly redSi=NULL;
9041  BOOLEAN change,any_change;
9042 // Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
9043 // for (i=0; i<=(strat->sl); i++)
9044 // {
9045 // Print("s%d:",i);
9046 // if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
9047 // pWrite(strat->S[i]);
9048 // }
9049 // Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
9050  any_change=FALSE;
9052  {
9053  while (suc != -1)
9054  {
9055  i=suc+1;
9056  while (i<=strat->sl)
9057  {
9058  change=FALSE;
9060  any_change = FALSE;
9061  if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
9062  {
9063  redSi = pHead(strat->S[i]);
9064  strat->S[i] = redBba(strat->S[i],i-1,strat);
9065  //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
9066  // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
9067  if (pCmp(redSi,strat->S[i])!=0)
9068  {
9069  change=TRUE;
9070  any_change=TRUE;
9071  #ifdef KDEBUG
9072  if (TEST_OPT_DEBUG)
9073  {
9074  PrintS("reduce:");
9075  wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
9076  }
9077  #endif
9078  if (TEST_OPT_PROT)
9079  {
9080  if (strat->S[i]==NULL)
9081  PrintS("V");
9082  else
9083  PrintS("v");
9084  mflush();
9085  }
9086  }
9087  pLmDelete(&redSi);
9088  if (strat->S[i]==NULL)
9089  {
9090  deleteInS(i,strat);
9091  i--;
9092  }
9093  else if (change)
9094  {
9096  {
9097  if (TEST_OPT_CONTENTSB)
9098  {
9099  number n;
9100  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
9101  if (!nIsOne(n))
9102  {
9104  denom->n=nInvers(n);
9105  denom->next=DENOMINATOR_LIST;
9106  DENOMINATOR_LIST=denom;
9107  }
9108  nDelete(&n);
9109  }
9110  else
9111  {
9112  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
9113  }
9114  }
9115  else
9116  {
9117  pNorm(strat->S[i]);
9118  }
9119  strat->sevS[i] = pGetShortExpVector(strat->S[i]);
9120  }
9121  }
9122  i++;
9123  }
9124  if (any_change) reorderS(&suc,strat);
9125  else break;
9126  }
9127  if (toT)
9128  {
9129  for (i=0; i<=strat->sl; i++)
9130  {
9131  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9132  {
9133  h.p = redtailBba(strat->S[i],i-1,strat);
9135  {
9136  h.pCleardenom();// also does remove Content
9137  }
9138  }
9139  else
9140  {
9141  h.p = strat->S[i];
9142  }
9143  strat->initEcart(&h);
9144  if (strat->honey)
9145  {
9146  strat->ecartS[i] = h.ecart;
9147  }
9148  if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
9149  else assume(strat->sevS[i] == pGetShortExpVector(h.p));
9150  h.sev = strat->sevS[i];
9151  /*puts the elements of S also to T*/
9152  strat->initEcart(&h);
9153  enterT(h,strat);
9154  strat->S_2_R[i] = strat->tl;
9155 #ifdef HAVE_SHIFTBBA
9156  if (currRing->isLPring)
9157  enterTShift(h, strat);
9158 #endif
9159  }
9160  }
9161  }
9162  else
9163  {
9164  while (suc != -1)
9165  {
9166  i=suc;
9167  while (i<=strat->sl)
9168  {
9169  change=FALSE;
9170  if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
9171  {
9172  redSi=pHead((strat->S)[i]);
9173  (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
9174  if ((strat->S)[i]==NULL)
9175  {
9176  deleteInS(i,strat);
9177  i--;
9178  }
9179  else if (pCmp((strat->S)[i],redSi)!=0)
9180  {
9181  any_change=TRUE;
9182  h.p = strat->S[i];
9183  strat->initEcart(&h);
9184  strat->ecartS[i] = h.ecart;
9186  {
9187  if (TEST_OPT_CONTENTSB)
9188  {
9189  number n;
9190  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
9191  if (!nIsOne(n))
9192  {
9194  denom->n=nInvers(n);
9195  denom->next=DENOMINATOR_LIST;
9196  DENOMINATOR_LIST=denom;
9197  }
9198  nDelete(&n);
9199  }
9200  else
9201  {
9202  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
9203  }
9204  }
9205  else
9206  {
9207  pNorm(strat->S[i]); // == h.p
9208  }
9209  h.sev = pGetShortExpVector(h.p);
9210  strat->sevS[i] = h.sev;
9211  }
9212  pLmDelete(&redSi);
9213  kTest(strat);
9214  }
9215  i++;
9216  }
9217 #ifdef KDEBUG
9218  kTest(strat);
9219 #endif
9220  if (any_change) reorderS(&suc,strat);
9221  else { suc=-1; break; }
9222  if (h.p!=NULL)
9223  {
9224  if (!strat->kHEdgeFound)
9225  {
9226  /*strat->kHEdgeFound =*/ HEckeTest(h.p,strat);
9227  }
9228  if (strat->kHEdgeFound)
9229  newHEdge(strat);
9230  }
9231  }
9232  for (i=0; i<=strat->sl; i++)
9233  {
9234  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9235  {
9236  strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
9237  strat->initEcart(&h);
9238  strat->ecartS[i] = h.ecart;
9239  h.sev = pGetShortExpVector(h.p);
9240  strat->sevS[i] = h.sev;
9241  }
9242  else
9243  {
9244  h.p = strat->S[i];
9245  h.ecart=strat->ecartS[i];
9246  h.sev = strat->sevS[i];
9247  h.length = h.pLength = pLength(h.p);
9248  }
9249  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9250  cancelunit1(&h,&suc,strat->sl,strat);
9251  h.SetpFDeg();
9252  /*puts the elements of S also to T*/
9253  enterT(h,strat);
9254  strat->S_2_R[i] = strat->tl;
9255 #ifdef HAVE_SHIFTBBA
9256  if (currRing->isLPring)
9257  enterTShift(h, strat);
9258 #endif
9259  }
9260  if (suc!= -1) updateS(toT,strat);
9261  }
9262 #ifdef KDEBUG
9263  kTest(strat);
9264 #endif
9265 }
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8991
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8967
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition: kutil.cc:8879
void HEckeTest(poly pp, kStrategy strat)
Definition: kutil.cc:468
void reorderS(int *suc, kStrategy strat)
Definition: kutil.cc:4982
BOOLEAN newHEdge(kStrategy strat)
Definition: kutil.cc:10867

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

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 176 of file kutil.h.

◆ test_PosInL

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

Definition at line 866 of file kutil.h.

◆ test_PosInT

EXTERN_VAR int(* test_PosInT) (const TSet T, const int tl, LObject &h) ( const TSet  T,
const int  tl,
LObject h 
)

Definition at line 865 of file kutil.h.