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

Go to the source code of this file.

Data Structures

struct  denominator_list_s
 
class  sTObject
 
class  sLObject
 
class  skStrategy
 

Macros

#define HAVE_TAIL_RING
 
#define setmax   128
 
#define setmaxL   ((4096-12)/sizeof(LObject))
 
#define setmaxLinc   ((4096)/sizeof(LObject))
 
#define setmaxT   ((4096-12)/sizeof(TObject))
 
#define setmaxTinc   ((4096)/sizeof(TObject))
 
#define RED_CANONICALIZE   200
 
#define REDNF_CANONICALIZE   60
 
#define REDTAIL_CANONICALIZE   100
 
#define KINLINE
 
#define NO_KINLINE   1
 
#define ALLOW_PROD_CRIT(A)   (!(A)->no_prod_crit)
 

Typedefs

typedef int * intset
 
typedef int64 wlen_type
 
typedef wlen_typewlen_set
 
typedef class sTObject TObject
 
typedef class sLObject LObject
 
typedef TObjectTSet
 
typedef LObjectLSet
 
typedef denominator_list_sdenominator_list
 

Functions

void deleteHC (poly *p, int *e, int *l, kStrategy strat)
 
void deleteHC (LObject *L, kStrategy strat, BOOLEAN fromNext=FALSE)
 
void deleteInS (int i, kStrategy strat)
 
void deleteInSSba (int i, kStrategy strat)
 
void cleanT (kStrategy strat)
 
static LSet initL (int nr=setmaxL)
 
void deleteInL (LSet set, int *length, int j, kStrategy strat)
 
void enterL (LSet *set, int *length, int *LSetmax, LObject p, int at)
 
void enterSBba (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSBbaShift (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSSba (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void initEcartPairBba (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
 
void initEcartPairMora (LObject *Lp, poly f, poly g, int ecartF, int ecartG)
 
int posInS (const kStrategy strat, const int length, const poly p, const int ecart_p)
 
int posInSMonFirst (const kStrategy strat, const int length, const poly p)
 
int posInIdealMonFirst (const ideal F, const poly p, int start=0, int end=-1)
 
int posInT0 (const TSet set, const int length, LObject &p)
 
int posInT1 (const TSet set, const int length, LObject &p)
 
int posInT2 (const TSet set, const int length, LObject &p)
 
int posInT11 (const TSet set, const int length, LObject &p)
 
int posInTSig (const TSet set, const int length, LObject &p)
 
int posInT110 (const TSet set, const int length, LObject &p)
 
int posInT13 (const TSet set, const int length, LObject &p)
 
int posInT15 (const TSet set, const int length, LObject &p)
 
int posInT17 (const TSet set, const int length, LObject &p)
 
int posInT17_c (const TSet set, const int length, LObject &p)
 
int posInT19 (const TSet set, const int length, LObject &p)
 
int posInT_EcartpLength (const TSet set, const int length, LObject &p)
 
int posInT_EcartFDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_FDegpLength (const TSet set, const int length, LObject &p)
 
int posInT_pLength (const TSet set, const int length, LObject &p)
 
void reorderS (int *suc, kStrategy strat)
 
int posInLF5C (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLSig (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLSigRing (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLRing (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInSyz (const kStrategy strat, const poly sig)
 
int posInL0 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL11 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL11Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInLF5CRing (const LSet set, int start, const int length, LObject *L, const kStrategy strat)
 
int posInL11Ringls (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL13 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL15 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL15Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL17 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL10 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL10Ring (const LSet set, const int length, LObject *L, const kStrategy strat)
 
int posInL110 (const LSet set, const int length, LObject *L, const kStrategy strat)
 
KINLINE poly redtailBba (poly p, int end_pos, kStrategy strat, BOOLEAN normalize=FALSE)
 
KINLINE poly redtailBbaBound (poly p, int end_pos, kStrategy strat, int bound, BOOLEAN normalize=FALSE)
 
KINLINE poly redtailBba_Ring (poly p, int end_pos, kStrategy strat)
 
KINLINE poly redtailBba_Z (poly p, int end_pos, kStrategy strat)
 
poly redtailBba_Ring (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_Z (LObject *L, int end_pos, kStrategy strat)
 
void redtailBbaAlsoLC_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailBbaBound (LObject *L, int end_pos, kStrategy strat, int bound, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailSba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailBba (TObject *T, int end_pos, kStrategy strat)
 
poly redtail (poly p, int end_pos, kStrategy strat)
 
poly redtail (LObject *L, int end_pos, kStrategy strat)
 
poly redNF (poly h, int &max_ind, int nonorm, kStrategy strat)
 
int redNF0 (LObject *P, kStrategy strat)
 
poly redNFTail (poly h, const int sl, kStrategy strat)
 
int redHoney (LObject *h, kStrategy strat)
 
int redLiftstd (LObject *h, kStrategy strat)
 
int redRing (LObject *h, kStrategy strat)
 
int redRing_Z (LObject *h, kStrategy strat)
 
int redRiloc (LObject *h, kStrategy strat)
 
void enterExtendedSpoly (poly h, kStrategy strat)
 
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
 
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
int redLazy (LObject *h, kStrategy strat)
 
int redHomog (LObject *h, kStrategy strat)
 
int redSig (LObject *h, kStrategy strat)
 
int redSigRing (LObject *h, kStrategy strat)
 
void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void enterpairs (poly h, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void entersets (LObject h)
 
void pairs ()
 
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
 
void message (int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
 
void messageStat (int hilbcount, kStrategy strat)
 
void messageStatSBA (int hilbcount, kStrategy strat)
 
void messageSets (kStrategy strat)
 
void initEcartNormal (TObject *h)
 
void initEcartBBA (TObject *h)
 
void initS (ideal F, ideal Q, kStrategy strat)
 
void initSL (ideal F, ideal Q, kStrategy strat)
 
void initSLSba (ideal F, ideal Q, kStrategy strat)
 
void initSyzRules (kStrategy strat)
 
void updateS (BOOLEAN toT, kStrategy strat)
 
void enterSyz (LObject &p, kStrategy strat, int atT)
 
void enterT (LObject &p, kStrategy strat, int atT=-1)
 
void replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
void enterT_strong (LObject &p, kStrategy strat, int atT=-1)
 
void cancelunit (LObject *p, BOOLEAN inNF=FALSE)
 
void HEckeTest (poly pp, kStrategy strat)
 
void initBuchMoraCrit (kStrategy strat)
 
void initSbaCrit (kStrategy strat)
 
void initHilbCrit (ideal F, ideal Q, intvec **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found More...
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindDivisibleByInT (const kStrategy strat, const LObject *L, const int start=0)
 return -1 if no divisor is found number of first divisor in T, otherwise More...
 
int kFindDivisibleByInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kFindSameLMInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kTestDivisibleByT0_Z (const kStrategy strat, const LObject *L)
 tests if T[0] divides the leading monomial of L, returns -1 if not More...
 
int kFindDivisibleByInS (const kStrategy strat, int *max_ind, LObject *L)
 return -1 if no divisor is found number of first divisor in S, otherwise More...
 
int kFindNextDivisibleByInS (const kStrategy strat, int start, int max_ind, LObject *L)
 
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart=LONG_MAX)
 
KINLINE TSet initT ()
 
KINLINE TObject ** initR ()
 
KINLINE unsigned long * initsevT ()
 
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing, omBin bin)
 
KINLINE poly k_LmInit_currRing_2_tailRing (poly p, ring tailRing)
 
KINLINE poly k_LmInit_tailRing_2_currRing (poly p, ring tailRing)
 
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing (poly p, ring tailRing)
 
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing (poly p, ring tailRing)
 
KINLINE BOOLEAN k_GetLeadTerms (const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
 
KINLINE void k_GetStrongLeadTerms (const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring taiRing)
 
BOOLEAN kTest (kStrategy strat)
 
BOOLEAN kTest_TS (kStrategy strat)
 
BOOLEAN kTest_L (LObject *L, kStrategy strat, BOOLEAN testp=FALSE, int lpos=-1, TSet T=NULL, int tlength=-1)
 
BOOLEAN kTest_T (TObject *T, kStrategy strat, int tpos=-1, char TN='?')
 
BOOLEAN kTest_S (kStrategy strat)
 
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
 
ideal bba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
 
ideal kNF2 (ideal F, ideal Q, ideal q, kStrategy strat, int lazyReduce)
 
poly kNF2Bound (ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
 
ideal kNF2Bound (ideal F, ideal Q, ideal q, int bound, kStrategy strat, int lazyReduce)
 
void initBba (kStrategy strat)
 
void initSba (ideal F, kStrategy strat)
 
void f5c (kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, intvec *hilb)
 
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL)
 
int ksReducePolyZ (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyLC (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyGCD (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyBound (LObject *PR, TObject *PW, int bound, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySig (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySigRing (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyTail (LObject *PR, TObject *PW, poly Current, poly spNoether=NULL)
 
KINLINE int ksReducePolyTail (LObject *PR, TObject *PW, LObject *Red)
 
void ksCreateSpoly (LObject *Pair, poly spNoether=NULL, int use_buckets=0, ring tailRing=currRing, poly m1=NULL, poly m2=NULL, TObject **R=NULL)
 
poly ksCreateShortSpoly (poly p1, poly p2, ring tailRing)
 
KINLINE poly ksOldSpolyRed (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldSpolyRedNew (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldCreateSpoly (poly p1, poly p2, poly spNoether=NULL, ring r=currRing)
 
KINLINE void ksOldSpolyTail (poly p1, poly q, poly q2, poly spNoether, ring r=currRing)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
poly preIntegerCheck (ideal F, ideal Q)
 used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell More...
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell More...
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output More...
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L=NULL, TObject *T=NULL, unsigned long new_expbound=0)
 
void kStratInitChangeTailRing (kStrategy strat)
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy. More...
 
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
 
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
 
poly pMove2CurrTail (poly p, kStrategy strat)
 
poly pMoveCurrTail2poly (poly p, kStrategy strat)
 
poly pCopyL2p (LObject h, kStrategy strat)
 
void enterTShift (LObject p, kStrategy strat, int atT=-1)
 
void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
int redFirstShift (LObject *h, kStrategy strat)
 
ideal bbaShift (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
static void kDeleteLcm (LObject *P)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 

Variables

EXTERN_VAR denominator_list DENOMINATOR_LIST
 
EXTERN_VAR int strat_nr
 
EXTERN_VAR int HCord
 
EXTERN_VAR int(* test_PosInT )(const TSet T, const int tl, LObject &h)
 
EXTERN_VAR int(* test_PosInL )(const LSet set, const int length, LObject *L, const kStrategy strat)
 

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 65 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

#define ALLOW_PROD_CRIT (   A)    (!(A)->no_prod_crit)

Definition at line 395 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 27 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 49 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 50 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 36 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 37 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 38 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 29 of file kutil.h.

◆ setmaxL

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

Definition at line 30 of file kutil.h.

◆ setmaxLinc

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

Definition at line 31 of file kutil.h.

◆ setmaxT

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

Definition at line 33 of file kutil.h.

◆ setmaxTinc

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

Definition at line 34 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 63 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 53 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 55 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 60 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 55 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 59 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 55 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 54 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6875 of file kutil.cc.

6876 {
6878  return FALSE;
6879  poly p1 = pOne();
6880  poly p2 = pOne();
6881  for (int ii=strat->sl; ii>start; ii--)
6882  {
6883  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6884  {
6885  p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6886  p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6887  if (!(pLmCmp(p1,p2) == 1))
6888  {
6889  pDelete(&p1);
6890  pDelete(&p2);
6891  return TRUE;
6892  }
6893  }
6894  }
6895  pDelete(&p1);
6896  pDelete(&p2);
6897  return FALSE;
6898 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
polyset S
Definition: kutil.h:306
unsigned long * sevSig
Definition: kutil.h:324
polyset sig
Definition: kutil.h:308
LObject P
Definition: kutil.h:302
int sl
Definition: kutil.h:348
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1397
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1909
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define pDelete(p_ptr)
Definition: polys.h:186
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:105
#define pOne()
Definition: polys.h:315
#define rField_is_Ring(R)
Definition: ring.h:486

◆ arriRewCriterionPre()

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

Definition at line 6900 of file kutil.cc.

6901 {
6902  //Over Rings, there are still some changes to do: considering coeffs
6904  return FALSE;
6905  int found = -1;
6906  for (int i=strat->Bl; i>-1; i--)
6907  {
6908  if (pLmEqual(strat->B[i].sig,sig))
6909  {
6910  found = i;
6911  break;
6912  }
6913  }
6914  if (found != -1)
6915  {
6916  if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6917  {
6918  deleteInL(strat->B,&strat->Bl,found,strat);
6919  }
6920  else
6921  {
6922  return TRUE;
6923  }
6924  }
6925  poly p1 = pOne();
6926  poly p2 = pOne();
6927  for (int ii=strat->sl; ii>-1; ii--)
6928  {
6929  if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6930  {
6931  p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6932  p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6933  if (!(pLmCmp(p1,p2) == 1))
6934  {
6935  pDelete(&p1);
6936  pDelete(&p2);
6937  return TRUE;
6938  }
6939  }
6940  }
6941  pDelete(&p1);
6942  pDelete(&p2);
6943  return FALSE;
6944 }
int i
Definition: cfEzgcd.cc:132
int Bl
Definition: kutil.h:352
LSet B
Definition: kutil.h:328
bool found
Definition: facFactorize.cc:55
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1270
#define pLmEqual(p1, p2)
Definition: polys.h:111

◆ arriRewDummy()

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

Definition at line 1272 of file kInline.h.

1273 {
1274  return FALSE;
1275 }

◆ bba()

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

Definition at line 2379 of file kstd2.cc.

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

◆ bbaShift()

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

Definition at line 4347 of file kstd2.cc.

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

◆ cancelunit()

void cancelunit ( LObject p,
BOOLEAN  inNF = FALSE 
)

Definition at line 373 of file kutil.cc.

374 {
375  if(rHasGlobalOrdering (currRing)) return;
376  if(TEST_OPT_CANCELUNIT) return;
377 
378  ring r = L->tailRing;
379  poly p = L->GetLmTailRing();
380  if(p_GetComp(p, r) != 0 && !p_OneComp(p, r)) return;
381 
382  number lc=NULL; /*dummy, is always set if rField_is_Ring(r) */
383  if (rField_is_Ring(r) /*&& (rHasLocalOrMixedOrdering(r))*/)
384  lc = pGetCoeff(p);
385 
386  // Leading coef have to be a unit
387  // example 2x+4x2 should be simplified to 2x*(1+2x)
388  // and 2 is not a unit in Z
389  //if ( !(n_IsUnit(pGetCoeff(p), r->cf)) ) return;
390 
391 // for(i=r->N;i>0;i--)
392 // {
393 // if ((p_GetExp(p,i,r)>0) && (rIsPolyVar(i, r)==TRUE)) return;
394 // }
395  poly h = pNext(p);
396  int i;
397 
399  {
400  loop
401  {
402  if (h==NULL)
403  {
404  p_Delete(&pNext(p), r);
405  if (!inNF)
406  {
407  number eins= nCopy(lc);
408  if (L->p != NULL)
409  {
410  pSetCoeff(L->p,eins);
411  if (L->t_p != NULL)
412  pSetCoeff0(L->t_p,eins);
413  }
414  else
415  pSetCoeff(L->t_p,eins);
416  /* p and t_p share the same coeff, if both are !=NULL */
417  /* p==NULL==t_p cannot happen here */
418  }
419  L->ecart = 0;
420  L->length = 1;
421  //if (L->pLength > 0)
422  L->pLength = 1;
423  L->max_exp = NULL;
424 
425  if (L->t_p != NULL && pNext(L->t_p) != NULL)
426  p_Delete(&pNext(L->t_p),r);
427  if (L->p != NULL && pNext(L->p) != NULL)
428  pNext(L->p) = NULL;
429  return;
430  }
431  i = rVar(r);
432  loop
433  {
434  if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
435  i--;
436  if (i == 0) break; // does divide, try next monom
437  }
438  //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
439  // Note: As long as qring j forbidden if j contains integer (i.e. ground rings are
440  // domains), no zerodivisor test needed CAUTION
441  if (!n_DivBy(pGetCoeff(h),lc,r->cf))
442  {
443  return;
444  }
445  pIter(h);
446  }
447  }
448  else
449  {
450  loop
451  {
452  if (h==NULL)
453  {
454  p_Delete(&pNext(p), r);
455  if (!inNF)
456  {
457  number eins=nInit(1);
458  if (L->p != NULL)
459  {
460  pSetCoeff(L->p,eins);
461  if (L->t_p != NULL)
462  pSetCoeff0(L->t_p,eins);
463  }
464  else
465  pSetCoeff(L->t_p,eins);
466  /* p and t_p share the same coeff, if both are !=NULL */
467  /* p==NULL==t_p cannot happen here */
468  }
469  L->ecart = 0;
470  L->length = 1;
471  //if (L->pLength > 0)
472  L->pLength = 1;
473  L->max_exp = NULL;
474 
475  if (L->t_p != NULL && pNext(L->t_p) != NULL)
476  p_Delete(&pNext(L->t_p),r);
477  if (L->p != NULL && pNext(L->p) != NULL)
478  pNext(L->p) = NULL;
479 
480  return;
481  }
482  i = rVar(r);
483  loop
484  {
485  if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
486  i--;
487  if (i == 0) break; // does divide, try next monom
488  }
489  //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
490  pIter(h);
491  }
492  }
493 }
CanonicalForm lc(const CanonicalForm &f)
int p
Definition: cfModGcd.cc:4078
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition: coeffs.h:753
STATIC_VAR Poly * h
Definition: janet.cc:971
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define nCopy(n)
Definition: numbers.h:15
#define nInit(i)
Definition: numbers.h:24
#define TEST_OPT_CANCELUNIT
Definition: options.h:128
BOOLEAN p_OneComp(poly p, const ring r)
return TRUE if all monoms have the same component
Definition: p_polys.cc:1204
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:760

◆ chainCritNormal()

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

Definition at line 3264 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3500 of file kutil.cc.

3501 {
3502  if (strat->pairtest!=NULL)
3503  {
3504  omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3505  strat->pairtest=NULL;
3506  }
3507  /*
3508  *the elements of B enter L
3509  */
3510  kMergeBintoL(strat);
3511 }

◆ chainCritSig()

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

Definition at line 3516 of file kutil.cc.

3517 {
3518  int i,j,l;
3519  kMergeBintoLSba(strat);
3520  j = strat->Ll;
3521  loop /*cannot be changed into a for !!! */
3522  {
3523  if (j <= 0)
3524  {
3525  /*now L[0] cannot be canceled any more and the tail can be removed*/
3526  if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3527  break;
3528  }
3529  if (strat->L[j].p2 == p)
3530  {
3531  i = j-1;
3532  loop
3533  {
3534  if (i < 0) break;
3535  if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3536  {
3537  /*L[i] could be canceled but we search for a better one to cancel*/
3538  strat->c3++;
3539  if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3540  && (pNext(strat->L[l].p) == strat->tail)
3541  && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3542  && pDivisibleBy(p,strat->L[l].lcm))
3543  {
3544  /*
3545  *"NOT equal(...)" because in case of "equal" the element L[l]
3546  *is "older" and has to be from theoretical point of view behind
3547  *L[i], but we do not want to reorder L
3548  */
3549  strat->L[i].p2 = strat->tail;
3550  /*
3551  *L[l] will be canceled, we cannot cancel L[i] later on,
3552  *so we mark it with "tail"
3553  */
3554  deleteInL(strat->L,&strat->Ll,l,strat);
3555  i--;
3556  }
3557  else
3558  {
3559  deleteInL(strat->L,&strat->Ll,i,strat);
3560  }
3561  j--;
3562  }
3563  i--;
3564  }
3565  }
3566  else if (strat->L[j].p2 == strat->tail)
3567  {
3568  /*now L[j] cannot be canceled any more and the tail can be removed*/
3569  strat->L[j].p2 = p;
3570  }
3571  j--;
3572  }
3573 }
void kMergeBintoLSba(kStrategy strat)
Definition: kutil.cc:3242

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 569 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1247 of file kInline.h.

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

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10559 of file kutil.cc.

10560 {
10561  int i;
10562  int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10563  LObject L;
10564 
10565 #ifdef KDEBUG
10566  // need to set this: during tailreductions of T[i], T[i].max is out of
10567  // sync
10568  sloppy_max = TRUE;
10569 #endif
10570 
10571  strat->noTailReduction = FALSE;
10572  //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10573  if (TEST_OPT_PROT)
10574  {
10575  PrintLn();
10576 // if (timerv) writeTime("standard base computed:");
10577  }
10578  if (TEST_OPT_PROT)
10579  {
10580  Print("(S:%d)",strat->sl);mflush();
10581  }
10582  for (i=strat->sl; i>=low; i--)
10583  {
10584  int end_pos=strat->sl;
10585  if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10586  if (strat->ak==0) end_pos=i-1;
10587  TObject* T_j = strat->s_2_t(i);
10588  if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10589  {
10590  L = *T_j;
10591  #ifdef KDEBUG
10592  if (TEST_OPT_DEBUG)
10593  {
10594  Print("test S[%d]:",i);
10595  p_wrp(L.p,currRing,strat->tailRing);
10596  PrintLn();
10597  }
10598  #endif
10600  strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10601  else
10602  strat->S[i] = redtail(&L, strat->sl, strat);
10603  #ifdef KDEBUG
10604  if (TEST_OPT_DEBUG)
10605  {
10606  Print("to (tailR) S[%d]:",i);
10607  p_wrp(strat->S[i],currRing,strat->tailRing);
10608  PrintLn();
10609  }
10610  #endif
10611 
10612  if (strat->redTailChange)
10613  {
10614  if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10615  if (pNext(T_j->p) != NULL)
10616  T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10617  else
10618  T_j->max_exp = NULL;
10619  }
10621  T_j->pCleardenom();
10622  }
10623  else
10624  {
10625  assume(currRing == strat->tailRing);
10626  #ifdef KDEBUG
10627  if (TEST_OPT_DEBUG)
10628  {
10629  Print("test S[%d]:",i);
10630  p_wrp(strat->S[i],currRing,strat->tailRing);
10631  PrintLn();
10632  }
10633  #endif
10635  strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10636  else
10637  strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10639  {
10640  if (TEST_OPT_CONTENTSB)
10641  {
10642  number n;
10643  p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10644  if (!nIsOne(n))
10645  {
10647  denom->n=nInvers(n);
10648  denom->next=DENOMINATOR_LIST;
10649  DENOMINATOR_LIST=denom;
10650  }
10651  nDelete(&n);
10652  }
10653  else
10654  {
10655  strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10656  }
10657  }
10658  #ifdef KDEBUG
10659  if (TEST_OPT_DEBUG)
10660  {
10661  Print("to (-tailR) S[%d]:",i);
10662  p_wrp(strat->S[i],currRing,strat->tailRing);
10663  PrintLn();
10664  }
10665  #endif
10666  }
10667  if (TEST_OPT_PROT)
10668  PrintS("-");
10669  }
10670  if (TEST_OPT_PROT) PrintLn();
10671 #ifdef KDEBUG
10672  sloppy_max = FALSE;
10673 #endif
10674 }
char noTailReduction
Definition: kutil.h:378
int ak
Definition: kutil.h:353
KINLINE TObject * s_2_t(int i)
Definition: kInline.h:47
#define Print
Definition: emacs.cc:80
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition: kutil.cc:7093
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7169
STATIC_VAR BOOLEAN sloppy_max
Definition: kutil.cc:824
VAR denominator_list DENOMINATOR_LIST
Definition: kutil.cc:84
denominator_list_s * denominator_list
Definition: kutil.h:63
denominator_list next
Definition: kutil.h:65
class sTObject TObject
Definition: kutil.h:57
class sLObject LObject
Definition: kutil.h:58
#define nDelete(n)
Definition: numbers.h:16
#define nInvers(a)
Definition: numbers.h:33
#define nIsOne(n)
Definition: numbers.h:25
#define omAlloc(size)
Definition: omAllocDecl.h:210
poly p_GetMaxExpP(poly p, const ring r)
return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0,...
Definition: p_polys.cc:1134
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:3015
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2906
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
#define mflush()
Definition: reporter.h:58

◆ deleteHC() [1/2]

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

Definition at line 294 of file kutil.cc.

295 {
296  if (strat->kNoether!=NULL)
297  {
298  kTest_L(L,strat);
299  poly p1;
300  poly p = L->GetLmTailRing();
301  int l = 1;
302 
303  if (!fromNext && p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
304  {
305  if (L->bucket != NULL) kBucketDestroy(&L->bucket);
306  L->Delete();
307  L->Clear();
308  L->ecart = -1;
309  return;
310  }
311  if (L->bucket != NULL)
312  {
313  deleteHCBucket(L,strat);
314  return;
315  }
316  BOOLEAN cut=FALSE;
317  p1 = p;
318  while (pNext(p1)!=NULL)
319  {
320  if (p_LmCmp(pNext(p1), strat->kNoetherTail(), L->tailRing) == -1)
321  {
322  cut=(pNext(p1)!=NULL);
323  if (cut)
324  {
325  p_Delete(&pNext(p1), L->tailRing);
326 
327  if (p1 == p)
328  {
329  if (L->t_p != NULL)
330  {
331  assume(L->p != NULL && p == L->t_p);
332  pNext(L->p) = NULL;
333  }
334  L->max_exp = NULL;
335  }
336  else if (fromNext)
337  L->max_exp = p_GetMaxExpP(pNext(L->p), L->tailRing ); // p1;
338  //if (L->pLength != 0)
339  L->pLength = l;
340  // Hmmm when called from updateT, then only
341  // reset ecart when cut
342  if (fromNext)
343  L->ecart = L->pLDeg() - L->GetpFDeg();
344  }
345  break;
346  }
347  l++;
348  pIter(p1);
349  }
350  if ((!fromNext) && cut)
351  {
352  L->SetpFDeg();
353  L->ecart = L->pLDeg(strat->LDegLast) - L->GetpFDeg();
354  }
355  kTest_L(L,strat);
356  }
357 }
KINLINE poly kNoetherTail()
Definition: kInline.h:66
poly kNoether
Definition: kutil.h:329
char LDegLast
Definition: kutil.h:385
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:216
static void deleteHCBucket(LObject *L, kStrategy strat)
Definition: kutil.cc:250
BOOLEAN kTest_L(LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
Definition: kutil.cc:950
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1707
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1552

◆ deleteHC() [2/2]

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

Definition at line 359 of file kutil.cc.

360 {
361  LObject L(*p, currRing, strat->tailRing);
362 
363  deleteHC(&L, strat);
364  *p = L.p;
365  *e = L.ecart;
366  *l = L.length;
367  if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
368 }
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition: kutil.cc:294

◆ deleteInL()

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

Definition at line 1270 of file kutil.cc.

1271 {
1272  if (set[j].lcm!=NULL)
1273  {
1274  kDeleteLcm(&set[j]);
1275  }
1276  if (set[j].sig!=NULL)
1277  {
1278 #ifdef HAVE_RINGS
1279  if (pGetCoeff(set[j].sig) != NULL)
1280  pLmDelete(set[j].sig);
1281  else
1282 #endif
1283  pLmFree(set[j].sig);
1284  }
1285  if (set[j].p!=NULL)
1286  {
1287  if (pNext(set[j].p) == strat->tail)
1288  {
1289 #ifdef HAVE_RINGS
1290  if (pGetCoeff(set[j].p) != NULL)
1291  pLmDelete(set[j].p);
1292  else
1293 #endif
1294  pLmFree(set[j].p);
1295  /*- tail belongs to several int spolys -*/
1296  }
1297  else
1298  {
1299  // search p in T, if it is there, do not delete it
1300  if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1301  {
1302  // assure that for global orderings kFindInT fails
1303  //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1304  set[j].Delete();
1305  }
1306  }
1307  }
1308  if (*length > 0 && j < *length)
1309  {
1310 #ifdef ENTER_USE_MEMMOVE
1311  memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1312 #else
1313  int i;
1314  for (i=j; i < (*length); i++)
1315  set[i] = set[i+1];
1316 #endif
1317  }
1318 #ifdef KDEBUG
1319  memset(&(set[*length]),0,sizeof(LObject));
1320 #endif
1321  (*length)--;
1322 }
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
int kFindInT(poly p, TSet T, int tlength)
returns index of p in TSet, or -1 if not found
Definition: kutil.cc:742
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:709

◆ deleteInS()

void deleteInS ( int  i,
kStrategy  strat 
)

Definition at line 1163 of file kutil.cc.

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

◆ deleteInSSba()

void deleteInSSba ( int  i,
kStrategy  strat 
)

Definition at line 1215 of file kutil.cc.

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4291 of file kutil.cc.

4292 {
4293  if (nIsOne(pGetCoeff(h))) return;
4294  number gcd;
4295  bool go = false;
4296  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4297  {
4298  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4299  go = true;
4300  }
4301  else
4302  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4303  if (go || !nIsOne(gcd))
4304  {
4305  poly p = h->next;
4306  if (!go)
4307  {
4308  number tmp = gcd;
4309  gcd = n_Ann(gcd,currRing->cf);
4310  nDelete(&tmp);
4311  }
4312  p_Test(p,strat->tailRing);
4313  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4314  nDelete(&gcd);
4315 
4316  if (p != NULL)
4317  {
4318  if (TEST_OPT_PROT)
4319  {
4320  PrintS("Z");
4321  }
4322 #ifdef KDEBUG
4323  if (TEST_OPT_DEBUG)
4324  {
4325  PrintS("--- create zero spoly: ");
4326  p_wrp(h,currRing,strat->tailRing);
4327  PrintS(" ---> ");
4328  }
4329 #endif
4330  poly tmp = pInit();
4331  pSetCoeff0(tmp, pGetCoeff(p));
4332  for (int i = 1; i <= rVar(currRing); i++)
4333  {
4334  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4335  }
4337  {
4338  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4339  }
4340  p_Setm(tmp, currRing);
4341  p = p_LmFreeAndNext(p, strat->tailRing);
4342  pNext(tmp) = p;
4343  LObject Lp;
4344  Lp.Init();
4345  Lp.p = tmp;
4346  Lp.tailRing = strat->tailRing;
4347  int posx;
4348  if (Lp.p!=NULL)
4349  {
4350  strat->initEcart(&Lp);
4351  if (strat->Ll==-1)
4352  posx =0;
4353  else
4354  posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4355  Lp.sev = pGetShortExpVector(Lp.p);
4356  if (strat->tailRing != currRing)
4357  {
4358  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4359  }
4360 #ifdef KDEBUG
4361  if (TEST_OPT_DEBUG)
4362  {
4363  p_wrp(tmp,currRing,strat->tailRing);
4364  PrintLn();
4365  }
4366 #endif
4367  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4368  }
4369  }
4370  }
4371  nDelete(&gcd);
4372 }
int Lmax
Definition: kutil.h:351
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition: coeffs.h:664
static FORCE_INLINE number n_Ann(number a, const coeffs r)
if r is a ring with zero divisors, return an annihilator!=0 of b otherwise return NULL
Definition: coeffs.h:679
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:969
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1327
#define __p_GetComp(p, r)
Definition: monomials.h:63
#define rRing_has_Comp(r)
Definition: monomials.h:266
#define __pp_Mult_nn(p, n, r)
Definition: p_polys.h:974
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:703
#define p_Test(p, r)
Definition: p_polys.h:162
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
#define pSetExp(p, i, v)
Definition: polys.h:42
int gcd(int a, int b)
Definition: walkSupport.cc:836

◆ enterExtendedSpolySig()

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

Definition at line 4374 of file kutil.cc.

4375 {
4376  if (nIsOne(pGetCoeff(h))) return;
4377  number gcd;
4378  bool go = false;
4379  if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4380  {
4381  gcd = n_Ann(pGetCoeff(h),currRing->cf);
4382  go = true;
4383  }
4384  else
4385  gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4386  if (go || !nIsOne(gcd))
4387  {
4388  poly p = h->next;
4389  if (!go)
4390  {
4391  number tmp = gcd;
4392  gcd = n_Ann(gcd,currRing->cf);
4393  nDelete(&tmp);
4394  }
4395  p_Test(p,strat->tailRing);
4396  p = __pp_Mult_nn(p, gcd, strat->tailRing);
4397 
4398  if (p != NULL)
4399  {
4400  if (TEST_OPT_PROT)
4401  {
4402  PrintS("Z");
4403  }
4404 #ifdef KDEBUG
4405  if (TEST_OPT_DEBUG)
4406  {
4407  PrintS("--- create zero spoly: ");
4408  p_wrp(h,currRing,strat->tailRing);
4409  PrintS(" ---> ");
4410  }
4411 #endif
4412  poly tmp = pInit();
4413  pSetCoeff0(tmp, pGetCoeff(p));
4414  for (int i = 1; i <= rVar(currRing); i++)
4415  {
4416  pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4417  }
4419  {
4420  p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4421  }
4422  p_Setm(tmp, currRing);
4423  p = p_LmFreeAndNext(p, strat->tailRing);
4424  pNext(tmp) = p;
4425  LObject Lp;
4426  Lp.Init();
4427  Lp.p = tmp;
4428  //printf("\nOld\n");pWrite(h);pWrite(hSig);
4429  #if EXT_POLY_NEW
4430  Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4431  if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4432  {
4433  strat->sigdrop = TRUE;
4434  //Try to reduce it as far as we can via redRing
4435  int red_result = redRing(&Lp,strat);
4436  if(red_result == 0)
4437  {
4438  // Cancel the sigdrop
4439  p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4440  strat->sigdrop = FALSE;
4441  return;
4442  }
4443  else
4444  {
4445  strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4446  #if 1
4447  strat->enterS(Lp,0,strat,strat->tl);
4448  #endif
4449  return;
4450  }
4451 
4452  }
4453  #else
4454  Lp.sig = pOne();
4455  if(strat->Ll >= 0)
4456  p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4457  else
4458  p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4459  #endif
4460  Lp.tailRing = strat->tailRing;
4461  int posx;
4462  if (Lp.p!=NULL)
4463  {
4464  strat->initEcart(&Lp);
4465  if (strat->Ll==-1)
4466  posx =0;
4467  else
4468  posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4469  Lp.sev = pGetShortExpVector(Lp.p);
4470  if (strat->tailRing != currRing)
4471  {
4472  Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4473  }
4474 #ifdef KDEBUG
4475  if (TEST_OPT_DEBUG)
4476  {
4477  p_wrp(tmp,currRing,strat->tailRing);
4478  PrintLn();
4479  }
4480 #endif
4481  //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4482  enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4483  }
4484  }
4485  nDelete(&gcd);
4486  }
4487  nDelete(&gcd);
4488 }
bool sigdrop
Definition: kutil.h:359
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:282
int redRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:827
#define nIsZero(n)
Definition: numbers.h:19

◆ enterL()

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

Definition at line 1327 of file kutil.cc.

1328 {
1329  // this should be corrected
1330  assume(p.FDeg == p.pFDeg());
1331 
1332  if ((*length)>=0)
1333  {
1334  if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1335  if (at <= (*length))
1336 #ifdef ENTER_USE_MEMMOVE
1337  memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1338 #else
1339  for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1340 #endif
1341  }
1342  else at = 0;
1343  (*set)[at] = p;
1344  (*length)++;
1345 }
static void enlargeL(LSet *L, int *length, const int incr)
Definition: kutil.cc:687
#define setmaxLinc
Definition: kutil.h:31

◆ enterOnePairNormal()

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

Definition at line 1999 of file kutil.cc.

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

◆ enterOnePairShift()

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

Definition at line 12561 of file kutil.cc.

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

◆ enterpairs()

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

Definition at line 4549 of file kutil.cc.

4550 {
4551  int j=pos;
4552 
4554  initenterpairs(h,k,ecart,0,strat, atR);
4555  if ( (!strat->fromT)
4556  && ((strat->syzComp==0)
4557  ||(pGetComp(h)<=strat->syzComp)))
4558  {
4559  unsigned long h_sev = pGetShortExpVector(h);
4560  loop
4561  {
4562  if (j > k) break;
4563  clearS(h,h_sev, &j,&k,strat);
4564  j++;
4565  }
4566  }
4567 }
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:3864

◆ enterpairsShift()

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

Definition at line 13335 of file kutil.cc.

13336 {
13337  /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
13338  /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
13339  int j=pos;
13340 
13341  /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
13342  initenterpairsShift(h,k,ecart,0,strat, atR);
13343  if ( (!strat->fromT)
13344  && ((strat->syzComp==0)
13345  ||(pGetComp(h)<=strat->syzComp)))
13346  {
13347  unsigned long h_sev = pGetShortExpVector(h);
13348  loop
13349  {
13350  if (j > k) break;
13351  // TODO this currently doesn't clear all possible elements because of commutative division
13352  if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
13353  clearS(h,h_sev, &j,&k,strat);
13354  j++;
13355  }
13356  }
13357 }
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:12902

◆ enterpairsSig()

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

Definition at line 4575 of file kutil.cc.

4576 {
4577  int j=pos;
4579  initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4580  if ( (!strat->fromT)
4581  && ((strat->syzComp==0)
4582  ||(pGetComp(h)<=strat->syzComp)))
4583  {
4584  unsigned long h_sev = pGetShortExpVector(h);
4585  loop
4586  {
4587  if (j > k) break;
4588  clearS(h,h_sev, &j,&k,strat);
4589  j++;
4590  }
4591  }
4592 }
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3929

◆ enterSBba()

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

Definition at line 9047 of file kutil.cc.

9048 {
9049  strat->news = TRUE;
9050  /*- puts p to the standardbasis s at position at -*/
9051  if (strat->sl == IDELEMS(strat->Shdl)-1)
9052  {
9053  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9054  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9055  (IDELEMS(strat->Shdl)+setmaxTinc)
9056  *sizeof(unsigned long));
9057  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9058  IDELEMS(strat->Shdl)*sizeof(int),
9059  (IDELEMS(strat->Shdl)+setmaxTinc)
9060  *sizeof(int));
9061  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9062  IDELEMS(strat->Shdl)*sizeof(int),
9063  (IDELEMS(strat->Shdl)+setmaxTinc)
9064  *sizeof(int));
9065  if (strat->lenS!=NULL)
9066  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9067  IDELEMS(strat->Shdl)*sizeof(int),
9068  (IDELEMS(strat->Shdl)+setmaxTinc)
9069  *sizeof(int));
9070  if (strat->lenSw!=NULL)
9071  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9072  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9073  (IDELEMS(strat->Shdl)+setmaxTinc)
9074  *sizeof(wlen_type));
9075  if (strat->fromQ!=NULL)
9076  {
9077  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9078  IDELEMS(strat->Shdl)*sizeof(int),
9079  (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
9080  }
9081  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
9082  IDELEMS(strat->Shdl)+=setmaxTinc;
9083  strat->Shdl->m=strat->S;
9084  }
9085  if (atS <= strat->sl)
9086  {
9087 #ifdef ENTER_USE_MEMMOVE
9088  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9089  (strat->sl - atS + 1)*sizeof(poly));
9090  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9091  (strat->sl - atS + 1)*sizeof(int));
9092  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9093  (strat->sl - atS + 1)*sizeof(unsigned long));
9094  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9095  (strat->sl - atS + 1)*sizeof(int));
9096  if (strat->lenS!=NULL)
9097  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9098  (strat->sl - atS + 1)*sizeof(int));
9099  if (strat->lenSw!=NULL)
9100  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9101  (strat->sl - atS + 1)*sizeof(wlen_type));
9102 #else
9103  for (i=strat->sl+1; i>=atS+1; i--)
9104  {
9105  strat->S[i] = strat->S[i-1];
9106  strat->ecartS[i] = strat->ecartS[i-1];
9107  strat->sevS[i] = strat->sevS[i-1];
9108  strat->S_2_R[i] = strat->S_2_R[i-1];
9109  }
9110  if (strat->lenS!=NULL)
9111  for (i=strat->sl+1; i>=atS+1; i--)
9112  strat->lenS[i] = strat->lenS[i-1];
9113  if (strat->lenSw!=NULL)
9114  for (i=strat->sl+1; i>=atS+1; i--)
9115  strat->lenSw[i] = strat->lenSw[i-1];
9116 #endif
9117  }
9118  if (strat->fromQ!=NULL)
9119  {
9120 #ifdef ENTER_USE_MEMMOVE
9121  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9122  (strat->sl - atS + 1)*sizeof(int));
9123 #else
9124  for (i=strat->sl+1; i>=atS+1; i--)
9125  {
9126  strat->fromQ[i] = strat->fromQ[i-1];
9127  }
9128 #endif
9129  strat->fromQ[atS]=0;
9130  }
9131 
9132  /*- save result -*/
9133  poly pp=p.p;
9134  strat->S[atS] = pp;
9135  if (strat->honey) strat->ecartS[atS] = p.ecart;
9136  if (p.sev == 0)
9137  p.sev = pGetShortExpVector(pp);
9138  else
9139  assume(p.sev == pGetShortExpVector(pp));
9140  strat->sevS[atS] = p.sev;
9141  strat->ecartS[atS] = p.ecart;
9142  strat->S_2_R[atS] = atR;
9143  strat->sl++;
9144 }
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
char news
Definition: kutil.h:400
#define setmaxTinc
Definition: kutil.h:34
int * intset
Definition: kutil.h:53
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3770

◆ enterSBbaShift()

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

Definition at line 9147 of file kutil.cc.

9148 {
9149  enterSBba(p, atS, strat, atR);
9150 
9151  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
9152  for (int i = maxPossibleShift; i > 0; i--)
9153  {
9154  // NOTE: don't use "shared tails" here. In rare cases it can cause problems
9155  // in `kNF2` because of lazy poly normalizations.
9156  LObject qq(p_Copy(p.p, strat->tailRing));
9157  p_mLPshift(qq.p, i, strat->tailRing);
9158  qq.shift = i;
9159  strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
9160  int atS = posInS(strat, strat->sl, qq.p, qq.ecart); // S needs to stay sorted because this is for example assumed when searching S later
9161  enterSBba(qq, atS, strat, -1);
9162  }
9163 }
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9047
int p_mLPmaxPossibleShift(poly p, const ring r)
Definition: shiftgb.cc:45
void p_mLPshift(poly m, int sh, const ring ri)
Definition: shiftop.cc:361

◆ entersets()

void entersets ( LObject  h)

◆ enterSSba()

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

Definition at line 9170 of file kutil.cc.

9171 {
9172  strat->news = TRUE;
9173  /*- puts p to the standardbasis s at position at -*/
9174  if (strat->sl == IDELEMS(strat->Shdl)-1)
9175  {
9176  strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9177  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9178  (IDELEMS(strat->Shdl)+setmax)
9179  *sizeof(unsigned long));
9180  strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
9181  IDELEMS(strat->Shdl)*sizeof(unsigned long),
9182  (IDELEMS(strat->Shdl)+setmax)
9183  *sizeof(unsigned long));
9184  strat->ecartS = (intset)omReallocSize(strat->ecartS,
9185  IDELEMS(strat->Shdl)*sizeof(int),
9186  (IDELEMS(strat->Shdl)+setmax)
9187  *sizeof(int));
9188  strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9189  IDELEMS(strat->Shdl)*sizeof(int),
9190  (IDELEMS(strat->Shdl)+setmax)
9191  *sizeof(int));
9192  if (strat->lenS!=NULL)
9193  strat->lenS=(int*)omRealloc0Size(strat->lenS,
9194  IDELEMS(strat->Shdl)*sizeof(int),
9195  (IDELEMS(strat->Shdl)+setmax)
9196  *sizeof(int));
9197  if (strat->lenSw!=NULL)
9198  strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9199  IDELEMS(strat->Shdl)*sizeof(wlen_type),
9200  (IDELEMS(strat->Shdl)+setmax)
9201  *sizeof(wlen_type));
9202  if (strat->fromQ!=NULL)
9203  {
9204  strat->fromQ = (intset)omReallocSize(strat->fromQ,
9205  IDELEMS(strat->Shdl)*sizeof(int),
9206  (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
9207  }
9208  pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
9209  pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
9210  IDELEMS(strat->Shdl)+=setmax;
9211  strat->Shdl->m=strat->S;
9212  }
9213  // in a signature-based algorithm the following situation will never
9214  // appear due to the fact that the critical pairs are already sorted
9215  // by increasing signature.
9216  // True. However, in the case of integers we need to put the element
9217  // that caused the signature drop on the first position
9218  if (atS <= strat->sl)
9219  {
9220 #ifdef ENTER_USE_MEMMOVE
9221  memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9222  (strat->sl - atS + 1)*sizeof(poly));
9223  memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
9224  (strat->sl - atS + 1)*sizeof(poly));
9225  memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
9226  (strat->sl - atS + 1)*sizeof(unsigned long));
9227  memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9228  (strat->sl - atS + 1)*sizeof(int));
9229  memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9230  (strat->sl - atS + 1)*sizeof(unsigned long));
9231  memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9232  (strat->sl - atS + 1)*sizeof(int));
9233  if (strat->lenS!=NULL)
9234  memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9235  (strat->sl - atS + 1)*sizeof(int));
9236  if (strat->lenSw!=NULL)
9237  memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9238  (strat->sl - atS + 1)*sizeof(wlen_type));
9239 #else
9240  for (i=strat->sl+1; i>=atS+1; i--)
9241  {
9242  strat->S[i] = strat->S[i-1];
9243  strat->ecartS[i] = strat->ecartS[i-1];
9244  strat->sevS[i] = strat->sevS[i-1];
9245  strat->S_2_R[i] = strat->S_2_R[i-1];
9246  strat->sig[i] = strat->sig[i-1];
9247  strat->sevSig[i] = strat->sevSig[i-1];
9248  }
9249  if (strat->lenS!=NULL)
9250  for (i=strat->sl+1; i>=atS+1; i--)
9251  strat->lenS[i] = strat->lenS[i-1];
9252  if (strat->lenSw!=NULL)
9253  for (i=strat->sl+1; i>=atS+1; i--)
9254  strat->lenSw[i] = strat->lenSw[i-1];
9255 #endif
9256  }
9257  if (strat->fromQ!=NULL)
9258  {
9259 #ifdef ENTER_USE_MEMMOVE
9260  memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9261  (strat->sl - atS + 1)*sizeof(int));
9262 #else
9263  for (i=strat->sl+1; i>=atS+1; i--)
9264  {
9265  strat->fromQ[i] = strat->fromQ[i-1];
9266  }
9267 #endif
9268  strat->fromQ[atS]=0;
9269  }
9270 
9271  /*- save result -*/
9272  strat->S[atS] = p.p;
9273  strat->sig[atS] = p.sig; // TODO: get ths correct signature in here!
9274  if (strat->honey) strat->ecartS[atS] = p.ecart;
9275  if (p.sev == 0)
9276  p.sev = pGetShortExpVector(p.p);
9277  else
9278  assume(p.sev == pGetShortExpVector(p.p));
9279  strat->sevS[atS] = p.sev;
9280  // during the interreduction process of a signature-based algorithm we do not
9281  // compute the signature at this point, but when the whole interreduction
9282  // process finishes, i.e. f5c terminates!
9283  if (p.sig != NULL)
9284  {
9285  if (p.sevSig == 0)
9286  p.sevSig = pGetShortExpVector(p.sig);
9287  else
9288  assume(p.sevSig == pGetShortExpVector(p.sig));
9289  strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9290  }
9291  strat->ecartS[atS] = p.ecart;
9292  strat->S_2_R[atS] = atR;
9293  strat->sl++;
9294 #ifdef DEBUGF5
9295  int k;
9296  Print("--- LIST S: %d ---\n",strat->sl);
9297  for(k=0;k<=strat->sl;k++)
9298  {
9299  pWrite(strat->sig[k]);
9300  }
9301  PrintS("--- LIST S END ---\n");
9302 #endif
9303 }
#define setmax
Definition: kutil.h:29
void pWrite(poly p)
Definition: polys.h:308

◆ enterSyz()

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

Definition at line 9598 of file kutil.cc.

9599 {
9600  int i;
9601  strat->newt = TRUE;
9602  if (strat->syzl == strat->syzmax-1)
9603  {
9604  pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9605  strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9606  (strat->syzmax)*sizeof(unsigned long),
9607  ((strat->syzmax)+setmax)
9608  *sizeof(unsigned long));
9609  strat->syzmax += setmax;
9610  }
9611  if (atT < strat->syzl)
9612  {
9613 #ifdef ENTER_USE_MEMMOVE
9614  memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9615  (strat->syzl-atT+1)*sizeof(poly));
9616  memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9617  (strat->syzl-atT+1)*sizeof(unsigned long));
9618 #endif
9619  for (i=strat->syzl; i>=atT+1; i--)
9620  {
9621 #ifndef ENTER_USE_MEMMOVE
9622  strat->syz[i] = strat->syz[i-1];
9623  strat->sevSyz[i] = strat->sevSyz[i-1];
9624 #endif
9625  }
9626  }
9627  //i = strat->syzl;
9628  i = atT;
9629  //Makes sure the syz saves just the signature
9630  #ifdef HAVE_RINGS
9632  pNext(p.sig) = NULL;
9633  #endif
9634  strat->syz[atT] = p.sig;
9635  strat->sevSyz[atT] = p.sevSig;
9636  strat->syzl++;
9637 #if F5DEBUG
9638  Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9639  pWrite(strat->syz[atT]);
9640 #endif
9641  // recheck pairs in strat->L with new rule and delete correspondingly
9642  int cc = strat->Ll;
9643  while (cc>-1)
9644  {
9645  //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9646  //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);
9647  if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9648  strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9649  #ifdef HAVE_RINGS
9650  &&((!rField_is_Ring(currRing))
9651  || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9652  #endif
9653  )
9654  {
9655  //printf("\nYES!\n");
9656  deleteInL(strat->L,&strat->Ll,cc,strat);
9657  }
9658  cc--;
9659  }
9660 //#if 1
9661 #ifdef DEBUGF5
9662  PrintS("--- Syzygies ---\n");
9663  Print("syzl %d\n",strat->syzl);
9664  Print("syzmax %d\n",strat->syzmax);
9665  PrintS("--------------------------------\n");
9666  for(i=0;i<=strat->syzl-1;i++)
9667  {
9668  Print("%d - ",i);
9669  pWrite(strat->syz[i]);
9670  }
9671  PrintS("--------------------------------\n");
9672 #endif
9673 }
unsigned long * sevSyz
Definition: kutil.h:323
int syzmax
Definition: kutil.h:349
int syzl
Definition: kutil.h:349
polyset syz
Definition: kutil.h:307
char newt
Definition: kutil.h:401
#define pLtCmp(p, q)
Definition: polys.h:123

◆ enterT()

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

Definition at line 9396 of file kutil.cc.

9397 {
9398  int i;
9399 
9400 #ifdef PDEBUG
9401 #ifdef HAVE_SHIFTBBA
9402  if (currRing->isLPring && p.shift > 0)
9403  {
9404  // in this case, the order is not correct. test LM and tail separately
9405  p_LmTest(p.p, currRing);
9406  p_Test(pNext(p.p), currRing);
9407  }
9408  else
9409 #endif
9410  {
9411  pp_Test(p.p, currRing, p.tailRing);
9412  }
9413 #endif
9414  assume(strat->tailRing == p.tailRing);
9415  // redMoraNF complains about this -- but, we don't really
9416  // neeed this so far
9417  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9418  assume(!strat->homog || (p.FDeg == p.pFDeg()));
9419  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9420 
9421 #ifdef KDEBUG
9422  // do not put an LObject twice into T:
9423  for(i=strat->tl;i>=0;i--)
9424  {
9425  if (p.p==strat->T[i].p)
9426  {
9427  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9428  return;
9429  }
9430  }
9431 #endif
9432 
9433 #ifdef HAVE_TAIL_RING
9434  if (currRing!=strat->tailRing)
9435  {
9436  p.t_p=p.GetLmTailRing();
9437  }
9438 #endif
9439  strat->newt = TRUE;
9440  if (atT < 0)
9441  atT = strat->posInT(strat->T, strat->tl, p);
9442  if (strat->tl == strat->tmax-1)
9443  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9444  if (atT <= strat->tl)
9445  {
9446 #ifdef ENTER_USE_MEMMOVE
9447  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9448  (strat->tl-atT+1)*sizeof(TObject));
9449  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9450  (strat->tl-atT+1)*sizeof(unsigned long));
9451 #endif
9452  for (i=strat->tl+1; i>=atT+1; i--)
9453  {
9454 #ifndef ENTER_USE_MEMMOVE
9455  strat->T[i] = strat->T[i-1];
9456  strat->sevT[i] = strat->sevT[i-1];
9457 #endif
9458  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9459  }
9460  }
9461 
9462  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9463  {
9464 #ifdef HAVE_SHIFTBBA
9465  // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9466  if (!(currRing->isLPring && p.shift > 0))
9467 #endif
9468  {
9470  (strat->tailRing != NULL ?
9471  strat->tailRing : currRing),
9472  strat->tailBin);
9473  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9474  }
9475  }
9476  strat->T[atT] = (TObject) p;
9477  //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9478 
9479  if (pNext(p.p) != NULL)
9480  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9481  else
9482  strat->T[atT].max_exp = NULL;
9483 
9484  strat->tl++;
9485  strat->R[strat->tl] = &(strat->T[atT]);
9486  strat->T[atT].i_r = strat->tl;
9487  assume((p.sev == 0) || (pGetShortExpVector(p.p) == p.sev));
9488  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9489  kTest_T(&(strat->T[atT]),strat);
9490 }
int tmax
Definition: kutil.h:350
omBin tailBin
Definition: kutil.h:345
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition: kutil.cc:548
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition: kutil.cc:825
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:164
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition: p_polys.h:900
#define p_LmTest(p, r)
Definition: p_polys.h:163
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:721

◆ enterT_strong()

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

Definition at line 9496 of file kutil.cc.

9497 {
9499  int i;
9500 
9501  pp_Test(p.p, currRing, p.tailRing);
9502  assume(strat->tailRing == p.tailRing);
9503  // redMoraNF complains about this -- but, we don't really
9504  // neeed this so far
9505  assume(p.pLength == 0 || (int)pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9506  assume(p.FDeg == p.pFDeg());
9507  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9508 
9509 #ifdef KDEBUG
9510  // do not put an LObject twice into T:
9511  for(i=strat->tl;i>=0;i--)
9512  {
9513  if (p.p==strat->T[i].p)
9514  {
9515  printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9516  return;
9517  }
9518  }
9519 #endif
9520 
9521 #ifdef HAVE_TAIL_RING
9522  if (currRing!=strat->tailRing)
9523  {
9524  p.t_p=p.GetLmTailRing();
9525  }
9526 #endif
9527  strat->newt = TRUE;
9528  if (atT < 0)
9529  atT = strat->posInT(strat->T, strat->tl, p);
9530  if (strat->tl == strat->tmax-1)
9531  enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9532  if (atT <= strat->tl)
9533  {
9534 #ifdef ENTER_USE_MEMMOVE
9535  memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9536  (strat->tl-atT+1)*sizeof(TObject));
9537  memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9538  (strat->tl-atT+1)*sizeof(unsigned long));
9539 #endif
9540  for (i=strat->tl+1; i>=atT+1; i--)
9541  {
9542 #ifndef ENTER_USE_MEMMOVE
9543  strat->T[i] = strat->T[i-1];
9544  strat->sevT[i] = strat->sevT[i-1];
9545 #endif
9546  strat->R[strat->T[i].i_r] = &(strat->T[i]);
9547  }
9548  }
9549 
9550  if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9551  {
9553  (strat->tailRing != NULL ?
9554  strat->tailRing : currRing),
9555  strat->tailBin);
9556  if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9557  }
9558  strat->T[atT] = (TObject) p;
9559  //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9560 
9561  if (pNext(p.p) != NULL)
9562  strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9563  else
9564  strat->T[atT].max_exp = NULL;
9565 
9566  strat->tl++;
9567  strat->R[strat->tl] = &(strat->T[atT]);
9568  strat->T[atT].i_r = strat->tl;
9569  assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9570  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9571  #if 1
9573  && !n_IsUnit(p.p->coef, currRing->cf))
9574  {
9575  for(i=strat->tl;i>=0;i--)
9576  {
9577  if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9578  {
9579  enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9580  }
9581  }
9582  }
9583  /*
9584  printf("\nThis is T:\n");
9585  for(i=strat->tl;i>=0;i--)
9586  {
9587  pWrite(strat->T[i].p);
9588  }
9589  //getchar();*/
9590  #endif
9591  kTest_T(&(strat->T[atT]),strat);
9592 }
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:515
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1597
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition: polys.h:140

◆ enterTShift()

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

Definition at line 13365 of file kutil.cc.

13366 {
13367  /* determine how many elements we have to insert */
13368  /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
13369  /* hence, a total number of elt's to add is: */
13370  /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
13371  pAssume(p.p != NULL);
13372 
13373  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
13374 
13375  for (int i = 1; i <= maxPossibleShift; i++)
13376  {
13377  LObject qq;
13378  qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
13379  qq.shift = i;
13380  strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
13381 
13382  enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13383  }
13384 }
#define pAssume(cond)
Definition: monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 10104 of file kutil.cc.

10105 {
10106  /*- release temp data -*/
10107  cleanT(strat);
10108  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10109  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10110  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10111  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10112  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10113  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10114  /*- set L: should be empty -*/
10115  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10116  /*- set B: should be empty -*/
10117  omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10118  pLmFree(&strat->tail);
10119  strat->syzComp=0;
10120 
10121 #ifdef HAVE_SHIFTBBA
10122  if (rIsLPRing(currRing) && strat->rightGB)
10123  {
10124  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10125  strat->fromQ=NULL;
10126  }
10127 #endif
10128 }
void * ADDRESS
Definition: auxiliary.h:119

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10307 of file kutil.cc.

10308 {
10309  /*- release temp data -*/
10311  cleanTSbaRing(strat);
10312  else
10313  cleanT(strat);
10314  omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10315  omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10316  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10317  omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10318  omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10319  omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10320  if(strat->syzmax>0)
10321  {
10322  omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10323  omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10324  if (strat->sbaOrder == 1)
10325  {
10326  omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10327  }
10328  }
10329  omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10330  /*- set L: should be empty -*/
10331  omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10332  /*- set B: should be empty -*/
10333  omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10334  /*- set sig: no need for the signatures anymore -*/
10335  omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10336  pLmDelete(&strat->tail);
10337  strat->syzComp=0;
10338 }
int syzidxmax
Definition: kutil.h:349
intset syzIdx
Definition: kutil.h:313
unsigned sbaOrder
Definition: kutil.h:316
void cleanTSbaRing(kStrategy strat)
Definition: kutil.cc:628

◆ f5c()

void f5c ( kStrategy  strat,
int &  olddeg,
int &  minimcnt,
int &  hilbeledeg,
int &  hilbcount,
int &  srmax,
int &  lrmax,
int &  reduc,
ideal  Q,
intvec w,
intvec hilb 
)

Definition at line 4035 of file kstd2.cc.

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

◆ faugereRewCriterion()

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

Definition at line 6816 of file kutil.cc.

6817 {
6818  //printf("Faugere Rewritten Criterion\n");
6820  return FALSE;
6821 //#if 1
6822 #ifdef DEBUGF5
6823  PrintS("rewritten criterion checks: ");
6824  pWrite(sig);
6825 #endif
6826  for(int k = strat->sl; k>=start; k--)
6827  {
6828 //#if 1
6829 #ifdef DEBUGF5
6830  PrintS("checking with: ");
6831  pWrite(strat->sig[k]);
6832  pWrite(pHead(strat->S[k]));
6833 #endif
6834  if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6835  {
6836 //#if 1
6837 #ifdef DEBUGF5
6838  PrintS("DELETE!\n");
6839 #endif
6840  strat->nrrewcrit++;
6841  return TRUE;
6842  }
6843  //k--;
6844  }
6845 #ifdef DEBUGF5
6846  PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6847  for(int kk = 0; kk<strat->sl+1; kk++)
6848  {
6849  pWrite(pHead(strat->S[kk]));
6850  }
6851  PrintS("------------------------------\n");
6852 #endif
6853  return FALSE;
6854 }
int nrrewcrit
Definition: kutil.h:361

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy  strat)

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

Definition at line 11147 of file kutil.cc.

11148 {
11149  assume(strat->tl<0); /* can only be called with no elements in T:
11150  i.e. after exitBuchMora */
11151  /* do not use strat->S, strat->sl as they may be out of sync*/
11152  if(!nCoeff_is_Z(currRing->cf))
11153  return;
11154  poly p,pp;
11155  for(int j = 0; j<IDELEMS(strat->Shdl); j++)
11156  {
11157  if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
11158  {
11159  for(int i = 0; i<IDELEMS(strat->Shdl); i++)
11160  {
11161  if((i != j) && (strat->Shdl->m[i] != NULL))
11162  {
11163  p = strat->Shdl->m[i];
11164  while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
11165 #if HAVE_SHIFTBBA
11166  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
11167 #endif
11168  ))
11169  {
11170  number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
11171  if (!nEqual(dummy,p->coef))
11172  {
11173  if (nIsZero(dummy))
11174  {
11175  nDelete(&dummy);
11176  pLmDelete(&strat->Shdl->m[i]);
11177  p=strat->Shdl->m[i];
11178  }
11179  else
11180  {
11181  p_SetCoeff(p,dummy,currRing);
11182  break;
11183  }
11184  }
11185  else
11186  {
11187  nDelete(&dummy);
11188  break;
11189  }
11190  }
11191  if (p!=NULL)
11192  {
11193  pp = pNext(p);
11194  while(pp != NULL)
11195  {
11196  if(pLmDivisibleBy(strat->Shdl->m[j], pp)
11197 #if HAVE_SHIFTBBA
11198  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
11199 #endif
11200  )
11201  {
11202  number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
11203  if (!nEqual(dummy,pp->coef))
11204  {
11205  p_SetCoeff(pp,dummy,currRing);
11206  if(nIsZero(pp->coef))
11207  {
11208  pLmDelete(&pNext(p));
11209  pp = pNext(p);
11210  }
11211  else
11212  {
11213  p = pp;
11214  pp = pNext(p);
11215  }
11216  }
11217  else
11218  {
11219  nDelete(&dummy);
11220  p = pp;
11221  pp = pNext(p);
11222  }
11223  }
11224  else
11225  {
11226  p = pp;
11227  pp = pNext(p);
11228  }
11229  }
11230  }
11231  }
11232  }
11233  //idPrint(strat->Shdl);
11234  }
11235  }
11236  idSkipZeroes(strat->Shdl);
11237 }
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:816
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition: coeffs.h:628
#define nEqual(n1, n2)
Definition: numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
#define pLPLmDivisibleBy(a, b)
Definition: shiftop.h:58
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 505 of file kutil.cc.

506 {
507  int j,/*k,*/p;
508 
509  if (currRing->pLexOrder
511  || (strat->ak >1)
513  {
514  return;
515  }
516  p=pIsPurePower(pp);
517  if (p!=0)
518  strat->NotUsedAxis[p] = FALSE;
519  /*- the leading term of pp is a power of the p-th variable -*/
520  for (j=(currRing->N);j>0; j--)
521  {
522  if (strat->NotUsedAxis[j])
523  {
524  strat->kAllAxis=FALSE;
525  return;
526  }
527  }
528  strat->kAllAxis=TRUE;
529 }
BOOLEAN * NotUsedAxis
Definition: kutil.h:332
char kAllAxis
Definition: kutil.h:376
#define pIsPurePower(p)
Definition: polys.h:248
BOOLEAN rHasMixedOrdering(const ring r)
Definition: ring.h:762

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1676 of file kstd1.cc.

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

◆ initBuchMora()

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

Definition at line 10019 of file kutil.cc.

10020 {
10021  strat->interpt = BTEST1(OPT_INTERRUPT);
10022  /*- creating temp data structures------------------- -*/
10023  //strat->cp = 0; // already by skStragy()
10024  //strat->c3 = 0; // already by skStragy()
10025 #ifdef HAVE_SHIFTBBA
10026  strat->cv = 0; // already by skStragy()
10027 #endif
10028  strat->tail = pInit();
10029  /*- set s -*/
10030  strat->sl = -1;
10031  /*- set L -*/
10032  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10033  strat->Ll = -1;
10034  strat->L = initL(strat->Lmax);
10035  /*- set B -*/
10036  strat->Bmax = setmaxL;
10037  strat->Bl = -1;
10038  strat->B = initL();
10039  /*- set T -*/
10040  strat->tl = -1;
10041  strat->tmax = setmaxT;
10042  strat->T = initT();
10043  strat->R = initR();
10044  strat->sevT = initsevT();
10045  /*- init local data struct.---------------------------------------- -*/
10046  //strat->P.ecart=0; // already by skStragy()
10047  //strat->P.length=0; // already by skStragy()
10048  //strat->P.pLength=0; // already by skStragy()
10050  {
10051  if (strat->kNoether!=NULL)
10052  {
10053  pSetComp(strat->kNoether, strat->ak);
10054  pSetComp(strat->kNoetherTail(), strat->ak);
10055  }
10056  }
10058  {
10059  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10060  }
10061  else
10062  {
10063  if(TEST_OPT_SB_1)
10064  {
10065  int i;
10066  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10067  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10068  {
10069  P->m[i-strat->newIdeal] = F->m[i];
10070  F->m[i] = NULL;
10071  }
10072  initSSpecial(F,Q,P,strat);
10073  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10074  {
10075  F->m[i] = P->m[i-strat->newIdeal];
10076  P->m[i-strat->newIdeal] = NULL;
10077  }
10078  idDelete(&P);
10079  }
10080  else
10081  {
10082  /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10083  // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
10084  }
10085  }
10086  strat->fromT = FALSE;
10088  if ((!TEST_OPT_SB_1)
10089  || (rField_is_Ring(currRing))
10090  )
10091  {
10092  updateS(TRUE,strat);
10093  }
10094 #ifdef HAVE_SHIFTBBA
10095  if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
10096 #endif
10097  {
10098  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10099  strat->fromQ=NULL;
10100  }
10101  assume(kTest_TS(strat));
10102 }
int newIdeal
Definition: kutil.h:356
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
KINLINE unsigned long * initsevT()
Definition: kInline.h:100
KINLINE TSet initT()
Definition: kInline.h:84
KINLINE TObject ** initR()
Definition: kInline.h:95
void initSSpecial(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8349
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:8812
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7947
#define setmaxL
Definition: kutil.h:30
static LSet initL(int nr=setmaxL)
Definition: kutil.h:421
#define setmaxT
Definition: kutil.h:33
#define OPT_INTERRUPT
Definition: options.h:79
#define BTEST1(a)
Definition: options.h:33
#define pSetComp(p, v)
Definition: polys.h:38

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9694 of file kutil.cc.

9695 {
9697  strat->chainCrit=chainCritNormal;
9698  if (TEST_OPT_SB_1)
9699  strat->chainCrit=chainCritOpt_1;
9700 #ifdef HAVE_RINGS
9701  if (rField_is_Ring(currRing))
9702  {
9704  strat->chainCrit=chainCritRing;
9705  }
9706 #endif
9707 #ifdef HAVE_RATGRING
9708  if (rIsRatGRing(currRing))
9709  {
9710  strat->chainCrit=chainCritPart;
9711  /* enterOnePairNormal get rational part in it */
9712  }
9713 #endif
9714  if (TEST_OPT_IDLIFT
9715  && (strat->syzComp==1)
9716  && (!rIsPluralRing(currRing)))
9718 
9719  strat->sugarCrit = TEST_OPT_SUGARCRIT;
9720  strat->Gebauer = strat->homog || strat->sugarCrit;
9721  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9722  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9723  strat->pairtest = NULL;
9724  /* alway use tailreduction, except:
9725  * - in local rings, - in lex order case, -in ring over extensions */
9727  //if(rHasMixedOrdering(currRing)==2)
9728  //{
9729  // strat->noTailReduction =TRUE;
9730  //}
9731 
9732 #ifdef HAVE_PLURAL
9733  // and r is plural_ring
9734  // hence this holds for r a rational_plural_ring
9735  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9736  { //or it has non-quasi-comm type... later
9737  strat->sugarCrit = FALSE;
9738  strat->Gebauer = FALSE;
9739  strat->honey = FALSE;
9740  }
9741 #endif
9742 
9743  // Coefficient ring?
9744  if (rField_is_Ring(currRing))
9745  {
9746  strat->sugarCrit = FALSE;
9747  strat->Gebauer = FALSE;
9748  strat->honey = FALSE;
9749  }
9750  #ifdef KDEBUG
9751  if (TEST_OPT_DEBUG)
9752  {
9753  if (strat->homog) PrintS("ideal/module is homogeneous\n");
9754  else PrintS("ideal/module is not homogeneous\n");
9755  }
9756  #endif
9757 }
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:291
char z2homog
Definition: kutil.h:374
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.h:290
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:1999
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3500
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1393
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2281
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3575
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3264
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:4051
static bool rIsSCA(const ring r)
Definition: nc.h:190
#define TEST_OPT_WEIGHTM
Definition: options.h:121
#define TEST_OPT_SUGARCRIT
Definition: options.h:107
#define TEST_OPT_NOT_SUGAR
Definition: options.h:106

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9846 of file kutil.cc.

9847 {
9849  {
9850  if (strat->honey)
9851  {
9852  strat->posInL = posInL15;
9853  // ok -- here is the deal: from my experiments for Singular-2-0
9854  // I conclude that that posInT_EcartpLength is the best of
9855  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9856  // see the table at the end of this file
9857  if (TEST_OPT_OLDSTD)
9858  strat->posInT = posInT15;
9859  else
9860  strat->posInT = posInT_EcartpLength;
9861  }
9862  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9863  {
9864  strat->posInL = posInL11;
9865  strat->posInT = posInT11;
9866  }
9867  else if (TEST_OPT_INTSTRATEGY)
9868  {
9869  strat->posInL = posInL11;
9870  strat->posInT = posInT11;
9871  }
9872  else
9873  {
9874  strat->posInL = posInL0;
9875  strat->posInT = posInT0;
9876  }
9877  //if (strat->minim>0) strat->posInL =posInLSpecial;
9878  if (strat->homog)
9879  {
9880  strat->posInL = posInL110;
9881  strat->posInT = posInT110;
9882  }
9883  }
9884  else /* local/mixed ordering */
9885  {
9886  if (strat->homog)
9887  {
9888  strat->posInL = posInL11;
9889  strat->posInT = posInT11;
9890  }
9891  else
9892  {
9893  if ((currRing->order[0]==ringorder_c)
9894  ||(currRing->order[0]==ringorder_C))
9895  {
9896  strat->posInL = posInL17_c;
9897  strat->posInT = posInT17_c;
9898  }
9899  else
9900  {
9901  strat->posInL = posInL17;
9902  strat->posInT = posInT17;
9903  }
9904  }
9905  }
9906  if (strat->minim>0) strat->posInL =posInLSpecial;
9907  // for further tests only
9908  if ((BTEST1(11)) || (BTEST1(12)))
9909  strat->posInL = posInL11;
9910  else if ((BTEST1(13)) || (BTEST1(14)))
9911  strat->posInL = posInL13;
9912  else if ((BTEST1(15)) || (BTEST1(16)))
9913  strat->posInL = posInL15;
9914  else if ((BTEST1(17)) || (BTEST1(18)))
9915  strat->posInL = posInL17;
9916  if (BTEST1(11))
9917  strat->posInT = posInT11;
9918  else if (BTEST1(13))
9919  strat->posInT = posInT13;
9920  else if (BTEST1(15))
9921  strat->posInT = posInT15;
9922  else if ((BTEST1(17)))
9923  strat->posInT = posInT17;
9924  else if ((BTEST1(19)))
9925  strat->posInT = posInT19;
9926  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9927  strat->posInT = posInT1;
9929 }
char posInLDependsOnLength
Definition: kutil.h:389
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6308
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5418
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5014
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4958
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5285
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:4947
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6396
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:9830
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5256
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5752
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6431
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5525
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5323
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5709
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6507
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5167
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5652
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6601
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6010
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9932 of file kutil.cc.

9933 {
9935  {
9936  if (strat->honey)
9937  {
9938  strat->posInL = posInL15Ring;
9939  // ok -- here is the deal: from my experiments for Singular-2-0
9940  // I conclude that that posInT_EcartpLength is the best of
9941  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9942  // see the table at the end of this file
9943  if (TEST_OPT_OLDSTD)
9944  strat->posInT = posInT15Ring;
9945  else
9946  strat->posInT = posInT_EcartpLength;
9947  }
9948  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9949  {
9950  strat->posInL = posInL11Ring;
9951  strat->posInT = posInT11;
9952  }
9953  else if (TEST_OPT_INTSTRATEGY)
9954  {
9955  strat->posInL = posInL11Ring;
9956  strat->posInT = posInT11;
9957  }
9958  else
9959  {
9960  strat->posInL = posInL0Ring;
9961  strat->posInT = posInT0;
9962  }
9963  //if (strat->minim>0) strat->posInL =posInLSpecial;
9964  if (strat->homog)
9965  {
9966  strat->posInL = posInL110Ring;
9967  strat->posInT = posInT110Ring;
9968  }
9969  }
9970  else
9971  {
9972  if (strat->homog)
9973  {
9974  //printf("\nHere 3\n");
9975  strat->posInL = posInL11Ring;
9976  strat->posInT = posInT11Ring;
9977  }
9978  else
9979  {
9980  if ((currRing->order[0]==ringorder_c)
9981  ||(currRing->order[0]==ringorder_C))
9982  {
9983  strat->posInL = posInL17_cRing;
9984  strat->posInT = posInT17_cRing;
9985  }
9986  else
9987  {
9988  strat->posInL = posInL11Ringls;
9989  strat->posInT = posInT17Ring;
9990  }
9991  }
9992  }
9993  if (strat->minim>0) strat->posInL =posInLSpecial;
9994  // for further tests only
9995  if ((BTEST1(11)) || (BTEST1(12)))
9996  strat->posInL = posInL11Ring;
9997  else if ((BTEST1(13)) || (BTEST1(14)))
9998  strat->posInL = posInL13;
9999  else if ((BTEST1(15)) || (BTEST1(16)))
10000  strat->posInL = posInL15Ring;
10001  else if ((BTEST1(17)) || (BTEST1(18)))
10002  strat->posInL = posInL17Ring;
10003  if (BTEST1(11))
10004  strat->posInT = posInT11Ring;
10005  else if (BTEST1(13))
10006  strat->posInT = posInT13;
10007  else if (BTEST1(15))
10008  strat->posInT = posInT15Ring;
10009  else if ((BTEST1(17)))
10010  strat->posInT = posInT17Ring;
10011  else if ((BTEST1(19)))
10012  strat->posInT = posInT19;
10013  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10014  strat->posInT = posInT1;
10016 }
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6551
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6665
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6052
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5209
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6349
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5778
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5050
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6122
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6466
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5377
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5479
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5586

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1359 of file kutil.cc.

1360 {
1361  h->FDeg = h->pFDeg();
1362  (*h).ecart = 0;
1363  h->length=h->pLength=pLength(h->p);
1364 }

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1351 of file kutil.cc.

1352 {
1353  h->FDeg = h->pFDeg();
1354  h->ecart = h->pLDeg() - h->FDeg;
1355  // h->length is set by h->pLDeg
1356  h->length=h->pLength=pLength(h->p);
1357 }

◆ initEcartPairBba()

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

Definition at line 1366 of file kutil.cc.

1367 {
1368  Lp->FDeg = Lp->pFDeg();
1369  (*Lp).ecart = 0;
1370  (*Lp).length = 0;
1371 }

◆ initEcartPairMora()

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

Definition at line 1373 of file kutil.cc.

1374 {
1375  Lp->FDeg = Lp->pFDeg();
1376  (*Lp).ecart = si_max(ecartF,ecartG);
1377  (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1378  (*Lp).length = 0;
1379 }
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:380

◆ initenterpairs()

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

Definition at line 3864 of file kutil.cc.

3865 {
3866 
3867  if ((strat->syzComp==0)
3868  || (pGetComp(h)<=strat->syzComp))
3869  {
3870  int j;
3871  BOOLEAN new_pair=FALSE;
3872 
3873  if (pGetComp(h)==0)
3874  {
3875  /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3876  if ((isFromQ)&&(strat->fromQ!=NULL))
3877  {
3878  for (j=0; j<=k; j++)
3879  {
3880  if (!strat->fromQ[j])
3881  {
3882  new_pair=TRUE;
3883  strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3884  //Print("j:%d, Ll:%d\n",j,strat->Ll);
3885  }
3886  }
3887  }
3888  else
3889  {
3890  new_pair=TRUE;
3891  for (j=0; j<=k; j++)
3892  {
3893  strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3894  //Print("j:%d, Ll:%d\n",j,strat->Ll);
3895  }
3896  }
3897  }
3898  else
3899  {
3900  for (j=0; j<=k; j++)
3901  {
3902  if ((pGetComp(h)==pGetComp(strat->S[j]))
3903  || (pGetComp(strat->S[j])==0))
3904  {
3905  new_pair=TRUE;
3906  strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3907  //Print("j:%d, Ll:%d\n",j,strat->Ll);
3908  }
3909  }
3910  }
3911  if (new_pair)
3912  {
3913  #ifdef HAVE_RATGRING
3914  if (currRing->real_var_start>0)
3915  chainCritPart(h,ecart,strat);
3916  else
3917  #endif
3918  strat->chainCrit(h,ecart,strat);
3919  }
3920  kMergeBintoL(strat);
3921  }
3922 }

◆ initHilbCrit()

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

Definition at line 9676 of file kutil.cc.

9677 {
9678 
9679  //if the ordering is local, then hilb criterion
9680  //can be used also if the ideal is not homogenous
9682  {
9684  *hilb=NULL;
9685  else
9686  return;
9687  }
9688  if (strat->homog!=isHomog)
9689  {
9690  *hilb=NULL;
9691  }
9692 }
@ isHomog
Definition: structs.h:41

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 421 of file kutil.h.

422 { return (LSet)omAlloc(nr*sizeof(LObject)); }
LObject * LSet
Definition: kutil.h:60

◆ initR()

KINLINE TObject** initR ( )

Definition at line 95 of file kInline.h.

96 {
97  return (TObject**) omAlloc0(setmaxT*sizeof(TObject*));
98 }
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ initS()

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

Definition at line 7853 of file kutil.cc.

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

◆ initSba()

void initSba ( ideal  F,
kStrategy  strat 
)

Definition at line 1734 of file kstd1.cc.

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

◆ initSbaBuchMora()

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

Definition at line 10232 of file kutil.cc.

10233 {
10234  strat->interpt = BTEST1(OPT_INTERRUPT);
10235  //strat->kNoether=NULL; // done by skStrategy
10236  /*- creating temp data structures------------------- -*/
10237  //strat->cp = 0; // done by skStrategy
10238  //strat->c3 = 0; // done by skStrategy
10239  strat->tail = pInit();
10240  /*- set s -*/
10241  strat->sl = -1;
10242  /*- set ps -*/
10243  strat->syzl = -1;
10244  /*- set L -*/
10245  strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10246  strat->Ll = -1;
10247  strat->L = initL(strat->Lmax);
10248  /*- set B -*/
10249  strat->Bmax = setmaxL;
10250  strat->Bl = -1;
10251  strat->B = initL();
10252  /*- set T -*/
10253  strat->tl = -1;
10254  strat->tmax = setmaxT;
10255  strat->T = initT();
10256  strat->R = initR();
10257  strat->sevT = initsevT();
10258  /*- init local data struct.---------------------------------------- -*/
10259  //strat->P.ecart=0; // done by skStrategy
10260  //strat->P.length=0; // done by skStrategy
10262  {
10263  if (strat->kNoether!=NULL)
10264  {
10265  pSetComp(strat->kNoether, strat->ak);
10266  pSetComp(strat->kNoetherTail(), strat->ak);
10267  }
10268  }
10270  {
10271  /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10272  }
10273  else
10274  {
10275  if(TEST_OPT_SB_1)
10276  {
10277  int i;
10278  ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10279  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10280  {
10281  P->m[i-strat->newIdeal] = F->m[i];
10282  F->m[i] = NULL;
10283  }
10284  initSSpecialSba(F,Q,P,strat);
10285  for (i=strat->newIdeal;i<IDELEMS(F);i++)
10286  {
10287  F->m[i] = P->m[i-strat->newIdeal];
10288  P->m[i-strat->newIdeal] = NULL;
10289  }
10290  idDelete(&P);
10291  }
10292  else
10293  {
10294  initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10295  }
10296  }
10297  //strat->fromT = FALSE; // done by skStrategy
10298  if (!TEST_OPT_SB_1)
10299  {
10300  if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10301  }
10302  //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10303  //strat->fromQ=NULL;
10304  assume(kTest_TS(strat));
10305 }
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8044
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8493

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9759 of file kutil.cc.

9760 {
9761  //strat->enterOnePair=enterOnePairNormal;
9763  //strat->chainCrit=chainCritNormal;
9764  strat->chainCrit = chainCritSig;
9765  /******************************************
9766  * rewCrit1 and rewCrit2 are already set in
9767  * kSba() in kstd1.cc
9768  *****************************************/
9769  //strat->rewCrit1 = faugereRewCriterion;
9770  if (strat->sbaOrder == 1)
9771  {
9772  strat->syzCrit = syzCriterionInc;
9773  }
9774  else
9775  {
9776  strat->syzCrit = syzCriterion;
9777  }
9778 #ifdef HAVE_RINGS
9779  if (rField_is_Ring(currRing))
9780  {
9782  strat->chainCrit=chainCritRing;
9783  }
9784 #endif
9785 #ifdef HAVE_RATGRING
9786  if (rIsRatGRing(currRing))
9787  {
9788  strat->chainCrit=chainCritPart;
9789  /* enterOnePairNormal get rational part in it */
9790  }
9791 #endif
9792 
9793  strat->sugarCrit = TEST_OPT_SUGARCRIT;
9794  strat->Gebauer = strat->homog || strat->sugarCrit;
9795  strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9796  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9797  strat->pairtest = NULL;
9798  /* alway use tailreduction, except:
9799  * - in local rings, - in lex order case, -in ring over extensions */
9802 
9803 #ifdef HAVE_PLURAL
9804  // and r is plural_ring
9805  // hence this holds for r a rational_plural_ring
9806  if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9807  { //or it has non-quasi-comm type... later
9808  strat->sugarCrit = FALSE;
9809  strat->Gebauer = FALSE;
9810  strat->honey = FALSE;
9811  }
9812 #endif
9813 
9814  // Coefficient ring?
9815  if (rField_is_Ring(currRing))
9816  {
9817  strat->sugarCrit = FALSE;
9818  strat->Gebauer = FALSE ;
9819  strat->honey = FALSE;
9820  }
9821  #ifdef KDEBUG
9822  if (TEST_OPT_DEBUG)
9823  {
9824  if (strat->homog) PrintS("ideal/module is homogeneous\n");
9825  else PrintS("ideal/module is not homogeneous\n");
9826  }
9827  #endif
9828 }
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.h:292
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6767
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3516
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6732

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 10130 of file kutil.cc.

10131 {
10133  {
10134  if (strat->honey)
10135  {
10136  strat->posInL = posInL15;
10137  // ok -- here is the deal: from my experiments for Singular-2-0
10138  // I conclude that that posInT_EcartpLength is the best of
10139  // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10140  // see the table at the end of this file
10141  if (TEST_OPT_OLDSTD)
10142  strat->posInT = posInT15;
10143  else
10144  strat->posInT = posInT_EcartpLength;
10145  }
10146  else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10147  {
10148  strat->posInL = posInL11;
10149  strat->posInT = posInT11;
10150  }
10151  else if (TEST_OPT_INTSTRATEGY)
10152  {
10153  strat->posInL = posInL11;
10154  strat->posInT = posInT11;
10155  }
10156  else
10157  {
10158  strat->posInL = posInL0;
10159  strat->posInT = posInT0;
10160  }
10161  //if (strat->minim>0) strat->posInL =posInLSpecial;
10162  if (strat->homog)
10163  {
10164  strat->posInL = posInL110;
10165  strat->posInT = posInT110;
10166  }
10167  }
10168  else
10169  {
10170  if (strat->homog)
10171  {
10172  strat->posInL = posInL11;
10173  strat->posInT = posInT11;
10174  }
10175  else
10176  {
10177  if ((currRing->order[0]==ringorder_c)
10178  ||(currRing->order[0]==ringorder_C))
10179  {
10180  strat->posInL = posInL17_c;
10181  strat->posInT = posInT17_c;
10182  }
10183  else
10184  {
10185  strat->posInL = posInL17;
10186  strat->posInT = posInT17;
10187  }
10188  }
10189  }
10190  if (strat->minim>0) strat->posInL =posInLSpecial;
10191  // for further tests only
10192  if ((BTEST1(11)) || (BTEST1(12)))
10193  strat->posInL = posInL11;
10194  else if ((BTEST1(13)) || (BTEST1(14)))
10195  strat->posInL = posInL13;
10196  else if ((BTEST1(15)) || (BTEST1(16)))
10197  strat->posInL = posInL15;
10198  else if ((BTEST1(17)) || (BTEST1(18)))
10199  strat->posInL = posInL17;
10200  if (BTEST1(11))
10201  strat->posInT = posInT11;
10202  else if (BTEST1(13))
10203  strat->posInT = posInT13;
10204  else if (BTEST1(15))
10205  strat->posInT = posInT15;
10206  else if ((BTEST1(17)))
10207  strat->posInT = posInT17;
10208  else if ((BTEST1(19)))
10209  strat->posInT = posInT19;
10210  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10211  strat->posInT = posInT1;
10212  if (rField_is_Ring(currRing))
10213  {
10214  strat->posInL = posInL11Ring;
10215  if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
10216  strat->posInL = posInL11Ringls;
10217  strat->posInT = posInT11;
10218  }
10219  strat->posInLDependsOnLength = FALSE;
10220  strat->posInLSba = posInLSig;
10221  //strat->posInL = posInLSig;
10222  strat->posInL = posInLF5C;
10223  /*
10224  if (rField_is_Ring(currRing))
10225  {
10226  strat->posInLSba = posInLSigRing;
10227  strat->posInL = posInL11Ring;
10228  }*/
10229  //strat->posInT = posInTSig;
10230 }
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5810
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:5998

◆ initsevT()

KINLINE unsigned long* initsevT ( )

Definition at line 100 of file kInline.h.

101 {
102  return (unsigned long*) omAlloc0(setmaxT*sizeof(unsigned long));
103 }

◆ initSL()

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

Definition at line 7947 of file kutil.cc.

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

◆ initSLSba()

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

Definition at line 8044 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8194 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

◆ k_GetLeadTerms()

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

Definition at line 1028 of file kInline.h.

1030 {
1031  p_LmCheckPolyRing(p1, p_r);
1032  p_LmCheckPolyRing(p2, p_r);
1033 
1034  int i;
1035  long x;
1036  m1 = p_Init(m_r,m_r->PolyBin);
1037  m2 = p_Init(m_r,m_r->PolyBin);
1038 
1039  for (i = p_r->N; i; i--)
1040  {
1041  x = p_GetExpDiff(p1, p2, i, p_r);
1042  if (x > 0)
1043  {
1044  if (x > (long) m_r->bitmask) goto false_return;
1045  p_SetExp(m2,i,x, m_r);
1046  p_SetExp(m1,i,0, m_r);
1047  }
1048  else
1049  {
1050  if (-x > (long) m_r->bitmask) goto false_return;
1051  p_SetExp(m1,i,-x, m_r);
1052  p_SetExp(m2,i,0, m_r);
1053  }
1054  }
1055 
1056  p_Setm(m1, m_r);
1057  p_Setm(m2, m_r);
1058  return TRUE;
1059 
1060  false_return:
1061  p_LmFree(m1, m_r);
1062  p_LmFree(m2, m_r);
1063  m1 = m2 = NULL;
1064  return FALSE;
1065 }
Variable x
Definition: cfModGcd.cc:4082
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:635
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:120
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1292

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

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

◆ k_LmInit_currRing_2_tailRing() [1/2]

KINLINE poly k_LmInit_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 1001 of file kInline.h.

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

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 969 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1006 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 978 of file kInline.h.

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

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 1011 of file kInline.h.

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

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 987 of file kInline.h.

988 {
989  poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
990  p_LmFree(p, currRing);
991  return np;
992 }

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1016 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 994 of file kInline.h.

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

◆ kCheckSpolyCreation()

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

Definition at line 10753 of file kutil.cc.

10754 {
10755  if (strat->overflow) return FALSE;
10756  assume(L->p1 != NULL && L->p2 != NULL);
10757  // shift changes: from 0 to -1
10758  assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10759  assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10760 
10761  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10762  return FALSE;
10763  // shift changes: extra case inserted
10764  if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10765  {
10766  return TRUE;
10767  }
10768  poly p1_max=NULL;
10769  if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10770  poly p2_max=NULL;
10771  if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10772 
10773  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10774  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10775  {
10776  p_LmFree(m1, strat->tailRing);
10777  p_LmFree(m2, strat->tailRing);
10778  m1 = NULL;
10779  m2 = NULL;
10780  return FALSE;
10781  }
10782  return TRUE;
10783 }
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:1028
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:2018

◆ kCheckStrongCreation()

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

Definition at line 10792 of file kutil.cc.

10793 {
10794  assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10795  //assume(strat->tailRing != currRing);
10796 
10797  poly p1_max = (strat->R[atR])->max_exp;
10798  poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10799 
10800  if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10801  ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10802  {
10803  return FALSE;
10804  }
10805  return TRUE;
10806 }

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11779 of file kutil.cc.

11780 {
11781  PrintS("red: ");
11782  if (strat->red==redFirst) PrintS("redFirst\n");
11783  else if (strat->red==redHoney) PrintS("redHoney\n");
11784  else if (strat->red==redEcart) PrintS("redEcart\n");
11785  else if (strat->red==redHomog) PrintS("redHomog\n");
11786  else if (strat->red==redLazy) PrintS("redLazy\n");
11787  else if (strat->red==redLiftstd) PrintS("redLiftstd\n");
11788  else Print("%p\n",(void*)strat->red);
11789  PrintS("posInT: ");
11790  if (strat->posInT==posInT0) PrintS("posInT0\n");
11791  else if (strat->posInT==posInT1) PrintS("posInT1\n");
11792  else if (strat->posInT==posInT11) PrintS("posInT11\n");
11793  else if (strat->posInT==posInT110) PrintS("posInT110\n");
11794  else if (strat->posInT==posInT13) PrintS("posInT13\n");
11795  else if (strat->posInT==posInT15) PrintS("posInT15\n");
11796  else if (strat->posInT==posInT17) PrintS("posInT17\n");
11797  else if (strat->posInT==posInT17_c) PrintS("posInT17_c\n");
11798  else if (strat->posInT==posInT19) PrintS("posInT19\n");
11799  else if (strat->posInT==posInT2) PrintS("posInT2\n");
11800  #ifdef HAVE_RINGS
11801  else if (strat->posInT==posInT11Ring) PrintS("posInT11Ring\n");
11802  else if (strat->posInT==posInT110Ring) PrintS("posInT110Ring\n");
11803  else if (strat->posInT==posInT15Ring) PrintS("posInT15Ring\n");
11804  else if (strat->posInT==posInT17Ring) PrintS("posInT17Ring\n");
11805  else if (strat->posInT==posInT17_cRing) PrintS("posInT17_cRing\n");
11806  #endif
11807 #ifdef HAVE_MORE_POS_IN_T
11808  else if (strat->posInT==posInT_EcartFDegpLength) PrintS("posInT_EcartFDegpLength\n");
11809  else if (strat->posInT==posInT_FDegpLength) PrintS("posInT_FDegpLength\n");
11810  else if (strat->posInT==posInT_pLength) PrintS("posInT_pLength\n");
11811 #endif
11812  else if (strat->posInT==posInT_EcartpLength) PrintS("posInT_EcartpLength\n");
11813  else if (strat->posInT==posInTrg0) PrintS("posInTrg0\n");
11814  else Print("%p\n",(void*)strat->posInT);
11815  PrintS("posInL: ");
11816  if (strat->posInL==posInL0) PrintS("posInL0\n");
11817  else if (strat->posInL==posInL10) PrintS("posInL10\n");
11818  else if (strat->posInL==posInL11) PrintS("posInL11\n");
11819  else if (strat->posInL==posInL110) PrintS("posInL110\n");
11820  else if (strat->posInL==posInL13) PrintS("posInL13\n");
11821  else if (strat->posInL==posInL15) PrintS("posInL15\n");
11822  else if (strat->posInL==posInL17) PrintS("posInL17\n");
11823  else if (strat->posInL==posInL17_c) PrintS("posInL17_c\n");
11824  #ifdef HAVE_RINGS
11825  else if (strat->posInL==posInL0) PrintS("posInL0Ring\n");
11826  else if (strat->posInL==posInL11Ring) PrintS("posInL11Ring\n");
11827  else if (strat->posInL==posInL11Ringls) PrintS("posInL11Ringls\n");
11828  else if (strat->posInL==posInL110Ring) PrintS("posInL110Ring\n");
11829  else if (strat->posInL==posInL15Ring) PrintS("posInL15Ring\n");
11830  else if (strat->posInL==posInL17Ring) PrintS("posInL17Ring\n");
11831  else if (strat->posInL==posInL17_cRing) PrintS("posInL17_cRing\n");
11832  #endif
11833  else if (strat->posInL==posInLSpecial) PrintS("posInLSpecial\n");
11834  else if (strat->posInL==posInLrg0) PrintS("posInLrg0\n");
11835  else Print("%p\n",(void*)strat->posInL);
11836  PrintS("enterS: ");
11837  if (strat->enterS==enterSBba) PrintS("enterSBba\n");
11838  else if (strat->enterS==enterSMora) PrintS("enterSMora\n");
11839  else if (strat->enterS==enterSMoraNF) PrintS("enterSMoraNF\n");
11840  else Print("%p\n",(void*)strat->enterS);
11841  PrintS("initEcart: ");
11842  if (strat->initEcart==initEcartBBA) PrintS("initEcartBBA\n");
11843  else if (strat->initEcart==initEcartNormal) PrintS("initEcartNormal\n");
11844  else Print("%p\n",(void*)strat->initEcart);
11845  PrintS("initEcartPair: ");
11846  if (strat->initEcartPair==initEcartPairBba) PrintS("initEcartPairBba\n");
11847  else if (strat->initEcartPair==initEcartPairMora) PrintS("initEcartPairMora\n");
11848  else Print("%p\n",(void*)strat->initEcartPair);
11849  Print("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11850  strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11851  Print("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11852  strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11853  PrintS("chainCrit: ");
11854  if (strat->chainCrit==chainCritNormal) PrintS("chainCritNormal\n");
11855  else if (strat->chainCrit==chainCritOpt_1) PrintS("chainCritOpt_1\n");
11856  else Print("%p\n",(void*)strat->chainCrit);
11857  Print("posInLDependsOnLength=%d\n",
11858  strat->posInLDependsOnLength);
11859  PrintS(showOption());PrintLn();
11860  PrintS("LDeg: ");
11861  if (currRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11862  else if (currRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11863  else if (currRing->pLDeg==pLDegb) PrintS("pLDegb");
11864  else if (currRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11865  else if (currRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11866  else if (currRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11867  else if (currRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11868  else if (currRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11869  else if (currRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11870  else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11871  else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11872  else if (currRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11873  else Print("? (%lx)", (long)currRing->pLDeg);
11874  PrintS(" / ");
11875  if (strat->tailRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11876  else if (strat->tailRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11877  else if (strat->tailRing->pLDeg==pLDegb) PrintS("pLDegb");
11878  else if (strat->tailRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11879  else if (strat->tailRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11880  else if (strat->tailRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11881  else if (strat->tailRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11882  else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11883  else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11884  else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11885  else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11886  else if (strat->tailRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11887  else Print("? (%lx)", (long)strat->tailRing->pLDeg);
11888  PrintLn();
11889  PrintS("currRing->pFDeg: ");
11890  if (currRing->pFDeg==p_Totaldegree) PrintS("p_Totaldegree");
11891  else if (currRing->pFDeg==p_WFirstTotalDegree) PrintS("pWFirstTotalDegree");
11892  else if (currRing->pFDeg==p_Deg) PrintS("p_Deg");
11893  else if (currRing->pFDeg==kHomModDeg) PrintS("kHomModDeg");
11894  else if (currRing->pFDeg==totaldegreeWecart) PrintS("totaldegreeWecart");
11895  else if (currRing->pFDeg==p_WTotaldegree) PrintS("p_WTotaldegree");
11896  else Print("? (%lx)", (long)currRing->pFDeg);
11897  PrintLn();
11898  Print(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11899  if(TEST_OPT_DEGBOUND)
11900  Print(" degBound: %d\n", Kstd1_deg);
11901 
11902  if( ecartWeights != NULL )
11903  {
11904  PrintS("ecartWeights: ");
11905  for (int i = rVar(currRing); i > 0; i--)
11906  Print("%hd ", ecartWeights[i]);
11907  PrintLn();
11909  }
11910 
11911 #ifndef SING_NDEBUG
11913 #endif
11914 }
int LazyDegree
Definition: kutil.h:353
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1352
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2420
int posInTrg0(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5091
int redFirst(LObject *h, kStrategy strat)
Definition: kstd1.cc:797
int redEcart(LObject *h, kStrategy strat)
Definition: kstd1.cc:169
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1668
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4986
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11745
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11654
VAR int Kstd1_deg
Definition: kutil.cc:247
char * showOption()
Definition: misc_ip.cc:713
int posInLrg0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6224
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1615
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11708
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:807
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:971
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:592
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1034
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1064
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:937
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:837
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:906
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:609
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:873
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1001
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:766
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:735
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1479
void rDebugPrint(const ring r)
Definition: ring.cc:4067
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:724

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 873 of file kutil.h.

874 {
875  if (P->lcm!=NULL)
876  {
877  #ifdef HAVE_RINGS
879  pLmDelete(P->lcm);
880  else
881  #endif
882  pLmFree(P->lcm);
883  P->lcm=NULL;
884  }
885 }

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6951 of file kutil.cc.

6952 {
6953  int j = 0;
6954  const unsigned long not_sev = ~L->sev;
6955  const unsigned long* sev = strat->sevS;
6956  poly p;
6957  ring r;
6958  L->GetLm(p, r);
6959 
6960  assume(~not_sev == p_GetShortExpVector(p, r));
6961 
6962  if (r == currRing)
6963  {
6964  if(!rField_is_Ring(r))
6965  {
6966  loop
6967  {
6968  if (j > end_pos) return NULL;
6969  #if defined(PDEBUG) || defined(PDIV_DEBUG)
6970  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6971  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6972  {
6973  break;
6974  }
6975  #else
6976  if (!(sev[j] & not_sev) &&
6977  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
6978  p_LmDivisibleBy(strat->S[j], p, r))
6979  {
6980  break;
6981  }
6982  #endif
6983  j++;
6984  }
6985  }
6986  #ifdef HAVE_RINGS
6987  else
6988  {
6989  loop
6990  {
6991  if (j > end_pos) return NULL;
6992  #if defined(PDEBUG) || defined(PDIV_DEBUG)
6993  if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6994  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6995  {
6996  break;
6997  }
6998  #else
6999  if (!(sev[j] & not_sev) &&
7000  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
7001  p_LmDivisibleBy(strat->S[j], p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
7002  {
7003  break;
7004  }
7005  #endif
7006  j++;
7007  }
7008  }
7009  #endif
7010  // if called from NF, T objects do not exist:
7011  if (strat->tl < 0 || strat->S_2_R[j] == -1)
7012  {
7013  T->Set(strat->S[j], r, strat->tailRing);
7014  assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
7015  return T;
7016  }
7017  else
7018  {
7019 ///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
7020 ///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
7021 // assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
7022  return strat->S_2_T(j);
7023  }
7024  }
7025  else
7026  {
7027  TObject* t;
7028  if(!rField_is_Ring(r))
7029  {
7030  loop
7031  {
7032  if (j > end_pos) return NULL;
7033  assume(strat->S_2_R[j] != -1);
7034  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7035  t = strat->S_2_T(j);
7036  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7037  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7038  (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7039  {
7040  t->pLength=pLength(t->t_p);
7041  return t;
7042  }
7043  #else
7044  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7045  {
7046  t = strat->S_2_T(j);
7047  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7048  if (p_LmDivisibleBy(t->t_p, p, r))
7049  {
7050  t->pLength=pLength(t->t_p);
7051  return t;
7052  }
7053  }
7054  #endif
7055  j++;
7056  }
7057  }
7058  #ifdef HAVE_RINGS
7059  else
7060  {
7061  loop
7062  {
7063  if (j > end_pos) return NULL;
7064  assume(strat->S_2_R[j] != -1);
7065  #if defined(PDEBUG) || defined(PDIV_DEBUG)
7066  t = strat->S_2_T(j);
7067  assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7068  if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7069  (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7070  {
7071  t->pLength=pLength(t->t_p);
7072  return t;
7073  }
7074  #else
7075  if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7076  {
7077  t = strat->S_2_T(j);
7078  assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7079  if (p_LmDivisibleBy(t->t_p, p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7080  {
7081  t->pLength=pLength(t->t_p);
7082  return t;
7083  }
7084  }
7085  #endif
7086  j++;
7087  }
7088  }
7089  #endif
7090  }
7091 }
KINLINE TObject * S_2_T(int i)
Definition: kInline.h:38

◆ kFindDivisibleByInT()

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

return -1 if no divisor is found number of first divisor in T, otherwise

Definition at line 290 of file kstd2.cc.

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

◆ kFindDivisibleByInT_Z()

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

Definition at line 209 of file kstd2.cc.

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

◆ kFindInT()

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

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

Definition at line 742 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 767 of file kutil.cc.

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

◆ kFindNextDivisibleByInS()

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

Definition at line 469 of file kstd2.cc.

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

◆ kFindSameLMInT_Z()

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

Definition at line 86 of file kstd2.cc.

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

◆ kFindZeroPoly()

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

Definition at line 555 of file kstd2.cc.

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

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3860 of file kstd2.cc.

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

◆ kNF2() [2/2]

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

Definition at line 3704 of file kstd2.cc.

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

◆ kNF2Bound() [1/2]

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

Definition at line 3948 of file kstd2.cc.

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

◆ kNF2Bound() [2/2]

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

Definition at line 3786 of file kstd2.cc.

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

◆ ksCreateShortSpoly()

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

Definition at line 1430 of file kspoly.cc.

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

◆ ksCreateSpoly()

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

Definition at line 1185 of file kspoly.cc.

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

◆ ksOldCreateSpoly()

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

Definition at line 1204 of file kInline.h.

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

◆ ksOldSpolyRed()

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

Definition at line 1184 of file kInline.h.

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

◆ ksOldSpolyRedNew()

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

Definition at line 1194 of file kInline.h.

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

◆ ksOldSpolyTail()

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

Definition at line 1214 of file kInline.h.

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

◆ ksReducePoly()

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

Definition at line 187 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 572 of file kspoly.cc.

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

◆ ksReducePolyGCD()

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

Definition at line 325 of file kspoly.cc.

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

◆ ksReducePolyLC()

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

Definition at line 458 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 719 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 925 of file kspoly.cc.

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

◆ ksReducePolyTail() [1/2]

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

Definition at line 1157 of file kInline.h.

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

◆ ksReducePolyTail() [2/2]

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

Definition at line 1334 of file kspoly.cc.

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

◆ ksReducePolyZ()

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

Definition at line 44 of file kspoly.cc.

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

◆ kStratChangeTailRing()

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

Definition at line 11240 of file kutil.cc.

11241 {
11242  assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11243  /* initial setup or extending */
11244 
11245  if (rIsLPRing(currRing)) return TRUE;
11246  if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11247  if (expbound >= currRing->bitmask) return FALSE;
11248  strat->overflow=FALSE;
11249  ring new_tailRing = rModifyRing(currRing,
11250  // Hmmm .. the condition pFDeg == p_Deg
11251  // might be too strong
11252  (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11253  (strat->ak==0), // omit_comp if the input is an ideal
11254  expbound); // exp_limit
11255 
11256  if (new_tailRing == currRing) return TRUE;
11257 
11258  strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11259  strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11260 
11261  if (currRing->pFDeg != currRing->pFDegOrig)
11262  {
11263  new_tailRing->pFDeg = currRing->pFDeg;
11264  new_tailRing->pLDeg = currRing->pLDeg;
11265  }
11266 
11267  if (TEST_OPT_PROT)
11268  Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11269  kTest_TS(strat);
11270  assume(new_tailRing != strat->tailRing);
11271  pShallowCopyDeleteProc p_shallow_copy_delete
11272  = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11273 
11274  omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11275 
11276  int i;
11277  for (i=0; i<=strat->tl; i++)
11278  {
11279  strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11280  p_shallow_copy_delete);
11281  }
11282  for (i=0; i<=strat->Ll; i++)
11283  {
11284  assume(strat->L[i].p != NULL);
11285  if (pNext(strat->L[i].p) != strat->tail)
11286  strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11287  }
11288  if ((strat->P.t_p != NULL) ||
11289  ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11290  strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11291 
11292  if ((L != NULL) && (L->tailRing != new_tailRing))
11293  {
11294  if (L->i_r < 0)
11295  L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11296  else
11297  {
11298  assume(L->i_r <= strat->tl);
11299  TObject* t_l = strat->R[L->i_r];
11300  assume(t_l != NULL);
11301  L->tailRing = new_tailRing;
11302  L->p = t_l->p;
11303  L->t_p = t_l->t_p;
11304  L->max_exp = t_l->max_exp;
11305  }
11306  }
11307 
11308  if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11309  T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11310 
11311  omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11312  if (strat->tailRing != currRing)
11313  rKillModifiedRing(strat->tailRing);
11314 
11315  strat->tailRing = new_tailRing;
11316  strat->tailBin = new_tailBin;
11317  strat->p_shallow_copy_delete
11318  = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11319 
11320  if (strat->kNoether != NULL)
11321  {
11322  if (strat->t_kNoether != NULL)
11323  p_LmFree(strat->t_kNoether, strat->tailRing);
11324  strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_tailRing);
11325  }
11326 
11327  kTest_TS(strat);
11328  if (TEST_OPT_PROT)
11329  PrintS("]");
11330  return TRUE;
11331 }
poly t_kNoether
Definition: kutil.h:330
pFDegProc pOrigFDeg_TailRing
Definition: kutil.h:298
pLDegProc pOrigLDeg_TailRing
Definition: kutil.h:299
omBin_t * omBin
Definition: omStructs.h:12
void rKillModifiedRing(ring r)
Definition: ring.cc:3004
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2643
#define omGetStickyBinOfBin(B)
Definition: xalloc.h:300
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:329

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11333 of file kutil.cc.

11334 {
11335  unsigned long l = 0;
11336  int i;
11337  long e;
11338 
11339  assume(strat->tailRing == currRing);
11340 
11341  for (i=0; i<= strat->Ll; i++)
11342  {
11343  l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11344  }
11345  for (i=0; i<=strat->tl; i++)
11346  {
11347  // Hmm ... this we could do in one Step
11348  l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11349  }
11350  if (rField_is_Ring(currRing))
11351  {
11352  l *= 2;
11353  }
11354  e = p_GetMaxExp(l, currRing);
11355  if (e <= 1) e = 2;
11356  if (rIsLPRing(currRing)) e = 1;
11357 
11358  kStratChangeTailRing(strat, NULL, NULL, e);
11359 }
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:1171
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:753

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1036 of file kutil.cc.

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

◆ kTest_L()

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

Definition at line 950 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1079 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 825 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1097 of file kutil.cc.

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

◆ kTestDivisibleByT0_Z()

int kTestDivisibleByT0_Z ( const kStrategy  strat,
const LObject L 
)

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

Definition at line 142 of file kstd2.cc.

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

◆ message()

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

Definition at line 7730 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7803 of file kutil.cc.

7804 {
7805  int i;
7806  if (strat->news)
7807  {
7808  PrintS("set S");
7809  for (i=0; i<=strat->sl; i++)
7810  {
7811  Print("\n %d:",i);
7812  p_wrp(strat->S[i], currRing, strat->tailRing);
7813  if (strat->fromQ!=NULL && strat->fromQ[i])
7814  Print(" (from Q)");
7815  }
7816  strat->news = FALSE;
7817  }
7818  if (strat->newt)
7819  {
7820  PrintS("\nset T");
7821  for (i=0; i<=strat->tl; i++)
7822  {
7823  Print("\n %d:",i);
7824  strat->T[i].wrp();
7825  if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7826  Print(" o:%ld e:%d l:%d",
7827  strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7828  }
7829  strat->newt = FALSE;
7830  }
7831  PrintS("\nset L");
7832  for (i=strat->Ll; i>=0; i--)
7833  {
7834  Print("\n%d:",i);
7835  p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7836  PrintS(" ");
7837  p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7838  PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7839  PrintS("\n p : ");
7840  strat->L[i].wrp();
7841  Print(" o:%ld e:%d l:%d",
7842  strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7843  }
7844  PrintLn();
7845 }

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7771 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7784 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10681 of file kutil.cc.

10682 {
10683  if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10684  return FALSE;
10685  int i,j;
10686  poly newNoether;
10687 
10688 #if 0
10689  if (currRing->weight_all_1)
10690  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether, strat->tailRing);
10691  else
10692  scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether, strat->tailRing);
10693 #else
10694  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether, strat->tailRing);
10695 #endif
10696  if (strat->kNoether==NULL) return FALSE;
10697  if (strat->t_kNoether != NULL)
10698  {
10699  p_LmFree(strat->t_kNoether, strat->tailRing);
10700  strat->t_kNoether=NULL;
10701  }
10702  if (strat->tailRing != currRing)
10703  strat->t_kNoether = k_LmInit_currRing_2_tailRing(strat->kNoether, strat->tailRing);
10704  /* compare old and new noether*/
10705  newNoether = pLmInit(strat->kNoether);
10706  pSetCoeff0(newNoether,nInit(1));
10707  j = p_FDeg(newNoether,currRing);
10708  for (i=1; i<=(currRing->N); i++)
10709  {
10710  if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10711  }
10712  pSetm(newNoether);
10713  if (j < HCord) /*- statistics -*/
10714  {
10715  if (TEST_OPT_PROT)
10716  {
10717  Print("H(%d)",j);
10718  mflush();
10719  }
10720  HCord=j;
10721  #ifdef KDEBUG
10722  if (TEST_OPT_DEBUG)
10723  {
10724  Print("H(%d):",j);
10725  wrp(strat->kNoether);
10726  PrintLn();
10727  }
10728  #endif
10729  }
10730  if (pCmp(strat->kNoether,newNoether)!=1)
10731  {
10732  if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10733  strat->kNoether=newNoether;
10734  if (strat->t_kNoether != NULL)
10735  {
10736  p_LmFree(strat->t_kNoether, strat->tailRing);
10737  strat->t_kNoether=NULL;
10738  }
10739  if (strat->tailRing != currRing)
10740  strat->t_kNoether = k_LmInit_currRing_2_tailRing(strat->kNoether, strat->tailRing);
10741 
10742  return TRUE;
10743  }
10744  pLmDelete(newNoether);
10745  return FALSE;
10746 }
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1079
VAR int HCord
Definition: kutil.cc:246
static void p_LmDelete0(poly p, const ring r)
Definition: p_polys.h:717
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition: polys.h:115
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pDecrExp(p, i)
Definition: polys.h:44

◆ pairs()

void pairs ( )

◆ pCopyL2p()

poly pCopyL2p ( LObject  h,
kStrategy  strat 
)

Definition at line 11948 of file kutil.cc.

11949 {
11950  /* restores a poly in currRing from LObject */
11951  LObject h = H;
11952  h.Copy();
11953  poly p;
11954  if (h.p == NULL)
11955  {
11956  if (h.t_p != NULL)
11957  {
11958  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
11959  return(p);
11960  }
11961  else
11962  {
11963  /* h.tp == NULL -> the object is NULL */
11964  return(NULL);
11965  }
11966  }
11967  /* we're here if h.p != NULL */
11968  if (h.t_p == NULL)
11969  {
11970  /* then h.p is the whole poly in currRing */
11971  p = h.p;
11972  return(p);
11973  }
11974  /* we're here if h.p != NULL and h.t_p != NULL */
11975  // clean h.p, get poly from t_p
11976  pNext(h.p)=NULL;
11977  pLmDelete(&h.p);
11978  p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
11979  /* dest. ring: */ currRing);
11980  // no need to clean h: we re-used the polys
11981  return(p);
11982 }
CanonicalForm H
Definition: facAbsFact.cc:60
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89

◆ pMove2CurrTail()

poly pMove2CurrTail ( poly  p,
kStrategy  strat 
)

Definition at line 11917 of file kutil.cc.

11918 {
11919  /* assume: p is completely in currRing */
11920  /* produces an object with LM in curring
11921  and TAIL in tailring */
11922  if (pNext(p)!=NULL)
11923  {
11924  pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
11925  }
11926  return(p);
11927 }

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 11931 of file kutil.cc.

11932 {
11933  /* assume: p has LM in curring and TAIL in tailring */
11934  /* convert it to complete currRing */
11935 
11936  /* check that LM is in currRing */
11938 
11939  if (pNext(p)!=NULL)
11940  {
11941  pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
11942  }
11943  return(p);
11944 }

◆ posInIdealMonFirst()

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

Definition at line 4903 of file kutil.cc.

4904 {
4905  if(end < 0 || end >= IDELEMS(F))
4906  end = IDELEMS(F);
4907  if (end<0) return 0;
4908  if(pNext(p) == NULL) return start;
4909  polyset set=F->m;
4910  int o = p_Deg(p,currRing);
4911  int op;
4912  int i;
4913  int an = start;
4914  for(i=start;i<end;i++)
4915  if(set[i] != NULL && pNext(set[i]) == NULL)
4916  an++;
4917  if(an == end-1)
4918  return end;
4919  int en= end;
4920  loop
4921  {
4922  if(an>=en)
4923  return en;
4924  if (an == en-1)
4925  {
4926  op = p_Deg(set[an],currRing);
4927  if ((op < o)
4928  || ((op == o) && (pLtCmp(set[an],p) == -1)))
4929  return en;
4930  return an;
4931  }
4932  i=(an+en) / 2;
4933  op = p_Deg(set[i],currRing);
4934  if ((op < o)
4935  || ((op == o) && (pLtCmp(set[i],p) == -1)))
4936  an=i;
4937  else
4938  en=i;
4939  }
4940 }
poly * polyset
Definition: polys.h:259

◆ posInL0()

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

Definition at line 5752 of file kutil.cc.

5754 {
5755  if (length<0) return 0;
5756 
5757  if (pLmCmp(set[length].p,p->p)== currRing->OrdSgn)
5758  return length+1;
5759 
5760  int i;
5761  int an = 0;
5762  int en= length;
5763  loop
5764  {
5765  if (an >= en-1)
5766  {
5767  if (pLmCmp(set[an].p,p->p) == currRing->OrdSgn) return en;
5768  return an;
5769  }
5770  i=(an+en) / 2;
5771  if (pLmCmp(set[i].p,p->p) == currRing->OrdSgn) an=i;
5772  else en=i;
5773  /*aend. fuer lazy == in !=- machen */
5774  }
5775 }

◆ posInL10()

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

Definition at line 1352 of file kstd1.cc.

1353 {
1354  int j,dp,dL;
1355 
1356  if (length<0) return 0;
1357  if (hasPurePower(p,strat->lastAxis,&dp,strat))
1358  {
1359  int op= p->GetpFDeg() +p->ecart;
1360  for (j=length; j>=0; j--)
1361  {
1362  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1363  return j+1;
1364  if (dp < dL)
1365  return j+1;
1366  if ((dp == dL)
1367  && (set[j].GetpFDeg()+set[j].ecart >= op))
1368  return j+1;
1369  }
1370  }
1371  j=length;
1372  loop
1373  {
1374  if (j<0) break;
1375  if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1376  j--;
1377  }
1378  return strat->posInLOld(set,j,p,strat);
1379 }
int lastAxis
Definition: kutil.h:355
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition: kutil.h:288
BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition: kstd1.cc:1304

◆ posInL10Ring()

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

◆ posInL11()

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

Definition at line 6010 of file kutil.cc.

6012 {
6013  if (length<0) return 0;
6014 
6015  int o = p->GetpFDeg();
6016  int op = set[length].GetpFDeg();
6017 
6018  if ((op > o)
6019  || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6020  return length+1;
6021  int i;
6022  int an = 0;
6023  int en= length;
6024  loop
6025  {
6026  if (an >= en-1)
6027  {
6028  op = set[an].GetpFDeg();
6029  if ((op > o)
6030  || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6031  return en;
6032  return an;
6033  }
6034  i=(an+en) / 2;
6035  op = set[i].GetpFDeg();
6036  if ((op > o)
6037  || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6038  an=i;
6039  else
6040  en=i;
6041  }
6042 }

◆ posInL110()

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

Definition at line 6308 of file kutil.cc.

6310 {
6311  if (length<0) return 0;
6312 
6313  int o = p->GetpFDeg();
6314  int op = set[length].GetpFDeg();
6315 
6316  if ((op > o)
6317  || ((op == o) && (set[length].length >p->length))
6318  || ((op == o) && (set[length].length <= p->length)
6319  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6320  return length+1;
6321  int i;
6322  int an = 0;
6323  int en= length;
6324  loop
6325  {
6326  if (an >= en-1)
6327  {
6328  op = set[an].GetpFDeg();
6329  if ((op > o)
6330  || ((op == o) && (set[an].length >p->length))
6331  || ((op == o) && (set[an].length <=p->length)
6332  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6333  return en;
6334  return an;
6335  }
6336  i=(an+en) / 2;
6337  op = set[i].GetpFDeg();
6338  if ((op > o)
6339  || ((op == o) && (set[i].length > p->length))
6340  || ((op == o) && (set[i].length <= p->length)
6341  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6342  an=i;
6343  else
6344  en=i;
6345  }
6346 }

◆ posInL11Ring()

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

Definition at line 6052 of file kutil.cc.

6054 {
6055  if (length<0) return 0;
6056 
6057  int o = p->GetpFDeg();
6058  int op = set[length].GetpFDeg();
6059 
6060  if ((op > o)
6061  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6062  return length+1;
6063  int i;
6064  int an = 0;
6065  int en= length;
6066  loop
6067  {
6068  if (an >= en-1)
6069  {
6070  op = set[an].GetpFDeg();
6071  if ((op > o)
6072  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6073  return en;
6074  return an;
6075  }
6076  i=(an+en) / 2;
6077  op = set[i].GetpFDeg();
6078  if ((op > o)
6079  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6080  an=i;
6081  else
6082  en=i;
6083  }
6084 }
#define pLtCmpOrdSgnDiffM(p, q)
Definition: polys.h:125

◆ posInL11Ringls()

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

Definition at line 6122 of file kutil.cc.

6124 {
6125  if (length < 0) return 0;
6126  int an,en,i;
6127  an = 0;
6128  en = length+1;
6129  loop
6130  {
6131  if (an >= en-1)
6132  {
6133  if(an == en)
6134  return en;
6135  if (set[an].FDeg > p->FDeg)
6136  return en;
6137  if (set[an].FDeg < p->FDeg)
6138  return an;
6139  if (set[an].FDeg == p->FDeg)
6140  {
6141  number lcset,lcp;
6142  lcset = pGetCoeff(set[an].p);
6143  lcp = pGetCoeff(p->p);
6144  if(!nGreaterZero(lcset))
6145  {
6146  set[an].p=p_Neg(set[an].p,currRing);
6147  if (set[an].t_p!=NULL)
6148  pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
6149  lcset=pGetCoeff(set[an].p);
6150  }
6151  if(!nGreaterZero(lcp))
6152  {
6153  p->p=p_Neg(p->p,currRing);
6154  if (p->t_p!=NULL)
6155  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6156  lcp=pGetCoeff(p->p);
6157  }
6158  if(nGreater(lcset, lcp))
6159  {
6160  return en;
6161  }
6162  else
6163  {
6164  return an;
6165  }
6166  }
6167  }
6168  i=(an+en) / 2;
6169  if (set[i].FDeg > p->FDeg)
6170  an=i;
6171  if (set[i].FDeg < p->FDeg)
6172  en=i;
6173  if (set[i].FDeg == p->FDeg)
6174  {
6175  number lcset,lcp;
6176  lcset = pGetCoeff(set[i].p);
6177  lcp = pGetCoeff(p->p);
6178  if(!nGreaterZero(lcset))
6179  {
6180  set[i].p=p_Neg(set[i].p,currRing);
6181  if (set[i].t_p!=NULL)
6182  pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6183  lcset=pGetCoeff(set[i].p);
6184  }
6185  if(!nGreaterZero(lcp))
6186  {
6187  p->p=p_Neg(p->p,currRing);
6188  if (p->t_p!=NULL)
6189  pSetCoeff0(p->t_p,pGetCoeff(p->p));
6190  lcp=pGetCoeff(p->p);
6191  }
6192  if(nGreater(lcset, lcp))
6193  {
6194  an = i;
6195  }
6196  else
6197  {
6198  en = i;
6199  }
6200  }
6201  }
6202 }
#define nGreater(a, b)
Definition: numbers.h:28

◆ posInL13()

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

Definition at line 6396 of file kutil.cc.

6398 {
6399  if (length<0) return 0;
6400 
6401  int o = p->GetpFDeg();
6402 
6403  if (set[length].GetpFDeg() > o)
6404  return length+1;
6405 
6406  int i;
6407  int an = 0;
6408  int en= length;
6409  loop
6410  {
6411  if (an >= en-1)
6412  {
6413  if (set[an].GetpFDeg() >= o)
6414  return en;
6415  return an;
6416  }
6417  i=(an+en) / 2;
6418  if (set[i].GetpFDeg() >= o)
6419  an=i;
6420  else
6421  en=i;
6422  }
6423 }

◆ posInL15()

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

Definition at line 6431 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6466 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6507 of file kutil.cc.

6509 {
6510  if (length<0) return 0;
6511 
6512  int o = p->GetpFDeg() + p->ecart;
6513 
6514  if ((set[length].GetpFDeg() + set[length].ecart > o)
6515  || ((set[length].GetpFDeg() + set[length].ecart == o)
6516  && (set[length].ecart > p->ecart))
6517  || ((set[length].GetpFDeg() + set[length].ecart == o)
6518  && (set[length].ecart == p->ecart)
6519  && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6520  return length+1;
6521  int i;
6522  int an = 0;
6523  int en= length;
6524  loop
6525  {
6526  if (an >= en-1)
6527  {
6528  if ((set[an].GetpFDeg() + set[an].ecart > o)
6529  || ((set[an].GetpFDeg() + set[an].ecart == o)
6530  && (set[an].ecart > p->ecart))
6531  || ((set[an].GetpFDeg() + set[an].ecart == o)
6532  && (set[an].ecart == p->ecart)
6533  && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6534  return en;
6535  return an;
6536  }
6537  i=(an+en) / 2;
6538  if ((set[i].GetpFDeg() + set[i].ecart > o)
6539  || ((set[i].GetpFDeg() + set[i].ecart == o)
6540  && (set[i].ecart > p->ecart))
6541  || ((set[i].GetpFDeg() +set[i].ecart == o)
6542  && (set[i].ecart == p->ecart)
6543  && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6544  an=i;
6545  else
6546  en=i;
6547  }
6548 }

◆ posInLF5C()

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

Definition at line 5998 of file kutil.cc.

6000 {
6001  return strat->Ll+1;
6002 }

◆ posInLF5CRing()

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

Definition at line 6086 of file kutil.cc.

6088 {
6089  if (length<0) return 0;
6090  if(start == (length +1)) return (length+1);
6091  int o = p->GetpFDeg();
6092  int op = set[length].GetpFDeg();
6093 
6094  if ((op > o)
6095  || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6096  return length+1;
6097  int i;
6098  int an = start;
6099  int en= length;
6100  loop
6101  {
6102  if (an >= en-1)
6103  {
6104  op = set[an].GetpFDeg();
6105  if ((op > o)
6106  || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6107  return en;
6108  return an;
6109  }
6110  i=(an+en) / 2;
6111  op = set[i].GetpFDeg();
6112  if ((op > o)
6113  || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6114  an=i;
6115  else
6116  en=i;
6117  }
6118 }

◆ posInLRing()

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

Definition at line 5897 of file kutil.cc.

5899 {
5900  if (length < 0) return 0;
5901  if (set[length].FDeg > p->FDeg)
5902  return length+1;
5903  if (set[length].FDeg == p->FDeg)
5904  if(set[length].GetpLength() > p->GetpLength())
5905  return length+1;
5906  int i;
5907  int an = 0;
5908  int en= length+1;
5909  loop
5910  {
5911  if (an >= en-1)
5912  {
5913  if(an == en)
5914  return en;
5915  if (set[an].FDeg > p->FDeg)
5916  return en;
5917  if(set[an].FDeg == p->FDeg)
5918  {
5919  if(set[an].GetpLength() > p->GetpLength())
5920  return en;
5921  else
5922  {
5923  if(set[an].GetpLength() == p->GetpLength())
5924  {
5925  if(nGreater(set[an].p->coef, p->p->coef))
5926  return en;
5927  else
5928  return an;
5929  }
5930  else
5931  {
5932  return an;
5933  }
5934  }
5935  }
5936  else
5937  return an;
5938  }
5939  i=(an+en) / 2;
5940  if (set[i].FDeg > p->FDeg)
5941  an=i;
5942  else
5943  {
5944  if(set[i].FDeg == p->FDeg)
5945  {
5946  if(set[i].GetpLength() > p->GetpLength())
5947  an=i;
5948  else
5949  {
5950  if(set[i].GetpLength() == p->GetpLength())
5951  {
5952  if(nGreater(set[i].p->coef, p->p->coef))
5953  an = i;
5954  else
5955  en = i;
5956  }
5957  else
5958  {
5959  en=i;
5960  }
5961  }
5962  }
5963  else
5964  en=i;
5965  }
5966  }
5967 }

◆ posInLSig()

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

Definition at line 5810 of file kutil.cc.

5812 {
5813  if (length<0) return 0;
5814  if (pLtCmp(set[length].sig,p->sig)== currRing->OrdSgn)
5815  return length+1;
5816 
5817  int i;
5818  int an = 0;
5819  int en= length;
5820  loop
5821  {
5822  if (an >= en-1)
5823  {
5824  if (pLtCmp(set[an].sig,p->sig) == currRing->OrdSgn) return en;
5825  return an;
5826  }
5827  i=(an+en) / 2;
5828  if (pLtCmp(set[i].sig,p->sig) == currRing->OrdSgn) an=i;
5829  else en=i;
5830  /*aend. fuer lazy == in !=- machen */
5831  }
5832 }

◆ posInLSigRing()

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

Definition at line 5834 of file kutil.cc.

5836 {
5837  assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
5838  if (length<0) return 0;
5839  if (pLtCmp(set[length].sig,p->sig)== 1)
5840  return length+1;
5841 
5842  int an,en,i;
5843  an = 0;
5844  en = length+1;
5845  int cmp;
5846  loop
5847  {
5848  if (an >= en-1)
5849  {
5850  if(an == en)
5851  return en;
5852  cmp = pLtCmp(set[an].sig,p->sig);
5853  if (cmp == 1)
5854  return en;
5855  if (cmp == -1)
5856  return an;
5857  if (cmp == 0)
5858  {
5859  if (set[an].FDeg > p->FDeg)
5860  return en;
5861  if (set[an].FDeg < p->FDeg)
5862  return an;
5863  if (set[an].FDeg == p->FDeg)
5864  {
5865  cmp = pLtCmp(set[an].p,p->p);
5866  if(cmp == 1)
5867  return en;
5868  else
5869  return an;
5870  }
5871  }
5872  }
5873  i=(an+en) / 2;
5874  cmp = pLtCmp(set[i].sig,p->sig);
5875  if (cmp == 1)
5876  an = i;
5877  if (cmp == -1)
5878  en = i;
5879  if (cmp == 0)
5880  {
5881  if (set[i].FDeg > p->FDeg)
5882  an = i;
5883  if (set[i].FDeg < p->FDeg)
5884  en = i;
5885  if (set[i].FDeg == p->FDeg)
5886  {
5887  cmp = pLtCmp(set[i].p,p->p);
5888  if(cmp == 1)
5889  an = i;
5890  else
5891  en = i;
5892  }
5893  }
5894  }
5895 }

◆ posInS()

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

Definition at line 4725 of file kutil.cc.

4727 {
4728  if(length==-1) return 0;
4729  polyset set=strat->S;
4730  int i;
4731  int an = 0;
4732  int en = length;
4733  int cmp_int = currRing->OrdSgn;
4735 #ifdef HAVE_PLURAL
4736  && (currRing->real_var_start==0)
4737 #endif
4738 #if 0
4739  || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
4740 #endif
4741  )
4742  {
4743  int o=p_Deg(p,currRing);
4744  int oo=p_Deg(set[length],currRing);
4745 
4746  if ((oo<o)
4747  || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
4748  return length+1;
4749 
4750  loop
4751  {
4752  if (an >= en-1)
4753  {
4754  if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
4755  {
4756  return an;
4757  }
4758  return en;
4759  }
4760  i=(an+en) / 2;
4761  if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
4762  else an=i;
4763  }
4764  }
4765  else
4766  {
4767  if (rField_is_Ring(currRing))
4768  {
4769  if (pLmCmp(set[length],p)== -cmp_int)
4770  return length+1;
4771  int cmp;
4772  loop
4773  {
4774  if (an >= en-1)
4775  {
4776  cmp = pLmCmp(set[an],p);
4777  if (cmp == cmp_int) return an;
4778  if (cmp == -cmp_int) return en;
4779  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
4780  return an;
4781  }
4782  i = (an+en) / 2;
4783  cmp = pLmCmp(set[i],p);
4784  if (cmp == cmp_int) en = i;
4785  else if (cmp == -cmp_int) an = i;
4786  else
4787  {
4788  if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
4789  else en = i;
4790  }
4791  }
4792  }
4793  else
4794  if (pLmCmp(set[length],p)== -cmp_int)
4795  return length+1;
4796 
4797  loop
4798  {
4799  if (an >= en-1)
4800  {
4801  if (pLmCmp(set[an],p) == cmp_int) return an;
4802  if (pLmCmp(set[an],p) == -cmp_int) return en;
4803  if ((cmp_int!=1)
4804  && ((strat->ecartS[an])>ecart_p))
4805  return an;
4806  return en;
4807  }
4808  i=(an+en) / 2;
4809  if (pLmCmp(set[i],p) == cmp_int) en=i;
4810  else if (pLmCmp(set[i],p) == -cmp_int) an=i;
4811  else
4812  {
4813  if ((cmp_int!=1)
4814  &&((strat->ecartS[i])<ecart_p))
4815  en=i;
4816  else
4817  an=i;
4818  }
4819  }
4820  }
4821 }

◆ posInSMonFirst()

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

Definition at line 4826 of file kutil.cc.

4827 {
4828  if (length<0) return 0;
4829  polyset set=strat->S;
4830  if(pNext(p) == NULL)
4831  {
4832  int mon = 0;
4833  for(int i = 0;i<=length;i++)
4834  {
4835  if(set[i] != NULL && pNext(set[i]) == NULL)
4836  mon++;
4837  }
4838  int o = p_Deg(p,currRing);
4839  int op = p_Deg(set[mon],currRing);
4840 
4841  if ((op < o)
4842  || ((op == o) && (pLtCmp(set[mon],p) == -1)))
4843  return length+1;
4844  int i;
4845  int an = 0;
4846  int en= mon;
4847  loop
4848  {
4849  if (an >= en-1)
4850  {
4851  op = p_Deg(set[an],currRing);
4852  if ((op < o)
4853  || ((op == o) && (pLtCmp(set[an],p) == -1)))
4854  return en;
4855  return an;
4856  }
4857  i=(an+en) / 2;
4858  op = p_Deg(set[i],currRing);
4859  if ((op < o)
4860  || ((op == o) && (pLtCmp(set[i],p) == -1)))
4861  an=i;
4862  else
4863  en=i;
4864  }
4865  }
4866  else /*if(pNext(p) != NULL)*/
4867  {
4868  int o = p_Deg(p,currRing);
4869  int op = p_Deg(set[length],currRing);
4870 
4871  if ((op < o)
4872  || ((op == o) && (pLtCmp(set[length],p) == -1)))
4873  return length+1;
4874  int i;
4875  int an = 0;
4876  for(i=0;i<=length;i++)
4877  if(set[i] != NULL && pNext(set[i]) == NULL)
4878  an++;
4879  int en= length;
4880  loop
4881  {
4882  if (an >= en-1)
4883  {
4884  op = p_Deg(set[an],currRing);
4885  if ((op < o)
4886  || ((op == o) && (pLtCmp(set[an],p) == -1)))
4887  return en;
4888  return an;
4889  }
4890  i=(an+en) / 2;
4891  op = p_Deg(set[i],currRing);
4892  if ((op < o)
4893  || ((op == o) && (pLtCmp(set[i],p) == -1)))
4894  an=i;
4895  else
4896  en=i;
4897  }
4898  }
4899 }

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 5970 of file kutil.cc.

5971 {
5972  if (strat->syzl==0) return 0;
5973  if (pLtCmp(strat->syz[strat->syzl-1],sig) != currRing->OrdSgn)
5974  return strat->syzl;
5975  int i;
5976  int an = 0;
5977  int en= strat->syzl-1;
5978  loop
5979  {
5980  if (an >= en-1)
5981  {
5982  if (pLtCmp(strat->syz[an],sig) != currRing->OrdSgn) return en;
5983  return an;
5984  }
5985  i=(an+en) / 2;
5986  if (pLtCmp(strat->syz[i],sig) != currRing->OrdSgn) an=i;
5987  else en=i;
5988  /*aend. fuer lazy == in !=- machen */
5989  }
5990 }

◆ posInT0()

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

Definition at line 4947 of file kutil.cc.

4948 {
4949  return (length+1);
4950 }

◆ posInT1()

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

Definition at line 4958 of file kutil.cc.

4959 {
4960  if (length==-1) return 0;
4961 
4962  if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
4963 
4964  int i;
4965  int an = 0;
4966  int en= length;
4967 
4968  loop
4969  {
4970  if (an >= en-1)
4971  {
4972  if (pLmCmp(set[an].p,p.p) == currRing->OrdSgn) return an;
4973  return en;
4974  }
4975  i=(an+en) / 2;
4976  if (pLmCmp(set[i].p,p.p) == currRing->OrdSgn) en=i;
4977  else an=i;
4978  }
4979 }

◆ posInT11()

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

Definition at line 5014 of file kutil.cc.

5015 {
5016  if (length==-1) return 0;
5017 
5018  int o = p.GetpFDeg();
5019  int op = set[length].GetpFDeg();
5020 
5021  if ((op < o)
5022  || ((op == o) && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5023  return length+1;
5024 
5025  int i;
5026  int an = 0;
5027  int en= length;
5028 
5029  loop
5030  {
5031  if (an >= en-1)
5032  {
5033  op= set[an].GetpFDeg();
5034  if ((op > o)
5035  || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5036  return an;
5037  return en;
5038  }
5039  i=(an+en) / 2;
5040  op = set[i].GetpFDeg();
5041  if (( op > o)
5042  || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5043  en=i;
5044  else
5045  an=i;
5046  }
5047 }

◆ posInT110()

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

Definition at line 5167 of file kutil.cc.

5168 {
5169  if (length==-1) return 0;
5170  p.GetpLength();
5171 
5172  int o = p.GetpFDeg();
5173  int op = set[length].GetpFDeg();
5174 
5175  if (( op < o)
5176  || (( op == o) && (set[length].length<p.length))
5177  || (( op == o) && (set[length].length == p.length)
5178  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5179  return length+1;
5180 
5181  int i;
5182  int an = 0;
5183  int en= length;
5184  loop
5185  {
5186  if (an >= en-1)
5187  {
5188  op = set[an].GetpFDeg();
5189  if (( op > o)
5190  || (( op == o) && (set[an].length > p.length))
5191  || (( op == o) && (set[an].length == p.length)
5192  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5193  return an;
5194  return en;
5195  }
5196  i=(an+en) / 2;
5197  op = set[i].GetpFDeg();
5198  if (( op > o)
5199  || (( op == o) && (set[i].length > p.length))
5200  || (( op == o) && (set[i].length == p.length)
5201  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5202  en=i;
5203  else
5204  an=i;
5205  }
5206 }

◆ posInT13()

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

Definition at line 5256 of file kutil.cc.

5257 {
5258  if (length==-1) return 0;
5259 
5260  int o = p.GetpFDeg();
5261 
5262  if (set[length].GetpFDeg() <= o)
5263  return length+1;
5264 
5265  int i;
5266  int an = 0;
5267  int en= length;
5268  loop
5269  {
5270  if (an >= en-1)
5271  {
5272  if (set[an].GetpFDeg() > o)
5273  return an;
5274  return en;
5275  }
5276  i=(an+en) / 2;
5277  if (set[i].GetpFDeg() > o)
5278  en=i;
5279  else
5280  an=i;
5281  }
5282 }

◆ posInT15()

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

Definition at line 5323 of file kutil.cc.

5342 {
5343  if (length==-1) return 0;
5344 
5345  int o = p.GetpFDeg() + p.ecart;
5346  int op = set[length].GetpFDeg()+set[length].ecart;
5347 
5348  if ((op < o)
5349  || ((op == o)
5350  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5351  return length+1;
5352 
5353  int i;
5354  int an = 0;
5355  int en= length;
5356  loop
5357  {
5358  if (an >= en-1)
5359  {
5360  op = set[an].GetpFDeg()+set[an].ecart;
5361  if (( op > o)
5362  || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5363  return an;
5364  return en;
5365  }
5366  i=(an+en) / 2;
5367  op = set[i].GetpFDeg()+set[i].ecart;
5368  if (( op > o)
5369  || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5370  en=i;
5371  else
5372  an=i;
5373  }
5374 }

◆ posInT17()

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

Definition at line 5418 of file kutil.cc.

5439 {
5440  if (length==-1) return 0;
5441 
5442  int o = p.GetpFDeg() + p.ecart;
5443  int op = set[length].GetpFDeg()+set[length].ecart;
5444 
5445  if ((op < o)
5446  || (( op == o) && (set[length].ecart > p.ecart))
5447  || (( op == o) && (set[length].ecart==p.ecart)
5448  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5449  return length+1;
5450 
5451  int i;
5452  int an = 0;
5453  int en= length;
5454  loop
5455  {
5456  if (an >= en-1)
5457  {
5458  op = set[an].GetpFDeg()+set[an].ecart;
5459  if (( op > o)
5460  || (( op == o) && (set[an].ecart < p.ecart))
5461  || (( op == o) && (set[an].ecart==p.ecart)
5462  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5463  return an;
5464  return en;
5465  }
5466  i=(an+en) / 2;
5467  op = set[i].GetpFDeg()+set[i].ecart;
5468  if ((op > o)
5469  || (( op == o) && (set[i].ecart < p.ecart))
5470  || (( op == o) && (set[i].ecart == p.ecart)
5471  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5472  en=i;
5473  else
5474  an=i;
5475  }
5476 }

◆ posInT17_c()

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

Definition at line 5525 of file kutil.cc.

5526 {
5527  if (length==-1) return 0;
5528 
5529  int cc = (-1+2*currRing->order[0]==ringorder_c);
5530  /* cc==1 for (c,..), cc==-1 for (C,..) */
5531  int o = p.GetpFDeg() + p.ecart;
5532  int c = pGetComp(p.p)*cc;
5533 
5534  if (pGetComp(set[length].p)*cc < c)
5535  return length+1;
5536  if (pGetComp(set[length].p)*cc == c)
5537  {
5538  int op = set[length].GetpFDeg()+set[length].ecart;
5539  if ((op < o)
5540  || ((op == o) && (set[length].ecart > p.ecart))
5541  || ((op == o) && (set[length].ecart==p.ecart)
5542  && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5543  return length+1;
5544  }
5545 
5546  int i;
5547  int an = 0;
5548  int en= length;
5549  loop
5550  {
5551  if (an >= en-1)
5552  {
5553  if (pGetComp(set[an].p)*cc < c)
5554  return en;
5555  if (pGetComp(set[an].p)*cc == c)
5556  {
5557  int op = set[an].GetpFDeg()+set[an].ecart;
5558  if ((op > o)
5559  || ((op == o) && (set[an].ecart < p.ecart))
5560  || ((op == o) && (set[an].ecart==p.ecart)
5561  && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5562  return an;
5563  }
5564  return en;
5565  }
5566  i=(an+en) / 2;
5567  if (pGetComp(set[i].p)*cc > c)
5568  en=i;
5569  else if (pGetComp(set[i].p)*cc == c)
5570  {
5571  int op = set[i].GetpFDeg()+set[i].ecart;
5572  if ((op > o)
5573  || ((op == o) && (set[i].ecart < p.ecart))
5574  || ((op == o) && (set[i].ecart == p.ecart)
5575  && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5576  en=i;
5577  else
5578  an=i;
5579  }
5580  else
5581  an=i;
5582  }
5583 }

◆ posInT19()

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

Definition at line 5652 of file kutil.cc.

5653 {
5654  p.GetpLength();
5655  if (length==-1) return 0;
5656 
5657  int o = p.ecart;
5658  int op=p.GetpFDeg();
5659 
5660  if (set[length].ecart < o)
5661  return length+1;
5662  if (set[length].ecart == o)
5663  {
5664  int oo=set[length].GetpFDeg();
5665  if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5666  return length+1;
5667  }
5668 
5669  int i;
5670  int an = 0;
5671  int en= length;
5672  loop
5673  {
5674  if (an >= en-1)
5675  {
5676  if (set[an].ecart > o)
5677  return an;
5678  if (set[an].ecart == o)
5679  {
5680  int oo=set[an].GetpFDeg();
5681  if((oo > op)
5682  || ((oo==op) && (set[an].length > p.length)))
5683  return an;
5684  }
5685  return en;
5686  }
5687  i=(an+en) / 2;
5688  if (set[i].ecart > o)
5689  en=i;
5690  else if (set[i].ecart == o)
5691  {
5692  int oo=set[i].GetpFDeg();
5693  if ((oo > op)
5694  || ((oo == op) && (set[i].length > p.length)))
5695  en=i;
5696  else
5697  an=i;
5698  }
5699  else
5700  an=i;
5701  }
5702 }

◆ posInT2()

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

Definition at line 4986 of file kutil.cc.

4987 {
4988  if (length==-1) return 0;
4989  p.GetpLength();
4990  if (set[length].length<p.length) return length+1;
4991 
4992  int i;
4993  int an = 0;
4994  int en= length;
4995 
4996  loop
4997  {
4998  if (an >= en-1)
4999  {
5000  if (set[an].length>p.length) return an;
5001  return en;
5002  }
5003  i=(an+en) / 2;
5004  if (set[i].length>p.length) en=i;
5005  else an=i;
5006  }
5007 }

◆ posInT_EcartFDegpLength()

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

Definition at line 11654 of file kutil.cc.

11655 {
11656 
11657  if (length==-1) return 0;
11658 
11659  int o = p.ecart;
11660  int op=p.GetpFDeg();
11661  int ol = p.GetpLength();
11662 
11663  if (set[length].ecart < o)
11664  return length+1;
11665  if (set[length].ecart == o)
11666  {
11667  int oo=set[length].GetpFDeg();
11668  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11669  return length+1;
11670  }
11671 
11672  int i;
11673  int an = 0;
11674  int en= length;
11675  loop
11676  {
11677  if (an >= en-1)
11678  {
11679  if (set[an].ecart > o)
11680  return an;
11681  if (set[an].ecart == o)
11682  {
11683  int oo=set[an].GetpFDeg();
11684  if((oo > op)
11685  || ((oo==op) && (set[an].pLength > ol)))
11686  return an;
11687  }
11688  return en;
11689  }
11690  i=(an+en) / 2;
11691  if (set[i].ecart > o)
11692  en=i;
11693  else if (set[i].ecart == o)
11694  {
11695  int oo=set[i].GetpFDeg();
11696  if ((oo > op)
11697  || ((oo == op) && (set[i].pLength > ol)))
11698  en=i;
11699  else
11700  an=i;
11701  }
11702  else
11703  an=i;
11704  }
11705 }

◆ posInT_EcartpLength()

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

Definition at line 5285 of file kutil.cc.

5286 {
5287  if (length==-1) return 0;
5288  int ol = p.GetpLength();
5289  int op=p.ecart;
5290  int oo=set[length].ecart;
5291 
5292  if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5293  return length+1;
5294 
5295  int i;
5296  int an = 0;
5297  int en= length;
5298  loop
5299  {
5300  if (an >= en-1)
5301  {
5302  int oo=set[an].ecart;
5303  if((oo > op)
5304  || ((oo==op) && (set[an].pLength > ol)))
5305  return an;
5306  return en;
5307  }
5308  i=(an+en) / 2;
5309  int oo=set[i].ecart;
5310  if ((oo > op)
5311  || ((oo == op) && (set[i].pLength > ol)))
5312  en=i;
5313  else
5314  an=i;
5315  }
5316 }

◆ posInT_FDegpLength()

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

Definition at line 11708 of file kutil.cc.

11709 {
11710 
11711  if (length==-1) return 0;
11712 
11713  int op=p.GetpFDeg();
11714  int ol = p.GetpLength();
11715 
11716  int oo=set[length].GetpFDeg();
11717  if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11718  return length+1;
11719 
11720  int i;
11721  int an = 0;
11722  int en= length;
11723  loop
11724  {
11725  if (an >= en-1)
11726  {
11727  int oo=set[an].GetpFDeg();
11728  if((oo > op)
11729  || ((oo==op) && (set[an].pLength > ol)))
11730  return an;
11731  return en;
11732  }
11733  i=(an+en) / 2;
11734  int oo=set[i].GetpFDeg();
11735  if ((oo > op)
11736  || ((oo == op) && (set[i].pLength > ol)))
11737  en=i;
11738  else
11739  an=i;
11740  }
11741 }

◆ posInT_pLength()

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

Definition at line 11745 of file kutil.cc.

11746 {
11747  int ol = p.GetpLength();
11748  if (length==-1)
11749  return 0;
11750  if (set[length].length<p.length)
11751  return length+1;
11752 
11753  int i;
11754  int an = 0;
11755  int en= length;
11756 
11757  loop
11758  {
11759  if (an >= en-1)
11760  {
11761  if (set[an].pLength>ol) return an;
11762  return en;
11763  }
11764  i=(an+en) / 2;
11765  if (set[i].pLength>ol) en=i;
11766  else an=i;
11767  }
11768 }

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

10983 {
10984  if(!nCoeff_is_Z(currRing->cf))
10985  return;
10986  poly pH = h->GetP();
10987  poly p,pp;
10988  p = pH;
10989  bool deleted = FALSE, ok = FALSE;
10990  for(int i = 0; i<=strat->sl; i++)
10991  {
10992  p = pH;
10993  if(pNext(strat->S[i]) == NULL)
10994  {
10995  //pWrite(p);
10996  //pWrite(strat->S[i]);
10997  while(ok == FALSE && p != NULL)
10998  {
10999  if(pLmDivisibleBy(strat->S[i], p)
11000 #ifdef HAVE_SHIFTBBA
11001  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
11002 #endif
11003  )
11004  {
11005  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11006  p_SetCoeff(p,dummy,currRing);
11007  }
11008  if(nIsZero(p->coef))
11009  {
11010  pLmDelete(&p);
11011  h->p = p;
11012  deleted = TRUE;
11013  }
11014  else
11015  {
11016  ok = TRUE;
11017  }
11018  }
11019  if (p!=NULL)
11020  {
11021  pp = pNext(p);
11022  while(pp != NULL)
11023  {
11024  if(pLmDivisibleBy(strat->S[i], pp)
11025 #ifdef HAVE_SHIFTBBA
11026  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
11027 #endif
11028  )
11029  {
11030  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11031  p_SetCoeff(pp,dummy,currRing);
11032  if(nIsZero(pp->coef))
11033  {
11034  pLmDelete(&pNext(p));
11035  pp = pNext(p);
11036  deleted = TRUE;
11037  }
11038  else
11039  {
11040  p = pp;
11041  pp = pNext(p);
11042  }
11043  }
11044  else
11045  {
11046  p = pp;
11047  pp = pNext(p);
11048  }
11049  }
11050  }
11051  }
11052  }
11053  h->SetLmCurrRing();
11054  if((deleted)&&(h->p!=NULL))
11055  strat->initEcart(h);
11056 }

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 11058 of file kutil.cc.

11059 {
11060  if(!nCoeff_is_Z(currRing->cf))
11061  return;
11062  poly hSig = h->sig;
11063  poly pH = h->GetP();
11064  poly p,pp;
11065  p = pH;
11066  bool deleted = FALSE, ok = FALSE;
11067  for(int i = 0; i<=strat->sl; i++)
11068  {
11069  p = pH;
11070  if(pNext(strat->S[i]) == NULL)
11071  {
11072  while(ok == FALSE && p!=NULL)
11073  {
11074  if(pLmDivisibleBy(strat->S[i], p))
11075  {
11076  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11077  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11078  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11079  {
11080  number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11081  p_SetCoeff(p,dummy,currRing);
11082  }
11083  pDelete(&sigMult);
11084  }
11085  if(nIsZero(p->coef))
11086  {
11087  pLmDelete(&p);
11088  h->p = p;
11089  deleted = TRUE;
11090  }
11091  else
11092  {
11093  ok = TRUE;
11094  }
11095  }
11096  if(p == NULL)
11097  return;
11098  pp = pNext(p);
11099  while(pp != NULL)
11100  {
11101  if(pLmDivisibleBy(strat->S[i], pp))
11102  {
11103  poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11104  sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11105  if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11106  {
11107  number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11108  p_SetCoeff(pp,dummy,currRing);
11109  if(nIsZero(pp->coef))
11110  {
11111  pLmDelete(&pNext(p));
11112  pp = pNext(p);
11113  deleted = TRUE;
11114  }
11115  else
11116  {
11117  p = pp;
11118  pp = pNext(p);
11119  }
11120  }
11121  else
11122  {
11123  p = pp;
11124  pp = pNext(p);
11125  }
11126  pDelete(&sigMult);
11127  }
11128  else
11129  {
11130  p = pp;
11131  pp = pNext(p);
11132  }
11133  }
11134  }
11135  }
11136  h->SetLmCurrRing();
11137  if(deleted)
11138  strat->initEcart(h);
11139 
11140 }
#define ppMult_mm(p, m)
Definition: polys.h:201
#define pDivideM(a, b)
Definition: polys.h:294

◆ preIntegerCheck()

poly preIntegerCheck ( ideal  F,
ideal  Q 
)

used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell

Definition at line 10815 of file kutil.cc.

10816 {
10817  if(!nCoeff_is_Z(currRing->cf))
10818  return NULL;
10819  ideal F = idCopy(Forig);
10820  idSkipZeroes(F);
10821  poly pmon;
10822  ring origR = currRing;
10823  ideal monred = idInit(1,1);
10824  for(int i=0; i<idElem(F); i++)
10825  {
10826  if(pNext(F->m[i]) == NULL)
10827  idInsertPoly(monred, pCopy(F->m[i]));
10828  }
10829  int posconst = idPosConstant(F);
10830  if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10831  {
10832  idDelete(&F);
10833  idDelete(&monred);
10834  return NULL;
10835  }
10836  int idelemQ = 0;
10837  if(Q!=NULL)
10838  {
10839  idelemQ = IDELEMS(Q);
10840  for(int i=0; i<idelemQ; i++)
10841  {
10842  if(pNext(Q->m[i]) == NULL)
10843  idInsertPoly(monred, pCopy(Q->m[i]));
10844  }
10845  idSkipZeroes(monred);
10846  posconst = idPosConstant(monred);
10847  //the constant, if found, will be from Q
10848  if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10849  {
10850  pmon = pCopy(monred->m[posconst]);
10851  idDelete(&F);
10852  idDelete(&monred);
10853  return pmon;
10854  }
10855  }
10856  ring QQ_ring = rCopy0(currRing,FALSE);
10857  nKillChar(QQ_ring->cf);
10858  QQ_ring->cf = nInitChar(n_Q, NULL);
10859  rComplete(QQ_ring,1);
10860  QQ_ring = rAssure_c_dp(QQ_ring);
10861  rChangeCurrRing(QQ_ring);
10862  nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10863  ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10864  for(int i = 0, j = 0; i<IDELEMS(F); i++)
10865  II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10866  for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10867  II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10868  ideal one = kStd(II, NULL, isNotHomog, NULL);
10869  idSkipZeroes(one);
10870  if(idIsConstant(one))
10871  {
10872  //one should be <1>
10873  for(int i = IDELEMS(II)-1; i>=0; i--)
10874  if(II->m[i] != NULL)
10875  II->m[i+1] = II->m[i];
10876  II->m[0] = pOne();
10877  ideal syz = idSyzygies(II, isNotHomog, NULL);
10878  poly integer = NULL;
10879  for(int i = IDELEMS(syz)-1;i>=0; i--)
10880  {
10881  if(pGetComp(syz->m[i]) == 1)
10882  {
10883  pSetComp(syz->m[i],0);
10884  if(pIsConstant(pHead(syz->m[i])))
10885  {
10886  integer = pHead(syz->m[i]);
10887  break;
10888  }
10889  }
10890  }
10891  rChangeCurrRing(origR);
10892  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10893  pmon = prMapR(integer, nMap2, QQ_ring, origR);
10894  idDelete(&monred);
10895  idDelete(&F);
10896  id_Delete(&II,QQ_ring);
10897  id_Delete(&one,QQ_ring);
10898  id_Delete(&syz,QQ_ring);
10899  p_Delete(&integer,QQ_ring);
10900  rDelete(QQ_ring);
10901  return pmon;
10902  }
10903  else
10904  {
10905  if(idIs0(monred))
10906  {
10907  poly mindegmon = NULL;
10908  for(int i = 0; i<IDELEMS(one); i++)
10909  {
10910  if(pNext(one->m[i]) == NULL)
10911  {
10912  if(mindegmon == NULL)
10913  mindegmon = pCopy(one->m[i]);
10914  else
10915  {
10916  if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10917  mindegmon = pCopy(one->m[i]);
10918  }
10919  }
10920  }
10921  if(mindegmon != NULL)
10922  {
10923  for(int i = IDELEMS(II)-1; i>=0; i--)
10924  if(II->m[i] != NULL)
10925  II->m[i+1] = II->m[i];
10926  II->m[0] = pCopy(mindegmon);
10927  ideal syz = idSyzygies(II, isNotHomog, NULL);
10928  bool found = FALSE;
10929  for(int i = IDELEMS(syz)-1;i>=0; i--)
10930  {
10931  if(pGetComp(syz->m[i]) == 1)
10932  {
10933  pSetComp(syz->m[i],0);
10934  if(pIsConstant(pHead(syz->m[i])))
10935  {
10936  pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10937  found = TRUE;
10938  break;
10939  }
10940  }
10941  }
10942  id_Delete(&syz,QQ_ring);
10943  if (found == FALSE)
10944  {
10945  rChangeCurrRing(origR);
10946  idDelete(&monred);
10947  idDelete(&F);
10948  id_Delete(&II,QQ_ring);
10949  id_Delete(&one,QQ_ring);
10950  rDelete(QQ_ring);
10951  return NULL;
10952  }
10953  rChangeCurrRing(origR);
10954  nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10955  pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10956  idDelete(&monred);
10957  idDelete(&F);
10958  id_Delete(&II,QQ_ring);
10959  id_Delete(&one,QQ_ring);
10960  id_Delete(&syz,QQ_ring);
10961  rDelete(QQ_ring);
10962  return pmon;
10963  }
10964  }
10965  }
10966  rChangeCurrRing(origR);
10967  idDelete(&monred);
10968  idDelete(&F);
10969  id_Delete(&II,QQ_ring);
10970  id_Delete(&one,QQ_ring);
10971  rDelete(QQ_ring);
10972  return NULL;
10973 }
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:30
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:700
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:354
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:522
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition: ideals.cc:830
#define idIsConstant(I)
Definition: ideals.h:40
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
ideal idCopy(ideal A)
Definition: ideals.h:60
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:37
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2433
void rChangeCurrRing(ring r)
Definition: polys.cc:15
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition: prCopy.cc:45
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3395
ring rAssure_c_dp(const ring r)
Definition: ring.cc:4931
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1363
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:449
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int idElem(const ideal F)
count non-zero elements
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
@ isNotHomog
Definition: structs.h:40

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4724 of file kstd2.cc.

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

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 934 of file kstd2.cc.

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

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 1897 of file kstd2.cc.

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

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1692 of file kstd2.cc.

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

◆ redLiftstd()

int redLiftstd ( LObject h,
kStrategy  strat 
)

Definition at line 167 of file kLiftstd.cc.

168 {
169  if (strat->tl<0) return 1;
170  assume(h->FDeg == h->pFDeg());
172  poly h_p;
173  int i,j,pass,ei, ii, h_d,ci;
174  unsigned long not_sev;
175  long reddeg,d;
176  #define START_REDUCE 512
177  int red_size=START_REDUCE;
178  number *A=(number*)omAlloc0(red_size*sizeof(number));
179  poly *C=(poly*)omAlloc0(red_size*sizeof(poly));
180  poly *T=(poly*)omAlloc0(red_size*sizeof(poly));
181  const ring tailRing=strat->tailRing;
182 
183  pass = j = 0;
184  d = reddeg = h->GetpFDeg() + h->ecart;
185  h->SetShortExpVector();
186  int li;
187  h_p = h->GetLmTailRing();
188  not_sev = ~ h->sev;
189 
190  // split h into mina part (h) and tail (h_tail)
191  poly h_tail=kSplitAt(strat->syzComp,h,strat);
192  // fix h-pLength
193  h->pLength=0;
194  // remove content
195  //number cont;
196  //p_Content_n(h_p,cont,strat->tailRing);
197  //if (!n_IsOne(cont,strat->tailRing))
198  // h_tail=p_Div_nn(h_tail,cont,tailRing);
199 
200  h->PrepareRed(strat->use_buckets);
201  loop
202  {
203  j=kFindDivisibleByInT(strat, h);
204  if (j < 0)
205  {
206  // lazy computation:
207  int l;
208  poly p=lazyComp(A,C,T,pass,h_tail,&l,strat->tailRing);
209  kBucket_Add_q(h->bucket,p,&l);
210  omFreeSize(A,red_size*sizeof(number));
211  omFreeSize(T,red_size*sizeof(poly));
212  omFreeSize(C,red_size*sizeof(poly));
213  return 1;
214  }
215 
216  ei = strat->T[j].ecart;
217  li = strat->T[j].pLength;
218  ci = nSize(pGetCoeff(strat->T[j].p));
219  ii = j;
220  /*
221  * the polynomial to reduce with (up to the moment) is;
222  * pi with ecart ei (T[ii])
223  */
224  i = j;
225  if (TEST_OPT_LENGTH)
226  {
227  if (li<=0) li=strat->T[j].GetpLength();
228  if (li>1)
229  loop
230  {
231  /*- possible with respect to ecart, minimal nSize -*/
232  i++;
233  if (i > strat->tl)
234  break;
235  //if (ei < h->ecart)
236  // break;
237  if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
238  || ((strat->T[i].ecart <= h->ecart)
239  && (strat->T[i].pLength <= li)
240  && (nSize(pGetCoeff(strat->T[i].p)) <ci)))
241  &&
242  p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
243  h_p, not_sev, tailRing))
244  {
245  /*
246  * the polynomial to reduce with is now;
247  */
248  ei = strat->T[i].ecart;
249  li = strat->T[i].pLength;
250  if (li<=0) li=strat->T[i].GetpLength();
251  ii = i;
252  if (li==1) break;
253  }
254  }
255  }
256 
257  /*
258  * end of search: have to reduce with pi
259  */
260 #ifdef KDEBUG
261  if (TEST_OPT_DEBUG)
262  {
263  PrintS("red:");
264  h->wrp();
265  Print("\nwith T[%d]:",ii);
266  strat->T[ii].wrp();
267  }
268 #endif
269  assume(strat->fromT == FALSE);
270 
271  //strat->T[ii].pCleardenom();
272  // split T[ii]:
273  // remember pLength of strat->T[ii]
274  int l_orig=strat->T[ii].pLength;
275  // split strat->T[ii]
276  poly T_tail=kSplitAt(strat->syzComp,&strat->T[ii],strat);
277  h->pLength=0; // force re-computation of length
278  ksReducePoly(h,&(strat->T[ii]),NULL,&A[pass],&C[pass], strat);
279  // restore T[ii]:
280  kAppend(T_tail,&strat->T[ii]);
281  strat->T[ii].pLength=l_orig;
282  // store T_tail
283  T[pass]=T_tail;
284  // delayed computation: A[pass]*tail-M[pass]*T[pass]
285 #ifdef KDEBUG
286  if (TEST_OPT_DEBUG)
287  {
288  PrintS("\nto:");
289  h->wrp();
290  PrintLn();
291  }
292 #endif
293  if(h->IsNull())
294  {
295  // clean up A,C,h_tail:
296  for(int i=0;i<=pass;i++)
297  {
298  n_Delete(&A[i],tailRing->cf);
299  p_Delete(&C[i],tailRing);
300  }
301  p_Delete(&h_tail,tailRing);
302  kDeleteLcm(h);
303  h->Clear();
304  omFreeSize(A,red_size*sizeof(number));
305  omFreeSize(T,red_size*sizeof(poly));
306  omFreeSize(C,red_size*sizeof(poly));
307  return 0;
308  }
309  h->SetShortExpVector();
310  not_sev = ~ h->sev;
311  h_d = h->SetpFDeg();
312  /* compute the ecart */
313  if (ei <= h->ecart)
314  h->ecart = d-h_d;
315  else
316  h->ecart = d-h_d+ei-h->ecart;
317 
318  /*
319  * try to reduce the s-polynomial h
320  *test first whether h should go to the lazyset L
321  *-if the degree jumps
322  *-if the number of pre-defined reductions jumps
323  */
324  pass++;
325  d = h_d + h->ecart;
326  if (pass%RED_CANONICALIZE==0) kBucketCanonicalize(h->bucket);
327  // if cache is to small, double its size:
328  if (pass>=red_size-1)
329  {
330  A=(number*)omRealloc0Size(A,red_size*sizeof(number),2*red_size*sizeof(number));
331  C=(poly*)omRealloc0Size(C,red_size*sizeof(poly),2*red_size*sizeof(poly));
332  T=(poly*)omRealloc0Size(T,red_size*sizeof(poly),2*red_size*sizeof(poly));
333  if(TEST_OPT_PROT) {Print("+%d+",red_size);mflush();}
334  red_size*=2;
335  }
336  }
337 }
static poly lazyComp(number *A, poly *M, poly *T, int index, poly s, int *l, const ring tailR)
Definition: kLiftstd.cc:132
static void kAppend(poly t, TObject *h)
Definition: kLiftstd.cc:121
#define START_REDUCE
static poly kSplitAt(int k, TObject *h, kStrategy strat)
Definition: kLiftstd.cc:28
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
Definition: kbuckets.cc:660
int kBucketCanonicalize(kBucket_pt bucket)
Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in one bucket: Returns number of bu...
#define nSize(n)
Definition: numbers.h:39
#define A
Definition: sirandom.c:24

◆ redNF()

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

Definition at line 2131 of file kstd2.cc.

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

◆ redNF0()

int redNF0 ( LObject P,
kStrategy  strat 
)

◆ redNFTail()

poly redNFTail ( poly  h,
const int  sl,
kStrategy  strat 
)

◆ redRiloc()

int redRiloc ( LObject h,
kStrategy  strat 
)

Definition at line 387 of file kstd1.cc.

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

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 827 of file kstd2.cc.

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

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 669 of file kstd2.cc.

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

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 1154 of file kstd2.cc.

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

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1322 of file kstd2.cc.

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

◆ redtail() [1/2]

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

Definition at line 7093 of file kutil.cc.

7094 {
7095  poly h, hn;
7096  strat->redTailChange=FALSE;
7097 
7098  L->GetP();
7099  poly p = L->p;
7100  if (strat->noTailReduction || pNext(p) == NULL)
7101  return p;
7102 
7103  LObject Ln(strat->tailRing);
7104  TObject* With;
7105  // placeholder in case strat->tl < 0
7106  TObject With_s(strat->tailRing);
7107  h = p;
7108  hn = pNext(h);
7109  long op = strat->tailRing->pFDeg(hn, strat->tailRing);
7110  long e;
7111  int l;
7112  BOOLEAN save_HE=strat->kAllAxis;
7113  strat->kAllAxis |=
7114  ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
7115 
7116  while(hn != NULL)
7117  {
7118  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7119  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7120  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7121  loop
7122  {
7123  Ln.Set(hn, strat->tailRing);
7124  Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
7125  if (strat->kAllAxis)
7126  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7127  else
7128  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
7129  if (With == NULL) break;
7130  With->length=0;
7131  With->pLength=0;
7132  strat->redTailChange=TRUE;
7133  if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
7134  {
7135  // reducing the tail would violate the exp bound
7136  if (kStratChangeTailRing(strat, L))
7137  {
7138  strat->kAllAxis = save_HE;
7139  return redtail(L, end_pos, strat);
7140  }
7141  else
7142  return NULL;
7143  }
7144  hn = pNext(h);
7145  if (hn == NULL) goto all_done;
7146  op = strat->tailRing->pFDeg(hn, strat->tailRing);
7147  if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7148  e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7149  }
7150  h = hn;
7151  hn = pNext(h);
7152  }
7153 
7154  all_done:
7155  if (strat->redTailChange)
7156  {
7157  L->pLength = 0;
7158  }
7159  strat->kAllAxis = save_HE;
7160  return p;
7161 }
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:6951
#define TEST_OPT_INFREDTAIL
Definition: options.h:118

◆ redtail() [2/2]

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

Definition at line 7163 of file kutil.cc.

7164 {
7165  LObject L(p, currRing);
7166  return redtail(&L, end_pos, strat);
7167 }

◆ redtailBba() [1/3]

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

Definition at line 7169 of file kutil.cc.

7170 {
7171  strat->redTailChange=FALSE;
7172  if (strat->noTailReduction) return L->GetLmCurrRing();
7173  poly h, p;
7174  p = h = L->GetLmTailRing();
7175  if ((h==NULL) || (pNext(h)==NULL))
7176  return L->GetLmCurrRing();
7177 
7178  TObject* With;
7179  // placeholder in case strat->tl < 0
7180  TObject With_s(strat->tailRing);
7181 
7182  LObject Ln(pNext(h), strat->tailRing);
7183  Ln.GetpLength();
7184 
7185  pNext(h) = NULL;
7186  if (L->p != NULL)
7187  {
7188  pNext(L->p) = NULL;
7189  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7190  }
7191  L->pLength = 1;
7192 
7193  Ln.PrepareRed(strat->use_buckets);
7194 
7195  int cnt=REDTAIL_CANONICALIZE;
7196  while(!Ln.IsNull())
7197  {
7198  loop
7199  {
7200  if (TEST_OPT_IDLIFT)
7201  {
7202  if (Ln.p!=NULL)
7203  {
7204  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7205  }
7206  else
7207  {
7208  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7209  }
7210  }
7211  Ln.SetShortExpVector();
7212  if (withT)
7213  {
7214  int j;
7215  j = kFindDivisibleByInT(strat, &Ln);
7216  if (j < 0) break;
7217  With = &(strat->T[j]);
7218  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7219  }
7220  else
7221  {
7222  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7223  if (With == NULL) break;
7224  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7225  }
7226  cnt--;
7227  if (cnt==0)
7228  {
7230  /*poly tmp=*/Ln.CanonicalizeP();
7231  if (normalize)
7232  {
7233  Ln.Normalize();
7234  //pNormalize(tmp);
7235  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7236  }
7237  }
7238  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7239  {
7240  With->pNorm();
7241  }
7242  strat->redTailChange=TRUE;
7243  if (ksReducePolyTail(L, With, &Ln))
7244  {
7245  // reducing the tail would violate the exp bound
7246  // set a flag and hope for a retry (in bba)
7247  strat->completeReduce_retry=TRUE;
7248  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7249  do
7250  {
7251  pNext(h) = Ln.LmExtractAndIter();
7252  pIter(h);
7253  L->pLength++;
7254  } while (!Ln.IsNull());
7255  goto all_done;
7256  }
7257  if (Ln.IsNull()) goto all_done;
7258  if (! withT) With_s.Init(currRing);
7259  }
7260  pNext(h) = Ln.LmExtractAndIter();
7261  pIter(h);
7262  pNormalize(h);
7263  L->pLength++;
7264  }
7265 
7266  all_done:
7267  Ln.Delete();
7268  if (L->p != NULL) pNext(L->p) = pNext(p);
7269 
7270  if (strat->redTailChange)
7271  {
7272  L->length = 0;
7273  L->pLength = 0;
7274  }
7275 
7276  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7277  //L->Normalize(); // HANNES: should have a test
7278  kTest_L(L,strat);
7279  return L->GetLmCurrRing();
7280 }
#define REDTAIL_CANONICALIZE
Definition: kutil.h:38
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition: syz3.cc:1026

◆ redtailBba() [2/3]

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

Definition at line 1222 of file kInline.h.

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

◆ redtailBba() [3/3]

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7641 of file kutil.cc.

7643 {
7644  strat->redTailChange=FALSE;
7645  if (strat->noTailReduction) return L->GetLmCurrRing();
7646  poly h, p;
7647  p = h = L->GetLmTailRing();
7648  if ((h==NULL) || (pNext(h)==NULL))
7649  return L->GetLmCurrRing();
7650 
7651  TObject* With;
7652  // placeholder in case strat->tl < 0
7653  TObject With_s(strat->tailRing);
7654 
7655  LObject Ln(pNext(h), strat->tailRing);
7656  Ln.pLength = L->GetpLength() - 1;
7657 
7658  pNext(h) = NULL;
7659  if (L->p != NULL) pNext(L->p) = NULL;
7660  L->pLength = 1;
7661 
7662  Ln.PrepareRed(strat->use_buckets);
7663 
7664  int cnt=REDTAIL_CANONICALIZE;
7665  while(!Ln.IsNull())
7666  {
7667  loop
7668  {
7669  Ln.SetShortExpVector();
7670  With_s.Init(currRing);
7671  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7672  if (With == NULL) break;
7673  cnt--;
7674  if (cnt==0)
7675  {
7677  /*poly tmp=*/Ln.CanonicalizeP();
7678  }
7679  // we are in a ring, do not call pNorm
7680  // test divisibility of coefs:
7681  poly p_Ln=Ln.GetLmCurrRing();
7682  poly p_With=With->GetLmCurrRing();
7683  if (n_DivBy(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf))
7684  {
7685  strat->redTailChange=TRUE;
7686 
7687  if (ksReducePolyTail_Z(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  }
7702  else break; /*proceed to next monomial*/
7703  if (Ln.IsNull()) goto all_done;
7704  }
7705  pNext(h) = Ln.LmExtractAndIter();
7706  pIter(h);
7707  pNormalize(h);
7708  L->pLength++;
7709  }
7710 
7711  all_done:
7712  Ln.Delete();
7713  if (L->p != NULL) pNext(L->p) = pNext(p);
7714 
7715  if (strat->redTailChange)
7716  {
7717  L->length = 0;
7718  }
7719 
7720  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7721  //L->Normalize(); // HANNES: should have a test
7722  kTest_L(L,strat);
7723  return L->GetLmCurrRing();
7724 }
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1137

◆ redtailBba_Ring() [2/2]

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

Definition at line 1235 of file kInline.h.

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

◆ redtailBba_Z() [1/2]

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

Definition at line 7527 of file kutil.cc.

7529 {
7530  strat->redTailChange=FALSE;
7531  if (strat->noTailReduction) return L->GetLmCurrRing();
7532  poly h, p;
7533  p = h = L->GetLmTailRing();
7534  if ((h==NULL) || (pNext(h)==NULL))
7535  return L->GetLmCurrRing();
7536 
7537  TObject* With;
7538  // placeholder in case strat->tl < 0
7539  TObject With_s(strat->tailRing);
7540 
7541  LObject Ln(pNext(h), strat->tailRing);
7542  Ln.pLength = L->GetpLength() - 1;
7543 
7544  pNext(h) = NULL;
7545  if (L->p != NULL) pNext(L->p) = NULL;
7546  L->pLength = 1;
7547 
7548  Ln.PrepareRed(strat->use_buckets);
7549 
7550  int cnt=REDTAIL_CANONICALIZE;
7551  while(!Ln.IsNull())
7552  {
7553  loop
7554  {
7555  Ln.SetShortExpVector();
7556  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7557  if (With == NULL) break;
7558  cnt--;
7559  if (cnt==0)
7560  {
7562  /*poly tmp=*/Ln.CanonicalizeP();
7563  }
7564  // we are in Z, do not call pNorm
7565  strat->redTailChange=TRUE;
7566  // test divisibility of coefs:
7567  poly p_Ln=Ln.GetLmCurrRing();
7568  poly p_With=With->GetLmCurrRing();
7569  number z=n_IntMod(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf);
7570  if (!nIsZero(z))
7571  {
7572  // subtract z*Ln, add z.Ln to L
7573  poly m=pHead(p_Ln);
7574  pSetCoeff(m,z);
7575  poly mm=pHead(m);
7576  pNext(h) = m;
7577  pIter(h);
7578  L->pLength++;
7579  mm=pNeg(mm);
7580  if (Ln.bucket!=NULL)
7581  {
7582  int dummy=1;
7583  kBucket_Add_q(Ln.bucket,mm,&dummy);
7584  }
7585  else
7586  {
7587  if ((Ln.t_p!=NULL)&&(Ln.p==NULL))
7588  Ln.GetP();
7589  if (Ln.p!=NULL)
7590  {
7591  Ln.p=pAdd(Ln.p,mm);
7592  if (Ln.t_p!=NULL)
7593  {
7594  pNext(Ln.t_p)=NULL;
7595  p_LmDelete(Ln.t_p,strat->tailRing);
7596  }
7597  }
7598  }
7599  }
7600  else
7601  nDelete(&z);
7602 
7603  if (ksReducePolyTail_Z(L, With, &Ln))
7604  {
7605  // reducing the tail would violate the exp bound
7606  // set a flag and hope for a retry (in bba)
7607  strat->completeReduce_retry=TRUE;
7608  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7609  do
7610  {
7611  pNext(h) = Ln.LmExtractAndIter();
7612  pIter(h);
7613  L->pLength++;
7614  } while (!Ln.IsNull());
7615  goto all_done;
7616  }
7617  if (Ln.IsNull()) goto all_done;
7618  With_s.Init(currRing);
7619  }
7620  pNext(h) = Ln.LmExtractAndIter();
7621  pIter(h);
7622  pNormalize(h);
7623  L->pLength++;
7624  }
7625 
7626  all_done:
7627  Ln.Delete();
7628  if (L->p != NULL) pNext(L->p) = pNext(p);
7629 
7630  if (strat->redTailChange)
7631  {
7632  L->length = 0;
7633  }
7634 
7635  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7636  //L->Normalize(); // HANNES: should have a test
7637  kTest_L(L,strat);
7638  return L->GetLmCurrRing();
7639 }
int m
Definition: cfEzgcd.cc:128
#define pAdd(p, q)
Definition: polys.h:203

◆ redtailBba_Z() [2/2]

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

Definition at line 1240 of file kInline.h.

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

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7398 of file kutil.cc.

7400 {
7401  strat->redTailChange=FALSE;
7402 
7403  poly h, p;
7404  p = h = L->GetLmTailRing();
7405  if ((h==NULL) || (pNext(h)==NULL))
7406  return;
7407 
7408  TObject* With;
7409  LObject Ln(pNext(h), strat->tailRing);
7410  Ln.GetpLength();
7411 
7412  pNext(h) = NULL;
7413  if (L->p != NULL)
7414  {
7415  pNext(L->p) = NULL;
7416  if (L->t_p != NULL) pNext(L->t_p) = NULL;
7417  }
7418  L->pLength = 1;
7419 
7420  Ln.PrepareRed(strat->use_buckets);
7421 
7422  int cnt=REDTAIL_CANONICALIZE;
7423 
7424  while(!Ln.IsNull())
7425  {
7426  loop
7427  {
7428  if (TEST_OPT_IDLIFT)
7429  {
7430  if (Ln.p!=NULL)
7431  {
7432  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7433  }
7434  else
7435  {
7436  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7437  }
7438  }
7439  Ln.SetShortExpVector();
7440  int j;
7441  j = kFindDivisibleByInT(strat, &Ln);
7442  if (j < 0)
7443  {
7444  j = kFindDivisibleByInT_Z(strat, &Ln);
7445  if (j < 0)
7446  {
7447  break;
7448  }
7449  else
7450  {
7451  /* reduction not cancelling a tail term, but reducing its coefficient */
7452  With = &(strat->T[j]);
7453  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7454  cnt--;
7455  if (cnt==0)
7456  {
7458  /*poly tmp=*/Ln.CanonicalizeP();
7459  }
7460  strat->redTailChange=TRUE;
7461  /* reduction cancelling a tail term */
7462  if (ksReducePolyTailLC_Z(L, With, &Ln))
7463  {
7464  // reducing the tail would violate the exp bound
7465  // set a flag and hope for a retry (in bba)
7466  strat->completeReduce_retry=TRUE;
7467  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7468  do
7469  {
7470  pNext(h) = Ln.LmExtractAndIter();
7471  pIter(h);
7472  L->pLength++;
7473  } while (!Ln.IsNull());
7474  goto all_done;
7475  }
7476  /* we have to break since we did not cancel the term, but only decreased
7477  * its coefficient. */
7478  break;
7479  }
7480  } else {
7481  With = &(strat->T[j]);
7482  assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7483  cnt--;
7484  if (cnt==0)
7485  {
7487  /*poly tmp=*/Ln.CanonicalizeP();
7488  }
7489  strat->redTailChange=TRUE;
7490  /* reduction cancelling a tail term */
7491  if (ksReducePolyTail_Z(L, With, &Ln))
7492  {
7493  // reducing the tail would violate the exp bound
7494  // set a flag and hope for a retry (in bba)
7495  strat->completeReduce_retry=TRUE;
7496  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7497  do
7498  {
7499  pNext(h) = Ln.LmExtractAndIter();
7500  pIter(h);
7501  L->pLength++;
7502  } while (!Ln.IsNull());
7503  goto all_done;
7504  }
7505  }
7506  if (Ln.IsNull()) goto all_done;
7507  }
7508  pNext(h) = Ln.LmExtractAndIter();
7509  pIter(h);
7510  L->pLength++;
7511  }
7512 
7513  all_done:
7514  Ln.Delete();
7515  if (L->p != NULL) pNext(L->p) = pNext(p);
7516 
7517  if (strat->redTailChange)
7518  {
7519  L->length = 0;
7520  L->pLength = 0;
7521  }
7522 
7523  kTest_L(L, strat);
7524  return;
7525 }
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1119

◆ redtailBbaBound() [1/2]

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

Definition at line 7282 of file kutil.cc.

7283 {
7284  strat->redTailChange=FALSE;
7285  if (strat->noTailReduction) return L->GetLmCurrRing();
7286  poly h, p;
7287  p = h = L->GetLmTailRing();
7288  if ((h==NULL) || (pNext(h)==NULL))
7289  return L->GetLmCurrRing();
7290 
7291  TObject* With;
7292  // placeholder in case strat->tl < 0
7293  TObject With_s(strat->tailRing);
7294 
7295  LObject Ln(pNext(h), strat->tailRing);
7296  Ln.pLength = L->GetpLength() - 1;
7297 
7298  pNext(h) = NULL;
7299  if (L->p != NULL) pNext(L->p) = NULL;
7300  L->pLength = 1;
7301 
7302  Ln.PrepareRed(strat->use_buckets);
7303 
7304  int cnt=REDTAIL_CANONICALIZE;
7305  while(!Ln.IsNull())
7306  {
7307  loop
7308  {
7309  if (TEST_OPT_IDLIFT)
7310  {
7311  if (Ln.p!=NULL)
7312  {
7313  if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7314  }
7315  else
7316  {
7317  if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7318  }
7319  }
7320  Ln.SetShortExpVector();
7321  if (withT)
7322  {
7323  int j;
7324  j = kFindDivisibleByInT(strat, &Ln);
7325  if (j < 0) break;
7326  With = &(strat->T[j]);
7327  }
7328  else
7329  {
7330  With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7331  if (With == NULL) break;
7332  }
7333  cnt--;
7334  if (cnt==0)
7335  {
7337  /*poly tmp=*/Ln.CanonicalizeP();
7338  if (normalize)
7339  {
7340  Ln.Normalize();
7341  //pNormalize(tmp);
7342  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7343  }
7344  }
7345  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7346  {
7347  With->pNorm();
7348  }
7349  strat->redTailChange=TRUE;
7350  if (ksReducePolyTail(L, With, &Ln))
7351  {
7352  // reducing the tail would violate the exp bound
7353  // set a flag and hope for a retry (in bba)
7354  strat->completeReduce_retry=TRUE;
7355  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7356  do
7357  {
7358  pNext(h) = Ln.LmExtractAndIter();
7359  pIter(h);
7360  L->pLength++;
7361  } while (!Ln.IsNull());
7362  goto all_done;
7363  }
7364  if(!Ln.IsNull())
7365  {
7366  Ln.GetP();
7367  Ln.p = pJet(Ln.p,bound);
7368  }
7369  if (Ln.IsNull())
7370  {
7371  goto all_done;
7372  }
7373  if (! withT) With_s.Init(currRing);
7374  }
7375  pNext(h) = Ln.LmExtractAndIter();
7376  pIter(h);
7377  pNormalize(h);
7378  L->pLength++;
7379  }
7380 
7381  all_done:
7382  Ln.Delete();
7383  if (L->p != NULL) pNext(L->p) = pNext(p);
7384 
7385  if (strat->redTailChange)
7386  {
7387  L->length = 0;
7388  L->pLength = 0;
7389  }
7390 
7391  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7392  //L->Normalize(); // HANNES: should have a test
7393  kTest_L(L,strat);
7394  return L->GetLmCurrRing();
7395 }
#define pJet(p, m)
Definition: polys.h:368

◆ redtailBbaBound() [2/2]

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

Definition at line 1228 of file kInline.h.

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

◆ redtailBbaShift()

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

Definition at line 13388 of file kutil.cc.

13389 {
13390  /* for the shift case need to run it with withT = TRUE */
13391  strat->redTailChange=FALSE;
13392  if (strat->noTailReduction) return L->GetLmCurrRing();
13393  poly h, p;
13394  p = h = L->GetLmTailRing();
13395  if ((h==NULL) || (pNext(h)==NULL))
13396  return L->GetLmCurrRing();
13397 
13398  TObject* With;
13399  // placeholder in case strat->tl < 0
13400  TObject With_s(strat->tailRing);
13401 
13402  LObject Ln(pNext(h), strat->tailRing);
13403  Ln.pLength = L->GetpLength() - 1;
13404 
13405  pNext(h) = NULL;
13406  if (L->p != NULL) pNext(L->p) = NULL;
13407  L->pLength = 1;
13408 
13409  Ln.PrepareRed(strat->use_buckets);
13410 
13411  while(!Ln.IsNull())
13412  {
13413  loop
13414  {
13415  Ln.SetShortExpVector();
13416  if (withT)
13417  {
13418  int j;
13419  j = kFindDivisibleByInT(strat, &Ln);
13420  if (j < 0) break;
13421  With = &(strat->T[j]);
13422  }
13423  else
13424  {
13425  With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13426  if (With == NULL) break;
13427  }
13428  if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13429  {
13430  With->pNorm();
13431  //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13432  }
13433  strat->redTailChange=TRUE;
13434  if (ksReducePolyTail(L, With, &Ln))
13435  {
13436  // reducing the tail would violate the exp bound
13437  // set a flag and hope for a retry (in bba)
13438  strat->completeReduce_retry=TRUE;
13439  if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13440  do
13441  {
13442  pNext(h) = Ln.LmExtractAndIter();
13443  pIter(h);
13444  L->pLength++;
13445  } while (!Ln.IsNull());
13446  goto all_done;
13447  }
13448  if (Ln.IsNull()) goto all_done;
13449  if (! withT) With_s.Init(currRing);
13450  }
13451  pNext(h) = Ln.LmExtractAndIter();
13452  pIter(h);
13453  L->pLength++;
13454  }
13455 
13456  all_done:
13457  Ln.Delete();
13458  if (L->p != NULL) pNext(L->p) = pNext(p);
13459 
13460  if (strat->redTailChange)
13461  {
13462  L->length = 0;
13463  }
13464  L->Normalize(); // HANNES: should have a test
13465  kTest_L(L,strat);
13466  return L->GetLmCurrRing();
13467 }

◆ redtailSba()

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

Definition at line 1572 of file kstd2.cc.

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

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 4672 of file kutil.cc.

4673 {
4674  int i,j,at,ecart, s2r;
4675  int fq=0;
4676  unsigned long sev;
4677  poly p;
4678  int new_suc=strat->sl+1;
4679  i= *suc;
4680  if (i<0) i=0;
4681 
4682  for (; i<=strat->sl; i++)
4683  {
4684  at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4685  if (at != i)
4686  {
4687  if (new_suc > at) new_suc = at;
4688  p = strat->S[i];
4689  ecart = strat->ecartS[i];
4690  sev = strat->sevS[i];
4691  s2r = strat->S_2_R[i];
4692  if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4693  for (j=i; j>=at+1; j--)
4694  {
4695  strat->S[j] = strat->S[j-1];
4696  strat->ecartS[j] = strat->ecartS[j-1];
4697  strat->sevS[j] = strat->sevS[j-1];
4698  strat->S_2_R[j] = strat->S_2_R[j-1];
4699  }
4700  strat->S[at] = p;
4701  strat->ecartS[at] = ecart;
4702  strat->sevS[at] = sev;
4703  strat->S_2_R[at] = s2r;
4704  if (strat->fromQ!=NULL)
4705  {
4706  for (j=i; j>=at+1; j--)
4707  {
4708  strat->fromQ[j] = strat->fromQ[j-1];
4709  }
4710  strat->fromQ[at]=fq;
4711  }
4712  }
4713  }
4714  if (new_suc <= strat->sl) *suc=new_suc;
4715  else *suc=-1;
4716 }

◆ replaceInLAndSAndT()

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

Definition at line 9305 of file kutil.cc.

9306 {
9307  p.GetP(strat->lmBin);
9308  if (strat->homog) strat->initEcart(&p);
9309  strat->redTailChange=FALSE;
9311  {
9312  p.pCleardenom();
9314  {
9315 #ifdef HAVE_SHIFTBBA
9316  if (rIsLPRing(currRing))
9317  p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9318  else
9319 #endif
9320  {
9321  p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9322  }
9323  p.pCleardenom();
9324  if (strat->redTailChange)
9325  p.t_p=NULL;
9326  if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9327  else strat->P.sev=0;
9328  }
9329  }
9330 
9331  assume(strat->tailRing == p.tailRing);
9332  assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9333 
9334  int i, j, pos;
9335  poly tp = strat->T[tj].p;
9336 
9337  /* enter p to T set */
9338  enterT(p, strat);
9339 
9340  for (j = 0; j <= strat->sl; ++j)
9341  {
9342  if (pLtCmp(tp, strat->S[j]) == 0)
9343  {
9344  break;
9345  }
9346  }
9347  /* it may be that the exchanged element
9348  * is until now only in T and not in S */
9349  if (j <= strat->sl)
9350  {
9351  deleteInS(j, strat);
9352  }
9353 
9354  pos = posInS(strat, strat->sl, p.p, p.ecart);
9355 
9356  pp_Test(p.p, currRing, p.tailRing);
9357  assume(p.FDeg == p.pFDeg());
9358 
9359  /* remove useless pairs from L set */
9360  for (i = 0; i <= strat->Ll; ++i)
9361  {
9362  if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9363  {
9364  deleteInL(strat->L, &(strat->Ll), i, strat);
9365  i--;
9366  continue;
9367  }
9368  if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9369  {
9370  deleteInL(strat->L, &(strat->Ll), i, strat);
9371  i--;
9372  }
9373  }
9374 #ifdef HAVE_SHIFTBBA
9375  if (rIsLPRing(currRing))
9376  enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9377  else
9378 #endif
9379  {
9380  /* generate new pairs with p, probably removing older, now useless pairs */
9381  superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9382  }
9383  /* enter p to S set */
9384  strat->enterS(p, pos, strat, strat->tl);
9385 
9386 #ifdef HAVE_SHIFTBBA
9387  /* do this after enterS so that the index in R (which is strat->tl) is correct */
9388  if (rIsLPRing(currRing) && !strat->rightGB)
9389  enterTShift(p,strat);
9390 #endif
9391 }

◆ sba()

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

Definition at line 2738 of file kstd2.cc.

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

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject h,
kStrategy  strat 
)

Definition at line 1747 of file kutil.cc.

1748 {
1749  if(strat->sl < 0) return FALSE;
1750  int i;
1751  for(i=0;i<strat->sl;i++)
1752  {
1753  //Construct the gcd pair between h and S[i]
1754  number d, s, t;
1755  poly m1, m2, gcd;
1756  d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1757  if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1758  {
1759  nDelete(&d);
1760  nDelete(&s);
1761  nDelete(&t);
1762  }
1763  else
1764  {
1765  k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1766  pSetCoeff0(m1, s);
1767  pSetCoeff0(m2, t);
1768  pSetCoeff0(gcd, d);
1769  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);
1770  poly pSigMult = p_Copy(h->sig,currRing);
1771  poly sSigMult = p_Copy(strat->sig[i],currRing);
1772  pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1773  sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1774  p_LmDelete(m1, strat->tailRing);
1775  p_LmDelete(m2, strat->tailRing);
1776  poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1777  if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1778  {
1779  pDelete(&h->p);
1780  h->p = gcd;
1781  pDelete(&h->sig);
1782  h->sig = pairsig;
1783  pNext(h->sig) = NULL;
1784  strat->initEcart(h);
1785  h->sev = pGetShortExpVector(h->p);
1786  h->sevSig = pGetShortExpVector(h->sig);
1787  h->i_r1 = -1;h->i_r2 = -1;
1788  if(h->lcm != NULL)
1789  {
1790  pLmDelete(h->lcm);
1791  h->lcm = NULL;
1792  }
1793  if (currRing!=strat->tailRing)
1794  h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1795  return TRUE;
1796  }
1797  //Delete what you didn't use
1798  pDelete(&gcd);
1799  pDelete(&pairsig);
1800  }
1801  }
1802  return FALSE;
1803 }
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:1071
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1003

◆ sbaRing()

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

Definition at line 11361 of file kutil.cc.

11362 {
11363  int n = rBlocks(r); // Including trailing zero!
11364  // if sbaOrder == 1 => use (C,monomial order from r)
11365  if (strat->sbaOrder == 1)
11366  {
11367  if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11368  {
11369  return r;
11370  }
11371  ring res = rCopy0(r, TRUE, FALSE);
11372  res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11373  res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11374  res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11375  int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11376  res->wvhdl = wvhdl;
11377  for (int i=1; i<n; i++)
11378  {
11379  res->order[i] = r->order[i-1];
11380  res->block0[i] = r->block0[i-1];
11381  res->block1[i] = r->block1[i-1];
11382  res->wvhdl[i] = r->wvhdl[i-1];
11383  }
11384 
11385  // new 1st block
11386  res->order[0] = ringorder_C; // Prefix
11387  // removes useless secondary component order if defined in old ring
11388  for (int i=rBlocks(res); i>0; --i)
11389  {
11390  if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11391  {
11392  res->order[i] = (rRingOrder_t)0;
11393  }
11394  }
11395  rComplete(res, 1);
11396 #ifdef HAVE_PLURAL
11397  if (rIsPluralRing(r))
11398  {
11399  if ( nc_rComplete(r, res, false) ) // no qideal!
11400  {
11401 #ifndef SING_NDEBUG
11402  WarnS("error in nc_rComplete");
11403 #endif
11404  // cleanup?
11405 
11406  // rDelete(res);
11407  // return r;
11408 
11409  // just go on..
11410  }
11411  }
11412 #endif
11413  strat->tailRing = res;
11414  return (res);
11415  }
11416  // if sbaOrder == 3 => degree - position - ring order
11417  if (strat->sbaOrder == 3)
11418  {
11419  ring res = rCopy0(r, TRUE, FALSE);
11420  res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11421  res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11422  res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11423  int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11424  res->wvhdl = wvhdl;
11425  for (int i=2; i<n+2; i++)
11426  {
11427  res->order[i] = r->order[i-2];
11428  res->block0[i] = r->block0[i-2];
11429  res->block1[i] = r->block1[i-2];
11430  res->wvhdl[i] = r->wvhdl[i-2];
11431  }
11432 
11433  // new 1st block
11434  res->order[0] = ringorder_a; // Prefix
11435  res->block0[0] = 1;
11436  res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11437  for (int i=0; i<res->N; ++i)
11438  res->wvhdl[0][i] = 1;
11439  res->block1[0] = si_min(res->N, rVar(res));
11440  // new 2nd block
11441  res->order[1] = ringorder_C; // Prefix
11442  res->wvhdl[1] = NULL;
11443  // removes useless secondary component order if defined in old ring
11444  for (int i=rBlocks(res); i>1; --i)
11445  {
11446  if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11447  {
11448  res->order[i] = (rRingOrder_t)0;
11449  }
11450  }
11451  rComplete(res, 1);
11452 #ifdef HAVE_PLURAL
11453  if (rIsPluralRing(r))
11454  {
11455  if ( nc_rComplete(r, res, false) ) // no qideal!
11456  {
11457 #ifndef SING_NDEBUG
11458  WarnS("error in nc_rComplete");
11459 #endif
11460  // cleanup?
11461 
11462  // rDelete(res);
11463  // return r;
11464 
11465  // just go on..
11466  }
11467  }
11468 #endif
11469  strat->tailRing = res;
11470  return (res);
11471  }
11472 
11473  // not sbaOrder == 1 => use Schreyer order
11474  // this is done by a trick when initializing the signatures
11475  // in initSLSba():
11476  // Instead of using the signature 1e_i for F->m[i], we start
11477  // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11478  // Schreyer order w.r.t. the underlying monomial order.
11479  // => we do not need to change the underlying polynomial ring at all!
11480 
11481  // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11482 
11483  /*
11484  else
11485  {
11486  ring res = rCopy0(r, FALSE, FALSE);
11487  // Create 2 more blocks for prefix/suffix:
11488  res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11489  res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11490  res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11491  int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11492 
11493  // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11494  // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11495 
11496  // new 1st block
11497  int j = 0;
11498  res->order[j] = ringorder_IS; // Prefix
11499  res->block0[j] = res->block1[j] = 0;
11500  // wvhdl[j] = NULL;
11501  j++;
11502 
11503  for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11504  {
11505  res->order [j] = r->order [i];
11506  res->block0[j] = r->block0[i];
11507  res->block1[j] = r->block1[i];
11508 
11509  if (r->wvhdl[i] != NULL)
11510  {
11511  wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11512  } // else wvhdl[j] = NULL;
11513  }
11514 
11515  // new last block
11516  res->order [j] = ringorder_IS; // Suffix
11517  res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11518  // wvhdl[j] = NULL;
11519  j++;
11520 
11521  // res->order [j] = 0; // The End!
11522  res->wvhdl = wvhdl;
11523 
11524  // j == the last zero block now!
11525  assume(j == (n+1));
11526  assume(res->order[0]==ringorder_IS);
11527  assume(res->order[j-1]==ringorder_IS);
11528  assume(res->order[j]==0);
11529 
11530  if (complete)
11531  {
11532  rComplete(res, 1);
11533 
11534 #ifdef HAVE_PLURAL
11535  if (rIsPluralRing(r))
11536  {
11537  if ( nc_rComplete(r, res, false) ) // no qideal!
11538  {
11539  }
11540  }
11541  assume(rIsPluralRing(r) == rIsPluralRing(res));
11542 #endif
11543 
11544 
11545 #ifdef HAVE_PLURAL
11546  ring old_ring = r;
11547 
11548 #endif
11549 
11550  if (r->qideal!=NULL)
11551  {
11552  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11553 
11554  assume(idRankFreeModule(res->qideal, res) == 0);
11555 
11556 #ifdef HAVE_PLURAL
11557  if( rIsPluralRing(res) )
11558  if( nc_SetupQuotient(res, r, true) )
11559  {
11560  // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11561  }
11562 
11563 #endif
11564  assume(idRankFreeModule(res->qideal, res) == 0);
11565  }
11566 
11567 #ifdef HAVE_PLURAL
11568  assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11569  assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11570  assume(rIsSCA(res) == rIsSCA(old_ring));
11571  assume(ncRingType(res) == ncRingType(old_ring));
11572 #endif
11573  }
11574  strat->tailRing = res;
11575  return res;
11576  }
11577  */
11578 
11579  assume(FALSE);
11580  return(NULL);
11581 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:125
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5647
static int rBlocks(ring r)
Definition: ring.h:569
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_a
Definition: ring.h:70

◆ superenterpairs()

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

Definition at line 4518 of file kutil.cc.

4519 {
4521 #if HAVE_SHIFTBBA
4522  assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4523 #endif
4524  // enter also zero divisor * poly, if this is non zero and of smaller degree
4525  if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat);
4526  initenterstrongPairs(h, k, ecart, 0, strat, atR);
4527  initenterpairs(h, k, ecart, 0, strat, atR);
4528  clearSbatch(h, k, pos, strat);
4529 }
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4492
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4209
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4291

◆ superenterpairsShift()

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

◆ superenterpairsSig()

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

Definition at line 4531 of file kutil.cc.

4532 {
4534  // enter also zero divisor * poly, if this is non zero and of smaller degree
4535  if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4536  if(strat->sigdrop) return;
4537  initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4538  if(strat->sigdrop) return;
4539  initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4540  if(strat->sigdrop) return;
4541  clearSbatch(h, k, pos, strat);
4542 }
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3989
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4264
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4374

◆ syzCriterion()

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

Definition at line 6732 of file kutil.cc.

6733 {
6734 //#if 1
6735 #ifdef DEBUGF5
6736  PrintS("syzygy criterion checks: ");
6737  pWrite(sig);
6738 #endif
6739  for (int k=0; k<strat->syzl; k++)
6740  {
6741  //printf("-%d",k);
6742 //#if 1
6743 #ifdef DEBUGF5
6744  Print("checking with: %d / %d -- \n",k,strat->syzl);
6745  pWrite(pHead(strat->syz[k]));
6746 #endif
6747  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6748  && (!rField_is_Ring(currRing) ||
6749  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6750  {
6751 //#if 1
6752 #ifdef DEBUGF5
6753  PrintS("DELETE!\n");
6754 #endif
6755  strat->nrsyzcrit++;
6756  //printf("- T -\n\n");
6757  return TRUE;
6758  }
6759  }
6760  //printf("- F -\n\n");
6761  return FALSE;
6762 }

◆ syzCriterionInc()

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

Definition at line 6767 of file kutil.cc.

6768 {
6769 //#if 1
6770  if(sig == NULL)
6771  return FALSE;
6772 #ifdef DEBUGF5
6773  PrintS("--- syzygy criterion checks: ");
6774  pWrite(sig);
6775 #endif
6776  int comp = __p_GetComp(sig, currRing);
6777  int min, max;
6778  if (comp<=1)
6779  return FALSE;
6780  else
6781  {
6782  min = strat->syzIdx[comp-2];
6783  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6784  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6785  //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6786  if (comp == strat->currIdx)
6787  {
6788  max = strat->syzl;
6789  }
6790  else
6791  {
6792  max = strat->syzIdx[comp-1];
6793  }
6794  for (int k=min; k<max; k++)
6795  {
6796 #ifdef F5DEBUG
6797  Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6798  Print("checking with: %d -- ",k);
6799  pWrite(pHead(strat->syz[k]));
6800 #endif
6801  if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6802  && (!rField_is_Ring(currRing) ||
6803  (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6804  {
6805  strat->nrsyzcrit++;
6806  return TRUE;
6807  }
6808  }
6809  return FALSE;
6810  }
6811 }
static int min(int a, int b)
Definition: fast_mult.cc:268
static int max(int a, int b)
Definition: fast_mult.cc:264

◆ updateResult()

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

Definition at line 10347 of file kutil.cc.

10348 {
10349  int l;
10350  if (strat->ak>0)
10351  {
10352  for (l=IDELEMS(r)-1;l>=0;l--)
10353  {
10354  if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10355  {
10356  pDelete(&r->m[l]); // and set it to NULL
10357  }
10358  }
10359  int q;
10360  poly p;
10361  if(!rField_is_Ring(currRing))
10362  {
10363  for (l=IDELEMS(r)-1;l>=0;l--)
10364  {
10365  if ((r->m[l]!=NULL)
10366  //&& (strat->syzComp>0)
10367  //&& (pGetComp(r->m[l])<=strat->syzComp)
10368  )
10369  {
10370  for(q=IDELEMS(Q)-1; q>=0;q--)
10371  {
10372  if ((Q->m[q]!=NULL)
10373  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10374  {
10375  if (TEST_OPT_REDSB)
10376  {
10377  p=r->m[l];
10378  r->m[l]=kNF(Q,NULL,p);
10379  pDelete(&p);
10380  }
10381  else
10382  {
10383  pDelete(&r->m[l]); // and set it to NULL
10384  }
10385  break;
10386  }
10387  }
10388  }
10389  }
10390  }
10391  #ifdef HAVE_RINGS
10392  else
10393  {
10394  for (l=IDELEMS(r)-1;l>=0;l--)
10395  {
10396  if ((r->m[l]!=NULL)
10397  //&& (strat->syzComp>0)
10398  //&& (pGetComp(r->m[l])<=strat->syzComp)
10399  )
10400  {
10401  for(q=IDELEMS(Q)-1; q>=0;q--)
10402  {
10403  if ((Q->m[q]!=NULL)
10404  &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10405  {
10406  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10407  {
10408  if (TEST_OPT_REDSB)
10409  {
10410  p=r->m[l];
10411  r->m[l]=kNF(Q,NULL,p);
10412  pDelete(&p);
10413  }
10414  else
10415  {
10416  pDelete(&r->m[l]); // and set it to NULL
10417  }
10418  break;
10419  }
10420  }
10421  }
10422  }
10423  }
10424  }
10425  #endif
10426  }
10427  else
10428  {
10429  int q;
10430  poly p;
10431  BOOLEAN reduction_found=FALSE;
10432  if (!rField_is_Ring(currRing))
10433  {
10434  for (l=IDELEMS(r)-1;l>=0;l--)
10435  {
10436  if (r->m[l]!=NULL)
10437  {
10438  for(q=IDELEMS(Q)-1; q>=0;q--)
10439  {
10440  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10441  {
10442  if (TEST_OPT_REDSB)
10443  {
10444  p=r->m[l];
10445  r->m[l]=kNF(Q,NULL,p);
10446  pDelete(&p);
10447  reduction_found=TRUE;
10448  }
10449  else
10450  {
10451  pDelete(&r->m[l]); // and set it to NULL
10452  }
10453  break;
10454  }
10455  }
10456  }
10457  }
10458  }
10459  #ifdef HAVE_RINGS
10460  //Also need divisibility of the leading coefficients
10461  else
10462  {
10463  for (l=IDELEMS(r)-1;l>=0;l--)
10464  {
10465  if (r->m[l]!=NULL)
10466  {
10467  for(q=IDELEMS(Q)-1; q>=0;q--)
10468  {
10469  if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10470  {
10471  if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10472  {
10473  if (TEST_OPT_REDSB)
10474  {
10475  p=r->m[l];
10476  r->m[l]=kNF(Q,NULL,p);
10477  pDelete(&p);
10478  reduction_found=TRUE;
10479  }
10480  else
10481  {
10482  pDelete(&r->m[l]); // and set it to NULL
10483  }
10484  break;
10485  }
10486  }
10487  }
10488  }
10489  }
10490  }
10491  #endif
10492  if (/*TEST_OPT_REDSB &&*/ reduction_found)
10493  {
10494  #ifdef HAVE_RINGS
10496  {
10497  for (l=IDELEMS(r)-1;l>=0;l--)
10498  {
10499  if (r->m[l]!=NULL)
10500  {
10501  for(q=IDELEMS(r)-1;q>=0;q--)
10502  {
10503  if ((l!=q)
10504  && (r->m[q]!=NULL)
10505  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10506  &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10507  )
10508  {
10509  //If they are equal then take the one with the smallest length
10510  if(pLmDivisibleBy(r->m[q],r->m[l])
10511  && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10512  && (pLength(r->m[q]) < pLength(r->m[l]) ||
10513  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10514  {
10515  pDelete(&r->m[l]);
10516  break;
10517  }
10518  else
10519  pDelete(&r->m[q]);
10520  }
10521  }
10522  }
10523  }
10524  }
10525  else
10526  #endif
10527  {
10528  for (l=IDELEMS(r)-1;l>=0;l--)
10529  {
10530  if (r->m[l]!=NULL)
10531  {
10532  for(q=IDELEMS(r)-1;q>=0;q--)
10533  {
10534  if ((l!=q)
10535  && (r->m[q]!=NULL)
10536  &&(pLmDivisibleBy(r->m[l],r->m[q]))
10537  )
10538  {
10539  //If they are equal then take the one with the smallest length
10540  if(pLmDivisibleBy(r->m[q],r->m[l])
10541  &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10542  (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10543  {
10544  pDelete(&r->m[l]);
10545  break;
10546  }
10547  else
10548  pDelete(&r->m[q]);
10549  }
10550  }
10551  }
10552  }
10553  }
10554  }
10555  }
10556  idSkipZeroes(r);
10557 }
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3167

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8812 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 66 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 269 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 181 of file kutil.h.

◆ test_PosInL

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

Definition at line 870 of file kutil.h.

◆ test_PosInT

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

Definition at line 869 of file kutil.h.