My Project  debian-1:4.1.1-p2+ds-4
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)
 
#define messageSets(s)   do {} while (0)
 
#define kTest(A)   (TRUE)
 
#define kTest_TS(A)   (TRUE)
 
#define kTest_T(T)   (TRUE)
 
#define kTest_S(T)   (TRUE)
 
#define kTest_L(T)   (TRUE)
 

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 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)
 
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 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 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 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 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)
 
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 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, int uptodeg, int lV)
 
void initBuchMoraShift (ideal F, ideal Q, kStrategy strat)
 
void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV)
 
void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS, int uptodeg, int lV)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR, int uptodeg, int lV)
 
void updateSShift (kStrategy strat, int uptodeg, int lV)
 
void initBbaShift (kStrategy strat)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
int redFirstShift (LObject *h, kStrategy strat)
 
ideal freegb (ideal I, int uptodeg, int lVblock)
 
ideal bbaShift (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat, int uptodeg, int lV)
 

Variables

denominator_list DENOMINATOR_LIST
 
int strat_nr
 
int HCord
 
int(* test_PosInT )(const TSet T, const int tl, LObject &h)
 
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 60 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 388 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 26 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 44 of file kutil.h.

◆ kTest

#define kTest (   A)    (TRUE)

Definition at line 640 of file kutil.h.

◆ kTest_L

#define kTest_L (   T)    (TRUE)

Definition at line 644 of file kutil.h.

◆ kTest_S

#define kTest_S (   T)    (TRUE)

Definition at line 643 of file kutil.h.

◆ kTest_T

#define kTest_T (   T)    (TRUE)

Definition at line 642 of file kutil.h.

◆ kTest_TS

#define kTest_TS (   A)    (TRUE)

Definition at line 641 of file kutil.h.

◆ messageSets

#define messageSets (   s)    do {} while (0)

Definition at line 532 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 45 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 28 of file kutil.h.

◆ setmaxL

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

Definition at line 29 of file kutil.h.

◆ setmaxLinc

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

Definition at line 30 of file kutil.h.

◆ setmaxT

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

Definition at line 32 of file kutil.h.

◆ setmaxTinc

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

Definition at line 33 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 58 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 48 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 53 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 55 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 52 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 54 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 50 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 49 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 7087 of file kutil.cc.

7089 {
7091  return FALSE;
7092  poly p1 = pOne();
7093  poly p2 = pOne();
7094  for (int ii=strat->sl; ii>start; ii--)
7095  {
7096  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
7097  {
7098  p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
7099  p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
7100  if (!(pLmCmp(p1,p2) == 1))
7101  {
7102  pDelete(&p1);
7103  pDelete(&p2);
7104  return TRUE;
7105  }
7106  }
7107  }
7108  pDelete(&p1);
7109  pDelete(&p2);
7110  return FALSE;

◆ arriRewCriterionPre()

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

Definition at line 7112 of file kutil.cc.

7114 {
7115  //Over Rings, there are still some changes to do: considering coeffs
7117  return FALSE;
7118  int found = -1;
7119  for (int i=strat->Bl; i>-1; i--) {
7120  if (pLmEqual(strat->B[i].sig,sig))
7121  {
7122  found = i;
7123  break;
7124  }
7125  }
7126  if (found != -1)
7127  {
7128  if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
7129  {
7130  deleteInL(strat->B,&strat->Bl,found,strat);
7131  }
7132  else
7133  {
7134  return TRUE;
7135  }
7136  }
7137  poly p1 = pOne();
7138  poly p2 = pOne();
7139  for (int ii=strat->sl; ii>-1; ii--)
7140  {
7141  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
7142  {
7143  p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
7144  p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
7145  if (!(pLmCmp(p1,p2) == 1))
7146  {
7147  pDelete(&p1);
7148  pDelete(&p2);
7149  return TRUE;
7150  }
7151  }
7152  }
7153  pDelete(&p1);
7154  pDelete(&p2);
7155  return FALSE;

◆ arriRewDummy()

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

Definition at line 1132 of file kInline.h.

1141 {

◆ bba()

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

Definition at line 1919 of file kstd2.cc.

1920 {
1921  int red_result = 1;
1922  int olddeg,reduc;
1923  int hilbeledeg=1,hilbcount=0,minimcnt=0;
1924  BOOLEAN withT = FALSE;
1925  BITSET save;
1926  SI_SAVE_OPT1(save);
1927 
1928  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
1930  initBuchMoraPosRing(strat);
1931  else
1932  initBuchMoraPos(strat);
1933  initHilbCrit(F,Q,&hilb,strat);
1934  initBba(strat);
1935  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
1936  /*Shdl=*/initBuchMora(F, Q,strat);
1937  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
1938  reduc = olddeg = 0;
1939 
1940 #ifndef NO_BUCKETS
1941  if (!TEST_OPT_NOT_BUCKETS)
1942  strat->use_buckets = 1;
1943 #endif
1944  // redtailBBa against T for inhomogenous input
1945  if (!TEST_OPT_OLDSTD)
1946  withT = ! strat->homog;
1947 
1948  // strat->posInT = posInT_pLength;
1949  kTest_TS(strat);
1950 
1951 #ifdef HAVE_TAIL_RING
1952  if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
1953  kStratInitChangeTailRing(strat);
1954 #endif
1955  if (BVERBOSE(23))
1956  {
1957  if (test_PosInT!=NULL) strat->posInT=test_PosInT;
1958  if (test_PosInL!=NULL) strat->posInL=test_PosInL;
1959  kDebugPrint(strat);
1960  }
1961 
1962 
1963 #ifdef KDEBUG
1964  //kDebugPrint(strat);
1965 #endif
1966  /* compute------------------------------------------------------- */
1967  while (strat->Ll >= 0)
1968  {
1969  #ifdef KDEBUG
1970  if (TEST_OPT_DEBUG) messageSets(strat);
1971  #endif
1972  if (siCntrlc)
1973  {
1974  while (strat->Ll >= 0)
1975  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1976  strat->noClearS=TRUE;
1977  }
1978  if (TEST_OPT_DEGBOUND
1979  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
1980  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
1981  {
1982  /*
1983  *stops computation if
1984  * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
1985  *a predefined number Kstd1_deg
1986  */
1987  while ((strat->Ll >= 0)
1988  && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
1989  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
1990  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
1991  )
1992  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1993  if (strat->Ll<0) break;
1994  else strat->noClearS=TRUE;
1995  }
1996  if (strat->Ll== 0) strat->interpt=TRUE;
1997  /* picks the last element from the lazyset L */
1998  strat->P = strat->L[strat->Ll];
1999  strat->Ll--;
2000 
2001  if (pNext(strat->P.p) == strat->tail)
2002  {
2003  // deletes the short spoly
2004  if (rField_is_Ring(currRing))
2005  pLmDelete(strat->P.p);
2006  else
2007  pLmFree(strat->P.p);
2008  strat->P.p = NULL;
2009  poly m1 = NULL, m2 = NULL;
2010 
2011  // check that spoly creation is ok
2012  while (strat->tailRing != currRing &&
2013  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2014  {
2015  assume(m1 == NULL && m2 == NULL);
2016  // if not, change to a ring where exponents are at least
2017  // large enough
2018  if (!kStratChangeTailRing(strat))
2019  {
2020  WerrorS("OVERFLOW...");
2021  break;
2022  }
2023  }
2024  // create the real one
2025  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2026  strat->tailRing, m1, m2, strat->R);
2027  }
2028  else if (strat->P.p1 == NULL)
2029  {
2030  if (strat->minim > 0)
2031  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2032  // for input polys, prepare reduction
2033  strat->P.PrepareRed(strat->use_buckets);
2034  }
2035 
2036  if (strat->P.p == NULL && strat->P.t_p == NULL)
2037  {
2038  red_result = 0;
2039  }
2040  else
2041  {
2042  if (TEST_OPT_PROT)
2043  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2044  &olddeg,&reduc,strat, red_result);
2045 
2046  /* reduction of the element chosen from L */
2047  red_result = strat->red(&strat->P,strat);
2048  if (errorreported) break;
2049  }
2050 
2051  if (strat->overflow)
2052  {
2053  if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2054  }
2055 
2056  // reduction to non-zero new poly
2057  if (red_result == 1)
2058  {
2059  // get the polynomial (canonicalize bucket, make sure P.p is set)
2060  strat->P.GetP(strat->lmBin);
2061  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2062  // but now, for entering S, T, we reset it
2063  // in the inhomogeneous case: FDeg == pFDeg
2064  if (strat->homog) strat->initEcart(&(strat->P));
2065 
2066  /* statistic */
2067  if (TEST_OPT_PROT) PrintS("s");
2068 
2069  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2070 
2071  // reduce the tail and normalize poly
2072  // in the ring case we cannot expect LC(f) = 1,
2073  // therefore we call pCleardenom instead of pNorm
2074  strat->redTailChange=FALSE;
2076  {
2077  strat->P.pCleardenom();
2079  {
2080  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2081  strat->P.pCleardenom();
2082  if (strat->redTailChange) { strat->P.t_p=NULL; }
2083  }
2084  }
2085  else
2086  {
2087  strat->P.pNorm();
2089  {
2090  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2091  if (strat->redTailChange) { strat->P.t_p=NULL; }
2092  }
2093  }
2094 
2095 #ifdef KDEBUG
2096  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2097 #endif /* KDEBUG */
2098 
2099  // min_std stuff
2100  if ((strat->P.p1==NULL) && (strat->minim>0))
2101  {
2102  if (strat->minim==1)
2103  {
2104  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2105  p_Delete(&strat->P.p2, currRing, strat->tailRing);
2106  }
2107  else
2108  {
2109  strat->M->m[minimcnt]=strat->P.p2;
2110  strat->P.p2=NULL;
2111  }
2112  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2113  pNext(strat->M->m[minimcnt])
2114  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2115  strat->tailRing, currRing,
2116  currRing->PolyBin);
2117  minimcnt++;
2118  }
2119 
2120  // enter into S, L, and T
2121  if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2122  {
2123  enterT(strat->P, strat);
2124  if (rField_is_Ring(currRing))
2125  superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2126  else
2127  enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2128  // posInS only depends on the leading term
2129  strat->enterS(strat->P, pos, strat, strat->tl);
2130 #if 0
2131  int pl=pLength(strat->P.p);
2132  if (pl==1)
2133  {
2134  //if (TEST_OPT_PROT)
2135  //PrintS("<1>");
2136  }
2137  else if (pl==2)
2138  {
2139  //if (TEST_OPT_PROT)
2140  //PrintS("<2>");
2141  }
2142 #endif
2143  }
2144  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2145 // Print("[%d]",hilbeledeg);
2146  if (strat->P.lcm!=NULL)
2147  {
2148  if (rField_is_Ring(currRing)) pLmDelete(strat->P.lcm);
2149  else pLmFree(strat->P.lcm);
2150  strat->P.lcm=NULL;
2151  }
2152  if (strat->s_poly!=NULL)
2153  {
2154  // the only valid entries are: strat->P.p,
2155  // strat->tailRing (read-only, keep it)
2156  // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2157  if (strat->s_poly(strat))
2158  {
2159  // we are called AFTER enterS, i.e. if we change P
2160  // we have to add it also to S/T
2161  // and add pairs
2162  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2163  enterT(strat->P, strat);
2164  if (rField_is_Ring(currRing))
2165  superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2166  else
2167  enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2168  strat->enterS(strat->P, pos, strat, strat->tl);
2169  }
2170  }
2171  }
2172  else if (strat->P.p1 == NULL && strat->minim > 0)
2173  {
2174  p_Delete(&strat->P.p2, currRing, strat->tailRing);
2175  }
2176 
2177 #ifdef KDEBUG
2178  memset(&(strat->P), 0, sizeof(strat->P));
2179 #endif /* KDEBUG */
2180  kTest_TS(strat);
2181  }
2182 #ifdef KDEBUG
2183  if (TEST_OPT_DEBUG) messageSets(strat);
2184 #endif /* KDEBUG */
2185 
2186  if (TEST_OPT_SB_1)
2187  {
2188  if(!rField_is_Ring(currRing))
2189  {
2190  int k=1;
2191  int j;
2192  while(k<=strat->sl)
2193  {
2194  j=0;
2195  loop
2196  {
2197  if (j>=k) break;
2198  clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2199  j++;
2200  }
2201  k++;
2202  }
2203  }
2204  }
2205  /* complete reduction of the standard basis--------- */
2206  if (TEST_OPT_REDSB)
2207  {
2208  completeReduce(strat);
2209  if (strat->completeReduce_retry)
2210  {
2211  // completeReduce needed larger exponents, retry
2212  // to reduce with S (instead of T)
2213  // and in currRing (instead of strat->tailRing)
2214 #ifdef HAVE_TAIL_RING
2215  if(currRing->bitmask>strat->tailRing->bitmask)
2216  {
2217  strat->completeReduce_retry=FALSE;
2218  cleanT(strat);strat->tailRing=currRing;
2219  int i;
2220  for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2221  completeReduce(strat);
2222  }
2223  if (strat->completeReduce_retry)
2224 #endif
2225  Werror("exponent bound is %ld",currRing->bitmask);
2226  }
2227  }
2228  else if (TEST_OPT_PROT) PrintLn();
2229  if (!errorreported)
2230  {
2232  {
2233  for(int i = 0;i<=strat->sl;i++)
2234  {
2235  if(!nGreaterZero(pGetCoeff(strat->S[i])))
2236  {
2237  strat->S[i] = pNeg(strat->S[i]);
2238  }
2239  }
2240  finalReduceByMon(strat);
2241  for(int i = 0;i<=strat->sl;i++)
2242  {
2243  if(!nGreaterZero(pGetCoeff(strat->S[i])))
2244  {
2245  strat->S[i] = pNeg(strat->S[i]);
2246  }
2247  }
2248  }
2249  else if (rField_is_Ring(currRing))
2250  finalReduceByMon(strat);
2251  }
2252  /* release temp data-------------------------------- */
2253  exitBuchMora(strat);
2254 // if (TEST_OPT_WEIGHTM)
2255 // {
2256 // pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2257 // if (ecartWeights)
2258 // {
2259 // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2260 // ecartWeights=NULL;
2261 // }
2262 // }
2263  if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
2264  SI_RESTORE_OPT1(save);
2265  if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2266 
2267  idTest(strat->Shdl);
2268 
2269  return (strat->Shdl);
2270 }

◆ bbaShift()

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

Definition at line 3860 of file kstd2.cc.

3863 {
3864  int red_result = 1;
3865  int olddeg,reduc;
3866  int hilbeledeg=1,hilbcount=0,minimcnt=0;
3867  BOOLEAN withT = TRUE; // very important for shifts
3868 
3869  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit, NO CHANGES */
3871  initBuchMoraPosRing(strat);
3872  else
3873  initBuchMoraPos(strat); /*NO CHANGES YET: perhaps later*/
3874  initHilbCrit(F,Q,&hilb,strat); /*NO CHANGES*/
3875  initBbaShift(strat); /* DONE */
3876  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
3877  /*Shdl=*/initBuchMoraShift(F, Q,strat); /* updateS with no toT, i.e. no init for T */
3878  updateSShift(strat,uptodeg,lV); /* initializes T */
3879 
3880  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
3881  reduc = olddeg = 0;
3882  strat->lV=lV;
3883 
3884 #ifndef NO_BUCKETS
3885  if (!TEST_OPT_NOT_BUCKETS)
3886  strat->use_buckets = 1;
3887 #endif
3888 
3889  // redtailBBa against T for inhomogenous input
3890  // if (!TEST_OPT_OLDSTD)
3891  // withT = ! strat->homog;
3892 
3893  // strat->posInT = posInT_pLength;
3894  kTest_TS(strat);
3895 
3896 #ifdef HAVE_TAIL_RING
3897 // kStratInitChangeTailRing(strat);
3898  strat->tailRing=currRing;
3899 #endif
3900 
3901  /* compute------------------------------------------------------- */
3902  while (strat->Ll >= 0)
3903  {
3904 #ifdef KDEBUG
3905  if (TEST_OPT_DEBUG) messageSets(strat);
3906 #endif
3907  if (strat->Ll== 0) strat->interpt=TRUE;
3908  if (TEST_OPT_DEGBOUND
3909  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
3910  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
3911  {
3912  /*
3913  *stops computation if
3914  * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
3915  *a predefined number Kstd1_deg
3916  */
3917  while ((strat->Ll >= 0)
3918  && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
3919  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
3920  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
3921  )
3922  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
3923  if (strat->Ll<0) break;
3924  else strat->noClearS=TRUE;
3925  }
3926  /* picks the last element from the lazyset L */
3927  strat->P = strat->L[strat->Ll];
3928  strat->Ll--;
3929 
3930  if (pNext(strat->P.p) == strat->tail)
3931  {
3932  // deletes the short spoly
3933  pLmFree(strat->P.p);
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  kStratChangeTailRing(strat);
3945  }
3946  // create the real one
3947  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
3948  strat->tailRing, m1, m2, strat->R);
3949  }
3950  else if (strat->P.p1 == NULL)
3951  {
3952  if (strat->minim > 0)
3953  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
3954  // for input polys, prepare reduction
3955  strat->P.PrepareRed(strat->use_buckets);
3956  }
3957 
3958  poly qq;
3959 
3960  /* here in the nonhomog case we shrink the new spoly */
3961 
3962  if ( ! strat->homog)
3963  {
3964  strat->P.GetP(strat->lmBin); // because shifts are counted with .p structure
3965  /* in the nonhomog case we have to shrink the polynomial */
3966  qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink
3967  if (qq != NULL)
3968  {
3969  /* we're here if Shrink is nonzero */
3970  strat->P.p = qq;
3971  strat->P.t_p = NULL;
3972  strat->P.GetP(strat->lmBin);
3973  // update sev and length
3974  strat->initEcart(&(strat->P));
3975  strat->P.sev = pGetShortExpVector(strat->P.p);
3976 // strat->P.FDeg = strat->P.pFDeg();
3977 // strat->P.length = strat->P.pLDeg();
3978 // strat->P.pLength =strat->P.GetpLength(); //pLength(strat->P.p);
3979  }
3980  else
3981  {
3982  /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/
3983 #ifdef KDEBUG
3984  if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0\n");}
3985 #endif
3986  strat->P.p = NULL;
3987  strat->P.t_p = NULL;
3988  }
3989  }
3990  /* end shrinking poly in the nonhomog case */
3991 
3992  if (strat->P.p == NULL && strat->P.t_p == NULL)
3993  {
3994  red_result = 0;
3995  }
3996  else
3997  {
3998  if (TEST_OPT_PROT)
3999  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4000  &olddeg,&reduc,strat, red_result);
4001 
4002  /* reduction of the element chosen from L */
4003  red_result = strat->red(&strat->P,strat);
4004  }
4005 
4006  // reduction to non-zero new poly
4007  if (red_result == 1)
4008  {
4009  /* statistic */
4010  if (TEST_OPT_PROT) PrintS("s");
4011 
4012  // get the polynomial (canonicalize bucket, make sure P.p is set)
4013  strat->P.GetP(strat->lmBin);
4014 
4015  int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4016 
4017  // reduce the tail and normalize poly
4019  {
4020  strat->P.pCleardenom();
4022  {
4023  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4024  strat->P.pCleardenom();
4025  }
4026  }
4027  else
4028  {
4029  strat->P.pNorm();
4031  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4032  }
4033 
4034  // here we must shrink again! and optionally reduce again
4035  // or build shrink into redtailBba!
4036 
4037 #ifdef KDEBUG
4038  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4039 #endif
4040 
4041  // min_std stuff
4042  if ((strat->P.p1==NULL) && (strat->minim>0))
4043  {
4044  if (strat->minim==1)
4045  {
4046  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4047  p_Delete(&strat->P.p2, currRing, strat->tailRing);
4048  }
4049  else
4050  {
4051  strat->M->m[minimcnt]=strat->P.p2;
4052  strat->P.p2=NULL;
4053  }
4054  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4055  pNext(strat->M->m[minimcnt])
4056  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4057  strat->tailRing, currRing,
4058  currRing->PolyBin);
4059  minimcnt++;
4060  }
4061 
4062  /* here in the nonhomog case we shrink the reduced poly AGAIN */
4063 
4064  if ( ! strat->homog)
4065  {
4066  strat->P.GetP(strat->lmBin); // because shifts are counted with .p structure
4067  /* in the nonhomog case we have to shrink the polynomial */
4068  if (strat->P.p!=NULL)
4069  {
4070  qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink
4071  if (qq != NULL)
4072  {
4073  /* we're here if Shrink is nonzero */
4074  strat->P.p = qq; // is not set by Delete
4075  strat->P.t_p = NULL;
4076  strat->P.GetP(strat->lmBin);
4077  // update sev and length
4078  strat->initEcart(&(strat->P));
4079  strat->P.sev = pGetShortExpVector(strat->P.p);
4080  }
4081  else
4082  {
4083  /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/
4084 #ifdef PDEBUG
4085  if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0");PrintLn();}
4086 #endif
4087  strat->P.p = NULL;
4088  strat->P.t_p = NULL;
4089  goto red_shrink2zero;
4090  }
4091  }
4092  else
4093  {
4094  qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink
4095  if (qq != NULL)
4096  {
4097  /* we're here if Shrink is nonzero */
4098  strat->P.p = qq;
4099  strat->P.t_p = NULL;
4100  // update sev and length
4101  strat->initEcart(&(strat->P));
4102  strat->P.sev = pGetShortExpVector(strat->P.p);
4103  }
4104  else
4105  {
4106  /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/
4107 #ifdef PDEBUG
4108  if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0");PrintLn();}
4109 #endif
4110  strat->P.p = NULL;
4111  strat->P.t_p = NULL;
4112  goto red_shrink2zero;
4113  }
4114  }
4115  }
4116  /* end shrinking poly AGAIN in the nonhomog case */
4117 
4118 
4119  // enter into S, L, and T
4120  //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4121  // enterT(strat->P, strat); // this was here before Shift stuff
4122  //enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV); // syntax
4123  // the default value for atT = -1 as in bba
4124  /* strat->P.GetP(); */
4125  // because shifts are counted with .p structure // done before, but ?
4126  int atR=strat->tl+1; // enterTShift introduces T[tl+1], T[tl+2]...
4127  // with T[tl+1]=P.p
4128  enterTShift(strat->P,strat,-1,uptodeg, lV);
4129  enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, atR,uptodeg,lV);
4130  // enterpairsShift(vw,strat->sl,strat->P.ecart,pos,strat, strat->tl,uptodeg,lV);
4131  // posInS only depends on the leading term
4132  strat->enterS(strat->P, pos, strat, atR);
4133 
4134  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4135 // Print("[%d]",hilbeledeg);
4136  if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
4137  }
4138  else
4139  {
4140  red_shrink2zero:
4141  if (strat->P.p1 == NULL && strat->minim > 0)
4142  {
4143  p_Delete(&strat->P.p2, currRing, strat->tailRing);
4144  }
4145  }
4146 #ifdef KDEBUG
4147  memset(&(strat->P), 0, sizeof(strat->P));
4148 #endif
4149  kTest_TS(strat);
4150  }
4151 #ifdef KDEBUG
4152  if (TEST_OPT_DEBUG) messageSets(strat);
4153 #endif
4154  /* complete reduction of the standard basis--------- */
4155  /* shift case: look for elt's in S such that they are divisible by elt in T */
4156  // if (TEST_OPT_SB_1)
4157  if (TEST_OPT_REDSB)
4158  {
4159  int k=0;
4160  int j=-1;
4161  while(k<=strat->sl)
4162  {
4163 // loop
4164 // {
4165 // if (j>=k) break;
4166 // clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
4167 // j++;
4168 // }
4169  LObject Ln (strat->S[k],currRing, strat->tailRing);
4170  Ln.SetShortExpVector();
4171  j = kFindDivisibleByInT(strat, &Ln, j+1);
4172  if (j<0) { k++; j=-1;}
4173  else
4174  {
4175  if ( pLmCmp(strat->S[k],strat->T[j].p) == 0)
4176  {
4177  j = kFindDivisibleByInT(strat, &Ln, j+1);
4178  if (j<0) { k++; j=-1;}
4179  else
4180  {
4181  deleteInS(k,strat);
4182  }
4183  }
4184  else
4185  {
4186  deleteInS(k,strat);
4187  }
4188  }
4189  }
4190  }
4191 
4192  if (TEST_OPT_REDSB)
4193  { completeReduce(strat, TRUE); //shift: withT = TRUE
4194  if (strat->completeReduce_retry)
4195  {
4196  // completeReduce needed larger exponents, retry
4197  // to reduce with S (instead of T)
4198  // and in currRing (instead of strat->tailRing)
4199 #ifdef HAVE_TAIL_RING
4200  if(currRing->bitmask>strat->tailRing->bitmask)
4201  {
4202  strat->completeReduce_retry=FALSE;
4203  cleanT(strat);strat->tailRing=currRing;
4204  int i;
4205  for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
4206  completeReduce(strat);
4207  }
4208  if (strat->completeReduce_retry)
4209 #endif
4210  Werror("exponent bound is %ld",currRing->bitmask);
4211  }
4212  }
4213  else if (TEST_OPT_PROT) PrintLn();
4214 
4215  /* release temp data-------------------------------- */
4216  exitBuchMora(strat);
4217 // if (TEST_OPT_WEIGHTM)
4218 // {
4219 // pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
4220 // if (ecartWeights)
4221 // {
4222 // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
4223 // ecartWeights=NULL;
4224 // }
4225 // }
4226  if (TEST_OPT_PROT) messageStat(hilbcount,strat);
4227  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);

◆ cancelunit()

void cancelunit ( LObject p,
BOOLEAN  inNF = FALSE 
)

Definition at line 331 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3123 of file kutil.cc.

3125 {
3126  int i,j,l;
3127 
3128  /*
3129  *pairtest[i] is TRUE if spoly(S[i],p) == 0.
3130  *In this case all elements in B such
3131  *that their lcm is divisible by the leading term of S[i] can be canceled
3132  */
3133  if (strat->pairtest!=NULL)
3134  {
3135  /*- i.e. there is an i with pairtest[i]==TRUE -*/
3136  for (j=0; j<=strat->sl; j++)
3137  {
3138  if (strat->pairtest[j])
3139  {
3140  for (i=strat->Bl; i>=0; i--)
3141  {
3142  if (pDivisibleBy(strat->S[j],strat->B[i].lcm))
3143  {
3144  deleteInL(strat->B,&strat->Bl,i,strat);
3145  strat->c3++;
3146  }
3147  }
3148  }
3149  }
3150  omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3151  strat->pairtest=NULL;
3152  }
3153  if (strat->Gebauer || strat->fromT)
3154  {
3155  if (strat->sugarCrit)
3156  {
3157  /*
3158  *suppose L[j] == (s,r) and p/lcm(s,r)
3159  *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3160  *and in case the sugar is o.k. then L[j] can be canceled
3161  */
3162  for (j=strat->Ll; j>=0; j--)
3163  {
3164  if (sugarDivisibleBy(ecart,strat->L[j].ecart)
3165  && ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
3166  && pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3167  {
3168  if (strat->L[j].p == strat->tail)
3169  {
3170  deleteInL(strat->L,&strat->Ll,j,strat);
3171  strat->c3++;
3172  }
3173  }
3174  }
3175  /*
3176  *this is GEBAUER-MOELLER:
3177  *in B all elements with the same lcm except the "best"
3178  *(i.e. the last one in B with this property) will be canceled
3179  */
3180  j = strat->Bl;
3181  loop /*cannot be changed into a for !!! */
3182  {
3183  if (j <= 0) break;
3184  i = j-1;
3185  loop
3186  {
3187  if (i < 0) break;
3188  if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3189  {
3190  strat->c3++;
3191  if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart))
3192  {
3193  deleteInL(strat->B,&strat->Bl,i,strat);
3194  j--;
3195  }
3196  else
3197  {
3198  deleteInL(strat->B,&strat->Bl,j,strat);
3199  break;
3200  }
3201  }
3202  i--;
3203  }
3204  j--;
3205  }
3206  }
3207  else /*sugarCrit*/
3208  {
3209  /*
3210  *suppose L[j] == (s,r) and p/lcm(s,r)
3211  *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3212  *and in case the sugar is o.k. then L[j] can be canceled
3213  */
3214  for (j=strat->Ll; j>=0; j--)
3215  {
3216  if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3217  {
3218  if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3219  {
3220  deleteInL(strat->L,&strat->Ll,j,strat);
3221  strat->c3++;
3222  }
3223  }
3224  }
3225  /*
3226  *this is GEBAUER-MOELLER:
3227  *in B all elements with the same lcm except the "best"
3228  *(i.e. the last one in B with this property) will be canceled
3229  */
3230  j = strat->Bl;
3231  loop /*cannot be changed into a for !!! */
3232  {
3233  if (j <= 0) break;
3234  for(i=j-1; i>=0; i--)
3235  {
3236  if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3237  {
3238  strat->c3++;
3239  deleteInL(strat->B,&strat->Bl,i,strat);
3240  j--;
3241  }
3242  }
3243  j--;
3244  }
3245  }
3246  /*
3247  *the elements of B enter L
3248  */
3249  kMergeBintoL(strat);
3250  }
3251  else
3252  {
3253  for (j=strat->Ll; j>=0; j--)
3254  {
3255  if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3256  {
3257  if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3258  {
3259  deleteInL(strat->L,&strat->Ll,j,strat);
3260  strat->c3++;
3261  }
3262  }
3263  }
3264  /*
3265  *this is our MODIFICATION of GEBAUER-MOELLER:
3266  *First the elements of B enter L,
3267  *then we fix a lcm and the "best" element in L
3268  *(i.e the last in L with this lcm and of type (s,p))
3269  *and cancel all the other elements of type (r,p) with this lcm
3270  *except the case the element (s,r) has also the same lcm
3271  *and is on the worst position with respect to (s,p) and (r,p)
3272  */
3273  /*
3274  *B enters to L/their order with respect to B is permutated for elements
3275  *B[i].p with the same leading term
3276  */
3277  kMergeBintoL(strat);
3278  j = strat->Ll;
3279  loop /*cannot be changed into a for !!! */
3280  {
3281  if (j <= 0)
3282  {
3283  /*now L[0] cannot be canceled any more and the tail can be removed*/
3284  if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3285  break;
3286  }
3287  if (strat->L[j].p2 == p)
3288  {
3289  i = j-1;
3290  loop
3291  {
3292  if (i < 0) break;
3293  if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3294  {
3295  /*L[i] could be canceled but we search for a better one to cancel*/
3296  strat->c3++;
3297  if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3298  && (pNext(strat->L[l].p) == strat->tail)
3299  && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3300  && pDivisibleBy(p,strat->L[l].lcm))
3301  {
3302  /*
3303  *"NOT equal(...)" because in case of "equal" the element L[l]
3304  *is "older" and has to be from theoretical point of view behind
3305  *L[i], but we do not want to reorder L
3306  */
3307  strat->L[i].p2 = strat->tail;
3308  /*
3309  *L[l] will be canceled, we cannot cancel L[i] later on,
3310  *so we mark it with "tail"
3311  */
3312  deleteInL(strat->L,&strat->Ll,l,strat);
3313  i--;
3314  }
3315  else
3316  {
3317  deleteInL(strat->L,&strat->Ll,i,strat);
3318  }
3319  j--;
3320  }
3321  i--;
3322  }
3323  }
3324  else if (strat->L[j].p2 == strat->tail)
3325  {
3326  /*now L[j] cannot be canceled any more and the tail can be removed*/
3327  strat->L[j].p2 = p;
3328  }
3329  j--;
3330  }
3331  }

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3336 of file kutil.cc.

3338 {
3339  if (strat->pairtest!=NULL)
3340  {
3341  omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3342  strat->pairtest=NULL;
3343  }
3344  /*
3345  *the elements of B enter L
3346  */
3347  kMergeBintoL(strat);

◆ chainCritSig()

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

Definition at line 3352 of file kutil.cc.

3354 {
3355  int i,j,l;
3356  kMergeBintoLSba(strat);
3357  j = strat->Ll;
3358  loop /*cannot be changed into a for !!! */
3359  {
3360  if (j <= 0)
3361  {
3362  /*now L[0] cannot be canceled any more and the tail can be removed*/
3363  if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3364  break;
3365  }
3366  if (strat->L[j].p2 == p)
3367  {
3368  i = j-1;
3369  loop
3370  {
3371  if (i < 0) break;
3372  if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3373  {
3374  /*L[i] could be canceled but we search for a better one to cancel*/
3375  strat->c3++;
3376  if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3377  && (pNext(strat->L[l].p) == strat->tail)
3378  && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3379  && pDivisibleBy(p,strat->L[l].lcm))
3380  {
3381  /*
3382  *"NOT equal(...)" because in case of "equal" the element L[l]
3383  *is "older" and has to be from theoretical point of view behind
3384  *L[i], but we do not want to reorder L
3385  */
3386  strat->L[i].p2 = strat->tail;
3387  /*
3388  *L[l] will be canceled, we cannot cancel L[i] later on,
3389  *so we mark it with "tail"
3390  */
3391  deleteInL(strat->L,&strat->Ll,l,strat);
3392  i--;
3393  }
3394  else
3395  {
3396  deleteInL(strat->L,&strat->Ll,i,strat);
3397  }
3398  j--;
3399  }
3400  i--;
3401  }
3402  }
3403  else if (strat->L[j].p2 == strat->tail)
3404  {
3405  /*now L[j] cannot be canceled any more and the tail can be removed*/
3406  strat->L[j].p2 = p;
3407  }
3408  j--;
3409  }

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 536 of file kutil.cc.

538 {
539  int i,j;
540  poly p;
541  assume(currRing == strat->tailRing || strat->tailRing != NULL);
542 
543  pShallowCopyDeleteProc p_shallow_copy_delete =
544  (strat->tailRing != currRing ?
546  NULL);
547  for (j=0; j<=strat->tl; j++)
548  {
549  p = strat->T[j].p;
550  strat->T[j].p=NULL;
551  if (strat->T[j].max_exp != NULL)
552  {
553  p_LmFree(strat->T[j].max_exp, strat->tailRing);
554  }
555  i = -1;
556  loop
557  {
558  i++;
559  if (i>strat->sl)
560  {
561  if (strat->T[j].t_p != NULL)
562  {
563  p_Delete(&(strat->T[j].t_p), strat->tailRing);
564  p_LmFree(p, currRing);
565  }
566  else
567  {
568  pDelete(&p);
569  }
570  break;
571  }
572  if (p == strat->S[i])
573  {
574  if (strat->T[j].t_p != NULL)
575  {
576  if (p_shallow_copy_delete!=NULL)
577  {
578  pNext(p) = p_shallow_copy_delete(pNext(p),strat->tailRing,currRing,
579  currRing->PolyBin);
580  }
581  p_LmFree(strat->T[j].t_p, strat->tailRing);
582  }
583  break;
584  }
585  }
586  }
587  strat->tl=-1;

◆ clearS()

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

Definition at line 1107 of file kInline.h.

1109 {
1110  LObject L(p, currRing, strat->tailRing);
1111  return redtailBba_Z(&L, pos, strat);
1112 }
1113 #endif
1114 
1115 KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
1116  kStrategy strat)
1117 {
1118  assume(p_sev == pGetShortExpVector(p));
1119  if (strat->noClearS) return;
1120  #ifdef HAVE_RINGS
1122  {
1123  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1124  return;
1125  if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1126  return;
1127  }
1128  else

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10392 of file kutil.cc.

10400 {
10401  int i;
10402  int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10403  LObject L;
10404 
10405 #ifdef KDEBUG
10406  // need to set this: during tailreductions of T[i], T[i].max is out of
10407  // sync
10408  sloppy_max = TRUE;
10409 #endif
10410 
10411  strat->noTailReduction = FALSE;
10412  //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10413  if (TEST_OPT_PROT)
10414  {
10415  PrintLn();
10416 // if (timerv) writeTime("standard base computed:");
10417  }
10418  if (TEST_OPT_PROT)
10419  {
10420  Print("(S:%d)",strat->sl);mflush();
10421  }
10422  for (i=strat->sl; i>=low; i--)
10423  {
10424  int end_pos=strat->sl;
10425  if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10426  if (strat->ak==0) end_pos=i-1;
10427  TObject* T_j = strat->s_2_t(i);
10428  if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10429  {
10430  L = *T_j;
10431  #ifdef KDEBUG
10432  if (TEST_OPT_DEBUG)
10433  {
10434  Print("test S[%d]:",i);
10435  p_wrp(L.p,currRing,strat->tailRing);
10436  PrintLn();
10437  }
10438  #endif
10440  strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10441  else
10442  strat->S[i] = redtail(&L, strat->sl, strat);
10443  #ifdef KDEBUG
10444  if (TEST_OPT_DEBUG)
10445  {
10446  Print("to (tailR) S[%d]:",i);
10447  p_wrp(strat->S[i],currRing,strat->tailRing);
10448  PrintLn();
10449  }
10450  #endif
10451 
10452  if (strat->redTailChange)
10453  {
10454  if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10455  if (pNext(T_j->p) != NULL)
10456  T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10457  else
10458  T_j->max_exp = NULL;
10459  }
10461  T_j->pCleardenom();
10462  }
10463  else
10464  {
10465  assume(currRing == strat->tailRing);
10466  #ifdef KDEBUG
10467  if (TEST_OPT_DEBUG)
10468  {
10469  Print("test S[%d]:",i);
10470  p_wrp(strat->S[i],currRing,strat->tailRing);
10471  PrintLn();
10472  }
10473  #endif
10475  strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10476  else
10477  strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10479  {
10480  if (TEST_OPT_CONTENTSB)
10481  {
10482  number n;
10483  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10484  if (!nIsOne(n))
10485  {
10487  denom->n=nInvers(n);
10488  denom->next=DENOMINATOR_LIST;
10489  DENOMINATOR_LIST=denom;
10490  }
10491  nDelete(&n);
10492  }
10493  else
10494  {
10495  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10496  }
10497  }
10498  #ifdef KDEBUG
10499  if (TEST_OPT_DEBUG)
10500  {
10501  Print("to (-tailR) S[%d]:",i);
10502  p_wrp(strat->S[i],currRing,strat->tailRing);
10503  PrintLn();
10504  }
10505  #endif
10506  }
10507  if (TEST_OPT_PROT)

◆ createG0()

ideal createG0 ( )

Definition at line 4388 of file kutil.cc.

4390 {
4391  // Initialize
4392  long exp[50]; // The exponent of \hat{X} (basepoint)
4393  long cexp[50]; // The current exponent for iterating over all
4394  long ind[50]; // The power of 2 in the i-th component of exp
4395  long cind[50]; // analog for cexp
4396  long mult[50]; // How to multiply the elements of G
4397  long cabsind = 0; // The abs. index of cexp, i.e. the sum of cind
4398  long habsind = 0; // The abs. index of the coefficient of h
4399  long step[50]; // The last increases
4400  for (int i = 1; i <= currRing->N; i++)
4401  {
4402  exp[i] = 0;
4403  cexp[i] = exp[i];
4404  ind[i] = 0;
4405  step[i] = 500000;
4406  cind[i] = ind[i];
4407  }
4408  long bound = currRing->ch;
4409  step[1] = 500000;
4410 #ifdef OLI_DEBUG
4411  PrintS("-------------\npoly :");
4412 // wrp(p);
4413  Print("\nexp : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
4414  Print("cexp : (%d, %d)\n", cexp[1], cexp[2]);
4415  Print("cind : (%d, %d)\n", cind[1], cind[2]);
4416  Print("bound : %d\n", bound);
4417  Print("cind : %d\n", cabsind);
4418 #endif
4419  if (cabsind == 0)
4420  {
4421  if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N)))
4422  {
4423  return idInit(1, 1);
4424  }
4425  }
4426  ideal G0 = idInit(1, 1);
4427  // Now the whole simplex
4428  do
4429  {
4430  // Build s-polynomial
4431  // 2**ind-def * mult * g - exp-def * h
4432  poly t_p;
4433  poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, currRing);
4434 #ifdef OLI_DEBUG
4435  Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
4436  PrintS("zPoly : ");
4437  wrp(zeroPoly);
4438  PrintLn();
4439 #endif
4440  // Add to ideal
4441  pEnlargeSet(&(G0->m), IDELEMS(G0), 1);
4442  IDELEMS(G0) += 1;
4443  G0->m[IDELEMS(G0) - 1] = zeroPoly;
4444  }
4445  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) );
4446  idSkipZeroes(G0);
4447  return G0;

◆ deleteHC() [1/2]

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

Definition at line 242 of file kutil.cc.

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

◆ deleteHC() [2/2]

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

Definition at line 317 of file kutil.cc.

319 {
320  LObject L(*p, currRing, strat->tailRing);
321 
322  deleteHC(&L, strat);
323  *p = L.p;
324  *e = L.ecart;
325  *l = L.length;
326  if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);

◆ deleteInL()

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

Definition at line 1151 of file kutil.cc.

1153 {
1154  if (set[j].lcm!=NULL)
1155  {
1156 #ifdef HAVE_RINGS
1158  && (pGetCoeff(set[j].lcm) != NULL))
1159  pLmDelete(set[j].lcm);
1160  else
1161 #endif
1162  pLmFree(set[j].lcm);
1163  }
1164  if (set[j].sig!=NULL)
1165  {
1166 #ifdef HAVE_RINGS
1167  if (pGetCoeff(set[j].sig) != NULL)
1168  pLmDelete(set[j].sig);
1169  else
1170 #endif
1171  pLmFree(set[j].sig);
1172  }
1173  if (set[j].p!=NULL)
1174  {
1175  if (pNext(set[j].p) == strat->tail)
1176  {
1177 #ifdef HAVE_RINGS
1178  if (pGetCoeff(set[j].p) != NULL)
1179  pLmDelete(set[j].p);
1180  else
1181 #endif
1182  pLmFree(set[j].p);
1183  /*- tail belongs to several int spolys -*/
1184  }
1185  else
1186  {
1187  // search p in T, if it is there, do not delete it
1188  if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1189  {
1190  // assure that for global orderings kFindInT fails
1191  //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1192  set[j].Delete();
1193  }
1194  }
1195  }
1196  if (*length > 0 && j < *length)
1197  {
1198 #ifdef ENTER_USE_MEMMOVE
1199  memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1200 #else
1201  int i;
1202  for (i=j; i < (*length); i++)
1203  set[i] = set[i+1];
1204 #endif
1205  }
1206 #ifdef KDEBUG
1207  memset(&(set[*length]),0,sizeof(LObject));
1208 #endif
1209  (*length)--;

◆ deleteInS()

void deleteInS ( int  i,
kStrategy  strat 
)

Definition at line 1044 of file kutil.cc.

1046 {
1047 #ifdef ENTER_USE_MEMMOVE
1048  memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1049  memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1050  memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1051  memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1052 #else
1053  int j;
1054  for (j=i; j<strat->sl; j++)
1055  {
1056  strat->S[j] = strat->S[j+1];
1057  strat->ecartS[j] = strat->ecartS[j+1];
1058  strat->sevS[j] = strat->sevS[j+1];
1059  strat->S_2_R[j] = strat->S_2_R[j+1];
1060  }
1061 #endif
1062  if (strat->lenS!=NULL)
1063  {
1064 #ifdef ENTER_USE_MEMMOVE
1065  memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1066 #else
1067  for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1068 #endif
1069  }
1070  if (strat->lenSw!=NULL)
1071  {
1072 #ifdef ENTER_USE_MEMMOVE
1073  memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1074 #else
1075  for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1076 #endif
1077  }
1078  if (strat->fromQ!=NULL)
1079  {
1080 #ifdef ENTER_USE_MEMMOVE
1081  memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1082 #else
1083  for (j=i; j<strat->sl; j++)
1084  {
1085  strat->fromQ[j] = strat->fromQ[j+1];
1086  }
1087 #endif
1088  }
1089  strat->S[strat->sl] = NULL;
1090  strat->sl--;

◆ deleteInSSba()

void deleteInSSba ( int  i,
kStrategy  strat 
)

Definition at line 1096 of file kutil.cc.

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4503 of file kutil.cc.

4505 {
4506  if (nIsOne(pGetCoeff(h))) return;
4507  number gcd;
4508  bool go = false;
4509  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4510  {
4511  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4512  go = true;
4513  }
4514  else
4515  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4516  if (go || !nIsOne(gcd))
4517  {
4518  poly p = h->next;
4519  if (!go)
4520  {
4521  number tmp = gcd;
4522  gcd = n_Ann(gcd,currRing->cf);
4523  nDelete(&tmp);
4524  }
4525  p_Test(p,strat->tailRing);
4526  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4527  nDelete(&gcd);
4528 
4529  if (p != NULL)
4530  {
4531  if (TEST_OPT_PROT)
4532  {
4533  PrintS("Z");
4534  }
4535 #ifdef KDEBUG
4536  if (TEST_OPT_DEBUG)
4537  {
4538  PrintS("--- create zero spoly: ");
4539  p_wrp(h,currRing,strat->tailRing);
4540  PrintS(" ---> ");
4541  }
4542 #endif
4543  poly tmp = pInit();
4544  pSetCoeff0(tmp, pGetCoeff(p));
4545  for (int i = 1; i <= rVar(currRing); i++)
4546  {
4547  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4548  }
4550  {
4551  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4552  }
4553  p_Setm(tmp, currRing);
4554  p = p_LmFreeAndNext(p, strat->tailRing);
4555  pNext(tmp) = p;
4556  LObject Lp;
4557  Lp.Init();
4558  Lp.p = tmp;
4559  Lp.tailRing = strat->tailRing;
4560  int posx;
4561  if (Lp.p!=NULL)
4562  {
4563  strat->initEcart(&Lp);
4564  if (strat->Ll==-1)
4565  posx =0;
4566  else
4567  posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4568  Lp.sev = pGetShortExpVector(Lp.p);
4569  if (strat->tailRing != currRing)
4570  {
4571  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4572  }
4573 #ifdef KDEBUG
4574  if (TEST_OPT_DEBUG)
4575  {
4576  p_wrp(tmp,currRing,strat->tailRing);
4577  PrintLn();
4578  }
4579 #endif
4580  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4581  }
4582  }
4583  }
4584  nDelete(&gcd);

◆ enterExtendedSpolySig()

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

Definition at line 4586 of file kutil.cc.

4588 {
4589  if (nIsOne(pGetCoeff(h))) return;
4590  number gcd;
4591  bool go = false;
4592  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4593  {
4594  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4595  go = true;
4596  }
4597  else
4598  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4599  if (go || !nIsOne(gcd))
4600  {
4601  poly p = h->next;
4602  if (!go)
4603  {
4604  number tmp = gcd;
4605  gcd = n_Ann(gcd,currRing->cf);
4606  nDelete(&tmp);
4607  }
4608  p_Test(p,strat->tailRing);
4609  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4610 
4611  if (p != NULL)
4612  {
4613  if (TEST_OPT_PROT)
4614  {
4615  PrintS("Z");
4616  }
4617 #ifdef KDEBUG
4618  if (TEST_OPT_DEBUG)
4619  {
4620  PrintS("--- create zero spoly: ");
4621  p_wrp(h,currRing,strat->tailRing);
4622  PrintS(" ---> ");
4623  }
4624 #endif
4625  poly tmp = pInit();
4626  pSetCoeff0(tmp, pGetCoeff(p));
4627  for (int i = 1; i <= rVar(currRing); i++)
4628  {
4629  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4630  }
4632  {
4633  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4634  }
4635  p_Setm(tmp, currRing);
4636  p = p_LmFreeAndNext(p, strat->tailRing);
4637  pNext(tmp) = p;
4638  LObject Lp;
4639  Lp.Init();
4640  Lp.p = tmp;
4641  //printf("\nOld\n");pWrite(h);pWrite(hSig);
4642  #if EXT_POLY_NEW
4643  Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4644  if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4645  {
4646  strat->sigdrop = TRUE;
4647  //Try to reduce it as far as we can via redRing
4648  int red_result = redRing(&Lp,strat);
4649  if(red_result == 0)
4650  {
4651  // Cancel the sigdrop
4652  p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4653  strat->sigdrop = FALSE;
4654  return;
4655  }
4656  else
4657  {
4658  strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4659  #if 1
4660  strat->enterS(Lp,0,strat,strat->tl);
4661  #endif
4662  return;
4663  }
4664 
4665  }
4666  #else
4667  Lp.sig = pOne();
4668  if(strat->Ll >= 0)
4669  p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4670  else
4671  p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4672  #endif
4673  Lp.tailRing = strat->tailRing;
4674  int posx;
4675  if (Lp.p!=NULL)
4676  {
4677  strat->initEcart(&Lp);
4678  if (strat->Ll==-1)
4679  posx =0;
4680  else
4681  posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4682  Lp.sev = pGetShortExpVector(Lp.p);
4683  if (strat->tailRing != currRing)
4684  {
4685  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4686  }
4687 #ifdef KDEBUG
4688  if (TEST_OPT_DEBUG)
4689  {
4690  p_wrp(tmp,currRing,strat->tailRing);
4691  PrintLn();
4692  }
4693 #endif
4694  //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4695  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4696  }
4697  }
4698  nDelete(&gcd);
4699  }
4700  nDelete(&gcd);

◆ enterL()

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

Definition at line 1214 of file kutil.cc.

1216 {
1217  // this should be corrected
1218  assume(p.FDeg == p.pFDeg());
1219 
1220  if ((*length)>=0)
1221  {
1222  if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1223  if (at <= (*length))
1224 #ifdef ENTER_USE_MEMMOVE
1225  memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1226 #else
1227  for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1228 #endif
1229  }
1230  else at = 0;
1231  (*set)[at] = p;
1232  (*length)++;

◆ enterOnePairNormal()

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

Definition at line 1860 of file kutil.cc.

1862 {
1863  assume(i<=strat->sl);
1864 
1865  int l,j,compare;
1866  LObject Lp;
1867  Lp.i_r = -1;
1868 
1869 #ifdef KDEBUG
1870  Lp.ecart=0; Lp.length=0;
1871 #endif
1872  /*- computes the lcm(s[i],p) -*/
1873  Lp.lcm = pInit();
1874 
1875 #ifndef HAVE_RATGRING
1876  pLcm(p,strat->S[i],Lp.lcm);
1877 #elif defined(HAVE_RATGRING)
1878  if (rIsRatGRing(currRing))
1879  pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
1880  else
1881  pLcm(p,strat->S[i],Lp.lcm);
1882 #endif
1883  pSetm(Lp.lcm);
1884 
1885 
1886  if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
1887  {
1888  if((!((strat->ecartS[i]>0)&&(ecart>0)))
1889  && pHasNotCF(p,strat->S[i]))
1890  {
1891  /*
1892  *the product criterion has applied for (s,p),
1893  *i.e. lcm(s,p)=product of the leading terms of s and p.
1894  *Suppose (s,r) is in L and the leading term
1895  *of p divides lcm(s,r)
1896  *(==> the leading term of p divides the leading term of r)
1897  *but the leading term of s does not divide the leading term of r
1898  *(notice that tis condition is automatically satisfied if r is still
1899  *in S), then (s,r) can be cancelled.
1900  *This should be done here because the
1901  *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
1902  *
1903  *Moreover, skipping (s,r) holds also for the noncommutative case.
1904  */
1905  strat->cp++;
1906  pLmFree(Lp.lcm);
1907  return;
1908  }
1909  else
1910  Lp.ecart = si_max(ecart,strat->ecartS[i]);
1911  if (strat->fromT && (strat->ecartS[i]>ecart))
1912  {
1913  pLmFree(Lp.lcm);
1914  return;
1915  /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
1916  }
1917  /*
1918  *the set B collects the pairs of type (S[j],p)
1919  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
1920  *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
1921  *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
1922  */
1923  {
1924  j = strat->Bl;
1925  loop
1926  {
1927  if (j < 0) break;
1928  compare=pDivComp(strat->B[j].lcm,Lp.lcm);
1929  if ((compare==1)
1930  &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
1931  {
1932  strat->c3++;
1933  if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1934  {
1935  pLmFree(Lp.lcm);
1936  return;
1937  }
1938  break;
1939  }
1940  else
1941  if ((compare ==-1)
1942  && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
1943  {
1944  deleteInL(strat->B,&strat->Bl,j,strat);
1945  strat->c3++;
1946  }
1947  j--;
1948  }
1949  }
1950  }
1951  else /*sugarcrit*/
1952  {
1953  if (ALLOW_PROD_CRIT(strat))
1954  {
1955  // if currRing->nc_type!=quasi (or skew)
1956  // TODO: enable productCrit for super commutative algebras...
1957  if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
1958  pHasNotCF(p,strat->S[i]))
1959  {
1960  /*
1961  *the product criterion has applied for (s,p),
1962  *i.e. lcm(s,p)=product of the leading terms of s and p.
1963  *Suppose (s,r) is in L and the leading term
1964  *of p devides lcm(s,r)
1965  *(==> the leading term of p devides the leading term of r)
1966  *but the leading term of s does not devide the leading term of r
1967  *(notice that tis condition is automatically satisfied if r is still
1968  *in S), then (s,r) can be canceled.
1969  *This should be done here because the
1970  *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
1971  */
1972  strat->cp++;
1973  pLmFree(Lp.lcm);
1974  return;
1975  }
1976  if (strat->fromT && (strat->ecartS[i]>ecart))
1977  {
1978  pLmFree(Lp.lcm);
1979  return;
1980  /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
1981  }
1982  /*
1983  *the set B collects the pairs of type (S[j],p)
1984  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
1985  *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
1986  *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
1987  */
1988  for(j = strat->Bl;j>=0;j--)
1989  {
1990  compare=pDivComp(strat->B[j].lcm,Lp.lcm);
1991  if (compare==1)
1992  {
1993  strat->c3++;
1994  if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1995  {
1996  pLmFree(Lp.lcm);
1997  return;
1998  }
1999  break;
2000  }
2001  else
2002  if (compare ==-1)
2003  {
2004  deleteInL(strat->B,&strat->Bl,j,strat);
2005  strat->c3++;
2006  }
2007  }
2008  }
2009  }
2010  /*
2011  *the pair (S[i],p) enters B if the spoly != 0
2012  */
2013  /*- compute the short s-polynomial -*/
2014  if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2015  pNorm(p);
2016 
2017  if ((strat->S[i]==NULL) || (p==NULL))
2018  return;
2019 
2020  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2021  Lp.p=NULL;
2022  else
2023  {
2024  #ifdef HAVE_PLURAL
2025  if ( rIsPluralRing(currRing) )
2026  {
2027  if(pHasNotCF(p, strat->S[i]))
2028  {
2029  if(ncRingType(currRing) == nc_lie)
2030  {
2031  // generalized prod-crit for lie-type
2032  strat->cp++;
2033  Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2034  }
2035  else
2036  if( ALLOW_PROD_CRIT(strat) )
2037  {
2038  // product criterion for homogeneous case in SCA
2039  strat->cp++;
2040  Lp.p = NULL;
2041  }
2042  else
2043  {
2044  Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2045  nc_CreateShortSpoly(strat->S[i], p, currRing);
2046  assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2047  pNext(Lp.p) = strat->tail; // !!!
2048  }
2049  }
2050  else
2051  {
2052  Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2053  nc_CreateShortSpoly(strat->S[i], p, currRing);
2054 
2055  assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2056  pNext(Lp.p) = strat->tail; // !!!
2057  }
2058  }
2059  else
2060  #endif
2061  {
2063  Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2064  }
2065  }
2066  if (Lp.p == NULL)
2067  {
2068  /*- the case that the s-poly is 0 -*/
2069  if (strat->pairtest==NULL) initPairtest(strat);
2070  strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
2071  strat->pairtest[strat->sl+1] = TRUE;
2072  /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
2073  /*
2074  *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
2075  *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
2076  *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading
2077  *term of p devides the lcm(s,r)
2078  *(this canceling should be done here because
2079  *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
2080  *the first case is handeled in chainCrit
2081  */
2082  if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2083  }
2084  else
2085  {
2086  /*- the pair (S[i],p) enters B -*/
2087  Lp.p1 = strat->S[i];
2088  Lp.p2 = p;
2089 
2090  if (
2092 // || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
2093  )
2094  {
2095  assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2096  pNext(Lp.p) = strat->tail; // !!!
2097  }
2098 
2099  if (atR >= 0)
2100  {
2101  Lp.i_r1 = strat->S_2_R[i];
2102  Lp.i_r2 = atR;
2103  }
2104  else
2105  {
2106  Lp.i_r1 = -1;
2107  Lp.i_r2 = -1;
2108  }
2109  strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2110 
2112  {
2113  if (!rIsPluralRing(currRing)
2115  && (Lp.p->coef!=NULL))
2116  nDelete(&(Lp.p->coef));
2117  }
2118 
2119  l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
2120  enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2121  }

◆ enterOnePairSelfShifts()

void enterOnePairSelfShifts ( poly  qq,
poly  p,
int  ecart,
int  isFromQ,
kStrategy  strat,
int  atR,
int  uptodeg,
int  lV 
)

Definition at line 12017 of file kutil.cc.

12027 {
12028 
12029  /* format: p,qq are in LObject form: lm in CR, tail in TR */
12030  /* for true self pairs qq ==p */
12031  /* we test both qq and p */
12033  assume(p_CheckIsFromRing(pNext(qq),strat->tailRing));
12036 
12037  /* since this proc is applied twice for (h, s*g) and (g,s*h), init j with 1 only */
12038 
12039  // int j = 0;
12040  int j = 1;
12041 
12042  /* for such self pairs start with 1, not with 0 */
12043  if (qq == p) j=1;
12044 
12045  /* should cycle through all shifts of q until uptodeg - lastVblock(q) */
12046  /* that is create the pairs (f, s \dot g) */
12047 
12048  int toInsert = itoInsert(qq, uptodeg, lV, strat->tailRing);
12049 
12050 #ifdef KDEBUG
12051  //if (TEST_OPT_DEBUG)
12052  //{
12053  // Print("entered SelfShifts: with toInsert=%d",toInsert); PrintLn();
12054  //}
12055 #endif
12056 
12057  poly q;
12058 
12059  /* these vars hold for all shifts of s[i] */
12060  int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
12061  int qfromQ = 0; // strat->fromQ[i];
12062 
12063  for (; j<= toInsert; j++)
12064  {
12065  // q = pLPshift(strat->S[i],j,uptodeg,lV);
12066  /* we increase shifts by one; must delete q there*/
12067  // q = qq; q = pMoveCurrTail2poly(q,strat);
12068  // q = pLPshift(q,j,uptodeg,lV); //,currRing);
12069  q = p_LPshiftT(qq, j, uptodeg, lV, strat, currRing);
12070  // q = p_mLPshift(qq,j,uptodeg,lV,currRing); // lm in currRing, shift this monomial
12071  // s = p_LPshift(pNext(qq), j, uptodeg, lV, strat->tailRing); // from tailRing
12072  // pNext(q) = s; // in tailRing
12073  /* here we need to call enterOnePair with two polys ... */

◆ enterOnePairShift()

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

Definition at line 12080 of file kutil.cc.

12090 {
12091 
12092  /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
12093 
12094  /* check this Formats: */
12096  assume(p_CheckIsFromRing(pNext(q),strat->tailRing));
12099 
12100 #ifdef KDEBUG
12101 // if (TEST_OPT_DEBUG)
12102 // {
12103 // PrintS("enterOnePairShift(q,p) invoked with q = ");
12104 // wrp(q); // wrp(pHead(q));
12105 // PrintS(", p = ");
12106 // wrp(p); //wrp(pHead(p));
12107 // PrintLn();
12108 // }
12109 #endif
12110 
12111  /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
12112 
12113  int qfromQ = qisFromQ;
12114 
12115  /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */
12116 
12117  int l,j,compare;
12118  LObject Lp;
12119  Lp.i_r = -1;
12120 
12121 #ifdef KDEBUG
12122  Lp.ecart=0; Lp.length=0;
12123 #endif
12124  /*- computes the lcm(s[i],p) -*/
12125  Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
12126 
12127  /* apply the V criterion */
12128  if (!isInV(Lp.lcm, lV))
12129  {
12130 #ifdef KDEBUG
12131  if (TEST_OPT_DEBUG)
12132  {
12133  PrintS("V crit applied to q = ");
12134  wrp(q); // wrp(pHead(q));
12135  PrintS(", p = ");
12136  wrp(p); //wrp(pHead(p));
12137  PrintLn();
12138  }
12139 #endif
12140  pLmFree(Lp.lcm);
12141  /* + counter for applying the V criterion */
12142  strat->cv++;
12143  return;
12144  }
12145 
12146  if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
12147  {
12148  if((!((ecartq>0)&&(ecart>0)))
12149  && pHasNotCF(p,q))
12150  {
12151  /*
12152  *the product criterion has applied for (s,p),
12153  *i.e. lcm(s,p)=product of the leading terms of s and p.
12154  *Suppose (s,r) is in L and the leading term
12155  *of p divides lcm(s,r)
12156  *(==> the leading term of p divides the leading term of r)
12157  *but the leading term of s does not divide the leading term of r
12158  *(notice that this condition is automatically satisfied if r is still
12159  *in S), then (s,r) can be cancelled.
12160  *This should be done here because the
12161  *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12162  *
12163  *Moreover, skipping (s,r) holds also for the noncommutative case.
12164  */
12165  strat->cp++;
12166  pLmFree(Lp.lcm);
12167  return;
12168  }
12169  else
12170  Lp.ecart = si_max(ecart,ecartq);
12171  if (strat->fromT && (ecartq>ecart))
12172  {
12173  pLmFree(Lp.lcm);
12174  return;
12175  /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12176  }
12177  /*
12178  *the set B collects the pairs of type (S[j],p)
12179  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12180  *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
12181  *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
12182  */
12183  {
12184  j = strat->Bl;
12185  loop
12186  {
12187  if (j < 0) break;
12188  compare=pDivComp(strat->B[j].lcm,Lp.lcm);
12189  if ((compare==1)
12190  &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
12191  {
12192  strat->c3++;
12193  if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12194  {
12195  pLmFree(Lp.lcm);
12196  return;
12197  }
12198  break;
12199  }
12200  else
12201  if ((compare ==-1)
12202  && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
12203  {
12204  deleteInL(strat->B,&strat->Bl,j,strat);
12205  strat->c3++;
12206  }
12207  j--;
12208  }
12209  }
12210  }
12211  else /*sugarcrit*/
12212  {
12213  if (ALLOW_PROD_CRIT(strat))
12214  {
12215  // if currRing->nc_type!=quasi (or skew)
12216  // TODO: enable productCrit for super commutative algebras...
12217  if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
12218  pHasNotCF(p,q))
12219  {
12220  /*
12221  *the product criterion has applied for (s,p),
12222  *i.e. lcm(s,p)=product of the leading terms of s and p.
12223  *Suppose (s,r) is in L and the leading term
12224  *of p devides lcm(s,r)
12225  *(==> the leading term of p devides the leading term of r)
12226  *but the leading term of s does not devide the leading term of r
12227  *(notice that tis condition is automatically satisfied if r is still
12228  *in S), then (s,r) can be canceled.
12229  *This should be done here because the
12230  *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12231  */
12232  strat->cp++;
12233  pLmFree(Lp.lcm);
12234  return;
12235  }
12236  if (strat->fromT && (ecartq>ecart))
12237  {
12238  pLmFree(Lp.lcm);
12239  return;
12240  /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12241  }
12242  /*
12243  *the set B collects the pairs of type (S[j],p)
12244  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12245  *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
12246  *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
12247  */
12248  for(j = strat->Bl;j>=0;j--)
12249  {
12250  compare=pDivComp(strat->B[j].lcm,Lp.lcm);
12251  if (compare==1)
12252  {
12253  strat->c3++;
12254  if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12255  {
12256  pLmFree(Lp.lcm);
12257  return;
12258  }
12259  break;
12260  }
12261  else
12262  if (compare ==-1)
12263  {
12264  deleteInL(strat->B,&strat->Bl,j,strat);
12265  strat->c3++;
12266  }
12267  }
12268  }
12269  }
12270  /*
12271  *the pair (S[i],p) enters B if the spoly != 0
12272  */
12273  /*- compute the short s-polynomial -*/
12274  if (strat->fromT && !TEST_OPT_INTSTRATEGY)
12275  pNorm(p);
12276  if ((q==NULL) || (p==NULL))
12277  return;
12278  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
12279  Lp.p=NULL;
12280  else
12281  {
12282 // if ( rIsPluralRing(currRing) )
12283 // {
12284 // if(pHasNotCF(p, q))
12285 // {
12286 // if(ncRingType(currRing) == nc_lie)
12287 // {
12288 // // generalized prod-crit for lie-type
12289 // strat->cp++;
12290 // Lp.p = nc_p_Bracket_qq(pCopy(p),q, currRing);
12291 // }
12292 // else
12293 // if( ALLOW_PROD_CRIT(strat) )
12294 // {
12295 // // product criterion for homogeneous case in SCA
12296 // strat->cp++;
12297 // Lp.p = NULL;
12298 // }
12299 // else
12300 // Lp.p = nc_CreateSpoly(q,p,currRing); // ?
12301 // }
12302 // else Lp.p = nc_CreateSpoly(q,p,currRing);
12303 // }
12304 // else
12305 // {
12306 
12307  /* ksCreateShortSpoly needs two Lobject-kind presentations */
12308  /* p is already in this form, so convert q */
12309  // q = pMove2CurrTail(q, strat);
12310  Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
12311  // }
12312  }
12313  if (Lp.p == NULL)
12314  {
12315  /*- the case that the s-poly is 0 -*/
12316  /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
12317 // if (strat->pairtest==NULL) initPairtest(strat);
12318 // strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
12319 // strat->pairtest[strat->sl+1] = TRUE;
12320  /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12321  /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
12322  /*
12323  *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
12324  *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
12325  *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading
12326  *term of p devides the lcm(s,r)
12327  *(this canceling should be done here because
12328  *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
12329  *the first case is handeled in chainCrit
12330  */
12331  if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
12332  }
12333  else
12334  {
12335  /*- the pair (S[i],p) enters B -*/
12336  /* both of them should have their LM in currRing and TAIL in tailring */
12337  Lp.p1 = q; // already in the needed form
12338  Lp.p2 = p; // already in the needed form
12339 
12340  if ( !rIsPluralRing(currRing) )
12341  pNext(Lp.p) = strat->tail;
12342 
12343  /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12344  /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12345  if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
12346  {
12347  Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
12348  Lp.i_r2 = atR;
12349  }
12350  else
12351  {
12352  /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12353  Lp.i_r1 = -1;
12354  Lp.i_r2 = -1;
12355  }
12356  strat->initEcartPair(&Lp,q,p,ecartq,ecart);
12357 
12359  {
12360  if (!rIsPluralRing(currRing)

◆ enterpairs()

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

Definition at line 4758 of file kutil.cc.

4760 {
4761  int j=pos;
4762 
4764  initenterpairs(h,k,ecart,0,strat, atR);
4765  if ( (!strat->fromT)
4766  && ((strat->syzComp==0)
4767  ||(pGetComp(h)<=strat->syzComp)))
4768  {
4769  unsigned long h_sev = pGetShortExpVector(h);
4770  loop
4771  {
4772  if (j > k) break;
4773  clearS(h,h_sev, &j,&k,strat);
4774  j++;
4775  }
4776  }

◆ enterpairsShift()

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

Definition at line 12442 of file kutil.cc.

12452 {
12453  /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12454  /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
12455  int j=pos;
12456 
12458  initenterpairsShift(h,k,ecart,0,strat, atR,uptodeg,lV);
12459  if ( (!strat->fromT)
12460  && ((strat->syzComp==0)
12461  ||(pGetComp(h)<=strat->syzComp)))
12462  {
12463  //Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl);
12464  unsigned long h_sev = pGetShortExpVector(h);
12465  loop

◆ enterpairsSig()

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

Definition at line 4784 of file kutil.cc.

4786 {
4787  int j=pos;
4789  initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4790  if ( (!strat->fromT)
4791  && ((strat->syzComp==0)
4792  ||(pGetComp(h)<=strat->syzComp)))
4793  {
4794  unsigned long h_sev = pGetShortExpVector(h);
4795  loop
4796  {
4797  if (j > k) break;
4798  clearS(h,h_sev, &j,&k,strat);
4799  j++;
4800  }
4801  }

◆ enterSBba()

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

Definition at line 9028 of file kutil.cc.

9035 {
9036  strat->news = TRUE;
9037  /*- puts p to the standardbasis s at position at -*/
9038  if (strat->sl == IDELEMS(strat->Shdl)-1)
9039  {
9040  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9041  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9042  (IDELEMS(strat->Shdl)+setmaxTinc)
9043  *sizeof(unsigned long));
9044  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9045  IDELEMS(strat->Shdl)*sizeof(int),
9046  (IDELEMS(strat->Shdl)+setmaxTinc)
9047  *sizeof(int));
9048  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9049  IDELEMS(strat->Shdl)*sizeof(int),
9050  (IDELEMS(strat->Shdl)+setmaxTinc)
9051  *sizeof(int));
9052  if (strat->lenS!=NULL)
9053  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9054  IDELEMS(strat->Shdl)*sizeof(int),
9055  (IDELEMS(strat->Shdl)+setmaxTinc)
9056  *sizeof(int));
9057  if (strat->lenSw!=NULL)
9058  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9059  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9060  (IDELEMS(strat->Shdl)+setmaxTinc)
9061  *sizeof(wlen_type));
9062  if (strat->fromQ!=NULL)
9063  {
9064  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9065  IDELEMS(strat->Shdl)*sizeof(int),
9066  (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
9067  }
9068  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
9069  IDELEMS(strat->Shdl)+=setmaxTinc;
9070  strat->Shdl->m=strat->S;
9071  }
9072  if (atS <= strat->sl)
9073  {
9074 #ifdef ENTER_USE_MEMMOVE
9075  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9076  (strat->sl - atS + 1)*sizeof(poly));
9077  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9078  (strat->sl - atS + 1)*sizeof(int));
9079  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9080  (strat->sl - atS + 1)*sizeof(unsigned long));
9081  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9082  (strat->sl - atS + 1)*sizeof(int));
9083  if (strat->lenS!=NULL)
9084  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9085  (strat->sl - atS + 1)*sizeof(int));
9086  if (strat->lenSw!=NULL)
9087  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9088  (strat->sl - atS + 1)*sizeof(wlen_type));
9089 #else
9090  for (i=strat->sl+1; i>=atS+1; i--)
9091  {
9092  strat->S[i] = strat->S[i-1];
9093  strat->ecartS[i] = strat->ecartS[i-1];
9094  strat->sevS[i] = strat->sevS[i-1];
9095  strat->S_2_R[i] = strat->S_2_R[i-1];
9096  }
9097  if (strat->lenS!=NULL)
9098  for (i=strat->sl+1; i>=atS+1; i--)
9099  strat->lenS[i] = strat->lenS[i-1];
9100  if (strat->lenSw!=NULL)
9101  for (i=strat->sl+1; i>=atS+1; i--)
9102  strat->lenSw[i] = strat->lenSw[i-1];
9103 #endif
9104  }
9105  if (strat->fromQ!=NULL)
9106  {
9107 #ifdef ENTER_USE_MEMMOVE
9108  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9109  (strat->sl - atS + 1)*sizeof(int));
9110 #else
9111  for (i=strat->sl+1; i>=atS+1; i--)
9112  {
9113  strat->fromQ[i] = strat->fromQ[i-1];
9114  }
9115 #endif
9116  strat->fromQ[atS]=0;
9117  }
9118 
9119  /*- save result -*/
9120  poly pp=p.p;
9121  strat->S[atS] = pp;
9122  if (strat->honey) strat->ecartS[atS] = p.ecart;
9123  if (p.sev == 0)
9124  p.sev = pGetShortExpVector(pp);
9125  else

◆ entersets()

void entersets ( LObject  h)

◆ enterSSba()

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

Definition at line 9131 of file kutil.cc.

9138 {
9139  strat->news = TRUE;
9140  /*- puts p to the standardbasis s at position at -*/
9141  if (strat->sl == IDELEMS(strat->Shdl)-1)
9142  {
9143  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9144  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9145  (IDELEMS(strat->Shdl)+setmax)
9146  *sizeof(unsigned long));
9147  strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
9148  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9149  (IDELEMS(strat->Shdl)+setmax)
9150  *sizeof(unsigned long));
9151  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9152  IDELEMS(strat->Shdl)*sizeof(int),
9153  (IDELEMS(strat->Shdl)+setmax)
9154  *sizeof(int));
9155  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9156  IDELEMS(strat->Shdl)*sizeof(int),
9157  (IDELEMS(strat->Shdl)+setmax)
9158  *sizeof(int));
9159  if (strat->lenS!=NULL)
9160  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9161  IDELEMS(strat->Shdl)*sizeof(int),
9162  (IDELEMS(strat->Shdl)+setmax)
9163  *sizeof(int));
9164  if (strat->lenSw!=NULL)
9165  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9166  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9167  (IDELEMS(strat->Shdl)+setmax)
9168  *sizeof(wlen_type));
9169  if (strat->fromQ!=NULL)
9170  {
9171  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9172  IDELEMS(strat->Shdl)*sizeof(int),
9173  (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
9174  }
9175  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
9176  pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
9177  IDELEMS(strat->Shdl)+=setmax;
9178  strat->Shdl->m=strat->S;
9179  }
9180  // in a signature-based algorithm the following situation will never
9181  // appear due to the fact that the critical pairs are already sorted
9182  // by increasing signature.
9183  // True. However, in the case of integers we need to put the element
9184  // that caused the signature drop on the first position
9185  if (atS <= strat->sl)
9186  {
9187 #ifdef ENTER_USE_MEMMOVE
9188  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9189  (strat->sl - atS + 1)*sizeof(poly));
9190  memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
9191  (strat->sl - atS + 1)*sizeof(poly));
9192  memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
9193  (strat->sl - atS + 1)*sizeof(unsigned long));
9194  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9195  (strat->sl - atS + 1)*sizeof(int));
9196  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9197  (strat->sl - atS + 1)*sizeof(unsigned long));
9198  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9199  (strat->sl - atS + 1)*sizeof(int));
9200  if (strat->lenS!=NULL)
9201  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9202  (strat->sl - atS + 1)*sizeof(int));
9203  if (strat->lenSw!=NULL)
9204  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9205  (strat->sl - atS + 1)*sizeof(wlen_type));
9206 #else
9207  for (i=strat->sl+1; i>=atS+1; i--)
9208  {
9209  strat->S[i] = strat->S[i-1];
9210  strat->ecartS[i] = strat->ecartS[i-1];
9211  strat->sevS[i] = strat->sevS[i-1];
9212  strat->S_2_R[i] = strat->S_2_R[i-1];
9213  strat->sig[i] = strat->sig[i-1];
9214  strat->sevSig[i] = strat->sevSig[i-1];
9215  }
9216  if (strat->lenS!=NULL)
9217  for (i=strat->sl+1; i>=atS+1; i--)
9218  strat->lenS[i] = strat->lenS[i-1];
9219  if (strat->lenSw!=NULL)
9220  for (i=strat->sl+1; i>=atS+1; i--)
9221  strat->lenSw[i] = strat->lenSw[i-1];
9222 #endif
9223  }
9224  if (strat->fromQ!=NULL)
9225  {
9226 #ifdef ENTER_USE_MEMMOVE
9227  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9228  (strat->sl - atS + 1)*sizeof(int));
9229 #else
9230  for (i=strat->sl+1; i>=atS+1; i--)
9231  {
9232  strat->fromQ[i] = strat->fromQ[i-1];
9233  }
9234 #endif
9235  strat->fromQ[atS]=0;
9236  }
9237 
9238  /*- save result -*/
9239  strat->S[atS] = p.p;
9240  strat->sig[atS] = p.sig; // TODO: get ths correct signature in here!
9241  if (strat->honey) strat->ecartS[atS] = p.ecart;
9242  if (p.sev == 0)
9243  p.sev = pGetShortExpVector(p.p);
9244  else
9245  assume(p.sev == pGetShortExpVector(p.p));
9246  strat->sevS[atS] = p.sev;
9247  // during the interreduction process of a signature-based algorithm we do not
9248  // compute the signature at this point, but when the whole interreduction
9249  // process finishes, i.e. f5c terminates!
9250  if (p.sig != NULL)
9251  {
9252  if (p.sevSig == 0)
9253  p.sevSig = pGetShortExpVector(p.sig);
9254  else
9255  assume(p.sevSig == pGetShortExpVector(p.sig));
9256  strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9257  }
9258  strat->ecartS[atS] = p.ecart;
9259  strat->S_2_R[atS] = atR;
9260  strat->sl++;
9261 #ifdef DEBUGF5
9262  int k;
9263  Print("--- LIST S: %d ---\n",strat->sl);
9264  for(k=0;k<=strat->sl;k++)

◆ enterSyz()

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

Definition at line 9452 of file kutil.cc.

9459 {
9460  int i;
9461  strat->newt = TRUE;
9462  if (strat->syzl == strat->syzmax-1)
9463  {
9464  pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9465  strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9466  (strat->syzmax)*sizeof(unsigned long),
9467  ((strat->syzmax)+setmax)
9468  *sizeof(unsigned long));
9469  strat->syzmax += setmax;
9470  }
9471  if (atT < strat->syzl)
9472  {
9473 #ifdef ENTER_USE_MEMMOVE
9474  memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9475  (strat->syzl-atT+1)*sizeof(poly));
9476  memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9477  (strat->syzl-atT+1)*sizeof(unsigned long));
9478 #endif
9479  for (i=strat->syzl; i>=atT+1; i--)
9480  {
9481 #ifndef ENTER_USE_MEMMOVE
9482  strat->syz[i] = strat->syz[i-1];
9483  strat->sevSyz[i] = strat->sevSyz[i-1];
9484 #endif
9485  }
9486  }
9487  //i = strat->syzl;
9488  i = atT;
9489  //Makes sure the syz saves just the signature
9490  #ifdef HAVE_RINGS
9492  pNext(p.sig) = NULL;
9493  #endif
9494  strat->syz[atT] = p.sig;
9495  strat->sevSyz[atT] = p.sevSig;
9496  strat->syzl++;
9497 #if F5DEBUG
9498  Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9499  pWrite(strat->syz[atT]);
9500 #endif
9501  // recheck pairs in strat->L with new rule and delete correspondingly
9502  int cc = strat->Ll;
9503  while (cc>-1)
9504  {
9505  //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9506  //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);
9507  if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9508  strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9509  #ifdef HAVE_RINGS
9510  &&((!rField_is_Ring(currRing))
9511  || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9512  #endif
9513  )
9514  {
9515  //printf("\nYES!\n");
9516  deleteInL(strat->L,&strat->Ll,cc,strat);
9517  }
9518  cc--;
9519  }
9520 //#if 1
9521 #ifdef DEBUGF5
9522  PrintS("--- Syzygies ---\n");
9523  Print("syzl %d\n",strat->syzl);
9524  Print("syzmax %d\n",strat->syzmax);
9525  PrintS("--------------------------------\n");
9526  for(i=0;i<=strat->syzl-1;i++)
9527  {

◆ enterT()

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

Definition at line 9269 of file kutil.cc.

9276 {
9277  int i;
9278 
9279  pp_Test(p.p, currRing, p.tailRing);
9280  assume(strat->tailRing == p.tailRing);
9281  // redMoraNF complains about this -- but, we don't really
9282  // neeed this so far
9283  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9284  assume(p.FDeg == p.pFDeg());
9285  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9286 
9287 #ifdef KDEBUG
9288  // do not put an LObject twice into T:
9289  for(i=strat->tl;i>=0;i--)
9290  {
9291  if (p.p==strat->T[i].p)
9292  {
9293  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9294  return;
9295  }
9296  }
9297 #endif
9298 
9299 #ifdef HAVE_TAIL_RING
9300  if (currRing!=strat->tailRing)
9301  {
9302  p.t_p=p.GetLmTailRing();
9303  }
9304 #endif
9305  strat->newt = TRUE;
9306  if (atT < 0)
9307  atT = strat->posInT(strat->T, strat->tl, p);
9308  if (strat->tl == strat->tmax-1)
9309  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9310  if (atT <= strat->tl)
9311  {
9312 #ifdef ENTER_USE_MEMMOVE
9313  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9314  (strat->tl-atT+1)*sizeof(TObject));
9315  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9316  (strat->tl-atT+1)*sizeof(unsigned long));
9317 #endif
9318  for (i=strat->tl+1; i>=atT+1; i--)
9319  {
9320 #ifndef ENTER_USE_MEMMOVE
9321  strat->T[i] = strat->T[i-1];
9322  strat->sevT[i] = strat->sevT[i-1];
9323 #endif
9324  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9325  }
9326  }
9327 
9328  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9329  {
9331  (strat->tailRing != NULL ?
9332  strat->tailRing : currRing),
9333  strat->tailBin);
9334  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9335  }
9336  strat->T[atT] = (TObject) p;
9337  //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9338 
9339  if (pNext(p.p) != NULL)
9340  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9341  else
9342  strat->T[atT].max_exp = NULL;
9343 
9344  strat->tl++;

◆ enterT_strong()

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

Definition at line 9350 of file kutil.cc.

9357 {
9359  int i;
9360 
9361  pp_Test(p.p, currRing, p.tailRing);
9362  assume(strat->tailRing == p.tailRing);
9363  // redMoraNF complains about this -- but, we don't really
9364  // neeed this so far
9365  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9366  assume(p.FDeg == p.pFDeg());
9367  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9368 
9369 #ifdef KDEBUG
9370  // do not put an LObject twice into T:
9371  for(i=strat->tl;i>=0;i--)
9372  {
9373  if (p.p==strat->T[i].p)
9374  {
9375  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9376  return;
9377  }
9378  }
9379 #endif
9380 
9381 #ifdef HAVE_TAIL_RING
9382  if (currRing!=strat->tailRing)
9383  {
9384  p.t_p=p.GetLmTailRing();
9385  }
9386 #endif
9387  strat->newt = TRUE;
9388  if (atT < 0)
9389  atT = strat->posInT(strat->T, strat->tl, p);
9390  if (strat->tl == strat->tmax-1)
9391  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9392  if (atT <= strat->tl)
9393  {
9394 #ifdef ENTER_USE_MEMMOVE
9395  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9396  (strat->tl-atT+1)*sizeof(TObject));
9397  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9398  (strat->tl-atT+1)*sizeof(unsigned long));
9399 #endif
9400  for (i=strat->tl+1; i>=atT+1; i--)
9401  {
9402 #ifndef ENTER_USE_MEMMOVE
9403  strat->T[i] = strat->T[i-1];
9404  strat->sevT[i] = strat->sevT[i-1];
9405 #endif
9406  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9407  }
9408  }
9409 
9410  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9411  {
9413  (strat->tailRing != NULL ?
9414  strat->tailRing : currRing),
9415  strat->tailBin);
9416  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9417  }
9418  strat->T[atT] = (TObject) p;
9419  //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9420 
9421  if (pNext(p.p) != NULL)
9422  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9423  else
9424  strat->T[atT].max_exp = NULL;
9425 
9426  strat->tl++;
9427  strat->R[strat->tl] = &(strat->T[atT]);
9428  strat->T[atT].i_r = strat->tl;
9429  assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9430  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9431  #if 1
9433  && !n_IsUnit(p.p->coef, currRing->cf))
9434  {
9435  for(i=strat->tl;i>=0;i--)
9436  {
9437  if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9438  {
9439  enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9440  }
9441  }
9442  }
9443  /*
9444  printf("\nThis is T:\n");
9445  for(i=strat->tl;i>=0;i--)
9446  {

◆ enterTShift()

void enterTShift ( LObject  p,
kStrategy  strat,
int  atT,
int  uptodeg,
int  lV 
)

Definition at line 12473 of file kutil.cc.

12483 {
12484  /* determine how many elements we have to insert */
12485  /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
12486  /* hence, a total number of elt's to add is: */
12487  /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
12488 
12489  int toInsert = itoInsert(p.p, uptodeg, lV, strat->tailRing);
12490 
12491 #ifdef PDEBUG
12492  // Print("enterTShift uses toInsert: %d", toInsert); PrintLn();
12493 #endif
12494  int i;
12495 
12496  if (atT < 0)
12497  atT = strat->posInT(strat->T, strat->tl, p);
12498 
12499  /* can call enterT in a sequence, e.g. */
12500 
12501  /* shift0 = it's our model for further shifts */
12502  enterT(p,strat,atT);
12503  LObject qq;
12504  for (i=1; i<=toInsert; i++) // toIns - 1?
12505  {
12506  qq = p; //qq.Copy();
12507  qq.t_p=NULL;
12508  qq.max_exp = NULL;
12509  if (p.p!=NULL)
12510  qq.p = p_LPshift(p_Copy(p.p,currRing), i, uptodeg, lV, currRing); // direct shift
12511  qq.GetTP();
12512  // update q.sev
12513  qq.sev = pGetShortExpVector(qq.p);
12514  #ifdef KTEST
12515  kTest_T(&qq, strat->tailRing, -1, 'L');
12516  #endif

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 9947 of file kutil.cc.

9955 {
9956  /*- release temp data -*/
9957  cleanT(strat);
9958  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
9959  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
9960  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
9961  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
9962  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
9963  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10140 of file kutil.cc.

10148 {
10149  /*- release temp data -*/
10151  cleanTSbaRing(strat);
10152  else
10153  cleanT(strat);
10154  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10155  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10156  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10157  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10158  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10159  omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10160  if(strat->syzmax>0)
10161  {
10162  omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10163  omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10164  if (strat->sbaOrder == 1)
10165  {
10166  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10167  }
10168  }
10169  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10170  /*- set L: should be empty -*/
10171  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));

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

3545 {
3546  int Ll_old, red_result = 1;
3547  int pos = 0;
3548  hilbeledeg=1;
3549  hilbcount=0;
3550  minimcnt=0;
3551  srmax = 0; // strat->sl is 0 at this point
3552  reduc = olddeg = lrmax = 0;
3553  // we cannot use strat->T anymore
3554  //cleanT(strat);
3555  //strat->tl = -1;
3556  Ll_old = strat->Ll;
3557  while (strat->tl >= 0)
3558  {
3559  if(!strat->T[strat->tl].is_redundant)
3560  {
3561  LObject h;
3562  h.p = strat->T[strat->tl].p;
3563  h.tailRing = strat->T[strat->tl].tailRing;
3564  h.t_p = strat->T[strat->tl].t_p;
3565  if (h.p!=NULL)
3566  {
3567  if (currRing->OrdSgn==-1)
3568  {
3569  cancelunit(&h);
3570  deleteHC(&h, strat);
3571  }
3572  if (h.p!=NULL)
3573  {
3575  {
3576  h.pCleardenom(); // also does remove Content
3577  }
3578  else
3579  {
3580  h.pNorm();
3581  }
3582  strat->initEcart(&h);
3584  pos = posInLF5CRing(strat->L, Ll_old+1,strat->Ll,&h,strat);
3585  else
3586  pos = strat->Ll+1;
3587  h.sev = pGetShortExpVector(h.p);
3588  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
3589  }
3590  }
3591  }
3592  strat->tl--;
3593  }
3594  strat->sl = -1;
3595 #if 0
3596 //#ifdef HAVE_TAIL_RING
3597  if(!rField_is_Ring()) // create strong gcd poly computes with tailring and S[i] ->to be fixed
3598  kStratInitChangeTailRing(strat);
3599 #endif
3600  //enterpairs(pOne(),0,0,-1,strat,strat->tl);
3601  //strat->sl = -1;
3602  /* picks the last element from the lazyset L */
3603  while (strat->Ll>Ll_old)
3604  {
3605  strat->P = strat->L[strat->Ll];
3606  strat->Ll--;
3607 //#if 1
3608 #ifdef DEBUGF5
3609  PrintS("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
3610  PrintS("-------------------------------------------------\n");
3611  pWrite(pHead(strat->P.p));
3612  pWrite(pHead(strat->P.p1));
3613  pWrite(pHead(strat->P.p2));
3614  printf("%d\n",strat->tl);
3615  PrintS("-------------------------------------------------\n");
3616 #endif
3617  if (pNext(strat->P.p) == strat->tail)
3618  {
3619  // deletes the short spoly
3620  if (rField_is_Ring(currRing))
3621  pLmDelete(strat->P.p);
3622  else
3623  pLmFree(strat->P.p);
3624 
3625  // TODO: needs some masking
3626  // TODO: masking needs to vanish once the signature
3627  // sutff is completely implemented
3628  strat->P.p = NULL;
3629  poly m1 = NULL, m2 = NULL;
3630 
3631  // check that spoly creation is ok
3632  while (strat->tailRing != currRing &&
3633  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
3634  {
3635  assume(m1 == NULL && m2 == NULL);
3636  // if not, change to a ring where exponents are at least
3637  // large enough
3638  if (!kStratChangeTailRing(strat))
3639  {
3640  WerrorS("OVERFLOW...");
3641  break;
3642  }
3643  }
3644  // create the real one
3645  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
3646  strat->tailRing, m1, m2, strat->R);
3647  }
3648  else if (strat->P.p1 == NULL)
3649  {
3650  if (strat->minim > 0)
3651  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
3652  // for input polys, prepare reduction
3653  if(!rField_is_Ring(currRing))
3654  strat->P.PrepareRed(strat->use_buckets);
3655  }
3656 
3657  if (strat->P.p == NULL && strat->P.t_p == NULL)
3658  {
3659  red_result = 0;
3660  }
3661  else
3662  {
3663  if (TEST_OPT_PROT)
3664  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
3665  &olddeg,&reduc,strat, red_result);
3666 
3667 #ifdef DEBUGF5
3668  PrintS("Poly before red: ");
3669  pWrite(strat->P.p);
3670 #endif
3671  /* complete reduction of the element chosen from L */
3672  red_result = strat->red2(&strat->P,strat);
3673  if (errorreported) break;
3674  }
3675 
3676  if (strat->overflow)
3677  {
3678  if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
3679  }
3680 
3681  // reduction to non-zero new poly
3682  if (red_result == 1)
3683  {
3684  // get the polynomial (canonicalize bucket, make sure P.p is set)
3685  strat->P.GetP(strat->lmBin);
3686  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
3687  // but now, for entering S, T, we reset it
3688  // in the inhomogeneous case: FDeg == pFDeg
3689  if (strat->homog) strat->initEcart(&(strat->P));
3690 
3691  /* statistic */
3692  if (TEST_OPT_PROT) PrintS("s");
3693  int pos;
3694  #if 1
3695  if(!rField_is_Ring(currRing))
3696  pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3697  else
3698  pos = posInSMonFirst(strat,strat->sl,strat->P.p);
3699  #else
3700  pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3701  #endif
3702  // reduce the tail and normalize poly
3703  // in the ring case we cannot expect LC(f) = 1,
3704  // therefore we call pCleardenom instead of pNorm
3705 #if F5CTAILRED
3706  BOOLEAN withT = TRUE;
3708  {
3709  strat->P.pCleardenom();
3711  {
3712  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
3713  strat->P.pCleardenom();
3714  }
3715  }
3716  else
3717  {
3718  strat->P.pNorm();
3720  strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
3721  }
3722 #endif
3723 #ifdef KDEBUG
3724  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3725 #endif /* KDEBUG */
3726 
3727  // min_std stuff
3728  if ((strat->P.p1==NULL) && (strat->minim>0))
3729  {
3730  if (strat->minim==1)
3731  {
3732  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
3733  p_Delete(&strat->P.p2, currRing, strat->tailRing);
3734  }
3735  else
3736  {
3737  strat->M->m[minimcnt]=strat->P.p2;
3738  strat->P.p2=NULL;
3739  }
3740  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
3741  pNext(strat->M->m[minimcnt])
3742  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
3743  strat->tailRing, currRing,
3744  currRing->PolyBin);
3745  minimcnt++;
3746  }
3747 
3748  // enter into S, L, and T
3749  // here we need to recompute new signatures, but those are trivial ones
3750  if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3751  {
3752  enterT(strat->P, strat);
3753  // posInS only depends on the leading term
3754  strat->enterS(strat->P, pos, strat, strat->tl);
3755 //#if 1
3756 #ifdef DEBUGF5
3757  PrintS("ELEMENT ADDED TO GCURR DURING INTERRED: ");
3758  pWrite(pHead(strat->S[strat->sl]));
3759  pWrite(strat->sig[strat->sl]);
3760 #endif
3761  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
3762  }
3763  // Print("[%d]",hilbeledeg);
3764  if (strat->P.lcm!=NULL)
3765 #ifdef HAVE_RINGS
3766  pLmDelete(strat->P.lcm);
3767 #else
3768  pLmFree(strat->P.lcm);
3769 #endif
3770  if (strat->sl>srmax) srmax = strat->sl;
3771  }
3772  else
3773  {
3774  // adds signature of the zero reduction to
3775  // strat->syz. This is the leading term of
3776  // syzygy and can be used in syzCriterion()
3777  // the signature is added if and only if the
3778  // pair was not detected by the rewritten criterion in strat->red = redSig
3779  if (strat->P.p1 == NULL && strat->minim > 0)
3780  {
3781  p_Delete(&strat->P.p2, currRing, strat->tailRing);
3782  }
3783  }
3784 
3785 #ifdef KDEBUG
3786  memset(&(strat->P), 0, sizeof(strat->P));
3787 #endif /* KDEBUG */
3788  }
3789  int cc = 0;
3790  while (cc<strat->tl+1)
3791  {
3792  strat->T[cc].sig = pOne();
3793  p_SetComp(strat->T[cc].sig,cc+1,currRing);
3794  strat->T[cc].sevSig = pGetShortExpVector(strat->T[cc].sig);
3795  strat->sig[cc] = strat->T[cc].sig;
3796  strat->sevSig[cc] = strat->T[cc].sevSig;
3797  strat->T[cc].is_sigsafe = TRUE;
3798  cc++;
3799  }
3800  strat->max_lower_index = strat->tl;
3801  // set current signature index of upcoming iteration step
3802  // NOTE: this needs to be set here, as otherwise initSyzRules cannot compute
3803  // the corresponding syzygy rules correctly
3804  strat->currIdx = cc+1;
3805  for (int cd=strat->Ll; cd>=0; cd--)
3806  {
3807  p_SetComp(strat->L[cd].sig,cc+1,currRing);
3808  cc++;
3809  }
3810  for (cc=strat->sl+1; cc<IDELEMS(strat->Shdl); ++cc)
3811  strat->Shdl->m[cc] = NULL;
3812  #if 0
3813  printf("\nAfter f5c sorting\n");
3814  for(int i=0;i<=strat->sl;i++)
3815  pWrite(pHead(strat->S[i]));
3816  getchar();
3817  #endif
3818 //#if 1
3819 #if DEBUGF5
3820  PrintS("------------------- STRAT S ---------------------\n");
3821  cc = 0;
3822  while (cc<strat->tl+1)
3823  {
3824  pWrite(pHead(strat->S[cc]));
3825  pWrite(strat->sig[cc]);
3826  printf("- - - - - -\n");
3827  cc++;
3828  }
3829  PrintS("-------------------------------------------------\n");
3830  PrintS("------------------- STRAT T ---------------------\n");
3831  cc = 0;
3832  while (cc<strat->tl+1)
3833  {
3834  pWrite(pHead(strat->T[cc].p));
3835  pWrite(strat->T[cc].sig);
3836  printf("- - - - - -\n");
3837  cc++;
3838  }
3839  PrintS("-------------------------------------------------\n");
3840  PrintS("------------------- STRAT L ---------------------\n");
3841  cc = 0;
3842  while (cc<strat->Ll+1)
3843  {
3844  pWrite(pHead(strat->L[cc].p));
3845  pWrite(pHead(strat->L[cc].p1));
3846  pWrite(pHead(strat->L[cc].p2));
3847  pWrite(strat->L[cc].sig);
3848  printf("- - - - - -\n");
3849  cc++;
3850  }
3851  PrintS("-------------------------------------------------\n");
3852  printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx);
3853 #endif

◆ faugereRewCriterion()

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

Definition at line 7028 of file kutil.cc.

7030 {
7031  //printf("Faugere Rewritten Criterion\n");
7033  return FALSE;
7034 //#if 1
7035 #ifdef DEBUGF5
7036  PrintS("rewritten criterion checks: ");
7037  pWrite(sig);
7038 #endif
7039  for(int k = strat->sl; k>=start; k--)
7040  {
7041 //#if 1
7042 #ifdef DEBUGF5
7043  PrintS("checking with: ");
7044  pWrite(strat->sig[k]);
7045  pWrite(pHead(strat->S[k]));
7046 #endif
7047  if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
7048  {
7049 //#if 1
7050 #ifdef DEBUGF5
7051  PrintS("DELETE!\n");
7052 #endif
7053  strat->nrrewcrit++;
7054  return TRUE;
7055  }
7056  //k--;
7057  }
7058 #ifdef DEBUGF5
7059  PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
7060  for(int kk = 0; kk<strat->sl+1; kk++)
7061  {
7062  pWrite(pHead(strat->S[kk]));
7063  }
7064  PrintS("------------------------------\n");
7065 #endif
7066  return FALSE;

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

10972 {
10973  if(!nCoeff_is_Ring_Z(currRing->cf))
10974  return;
10975  poly p,pp;
10976  for(int j = 0; j<=strat->sl; j++)
10977  {
10978  if((strat->S[j]!=NULL)&&(pNext(strat->S[j]) == NULL))
10979  {
10980  for(int i = 0; i<=strat->sl; i++)
10981  {
10982  if((i != j) && (strat->S[i] != NULL))
10983  {
10984  p = strat->S[i];
10985  if(pLmDivisibleBy(strat->S[j], p))
10986  {
10987  number dummy = n_IntMod(p->coef, strat->S[j]->coef, currRing->cf);
10988  p_SetCoeff(p,dummy,currRing);
10989  }
10990  pp = pNext(p);
10991  if((pp == NULL) && (nIsZero(p->coef)))
10992  {
10993  deleteInS(i, strat);
10994  }
10995  else
10996  {
10997  while(pp != NULL)
10998  {
10999  if(pLmDivisibleBy(strat->S[j], pp))
11000  {
11001  number dummy = n_IntMod(pp->coef, strat->S[j]->coef, currRing->cf);
11002  p_SetCoeff(pp,dummy,currRing);
11003  if(nIsZero(pp->coef))
11004  {
11005  pLmDelete(&pNext(p));
11006  pp = pNext(p);
11007  }
11008  else
11009  {
11010  p = pp;
11011  pp = pNext(p);
11012  }
11013  }
11014  else
11015  {
11016  p = pp;
11017  pp = pNext(p);
11018  }
11019  }
11020  }
11021  if(strat->S[i]!= NULL && nIsZero(pGetCoeff(strat->S[i])))
11022  {
11023  if(pNext(strat->S[i]) == NULL)
11024  strat->S[i]=NULL;
11025  else

◆ findMinLMPair()

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

◆ freegb()

ideal freegb ( ideal  I,
int  uptodeg,
int  lVblock 
)

Definition at line 4230 of file kstd2.cc.

4233 {
4234  /* todo main call */
4235 
4236  /* assume: ring is prepared, ideal is copied into shifted ring */
4237  /* uptodeg and lVblock are correct - test them! */
4238 
4239  /* check whether the ideal is in V */
4240 
4241 // if (0)
4242  if (! ideal_isInV(I,lVblock) )
4243  {
4244  WerrorS("The input ideal contains incorrectly encoded elements! ");
4245  return(NULL);
4246  }
4247 
4248  // kStrategy strat = new skStrategy;
4249  /* ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV) */
4250  /* at the moment:
4251 - no quotient (check)
4252 - no *w, no *hilb
4253  */
4254  /* ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
4255  int newIdeal, intvec *vw) */
4256  ideal RS = kStdShift(I,NULL, testHomog, NULL,NULL,0,0,NULL, uptodeg, lVblock);
4257  //bbaShift(I,NULL, NULL, NULL, strat, uptodeg, lVblock);
4258  idSkipZeroes(RS);

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 466 of file kutil.cc.

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

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ ind2()

long ind2 ( long  arg)

Definition at line 4043 of file kutil.cc.

4045 {
4046  long ind = 0;
4047  if (arg <= 0) return 0;
4048  while (arg%2 == 0)
4049  {
4050  arg = arg / 2;
4051  ind++;
4052  }
4053  return ind;

◆ ind_fact_2()

long ind_fact_2 ( long  arg)

Definition at line 4055 of file kutil.cc.

4057 {
4058  long ind = 0;
4059  if (arg <= 0) return 0;
4060  if (arg%2 == 1) { arg--; }
4061  while (arg > 0)
4062  {
4063  ind += ind2(arg);
4064  arg = arg - 2;
4065  }
4066  return ind;

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1337 of file kstd1.cc.

1339 {
1340  /* setting global variables ------------------- */
1341  strat->enterS = enterSBba;
1342  strat->red = redHoney;
1343  if (strat->honey)
1344  strat->red = redHoney;
1345  else if (currRing->pLexOrder && !strat->homog)
1346  strat->red = redLazy;
1347  else
1348  {
1349  strat->LazyPass *=4;
1350  strat->red = redHomog;
1351  }
1352  if (rField_is_Ring(currRing))
1353  {
1354  strat->red = redRing;
1355  }
1356  if (currRing->pLexOrder && strat->honey)
1357  strat->initEcart = initEcartNormal;
1358  else
1359  strat->initEcart = initEcartBBA;
1360  if (strat->honey)
1362  else
1364 // if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1365 // {
1366 // //interred machen Aenderung
1367 // strat->pOrigFDeg=pFDeg;
1368 // strat->pOrigLDeg=pLDeg;
1369 // //h=ggetid("ecart");
1370 // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1371 // //{
1372 // // ecartWeights=iv2array(IDINTVEC(h));
1373 // //}
1374 // //else
1375 // {
1376 // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1377 // /*uses automatic computation of the ecartWeights to set them*/
1378 // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1379 // }
1380 // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1381 // if (TEST_OPT_PROT)
1382 // {
1383 // for(i=1; i<=(currRing->N); i++)
1384 // Print(" %d",ecartWeights[i]);
1385 // PrintLn();
1386 // mflush();
1387 // }
1388 // }

◆ initBbaShift()

void initBbaShift ( kStrategy  strat)

Definition at line 4390 of file kstd2.cc.

4393 {
4394  /* setting global variables ------------------- */
4395  strat->enterS = enterSBba; /* remains as is, we change enterT! */
4396 
4397  strat->red = redFirstShift; /* no redHomog ! */
4398 
4399  if (currRing->pLexOrder && strat->honey)
4400  strat->initEcart = initEcartNormal;
4401  else
4402  strat->initEcart = initEcartBBA;
4403  if (strat->honey)
4405  else
4407 // if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
4408 // {
4409 // //interred machen Aenderung
4410 // pFDegOld=currRing->pFDeg;
4411 // pLDegOld=pLDeg;
4412 // //h=ggetid("ecart");
4413 // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
4414 // //{
4415 // // ecartWeights=iv2array(IDINTVEC(h));
4416 // //}
4417 // //else
4418 // {
4419 // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
4420 // /*uses automatic computation of the ecartWeights to set them*/
4421 // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights,currRing);
4422 // }
4423 // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
4424 // if (TEST_OPT_PROT)
4425 // {
4426 // for(int i=1; i<=rVar(currRing); i++)
4427 // Print(" %d",ecartWeights[i]);
4428 // PrintLn();
4429 // mflush();
4430 // }

◆ initBuchMora()

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

Definition at line 9871 of file kutil.cc.

9879 {
9880  strat->interpt = BTEST1(OPT_INTERRUPT);
9881  strat->kHEdge=NULL;
9883  /*- creating temp data structures------------------- -*/
9884  strat->cp = 0;
9885  strat->c3 = 0;
9886  strat->tail = pInit();
9887  /*- set s -*/
9888  strat->sl = -1;
9889  /*- set L -*/
9890  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9891  strat->Ll = -1;
9892  strat->L = initL(strat->Lmax);
9893  /*- set B -*/
9894  strat->Bmax = setmaxL;
9895  strat->Bl = -1;
9896  strat->B = initL();
9897  /*- set T -*/
9898  strat->tl = -1;
9899  strat->tmax = setmaxT;
9900  strat->T = initT();
9901  strat->R = initR();
9902  strat->sevT = initsevT();
9903  /*- init local data struct.---------------------------------------- -*/
9904  strat->P.ecart=0;
9905  strat->P.length=0;
9906  strat->P.pLength=0;
9908  {
9909  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
9910  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
9911  }
9913  {
9914  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9915  }
9916  else
9917  {
9918  if(TEST_OPT_SB_1)
9919  {
9920  int i;
9921  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
9922  for (i=strat->newIdeal;i<IDELEMS(F);i++)
9923  {
9924  P->m[i-strat->newIdeal] = F->m[i];
9925  F->m[i] = NULL;
9926  }
9927  initSSpecial(F,Q,P,strat);
9928  for (i=strat->newIdeal;i<IDELEMS(F);i++)
9929  {
9930  F->m[i] = P->m[i-strat->newIdeal];
9931  P->m[i-strat->newIdeal] = NULL;
9932  }
9933  idDelete(&P);
9934  }
9935  else
9936  {
9937  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9938  // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
9939  }
9940  }
9941  strat->fromT = FALSE;
9943  if ((!TEST_OPT_SB_1)
9944  || (rField_is_Ring(currRing))
9945  )

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9548 of file kutil.cc.

9549  {
9550  *hilb=NULL;
9551  }
9552 }
9553 
9554 void initBuchMoraCrit(kStrategy strat)
9555 {
9557  strat->chainCrit=chainCritNormal;
9558  if (TEST_OPT_SB_1)
9559  strat->chainCrit=chainCritOpt_1;
9560 #ifdef HAVE_RINGS
9561  if (rField_is_Ring(currRing))
9562  {
9564  strat->chainCrit=chainCritRing;
9565  }
9566 #endif
9567 #ifdef HAVE_RATGRING
9568  if (rIsRatGRing(currRing))
9569  {
9570  strat->chainCrit=chainCritPart;
9571  /* enterOnePairNormal get rational part in it */
9572  }
9573 #endif
9574  if (TEST_OPT_IDLIFT /* i.e. also strat->syzComp==1 */
9575  && (!rIsPluralRing(currRing)))
9577 
9578  strat->sugarCrit = TEST_OPT_SUGARCRIT;
9579  strat->Gebauer = strat->homog || strat->sugarCrit;
9580  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9581  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9582  strat->pairtest = NULL;
9583  /* alway use tailreduction, except:
9584  * - in local rings, - in lex order case, -in ring over extensions */
9586  //if(rHasMixedOrdering(currRing)==2)
9587  //{
9588  // strat->noTailReduction =TRUE;
9589  //}
9590 
9591 #ifdef HAVE_PLURAL
9592  // and r is plural_ring
9593  // hence this holds for r a rational_plural_ring
9594  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9595  { //or it has non-quasi-comm type... later
9596  strat->sugarCrit = FALSE;
9597  strat->Gebauer = FALSE;
9598  strat->honey = FALSE;
9599  }
9600 #endif
9601 
9602  // Coefficient ring?
9603  if (rField_is_Ring(currRing))
9604  {
9605  strat->sugarCrit = FALSE;
9606  strat->Gebauer = FALSE ;
9607  strat->honey = FALSE;
9608  }
9609  #ifdef KDEBUG
9610  if (TEST_OPT_DEBUG)

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9698 of file kutil.cc.

9706 {
9708  {
9709  if (strat->honey)
9710  {
9711  strat->posInL = posInL15;
9712  // ok -- here is the deal: from my experiments for Singular-2-0
9713  // I conclude that that posInT_EcartpLength is the best of
9714  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9715  // see the table at the end of this file
9716  if (TEST_OPT_OLDSTD)
9717  strat->posInT = posInT15;
9718  else
9719  strat->posInT = posInT_EcartpLength;
9720  }
9721  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9722  {
9723  strat->posInL = posInL11;
9724  strat->posInT = posInT11;
9725  }
9726  else if (TEST_OPT_INTSTRATEGY)
9727  {
9728  strat->posInL = posInL11;
9729  strat->posInT = posInT11;
9730  }
9731  else
9732  {
9733  strat->posInL = posInL0;
9734  strat->posInT = posInT0;
9735  }
9736  //if (strat->minim>0) strat->posInL =posInLSpecial;
9737  if (strat->homog)
9738  {
9739  strat->posInL = posInL110;
9740  strat->posInT = posInT110;
9741  }
9742  }
9743  else
9744  {
9745  if (strat->homog)
9746  {
9747  strat->posInL = posInL11;
9748  strat->posInT = posInT11;
9749  }
9750  else
9751  {
9752  if ((currRing->order[0]==ringorder_c)
9753  ||(currRing->order[0]==ringorder_C))
9754  {
9755  strat->posInL = posInL17_c;
9756  strat->posInT = posInT17_c;
9757  }
9758  else
9759  {
9760  strat->posInL = posInL17;
9761  strat->posInT = posInT17;
9762  }
9763  }
9764  }
9765  if (strat->minim>0) strat->posInL =posInLSpecial;
9766  // for further tests only
9767  if ((BTEST1(11)) || (BTEST1(12)))
9768  strat->posInL = posInL11;
9769  else if ((BTEST1(13)) || (BTEST1(14)))
9770  strat->posInL = posInL13;
9771  else if ((BTEST1(15)) || (BTEST1(16)))
9772  strat->posInL = posInL15;
9773  else if ((BTEST1(17)) || (BTEST1(18)))
9774  strat->posInL = posInL17;
9775  if (BTEST1(11))
9776  strat->posInT = posInT11;
9777  else if (BTEST1(13))
9778  strat->posInT = posInT13;
9779  else if (BTEST1(15))
9780  strat->posInT = posInT15;
9781  else if ((BTEST1(17)))

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9784 of file kutil.cc.

9792 {
9794  {
9795  if (strat->honey)
9796  {
9797  strat->posInL = posInL15Ring;
9798  // ok -- here is the deal: from my experiments for Singular-2-0
9799  // I conclude that that posInT_EcartpLength is the best of
9800  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9801  // see the table at the end of this file
9802  if (TEST_OPT_OLDSTD)
9803  strat->posInT = posInT15Ring;
9804  else
9805  strat->posInT = posInT_EcartpLength;
9806  }
9807  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9808  {
9809  strat->posInL = posInL11Ring;
9810  strat->posInT = posInT11;
9811  }
9812  else if (TEST_OPT_INTSTRATEGY)
9813  {
9814  strat->posInL = posInL11Ring;
9815  strat->posInT = posInT11;
9816  }
9817  else
9818  {
9819  strat->posInL = posInL0Ring;
9820  strat->posInT = posInT0;
9821  }
9822  //if (strat->minim>0) strat->posInL =posInLSpecial;
9823  if (strat->homog)
9824  {
9825  strat->posInL = posInL110Ring;
9826  strat->posInT = posInT110Ring;
9827  }
9828  }
9829  else
9830  {
9831  if (strat->homog)
9832  {
9833  //printf("\nHere 3\n");
9834  strat->posInL = posInL11Ring;
9835  strat->posInT = posInT11Ring;
9836  }
9837  else
9838  {
9839  if ((currRing->order[0]==ringorder_c)
9840  ||(currRing->order[0]==ringorder_C))
9841  {
9842  strat->posInL = posInL17_cRing;
9843  strat->posInT = posInT17_cRing;
9844  }
9845  else
9846  {
9847  strat->posInL = posInL11Ringls;
9848  strat->posInT = posInT17Ring;
9849  }
9850  }
9851  }
9852  if (strat->minim>0) strat->posInL =posInLSpecial;
9853  // for further tests only
9854  if ((BTEST1(11)) || (BTEST1(12)))
9855  strat->posInL = posInL11Ring;
9856  else if ((BTEST1(13)) || (BTEST1(14)))
9857  strat->posInL = posInL13;
9858  else if ((BTEST1(15)) || (BTEST1(16)))
9859  strat->posInL = posInL15Ring;
9860  else if ((BTEST1(17)) || (BTEST1(18)))
9861  strat->posInL = posInL17Ring;
9862  if (BTEST1(11))
9863  strat->posInT = posInT11Ring;
9864  else if (BTEST1(13))
9865  strat->posInT = posInT13;
9866  else if (BTEST1(15))
9867  strat->posInT = posInT15Ring;
9868  else if ((BTEST1(17)))

◆ initBuchMoraShift()

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

Definition at line 11862 of file kutil.cc.

11872 {
11873  strat->interpt = BTEST1(OPT_INTERRUPT);
11874  strat->kHEdge=NULL;
11876  /*- creating temp data structures------------------- -*/
11877  strat->cp = 0;
11878  strat->c3 = 0;
11879  strat->cv = 0;
11880  strat->tail = pInit();
11881  /*- set s -*/
11882  strat->sl = -1;
11883  /*- set L -*/
11884  strat->Lmax = setmaxL;
11885  strat->Ll = -1;
11886  strat->L = initL();
11887  /*- set B -*/
11888  strat->Bmax = setmaxL;
11889  strat->Bl = -1;
11890  strat->B = initL();
11891  /*- set T -*/
11892  strat->tl = -1;
11893  strat->tmax = setmaxT;
11894  strat->T = initT();
11895  strat->R = initR();
11896  strat->sevT = initsevT();
11897  /*- init local data struct.---------------------------------------- -*/
11898  strat->P.ecart=0;
11899  strat->P.length=0;
11901  {
11902  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
11903  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
11904  }
11906  {
11907  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
11908  }
11909  {
11910  if(TEST_OPT_SB_1)
11911  {
11912  int i;
11913  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
11914  for (i=strat->newIdeal;i<IDELEMS(F);i++)
11915  {
11916  P->m[i-strat->newIdeal] = F->m[i];
11917  F->m[i] = NULL;
11918  }
11919  initSSpecial(F,Q,P,strat);
11920  for (i=strat->newIdeal;i<IDELEMS(F);i++)
11921  {
11922  F->m[i] = P->m[i-strat->newIdeal];
11923  P->m[i-strat->newIdeal] = NULL;
11924  }
11925  idDelete(&P);
11926  }
11927  else
11928  {
11929  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
11930  // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
11931  }
11932  }
11933  strat->fromT = FALSE;
11934  if (!TEST_OPT_SB_1)

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1246 of file kutil.cc.

1248 {
1249  h->FDeg = h->pFDeg();
1250  (*h).ecart = 0;
1251  h->length=h->pLength=pLength(h->p);

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1238 of file kutil.cc.

1240 {
1241  h->FDeg = h->pFDeg();
1242  h->ecart = h->pLDeg() - h->FDeg;
1243  // h->length is set by h->pLDeg
1244  h->length=h->pLength=pLength(h->p);

◆ initEcartPairBba()

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

Definition at line 1253 of file kutil.cc.

1255 {
1256  Lp->FDeg = Lp->pFDeg();
1257  (*Lp).ecart = 0;
1258  (*Lp).length = 0;

◆ initEcartPairMora()

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

Definition at line 1260 of file kutil.cc.

1262 {
1263  Lp->FDeg = Lp->pFDeg();
1264  (*Lp).ecart = si_max(ecartF,ecartG);
1265  (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1266  (*Lp).length = 0;

◆ initHilbCrit()

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

Definition at line 9530 of file kutil.cc.

9537 {
9538 
9539  //if the ordering is local, then hilb criterion
9540  //can be used also if the ideal is not homogenous
9542  {
9544  *hilb=NULL;
9545  else
9546  return;

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 414 of file kutil.h.

416 { return (LSet)omAlloc(nr*sizeof(LObject)); }

◆ initR()

KINLINE TObject** initR ( )

Definition at line 89 of file kInline.h.

93 {

◆ initS()

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

Definition at line 7846 of file kutil.cc.

7849 {
7850  int i,pos;
7851 
7852  if (Q!=NULL) i=((IDELEMS(F)+IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7853  else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7854  strat->ecartS=initec(i);
7855  strat->sevS=initsevS(i);
7856  strat->S_2_R=initS_2_R(i);
7857  strat->fromQ=NULL;
7858  strat->Shdl=idInit(i,F->rank);
7859  strat->S=strat->Shdl->m;
7860  /*- put polys into S -*/
7861  if (Q!=NULL)
7862  {
7863  strat->fromQ=initec(i);
7864  memset(strat->fromQ,0,i*sizeof(int));
7865  for (i=0; i<IDELEMS(Q); i++)
7866  {
7867  if (Q->m[i]!=NULL)
7868  {
7869  LObject h;
7870  h.p = pCopy(Q->m[i]);
7872  {
7873  h.pCleardenom(); // also does remove Content
7874  }
7875  else
7876  {
7877  h.pNorm();
7878  }
7880  {
7881  deleteHC(&h, strat);
7882  }
7883  if (h.p!=NULL)
7884  {
7885  strat->initEcart(&h);
7886  if (strat->sl==-1)
7887  pos =0;
7888  else
7889  {
7890  pos = posInS(strat,strat->sl,h.p,h.ecart);
7891  }
7892  h.sev = pGetShortExpVector(h.p);
7893  strat->enterS(h,pos,strat,-1);
7894  strat->fromQ[pos]=1;
7895  }
7896  }
7897  }
7898  }
7899  for (i=0; i<IDELEMS(F); i++)
7900  {
7901  if (F->m[i]!=NULL)
7902  {
7903  LObject h;
7904  h.p = pCopy(F->m[i]);
7906  {
7907  cancelunit(&h); /*- tries to cancel a unit -*/
7908  deleteHC(&h, strat);
7909  }
7910  if (h.p!=NULL)
7911  // do not rely on the input being a SB!
7912  {
7914  {
7915  h.pCleardenom(); // also does remove Content
7916  }
7917  else
7918  {
7919  h.pNorm();
7920  }
7921  strat->initEcart(&h);
7922  if (strat->sl==-1)
7923  pos =0;
7924  else
7925  pos = posInS(strat,strat->sl,h.p,h.ecart);
7926  h.sev = pGetShortExpVector(h.p);
7927  strat->enterS(h,pos,strat,-1);
7928  }
7929  }
7930  }
7931  /*- test, if a unit is in F -*/
7932  if ((strat->sl>=0)
7933 #ifdef HAVE_RINGS
7934  && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7935 #endif
7936  && pIsConstant(strat->S[0]))
7937  {
7938  while (strat->sl>0) deleteInS(strat->sl,strat);

◆ initSba()

void initSba ( ideal  F,
kStrategy  strat 
)

Definition at line 1390 of file kstd1.cc.

1392 {
1393  int i;
1394  //idhdl h;
1395  /* setting global variables ------------------- */
1396  strat->enterS = enterSSba;
1397  strat->red2 = redHoney;
1398  if (strat->honey)
1399  strat->red2 = redHoney;
1400  else if (currRing->pLexOrder && !strat->homog)
1401  strat->red2 = redLazy;
1402  else
1403  {
1404  strat->LazyPass *=4;
1405  strat->red2 = redHomog;
1406  }
1407  if (rField_is_Ring(currRing))
1408  {
1410  {strat->red2 = redRiloc;}
1411  else
1412  {strat->red2 = redRing;}
1413  }
1414  if (currRing->pLexOrder && strat->honey)
1415  strat->initEcart = initEcartNormal;
1416  else
1417  strat->initEcart = initEcartBBA;
1418  if (strat->honey)
1420  else
1422  //strat->kIdeal = NULL;
1423  //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1424  //else strat->kIdeal->rtyp=MODUL_CMD;
1425  //strat->kIdeal->data=(void *)strat->Shdl;
1426  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1427  {
1428  //interred machen Aenderung
1429  strat->pOrigFDeg = currRing->pFDeg;
1430  strat->pOrigLDeg = currRing->pLDeg;
1431  //h=ggetid("ecart");
1432  //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1433  //{
1434  // ecartWeights=iv2array(IDINTVEC(h));
1435  //}
1436  //else
1437  {
1438  ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1439  /*uses automatic computation of the ecartWeights to set them*/
1441  }
1443  if (TEST_OPT_PROT)
1444  {
1445  for(i=1; i<=(currRing->N); i++)
1446  Print(" %d",ecartWeights[i]);
1447  PrintLn();
1448  mflush();
1449  }
1450  }
1451  // for sig-safe reductions in signature-based
1452  // standard basis computations
1454  strat->red = redSigRing;
1455  else
1456  strat->red = redSig;
1457  //strat->sbaOrder = 1;
1458  strat->currIdx = 1;

◆ initSbaBuchMora()

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

Definition at line 10067 of file kutil.cc.

10067  {
10068  strat->posInLSba = posInLSigRing;
10069  strat->posInL = posInL11Ring;
10070  }*/
10071  //strat->posInT = posInTSig;
10072 }
10073 
10074 void initSbaBuchMora (ideal F,ideal Q,kStrategy strat)
10075 {
10076  strat->interpt = BTEST1(OPT_INTERRUPT);
10077  strat->kHEdge=NULL;
10079  /*- creating temp data structures------------------- -*/
10080  strat->cp = 0;
10081  strat->c3 = 0;
10082  strat->tail = pInit();
10083  /*- set s -*/
10084  strat->sl = -1;
10085  /*- set ps -*/
10086  strat->syzl = -1;
10087  /*- set L -*/
10088  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10089  strat->Ll = -1;
10090  strat->L = initL(strat->Lmax);
10091  /*- set B -*/
10092  strat->Bmax = setmaxL;
10093  strat->Bl = -1;
10094  strat->B = initL();
10095  /*- set T -*/
10096  strat->tl = -1;
10097  strat->tmax = setmaxT;
10098  strat->T = initT();
10099  strat->R = initR();
10100  strat->sevT = initsevT();
10101  /*- init local data struct.---------------------------------------- -*/
10102  strat->P.ecart=0;
10103  strat->P.length=0;
10105  {
10106  if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10107  if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10108  }
10110  {
10111  /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10112  }
10113  else
10114  {
10115  if(TEST_OPT_SB_1)
10116  {
10117  int i;
10118  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10119  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10120  {
10121  P->m[i-strat->newIdeal] = F->m[i];
10122  F->m[i] = NULL;
10123  }
10124  initSSpecialSba(F,Q,P,strat);
10125  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10126  {
10127  F->m[i] = P->m[i-strat->newIdeal];
10128  P->m[i-strat->newIdeal] = NULL;
10129  }
10130  idDelete(&P);
10131  }
10132  else
10133  {
10134  initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10135  }
10136  }
10137  strat->fromT = FALSE;
10138  if (!TEST_OPT_SB_1)

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9612 of file kutil.cc.

9619 {
9620  //strat->enterOnePair=enterOnePairNormal;
9622  //strat->chainCrit=chainCritNormal;
9623  strat->chainCrit = chainCritSig;
9624  /******************************************
9625  * rewCrit1 and rewCrit2 are already set in
9626  * kSba() in kstd1.cc
9627  *****************************************/
9628  //strat->rewCrit1 = faugereRewCriterion;
9629  if (strat->sbaOrder == 1)
9630  {
9631  strat->syzCrit = syzCriterionInc;
9632  }
9633  else
9634  {
9635  strat->syzCrit = syzCriterion;
9636  }
9637 #ifdef HAVE_RINGS
9638  if (rField_is_Ring(currRing))
9639  {
9641  strat->chainCrit=chainCritRing;
9642  }
9643 #endif
9644 #ifdef HAVE_RATGRING
9645  if (rIsRatGRing(currRing))
9646  {
9647  strat->chainCrit=chainCritPart;
9648  /* enterOnePairNormal get rational part in it */
9649  }
9650 #endif
9651 
9652  strat->sugarCrit = TEST_OPT_SUGARCRIT;
9653  strat->Gebauer = strat->homog || strat->sugarCrit;
9654  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9655  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9656  strat->pairtest = NULL;
9657  /* alway use tailreduction, except:
9658  * - in local rings, - in lex order case, -in ring over extensions */
9661 
9662 #ifdef HAVE_PLURAL
9663  // and r is plural_ring
9664  // hence this holds for r a rational_plural_ring
9665  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9666  { //or it has non-quasi-comm type... later
9667  strat->sugarCrit = FALSE;
9668  strat->Gebauer = FALSE;
9669  strat->honey = FALSE;
9670  }
9671 #endif
9672 
9673  // Coefficient ring?
9674  if (rField_is_Ring(currRing))
9675  {
9676  strat->sugarCrit = FALSE;
9677  strat->Gebauer = FALSE ;
9678  strat->honey = FALSE;
9679  }
9680  #ifdef KDEBUG

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 9965 of file kutil.cc.

9973 {
9975  {
9976  if (strat->honey)
9977  {
9978  strat->posInL = posInL15;
9979  // ok -- here is the deal: from my experiments for Singular-2-0
9980  // I conclude that that posInT_EcartpLength is the best of
9981  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9982  // see the table at the end of this file
9983  if (TEST_OPT_OLDSTD)
9984  strat->posInT = posInT15;
9985  else
9986  strat->posInT = posInT_EcartpLength;
9987  }
9988  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9989  {
9990  strat->posInL = posInL11;
9991  strat->posInT = posInT11;
9992  }
9993  else if (TEST_OPT_INTSTRATEGY)
9994  {
9995  strat->posInL = posInL11;
9996  strat->posInT = posInT11;
9997  }
9998  else
9999  {
10000  strat->posInL = posInL0;
10001  strat->posInT = posInT0;
10002  }
10003  //if (strat->minim>0) strat->posInL =posInLSpecial;
10004  if (strat->homog)
10005  {
10006  strat->posInL = posInL110;
10007  strat->posInT = posInT110;
10008  }
10009  }
10010  else
10011  {
10012  if (strat->homog)
10013  {
10014  strat->posInL = posInL11;
10015  strat->posInT = posInT11;
10016  }
10017  else
10018  {
10019  if ((currRing->order[0]==ringorder_c)
10020  ||(currRing->order[0]==ringorder_C))
10021  {
10022  strat->posInL = posInL17_c;
10023  strat->posInT = posInT17_c;
10024  }
10025  else
10026  {
10027  strat->posInL = posInL17;
10028  strat->posInT = posInT17;
10029  }
10030  }
10031  }
10032  if (strat->minim>0) strat->posInL =posInLSpecial;
10033  // for further tests only
10034  if ((BTEST1(11)) || (BTEST1(12)))
10035  strat->posInL = posInL11;
10036  else if ((BTEST1(13)) || (BTEST1(14)))
10037  strat->posInL = posInL13;
10038  else if ((BTEST1(15)) || (BTEST1(16)))
10039  strat->posInL = posInL15;
10040  else if ((BTEST1(17)) || (BTEST1(18)))
10041  strat->posInL = posInL17;
10042  if (BTEST1(11))
10043  strat->posInT = posInT11;
10044  else if (BTEST1(13))
10045  strat->posInT = posInT13;
10046  else if (BTEST1(15))
10047  strat->posInT = posInT15;
10048  else if ((BTEST1(17)))
10049  strat->posInT = posInT17;
10050  else if ((BTEST1(19)))
10051  strat->posInT = posInT19;
10052  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10053  strat->posInT = posInT1;
10054  if (rField_is_Ring(currRing))
10055  {
10056  strat->posInL = posInL11Ring;
10057  if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
10058  strat->posInL = posInL11Ringls;
10059  strat->posInT = posInT11;
10060  }
10061  strat->posInLDependsOnLength = FALSE;
10062  strat->posInLSba = posInLSig;
10063  //strat->posInL = posInLSig;
10064  strat->posInL = posInLF5C;
10065  /*

◆ initsevT()

KINLINE unsigned long* initsevT ( )

Definition at line 94 of file kInline.h.

98 {

◆ initSL()

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

Definition at line 7940 of file kutil.cc.

7943 {
7944  int i,pos;
7945 
7946  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7947  else i=setmaxT;
7948  strat->ecartS=initec(i);
7949  strat->sevS=initsevS(i);
7950  strat->S_2_R=initS_2_R(i);
7951  strat->fromQ=NULL;
7952  strat->Shdl=idInit(i,F->rank);
7953  strat->S=strat->Shdl->m;
7954  /*- put polys into S -*/
7955  if (Q!=NULL)
7956  {
7957  strat->fromQ=initec(i);
7958  memset(strat->fromQ,0,i*sizeof(int));
7959  for (i=0; i<IDELEMS(Q); i++)
7960  {
7961  if (Q->m[i]!=NULL)
7962  {
7963  LObject h;
7964  h.p = pCopy(Q->m[i]);
7966  {
7967  deleteHC(&h,strat);
7968  }
7970  {
7971  h.pCleardenom(); // also does remove Content
7972  }
7973  else
7974  {
7975  h.pNorm();
7976  }
7977  if (h.p!=NULL)
7978  {
7979  strat->initEcart(&h);
7980  if (strat->sl==-1)
7981  pos =0;
7982  else
7983  {
7984  pos = posInS(strat,strat->sl,h.p,h.ecart);
7985  }
7986  h.sev = pGetShortExpVector(h.p);
7987  strat->enterS(h,pos,strat,-1);
7988  strat->fromQ[pos]=1;
7989  }
7990  }
7991  }
7992  }
7993  for (i=0; i<IDELEMS(F); i++)
7994  {
7995  if (F->m[i]!=NULL)
7996  {
7997  LObject h;
7998  h.p = pCopy(F->m[i]);
7999  if (h.p!=NULL)
8000  {
8002  {
8003  cancelunit(&h); /*- tries to cancel a unit -*/
8004  deleteHC(&h, strat);
8005  }
8006  if (h.p!=NULL)
8007  {
8009  {
8010  h.pCleardenom(); // also does remove Content
8011  }
8012  else
8013  {
8014  h.pNorm();
8015  }
8016  strat->initEcart(&h);
8017  if (strat->Ll==-1)
8018  pos =0;
8019  else
8020  pos = strat->posInL(strat->L,strat->Ll,&h,strat);
8021  h.sev = pGetShortExpVector(h.p);
8022  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8023  }
8024  }
8025  }
8026  }
8027  /*- test, if a unit is in F -*/
8028 
8029  if ((strat->Ll>=0)
8030 #ifdef HAVE_RINGS
8031  && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8032 #endif
8033  && pIsConstant(strat->L[strat->Ll].p))
8034  {
8035  while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);

◆ initSLSba()

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

Definition at line 8037 of file kutil.cc.

8040 {
8041  int i,pos;
8042  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
8043  else i=setmaxT;
8044  strat->ecartS = initec(i);
8045  strat->sevS = initsevS(i);
8046  strat->sevSig = initsevS(i);
8047  strat->S_2_R = initS_2_R(i);
8048  strat->fromQ = NULL;
8049  strat->Shdl = idInit(i,F->rank);
8050  strat->S = strat->Shdl->m;
8051  strat->sig = (poly *)omAlloc0(i*sizeof(poly));
8052  if (strat->sbaOrder != 1)
8053  {
8054  strat->syz = (poly *)omAlloc0(i*sizeof(poly));
8055  strat->sevSyz = initsevS(i);
8056  strat->syzmax = i;
8057  strat->syzl = 0;
8058  }
8059  /*- put polys into S -*/
8060  if (Q!=NULL)
8061  {
8062  strat->fromQ=initec(i);
8063  memset(strat->fromQ,0,i*sizeof(int));
8064  for (i=0; i<IDELEMS(Q); i++)
8065  {
8066  if (Q->m[i]!=NULL)
8067  {
8068  LObject h;
8069  h.p = pCopy(Q->m[i]);
8071  {
8072  deleteHC(&h,strat);
8073  }
8075  {
8076  h.pCleardenom(); // also does remove Content
8077  }
8078  else
8079  {
8080  h.pNorm();
8081  }
8082  if (h.p!=NULL)
8083  {
8084  strat->initEcart(&h);
8085  if (strat->sl==-1)
8086  pos =0;
8087  else
8088  {
8089  pos = posInS(strat,strat->sl,h.p,h.ecart);
8090  }
8091  h.sev = pGetShortExpVector(h.p);
8092  strat->enterS(h,pos,strat,-1);
8093  strat->fromQ[pos]=1;
8094  }
8095  }
8096  }
8097  }
8098  for (i=0; i<IDELEMS(F); i++)
8099  {
8100  if (F->m[i]!=NULL)
8101  {
8102  LObject h;
8103  h.p = pCopy(F->m[i]);
8104  h.sig = pOne();
8105  //h.sig = pInit();
8106  //p_SetCoeff(h.sig,nInit(1),currRing);
8107  p_SetComp(h.sig,i+1,currRing);
8108  // if we are working with the Schreyer order we generate it
8109  // by multiplying the initial signatures with the leading monomial
8110  // of the corresponding initial polynomials generating the ideal
8111  // => we can keep the underlying monomial order and get a Schreyer
8112  // order without any bigger overhead
8113  if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
8114  {
8115  p_ExpVectorAdd (h.sig,F->m[i],currRing);
8116  }
8117  h.sevSig = pGetShortExpVector(h.sig);
8118 #ifdef DEBUGF5
8119  pWrite(h.p);
8120  pWrite(h.sig);
8121 #endif
8122  if (h.p!=NULL)
8123  {
8125  {
8126  cancelunit(&h); /*- tries to cancel a unit -*/
8127  deleteHC(&h, strat);
8128  }
8129  if (h.p!=NULL)
8130  {
8132  {
8133  h.pCleardenom(); // also does remove Content
8134  }
8135  else
8136  {
8137  h.pNorm();
8138  }
8139  strat->initEcart(&h);
8140  if (strat->Ll==-1)
8141  pos =0;
8142  else
8143  pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
8144  h.sev = pGetShortExpVector(h.p);
8145  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8146  }
8147  }
8148  /*
8149  if (strat->sbaOrder != 1)
8150  {
8151  for(j=0;j<i;j++)
8152  {
8153  strat->syz[ctr] = pCopy(F->m[j]);
8154  p_SetCompP(strat->syz[ctr],i+1,currRing);
8155  // add LM(F->m[i]) to the signature to get a Schreyer order
8156  // without changing the underlying polynomial ring at all
8157  p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
8158  // since p_Add_q() destroys all input
8159  // data we need to recreate help
8160  // each time
8161  poly help = pCopy(F->m[i]);
8162  p_SetCompP(help,j+1,currRing);
8163  pWrite(strat->syz[ctr]);
8164  pWrite(help);
8165  printf("%d\n",pLmCmp(strat->syz[ctr],help));
8166  strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
8167  printf("%d. SYZ ",ctr);
8168  pWrite(strat->syz[ctr]);
8169  strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
8170  ctr++;
8171  }
8172  strat->syzl = ps;
8173  }
8174  */
8175  }
8176  }
8177  /*- test, if a unit is in F -*/
8178 
8179  if ((strat->Ll>=0)
8180 #ifdef HAVE_RINGS
8181  && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8182 #endif
8183  && pIsConstant(strat->L[strat->Ll].p))
8184  {
8185  while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8187 of file kutil.cc.

8190 {
8191  if( strat->S[0] )
8192  {
8193  if( strat->S[1] && !rField_is_Ring(currRing))
8194  {
8195  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
8196  omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
8197  omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
8198  }
8199  int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
8200  /************************************************************
8201  * computing the length of the syzygy array needed
8202  ***********************************************************/
8203  for(i=1; i<=strat->sl; i++)
8204  {
8205  if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8206  {
8207  ps += i;
8208  }
8209  }
8210  ps += strat->sl+1;
8211  //comp = pGetComp (strat->P.sig);
8212  comp = strat->currIdx;
8213  strat->syzIdx = initec(comp);
8214  strat->sevSyz = initsevS(ps);
8215  strat->syz = (poly *)omAlloc(ps*sizeof(poly));
8216  strat->syzmax = ps;
8217  strat->syzl = 0;
8218  strat->syzidxmax = comp;
8219 #if defined(DEBUGF5) || defined(DEBUGF51)
8220  PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
8221 #endif
8222  i = 1;
8223  j = 0;
8224  /************************************************************
8225  * generating the leading terms of the principal syzygies
8226  ***********************************************************/
8227  while (i <= strat->sl)
8228  {
8229  /**********************************************************
8230  * principal syzygies start with component index 2
8231  * the array syzIdx starts with index 0
8232  * => the rules for a signature with component comp start
8233  * at strat->syz[strat->syzIdx[comp-2]] !
8234  *********************************************************/
8235  if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
8236  {
8237  comp = pGetComp(strat->sig[i]);
8238  comp_old = pGetComp(strat->sig[i-1]);
8239  diff = comp - comp_old - 1;
8240  // diff should be zero, but sometimes also the initial generating
8241  // elements of the input ideal reduce to zero. then there is an
8242  // index-gap between the signatures. for these inbetween signatures we
8243  // can safely set syzIdx[j] = 0 as no such element will be ever computed
8244  // in the following.
8245  // doing this, we keep the relation "j = comp - 2" alive, which makes
8246  // jumps way easier when checking criteria
8247  while (diff>0)
8248  {
8249  strat->syzIdx[j] = 0;
8250  diff--;
8251  j++;
8252  }
8253  strat->syzIdx[j] = ctr;
8254  j++;
8255  LObject Q;
8256  int pos;
8257  for (k = 0; k<i; k++)
8258  {
8259  Q.sig = pOne();
8261  p_SetCoeff(Q.sig,nCopy(p_GetCoeff(strat->S[k],currRing)),currRing);
8262  p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8263  p_SetCompP (Q.sig, comp, currRing);
8264  poly q = p_One(currRing);
8267  p_ExpVectorCopy(q,strat->S[i],currRing);
8268  q = p_Neg (q, currRing);
8269  p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8270  Q.sig = p_Add_q (Q.sig, q, currRing);
8271  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8272  pos = posInSyz(strat, Q.sig);
8273  enterSyz(Q, strat, pos);
8274  ctr++;
8275  }
8276  }
8277  i++;
8278  }
8279  /**************************************************************
8280  * add syzygies for upcoming first element of new iteration step
8281  **************************************************************/
8282  comp = strat->currIdx;
8283  comp_old = pGetComp(strat->sig[i-1]);
8284  diff = comp - comp_old - 1;
8285  // diff should be zero, but sometimes also the initial generating
8286  // elements of the input ideal reduce to zero. then there is an
8287  // index-gap between the signatures. for these inbetween signatures we
8288  // can safely set syzIdx[j] = 0 as no such element will be ever computed
8289  // in the following.
8290  // doing this, we keep the relation "j = comp - 2" alive, which makes
8291  // jumps way easier when checking criteria
8292  while (diff>0)
8293  {
8294  strat->syzIdx[j] = 0;
8295  diff--;
8296  j++;
8297  }
8298  strat->syzIdx[j] = ctr;
8299  LObject Q;
8300  int pos;
8301  for (k = 0; k<strat->sl+1; k++)
8302  {
8303  Q.sig = pOne();
8305  p_SetCoeff(Q.sig,nCopy(p_GetCoeff(strat->S[k],currRing)),currRing);
8306  p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8307  p_SetCompP (Q.sig, comp, currRing);
8308  poly q = p_One(currRing);
8310  p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8311  p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8312  q = p_Neg (q, currRing);
8313  p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8314  Q.sig = p_Add_q (Q.sig, q, currRing);
8315  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8316  pos = posInSyz(strat, Q.sig);
8317  enterSyz(Q, strat, pos);
8318  ctr++;
8319  }
8320 //#if 1
8321 #ifdef DEBUGF5
8322  PrintS("Principal syzygies:\n");
8323  Print("syzl %d\n",strat->syzl);
8324  Print("syzmax %d\n",strat->syzmax);
8325  Print("ps %d\n",ps);
8326  PrintS("--------------------------------\n");
8327  for(i=0;i<=strat->syzl-1;i++)
8328  {
8329  Print("%d - ",i);
8330  pWrite(strat->syz[i]);
8331  }
8332  for(i=0;i<strat->currIdx;i++)
8333  {

◆ initT()

KINLINE TSet initT ( )

Definition at line 78 of file kInline.h.

82 {
83  TSet T = (TSet)omAlloc0(setmaxT*sizeof(TObject));
84  for (int i=setmaxT-1; i>=0; i--)
85  {
86  T[i].tailRing = currRing;
87  T[i].i_r = -1;

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

941 {
942  p_LmCheckPolyRing(p1, p_r);
943  p_LmCheckPolyRing(p2, p_r);
944 
945  int i;
946  long x;
947  m1 = p_Init(m_r,m_r->PolyBin);
948  m2 = p_Init(m_r,m_r->PolyBin);
949 
950  for (i = p_r->N; i; i--)
951  {
952  x = p_GetExpDiff(p1, p2, i, p_r);
953  if (x > 0)
954  {
955  if (x > (long) m_r->bitmask) goto false_return;
956  p_SetExp(m2,i,x, m_r);
957  p_SetExp(m1,i,0, m_r);
958  }
959  else
960  {
961  if (-x > (long) m_r->bitmask) goto false_return;
962  p_SetExp(m1,i,-x, m_r);
963  p_SetExp(m2,i,0, m_r);
964  }
965  }
966 
967  p_Setm(m1, m_r);
968  p_Setm(m2, m_r);
969  return TRUE;
970 

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

984 {
985  p_LmCheckPolyRing(p1, leadRing);
986  p_LmCheckPolyRing(p2, leadRing);
987 
988  int i;
989  int x;
990  int e1;
991  int e2;
992  int s;
993  m1 = p_Init(tailRing,tailRing->PolyBin);
994  m2 = p_Init(tailRing,tailRing->PolyBin);
995  lcm = p_Init(leadRing,leadRing->PolyBin);
996 
997  for (i = leadRing->N; i>=0; i--)
998  {
999  e1 = p_GetExp(p1,i,leadRing);
1000  e2 = p_GetExp(p2,i,leadRing);
1001  x = e1 - e2;
1002  if (x > 0)
1003  {
1004  p_SetExp(m2,i,x, tailRing);
1005  //p_SetExp(m1,i,0, tailRing); // done by p_Init
1006  s = e1;
1007  }
1008  else if (x<0)
1009  {
1010  p_SetExp(m1,i,-x, tailRing);
1011  //p_SetExp(m2,i,0, tailRing); // done by p_Init
1012  s = e2;
1013  }
1014  else
1015  s = e1; // e1==e2
1016  p_SetExp(lcm,i,s, leadRing);

◆ k_LmInit_currRing_2_tailRing() [1/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 907 of file kInline.h.

913 {

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 875 of file kInline.h.

881 {
882 

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 912 of file kInline.h.

913 {
914  return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
915 }

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 884 of file kInline.h.

890 {

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 917 of file kInline.h.

918 {
919  return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
920 }

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 893 of file kInline.h.

899 {

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 922 of file kInline.h.

923 {
924  return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
925 }

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 900 of file kInline.h.

906 {

◆ kCheckSpolyCreation()

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

Definition at line 10577 of file kutil.cc.

10586 {
10587  if (strat->overflow) return FALSE;
10588  assume(L->p1 != NULL && L->p2 != NULL);
10589  // shift changes: from 0 to -1
10590  assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10591  assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10592  assume(strat->tailRing != currRing);
10593 
10594  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10595  return FALSE;
10596  // shift changes: extra case inserted
10597  if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10598  {
10599  return TRUE;
10600  }
10601  poly p1_max = (strat->R[L->i_r1])->max_exp;
10602  poly p2_max = (strat->R[L->i_r2])->max_exp;
10603 
10604  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10605  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10606  {

◆ kCheckStrongCreation()

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

Definition at line 10614 of file kutil.cc.

10624 {
10625  assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10626  //assume(strat->tailRing != currRing);
10627 
10628  poly p1_max = (strat->R[atR])->max_exp;

◆ kCreateZeroPoly()

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

Definition at line 4259 of file kutil.cc.

4261 {
4262 
4263  poly zeroPoly = NULL;
4264 
4265  number tmp1;
4266  poly tmp2, tmp3;
4267 
4268  if (cabsind == -1)
4269  {
4270  cabsind = 0;
4271  for (int i = 1; i <= leadRing->N; i++)
4272  {
4273  cabsind += ind_fact_2(exp[i]);
4274  }
4275 // Print("cabsind: %d\n", cabsind);
4276  }
4277  if (cabsind < leadRing->ch)
4278  {
4279  zeroPoly = p_ISet(twoPow(leadRing->ch - cabsind), tailRing);
4280  }
4281  else
4282  {
4283  zeroPoly = p_ISet(1, tailRing);
4284  }
4285  for (int i = 1; i <= leadRing->N; i++)
4286  {
4287  for (long j = 1; j <= exp[i]; j++)
4288  {
4289  tmp1 = nInit(j);
4290  tmp2 = p_ISet(1, tailRing);
4291  p_SetExp(tmp2, i, 1, tailRing);
4292  p_Setm(tmp2, tailRing);
4293  if (nIsZero(tmp1))
4294  { // should nowbe obsolet, test ! TODO OLIVER
4295  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
4296  }
4297  else
4298  {
4299  tmp3 = p_NSet(nCopy(tmp1), tailRing);
4300  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
4301  }
4302  }
4303  }
4304  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
4305  for (int i = 1; i <= leadRing->N; i++)
4306  {
4307  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
4308  }
4309  p_Setm(tmp2, leadRing);
4310  *t_p = zeroPoly;
4311  zeroPoly = pNext(zeroPoly);
4312  pNext(*t_p) = NULL;
4313  pNext(tmp2) = zeroPoly;
4314  return tmp2;

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11574 of file kutil.cc.

11584 {
11585  PrintS("red: ");
11586  if (strat->red==redFirst) PrintS("redFirst\n");
11587  else if (strat->red==redHoney) PrintS("redHoney\n");
11588  else if (strat->red==redEcart) PrintS("redEcart\n");
11589  else if (strat->red==redHomog) PrintS("redHomog\n");
11590  else Print("%p\n",(void*)strat->red);
11591  PrintS("posInT: ");
11592  if (strat->posInT==posInT0) PrintS("posInT0\n");
11593  else if (strat->posInT==posInT1) PrintS("posInT1\n");
11594  else if (strat->posInT==posInT11) PrintS("posInT11\n");
11595  else if (strat->posInT==posInT110) PrintS("posInT110\n");
11596  else if (strat->posInT==posInT13) PrintS("posInT13\n");
11597  else if (strat->posInT==posInT15) PrintS("posInT15\n");
11598  else if (strat->posInT==posInT17) PrintS("posInT17\n");
11599  else if (strat->posInT==posInT17_c) PrintS("posInT17_c\n");
11600  else if (strat->posInT==posInT19) PrintS("posInT19\n");
11601  else if (strat->posInT==posInT2) PrintS("posInT2\n");
11602  #ifdef HAVE_RINGS
11603  else if (strat->posInT==posInT11Ring) PrintS("posInT11Ring\n");
11604  else if (strat->posInT==posInT110Ring) PrintS("posInT110Ring\n");
11605  else if (strat->posInT==posInT15Ring) PrintS("posInT15Ring\n");
11606  else if (strat->posInT==posInT17Ring) PrintS("posInT17Ring\n");
11607  else if (strat->posInT==posInT17_cRing) PrintS("posInT17_cRing\n");
11608  #endif
11609 #ifdef HAVE_MORE_POS_IN_T
11610  else if (strat->posInT==posInT_EcartFDegpLength) PrintS("posInT_EcartFDegpLength\n");
11611  else if (strat->posInT==posInT_FDegpLength) PrintS("posInT_FDegpLength\n");
11612  else if (strat->posInT==posInT_pLength) PrintS("posInT_pLength\n");
11613 #endif
11614  else if (strat->posInT==posInT_EcartpLength) PrintS("posInT_EcartpLength\n");
11615  else if (strat->posInT==posInTrg0) PrintS("posInTrg0\n");
11616  else Print("%p\n",(void*)strat->posInT);
11617  PrintS("posInL: ");
11618  if (strat->posInL==posInL0) PrintS("posInL0\n");
11619  else if (strat->posInL==posInL10) PrintS("posInL10\n");
11620  else if (strat->posInL==posInL11) PrintS("posInL11\n");
11621  else if (strat->posInL==posInL110) PrintS("posInL110\n");
11622  else if (strat->posInL==posInL13) PrintS("posInL13\n");
11623  else if (strat->posInL==posInL15) PrintS("posInL15\n");
11624  else if (strat->posInL==posInL17) PrintS("posInL17\n");
11625  else if (strat->posInL==posInL17_c) PrintS("posInL17_c\n");
11626  #ifdef HAVE_RINGS
11627  else if (strat->posInL==posInL0) PrintS("posInL0Ring\n");
11628  else if (strat->posInL==posInL11Ring) PrintS("posInL11Ring\n");
11629  else if (strat->posInL==posInL11Ringls) PrintS("posInL11Ringls\n");
11630  else if (strat->posInL==posInL110Ring) PrintS("posInL110Ring\n");
11631  else if (strat->posInL==posInL15Ring) PrintS("posInL15Ring\n");
11632  else if (strat->posInL==posInL17Ring) PrintS("posInL17Ring\n");
11633  else if (strat->posInL==posInL17_cRing) PrintS("posInL17_cRing\n");
11634  #endif
11635  else if (strat->posInL==posInLSpecial) PrintS("posInLSpecial\n");
11636  else if (strat->posInL==posInLrg0) PrintS("posInLrg0\n");
11637  else Print("%p\n",(void*)strat->posInL);
11638  PrintS("enterS: ");
11639  if (strat->enterS==enterSBba) PrintS("enterSBba\n");
11640  else if (strat->enterS==enterSMora) PrintS("enterSMora\n");
11641  else if (strat->enterS==enterSMoraNF) PrintS("enterSMoraNF\n");
11642  else Print("%p\n",(void*)strat->enterS);
11643  PrintS("initEcart: ");
11644  if (strat->initEcart==initEcartBBA) PrintS("initEcartBBA\n");
11645  else if (strat->initEcart==initEcartNormal) PrintS("initEcartNormal\n");
11646  else Print("%p\n",(void*)strat->initEcart);
11647  PrintS("initEcartPair: ");
11648  if (strat->initEcartPair==initEcartPairBba) PrintS("initEcartPairBba\n");
11649  else if (strat->initEcartPair==initEcartPairMora) PrintS("initEcartPairMora\n");
11650  else Print("%p\n",(void*)strat->initEcartPair);
11651  Print("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11652  strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11653  Print("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11654  strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11655  PrintS("chainCrit: ");
11656  if (strat->chainCrit==chainCritNormal) PrintS("chainCritNormal\n");
11657  else if (strat->chainCrit==chainCritOpt_1) PrintS("chainCritOpt_1\n");
11658  else Print("%p\n",(void*)strat->chainCrit);
11659  Print("posInLDependsOnLength=%d\n",
11660  strat->posInLDependsOnLength);
11661  PrintS(showOption());PrintLn();
11662  PrintS("LDeg: ");
11663  if (currRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11664  else if (currRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11665  else if (currRing->pLDeg==pLDegb) PrintS("pLDegb");
11666  else if (currRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11667  else if (currRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11668  else if (currRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11669  else if (currRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11670  else if (currRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11671  else if (currRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11672  else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11673  else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11674  else if (currRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11675  else Print("? (%lx)", (long)currRing->pLDeg);
11676  PrintS(" / ");
11677  if (strat->tailRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11678  else if (strat->tailRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11679  else if (strat->tailRing->pLDeg==pLDegb) PrintS("pLDegb");
11680  else if (strat->tailRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11681  else if (strat->tailRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11682  else if (strat->tailRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11683  else if (strat->tailRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11684  else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11685  else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11686  else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11687  else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11688  else if (strat->tailRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11689  else Print("? (%lx)", (long)strat->tailRing->pLDeg);
11690  PrintLn();
11691  PrintS("currRing->pFDeg: ");
11692  if (currRing->pFDeg==p_Totaldegree) PrintS("p_Totaldegree");
11693  else if (currRing->pFDeg==p_WFirstTotalDegree) PrintS("pWFirstTotalDegree");
11694  else if (currRing->pFDeg==p_Deg) PrintS("p_Deg");
11695  else if (currRing->pFDeg==kHomModDeg) PrintS("kHomModDeg");
11696  else if (currRing->pFDeg==totaldegreeWecart) PrintS("totaldegreeWecart");
11697  else if (currRing->pFDeg==p_WTotaldegree) PrintS("p_WTotaldegree");
11698  else Print("? (%lx)", (long)currRing->pFDeg);
11699  PrintLn();
11700  Print(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11701  if(TEST_OPT_DEGBOUND)
11702  Print(" degBound: %d\n", Kstd1_deg);
11703 
11704  if( ecartWeights != NULL )
11705  {
11706  PrintS("ecartWeights: ");
11707  for (int i = rVar(currRing); i > 0; i--)

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

197 {
198  unsigned long not_sev = ~L->sev;
199  poly p = L->GetLmCurrRing();
200  int j = 0;
201 
202  pAssume(~not_sev == p_GetShortExpVector(p, currRing));
203 
205 #if 1
206  int ende;
207  if (is_Ring
208  || (strat->ak>0)
209  || currRing->pLexOrder)
210  ende=strat->sl;
211  else
212  {
213  ende=posInS(strat,*max_ind,p,0)+1;
214  if (ende>(*max_ind)) ende=(*max_ind);
215  }
216 #else
217  int ende=strat->sl;
218 #endif
219  if(is_Ring)
220  {
221  loop
222  {
223  if (j > ende) return -1;
224 #if defined(PDEBUG) || defined(PDIV_DEBUG)
225  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
226  p, not_sev, currRing))
227  {
228  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
229  return j;
230  }
231 #else
232  if ( !(strat->sevS[j] & not_sev) &&
233  p_LmDivisibleBy(strat->S[j], p, currRing))
234  {
235  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
236  return j;
237  }
238 #endif
239  j++;
240  }
241  }
242  else
243  {
244  loop
245  {
246  if (j > ende) return -1;
247 #if defined(PDEBUG) || defined(PDIV_DEBUG)
248  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
249  p, not_sev, currRing))
250  {
251  return j;
252  }
253 #else
254  if ( !(strat->sevS[j] & not_sev) &&
255  p_LmDivisibleBy(strat->S[j], p, currRing))
256  {
257  return j;
258  }
259 #endif
260  j++;
261  }
262  }
263 }

◆ kFindDivisibleByInS_T()

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

Definition at line 7161 of file kutil.cc.

7164 {
7165  int j = 0;
7166  const unsigned long not_sev = ~L->sev;
7167  const unsigned long* sev = strat->sevS;
7168  poly p;
7169  ring r;
7170  L->GetLm(p, r);
7171 
7172  assume(~not_sev == p_GetShortExpVector(p, r));
7173 
7174  if (r == currRing)
7175  {
7176  if(!rField_is_Ring(r))
7177  {
7178  loop
7179  {
7180  if (j > end_pos) return NULL;
7181  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7182  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7183  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7184  {
7185  break;
7186  }
7187  #else
7188  if (!(sev[j] & not_sev) &&
7189  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7190  p_LmDivisibleBy(strat->S[j], p, r))
7191  {
7192  break;
7193  }
7194  #endif
7195  j++;
7196  }
7197  }
7198  #ifdef HAVE_RINGS
7199  else
7200  {
7201  loop
7202  {
7203  if (j > end_pos) return NULL;
7204  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7205  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
7206  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7207  {
7208  break;
7209  }
7210  #else
7211  if (!(sev[j] & not_sev) &&
7212  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7213  p_LmDivisibleBy(strat->S[j], p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7214  {
7215  break;
7216  }
7217  #endif
7218  j++;
7219  }
7220  }
7221  #endif
7222  // if called from NF, T objects do not exist:
7223  if (strat->tl < 0 || strat->S_2_R[j] == -1)
7224  {
7225  T->Set(strat->S[j], r, strat->tailRing);
7226  assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
7227  return T;
7228  }
7229  else
7230  {
7231 ///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
7232 ///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
7233 // assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
7234  return strat->S_2_T(j);
7235  }
7236  }
7237  else
7238  {
7239  TObject* t;
7240  if(!rField_is_Ring(r))
7241  {
7242  loop
7243  {
7244  if (j > end_pos) return NULL;
7245  assume(strat->S_2_R[j] != -1);
7246  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7247  t = strat->S_2_T(j);
7248  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7249  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7250  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7251  {
7252  t->pLength=pLength(t->t_p);
7253  return t;
7254  }
7255  #else
7256  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7257  {
7258  t = strat->S_2_T(j);
7259  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7260  if (p_LmDivisibleBy(t->t_p, p, r))
7261  {
7262  t->pLength=pLength(t->t_p);
7263  return t;
7264  }
7265  }
7266  #endif
7267  j++;
7268  }
7269  }
7270  #ifdef HAVE_RINGS
7271  else
7272  {
7273  loop
7274  {
7275  if (j > end_pos) return NULL;
7276  assume(strat->S_2_R[j] != -1);
7277  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7278  t = strat->S_2_T(j);
7279  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7280  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7281  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7282  {
7283  t->pLength=pLength(t->t_p);
7284  return t;
7285  }
7286  #else
7287  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7288  {
7289  t = strat->S_2_T(j);
7290  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7291  if (p_LmDivisibleBy(t->t_p, p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7292  {
7293  t->pLength=pLength(t->t_p);
7294  return t;
7295  }
7296  }
7297  #endif
7298  j++;
7299  }
7300  }
7301  #endif

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

87 {
88  unsigned long not_sev = ~L->sev;
89  int j = start;
90 
91  const TSet T=strat->T;
92  const unsigned long* sevT=strat->sevT;
93  const ring r=currRing;
94  const BOOLEAN is_Ring=rField_is_Ring(r);
95  if (L->p!=NULL)
96  {
97  const poly p=L->p;
98 
99  pAssume(~not_sev == p_GetShortExpVector(p, r));
100 
101  if(is_Ring)
102  {
103  loop
104  {
105  if (j > strat->tl) return -1;
106 #if defined(PDEBUG) || defined(PDIV_DEBUG)
107  if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
108  {
109  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
110  return j;
111  }
112 #else
113  if (!(sevT[j] & not_sev) &&
114  p_LmDivisibleBy(T[j].p, p, r))
115  {
116  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
117  return j;
118  }
119 #endif
120  j++;
121  }
122  }
123  else
124  {
125  loop
126  {
127  if (j > strat->tl) return -1;
128 #if defined(PDEBUG) || defined(PDIV_DEBUG)
129  if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
130  {
131  return j;
132  }
133 #else
134  if (!(sevT[j] & not_sev) &&
135  p_LmDivisibleBy(T[j].p, p, r))
136  {
137  return j;
138  }
139 #endif
140  j++;
141  }
142  }
143  }
144  else
145  {
146  const poly p=L->t_p;
147  const ring r=strat->tailRing;
148  if(is_Ring)
149  {
150  loop
151  {
152  if (j > strat->tl) return -1;
153 #if defined(PDEBUG) || defined(PDIV_DEBUG)
154  if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
155  p, not_sev, r))
156  {
157  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
158  return j;
159  }
160 #else
161  if (!(sevT[j] & not_sev) &&
162  p_LmDivisibleBy(T[j].t_p, p, r))
163  {
164  if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
165  return j;
166  }
167 #endif
168  j++;
169  }
170  }
171  else
172  {
173  loop
174  {
175  if (j > strat->tl) return -1;
176 #if defined(PDEBUG) || defined(PDIV_DEBUG)
177  if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
178  p, not_sev, r))
179  {
180  return j;
181  }
182 #else
183  if (!(sevT[j] & not_sev) &&
184  p_LmDivisibleBy(T[j].t_p, p, r))
185  {
186  return j;
187  }
188 #endif
189  j++;
190  }
191  }
192  }
193 }

◆ kFindInT()

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

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

Definition at line 703 of file kutil.cc.

705 {
706  int i;
707 
708  for (i=0; i<=tlength; i++)
709  {
710  if (T[i].p == p) return i;
711  }
712  return -1;

◆ kFindNextDivisibleByInS()

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

Definition at line 265 of file kstd2.cc.

266 {
267  unsigned long not_sev = ~L->sev;
268  poly p = L->GetLmCurrRing();
269  int j = start;
270 
271  pAssume(~not_sev == p_GetShortExpVector(p, currRing));
272 #if 1
273  int ende=max_ind;
274 #else
275  int ende=strat->sl;
276 #endif
278  {
279  loop
280  {
281  if (j > ende) return -1;
282 #if defined(PDEBUG) || defined(PDIV_DEBUG)
283  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
284  p, not_sev, currRing))
285  {
286  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
287  return j;
288  }
289 #else
290  if ( !(strat->sevS[j] & not_sev) &&
291  p_LmDivisibleBy(strat->S[j], p, currRing))
292  {
293  if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
294  return j;
295  }
296 #endif
297  j++;
298  }
299  }
300  else
301  {
302  loop
303  {
304  if (j > ende) return -1;
305 #if defined(PDEBUG) || defined(PDIV_DEBUG)
306  if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
307  p, not_sev, currRing))
308  {
309  return j;
310  }
311 #else
312  if ( !(strat->sevS[j] & not_sev) &&
313  p_LmDivisibleBy(strat->S[j], p, currRing))
314  {
315  return j;
316  }
317 #endif
318  j++;
319  }
320  }
321 }

◆ kFindZeroPoly()

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

Definition at line 324 of file kstd2.cc.

325 {
326  // m = currRing->ch
327 
328  if (input_p == NULL) return NULL;
329 
330  poly p = input_p;
331  poly zeroPoly = NULL;
332  unsigned long a = (unsigned long) pGetCoeff(p);
333 
334  int k_ind2 = 0;
335  int a_ind2 = ind2(a);
336 
337  // unsigned long k = 1;
338  // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
339  for (int i = 1; i <= leadRing->N; i++)
340  {
341  k_ind2 = k_ind2 + ind_fact_2(p_GetExp(p, i, leadRing));
342  }
343 
344  a = (unsigned long) pGetCoeff(p);
345 
346  number tmp1;
347  poly tmp2, tmp3;
348  poly lead_mult = p_ISet(1, tailRing);
349  if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
350  {
351  int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf);
352  int s_exp;
353  zeroPoly = p_ISet(a, tailRing);
354  for (int i = 1; i <= leadRing->N; i++)
355  {
356  s_exp = p_GetExp(p, i,leadRing);
357  if (s_exp % 2 != 0)
358  {
359  s_exp = s_exp - 1;
360  }
361  while ( (0 < ind2(s_exp)) && (ind2(s_exp) <= too_much) )
362  {
363  too_much = too_much - ind2(s_exp);
364  s_exp = s_exp - 2;
365  }
366  p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
367  for (int j = 1; j <= s_exp; j++)
368  {
369  tmp1 = nInit(j);
370  tmp2 = p_ISet(1, tailRing);
371  p_SetExp(tmp2, i, 1, tailRing);
372  p_Setm(tmp2, tailRing);
373  if (nIsZero(tmp1))
374  { // should nowbe obsolet, test ! TODO OLIVER
375  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
376  }
377  else
378  {
379  tmp3 = p_NSet(nCopy(tmp1), tailRing);
380  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
381  }
382  }
383  }
384  p_Setm(lead_mult, tailRing);
385  zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing);
386  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
387  for (int i = 1; i <= leadRing->N; i++)
388  {
389  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
390  }
391  p_Setm(tmp2, leadRing);
392  zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
393  pNext(tmp2) = zeroPoly;
394  return tmp2;
395  }
396 /* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
397  if (1 == 0 && alpha_k <= a)
398  { // Temporarly disabled, reducing coefficients not compatible with std TODO Oliver
399  zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
400  for (int i = 1; i <= leadRing->N; i++)
401  {
402  for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
403  {
404  tmp1 = nInit(j);
405  tmp2 = p_ISet(1, tailRing);
406  p_SetExp(tmp2, i, 1, tailRing);
407  p_Setm(tmp2, tailRing);
408  if (nIsZero(tmp1))
409  {
410  zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
411  }
412  else
413  {
414  tmp3 = p_ISet((unsigned long) tmp1, tailRing);
415  zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
416  }
417  }
418  }
419  tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing);
420  for (int i = 1; i <= leadRing->N; i++)
421  {
422  pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
423  }
424  p_Setm(tmp2, leadRing);
425  zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
426  pNext(tmp2) = zeroPoly;
427  return tmp2;
428  } */
429  return NULL;
430 }

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3383 of file kstd2.cc.

3385 {
3386  assume(!idIs0(q));
3387  assume(!(idIs0(F)&&(Q==NULL)));
3388 // lazy_reduce flags: can be combined by |
3389 //#define KSTD_NF_LAZY 1
3390  // do only a reduction of the leading term
3391 //#define KSTD_NF_NONORM 4
3392  // only global: avoid normalization, return a multiply of NF
3393  poly p;
3394  int i;
3395  ideal res;
3396  int max_ind;
3397 
3398  //if (idIs0(q))
3399  // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
3400  //if ((idIs0(F))&&(Q==NULL))
3401  // return idCopy(q); /*F=0*/
3402  //strat->ak = idRankFreeModule(F);
3403  /*- creating temp data structures------------------- -*/
3404  BITSET save1;
3405  SI_SAVE_OPT1(save1);
3407  initBuchMoraCrit(strat);
3408  strat->initEcart = initEcartBBA;
3409  strat->enterS = enterSBba;
3410  /*- set S -*/
3411  strat->sl = -1;
3412 #ifndef NO_BUCKETS
3414 #endif
3415  /*- init local data struct.---------------------------------------- -*/
3416  /*Shdl=*/initS(F,Q,strat);
3417  /*- compute------------------------------------------------------- -*/
3418  res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
3420  for (i=IDELEMS(q)-1; i>=0; i--)
3421  {
3422  if (q->m[i]!=NULL)
3423  {
3424  if (TEST_OPT_PROT) { PrintS("r");mflush(); }
3425  p = redNF(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat);
3426  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3427  {
3428  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3429  if (rField_is_Ring(currRing))
3430  {
3431  p = redtailBba_Z(p,max_ind,strat);
3432  }
3433  else
3434  {
3435  p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3436  }
3437  }
3438  res->m[i]=p;
3439  }
3440  //else
3441  // res->m[i]=NULL;
3442  }
3443  /*- release temp data------------------------------- -*/
3444  assume(strat->L==NULL); /* strat->L unused */
3445  assume(strat->B==NULL); /* strat->B unused */
3446  omFree(strat->sevS);
3447  omFree(strat->ecartS);
3448  assume(strat->T==NULL);//omfree(strat->T);
3449  assume(strat->sevT==NULL);//omfree(strat->sevT);
3450  assume(strat->R==NULL);//omfree(strat->R);
3451  omfree(strat->S_2_R);
3452  omfree(strat->fromQ);
3453  idDelete(&strat->Shdl);
3454  SI_RESTORE_OPT1(save1);
3455  if (TEST_OPT_PROT) PrintLn();
3456  return res;

◆ kNF2() [2/2]

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

Definition at line 3244 of file kstd2.cc.

3246 {
3247  assume(q!=NULL);
3248  assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3249 
3250 // lazy_reduce flags: can be combined by |
3251 //#define KSTD_NF_LAZY 1
3252  // do only a reduction of the leading term
3253 //#define KSTD_NF_NONORM 4
3254  // only global: avoid normalization, return a multiply of NF
3255  poly p;
3256 
3257  //if ((idIs0(F))&&(Q==NULL))
3258  // return pCopy(q); /*F=0*/
3259  //strat->ak = idRankFreeModule(F);
3260  /*- creating temp data structures------------------- -*/
3261  BITSET save1;
3262  SI_SAVE_OPT1(save1);
3264  initBuchMoraCrit(strat);
3265  strat->initEcart = initEcartBBA;
3266  strat->enterS = enterSBba;
3267 #ifndef NO_BUCKETS
3269 #endif
3270  /*- set S -*/
3271  strat->sl = -1;
3272  /*- init local data struct.---------------------------------------- -*/
3273  /*Shdl=*/initS(F,Q,strat);
3274  /*- compute------------------------------------------------------- -*/
3275  //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3276  //{
3277  // for (i=strat->sl;i>=0;i--)
3278  // pNorm(strat->S[i]);
3279  //}
3280  kTest(strat);
3281  if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3282  if (BVERBOSE(23)) kDebugPrint(strat);
3283  int max_ind;
3284  p = redNF(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat);
3285  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3286  {
3287  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3288  if (rField_is_Ring(currRing))
3289  {
3290  p = redtailBba_Z(p,max_ind,strat);
3291  }
3292  else
3293  {
3295  p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3296  }
3297  }
3298  /*- release temp data------------------------------- -*/
3299  assume(strat->L==NULL); /* strat->L unused */
3300  assume(strat->B==NULL); /* strat->B unused */
3301  omFree(strat->sevS);
3302  omFree(strat->ecartS);
3303  assume(strat->T==NULL);//omfree(strat->T);
3304  assume(strat->sevT==NULL);//omfree(strat->sevT);
3305  assume(strat->R==NULL);//omfree(strat->R);
3306  omfree(strat->S_2_R);
3307  omfree(strat->fromQ);
3308  idDelete(&strat->Shdl);
3309  SI_RESTORE_OPT1(save1);
3310  if (TEST_OPT_PROT) PrintLn();
3311  return p;

◆ kNF2Bound() [1/2]

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

Definition at line 3458 of file kstd2.cc.

3460 {
3461  assume(!idIs0(q));
3462  assume(!(idIs0(F)&&(Q==NULL)));
3463 // lazy_reduce flags: can be combined by |
3464 //#define KSTD_NF_LAZY 1
3465  // do only a reduction of the leading term
3466 //#define KSTD_NF_NONORM 4
3467  // only global: avoid normalization, return a multiply of NF
3468  poly p;
3469  int i;
3470  ideal res;
3471  int max_ind;
3472 
3473  //if (idIs0(q))
3474  // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
3475  //if ((idIs0(F))&&(Q==NULL))
3476  // return idCopy(q); /*F=0*/
3477  //strat->ak = idRankFreeModule(F);
3478  /*- creating temp data structures------------------- -*/
3479  BITSET save1;
3480  SI_SAVE_OPT1(save1);
3482  initBuchMoraCrit(strat);
3483  strat->initEcart = initEcartBBA;
3484  strat->enterS = enterSBba;
3485  /*- set S -*/
3486  strat->sl = -1;
3487 #ifndef NO_BUCKETS
3489 #endif
3490  /*- init local data struct.---------------------------------------- -*/
3491  /*Shdl=*/initS(F,Q,strat);
3492  /*- compute------------------------------------------------------- -*/
3493  res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
3495  for (i=IDELEMS(q)-1; i>=0; i--)
3496  {
3497  if (q->m[i]!=NULL)
3498  {
3499  if (TEST_OPT_PROT) { PrintS("r");mflush(); }
3500  p = redNFBound(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
3501  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3502  {
3503  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3504  if (rField_is_Ring(currRing))
3505  {
3506  p = redtailBba_Z(p,max_ind,strat);
3507  }
3508  else
3509  {
3510  p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
3511  }
3512  }
3513  res->m[i]=p;
3514  }
3515  //else
3516  // res->m[i]=NULL;
3517  }
3518  /*- release temp data------------------------------- -*/
3519  assume(strat->L==NULL); /* strat->L unused */
3520  assume(strat->B==NULL); /* strat->B unused */
3521  omFree(strat->sevS);
3522  omFree(strat->ecartS);
3523  assume(strat->T==NULL);//omfree(strat->T);
3524  assume(strat->sevT==NULL);//omfree(strat->sevT);
3525  assume(strat->R==NULL);//omfree(strat->R);
3526  omfree(strat->S_2_R);
3527  omfree(strat->fromQ);
3528  idDelete(&strat->Shdl);
3529  SI_RESTORE_OPT1(save1);
3530  if (TEST_OPT_PROT) PrintLn();
3531  return res;

◆ kNF2Bound() [2/2]

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

Definition at line 3313 of file kstd2.cc.

3315 {
3316  assume(q!=NULL);
3317  assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3318 
3319 // lazy_reduce flags: can be combined by |
3320 //#define KSTD_NF_LAZY 1
3321  // do only a reduction of the leading term
3322 //#define KSTD_NF_NONORM 4
3323  // only global: avoid normalization, return a multiply of NF
3324  poly p;
3325 
3326  //if ((idIs0(F))&&(Q==NULL))
3327  // return pCopy(q); /*F=0*/
3328  //strat->ak = idRankFreeModule(F);
3329  /*- creating temp data structures------------------- -*/
3330  BITSET save1;
3331  SI_SAVE_OPT1(save1);
3333  initBuchMoraCrit(strat);
3334  strat->initEcart = initEcartBBA;
3335  strat->enterS = enterSBba;
3336 #ifndef NO_BUCKETS
3338 #endif
3339  /*- set S -*/
3340  strat->sl = -1;
3341  /*- init local data struct.---------------------------------------- -*/
3342  /*Shdl=*/initS(F,Q,strat);
3343  /*- compute------------------------------------------------------- -*/
3344  //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3345  //{
3346  // for (i=strat->sl;i>=0;i--)
3347  // pNorm(strat->S[i]);
3348  //}
3349  kTest(strat);
3350  if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3351  if (BVERBOSE(23)) kDebugPrint(strat);
3352  int max_ind;
3353  p = redNFBound(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound);
3354  if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3355  {
3356  if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
3357  if (rField_is_Ring(currRing))
3358  {
3359  p = redtailBba_Z(p,max_ind,strat);
3360  }
3361  else
3362  {
3364  p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0);
3365  //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
3366  }
3367  }
3368  /*- release temp data------------------------------- -*/
3369  assume(strat->L==NULL); /* strat->L unused */
3370  assume(strat->B==NULL); /* strat->B unused */
3371  omFree(strat->sevS);
3372  omFree(strat->ecartS);
3373  assume(strat->T==NULL);//omfree(strat->T);
3374  assume(strat->sevT==NULL);//omfree(strat->sevT);
3375  assume(strat->R==NULL);//omfree(strat->R);
3376  omfree(strat->S_2_R);
3377  omfree(strat->fromQ);
3378  idDelete(&strat->Shdl);
3379  SI_RESTORE_OPT1(save1);
3380  if (TEST_OPT_PROT) PrintLn();
3381  return p;

◆ ksCreateShortSpoly()

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

Definition at line 998 of file kspoly.cc.

999  :
1000 * 1. the coefficient is 0 (p_Init)
1001 * 1. a) in the case of coefficient ring, the coefficient is calculated
1002 * 2. pNext is undefined
1003 */
1004 //static void bbb() { int i=0; }
1005 poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
1006 {
1007  poly a1 = pNext(p1), a2 = pNext(p2);
1008  long c1=p_GetComp(p1, currRing),c2=p_GetComp(p2, currRing);
1009  long c;
1010  poly m1,m2;
1011  number t1 = NULL,t2 = NULL;
1012  int cm,i;
1013  BOOLEAN equal;
1014 
1015 #ifdef HAVE_RINGS
1016  BOOLEAN is_Ring=rField_is_Ring(currRing);
1017  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
1018  if (is_Ring)
1019  {
1020  ksCheckCoeff(&lc1, &lc2, currRing->cf); // gcd and zero divisors
1021  if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
1022  if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
1023  while (a1 != NULL && nIsZero(t2))
1024  {
1025  pIter(a1);
1026  nDelete(&t2);
1027  if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
1028  }
1029  while (a2 != NULL && nIsZero(t1))
1030  {
1031  pIter(a2);
1032  nDelete(&t1);
1033  if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
1034  }
1035  }
1036 #endif
1037 
1038  if (a1==NULL)
1039  {
1040  if(a2!=NULL)
1041  {
1042  m2=p_Init(currRing);
1043 x2:
1044  for (i = (currRing->N); i; i--)
1045  {
1046  c = p_GetExpDiff(p1, p2,i, currRing);
1047  if (c>0)
1048  {
1049  p_SetExp(m2,i,(c+p_GetExp(a2,i,tailRing)),currRing);
1050  }
1051  else
1052  {
1053  p_SetExp(m2,i,p_GetExp(a2,i,tailRing),currRing);
1054  }
1055  }
1056  if ((c1==c2)||(c2!=0))
1057  {
1058  p_SetComp(m2,p_GetComp(a2,tailRing), currRing);
1059  }
1060  else
1061  {
1062  p_SetComp(m2,c1,currRing);
1063  }
1064  p_Setm(m2, currRing);
1065 #ifdef HAVE_RINGS
1066  if (is_Ring)
1067  {
1068  nDelete(&lc1);
1069  nDelete(&lc2);
1070  nDelete(&t2);
1071  pSetCoeff0(m2, t1);
1072  }
1073 #endif
1074  return m2;
1075  }
1076  else
1077  {
1078 #ifdef HAVE_RINGS
1079  if (is_Ring)
1080  {
1081  nDelete(&lc1);
1082  nDelete(&lc2);
1083  nDelete(&t1);
1084  nDelete(&t2);
1085  }
1086 #endif
1087  return NULL;
1088  }
1089  }
1090  if (a2==NULL)
1091  {
1092  m1=p_Init(currRing);
1093 x1:
1094  for (i = (currRing->N); i; i--)
1095  {
1096  c = p_GetExpDiff(p2, p1,i,currRing);
1097  if (c>0)
1098  {
1099  p_SetExp(m1,i,(c+p_GetExp(a1,i, tailRing)),currRing);
1100  }
1101  else
1102  {
1103  p_SetExp(m1,i,p_GetExp(a1,i, tailRing), currRing);
1104  }
1105  }
1106  if ((c1==c2)||(c1!=0))
1107  {
1108  p_SetComp(m1,p_GetComp(a1,tailRing),currRing);
1109  }
1110  else
1111  {
1112  p_SetComp(m1,c2,currRing);
1113  }
1114  p_Setm(m1, currRing);
1115 #ifdef HAVE_RINGS
1116  if (is_Ring)
1117  {
1118  pSetCoeff0(m1, t2);
1119  nDelete(&lc1);
1120  nDelete(&lc2);
1121  nDelete(&t1);
1122  }
1123 #endif
1124  return m1;
1125  }
1126  m1 = p_Init(currRing);
1127  m2 = p_Init(currRing);
1128  loop
1129  {
1130  for (i = (currRing->N); i; i--)
1131  {
1132  c = p_GetExpDiff(p1, p2,i,currRing);
1133  if (c > 0)
1134  {
1135  p_SetExp(m2,i,(c+p_GetExp(a2,i,tailRing)), currRing);
1136  p_SetExp(m1,i,p_GetExp(a1,i, tailRing), currRing);
1137  }
1138  else
1139  {
1140  p_SetExp(m1,i,(p_GetExp(a1,i,tailRing)-c), currRing);
1141  p_SetExp(m2,i,p_GetExp(a2,i, tailRing), currRing);
1142  }
1143  }
1144  if(c1==c2)
1145  {
1146  p_SetComp(m1,p_GetComp(a1, tailRing), currRing);
1147  p_SetComp(m2,p_GetComp(a2, tailRing), currRing);
1148  }
1149  else
1150  {
1151  if(c1!=0)
1152  {
1153  p_SetComp(m1,p_GetComp(a1, tailRing), currRing);
1154  p_SetComp(m2,c1, currRing);
1155  }
1156  else
1157  {
1158  p_SetComp(m2,p_GetComp(a2, tailRing), currRing);
1159  p_SetComp(m1,c2, currRing);
1160  }
1161  }
1162  p_Setm(m1,currRing);
1163  p_Setm(m2,currRing);
1164  cm = p_LmCmp(m1, m2,currRing);
1165  if (cm!=0)
1166  {
1167  if(cm==1)
1168  {
1169  p_LmFree(m2,currRing);
1170 #ifdef HAVE_RINGS
1171  if (is_Ring)
1172  {
1173  pSetCoeff0(m1, t2);
1174  nDelete(&lc1);
1175  nDelete(&lc2);
1176  nDelete(&t1);
1177  }
1178 #endif
1179  return m1;
1180  }
1181  else
1182  {
1183  p_LmFree(m1,currRing);
1184 #ifdef HAVE_RINGS
1185  if (is_Ring)
1186  {
1187  pSetCoeff0(m2, t1);
1188  nDelete(&lc1);
1189  nDelete(&lc2);
1190  nDelete(&t2);
1191  }
1192 #endif
1193  return m2;
1194  }
1195  }
1196 #ifdef HAVE_RINGS
1197  if (is_Ring)
1198  {
1199  equal = nEqual(t1,t2);
1200  }
1201  else
1202 #endif
1203  {
1204  t1 = nMult(pGetCoeff(a2),pGetCoeff(p1));
1205  t2 = nMult(pGetCoeff(a1),pGetCoeff(p2));
1206  equal = nEqual(t1,t2);
1207  nDelete(&t2);
1208  nDelete(&t1);
1209  }
1210  if (!equal)
1211  {
1212  p_LmFree(m2,currRing);
1213 #ifdef HAVE_RINGS
1214  if (is_Ring)
1215  {
1216  pSetCoeff0(m1, nSub(t1, t2));
1217  nDelete(&lc1);
1218  nDelete(&lc2);
1219  nDelete(&t1);
1220  nDelete(&t2);
1221  }
1222 #endif
1223  return m1;
1224  }
1225  pIter(a1);
1226  pIter(a2);
1227 #ifdef HAVE_RINGS
1228  if (is_Ring)
1229  {
1230  if (a2 != NULL)
1231  {
1232  nDelete(&t1);
1233  t1 = nMult(pGetCoeff(a2),lc1);
1234  }
1235  if (a1 != NULL)
1236  {
1237  nDelete(&t2);
1238  t2 = nMult(pGetCoeff(a1),lc2);
1239  }
1240  while ((a1 != NULL) && nIsZero(t2))
1241  {
1242  pIter(a1);
1243  if (a1 != NULL)
1244  {
1245  nDelete(&t2);
1246  t2 = nMult(pGetCoeff(a1),lc2);
1247  }
1248  }
1249  while ((a2 != NULL) && nIsZero(t1))
1250  {
1251  pIter(a2);
1252  if (a2 != NULL)
1253  {
1254  nDelete(&t1);
1255  t1 = nMult(pGetCoeff(a2),lc1);
1256  }
1257  }
1258  }
1259 #endif
1260  if (a2==NULL)
1261  {
1262  p_LmFree(m2,currRing);
1263  if (a1==NULL)
1264  {
1265 #ifdef HAVE_RINGS
1266  if (is_Ring)
1267  {
1268  nDelete(&lc1);
1269  nDelete(&lc2);
1270  nDelete(&t1);
1271  nDelete(&t2);
1272  }
1273 #endif
1274  p_LmFree(m1,currRing);
1275  return NULL;
1276  }
1277  goto x1;
1278  }

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

762 {
763 #ifdef KDEBUG
764  create_count++;
765 #endif
766  kTest_L(Pair);
767  poly p1 = Pair->p1;
768  poly p2 = Pair->p2;
769  Pair->tailRing = tailRing;
770 
771  assume(p1 != NULL);
772  assume(p2 != NULL);
773  assume(tailRing != NULL);
774 
775  poly a1 = pNext(p1), a2 = pNext(p2);
776  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
777  int co=0/*, ct = ksCheckCoeff(&lc1, &lc2, currRing->cf)*/; // gcd and zero divisors
778  (void) ksCheckCoeff(&lc1, &lc2, currRing->cf);
779 
780  int l1=0, l2=0;
781 
782  if (currRing->pCompIndex >= 0)
783  {
784  if (__p_GetComp(p1, currRing)!=__p_GetComp(p2, currRing))
785  {
786  if (__p_GetComp(p1, currRing)==0)
787  {
788  co=1;
789  p_SetCompP(p1,__p_GetComp(p2, currRing), currRing, tailRing);
790  }
791  else
792  {
793  co=2;
794  p_SetCompP(p2, __p_GetComp(p1, currRing), currRing, tailRing);
795  }
796  }
797  }
798 
799  // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
800  // m2 = LCM(LM(p1), LM(p2))/LM(p2)
801  if (m1 == NULL)
802  k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing);
803 
804  pSetCoeff0(m1, lc2);
805  pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2)
806 
807  if (R != NULL)
808  {
809  if (Pair->i_r1 == -1)
810  {
811  l1 = pLength(p1) - 1;
812  }
813  else
814  {
815  l1 = (R[Pair->i_r1])->GetpLength() - 1;
816  }
817  if ((Pair->i_r2 == -1)||(R[Pair->i_r2]==NULL))
818  {
819  l2 = pLength(p2) - 1;
820  }
821  else
822  {
823  l2 = (R[Pair->i_r2])->GetpLength() - 1;
824  }
825  }
826 
827  // get m2 * a2
828  if (spNoether != NULL)
829  {
830  l2 = -1;
831  a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
832  assume(l2 == pLength(a2));
833  }
834  else
835  a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
836 #ifdef HAVE_RINGS
837  if (!(rField_is_Domain(currRing))) l2 = pLength(a2);
838 #endif
839 
840  Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
841 
842  // get m2*a2 - m1*a1
843  Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
844 
845  // Clean-up time
846  Pair->LmDeleteAndIter();
847  p_LmDelete(m1, tailRing);
848 
849  if (co != 0)
850  {
851  if (co==1)
852  {
853  p_SetCompP(p1,0, currRing, tailRing);
854  }
855  else
856  {
857  p_SetCompP(p2,0, currRing, tailRing);
858  }
859  }
860 
861  // the following is commented out: shrinking
862 #ifdef HAVE_SHIFTBBA_NONEXISTENT
863  if (currRing->isLPring)
864  {
865  // assume? h->p in currRing
866  Pair->GetP();
867  poly qq = p_Shrink(Pair->p, currRing->isLPring, currRing);
868  Pair->Clear(); // does the right things
869  Pair->p = qq;

◆ ksOldCreateSpoly()

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

Definition at line 1069 of file kInline.h.

1078 {

◆ ksOldSpolyRed()

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

Definition at line 1049 of file kInline.h.

1058 {

◆ ksOldSpolyRedNew()

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

Definition at line 1059 of file kInline.h.

1068 {

◆ ksOldSpolyTail()

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

Definition at line 1079 of file kInline.h.

1088 {

◆ ksReducePoly()

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

Definition at line 39 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 170 of file kspoly.cc.

178 {
179 #ifdef KDEBUG
180  red_count++;
181 #ifdef TEST_OPT_DEBUG_RED
182  if (TEST_OPT_DEBUG)
183  {
184  Print("Red %d:", red_count); PR->wrp(); Print(" with:");
185  PW->wrp();
186  //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
187  //pWrite(PR->p);
188  }
189 #endif
190 #endif
191  int ret = 0;
192  ring tailRing = PR->tailRing;
193  kTest_L(PR);
194  kTest_T(PW);
195 
196  poly p1 = PR->GetLmTailRing(); // p2 | p1
197  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
198  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
199  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
200  p_CheckPolyRing(p1, tailRing);
201  p_CheckPolyRing(p2, tailRing);
202 
203  pAssume1(p2 != NULL && p1 != NULL &&
204  p_DivisibleBy(p2, p1, tailRing));
205 
206  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
207  (p_GetComp(p2, tailRing) == 0 &&
208  p_MaxComp(pNext(p2),tailRing) == 0));
209 
210 #ifdef HAVE_PLURAL
211  if (rIsPluralRing(currRing))
212  {
213  // for the time being: we know currRing==strat->tailRing
214  // no exp-bound checking needed
215  // (only needed if exp-bound(tailring)<exp-b(currRing))
216  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
217  else
218  {
219  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
220  assume(_p != NULL);
221  nc_PolyPolyRed(_p, p2,coef, currRing);
222  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
223  PR->pLength=0; // usually not used, GetpLength re-computes it if needed
224  }
225  return 0;
226  }
227 #endif
228 
229  if (t2==NULL) // Divisor is just one term, therefore it will
230  { // just cancel the leading term
231  PR->LmDeleteAndIter();
232  if (coef != NULL) *coef = n_Init(1, tailRing);
233  return 0;
234  }
235 
236  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
237 
238  if (tailRing != currRing)
239  {
240  // check that reduction does not violate exp bound
241  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
242  {
243  // undo changes of lm
244  p_ExpVectorAdd(lm, p2, tailRing);
245  if (strat == NULL) return 2;
246  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
247  tailRing = strat->tailRing;
248  p1 = PR->GetLmTailRing();
249  p2 = PW->GetLmTailRing();
250  t2 = pNext(p2);
251  lm = p1;
252  p_ExpVectorSub(lm, p2, tailRing);
253  ret = 1;
254  }
255  }
256 
257  // take care of coef buisness
258  if (! n_IsOne(pGetCoeff(p2), tailRing))
259  {
260  number bn = pGetCoeff(lm);
261  number an = pGetCoeff(p2);
262  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
263  p_SetCoeff(lm, bn, tailRing);
264  if ((ct == 0) || (ct == 2))
265  PR->Tail_Mult_nn(an);
266  if (coef != NULL) *coef = an;
267  else n_Delete(&an, tailRing);
268  }
269  else
270  {
271  if (coef != NULL) *coef = n_Init(1, tailRing);
272  }
273 
274 
275  // and finally,
276  PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
277  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
278  PR->LmDeleteAndIter();
279 
280  // the following is commented out: shrinking
281 #ifdef HAVE_SHIFTBBA_NONEXISTENT
282  if ( (currRing->isLPring) && (!strat->homog) )
283  {
284  // assume? h->p in currRing
285  PR->GetP();
286  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
287  PR->Clear(); // does the right things
288  PR->p = qq;
289  PR->t_p = NULL;
290  PR->SetShortExpVector();
291  }
292 #endif
293 
294 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
295  if (TEST_OPT_DEBUG)
296  {
297  Print(" to: "); PR->wrp(); Print("\n");
298  //printf("\nt^%i ", PR->ecart);pWrite(pHead(PR->p));
299  }
300 #endif

◆ ksReducePolySig()

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

Definition at line 308 of file kspoly.cc.

317 {
318 #ifdef KDEBUG
319  red_count++;
320 #ifdef TEST_OPT_DEBUG_RED
321  if (TEST_OPT_DEBUG)
322  {
323  Print("Red %d:", red_count); PR->wrp(); Print(" with:");
324  PW->wrp();
325  }
326 #endif
327 #endif
328  int ret = 0;
329  ring tailRing = PR->tailRing;
330  kTest_L(PR);
331  kTest_T(PW);
332 
333  // signature-based stuff:
334  // checking for sig-safeness first
335  // NOTE: This has to be done in the current ring
336  //
337  /**********************************************
338  *
339  * TODO:
340  * --------------------------------------------
341  * if strat->sbaOrder == 1
342  * Since we are subdividing lower index and
343  * current index reductions it is enough to
344  * look at the polynomial part of the signature
345  * for a check. This should speed-up checking
346  * a lot!
347  * if !strat->sbaOrder == 0
348  * We are not subdividing lower and current index
349  * due to the fact that we are using the induced
350  * Schreyer order
351  *
352  * nevertheless, this different behaviour is
353  * taken care of by is_sigsafe
354  * => one reduction procedure can be used for
355  * both, the incremental and the non-incremental
356  * attempt!
357  * --------------------------------------------
358  *
359  *********************************************/
360  //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
361  if (!PW->is_sigsafe)
362  {
363  poly sigMult = pCopy(PW->sig); // copy signature of reducer
364 //#if 1
365 #ifdef DEBUGF5
366  printf("IN KSREDUCEPOLYSIG: \n");
367  pWrite(pHead(f1));
368  pWrite(pHead(f2));
369  pWrite(sigMult);
370  printf("--------------\n");
371 #endif
372  p_ExpVectorAddSub(sigMult,PR->GetLmCurrRing(),PW->GetLmCurrRing(),currRing);
373 //#if 1
374 #ifdef DEBUGF5
375  printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
376  pWrite(pHead(f1));
377  pWrite(pHead(f2));
378  pWrite(sigMult);
379  pWrite(PR->sig);
380  printf("--------------\n");
381 #endif
382  int sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
383  // now we can delete the copied polynomial data used for checking for
384  // sig-safeness of the reduction step
385 //#if 1
386 #ifdef DEBUGF5
387  printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
388 
389 #endif
390  //pDelete(&f1);
391  pDelete(&sigMult);
392  // go on with the computations only if the signature of p2 is greater than the
393  // signature of fm*p1
394  if(sigSafe != 1)
395  {
396  PR->is_redundant = TRUE;
397  return 3;
398  }
399  //PW->is_sigsafe = TRUE;
400  }
401  PR->is_redundant = FALSE;
402  poly p1 = PR->GetLmTailRing(); // p2 | p1
403  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
404  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
405  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
406  p_CheckPolyRing(p1, tailRing);
407  p_CheckPolyRing(p2, tailRing);
408 
409  pAssume1(p2 != NULL && p1 != NULL &&
410  p_DivisibleBy(p2, p1, tailRing));
411 
412  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
413  (p_GetComp(p2, tailRing) == 0 &&
414  p_MaxComp(pNext(p2),tailRing) == 0));
415 
416 #ifdef HAVE_PLURAL
417  if (rIsPluralRing(currRing))
418  {
419  // for the time being: we know currRing==strat->tailRing
420  // no exp-bound checking needed
421  // (only needed if exp-bound(tailring)<exp-b(currRing))
422  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
423  else
424  {
425  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
426  assume(_p != NULL);
427  nc_PolyPolyRed(_p, p2, coef, currRing);
428  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
429  PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
430  }
431  return 0;
432  }
433 #endif
434 
435  if (t2==NULL) // Divisor is just one term, therefore it will
436  { // just cancel the leading term
437  PR->LmDeleteAndIter();
438  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
439  return 0;
440  }
441 
442  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
443 
444  if (tailRing != currRing)
445  {
446  // check that reduction does not violate exp bound
447  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
448  {
449  // undo changes of lm
450  p_ExpVectorAdd(lm, p2, tailRing);
451  if (strat == NULL) return 2;
452  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
453  tailRing = strat->tailRing;
454  p1 = PR->GetLmTailRing();
455  p2 = PW->GetLmTailRing();
456  t2 = pNext(p2);
457  lm = p1;
458  p_ExpVectorSub(lm, p2, tailRing);
459  ret = 1;
460  }
461  }
462 
463  // take care of coef buisness
464  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
465  {
466  number bn = pGetCoeff(lm);
467  number an = pGetCoeff(p2);
468  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
469  p_SetCoeff(lm, bn, tailRing);
470  if ((ct == 0) || (ct == 2))
471  PR->Tail_Mult_nn(an);
472  if (coef != NULL) *coef = an;
473  else n_Delete(&an, tailRing->cf);
474  }
475  else
476  {
477  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
478  }
479 
480 
481  // and finally,
482  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
483  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
484  PR->LmDeleteAndIter();
485 
486  // the following is commented out: shrinking
487 #ifdef HAVE_SHIFTBBA_NONEXISTENT
488  if ( (currRing->isLPring) && (!strat->homog) )
489  {
490  // assume? h->p in currRing
491  PR->GetP();
492  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
493  PR->Clear(); // does the right things
494  PR->p = qq;
495  PR->t_p = NULL;
496  PR->SetShortExpVector();
497  }
498 #endif
499 
500 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
501  if (TEST_OPT_DEBUG)
502  {
503  Print(" to: "); PR->wrp(); Print("\n");

◆ ksReducePolySigRing()

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

Definition at line 505 of file kspoly.cc.

515 {
516 #ifdef KDEBUG
517  red_count++;
518 #ifdef TEST_OPT_DEBUG_RED
519  if (TEST_OPT_DEBUG)
520  {
521  Print("Red %d:", red_count); PR->wrp(); Print(" with:");
522  PW->wrp();
523  }
524 #endif
525 #endif
526  int ret = 0;
527  ring tailRing = PR->tailRing;
528  kTest_L(PR);
529  kTest_T(PW);
530 
531  // signature-based stuff:
532  // checking for sig-safeness first
533  // NOTE: This has to be done in the current ring
534  //
535  /**********************************************
536  *
537  * TODO:
538  * --------------------------------------------
539  * if strat->sbaOrder == 1
540  * Since we are subdividing lower index and
541  * current index reductions it is enough to
542  * look at the polynomial part of the signature
543  * for a check. This should speed-up checking
544  * a lot!
545  * if !strat->sbaOrder == 0
546  * We are not subdividing lower and current index
547  * due to the fact that we are using the induced
548  * Schreyer order
549  *
550  * nevertheless, this different behaviour is
551  * taken care of by is_sigsafe
552  * => one reduction procedure can be used for
553  * both, the incremental and the non-incremental
554  * attempt!
555  * --------------------------------------------
556  *
557  *********************************************/
558  //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
559  if (!PW->is_sigsafe)
560  {
561  poly sigMult = pCopy(PW->sig); // copy signature of reducer
562 //#if 1
563 #ifdef DEBUGF5
564  printf("IN KSREDUCEPOLYSIG: \n");
565  pWrite(pHead(f1));
566  pWrite(pHead(f2));
567  pWrite(sigMult);
568  printf("--------------\n");
569 #endif
570  p_ExpVectorAddSub(sigMult,PR->GetLmCurrRing(),PW->GetLmCurrRing(),currRing);
571  //I have also to set the leading coeficient for sigMult (in the case of rings)
573  {
574  pSetCoeff(sigMult,nMult(nDiv(pGetCoeff(PR->p),pGetCoeff(PW->p)), pGetCoeff(sigMult)));
575  if(nIsZero(pGetCoeff(sigMult)))
576  {
577  sigMult = NULL;
578  }
579  }
580 //#if 1
581 #ifdef DEBUGF5
582  printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
583  pWrite(pHead(f1));
584  pWrite(pHead(f2));
585  pWrite(sigMult);
586  pWrite(PR->sig);
587  printf("--------------\n");
588 #endif
589  int sigSafe;
591  sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
592  // now we can delete the copied polynomial data used for checking for
593  // sig-safeness of the reduction step
594 //#if 1
595 #ifdef DEBUGF5
596  printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
597 
598 #endif
600  {
601  // Set the sig
602  poly origsig = pCopy(PR->sig);
603  if(sigMult != NULL)
604  PR->sig = pHead(pSub(PR->sig, sigMult));
605  //The sigs have the same lm, have to substract
606  //It may happen that now the signature is 0 (drop)
607  if(PR->sig == NULL)
608  {
609  strat->sigdrop=TRUE;
610  }
611  else
612  {
613  if(pLtCmp(PR->sig,origsig) == 1)
614  {
615  // do not allow this reduction - it will increase it's signature
616  // and the partially standard basis is just till the old sig, not the new one
617  PR->is_redundant = TRUE;
618  pDelete(&PR->sig);
619  PR->sig = origsig;
620  strat->blockred++;
621  return 3;
622  }
623  if(pLtCmp(PR->sig,origsig) == -1)
624  {
625  strat->sigdrop=TRUE;
626  }
627  }
628  pDelete(&origsig);
629  }
630  //pDelete(&f1);
631  // go on with the computations only if the signature of p2 is greater than the
632  // signature of fm*p1
633  if(sigSafe != 1 && !rField_is_Ring(currRing))
634  {
635  PR->is_redundant = TRUE;
636  return 3;
637  }
638  //PW->is_sigsafe = TRUE;
639  }
640  PR->is_redundant = FALSE;
641  poly p1 = PR->GetLmTailRing(); // p2 | p1
642  poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
643  poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
644  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
645  p_CheckPolyRing(p1, tailRing);
646  p_CheckPolyRing(p2, tailRing);
647 
648  pAssume1(p2 != NULL && p1 != NULL &&
649  p_DivisibleBy(p2, p1, tailRing));
650 
651  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
652  (p_GetComp(p2, tailRing) == 0 &&
653  p_MaxComp(pNext(p2),tailRing) == 0));
654 
655 #ifdef HAVE_PLURAL
656  if (rIsPluralRing(currRing))
657  {
658  // for the time being: we know currRing==strat->tailRing
659  // no exp-bound checking needed
660  // (only needed if exp-bound(tailring)<exp-b(currRing))
661  if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
662  else
663  {
664  poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
665  assume(_p != NULL);
666  nc_PolyPolyRed(_p, p2, coef, currRing);
667  if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
668  PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
669  }
670  return 0;
671  }
672 #endif
673 
674  if (t2==NULL) // Divisor is just one term, therefore it will
675  { // just cancel the leading term
676  PR->LmDeleteAndIter();
677  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
678  return 0;
679  }
680 
681  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
682 
683  if (tailRing != currRing)
684  {
685  // check that reduction does not violate exp bound
686  while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
687  {
688  // undo changes of lm
689  p_ExpVectorAdd(lm, p2, tailRing);
690  if (strat == NULL) return 2;
691  if (! kStratChangeTailRing(strat, PR, PW)) return -1;
692  tailRing = strat->tailRing;
693  p1 = PR->GetLmTailRing();
694  p2 = PW->GetLmTailRing();
695  t2 = pNext(p2);
696  lm = p1;
697  p_ExpVectorSub(lm, p2, tailRing);
698  ret = 1;
699  }
700  }
701  // take care of coef buisness
703  {
704  p_SetCoeff(lm, nDiv(pGetCoeff(lm),pGetCoeff(p2)), tailRing);
705  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
706  }
707  else
708  {
709  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
710  {
711  number bn = pGetCoeff(lm);
712  number an = pGetCoeff(p2);
713  int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC
714  p_SetCoeff(lm, bn, tailRing);
715  if (((ct == 0) || (ct == 2)))
716  PR->Tail_Mult_nn(an);
717  if (coef != NULL) *coef = an;
718  else n_Delete(&an, tailRing->cf);
719  }
720  else
721  {
722  if (coef != NULL) *coef = n_Init(1, tailRing->cf);
723  }
724  }
725 
726  // and finally,
727  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
728  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
729  PR->LmDeleteAndIter();
730 
731  // the following is commented out: shrinking
732 #ifdef HAVE_SHIFTBBA_NONEXISTENT
733  if ( (currRing->isLPring) && (!strat->homog) )
734  {
735  // assume? h->p in currRing
736  PR->GetP();
737  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
738  PR->Clear(); // does the right things
739  PR->p = qq;
740  PR->t_p = NULL;
741  PR->SetShortExpVector();
742  }
743 #endif
744 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
745  if (TEST_OPT_DEBUG)
746  {

◆ ksReducePolyTail() [1/2]

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

Definition at line 1023 of file kInline.h.

1031 {
1032  BOOLEAN ret;
1033  number coef;
1034 
1035  assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1036  Red->HeadNormalize();
1037  ret = ksReducePoly(Red, PW, NULL, &coef);
1038 
1039  if (!ret)
1040  {
1041  if (! n_IsOne(coef, currRing->cf))
1042  {

◆ ksReducePolyTail() [2/2]

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

Definition at line 871 of file kspoly.cc.

878 {
879  BOOLEAN ret;
880  number coef;
881  poly Lp = PR->GetLmCurrRing();
882  poly Save = PW->GetLmCurrRing();
883 
884  kTest_L(PR);
885  kTest_T(PW);
886  pAssume(pIsMonomOf(Lp, Current));
887 
888  assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
889  assume(PR->bucket == NULL);
890 
891  LObject Red(pNext(Current), PR->tailRing);
892  TObject With(PW, Lp == Save);
893 
894  pAssume(!pHaveCommonMonoms(Red.p, With.p));
895  ret = ksReducePoly(&Red, &With, spNoether, &coef);
896 
897  if (!ret)
898  {
899  if (! n_IsOne(coef, currRing->cf))
900  {
901  pNext(Current) = NULL;
902  if (Current == PR->p && PR->t_p != NULL)
903  pNext(PR->t_p) = NULL;
904  PR->Mult_nn(coef);
905  }
906 
907  n_Delete(&coef, currRing->cf);
908  pNext(Current) = Red.GetLmTailRing();
909  if (Current == PR->p && PR->t_p != NULL)
910  pNext(PR->t_p) = pNext(Current);
911  }
912 
913  if (Lp == Save)
914  With.Delete();
915 
916  // the following is commented out: shrinking
917 #ifdef HAVE_SHIFTBBA_NONEXISTENT
918  if (currRing->isLPring)
919  {
920  // assume? h->p in currRing
921  PR->GetP();
922  poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
923  PR->Clear(); // does the right things
924  PR->p = qq;
925  PR->t_p = NULL;

◆ kStratChangeTailRing()

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

Definition at line 11028 of file kutil.cc.

11038 {
11039  assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11040  /* initial setup or extending */
11041 
11042  if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11043  if (expbound >= currRing->bitmask) return FALSE;
11044  strat->overflow=FALSE;
11045  ring new_tailRing = rModifyRing(currRing,
11046  // Hmmm .. the condition pFDeg == p_Deg
11047  // might be too strong
11048  (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11049  (strat->ak==0), // omit_comp if the input is an ideal
11050  expbound); // exp_limit
11051 
11052  if (new_tailRing == currRing) return TRUE;
11053 
11054  strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11055  strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11056 
11057  if (currRing->pFDeg != currRing->pFDegOrig)
11058  {
11059  new_tailRing->pFDeg = currRing->pFDeg;
11060  new_tailRing->pLDeg = currRing->pLDeg;
11061  }
11062 
11063  if (TEST_OPT_PROT)
11064  Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11065  kTest_TS(strat);
11066  assume(new_tailRing != strat->tailRing);
11067  pShallowCopyDeleteProc p_shallow_copy_delete
11068  = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11069 
11070  omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11071 
11072  int i;
11073  for (i=0; i<=strat->tl; i++)
11074  {
11075  strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11076  p_shallow_copy_delete);
11077  }
11078  for (i=0; i<=strat->Ll; i++)
11079  {
11080  assume(strat->L[i].p != NULL);
11081  if (pNext(strat->L[i].p) != strat->tail)
11082  strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11083  }
11084  if ((strat->P.t_p != NULL) ||
11085  ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11086  strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11087 
11088  if ((L != NULL) && (L->tailRing != new_tailRing))
11089  {
11090  if (L->i_r < 0)
11091  L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11092  else
11093  {
11094  assume(L->i_r <= strat->tl);
11095  TObject* t_l = strat->R[L->i_r];
11096  assume(t_l != NULL);
11097  L->tailRing = new_tailRing;
11098  L->p = t_l->p;
11099  L->t_p = t_l->t_p;
11100  L->max_exp = t_l->max_exp;
11101  }
11102  }
11103 
11104  if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11105  T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11106 
11107  omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11108  if (strat->tailRing != currRing)
11109  rKillModifiedRing(strat->tailRing);
11110 
11111  strat->tailRing = new_tailRing;
11112  strat->tailBin = new_tailBin;
11113  strat->p_shallow_copy_delete
11114  = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11115 
11116  if (strat->kHEdge != NULL)
11117  {
11118  if (strat->t_kHEdge != NULL)
11119  p_LmFree(strat->t_kHEdge, strat->tailRing);
11120  strat->t_kHEdge=k_LmInit_currRing_2_tailRing(strat->kHEdge, new_tailRing);
11121  }
11122 
11123  if (strat->kNoether != NULL)
11124  {
11125  if (strat->t_kNoether != NULL)

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11127 of file kutil.cc.

11137 {
11138  unsigned long l = 0;
11139  int i;
11140  long e;
11141 
11142  assume(strat->tailRing == currRing);
11143 
11144  for (i=0; i<= strat->Ll; i++)
11145  {
11146  l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11147  }
11148  for (i=0; i<=strat->tl; i++)
11149  {
11150  // Hmm ... this we could do in one Step
11151  l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11152  }

◆ message()

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

Definition at line 7727 of file kutil.cc.

7730 {
7731  if (i != *olddeg)
7732  {
7733  Print("%d",i);
7734  *olddeg = i;
7735  }
7736  if (TEST_OPT_OLDSTD)
7737  {
7738  if (strat->Ll != *reduc)
7739  {
7740  if (strat->Ll != *reduc-1)
7741  Print("(%d)",strat->Ll+1);
7742  else
7743  PrintS("-");
7744  *reduc = strat->Ll;
7745  }
7746  else
7747  PrintS(".");
7748  mflush();
7749  }
7750  else
7751  {
7752  if (red_result == 0)
7753  PrintS("-");
7754  else if (red_result < 0)
7755  PrintS(".");
7756  if ((red_result > 0) || ((strat->Ll % 100)==99))
7757  {
7758  if (strat->Ll != *reduc && strat->Ll > 0)
7759  {
7760  Print("(%d)",strat->Ll+1);
7761  *reduc = strat->Ll;
7762  }
7763  }

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7768 of file kutil.cc.

7771 {
7772  //PrintS("\nUsage/Allocation of temporary storage:\n");
7773  //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7774  //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7775  Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7776  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7777  /* in usual case strat->cv is 0, it gets changed only in shift routines */
7778  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7780 of file kutil.cc.

7783 {
7784  //PrintS("\nUsage/Allocation of temporary storage:\n");
7785  //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7786  //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7787  Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7788  //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7789  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7790  /* in usual case strat->cv is 0, it gets changed only in shift routines */
7791  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10514 of file kutil.cc.

10522 {
10523  if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10524  return FALSE;
10525  int i,j;
10526  poly newNoether;
10527 
10528 #if 0
10529  if (currRing->weight_all_1)
10530  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10531  else
10532  scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10533 #else
10534  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10535 #endif
10536  if (strat->kHEdge==NULL) return FALSE;
10537  if (strat->t_kHEdge != NULL) p_LmFree(strat->t_kHEdge, strat->tailRing);
10538  if (strat->tailRing != currRing)
10539  strat->t_kHEdge = k_LmInit_currRing_2_tailRing(strat->kHEdge, strat->tailRing);
10540  /* compare old and new noether*/
10541  newNoether = pLmInit(strat->kHEdge);
10542  pSetCoeff0(newNoether,nInit(1));
10543  j = p_FDeg(newNoether,currRing);
10544  for (i=1; i<=(currRing->N); i++)
10545  {
10546  if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10547  }
10548  pSetm(newNoether);
10549  if (j < strat->HCord) /*- statistics -*/
10550  {
10551  if (TEST_OPT_PROT)
10552  {
10553  Print("H(%d)",j);
10554  mflush();
10555  }
10556  strat->HCord=j;
10557  #ifdef KDEBUG
10558  if (TEST_OPT_DEBUG)
10559  {
10560  Print("H(%d):",j);
10561  wrp(strat->kHEdge);
10562  PrintLn();
10563  }
10564  #endif
10565  }
10566  if (pCmp(strat->kNoether,newNoether)!=1)
10567  {
10568  if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether);
10569  strat->kNoether=newNoether;
10570  if (strat->t_kNoether != NULL) p_LmFree(strat->t_kNoether, strat->tailRing);
10571  if (strat->tailRing != currRing)

◆ pairs()

void pairs ( )

◆ pCopyL2p()

poly pCopyL2p ( LObject  h,
kStrategy  strat 
)

Definition at line 11741 of file kutil.cc.

11742  {
11743  pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
11744  }
11745  return(p);
11746 }
11747 #endif
11748 
11749 #ifdef HAVE_SHIFTBBA
11750 poly pCopyL2p(LObject H, kStrategy strat)
11751 {
11752  /* restores a poly in currRing from LObject */
11753  LObject h = H;
11754  h.Copy();
11755  poly p;
11756  if (h.p == NULL)
11757  {
11758  if (h.t_p != NULL)
11759  {
11760  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
11761  return(p);
11762  }
11763  else
11764  {
11765  /* h.tp == NULL -> the object is NULL */
11766  return(NULL);
11767  }
11768  }
11769  /* we're here if h.p != NULL */
11770  if (h.t_p == NULL)
11771  {
11772  /* then h.p is the whole poly in currRing */
11773  p = h.p;
11774  return(p);
11775  }

◆ pMove2CurrTail()

poly pMove2CurrTail ( poly  p,
kStrategy  strat 
)

Definition at line 11710 of file kutil.cc.

11720 {

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 11724 of file kutil.cc.

11725  {
11726  pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
11727  }
11728  return(p);
11729 }
11730 #endif
11731 
11732 #ifdef HAVE_SHIFTBBA
11733 poly pMoveCurrTail2poly(poly p, kStrategy strat)
11734 {
11735  /* assume: p has LM in curring and TAIL in tailring */
11736  /* convert it to complete currRing */
11737 

◆ posInIdealMonFirst()

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

Definition at line 5112 of file kutil.cc.

5114 {
5115  if(end < 0 || end >= IDELEMS(F))
5116  end = IDELEMS(F);
5117  if (end<0) return 0;
5118  if(pNext(p) == NULL) return start;
5119  polyset set=F->m;
5120  int o = p_Deg(p,currRing);
5121  int op;
5122  int i;
5123  int an = start;
5124  for(i=start;i<end;i++)
5125  if(set[i] != NULL && pNext(set[i]) == NULL)
5126  an++;
5127  if(an == end-1)
5128  return end;
5129  int en= end;
5130  loop
5131  {
5132  if(an>=en)
5133  return en;
5134  if (an == en-1)
5135  {
5136  op = p_Deg(set[an],currRing);
5137  if ((op < o)
5138  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5139  return en;
5140  return an;
5141  }
5142  i=(an+en) / 2;
5143  op = p_Deg(set[i],currRing);
5144  if ((op < o)
5145  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5146  an=i;
5147  else
5148  en=i;
5149  }

◆ posInL0()

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

Definition at line 5964 of file kutil.cc.

5967 {
5968  if (length<0) return 0;
5969 
5970  if (pLmCmp(set[length].p,p->p)== currRing->OrdSgn)
5971  return length+1;
5972 
5973  int i;
5974  int an = 0;
5975  int en= length;
5976  loop
5977  {
5978  if (an >= en-1)
5979  {
5980  if (pLmCmp(set[an].p,p->p) == currRing->OrdSgn) return en;
5981  return an;
5982  }
5983  i=(an+en) / 2;
5984  if (pLmCmp(set[i].p,p->p) == currRing->OrdSgn) an=i;
5985  else en=i;
5986  /*aend. fuer lazy == in !=- machen */
5987  }

◆ posInL10()

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

Definition at line 1009 of file kstd1.cc.

1011 {
1012  int j,dp,dL;
1013 
1014  if (length<0) return 0;
1015  if (hasPurePower(p,strat->lastAxis,&dp,strat))
1016  {
1017  int op= p->GetpFDeg() +p->ecart;
1018  for (j=length; j>=0; j--)
1019  {
1020  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1021  return j+1;
1022  if (dp < dL)
1023  return j+1;
1024  if ((dp == dL)
1025  && (set[j].GetpFDeg()+set[j].ecart >= op))
1026  return j+1;
1027  }
1028  }
1029  j=length;
1030  loop
1031  {
1032  if (j<0) break;
1033  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1034  j--;
1035  }
1036  return strat->posInLOld(set,j,p,strat);

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

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

◆ posInL110()

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

Definition at line 6520 of file kutil.cc.

6523 {
6524  if (length<0) return 0;
6525 
6526  int o = p->GetpFDeg();
6527  int op = set[length].GetpFDeg();
6528 
6529  if ((op > o)
6530  || ((op == o) && (set[length].length >p->length))
6531  || ((op == o) && (set[length].length <= p->length)
6532  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6533  return length+1;
6534  int i;
6535  int an = 0;
6536  int en= length;
6537  loop
6538  {
6539  if (an >= en-1)
6540  {
6541  op = set[an].GetpFDeg();
6542  if ((op > o)
6543  || ((op == o) && (set[an].length >p->length))
6544  || ((op == o) && (set[an].length <=p->length)
6545  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6546  return en;
6547  return an;
6548  }
6549  i=(an+en) / 2;
6550  op = set[i].GetpFDeg();
6551  if ((op > o)
6552  || ((op == o) && (set[i].length > p->length))
6553  || ((op == o) && (set[i].length <= p->length)
6554  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6555  an=i;
6556  else
6557  en=i;
6558  }

◆ posInL11Ring()

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

Definition at line 6264 of file kutil.cc.

6267 {
6268  if (length<0) return 0;
6269 
6270  int o = p->GetpFDeg();
6271  int op = set[length].GetpFDeg();
6272 
6273  if ((op > o)
6274  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6275  return length+1;
6276  int i;
6277  int an = 0;
6278  int en= length;
6279  loop
6280  {
6281  if (an >= en-1)
6282  {
6283  op = set[an].GetpFDeg();
6284  if ((op > o)
6285  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6286  return en;
6287  return an;
6288  }
6289  i=(an+en) / 2;
6290  op = set[i].GetpFDeg();
6291  if ((op > o)
6292  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6293  an=i;
6294  else
6295  en=i;
6296  }

◆ posInL11Ringls()

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

Definition at line 6334 of file kutil.cc.

6337 {
6338  if (length < 0) return 0;
6339  int an,en,i;
6340  an = 0;
6341  en = length+1;
6342  loop
6343  {
6344  if (an >= en-1)
6345  {
6346  if(an == en)
6347  return en;
6348  if (set[an].FDeg > p->FDeg)
6349  return en;
6350  if (set[an].FDeg < p->FDeg)
6351  return an;
6352  if (set[an].FDeg == p->FDeg)
6353  {
6354  number lcset,lcp;
6355  lcset = pGetCoeff(set[an].p);
6356  lcp = pGetCoeff(p->p);
6357  if(!nGreaterZero(lcset))
6358  {
6359  set[an].p=p_Neg(set[an].p,currRing);
6360  if (set[an].t_p!=NULL)
6361  pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
6362  lcset=pGetCoeff(set[an].p);
6363  }
6364  if(!nGreaterZero(lcp))
6365  {
6366  p->p=p_Neg(p->p,currRing);
6367  if (p->t_p!=NULL)
6368  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6369  lcp=pGetCoeff(p->p);
6370  }
6371  if(nGreater(lcset, lcp))
6372  {
6373  return en;
6374  }
6375  else
6376  {
6377  return an;
6378  }
6379  }
6380  }
6381  i=(an+en) / 2;
6382  if (set[i].FDeg > p->FDeg)
6383  an=i;
6384  if (set[i].FDeg < p->FDeg)
6385  en=i;
6386  if (set[i].FDeg == p->FDeg)
6387  {
6388  number lcset,lcp;
6389  lcset = pGetCoeff(set[i].p);
6390  lcp = pGetCoeff(p->p);
6391  if(!nGreaterZero(lcset))
6392  {
6393  set[i].p=p_Neg(set[i].p,currRing);
6394  if (set[i].t_p!=NULL)
6395  pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6396  lcset=pGetCoeff(set[i].p);
6397  }
6398  if(!nGreaterZero(lcp))
6399  {
6400  p->p=p_Neg(p->p,currRing);
6401  if (p->t_p!=NULL)
6402  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6403  lcp=pGetCoeff(p->p);
6404  }
6405  if(nGreater(lcset, lcp))
6406  {
6407  an = i;
6408  }
6409  else
6410  {
6411  en = i;
6412  }
6413  }
6414  }

◆ posInL13()

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

Definition at line 6608 of file kutil.cc.

6611 {
6612  if (length<0) return 0;
6613 
6614  int o = p->GetpFDeg();
6615 
6616  if (set[length].GetpFDeg() > o)
6617  return length+1;
6618 
6619  int i;
6620  int an = 0;
6621  int en= length;
6622  loop
6623  {
6624  if (an >= en-1)
6625  {
6626  if (set[an].GetpFDeg() >= o)
6627  return en;
6628  return an;
6629  }
6630  i=(an+en) / 2;
6631  if (set[i].GetpFDeg() >= o)
6632  an=i;
6633  else
6634  en=i;
6635  }

◆ posInL15()

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

Definition at line 6643 of file kutil.cc.

6646 {
6647  if (length<0) return 0;
6648 
6649  int o = p->GetpFDeg() + p->ecart;
6650  int op = set[length].GetpFDeg() + set[length].ecart;
6651 
6652  if ((op > o)
6653  || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6654  return length+1;
6655  int i;
6656  int an = 0;
6657  int en= length;
6658  loop
6659  {
6660  if (an >= en-1)
6661  {
6662  op = set[an].GetpFDeg() + set[an].ecart;
6663  if ((op > o)
6664  || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6665  return en;
6666  return an;
6667  }
6668  i=(an+en) / 2;
6669  op = set[i].GetpFDeg() + set[i].ecart;
6670  if ((op > o)
6671  || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6672  an=i;
6673  else
6674  en=i;
6675  }

◆ posInL15Ring()

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

Definition at line 6678 of file kutil.cc.

6681 {
6682  if (length<0) return 0;
6683 
6684  int o = p->GetpFDeg() + p->ecart;
6685  int op = set[length].GetpFDeg() + set[length].ecart;
6686 
6687  if ((op > o)
6688  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6689  return length+1;
6690  int i;
6691  int an = 0;
6692  int en= length;
6693  loop
6694  {
6695  if (an >= en-1)
6696  {
6697  op = set[an].GetpFDeg() + set[an].ecart;
6698  if ((op > o)
6699  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6700  return en;
6701  return an;
6702  }
6703  i=(an+en) / 2;
6704  op = set[i].GetpFDeg() + set[i].ecart;
6705  if ((op > o)
6706  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6707  an=i;
6708  else
6709  en=i;
6710  }

◆ posInL17()

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

Definition at line 6719 of file kutil.cc.

6722 {
6723  if (length<0) return 0;
6724 
6725  int o = p->GetpFDeg() + p->ecart;
6726 
6727  if ((set[length].GetpFDeg() + set[length].ecart > o)
6728  || ((set[length].GetpFDeg() + set[length].ecart == o)
6729  && (set[length].ecart > p->ecart))
6730  || ((set[length].GetpFDeg() + set[length].ecart == o)
6731  && (set[length].ecart == p->ecart)
6732  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6733  return length+1;
6734  int i;
6735  int an = 0;
6736  int en= length;
6737  loop
6738  {
6739  if (an >= en-1)
6740  {
6741  if ((set[an].GetpFDeg() + set[an].ecart > o)
6742  || ((set[an].GetpFDeg() + set[an].ecart == o)
6743  && (set[an].ecart > p->ecart))
6744  || ((set[an].GetpFDeg() + set[an].ecart == o)
6745  && (set[an].ecart == p->ecart)
6746  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6747  return en;
6748  return an;
6749  }
6750  i=(an+en) / 2;
6751  if ((set[i].GetpFDeg() + set[i].ecart > o)
6752  || ((set[i].GetpFDeg() + set[i].ecart == o)
6753  && (set[i].ecart > p->ecart))
6754  || ((set[i].GetpFDeg() +set[i].ecart == o)
6755  && (set[i].ecart == p->ecart)
6756  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6757  an=i;
6758  else
6759  en=i;
6760  }

◆ posInLF5C()

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

Definition at line 6210 of file kutil.cc.

6213 {
6214  return strat->Ll+1;

◆ posInLF5CRing()

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

Definition at line 6298 of file kutil.cc.

6301 {
6302  if (length<0) return 0;
6303  if(start == (length +1)) return (length+1);
6304  int o = p->GetpFDeg();
6305  int op = set[length].GetpFDeg();
6306 
6307  if ((op > o)
6308  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6309  return length+1;
6310  int i;
6311  int an = start;
6312  int en= length;
6313  loop
6314  {
6315  if (an >= en-1)
6316  {
6317  op = set[an].GetpFDeg();
6318  if ((op > o)
6319  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6320  return en;
6321  return an;
6322  }
6323  i=(an+en) / 2;
6324  op = set[i].GetpFDeg();
6325  if ((op > o)
6326  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6327  an=i;
6328  else
6329  en=i;
6330  }

◆ posInLRing()

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

Definition at line 6109 of file kutil.cc.

6112 {
6113  if (length < 0) return 0;
6114  if (set[length].FDeg > p->FDeg)
6115  return length+1;
6116  if (set[length].FDeg == p->FDeg)
6117  if(set[length].GetpLength() > p->GetpLength())
6118  return length+1;
6119  int i;
6120  int an = 0;
6121  int en= length+1;
6122  loop
6123  {
6124  if (an >= en-1)
6125  {
6126  if(an == en)
6127  return en;
6128  if (set[an].FDeg > p->FDeg)
6129  return en;
6130  if(set[an].FDeg == p->FDeg)
6131  {
6132  if(set[an].GetpLength() > p->GetpLength())
6133  return en;
6134  else
6135  {
6136  if(set[an].GetpLength() == p->GetpLength())
6137  {
6138  if(nGreater(set[an].p->coef, p->p->coef))
6139  return en;
6140  else
6141  return an;
6142  }
6143  else
6144  {
6145  return an;
6146  }
6147  }
6148  }
6149  else
6150  return an;
6151  }
6152  i=(an+en) / 2;
6153  if (set[i].FDeg > p->FDeg)
6154  an=i;
6155  else
6156  {
6157  if(set[i].FDeg == p->FDeg)
6158  {
6159  if(set[i].GetpLength() > p->GetpLength())
6160  an=i;
6161  else
6162  {
6163  if(set[i].GetpLength() == p->GetpLength())
6164  {
6165  if(nGreater(set[i].p->coef, p->p->coef))
6166  an = i;
6167  else
6168  en = i;
6169  }
6170  else
6171  {
6172  en=i;
6173  }
6174  }
6175  }
6176  else
6177  en=i;
6178  }
6179  }

◆ posInLSig()

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

Definition at line 6022 of file kutil.cc.

6025 {
6026  if (length<0) return 0;
6027  if (pLtCmp(set[length].sig,p->sig)== currRing->OrdSgn)
6028  return length+1;
6029 
6030  int i;
6031  int an = 0;
6032  int en= length;
6033  loop
6034  {
6035  if (an >= en-1)
6036  {
6037  if (pLtCmp(set[an].sig,p->sig) == currRing->OrdSgn) return en;
6038  return an;
6039  }
6040  i=(an+en) / 2;
6041  if (pLtCmp(set[i].sig,p->sig) == currRing->OrdSgn) an=i;
6042  else en=i;
6043  /*aend. fuer lazy == in !=- machen */
6044  }

◆ posInLSigRing()

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

Definition at line 6046 of file kutil.cc.

6049 {
6050  assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
6051  if (length<0) return 0;
6052  if (pLtCmp(set[length].sig,p->sig)== 1)
6053  return length+1;
6054 
6055  int an,en,i;
6056  an = 0;
6057  en = length+1;
6058  int cmp;
6059  loop
6060  {
6061  if (an >= en-1)
6062  {
6063  if(an == en)
6064  return en;
6065  cmp = pLtCmp(set[an].sig,p->sig);
6066  if (cmp == 1)
6067  return en;
6068  if (cmp == -1)
6069  return an;
6070  if (cmp == 0)
6071  {
6072  if (set[an].FDeg > p->FDeg)
6073  return en;
6074  if (set[an].FDeg < p->FDeg)
6075  return an;
6076  if (set[an].FDeg == p->FDeg)
6077  {
6078  cmp = pLtCmp(set[an].p,p->p);
6079  if(cmp == 1)
6080  return en;
6081  else
6082  return an;
6083  }
6084  }
6085  }
6086  i=(an+en) / 2;
6087  cmp = pLtCmp(set[i].sig,p->sig);
6088  if (cmp == 1)
6089  an = i;
6090  if (cmp == -1)
6091  en = i;
6092  if (cmp == 0)
6093  {
6094  if (set[i].FDeg > p->FDeg)
6095  an = i;
6096  if (set[i].FDeg < p->FDeg)
6097  en = i;
6098  if (set[i].FDeg == p->FDeg)
6099  {
6100  cmp = pLtCmp(set[i].p,p->p);
6101  if(cmp == 1)
6102  an = i;
6103  else
6104  en = i;
6105  }
6106  }
6107  }

◆ posInS()

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

Definition at line 4934 of file kutil.cc.

4937 {
4938  if(length==-1) return 0;
4939  polyset set=strat->S;
4940  int i;
4941  int an = 0;
4942  int en = length;
4943  int cmp_int = currRing->OrdSgn;
4945 #ifdef HAVE_PLURAL
4946  && (currRing->real_var_start==0)
4947 #endif
4948 #if 0
4949  || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
4950 #endif
4951  )
4952  {
4953  int o=p_Deg(p,currRing);
4954  int oo=p_Deg(set[length],currRing);
4955 
4956  if ((oo<o)
4957  || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
4958  return length+1;
4959 
4960  loop
4961  {
4962  if (an >= en-1)
4963  {
4964  if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
4965  {
4966  return an;
4967  }
4968  return en;
4969  }
4970  i=(an+en) / 2;
4971  if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
4972  else an=i;
4973  }
4974  }
4975  else
4976  {
4977  if (rField_is_Ring(currRing))
4978  {
4979  if (pLmCmp(set[length],p)== -cmp_int)
4980  return length+1;
4981  int cmp;
4982  loop
4983  {
4984  if (an >= en-1)
4985  {
4986  cmp = pLmCmp(set[an],p);
4987  if (cmp == cmp_int) return an;
4988  if (cmp == -cmp_int) return en;
4989  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
4990  return an;
4991  }
4992  i = (an+en) / 2;
4993  cmp = pLmCmp(set[i],p);
4994  if (cmp == cmp_int) en = i;
4995  else if (cmp == -cmp_int) an = i;
4996  else
4997  {
4998  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
4999  else en = i;
5000  }
5001  }
5002  }
5003  else
5004  if (pLmCmp(set[length],p)== -cmp_int)
5005  return length+1;
5006 
5007  loop
5008  {
5009  if (an >= en-1)
5010  {
5011  if (pLmCmp(set[an],p) == cmp_int) return an;
5012  if (pLmCmp(set[an],p) == -cmp_int) return en;
5013  if ((cmp_int!=1)
5014  && ((strat->ecartS[an])>ecart_p))
5015  return an;
5016  return en;
5017  }
5018  i=(an+en) / 2;
5019  if (pLmCmp(set[i],p) == cmp_int) en=i;
5020  else if (pLmCmp(set[i],p) == -cmp_int) an=i;
5021  else
5022  {
5023  if ((cmp_int!=1)
5024  &&((strat->ecartS[i])<ecart_p))
5025  en=i;
5026  else
5027  an=i;
5028  }
5029  }
5030  }

◆ posInSMonFirst()

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

Definition at line 5035 of file kutil.cc.

5037 {
5038  if (length<0) return 0;
5039  polyset set=strat->S;
5040  if(pNext(p) == NULL)
5041  {
5042  int mon = 0;
5043  for(int i = 0;i<=length;i++)
5044  {
5045  if(set[i] != NULL && pNext(set[i]) == NULL)
5046  mon++;
5047  }
5048  int o = p_Deg(p,currRing);
5049  int op = p_Deg(set[mon],currRing);
5050 
5051  if ((op < o)
5052  || ((op == o) && (pLtCmp(set[mon],p) == -1)))
5053  return length+1;
5054  int i;
5055  int an = 0;
5056  int en= mon;
5057  loop
5058  {
5059  if (an >= en-1)
5060  {
5061  op = p_Deg(set[an],currRing);
5062  if ((op < o)
5063  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5064  return en;
5065  return an;
5066  }
5067  i=(an+en) / 2;
5068  op = p_Deg(set[i],currRing);
5069  if ((op < o)
5070  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5071  an=i;
5072  else
5073  en=i;
5074  }
5075  }
5076  else /*if(pNext(p) != NULL)*/
5077  {
5078  int o = p_Deg(p,currRing);
5079  int op = p_Deg(set[length],currRing);
5080 
5081  if ((op < o)
5082  || ((op == o) && (pLtCmp(set[length],p) == -1)))
5083  return length+1;
5084  int i;
5085  int an = 0;
5086  for(i=0;i<=length;i++)
5087  if(set[i] != NULL && pNext(set[i]) == NULL)
5088  an++;
5089  int en= length;
5090  loop
5091  {
5092  if (an >= en-1)
5093  {
5094  op = p_Deg(set[an],currRing);
5095  if ((op < o)
5096  || ((op == o) && (pLtCmp(set[an],p) == -1)))
5097  return en;
5098  return an;
5099  }
5100  i=(an+en) / 2;
5101  op = p_Deg(set[i],currRing);
5102  if ((op < o)
5103  || ((op == o) && (pLtCmp(set[i],p) == -1)))
5104  an=i;
5105  else
5106  en=i;
5107  }
5108  }

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 6182 of file kutil.cc.

6184 {
6185  if (strat->syzl==0) return 0;
6186  if (pLtCmp(strat->syz[strat->syzl-1],sig) != currRing->OrdSgn)
6187  return strat->syzl;
6188  int i;
6189  int an = 0;
6190  int en= strat->syzl-1;
6191  loop
6192  {
6193  if (an >= en-1)
6194  {
6195  if (pLtCmp(strat->syz[an],sig) != currRing->OrdSgn) return en;
6196  return an;
6197  }
6198  i=(an+en) / 2;
6199  if (pLtCmp(strat->syz[i],sig) != currRing->OrdSgn) an=i;
6200  else en=i;
6201  /*aend. fuer lazy == in !=- machen */
6202  }

◆ posInT0()

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

Definition at line 5156 of file kutil.cc.

5158 {
5159  return (length+1);

◆ posInT1()

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

Definition at line 5167 of file kutil.cc.

5169 {
5170  if (length==-1) return 0;
5171 
5172  if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
5173 
5174  int i;
5175  int an = 0;
5176  int en= length;
5177 
5178  loop
5179  {
5180  if (an >= en-1)
5181  {
5182  if (pLmCmp(set[an].p,p.p) == currRing->OrdSgn) return an;
5183  return en;
5184  }
5185  i=(an+en) / 2;
5186  if (pLmCmp(set[i].p,p.p) == currRing->OrdSgn) en=i;
5187  else an=i;
5188  }

◆ posInT11()

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

Definition at line 5225 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5378 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5467 of file kutil.cc.

5469 {
5470  if (length==-1) return 0;
5471 
5472  int o = p.GetpFDeg();
5473 
5474  if (set[length].GetpFDeg() <= o)
5475  return length+1;
5476 
5477  int i;
5478  int an = 0;
5479  int en= length;
5480  loop
5481  {
5482  if (an >= en-1)
5483  {
5484  if (set[an].GetpFDeg() > o)
5485  return an;
5486  return en;
5487  }
5488  i=(an+en) / 2;
5489  if (set[i].GetpFDeg() > o)
5490  en=i;
5491  else
5492  an=i;
5493  }

◆ posInT15()

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

Definition at line 5535 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5630 of file kutil.cc.

5652 {
5653  if (length==-1) return 0;
5654 
5655  int o = p.GetpFDeg() + p.ecart;
5656  int op = set[length].GetpFDeg()+set[length].ecart;
5657 
5658  if ((op < o)
5659  || (( op == o) && (set[length].ecart > p.ecart))
5660  || (( op == o) && (set[length].ecart==p.ecart)
5661  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5662  return length+1;
5663 
5664  int i;
5665  int an = 0;
5666  int en= length;
5667  loop
5668  {
5669  if (an >= en-1)
5670  {
5671  op = set[an].GetpFDeg()+set[an].ecart;
5672  if (( op > o)
5673  || (( op == o) && (set[an].ecart < p.ecart))
5674  || (( op == o) && (set[an].ecart==p.ecart)
5675  && (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) && (set[i].ecart < p.ecart))
5683  || (( op == o) && (set[i].ecart == p.ecart)
5684  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5685  en=i;
5686  else
5687  an=i;
5688  }

◆ posInT17_c()

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

Definition at line 5737 of file kutil.cc.

5739 {
5740  if (length==-1) return 0;
5741 
5742  int cc = (-1+2*currRing->order[0]==ringorder_c);
5743  /* cc==1 for (c,..), cc==-1 for (C,..) */
5744  int o = p.GetpFDeg() + p.ecart;
5745  int c = pGetComp(p.p)*cc;
5746 
5747  if (pGetComp(set[length].p)*cc < c)
5748  return length+1;
5749  if (pGetComp(set[length].p)*cc == c)
5750  {
5751  int op = set[length].GetpFDeg()+set[length].ecart;
5752  if ((op < o)
5753  || ((op == o) && (set[length].ecart > p.ecart))
5754  || ((op == o) && (set[length].ecart==p.ecart)
5755  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5756  return length+1;
5757  }
5758 
5759  int i;
5760  int an = 0;
5761  int en= length;
5762  loop
5763  {
5764  if (an >= en-1)
5765  {
5766  if (pGetComp(set[an].p)*cc < c)
5767  return en;
5768  if (pGetComp(set[an].p)*cc == c)
5769  {
5770  int op = set[an].GetpFDeg()+set[an].ecart;
5771  if ((op > o)
5772  || ((op == o) && (set[an].ecart < p.ecart))
5773  || ((op == o) && (set[an].ecart==p.ecart)
5774  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5775  return an;
5776  }
5777  return en;
5778  }
5779  i=(an+en) / 2;
5780  if (pGetComp(set[i].p)*cc > c)
5781  en=i;
5782  else if (pGetComp(set[i].p)*cc == c)
5783  {
5784  int op = set[i].GetpFDeg()+set[i].ecart;
5785  if ((op > o)
5786  || ((op == o) && (set[i].ecart < p.ecart))
5787  || ((op == o) && (set[i].ecart == p.ecart)
5788  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5789  en=i;
5790  else
5791  an=i;
5792  }
5793  else
5794  an=i;
5795  }

◆ posInT19()

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

Definition at line 5864 of file kutil.cc.

5866 {
5867  p.GetpLength();
5868  if (length==-1) return 0;
5869 
5870  int o = p.ecart;
5871  int op=p.GetpFDeg();
5872 
5873  if (set[length].ecart < o)
5874  return length+1;
5875  if (set[length].ecart == o)
5876  {
5877  int oo=set[length].GetpFDeg();
5878  if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5879  return length+1;
5880  }
5881 
5882  int i;
5883  int an = 0;
5884  int en= length;
5885  loop
5886  {
5887  if (an >= en-1)
5888  {
5889  if (set[an].ecart > o)
5890  return an;
5891  if (set[an].ecart == o)
5892  {
5893  int oo=set[an].GetpFDeg();
5894  if((oo > op)
5895  || ((oo==op) && (set[an].length > p.length)))
5896  return an;
5897  }
5898  return en;
5899  }
5900  i=(an+en) / 2;
5901  if (set[i].ecart > o)
5902  en=i;
5903  else if (set[i].ecart == o)
5904  {
5905  int oo=set[i].GetpFDeg();
5906  if ((oo > op)
5907  || ((oo == op) && (set[i].length > p.length)))
5908  en=i;
5909  else
5910  an=i;
5911  }
5912  else
5913  an=i;
5914  }

◆ posInT2()

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

Definition at line 5195 of file kutil.cc.

5197 {
5198  p.GetpLength();
5199  if (length==-1)
5200  return 0;
5201  if (set[length].length<p.length)
5202  return length+1;
5203 
5204  int i;
5205  int an = 0;
5206  int en= length;
5207 
5208  loop
5209  {
5210  if (an >= en-1)
5211  {
5212  if (set[an].length>p.length) return an;
5213  return en;
5214  }
5215  i=(an+en) / 2;
5216  if (set[i].length>p.length) en=i;
5217  else an=i;
5218  }

◆ posInT_EcartFDegpLength()

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

Definition at line 11449 of file kutil.cc.

11459 {
11460 
11461  if (length==-1) return 0;
11462 
11463  int o = p.ecart;
11464  int op=p.GetpFDeg();
11465  int ol = p.GetpLength();
11466 
11467  if (set[length].ecart < o)
11468  return length+1;
11469  if (set[length].ecart == o)
11470  {
11471  int oo=set[length].GetpFDeg();
11472  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11473  return length+1;
11474  }
11475 
11476  int i;
11477  int an = 0;
11478  int en= length;
11479  loop
11480  {
11481  if (an >= en-1)
11482  {
11483  if (set[an].ecart > o)
11484  return an;
11485  if (set[an].ecart == o)
11486  {
11487  int oo=set[an].GetpFDeg();
11488  if((oo > op)
11489  || ((oo==op) && (set[an].pLength > ol)))
11490  return an;
11491  }
11492  return en;
11493  }
11494  i=(an+en) / 2;
11495  if (set[i].ecart > o)
11496  en=i;
11497  else if (set[i].ecart == o)
11498  {
11499  int oo=set[i].GetpFDeg();
11500  if ((oo > op)

◆ posInT_EcartpLength()

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

Definition at line 5496 of file kutil.cc.

5498 {
5499  int ol = p.GetpLength();
5500  if (length==-1) return 0;
5501 
5502  int op=p.ecart;
5503 
5504  int oo=set[length].ecart;
5505  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
5506  return length+1;
5507 
5508  int i;
5509  int an = 0;
5510  int en= length;
5511  loop
5512  {
5513  if (an >= en-1)
5514  {
5515  int oo=set[an].ecart;
5516  if((oo > op)
5517  || ((oo==op) && (set[an].pLength > ol)))
5518  return an;
5519  return en;
5520  }
5521  i=(an+en) / 2;
5522  int oo=set[i].ecart;
5523  if ((oo > op)
5524  || ((oo == op) && (set[i].pLength > ol)))
5525  en=i;
5526  else
5527  an=i;
5528  }

◆ posInT_FDegpLength()

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

Definition at line 11503 of file kutil.cc.

11513 {
11514 
11515  if (length==-1) return 0;
11516 
11517  int op=p.GetpFDeg();
11518  int ol = p.GetpLength();
11519 
11520  int oo=set[length].GetpFDeg();
11521  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11522  return length+1;
11523 
11524  int i;
11525  int an = 0;
11526  int en= length;
11527  loop
11528  {
11529  if (an >= en-1)
11530  {
11531  int oo=set[an].GetpFDeg();
11532  if((oo > op)
11533  || ((oo==op) && (set[an].pLength > ol)))
11534  return an;
11535  return en;
11536  }

◆ posInT_pLength()

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

Definition at line 11540 of file kutil.cc.

11550 {
11551  int ol = p.GetpLength();
11552  if (length==-1)
11553  return 0;
11554  if (set[length].length<p.length)
11555  return length+1;
11556 
11557  int i;
11558  int an = 0;
11559  int en= length;
11560 
11561  loop
11562  {
11563  if (an >= en-1)

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

10815 {
10816  if(!nCoeff_is_Ring_Z(currRing->cf))
10817  return;
10818  poly pH = h->GetP();
10819  poly p,pp;
10820  p = pH;
10821  bool deleted = FALSE, ok = FALSE;
10822  for(int i = 0; i<=strat->sl; i++)
10823  {
10824  p = pH;
10825  if(pNext(strat->S[i]) == NULL)
10826  {
10827  //pWrite(p);
10828  //pWrite(strat->S[i]);
10829  while(ok == FALSE && p != NULL)
10830  {
10831  if(pLmDivisibleBy(strat->S[i], p))
10832  {
10833  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10834  p_SetCoeff(p,dummy,currRing);
10835  }
10836  if(nIsZero(p->coef))
10837  {
10838  pLmDelete(&p);
10839  h->p = p;
10840  deleted = TRUE;
10841  }
10842  else
10843  {
10844  ok = TRUE;
10845  }
10846  }
10847  if (p!=NULL)
10848  {
10849  pp = pNext(p);
10850  while(pp != NULL)
10851  {
10852  if(pLmDivisibleBy(strat->S[i], pp))
10853  {
10854  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10855  p_SetCoeff(pp,dummy,currRing);
10856  if(nIsZero(pp->coef))
10857  {
10858  pLmDelete(&pNext(p));
10859  pp = pNext(p);
10860  deleted = TRUE;
10861  }
10862  else
10863  {
10864  p = pp;
10865  pp = pNext(p);
10866  }
10867  }
10868  else
10869  {
10870  p = pp;
10871  pp = pNext(p);

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 10873 of file kutil.cc.

10883 {
10884  if(!nCoeff_is_Ring_Z(currRing->cf))
10885  return;
10886  poly hSig = h->sig;
10887  poly pH = h->GetP();
10888  poly p,pp;
10889  p = pH;
10890  bool deleted = FALSE, ok = FALSE;
10891  for(int i = 0; i<=strat->sl; i++)
10892  {
10893  p = pH;
10894  if(pNext(strat->S[i]) == NULL)
10895  {
10896  while(ok == FALSE && p!=NULL)
10897  {
10898  if(pLmDivisibleBy(strat->S[i], p))
10899  {
10900  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10901  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10902  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10903  {
10904  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10905  p_SetCoeff(p,dummy,currRing);
10906  }
10907  pDelete(&sigMult);
10908  }
10909  if(nIsZero(p->coef))
10910  {
10911  pLmDelete(&p);
10912  h->p = p;
10913  deleted = TRUE;
10914  }
10915  else
10916  {
10917  ok = TRUE;
10918  }
10919  }
10920  if(p == NULL)
10921  return;
10922  pp = pNext(p);
10923  while(pp != NULL)
10924  {
10925  if(pLmDivisibleBy(strat->S[i], pp))
10926  {
10927  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10928  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10929  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10930  {
10931  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10932  p_SetCoeff(pp,dummy,currRing);
10933  if(nIsZero(pp->coef))
10934  {
10935  pLmDelete(&pNext(p));
10936  pp = pNext(p);
10937  deleted = TRUE;
10938  }
10939  else
10940  {
10941  p = pp;
10942  pp = pNext(p);
10943  }
10944  }
10945  else
10946  {
10947  p = pp;
10948  pp = pNext(p);
10949  }
10950  pDelete(&sigMult);
10951  }
10952  else
10953  {
10954  p = pp;
10955  pp = pNext(p);

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

10647 {
10649  if(!nCoeff_is_Ring_Z(currRing->cf))
10650  return NULL;
10651  ideal F = idCopy(Forig);
10652  idSkipZeroes(F);
10653  poly pmon;
10654  ring origR = currRing;
10655  ideal monred = idInit(1,1);
10656  for(int i=0; i<idElem(F); i++)
10657  {
10658  if(pNext(F->m[i]) == NULL)
10659  idInsertPoly(monred, pCopy(F->m[i]));
10660  }
10661  int posconst = idPosConstant(F);
10662  if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10663  {
10664  idDelete(&F);
10665  idDelete(&monred);
10666  return NULL;
10667  }
10668  int idelemQ = 0;
10669  if(Q!=NULL)
10670  {
10671  idelemQ = IDELEMS(Q);
10672  for(int i=0; i<idelemQ; i++)
10673  {
10674  if(pNext(Q->m[i]) == NULL)
10675  idInsertPoly(monred, pCopy(Q->m[i]));
10676  }
10677  idSkipZeroes(monred);
10678  posconst = idPosConstant(monred);
10679  //the constant, if found, will be from Q
10680  if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10681  {
10682  pmon = pCopy(monred->m[posconst]);
10683  idDelete(&F);
10684  idDelete(&monred);
10685  return pmon;
10686  }
10687  }
10688  ring QQ_ring = rCopy0(currRing,FALSE);
10689  nKillChar(QQ_ring->cf);
10690  QQ_ring->cf = nInitChar(n_Q, NULL);
10691  rComplete(QQ_ring,1);
10692  QQ_ring = rAssure_c_dp(QQ_ring);
10693  rChangeCurrRing(QQ_ring);
10694  nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10695  ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10696  for(int i = 0, j = 0; i<IDELEMS(F); i++)
10697  II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10698  for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10699  II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10700  ideal one = kStd(II, NULL, isNotHomog, NULL);
10701  idSkipZeroes(one);
10702  if(idIsConstant(one))
10703  {
10704  //one should be <1>
10705  for(int i = IDELEMS(II)-1; i>=0; i--)
10706  if(II->m[i] != NULL)
10707  II->m[i+1] = II->m[i];
10708  II->m[0] = pOne();
10709  ideal syz = idSyzygies(II, isNotHomog, NULL);
10710  poly integer = NULL;
10711  for(int i = IDELEMS(syz)-1;i>=0; i--)
10712  {
10713  if(pGetComp(syz->m[i]) == 1)
10714  {
10715  pSetComp(syz->m[i],0);
10716  if(pIsConstant(pHead(syz->m[i])))
10717  {
10718  integer = pHead(syz->m[i]);
10719  break;
10720  }
10721  }
10722  }
10723  rChangeCurrRing(origR);
10724  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10725  pmon = prMapR(integer, nMap2, QQ_ring, origR);
10726  idDelete(&monred);
10727  idDelete(&F);
10728  id_Delete(&II,QQ_ring);
10729  id_Delete(&one,QQ_ring);
10730  id_Delete(&syz,QQ_ring);
10731  p_Delete(&integer,QQ_ring);
10732  rDelete(QQ_ring);
10733  return pmon;
10734  }
10735  else
10736  {
10737  if(idIs0(monred))
10738  {
10739  poly mindegmon = NULL;
10740  for(int i = 0; i<IDELEMS(one); i++)
10741  {
10742  if(pNext(one->m[i]) == NULL)
10743  {
10744  if(mindegmon == NULL)
10745  mindegmon = pCopy(one->m[i]);
10746  else
10747  {
10748  if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10749  mindegmon = pCopy(one->m[i]);
10750  }
10751  }
10752  }
10753  if(mindegmon != NULL)
10754  {
10755  for(int i = IDELEMS(II)-1; i>=0; i--)
10756  if(II->m[i] != NULL)
10757  II->m[i+1] = II->m[i];
10758  II->m[0] = pCopy(mindegmon);
10759  ideal syz = idSyzygies(II, isNotHomog, NULL);
10760  bool found = FALSE;
10761  for(int i = IDELEMS(syz)-1;i>=0; i--)
10762  {
10763  if(pGetComp(syz->m[i]) == 1)
10764  {
10765  pSetComp(syz->m[i],0);
10766  if(pIsConstant(pHead(syz->m[i])))
10767  {
10768  pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10769  found = TRUE;
10770  break;
10771  }
10772  }
10773  }
10774  id_Delete(&syz,QQ_ring);
10775  if (found == FALSE)
10776  {
10777  rChangeCurrRing(origR);
10778  idDelete(&monred);
10779  idDelete(&F);
10780  id_Delete(&II,QQ_ring);
10781  id_Delete(&one,QQ_ring);
10782  rDelete(QQ_ring);
10783  return NULL;
10784  }
10785  rChangeCurrRing(origR);
10786  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10787  pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10788  idDelete(&monred);
10789  idDelete(&F);
10790  id_Delete(&II,QQ_ring);
10791  id_Delete(&one,QQ_ring);
10792  id_Delete(&syz,QQ_ring);
10793  rDelete(QQ_ring);
10794  return pmon;
10795  }
10796  }

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4264 of file kstd2.cc.

4267 {
4268  if (h->IsNull()) return 0;
4269 
4270  int at, reddeg,d;
4271  int pass = 0;
4272  int j = 0;
4273 
4274  if (! strat->homog)
4275  {
4276  d = h->GetpFDeg() + h->ecart;
4277  reddeg = strat->LazyDegree+d;
4278  }
4279  h->SetShortExpVector();
4280  loop
4281  {
4282  j = kFindDivisibleByInT(strat, h);
4283  if (j < 0)
4284  {
4285  h->SetDegStuffReturnLDeg(strat->LDegLast);
4286  return 1;
4287  }
4288 
4289  if (!TEST_OPT_INTSTRATEGY)
4290  strat->T[j].pNorm();
4291 #ifdef KDEBUG
4292  if (TEST_OPT_DEBUG)
4293  {
4294  PrintS("reduce ");
4295  h->wrp();
4296  PrintS(" with ");
4297  strat->T[j].wrp();
4298  }
4299 #endif
4300  ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, strat);
4301  if (!h->IsNull())
4302  {
4303  poly qq=p_Shrink(h->GetP(),strat->lV,currRing);
4304  h->p=qq;
4305  h->t_p=NULL;
4306  }
4307 
4308 #ifdef KDEBUG
4309  if (TEST_OPT_DEBUG)
4310  {
4311  PrintS("\nto ");
4312  wrp(h->p);
4313  PrintLn();
4314  }
4315 #endif
4316  if (h->IsNull())
4317  {
4318  if (h->lcm!=NULL) pLmFree(h->lcm);
4319  h->Clear();
4320  return 0;
4321  }
4322  h->SetShortExpVector();
4323 
4324 #if 0
4325  if ((strat->syzComp!=0) && !strat->honey)
4326  {
4327  if ((strat->syzComp>0) &&
4328  (h->Comp() > strat->syzComp))
4329  {
4330  assume(h->MinComp() > strat->syzComp);
4331 #ifdef KDEBUG
4332  if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
4333 #endif
4334  if (strat->homog)
4335  h->SetDegStuffReturnLDeg(strat->LDegLast);
4336  return -2;
4337  }
4338  }
4339 #endif
4340  if (!strat->homog)
4341  {
4342  if (!TEST_OPT_OLDSTD && strat->honey)
4343  {
4344  h->SetpFDeg();
4345  if (strat->T[j].ecart <= h->ecart)
4346  h->ecart = d - h->GetpFDeg();
4347  else
4348  h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
4349 
4350  d = h->GetpFDeg() + h->ecart;
4351  }
4352  else
4353  d = h->SetDegStuffReturnLDeg(strat->LDegLast);
4354  /*- try to reduce the s-polynomial -*/
4355  pass++;
4356  /*
4357  *test whether the polynomial should go to the lazyset L
4358  *-if the degree jumps
4359  *-if the number of pre-defined reductions jumps
4360  */
4361  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
4362  && ((d >= reddeg) || (pass > strat->LazyPass)))
4363  {
4364  h->SetLmCurrRing();
4365  if (strat->posInLDependsOnLength)
4366  h->SetLength(strat->length_pLength);
4367  at = strat->posInL(strat->L,strat->Ll,h,strat);
4368  if (at <= strat->Ll)
4369  {
4370  //int dummy=strat->sl;
4371  /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
4372  //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
4373  if (kFindDivisibleByInT(strat, h) < 0)
4374  return 1;
4375  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
4376 #ifdef KDEBUG
4377  if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
4378 #endif
4379  h->Clear();
4380  return -1;
4381  }
4382  }
4383  if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
4384  {
4385  reddeg = d+1;
4386  Print(".%d",d);mflush();
4387  }
4388  }

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 548 of file kstd2.cc.

549 {
550  if (strat->tl<0) return 1;
551  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
552  assume(h->FDeg == h->pFDeg());
553 
554  poly h_p;
555  int i,j,at,pass, ii;
556  unsigned long not_sev;
557  // long reddeg,d;
558 
559  pass = j = 0;
560  // d = reddeg = h->GetpFDeg();
561  h->SetShortExpVector();
562  int li;
563  h_p = h->GetLmTailRing();
564  not_sev = ~ h->sev;
565  loop
566  {
567  j = kFindDivisibleByInT(strat, h);
568  if (j < 0) return 1;
569 
570  li = strat->T[j].pLength;
571  if (li<=0) li=strat->T[j].GetpLength();
572  ii = j;
573  /*
574  * the polynomial to reduce with (up to the moment) is;
575  * pi with length li
576  */
577  i = j;
578 #if 1
579  if (TEST_OPT_LENGTH)
580  loop
581  {
582  /*- search the shortest possible with respect to length -*/
583  i++;
584  if (i > strat->tl)
585  break;
586  if (li==1)
587  break;
588  if ((strat->T[i].pLength < li)
589  &&
590  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
591  h_p, not_sev, strat->tailRing))
592  {
593  /*
594  * the polynomial to reduce with is now;
595  */
596  li = strat->T[i].pLength;
597  if (li<=0) li=strat->T[i].GetpLength();
598  ii = i;
599  }
600  }
601 #endif
602 
603  /*
604  * end of search: have to reduce with pi
605  */
606 #ifdef KDEBUG
607  if (TEST_OPT_DEBUG)
608  {
609  PrintS("red:");
610  h->wrp();
611  PrintS(" with ");
612  strat->T[ii].wrp();
613  }
614 #endif
615  assume(strat->fromT == FALSE);
616 
617  ksReducePoly(h, &(strat->T[ii]), NULL, NULL, strat);
618 #if SBA_PRINT_REDUCTION_STEPS
619  sba_interreduction_steps++;
620 #endif
621 #if SBA_PRINT_OPERATIONS
622  sba_interreduction_operations += pLength(strat->T[ii].p);
623 #endif
624 
625 #ifdef KDEBUG
626  if (TEST_OPT_DEBUG)
627  {
628  PrintS("\nto ");
629  h->wrp();
630  PrintLn();
631  }
632 #endif
633 
634  h_p = h->GetLmTailRing();
635  if (h_p == NULL)
636  {
637  if (h->lcm!=NULL) pLmFree(h->lcm);
638 #ifdef KDEBUG
639  h->lcm=NULL;
640 #endif
641  return 0;
642  }
643  h->SetShortExpVector();
644  not_sev = ~ h->sev;
645  /*
646  * try to reduce the s-polynomial h
647  *test first whether h should go to the lazyset L
648  *-if the degree jumps
649  *-if the number of pre-defined reductions jumps
650  */
651  pass++;
652  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
653  {
654  h->SetLmCurrRing();
655  at = strat->posInL(strat->L,strat->Ll,h,strat);
656  if (at <= strat->Ll)
657  {
658  int dummy=strat->sl;
659  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
660  return 1;
661  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
662 #ifdef KDEBUG
663  if (TEST_OPT_DEBUG)
664  Print(" lazy: -> L%d\n",at);
665 #endif
666  h->Clear();
667  return -1;
668  }
669  }
670  }
671 }

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 1402 of file kstd2.cc.

1403 {
1404  if (strat->tl<0) return 1;
1405  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1406  assume(h->FDeg == h->pFDeg());
1407  poly h_p;
1408  int i,j,at,pass,ei, ii, h_d;
1409  unsigned long not_sev;
1410  long reddeg,d;
1411 
1412  pass = j = 0;
1413  d = reddeg = h->GetpFDeg() + h->ecart;
1414  h->SetShortExpVector();
1415  int li;
1416  h_p = h->GetLmTailRing();
1417  not_sev = ~ h->sev;
1418 
1419  h->PrepareRed(strat->use_buckets);
1420  loop
1421  {
1422  j=kFindDivisibleByInT(strat, h);
1423  if (j < 0) return 1;
1424 
1425  ei = strat->T[j].ecart;
1426  li = strat->T[j].pLength;
1427  if (li<=0) li=strat->T[j].GetpLength();
1428  ii = j;
1429  /*
1430  * the polynomial to reduce with (up to the moment) is;
1431  * pi with ecart ei (T[ii])
1432  */
1433  i = j;
1434  if (TEST_OPT_LENGTH)
1435  loop
1436  {
1437  /*- takes the first possible with respect to ecart -*/
1438  i++;
1439  if (i > strat->tl)
1440  break;
1441  //if (ei < h->ecart)
1442  // break;
1443  if (li==1)
1444  break;
1445  if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
1446  || ((strat->T[i].ecart <= h->ecart) && (strat->T[i].pLength < li)))
1447  &&
1448  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1449  h_p, not_sev, strat->tailRing))
1450  {
1451  /*
1452  * the polynomial to reduce with is now;
1453  */
1454  ei = strat->T[i].ecart;
1455  li = strat->T[i].pLength;
1456  if (li<=0) li=strat->T[i].GetpLength();
1457  ii = i;
1458  }
1459  }
1460 
1461  /*
1462  * end of search: have to reduce with pi
1463  */
1464  if (!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart))
1465  {
1466  h->GetTP(); // clears bucket
1467  h->SetLmCurrRing();
1468  /*
1469  * It is not possible to reduce h with smaller ecart;
1470  * if possible h goes to the lazy-set L,i.e
1471  * if its position in L would be not the last one
1472  */
1473  if (strat->Ll >= 0) /* L is not empty */
1474  {
1475  at = strat->posInL(strat->L,strat->Ll,h,strat);
1476  if(at <= strat->Ll)
1477  /*- h will not become the next element to reduce -*/
1478  {
1479  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1480 #ifdef KDEBUG
1481  if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
1482 #endif
1483  h->Clear();
1484  return -1;
1485  }
1486  }
1487  }
1488 #ifdef KDEBUG
1489  if (TEST_OPT_DEBUG)
1490  {
1491  PrintS("red:");
1492  h->wrp();
1493  Print("\nwith T[%d]:",ii);
1494  strat->T[ii].wrp();
1495  }
1496 #endif
1497  assume(strat->fromT == FALSE);
1498 
1499  ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,strat);
1500 #if SBA_PRINT_REDUCTION_STEPS
1501  sba_interreduction_steps++;
1502 #endif
1503 #if SBA_PRINT_OPERATIONS
1504  sba_interreduction_operations += pLength(strat->T[ii].p);
1505 #endif
1506 #ifdef KDEBUG
1507  if (TEST_OPT_DEBUG)
1508  {
1509  PrintS("\nto:");
1510  h->wrp();
1511  PrintLn();
1512  }
1513 #endif
1514  if(h->IsNull())
1515  {
1516  h->Clear();
1517  if (h->lcm!=NULL) pLmFree(h->lcm);
1518  #ifdef KDEBUG
1519  h->lcm=NULL;
1520  #endif
1521  return 0;
1522  }
1523  if (TEST_OPT_IDLIFT)
1524  {
1525  if (h->p!=NULL)
1526  {
1527  if(p_GetComp(h->p,currRing)>strat->syzComp)
1528  {
1529  h->Delete();
1530  return 0;
1531  }
1532  }
1533  else if (h->t_p!=NULL)
1534  {
1535  if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1536  {
1537  h->Delete();
1538  return 0;
1539  }
1540  }
1541  }
1542  h->SetShortExpVector();
1543  not_sev = ~ h->sev;
1544  h_d = h->SetpFDeg();
1545  /* compute the ecart */
1546  if (ei <= h->ecart)
1547  h->ecart = d-h_d;
1548  else
1549  h->ecart = d-h_d+ei-h->ecart;
1550 
1551  /*
1552  * try to reduce the s-polynomial h
1553  *test first whether h should go to the lazyset L
1554  *-if the degree jumps
1555  *-if the number of pre-defined reductions jumps
1556  */
1557  pass++;
1558  d = h_d + h->ecart;
1559  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1560  {
1561  h->GetTP(); // clear bucket
1562  h->SetLmCurrRing();
1563  at = strat->posInL(strat->L,strat->Ll,h,strat);
1564  if (at <= strat->Ll)
1565  {
1566  int dummy=strat->sl;
1567  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1568  return 1;
1569  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1570 #ifdef KDEBUG
1571  if (TEST_OPT_DEBUG)
1572  Print(" degree jumped: -> L%d\n",at);
1573 #endif
1574  h->Clear();
1575  return -1;
1576  }
1577  }
1578  else if (d > reddeg)
1579  {
1580  if (d>=(long)strat->tailRing->bitmask)
1581  {
1582  if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask)
1583  {
1584  strat->overflow=TRUE;
1585  //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1586  h->GetP();
1587  at = strat->posInL(strat->L,strat->Ll,h,strat);
1588  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1589  h->Clear();
1590  return -1;
1591  }
1592  }
1593  else if (TEST_OPT_PROT && (strat->Ll < 0) )
1594  {
1595  //h->wrp(); Print("<%d>\n",h->GetpLength());
1596  reddeg = d;
1597  Print(".%ld",d); mflush();
1598  }
1599  }
1600  }
1601 }

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1254 of file kstd2.cc.

1255 {
1256  if (strat->tl<0) return 1;
1257  int at,i,ii,li;
1258  int j = 0;
1259  int pass = 0;
1260  assume(h->pFDeg() == h->FDeg);
1261  long reddeg = h->GetpFDeg();
1262  long d;
1263  unsigned long not_sev;
1264 
1265  h->SetShortExpVector();
1266  poly h_p = h->GetLmTailRing();
1267  not_sev = ~ h->sev;
1268  loop
1269  {
1270  j = kFindDivisibleByInT(strat, h);
1271  if (j < 0) return 1;
1272 
1273  li = strat->T[j].pLength;
1274  if (li<=0) li=strat->T[j].GetpLength();
1275  ii = j;
1276  /*
1277  * the polynomial to reduce with (up to the moment) is;
1278  * pi with length li
1279  */
1280 
1281  i = j;
1282 #if 1
1283  if (TEST_OPT_LENGTH)
1284  loop
1285  {
1286  /*- search the shortest possible with respect to length -*/
1287  i++;
1288  if (i > strat->tl)
1289  break;
1290  if (li==1)
1291  break;
1292  if ((strat->T[i].pLength < li)
1293  &&
1294  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1295  h_p, not_sev, strat->tailRing))
1296  {
1297  /*
1298  * the polynomial to reduce with is now;
1299  */
1300  li = strat->T[i].pLength;
1301  if (li<=0) li=strat->T[i].GetpLength();
1302  ii = i;
1303  }
1304  }
1305 #endif
1306 
1307  /*
1308  * end of search: have to reduce with pi
1309  */
1310 
1311 
1312 #ifdef KDEBUG
1313  if (TEST_OPT_DEBUG)
1314  {
1315  PrintS("red:");
1316  h->wrp();
1317  PrintS(" with ");
1318  strat->T[ii].wrp();
1319  }
1320 #endif
1321 
1322  ksReducePoly(h, &(strat->T[ii]), NULL, NULL, strat);
1323 #if SBA_PRINT_REDUCTION_STEPS
1324  sba_interreduction_steps++;
1325 #endif
1326 #if SBA_PRINT_OPERATIONS
1327  sba_interreduction_operations += pLength(strat->T[ii].p);
1328 #endif
1329 
1330 #ifdef KDEBUG
1331  if (TEST_OPT_DEBUG)
1332  {
1333  PrintS("\nto ");
1334  h->wrp();
1335  PrintLn();
1336  }
1337 #endif
1338 
1339  h_p=h->GetLmTailRing();
1340 
1341  if (h_p == NULL)
1342  {
1343  if (h->lcm!=NULL) pLmFree(h->lcm);
1344 #ifdef KDEBUG
1345  h->lcm=NULL;
1346 #endif
1347  return 0;
1348  }
1349  h->SetShortExpVector();
1350  not_sev = ~ h->sev;
1351  d = h->SetpFDeg();
1352  /*- try to reduce the s-polynomial -*/
1353  pass++;
1354  if (//!TEST_OPT_REDTHROUGH &&
1355  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1356  {
1357  h->SetLmCurrRing();
1358  at = strat->posInL(strat->L,strat->Ll,h,strat);
1359  if (at <= strat->Ll)
1360  {
1361 #if 1
1362  int dummy=strat->sl;
1363  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1364  return 1;
1365 #endif
1366 #ifdef KDEBUG
1367  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1368 #endif
1369  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1370  h->Clear();
1371  return -1;
1372  }
1373  }
1374  else if (d != reddeg)
1375  {
1376  if (d>=(long)strat->tailRing->bitmask)
1377  {
1378  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1379  {
1380  strat->overflow=TRUE;
1381  //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1382  h->GetP();
1383  at = strat->posInL(strat->L,strat->Ll,h,strat);
1384  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1385  h->Clear();
1386  return -1;
1387  }
1388  }
1389  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1390  {
1391  Print(".%ld",d);mflush();
1392  reddeg = d;
1393  }
1394  }
1395  }
1396 }

◆ redNF()

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

Definition at line 1607 of file kstd2.cc.

1608 {
1609 #define REDNF_CANONICALIZE 60
1610  if (h==NULL) return NULL;
1611  int j;
1612  int cnt=REDNF_CANONICALIZE;
1613  max_ind=strat->sl;
1614 
1615  if (0 > strat->sl)
1616  {
1617  return h;
1618  }
1619  LObject P(h);
1620  P.SetShortExpVector();
1621  P.bucket = kBucketCreate(currRing);
1622  kBucketInit(P.bucket,P.p,pLength(P.p));
1623  kbTest(P.bucket);
1624 #ifdef HAVE_RINGS
1625  BOOLEAN is_ring = rField_is_Ring(currRing);
1626 #endif
1627 #ifdef KDEBUG
1628 // if (TEST_OPT_DEBUG)
1629 // {
1630 // PrintS("redNF: starting S:\n");
1631 // for( j = 0; j <= max_ind; j++ )
1632 // {
1633 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
1634 // pWrite(strat->S[j]);
1635 // }
1636 // };
1637 #endif
1638 
1639  loop
1640  {
1641  j=kFindDivisibleByInS(strat,&max_ind,&P);
1642  if (j>=0)
1643  {
1644 #ifdef HAVE_RINGS
1645  if (!is_ring)
1646  {
1647 #endif
1648  int sl=pSize(strat->S[j]);
1649  int jj=j;
1650  loop
1651  {
1652  int sll;
1653  jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
1654  if (jj<0) break;
1655  sll=pSize(strat->S[jj]);
1656  if (sll<sl)
1657  {
1658  #ifdef KDEBUG
1659  if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
1660  #endif
1661  //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
1662  j=jj;
1663  sl=sll;
1664  }
1665  }
1666  if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
1667  {
1668  pNorm(strat->S[j]);
1669  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1670  }
1671 #ifdef HAVE_RINGS
1672  }
1673 #endif
1674  nNormalize(pGetCoeff(P.p));
1675 #ifdef KDEBUG
1676  if (TEST_OPT_DEBUG)
1677  {
1678  PrintS("red:");
1679  wrp(h);
1680  PrintS(" with ");
1681  wrp(strat->S[j]);
1682  }
1683 #endif
1684 #ifdef HAVE_PLURAL
1685  if (rIsPluralRing(currRing))
1686  {
1687  number coef;
1688  nc_kBucketPolyRed(P.bucket,strat->S[j],&coef);
1689  nDelete(&coef);
1690  }
1691  else
1692 #endif
1693  {
1694  number coef;
1695  coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
1696  nDelete(&coef);
1697  }
1698  cnt--;
1699  if (cnt==0)
1700  {
1701  kBucketCanonicalize(P.bucket);
1702  cnt=REDNF_CANONICALIZE;
1703  }
1704  h = kBucketGetLm(P.bucket); // FRAGE OLIVER
1705  if (h==NULL)
1706  {
1707  kBucketDestroy(&P.bucket);
1708 
1709 #ifdef KDEBUG
1710 // if (TEST_OPT_DEBUG)
1711 // {
1712 // PrintS("redNF: starting S:\n");
1713 // for( j = 0; j <= max_ind; j++ )
1714 // {
1715 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
1716 // pWrite(strat->S[j]);
1717 // }
1718 // };
1719 #endif
1720 
1721  return NULL;
1722  }
1723  kbTest(P.bucket);
1724  P.p=h;
1725  P.t_p=NULL;
1726  P.SetShortExpVector();
1727 #ifdef KDEBUG
1728  if (TEST_OPT_DEBUG)
1729  {
1730  PrintS("\nto:");
1731  wrp(h);
1732  PrintLn();
1733  }
1734 #endif
1735  }
1736  else
1737  {
1738  P.p=kBucketClear(P.bucket);
1739  kBucketDestroy(&P.bucket);
1740  pNormalize(P.p);
1741 
1742 #ifdef KDEBUG
1743 // if (TEST_OPT_DEBUG)
1744 // {
1745 // PrintS("redNF: starting S:\n");
1746 // for( j = 0; j <= max_ind; j++ )
1747 // {
1748 // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
1749 // pWrite(strat->S[j]);
1750 // }
1751 // };
1752 #endif
1753 
1754  return P.p;
1755  }
1756  }
1757 }

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

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

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 438 of file kstd2.cc.

439 {
440  if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors)
441  if (strat->tl<0) return 1;
442 
443  int at/*,i*/;
444  long d;
445  int j = 0;
446  int pass = 0;
447  // poly zeroPoly = NULL;
448 
449 // TODO warum SetpFDeg notwendig?
450  h->SetpFDeg();
451  assume(h->pFDeg() == h->FDeg);
452  long reddeg = h->GetpFDeg();
453 
454  h->SetShortExpVector();
455  loop
456  {
457  j = kFindDivisibleByInT(strat, h);
458  if (j < 0)
459  {
460  // over ZZ: cleanup coefficients by complete reduction with monomials
461  postReduceByMon(h, strat);
462  if(h->p == NULL)
463  {
464  if (h->lcm!=NULL) pLmDelete(h->lcm);
465  h->Clear();
466  return 0;
467  }
468  if(nIsZero(pGetCoeff(h->p))) return 2;
469  j = kFindDivisibleByInT(strat, h);
470  if(j < 0)
471  {
472  if(strat->tl >= 0)
473  h->i_r1 = strat->tl;
474  else
475  h->i_r1 = -1;
476  if (h->GetLmTailRing() == NULL)
477  {
478  if (h->lcm!=NULL) pLmDelete(h->lcm);
479  h->Clear();
480  return 0;
481  }
482  return 1;
483  }
484  }
485  //printf("\nFound one: ");pWrite(strat->T[j].p);
486  //enterT(*h, strat);
487  ksReducePoly(h, &(strat->T[j]), NULL, NULL, strat); // with debug output
488  //printf("\nAfter small red: ");pWrite(h->p);
489  if (h->GetLmTailRing() == NULL)
490  {
491  if (h->lcm!=NULL) pLmDelete(h->lcm);
492 #ifdef KDEBUG
493  h->lcm=NULL;
494 #endif
495  h->Clear();
496  return 0;
497  }
498  h->SetShortExpVector();
499  d = h->SetpFDeg();
500  /*- try to reduce the s-polynomial -*/
501  pass++;
502  if (!TEST_OPT_REDTHROUGH &&
503  (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
504  {
505  h->SetLmCurrRing();
506  if (strat->posInLDependsOnLength)
507  h->SetLength(strat->length_pLength);
508  at = strat->posInL(strat->L,strat->Ll,h,strat);
509  if (at <= strat->Ll)
510  {
511 #ifdef KDEBUG
512  if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
513 #endif
514  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
515  h->Clear();
516  return -1;
517  }
518  }
519  if (d != reddeg)
520  {
521  if (d >= (long)strat->tailRing->bitmask)
522  {
523  if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
524  {
525  strat->overflow=TRUE;
526  //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
527  h->GetP();
528  at = strat->posInL(strat->L,strat->Ll,h,strat);
529  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
530  h->Clear();
531  return -1;
532  }
533  }
534  else if ((TEST_OPT_PROT) && (strat->Ll < 0))
535  {
536  Print(".%ld",d);mflush();
537  reddeg = d;
538  }
539  }
540  }
541 }

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 711 of file kstd2.cc.

712 {
713  if (strat->tl<0) return 1;
714  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
715  //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
716  assume(h->FDeg == h->pFDeg());
717 //#if 1
718 #ifdef DEBUGF5
719  PrintS("------- IN REDSIG -------\n");
720  Print("p: ");
721  pWrite(pHead(h->p));
722  PrintS("p1: ");
723  pWrite(pHead(h->p1));
724  PrintS("p2: ");
725  pWrite(pHead(h->p2));
726  PrintS("---------------------------\n");
727 #endif
728  poly h_p;
729  int i,j,at,pass, ii;
730  int start=0;
731  int sigSafe;
732  unsigned long not_sev;
733  // long reddeg,d;
734 
735  pass = j = 0;
736  // d = reddeg = h->GetpFDeg();
737  h->SetShortExpVector();
738  int li;
739  h_p = h->GetLmTailRing();
740  not_sev = ~ h->sev;
741  loop
742  {
743  j = kFindDivisibleByInT(strat, h, start);
744  if (j < 0)
745  {
746  return 1;
747  }
748 
749  li = strat->T[j].pLength;
750  if (li<=0) li=strat->T[j].GetpLength();
751  ii = j;
752  /*
753  * the polynomial to reduce with (up to the moment) is;
754  * pi with length li
755  */
756  i = j;
757 #if 1
758  if (TEST_OPT_LENGTH)
759  loop
760  {
761  /*- search the shortest possible with respect to length -*/
762  i++;
763  if (i > strat->tl)
764  break;
765  if (li==1)
766  break;
767  if ((strat->T[i].pLength < li)
768  &&
769  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
770  h_p, not_sev, strat->tailRing))
771  {
772  /*
773  * the polynomial to reduce with is now;
774  */
775  li = strat->T[i].pLength;
776  if (li<=0) li=strat->T[i].GetpLength();
777  ii = i;
778  }
779  }
780  start = ii+1;
781 #endif
782 
783  /*
784  * end of search: have to reduce with pi
785  */
786 #ifdef KDEBUG
787  if (TEST_OPT_DEBUG)
788  {
789  PrintS("red:");
790  h->wrp();
791  PrintS(" with ");
792  strat->T[ii].wrp();
793  }
794 #endif
795  assume(strat->fromT == FALSE);
796 //#if 1
797 #ifdef DEBUGF5
798  Print("BEFORE REDUCTION WITH %d:\n",ii);
799  PrintS("--------------------------------\n");
800  pWrite(h->sig);
801  pWrite(strat->T[ii].sig);
802  pWrite(h->GetLmCurrRing());
803  pWrite(pHead(h->p1));
804  pWrite(pHead(h->p2));
805  pWrite(pHead(strat->T[ii].p));
806  PrintS("--------------------------------\n");
807  printf("INDEX OF REDUCER T: %d\n",ii);
808 #endif
809  sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
810 #if SBA_PRINT_REDUCTION_STEPS
811  if (sigSafe != 3)
812  sba_reduction_steps++;
813 #endif
814 #if SBA_PRINT_OPERATIONS
815  if (sigSafe != 3)
816  sba_operations += pLength(strat->T[ii].p);
817 #endif
818  // if reduction has taken place, i.e. the reduction was sig-safe
819  // otherwise start is already at the next position and the loop
820  // searching reducers in T goes on from index start
821 //#if 1
822 #ifdef DEBUGF5
823  Print("SigSAFE: %d\n",sigSafe);
824 #endif
825  if (sigSafe != 3)
826  {
827  // start the next search for reducers in T from the beginning
828  start = 0;
829 #ifdef KDEBUG
830  if (TEST_OPT_DEBUG)
831  {
832  PrintS("\nto ");
833  h->wrp();
834  PrintLn();
835  }
836 #endif
837 
838  h_p = h->GetLmTailRing();
839  if (h_p == NULL)
840  {
841  if (h->lcm!=NULL) pLmFree(h->lcm);
842 #ifdef KDEBUG
843  h->lcm=NULL;
844 #endif
845  return 0;
846  }
847  h->SetShortExpVector();
848  not_sev = ~ h->sev;
849  /*
850  * try to reduce the s-polynomial h
851  *test first whether h should go to the lazyset L
852  *-if the degree jumps
853  *-if the number of pre-defined reductions jumps
854  */
855  pass++;
856  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
857  {
858  h->SetLmCurrRing();
859  at = strat->posInL(strat->L,strat->Ll,h,strat);
860  if (at <= strat->Ll)
861  {
862  int dummy=strat->sl;
863  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
864  {
865  return 1;
866  }
867  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
868 #ifdef KDEBUG
869  if (TEST_OPT_DEBUG)
870  Print(" lazy: -> L%d\n",at);
871 #endif
872  h->Clear();
873  return -1;
874  }
875  }
876  }
877  }
878 }

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 881 of file kstd2.cc.

882 {
883  //Since reduce is really bad for SBA we use the following idea:
884  // We first check if we can build a gcd pair between h and S
885  //where the sig remains the same and replace h by this gcd poly
887  #if GCD_SBA
888  while(sbaCheckGcdPair(h,strat))
889  {
890  h->sev = pGetShortExpVector(h->p);
891  }
892  #endif
893  poly beforeredsig;
894  beforeredsig = pCopy(h->sig);
895 
896  if (strat->tl<0) return 1;
897  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
898  //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
899  assume(h->FDeg == h->pFDeg());
900 //#if 1
901 #ifdef DEBUGF5
902  Print("------- IN REDSIG -------\n");
903  Print("p: ");
904  pWrite(pHead(h->p));
905  Print("p1: ");
906  pWrite(pHead(h->p1));
907  Print("p2: ");
908  pWrite(pHead(h->p2));
909  Print("---------------------------\n");
910 #endif
911  poly h_p;
912  int i,j,at,pass, ii;
913  int start=0;
914  int sigSafe;
915  unsigned long not_sev;
916  // long reddeg,d;
917 
918  pass = j = 0;
919  // d = reddeg = h->GetpFDeg();
920  h->SetShortExpVector();
921  int li;
922  h_p = h->GetLmTailRing();
923  not_sev = ~ h->sev;
924  loop
925  {
926  j = kFindDivisibleByInT(strat, h, start);
927  if (j < 0)
928  {
929  #if GCD_SBA
930  while(sbaCheckGcdPair(h,strat))
931  {
932  h->sev = pGetShortExpVector(h->p);
933  h->is_redundant = FALSE;
934  start = 0;
935  }
936  #endif
937  // over ZZ: cleanup coefficients by complete reduction with monomials
938  postReduceByMonSig(h, strat);
939  if(h->p == NULL || nIsZero(pGetCoeff(h->p))) return 2;
940  j = kFindDivisibleByInT(strat, h,start);
941  if(j < 0)
942  {
943  if(strat->tl >= 0)
944  h->i_r1 = strat->tl;
945  else
946  h->i_r1 = -1;
947  if (h->GetLmTailRing() == NULL)
948  {
949  if (h->lcm!=NULL) pLmDelete(h->lcm);
950  h->Clear();
951  return 0;
952  }
953  //Check for sigdrop after reduction
954  if(pLtCmp(beforeredsig,h->sig) == 1)
955  {
956  strat->sigdrop = TRUE;
957  //Reduce it as much as you can
958  int red_result = redRing(h,strat);
959  if(red_result == 0)
960  {
961  //It reduced to 0, cancel the sigdrop
962  strat->sigdrop = FALSE;
963  p_Delete(&h->sig,currRing);h->sig = NULL;
964  return 0;
965  }
966  else
967  {
968  //strat->enterS(*h, strat->sl+1, strat, strat->tl);
969  return 0;
970  }
971  }
972  p_Delete(&beforeredsig,currRing);
973  return 1;
974  }
975  }
976 
977  li = strat->T[j].pLength;
978  if (li<=0) li=strat->T[j].GetpLength();
979  ii = j;
980  /*
981  * the polynomial to reduce with (up to the moment) is;
982  * pi with length li
983  */
984  i = j;
985  if (TEST_OPT_LENGTH)
986  loop
987  {
988  /*- search the shortest possible with respect to length -*/
989  i++;
990  if (i > strat->tl)
991  break;
992  if (li==1)
993  break;
994  if ((strat->T[i].pLength < li)
995  && n_DivBy(pGetCoeff(h_p),pGetCoeff(strat->T[i].p),currRing->cf)
996  && p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
997  h_p, not_sev, strat->tailRing))
998  {
999  /*
1000  * the polynomial to reduce with is now;
1001  */
1002  li = strat->T[i].pLength;
1003  if (li<=0) li=strat->T[i].GetpLength();
1004  ii = i;
1005  }
1006  }
1007 
1008  start = ii+1;
1009 
1010  /*
1011  * end of search: have to reduce with pi
1012  */
1013 #ifdef KDEBUG
1014  if (TEST_OPT_DEBUG)
1015  {
1016  PrintS("red:");
1017  h->wrp();
1018  PrintS(" with ");
1019  strat->T[ii].wrp();
1020  }
1021 #endif
1022  assume(strat->fromT == FALSE);
1023 //#if 1
1024 #ifdef DEBUGF5
1025  Print("BEFORE REDUCTION WITH %d:\n",ii);
1026  Print("--------------------------------\n");
1027  pWrite(h->sig);
1028  pWrite(strat->T[ii].sig);
1029  pWrite(h->GetLmCurrRing());
1030  pWrite(pHead(h->p1));
1031  pWrite(pHead(h->p2));
1032  pWrite(pHead(strat->T[ii].p));
1033  Print("--------------------------------\n");
1034  printf("INDEX OF REDUCER T: %d\n",ii);
1035 #endif
1036  sigSafe = ksReducePolySigRing(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1037  if(h->p == NULL && h->sig == NULL)
1038  {
1039  //Trivial case catch
1040  strat->sigdrop = FALSE;
1041  }
1042  #if 0
1043  //If the reducer has the same lt (+ or -) as the other one, reduce it via redRing
1044  //In some cases this proves to be very bad
1045  if(rField_is_Ring(currRing) && h->p != NULL && pLmCmp(h->p,strat->T[ii].p)==0)
1046  {
1047  int red_result = redRing(h,strat);
1048  if(red_result == 0)
1049  {
1050  pDelete(&h->sig);h->sig = NULL;
1051  return 0;
1052  }
1053  else
1054  {
1055  strat->sigdrop = TRUE;
1056  return 1;
1057  }
1058  }
1059  #endif
1060  if(strat->sigdrop)
1061  return 1;
1062 #if SBA_PRINT_REDUCTION_STEPS
1063  if (sigSafe != 3)
1064  sba_reduction_steps++;
1065 #endif
1066 #if SBA_PRINT_OPERATIONS
1067  if (sigSafe != 3)
1068  sba_operations += pLength(strat->T[ii].p);
1069 #endif
1070  // if reduction has taken place, i.e. the reduction was sig-safe
1071  // otherwise start is already at the next position and the loop
1072  // searching reducers in T goes on from index start
1073 //#if 1
1074 #ifdef DEBUGF5
1075  Print("SigSAFE: %d\n",sigSafe);
1076 #endif
1077  if (sigSafe != 3)
1078  {
1079  // start the next search for reducers in T from the beginning
1080  start = 0;
1081 #ifdef KDEBUG
1082  if (TEST_OPT_DEBUG)
1083  {
1084  PrintS("\nto ");
1085  h->wrp();
1086  PrintLn();
1087  }
1088 #endif
1089 
1090  h_p = h->GetLmTailRing();
1091  if (h_p == NULL)
1092  {
1093  if (h->lcm!=NULL) pLmFree(h->lcm);
1094 #ifdef KDEBUG
1095  h->lcm=NULL;
1096 #endif
1097  return 0;
1098  }
1099  h->SetShortExpVector();
1100  not_sev = ~ h->sev;
1101  /*
1102  * try to reduce the s-polynomial h
1103  *test first whether h should go to the lazyset L
1104  *-if the degree jumps
1105  *-if the number of pre-defined reductions jumps
1106  */
1107  pass++;
1108  if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1109  {
1110  h->SetLmCurrRing();
1111  at = strat->posInL(strat->L,strat->Ll,h,strat);
1112  if (at <= strat->Ll)
1113  {
1114  int dummy=strat->sl;
1115  if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1116  {
1117  return 1;
1118  }
1119  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1120 #ifdef KDEBUG
1121  if (TEST_OPT_DEBUG)
1122  Print(" lazy: -> L%d\n",at);
1123 #endif
1124  h->Clear();
1125  return -1;
1126  }
1127  }
1128  }
1129  }
1130 }

◆ redtail() [1/2]

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

Definition at line 7303 of file kutil.cc.

7306 {
7307  poly h, hn;
7308  strat->redTailChange=FALSE;
7309 
7310  L->GetP();
7311  poly p = L->p;
7312  if (strat->noTailReduction || pNext(p) == NULL)
7313  return p;
7314 
7315  LObject Ln(strat->tailRing);
7316  TObject* With;
7317  // placeholder in case strat->tl < 0
7318  TObject With_s(strat->tailRing);
7319  h = p;
7320  hn = pNext(h);
7321  long op = strat->tailRing->pFDeg(hn, strat->tailRing);
7322  long e;
7323  int l;
7324  BOOLEAN save_HE=strat->kHEdgeFound;
7325  strat->kHEdgeFound |=
7326  ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
7327 
7328  while(hn != NULL)
7329  {
7330  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7331  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7332  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7333  loop
7334  {
7335  Ln.Set(hn, strat->tailRing);
7336  Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
7337  if (strat->kHEdgeFound)
7338  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7339  else
7340  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
7341  if (With == NULL) break;
7342  With->length=0;
7343  With->pLength=0;
7344  strat->redTailChange=TRUE;
7345  if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
7346  {
7347  // reducing the tail would violate the exp bound
7348  if (kStratChangeTailRing(strat, L))
7349  {
7350  strat->kHEdgeFound = save_HE;
7351  return redtail(L, end_pos, strat);
7352  }
7353  else
7354  return NULL;
7355  }
7356  hn = pNext(h);
7357  if (hn == NULL) goto all_done;
7358  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7359  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7360  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7361  }
7362  h = hn;
7363  hn = pNext(h);
7364  }
7365 
7366  all_done:
7367  if (strat->redTailChange)
7368  {
7369  L->pLength = 0;
7370  }
7371  strat->kHEdgeFound = save_HE;

◆ redtail() [2/2]

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

Definition at line 7373 of file kutil.cc.

7376 {
7377  LObject L(p, currRing);

◆ redtailBba() [1/3]

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

Definition at line 7379 of file kutil.cc.

7382 {
7383 #define REDTAIL_CANONICALIZE 100
7384  strat->redTailChange=FALSE;
7385  if (strat->noTailReduction) return L->GetLmCurrRing();
7386  poly h, p;
7387  p = h = L->GetLmTailRing();
7388  if ((h==NULL) || (pNext(h)==NULL))
7389  return L->GetLmCurrRing();
7390 
7391  TObject* With;
7392  // placeholder in case strat->tl < 0
7393  TObject With_s(strat->tailRing);
7394 
7395  LObject Ln(pNext(h), strat->tailRing);
7396  Ln.GetpLength();
7397 
7398  pNext(h) = NULL;
7399  if (L->p != NULL)
7400  {
7401  pNext(L->p) = NULL;
7402  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7403  }
7404  L->pLength = 1;
7405 
7406  Ln.PrepareRed(strat->use_buckets);
7407 
7408  int cnt=REDTAIL_CANONICALIZE;
7409  while(!Ln.IsNull())
7410  {
7411  loop
7412  {
7413  if (TEST_OPT_IDLIFT)
7414  {
7415  if (Ln.p!=NULL)
7416  {
7417  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7418  }
7419  else
7420  {
7421  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7422  }
7423  }
7424  Ln.SetShortExpVector();
7425  if (withT)
7426  {
7427  int j;
7428  j = kFindDivisibleByInT(strat, &Ln);
7429  if (j < 0) break;
7430  With = &(strat->T[j]);
7431  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7432  }
7433  else
7434  {
7435  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7436  if (With == NULL) break;
7437  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7438  }
7439  cnt--;
7440  if (cnt==0)
7441  {
7443  /*poly tmp=*/Ln.CanonicalizeP();
7444  if (normalize)
7445  {
7446  Ln.Normalize();
7447  //pNormalize(tmp);
7448  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7449  }
7450  }
7451  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7452  {
7453  With->pNorm();
7454  }
7455  strat->redTailChange=TRUE;
7456  if (ksReducePolyTail(L, With, &Ln))
7457  {
7458  // reducing the tail would violate the exp bound
7459  // set a flag and hope for a retry (in bba)
7460  strat->completeReduce_retry=TRUE;
7461  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7462  do
7463  {
7464  pNext(h) = Ln.LmExtractAndIter();
7465  pIter(h);
7466  L->pLength++;
7467  } while (!Ln.IsNull());
7468  goto all_done;
7469  }
7470  if (Ln.IsNull()) goto all_done;
7471  if (! withT) With_s.Init(currRing);
7472  }
7473  pNext(h) = Ln.LmExtractAndIter();
7474  pIter(h);
7475  pNormalize(h);
7476  L->pLength++;
7477  }
7478 
7479  all_done:
7480  Ln.Delete();
7481  if (L->p != NULL) pNext(L->p) = pNext(p);
7482 
7483  if (strat->redTailChange)
7484  {
7485  L->length = 0;
7486  L->pLength = 0;
7487  }
7488 
7489  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7490  //L->Normalize(); // HANNES: should have a test
7491  kTest_L(L);

◆ redtailBba() [2/3]

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

Definition at line 1087 of file kInline.h.

1088 {
1089  LObject L(q, currRing, r);
1090  TObject T(p1, currRing, r);
1091 

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

7613 {
7614  strat->redTailChange=FALSE;
7615  if (strat->noTailReduction) return L->GetLmCurrRing();
7616  poly h, p;
7617  p = h = L->GetLmTailRing();
7618  if ((h==NULL) || (pNext(h)==NULL))
7619  return L->GetLmCurrRing();
7620 
7621  TObject* With;
7622  // placeholder in case strat->tl < 0
7623  TObject With_s(strat->tailRing);
7624 
7625  LObject Ln(pNext(h), strat->tailRing);
7626  Ln.pLength = L->GetpLength() - 1;
7627 
7628  pNext(h) = NULL;
7629  if (L->p != NULL) pNext(L->p) = NULL;
7630  L->pLength = 1;
7631 
7632  Ln.PrepareRed(strat->use_buckets);
7633 
7634  int cnt=REDTAIL_CANONICALIZE;
7635  while(!Ln.IsNull())
7636  {
7637  loop
7638  {
7639  Ln.SetShortExpVector();
7640  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7641  if (With == NULL) break;
7642  cnt--;
7643  if (cnt==0)
7644  {
7646  /*poly tmp=*/Ln.CanonicalizeP();
7647  }
7648  // we are in Z, do not call pNorm
7649  strat->redTailChange=TRUE;
7650  // test divisibility of coefs:
7651  poly p_Ln=Ln.GetLmCurrRing();
7652  poly p_With=With->GetLmCurrRing();
7653  number z=n_IntMod(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf);
7654  if (!nIsZero(z))
7655  {
7656  // subtract z*Ln, add z.Ln to L
7657  poly m=pHead(p_Ln);
7658  pSetCoeff(m,z);
7659  poly mm=pHead(m);
7660  pNext(h) = m;
7661  pIter(h);
7662  L->pLength++;
7663  mm=pNeg(mm);
7664  if (Ln.bucket!=NULL)
7665  {
7666  int dummy=1;
7667  kBucket_Add_q(Ln.bucket,mm,&dummy);
7668  }
7669  else
7670  {
7671  if ((Ln.t_p!=NULL)&&(Ln.p==NULL))
7672  Ln.GetP();
7673  if (Ln.p!=NULL)
7674  {
7675  Ln.p=pAdd(Ln.p,mm);
7676  if (Ln.t_p!=NULL)
7677  {
7678  pNext(Ln.t_p)=NULL;
7679  p_LmDelete(Ln.t_p,strat->tailRing);
7680  }
7681  }
7682  }
7683  }
7684  else
7685  nDelete(&z);
7686 
7687  if (ksReducePolyTail(L, With, &Ln))
7688  {
7689  // reducing the tail would violate the exp bound
7690  // set a flag and hope for a retry (in bba)
7691  strat->completeReduce_retry=TRUE;
7692  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7693  do
7694  {
7695  pNext(h) = Ln.LmExtractAndIter();
7696  pIter(h);
7697  L->pLength++;
7698  } while (!Ln.IsNull());
7699  goto all_done;
7700  }
7701  if (Ln.IsNull()) goto all_done;
7702  With_s.Init(currRing);
7703  }
7704  pNext(h) = Ln.LmExtractAndIter();
7705  pIter(h);
7706  pNormalize(h);
7707  L->pLength++;
7708  }
7709 
7710  all_done:
7711  Ln.Delete();
7712  if (L->p != NULL) pNext(L->p) = pNext(p);
7713 
7714  if (strat->redTailChange)
7715  {
7716  L->length = 0;
7717  }
7718 
7719  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7720  //L->Normalize(); // HANNES: should have a test
7721  kTest_L(L);

◆ redtailBba_Z() [2/2]

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

Definition at line 1100 of file kInline.h.

1102 {
1103  LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1104  return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);

◆ redtailBbaBound() [1/2]

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

Definition at line 7493 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

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

Definition at line 1093 of file kInline.h.

1096 {
1097  LObject L(p);

◆ redtailBbaShift()

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

Definition at line 12520 of file kutil.cc.

12530 {
12531  /* for the shift case need to run it with withT = TRUE */
12532  strat->redTailChange=FALSE;
12533  if (strat->noTailReduction) return L->GetLmCurrRing();
12534  poly h, p;
12535  p = h = L->GetLmTailRing();
12536  if ((h==NULL) || (pNext(h)==NULL))
12537  return L->GetLmCurrRing();
12538 
12539  TObject* With;
12540  // placeholder in case strat->tl < 0
12541  TObject With_s(strat->tailRing);
12542 
12543  LObject Ln(pNext(h), strat->tailRing);
12544  Ln.pLength = L->GetpLength() - 1;
12545 
12546  pNext(h) = NULL;
12547  if (L->p != NULL) pNext(L->p) = NULL;
12548  L->pLength = 1;
12549 
12550  Ln.PrepareRed(strat->use_buckets);
12551 
12552  while(!Ln.IsNull())
12553  {
12554  loop
12555  {
12556  Ln.SetShortExpVector();
12557  if (withT)
12558  {
12559  int j;
12560  j = kFindDivisibleByInT(strat, &Ln);
12561  if (j < 0) break;
12562  With = &(strat->T[j]);
12563  }
12564  else
12565  {
12566  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
12567  if (With == NULL) break;
12568  }
12569  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
12570  {
12571  With->pNorm();
12572  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
12573  }
12574  strat->redTailChange=TRUE;
12575  if (ksReducePolyTail(L, With, &Ln))
12576  {
12577  // reducing the tail would violate the exp bound
12578  // set a flag and hope for a retry (in bba)
12579  strat->completeReduce_retry=TRUE;
12580  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
12581  do
12582  {
12583  pNext(h) = Ln.LmExtractAndIter();
12584  pIter(h);
12585  L->pLength++;
12586  } while (!Ln.IsNull());
12587  goto all_done;
12588  }
12589  if (Ln.IsNull()) goto all_done;
12590  if (! withT) With_s.Init(currRing);
12591  }
12592  pNext(h) = Ln.LmExtractAndIter();
12593  pIter(h);
12594  L->pLength++;
12595  }
12596 
12597  all_done:
12598  Ln.Delete();
12599  if (L->p != NULL) pNext(L->p) = pNext(p);

◆ redtailSba()

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

Definition at line 1133 of file kstd2.cc.

1134 {
1135 #define REDTAIL_CANONICALIZE 100
1136  strat->redTailChange=FALSE;
1137  if (strat->noTailReduction) return L->GetLmCurrRing();
1138  poly h, p;
1139  p = h = L->GetLmTailRing();
1140  if ((h==NULL) || (pNext(h)==NULL))
1141  return L->GetLmCurrRing();
1142 
1143  TObject* With;
1144  // placeholder in case strat->tl < 0
1145  TObject With_s(strat->tailRing);
1146 
1147  LObject Ln(pNext(h), strat->tailRing);
1148  Ln.sig = L->sig;
1149  Ln.sevSig = L->sevSig;
1150  Ln.pLength = L->GetpLength() - 1;
1151 
1152  pNext(h) = NULL;
1153  if (L->p != NULL) pNext(L->p) = NULL;
1154  L->pLength = 1;
1155 
1156  Ln.PrepareRed(strat->use_buckets);
1157 
1158  int cnt=REDTAIL_CANONICALIZE;
1159  while(!Ln.IsNull())
1160  {
1161  loop
1162  {
1163  if(rField_is_Ring(currRing) && strat->sigdrop)
1164  break;
1165  Ln.SetShortExpVector();
1166  if (withT)
1167  {
1168  int j;
1169  j = kFindDivisibleByInT(strat, &Ln);
1170  if (j < 0) break;
1171  With = &(strat->T[j]);
1172  }
1173  else
1174  {
1175  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1176  if (With == NULL) break;
1177  }
1178  cnt--;
1179  if (cnt==0)
1180  {
1182  /*poly tmp=*/Ln.CanonicalizeP();
1184  {
1185  Ln.Normalize();
1186  //pNormalize(tmp);
1187  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1188  }
1189  }
1190  if (normalize && (!TEST_OPT_INTSTRATEGY) && !rField_is_Ring(currRing) && (!nIsOne(pGetCoeff(With->p))))
1191  {
1192  With->pNorm();
1193  }
1194  strat->redTailChange=TRUE;
1195  int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1197  L->sig = Ln.sig;
1198  //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1199  // I delete it an then set Ln.sig. Hence L->sig is lost
1200 #if SBA_PRINT_REDUCTION_STEPS
1201  if (ret != 3)
1202  sba_reduction_steps++;
1203 #endif
1204 #if SBA_PRINT_OPERATIONS
1205  if (ret != 3)
1206  sba_operations += pLength(With->p);
1207 #endif
1208  if (ret)
1209  {
1210  // reducing the tail would violate the exp bound
1211  // set a flag and hope for a retry (in bba)
1212  strat->completeReduce_retry=TRUE;
1213  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1214  do
1215  {
1216  pNext(h) = Ln.LmExtractAndIter();
1217  pIter(h);
1218  L->pLength++;
1219  } while (!Ln.IsNull());
1220  goto all_done;
1221  }
1222  if (Ln.IsNull()) goto all_done;
1223  if (! withT) With_s.Init(currRing);
1224  if(rField_is_Ring(currRing) && strat->sigdrop)
1225  {
1226  //Cannot break the loop here so easily
1227  break;
1228  }
1229  }
1230  pNext(h) = Ln.LmExtractAndIter();
1231  pIter(h);
1232  if(!rField_is_Ring(currRing))
1233  pNormalize(h);
1234  L->pLength++;
1235  }
1236  all_done:
1237  Ln.Delete();
1238  if (L->p != NULL) pNext(L->p) = pNext(p);
1239 
1240  if (strat->redTailChange)
1241  {
1242  L->length = 0;
1243  }
1244  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1245  //L->Normalize(); // HANNES: should have a test
1246  kTest_L(L);
1247  return L->GetLmCurrRing();
1248 }

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 4881 of file kutil.cc.

4883 {
4884  int i,j,at,ecart, s2r;
4885  int fq=0;
4886  unsigned long sev;
4887  poly p;
4888  int new_suc=strat->sl+1;
4889  i= *suc;
4890  if (i<0) i=0;
4891 
4892  for (; i<=strat->sl; i++)
4893  {
4894  at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4895  if (at != i)
4896  {
4897  if (new_suc > at) new_suc = at;
4898  p = strat->S[i];
4899  ecart = strat->ecartS[i];
4900  sev = strat->sevS[i];
4901  s2r = strat->S_2_R[i];
4902  if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4903  for (j=i; j>=at+1; j--)
4904  {
4905  strat->S[j] = strat->S[j-1];
4906  strat->ecartS[j] = strat->ecartS[j-1];
4907  strat->sevS[j] = strat->sevS[j-1];
4908  strat->S_2_R[j] = strat->S_2_R[j-1];
4909  }
4910  strat->S[at] = p;
4911  strat->ecartS[at] = ecart;
4912  strat->sevS[at] = sev;
4913  strat->S_2_R[at] = s2r;
4914  if (strat->fromQ!=NULL)
4915  {
4916  for (j=i; j>=at+1; j--)
4917  {
4918  strat->fromQ[j] = strat->fromQ[j-1];
4919  }
4920  strat->fromQ[at]=fq;
4921  }
4922  }
4923  }
4924  if (new_suc <= strat->sl) *suc=new_suc;
4925  else *suc=-1;

◆ sba()

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

Definition at line 2272 of file kstd2.cc.

2273 {
2274  // ring order stuff:
2275  // in sba we have (until now) two possibilities:
2276  // 1. an incremental computation w.r.t. (C,monomial order)
2277  // 2. a (possibly non-incremental) computation w.r.t. the
2278  // induced Schreyer order.
2279  // The corresponding orders are computed in sbaRing(), depending
2280  // on the flag strat->sbaOrder
2281 #if SBA_PRINT_ZERO_REDUCTIONS
2282  long zeroreductions = 0;
2283 #endif
2284 #if SBA_PRINT_PRODUCT_CRITERION
2285  long product_criterion = 0;
2286 #endif
2287 #if SBA_PRINT_SIZE_G
2288  int size_g = 0;
2289  int size_g_non_red = 0;
2290 #endif
2291 #if SBA_PRINT_SIZE_SYZ
2292  long size_syz = 0;
2293 #endif
2294  // global variable
2295 #if SBA_PRINT_REDUCTION_STEPS
2296  sba_reduction_steps = 0;
2297  sba_interreduction_steps = 0;
2298 #endif
2299 #if SBA_PRINT_OPERATIONS
2300  sba_operations = 0;
2301  sba_interreduction_operations = 0;
2302 #endif
2303 
2304  ideal F1 = F0;
2305  ring sRing, currRingOld;
2306  currRingOld = currRing;
2307  if (strat->sbaOrder == 1 || strat->sbaOrder == 3)
2308  {
2309  sRing = sbaRing(strat);
2310  if (sRing!=currRingOld)
2311  {
2312  rChangeCurrRing (sRing);
2313  F1 = idrMoveR (F0, currRingOld, currRing);
2314  }
2315  }
2316  ideal F;
2317  // sort ideal F
2318  //Put the SigDrop element on the correct position (think of sbaEnterS)
2319  //We also sort them
2320  if(rField_is_Ring(currRing) && strat->sigdrop)
2321  {
2322  #if 1
2323  F = idInit(IDELEMS(F1),F1->rank);
2324  for (int i=0; i<IDELEMS(F1);++i)
2325  F->m[i] = F1->m[i];
2326  if(strat->sbaEnterS >= 0)
2327  {
2328  poly dummy;
2329  dummy = pCopy(F->m[0]); //the sigdrop element
2330  for(int i = 0;i<strat->sbaEnterS;i++)
2331  F->m[i] = F->m[i+1];
2332  F->m[strat->sbaEnterS] = dummy;
2333  }
2334  #else
2335  F = idInit(1,F1->rank);
2336  //printf("\nBefore the initial block sorting:\n");idPrint(F1);
2337  F->m[0] = F1->m[0];
2338  int pos;
2339  if(strat->sbaEnterS >= 0)
2340  {
2341  for(int i=1;i<=strat->sbaEnterS;i++)
2342  {
2343  pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS);
2344  idInsertPolyOnPos(F,F1->m[i],pos);
2345  }
2346  for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++)
2347  {
2348  pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F));
2349  idInsertPolyOnPos(F,F1->m[i],pos);
2350  }
2351  poly dummy;
2352  dummy = pCopy(F->m[0]); //the sigdrop element
2353  for(int i = 0;i<strat->sbaEnterS;i++)
2354  F->m[i] = F->m[i+1];
2355  F->m[strat->sbaEnterS] = dummy;
2356  }
2357  else
2358  {
2359  for(int i=1;i<IDELEMS(F1);i++)
2360  {
2361  pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F));
2362  idInsertPolyOnPos(F,F1->m[i],pos);
2363  }
2364  }
2365  #endif
2366  //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar();
2367  }
2368  else
2369  {
2370  F = idInit(IDELEMS(F1),F1->rank);
2371  intvec *sort = idSort(F1);
2372  for (int i=0; i<sort->length();++i)
2373  F->m[i] = F1->m[(*sort)[i]-1];
2375  {
2376  // put the monomials after the sbaEnterS polynomials
2377  //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F);
2378  int nrmon = 0;
2379  for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--)
2380  {
2381  //pWrite(F->m[i]);
2382  if(F->m[i] != NULL && pNext(F->m[i]) == NULL)
2383  {
2384  poly mon = F->m[i];
2385  for(j = i;j>strat->sbaEnterS+nrmon+1;j--)
2386  {
2387  F->m[j] = F->m[j-1];
2388  }
2389  F->m[j] = mon;
2390  nrmon++;
2391  }
2392  //idPrint(F);
2393  }
2394  }
2395  }
2396  //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar();
2398  strat->sigdrop = FALSE;
2399  strat->nrsyzcrit = 0;
2400  strat->nrrewcrit = 0;
2402  F = kInterRed(F,NULL);
2403 #endif
2404 #if F5DEBUG
2405  printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
2406  rWrite (currRing);
2407  printf("ordSgn = %d\n",currRing->OrdSgn);
2408  printf("\n");
2409 #endif
2410  int srmax,lrmax, red_result = 1;
2411  int olddeg,reduc;
2412  int hilbeledeg=1,hilbcount=0,minimcnt=0;
2413  LObject L;
2414  BOOLEAN withT = TRUE;
2415  strat->max_lower_index = 0;
2416  //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2417  initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/
2418  initSbaPos(strat);
2419  initHilbCrit(F,Q,&hilb,strat);
2420  initSba(F,strat);
2421  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2422  /*Shdl=*/initSbaBuchMora(F, Q,strat);
2423  idTest(strat->Shdl);
2424  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2425  srmax = strat->sl;
2426  reduc = olddeg = lrmax = 0;
2427 #ifndef NO_BUCKETS
2428  if (!TEST_OPT_NOT_BUCKETS)
2429  strat->use_buckets = 1;
2430 #endif
2431 
2432  // redtailBBa against T for inhomogenous input
2433  // if (!TEST_OPT_OLDSTD)
2434  // withT = ! strat->homog;
2435 
2436  // strat->posInT = posInT_pLength;
2437  kTest_TS(strat);
2438 
2439 #ifdef HAVE_TAIL_RING
2440  if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2441  kStratInitChangeTailRing(strat);
2442 #endif
2443  if (BVERBOSE(23))
2444  {
2445  if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2446  if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2447  kDebugPrint(strat);
2448  }
2449  // We add the elements directly in S from the previous loop
2450  if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0)
2451  {
2452  for(int i = 0;i<strat->sbaEnterS;i++)
2453  {
2454  //Update: now the element is at the corect place
2455  //i+1 because on the 0 position is the sigdrop element
2456  enterT(strat->L[strat->Ll-(i)],strat);
2457  strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl);
2458  }
2459  strat->Ll = strat->Ll - strat->sbaEnterS;
2460  strat->sbaEnterS = -1;
2461  }
2462  kTest_TS(strat);
2463 #ifdef KDEBUG
2464  //kDebugPrint(strat);
2465 #endif
2466  /* compute------------------------------------------------------- */
2467  while (strat->Ll >= 0)
2468  {
2469  if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
2470  #ifdef KDEBUG
2471  if (TEST_OPT_DEBUG) messageSets(strat);
2472  #endif
2473  if (strat->Ll== 0) strat->interpt=TRUE;
2474  /*
2475  if (TEST_OPT_DEGBOUND
2476  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2477  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2478  {
2479 
2480  //stops computation if
2481  // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2482  //a predefined number Kstd1_deg
2483  while ((strat->Ll >= 0)
2484  && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2485  && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2486  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2487  )
2488  deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2489  if (strat->Ll<0) break;
2490  else strat->noClearS=TRUE;
2491  }
2492  */
2493  if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)
2494  {
2495  strat->currIdx = pGetComp(strat->L[strat->Ll].sig);
2496 #if F5C
2497  // 1. interreduction of the current standard basis
2498  // 2. generation of new principal syzygy rules for syzCriterion
2499  f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
2500  lrmax, reduc, Q, w, hilb );
2501 #endif
2502  // initialize new syzygy rules for the next iteration step
2503  initSyzRules(strat);
2504  }
2505  /*********************************************************************
2506  * interrreduction step is done, we can go on with the next iteration
2507  * step of the signature-based algorithm
2508  ********************************************************************/
2509  /* picks the last element from the lazyset L */
2510  strat->P = strat->L[strat->Ll];
2511  strat->Ll--;
2512 
2514  strat->sbaEnterS = pGetComp(strat->P.sig) - 1;
2515  /* reduction of the element chosen from L */
2516  if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1))
2517  {
2518  //#if 1
2519 #ifdef DEBUGF5
2520  PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
2521  PrintS("-------------------------------------------------\n");
2522  pWrite(strat->P.sig);
2523  pWrite(pHead(strat->P.p));
2524  pWrite(pHead(strat->P.p1));
2525  pWrite(pHead(strat->P.p2));
2526  PrintS("-------------------------------------------------\n");
2527 #endif
2528  if (pNext(strat->P.p) == strat->tail)
2529  {
2530  // deletes the short spoly
2531  /*
2532  if (rField_is_Ring(currRing))
2533  pLmDelete(strat->P.p);
2534  else
2535  pLmFree(strat->P.p);
2536 */
2537  // TODO: needs some masking
2538  // TODO: masking needs to vanish once the signature
2539  // sutff is completely implemented
2540  strat->P.p = NULL;
2541  poly m1 = NULL, m2 = NULL;
2542 
2543  // check that spoly creation is ok
2544  while (strat->tailRing != currRing &&
2545  !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2546  {
2547  assume(m1 == NULL && m2 == NULL);
2548  // if not, change to a ring where exponents are at least
2549  // large enough
2550  if (!kStratChangeTailRing(strat))
2551  {
2552  WerrorS("OVERFLOW...");
2553  break;
2554  }
2555  }
2556  // create the real one
2557  ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2558  strat->tailRing, m1, m2, strat->R);
2559 
2560  }
2561  else if (strat->P.p1 == NULL)
2562  {
2563  if (strat->minim > 0)
2564  strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2565  // for input polys, prepare reduction
2566  if(!rField_is_Ring(currRing))
2567  strat->P.PrepareRed(strat->use_buckets);
2568  }
2569  if (strat->P.p == NULL && strat->P.t_p == NULL)
2570  {
2571  red_result = 0;
2572  }
2573  else
2574  {
2575  //#if 1
2576 #ifdef DEBUGF5
2577  PrintS("Poly before red: ");
2578  pWrite(pHead(strat->P.p));
2579  pWrite(strat->P.sig);
2580 #endif
2581 #if SBA_PRODUCT_CRITERION
2582  if (strat->P.prod_crit)
2583  {
2584 #if SBA_PRINT_PRODUCT_CRITERION
2585  product_criterion++;
2586 #endif
2587  int pos = posInSyz(strat, strat->P.sig);
2588  enterSyz(strat->P, strat, pos);
2589  if (strat->P.lcm!=NULL)
2590  pLmFree(strat->P.lcm);
2591  red_result = 2;
2592  }
2593  else
2594  {
2595  red_result = strat->red(&strat->P,strat);
2596  }
2597 #else
2598  red_result = strat->red(&strat->P,strat);
2599 #endif
2600  }
2601  }
2602  else
2603  {
2604  /*
2605  if (strat->P.lcm != NULL)
2606  pLmFree(strat->P.lcm);
2607  */
2608  red_result = 2;
2609  }
2611  {
2612  if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig)))
2613  {
2614  strat->P.p = pNeg(strat->P.p);
2615  strat->P.sig = pNeg(strat->P.sig);
2616  }
2617  strat->P.pLength = pLength(strat->P.p);
2618  if(strat->P.sig != NULL)
2619  strat->P.sevSig = pGetShortExpVector(strat->P.sig);
2620  if(strat->P.p != NULL)
2621  strat->P.sev = pGetShortExpVector(strat->P.p);
2622  }
2623  //sigdrop case
2624  if(rField_is_Ring(currRing) && strat->sigdrop)
2625  {
2626  //First reduce it as much as one can
2627  red_result = redRing(&strat->P,strat);
2628  if(red_result == 0)
2629  {
2630  strat->sigdrop = FALSE;
2631  pDelete(&strat->P.sig);
2632  strat->P.sig = NULL;
2633  }
2634  else
2635  {
2636  strat->enterS(strat->P, 0, strat, strat->tl);
2637  if (TEST_OPT_PROT)
2638  PrintS("-");
2639  break;
2640  }
2641  }
2642  if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax)
2643  {
2644  strat->sigdrop = TRUE;
2645  break;
2646  }
2647 
2648  if (errorreported) break;
2649 
2650 //#if 1
2651 #ifdef DEBUGF5
2652  if (red_result != 0)
2653  {
2654  PrintS("Poly after red: ");
2655  pWrite(pHead(strat->P.p));
2656  pWrite(strat->P.GetLmCurrRing());
2657  pWrite(strat->P.sig);
2658  printf("%d\n",red_result);
2659  }
2660 #endif
2661  if (TEST_OPT_PROT)
2662  {
2663  if(strat->P.p != NULL)
2664  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2665  &olddeg,&reduc,strat, red_result);
2666  else
2667  message((strat->honey ? strat->P.ecart : 0),
2668  &olddeg,&reduc,strat, red_result);
2669  }
2670 
2671  if (strat->overflow)
2672  {
2673  if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2674  }
2675  // reduction to non-zero new poly
2676  if (red_result == 1)
2677  {
2678  // get the polynomial (canonicalize bucket, make sure P.p is set)
2679  strat->P.GetP(strat->lmBin);
2680 
2681  // sig-safe computations may lead to wrong FDeg computation, thus we need
2682  // to recompute it to make sure everything is alright
2683  (strat->P).FDeg = (strat->P).pFDeg();
2684  // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2685  // but now, for entering S, T, we reset it
2686  // in the inhomogeneous case: FDeg == pFDeg
2687  if (strat->homog) strat->initEcart(&(strat->P));
2688 
2689  /* statistic */
2690  if (TEST_OPT_PROT) PrintS("s");
2691 
2692  //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2693  // in F5E we know that the last reduced element is already the
2694  // the one with highest signature
2695  int pos = strat->sl+1;
2696 
2697  // reduce the tail and normalize poly
2698  // in the ring case we cannot expect LC(f) = 1,
2699  // therefore we call pCleardenom instead of pNorm
2700  #ifdef HAVE_RINGS
2701  poly beforetailred;
2703  beforetailred = pCopy(strat->P.sig);
2704  #endif
2705 #if SBA_TAIL_RED
2707  {
2709  strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
2710  }
2711  else
2712  {
2713  if (strat->sbaOrder != 2)
2714  {
2716  {
2717  strat->P.pCleardenom();
2719  {
2720  strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
2721  strat->P.pCleardenom();
2722  }
2723  }
2724  else
2725  {
2726  strat->P.pNorm();
2728  strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
2729  }
2730  }
2731  }
2732  // It may happen that we have lost the sig in redtailsba
2733  // It cannot reduce to 0 since here we are doing just tail reduction.
2734  // Best case scenerio: remains the leading term
2735  if(rField_is_Ring(currRing) && strat->sigdrop)
2736  {
2737  strat->enterS(strat->P, 0, strat, strat->tl);
2738  break;
2739  }
2740 #endif
2742  {
2743  if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1)
2744  {
2745  strat->sigdrop = TRUE;
2746  //Reduce it as much as you can
2747  red_result = redRing(&strat->P,strat);
2748  if(red_result == 0)
2749  {
2750  //It reduced to 0, cancel the sigdrop
2751  strat->sigdrop = FALSE;
2752  p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL;
2753  }
2754  else
2755  {
2756  strat->enterS(strat->P, 0, strat, strat->tl);
2757  break;
2758  }
2759  }
2760  p_Delete(&beforetailred,currRing);
2761  // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing
2762  if(strat->P.p == NULL)
2763  goto case_when_red_result_changed;
2764  }
2765  // remove sigsafe label since it is no longer valid for the next element to
2766  // be reduced
2767  if (strat->sbaOrder == 1)
2768  {
2769  for (int jj = 0; jj<strat->tl+1; jj++)
2770  {
2771  if (pGetComp(strat->T[jj].sig) == strat->currIdx)
2772  {
2773  strat->T[jj].is_sigsafe = FALSE;
2774  }
2775  }
2776  }
2777  else
2778  {
2779  for (int jj = 0; jj<strat->tl+1; jj++)
2780  {
2781  strat->T[jj].is_sigsafe = FALSE;
2782  }
2783  }
2784 #ifdef KDEBUG
2785  if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2786 #endif /* KDEBUG */
2787 
2788  // min_std stuff
2789  if ((strat->P.p1==NULL) && (strat->minim>0))
2790  {
2791  if (strat->minim==1)
2792  {
2793  strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2794  p_Delete(&strat->P.p2, currRing, strat->tailRing);
2795  }
2796  else
2797  {
2798  strat->M->m[minimcnt]=strat->P.p2;
2799  strat->P.p2=NULL;
2800  }
2801  if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2802  pNext(strat->M->m[minimcnt])
2803  = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2804  strat->tailRing, currRing,
2805  currRing->PolyBin);
2806  minimcnt++;
2807  }
2808 
2809  // enter into S, L, and T
2810  //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2811  enterT(strat->P, strat);
2812  strat->T[strat->tl].is_sigsafe = FALSE;
2813  /*
2814  printf("hier\n");
2815  pWrite(strat->P.GetLmCurrRing());
2816  pWrite(strat->P.sig);
2817  */
2818  if (rField_is_Ring(currRing))
2819  superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2820  else
2821  enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2822  if(rField_is_Ring(currRing) && strat->sigdrop)
2823  break;
2825  strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing);
2826  strat->enterS(strat->P, pos, strat, strat->tl);
2827  if(strat->sbaOrder != 1)
2828  {
2829  BOOLEAN overwrite = FALSE;
2830  for (int tk=0; tk<strat->sl+1; tk++)
2831  {
2832  if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))
2833  {
2834  //printf("TK %d / %d\n",tk,strat->sl);
2835  overwrite = FALSE;
2836  break;
2837  }
2838  }
2839  //printf("OVERWRITE %d\n",overwrite);
2840  if (overwrite)
2841  {
2842  int cmp = pGetComp(strat->P.sig);
2843  int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
2844  p_GetExpV (strat->P.p,vv,currRing);
2845  p_SetExpV (strat->P.sig, vv,currRing);
2846  p_SetComp (strat->P.sig,cmp,currRing);
2847 
2848  strat->P.sevSig = pGetShortExpVector (strat->P.sig);
2849  int i;
2850  LObject Q;
2851  for(int ps=0;ps<strat->sl+1;ps++)
2852  {
2853 
2854  strat->newt = TRUE;
2855  if (strat->syzl == strat->syzmax)
2856  {
2857  pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);
2858  strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
2859  (strat->syzmax)*sizeof(unsigned long),
2860  ((strat->syzmax)+setmaxTinc)
2861  *sizeof(unsigned long));
2862  strat->syzmax += setmaxTinc;
2863  }
2864  Q.sig = pCopy(strat->P.sig);
2865  // add LM(F->m[i]) to the signature to get a Schreyer order
2866  // without changing the underlying polynomial ring at all
2867  if (strat->sbaOrder == 0)
2868  p_ExpVectorAdd (Q.sig,strat->S[ps],currRing);
2869  // since p_Add_q() destroys all input
2870  // data we need to recreate help
2871  // each time
2872  // ----------------------------------------------------------
2873  // in the Schreyer order we always know that the multiplied
2874  // module monomial strat->P.sig gives the leading monomial of
2875  // the corresponding principal syzygy
2876  // => we do not need to compute the "real" syzygy completely
2877  poly help = p_Copy(strat->sig[ps],currRing);
2878  p_ExpVectorAdd (help,strat->P.p,currRing);
2879  Q.sig = p_Add_q(Q.sig,help,currRing);
2880  //printf("%d. SYZ ",i+1);
2881  //pWrite(strat->syz[i]);
2882  Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
2883  i = posInSyz(strat, Q.sig);
2884  enterSyz(Q, strat, i);
2885  }
2886  }
2887  }
2888  // deg - idx - lp/rp
2889  // => we need to add syzygies with indices > pGetComp(strat->P.sig)
2890  if(strat->sbaOrder == 0 || strat->sbaOrder == 3)
2891  {
2892  int cmp = pGetComp(strat->P.sig);
2893  int max_cmp = IDELEMS(F);
2894  int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
2895  p_GetExpV (strat->P.p,vv,currRing);
2896  LObject Q;
2897  int pos;
2898  int idx = __p_GetComp(strat->P.sig,currRing);
2899  //printf("++ -- adding syzygies -- ++\n");
2900  // if new element is the first one in this index
2901  if (strat->currIdx < idx)
2902  {
2903  for (int i=0; i<strat->sl; ++i)
2904  {
2905  Q.sig = p_Copy(strat->P.sig,currRing);
2906  p_ExpVectorAdd(Q.sig,strat->S[i],currRing);
2907  poly help = p_Copy(strat->sig[i],currRing);
2908  p_ExpVectorAdd(help,strat->P.p,currRing);
2909  Q.sig = p_Add_q(Q.sig,help,currRing);
2910  //pWrite(Q.sig);
2911  pos = posInSyz(strat, Q.sig);
2912  enterSyz(Q, strat, pos);
2913  }
2914  strat->currIdx = idx;
2915  }
2916  else
2917  {
2918  // if the element is not the first one in the given index we build all
2919  // possible syzygies with elements of higher index
2920  for (int i=cmp+1; i<=max_cmp; ++i)
2921  {
2922  pos = -1;
2923  for (int j=0; j<strat->sl; ++j)
2924  {
2925  if (__p_GetComp(strat->sig[j],currRing) == i)
2926  {
2927  pos = j;
2928  break;
2929  }
2930  }
2931  if (pos != -1)
2932  {
2933  Q.sig = p_One(currRing);
2934  p_SetExpV(Q.sig, vv, currRing);
2935  // F->m[i-1] corresponds to index i
2936  p_ExpVectorAdd(Q.sig,F->m[i-1],currRing);
2937  p_SetComp(Q.sig, i, currRing);
2938  poly help = p_Copy(strat->P.sig,currRing);
2939  p_ExpVectorAdd(help,strat->S[pos],currRing);
2940  Q.sig = p_Add_q(Q.sig,help,currRing);
2941  if (strat->sbaOrder == 0)
2942  {
2943  if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn)
2944  {
2945  pos = posInSyz(strat, Q.sig);
2946  enterSyz(Q, strat, pos);
2947  }
2948  }
2949  else
2950  {
2951  pos = posInSyz(strat, Q.sig);
2952  enterSyz(Q, strat, pos);
2953  }
2954  }
2955  }
2956  //printf("++ -- done adding syzygies -- ++\n");
2957  }
2958  }
2959 //#if 1
2960 #if DEBUGF50
2961  printf("---------------------------\n");
2962  Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);
2963  PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl]));
2964  PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]);
2965 #endif
2966  /*
2967  if (newrules)
2968  {
2969  newrules = FALSE;
2970  }
2971  */
2972 #if 0
2973  int pl=pLength(strat->P.p);
2974  if (pl==1)
2975  {
2976  //if (TEST_OPT_PROT)
2977  //PrintS("<1>");
2978  }
2979  else if (pl==2)
2980  {
2981  //if (TEST_OPT_PROT)
2982  //PrintS("<2>");
2983  }
2984 #endif
2985  if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2986 // Print("[%d]",hilbeledeg);
2987  if (strat->P.lcm!=NULL)
2988 #ifdef HAVE_RINGS
2989  pLmDelete(strat->P.lcm);
2990 #else
2991  pLmFree(strat->P.lcm);
2992 #endif
2993  if (strat->sl>srmax) srmax = strat->sl;
2994  }
2995  else
2996  {
2997  case_when_red_result_changed:
2998  // adds signature of the zero reduction to
2999  // strat->syz. This is the leading term of
3000  // syzygy and can be used in syzCriterion()
3001  // the signature is added if and only if the
3002  // pair was not detected by the rewritten criterion in strat->red = redSig
3003  if (red_result!=2)
3004  {
3005 #if SBA_PRINT_ZERO_REDUCTIONS
3006  zeroreductions++;
3007 #endif
3008  if(rField_is_Ring(currRing) && strat->P.p == NULL && strat->P.sig == NULL)
3009  {
3010  //Catch the case when p = 0, sig = 0
3011  }
3012  else
3013  {
3014  int pos = posInSyz(strat, strat->P.sig);
3015  enterSyz(strat->P, strat, pos);
3016  //#if 1
3017  #ifdef DEBUGF5
3018  Print("ADDING STUFF TO SYZ : ");
3019  //pWrite(strat->P.p);
3020  pWrite(strat->P.sig);
3021  #endif
3022  }
3023  }
3024  if (strat->P.p1 == NULL && strat->minim > 0)
3025  {
3026  p_Delete(&strat->P.p2, currRing, strat->tailRing);
3027  }
3028  }
3029 
3030 #ifdef KDEBUG
3031  memset(&(strat->P), 0, sizeof(strat->P));
3032 #endif /* KDEBUG */
3033  kTest_TS(strat);
3034  }
3035  #if 0
3036  if(strat->sigdrop)
3037  printf("\nSigDrop!\n");
3038  else
3039  printf("\nEnded with no SigDrop\n");
3040  #endif
3041 // Clean strat->P for the next sba call
3042  if(rField_is_Ring(currRing) && strat->sigdrop)
3043  {
3044  //This is used to know how many elements can we directly add to S in the next run
3045  if(strat->P.sig != NULL)
3046  strat->sbaEnterS = pGetComp(strat->P.sig)-1;
3047  //else we already set it at the beggining of the loop
3048  #ifdef KDEBUG
3049  memset(&(strat->P), 0, sizeof(strat->P));
3050  #endif /* KDEBUG */
3051  }
3052 #ifdef KDEBUG
3053  if (TEST_OPT_DEBUG) messageSets(strat);
3054 #endif /* KDEBUG */
3055 
3056  if (TEST_OPT_SB_1)
3057  {
3058  if(!rField_is_Ring(currRing))
3059  {
3060  int k=1;
3061  int j;
3062  while(k<=strat->sl)
3063  {
3064  j=0;
3065  loop
3066  {
3067  if (j>=k) break;
3068  clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
3069  j++;
3070  }
3071  k++;
3072  }
3073  }
3074  }
3075  /* complete reduction of the standard basis--------- */
3076  if (TEST_OPT_REDSB)
3077  {
3078  completeReduce(strat);
3079  if (strat->completeReduce_retry)
3080  {
3081  // completeReduce needed larger exponents, retry
3082  // to reduce with S (instead of T)
3083  // and in currRing (instead of strat->tailRing)
3084 #ifdef HAVE_TAIL_RING
3085  if(currRing->bitmask>strat->tailRing->bitmask)
3086  {
3087  strat->completeReduce_retry=FALSE;
3088  cleanT(strat);strat->tailRing=currRing;
3089  int i;
3090  for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3091  completeReduce(strat);
3092  }
3093  if (strat->completeReduce_retry)
3094 #endif
3095  Werror("exponent bound is %ld",currRing->bitmask);
3096  }
3097  }
3098  else if (TEST_OPT_PROT) PrintLn();
3099 
3100 #if SBA_PRINT_SIZE_SYZ
3101  // that is correct, syzl is counting one too far
3102  size_syz = strat->syzl;
3103 #endif
3104 // if (TEST_OPT_WEIGHTM)
3105 // {
3106 // pRestoreDegProcs(pFDegOld, pLDegOld);
3107 // if (ecartWeights)
3108 // {
3109 // omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
3110 // ecartWeights=NULL;
3111 // }
3112 // }
3113  if (TEST_OPT_PROT) messageStatSBA(hilbcount,strat);
3114  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3115 #if SBA_PRINT_SIZE_G
3116  size_g_non_red = IDELEMS(strat->Shdl);
3117 #endif
3118  if(!rField_is_Ring(currRing))
3119  exitSba(strat);
3120  // I have to add the initial input polynomials which where not used (p1 and p2 = NULL)
3121  #ifdef HAVE_RINGS
3122  int k;
3124  {
3125  //for(k = strat->sl;k>=0;k--)
3126  // {printf("\nS[%i] = %p\n",k,strat->Shdl->m[k]);pWrite(strat->Shdl->m[k]);}
3127  k = strat->Ll;
3128  #if 1
3129  // 1 - adds just the unused ones, 0 - adds everthing
3130  for(;k>=0 && (strat->L[k].p1 != NULL || strat->L[k].p2 != NULL);k--)
3131  {
3132  //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);
3133  deleteInL(strat->L,&strat->Ll,k,strat);
3134  }
3135  #endif
3136  //for(int kk = strat->sl;kk>=0;kk--)
3137  // {printf("\nS[%i] = %p\n",kk,strat->Shdl->m[kk]);pWrite(strat->Shdl->m[kk]);}
3138  //idPrint(strat->Shdl);
3139  //printf("\nk = %i\n",k);
3140  for(;k>=0 && strat->L[k].p1 == NULL && strat->L[k].p2 == NULL;k--)
3141  {
3142  //printf("\nAdded k = %i\n",k);
3143  strat->enterS(strat->L[k], strat->sl+1, strat, strat->tl);
3144  //printf("\nThis elements was added from L on pos %i\n",strat->sl);pWrite(strat->S[strat->sl]);pWrite(strat->sig[strat->sl]);
3145  }
3146  }
3147  // 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
3148  #if 0
3149  if(strat->sigdrop && rField_is_Ring(currRing))
3150  {
3151  for(k=strat->sl;k>=0;k--)
3152  {
3153  printf("\nsig[%i] = ",i);pWrite(strat->sig[k]);
3154  if(strat->sig[k] == NULL)
3155  strat->sig[k] = pCopy(strat->sig[k-1]);
3156  }
3157  }
3158  #endif
3159  #endif
3160  //Never do this - you will damage S
3161  //idSkipZeroes(strat->Shdl);
3162  //idPrint(strat->Shdl);
3163 
3164  if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld)
3165  {
3166  rChangeCurrRing (currRingOld);
3167  F0 = idrMoveR (F1, sRing, currRing);
3168  strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing);
3169  rChangeCurrRing (sRing);
3171  exitSba(strat);
3172  rChangeCurrRing (currRingOld);
3173  if(strat->tailRing == sRing)
3174  strat->tailRing = currRing;
3175  rDelete (sRing);
3176  }
3177  if(rField_is_Ring(currRing) && !strat->sigdrop)
3178  id_DelDiv(strat->Shdl, currRing);
3179  if(!rField_is_Ring(currRing))
3180  id_DelDiv(strat->Shdl, currRing);
3181  idSkipZeroes(strat->Shdl);
3182  idTest(strat->Shdl);
3183 
3184 #if SBA_PRINT_SIZE_G
3185  size_g = IDELEMS(strat->Shdl);
3186 #endif
3187 #ifdef DEBUGF5
3188  printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));
3189  int oo = 0;
3190  while (oo<IDELEMS(strat->Shdl))
3191  {
3192  printf(" %d. ",oo+1);
3193  pWrite(pHead(strat->Shdl->m[oo]));
3194  oo++;
3195  }
3196 #endif
3197 #if SBA_PRINT_ZERO_REDUCTIONS
3198  printf("----------------------------------------------------------\n");
3199  printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3200  zeroreductions = 0;
3201 #endif
3202 #if SBA_PRINT_REDUCTION_STEPS
3203  printf("----------------------------------------------------------\n");
3204  printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3205 #endif
3206 #if SBA_PRINT_OPERATIONS
3207  printf("OPERATIONS: %ld\n",sba_operations);
3208 #endif
3209 #if SBA_PRINT_REDUCTION_STEPS
3210  printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3211  printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3212 #endif
3213 #if SBA_PRINT_OPERATIONS
3214  printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3215 #endif
3216 #if SBA_PRINT_REDUCTION_STEPS
3217  printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3218  printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3219  sba_interreduction_steps = 0;
3220  sba_reduction_steps = 0;
3221 #endif
3222 #if SBA_PRINT_OPERATIONS
3223  printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3224  sba_interreduction_operations = 0;
3225  sba_operations = 0;
3226 #endif
3227 #if SBA_PRINT_SIZE_G
3228  printf("----------------------------------------------------------\n");
3229  printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3230  size_g = 0;
3231  size_g_non_red = 0;
3232 #endif
3233 #if SBA_PRINT_SIZE_SYZ
3234  printf("SIZE OF SYZ: %ld\n",size_syz);
3235  printf("----------------------------------------------------------\n");
3236  size_syz = 0;
3237 #endif
3238 #if SBA_PRINT_PRODUCT_CRITERION
3239  printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3240  product_criterion = 0;
3241 #endif
3242  return (strat->Shdl);

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject h,
kStrategy  strat 
)

Definition at line 1607 of file kutil.cc.

1609 {
1610  if(strat->sl < 0) return FALSE;
1611  int i;
1612  for(i=0;i<strat->sl;i++)
1613  {
1614  //Construct the gcd pair between h and S[i]
1615  number d, s, t;
1616  poly m1, m2, gcd;
1617  d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1618  if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1619  {
1620  nDelete(&d);
1621  nDelete(&s);
1622  nDelete(&t);
1623  }
1624  else
1625  {
1626  k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1627  pSetCoeff0(m1, s);
1628  pSetCoeff0(m2, t);
1629  pSetCoeff0(gcd, d);
1630  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);
1631  poly pSigMult = p_Copy(h->sig,currRing);
1632  poly sSigMult = p_Copy(strat->sig[i],currRing);
1633  pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1634  sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1635  p_LmDelete(m1, strat->tailRing);
1636  p_LmDelete(m2, strat->tailRing);
1637  poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1638  if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1639  {
1640  pDelete(&h->p);
1641  h->p = gcd;
1642  pDelete(&h->sig);
1643  h->sig = pairsig;
1644  pNext(h->sig) = NULL;
1645  strat->initEcart(h);
1646  h->sev = pGetShortExpVector(h->p);
1647  h->sevSig = pGetShortExpVector(h->sig);
1648  h->i_r1 = -1;h->i_r2 = -1;
1649  if(h->lcm != NULL)
1650  {
1651  pLmDelete(h->lcm);
1652  h->lcm = NULL;
1653  }
1654  if (currRing!=strat->tailRing)
1655  h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1656  return TRUE;
1657  }
1658  //Delete what you didn't use
1659  pDelete(&gcd);
1660  pDelete(&pairsig);
1661  }
1662  }
1663  return FALSE;

◆ sbaRing()

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

Definition at line 11154 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4730 of file kutil.cc.

4732 {
4734  // enter also zero divisor * poly, if this is non zero and of smaller degree
4735  if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat);
4736  initenterpairs(h, k, ecart, 0, strat, atR);
4737  initenterstrongPairs(h, k, ecart, 0, strat, atR);
4738  clearSbatch(h, k, pos, strat);

◆ superenterpairsSig()

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

Definition at line 4740 of file kutil.cc.

4742 {
4744  // enter also zero divisor * poly, if this is non zero and of smaller degree
4745  if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4746  if(strat->sigdrop) return;
4747  initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4748  if(strat->sigdrop) return;
4749  initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4750  if(strat->sigdrop) return;
4751  clearSbatch(h, k, pos, strat);

◆ syzCriterion()

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

Definition at line 6944 of file kutil.cc.

6946 {
6947 //#if 1
6948 #ifdef DEBUGF5
6949  PrintS("syzygy criterion checks: ");
6950  pWrite(sig);
6951 #endif
6952  for (int k=0; k<strat->syzl; k++)
6953  {
6954  //printf("-%d",k);
6955 //#if 1
6956 #ifdef DEBUGF5
6957  Print("checking with: %d / %d -- \n",k,strat->syzl);
6958  pWrite(pHead(strat->syz[k]));
6959 #endif
6960  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6961  && (!rField_is_Ring(currRing) ||
6962  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6963  {
6964 //#if 1
6965 #ifdef DEBUGF5
6966  PrintS("DELETE!\n");
6967 #endif
6968  strat->nrsyzcrit++;
6969  //printf("- T -\n\n");
6970  return TRUE;
6971  }
6972  }
6973  //printf("- F -\n\n");
6974  return FALSE;

◆ syzCriterionInc()

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

Definition at line 6979 of file kutil.cc.

6981 {
6982 //#if 1
6983  if(sig == NULL)
6984  return FALSE;
6985 #ifdef DEBUGF5
6986  PrintS("--- syzygy criterion checks: ");
6987  pWrite(sig);
6988 #endif
6989  int comp = __p_GetComp(sig, currRing);
6990  int min, max;
6991  if (comp<=1)
6992  return FALSE;
6993  else
6994  {
6995  min = strat->syzIdx[comp-2];
6996  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6997  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6998  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6999  if (comp == strat->currIdx)
7000  {
7001  max = strat->syzl;
7002  }
7003  else
7004  {
7005  max = strat->syzIdx[comp-1];
7006  }
7007  for (int k=min; k<max; k++)
7008  {
7009 #ifdef F5DEBUG
7010  Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
7011  Print("checking with: %d -- ",k);
7012  pWrite(pHead(strat->syz[k]));
7013 #endif
7014  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
7015  && (!rField_is_Ring(currRing) ||
7016  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
7017  {
7018  strat->nrsyzcrit++;
7019  return TRUE;
7020  }
7021  }
7022  return FALSE;
7023  }

◆ twoPow()

long twoPow ( long  arg)

Definition at line 4070 of file kutil.cc.

4072 {
4073  return 1L << arg;

◆ updateResult()

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

Definition at line 10180 of file kutil.cc.

10188 {
10189  int l;
10190  if (strat->ak>0)
10191  {
10192  for (l=IDELEMS(r)-1;l>=0;l--)
10193  {
10194  if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10195  {
10196  pDelete(&r->m[l]); // and set it to NULL
10197  }
10198  }
10199  int q;
10200  poly p;
10201  if(!rField_is_Ring(currRing))
10202  {
10203  for (l=IDELEMS(r)-1;l>=0;l--)
10204  {
10205  if ((r->m[l]!=NULL)
10206  //&& (strat->syzComp>0)
10207  //&& (pGetComp(r->m[l])<=strat->syzComp)
10208  )
10209  {
10210  for(q=IDELEMS(Q)-1; q>=0;q--)
10211  {
10212  if ((Q->m[q]!=NULL)
10213  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10214  {
10215  if (TEST_OPT_REDSB)
10216  {
10217  p=r->m[l];
10218  r->m[l]=kNF(Q,NULL,p);
10219  pDelete(&p);
10220  }
10221  else
10222  {
10223  pDelete(&r->m[l]); // and set it to NULL
10224  }
10225  break;
10226  }
10227  }
10228  }
10229  }
10230  }
10231  #ifdef HAVE_RINGS
10232  else
10233  {
10234  for (l=IDELEMS(r)-1;l>=0;l--)
10235  {
10236  if ((r->m[l]!=NULL)
10237  //&& (strat->syzComp>0)
10238  //&& (pGetComp(r->m[l])<=strat->syzComp)
10239  )
10240  {
10241  for(q=IDELEMS(Q)-1; q>=0;q--)
10242  {
10243  if ((Q->m[q]!=NULL)
10244  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10245  {
10246  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10247  {
10248  if (TEST_OPT_REDSB)
10249  {
10250  p=r->m[l];
10251  r->m[l]=kNF(Q,NULL,p);
10252  pDelete(&p);
10253  }
10254  else
10255  {
10256  pDelete(&r->m[l]); // and set it to NULL
10257  }
10258  break;
10259  }
10260  }
10261  }
10262  }
10263  }
10264  }
10265  #endif
10266  }
10267  else
10268  {
10269  int q;
10270  poly p;
10271  BOOLEAN reduction_found=FALSE;
10272  if (!rField_is_Ring(currRing))
10273  {
10274  for (l=IDELEMS(r)-1;l>=0;l--)
10275  {
10276  if (r->m[l]!=NULL)
10277  {
10278  for(q=IDELEMS(Q)-1; q>=0;q--)
10279  {
10280  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10281  {
10282  if (TEST_OPT_REDSB)
10283  {
10284  p=r->m[l];
10285  r->m[l]=kNF(Q,NULL,p);
10286  pDelete(&p);
10287  reduction_found=TRUE;
10288  }
10289  else
10290  {
10291  pDelete(&r->m[l]); // and set it to NULL
10292  }
10293  break;
10294  }
10295  }
10296  }
10297  }
10298  }
10299  #ifdef HAVE_RINGS
10300  //Also need divisibility of the leading coefficients
10301  else
10302  {
10303  for (l=IDELEMS(r)-1;l>=0;l--)
10304  {
10305  if (r->m[l]!=NULL)
10306  {
10307  for(q=IDELEMS(Q)-1; q>=0;q--)
10308  {
10309  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10310  {
10311  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10312  {
10313  if (TEST_OPT_REDSB)
10314  {
10315  p=r->m[l];
10316  r->m[l]=kNF(Q,NULL,p);
10317  pDelete(&p);
10318  reduction_found=TRUE;
10319  }
10320  else
10321  {
10322  pDelete(&r->m[l]); // and set it to NULL
10323  }
10324  break;
10325  }
10326  }
10327  }
10328  }
10329  }
10330  }
10331  #endif
10332  if (/*TEST_OPT_REDSB &&*/ reduction_found)
10333  {
10334  #ifdef HAVE_RINGS
10336  {
10337  for (l=IDELEMS(r)-1;l>=0;l--)
10338  {
10339  if (r->m[l]!=NULL)
10340  {
10341  for(q=IDELEMS(r)-1;q>=0;q--)
10342  {
10343  if ((l!=q)
10344  && (r->m[q]!=NULL)
10345  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10346  &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10347  )
10348  {
10349  //If they are equal then take the one with the smallest length
10350  if(pLmDivisibleBy(r->m[q],r->m[l])
10351  && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10352  && (pLength(r->m[q]) < pLength(r->m[l]) ||
10353  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10354  {
10355  pDelete(&r->m[l]);
10356  break;
10357  }
10358  else
10359  pDelete(&r->m[q]);
10360  }
10361  }
10362  }
10363  }
10364  }
10365  else
10366  #endif
10367  {
10368  for (l=IDELEMS(r)-1;l>=0;l--)
10369  {
10370  if (r->m[l]!=NULL)
10371  {
10372  for(q=IDELEMS(r)-1;q>=0;q--)
10373  {
10374  if ((l!=q)
10375  && (r->m[q]!=NULL)
10376  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10377  )
10378  {
10379  //If they are equal then take the one with the smallest length
10380  if(pLmDivisibleBy(r->m[q],r->m[l])
10381  &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10382  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10383  {
10384  pDelete(&r->m[l]);
10385  break;
10386  }
10387  else
10388  pDelete(&r->m[q]);
10389  }
10390  }

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8801 of file kutil.cc.

8808 {
8809  LObject h;
8810  int i, suc=0;
8811  poly redSi=NULL;
8812  BOOLEAN change,any_change;
8813 // Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
8814 // for (i=0; i<=(strat->sl); i++)
8815 // {
8816 // Print("s%d:",i);
8817 // if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
8818 // pWrite(strat->S[i]);
8819 // }
8820 // Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
8821  any_change=FALSE;
8823  {
8824  while (suc != -1)
8825  {
8826  i=suc+1;
8827  while (i<=strat->sl)
8828  {
8829  change=FALSE;
8831  any_change = FALSE;
8832  if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8833  {
8834  redSi = pHead(strat->S[i]);
8835  strat->S[i] = redBba(strat->S[i],i-1,strat);
8836  //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
8837  // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
8838  if (pCmp(redSi,strat->S[i])!=0)
8839  {
8840  change=TRUE;
8841  any_change=TRUE;
8842  #ifdef KDEBUG
8843  if (TEST_OPT_DEBUG)
8844  {
8845  PrintS("reduce:");
8846  wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
8847  }
8848  #endif
8849  if (TEST_OPT_PROT)
8850  {
8851  if (strat->S[i]==NULL)
8852  PrintS("V");
8853  else
8854  PrintS("v");
8855  mflush();
8856  }
8857  }
8858  pLmDelete(&redSi);
8859  if (strat->S[i]==NULL)
8860  {
8861  deleteInS(i,strat);
8862  i--;
8863  }
8864  else if (change)
8865  {
8867  {
8868  if (TEST_OPT_CONTENTSB)
8869  {
8870  number n;
8871  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8872  if (!nIsOne(n))
8873  {
8875  denom->n=nInvers(n);
8876  denom->next=DENOMINATOR_LIST;
8877  DENOMINATOR_LIST=denom;
8878  }
8879  nDelete(&n);
8880  }
8881  else
8882  {
8883  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8884  }
8885  }
8886  else
8887  {
8888  pNorm(strat->S[i]);
8889  }
8890  strat->sevS[i] = pGetShortExpVector(strat->S[i]);
8891  }
8892  }
8893  i++;
8894  }
8895  if (any_change) reorderS(&suc,strat);
8896  else break;
8897  }
8898  if (toT)
8899  {
8900  for (i=0; i<=strat->sl; i++)
8901  {
8902  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8903  {
8904  h.p = redtailBba(strat->S[i],i-1,strat);
8906  {
8907  h.pCleardenom();// also does remove Content
8908  }
8909  }
8910  else
8911  {
8912  h.p = strat->S[i];
8913  }
8914  strat->initEcart(&h);
8915  if (strat->honey)
8916  {
8917  strat->ecartS[i] = h.ecart;
8918  }
8919  if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
8920  else assume(strat->sevS[i] == pGetShortExpVector(h.p));
8921  h.sev = strat->sevS[i];
8922  /*puts the elements of S also to T*/
8923  strat->initEcart(&h);
8924  enterT(h,strat);
8925  strat->S_2_R[i] = strat->tl;
8926  }
8927  }
8928  }
8929  else
8930  {
8931  while (suc != -1)
8932  {
8933  i=suc;
8934  while (i<=strat->sl)
8935  {
8936  change=FALSE;
8937  if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8938  {
8939  redSi=pHead((strat->S)[i]);
8940  (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
8941  if ((strat->S)[i]==NULL)
8942  {
8943  deleteInS(i,strat);
8944  i--;
8945  }
8946  else if (pCmp((strat->S)[i],redSi)!=0)
8947  {
8948  any_change=TRUE;
8949  h.p = strat->S[i];
8950  strat->initEcart(&h);
8951  strat->ecartS[i] = h.ecart;
8953  {
8954  if (TEST_OPT_CONTENTSB)
8955  {
8956  number n;
8957  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8958  if (!nIsOne(n))
8959  {
8961  denom->n=nInvers(n);
8962  denom->next=DENOMINATOR_LIST;
8963  DENOMINATOR_LIST=denom;
8964  }
8965  nDelete(&n);
8966  }
8967  else
8968  {
8969  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8970  }
8971  }
8972  else
8973  {
8974  pNorm(strat->S[i]); // == h.p
8975  }
8976  h.sev = pGetShortExpVector(h.p);
8977  strat->sevS[i] = h.sev;
8978  }
8979  pLmDelete(&redSi);
8980  kTest(strat);
8981  }
8982  i++;
8983  }
8984 #ifdef KDEBUG
8985  kTest(strat);
8986 #endif
8987  if (any_change) reorderS(&suc,strat);
8988  else { suc=-1; break; }
8989  if (h.p!=NULL)
8990  {
8991  if (!strat->kHEdgeFound)
8992  {
8993  /*strat->kHEdgeFound =*/ HEckeTest(h.p,strat);
8994  }
8995  if (strat->kHEdgeFound)
8996  newHEdge(strat);
8997  }
8998  }
8999  for (i=0; i<=strat->sl; i++)
9000  {
9001  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9002  {
9003  strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
9004  strat->initEcart(&h);
9005  strat->ecartS[i] = h.ecart;
9006  h.sev = pGetShortExpVector(h.p);
9007  strat->sevS[i] = h.sev;
9008  }
9009  else
9010  {
9011  h.p = strat->S[i];
9012  h.ecart=strat->ecartS[i];
9013  h.sev = strat->sevS[i];
9014  h.length = h.pLength = pLength(h.p);
9015  }
9016  if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
9017  cancelunit1(&h,&suc,strat->sl,strat);
9018  h.SetpFDeg();
9019  /*puts the elements of S also to T*/
9020  enterT(h,strat);
9021  strat->S_2_R[i] = strat->tl;
9022  }

◆ updateSShift()

void updateSShift ( kStrategy  strat,
int  uptodeg,
int  lV 
)

Definition at line 11834 of file kutil.cc.

11844 {
11845  /* to use after updateS(toT=FALSE,strat) */
11846  /* fills T with shifted elt's of S */
11847  int i;
11848  LObject h;
11849  int atT = -1; // or figure out smth better
11850  strat->tl = -1; // init
11851  for (i=0; i<=strat->sl; i++)
11852  {
11853  memset(&h,0,sizeof(h));
11854  h.p = strat->S[i];
11855  strat->initEcart(&h);
11856  h.sev = strat->sevS[i];
11857  h.t_p = NULL;
11858  h.GetTP(); // creates correct t_p

Variable Documentation

◆ DENOMINATOR_LIST

denominator_list DENOMINATOR_LIST

Definition at line 86 of file kutil.cc.

◆ HCord

int HCord

Definition at line 234 of file kutil.cc.

◆ strat_nr

int strat_nr

Definition at line 25 of file kstdfac.cc.

◆ test_PosInL

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

Definition at line 81 of file kstd2.cc.

◆ test_PosInT

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

Definition at line 80 of file kstd2.cc.

n_IntMod
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
chainCritSig
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3352
kEcartWeights
void kEcartWeights(poly *s, int sl, short *eweight, const ring R)
Definition: weight.cc:187
clearS
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1107
rHasGlobalOrdering
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:750
skStrategy::S_2_T
KINLINE TObject * S_2_T(int i)
Definition: kInline.h:33
si_min
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
ksCheckCoeff
int ksCheckCoeff(number *a, number *b)
pDivisibleBy
#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:132
kStratInitChangeTailRing
void kStratInitChangeTailRing(kStrategy strat)
Definition: kutil.cc:11127
enterpairsSig
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4784
FALSE
#define FALSE
Definition: auxiliary.h:94
redNF
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition: kstd2.cc:1607
chainCritRing
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:3888
posInLSig
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6022
idCopy
ideal idCopy(ideal A)
Definition: ideals.h:59
k_LmShallowCopyDelete_currRing_2_tailRing
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:893
k_LmInit_tailRing_2_currRing
KINLINE poly k_LmInit_tailRing_2_currRing(poly t_p, ring tailRing, omBin lmBin)
Definition: kInline.h:884
skStrategy
Definition: kutil.h:261
idElem
int idElem(const ideal F)
count non-zero elements
Definition: simpleideals.cc:209
p_LmFreeAndNext
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:690
pLDeg1
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:832
kBucketCanonicalize
int kBucketCanonicalize(kBucket_pt bucket)
skStrategy::max_lower_index
int max_lower_index
Definition: kutil.h:308
p_LmDeleteAndNext
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:712
skStrategy::M
ideal M
Definition: kutil.h:295
nc_PolyPolyRed
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
Definition: old.gring.cc:2229
deleteHC
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition: kutil.cc:242
kStdShift
ideal kStdShift(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, int uptodeg, int lV)
Definition: kstd1.cc:2563
p_GetCoeff
#define p_GetCoeff(p, r)
Definition: monomials.h:54
pIsConstant
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:215
skStrategy::fromQ
intset fromQ
Definition: kutil.h:311
initBuchMoraCrit
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9548
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:68
enterExtendedSpolySig
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4586
skStrategy::tail
poly tail
Definition: kutil.h:326
nNormalize
#define nNormalize(n)
Definition: numbers.h:30
pLmEqual
#define pLmEqual(p1, p2)
Definition: polys.h:107
initPairtest
void initPairtest(kStrategy strat)
Definition: kutil.cc:658
redRiloc
int redRiloc(LObject *h, kStrategy strat)
Definition: kstd1.cc:343
pGetComp
#define pGetComp(p)
Component.
Definition: polys.h:36
p_GetExp
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:457
j
int j
Definition: facHensel.cc:105
posInT17_c
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5737
pNorm
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:337
TEST_OPT_INFREDTAIL
#define TEST_OPT_INFREDTAIL
Definition: options.h:115
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
cleanT
void cleanT(kStrategy strat)
Definition: kutil.cc:536
pRestoreDegProcs
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3583
Kstd1_deg
int Kstd1_deg
Definition: kutil.cc:235
skStrategy::enterS
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition: kutil.h:276
SBA_INTERRED_START
#define SBA_INTERRED_START
Definition: kstd2.cc:35
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition: options.h:101
pLDeg0c
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:761
redEcart
int redEcart(LObject *h, kStrategy strat)
Definition: kstd1.cc:167
pHasNotCF
#define pHasNotCF(p1, p2)
Definition: polys.h:238
errorreported
short errorreported
Definition: feFopen.cc:23
k
int k
Definition: cfEzgcd.cc:92
idDelete
#define idDelete(H)
delete an ideal
Definition: ideals.h:28
scComputeHC
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1005
equal
bool equal
Definition: cfModGcd.cc:4067
pLmFree
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:68
skStrategy::tmax
int tmax
Definition: kutil.h:342
TEST_OPT_REDTAIL
#define TEST_OPT_REDTAIL
Definition: options.h:114
pAssume
#define pAssume(cond)
Definition: monomials.h:93
enterOneStrongPoly
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1479
skStrategy::cp
int cp
Definition: kutil.h:339
khCheck
void khCheck(ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count, kStrategy strat)
Definition: khstd.cc:27
TObject
class sTObject TObject
Definition: kutil.h:52
ecartWeights
short * ecartWeights
Definition: weight0.c:27
x
Variable x
Definition: cfModGcd.cc:4023
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: kstd2.cc:196
ppMult_mm
#define ppMult_mm(p, m)
Definition: polys.h:180
kTest_T
#define kTest_T(T)
Definition: kutil.h:642
LSet
LObject * LSet
Definition: kutil.h:55
posInL0
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5964
rField_is_Domain
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:479
pLDeg0
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:730
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
TEST_OPT_DEGBOUND
#define TEST_OPT_DEGBOUND
Definition: options.h:111
nc_p_Bracket_qq
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2242
diff
static gmp_float * diff
Definition: mpr_complex.cc:45
posInL17_c
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6813
skStrategy::P
LObject P
Definition: kutil.h:292
n_GetChar
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
REDTAIL_CANONICALIZE
#define REDTAIL_CANONICALIZE
skStrategy::sbaOrder
unsigned sbaOrder
Definition: kutil.h:306
isInV
int isInV(poly p, int lV)
Definition: shiftgb.cc:237
initT
KINLINE TSet initT()
Definition: kInline.h:78
polyset
poly * polyset
Definition: polys.h:235
nGreater
#define nGreater(a, b)
Definition: numbers.h:28
skStrategy::ecartS
intset ecartS
Definition: kutil.h:299
pLDeg1_Totaldegree
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:966
pGetExp
#define pGetExp(p, i)
Exponent.
Definition: polys.h:40
idrMoveR_NoSort
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:261
initBbaShift
void initBbaShift(kStrategy strat)
Definition: kstd2.cc:4390
posInT_EcartFDegpLength
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11449
pEnlargeSet
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3630
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
redtail
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition: kutil.cc:7303
posInT17
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5630
isInPairsetL
BOOLEAN isInPairsetL(int length, poly p1, poly p2, int *k, kStrategy strat)
Definition: kutil.cc:667
skStrategy::t_kHEdge
poly t_kHEdge
Definition: kutil.h:321
posInT110Ring
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5420
p_Mult_mm
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:982
skStrategy::posInLOld
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition: kutil.h:278
skStrategy::chainCrit
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:281
skStrategy::R
TObject ** R
Definition: kutil.h:332
ncRingType
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:167
BITSET
#define BITSET
Definition: structs.h:17
skStrategy::L
LSet L
Definition: kutil.h:317
skStrategy::S
polyset S
Definition: kutil.h:296
initsevT
KINLINE unsigned long * initsevT()
Definition: kInline.h:94
skStrategy::z2homog
char z2homog
Definition: kutil.h:367
kBucketPolyRed
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition: kbuckets.cc:1060
isNotHomog
Definition: structs.h:38
initBuchMoraShift
void initBuchMoraShift(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:11862
p_Neg
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1028
nEqual
#define nEqual(n1, n2)
Definition: numbers.h:20
skStrategy::lenS
intset lenS
Definition: kutil.h:309
p_SetCompP
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:245
rKillModifiedRing
void rKillModifiedRing(ring r)
Definition: ring.cc:2957
BTEST1
#define BTEST1(a)
Definition: options.h:33
updateResult
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10180
id_DelDiv
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...
Definition: simpleideals.cc:341
kCheckSpolyCreation
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition: kutil.cc:10577
superenterpairs
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4730
totaldegreeWecart
long totaldegreeWecart(poly p, ring r)
Definition: weight.cc:222
posInT110
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5378
skStrategy::tailRing
ring tailRing
Definition: kutil.h:335
idInsertPoly
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
Definition: simpleideals.cc:639
redtailBba
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7379
length
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
ind_fact_2
long ind_fact_2(long arg)
Definition: kutil.cc:4055
SI_SAVE_OPT1
#define SI_SAVE_OPT1(A)
Definition: options.h:21
p_ShallowCopyDelete
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition: p_polys.h:869
p_ExpVectorCopy
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition: p_polys.h:1242
itoInsert
int itoInsert(poly p, int uptodeg, int lV, const ring r)
Definition: shiftgb.cc:320
TEST_OPT_CONTENTSB
#define TEST_OPT_CONTENTSB
Definition: options.h:124
__p_GetComp
#define __p_GetComp(p, r)
Definition: monomials.h:67
ksReducePolyTailSig
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition: kstd2.cc:673
prMapR
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition: prCopy.cc:46
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
pLDeg1c_Deg
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:932
skStrategy::tailBin
omBin tailBin
Definition: kutil.h:337
TEST_OPT_DEBUG
#define TEST_OPT_DEBUG
Definition: options.h:106
pNeg
#define pNeg(p)
Definition: polys.h:177
p_Test
#define p_Test(p, r)
Definition: p_polys.h:155
nc_rComplete
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5519
p_wrp
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:234
skStrategy::overflow
char overflow
Definition: kutil.h:397
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:349
pGetShortExpVector
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition: polys.h:146
n_Q
rational (GMP) numbers
Definition: coeffs.h:30
REDTAIL_CANONICALIZE
#define REDTAIL_CANONICALIZE
idTest
#define idTest(id)
Definition: ideals.h:46
pp_Mult_mm
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:972
posInS
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:4934
initSbaCrit
void initSbaCrit(kStrategy strat)
Definition: kutil.cc:9612
skStrategy::sevS
unsigned long * sevS
Definition: kutil.h:312
skStrategy::homog
char homog
Definition: kutil.h:365
kBucketGetLm
const poly kBucketGetLm(kBucket_pt bucket)
Definition: kbuckets.cc:487
pLDeg1c_WFirstTotalDegree
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1059
sValAssign_sys::arg
short arg
Definition: gentable.cc:105
pDelete
#define pDelete(p_ptr)
Definition: polys.h:166
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: kstd2.cc:3540
pLtCmp
#define pLtCmp(p, q)
Definition: polys.h:118
posInT_EcartpLength
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5496
skStrategy::honey
char honey
Definition: kutil.h:370
testHomog
Definition: structs.h:40
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
posInL0Ring
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5990
postReduceByMon
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
Definition: kutil.cc:10805
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition: simpleideals.cc:767
enlargeL
static void enlargeL(LSet *L, int *length, const int incr)
Definition: kutil.cc:648
posInT_FDegpLength
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11503
loop
#define loop
Definition: structs.h:77
skStrategy::B
LSet B
Definition: kutil.h:318
skStrategy::Lmax
int Lmax
Definition: kutil.h:343
pSetComp
#define pSetComp(p, v)
Definition: polys.h:37
syzCriterion
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6944
pJet
#define pJet(p, m)
Definition: polys.h:342
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
TEST_OPT_REDSB
#define TEST_OPT_REDSB
Definition: options.h:102
p_Lcm
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1599
initec
static intset initec(const int maxnr)
Definition: kutil.cc:501
ind2
long ind2(long arg)
Definition: kutil.cc:4043
p_LmDivisibleBy
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1794
posInSyz
int posInSyz(const kStrategy strat, poly sig)
Definition: kutil.cc:6182
posInT17_cRing
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5798
p_ExpVectorSub
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition: p_polys.h:1368
pLDegb
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:802
skStrategy::lmBin
omBin lmBin
Definition: kutil.h:336
p_LmCheckIsFromRing
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:67
enterSMoraNF
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1327
hasPurePower
BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition: kstd1.cc:959
posInT19
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5864
found
bool found
Definition: facFactorize.cc:56
p_LPshiftT
poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r)
Definition: shiftgb.cc:41
skStrategy::blockred
int blockred
Definition: kutil.h:357
setmax
#define setmax
Definition: kutil.h:28
nGreaterZero
#define nGreaterZero(n)
Definition: numbers.h:27
test_PosInL
int(* test_PosInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kstd2.cc:81
p_SetExp
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:476
skStrategy::t_kNoether
poly t_kNoether
Definition: kutil.h:323
ringorder_C
Definition: ring.h:79
k_LmInit_currRing_2_tailRing
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:875
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1324
p_LmCheckPolyRing
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:116
prMoveR
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:90
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:403
rGetCurrSyzLimit
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:713
skStrategy::syzidxmax
int syzidxmax
Definition: kutil.h:341
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:183
rAssure_c_dp
ring rAssure_c_dp(const ring r)
Definition: ring.cc:4876
newHEdge
BOOLEAN newHEdge(kStrategy strat)
Definition: kutil.cc:10514
kTest
#define kTest(A)
Definition: kutil.h:640
redtailBba_Z
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition: kInline.h:1100
kMergeBintoLSba
void kMergeBintoLSba(kStrategy strat)
Definition: kutil.cc:3102
chainCritOpt_1
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3336
p_SetExpV
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1463
ksCreateShortSpoly
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition: kspoly.cc:998
syzCriterionInc
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6979
kFindNextDivisibleByInS
int kFindNextDivisibleByInS(const kStrategy strat, int start, int max_ind, LObject *L)
Definition: kstd2.cc:265
p_WFirstTotalDegree
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:587
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:797
TEST_OPT_LENGTH
#define TEST_OPT_LENGTH
Definition: options.h:127
posInLSigRing
int posInLSigRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6046
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
skStrategy::sevSyz
unsigned long * sevSyz
Definition: kutil.h:313
ksCreateSpoly
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition: kspoly.cc:753
skStrategy::red2
int(* red2)(LObject *L, kStrategy strat)
Definition: kutil.h:269
initEcartPairBba
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition: kutil.cc:1253
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:582
denominator_list
denominator_list_s * denominator_list
Definition: kutil.h:58
posInLSpecial
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5921
ALLOW_PROD_CRIT
#define ALLOW_PROD_CRIT(A)
Definition: kutil.h:388
test_PosInT
int(* test_PosInT)(const TSet T, const int tl, LObject &h)
Definition: kstd2.cc:80
p_ExpVectorAdd
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition: p_polys.h:1339
rField_is_Ring_Z
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:473
TRUE
#define TRUE
Definition: auxiliary.h:98
skStrategy::s_2_t
KINLINE TObject * s_2_t(int i)
Definition: kInline.h:42
TEST_OPT_INTSTRATEGY
#define TEST_OPT_INTSTRATEGY
Definition: options.h:108
i
int i
Definition: cfEzgcd.cc:125
redtailSba
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kstd2.cc:1133
p_OneComp
BOOLEAN p_OneComp(poly p, const ring r)
return TRUE if all monoms have the same component
Definition: p_polys.cc:1197
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:113
rHasLocalOrMixedOrdering
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:751
skStrategy::syz
polyset syz
Definition: kutil.h:297
ksReducePoly
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:39
res
CanonicalForm res
Definition: facAbsFact.cc:64
nIsOne
#define nIsOne(n)
Definition: numbers.h:25
kBucket_Add_q
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition: kbuckets.cc:635
skStrategy::sl
int sl
Definition: kutil.h:340
n_Ann
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
nc_lie
Definition: nc.h:18
idrMoveR
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
skStrategy::redTailChange
char redTailChange
Definition: kutil.h:392
kBucketDestroy
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:212
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition: simpleideals.cc:781
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
posInSMonFirst
int posInSMonFirst(const kStrategy strat, const int length, const poly p)
Definition: kutil.cc:5035
skStrategy::T
TSet T
Definition: kutil.h:316
redRing
int redRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:438
skStrategy::posInLDependsOnLength
char posInLDependsOnLength
Definition: kutil.h:382
skStrategy::syzl
int syzl
Definition: kutil.h:341
skStrategy::LazyDegree
int LazyDegree
Definition: kutil.h:345
Sy_bit
#define Sy_bit(x)
Definition: options.h:31
enterSBba
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9028
cd
CanonicalForm cd(bCommonDen(FF))
Definition: cfModGcd.cc:4030
posInT2
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5195
skStrategy::Gebauer
char Gebauer
Definition: kutil.h:371
TEST_OPT_NOT_BUCKETS
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:103
initEcartNormal
void initEcartNormal(TObject *h)
Definition: kutil.cc:1238
PrintS
void PrintS(const char *s)
Definition: reporter.cc:283
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
TEST_OPT_NOT_SUGAR
#define TEST_OPT_NOT_SUGAR
Definition: options.h:104
skStrategy::syzIdx
intset syzIdx
Definition: kutil.h:303
lc
CanonicalForm lc(const CanonicalForm &f)
Definition: canonicalform.h:297
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
pLDeg1_WFirstTotalDegree
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1029
p_Cmp
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1642
kBucketInit
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:474
pLcm
#define pLcm(a, b, m)
Definition: polys.h:269
message
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition: kutil.cc:7727
kbTest
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:193
finalReduceByMon
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition: kutil.cc:10962
skStrategy::LazyPass
int LazyPass
Definition: kutil.h:345
setmaxTinc
#define setmaxTinc
Definition: kutil.h:33
TEST_OPT_OLDSTD
#define TEST_OPT_OLDSTD
Definition: options.h:120
ksReducePolyTail
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1023
posInT_pLength
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11540
skStrategy::newIdeal
int newIdeal
Definition: kutil.h:349
T
static jList * T
Definition: janet.cc:31
skStrategy::Shdl
ideal Shdl
Definition: kutil.h:293
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition: simpleideals.cc:171
rField_is_Ring
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:476
posInTrg0
int posInTrg0(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5302
completeReduce
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition: kutil.cc:10392
skStrategy::sig
polyset sig
Definition: kutil.h:298
denominator_list_s
Definition: kutil.h:60
posInL11Ringls
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6334
skStrategy::posInL
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:274
skStrategy::kNoetherTail
KINLINE poly kNoetherTail()
Definition: kInline.h:61
TSet
TObject * TSet
Definition: kutil.h:54
initS_2_R
static int * initS_2_R(const int maxnr)
Definition: kutil.cc:510
exitBuchMora
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:9947
enterSSba
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9131
h
static Poly * h
Definition: janet.cc:972
rIsRatGRing
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:414
ENTER_USE_MEMMOVE
#define ENTER_USE_MEMMOVE
Definition: kutil.cc:50
redFirst
int redFirst(LObject *h, kStrategy strat)
Definition: kstd1.cc:529
initenterpairs
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3700
ksReducePolySig
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:308
skStrategy::fromT
char fromT
Definition: kutil.h:372
max
static int max(int a, int b)
Definition: fast_mult.cc:264
skStrategy::pOrigFDeg_TailRing
pFDegProc pOrigFDeg_TailRing
Definition: kutil.h:288
posInL17Ring
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6763
initenterstrongPairsSig
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4476
initL
static LSet initL(int nr=setmaxL)
Definition: kutil.h:414
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:698
initBuchMora
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:9871
intset
int * intset
Definition: kutil.h:48
pInit
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:59
redMora
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8756
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: kInline.h:933
pCopyL2p
poly pCopyL2p(LObject H, kStrategy strat)
Definition: kutil.cc:11741
OPT_REDTAIL
#define OPT_REDTAIL
Definition: options.h:89
pOne
#define pOne()
Definition: polys.h:289
kMergeBintoL
void kMergeBintoL(kStrategy strat)
Definition: kutil.cc:3081
enterSyz
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9452
posInL10
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1009
siCntrlc
BOOLEAN siCntrlc
Definition: options.c:14
cancelunit1
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition: kutil.cc:8644
kFindDivisibleByInT
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:86
enterOnePairLift
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2141
intvec
Definition: intvec.h:16
pLDeg1c_Totaldegree
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:996
pIter
#define pIter(p)
Definition: monomials.h:41
setmaxT
#define setmaxT
Definition: kutil.h:32
p_Cleardenom
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2779
p_ExpVectorAddSub
static void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
Definition: p_polys.h:1384
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
posInL11Ring
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6264
initenterpairsSigRing
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3825
skStrategy::sevSig
unsigned long * sevSig
Definition: kutil.h:314
skStrategy::syzmax
int syzmax
Definition: kutil.h:341
pGetShallowCopyDeleteProc
pShallowCopyDeleteProc pGetShallowCopyDeleteProc(ring, ring)
Definition: pShallowCopyDelete.cc:48
pLDeg1c
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:868
p_LmExpVectorAddIsOk
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:1936
nDiv
#define nDiv(a, b)
Definition: numbers.h:32
posInLF5CRing
int posInLF5CRing(const LSet set, int start, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6298
kTest_TS
#define kTest_TS(A)
Definition: kutil.h:641
initBuchMoraPos
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:9698
n_Init
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
p_DivisibleBy
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1803
clearSbatch
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4704
sugarDivisibleBy
static BOOLEAN sugarDivisibleBy(int ecart1, int ecart2)
Definition: kutil.cc:1271
p_GetExpV
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1448
p_Init
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1249
p_LmCmp
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1488
chainCritPart
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3411
p_ExpVectorSum
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1353
pp
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
p_GetMaxExpP
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
kBucketClear
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:502
kFindDivisibleByInS_T
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:7161
skStrategy::lenSw
wlen_set lenSw
Definition: kutil.h:310
rBlocks
static int rBlocks(ring r)
Definition: ring.h:558
__pp_Mult_nn
#define __pp_Mult_nn(p, n, r)
Definition: p_polys.h:943
tmp1
CFList tmp1
Definition: facFqBivar.cc:70
messageStat
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7768
pLtCmpOrdSgnDiffM
#define pLtCmpOrdSgnDiffM(p, q)
Definition: polys.h:120
initSyzRules
void initSyzRules(kStrategy strat)
Definition: kutil.cc:8187
skStrategy::S_2_R
int * S_2_R
Definition: kutil.h:334
pLcmRat
void pLcmRat(poly a, poly b, poly m, int rat_shift)
Definition: ratgring.cc:30
posInL15Ring
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6678
skStrategy::kHEdgeFound
char kHEdgeFound
Definition: kutil.h:369
skStrategy::noTailReduction
char noTailReduction
Definition: kutil.h:371
pCompareChain
BOOLEAN pCompareChain(poly p, poly p1, poly p2, poly lcm, const ring R)
Returns TRUE if.
Definition: kpolys.cc:20
messageSets
#define messageSets(s)
Definition: kutil.h:532
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2812
sort
void sort(CFArray &A, int l=0)
quick sort A
Definition: facSparseHensel.h:114
kDebugPrint
void kDebugPrint(kStrategy strat)
Definition: kutil.cc:11574
kTest_L
#define kTest_L(T)
Definition: kutil.h:644
pAdd
#define pAdd(p, q)
Definition: polys.h:182
pLmInit
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:62
pDivideM
#define pDivideM(a, b)
Definition: polys.h:268
skStrategy::news
char news
Definition: kutil.h:393
ringorder_c
Definition: ring.h:78
OPT_INTSTRATEGY
#define OPT_INTSTRATEGY
Definition: options.h:90
skStrategy::syzComp
int syzComp
Definition: kutil.h:346
DENOMINATOR_LIST
denominator_list DENOMINATOR_LIST
Definition: kutil.cc:86
posInT13
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5467
help
#define help
Definition: libparse.cc:1227
Kstd1_deg
int Kstd1_deg
Definition: kutil.cc:235
posInL13
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6608
wlen_type
int64 wlen_type
Definition: kutil.h:49
pSetCoeff
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:30
kFindInT
int kFindInT(poly p, TSet T, int tlength)
returns index of p in TSet, or -1 if not found
Definition: kutil.cc:703
pDecrExp
#define pDecrExp(p, i)
Definition: polys.h:43
posInL110Ring
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6561
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
skStrategy::NotUsedAxis
BOOLEAN * NotUsedAxis
Definition: kutil.h:324
skStrategy::interpt
char interpt
Definition: kutil.h:364
ideal_isInV
int ideal_isInV(ideal I, int lV)
Definition: shiftgb.cc:304
skStrategy::kHEdge
poly kHEdge
Definition: kutil.h:319
skStrategy::posInLSba
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:272
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:438
skStrategy::pOrigLDeg_TailRing
pLDegProc pOrigLDeg_TailRing
Definition: kutil.h:289
p_LmFree
static void p_LmFree(poly p, ring)
Definition: p_polys.h:670
skStrategy::rewCrit2
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition: kutil.h:284
redSig
int redSig(LObject *h, kStrategy strat)
Definition: kstd2.cc:711
KSTD_NF_NONORM
#define KSTD_NF_NONORM
Definition: kstd1.h:20
initBba
void initBba(kStrategy strat)
Definition: kstd1.cc:1337
nc_CreateShortSpoly
poly nc_CreateShortSpoly(poly p1, poly p2, const ring r)
Definition: old.gring.cc:1878
nIsZero
#define nIsZero(n)
Definition: numbers.h:19
initSbaPos
void initSbaPos(kStrategy strat)
Definition: kutil.cc:9965
skStrategy::cv
int cv
Definition: kutil.h:362
p_Deg
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:578
posInL11
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6222
redNFBound
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
Definition: kstd2.cc:1763
skStrategy::sigdrop
bool sigdrop
Definition: kutil.h:352
omBin
omBin_t * omBin
Definition: omStructs.h:11
nMult
#define nMult(n1, n2)
Definition: numbers.h:17
posInIdealMonFirst
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
Definition: kutil.cc:5112
posInL17_cRing
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6877
p_Delete
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:842
initSL
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7940
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
skStrategy::Ll
int Ll
Definition: kutil.h:343
create_count
int create_count
Definition: kspoly.cc:24
min
static int min(int a, int b)
Definition: fast_mult.cc:268
posInL17
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6719
postReduceByMonSig
void postReduceByMonSig(LObject *h, kStrategy strat)
Definition: kutil.cc:10873
p_One
poly p_One(const ring r)
Definition: p_polys.cc:1302
sbaCheckGcdPair
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition: kutil.cc:1607
enterpairsShift
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR, int uptodeg, int lV)
Definition: kutil.cc:12442
maxdegreeWecart
long maxdegreeWecart(poly p, int *l, ring r)
Definition: weight.cc:252
posInT15Ring
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5589
setmaxL
#define setmaxL
Definition: kutil.h:29
redtailBba
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1087
HCord
int HCord
Definition: kutil.cc:234
normalize
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition: syz3.cc:1026
initBuchMoraPosRing
void initBuchMoraPosRing(kStrategy strat)
Definition: kutil.cc:9784
rWrite
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:226
chainCritNormal
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3123
skStrategy::c3
int c3
Definition: kutil.h:339
si_max
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
bound
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
p_Shrink
poly p_Shrink(poly p, int lV, const ring r)
Definition: shiftgb.cc:369
mult
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:647
skStrategy::LDegLast
char LDegLast
Definition: kutil.h:378
enterSMora
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1273
skStrategy::p_shallow_copy_delete
pShallowCopyDeleteProc p_shallow_copy_delete
Definition: kutil.h:330
pLDeg1_Deg
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:901
redtailBbaBound
KINLINE poly redtailBbaBound(poly p, int pos, kStrategy strat, int bound, BOOLEAN normalize)
Definition: kInline.h:1093
skStrategy::sevT
unsigned long * sevT
Definition: kutil.h:315
pAssume1
#define pAssume1(cond)
Definition: monomials.h:174
p_CheckPolyRing
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition: pDebug.cc:108
rRing_has_Comp
#define rRing_has_Comp(r)
Definition: monomials.h:265
posInL110
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6520
redBba
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition: kutil.cc:8732
ringorder_a
Definition: ring.h:76
initSLSba
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8037
nSub
#define nSub(n1, n2)
Definition: numbers.h:22
skStrategy::sbaEnterS
int sbaEnterS
Definition: kutil.h:355
BVERBOSE
#define BVERBOSE(a)
Definition: options.h:34
Print
#define Print
Definition: emacs.cc:79
skStrategy::initEcartPair
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition: kutil.h:277
nInvers
#define nInvers(a)
Definition: numbers.h:33
skStrategy::newt
char newt
Definition: kutil.h:394
initSbaBuchMora
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:10067
TEST_OPT_WEIGHTM
#define TEST_OPT_WEIGHTM
Definition: options.h:118
KINLINE
#define KINLINE
Definition: kutil.h:44
TEST_OPT_SUGARCRIT
#define TEST_OPT_SUGARCRIT
Definition: options.h:105
cleanTSbaRing
void cleanTSbaRing(kStrategy strat)
Definition: kutil.cc:589
omMergeStickyBinIntoBin
void omMergeStickyBinIntoBin(omBin sticky_bin, omBin into_bin)
Definition: omBin.c:392
reorderS
void reorderS(int *suc, kStrategy strat)
Definition: kutil.cc:4881
p_NSet
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1432
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
pIsPurePower
#define pIsPurePower(p)
Definition: polys.h:225
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:36
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:400
pp_Test
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:157
posInLF5C
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:6210
idInsertPolyOnPos
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
Definition: simpleideals.cc:658
red_count
int red_count
Definition: kspoly.cc:23
initsevS
static unsigned long * initsevS(const int maxnr)
Definition: kutil.cc:506
TEST_OPT_IDLIFT
#define TEST_OPT_IDLIFT
Definition: options.h:126
pSetCoeff0
#define pSetCoeff0(p, n)
Definition: monomials.h:63
rModifyRing
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2597
n_Gcd
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
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
p_GetExpDiff
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:623
skStrategy::pairtest
BOOLEAN * pairtest
Definition: kutil.h:325
showOption
char * showOption()
Definition: misc_ip.cc:727
m
int m
Definition: cfEzgcd.cc:121
skStrategy::kNoether
poly kNoether
Definition: kutil.h:320
enterOnePairRing
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1280
HEckeTest
void HEckeTest(poly pp, kStrategy strat)
Definition: kutil.cc:466
skStrategy::tl
int tl
Definition: kutil.h:342
skStrategy::Bl
int Bl
Definition: kutil.h:344
WarnS
#define WarnS
Definition: emacs.cc:77
n_DivBy
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:783
assume
#define assume(x)
Definition: mod2.h:384
p_GetMaxExpL
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
NULL
#define NULL
Definition: omList.c:9
pLmDelete
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:74
posInT1
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5167
pSetm
#define pSetm(p)
Definition: polys.h:246
idSyzygies
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition: ideals.cc:730
skStrategy::noClearS
char noClearS
Definition: kutil.h:395
skStrategy::length_pLength
char length_pLength
Definition: kutil.h:380
mflush
#define mflush()
Definition: reporter.h:56
pLmShortDivisibleBy
#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:140
p_SetComp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:238
l
int l
Definition: cfEzgcd.cc:93
lcm
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:709
enlargeT
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition: kutil.cc:515
nDelete
#define nDelete(n)
Definition: numbers.h:16
posInLrg0
int posInLrg0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6436
skStrategy::lastAxis
int lastAxis
Definition: kutil.h:348
p_WTotaldegree
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:604
omRealloc0Size
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:219
kBucket
Definition: kbuckets.h:174
R
#define R
Definition: sirandom.c:26
initSSpecialSba
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8482
posInT11Ring
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5261
skStrategy::completeReduce_retry
char completeReduce_retry
Definition: kutil.h:396
TEST_OPT_SB_1
#define TEST_OPT_SB_1
Definition: options.h:116
p_Setm
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:224
LObject
class sLObject LObject
Definition: kutil.h:53
skStrategy::ak
int ak
Definition: kutil.h:345
posInL15
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6643
TEST_OPT_CANCELUNIT
#define TEST_OPT_CANCELUNIT
Definition: options.h:125
gcd
int gcd(int a, int b)
Definition: walkSupport.cc:836
initenterpairsShift
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV)
Definition: kutil.cc:12369
pLmDivisibleBy
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition: polys.h:134
pSetExp
#define pSetExp(p, i, v)
Definition: polys.h:41
updateSShift
void updateSShift(kStrategy strat, int uptodeg, int lV)
Definition: kutil.cc:11834
initenterstrongPairs
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4454
denominator_list_s::next
denominator_list next
Definition: kutil.h:60
doRed
static int doRed(LObject *h, TObject *with, BOOLEAN intoT, kStrategy strat, bool redMoraNF)
Definition: kstd1.cc:117
cancelunit
void cancelunit(LObject *L, BOOLEAN inNF)
Definition: kutil.cc:331
pDivComp
static int pDivComp(poly p, poly q)
Definition: kutil.cc:185
TEST_OPT_REDTHROUGH
#define TEST_OPT_REDTHROUGH
Definition: options.h:119
p_Totaldegree
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1435
skStrategy::pOrigFDeg
pFDegProc pOrigFDeg
Definition: kutil.h:286
p
int p
Definition: cfModGcd.cc:4019
initSba
void initSba(ideal F, kStrategy strat)
Definition: kstd1.cc:1390
pShallowCopyDeleteProc
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:50
REDNF_CANONICALIZE
#define REDNF_CANONICALIZE
kBucketCreate
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:205
posInT17Ring
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5691
messageStatSBA
void messageStatSBA(int hilbcount, kStrategy strat)
Definition: kutil.cc:7780
enterL
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1214
redLazy
int redLazy(LObject *h, kStrategy strat)
Definition: kstd2.cc:1254
deleteInL
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1151
skStrategy::initEcart
void(* initEcart)(TObject *L)
Definition: kutil.h:270
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
p_GetMaxExp
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:733
nInit
#define nInit(i)
Definition: numbers.h:24
pLmCmp
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:101
initSSpecial
void initSSpecial(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8338
H
CanonicalForm H
Definition: facAbsFact.cc:64
rIsSyzIndexRing
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:710
skStrategy::red
int(* red)(LObject *L, kStrategy strat)
Definition: kutil.h:268
kHomModDeg
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2082
initEcartBBA
void initEcartBBA(TObject *h)
Definition: kutil.cc:1246
skStrategy::lV
int lV
Definition: kutil.h:361
enterpairs
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4758
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:165
SI_RESTORE_OPT1
#define SI_RESTORE_OPT1(A)
Definition: options.h:24
skStrategy::nrsyzcrit
int nrsyzcrit
Definition: kutil.h:353
n_SetMap
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
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:24
skStrategy::posInT
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition: kutil.h:271
pNormalize
#define pNormalize(p)
Definition: polys.h:291
posInT15
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5535
skStrategy::currIdx
int currIdx
Definition: kutil.h:307
initenterpairsSig
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3765
kStd
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:2095
p_ISet
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1286
comp
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
Definition: facSparseHensel.h:25
Q
#define Q
Definition: sirandom.c:25
posInT0
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:5156
p_Mult_q
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1035
deleteInS
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:1044
pHead
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:65
k_GetStrongLeadTerms
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:976
initEcartPairMora
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition: kutil.cc:1260
skStrategy::sugarCrit
char sugarCrit
Definition: kutil.h:370
rHasMixedOrdering
BOOLEAN rHasMixedOrdering(const ring r)
Definition: ring.h:752
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:48
tmp2
CFList tmp2
Definition: facFqBivar.cc:70
redFirstShift
int redFirstShift(LObject *h, kStrategy strat)
Definition: kstd2.cc:4264
denominator_list_s::n
number n
Definition: kutil.h:60
skStrategy::minim
int minim
Definition: kutil.h:350
enterOnePairNormal
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:1860
PrintLn
void PrintLn()
Definition: reporter.cc:309
kInterRed
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3386
skStrategy::use_buckets
char use_buckets
Definition: kutil.h:376
skStrategy::Bmax
int Bmax
Definition: kutil.h:344
sbaRing
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
Definition: kutil.cc:11154
rIsSCA
static bool rIsSCA(const ring r)
Definition: nc.h:198
kStratChangeTailRing
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition: kutil.cc:11028
p_GetShortExpVector
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4660
initR
KINLINE TObject ** initR()
Definition: kInline.h:89
p_LPshift
poly p_LPshift(poly p, int sh, int uptodeg, int lV, const ring r)
Definition: shiftgb.cc:73
omGetStickyBinOfBin
omBin omGetStickyBinOfBin(omBin bin)
Definition: omBin.c:369
skStrategy::syzCrit
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.h:282
pHaveCommonMonoms
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition: pDebug.cc:169
p_FDeg
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:369
kCreateZeroPoly
poly kCreateZeroPoly(long exp[], long cabsind, poly *t_p, ring leadRing, ring tailRing)
Definition: kutil.cc:4259
enterExtendedSpoly
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4503
initHilbCrit
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
Definition: kutil.cc:9530
p_MaxComp
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:283
exitSba
void exitSba(kStrategy strat)
Definition: kutil.cc:10140
pSub
#define pSub(a, b)
Definition: polys.h:261
redHoney
int redHoney(LObject *h, kStrategy strat)
Definition: kstd2.cc:1402
nCoeff_is_Ring_Z
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:755
nCopy
#define nCopy(n)
Definition: numbers.h:15
n_ExtGcd
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
n_IsUnit
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
rRingOrder_t
rRingOrder_t
order stuff
Definition: ring.h:73
skStrategy::HCord
int HCord
Definition: kutil.h:347
ksReducePolySigRing
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:505
pNext
#define pNext(p)
Definition: monomials.h:40
superenterpairsSig
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4740
pSize
#define pSize(p)
Definition: polys.h:292
enterT
void enterT(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9269
idSort
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition: ideals.h:185
setmaxLinc
#define setmaxLinc
Definition: kutil.h:30
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
p_LmShortDivisibleBy
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1828
pCmp
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition: polys.h:111
OPT_INTERRUPT
#define OPT_INTERRUPT
Definition: options.h:77
nc_kBucketPolyRed
static void nc_kBucketPolyRed(kBucket_pt b, poly p, number *c)
Definition: nc.h:284
posInT11
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5225
enterTShift
void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV)
Definition: kutil.cc:12473
twoPow
long twoPow(long arg)
Definition: kutil.cc:4070
skStrategy::blockredmax
int blockredmax
Definition: kutil.h:358
redSigRing
int redSigRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:881
nKillChar
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:510
idIsConstant
#define idIsConstant(I)
Definition: ideals.h:39
skStrategy::enterOnePair
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.h:280
idPosConstant
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:36
redHomog
int redHomog(LObject *h, kStrategy strat)
Definition: kstd2.cc:548
pMoveCurrTail2poly
poly pMoveCurrTail2poly(poly p, kStrategy strat)
Definition: kutil.cc:11724
KSTD_NF_LAZY
#define KSTD_NF_LAZY
Definition: kstd1.h:16
pIsMonomOf
BOOLEAN pIsMonomOf(poly p, poly m)
Definition: pDebug.cc:159
skStrategy::nrrewcrit
int nrrewcrit
Definition: kutil.h:354
initS
void initS(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7846
nextZeroSimplexExponent
int nextZeroSimplexExponent(long exp[], long ind[], long cexp[], long cind[], long *cabsind, long step[], long bound, long N)
Definition: kutil.cc:4193
rComplete
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:3350
pWrite
void pWrite(poly p)
Definition: polys.h:282
omReallocSize
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:218
wrp
void wrp(poly p)
Definition: polys.h:284
omfree
#define omfree(addr)
Definition: omAllocDecl.h:235
p_Cleardenom_n
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:2888
skStrategy::pOrigLDeg
pLDegProc pOrigLDeg
Definition: kutil.h:287
p_CheckIsFromRing
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:98
si_opt_1
unsigned si_opt_1
Definition: options.c:5