My Project
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
kutil.h File Reference
#include <string.h>
#include "omalloc/omalloc.h"
#include "omalloc/omallocClass.h"
#include "misc/mylimits.h"
#include "kernel/polys.h"
#include "polys/operations/pShallowCopyDelete.h"
#include "kernel/structs.h"
#include "kernel/GBEngine/kstd1.h"
#include "coeffs/bigintmat.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   ((int)((4096-12)/sizeof(LObject)))
 
#define setmaxLinc   ((int)((4096)/sizeof(LObject)))
 
#define setmaxT   ((int)((4096-12)/sizeof(TObject)))
 
#define setmaxTinc   ((int)((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 intintset
 
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 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 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_NF (poly p, kStrategy strat)
 
poly redtailBba_Ring (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_Z (LObject *L, int end_pos, kStrategy strat)
 
void redtailBbaAlsoLC_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailBbaBound (LObject *L, int end_pos, kStrategy strat, int bound, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailSba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT=FALSE, BOOLEAN normalize=FALSE)
 
poly redtailBba (TObject *T, int end_pos, kStrategy strat)
 
poly redtail (poly p, int end_pos, kStrategy strat)
 
poly redtail (LObject *L, int end_pos, kStrategy strat)
 
poly redNF (poly h, int &max_ind, int nonorm, kStrategy strat)
 
int redNF0 (LObject *P, kStrategy strat)
 
poly redNFTail (poly h, const int sl, kStrategy strat)
 
int redHoney (LObject *h, kStrategy strat)
 
int redHoneyM (LObject *h, kStrategy strat)
 
int redLiftstd (LObject *h, kStrategy strat)
 
int redRing (LObject *h, kStrategy strat)
 
int redRing_Z (LObject *h, kStrategy strat)
 
int redRiloc (LObject *h, kStrategy strat)
 
void enterExtendedSpoly (poly h, kStrategy strat)
 
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
 
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
int redLazy (LObject *h, kStrategy strat)
 
int redHomog (LObject *h, kStrategy strat)
 
int redSig (LObject *h, kStrategy strat)
 
int redSigRing (LObject *h, kStrategy strat)
 
void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void enterpairs (poly h, int k, int ec, int pos, kStrategy strat, int atR=-1)
 
void entersets (LObject h)
 
void pairs ()
 
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
 
void message (int i, int *olddeg, int *reduc, 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, bigintmat **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindDivisibleByInT (const kStrategy strat, const LObject *L, const int start=0)
 return -1 if no divisor is found number of first divisor in T, otherwise
 
int kFindDivisibleByInT_ecart (const kStrategy strat, const LObject *L, const int ecart)
 
int kFindDivisibleByInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kFindSameLMInT_Z (const kStrategy strat, const LObject *L, const int start=0)
 
int kTestDivisibleByT0_Z (const kStrategy strat, const LObject *L)
 tests if T[0] divides the leading monomial of L, returns -1 if not
 
int kFindDivisibleByInS (const kStrategy strat, int *max_ind, LObject *L)
 return -1 if no divisor is found number of first divisor in S, otherwise
 
int kFindNextDivisibleByInS (const kStrategy strat, int start, int max_ind, LObject *L)
 
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart=LONG_MAX)
 
KINLINE TSet initT ()
 
KINLINE TObject ** initR ()
 
KINLINE unsigned longinitsevT ()
 
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)
 
int redFirst (LObject *h, kStrategy strat)
 
int redEcart (LObject *h, kStrategy strat)
 
void enterSMora (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSMoraNF (LObject &p, int atS, kStrategy strat, int atR=-1)
 
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
 
ideal bba (ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, bigintmat *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, bigintmat *hilb)
 
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL, BOOLEAN redtail=FALSE)
 
int ksReducePolyZ (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyLC (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyGCD (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyBound (LObject *PR, TObject *PW, int bound, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySig (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolySigRing (LObject *PR, TObject *PW, long idx, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
 
int ksReducePolyTail (LObject *PR, TObject *PW, poly Current, poly spNoether=NULL)
 
KINLINE int ksReducePolyTail (LObject *PR, TObject *PW, LObject *Red)
 
void ksCreateSpoly (LObject *Pair, poly spNoether=NULL, int use_buckets=0, ring tailRing=currRing, poly m1=NULL, poly m2=NULL, TObject **R=NULL)
 
poly ksCreateShortSpoly (poly p1, poly p2, ring tailRing)
 
KINLINE poly ksOldSpolyRed (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldSpolyRedNew (poly p1, poly p2, poly spNoether=NULL)
 
KINLINE poly ksOldCreateSpoly (poly p1, poly p2, poly spNoether=NULL, ring r=currRing)
 
KINLINE void ksOldSpolyTail (poly p1, poly q, poly q2, poly spNoether, ring r=currRing)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
poly preIntegerCheck (ideal F, ideal Q)
 used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L=NULL, TObject *T=NULL, unsigned long new_expbound=0)
 
void kStratInitChangeTailRing (kStrategy strat)
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
 
ring sbaRing (kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1)
 
KINLINE void clearS (poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
 
static int kFindInL1 (const poly p, const kStrategy strat)
 
void enterTShift (LObject p, kStrategy strat, int atT=-1)
 
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
int redFirstShift (LObject *h, kStrategy strat)
 
ideal bbaShift (ideal F, ideal Q, intvec *w, bigintmat *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 66 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

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

Definition at line 394 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 28 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 50 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 51 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 37 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 38 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 39 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 30 of file kutil.h.

◆ setmaxL

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

Definition at line 31 of file kutil.h.

◆ setmaxLinc

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

Definition at line 32 of file kutil.h.

◆ setmaxT

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

Definition at line 34 of file kutil.h.

◆ setmaxTinc

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

Definition at line 35 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 64 of file kutil.h.

◆ intset

Definition at line 54 of file kutil.h.

◆ LObject

Definition at line 59 of file kutil.h.

◆ LSet

Definition at line 61 of file kutil.h.

◆ TObject

Definition at line 58 of file kutil.h.

◆ TSet

Definition at line 60 of file kutil.h.

◆ wlen_set

Definition at line 56 of file kutil.h.

◆ wlen_type

Definition at line 55 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6618 of file kutil.cc.

6619{
6621 return FALSE;
6622 poly p1 = pOne();
6623 poly p2 = pOne();
6624 for (int ii=strat->sl; ii>start; ii--)
6625 {
6626 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6627 {
6628 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6629 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6630 if (!(pLmCmp(p1,p2) == 1))
6631 {
6632 pDelete(&p1);
6633 pDelete(&p2);
6634 return TRUE;
6635 }
6636 }
6637 }
6638 pDelete(&p1);
6639 pDelete(&p2);
6640 return FALSE;
6641}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
polyset S
Definition kutil.h:307
unsigned long * sevSig
Definition kutil.h:325
polyset sig
Definition kutil.h:309
LObject P
Definition kutil.h:303
int sl
Definition kutil.h:349
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1446
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1931
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pDelete(p_ptr)
Definition polys.h:187
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
#define pOne()
Definition polys.h:316
#define rField_is_Ring(R)
Definition ring.h:491

◆ arriRewCriterionPre()

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

Definition at line 6643 of file kutil.cc.

6644{
6645 //Over Rings, there are still some changes to do: considering coeffs
6647 return FALSE;
6648 int found = -1;
6649 for (int i=strat->Bl; i>-1; i--)
6650 {
6651 if (pLmEqual(strat->B[i].sig,sig))
6652 {
6653 found = i;
6654 break;
6655 }
6656 }
6657 if (found != -1)
6658 {
6659 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6660 {
6661 deleteInL(strat->B,&strat->Bl,found,strat);
6662 }
6663 else
6664 {
6665 return TRUE;
6666 }
6667 }
6668 poly p1 = pOne();
6669 poly p2 = pOne();
6670 for (int ii=strat->sl; ii>-1; ii--)
6671 {
6672 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6673 {
6674 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6675 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6676 if (!(pLmCmp(p1,p2) == 1))
6677 {
6678 pDelete(&p1);
6679 pDelete(&p2);
6680 return TRUE;
6681 }
6682 }
6683 }
6684 pDelete(&p1);
6685 pDelete(&p2);
6686 return FALSE;
6687}
int i
Definition cfEzgcd.cc:132
int Bl
Definition kutil.h:353
LSet B
Definition kutil.h:329
bool found
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1208
#define pLmEqual(p1, p2)
Definition polys.h:112

◆ arriRewDummy()

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

Definition at line 1258 of file kInline.h.

1259{
1260 return FALSE;
1261}

◆ bba()

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

Definition at line 2618 of file kstd2.cc.

2619{
2620 int red_result = 1;
2621 int olddeg,reduc;
2622 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2624 BITSET save;
2626
2627 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2629 initBuchMoraPosRing(strat);
2630 else
2631 initBuchMoraPos(strat);
2632 initHilbCrit(F,Q,&hilb,strat);
2633 initBba(strat);
2634 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2635 initBuchMora(F, Q,strat);
2636 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2637 reduc = olddeg = 0;
2638
2639#ifndef NO_BUCKETS
2641 strat->use_buckets = 1;
2642#endif
2643 // redtailBBa against T for inhomogeneous input
2644 if (!TEST_OPT_OLDSTD)
2645 withT = ! strat->homog;
2646
2647 // strat->posInT = posInT_pLength;
2648 #ifdef KDEBUG
2649 kTest_TS(strat);
2650 #endif
2651
2652#ifdef HAVE_TAIL_RING
2653 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2655#endif
2656 if (BVERBOSE(23))
2657 {
2658 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2659 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2660 kDebugPrint(strat);
2661 }
2662
2663
2664#ifdef KDEBUG
2665 //kDebugPrint(strat);
2666#endif
2667 /* compute------------------------------------------------------- */
2668 while (strat->Ll >= 0)
2669 {
2670 #ifdef KDEBUG
2671 if (TEST_OPT_DEBUG) messageSets(strat);
2672 #endif
2673 if (siCntrlc)
2674 {
2675 while (strat->Ll >= 0)
2676 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2677 strat->noClearS=TRUE;
2678 }
2680 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2681 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2682 {
2683 /*
2684 *stops computation if
2685 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2686 *a predefined number Kstd1_deg
2687 */
2688 while ((strat->Ll >= 0)
2689 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2690 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2691 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2692 )
2693 {
2694 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2695 if(TEST_OPT_PROT) PrintS("D");
2696 }
2697 if (strat->Ll<0) break;
2698 else strat->noClearS=TRUE;
2699 }
2700 if (strat->Ll== 0) strat->interpt=TRUE;
2701 /* picks the last element from the lazyset L */
2702 strat->P = strat->L[strat->Ll];
2703 strat->Ll--;
2704
2705 if (pNext(strat->P.p) == strat->tail)
2706 {
2707 // deletes the short spoly
2709 pLmDelete(strat->P.p);
2710 else
2711 pLmFree(strat->P.p);
2712 strat->P.p = NULL;
2713 poly m1 = NULL, m2 = NULL;
2714
2715 // check that spoly creation is ok
2716 while (strat->tailRing != currRing &&
2717 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2718 {
2719 assume(m1 == NULL && m2 == NULL);
2720 // if not, change to a ring where exponents are at least
2721 // large enough
2722 if (!kStratChangeTailRing(strat))
2723 {
2724 WerrorS("OVERFLOW...");
2725 break;
2726 }
2727 }
2728 // create the real one
2729 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2730 strat->tailRing, m1, m2, strat->R);
2731 }
2732 else if (strat->P.p1 == NULL)
2733 {
2734 if (strat->minim > 0)
2735 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2736 // for input polys, prepare reduction
2737 strat->P.PrepareRed(strat->use_buckets);
2738 }
2739
2740 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2741 {
2742 red_result = 0;
2743 }
2744 else
2745 {
2746 if (TEST_OPT_PROT)
2747 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2748 &olddeg,&reduc,strat, red_result);
2749
2750 /* reduction of the element chosen from L */
2751 red_result = strat->red(&strat->P,strat);
2752 if (errorreported) break;
2753 }
2754
2755 if (strat->overflow)
2756 {
2757 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2758 }
2759
2760 // reduction to non-zero new poly
2761 if (red_result == 1)
2762 {
2763 // get the polynomial (canonicalize bucket, make sure P.p is set)
2764 strat->P.GetP(strat->lmBin);
2765 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2766 // but now, for entering S, T, we reset it
2767 // in the inhomogeneous case: FDeg == pFDeg
2768 if (strat->homog) strat->initEcart(&(strat->P));
2769
2770 /* statistic */
2771 if (TEST_OPT_PROT) PrintS("s");
2772
2773 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2774
2775 // reduce the tail and normalize poly
2776 // in the ring case we cannot expect LC(f) = 1,
2777 strat->redTailChange=FALSE;
2778
2779 /* if we are computing over Z we always want to try and cut down
2780 * the coefficients in the tail terms */
2782 {
2783 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2784 }
2785
2787 {
2788 strat->P.pCleardenom();
2790 {
2791 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2792 strat->P.pCleardenom();
2793 if (strat->redTailChange) { strat->P.t_p=NULL; }
2794 }
2795 }
2796 else
2797 {
2798 strat->P.pNorm();
2800 {
2801 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2802 if (strat->redTailChange) { strat->P.t_p=NULL; }
2803 }
2804 }
2805
2806#ifdef KDEBUG
2807 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2808#endif /* KDEBUG */
2809
2810 // min_std stuff
2811 if ((strat->P.p1==NULL) && (strat->minim>0))
2812 {
2813 if (strat->minim==1)
2814 {
2815 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2816 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2817 }
2818 else
2819 {
2820 strat->M->m[minimcnt]=strat->P.p2;
2821 strat->P.p2=NULL;
2822 }
2823 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2824 pNext(strat->M->m[minimcnt])
2825 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2826 strat->tailRing, currRing,
2827 currRing->PolyBin);
2828 minimcnt++;
2829 }
2830
2831 // enter into S, L, and T
2832 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2833 {
2834 strat->P.SetShortExpVector();
2835 enterT(strat->P, strat);
2837 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2838 else
2839 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2840 // posInS only depends on the leading term
2841 strat->enterS(strat->P, pos, strat, strat->tl);
2842#if 0
2843 int pl=pLength(strat->P.p);
2844 if (pl==1)
2845 {
2846 //if (TEST_OPT_PROT)
2847 //PrintS("<1>");
2848 }
2849 else if (pl==2)
2850 {
2851 //if (TEST_OPT_PROT)
2852 //PrintS("<2>");
2853 }
2854#endif
2855 }
2856 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2857// Print("[%d]",hilbeledeg);
2858 kDeleteLcm(&strat->P);
2859 if (strat->s_poly!=NULL)
2860 {
2861 // the only valid entries are: strat->P.p,
2862 // strat->tailRing (read-only, keep it)
2863 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2864 if (strat->s_poly(strat))
2865 {
2866 // we are called AFTER enterS, i.e. if we change P
2867 // we have to add it also to S/T
2868 // and add pairs
2869 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2870 enterT(strat->P, strat);
2872 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2873 else
2874 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2875 strat->enterS(strat->P, pos, strat, strat->tl);
2876 }
2877 }
2878 }
2879 else if (strat->P.p1 == NULL && strat->minim > 0)
2880 {
2881 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2882 }
2883
2884#ifdef KDEBUG
2885 strat->P.Init();
2886 kTest_TS(strat);
2887#endif /* KDEBUG */
2888 }
2889#ifdef KDEBUG
2890 if (TEST_OPT_DEBUG) messageSets(strat);
2891#endif /* KDEBUG */
2892
2893 if (TEST_OPT_SB_1)
2894 {
2896 {
2897 int k=1;
2898 int j;
2899 while(k<=strat->sl)
2900 {
2901 j=0;
2902 loop
2903 {
2904 if (j>=k) break;
2905 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2906 j++;
2907 }
2908 k++;
2909 }
2910 }
2911 }
2912 /* complete reduction of the standard basis--------- */
2913 if (TEST_OPT_REDSB)
2914 {
2915 completeReduce(strat);
2916 if (strat->completeReduce_retry)
2917 {
2918 // completeReduce needed larger exponents, retry
2919 // to reduce with S (instead of T)
2920 // and in currRing (instead of strat->tailRing)
2921#ifdef HAVE_TAIL_RING
2922 if(currRing->bitmask>strat->tailRing->bitmask)
2923 {
2925 cleanT(strat);strat->tailRing=currRing;
2926 int i;
2927 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2928 completeReduce(strat);
2929 }
2930 if (strat->completeReduce_retry)
2931#endif
2932 Werror("exponent bound is %ld",currRing->bitmask);
2933 }
2934 }
2935 else if (TEST_OPT_PROT) PrintLn();
2936 /* release temp data-------------------------------- */
2937 exitBuchMora(strat);
2938 /* postprocessing for GB over ZZ --------------------*/
2939 if (!errorreported)
2940 {
2942 {
2943 for(int i = 0;i<=strat->sl;i++)
2944 {
2945 if(!nGreaterZero(pGetCoeff(strat->S[i])))
2946 {
2947 strat->S[i] = pNeg(strat->S[i]);
2948 }
2949 }
2950 finalReduceByMon(strat);
2951 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2952 {
2953 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2954 {
2955 strat->S[i] = pNeg(strat->Shdl->m[i]);
2956 }
2957 }
2958 }
2959 //else if (rField_is_Ring(currRing))
2960 // finalReduceByMon(strat);
2961 }
2962// if (TEST_OPT_WEIGHTM)
2963// {
2964// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2965// if (ecartWeights)
2966// {
2967// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2968// ecartWeights=NULL;
2969// }
2970// }
2973 /* postprocessing for GB over Q-rings ------------------*/
2974 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2975
2976 idTest(strat->Shdl);
2977
2978 return (strat->Shdl);
2979}
#define BITSET
Definition auxiliary.h:85
int BOOLEAN
Definition auxiliary.h:88
int k
Definition cfEzgcd.cc:99
int syzComp
Definition kutil.h:355
int * S_2_R
Definition kutil.h:343
ring tailRing
Definition kutil.h:344
int Ll
Definition kutil.h:352
omBin lmBin
Definition kutil.h:345
char honey
Definition kutil.h:376
int minim
Definition kutil.h:358
TObject ** R
Definition kutil.h:341
ideal M
Definition kutil.h:306
int tl
Definition kutil.h:351
poly tail
Definition kutil.h:335
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:285
ideal Shdl
Definition kutil.h:304
pShallowCopyDeleteProc p_shallow_copy_delete
Definition kutil.h:339
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:287
char use_buckets
Definition kutil.h:382
char interpt
Definition kutil.h:370
char redTailChange
Definition kutil.h:398
char completeReduce_retry
Definition kutil.h:402
void(* initEcart)(TObject *L)
Definition kutil.h:281
char noClearS
Definition kutil.h:401
char overflow
Definition kutil.h:403
LSet L
Definition kutil.h:328
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:279
unsigned long * sevS
Definition kutil.h:323
char homog
Definition kutil.h:371
s_poly_proc_t s_poly
Definition kutil.h:301
const CanonicalForm & w
Definition facAbsFact.cc:51
int j
Definition facHensel.cc:110
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define idTest(id)
Definition ideals.h:47
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition kInline.h:1212
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition kInline.h:1235
void khCheck(ideal Q, intvec *w, bigintmat *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:1203
void initBba(kStrategy strat)
Definition kstd1.cc:1690
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
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:11501
VAR int(* test_PosInT)(const TSet T, const int tl, LObject &h)
Definition kstd2.cc:82
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9744
void enterT(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9136
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7460
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1067
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4487
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:7137
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9573
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10962
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9831
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4663
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10482
void cleanT(kStrategy strat)
Definition kutil.cc:557
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10074
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4457
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11059
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9428
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10280
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9658
void messageSets(kStrategy strat)
Definition kutil.cc:7533
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7501
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10870
void initHilbCrit(ideal, ideal, bigintmat **hilb, kStrategy strat)
Definition kutil.cc:9410
static void kDeleteLcm(LObject *P)
Definition kutil.h:881
#define assume(x)
Definition mod2.h:389
#define pNext(p)
Definition monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define nGreaterZero(n)
Definition numbers.h:27
#define NULL
Definition omList.c:12
VAR BOOLEAN siCntrlc
Definition options.c:14
#define TEST_OPT_IDLIFT
Definition options.h:131
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define BVERBOSE(a)
Definition options.h:35
#define TEST_OPT_REDTAIL
Definition options.h:118
#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:125
#define TEST_OPT_REDSB
Definition options.h:106
#define TEST_OPT_DEGBOUND
Definition options.h:115
#define TEST_OPT_SB_1
Definition options.h:121
#define TEST_OPT_PROT
Definition options.h:105
#define TEST_OPT_DEBUG
Definition options.h:110
#define TEST_OPT_CONTENTSB
Definition options.h:129
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
static int pLength(poly a)
Definition p_polys.h:190
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
#define pNeg(p)
Definition polys.h:199
#define pGetComp(p)
Component.
Definition polys.h:38
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
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:71
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314
void Werror(const char *fmt,...)
Definition reporter.cc:189
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define IDELEMS(i)
#define Q
Definition sirandom.c:26
#define loop
Definition structs.h:71

◆ bbaShift()

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

Definition at line 4593 of file kstd2.cc.

4594{
4595 int red_result = 1;
4596 int olddeg,reduc;
4597 int hilbeledeg=1,hilbcount=0,minimcnt=0;
4598 BOOLEAN withT = TRUE; // currently only T contains the shifts
4599 BITSET save;
4601
4602 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
4604 initBuchMoraPosRing(strat);
4605 else
4606 initBuchMoraPos(strat);
4607 initHilbCrit(F,Q,&hilb,strat);
4608 initBba(strat);
4609 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
4610 /*Shdl=*/initBuchMora(F, Q,strat);
4611 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
4612 reduc = olddeg = 0;
4613
4614#ifndef NO_BUCKETS
4616 strat->use_buckets = 1;
4617#endif
4618 // redtailBBa against T for inhomogeneous input
4619 // if (!TEST_OPT_OLDSTD)
4620 // withT = ! strat->homog;
4621
4622 // strat->posInT = posInT_pLength;
4623 kTest_TS(strat);
4624
4625#ifdef HAVE_TAIL_RING
4626 // if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4627 // kStratInitChangeTailRing(strat);
4628 strat->tailRing=currRing;
4629#endif
4630 if (BVERBOSE(23))
4631 {
4632 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
4633 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
4634 kDebugPrint(strat);
4635 }
4636
4637#ifdef KDEBUG
4638 //kDebugPrint(strat);
4639#endif
4640 /* compute------------------------------------------------------- */
4641 while (strat->Ll >= 0)
4642 {
4643 #ifdef KDEBUG
4644 if (TEST_OPT_DEBUG) messageSets(strat);
4645 #endif
4646 if (siCntrlc)
4647 {
4648 while (strat->Ll >= 0)
4649 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4650 strat->noClearS=TRUE;
4651 }
4653 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4654 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
4655 {
4656 /*
4657 *stops computation if
4658 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
4659 *a predefined number Kstd1_deg
4660 */
4661 while ((strat->Ll >= 0)
4662 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
4663 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
4664 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
4665 )
4666 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
4667 if (strat->Ll<0) break;
4668 else strat->noClearS=TRUE;
4669 }
4670 if (strat->Ll== 0) strat->interpt=TRUE;
4671 /* picks the last element from the lazyset L */
4672 strat->P = strat->L[strat->Ll];
4673 strat->Ll--;
4674
4675 if (pNext(strat->P.p) == strat->tail)
4676 {
4677 // deletes the short spoly
4679 pLmDelete(strat->P.p);
4680 else
4681 pLmFree(strat->P.p);
4682 strat->P.p = NULL;
4683 poly m1 = NULL, m2 = NULL;
4684
4685 // check that spoly creation is ok
4686 while (strat->tailRing != currRing &&
4687 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4688 {
4689 assume(m1 == NULL && m2 == NULL);
4690 // if not, change to a ring where exponents are at least
4691 // large enough
4692 if (!kStratChangeTailRing(strat))
4693 {
4694 WerrorS("OVERFLOW...");
4695 break;
4696 }
4697 }
4698 // create the real one
4699 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4700 strat->tailRing, m1, m2, strat->R);
4701 }
4702 else if (strat->P.p1 == NULL)
4703 {
4704 if (strat->minim > 0)
4705 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4706 // for input polys, prepare reduction
4707 strat->P.PrepareRed(strat->use_buckets);
4708 }
4709
4710 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
4711 {
4712 red_result = 0;
4713 }
4714 else
4715 {
4716 if (TEST_OPT_PROT)
4717 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4718 &olddeg,&reduc,strat, red_result);
4719
4720 /* reduction of the element chosen from L */
4721 red_result = strat->red(&strat->P,strat);
4722 if (errorreported) break;
4723 }
4724
4725 if (strat->overflow)
4726 {
4727 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4728 }
4729
4730 // reduction to non-zero new poly
4731 if (red_result == 1)
4732 {
4733 // get the polynomial (canonicalize bucket, make sure P.p is set)
4734 strat->P.GetP(strat->lmBin);
4735 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4736 // but now, for entering S, T, we reset it
4737 // in the inhomogeneous case: FDeg == pFDeg
4738 if (strat->homog) strat->initEcart(&(strat->P));
4739
4740 /* statistic */
4741 if (TEST_OPT_PROT) PrintS("s");
4742
4743 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4744
4745 // reduce the tail and normalize poly
4746 // in the ring case we cannot expect LC(f) = 1,
4747 strat->redTailChange=FALSE;
4748
4749 /* if we are computing over Z we always want to try and cut down
4750 * the coefficients in the tail terms */
4752 {
4753 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
4754 }
4755
4757 {
4758 strat->P.pCleardenom();
4760 {
4761 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
4762 strat->P.pCleardenom();
4763 if (strat->redTailChange)
4764 {
4765 strat->P.t_p=NULL;
4766 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4767 }
4768 }
4769 }
4770 else
4771 {
4772 strat->P.pNorm();
4774 {
4775 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4776 if (strat->redTailChange)
4777 {
4778 strat->P.t_p=NULL;
4779 strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
4780 }
4781 }
4782 }
4783
4784#ifdef KDEBUG
4785 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4786#endif /* KDEBUG */
4787
4788 // min_std stuff
4789 if ((strat->P.p1==NULL) && (strat->minim>0))
4790 {
4791 if (strat->minim==1)
4792 {
4793 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4794 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4795 }
4796 else
4797 {
4798 strat->M->m[minimcnt]=strat->P.p2;
4799 strat->P.p2=NULL;
4800 }
4801 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4802 pNext(strat->M->m[minimcnt])
4803 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4804 strat->tailRing, currRing,
4805 currRing->PolyBin);
4806 minimcnt++;
4807 }
4808
4809
4810 // enter into S, L, and T
4811 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4812 {
4813 enterT(strat->P, strat);
4814 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4815 // posInS only depends on the leading term
4816 strat->enterS(strat->P, pos, strat, strat->tl);
4817 if (!strat->rightGB)
4818 enterTShift(strat->P, strat);
4819 }
4820
4821 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4822// Print("[%d]",hilbeledeg);
4823 kDeleteLcm(&strat->P);
4824 if (strat->s_poly!=NULL)
4825 {
4826 // the only valid entries are: strat->P.p,
4827 // strat->tailRing (read-only, keep it)
4828 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
4829 if (strat->s_poly(strat))
4830 {
4831 // we are called AFTER enterS, i.e. if we change P
4832 // we have to add it also to S/T
4833 // and add pairs
4834 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4835 enterT(strat->P, strat);
4836 enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
4837 strat->enterS(strat->P, pos, strat, strat->tl);
4838 if (!strat->rightGB)
4839 enterTShift(strat->P,strat);
4840 }
4841 }
4842 }
4843 else if (strat->P.p1 == NULL && strat->minim > 0)
4844 {
4845 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4846 }
4847#ifdef KDEBUG
4848 strat->P.Init();
4849#endif /* KDEBUG */
4850 kTest_TS(strat);
4851 }
4852#ifdef KDEBUG
4853 if (TEST_OPT_DEBUG) messageSets(strat);
4854#endif /* KDEBUG */
4855 /* shift case: look for elt's in S such that they are divisible by elt in T */
4856 if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
4857 {
4859 {
4860 for (int k = 0; k <= strat->sl; ++k)
4861 {
4862 if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
4863 for (int j = 0; j<=strat->tl; ++j)
4864 {
4865 if (strat->T[j].p!=NULL)
4866 {
4867 // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
4868 assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
4869 assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
4870 if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
4871 {
4872 if (pLmCmp(strat->T[j].p, strat->S[k]) != 0)
4873 { // check whether LM is different
4874 deleteInS(k, strat);
4875 --k;
4876 break;
4877 }
4878 }
4879 }
4880 }
4881 }
4882 }
4883 }
4884 /* complete reduction of the standard basis--------- */
4885 if (TEST_OPT_REDSB)
4886 {
4887 completeReduce(strat, TRUE); //shift: withT = TRUE
4888 if (strat->completeReduce_retry)
4889 {
4890 // completeReduce needed larger exponents, retry
4891 // to reduce with S (instead of T)
4892 // and in currRing (instead of strat->tailRing)
4893#ifdef HAVE_TAIL_RING
4894 if(currRing->bitmask>strat->tailRing->bitmask)
4895 {
4897 cleanT(strat);strat->tailRing=currRing;
4898 int i;
4899 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
4900 WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know
4901 completeReduce(strat);
4902 }
4903 if (strat->completeReduce_retry)
4904#endif
4905 Werror("exponent bound is %ld",currRing->bitmask);
4906 }
4907 }
4908 else if (TEST_OPT_PROT) PrintLn();
4909
4910 /* release temp data-------------------------------- */
4911 exitBuchMora(strat);
4912 /* postprocessing for GB over ZZ --------------------*/
4913 if (!errorreported)
4914 {
4916 {
4917 for(int i = 0;i<=strat->sl;i++)
4918 {
4919 if(!nGreaterZero(pGetCoeff(strat->S[i])))
4920 {
4921 strat->S[i] = pNeg(strat->S[i]);
4922 }
4923 }
4924 finalReduceByMon(strat);
4925 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
4926 {
4927 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
4928 {
4929 strat->S[i] = pNeg(strat->Shdl->m[i]);
4930 }
4931 }
4932 }
4933 //else if (rField_is_Ring(currRing))
4934 // finalReduceByMon(strat);
4935 }
4936// if (TEST_OPT_WEIGHTM)
4937// {
4938// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
4939// if (ecartWeights)
4940// {
4941// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
4942// ecartWeights=NULL;
4943// }
4944// }
4947 /* postprocessing for GB over Q-rings ------------------*/
4948 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
4949
4950 idTest(strat->Shdl);
4951
4952 return (strat->Shdl);
4953}
TSet T
Definition kutil.h:327
char rightGB
Definition kutil.h:368
unsigned long * sevT
Definition kutil.h:326
intset fromQ
Definition kutil.h:322
#define WarnS
Definition emacs.cc:78
void enterTShift(LObject p, kStrategy strat, int atT)
Definition kutil.cc:12980
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:12950
void deleteInS(int i, kStrategy strat)
Definition kutil.cc:1132
#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:147
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153

◆ cancelunit()

void cancelunit ( LObject p,
BOOLEAN  inNF = FALSE 
)

Definition at line 365 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3204 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3445 of file kutil.cc.

3446{
3447 if (strat->pairtest!=NULL)
3448 {
3449 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3450 strat->pairtest=NULL;
3451 }
3452 /*
3453 *the elements of B enter L
3454 */
3455 kMergeBintoL(strat);
3456}

◆ chainCritSig()

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

Definition at line 3461 of file kutil.cc.

3462{
3463 int i,j,l;
3464 kMergeBintoLSba(strat);
3465 j = strat->Ll;
3466 loop /*cannot be changed into a for !!! */
3467 {
3468 if (j <= 0)
3469 {
3470 /*now L[0] cannot be canceled any more and the tail can be removed*/
3471 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3472 break;
3473 }
3474 if (strat->L[j].p2 == p)
3475 {
3476 i = j-1;
3477 loop
3478 {
3479 if (i < 0) break;
3480 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3481 {
3482 /*L[i] could be canceled but we search for a better one to cancel*/
3483 strat->c3++;
3484 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3485 && (pNext(strat->L[l].p) == strat->tail)
3486 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3487 && pDivisibleBy(p,strat->L[l].lcm))
3488 {
3489 /*
3490 *"NOT equal(...)" because in case of "equal" the element L[l]
3491 *is "older" and has to be from theoretical point of view behind
3492 *L[i], but we do not want to reorder L
3493 */
3494 strat->L[i].p2 = strat->tail;
3495 /*
3496 *L[l] will be canceled, we cannot cancel L[i] later on,
3497 *so we mark it with "tail"
3498 */
3499 deleteInL(strat->L,&strat->Ll,l,strat);
3500 i--;
3501 }
3502 else
3503 {
3504 deleteInL(strat->L,&strat->Ll,i,strat);
3505 }
3506 j--;
3507 }
3508 i--;
3509 }
3510 }
3511 else if (strat->L[j].p2 == strat->tail)
3512 {
3513 /*now L[j] cannot be canceled any more and the tail can be removed*/
3514 strat->L[j].p2 = p;
3515 }
3516 j--;
3517 }
3518}
void kMergeBintoLSba(kStrategy strat)
Definition kutil.cc:3182

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 557 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1235 of file kInline.h.

1237{
1239 if (strat->noClearS) return;
1241 {
1242 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1243 return;
1244 if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1245 return;
1246 }
1247 else
1248 {
1249 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1250 }
1251 deleteInS((*at),strat);
1252 (*at)--;
1253 (*k)--;
1254}

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10280 of file kutil.cc.

10281{
10282 int i;
10283 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10284 LObject L;
10285
10286#ifdef KDEBUG
10287 // need to set this: during tailreductions of T[i], T[i].max is out of
10288 // sync
10289 sloppy_max = TRUE;
10290#endif
10291
10292 strat->noTailReduction = FALSE;
10293 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10294 if (TEST_OPT_PROT)
10295 {
10296 PrintLn();
10297// if (timerv) writeTime("standard base computed:");
10298 }
10299 if (TEST_OPT_PROT)
10300 {
10301 Print("(S:%d)",strat->sl);mflush();
10302 }
10303 for (i=strat->sl; i>=low; i--)
10304 {
10305 int end_pos=strat->sl;
10306 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10307 if (strat->ak==0) end_pos=i-1;
10308 TObject* T_j = strat->s_2_t(i);
10309 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10310 {
10311 L = *T_j;
10312 #ifdef KDEBUG
10313 if (TEST_OPT_DEBUG)
10314 {
10315 Print("test S[%d]:",i);
10316 p_wrp(L.p,currRing,strat->tailRing);
10317 PrintLn();
10318 }
10319 #endif
10321 strat->S[i] = redtailBba(&L, end_pos, strat, withT,FALSE /*no normalize*/);
10322 else
10323 strat->S[i] = redtail(&L, strat->sl, strat);
10324 #ifdef KDEBUG
10325 if (TEST_OPT_DEBUG)
10326 {
10327 Print("to (tailR) S[%d]:",i);
10328 p_wrp(strat->S[i],currRing,strat->tailRing);
10329 PrintLn();
10330 }
10331 #endif
10332
10333 if (strat->redTailChange)
10334 {
10335 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10336 if (pNext(T_j->p) != NULL)
10337 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10338 else
10339 T_j->max_exp = NULL;
10340 }
10342 T_j->pCleardenom();
10343 }
10344 else
10345 {
10346 assume(currRing == strat->tailRing);
10347 #ifdef KDEBUG
10348 if (TEST_OPT_DEBUG)
10349 {
10350 Print("test S[%d]:",i);
10351 p_wrp(strat->S[i],currRing,strat->tailRing);
10352 PrintLn();
10353 }
10354 #endif
10356 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10357 else
10358 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10360 {
10362 {
10363 number n;
10364 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10365 if (!nIsOne(n))
10366 {
10368 denom->n=nInvers(n);
10369 denom->next=DENOMINATOR_LIST;
10371 }
10372 nDelete(&n);
10373 }
10374 else
10375 {
10376 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10377 }
10378 }
10379 #ifdef KDEBUG
10380 if (TEST_OPT_DEBUG)
10381 {
10382 Print("to (-tailR) S[%d]:",i);
10383 p_wrp(strat->S[i],currRing,strat->tailRing);
10384 PrintLn();
10385 }
10386 #endif
10387 }
10388 if (TEST_OPT_PROT)
10389 PrintS("-");
10390 }
10391 if (TEST_OPT_PROT) PrintLn();
10392#ifdef KDEBUG
10393 sloppy_max = FALSE;
10394#endif
10395}
char noTailReduction
Definition kutil.h:377
int ak
Definition kutil.h:354
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:6833
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kutil.cc:6909
STATIC_VAR BOOLEAN sloppy_max
Definition kutil.cc:788
VAR denominator_list DENOMINATOR_LIST
Definition kutil.cc:79
denominator_list_s * denominator_list
Definition kutil.h:64
class sTObject TObject
Definition kutil.h:58
class sLObject LObject
Definition kutil.h:59
#define nDelete(n)
Definition numbers.h:16
#define nInvers(a)
Definition numbers.h:33
#define nIsOne(n)
Definition numbers.h:25
#define omAlloc(size)
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:1139
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition p_polys.cc:2958
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
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 286 of file kutil.cc.

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

◆ deleteHC() [2/2]

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

Definition at line 351 of file kutil.cc.

352{
353 LObject L(*p, currRing, strat->tailRing);
354
355 deleteHC(&L, strat);
356 *p = L.p;
357 *e = L.ecart;
358 *l = L.length;
359 if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
360}
int length() const
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition kutil.cc:286

◆ deleteInL()

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

Definition at line 1208 of file kutil.cc.

1209{
1210 if (set[j].lcm!=NULL)
1211 {
1212 kDeleteLcm(&set[j]);
1213 }
1214 if (set[j].sig!=NULL)
1215 {
1216 if (pGetCoeff(set[j].sig) != NULL)
1217 pLmDelete(set[j].sig);
1218 else
1219 pLmFree(set[j].sig);
1220 }
1221 if (set[j].p!=NULL)
1222 {
1223 if (pNext(set[j].p) == strat->tail)
1224 {
1225 if (pGetCoeff(set[j].p) != NULL)
1226 pLmDelete(set[j].p);
1227 else
1228 pLmFree(set[j].p);
1229 /*- tail belongs to several int spolys -*/
1230 }
1231 else
1232 {
1233 // search p in T, if it is there, do not delete it
1234 if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1235 {
1236 // assure that for global orderings kFindInT fails
1237 //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1238 set[j].Delete();
1239 }
1240 }
1241 }
1242 #ifdef HAVE_SHIFTBBA
1243 if (is_shifted_p1(/*strat->P.p1,*/strat))
1244 {
1245 // clean up strat->P.p1: may be shifted
1246 pLmDelete(strat->P.p1);
1247 strat->P.p1=NULL;
1248 }
1249 #endif
1250 if (*length > 0 && j < *length)
1251 {
1252#ifdef ENTER_USE_MEMMOVE
1253 memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1254#else
1255 int i;
1256 for (i=j; i < (*length); i++)
1257 set[i] = set[i+1];
1258#endif
1259 }
1260#ifdef KDEBUG
1261 set[*length].Init();
1262#endif
1263 (*length)--;
1264}
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:703
static BOOLEAN is_shifted_p1(const kStrategy strat)
Definition kutil.cc:1181
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 1132 of file kutil.cc.

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4232 of file kutil.cc.

4233{
4234 if (nIsOne(pGetCoeff(h))) return;
4235 number gcd;
4236 number zero=n_Init(0,currRing->cf);
4237 bool go = false;
4238 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4239 {
4240 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4241 go = true;
4242 }
4243 else
4244 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4245 if (go || !nIsOne(gcd))
4246 {
4247 poly p = h->next;
4248 if (!go)
4249 {
4250 number tmp = gcd;
4251 gcd = n_Ann(gcd,currRing->cf);
4252 nDelete(&tmp);
4253 }
4254 p_Test(p,strat->tailRing);
4255 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4256
4257 if (p != NULL)
4258 {
4259 if (TEST_OPT_PROT)
4260 {
4261 PrintS("Z");
4262 }
4263#ifdef KDEBUG
4264 if (TEST_OPT_DEBUG)
4265 {
4266 PrintS("--- create zero spoly: ");
4267 p_wrp(h,currRing,strat->tailRing);
4268 PrintS(" ---> ");
4269 }
4270#endif
4271 poly tmp = pInit();
4273 for (int i = 1; i <= rVar(currRing); i++)
4274 {
4275 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4276 }
4278 {
4280 }
4282 p = p_LmFreeAndNext(p, strat->tailRing);
4283 pNext(tmp) = p;
4284 LObject Lp;
4285 Lp.Init();
4286 Lp.p = tmp;
4287 Lp.tailRing = strat->tailRing;
4288 int posx;
4289 if (Lp.p!=NULL)
4290 {
4291 strat->initEcart(&Lp);
4292 if (strat->Ll==-1)
4293 posx =0;
4294 else
4295 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4296 Lp.sev = pGetShortExpVector(Lp.p);
4297 if (strat->tailRing != currRing)
4298 {
4299 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4300 }
4301#ifdef KDEBUG
4302 if (TEST_OPT_DEBUG)
4303 {
4304 p_wrp(tmp,currRing,strat->tailRing);
4305 PrintLn();
4306 }
4307#endif
4308 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4309 }
4310 }
4311 }
4312 nDelete(&zero);
4313 nDelete(&gcd);
4314}
int Lmax
Definition kutil.h:352
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:667
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:682
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:541
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:959
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1269
#define __p_GetComp(p, r)
Definition monomials.h:63
#define rRing_has_Comp(r)
Definition monomials.h:266
#define __pp_Mult_nn(p, n, r)
Definition p_polys.h:1004
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static poly p_LmFreeAndNext(poly p, ring)
Definition p_polys.h:713
#define p_Test(p, r)
Definition p_polys.h:161
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
#define pSetExp(p, i, v)
Definition polys.h:43
int gcd(int a, int b)

◆ enterExtendedSpolySig()

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

Definition at line 4316 of file kutil.cc.

4317{
4318 if (nIsOne(pGetCoeff(h))) return;
4319 number gcd;
4320 number zero=n_Init(0,currRing->cf);
4321 bool go = false;
4322 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4323 {
4324 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4325 go = true;
4326 }
4327 else
4328 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4329 if (go || !nIsOne(gcd))
4330 {
4331 poly p = h->next;
4332 if (!go)
4333 {
4334 number tmp = gcd;
4335 gcd = n_Ann(gcd,currRing->cf);
4336 nDelete(&tmp);
4337 }
4338 p_Test(p,strat->tailRing);
4339 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4340
4341 if (p != NULL)
4342 {
4343 if (TEST_OPT_PROT)
4344 {
4345 PrintS("Z");
4346 }
4347#ifdef KDEBUG
4348 if (TEST_OPT_DEBUG)
4349 {
4350 PrintS("--- create zero spoly: ");
4351 p_wrp(h,currRing,strat->tailRing);
4352 PrintS(" ---> ");
4353 }
4354#endif
4355 poly tmp = pInit();
4357 for (int i = 1; i <= rVar(currRing); i++)
4358 {
4359 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4360 }
4362 {
4364 }
4366 p = p_LmFreeAndNext(p, strat->tailRing);
4367 pNext(tmp) = p;
4368 LObject Lp;
4369 Lp.Init();
4370 Lp.p = tmp;
4371 //printf("\nOld\n");pWrite(h);pWrite(hSig);
4372 #if EXT_POLY_NEW
4373 Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4374 if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4375 {
4376 strat->sigdrop = TRUE;
4377 //Try to reduce it as far as we can via redRing
4378 int red_result = redRing(&Lp,strat);
4379 if(red_result == 0)
4380 {
4381 // Cancel the sigdrop
4382 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4383 strat->sigdrop = FALSE;
4384 }
4385 else
4386 {
4387 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4388 #if 1
4389 strat->enterS(Lp,0,strat,strat->tl);
4390 #endif
4391 }
4392 nDelete(&zero);
4393 nDelete(&gcd);
4394 return;
4395 }
4396 #else
4397 Lp.sig = pOne();
4398 if(strat->Ll >= 0)
4399 p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4400 else
4402 #endif
4403 Lp.tailRing = strat->tailRing;
4404 int posx;
4405 if (Lp.p!=NULL)
4406 {
4407 strat->initEcart(&Lp);
4408 if (strat->Ll==-1)
4409 posx =0;
4410 else
4411 posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4412 Lp.sev = pGetShortExpVector(Lp.p);
4413 if (strat->tailRing != currRing)
4414 {
4415 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4416 }
4417#ifdef KDEBUG
4418 if (TEST_OPT_DEBUG)
4419 {
4420 p_wrp(tmp,currRing,strat->tailRing);
4421 PrintLn();
4422 }
4423#endif
4424 //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4425 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4426 }
4427 }
4428 }
4429 nDelete(&gcd);
4430 nDelete(&zero);
4431}
bool sigdrop
Definition kutil.h:359
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:283
int redRing(LObject *h, kStrategy strat)
Definition kstd2.cc:992
#define nIsZero(n)
Definition numbers.h:19

◆ enterL()

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

Definition at line 1269 of file kutil.cc.

1270{
1271 // this should be corrected
1272 assume(p.FDeg == p.pFDeg());
1273
1274 if ((*length)>=0)
1275 {
1276 if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,*LSetmax);
1277 if (at <= (*length))
1278#ifdef ENTER_USE_MEMMOVE
1279 memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1280#else
1281 for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1282#endif
1283 }
1284 else at = 0;
1285 (*set)[at] = p;
1286 (*length)++;
1287}
static void enlargeL(LSet *L, int *length, const int incr)
Definition kutil.cc:668

◆ enterOnePairNormal()

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

Definition at line 1939 of file kutil.cc.

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

◆ enterOnePairShift()

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

Definition at line 12166 of file kutil.cc.

12167{
12168#ifdef CRITERION_DEBUG
12169 if (TEST_OPT_DEBUG)
12170 {
12171 PrintS("Consider pair ("); wrp(q); PrintS(", "); wrp(p); PrintS(")"); PrintLn();
12172 // also write the LMs in separate lines:
12173 poly lmq = pHead(q);
12174 poly lmp = pHead(p);
12175 pSetCoeff(lmq, n_Init(1, currRing->cf));
12176 pSetCoeff(lmp, n_Init(1, currRing->cf));
12177 Print(" %s\n", pString(lmq));
12178 Print(" %s\n", pString(lmp));
12179 pLmDelete(lmq);
12180 pLmDelete(lmp);
12181 }
12182#endif
12183
12184 /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
12185
12186 /* check this Formats: */
12191
12192 /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
12193
12194 int qfromQ = qisFromQ;
12195
12196 /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */
12197
12198 int l,j,compare;
12199 LObject Lp;
12200 Lp.i_r = -1;
12201
12202#ifdef KDEBUG
12203 Lp.ecart=0; Lp.length=0;
12204#endif
12205 /*- computes the lcm(s[i],p) -*/
12206 Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
12207
12208 /* the V criterion */
12209 if (!pmIsInV(Lp.lcm))
12210 {
12211 strat->cv++; // counter for applying the V criterion
12212 pLmFree(Lp.lcm);
12213#ifdef CRITERION_DEBUG
12214 if (TEST_OPT_DEBUG) PrintS("--- V crit\n");
12215#endif
12216 return TRUE;
12217 }
12218
12219 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
12220 {
12221 if((!((ecartq>0)&&(ecart>0)))
12222 && pHasNotCF(p,q))
12223 {
12224 /*
12225 *the product criterion has applied for (s,p),
12226 *i.e. lcm(s,p)=product of the leading terms of s and p.
12227 *Suppose (s,r) is in L and the leading term
12228 *of p divides lcm(s,r)
12229 *(==> the leading term of p divides the leading term of r)
12230 *but the leading term of s does not divide the leading term of r
12231 *(notice that this condition is automatically satisfied if r is still
12232 *in S), then (s,r) can be cancelled.
12233 *This should be done here because the
12234 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12235 *
12236 *Moreover, skipping (s,r) holds also for the noncommutative case.
12237 */
12238 strat->cp++;
12239 pLmFree(Lp.lcm);
12240#ifdef CRITERION_DEBUG
12241 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12242#endif
12243 return TRUE;
12244 }
12245 else
12246 Lp.ecart = si_max(ecart,ecartq);
12247 if (strat->fromT && (ecartq>ecart))
12248 {
12249 pLmFree(Lp.lcm);
12250#ifdef CRITERION_DEBUG
12251 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12252#endif
12253 return TRUE;
12254 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12255 }
12256 /*
12257 *the set B collects the pairs of type (S[j],p)
12258 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12259 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12260 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12261 */
12262 {
12263 j = strat->Bl;
12264 loop
12265 {
12266 if (j < 0) break;
12267 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12268 if ((compare==1)
12269 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
12270 {
12271 strat->c3++;
12272 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12273 {
12274 pLmFree(Lp.lcm);
12275#ifdef CRITERION_DEBUG
12276 if (TEST_OPT_DEBUG)
12277 {
12278 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12279 }
12280#endif
12281 return TRUE;
12282 }
12283 break;
12284 }
12285 else
12286 if ((compare ==-1)
12287 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
12288 {
12289#ifdef CRITERION_DEBUG
12290 if (TEST_OPT_DEBUG)
12291 {
12292 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12293 }
12294#endif
12295 deleteInL(strat->B,&strat->Bl,j,strat);
12296 strat->c3++;
12297 }
12298 j--;
12299 }
12300 }
12301 }
12302 else /*sugarcrit*/
12303 {
12304 if (ALLOW_PROD_CRIT(strat))
12305 {
12306 // if currRing->nc_type!=quasi (or skew)
12307 // TODO: enable productCrit for super commutative algebras...
12308 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
12309 pHasNotCF(p,q))
12310 {
12311 /*
12312 *the product criterion has applied for (s,p),
12313 *i.e. lcm(s,p)=product of the leading terms of s and p.
12314 *Suppose (s,r) is in L and the leading term
12315 *of p divides lcm(s,r)
12316 *(==> the leading term of p divides the leading term of r)
12317 *but the leading term of s does not divide the leading term of r
12318 *(notice that tis condition is automatically satisfied if r is still
12319 *in S), then (s,r) can be canceled.
12320 *This should be done here because the
12321 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
12322 */
12323 strat->cp++;
12324 pLmFree(Lp.lcm);
12325#ifdef CRITERION_DEBUG
12326 if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
12327#endif
12328 return TRUE;
12329 }
12330 if (strat->fromT && (ecartq>ecart))
12331 {
12332 pLmFree(Lp.lcm);
12333#ifdef CRITERION_DEBUG
12334 if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
12335#endif
12336 return TRUE;
12337 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
12338 }
12339 /*
12340 *the set B collects the pairs of type (S[j],p)
12341 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
12342 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
12343 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
12344 */
12345 for(j = strat->Bl;j>=0;j--)
12346 {
12347 compare=pLPDivComp(strat->B[j].lcm,Lp.lcm);
12348 if (compare==1)
12349 {
12350 strat->c3++;
12351 if ((strat->fromQ==NULL) || (isFromQ==0) || (qfromQ==0))
12352 {
12353 pLmFree(Lp.lcm);
12354#ifdef CRITERION_DEBUG
12355 if (TEST_OPT_DEBUG)
12356 {
12357 Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12358 }
12359#endif
12360 return TRUE;
12361 }
12362 break;
12363 }
12364 else
12365 if (compare ==-1)
12366 {
12367#ifdef CRITERION_DEBUG
12368 if (TEST_OPT_DEBUG)
12369 {
12370 Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
12371 }
12372#endif
12373 deleteInL(strat->B,&strat->Bl,j,strat);
12374 strat->c3++;
12375 }
12376 }
12377 }
12378 }
12379 /*
12380 *the pair (S[i],p) enters B if the spoly != 0
12381 */
12382 /*- compute the short s-polynomial -*/
12383 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
12384 pNorm(p);
12385 if ((q==NULL) || (p==NULL))
12386 {
12387#ifdef CRITERION_DEBUG
12388 if (TEST_OPT_DEBUG) PrintS("--- q == NULL || p == NULL\n");
12389#endif
12390 return FALSE;
12391 }
12392 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
12393 {
12394 Lp.p=NULL;
12395#ifdef CRITERION_DEBUG
12396 if (TEST_OPT_DEBUG) PrintS("--- pair is from Q\n");
12397#endif
12398 }
12399 else
12400 {
12401// if ( rIsPluralRing(currRing) )
12402// {
12403// if(pHasNotCF(p, q))
12404// {
12405// if(ncRingType(currRing) == nc_lie)
12406// {
12407// // generalized prod-crit for lie-type
12408// strat->cp++;
12409// Lp.p = nc_p_Bracket_qq(pCopy(p),q, currRing);
12410// }
12411// else
12412// if( ALLOW_PROD_CRIT(strat) )
12413// {
12414// // product criterion for homogeneous case in SCA
12415// strat->cp++;
12416// Lp.p = NULL;
12417// }
12418// else
12419// Lp.p = nc_CreateSpoly(q,p,currRing); // ?
12420// }
12421// else Lp.p = nc_CreateSpoly(q,p,currRing);
12422// }
12423// else
12424// {
12425
12426 /* ksCreateShortSpoly needs two Lobject-kind presentations */
12427 /* p is already in this form, so convert q */
12428 Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
12429 // }
12430 }
12431 if (Lp.p == NULL)
12432 {
12433 /*- the case that the s-poly is 0 -*/
12434 // TODO: currently ifromS is only > 0 if called from enterOnePairWithShifts
12435 if (ifromS > 0)
12436 {
12437 if (strat->pairtest==NULL) initPairtest(strat);
12438 strat->pairtest[ifromS] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
12439 strat->pairtest[strat->sl+1] = TRUE;
12440 }
12441 //if (TEST_OPT_DEBUG){Print("!");} // option teach
12442 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12443 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
12444 /*
12445 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
12446 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
12447 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
12448 *term of p divides the lcm(s,r)
12449 *(this canceling should be done here because
12450 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
12451 *the first case is handled in chainCrit
12452 */
12453 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
12454#ifdef CRITERION_DEBUG
12455 if (TEST_OPT_DEBUG) PrintS("--- S-poly = 0\n");
12456#endif
12457 return TRUE;
12458 }
12459 else
12460 {
12461 /*- the pair (S[i],p) enters B -*/
12462 /* both of them should have their LM in currRing and TAIL in tailring */
12463 Lp.p1 = q; // already in the needed form
12464 Lp.p2 = p; // already in the needed form
12465
12466 if ( !rIsPluralRing(currRing) )
12467 pNext(Lp.p) = strat->tail;
12468
12469 /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12470 /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12471 if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
12472 {
12473 Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
12474 Lp.i_r2 = atR;
12475 }
12476 else
12477 {
12478 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12479 Lp.i_r1 = -1;
12480 Lp.i_r2 = -1;
12481 }
12482 strat->initEcartPair(&Lp,q,p,ecartq,ecart);
12483
12485 {
12488 && (Lp.p->coef!=NULL))
12489 nDelete(&(Lp.p->coef));
12490 }
12491
12492 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
12493 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
12494#ifdef CRITERION_DEBUG
12495 if (TEST_OPT_DEBUG) PrintS("+++ Entered pair\n");
12496#endif
12497 }
12498 return FALSE;
12499}
int cv
Definition kutil.h:367
static int pLPDivComp(poly p, poly q)
Definition kutil.cc:225
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition pDebug.cc:105
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition pDebug.cc:74
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
void wrp(poly p)
Definition polys.h:311
char * pString(poly p)
Definition polys.h:307
#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 4487 of file kutil.cc.

4488{
4489 int j=pos;
4490
4492 initenterpairs(h,k,ecart,0,strat, atR);
4493 if ( (!strat->fromT)
4494 && ((strat->syzComp==0)
4495 ||(pGetComp(h)<=strat->syzComp)))
4496 {
4497 unsigned long h_sev = pGetShortExpVector(h);
4498 loop
4499 {
4500 if (j > k) break;
4501 clearS(h,h_sev, &j,&k,strat);
4502 j++;
4503 }
4504 }
4505}
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:3809

◆ enterpairsShift()

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

Definition at line 12950 of file kutil.cc.

12951{
12952 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12953 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
12954 int j=pos;
12955
12956 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
12957 initenterpairsShift(h,k,ecart,0,strat, atR);
12958 if ( (!strat->fromT)
12959 && ((strat->syzComp==0)
12960 ||(pGetComp(h)<=strat->syzComp)))
12961 {
12962 unsigned long h_sev = pGetShortExpVector(h);
12963 loop
12964 {
12965 if (j > k) break;
12966 // TODO this currently doesn't clear all possible elements because of commutative division
12967 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
12968 clearS(h,h_sev, &j,&k,strat);
12969 j++;
12970 }
12971 }
12972}
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:12508

◆ enterpairsSig()

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

Definition at line 4513 of file kutil.cc.

4514{
4515 int j=pos;
4517 initenterpairsSig(h,hSig,hFrom,k,ecart,0,strat, atR);
4518 if ( (!strat->fromT)
4519 && ((strat->syzComp==0)
4520 ||(pGetComp(h)<=strat->syzComp)))
4521 {
4522 unsigned long h_sev = pGetShortExpVector(h);
4523 loop
4524 {
4525 if (j > k) break;
4526 clearS(h,h_sev, &j,&k,strat);
4527 j++;
4528 }
4529 }
4530}
void initenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3874

◆ enterSBba()

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

Definition at line 8787 of file kutil.cc.

8788{
8789 strat->news = TRUE;
8790 /*- puts p to the standardbasis s at position at -*/
8791 if (strat->sl == IDELEMS(strat->Shdl)-1)
8792 {
8793 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
8794 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8795 (IDELEMS(strat->Shdl)+setmaxTinc)
8796 *sizeof(unsigned long));
8797 strat->ecartS = (intset)omReallocSize(strat->ecartS,
8798 IDELEMS(strat->Shdl)*sizeof(int),
8799 (IDELEMS(strat->Shdl)+setmaxTinc)
8800 *sizeof(int));
8801 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
8802 IDELEMS(strat->Shdl)*sizeof(int),
8803 (IDELEMS(strat->Shdl)+setmaxTinc)
8804 *sizeof(int));
8805 if (strat->lenS!=NULL)
8806 strat->lenS=(int*)omRealloc0Size(strat->lenS,
8807 IDELEMS(strat->Shdl)*sizeof(int),
8808 (IDELEMS(strat->Shdl)+setmaxTinc)
8809 *sizeof(int));
8810 if (strat->lenSw!=NULL)
8811 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
8812 IDELEMS(strat->Shdl)*sizeof(wlen_type),
8813 (IDELEMS(strat->Shdl)+setmaxTinc)
8814 *sizeof(wlen_type));
8815 if (strat->fromQ!=NULL)
8816 {
8817 strat->fromQ = (intset)omReallocSize(strat->fromQ,
8818 IDELEMS(strat->Shdl)*sizeof(int),
8819 (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
8820 }
8821 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
8822 IDELEMS(strat->Shdl)+=setmaxTinc;
8823 strat->Shdl->m=strat->S;
8824 }
8825 if (atS <= strat->sl)
8826 {
8827#ifdef ENTER_USE_MEMMOVE
8828 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
8829 (strat->sl - atS + 1)*sizeof(poly));
8830 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
8831 (strat->sl - atS + 1)*sizeof(int));
8832 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
8833 (strat->sl - atS + 1)*sizeof(unsigned long));
8834 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
8835 (strat->sl - atS + 1)*sizeof(int));
8836 if (strat->lenS!=NULL)
8837 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
8838 (strat->sl - atS + 1)*sizeof(int));
8839 if (strat->lenSw!=NULL)
8840 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
8841 (strat->sl - atS + 1)*sizeof(wlen_type));
8842#else
8843 for (i=strat->sl+1; i>=atS+1; i--)
8844 {
8845 strat->S[i] = strat->S[i-1];
8846 strat->ecartS[i] = strat->ecartS[i-1];
8847 strat->sevS[i] = strat->sevS[i-1];
8848 strat->S_2_R[i] = strat->S_2_R[i-1];
8849 }
8850 if (strat->lenS!=NULL)
8851 for (i=strat->sl+1; i>=atS+1; i--)
8852 strat->lenS[i] = strat->lenS[i-1];
8853 if (strat->lenSw!=NULL)
8854 for (i=strat->sl+1; i>=atS+1; i--)
8855 strat->lenSw[i] = strat->lenSw[i-1];
8856#endif
8857 }
8858 if (strat->fromQ!=NULL)
8859 {
8860#ifdef ENTER_USE_MEMMOVE
8861 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
8862 (strat->sl - atS + 1)*sizeof(int));
8863#else
8864 for (i=strat->sl+1; i>=atS+1; i--)
8865 {
8866 strat->fromQ[i] = strat->fromQ[i-1];
8867 }
8868#endif
8869 strat->fromQ[atS]=0;
8870 }
8871
8872 /*- save result -*/
8873 poly pp=p.p;
8874 strat->S[atS] = pp;
8875 if (strat->honey) strat->ecartS[atS] = p.ecart;
8876 if (p.sev == 0)
8877 p.sev = pGetShortExpVector(pp);
8878 else
8879 assume(p.sev == pGetShortExpVector(pp));
8880 strat->sevS[atS] = p.sev;
8881 strat->ecartS[atS] = p.ecart;
8882 strat->S_2_R[atS] = atR;
8883 strat->sl++;
8884}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
char news
Definition kutil.h:399
#define setmaxTinc
Definition kutil.h:35
int * intset
Definition kutil.h:54
#define omReallocSize(addr, o_size, size)
#define omRealloc0Size(addr, o_size, size)
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3776

◆ enterSBbaShift()

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

Definition at line 8887 of file kutil.cc.

8888{
8889 enterSBba(p, atS, strat, atR);
8890
8892 for (int i = maxPossibleShift; i > 0; i--)
8893 {
8894 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
8895 // in `kNF2` because of lazy poly normalizations.
8896 LObject qq(p_Copy(p.p, strat->tailRing));
8897 p_mLPshift(qq.p, i, strat->tailRing);
8898 qq.shift = i;
8899 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
8900 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
8901 enterSBba(qq, atS, strat, -1);
8902 }
8903}
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8787
int p_mLPmaxPossibleShift(poly p, const ring r)
Definition shiftgb.cc:45
void p_mLPshift(poly m, int sh, const ring ri)
Definition shiftop.cc:362

◆ entersets()

void entersets ( LObject  h)

◆ enterSMora()

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

Definition at line 1629 of file kstd1.cc.

1630{
1631 enterSBba(p, atS, strat, atR);
1632 #ifdef KDEBUG
1633 if (TEST_OPT_DEBUG)
1634 {
1635 Print("new s%d:",atS);
1636 p_wrp(p.p,currRing,strat->tailRing);
1637 PrintLn();
1638 }
1639 #endif
1640 HEckeTest(p.p,strat);
1641 if (strat->kAllAxis)
1642 {
1643 if (newHEdge(strat))
1644 {
1645 firstUpdate(strat);
1646 if (TEST_OPT_FINDET)
1647 return;
1648
1649 /*- cuts elements in L above noether and reorders L -*/
1650 updateLHC(strat);
1651 /*- reorders L with respect to posInL -*/
1652 reorderL(strat);
1653 }
1654 }
1655 else if ((strat->kNoether==NULL)
1656 && (TEST_OPT_FASTHC))
1657 {
1658 if (strat->posInLOldFlag)
1659 {
1660 missingAxis(&strat->lastAxis,strat);
1661 if (strat->lastAxis)
1662 {
1663 strat->posInLOld = strat->posInL;
1664 strat->posInLOldFlag = FALSE;
1665 strat->posInL = posInL10;
1666 strat->posInLDependsOnLength = TRUE;
1667 updateL(FALSE,strat);
1668 reorderL(strat);
1669 }
1670 }
1671 else if (strat->lastAxis)
1672 updateL(TRUE,strat);
1673 }
1674}
char posInLOldFlag
Definition kutil.h:381
int lastAxis
Definition kutil.h:356
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:289
char kAllAxis
Definition kutil.h:375
char posInLDependsOnLength
Definition kutil.h:388
static void firstUpdate(kStrategy strat)
Definition kstd1.cc:1566
static void updateL(BOOLEAN searchPP, kStrategy strat)
Definition kstd1.cc:1394
static void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1279
static void updateLHC(kStrategy strat)
Definition kstd1.cc:1474
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1360
static void reorderL(kStrategy strat)
Definition kstd1.cc:1222
void HEckeTest(poly pp, kStrategy strat)
Definition kutil.cc:493
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10402
#define TEST_OPT_FINDET
Definition options.h:113
#define TEST_OPT_FASTHC
Definition options.h:111

◆ enterSMoraNF()

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

Definition at line 1682 of file kstd1.cc.

1683{
1684 enterSBba(p, atS, strat, atR);
1685 if ((!strat->kAllAxis) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat);
1686 if (strat->kAllAxis)
1687 newHEdge(strat);
1688}

◆ enterSSba()

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

Definition at line 8910 of file kutil.cc.

8911{
8912 strat->news = TRUE;
8913 /*- puts p to the standardbasis s at position at -*/
8914 if (strat->sl == IDELEMS(strat->Shdl)-1)
8915 {
8916 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
8917 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8918 (IDELEMS(strat->Shdl)+setmax)
8919 *sizeof(unsigned long));
8920 strat->sevSig = (unsigned long*) omRealloc0Size(strat->sevSig,
8921 IDELEMS(strat->Shdl)*sizeof(unsigned long),
8922 (IDELEMS(strat->Shdl)+setmax)
8923 *sizeof(unsigned long));
8924 strat->ecartS = (intset)omReallocSize(strat->ecartS,
8925 IDELEMS(strat->Shdl)*sizeof(int),
8926 (IDELEMS(strat->Shdl)+setmax)
8927 *sizeof(int));
8928 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
8929 IDELEMS(strat->Shdl)*sizeof(int),
8930 (IDELEMS(strat->Shdl)+setmax)
8931 *sizeof(int));
8932 if (strat->lenS!=NULL)
8933 strat->lenS=(int*)omRealloc0Size(strat->lenS,
8934 IDELEMS(strat->Shdl)*sizeof(int),
8935 (IDELEMS(strat->Shdl)+setmax)
8936 *sizeof(int));
8937 if (strat->lenSw!=NULL)
8938 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
8939 IDELEMS(strat->Shdl)*sizeof(wlen_type),
8940 (IDELEMS(strat->Shdl)+setmax)
8941 *sizeof(wlen_type));
8942 if (strat->fromQ!=NULL)
8943 {
8944 strat->fromQ = (intset)omReallocSize(strat->fromQ,
8945 IDELEMS(strat->Shdl)*sizeof(int),
8946 (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
8947 }
8948 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
8949 pEnlargeSet(&strat->sig,IDELEMS(strat->Shdl),setmax);
8950 IDELEMS(strat->Shdl)+=setmax;
8951 strat->Shdl->m=strat->S;
8952 }
8953 // in a signature-based algorithm the following situation will never
8954 // appear due to the fact that the critical pairs are already sorted
8955 // by increasing signature.
8956 // True. However, in the case of integers we need to put the element
8957 // that caused the signature drop on the first position
8958 if (atS <= strat->sl)
8959 {
8960#ifdef ENTER_USE_MEMMOVE
8961 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
8962 (strat->sl - atS + 1)*sizeof(poly));
8963 memmove(&(strat->sig[atS+1]), &(strat->sig[atS]),
8964 (strat->sl - atS + 1)*sizeof(poly));
8965 memmove(&(strat->sevSig[atS+1]), &(strat->sevSig[atS]),
8966 (strat->sl - atS + 1)*sizeof(unsigned long));
8967 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
8968 (strat->sl - atS + 1)*sizeof(int));
8969 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
8970 (strat->sl - atS + 1)*sizeof(unsigned long));
8971 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
8972 (strat->sl - atS + 1)*sizeof(int));
8973 if (strat->lenS!=NULL)
8974 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
8975 (strat->sl - atS + 1)*sizeof(int));
8976 if (strat->lenSw!=NULL)
8977 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
8978 (strat->sl - atS + 1)*sizeof(wlen_type));
8979#else
8980 for (i=strat->sl+1; i>=atS+1; i--)
8981 {
8982 strat->S[i] = strat->S[i-1];
8983 strat->ecartS[i] = strat->ecartS[i-1];
8984 strat->sevS[i] = strat->sevS[i-1];
8985 strat->S_2_R[i] = strat->S_2_R[i-1];
8986 strat->sig[i] = strat->sig[i-1];
8987 strat->sevSig[i] = strat->sevSig[i-1];
8988 }
8989 if (strat->lenS!=NULL)
8990 for (i=strat->sl+1; i>=atS+1; i--)
8991 strat->lenS[i] = strat->lenS[i-1];
8992 if (strat->lenSw!=NULL)
8993 for (i=strat->sl+1; i>=atS+1; i--)
8994 strat->lenSw[i] = strat->lenSw[i-1];
8995#endif
8996 }
8997 if (strat->fromQ!=NULL)
8998 {
8999#ifdef ENTER_USE_MEMMOVE
9000 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9001 (strat->sl - atS + 1)*sizeof(int));
9002#else
9003 for (i=strat->sl+1; i>=atS+1; i--)
9004 {
9005 strat->fromQ[i] = strat->fromQ[i-1];
9006 }
9007#endif
9008 strat->fromQ[atS]=0;
9009 }
9010
9011 /*- save result -*/
9012 strat->S[atS] = p.p;
9013 strat->sig[atS] = p.sig; // TODO: get the correct signature in here!
9014 if (strat->honey) strat->ecartS[atS] = p.ecart;
9015 if (p.sev == 0)
9016 p.sev = pGetShortExpVector(p.p);
9017 else
9018 assume(p.sev == pGetShortExpVector(p.p));
9019 strat->sevS[atS] = p.sev;
9020 // during the interreduction process of a signature-based algorithm we do not
9021 // compute the signature at this point, but when the whole interreduction
9022 // process finishes, i.e. f5c terminates!
9023 if (p.sig != NULL)
9024 {
9025 if (p.sevSig == 0)
9026 p.sevSig = pGetShortExpVector(p.sig);
9027 else
9028 assume(p.sevSig == pGetShortExpVector(p.sig));
9029 strat->sevSig[atS] = p.sevSig; // TODO: get the correct signature in here!
9030 }
9031 strat->ecartS[atS] = p.ecart;
9032 strat->S_2_R[atS] = atR;
9033 strat->sl++;
9034#ifdef DEBUGF5
9035 int k;
9036 Print("--- LIST S: %d ---\n",strat->sl);
9037 for(k=0;k<=strat->sl;k++)
9038 {
9039 pWrite(strat->sig[k]);
9040 }
9041 PrintS("--- LIST S END ---\n");
9042#endif
9043}
#define setmax
Definition kutil.h:30
void pWrite(poly p)
Definition polys.h:309

◆ enterSyz()

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

Definition at line 9336 of file kutil.cc.

9337{
9338 int i;
9339 strat->newt = TRUE;
9340 if (strat->syzl == strat->syzmax-1)
9341 {
9342 pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9343 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9344 (strat->syzmax)*sizeof(unsigned long),
9345 ((strat->syzmax)+setmax)
9346 *sizeof(unsigned long));
9347 strat->syzmax += setmax;
9348 }
9349 if (atT < strat->syzl)
9350 {
9351#ifdef ENTER_USE_MEMMOVE
9352 memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9353 (strat->syzl-atT+1)*sizeof(poly));
9354 memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9355 (strat->syzl-atT+1)*sizeof(unsigned long));
9356#endif
9357 for (i=strat->syzl; i>=atT+1; i--)
9358 {
9359#ifndef ENTER_USE_MEMMOVE
9360 strat->syz[i] = strat->syz[i-1];
9361 strat->sevSyz[i] = strat->sevSyz[i-1];
9362#endif
9363 }
9364 }
9365 //i = strat->syzl;
9366 i = atT;
9367 //Makes sure the syz saves just the signature
9369 pNext(p.sig) = NULL;
9370 strat->syz[atT] = p.sig;
9371 strat->sevSyz[atT] = p.sevSig;
9372 strat->syzl++;
9373#if F5DEBUG
9374 Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9375 pWrite(strat->syz[atT]);
9376#endif
9377 // recheck pairs in strat->L with new rule and delete correspondingly
9378 int cc = strat->Ll;
9379 while (cc>-1)
9380 {
9381 //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9382 //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);
9383 if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9384 strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9386 || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9387 )
9388 {
9389 //printf("\nYES!\n");
9390 deleteInL(strat->L,&strat->Ll,cc,strat);
9391 }
9392 cc--;
9393 }
9394//#if 1
9395#ifdef DEBUGF5
9396 PrintS("--- Syzygies ---\n");
9397 Print("syzl %d\n",strat->syzl);
9398 Print("syzmax %d\n",strat->syzmax);
9399 PrintS("--------------------------------\n");
9400 for(i=0;i<=strat->syzl-1;i++)
9401 {
9402 Print("%d - ",i);
9403 pWrite(strat->syz[i]);
9404 }
9405 PrintS("--------------------------------\n");
9406#endif
9407}
unsigned long * sevSyz
Definition kutil.h:324
int syzmax
Definition kutil.h:350
int syzl
Definition kutil.h:350
polyset syz
Definition kutil.h:308
char newt
Definition kutil.h:400
#define pLtCmp(p, q)
Definition polys.h:124

◆ enterT()

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

Definition at line 9136 of file kutil.cc.

9137{
9138 int i;
9139
9140#ifdef PDEBUG
9141#ifdef HAVE_SHIFTBBA
9142 if (currRing->isLPring && p.shift > 0)
9143 {
9144 // in this case, the order is not correct. test LM and tail separately
9145 p_LmTest(p.p, currRing);
9146 p_Test(pNext(p.p), currRing);
9147 }
9148 else
9149#endif
9150 {
9151 pp_Test(p.p, currRing, p.tailRing);
9152 }
9153#endif
9154 assume(strat->tailRing == p.tailRing);
9155 // redMoraNF complains about this -- but, we don't really
9156 // need this so far
9157 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9158 assume(!strat->homog || (p.FDeg == p.pFDeg()));
9159 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9160
9161#ifdef KDEBUG
9162 // do not put an LObject twice into T:
9163 for(i=strat->tl;i>=0;i--)
9164 {
9165 if (p.p==strat->T[i].p)
9166 {
9167 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9168 return;
9169 }
9170 }
9171#endif
9172
9173#ifdef HAVE_TAIL_RING
9174 if (currRing!=strat->tailRing)
9175 {
9176 p.t_p=p.GetLmTailRing();
9177 }
9178#endif
9179 strat->newt = TRUE;
9180 if (atT < 0)
9181 atT = strat->posInT(strat->T, strat->tl, p);
9182 if (strat->tl == strat->tmax-1)
9183 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,strat->tmax);
9184 if (atT <= strat->tl)
9185 {
9186#ifdef ENTER_USE_MEMMOVE
9187 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9188 (strat->tl-atT+1)*sizeof(TObject));
9189 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9190 (strat->tl-atT+1)*sizeof(unsigned long));
9191#endif
9192 for (i=strat->tl+1; i>=atT+1; i--)
9193 {
9194#ifndef ENTER_USE_MEMMOVE
9195 strat->T[i] = strat->T[i-1];
9196 strat->sevT[i] = strat->sevT[i-1];
9197#endif
9198 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9199 }
9200 }
9201
9202 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9203 {
9204#ifdef HAVE_SHIFTBBA
9205 // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9206 if (!(currRing->isLPring && p.shift > 0))
9207#endif
9208 {
9210 (strat->tailRing != NULL ?
9211 strat->tailRing : currRing),
9212 strat->tailBin);
9213 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9214 }
9215 }
9216 strat->T[atT] = (TObject) p;
9217 //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9218
9219 if ((pNext(p.p) != NULL) && (!rIsLPRing(currRing)))
9220 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9221 else
9222 strat->T[atT].max_exp = NULL;
9223
9224 strat->tl++;
9225 strat->R[strat->tl] = &(strat->T[atT]);
9226 strat->T[atT].i_r = strat->tl;
9227 assume((p.sev == 0) || (pGetShortExpVector(p.p) == p.sev));
9228 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9229 kTest_T(&(strat->T[atT]),strat);
9230}
int tmax
Definition kutil.h:351
omBin tailBin
Definition kutil.h:346
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition kutil.cc:536
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition kutil.cc:789
#define pp_Test(p, lmRing, tailRing)
Definition p_polys.h:163
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition p_polys.h:930
#define p_LmTest(p, r)
Definition p_polys.h:162
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition ring.h:726

◆ enterT_strong()

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

Definition at line 9235 of file kutil.cc.

9236{
9238 int i;
9239
9240 pp_Test(p.p, currRing, p.tailRing);
9241 assume(strat->tailRing == p.tailRing);
9242 // redMoraNF complains about this -- but, we don't really
9243 // need this so far
9244 assume(p.pLength == 0 || (int)pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9245 assume(p.FDeg == p.pFDeg());
9246 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9247
9248#ifdef KDEBUG
9249 // do not put an LObject twice into T:
9250 for(i=strat->tl;i>=0;i--)
9251 {
9252 if (p.p==strat->T[i].p)
9253 {
9254 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9255 return;
9256 }
9257 }
9258#endif
9259
9260#ifdef HAVE_TAIL_RING
9261 if (currRing!=strat->tailRing)
9262 {
9263 p.t_p=p.GetLmTailRing();
9264 }
9265#endif
9266 strat->newt = TRUE;
9267 if (atT < 0)
9268 atT = strat->posInT(strat->T, strat->tl, p);
9269 if (strat->tl == strat->tmax-1)
9270 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,strat->tmax);
9271 if (atT <= strat->tl)
9272 {
9273#ifdef ENTER_USE_MEMMOVE
9274 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9275 (strat->tl-atT+1)*sizeof(TObject));
9276 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9277 (strat->tl-atT+1)*sizeof(unsigned long));
9278#endif
9279 for (i=strat->tl+1; i>=atT+1; i--)
9280 {
9281#ifndef ENTER_USE_MEMMOVE
9282 strat->T[i] = strat->T[i-1];
9283 strat->sevT[i] = strat->sevT[i-1];
9284#endif
9285 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9286 }
9287 }
9288
9289 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9290 {
9292 (strat->tailRing != NULL ?
9293 strat->tailRing : currRing),
9294 strat->tailBin);
9295 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9296 }
9297 strat->T[atT] = (TObject) p;
9298 //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9299
9300 if (pNext(p.p) != NULL)
9301 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9302 else
9303 strat->T[atT].max_exp = NULL;
9304
9305 strat->tl++;
9306 strat->R[strat->tl] = &(strat->T[atT]);
9307 strat->T[atT].i_r = strat->tl;
9308 assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9309 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9310 #if 1
9312 && !n_IsUnit(p.p->coef, currRing->cf))
9313 {
9314 for(i=strat->tl;i>=0;i--)
9315 {
9316 if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9317 {
9318 enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9319 }
9320 }
9321 }
9322 /*
9323 printf("\nThis is T:\n");
9324 for(i=strat->tl;i>=0;i--)
9325 {
9326 pWrite(strat->T[i].p);
9327 }
9328 //getchar();*/
9329 #endif
9330 kTest_T(&(strat->T[atT]),strat);
9331}
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:521
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition kutil.cc:1538
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition polys.h:141

◆ enterTShift()

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

Definition at line 12980 of file kutil.cc.

12981{
12982 /* determine how many elements we have to insert */
12983 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
12984 /* hence, a total number of elt's to add is: */
12985 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
12986 pAssume(p.p != NULL);
12987
12989
12990 for (int i = 1; i <= maxPossibleShift; i++)
12991 {
12992 LObject qq;
12993 qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
12994 qq.shift = i;
12995 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
12996
12997 enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
12998 }
12999}
#define pAssume(cond)
Definition monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 9831 of file kutil.cc.

9832{
9833 /*- release temp data -*/
9834 cleanT(strat);
9835 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
9836 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
9837 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
9838 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
9839 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
9840 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
9841 /*- set L: should be empty -*/
9842 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
9843 /*- set B: should be empty -*/
9844 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
9845 pLmFree(&strat->tail);
9846 strat->syzComp=0;
9847
9848#ifdef HAVE_SHIFTBBA
9849 if (rIsLPRing(currRing) && strat->rightGB)
9850 {
9851 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
9852 strat->fromQ=NULL;
9853 }
9854#endif
9855}

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10034 of file kutil.cc.

10035{
10036 /*- release temp data -*/
10038 cleanTSbaRing(strat);
10039 else
10040 cleanT(strat);
10041 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10042 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10043 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10044 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10045 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10046 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10047 if(strat->syzmax>0)
10048 {
10049 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10050 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10051 if (strat->sbaOrder == 1)
10052 {
10053 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10054 }
10055 }
10056 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10057 /*- set L: should be empty -*/
10058 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10059 /*- set B: should be empty -*/
10060 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10061 /*- set sig: no need for the signatures anymore -*/
10062 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10063 pLmDelete(&strat->tail);
10064 strat->syzComp=0;
10065}
int syzidxmax
Definition kutil.h:350
intset syzIdx
Definition kutil.h:314
unsigned sbaOrder
Definition kutil.h:317
void cleanTSbaRing(kStrategy strat)
Definition kutil.cc:616

◆ f5c()

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

Definition at line 4281 of file kstd2.cc.

4284{
4285 int Ll_old, red_result = 1;
4286 int pos = 0;
4287 hilbeledeg=1;
4288 hilbcount=0;
4289 minimcnt=0;
4290 srmax = 0; // strat->sl is 0 at this point
4291 reduc = olddeg = lrmax = 0;
4292 // we cannot use strat->T anymore
4293 //cleanT(strat);
4294 //strat->tl = -1;
4295 Ll_old = strat->Ll;
4296 while (strat->tl >= 0)
4297 {
4298 if(!strat->T[strat->tl].is_redundant)
4299 {
4300 LObject h;
4301 h.p = strat->T[strat->tl].p;
4302 h.tailRing = strat->T[strat->tl].tailRing;
4303 h.t_p = strat->T[strat->tl].t_p;
4304 if (h.p!=NULL)
4305 {
4306 if (currRing->OrdSgn==-1)
4307 {
4308 cancelunit(&h);
4309 deleteHC(&h, strat);
4310 }
4311 if (h.p!=NULL)
4312 {
4314 {
4315 h.pCleardenom(); // also does remove Content
4316 }
4317 else
4318 {
4319 h.pNorm();
4320 }
4321 strat->initEcart(&h);
4323 pos = posInLF5CRing(strat->L, Ll_old+1,strat->Ll,&h,strat);
4324 else
4325 pos = strat->Ll+1;
4326 h.sev = pGetShortExpVector(h.p);
4327 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
4328 }
4329 }
4330 }
4331 strat->tl--;
4332 }
4333 strat->sl = -1;
4334#if 0
4335//#ifdef HAVE_TAIL_RING
4336 if(!rField_is_Ring()) // create strong gcd poly computes with tailring and S[i] ->to be fixed
4338#endif
4339 //enterpairs(pOne(),0,0,-1,strat,strat->tl);
4340 //strat->sl = -1;
4341 /* picks the last element from the lazyset L */
4342 while (strat->Ll>Ll_old)
4343 {
4344 strat->P = strat->L[strat->Ll];
4345 strat->Ll--;
4346//#if 1
4347#ifdef DEBUGF5
4348 PrintS("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
4349 PrintS("-------------------------------------------------\n");
4350 pWrite(pHead(strat->P.p));
4351 pWrite(pHead(strat->P.p1));
4352 pWrite(pHead(strat->P.p2));
4353 printf("%d\n",strat->tl);
4354 PrintS("-------------------------------------------------\n");
4355#endif
4356 if (pNext(strat->P.p) == strat->tail)
4357 {
4358 // deletes the short spoly
4360 pLmDelete(strat->P.p);
4361 else
4362 pLmFree(strat->P.p);
4363
4364 // TODO: needs some masking
4365 // TODO: masking needs to vanish once the signature
4366 // stuff is completely implemented
4367 strat->P.p = NULL;
4368 poly m1 = NULL, m2 = NULL;
4369
4370 // check that spoly creation is ok
4371 while (strat->tailRing != currRing &&
4372 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
4373 {
4374 assume(m1 == NULL && m2 == NULL);
4375 // if not, change to a ring where exponents are at least
4376 // large enough
4377 if (!kStratChangeTailRing(strat))
4378 {
4379 WerrorS("OVERFLOW...");
4380 break;
4381 }
4382 }
4383 // create the real one
4384 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
4385 strat->tailRing, m1, m2, strat->R);
4386 }
4387 else if (strat->P.p1 == NULL)
4388 {
4389 if (strat->minim > 0)
4390 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
4391 // for input polys, prepare reduction
4393 strat->P.PrepareRed(strat->use_buckets);
4394 }
4395
4396 if (strat->P.p == NULL && strat->P.t_p == NULL)
4397 {
4398 red_result = 0;
4399 }
4400 else
4401 {
4402 if (TEST_OPT_PROT)
4403 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
4404 &olddeg,&reduc,strat, red_result);
4405
4406#ifdef DEBUGF5
4407 PrintS("Poly before red: ");
4408 pWrite(strat->P.p);
4409#endif
4410 /* complete reduction of the element chosen from L */
4411 red_result = strat->red2(&strat->P,strat);
4412 if (errorreported) break;
4413 }
4414
4415 if (strat->overflow)
4416 {
4417 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
4418 }
4419
4420 // reduction to non-zero new poly
4421 if (red_result == 1)
4422 {
4423 // get the polynomial (canonicalize bucket, make sure P.p is set)
4424 strat->P.GetP(strat->lmBin);
4425 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
4426 // but now, for entering S, T, we reset it
4427 // in the inhomogeneous case: FDeg == pFDeg
4428 if (strat->homog) strat->initEcart(&(strat->P));
4429
4430 /* statistic */
4431 if (TEST_OPT_PROT) PrintS("s");
4432 int pos;
4433 #if 1
4435 pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4436 else
4437 pos = posInSMonFirst(strat,strat->sl,strat->P.p);
4438 #else
4439 pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
4440 #endif
4441 // reduce the tail and normalize poly
4442 // in the ring case we cannot expect LC(f) = 1,
4443#if F5CTAILRED
4444 BOOLEAN withT = TRUE;
4446 {
4447 strat->P.pCleardenom();
4449 {
4450 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4451 strat->P.pCleardenom();
4452 }
4453 }
4454 else
4455 {
4456 strat->P.pNorm();
4458 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
4459 }
4460#endif
4461#ifdef KDEBUG
4462 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
4463#endif /* KDEBUG */
4464
4465 // min_std stuff
4466 if ((strat->P.p1==NULL) && (strat->minim>0))
4467 {
4468 if (strat->minim==1)
4469 {
4470 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
4471 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4472 }
4473 else
4474 {
4475 strat->M->m[minimcnt]=strat->P.p2;
4476 strat->P.p2=NULL;
4477 }
4478 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
4479 pNext(strat->M->m[minimcnt])
4480 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
4481 strat->tailRing, currRing,
4482 currRing->PolyBin);
4483 minimcnt++;
4484 }
4485
4486 // enter into S, L, and T
4487 // here we need to recompute new signatures, but those are trivial ones
4488 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
4489 {
4490 enterT(strat->P, strat);
4491 // posInS only depends on the leading term
4492 strat->enterS(strat->P, pos, strat, strat->tl);
4493//#if 1
4494#ifdef DEBUGF5
4495 PrintS("ELEMENT ADDED TO GCURR DURING INTERRED: ");
4496 pWrite(pHead(strat->S[strat->sl]));
4497 pWrite(strat->sig[strat->sl]);
4498#endif
4499 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
4500 }
4501 // Print("[%d]",hilbeledeg);
4502 kDeleteLcm(&strat->P);
4503 if (strat->sl>srmax) srmax = strat->sl;
4504 }
4505 else
4506 {
4507 // adds signature of the zero reduction to
4508 // strat->syz. This is the leading term of
4509 // syzygy and can be used in syzCriterion()
4510 // the signature is added if and only if the
4511 // pair was not detected by the rewritten criterion in strat->red = redSig
4512 if (strat->P.p1 == NULL && strat->minim > 0)
4513 {
4514 p_Delete(&strat->P.p2, currRing, strat->tailRing);
4515 }
4516 }
4517
4518#ifdef KDEBUG
4519 strat->P.Init();
4520#endif /* KDEBUG */
4521 }
4522 int cc = 0;
4523 while (cc<strat->tl+1)
4524 {
4525 strat->T[cc].sig = pOne();
4526 p_SetComp(strat->T[cc].sig,cc+1,currRing);
4527 strat->T[cc].sevSig = pGetShortExpVector(strat->T[cc].sig);
4528 strat->sig[cc] = strat->T[cc].sig;
4529 strat->sevSig[cc] = strat->T[cc].sevSig;
4530 strat->T[cc].is_sigsafe = TRUE;
4531 cc++;
4532 }
4533 strat->max_lower_index = strat->tl;
4534 // set current signature index of upcoming iteration step
4535 // NOTE: this needs to be set here, as otherwise initSyzRules cannot compute
4536 // the corresponding syzygy rules correctly
4537 strat->currIdx = cc+1;
4538 for (int cd=strat->Ll; cd>=0; cd--)
4539 {
4540 p_SetComp(strat->L[cd].sig,cc+1,currRing);
4541 cc++;
4542 }
4543 for (cc=strat->sl+1; cc<IDELEMS(strat->Shdl); ++cc)
4544 strat->Shdl->m[cc] = NULL;
4545 #if 0
4546 printf("\nAfter f5c sorting\n");
4547 for(int i=0;i<=strat->sl;i++)
4548 pWrite(pHead(strat->S[i]));
4549 getchar();
4550 #endif
4551//#if 1
4552#if DEBUGF5
4553 PrintS("------------------- STRAT S ---------------------\n");
4554 cc = 0;
4555 while (cc<strat->tl+1)
4556 {
4557 pWrite(pHead(strat->S[cc]));
4558 pWrite(strat->sig[cc]);
4559 printf("- - - - - -\n");
4560 cc++;
4561 }
4562 PrintS("-------------------------------------------------\n");
4563 PrintS("------------------- STRAT T ---------------------\n");
4564 cc = 0;
4565 while (cc<strat->tl+1)
4566 {
4567 pWrite(pHead(strat->T[cc].p));
4568 pWrite(strat->T[cc].sig);
4569 printf("- - - - - -\n");
4570 cc++;
4571 }
4572 PrintS("-------------------------------------------------\n");
4573 PrintS("------------------- STRAT L ---------------------\n");
4574 cc = 0;
4575 while (cc<strat->Ll+1)
4576 {
4577 pWrite(pHead(strat->L[cc].p));
4578 pWrite(pHead(strat->L[cc].p1));
4579 pWrite(pHead(strat->L[cc].p2));
4580 pWrite(strat->L[cc].sig);
4581 printf("- - - - - -\n");
4582 cc++;
4583 }
4584 PrintS("-------------------------------------------------\n");
4585 printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx);
4586#endif
4587
4588}
CanonicalForm cd(bCommonDen(FF))
Definition cfModGcd.cc:4097
int currIdx
Definition kutil.h:318
int(* red2)(LObject *L, kStrategy strat)
Definition kutil.h:280
int max_lower_index
Definition kutil.h:319
int posInSMonFirst(const kStrategy strat, const int length, const poly p)
Definition kutil.cc:4764
int posInLF5CRing(const LSet set, int start, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5875
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365

◆ faugereRewCriterion()

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

Definition at line 6559 of file kutil.cc.

6560{
6561 //printf("Faugere Rewritten Criterion\n");
6563 return FALSE;
6564//#if 1
6565#ifdef DEBUGF5
6566 PrintS("rewritten criterion checks: ");
6567 pWrite(sig);
6568#endif
6569 for(int k = strat->sl; k>=start; k--)
6570 {
6571//#if 1
6572#ifdef DEBUGF5
6573 PrintS("checking with: ");
6574 pWrite(strat->sig[k]);
6575 pWrite(pHead(strat->S[k]));
6576#endif
6577 if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6578 {
6579//#if 1
6580#ifdef DEBUGF5
6581 PrintS("DELETE!\n");
6582#endif
6583 strat->nrrewcrit++;
6584 return TRUE;
6585 }
6586 //k--;
6587 }
6588#ifdef DEBUGF5
6589 PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6590 for(int kk = 0; kk<strat->sl+1; kk++)
6591 {
6592 pWrite(pHead(strat->S[kk]));
6593 }
6594 PrintS("------------------------------\n");
6595#endif
6596 return FALSE;
6597}
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 10870 of file kutil.cc.

10871{
10872 assume(strat->tl<0); /* can only be called with no elements in T:
10873 i.e. after exitBuchMora */
10874 /* do not use strat->S, strat->sl as they may be out of sync*/
10875 if(!nCoeff_is_Z(currRing->cf))
10876 return;
10877 poly p,pp;
10878 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
10879 {
10880 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
10881 {
10882 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
10883 {
10884 if((i != j) && (strat->Shdl->m[i] != NULL))
10885 {
10886 p = strat->Shdl->m[i];
10887 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
10888#if HAVE_SHIFTBBA
10889 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
10890#endif
10891 ))
10892 {
10893 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
10894 if (!nEqual(dummy,p->coef))
10895 {
10896 if (nIsZero(dummy))
10897 {
10898 nDelete(&dummy);
10899 pLmDelete(&strat->Shdl->m[i]);
10900 p=strat->Shdl->m[i];
10901 }
10902 else
10903 {
10905 break;
10906 }
10907 }
10908 else
10909 {
10910 nDelete(&dummy);
10911 break;
10912 }
10913 }
10914 if (p!=NULL)
10915 {
10916 pp = pNext(p);
10917 while(pp != NULL)
10918 {
10919 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
10920#if HAVE_SHIFTBBA
10921 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
10922#endif
10923 )
10924 {
10925 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
10926 if (!nEqual(dummy,pp->coef))
10927 {
10929 if(nIsZero(pp->coef))
10930 {
10931 pLmDelete(&pNext(p));
10932 pp = pNext(p);
10933 }
10934 else
10935 {
10936 p = pp;
10937 pp = pNext(p);
10938 }
10939 }
10940 else
10941 {
10942 nDelete(&dummy);
10943 p = pp;
10944 pp = pNext(p);
10945 }
10946 }
10947 else
10948 {
10949 p = pp;
10950 pp = pNext(p);
10951 }
10952 }
10953 }
10954 }
10955 }
10956 //idPrint(strat->Shdl);
10957 }
10958 }
10959 idSkipZeroes(strat->Shdl);
10960}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:811
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:631
#define nEqual(n1, n2)
Definition numbers.h:20
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
#define pLPLmDivisibleBy(a, b)
Definition shiftop.h:58
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 493 of file kutil.cc.

494{
495 int j,p;
496
497 if (currRing->pLexOrder
499 || (strat->ak >1)
501 {
502 return;
503 }
505 if (p!=0)
506 strat->NotUsedAxis[p] = FALSE;
507 /*- the leading term of pp is a power of the p-th variable -*/
508 for (j=(currRing->N);j>0; j--)
509 {
510 if (strat->NotUsedAxis[j])
511 {
512 strat->kAllAxis=FALSE;
513 return;
514 }
515 }
516 strat->kAllAxis=TRUE;
517}
BOOLEAN * NotUsedAxis
Definition kutil.h:333
#define pIsPurePower(p)
Definition polys.h:249
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:770

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1690 of file kstd1.cc.

1691{
1692 /* setting global variables ------------------- */
1693 strat->enterS = enterSBba;
1694 strat->red = redHoney;
1695 if (strat->honey)
1696 strat->red = redHoney;
1697 else if (currRing->pLexOrder && !strat->homog)
1698 strat->red = redLazy;
1699 else
1700 {
1701 strat->LazyPass *=4;
1702 strat->red = redHomog;
1703 }
1705 {
1706 if (rField_is_Z(currRing))
1707 strat->red = redRing_Z;
1708 else
1709 strat->red = redRing;
1710 }
1711 if (TEST_OPT_IDLIFT
1712 && (!rIsNCRing(currRing))
1713 && (!rField_is_Ring(currRing)))
1714 strat->red=redLiftstd;
1715 if (currRing->pLexOrder && strat->honey)
1716 strat->initEcart = initEcartNormal;
1717 else
1718 strat->initEcart = initEcartBBA;
1719 if (strat->honey)
1721 else
1723// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1724// {
1725// //interred machen Aenderung
1726// strat->pOrigFDeg=pFDeg;
1727// strat->pOrigLDeg=pLDeg;
1728// //h=ggetid("ecart");
1729// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1730// //{
1731// // ecartWeights=iv2array(IDINTVEC(h));
1732// //}
1733// //else
1734// {
1735// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1736// /*uses automatic computation of the ecartWeights to set them*/
1737// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1738// }
1739// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1740// if (TEST_OPT_PROT)
1741// {
1742// for(i=1; i<=(currRing->N); i++)
1743// Print(" %d",ecartWeights[i]);
1744// PrintLn();
1745// mflush();
1746// }
1747// }
1748}
int LazyPass
Definition kutil.h:354
int redLiftstd(LObject *h, kStrategy strat)
Definition kLiftstd.cc:167
int redRing_Z(LObject *h, kStrategy strat)
Definition kstd2.cc:724
int redHoney(LObject *h, kStrategy strat)
Definition kstd2.cc:2114
int redHomog(LObject *h, kStrategy strat)
Definition kstd2.cc:1154
int redLazy(LObject *h, kStrategy strat)
Definition kstd2.cc:1909
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition kutil.cc:1315
void initEcartNormal(TObject *h)
Definition kutil.cc:1293
void initEcartBBA(TObject *h)
Definition kutil.cc:1301
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition kutil.cc:1308
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427

◆ initBuchMora()

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

Definition at line 9744 of file kutil.cc.

9745{
9746 strat->interpt = BTEST1(OPT_INTERRUPT);
9747 /*- creating temp data structures------------------- -*/
9748 //strat->cp = 0; // already by skStragy()
9749 //strat->c3 = 0; // already by skStragy()
9750#ifdef HAVE_SHIFTBBA
9751 strat->cv = 0; // already by skStragy()
9752#endif
9753 strat->tail = pInit();
9754 /*- set s -*/
9755 strat->sl = -1;
9756 /*- set L -*/
9757 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9758 strat->Ll = -1;
9759 strat->L = initL(strat->Lmax);
9760 /*- set B -*/
9761 strat->Bmax = setmaxL;
9762 strat->Bl = -1;
9763 strat->B = initL();
9764 /*- set T -*/
9765 strat->tl = -1;
9766 strat->tmax = setmaxT;
9767 strat->T = initT();
9768 strat->R = initR();
9769 strat->sevT = initsevT();
9770 /*- init local data struct.---------------------------------------- -*/
9771 //strat->P.ecart=0; // already by skStragy()
9772 //strat->P.length=0; // already by skStragy()
9773 //strat->P.pLength=0; // already by skStragy()
9775 {
9776 if (strat->kNoether!=NULL)
9777 {
9778 pSetComp(strat->kNoether, strat->ak);
9779 pSetComp(strat->kNoetherTail(), strat->ak);
9780 }
9781 }
9783 {
9784 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9785 }
9786 else
9787 {
9788 if(TEST_OPT_SB_1)
9789 {
9790 int i;
9791 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
9792 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9793 {
9794 P->m[i-strat->newIdeal] = F->m[i];
9795 F->m[i] = NULL;
9796 }
9797 initSSpecial(F,Q,P,strat);
9798 for (i=strat->newIdeal;i<IDELEMS(F);i++)
9799 {
9800 F->m[i] = P->m[i-strat->newIdeal];
9801 P->m[i-strat->newIdeal] = NULL;
9802 }
9803 idDelete(&P);
9804 }
9805 else
9806 {
9807 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
9808 // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
9809 }
9810 }
9811 strat->fromT = FALSE;
9813 if ((!TEST_OPT_SB_1)
9815 )
9816 {
9817 updateS(TRUE,strat);
9818 }
9819#ifdef HAVE_SHIFTBBA
9820 if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
9821#endif
9822 {
9823 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
9824 strat->fromQ=NULL;
9825 }
9826 #ifdef KDEBUG
9827 assume(kTest_TS(strat));
9828 #endif
9829}
int newIdeal
Definition kutil.h:357
#define idDelete(H)
delete an ideal
Definition ideals.h:29
KINLINE TSet initT()
Definition kInline.h:84
KINLINE TObject ** initR()
Definition kInline.h:95
KINLINE unsigned long * initsevT()
Definition kInline.h:100
void initSSpecial(ideal F, ideal Q, ideal P, kStrategy strat)
Definition kutil.cc:8083
void updateS(BOOLEAN toT, kStrategy strat)
Definition kutil.cc:8552
void initSL(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7676
#define setmaxL
Definition kutil.h:31
static LSet initL(int nr=setmaxL)
Definition kutil.h:419
#define setmaxT
Definition kutil.h:34
#define setmaxLinc
Definition kutil.h:32
#define OPT_INTERRUPT
Definition options.h:80
#define BTEST1(a)
Definition options.h:34
#define pSetComp(p, v)
Definition polys.h:39

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9428 of file kutil.cc.

9429{
9432 if (TEST_OPT_SB_1)
9435 {
9437 strat->chainCrit=chainCritRing;
9438 }
9439#ifdef HAVE_RATGRING
9440 if (rIsRatGRing(currRing))
9441 {
9442 strat->chainCrit=chainCritPart;
9443 /* enterOnePairNormal get rational part in it */
9444 }
9445#endif
9446 if (TEST_OPT_IDLIFT
9447 && (strat->syzComp==1)
9448 && (!rIsPluralRing(currRing)))
9450
9452 strat->Gebauer = strat->homog || strat->sugarCrit;
9453 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9454 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9455 strat->pairtest = NULL;
9456 /* always use tailreduction, except:
9457 * - in local rings, - in lex order case, -in ring over extensions */
9459 //if(rHasMixedOrdering(currRing)==2)
9460 //{
9461 // strat->noTailReduction =TRUE;
9462 //}
9463
9464#ifdef HAVE_PLURAL
9465 // and r is plural_ring
9466 // hence this holds for r a rational_plural_ring
9467 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9468 { //or it has non-quasi-comm type... later
9469 strat->sugarCrit = FALSE;
9470 strat->Gebauer = FALSE;
9471 strat->honey = FALSE;
9472 }
9473#endif
9474
9475 // Coefficient ring?
9477 {
9478 strat->sugarCrit = FALSE;
9479 strat->Gebauer = FALSE;
9480 strat->honey = FALSE;
9481 }
9482 #ifdef KDEBUG
9483 if (TEST_OPT_DEBUG)
9484 {
9485 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9486 else PrintS("ideal/module is not homogeneous\n");
9487 }
9488 #endif
9489}
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition kutil.h:292
char z2homog
Definition kutil.h:373
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:291
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:1939
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3445
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:1334
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2221
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3520
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3204
void chainCritRing(poly p, int, kStrategy strat)
Definition kutil.cc:3996
static bool rIsSCA(const ring r)
Definition nc.h:190
#define TEST_OPT_WEIGHTM
Definition options.h:123
#define TEST_OPT_SUGARCRIT
Definition options.h:109
#define TEST_OPT_NOT_SUGAR
Definition options.h:108

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9573 of file kutil.cc.

9574{
9576 {
9577 if (strat->honey)
9578 {
9579 strat->posInL = posInL15;
9580 // ok -- here is the deal: from my experiments for Singular-2-0
9581 // I conclude that that posInT_EcartpLength is the best of
9582 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9583 // see the table at the end of this file
9584 if (TEST_OPT_OLDSTD)
9585 strat->posInT = posInT15;
9586 else
9587 strat->posInT = posInT_EcartpLength;
9588 }
9589 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9590 {
9591 strat->posInL = posInL11;
9592 strat->posInT = posInT11;
9593 }
9594 else if (TEST_OPT_INTSTRATEGY)
9595 {
9596 strat->posInL = posInL11;
9597 strat->posInT = posInT11;
9598 }
9599 else
9600 {
9601 strat->posInL = posInL0;
9602 strat->posInT = posInT0;
9603 }
9604 //if (strat->minim>0) strat->posInL =posInLSpecial;
9605 if (strat->homog)
9606 {
9607 strat->posInL = posInL110;
9608 strat->posInT = posInT110;
9609 }
9610 }
9611 else /* local/mixed ordering */
9612 {
9613 if (strat->homog)
9614 {
9615 strat->posInL = posInL11;
9616 strat->posInT = posInT11;
9617 }
9618 else
9619 {
9620 if ((currRing->order[0]==ringorder_c)
9621 ||(currRing->order[0]==ringorder_C))
9622 {
9623 strat->posInL = posInL17_c;
9624 strat->posInT = posInT17_c;
9625 }
9626 else
9627 {
9628 strat->posInL = posInL17;
9629 strat->posInT = posInT17;
9630 }
9631 }
9632 }
9633 if (strat->minim>0) strat->posInL =posInLSpecial;
9634 // for further tests only
9635 if ((BTEST1(11)) || (BTEST1(12)))
9636 strat->posInL = posInL11;
9637 else if ((BTEST1(13)) || (BTEST1(14)))
9638 strat->posInL = posInL13;
9639 else if ((BTEST1(15)) || (BTEST1(16)))
9640 strat->posInL = posInL15;
9641 else if ((BTEST1(17)) || (BTEST1(18)))
9642 strat->posInL = posInL17;
9643 if (BTEST1(11))
9644 strat->posInT = posInT11;
9645 else if (BTEST1(13))
9646 strat->posInT = posInT13;
9647 else if (BTEST1(15))
9648 strat->posInT = posInT15;
9649 else if ((BTEST1(17)))
9650 strat->posInT = posInT17;
9651 else if ((BTEST1(19)))
9652 strat->posInT = posInT19;
9653 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9654 strat->posInT = posInT1;
9656}
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6055
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5278
int posInT11(const TSet set, const int length, LObject &p)
Definition kutil.cc:4953
int posInT1(const TSet set, const int length, LObject &p)
Definition kutil.cc:4896
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:5146
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4885
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6142
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition kutil.cc:9560
int posInT13(const TSet set, const int length, LObject &p)
Definition kutil.cc:5117
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5611
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6177
int posInT17_c(const TSet set, const int length, LObject &p)
Definition kutil.cc:5384
int posInT15(const TSet set, const int length, LObject &p)
Definition kutil.cc:5184
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5567
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6252
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5029
int posInT19(const TSet set, const int length, LObject &p)
Definition kutil.cc:5510
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6345
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5799
@ ringorder_C
Definition ring.h:74
@ ringorder_c
Definition ring.h:73

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9658 of file kutil.cc.

9659{
9661 {
9662 if (strat->honey)
9663 {
9664 strat->posInL = posInL15Ring;
9665 // ok -- here is the deal: from my experiments for Singular-2-0
9666 // I conclude that that posInT_EcartpLength is the best of
9667 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9668 // see the table at the end of this file
9669 if (TEST_OPT_OLDSTD)
9670 strat->posInT = posInT15Ring;
9671 else
9672 strat->posInT = posInT_EcartpLength;
9673 }
9674 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9675 {
9676 strat->posInL = posInL11Ring;
9677 strat->posInT = posInT11;
9678 }
9679 else if (TEST_OPT_INTSTRATEGY)
9680 {
9681 strat->posInL = posInL11Ring;
9682 strat->posInT = posInT11;
9683 }
9684 else
9685 {
9686 strat->posInL = posInL0Ring;
9687 strat->posInT = posInT0;
9688 }
9689 //if (strat->minim>0) strat->posInL =posInLSpecial;
9690 if (strat->homog)
9691 {
9692 strat->posInL = posInL110Ring;
9693 strat->posInT = posInT110Ring;
9694 }
9695 }
9696 else
9697 {
9698 if (strat->homog)
9699 {
9700 //printf("\nHere 3\n");
9701 strat->posInL = posInL11Ring;
9702 strat->posInT = posInT11Ring;
9703 }
9704 else
9705 {
9706 if ((currRing->order[0]==ringorder_c)
9707 ||(currRing->order[0]==ringorder_C))
9708 {
9709 strat->posInL = posInL17_cRing;
9710 strat->posInT = posInT17_cRing;
9711 }
9712 else
9713 {
9714 strat->posInL = posInL11Ringls;
9715 strat->posInT = posInT17Ring;
9716 }
9717 }
9718 }
9719 if (strat->minim>0) strat->posInL =posInLSpecial;
9720 // for further tests only
9721 if ((BTEST1(11)) || (BTEST1(12)))
9722 strat->posInL = posInL11Ring;
9723 else if ((BTEST1(13)) || (BTEST1(14)))
9724 strat->posInL = posInL13;
9725 else if ((BTEST1(15)) || (BTEST1(16)))
9726 strat->posInL = posInL15Ring;
9727 else if ((BTEST1(17)) || (BTEST1(18)))
9728 strat->posInL = posInL17Ring;
9729 if (BTEST1(11))
9730 strat->posInT = posInT11Ring;
9731 else if (BTEST1(13))
9732 strat->posInT = posInT13;
9733 else if (BTEST1(15))
9734 strat->posInT = posInT15Ring;
9735 else if ((BTEST1(17)))
9736 strat->posInT = posInT17Ring;
9737 else if ((BTEST1(19)))
9738 strat->posInT = posInT19;
9739 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9740 strat->posInT = posInT1;
9742}
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6296
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6409
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5841
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5071
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6096
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5638
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:4989
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5909
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6212
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5238
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5339
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition kutil.cc:5445

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1301 of file kutil.cc.

1302{
1303 h->FDeg = h->pFDeg();
1304 (*h).ecart = 0;
1305 h->length=h->pLength=pLength(h->p);
1306}

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1293 of file kutil.cc.

1294{
1295 h->FDeg = h->pFDeg();
1296 h->ecart = h->pLDeg() - h->FDeg;
1297 // h->length is set by h->pLDeg
1298 h->length=h->pLength=pLength(h->p);
1299}

◆ initEcartPairBba()

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

Definition at line 1308 of file kutil.cc.

1309{
1310 Lp->FDeg = Lp->pFDeg();
1311 (*Lp).ecart = 0;
1312 (*Lp).length = 0;
1313}

◆ initEcartPairMora()

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

Definition at line 1315 of file kutil.cc.

1316{
1317 Lp->FDeg = Lp->pFDeg();
1318 (*Lp).ecart = si_max(ecartF,ecartG);
1319 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1320 (*Lp).length = 0;
1321}
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:382

◆ initenterpairs()

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

Definition at line 3809 of file kutil.cc.

3810{
3811
3812 if ((strat->syzComp==0)
3813 || (pGetComp(h)<=strat->syzComp))
3814 {
3815 int j;
3817
3818 if (pGetComp(h)==0)
3819 {
3820 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3821 if ((isFromQ)&&(strat->fromQ!=NULL))
3822 {
3823 for (j=0; j<=k; j++)
3824 {
3825 if (!strat->fromQ[j])
3826 {
3827 new_pair=TRUE;
3828 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3829 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3830 }
3831 }
3832 }
3833 else
3834 {
3835 new_pair=TRUE;
3836 for (j=0; j<=k; j++)
3837 {
3838 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3839 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3840 }
3841 }
3842 }
3843 else
3844 {
3845 for (j=0; j<=k; j++)
3846 {
3847 if ((pGetComp(h)==pGetComp(strat->S[j]))
3848 || (pGetComp(strat->S[j])==0))
3849 {
3850 new_pair=TRUE;
3851 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3852 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3853 }
3854 }
3855 }
3856 if (new_pair)
3857 {
3858 #ifdef HAVE_RATGRING
3859 if (currRing->real_var_start>0)
3860 chainCritPart(h,ecart,strat);
3861 else
3862 #endif
3863 strat->chainCrit(h,ecart,strat);
3864 }
3865 kMergeBintoL(strat);
3866 }
3867}

◆ initHilbCrit()

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

Definition at line 9410 of file kutil.cc.

9411{
9412
9413 //if the ordering is local, then hilb criterion
9414 //can be used also if the ideal is not homogeneous
9416 {
9418 *hilb=NULL;
9419 else
9420 return;
9421 }
9422 if (strat->homog!=isHomog)
9423 {
9424 *hilb=NULL;
9425 }
9426}
@ isHomog
Definition structs.h:33

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 419 of file kutil.h.

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

◆ initR()

KINLINE TObject ** initR ( )

Definition at line 95 of file kInline.h.

96{
97 return (TObject**) omAlloc0(setmaxT*sizeof(TObject*));
98}
#define omAlloc0(size)

◆ initS()

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

Definition at line 7583 of file kutil.cc.

7584{
7585 int i,pos;
7586
7588 else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7589 if (i<setmaxTinc) i=setmaxT;
7590 strat->ecartS=initec(i);
7591 strat->sevS=initsevS(i);
7592 strat->S_2_R=initS_2_R(i);
7593 strat->fromQ=NULL;
7594 strat->Shdl=idInit(i,F->rank);
7595 strat->S=strat->Shdl->m;
7596 /*- put polys into S -*/
7597 if (Q!=NULL)
7598 {
7599 strat->fromQ=initec(i);
7600 memset(strat->fromQ,0,i*sizeof(int));
7601 for (i=0; i<IDELEMS(Q); i++)
7602 {
7603 if (Q->m[i]!=NULL)
7604 {
7605 LObject h;
7606 h.p = pCopy(Q->m[i]);
7608 {
7609 h.pCleardenom(); // also does remove Content
7610 }
7611 else
7612 {
7613 h.pNorm();
7614 }
7616 {
7617 deleteHC(&h, strat);
7618 }
7619 if (h.p!=NULL)
7620 {
7621 strat->initEcart(&h);
7622 if (strat->sl==-1)
7623 pos =0;
7624 else
7625 {
7626 pos = posInS(strat,strat->sl,h.p,h.ecart);
7627 }
7628 h.sev = pGetShortExpVector(h.p);
7629 strat->enterS(h,pos,strat,-1);
7630 strat->fromQ[pos]=1;
7631 }
7632 }
7633 }
7634 }
7635 for (i=0; i<IDELEMS(F); i++)
7636 {
7637 if (F->m[i]!=NULL)
7638 {
7639 LObject h;
7640 h.p = pCopy(F->m[i]);
7642 {
7643 cancelunit(&h); /*- tries to cancel a unit -*/
7644 deleteHC(&h, strat);
7645 }
7646 if (h.p!=NULL)
7647 // do not rely on the input being a SB!
7648 {
7650 {
7651 h.pCleardenom(); // also does remove Content
7652 }
7653 else
7654 {
7655 h.pNorm();
7656 }
7657 strat->initEcart(&h);
7658 if (strat->sl==-1)
7659 pos =0;
7660 else
7661 pos = posInS(strat,strat->sl,h.p,h.ecart);
7662 h.sev = pGetShortExpVector(h.p);
7663 strat->enterS(h,pos,strat,-1);
7664 }
7665 }
7666 }
7667 /*- test, if a unit is in F -*/
7668 if ((strat->sl>=0)
7669 && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7670 && pIsConstant(strat->S[0]))
7671 {
7672 while (strat->sl>0) deleteInS(strat->sl,strat);
7673 }
7674}
static intset initec(const int maxnr)
Definition kutil.cc:522
static int * initS_2_R(const int maxnr)
Definition kutil.cc:531
static unsigned long * initsevS(const int maxnr)
Definition kutil.cc:527
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239

◆ initSba()

void initSba ( ideal  F,
kStrategy  strat 
)

Definition at line 1750 of file kstd1.cc.

1751{
1752 int i;
1753 //idhdl h;
1754 /* setting global variables ------------------- */
1755 strat->enterS = enterSSba;
1756 strat->red2 = redHoney;
1757 if (strat->honey)
1758 strat->red2 = redHoney;
1759 else if (currRing->pLexOrder && !strat->homog)
1760 strat->red2 = redLazy;
1761 else
1762 {
1763 strat->LazyPass *=4;
1764 strat->red2 = redHomog;
1765 }
1767 {
1769 {strat->red2 = redRiloc;}
1770 else
1771 {strat->red2 = redRing;}
1772 }
1773 if (currRing->pLexOrder && strat->honey)
1774 strat->initEcart = initEcartNormal;
1775 else
1776 strat->initEcart = initEcartBBA;
1777 if (strat->honey)
1779 else
1781 //strat->kIdeal = NULL;
1782 //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1783 //else strat->kIdeal->rtyp=MODUL_CMD;
1784 //strat->kIdeal->data=(void *)strat->Shdl;
1785 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1786 {
1787 //interred machen Aenderung
1788 strat->pOrigFDeg = currRing->pFDeg;
1789 strat->pOrigLDeg = currRing->pLDeg;
1790 //h=ggetid("ecart");
1791 //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1792 //{
1793 // ecartWeights=iv2array(IDINTVEC(h));
1794 //}
1795 //else
1796 {
1797 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1798 /*uses automatic computation of the ecartWeights to set them*/
1800 }
1802 if (TEST_OPT_PROT)
1803 {
1804 for(i=1; i<=(currRing->N); i++)
1805 Print(" %d",ecartWeights[i]);
1806 PrintLn();
1807 mflush();
1808 }
1809 }
1810 // for sig-safe reductions in signature-based
1811 // standard basis computations
1813 strat->red = redSigRing;
1814 else
1815 strat->red = redSig;
1816 //strat->sbaOrder = 1;
1817 strat->currIdx = 1;
1818}
pFDegProc pOrigFDeg
Definition kutil.h:297
pLDegProc pOrigLDeg
Definition kutil.h:298
int redRiloc(LObject *h, kStrategy strat)
Definition kstd1.cc:385
int redSigRing(LObject *h, kStrategy strat)
Definition kstd2.cc:1540
int redSig(LObject *h, kStrategy strat)
Definition kstd2.cc:1373
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8910
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3729
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 9959 of file kutil.cc.

9960{
9961 strat->interpt = BTEST1(OPT_INTERRUPT);
9962 //strat->kNoether=NULL; // done by skStrategy
9963 /*- creating temp data structures------------------- -*/
9964 //strat->cp = 0; // done by skStrategy
9965 //strat->c3 = 0; // done by skStrategy
9966 strat->tail = pInit();
9967 /*- set s -*/
9968 strat->sl = -1;
9969 /*- set ps -*/
9970 strat->syzl = -1;
9971 /*- set L -*/
9972 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
9973 strat->Ll = -1;
9974 strat->L = initL(strat->Lmax);
9975 /*- set B -*/
9976 strat->Bmax = setmaxL;
9977 strat->Bl = -1;
9978 strat->B = initL();
9979 /*- set T -*/
9980 strat->tl = -1;
9981 strat->tmax = setmaxT;
9982 strat->T = initT();
9983 strat->R = initR();
9984 strat->sevT = initsevT();
9985 /*- init local data struct.---------------------------------------- -*/
9986 //strat->P.ecart=0; // done by skStrategy
9987 //strat->P.length=0; // done by skStrategy
9989 {
9990 if (strat->kNoether!=NULL)
9991 {
9992 pSetComp(strat->kNoether, strat->ak);
9993 pSetComp(strat->kNoetherTail(), strat->ak);
9994 }
9995 }
9997 {
9998 /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
9999 }
10000 else
10001 {
10002 if(TEST_OPT_SB_1)
10003 {
10004 int i;
10005 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10006 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10007 {
10008 P->m[i-strat->newIdeal] = F->m[i];
10009 F->m[i] = NULL;
10010 }
10011 initSSpecialSba(F,Q,P,strat);
10012 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10013 {
10014 F->m[i] = P->m[i-strat->newIdeal];
10015 P->m[i-strat->newIdeal] = NULL;
10016 }
10017 idDelete(&P);
10018 }
10019 else
10020 {
10021 initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10022 }
10023 }
10024 //strat->fromT = FALSE; // done by skStrategy
10025 if (!TEST_OPT_SB_1)
10026 {
10027 if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10028 }
10029 //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10030 //strat->fromQ=NULL;
10031 assume(kTest_TS(strat));
10032}
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7776
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition kutil.cc:8231

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9491 of file kutil.cc.

9492{
9493 //strat->enterOnePair=enterOnePairNormal;
9495 //strat->chainCrit=chainCritNormal;
9496 strat->chainCrit = chainCritSig;
9497 /******************************************
9498 * rewCrit1 and rewCrit2 are already set in
9499 * kSba() in kstd1.cc
9500 *****************************************/
9501 //strat->rewCrit1 = faugereRewCriterion;
9502 if (strat->sbaOrder == 1)
9503 {
9504 strat->syzCrit = syzCriterionInc;
9505 }
9506 else
9507 {
9508 strat->syzCrit = syzCriterion;
9509 }
9511 {
9513 strat->chainCrit=chainCritRing;
9514 }
9515#ifdef HAVE_RATGRING
9516 if (rIsRatGRing(currRing))
9517 {
9518 strat->chainCrit=chainCritPart;
9519 /* enterOnePairNormal get rational part in it */
9520 }
9521#endif
9522
9524 strat->Gebauer = strat->homog || strat->sugarCrit;
9525 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9526 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9527 strat->pairtest = NULL;
9528 /* always use tailreduction, except:
9529 * - in local rings, - in lex order case, -in ring over extensions */
9532
9533#ifdef HAVE_PLURAL
9534 // and r is plural_ring
9535 // hence this holds for r a rational_plural_ring
9536 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9537 { //or it has non-quasi-comm type... later
9538 strat->sugarCrit = FALSE;
9539 strat->Gebauer = FALSE;
9540 strat->honey = FALSE;
9541 }
9542#endif
9543
9544 // Coefficient ring?
9546 {
9547 strat->sugarCrit = FALSE;
9548 strat->Gebauer = FALSE ;
9549 strat->honey = FALSE;
9550 }
9551 #ifdef KDEBUG
9552 if (TEST_OPT_DEBUG)
9553 {
9554 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9555 else PrintS("ideal/module is not homogeneous\n");
9556 }
9557 #endif
9558}
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.h:293
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6510
void chainCritSig(poly p, int, kStrategy strat)
Definition kutil.cc:3461
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6475

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 9857 of file kutil.cc.

9858{
9860 {
9861 if (strat->honey)
9862 {
9863 strat->posInL = posInL15;
9864 // ok -- here is the deal: from my experiments for Singular-2-0
9865 // I conclude that that posInT_EcartpLength is the best of
9866 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9867 // see the table at the end of this file
9868 if (TEST_OPT_OLDSTD)
9869 strat->posInT = posInT15;
9870 else
9871 strat->posInT = posInT_EcartpLength;
9872 }
9873 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9874 {
9875 strat->posInL = posInL11;
9876 strat->posInT = posInT11;
9877 }
9878 else if (TEST_OPT_INTSTRATEGY)
9879 {
9880 strat->posInL = posInL11;
9881 strat->posInT = posInT11;
9882 }
9883 else
9884 {
9885 strat->posInL = posInL0;
9886 strat->posInT = posInT0;
9887 }
9888 //if (strat->minim>0) strat->posInL =posInLSpecial;
9889 if (strat->homog)
9890 {
9891 strat->posInL = posInL110;
9892 strat->posInT = posInT110;
9893 }
9894 }
9895 else
9896 {
9897 if (strat->homog)
9898 {
9899 strat->posInL = posInL11;
9900 strat->posInT = posInT11;
9901 }
9902 else
9903 {
9904 if ((currRing->order[0]==ringorder_c)
9905 ||(currRing->order[0]==ringorder_C))
9906 {
9907 strat->posInL = posInL17_c;
9908 strat->posInT = posInT17_c;
9909 }
9910 else
9911 {
9912 strat->posInL = posInL17;
9913 strat->posInT = posInT17;
9914 }
9915 }
9916 }
9917 if (strat->minim>0) strat->posInL =posInLSpecial;
9918 // for further tests only
9919 if ((BTEST1(11)) || (BTEST1(12)))
9920 strat->posInL = posInL11;
9921 else if ((BTEST1(13)) || (BTEST1(14)))
9922 strat->posInL = posInL13;
9923 else if ((BTEST1(15)) || (BTEST1(16)))
9924 strat->posInL = posInL15;
9925 else if ((BTEST1(17)) || (BTEST1(18)))
9926 strat->posInL = posInL17;
9927 if (BTEST1(11))
9928 strat->posInT = posInT11;
9929 else if (BTEST1(13))
9930 strat->posInT = posInT13;
9931 else if (BTEST1(15))
9932 strat->posInT = posInT15;
9933 else if ((BTEST1(17)))
9934 strat->posInT = posInT17;
9935 else if ((BTEST1(19)))
9936 strat->posInT = posInT19;
9937 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9938 strat->posInT = posInT1;
9940 {
9941 strat->posInL = posInL11Ring;
9942 if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
9943 strat->posInL = posInL11Ringls;
9944 strat->posInT = posInT11;
9945 }
9947 strat->posInLSba = posInLSig;
9948 //strat->posInL = posInLSig;
9949 strat->posInL = posInLF5C;
9950 /*
9951 if (rField_is_Ring(currRing))
9952 {
9953 strat->posInLSba = posInLSigRing;
9954 strat->posInL = posInL11Ring;
9955 }*/
9956 //strat->posInT = posInTSig;
9957}
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5669
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition kutil.cc:5787

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

7677{
7678 int i,pos;
7679
7680 if (Q!=NULL)
7681 {
7683 if (i<setmaxTinc) i=setmaxT;
7684 }
7685 else i=setmaxT;
7686 strat->ecartS=initec(i);
7687 strat->sevS=initsevS(i);
7688 strat->S_2_R=initS_2_R(i);
7689 strat->fromQ=NULL;
7690 strat->Shdl=idInit(i,F->rank);
7691 strat->S=strat->Shdl->m;
7692 /*- put polys into S -*/
7693 if (Q!=NULL)
7694 {
7695 strat->fromQ=initec(i);
7696 memset(strat->fromQ,0,i*sizeof(int));
7697 for (i=0; i<IDELEMS(Q); i++)
7698 {
7699 if (Q->m[i]!=NULL)
7700 {
7701 LObject h;
7702 h.p = pCopy(Q->m[i]);
7704 {
7705 deleteHC(&h,strat);
7706 cancelunit(&h); /*- tries to cancel a unit -*/
7707 }
7709 {
7710 h.pCleardenom(); // also does remove Content
7711 }
7712 else
7713 {
7714 h.pNorm();
7715 }
7716 if (h.p!=NULL)
7717 {
7718 strat->initEcart(&h);
7719 if (strat->sl==-1)
7720 pos =0;
7721 else
7722 {
7723 pos = posInS(strat,strat->sl,h.p,h.ecart);
7724 }
7725 h.sev = pGetShortExpVector(h.p);
7726 strat->enterS(h,pos,strat,-1);
7727 strat->fromQ[pos]=1;
7728 }
7729 }
7730 }
7731 }
7732 for (i=0; i<IDELEMS(F); i++)
7733 {
7734 if (F->m[i]!=NULL)
7735 {
7736 LObject h;
7737 h.p = pCopy(F->m[i]);
7738 if (h.p!=NULL)
7739 {
7741 {
7742 cancelunit(&h); /*- tries to cancel a unit -*/
7743 deleteHC(&h, strat);
7744 }
7745 if (h.p!=NULL)
7746 {
7748 {
7749 h.pCleardenom(); // also does remove Content
7750 }
7751 else
7752 {
7753 h.pNorm();
7754 }
7755 strat->initEcart(&h);
7756 if (strat->Ll==-1)
7757 pos =0;
7758 else
7759 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
7760 h.sev = pGetShortExpVector(h.p);
7761 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7762 }
7763 }
7764 }
7765 }
7766 /*- test, if a unit is in F -*/
7767
7768 if ((strat->Ll>=0)
7769 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7770 && pIsConstant(strat->L[strat->Ll].p))
7771 {
7772 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7773 }
7774}

◆ initSLSba()

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

Definition at line 7776 of file kutil.cc.

7777{
7778 int i,pos;
7779 if (Q!=NULL)
7780 {
7782 if (i<setmaxTinc) i=setmaxT;
7783 }
7784 else i=setmaxT;
7785 strat->ecartS = initec(i);
7786 strat->sevS = initsevS(i);
7787 strat->sevSig = initsevS(i);
7788 strat->S_2_R = initS_2_R(i);
7789 strat->fromQ = NULL;
7790 strat->Shdl = idInit(i,F->rank);
7791 strat->S = strat->Shdl->m;
7792 strat->sig = (poly *)omAlloc0(i*sizeof(poly));
7793 if (strat->sbaOrder != 1)
7794 {
7795 strat->syz = (poly *)omAlloc0(i*sizeof(poly));
7796 strat->sevSyz = initsevS(i);
7797 strat->syzmax = i;
7798 strat->syzl = 0;
7799 }
7800 /*- put polys into S -*/
7801 if (Q!=NULL)
7802 {
7803 strat->fromQ=initec(i);
7804 memset(strat->fromQ,0,i*sizeof(int));
7805 for (i=0; i<IDELEMS(Q); i++)
7806 {
7807 if (Q->m[i]!=NULL)
7808 {
7809 LObject h;
7810 h.p = pCopy(Q->m[i]);
7812 {
7813 deleteHC(&h,strat);
7814 }
7816 {
7817 h.pCleardenom(); // also does remove Content
7818 }
7819 else
7820 {
7821 h.pNorm();
7822 }
7823 if (h.p!=NULL)
7824 {
7825 strat->initEcart(&h);
7826 if (strat->sl==-1)
7827 pos =0;
7828 else
7829 {
7830 pos = posInS(strat,strat->sl,h.p,h.ecart);
7831 }
7832 h.sev = pGetShortExpVector(h.p);
7833 strat->enterS(h,pos,strat,-1);
7834 strat->fromQ[pos]=1;
7835 }
7836 }
7837 }
7838 }
7839 for (i=0; i<IDELEMS(F); i++)
7840 {
7841 if (F->m[i]!=NULL)
7842 {
7843 LObject h;
7844 h.p = pCopy(F->m[i]);
7845 h.sig = pOne();
7846 //h.sig = pInit();
7847 //p_SetCoeff(h.sig,nInit(1),currRing);
7848 p_SetComp(h.sig,i+1,currRing);
7849 // if we are working with the Schreyer order we generate it
7850 // by multiplying the initial signatures with the leading monomial
7851 // of the corresponding initial polynomials generating the ideal
7852 // => we can keep the underlying monomial order and get a Schreyer
7853 // order without any bigger overhead
7854 if (strat->sbaOrder == 0 || strat->sbaOrder == 3)
7855 {
7856 p_ExpVectorAdd (h.sig,F->m[i],currRing);
7857 }
7858 h.sevSig = pGetShortExpVector(h.sig);
7859#ifdef DEBUGF5
7860 pWrite(h.p);
7861 pWrite(h.sig);
7862#endif
7863 if (h.p!=NULL)
7864 {
7866 {
7867 cancelunit(&h); /*- tries to cancel a unit -*/
7868 deleteHC(&h, strat);
7869 }
7870 if (h.p!=NULL)
7871 {
7873 {
7874 h.pCleardenom(); // also does remove Content
7875 }
7876 else
7877 {
7878 h.pNorm();
7879 }
7880 strat->initEcart(&h);
7881 if (strat->Ll==-1)
7882 pos =0;
7883 else
7884 pos = strat->posInLSba(strat->L,strat->Ll,&h,strat);
7885 h.sev = pGetShortExpVector(h.p);
7886 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
7887 }
7888 }
7889 /*
7890 if (strat->sbaOrder != 1)
7891 {
7892 for(j=0;j<i;j++)
7893 {
7894 strat->syz[ctr] = pCopy(F->m[j]);
7895 p_SetCompP(strat->syz[ctr],i+1,currRing);
7896 // add LM(F->m[i]) to the signature to get a Schreyer order
7897 // without changing the underlying polynomial ring at all
7898 p_ExpVectorAdd (strat->syz[ctr],F->m[i],currRing);
7899 // since p_Add_q() destroys all input
7900 // data we need to recreate help
7901 // each time
7902 poly help = pCopy(F->m[i]);
7903 p_SetCompP(help,j+1,currRing);
7904 pWrite(strat->syz[ctr]);
7905 pWrite(help);
7906 printf("%d\n",pLmCmp(strat->syz[ctr],help));
7907 strat->syz[ctr] = p_Add_q(strat->syz[ctr],help,currRing);
7908 printf("%d. SYZ ",ctr);
7909 pWrite(strat->syz[ctr]);
7910 strat->sevSyz[ctr] = p_GetShortExpVector(strat->syz[ctr],currRing);
7911 ctr++;
7912 }
7913 strat->syzl = ps;
7914 }
7915 */
7916 }
7917 }
7918 /*- test, if a unit is in F -*/
7919
7920 if ((strat->Ll>=0)
7921 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
7922 && pIsConstant(strat->L[strat->Ll].p))
7923 {
7924 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
7925 }
7926}
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition p_polys.h:1432

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 7928 of file kutil.cc.

7929{
7930 if( strat->S[0] )
7931 {
7932 if( strat->S[1] && !rField_is_Ring(currRing))
7933 {
7934 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
7935 omFreeSize(strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
7936 omFreeSize(strat->syz,(strat->syzmax)*sizeof(poly));
7937 }
7938 int i, j, k, diff, comp, comp_old, ps=0, ctr=0;
7939 /************************************************************
7940 * computing the length of the syzygy array needed
7941 ***********************************************************/
7942 for(i=1; i<=strat->sl; i++)
7943 {
7944 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
7945 {
7946 ps += i;
7947 }
7948 }
7949 ps += strat->sl+1;
7950 //comp = pGetComp (strat->P.sig);
7951 comp = strat->currIdx;
7952 strat->syzIdx = initec(comp);
7953 strat->sevSyz = initsevS(ps);
7954 strat->syz = (poly *)omAlloc(ps*sizeof(poly));
7955 strat->syzmax = ps;
7956 strat->syzl = 0;
7957 strat->syzidxmax = comp;
7958#if defined(DEBUGF5) || defined(DEBUGF51)
7959 PrintS("------------- GENERATING SYZ RULES NEW ---------------\n");
7960#endif
7961 i = 1;
7962 j = 0;
7963 /************************************************************
7964 * generating the leading terms of the principal syzygies
7965 ***********************************************************/
7966 while (i <= strat->sl)
7967 {
7968 /**********************************************************
7969 * principal syzygies start with component index 2
7970 * the array syzIdx starts with index 0
7971 * => the rules for a signature with component comp start
7972 * at strat->syz[strat->syzIdx[comp-2]] !
7973 *********************************************************/
7974 if (pGetComp(strat->sig[i-1]) != pGetComp(strat->sig[i]))
7975 {
7976 comp = pGetComp(strat->sig[i]);
7977 comp_old = pGetComp(strat->sig[i-1]);
7978 diff = comp - comp_old - 1;
7979 // diff should be zero, but sometimes also the initial generating
7980 // elements of the input ideal reduce to zero. then there is an
7981 // index-gap between the signatures. for these in-between signatures we
7982 // can safely set syzIdx[j] = 0 as no such element will be ever computed
7983 // in the following.
7984 // doing this, we keep the relation "j = comp - 2" alive, which makes
7985 // jumps way easier when checking criteria
7986 while (diff>0)
7987 {
7988 strat->syzIdx[j] = 0;
7989 diff--;
7990 j++;
7991 }
7992 strat->syzIdx[j] = ctr;
7993 j++;
7994 LObject Q;
7995 int pos;
7996 for (k = 0; k<i; k++)
7997 {
7998 Q.sig = pOne();
8001 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8002 p_SetCompP (Q.sig, comp, currRing);
8003 poly q = p_One(currRing);
8006 p_ExpVectorCopy(q,strat->S[i],currRing);
8007 q = p_Neg (q, currRing);
8008 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8009 Q.sig = p_Add_q (Q.sig, q, currRing);
8010 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8011 pos = posInSyz(strat, Q.sig);
8012 enterSyz(Q, strat, pos);
8013 ctr++;
8014 }
8015 }
8016 i++;
8017 }
8018 /**************************************************************
8019 * add syzygies for upcoming first element of new iteration step
8020 **************************************************************/
8021 comp = strat->currIdx;
8022 comp_old = pGetComp(strat->sig[i-1]);
8023 diff = comp - comp_old - 1;
8024 // diff should be zero, but sometimes also the initial generating
8025 // elements of the input ideal reduce to zero. then there is an
8026 // index-gap between the signatures. for these in-between signatures we
8027 // can safely set syzIdx[j] = 0 as no such element will be ever computed
8028 // in the following.
8029 // doing this, we keep the relation "j = comp - 2" alive, which makes
8030 // jumps way easier when checking criteria
8031 while (diff>0)
8032 {
8033 strat->syzIdx[j] = 0;
8034 diff--;
8035 j++;
8036 }
8037 strat->syzIdx[j] = ctr;
8038 LObject Q;
8039 int pos;
8040 for (k = 0; k<strat->sl+1; k++)
8041 {
8042 Q.sig = pOne();
8045 p_ExpVectorCopy(Q.sig,strat->S[k],currRing);
8046 p_SetCompP (Q.sig, comp, currRing);
8047 poly q = p_One(currRing);
8049 p_SetCoeff(q,nCopy(p_GetCoeff(strat->L[strat->Ll].p,currRing)),currRing);
8050 p_ExpVectorCopy(q,strat->L[strat->Ll].p,currRing);
8051 q = p_Neg (q, currRing);
8052 p_SetCompP (q, __p_GetComp(strat->sig[k], currRing), currRing);
8053 Q.sig = p_Add_q (Q.sig, q, currRing);
8054 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
8055 pos = posInSyz(strat, Q.sig);
8056 enterSyz(Q, strat, pos);
8057 ctr++;
8058 }
8059//#if 1
8060#ifdef DEBUGF5
8061 PrintS("Principal syzygies:\n");
8062 Print("syzl %d\n",strat->syzl);
8063 Print("syzmax %d\n",strat->syzmax);
8064 Print("ps %d\n",ps);
8065 PrintS("--------------------------------\n");
8066 for(i=0;i<=strat->syzl-1;i++)
8067 {
8068 Print("%d - ",i);
8069 pWrite(strat->syz[i]);
8070 }
8071 for(i=0;i<strat->currIdx;i++)
8072 {
8073 Print("%d - %d\n",i,strat->syzIdx[i]);
8074 }
8075 PrintS("--------------------------------\n");
8076#endif
8077 }
8078}
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9336
int posInSyz(const kStrategy strat, poly sig)
Definition kutil.cc:5758
#define p_GetCoeff(p, r)
Definition monomials.h:50
STATIC_VAR gmp_float * diff
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4889
poly p_One(const ring r)
Definition p_polys.cc:1314
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition p_polys.h:1334
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:256

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

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

1020{
1023
1024 int i;
1025 long x;
1026 m1 = p_Init(m_r,m_r->PolyBin);
1027 m2 = p_Init(m_r,m_r->PolyBin);
1028
1029 for (i = p_r->N; i; i--)
1030 {
1031 x = p_GetExpDiff(p1, p2, i, p_r);
1032 if (x > 0)
1033 {
1034 if (x > (long) m_r->bitmask) goto false_return;
1035 p_SetExp(m2,i,x, m_r);
1036 p_SetExp(m1,i,0, m_r);
1037 }
1038 else
1039 {
1040 if (-x > (long) m_r->bitmask) goto false_return;
1041 p_SetExp(m1,i,-x, m_r);
1042 p_SetExp(m2,i,0, m_r);
1043 }
1044 }
1045
1046 p_Setm(m1, m_r);
1047 p_Setm(m2, m_r);
1048 return TRUE;
1049
1051 p_LmFree(m1, m_r);
1052 p_LmFree(m2, m_r);
1053 m1 = m2 = NULL;
1054 return FALSE;
1055}
Variable x
Definition cfModGcd.cc:4090
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition p_polys.h:637
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition pDebug.cc:123
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341

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

1062{
1065
1066 int i;
1067 int x;
1068 int e1;
1069 int e2;
1070 int s;
1071 m1 = p_Init(tailRing,tailRing->PolyBin);
1072 m2 = p_Init(tailRing,tailRing->PolyBin);
1073 lcm = p_Init(leadRing,leadRing->PolyBin);
1074
1075 for (i = leadRing->N; i>=0; i--)
1076 {
1077 e1 = p_GetExp(p1,i,leadRing);
1078 e2 = p_GetExp(p2,i,leadRing);
1079 x = e1 - e2;
1080 if (x > 0)
1081 {
1082 p_SetExp(m2,i,x, tailRing);
1083 //p_SetExp(m1,i,0, tailRing); // done by p_Init
1084 s = e1;
1085 }
1086 else if (x<0)
1087 {
1088 p_SetExp(m1,i,-x, tailRing);
1089 //p_SetExp(m2,i,0, tailRing); // done by p_Init
1090 s = e2;
1091 }
1092 else
1093 s = e1; // e1==e2
1095 }
1096
1097 p_Setm(m1, tailRing);
1098 p_Setm(m2, tailRing);
1100}
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 991 of file kInline.h.

992{
993 return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
994}

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 959 of file kInline.h.

960{
961
962 poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
963 pNext(t_p) = pNext(p);
964 pSetCoeff0(t_p, pGetCoeff(p));
965 return t_p;
966}
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1356

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 996 of file kInline.h.

997{
998 return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
999}
KINLINE poly k_LmInit_tailRing_2_currRing(poly t_p, ring tailRing, omBin lmBin)
Definition kInline.h:968

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 968 of file kInline.h.

969{
970 poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
971 pNext(p) = pNext(t_p);
972 pSetCoeff0(p, pGetCoeff(t_p));
973 return p;
974}

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 1001 of file kInline.h.

1002{
1003 return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
1004}
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:977

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 977 of file kInline.h.

978{
979 poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
981 return np;
982}

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1006 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 984 of file kInline.h.

985{
986 poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
987 p_LmFree(p, tailRing);
988 return np;
989}

◆ kCheckSpolyCreation()

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

Definition at line 10482 of file kutil.cc.

10483{
10484 if (strat->overflow) return FALSE;
10485 assume(L->p1 != NULL && L->p2 != NULL);
10486 // shift changes: from 0 to -1
10487 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10488 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10489
10490 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10491 return FALSE;
10492 // shift changes: extra case inserted
10493 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10494 {
10495 return TRUE;
10496 }
10497 poly p1_max=NULL;
10498 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10499 poly p2_max=NULL;
10500 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10501
10502 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10503 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10504 {
10505 p_LmFree(m1, strat->tailRing);
10506 p_LmFree(m2, strat->tailRing);
10507 m1 = NULL;
10508 m2 = NULL;
10509 return FALSE;
10510 }
10511 return TRUE;
10512}
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:1018
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition p_polys.h:2020

◆ kCheckStrongCreation()

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

Definition at line 10520 of file kutil.cc.

10521{
10522 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10523 //assume(strat->tailRing != currRing);
10524
10525 poly p1_max = (strat->R[atR])->max_exp;
10526 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10527
10528 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10529 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10530 {
10531 return FALSE;
10532 }
10533 return TRUE;
10534}

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11501 of file kutil.cc.

11502{
11503 printf("red: ");
11504 if (strat->red==redFirst) printf("redFirst\n");
11505 else if (strat->red==redHoney) printf("redHoney\n");
11506 else if (strat->red==redEcart) printf("redEcart\n");
11507 else if (strat->red==redHomog) printf("redHomog\n");
11508 else if (strat->red==redLazy) printf("redLazy\n");
11509 else if (strat->red==redLiftstd) printf("redLiftstd\n");
11510 else printf("%p\n",(void*)strat->red);
11511 printf("posInT: ");
11512 if (strat->posInT==posInT0) printf("posInT0\n");
11513 else if (strat->posInT==posInT1) printf("posInT1\n");
11514 else if (strat->posInT==posInT11) printf("posInT11\n");
11515 else if (strat->posInT==posInT110) printf("posInT110\n");
11516 else if (strat->posInT==posInT13) printf("posInT13\n");
11517 else if (strat->posInT==posInT15) printf("posInT15\n");
11518 else if (strat->posInT==posInT17) printf("posInT17\n");
11519 else if (strat->posInT==posInT17_c) printf("posInT17_c\n");
11520 else if (strat->posInT==posInT19) printf("posInT19\n");
11521 else if (strat->posInT==posInT2) printf("posInT2\n");
11522 else if (strat->posInT==posInT11Ring) printf("posInT11Ring\n");
11523 else if (strat->posInT==posInT110Ring) printf("posInT110Ring\n");
11524 else if (strat->posInT==posInT15Ring) printf("posInT15Ring\n");
11525 else if (strat->posInT==posInT17Ring) printf("posInT17Ring\n");
11526 else if (strat->posInT==posInT17_cRing) printf("posInT17_cRing\n");
11527#ifdef HAVE_MORE_POS_IN_T
11528 else if (strat->posInT==posInT_EcartFDegpLength) printf("posInT_EcartFDegpLength\n");
11529 else if (strat->posInT==posInT_FDegpLength) printf("posInT_FDegpLength\n");
11530 else if (strat->posInT==posInT_pLength) printf("posInT_pLength\n");
11531#endif
11532 else if (strat->posInT==posInT_EcartpLength) printf("posInT_EcartpLength\n");
11533 else printf("%p\n",(void*)strat->posInT);
11534 printf("posInL: ");
11535 if (strat->posInL==posInL0) printf("posInL0\n");
11536 else if (strat->posInL==posInL10) printf("posInL10\n");
11537 else if (strat->posInL==posInL11) printf("posInL11\n");
11538 else if (strat->posInL==posInL110) printf("posInL110\n");
11539 else if (strat->posInL==posInL13) printf("posInL13\n");
11540 else if (strat->posInL==posInL15) printf("posInL15\n");
11541 else if (strat->posInL==posInL17) printf("posInL17\n");
11542 else if (strat->posInL==posInL17_c) printf("posInL17_c\n");
11543 else if (strat->posInL==posInL0) printf("posInL0Ring\n");
11544 else if (strat->posInL==posInL11Ring) printf("posInL11Ring\n");
11545 else if (strat->posInL==posInL11Ringls) printf("posInL11Ringls\n");
11546 else if (strat->posInL==posInL110Ring) printf("posInL110Ring\n");
11547 else if (strat->posInL==posInL15Ring) printf("posInL15Ring\n");
11548 else if (strat->posInL==posInL17Ring) printf("posInL17Ring\n");
11549 else if (strat->posInL==posInL17_cRing) printf("posInL17_cRing\n");
11550 else if (strat->posInL==posInLSpecial) printf("posInLSpecial\n");
11551 else printf("%p\n",(void*)strat->posInL);
11552 printf("enterS: ");
11553 if (strat->enterS==enterSBba) printf("enterSBba\n");
11554 else if (strat->enterS==enterSMora) printf("enterSMora\n");
11555 else if (strat->enterS==enterSMoraNF) printf("enterSMoraNF\n");
11556 else printf("%p\n",(void*)strat->enterS);
11557 printf("initEcart: ");
11558 if (strat->initEcart==initEcartBBA) printf("initEcartBBA\n");
11559 else if (strat->initEcart==initEcartNormal) printf("initEcartNormal\n");
11560 else printf("%p\n",(void*)strat->initEcart);
11561 printf("initEcartPair: ");
11562 if (strat->initEcartPair==initEcartPairBba) printf("initEcartPairBba\n");
11563 else if (strat->initEcartPair==initEcartPairMora) printf("initEcartPairMora\n");
11564 else printf("%p\n",(void*)strat->initEcartPair);
11565 printf("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11566 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11567 printf("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11568 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11569 printf("chainCrit: ");
11570 if (strat->chainCrit==chainCritNormal) printf("chainCritNormal\n");
11571 else if (strat->chainCrit==chainCritOpt_1) printf("chainCritOpt_1\n");
11572 else printf("%p\n",(void*)strat->chainCrit);
11573 printf("posInLDependsOnLength=%d\n",
11574 strat->posInLDependsOnLength);
11575 printf("%s\n",showOption());
11576 printf("LDeg: ");
11577 if (currRing->pLDeg==pLDeg0) printf("pLDeg0");
11578 else if (currRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11579 else if (currRing->pLDeg==pLDegb) printf("pLDegb");
11580 else if (currRing->pLDeg==pLDeg1) printf("pLDeg1");
11581 else if (currRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11582 else if (currRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11583 else if (currRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11584 else if (currRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11585 else if (currRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11586 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11587 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11588 else if (currRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11589 else printf("? (%lx)", (long)currRing->pLDeg);
11590 printf(" / ");
11591 if (strat->tailRing->pLDeg==pLDeg0) printf("pLDeg0");
11592 else if (strat->tailRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11593 else if (strat->tailRing->pLDeg==pLDegb) printf("pLDegb");
11594 else if (strat->tailRing->pLDeg==pLDeg1) printf("pLDeg1");
11595 else if (strat->tailRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11596 else if (strat->tailRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11597 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11598 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11599 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11600 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11601 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11602 else if (strat->tailRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11603 else printf("? (%lx)", (long)strat->tailRing->pLDeg);
11604 printf("\n");
11605 printf("currRing->pFDeg: ");
11606 if (currRing->pFDeg==p_Totaldegree) printf("p_Totaldegree");
11607 else if (currRing->pFDeg==p_WFirstTotalDegree) printf("pWFirstTotalDegree");
11608 else if (currRing->pFDeg==p_Deg) printf("p_Deg");
11609 else if (currRing->pFDeg==kHomModDeg) printf("kHomModDeg");
11610 else if (currRing->pFDeg==kModDeg) printf("kModDeg");
11611 else if (currRing->pFDeg==totaldegreeWecart) printf("totaldegreeWecart");
11612 else if (currRing->pFDeg==p_WTotaldegree) printf("p_WTotaldegree");
11613 else printf("? (%lx)", (long)currRing->pFDeg);
11614 printf("\n");
11615 printf(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11617 printf(" degBound: %d\n", Kstd1_deg);
11618
11619 if( ecartWeights != NULL )
11620 {
11621 printf("ecartWeights: ");
11622 for (int i = rVar(currRing); i > 0; i--)
11623 printf("%hd ", ecartWeights[i]);
11624 printf("\n");
11626 }
11627
11628#ifndef SING_NDEBUG
11630#endif
11631}
int LazyDegree
Definition kutil.h:354
void enterSMora(LObject &p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1629
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2426
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:794
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2416
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1682
int posInT2(const TSet set, const int length, LObject &p)
Definition kutil.cc:4925
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11472
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11381
VAR int Kstd1_deg
Definition kutil.cc:240
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11435
char * showOption()
Definition misc_ip.cc:711
long pLDegb(poly p, int *l, const ring r)
Definition p_polys.cc:812
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition p_polys.cc:976
long p_WFirstTotalDegree(poly p, const ring r)
Definition p_polys.cc:595
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition p_polys.cc:1039
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition p_polys.cc:1069
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition p_polys.cc:942
long pLDeg1(poly p, int *l, const ring r)
Definition p_polys.cc:842
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition p_polys.cc:911
long p_WTotaldegree(poly p, const ring r)
Definition p_polys.cc:612
long pLDeg1c(poly p, int *l, const ring r)
Definition p_polys.cc:878
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition p_polys.cc:1006
long pLDeg0c(poly p, int *l, const ring r)
Definition p_polys.cc:771
long pLDeg0(poly p, int *l, const ring r)
Definition p_polys.cc:740
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1528
void rDebugPrint(const ring r)
Definition ring.cc:4214
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:729

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 881 of file kutil.h.

882{
883 if (P->lcm!=NULL)
884 {
886 pLmDelete(P->lcm);
887 else
888 pLmFree(P->lcm);
889 P->lcm=NULL;
890 }
891}

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

469{
470 unsigned long not_sev = ~L->sev;
471 poly p = L->GetLmCurrRing();
472 int j = 0;
473
475
477#if 1
478 int ende;
479 if (is_Ring
480 || (strat->ak>0)
481 || currRing->pLexOrder)
482 ende=strat->sl;
483 else
484 {
485 ende=posInS(strat,*max_ind,p,0)+1;
486 if (ende>(*max_ind)) ende=(*max_ind);
487 }
488#else
489 int ende=strat->sl;
490#endif
491 if(is_Ring)
492 {
493 loop
494 {
495 if (j > ende) return -1;
496#if defined(PDEBUG) || defined(PDIV_DEBUG)
497 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
498 p, not_sev, currRing))
499#else
500 if ( !(strat->sevS[j] & not_sev) &&
501 p_LmDivisibleBy(strat->S[j], p, currRing))
502#endif
503 {
504 if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf))
505 return j;
506 }
507 j++;
508 }
509 }
510 else
511 {
512 loop
513 {
514 if (j > ende) return -1;
515#if defined(PDEBUG) || defined(PDIV_DEBUG)
516 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
517 p, not_sev, currRing))
518#else
519 if ( !(strat->sevS[j] & not_sev) &&
520 p_LmDivisibleBy(strat->S[j], p, currRing))
521#endif
522 {
523 return j;
524 }
525 j++;
526 }
527 }
528}
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1912

◆ kFindDivisibleByInS_T()

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

Definition at line 6694 of file kutil.cc.

6695{
6696 int j = 0;
6697 const unsigned long not_sev = ~L->sev;
6698 const unsigned long* sev = strat->sevS;
6699 poly p;
6700 ring r;
6701 L->GetLm(p, r);
6702
6704
6705 if (r == currRing)
6706 {
6707 if(!rField_is_Ring(r))
6708 {
6709 loop
6710 {
6711 if (j > end_pos) return NULL;
6712 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6713 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6714 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6715 #else
6716 if (!(sev[j] & not_sev) &&
6717 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
6718 p_LmDivisibleBy(strat->S[j], p, r))
6719 #endif
6720 {
6721 break;
6722 }
6723 j++;
6724 }
6725 }
6726 else
6727 {
6728 loop
6729 {
6730 if (j > end_pos) return NULL;
6731 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6732 if (strat->S[j]!= NULL
6733 && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r)
6734 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6735 && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6736 #else
6737 if (!(sev[j] & not_sev)
6738 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6739 && p_LmDivisibleBy(strat->S[j], p, r)
6740 && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6741 #endif
6742 {
6743 break; // found
6744 }
6745 j++;
6746 }
6747 }
6748 // if called from NF, T objects do not exist:
6749 if (strat->tl < 0 || strat->S_2_R[j] == -1)
6750 {
6751 T->Set(strat->S[j], r, strat->tailRing);
6752 assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
6753 return T;
6754 }
6755 else
6756 {
6757///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
6758///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
6759// assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
6760 return strat->S_2_T(j);
6761 }
6762 }
6763 else
6764 {
6765 TObject* t;
6766 if(!rField_is_Ring(r))
6767 {
6768 loop
6769 {
6770 if (j > end_pos) return NULL;
6771 assume(strat->S_2_R[j] != -1);
6772 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6773 t = strat->S_2_T(j);
6774 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
6775 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r)
6776 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6777 {
6778 t->pLength=pLength(t->t_p);
6779 return t;
6780 }
6781 #else
6782 if (! (sev[j] & not_sev)
6783 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6784 {
6785 t = strat->S_2_T(j);
6786 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
6787 if (p_LmDivisibleBy(t->t_p, p, r))
6788 {
6789 t->pLength=pLength(t->t_p);
6790 return t;
6791 }
6792 }
6793 #endif
6794 j++;
6795 }
6796 }
6797 else
6798 {
6799 loop
6800 {
6801 if (j > end_pos) return NULL;
6802 assume(strat->S_2_R[j] != -1);
6803 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6804 t = strat->S_2_T(j);
6805 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
6806 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r)
6807 && (ecart== LONG_MAX || ecart>= strat->ecartS[j])
6808 && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
6809 {
6810 t->pLength=pLength(t->t_p);
6811 return t;
6812 }
6813 #else
6814 if (! (sev[j] & not_sev)
6815 && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6816 {
6817 t = strat->S_2_T(j);
6818 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
6819 if (p_LmDivisibleBy(t->t_p, p, r)
6820 && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
6821 {
6822 t->pLength=pLength(t->t_p);
6823 return t;
6824 }
6825 }
6826 #endif
6827 j++;
6828 }
6829 }
6830 }
6831}
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 321 of file kstd2.cc.

322{
323 unsigned long not_sev = ~L->sev;
324 int j = start;
325
326 const TSet T=strat->T;
327 const unsigned long* sevT=strat->sevT;
328 const ring r=currRing;
330 if (L->p!=NULL)
331 {
332 const poly p=L->p;
333
335
336 if(is_Ring)
337 {
338 loop
339 {
340 if (j > strat->tl) return -1;
341#if defined(PDEBUG) || defined(PDIV_DEBUG)
342 if ((T[j].p!=NULL)
343 && p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
344#else
345 if (!(sevT[j] & not_sev)
346 && (T[j].p!=NULL)
347 && p_LmDivisibleBy(T[j].p, p, r))
348#endif
349 {
350 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf))
351 return j;
352 }
353 j++;
354 }
355 }
356 else
357 {
358 loop
359 {
360 if (j > strat->tl) return -1;
361#if defined(PDEBUG) || defined(PDIV_DEBUG)
362 if ((T[j].p!=NULL)
363 && p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
364#else
365 if (!(sevT[j] & not_sev)
366 && (T[j].p!=NULL)
367 && p_LmDivisibleBy(T[j].p, p, r))
368#endif
369 {
370 return j;
371 }
372 j++;
373 }
374 }
375 }
376 else
377 {
378 const poly p=L->t_p;
379 const ring r=strat->tailRing;
380 if(is_Ring)
381 {
382 loop
383 {
384 if (j > strat->tl) return -1;
385#if defined(PDEBUG) || defined(PDIV_DEBUG)
386 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
387 p, not_sev, r))
388#else
389 if (!(sevT[j] & not_sev) &&
390 p_LmDivisibleBy(T[j].t_p, p, r))
391#endif
392 {
393 if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf))
394 return j;
395 }
396 j++;
397 }
398 }
399 else
400 {
401 loop
402 {
403 if (j > strat->tl) return -1;
404#if defined(PDEBUG) || defined(PDIV_DEBUG)
405 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
406 p, not_sev, r))
407#else
408 if (!(sevT[j] & not_sev) &&
409 p_LmDivisibleBy(T[j].t_p, p, r))
410#endif
411 {
412 return j;
413 }
414 j++;
415 }
416 }
417 }
418}

◆ kFindDivisibleByInT_ecart()

int kFindDivisibleByInT_ecart ( const kStrategy  strat,
const LObject L,
const int  ecart 
)

Definition at line 420 of file kstd2.cc.

421{
422 if (TEST_OPT_LENGTH)
423 {
424 int r=-1; // found, but bad ecart
425 int j=-2; // found, good ecart
426 int jj=-1; // current search
427 loop
428 {
429 jj=kFindDivisibleByInT(strat,L,jj+1);
430 if (jj== -1)
431 {
432 if (j<0) return r; // nothing with good ecart
433 else return j; // end of search, return best found
434 }
435 else if (r<0) r=jj; // save bad ecart found
436 if (strat->T[jj].ecart<=ecart) // good enough
437 {
438 if (strat->T[jj].pLength<=0)
439 strat->T[jj].pLength=strat->T[jj].GetpLength();
440 if (j== -2) j=jj; // first found
441 else if (strat->T[j].pLength > strat->T[jj].pLength) // jj better then j
442 j=jj;
443 if (strat->T[j].pLength<=2) return j; // length already minimal
444 }
445 }
446 }
447 else
448 {
449 int r=-1;
450 int jj=-1;
451 loop
452 {
453 jj=kFindDivisibleByInT(strat,L,jj+1);
454 if (jj== -1)
455 {
456 return r; // nothing found
457 }
458 else if (r== -1) r=jj;
459 if (strat->T[jj].ecart<=ecart) // good enough
460 {
461 return jj;
462 }
463 }
464 }
465}
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:321
#define TEST_OPT_LENGTH
Definition options.h:132

◆ kFindDivisibleByInT_Z()

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

Definition at line 213 of file kstd2.cc.

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

◆ kFindInL1()

static int kFindInL1 ( const poly  p,
const kStrategy  strat 
)
inlinestatic

Definition at line 852 of file kutil.h.

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

◆ kFindInT()

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

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

Definition at line 703 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 728 of file kutil.cc.

729{
730 int i;
731
732 for (i=0; i<=tlength; i++)
733 {
734 // in the Letterplace ring the LMs in T and L are copies thus we have to use pEqualPolys() instead of ==
735 if (pEqualPolys(T[i].p, p)) return i;
736 }
737 return -1;
738}
#define pEqualPolys(p1, p2)
Definition polys.h:400

◆ kFindNextDivisibleByInS()

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

Definition at line 571 of file kstd2.cc.

572{
573 unsigned long not_sev = ~L->sev;
574 poly p = L->GetLmCurrRing();
575 int j = start;
576
578#if 1
579 int ende=max_ind;
580#else
581 int ende=strat->sl;
582#endif
583 loop
584 {
585 if (j > ende) return -1;
586#if defined(PDEBUG) || defined(PDIV_DEBUG)
587 if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j],
588 p, not_sev, currRing))
589#else
590 if ( !(strat->sevS[j] & not_sev) &&
591 p_LmDivisibleBy(strat->S[j], p, currRing))
592#endif
593 {
594 return j;
595 }
596 j++;
597 }
598}

◆ kFindSameLMInT_Z()

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

◆ kFindZeroPoly()

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

Definition at line 613 of file kstd2.cc.

614{
615 // m = currRing->ch
616
617 if (input_p == NULL) return NULL;
618
619 poly p = input_p;
620 poly zeroPoly = NULL;
621 unsigned long a = (unsigned long) pGetCoeff(p);
622
623 int k_ind2 = 0;
624 int a_ind2 = SI_LOG2_LONG(a);
625
626 // unsigned long k = 1;
627 // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
628 for (int i = 1; i <= leadRing->N; i++)
629 {
631 }
632
633 a = (unsigned long) pGetCoeff(p);
634
635 number tmp1;
636 poly tmp2, tmp3;
637 poly lead_mult = p_ISet(1, tailRing);
638 if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
639 {
640 int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf);
641 int s_exp;
642 zeroPoly = p_ISet(a, tailRing);
643 for (int i = 1; i <= leadRing->N; i++)
644 {
646 if (s_exp % 2 != 0)
647 {
648 s_exp = s_exp - 1;
649 }
650 while ( (0 < SI_LOG2_LONG(s_exp)) && (SI_LOG2_LONG(s_exp) <= too_much) )
651 {
653 s_exp = s_exp - 2;
654 }
655 p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
656 for (int j = 1; j <= s_exp; j++)
657 {
658 tmp1 = nInit(j);
659 tmp2 = p_ISet(1, tailRing);
660 p_SetExp(tmp2, i, 1, tailRing);
661 p_Setm(tmp2, tailRing);
662 if (nIsZero(tmp1))
663 { // should nowbe obsolet, test ! TODO OLIVER
664 zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
665 }
666 else
667 {
668 tmp3 = p_NSet(nCopy(tmp1), tailRing);
669 zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
670 }
671 }
672 }
673 p_Setm(lead_mult, tailRing);
674 zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing);
676 for (int i = 1; i <= leadRing->N; i++)
677 {
678 pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
679 }
683 return tmp2;
684 }
685/* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
686 if (1 == 0 && alpha_k <= a)
687 { // Temporarily disabled, reducing coefficients not compatible with std TODO Oliver
688 zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
689 for (int i = 1; i <= leadRing->N; i++)
690 {
691 for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
692 {
693 tmp1 = nInit(j);
694 tmp2 = p_ISet(1, tailRing);
695 p_SetExp(tmp2, i, 1, tailRing);
696 p_Setm(tmp2, tailRing);
697 if (nIsZero(tmp1))
698 {
699 zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
700 }
701 else
702 {
703 tmp3 = p_ISet((unsigned long) tmp1, tailRing);
704 zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
705 }
706 }
707 }
708 tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing);
709 for (int i = 1; i <= leadRing->N; i++)
710 {
711 pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
712 }
713 p_Setm(tmp2, leadRing);
714 zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing);
715 pNext(tmp2) = zeroPoly;
716 return tmp2;
717 } */
718 return NULL;
719}
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:450
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
static long ind_fact_2(long arg)
Definition kstd2.cc:600
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1474
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
static int SI_LOG2_LONG(long v)
Definition si_log2.h:22

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 4106 of file kstd2.cc.

4107{
4108 assume(!idIs0(q));
4109 assume(!(idIs0(F)&&(Q==NULL)));
4110// lazy_reduce flags: can be combined by |
4111//#define KSTD_NF_LAZY 1
4112 // do only a reduction of the leading term
4113//#define KSTD_NF_NONORM 4
4114 // only global: avoid normalization, return a multiply of NF
4115 poly p;
4116 int i;
4117 ideal res;
4118 int max_ind;
4119
4120 //if (idIs0(q))
4121 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4122 //if ((idIs0(F))&&(Q==NULL))
4123 // return idCopy(q); /*F=0*/
4124 //strat->ak = idRankFreeModule(F);
4125 /*- creating temp data structures------------------- -*/
4126 BITSET save1;
4129 initBuchMoraCrit(strat);
4130 strat->initEcart = initEcartBBA;
4131#ifdef HAVE_SHIFTBBA
4132 if (rIsLPRing(currRing))
4133 {
4134 strat->enterS = enterSBbaShift;
4135 }
4136 else
4137#endif
4138 {
4139 strat->enterS = enterSBba;
4140 }
4141 /*- set S -*/
4142 strat->sl = -1;
4143#ifndef NO_BUCKETS
4145#endif
4146 /*- init local data struct.---------------------------------------- -*/
4147 /*Shdl=*/initS(F,Q,strat);
4148 /*- compute------------------------------------------------------- -*/
4149 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4150 for (i=IDELEMS(q)-1; i>=0; i--)
4151 {
4152 if (q->m[i]!=NULL)
4153 {
4154 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4155 p = redNF(pCopy(q->m[i]),max_ind,
4157 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4158 {
4159 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4161 {
4162 p = redtailBba_NF(p,strat);
4163 }
4164 else
4165 {
4166 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4168 }
4169 }
4170 res->m[i]=p;
4171 }
4172 //else
4173 // res->m[i]=NULL;
4174 }
4175 /*- release temp data------------------------------- -*/
4176 assume(strat->L==NULL); /* strat->L unused */
4177 assume(strat->B==NULL); /* strat->B unused */
4178 omFree(strat->sevS);
4179 omFree(strat->ecartS);
4180 assume(strat->T==NULL);//omfree(strat->T);
4181 assume(strat->sevT==NULL);//omfree(strat->sevT);
4182 assume(strat->R==NULL);//omfree(strat->R);
4183 omfree(strat->S_2_R);
4184 omfree(strat->fromQ);
4185 strat->fromQ=NULL;
4186 idDelete(&strat->Shdl);
4188 if (TEST_OPT_PROT) PrintLn();
4189 return res;
4190}
CanonicalForm res
Definition facAbsFact.cc:60
#define KSTD_NF_LAZY
Definition kstd1.h:18
#define KSTD_NF_NONORM
Definition kstd1.h:22
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2311
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7583
poly redtailBba_NF(poly p, kStrategy strat)
Definition kutil.cc:7347
void enterSBbaShift(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8887
#define omfree(addr)
#define omFree(addr)
VAR unsigned si_opt_1
Definition options.c:5
#define OPT_INTSTRATEGY
Definition options.h:93
#define OPT_REDTAIL
Definition options.h:92
#define Sy_bit(x)
Definition options.h:31

◆ kNF2() [2/2]

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

Definition at line 3943 of file kstd2.cc.

3944{
3945 assume(q!=NULL);
3946 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
3947
3948// lazy_reduce flags: can be combined by |
3949//#define KSTD_NF_LAZY 1
3950 // do only a reduction of the leading term
3951//#define KSTD_NF_NONORM 4
3952 // only global: avoid normalization, return a multiply of NF
3953//#define KSTD_NF_CANCELUNIT 8
3954 // apply cancelunit to f inf NF(f,I)
3955//#define KSTD_NF_NOLF 4096
3956 // avoid PrintLn with OPT_PROT
3957
3958 poly p;
3959
3960 //if ((idIs0(F))&&(Q==NULL))
3961 // return pCopy(q); /*F=0*/
3962 //strat->ak = idRankFreeModule(F);
3963 /*- creating temp data structures------------------- -*/
3964 BITSET save1;
3967 initBuchMoraCrit(strat);
3968 strat->initEcart = initEcartBBA;
3969#ifdef HAVE_SHIFTBBA
3970 if (rIsLPRing(currRing))
3971 {
3972 strat->enterS = enterSBbaShift;
3973 }
3974 else
3975#endif
3976 {
3977 strat->enterS = enterSBba;
3978 }
3979#ifndef NO_BUCKETS
3981#endif
3982 /*- set S -*/
3983 strat->sl = -1;
3984 /*- init local data struct.---------------------------------------- -*/
3985 /*Shdl=*/initS(F,Q,strat);
3986 /*- compute------------------------------------------------------- -*/
3987 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
3988 //{
3989 // for (i=strat->sl;i>=0;i--)
3990 // pNorm(strat->S[i]);
3991 //}
3992 kTest(strat);
3993 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
3994 if (BVERBOSE(23)) kDebugPrint(strat);
3995 int max_ind;
3997 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
3998 {
3999 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4001 {
4002 p = redtailBba_NF(p,strat);
4003 }
4004 else if (rField_is_Ring(currRing))
4005 {
4006 p = redtailBba_Ring(p,max_ind,strat);
4007 }
4008 else
4009 {
4010 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4012 }
4013 }
4014 /*- release temp data------------------------------- -*/
4015 assume(strat->L==NULL); /* strat->L unused */
4016 assume(strat->B==NULL); /* strat->B unused */
4017 omFree(strat->sevS);
4018 omFree(strat->ecartS);
4019 assume(strat->T==NULL);//omfree(strat->T);
4020 assume(strat->sevT==NULL);//omfree(strat->sevT);
4021 assume(strat->R==NULL);//omfree(strat->R);
4022 omfree(strat->S_2_R);
4023 omfree(strat->fromQ);
4024 strat->fromQ=NULL;
4025 idDelete(&strat->Shdl);
4027 if (TEST_OPT_PROT && ((lazyReduce &KSTD_NF_NOLF)==0)) PrintLn();
4028 return p;
4029}
KINLINE poly redtailBba_Ring(poly p, int pos, kStrategy strat)
Definition kInline.h:1224
#define KSTD_NF_NOLF
Definition kstd1.h:26
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1004
static BOOLEAN rField_is_Zn(const ring r)
Definition ring.h:518

◆ kNF2Bound() [1/2]

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

Definition at line 4192 of file kstd2.cc.

4193{
4194 assume(!idIs0(q));
4195 assume(!(idIs0(F)&&(Q==NULL)));
4196// lazy_reduce flags: can be combined by |
4197//#define KSTD_NF_LAZY 1
4198 // do only a reduction of the leading term
4199//#define KSTD_NF_NONORM 4
4200 // only global: avoid normalization, return a multiply of NF
4201 poly p;
4202 int i;
4203 ideal res;
4204 int max_ind;
4205
4206 //if (idIs0(q))
4207 // return idInit(IDELEMS(q),si_max(q->rank,F->rank));
4208 //if ((idIs0(F))&&(Q==NULL))
4209 // return idCopy(q); /*F=0*/
4210 //strat->ak = idRankFreeModule(F);
4211 /*- creating temp data structures------------------- -*/
4212 BITSET save1;
4215 initBuchMoraCrit(strat);
4216 strat->initEcart = initEcartBBA;
4217 strat->enterS = enterSBba;
4218 /*- set S -*/
4219 strat->sl = -1;
4220#ifndef NO_BUCKETS
4222#endif
4223 /*- init local data struct.---------------------------------------- -*/
4224 /*Shdl=*/initS(F,Q,strat);
4225 /*- compute------------------------------------------------------- -*/
4226 res=idInit(IDELEMS(q),si_max(q->rank,F->rank));
4227 for (i=IDELEMS(q)-1; i>=0; i--)
4228 {
4229 if (q->m[i]!=NULL)
4230 {
4231 if (TEST_OPT_PROT) { PrintS("r");mflush(); }
4232 p = redNFBound(pCopy(q->m[i]),max_ind,
4234 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4235 {
4236 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4238 {
4239 p = redtailBba_Z(p,max_ind,strat);
4240 }
4241 else if (rField_is_Ring(currRing))
4242 {
4243 p = redtailBba_Ring(p,max_ind,strat);
4244 }
4245 else
4246 {
4247 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4249 }
4250 }
4251 res->m[i]=p;
4252 }
4253 //else
4254 // res->m[i]=NULL;
4255 }
4256 /*- release temp data------------------------------- -*/
4257 assume(strat->L==NULL); /* strat->L unused */
4258 assume(strat->B==NULL); /* strat->B unused */
4259 omFree(strat->sevS);
4260 omFree(strat->ecartS);
4261 assume(strat->T==NULL);//omfree(strat->T);
4262 assume(strat->sevT==NULL);//omfree(strat->sevT);
4263 assume(strat->R==NULL);//omfree(strat->R);
4264 omfree(strat->S_2_R);
4265 omfree(strat->fromQ);
4266 strat->fromQ=NULL;
4267 idDelete(&strat->Shdl);
4269 if (TEST_OPT_PROT) PrintLn();
4270 return res;
4271}
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:1218
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition kInline.h:1229
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
Definition kstd2.cc:2507

◆ kNF2Bound() [2/2]

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

Definition at line 4031 of file kstd2.cc.

4032{
4033 assume(q!=NULL);
4034 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
4035
4036// lazy_reduce flags: can be combined by |
4037//#define KSTD_NF_LAZY 1
4038 // do only a reduction of the leading term
4039//#define KSTD_NF_NONORM 4
4040 // only global: avoid normalization, return a multiply of NF
4041 poly p;
4042
4043 //if ((idIs0(F))&&(Q==NULL))
4044 // return pCopy(q); /*F=0*/
4045 //strat->ak = idRankFreeModule(F);
4046 /*- creating temp data structures------------------- -*/
4047 BITSET save1;
4050 initBuchMoraCrit(strat);
4051 strat->initEcart = initEcartBBA;
4052 strat->enterS = enterSBba;
4053#ifndef NO_BUCKETS
4055#endif
4056 /*- set S -*/
4057 strat->sl = -1;
4058 /*- init local data struct.---------------------------------------- -*/
4059 /*Shdl=*/initS(F,Q,strat);
4060 /*- compute------------------------------------------------------- -*/
4061 //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0))
4062 //{
4063 // for (i=strat->sl;i>=0;i--)
4064 // pNorm(strat->S[i]);
4065 //}
4066 kTest(strat);
4067 if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
4068 if (BVERBOSE(23)) kDebugPrint(strat);
4069 int max_ind;
4071 if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
4072 {
4073 if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
4075 {
4076 p = redtailBba_Z(p,max_ind,strat);
4077 }
4078 else if (rField_is_Ring(currRing))
4079 {
4080 p = redtailBba_Ring(p,max_ind,strat);
4081 }
4082 else
4083 {
4084 si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY);
4086 //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0);
4087 }
4088 }
4089 /*- release temp data------------------------------- -*/
4090 assume(strat->L==NULL); /* strat->L unused */
4091 assume(strat->B==NULL); /* strat->B unused */
4092 omFree(strat->sevS);
4093 omFree(strat->ecartS);
4094 assume(strat->T==NULL);//omfree(strat->T);
4095 assume(strat->sevT==NULL);//omfree(strat->sevT);
4096 assume(strat->R==NULL);//omfree(strat->R);
4097 omfree(strat->S_2_R);
4098 omfree(strat->fromQ);
4099 strat->fromQ=NULL;
4100 idDelete(&strat->Shdl);
4102 if (TEST_OPT_PROT) PrintLn();
4103 return p;
4104}

◆ ksCreateShortSpoly()

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

Definition at line 1446 of file kspoly.cc.

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

◆ ksCreateSpoly()

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

Definition at line 1203 of file kspoly.cc.

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

◆ ksOldCreateSpoly()

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

Definition at line 1194 of file kInline.h.

1195{
1196 LObject L(r);
1197 L.p1 = p1;
1198 L.p2 = p2;
1199
1201 return L.GetLmCurrRing();
1202}

◆ ksOldSpolyRed()

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

Definition at line 1174 of file kInline.h.

1175{
1176 LObject L(p2);
1177 TObject T(p1);
1178
1179 ksReducePoly(&L, &T, spNoether);
1180
1181 return L.GetLmCurrRing();
1182}
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat, BOOLEAN reduce)
Definition kspoly.cc:187

◆ ksOldSpolyRedNew()

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

Definition at line 1184 of file kInline.h.

1185{
1186 LObject L(p_Copy(p2, currRing));
1187 TObject T(p1);
1188
1189 ksReducePoly(&L, &T, spNoether);
1190
1191 return L.GetLmCurrRing();
1192}

◆ ksOldSpolyTail()

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

Definition at line 1204 of file kInline.h.

1205{
1206 LObject L(q, currRing, r);
1207 TObject T(p1, currRing, r);
1208
1210}
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1147

◆ ksReducePoly()

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

Definition at line 187 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 590 of file kspoly.cc.

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

◆ ksReducePolyGCD()

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

◆ ksReducePolyLC()

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

Definition at line 477 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 737 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 943 of file kspoly.cc.

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

◆ ksReducePolyTail() [1/2]

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

Definition at line 1147 of file kInline.h.

1148{
1149 BOOLEAN ret;
1150 number coef;
1151
1152 assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1153 Red->HeadNormalize();
1154 ret = ksReducePoly(Red, PW, NULL, &coef);
1155
1156 if (!ret)
1157 {
1158 if (! n_IsOne(coef, currRing->cf))
1159 {
1160 PR->Mult_nn(coef);
1161 // HANNES: mark for Normalize
1162 }
1163 n_Delete(&coef, currRing->cf);
1164 }
1165 return ret;
1166}

◆ ksReducePolyTail() [2/2]

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

Definition at line 1350 of file kspoly.cc.

1351{
1352 BOOLEAN ret;
1353 number coef;
1354 poly Lp = PR->GetLmCurrRing();
1355 poly Save = PW->GetLmCurrRing();
1356
1357 pAssume(pIsMonomOf(Lp, Current));
1358
1359 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
1360 assume(PR->bucket == NULL);
1361
1362 LObject Red(pNext(Current), PR->tailRing);
1363 TObject With(PW, Lp == Save);
1364
1366 ret = ksReducePoly(&Red, &With, spNoether, &coef);
1367
1368 if (!ret)
1369 {
1370 if (! n_IsOne(coef, currRing->cf))
1371 {
1372 pNext(Current) = NULL;
1373 if (Current == PR->p && PR->t_p != NULL)
1374 pNext(PR->t_p) = NULL;
1375 PR->Mult_nn(coef);
1376 }
1377
1378 n_Delete(&coef, currRing->cf);
1379 pNext(Current) = Red.GetLmTailRing();
1380 if (Current == PR->p && PR->t_p != NULL)
1381 pNext(PR->t_p) = pNext(Current);
1382 }
1383
1384 if (Lp == Save)
1385 With.Delete();
1386
1387 return ret;
1388}
BOOLEAN pIsMonomOf(poly p, poly m)
Definition pDebug.cc:164
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition pDebug.cc:174

◆ ksReducePolyZ()

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

◆ kStratChangeTailRing()

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

Definition at line 10962 of file kutil.cc.

10963{
10964 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
10965 /* initial setup or extending */
10966
10967 if (rIsLPRing(currRing)) return TRUE;
10968 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
10969 if (expbound >= currRing->bitmask) return FALSE;
10970 strat->overflow=FALSE;
10972 // Hmmm .. the condition pFDeg == p_Deg
10973 // might be too strong
10974 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
10975 (strat->ak==0), // omit_comp if the input is an ideal
10976 expbound); // exp_limit
10977
10978 if (new_tailRing == currRing) return TRUE;
10979
10980 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
10981 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
10982
10983 if (currRing->pFDeg != currRing->pFDegOrig)
10984 {
10985 new_tailRing->pFDeg = currRing->pFDeg;
10986 new_tailRing->pLDeg = currRing->pLDeg;
10987 }
10988
10989 if (TEST_OPT_PROT)
10990 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
10991 #ifdef KDEBUG
10992 kTest_TS(strat);
10993 assume(new_tailRing != strat->tailRing);
10994 #endif
10995 pShallowCopyDeleteProc p_shallow_copy_delete
10997
10999
11000 int i;
11001 for (i=0; i<=strat->tl; i++)
11002 {
11003 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11004 p_shallow_copy_delete);
11005 }
11006 for (i=0; i<=strat->Ll; i++)
11007 {
11008 assume(strat->L[i].p != NULL);
11009 if (pNext(strat->L[i].p) != strat->tail)
11010 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11011 }
11012 if ((strat->P.t_p != NULL) ||
11013 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11014 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11015
11016 if ((L != NULL) && (L->tailRing != new_tailRing))
11017 {
11018 if (L->i_r < 0)
11019 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11020 else
11021 {
11022 assume(L->i_r <= strat->tl);
11023 TObject* t_l = strat->R[L->i_r];
11024 assume(t_l != NULL);
11025 L->tailRing = new_tailRing;
11026 L->p = t_l->p;
11027 L->t_p = t_l->t_p;
11028 L->max_exp = t_l->max_exp;
11029 }
11030 }
11031
11032 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11033 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11034
11035 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11036 if (strat->tailRing != currRing)
11038
11039 strat->tailRing = new_tailRing;
11040 strat->tailBin = new_tailBin;
11043
11044 if (strat->kNoether != NULL)
11045 {
11046 if (strat->t_kNoether != NULL)
11047 p_LmFree(strat->t_kNoether, strat->tailRing);
11049 }
11050
11051 #ifdef KDEBUG
11052 kTest_TS(strat);
11053 #endif
11054 if (TEST_OPT_PROT)
11055 PrintS("]");
11056 return TRUE;
11057}
poly t_kNoether
Definition kutil.h:331
pFDegProc pOrigFDeg_TailRing
Definition kutil.h:299
pLDegProc pOrigLDeg_TailRing
Definition kutil.h:300
omBin_t * omBin
Definition omStructs.h:12
void rKillModifiedRing(ring r)
Definition ring.cc:3119
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition ring.cc:2758
#define omGetStickyBinOfBin(B)
Definition xalloc.h:247
#define omMergeStickyBinIntoBin(A, B)
Definition xalloc.h:275

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11059 of file kutil.cc.

11060{
11061 unsigned long l = 0;
11062 int i;
11063 long e;
11064
11065 assume(strat->tailRing == currRing);
11066
11067 for (i=0; i<= strat->Ll; i++)
11068 {
11069 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11070 }
11071 for (i=0; i<=strat->tl; i++)
11072 {
11073 // Hmm ... this we could do in one Step
11074 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11075 }
11077 {
11078 l *= 2;
11079 }
11080 e = p_GetMaxExp(l, currRing);
11081 if (e <= 1) e = 2;
11082 if (rIsLPRing(currRing)) e = 1;
11083
11084 kStratChangeTailRing(strat, NULL, NULL, e);
11085}
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:1176
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition p_polys.h:783

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1004 of file kutil.cc.

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

◆ kTest_L()

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

Definition at line 916 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1049 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 789 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1067 of file kutil.cc.

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

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

147{
148 if (strat->tl < 1)
149 return -1;
150
151 unsigned long not_sev = ~L->sev;
152 const unsigned long sevT0 = strat->sevT[0];
154 if (L->p!=NULL)
155 {
156 const poly T0p = strat->T[0].p;
157 const ring r = currRing;
158 const poly p = L->p;
159 orest = pGetCoeff(p);
160
162
163#if defined(PDEBUG) || defined(PDIV_DEBUG)
165#else
166 if (!(sevT0 & not_sev) && p_LmDivisibleBy(T0p, p, r))
167#endif
168 {
169 if (n_QuotRem!=ndQuotRem) /*euclidean ring*/
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 n_Delete(&mult,r->cf);
175 n_Delete(&rest,r->cf);
176 return 0;
177 }
178 n_Delete(&mult,r->cf);
179 n_Delete(&rest,r->cf);
180 }
181 }
182 }
183 else
184 {
185 const poly T0p = strat->T[0].t_p;
186 const ring r = strat->tailRing;
187 const poly p = L->t_p;
188 orest = pGetCoeff(p);
189#if defined(PDEBUG) || defined(PDIV_DEBUG)
191 p, not_sev, r))
192#else
193 if (!(sevT0 & not_sev) && p_LmDivisibleBy(T0p, p, r))
194#endif
195 {
196 if (n_QuotRem!=ndQuotRem) /*euclidean ring*/
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 n_Delete(&mult,r->cf);
202 n_Delete(&rest,r->cf);
203 return 0;
204 }
205 n_Delete(&mult,r->cf);
206 n_Delete(&rest,r->cf);
207 }
208 }
209 }
210 return -1;
211}
number ndQuotRem(number a, number b, number *r, const coeffs R)
Definition numbers.cc:356

◆ message()

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

Definition at line 7460 of file kutil.cc.

7461{
7462 if (i != *olddeg)
7463 {
7464 Print("%d",i);
7465 *olddeg = i;
7466 }
7467 if (TEST_OPT_OLDSTD)
7468 {
7469 if (strat->Ll != *reduc)
7470 {
7471 if (strat->Ll != *reduc-1)
7472 Print("(%d)",strat->Ll+1);
7473 else
7474 PrintS("-");
7475 *reduc = strat->Ll;
7476 }
7477 else
7478 PrintS(".");
7479 mflush();
7480 }
7481 else
7482 {
7483 if (red_result == 0)
7484 PrintS("-");
7485 else if (red_result < 0)
7486 PrintS(".");
7487 if ((red_result > 0) || ((strat->Ll % 100)==99))
7488 {
7489 if (strat->Ll != *reduc && strat->Ll > 0)
7490 {
7491 Print("(%d)",strat->Ll+1);
7492 *reduc = strat->Ll;
7493 }
7494 }
7495 }
7496}

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7533 of file kutil.cc.

7534{
7535 int i;
7536 if (strat->news)
7537 {
7538 PrintS("set S");
7539 for (i=0; i<=strat->sl; i++)
7540 {
7541 Print("\n %d:",i);
7542 p_wrp(strat->S[i], currRing, strat->tailRing);
7543 if (strat->fromQ!=NULL && strat->fromQ[i])
7544 Print(" (from Q)");
7545 }
7546 strat->news = FALSE;
7547 }
7548 if (strat->newt)
7549 {
7550 PrintS("\nset T");
7551 for (i=0; i<=strat->tl; i++)
7552 {
7553 Print("\n %d:",i);
7554 strat->T[i].wrp();
7555 if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7556 Print(" o:%ld e:%d l:%d",
7557 strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7558 }
7559 strat->newt = FALSE;
7560 }
7561 PrintS("\nset L");
7562 for (i=strat->Ll; i>=0; i--)
7563 {
7564 Print("\n%d:",i);
7565 p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7566 PrintS(" ");
7567 p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7568 PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7569 PrintS("\n p : ");
7570 strat->L[i].wrp();
7571 Print(" o:%ld e:%d l:%d",
7572 strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7573 }
7574 PrintLn();
7575}

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7501 of file kutil.cc.

7502{
7503 //PrintS("\nUsage/Allocation of temporary storage:\n");
7504 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7505 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7506 Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7507 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7508 #ifdef HAVE_SHIFTBBA
7509 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7510 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7511 #endif
7512}

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7514 of file kutil.cc.

7515{
7516 //PrintS("\nUsage/Allocation of temporary storage:\n");
7517 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7518 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7519 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7520 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7521 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7522 #ifdef HAVE_SHIFTBBA
7523 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7524 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7525 #endif
7526}
int nrsyzcrit
Definition kutil.h:360

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10402 of file kutil.cc.

10403{
10404 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10405 return FALSE;
10406 int i,j;
10407 poly newNoether;
10408
10409#if 0
10410 if (currRing->weight_all_1)
10411 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10412 else
10413 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10414#else
10415 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10416#endif
10417 if (strat->kNoether==NULL) return FALSE;
10418 if (strat->t_kNoether != NULL)
10419 {
10420 p_LmFree(strat->t_kNoether, strat->tailRing);
10421 strat->t_kNoether=NULL;
10422 }
10423 if (strat->tailRing != currRing)
10425 /* compare old and new noether*/
10426 newNoether = pLmInit(strat->kNoether);
10429 // newNoether is now the new highest edge (on the boundary)
10430 // now find the next monomial after highest monomial in R/I
10431 // (the smallest monomial not in R/I)
10432 for (i=currRing->N-1;i>0; i--)
10433 {
10434 int e;
10435 if ((e=pGetExp(newNoether, i)) > 0)
10436 {
10437 e--;
10438 pSetExp(newNoether,i,e);
10439 }
10440 }
10442 if (j < HCord) /*- statistics -*/
10443 {
10444 if (TEST_OPT_PROT)
10445 {
10446 Print("H(%d)",j);
10447 mflush();
10448 }
10449 HCord=j;
10450 #ifdef KDEBUG
10451 if (TEST_OPT_DEBUG)
10452 {
10453 Print("H(%d):",j);
10454 wrp(strat->kNoether);
10455 PrintLn();
10456 }
10457 #endif
10458 }
10459 if (pCmp(strat->kNoether,newNoether)!=1)
10460 {
10461 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10462 strat->kNoether=newNoether;
10463 if (strat->t_kNoether != NULL)
10464 {
10465 p_LmFree(strat->t_kNoether, strat->tailRing);
10466 strat->t_kNoether=NULL;
10467 }
10468 if (strat->tailRing != currRing)
10470
10471 return TRUE;
10472 }
10474 return FALSE;
10475}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition hdegree.cc:1074
VAR int HCord
Definition kutil.cc:239
static void p_LmDelete0(poly p, const ring r)
Definition p_polys.h:735
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition polys.h:116
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65
#define pGetExp(p, i)
Exponent.
Definition polys.h:42

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

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

Definition at line 4841 of file kutil.cc.

4842{
4844 end = IDELEMS(F);
4845 if (end<0) return 0;
4846 if(pNext(p) == NULL) return start;
4847 polyset set=F->m;
4848 int o = p_Deg(p,currRing);
4849 int op;
4850 int i;
4851 int an = start;
4852 for(i=start;i<end;i++)
4853 if(set[i] != NULL && pNext(set[i]) == NULL)
4854 an++;
4855 if(an == end-1)
4856 return end;
4857 int en= end;
4858 loop
4859 {
4860 if(an>=en)
4861 return en;
4862 if (an == en-1)
4863 {
4864 op = p_Deg(set[an],currRing);
4865 if ((op < o)
4866 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4867 return en;
4868 return an;
4869 }
4870 i=(an+en) / 2;
4871 op = p_Deg(set[i],currRing);
4872 if ((op < o)
4873 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4874 an=i;
4875 else
4876 en=i;
4877 }
4878}
poly * polyset
Definition polys.h:260

◆ posInL0()

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

Definition at line 5611 of file kutil.cc.

5613{
5614 if (length<0) return 0;
5615
5616 int cmp_int=currRing->OrdSgn;
5617
5618 if (pLmCmp(set[length].p,p->p)== cmp_int)
5619 return length+1;
5620
5621 int i;
5622 int an = 0;
5623 int en= length;
5624 loop
5625 {
5626 if (an >= en-1)
5627 {
5628 if (pLmCmp(set[an].p,p->p) == cmp_int) return en;
5629 return an;
5630 }
5631 i=(an+en) / 2;
5632 if (pLmCmp(set[i].p,p->p) == cmp_int) an=i;
5633 else en=i;
5634 /*aend. fuer lazy == in !=- machen */
5635 }
5636}

◆ posInL10()

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

Definition at line 1360 of file kstd1.cc.

1361{
1362 int j,dp,dL;
1363
1364 if (length<0) return 0;
1365 if (hasPurePower(p,strat->lastAxis,&dp,strat))
1366 {
1367 int op= p->GetpFDeg() +p->ecart;
1368 for (j=length; j>=0; j--)
1369 {
1370 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1371 return j+1;
1372 if (dp < dL)
1373 return j+1;
1374 if ((dp == dL)
1375 && (set[j].GetpFDeg()+set[j].ecart >= op))
1376 return j+1;
1377 }
1378 }
1379 j=length;
1380 loop
1381 {
1382 if (j<0) break;
1383 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1384 j--;
1385 }
1386 return strat->posInLOld(set,j,p,strat);
1387}
static BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition kstd1.cc:1312

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

5801{
5802 if (length<0) return 0;
5803
5804 int o = p->GetpFDeg();
5805 int op = set[length].GetpFDeg();
5806 int cmp_int= -currRing->OrdSgn;
5807
5808 if ((op > o)
5809 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
5810 return length+1;
5811 int i;
5812 int an = 0;
5813 int en= length;
5814 loop
5815 {
5816 if (an >= en-1)
5817 {
5818 op = set[an].GetpFDeg();
5819 if ((op > o)
5820 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
5821 return en;
5822 return an;
5823 }
5824 i=(an+en) / 2;
5825 op = set[i].GetpFDeg();
5826 if ((op > o)
5827 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
5828 an=i;
5829 else
5830 en=i;
5831 }
5832}

◆ posInL110()

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

Definition at line 6055 of file kutil.cc.

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

◆ posInL11Ring()

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

Definition at line 5841 of file kutil.cc.

5843{
5844 if (length<0) return 0;
5845
5846 int o = p->GetpFDeg();
5847 int op = set[length].GetpFDeg();
5848
5849 if ((op > o)
5850 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
5851 return length+1;
5852 int i;
5853 int an = 0;
5854 int en= length;
5855 loop
5856 {
5857 if (an >= en-1)
5858 {
5859 op = set[an].GetpFDeg();
5860 if ((op > o)
5861 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
5862 return en;
5863 return an;
5864 }
5865 i=(an+en) / 2;
5866 op = set[i].GetpFDeg();
5867 if ((op > o)
5868 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
5869 an=i;
5870 else
5871 en=i;
5872 }
5873}
#define pLtCmpOrdSgnDiffM(p, q)
Definition polys.h:126

◆ posInL11Ringls()

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

Definition at line 5909 of file kutil.cc.

5911{
5912 if (length < 0) return 0;
5913 int an,en,i;
5914 an = 0;
5915 en = length+1;
5916 loop
5917 {
5918 if (an >= en-1)
5919 {
5920 if(an == en)
5921 return en;
5922 if (set[an].FDeg > p->FDeg)
5923 return en;
5924 if (set[an].FDeg < p->FDeg)
5925 return an;
5926 if (set[an].FDeg == p->FDeg)
5927 {
5929 lcset = pGetCoeff(set[an].p);
5930 lcp = pGetCoeff(p->p);
5931 if(!nGreaterZero(lcset))
5932 {
5933 set[an].p=p_Neg(set[an].p,currRing);
5934 if (set[an].t_p!=NULL)
5935 pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
5936 lcset=pGetCoeff(set[an].p);
5937 }
5938 if(!nGreaterZero(lcp))
5939 {
5940 p->p=p_Neg(p->p,currRing);
5941 if (p->t_p!=NULL)
5942 pSetCoeff0(p->t_p,pGetCoeff(p->p));
5943 lcp=pGetCoeff(p->p);
5944 }
5945 if(nGreater(lcset, lcp))
5946 {
5947 return en;
5948 }
5949 else
5950 {
5951 return an;
5952 }
5953 }
5954 }
5955 i=(an+en) / 2;
5956 if (set[i].FDeg > p->FDeg)
5957 an=i;
5958 if (set[i].FDeg < p->FDeg)
5959 en=i;
5960 if (set[i].FDeg == p->FDeg)
5961 {
5963 lcset = pGetCoeff(set[i].p);
5964 lcp = pGetCoeff(p->p);
5965 if(!nGreaterZero(lcset))
5966 {
5967 set[i].p=p_Neg(set[i].p,currRing);
5968 if (set[i].t_p!=NULL)
5969 pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
5970 lcset=pGetCoeff(set[i].p);
5971 }
5972 if(!nGreaterZero(lcp))
5973 {
5974 p->p=p_Neg(p->p,currRing);
5975 if (p->t_p!=NULL)
5976 pSetCoeff0(p->t_p,pGetCoeff(p->p));
5977 lcp=pGetCoeff(p->p);
5978 }
5979 if(nGreater(lcset, lcp))
5980 {
5981 an = i;
5982 }
5983 else
5984 {
5985 en = i;
5986 }
5987 }
5988 }
5989}
#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 6142 of file kutil.cc.

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

◆ posInL15()

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

Definition at line 6177 of file kutil.cc.

6179{
6180 if (length<0) return 0;
6181
6182 int o = p->GetpFDeg() + p->ecart;
6183 int op = set[length].GetpFDeg() + set[length].ecart;
6184 int cmp_int= -currRing->OrdSgn;
6185
6186 if ((op > o)
6187 || ((op == o) && (pLmCmp(set[length].p,p->p) != cmp_int)))
6188 return length+1;
6189 int i;
6190 int an = 0;
6191 int en= length;
6192 loop
6193 {
6194 if (an >= en-1)
6195 {
6196 op = set[an].GetpFDeg() + set[an].ecart;
6197 if ((op > o)
6198 || ((op == o) && (pLmCmp(set[an].p,p->p) != cmp_int)))
6199 return en;
6200 return an;
6201 }
6202 i=(an+en) / 2;
6203 op = set[i].GetpFDeg() + set[i].ecart;
6204 if ((op > o)
6205 || ((op == o) && (pLmCmp(set[i].p,p->p) != cmp_int)))
6206 an=i;
6207 else
6208 en=i;
6209 }
6210}

◆ posInL15Ring()

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

Definition at line 6212 of file kutil.cc.

6214{
6215 if (length<0) return 0;
6216
6217 int o = p->GetpFDeg() + p->ecart;
6218 int op = set[length].GetpFDeg() + set[length].ecart;
6219
6220 if ((op > o)
6221 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6222 return length+1;
6223 int i;
6224 int an = 0;
6225 int en= length;
6226 loop
6227 {
6228 if (an >= en-1)
6229 {
6230 op = set[an].GetpFDeg() + set[an].ecart;
6231 if ((op > o)
6232 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6233 return en;
6234 return an;
6235 }
6236 i=(an+en) / 2;
6237 op = set[i].GetpFDeg() + set[i].ecart;
6238 if ((op > o)
6239 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6240 an=i;
6241 else
6242 en=i;
6243 }
6244}

◆ posInL17()

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

Definition at line 6252 of file kutil.cc.

6254{
6255 if (length<0) return 0;
6256
6257 int o = p->GetpFDeg() + p->ecart;
6258 int cmp_int= -currRing->OrdSgn;
6259
6260 if ((set[length].GetpFDeg() + set[length].ecart > o)
6261 || ((set[length].GetpFDeg() + set[length].ecart == o)
6262 && (set[length].ecart > p->ecart))
6263 || ((set[length].GetpFDeg() + set[length].ecart == o)
6264 && (set[length].ecart == p->ecart)
6265 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6266 return length+1;
6267 int i;
6268 int an = 0;
6269 int en= length;
6270 loop
6271 {
6272 if (an >= en-1)
6273 {
6274 if ((set[an].GetpFDeg() + set[an].ecart > o)
6275 || ((set[an].GetpFDeg() + set[an].ecart == o)
6276 && (set[an].ecart > p->ecart))
6277 || ((set[an].GetpFDeg() + set[an].ecart == o)
6278 && (set[an].ecart == p->ecart)
6279 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6280 return en;
6281 return an;
6282 }
6283 i=(an+en) / 2;
6284 if ((set[i].GetpFDeg() + set[i].ecart > o)
6285 || ((set[i].GetpFDeg() + set[i].ecart == o)
6286 && (set[i].ecart > p->ecart))
6287 || ((set[i].GetpFDeg() +set[i].ecart == o)
6288 && (set[i].ecart == p->ecart)
6289 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6290 an=i;
6291 else
6292 en=i;
6293 }
6294}

◆ posInLF5C()

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

Definition at line 5787 of file kutil.cc.

5789{
5790 return strat->Ll+1;
5791}

◆ posInLF5CRing()

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

Definition at line 5875 of file kutil.cc.

5877{
5878 if (length<0) return 0;
5879 if(start == (length +1)) return (length+1);
5880 int o = p->GetpFDeg();
5881 int op = set[length].GetpFDeg();
5882
5883 if ((op > o)
5884 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
5885 return length+1;
5886 int i;
5887 int an = start;
5888 int en= length;
5889 loop
5890 {
5891 if (an >= en-1)
5892 {
5893 op = set[an].GetpFDeg();
5894 if ((op > o)
5895 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
5896 return en;
5897 return an;
5898 }
5899 i=(an+en) / 2;
5900 op = set[i].GetpFDeg();
5901 if ((op > o)
5902 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
5903 an=i;
5904 else
5905 en=i;
5906 }
5907}

◆ posInLSig()

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

Definition at line 5669 of file kutil.cc.

5671{
5672 if (length<0) return 0;
5673 int cmp_int=currRing->OrdSgn;
5674 if (pLtCmp(set[length].sig,p->sig)==cmp_int)
5675 return length+1;
5676
5677 int i;
5678 int an = 0;
5679 int en= length;
5680 loop
5681 {
5682 if (an >= en-1)
5683 {
5684 if (pLtCmp(set[an].sig,p->sig) == cmp_int) return en;
5685 return an;
5686 }
5687 i=(an+en) / 2;
5688 if (pLtCmp(set[i].sig,p->sig) == cmp_int) an=i;
5689 else en=i;
5690 /*aend. fuer lazy == in !=- machen */
5691 }
5692}

◆ posInLSigRing()

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

Definition at line 5694 of file kutil.cc.

5696{
5697 assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
5698 if (length<0) return 0;
5699 if (pLtCmp(set[length].sig,p->sig)== 1)
5700 return length+1;
5701
5702 int an,en,i;
5703 an = 0;
5704 en = length+1;
5705 int cmp;
5706 loop
5707 {
5708 if (an >= en-1)
5709 {
5710 if(an == en)
5711 return en;
5712 cmp = pLtCmp(set[an].sig,p->sig);
5713 if (cmp == 1)
5714 return en;
5715 if (cmp == -1)
5716 return an;
5717 if (cmp == 0)
5718 {
5719 if (set[an].FDeg > p->FDeg)
5720 return en;
5721 if (set[an].FDeg < p->FDeg)
5722 return an;
5723 if (set[an].FDeg == p->FDeg)
5724 {
5725 cmp = pLtCmp(set[an].p,p->p);
5726 if(cmp == 1)
5727 return en;
5728 else
5729 return an;
5730 }
5731 }
5732 }
5733 i=(an+en) / 2;
5734 cmp = pLtCmp(set[i].sig,p->sig);
5735 if (cmp == 1)
5736 an = i;
5737 if (cmp == -1)
5738 en = i;
5739 if (cmp == 0)
5740 {
5741 if (set[i].FDeg > p->FDeg)
5742 an = i;
5743 if (set[i].FDeg < p->FDeg)
5744 en = i;
5745 if (set[i].FDeg == p->FDeg)
5746 {
5747 cmp = pLtCmp(set[i].p,p->p);
5748 if(cmp == 1)
5749 an = i;
5750 else
5751 en = i;
5752 }
5753 }
5754 }
5755}

◆ posInS()

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

Definition at line 4663 of file kutil.cc.

4665{
4666 if(length==-1) return 0;
4667 polyset set=strat->S;
4668 int i;
4669 int an = 0;
4670 int en = length;
4671 int cmp_int = currRing->OrdSgn;
4674 && (currRing->real_var_start==0)
4675#endif
4676#if 0
4677 || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
4678#endif
4679 )
4680 {
4681 int o=p_Deg(p,currRing);
4682 int oo=p_Deg(set[length],currRing);
4683
4684 if ((oo<o)
4685 || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
4686 return length+1;
4687
4688 loop
4689 {
4690 if (an >= en-1)
4691 {
4692 if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
4693 {
4694 return an;
4695 }
4696 return en;
4697 }
4698 i=(an+en) / 2;
4699 if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
4700 else an=i;
4701 }
4702 }
4703 else
4704 {
4706 {
4707 if (pLmCmp(set[length],p)== -cmp_int)
4708 return length+1;
4709 int cmp;
4710 loop
4711 {
4712 if (an >= en-1)
4713 {
4714 cmp = pLmCmp(set[an],p);
4715 if (cmp == cmp_int) return an;
4716 if (cmp == -cmp_int) return en;
4717 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
4718 return an;
4719 }
4720 i = (an+en) / 2;
4721 cmp = pLmCmp(set[i],p);
4722 if (cmp == cmp_int) en = i;
4723 else if (cmp == -cmp_int) an = i;
4724 else
4725 {
4726 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
4727 else en = i;
4728 }
4729 }
4730 }
4731 else
4732 if (pLmCmp(set[length],p)== -cmp_int)
4733 return length+1;
4734
4735 loop
4736 {
4737 if (an >= en-1)
4738 {
4739 if (pLmCmp(set[an],p) == cmp_int) return an;
4740 if (pLmCmp(set[an],p) == -cmp_int) return en;
4741 if ((cmp_int!=1)
4742 && ((strat->ecartS[an])>ecart_p))
4743 return an;
4744 return en;
4745 }
4746 i=(an+en) / 2;
4747 if (pLmCmp(set[i],p) == cmp_int) en=i;
4748 else if (pLmCmp(set[i],p) == -cmp_int) an=i;
4749 else
4750 {
4751 if ((cmp_int!=1)
4752 &&((strat->ecartS[i])<ecart_p))
4753 en=i;
4754 else
4755 an=i;
4756 }
4757 }
4758 }
4759}

◆ posInSMonFirst()

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

Definition at line 4764 of file kutil.cc.

4765{
4766 if (length<0) return 0;
4767 polyset set=strat->S;
4768 if(pNext(p) == NULL)
4769 {
4770 int mon = 0;
4771 for(int i = 0;i<=length;i++)
4772 {
4773 if(set[i] != NULL && pNext(set[i]) == NULL)
4774 mon++;
4775 }
4776 int o = p_Deg(p,currRing);
4777 int op = p_Deg(set[mon],currRing);
4778
4779 if ((op < o)
4780 || ((op == o) && (pLtCmp(set[mon],p) == -1)))
4781 return length+1;
4782 int i;
4783 int an = 0;
4784 int en= mon;
4785 loop
4786 {
4787 if (an >= en-1)
4788 {
4789 op = p_Deg(set[an],currRing);
4790 if ((op < o)
4791 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4792 return en;
4793 return an;
4794 }
4795 i=(an+en) / 2;
4796 op = p_Deg(set[i],currRing);
4797 if ((op < o)
4798 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4799 an=i;
4800 else
4801 en=i;
4802 }
4803 }
4804 else /*if(pNext(p) != NULL)*/
4805 {
4806 int o = p_Deg(p,currRing);
4807 int op = p_Deg(set[length],currRing);
4808
4809 if ((op < o)
4810 || ((op == o) && (pLtCmp(set[length],p) == -1)))
4811 return length+1;
4812 int i;
4813 int an = 0;
4814 for(i=0;i<=length;i++)
4815 if(set[i] != NULL && pNext(set[i]) == NULL)
4816 an++;
4817 int en= length;
4818 loop
4819 {
4820 if (an >= en-1)
4821 {
4822 op = p_Deg(set[an],currRing);
4823 if ((op < o)
4824 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4825 return en;
4826 return an;
4827 }
4828 i=(an+en) / 2;
4829 op = p_Deg(set[i],currRing);
4830 if ((op < o)
4831 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4832 an=i;
4833 else
4834 en=i;
4835 }
4836 }
4837}

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 5758 of file kutil.cc.

5759{
5760 if (strat->syzl==0) return 0;
5761 int cmp_int=currRing->OrdSgn;
5762 if (pLtCmp(strat->syz[strat->syzl-1],sig) != cmp_int)
5763 return strat->syzl;
5764 int i;
5765 int an = 0;
5766 int en= strat->syzl-1;
5767 loop
5768 {
5769 if (an >= en-1)
5770 {
5771 if (pLtCmp(strat->syz[an],sig) != cmp_int) return en;
5772 return an;
5773 }
5774 i=(an+en) / 2;
5775 if (pLtCmp(strat->syz[i],sig) != cmp_int) an=i;
5776 else en=i;
5777 /*aend. fuer lazy == in !=- machen */
5778 }
5779}

◆ posInT0()

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

Definition at line 4885 of file kutil.cc.

4886{
4887 return (length+1);
4888}

◆ posInT1()

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

Definition at line 4896 of file kutil.cc.

4897{
4898 if (length==-1) return 0;
4899
4900 if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
4901
4902 int i;
4903 int an = 0;
4904 int en= length;
4905 int cmp_int=currRing->OrdSgn;
4906
4907 loop
4908 {
4909 if (an >= en-1)
4910 {
4911 if (pLmCmp(set[an].p,p.p) == cmp_int) return an;
4912 return en;
4913 }
4914 i=(an+en) / 2;
4915 if (pLmCmp(set[i].p,p.p) == cmp_int) en=i;
4916 else an=i;
4917 }
4918}

◆ posInT11()

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

Definition at line 4953 of file kutil.cc.

4954{
4955 if (length==-1) return 0;
4956
4957 int o = p.GetpFDeg();
4958 int op = set[length].GetpFDeg();
4959 int cmp_int=currRing->OrdSgn;
4960
4961 if ((op < o)
4962 || ((op == o) && (pLmCmp(set[length].p,p.p) != cmp_int)))
4963 return length+1;
4964
4965 int i;
4966 int an = 0;
4967 int en= length;
4968
4969 loop
4970 {
4971 if (an >= en-1)
4972 {
4973 op= set[an].GetpFDeg();
4974 if ((op > o)
4975 || (( op == o) && (pLmCmp(set[an].p,p.p) == cmp_int)))
4976 return an;
4977 return en;
4978 }
4979 i=(an+en) / 2;
4980 op = set[i].GetpFDeg();
4981 if (( op > o)
4982 || (( op == o) && (pLmCmp(set[i].p,p.p) == cmp_int)))
4983 en=i;
4984 else
4985 an=i;
4986 }
4987}

◆ posInT110()

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

Definition at line 5029 of file kutil.cc.

5030{
5031 if (length==-1) return 0;
5032 p.GetpLength();
5033
5034 int o = p.GetpFDeg();
5035 int op = set[length].GetpFDeg();
5036 int cmp_int=currRing->OrdSgn;
5037
5038 if (( op < o)
5039 || (( op == o) && (set[length].length<p.length))
5040 || (( op == o) && (set[length].length == p.length)
5041 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5042 return length+1;
5043
5044 int i;
5045 int an = 0;
5046 int en= length;
5047 loop
5048 {
5049 if (an >= en-1)
5050 {
5051 op = set[an].GetpFDeg();
5052 if (( op > o)
5053 || (( op == o) && (set[an].length > p.length))
5054 || (( op == o) && (set[an].length == p.length)
5055 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5056 return an;
5057 return en;
5058 }
5059 i=(an+en) / 2;
5060 op = set[i].GetpFDeg();
5061 if (( op > o)
5062 || (( op == o) && (set[i].length > p.length))
5063 || (( op == o) && (set[i].length == p.length)
5064 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5065 en=i;
5066 else
5067 an=i;
5068 }
5069}

◆ posInT13()

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

Definition at line 5117 of file kutil.cc.

5118{
5119 if (length==-1) return 0;
5120
5121 int o = p.GetpFDeg();
5122
5123 if (set[length].GetpFDeg() <= o)
5124 return length+1;
5125
5126 int i;
5127 int an = 0;
5128 int en= length;
5129 loop
5130 {
5131 if (an >= en-1)
5132 {
5133 if (set[an].GetpFDeg() > o)
5134 return an;
5135 return en;
5136 }
5137 i=(an+en) / 2;
5138 if (set[i].GetpFDeg() > o)
5139 en=i;
5140 else
5141 an=i;
5142 }
5143}

◆ posInT15()

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

Definition at line 5184 of file kutil.cc.

5203{
5204 if (length==-1) return 0;
5205
5206 int o = p.GetpFDeg() + p.ecart;
5207 int op = set[length].GetpFDeg()+set[length].ecart;
5208 int cmp_int=currRing->OrdSgn;
5209
5210 if ((op < o)
5211 || ((op == o)
5212 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5213 return length+1;
5214
5215 int i;
5216 int an = 0;
5217 int en= length;
5218 loop
5219 {
5220 if (an >= en-1)
5221 {
5222 op = set[an].GetpFDeg()+set[an].ecart;
5223 if (( op > o)
5224 || (( op == o) && (pLmCmp(set[an].p,p.p) == cmp_int)))
5225 return an;
5226 return en;
5227 }
5228 i=(an+en) / 2;
5229 op = set[i].GetpFDeg()+set[i].ecart;
5230 if (( op > o)
5231 || (( op == o) && (pLmCmp(set[i].p,p.p) == cmp_int)))
5232 en=i;
5233 else
5234 an=i;
5235 }
5236}

◆ posInT17()

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

Definition at line 5278 of file kutil.cc.

5299{
5300 if (length==-1) return 0;
5301
5302 int o = p.GetpFDeg() + p.ecart;
5303 int op = set[length].GetpFDeg()+set[length].ecart;
5304 int cmp_int=currRing->OrdSgn;
5305
5306 if ((op < o)
5307 || (( op == o) && (set[length].ecart > p.ecart))
5308 || (( op == o) && (set[length].ecart==p.ecart)
5309 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5310 return length+1;
5311
5312 int i;
5313 int an = 0;
5314 int en= length;
5315 loop
5316 {
5317 if (an >= en-1)
5318 {
5319 op = set[an].GetpFDeg()+set[an].ecart;
5320 if (( op > o)
5321 || (( op == o) && (set[an].ecart < p.ecart))
5322 || (( op == o) && (set[an].ecart==p.ecart)
5323 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5324 return an;
5325 return en;
5326 }
5327 i=(an+en) / 2;
5328 op = set[i].GetpFDeg()+set[i].ecart;
5329 if ((op > o)
5330 || (( op == o) && (set[i].ecart < p.ecart))
5331 || (( op == o) && (set[i].ecart == p.ecart)
5332 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5333 en=i;
5334 else
5335 an=i;
5336 }
5337}

◆ posInT17_c()

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

Definition at line 5384 of file kutil.cc.

5385{
5386 if (length==-1) return 0;
5387
5388 int cc = (-1+2*currRing->order[0]==ringorder_c);
5389 /* cc==1 for (c,..), cc==-1 for (C,..) */
5390 int o = p.GetpFDeg() + p.ecart;
5391 int c = pGetComp(p.p)*cc;
5392 int cmp_int=currRing->OrdSgn;
5393
5394 if (pGetComp(set[length].p)*cc < c)
5395 return length+1;
5396 if (pGetComp(set[length].p)*cc == c)
5397 {
5398 int op = set[length].GetpFDeg()+set[length].ecart;
5399 if ((op < o)
5400 || ((op == o) && (set[length].ecart > p.ecart))
5401 || ((op == o) && (set[length].ecart==p.ecart)
5402 && (pLmCmp(set[length].p,p.p) != cmp_int)))
5403 return length+1;
5404 }
5405
5406 int i;
5407 int an = 0;
5408 int en= length;
5409 loop
5410 {
5411 if (an >= en-1)
5412 {
5413 if (pGetComp(set[an].p)*cc < c)
5414 return en;
5415 if (pGetComp(set[an].p)*cc == c)
5416 {
5417 int op = set[an].GetpFDeg()+set[an].ecart;
5418 if ((op > o)
5419 || ((op == o) && (set[an].ecart < p.ecart))
5420 || ((op == o) && (set[an].ecart==p.ecart)
5421 && (pLmCmp(set[an].p,p.p) == cmp_int)))
5422 return an;
5423 }
5424 return en;
5425 }
5426 i=(an+en) / 2;
5427 if (pGetComp(set[i].p)*cc > c)
5428 en=i;
5429 else if (pGetComp(set[i].p)*cc == c)
5430 {
5431 int op = set[i].GetpFDeg()+set[i].ecart;
5432 if ((op > o)
5433 || ((op == o) && (set[i].ecart < p.ecart))
5434 || ((op == o) && (set[i].ecart == p.ecart)
5435 && (pLmCmp(set[i].p,p.p) == cmp_int)))
5436 en=i;
5437 else
5438 an=i;
5439 }
5440 else
5441 an=i;
5442 }
5443}

◆ posInT19()

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

Definition at line 5510 of file kutil.cc.

5511{
5512 p.GetpLength();
5513 if (length==-1) return 0;
5514
5515 int o = p.ecart;
5516 int op=p.GetpFDeg();
5517
5518 if (set[length].ecart < o)
5519 return length+1;
5520 if (set[length].ecart == o)
5521 {
5522 int oo=set[length].GetpFDeg();
5523 if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5524 return length+1;
5525 }
5526
5527 int i;
5528 int an = 0;
5529 int en= length;
5530 loop
5531 {
5532 if (an >= en-1)
5533 {
5534 if (set[an].ecart > o)
5535 return an;
5536 if (set[an].ecart == o)
5537 {
5538 int oo=set[an].GetpFDeg();
5539 if((oo > op)
5540 || ((oo==op) && (set[an].length > p.length)))
5541 return an;
5542 }
5543 return en;
5544 }
5545 i=(an+en) / 2;
5546 if (set[i].ecart > o)
5547 en=i;
5548 else if (set[i].ecart == o)
5549 {
5550 int oo=set[i].GetpFDeg();
5551 if ((oo > op)
5552 || ((oo == op) && (set[i].length > p.length)))
5553 en=i;
5554 else
5555 an=i;
5556 }
5557 else
5558 an=i;
5559 }
5560}

◆ posInT2()

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

Definition at line 4925 of file kutil.cc.

4926{
4927 if (length==-1) return 0;
4928 p.GetpLength();
4929 if (set[length].length<p.length) return length+1;
4930
4931 int i;
4932 int an = 0;
4933 int en= length;
4934
4935 loop
4936 {
4937 if (an >= en-1)
4938 {
4939 if (set[an].length>p.length) return an;
4940 return en;
4941 }
4942 i=(an+en) / 2;
4943 if (set[i].length>p.length) en=i;
4944 else an=i;
4945 }
4946}

◆ posInT_EcartFDegpLength()

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

Definition at line 11381 of file kutil.cc.

11382{
11383
11384 if (length==-1) return 0;
11385
11386 int o = p.ecart;
11387 int op=p.GetpFDeg();
11388 int ol = p.GetpLength();
11389
11390 if (set[length].ecart < o)
11391 return length+1;
11392 if (set[length].ecart == o)
11393 {
11394 int oo=set[length].GetpFDeg();
11395 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11396 return length+1;
11397 }
11398
11399 int i;
11400 int an = 0;
11401 int en= length;
11402 loop
11403 {
11404 if (an >= en-1)
11405 {
11406 if (set[an].ecart > o)
11407 return an;
11408 if (set[an].ecart == o)
11409 {
11410 int oo=set[an].GetpFDeg();
11411 if((oo > op)
11412 || ((oo==op) && (set[an].pLength > ol)))
11413 return an;
11414 }
11415 return en;
11416 }
11417 i=(an+en) / 2;
11418 if (set[i].ecart > o)
11419 en=i;
11420 else if (set[i].ecart == o)
11421 {
11422 int oo=set[i].GetpFDeg();
11423 if ((oo > op)
11424 || ((oo == op) && (set[i].pLength > ol)))
11425 en=i;
11426 else
11427 an=i;
11428 }
11429 else
11430 an=i;
11431 }
11432}

◆ posInT_EcartpLength()

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

Definition at line 5146 of file kutil.cc.

5147{
5148 if (length==-1) return 0;
5149 int ol = p.GetpLength();
5150 int op=p.ecart;
5151 int oo=set[length].ecart;
5152
5153 if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5154 return length+1;
5155
5156 int i;
5157 int an = 0;
5158 int en= length;
5159 loop
5160 {
5161 if (an >= en-1)
5162 {
5163 int oo=set[an].ecart;
5164 if((oo > op)
5165 || ((oo==op) && (set[an].pLength > ol)))
5166 return an;
5167 return en;
5168 }
5169 i=(an+en) / 2;
5170 int oo=set[i].ecart;
5171 if ((oo > op)
5172 || ((oo == op) && (set[i].pLength > ol)))
5173 en=i;
5174 else
5175 an=i;
5176 }
5177}

◆ posInT_FDegpLength()

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

Definition at line 11435 of file kutil.cc.

11436{
11437
11438 if (length==-1) return 0;
11439
11440 int op=p.GetpFDeg();
11441 int ol = p.GetpLength();
11442
11443 int oo=set[length].GetpFDeg();
11444 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11445 return length+1;
11446
11447 int i;
11448 int an = 0;
11449 int en= length;
11450 loop
11451 {
11452 if (an >= en-1)
11453 {
11454 int oo=set[an].GetpFDeg();
11455 if((oo > op)
11456 || ((oo==op) && (set[an].pLength > ol)))
11457 return an;
11458 return en;
11459 }
11460 i=(an+en) / 2;
11461 int oo=set[i].GetpFDeg();
11462 if ((oo > op)
11463 || ((oo == op) && (set[i].pLength > ol)))
11464 en=i;
11465 else
11466 an=i;
11467 }
11468}

◆ posInT_pLength()

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

Definition at line 11472 of file kutil.cc.

11473{
11474 int ol = p.GetpLength();
11475 if (length==-1)
11476 return 0;
11477 if (set[length].length<p.length)
11478 return length+1;
11479
11480 int i;
11481 int an = 0;
11482 int en= length;
11483
11484 loop
11485 {
11486 if (an >= en-1)
11487 {
11488 if (set[an].pLength>ol) return an;
11489 return en;
11490 }
11491 i=(an+en) / 2;
11492 if (set[i].pLength>ol) en=i;
11493 else an=i;
11494 }
11495}

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

10706{
10707 if(!nCoeff_is_Z(currRing->cf))
10708 return;
10709 poly pH = h->GetP();
10710 poly p,pp;
10711 p = pH;
10712 bool deleted = FALSE, ok = FALSE;
10713 for(int i = 0; i<=strat->sl; i++)
10714 {
10715 p = pH;
10716 if(pNext(strat->S[i]) == NULL)
10717 {
10718 //pWrite(p);
10719 //pWrite(strat->S[i]);
10720 while(ok == FALSE && p != NULL)
10721 {
10722 if(pLmDivisibleBy(strat->S[i], p)
10724 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
10725#endif
10726 )
10727 {
10728 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10730 }
10731 if(nIsZero(p->coef))
10732 {
10733 pLmDelete(&p);
10734 h->p = p;
10735 deleted = TRUE;
10736 }
10737 else
10738 {
10739 ok = TRUE;
10740 }
10741 }
10742 if (p!=NULL)
10743 {
10744 pp = pNext(p);
10745 while(pp != NULL)
10746 {
10747 if(pLmDivisibleBy(strat->S[i], pp)
10749 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
10750#endif
10751 )
10752 {
10753 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10755 if(nIsZero(pp->coef))
10756 {
10757 pLmDelete(&pNext(p));
10758 pp = pNext(p);
10759 deleted = TRUE;
10760 }
10761 else
10762 {
10763 p = pp;
10764 pp = pNext(p);
10765 }
10766 }
10767 else
10768 {
10769 p = pp;
10770 pp = pNext(p);
10771 }
10772 }
10773 }
10774 }
10775 }
10776 h->SetLmCurrRing();
10777 if((deleted)&&(h->p!=NULL))
10778 strat->initEcart(h);
10779}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 10781 of file kutil.cc.

10782{
10783 if(!nCoeff_is_Z(currRing->cf))
10784 return;
10785 poly hSig = h->sig;
10786 poly pH = h->GetP();
10787 poly p,pp;
10788 p = pH;
10789 bool deleted = FALSE, ok = FALSE;
10790 for(int i = 0; i<=strat->sl; i++)
10791 {
10792 p = pH;
10793 if(pNext(strat->S[i]) == NULL)
10794 {
10795 while(ok == FALSE && p!=NULL)
10796 {
10797 if(pLmDivisibleBy(strat->S[i], p))
10798 {
10799 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10800 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10801 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10802 {
10803 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10805 }
10806 pDelete(&sigMult);
10807 }
10808 if(nIsZero(p->coef))
10809 {
10810 pLmDelete(&p);
10811 h->p = p;
10812 deleted = TRUE;
10813 }
10814 else
10815 {
10816 ok = TRUE;
10817 }
10818 }
10819 if(p == NULL)
10820 return;
10821 pp = pNext(p);
10822 while(pp != NULL)
10823 {
10824 if(pLmDivisibleBy(strat->S[i], pp))
10825 {
10826 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
10827 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
10828 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
10829 {
10830 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10832 if(nIsZero(pp->coef))
10833 {
10834 pLmDelete(&pNext(p));
10835 pp = pNext(p);
10836 deleted = TRUE;
10837 }
10838 else
10839 {
10840 p = pp;
10841 pp = pNext(p);
10842 }
10843 }
10844 else
10845 {
10846 p = pp;
10847 pp = pNext(p);
10848 }
10849 pDelete(&sigMult);
10850 }
10851 else
10852 {
10853 p = pp;
10854 pp = pNext(p);
10855 }
10856 }
10857 }
10858 }
10859 h->SetLmCurrRing();
10860 if(deleted)
10861 strat->initEcart(h);
10862
10863}
#define ppMult_mm(p, m)
Definition polys.h:202
#define pDivideM(a, b)
Definition polys.h:295

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

10542{
10544 ideal F = idCopy(Forig);
10545 idSkipZeroes(F);
10546 poly pmon;
10548 ideal monred = idInit(1,1);
10549 for(int i=0; i<idElem(F); i++)
10550 {
10551 if(pNext(F->m[i]) == NULL)
10552 idInsertPoly(monred, pCopy(F->m[i]));
10553 }
10554 int posconst = idPosConstant(F);
10555 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10556 {
10557 idDelete(&F);
10558 idDelete(&monred);
10559 return NULL;
10560 }
10561 int idelemQ = 0;
10562 if(Q!=NULL)
10563 {
10564 idelemQ = IDELEMS(Q);
10565 for(int i=0; i<idelemQ; i++)
10566 {
10567 if(pNext(Q->m[i]) == NULL)
10568 idInsertPoly(monred, pCopy(Q->m[i]));
10569 }
10572 //the constant, if found, will be from Q
10573 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10574 {
10575 pmon = pCopy(monred->m[posconst]);
10576 idDelete(&F);
10577 idDelete(&monred);
10578 return pmon;
10579 }
10580 }
10582 nKillChar(QQ_ring->cf);
10583 QQ_ring->cf = nInitChar(n_Q, NULL);
10584 rComplete(QQ_ring,1);
10587 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10589 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10590 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10591 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10592 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10594 idSkipZeroes(one);
10595 if(idIsConstant(one))
10596 {
10597 //one should be <1>
10598 for(int i = IDELEMS(II)-1; i>=0; i--)
10599 if(II->m[i] != NULL)
10600 II->m[i+1] = II->m[i];
10601 II->m[0] = pOne();
10603 poly integer = NULL;
10604 for(int i = IDELEMS(syz)-1;i>=0; i--)
10605 {
10606 if(pGetComp(syz->m[i]) == 1)
10607 {
10608 pSetComp(syz->m[i],0);
10609 if(pIsConstant(pHead(syz->m[i])))
10610 {
10611 integer = pHead(syz->m[i]);
10612 break;
10613 }
10614 }
10615 }
10617 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10619 idDelete(&monred);
10620 idDelete(&F);
10622 id_Delete(&one,QQ_ring);
10623 id_Delete(&syz,QQ_ring);
10626 return pmon;
10627 }
10628 else
10629 {
10630 if(idIs0(monred))
10631 {
10632 poly mindegmon = NULL;
10633 for(int i = 0; i<IDELEMS(one); i++)
10634 {
10635 if(pNext(one->m[i]) == NULL)
10636 {
10637 if(mindegmon == NULL)
10638 mindegmon = pCopy(one->m[i]);
10639 else
10640 {
10641 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10642 mindegmon = pCopy(one->m[i]);
10643 }
10644 }
10645 }
10646 if(mindegmon != NULL)
10647 {
10648 for(int i = IDELEMS(II)-1; i>=0; i--)
10649 if(II->m[i] != NULL)
10650 II->m[i+1] = II->m[i];
10651 II->m[0] = pCopy(mindegmon);
10653 bool found = FALSE;
10654 for(int i = IDELEMS(syz)-1;i>=0; i--)
10655 {
10656 if(pGetComp(syz->m[i]) == 1)
10657 {
10658 pSetComp(syz->m[i],0);
10659 if(pIsConstant(pHead(syz->m[i])))
10660 {
10661 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10662 found = TRUE;
10663 break;
10664 }
10665 }
10666 }
10667 id_Delete(&syz,QQ_ring);
10668 if (found == FALSE)
10669 {
10671 idDelete(&monred);
10672 idDelete(&F);
10674 id_Delete(&one,QQ_ring);
10676 return NULL;
10677 }
10679 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10681 idDelete(&monred);
10682 idDelete(&F);
10684 id_Delete(&one,QQ_ring);
10685 id_Delete(&syz,QQ_ring);
10687 return pmon;
10688 }
10689 }
10690 }
10692 idDelete(&monred);
10693 idDelete(&F);
10695 id_Delete(&one,QQ_ring);
10697 return NULL;
10698}
Matrices of numbers.
Definition bigintmat.h:51
@ 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:703
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:563
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:836
#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 kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2611
void rChangeCurrRing(ring r)
Definition polys.cc:16
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:3527
ring rAssure_c_dp(const ring r)
Definition ring.cc:5134
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
static int idElem(const ideal F)
number of non-zero polys in F
@ isNotHomog
Definition structs.h:32

◆ redEcart()

int redEcart ( LObject h,
kStrategy  strat 
)

Definition at line 168 of file kstd1.cc.

169{
170 int i,at,ei,li,ii;
171 int j = 0;
172 int pass = 0;
173 long d,reddeg;
174
175 d = h->GetpFDeg()+ h->ecart;
176 reddeg = strat->LazyDegree+d;
177 h->SetShortExpVector();
178 loop
179 {
180 j = kFindDivisibleByInT(strat, h);
181 if (j < 0)
182 {
183 if (strat->honey) h->SetLength(strat->length_pLength);
184 return 1;
185 }
186
187 ei = strat->T[j].ecart;
188 ii = j;
189
190 if (ei > h->ecart)
191 {
192 unsigned long not_sev=~h->sev;
193 poly h_t= h->GetLmTailRing();
194 li = strat->T[j].length;
195 if (li<=0) li=strat->T[j].GetpLength();
196 // the polynomial to reduce with (up to the moment) is;
197 // pi with ecart ei and length li
198 // look for one with smaller ecart
199 i = j;
200 loop
201 {
202 /*- takes the first possible with respect to ecart -*/
203 i++;
204 if (i > strat->tl) break;
205#if 1
206 if (strat->T[i].length<=0) strat->T[i].GetpLength();
207 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
208 strat->T[i].length < li))
209 &&
210 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h_t, not_sev, strat->tailRing))
211#else
212 j = kFindDivisibleByInT(strat, h, i);
213 if (j < 0) break;
214 i = j;
215 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
216 strat->T[i].length < li))
217#endif
218 {
219 // the polynomial to reduce with is now
220 ii = i;
221 ei = strat->T[i].ecart;
222 if (ei <= h->ecart) break;
223 li = strat->T[i].length;
224 }
225 }
226 }
227
228 // end of search: have to reduce with pi
229 if ((ei > h->ecart)&&(strat->kNoether==NULL))
230 {
231 // It is not possible to reduce h with smaller ecart;
232 // if possible h goes to the lazy-set L,i.e
233 // if its position in L would be not the last one
234 strat->fromT = TRUE;
235 if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
236 {
237 h->SetLmCurrRing();
238 if (strat->honey && strat->posInLDependsOnLength)
239 h->SetLength(strat->length_pLength);
240 assume(h->FDeg == h->pFDeg());
241 at = strat->posInL(strat->L,strat->Ll,h,strat);
242 if (at <= strat->Ll)
243 {
244 /*- h will not become the next element to reduce -*/
245 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
246#ifdef KDEBUG
247 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
248#endif
249 h->Clear();
250 strat->fromT = FALSE;
251 return -1;
252 }
253 }
254 }
255
256 // now we finally can reduce
257 doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
258 strat->fromT=FALSE;
259
260 // are we done ???
261 if (h->IsNull())
262 {
264 kDeleteLcm(h);
265 h->Clear();
266 return 0;
267 }
268 if (TEST_OPT_IDLIFT)
269 {
270 if (h->p!=NULL)
271 {
272 if(p_GetComp(h->p,currRing)>strat->syzComp)
273 {
274 h->Delete();
275 return 0;
276 }
277 }
278 else // if (h->t_p!=NULL)
279 {
280 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
281 {
282 h->Delete();
283 return 0;
284 }
285 }
286 }
287 #if 0
288 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
289 {
290 if (h->p!=NULL)
291 {
292 if(p_GetComp(h->p,currRing)>strat->syzComp)
293 {
294 return 1;
295 }
296 }
297 else // if (h->t_p!=NULL)
298 {
299 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
300 {
301 return 1;
302 }
303 }
304 }
305 #endif
306
307 // done ? NO!
308 h->SetShortExpVector();
309 h->SetpFDeg();
310 if (strat->honey)
311 {
312 if (ei <= h->ecart)
313 h->ecart = d-h->GetpFDeg();
314 else
315 h->ecart = d-h->GetpFDeg()+ei-h->ecart;
316 }
317 else
318 // this has the side effect of setting h->length
319 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
320#if 0
321 if (strat->syzComp!=0)
322 {
323 if ((strat->syzComp>0) && (h->Comp() > strat->syzComp))
324 {
325 assume(h->MinComp() > strat->syzComp);
326 if (strat->honey) h->SetLength();
327#ifdef KDEBUG
328 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
329#endif
330 return -2;
331 }
332 }
333#endif
334 /*- try to reduce the s-polynomial -*/
335 pass++;
336 d = h->GetpFDeg()+h->ecart;
337 /*
338 *test whether the polynomial should go to the lazyset L
339 *-if the degree jumps
340 *-if the number of pre-defined reductions jumps
341 */
342 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
343 && ((d >= reddeg) || (pass > strat->LazyPass)))
344 {
345 h->SetLmCurrRing();
346 if (strat->honey && strat->posInLDependsOnLength)
347 h->SetLength(strat->length_pLength);
348 assume(h->FDeg == h->pFDeg());
349 at = strat->posInL(strat->L,strat->Ll,h,strat);
350 if (at <= strat->Ll)
351 {
352 int dummy=strat->sl;
353 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
354 {
355 if (strat->honey && !strat->posInLDependsOnLength)
356 h->SetLength(strat->length_pLength);
357 return 1;
358 }
359 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
360#ifdef KDEBUG
361 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
362#endif
363 h->Clear();
364 return -1;
365 }
366 }
367 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
368 {
369 Print(".%ld",d);mflush();
370 reddeg = d+1;
371 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
372 {
373 strat->overflow=TRUE;
374 //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
375 h->GetP();
376 at = strat->posInL(strat->L,strat->Ll,h,strat);
377 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
378 h->Clear();
379 return -1;
380 }
381 }
382 }
383}
char length_pLength
Definition kutil.h:386
static int doRed(LObject *h, TObject *with, BOOLEAN intoT, kStrategy strat, bool redMoraNF)
Definition kstd1.cc:118
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:468
#define TEST_OPT_REDTHROUGH
Definition options.h:124
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:119

◆ redFirst()

int redFirst ( LObject h,
kStrategy  strat 
)

Definition at line 794 of file kstd1.cc.

795{
796 if (strat->tl<0) return 1;
797 if (h->IsNull()) return 0;
798
799 int at;
800 long reddeg,d;
801 int pass = 0;
802 int cnt = RED_CANONICALIZE;
803 int j = 0;
804
805 reddeg = d = h->GetpFDeg();
806 if (! strat->homog)
807 {
808 d += h->ecart;
809 reddeg = strat->LazyDegree+d;
810 }
811 h->SetShortExpVector();
812 loop
813 {
814 j = kFindDivisibleByInT(strat, h);
815 if (j < 0)
816 {
817 h->SetDegStuffReturnLDeg(strat->LDegLast);
818 return 1;
819 }
820
822 strat->T[j].pNorm();
823#ifdef KDEBUG
824 if (TEST_OPT_DEBUG)
825 {
826 PrintS("reduce ");
827 h->wrp();
828 PrintS(" with ");
829 strat->T[j].wrp();
830 }
831#endif
832 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
833#ifdef KDEBUG
834 if (TEST_OPT_DEBUG)
835 {
836 PrintS(" to ");
837 wrp(h->p);
838 PrintLn();
839 }
840#endif
841 if (h->IsNull())
842 {
844 kDeleteLcm(h);
845 h->Clear();
846 return 0;
847 }
848 if (TEST_OPT_IDLIFT)
849 {
850 if (h->p!=NULL)
851 {
852 if(p_GetComp(h->p,currRing)>strat->syzComp)
853 {
854 h->Delete();
855 return 0;
856 }
857 }
858 else // if (h->t_p!=NULL)
859 {
860 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
861 {
862 h->Delete();
863 return 0;
864 }
865 }
866 }
867 #if 0
868 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
869 {
870 if (h->p!=NULL)
871 {
872 if(p_GetComp(h->p,currRing)>strat->syzComp)
873 {
874 return 1;
875 }
876 }
877 else // if (h->t_p!=NULL)
878 {
879 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
880 {
881 return 1;
882 }
883 }
884 }
885 #endif
886 h->SetShortExpVector();
887
888#if 0
889 if ((strat->syzComp!=0) && !strat->honey)
890 {
891 if ((strat->syzComp>0) &&
892 (h->Comp() > strat->syzComp))
893 {
894 assume(h->MinComp() > strat->syzComp);
895#ifdef KDEBUG
896 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
897#endif
898 if (strat->homog)
899 h->SetDegStuffReturnLDeg(strat->LDegLast);
900 return -2;
901 }
902 }
903#endif
904 if (!strat->homog)
905 {
906 if (!TEST_OPT_OLDSTD && strat->honey)
907 {
908 h->SetpFDeg();
909 if (strat->T[j].ecart <= h->ecart)
910 h->ecart = d - h->GetpFDeg();
911 else
912 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
913
914 d = h->GetpFDeg() + h->ecart;
915 }
916 else
917 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
918 /*- try to reduce the s-polynomial -*/
919 cnt--;
920 pass++;
921 /*
922 *test whether the polynomial should go to the lazyset L
923 *-if the degree jumps
924 *-if the number of pre-defined reductions jumps
925 */
926 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
927 && ((d >= reddeg) || (pass > strat->LazyPass)))
928 {
929 h->SetLmCurrRing();
930 if (strat->posInLDependsOnLength)
931 h->SetLength(strat->length_pLength);
932 at = strat->posInL(strat->L,strat->Ll,h,strat);
933 if (at <= strat->Ll)
934 {
935 int dummy=strat->sl;
936 if (kFindDivisibleByInS(strat,&dummy, h) < 0)
937 return 1;
938 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
939#ifdef KDEBUG
940 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
941#endif
942 h->Clear();
943 return -1;
944 }
945 }
946 if (UNLIKELY(cnt==0))
947 {
948 h->CanonicalizeP();
950 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
951 }
952 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
953 {
954 reddeg = d+1;
955 Print(".%ld",d);mflush();
956 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
957 {
958 strat->overflow=TRUE;
959 //Print("OVERFLOW in redFirst d=%ld, max=%ld",d,strat->tailRing->bitmask);
960 h->GetP();
961 at = strat->posInL(strat->L,strat->Ll,h,strat);
962 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
963 h->Clear();
964 return -1;
965 }
966 }
967 }
968 }
969}
#define UNLIKELY(X)
Definition auxiliary.h:405
#define RED_CANONICALIZE
Definition kutil.h:37

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4973 of file kstd2.cc.

4974{
4975 if (h->IsNull()) return 0;
4976
4977 int at, reddeg,d;
4978 int pass = 0;
4979 int j = 0;
4980
4981 if (! strat->homog)
4982 {
4983 d = h->GetpFDeg() + h->ecart;
4984 reddeg = strat->LazyDegree+d;
4985 }
4986 h->SetShortExpVector();
4987 loop
4988 {
4989 j = kFindDivisibleByInT(strat, h);
4990 if (j < 0)
4991 {
4992 h->SetDegStuffReturnLDeg(strat->LDegLast);
4993 return 1;
4994 }
4995
4997 strat->T[j].pNorm();
4998#ifdef KDEBUG
4999 if (TEST_OPT_DEBUG)
5000 {
5001 PrintS("reduce ");
5002 h->wrp();
5003 PrintS(" with ");
5004 strat->T[j].wrp();
5005 }
5006#endif
5007 ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
5008
5009#ifdef KDEBUG
5010 if (TEST_OPT_DEBUG)
5011 {
5012 PrintS("\nto ");
5013 wrp(h->p);
5014 PrintLn();
5015 }
5016#endif
5017 if (h->IsNull())
5018 {
5019 kDeleteLcm(h);
5020 h->Clear();
5021 return 0;
5022 }
5023 h->SetShortExpVector();
5024
5025#if 0
5026 if ((strat->syzComp!=0) && !strat->honey)
5027 {
5028 if ((strat->syzComp>0) &&
5029 (h->Comp() > strat->syzComp))
5030 {
5031 assume(h->MinComp() > strat->syzComp);
5032#ifdef KDEBUG
5033 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
5034#endif
5035 if (strat->homog)
5036 h->SetDegStuffReturnLDeg(strat->LDegLast);
5037 return -2;
5038 }
5039 }
5040#endif
5041 if (!strat->homog)
5042 {
5043 if (!TEST_OPT_OLDSTD && strat->honey)
5044 {
5045 h->SetpFDeg();
5046 if (strat->T[j].ecart <= h->ecart)
5047 h->ecart = d - h->GetpFDeg();
5048 else
5049 h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
5050
5051 d = h->GetpFDeg() + h->ecart;
5052 }
5053 else
5054 d = h->SetDegStuffReturnLDeg(strat->LDegLast);
5055 /*- try to reduce the s-polynomial -*/
5056 pass++;
5057 /*
5058 *test whether the polynomial should go to the lazyset L
5059 *-if the degree jumps
5060 *-if the number of pre-defined reductions jumps
5061 */
5062 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
5063 && ((d >= reddeg) || (pass > strat->LazyPass)))
5064 {
5065 h->SetLmCurrRing();
5066 if (strat->posInLDependsOnLength)
5067 h->SetLength(strat->length_pLength);
5068 at = strat->posInL(strat->L,strat->Ll,h,strat);
5069 if (at <= strat->Ll)
5070 {
5071 //int dummy=strat->sl;
5072 /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */
5073 //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0)
5074 if (kFindDivisibleByInT(strat, h) < 0)
5075 return 1;
5076 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
5077#ifdef KDEBUG
5078 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
5079#endif
5080 h->Clear();
5081 return -1;
5082 }
5083 }
5084 if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
5085 {
5086 reddeg = d+1;
5087 Print(".%d",d);mflush();
5088 }
5089 }
5090 }
5091}

◆ redHomog()

int redHomog ( 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 assume(h->FDeg == h->pFDeg());
1159
1160 poly h_p;
1161 int i,j,at,pass,cnt,ii;
1162 // long reddeg,d;
1163 int li;
1165
1166 pass = j = 0;
1167 cnt = RED_CANONICALIZE;
1168 h->SetShortExpVector();
1169 h_p = h->GetLmTailRing();
1170 h->PrepareRed(strat->use_buckets);
1171 loop
1172 {
1173 j = kFindDivisibleByInT(strat, h);
1174 if (j < 0) return 1;
1175
1176 li = strat->T[j].pLength;
1177 ii = j;
1178 /*
1179 * the polynomial to reduce with (up to the moment) is;
1180 * pi with length li
1181 */
1182 i = j;
1183#if 1
1184 if (test_opt_length)
1185 {
1186 if (li<=0) li=strat->T[j].GetpLength();
1187 if (li>2)
1188 {
1189 unsigned long not_sev = ~ h->sev;
1190 loop
1191 {
1192 /*- search the shortest possible with respect to length -*/
1193 i++;
1194 if (i > strat->tl)
1195 break;
1196 if ((strat->T[i].pLength < li)
1197 &&
1198 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1199 h_p, not_sev, strat->tailRing))
1200 {
1201 /*
1202 * the polynomial to reduce with is now;
1203 */
1204 li = strat->T[i].pLength;
1205 if (li<=0) li=strat->T[i].GetpLength();
1206 ii = i;
1207 if (li<3) break;
1208 }
1209 }
1210 }
1211 }
1212#endif
1213
1214 /*
1215 * end of search: have to reduce with pi
1216 */
1217#ifdef KDEBUG
1218 if (TEST_OPT_DEBUG)
1219 {
1220 PrintS("red:");
1221 h->wrp();
1222 PrintS(" with ");
1223 strat->T[ii].wrp();
1224 }
1225#endif
1226 assume(strat->fromT == FALSE);
1227
1228 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1229#if SBA_PRINT_REDUCTION_STEPS
1231#endif
1232#if SBA_PRINT_OPERATIONS
1234#endif
1235
1236#ifdef KDEBUG
1237 if (TEST_OPT_DEBUG)
1238 {
1239 PrintS("\nto ");
1240 h->wrp();
1241 PrintLn();
1242 }
1243#endif
1244
1245 h_p = h->GetLmTailRing();
1246 if (h_p == NULL)
1247 {
1248 kDeleteLcm(h);
1249 return 0;
1250 }
1252 {
1253 if (h->p!=NULL)
1254 {
1255 if(p_GetComp(h->p,currRing)>strat->syzComp)
1256 {
1257 h->Delete();
1258 return 0;
1259 }
1260 }
1261 else //if (h->t_p!=NULL)
1262 {
1263 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1264 {
1265 h->Delete();
1266 return 0;
1267 }
1268 }
1269 }
1270 #if 0
1271 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
1272 {
1273 if (h->p!=NULL)
1274 {
1275 if(p_GetComp(h->p,currRing)>strat->syzComp)
1276 {
1277 return 1;
1278 }
1279 }
1280 else // if (h->t_p!=NULL)
1281 {
1282 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
1283 {
1284 return 1;
1285 }
1286 }
1287 }
1288 #endif
1289 h->SetShortExpVector();
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 cnt--;
1297 pass++;
1298 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1299 {
1300 h->SetLmCurrRing();
1301 at = strat->posInL(strat->L,strat->Ll,h,strat);
1302 if (at <= strat->Ll)
1303 {
1304#ifdef HAVE_SHIFTBBA
1305 if (rIsLPRing(currRing))
1306 {
1307 if (kFindDivisibleByInT(strat, h) < 0)
1308 return 1;
1309 }
1310 else
1311#endif
1312 {
1313 int dummy=strat->sl;
1314 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1315 return 1;
1316 }
1317 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1318#ifdef KDEBUG
1319 if (TEST_OPT_DEBUG)
1320 Print(" lazy: -> L%d\n",at);
1321#endif
1322 h->Clear();
1323 return -1;
1324 }
1325 }
1326 else if (UNLIKELY(cnt==0))
1327 {
1328 h->CanonicalizeP();
1329 cnt=RED_CANONICALIZE;
1330 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
1331 }
1332 }
1333}

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 2114 of file kstd2.cc.

2115{
2116 if (strat->tl<0) return 1;
2117 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
2118 assume(h->FDeg == h->pFDeg());
2119 int j,at,pass,ei, ii, h_d;
2120 long reddeg,d;
2121
2122 pass = j = 0;
2123 d = reddeg = h->GetpFDeg() + h->ecart;
2124 h->SetShortExpVector();
2125
2126 h->PrepareRed(strat->use_buckets);
2127 loop
2128 {
2129 j=kFindDivisibleByInT_ecart(strat, h, h->ecart);
2130 if (j < 0) return 1;
2131
2132 ii = j;
2133 ei = strat->T[ii].ecart;
2134 /*
2135 * the polynomial to reduce with (up to the moment) is;
2136 * pi with ecart ei (T[ii])
2137 */
2138
2139 /*
2140 * end of search: have to reduce with pi
2141 */
2142 if (UNLIKELY(!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart)))
2143 {
2144 h->GetTP(); // clears bucket
2145 h->SetLmCurrRing();
2146 /*
2147 * It is not possible to reduce h with smaller ecart;
2148 * if possible h goes to the lazy-set L,i.e
2149 * if its position in L would be not the last one
2150 */
2151 if (strat->Ll >= 0) /* L is not empty */
2152 {
2153 at = strat->posInL(strat->L,strat->Ll,h,strat);
2154 if(at <= strat->Ll)
2155 /*- h will not become the next element to reduce -*/
2156 {
2157 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2158#ifdef KDEBUG
2159 if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
2160#endif
2161 h->Clear();
2162 return -1;
2163 }
2164 }
2165 }
2166#ifdef KDEBUG
2167 if (TEST_OPT_DEBUG)
2168 {
2169 PrintS("red:");
2170 h->wrp();
2171 Print("\nwith T[%d]:",ii);
2172 strat->T[ii].wrp();
2173 }
2174#endif
2175 assume(strat->fromT == FALSE);
2176
2177 ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,NULL, strat);
2178#if SBA_PRINT_REDUCTION_STEPS
2180#endif
2181#if SBA_PRINT_OPERATIONS
2182 sba_interreduction_operations += strat->T[ii].pLength;
2183#endif
2184#ifdef KDEBUG
2185 if (TEST_OPT_DEBUG)
2186 {
2187 PrintS("\nto:");
2188 h->wrp();
2189 PrintLn();
2190 }
2191#endif
2192 if(h->IsNull())
2193 {
2194 kDeleteLcm(h);
2195 h->Clear();
2196 return 0;
2197 }
2199 {
2200 if (h->p!=NULL)
2201 {
2202 if(p_GetComp(h->p,currRing)>strat->syzComp)
2203 {
2204 h->Delete();
2205 return 0;
2206 }
2207 }
2208 else //if (h->t_p!=NULL)
2209 {
2210 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2211 {
2212 h->Delete();
2213 return 0;
2214 }
2215 }
2216 }
2217 else
2218 if (UNLIKELY((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ)))
2219 {
2220 if (h->p!=NULL)
2221 {
2222 if(p_GetComp(h->p,currRing)>strat->syzComp)
2223 {
2224 return 1;
2225 }
2226 }
2227 else // if (h->t_p!=NULL)
2228 {
2229 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2230 {
2231 return 1;
2232 }
2233 }
2234 }
2235 h->SetShortExpVector();
2236 h_d = h->SetpFDeg();
2237 /* compute the ecart */
2238 if (ei <= h->ecart)
2239 h->ecart = d-h_d;
2240 else
2241 h->ecart = d-h_d+ei-h->ecart;
2242
2243 /*
2244 * try to reduce the s-polynomial h
2245 *test first whether h should go to the lazyset L
2246 *-if the degree jumps
2247 *-if the number of pre-defined reductions jumps
2248 */
2249 pass++;
2250 d = h_d + h->ecart;
2252 && (strat->Ll >= 0)
2253 && ((d > reddeg) || (pass > strat->LazyPass))))
2254 {
2255 h->GetTP(); // clear bucket
2256 h->SetLmCurrRing();
2257 at = strat->posInL(strat->L,strat->Ll,h,strat);
2258 if (at <= strat->Ll)
2259 {
2260#ifdef HAVE_SHIFTBBA
2261 if (rIsLPRing(currRing))
2262 {
2263 if (kFindDivisibleByInT(strat, h) < 0)
2264 return 1;
2265 }
2266 else
2267#endif
2268 {
2269 int dummy=strat->sl;
2270 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2271 return 1;
2272 }
2273 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2274#ifdef KDEBUG
2275 if (TEST_OPT_DEBUG)
2276 Print(" degree jumped: -> L%d\n",at);
2277#endif
2278 h->Clear();
2279 return -1;
2280 }
2281 }
2282 else if (d > reddeg)
2283 {
2284 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
2285 {
2286 if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask)
2287 {
2288 strat->overflow=TRUE;
2289 //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2290 h->GetP();
2291 at = strat->posInL(strat->L,strat->Ll,h,strat);
2292 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2293 h->Clear();
2294 return -1;
2295 }
2296 }
2297 else if (UNLIKELY(TEST_OPT_PROT && (strat->Ll < 0) ))
2298 {
2299 //h->wrp(); Print("<%d>\n",h->GetpLength());
2300 reddeg = d;
2301 Print(".%ld",d); mflush();
2302 }
2303 }
2304 }
2305}
int kFindDivisibleByInT_ecart(const kStrategy strat, const LObject *L, const int ecart)
Definition kstd2.cc:420

◆ redHoneyM()

int redHoneyM ( LObject h,
kStrategy  strat 
)

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1909 of file kstd2.cc.

1910{
1911 if (strat->tl<0) return 1;
1912 int at,i,ii,li;
1913 int j = 0;
1914 int pass = 0;
1915 int cnt = RED_CANONICALIZE;
1916 assume(h->pFDeg() == h->FDeg);
1917 long reddeg = h->GetpFDeg();
1918 long d;
1920
1921 h->SetShortExpVector();
1922 poly h_p = h->GetLmTailRing();
1923 h->PrepareRed(strat->use_buckets);
1924 loop
1925 {
1926 j = kFindDivisibleByInT(strat, h);
1927 if (j < 0) return 1;
1928
1929 li = strat->T[j].pLength;
1930 ii = j;
1931 /*
1932 * the polynomial to reduce with (up to the moment) is;
1933 * pi with length li
1934 */
1935
1936 i = j;
1937#if 1
1938 if (test_opt_length)
1939 {
1940 if (li<=0) li=strat->T[j].GetpLength();
1941 if(li>2)
1942 {
1943 unsigned long not_sev = ~ h->sev;
1944 loop
1945 {
1946 /*- search the shortest possible with respect to length -*/
1947 i++;
1948 if (i > strat->tl)
1949 break;
1950 if ((strat->T[i].pLength < li)
1951 &&
1952 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1953 h_p, not_sev, strat->tailRing))
1954 {
1955 /*
1956 * the polynomial to reduce with is now;
1957 */
1958 li = strat->T[i].pLength;
1959 if (li<=0) li=strat->T[i].GetpLength();
1960 ii = i;
1961 if (li<3) break;
1962 }
1963 }
1964 }
1965 }
1966#endif
1967
1968 /*
1969 * end of search: have to reduce with pi
1970 */
1971
1972
1973#ifdef KDEBUG
1974 if (TEST_OPT_DEBUG)
1975 {
1976 PrintS("red:");
1977 h->wrp();
1978 PrintS(" with ");
1979 strat->T[ii].wrp();
1980 }
1981#endif
1982
1983 ksReducePoly(h, &(strat->T[ii]), NULL, NULL, NULL, strat);
1984#if SBA_PRINT_REDUCTION_STEPS
1986#endif
1987#if SBA_PRINT_OPERATIONS
1989#endif
1990
1991#ifdef KDEBUG
1992 if (TEST_OPT_DEBUG)
1993 {
1994 PrintS("\nto ");
1995 h->wrp();
1996 PrintLn();
1997 }
1998#endif
1999
2000 h_p=h->GetLmTailRing();
2001
2002 if (h_p == NULL)
2003 {
2004 kDeleteLcm(h);
2005 return 0;
2006 }
2008 {
2009 if (h->p!=NULL)
2010 {
2011 if(p_GetComp(h->p,currRing)>strat->syzComp)
2012 {
2013 h->Delete();
2014 return 0;
2015 }
2016 }
2017 else //if (h->t_p!=NULL)
2018 {
2019 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2020 {
2021 h->Delete();
2022 return 0;
2023 }
2024 }
2025 }
2026 #if 0
2027 else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
2028 {
2029 if (h->p!=NULL)
2030 {
2031 if(p_GetComp(h->p,currRing)>strat->syzComp)
2032 {
2033 return 1;
2034 }
2035 }
2036 else // if (h->t_p!=NULL)
2037 {
2038 if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
2039 {
2040 return 1;
2041 }
2042 }
2043 }
2044 #endif
2045 h->SetShortExpVector();
2046 d = h->SetpFDeg();
2047 /*- try to reduce the s-polynomial -*/
2048 cnt--;
2049 pass++;
2050 if (//!TEST_OPT_REDTHROUGH &&
2051 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
2052 {
2053 h->SetLmCurrRing();
2054 at = strat->posInL(strat->L,strat->Ll,h,strat);
2055 if (at <= strat->Ll)
2056 {
2057#if 1
2058#ifdef HAVE_SHIFTBBA
2059 if (rIsLPRing(currRing))
2060 {
2061 if (kFindDivisibleByInT(strat, h) < 0)
2062 return 1;
2063 }
2064 else
2065#endif
2066 {
2067 int dummy=strat->sl;
2068 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
2069 return 1;
2070 }
2071#endif
2072#ifdef KDEBUG
2073 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
2074#endif
2075 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2076 h->Clear();
2077 return -1;
2078 }
2079 }
2080 else if (d != reddeg)
2081 {
2082 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
2083 {
2084 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
2085 {
2086 strat->overflow=TRUE;
2087 //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
2088 h->GetP();
2089 at = strat->posInL(strat->L,strat->Ll,h,strat);
2090 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
2091 h->Clear();
2092 return -1;
2093 }
2094 }
2095 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
2096 {
2097 Print(".%ld",d);mflush();
2098 reddeg = d;
2099 }
2100 }
2101 else if (UNLIKELY(cnt==0))
2102 {
2103 h->CanonicalizeP();
2104 cnt=RED_CANONICALIZE;
2105 //if (TEST_OPT_PROT) { PrintS("!");mflush(); }
2106 }
2107 }
2108}

◆ 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
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 main part (h) and tail (h_tail)
191 poly h_tail=kSplitAt(strat->syzComp,h,strat);
192 // fix h-pLength
193 h->pLength=0;
194 h->PrepareRed(strat->use_buckets);
195 loop
196 {
197 j=kFindDivisibleByInT(strat, h);
198 if (j < 0)
199 {
200 // lazy computation:
201 int l;
202 poly p=lazyComp(A,C,T,pass,h_tail,&l,strat->tailRing);
203 kBucket_Add_q(h->bucket,p,&l);
204 omFreeSize(A,red_size*sizeof(number));
205 omFreeSize(T,red_size*sizeof(poly));
206 omFreeSize(C,red_size*sizeof(poly));
207 return 1;
208 }
209
210 ei = strat->T[j].ecart;
211 li = strat->T[j].pLength;
212 ci = nSize(pGetCoeff(strat->T[j].p));
213 ii = j;
214 /*
215 * the polynomial to reduce with (up to the moment) is;
216 * pi with ecart ei (T[ii])
217 */
218 i = j;
219 if (TEST_OPT_LENGTH)
220 {
221 if (li<=0) li=strat->T[j].GetpLength();
222 if (li>1)
223 loop
224 {
225 /*- possible with respect to ecart, minimal nSize -*/
226 i++;
227 if (i > strat->tl)
228 break;
229 //if (ei < h->ecart)
230 // break;
231 if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
232 || ((strat->T[i].ecart <= h->ecart)
233 && (strat->T[i].pLength <= li)
234 && (nSize(pGetCoeff(strat->T[i].p)) <ci)))
235 &&
236 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
237 h_p, not_sev, tailRing))
238 {
239 /*
240 * the polynomial to reduce with is now;
241 */
242 ei = strat->T[i].ecart;
243 li = strat->T[i].pLength;
244 if (li<=0) li=strat->T[i].GetpLength();
245 ii = i;
246 if (li==1) break;
247 }
248 }
249 }
250
251 /*
252 * end of search: have to reduce with pi
253 */
254#ifdef KDEBUG
255 if (TEST_OPT_DEBUG)
256 {
257 PrintS("red:");
258 h->wrp();
259 Print("\nwith T[%d]:",ii);
260 strat->T[ii].wrp();
261 }
262#endif
263 assume(strat->fromT == FALSE);
264
265 //strat->T[ii].pCleardenom();
266 // split T[ii]:
267 // remember pLength of strat->T[ii]
268 int l_orig=strat->T[ii].pLength;
269 // split strat->T[ii]
270 poly T_tail=kSplitAt(strat->syzComp,&strat->T[ii],strat);
271 h->pLength=0; // force re-computation of length
272 ksReducePoly(h,&(strat->T[ii]),NULL,&A[pass],&C[pass], strat);
273 // restore T[ii]:
274 kAppend(T_tail,&strat->T[ii]);
275 strat->T[ii].pLength=l_orig;
276 // store T_tail
277 T[pass]=T_tail;
278 // delayed computation: A[pass]*tail-M[pass]*T[pass]
279#ifdef KDEBUG
280 if (TEST_OPT_DEBUG)
281 {
282 PrintS("\nto:");
283 h->wrp();
284 PrintLn();
285 }
286#endif
287 if(h->IsNull())
288 {
289 // clean up A,C,h_tail:
290 for(int i=0;i<=pass;i++)
291 {
292 n_Delete(&A[i],tailRing->cf);
293 p_Delete(&C[i],tailRing);
294 }
295 p_Delete(&h_tail,tailRing);
296 kDeleteLcm(h);
297 h->Clear();
298 omFreeSize(A,red_size*sizeof(number));
299 omFreeSize(T,red_size*sizeof(poly));
300 omFreeSize(C,red_size*sizeof(poly));
301 return 0;
302 }
303 h->SetShortExpVector();
304 not_sev = ~ h->sev;
305 h_d = h->SetpFDeg();
306 /* compute the ecart */
307 if (ei <= h->ecart)
308 h->ecart = d-h_d;
309 else
310 h->ecart = d-h_d+ei-h->ecart;
311
312 /*
313 * try to reduce the s-polynomial h
314 *test first whether h should go to the lazyset L
315 *-if the degree jumps
316 *-if the number of pre-defined reductions jumps
317 */
318 pass++;
319 d = h_d + h->ecart;
321 // if cache is to small, double its size:
322 if (pass>=red_size-1)
323 {
324 A=(number*)omRealloc0Size(A,red_size*sizeof(number),2*red_size*sizeof(number));
325 C=(poly*)omRealloc0Size(C,red_size*sizeof(poly),2*red_size*sizeof(poly));
326 T=(poly*)omRealloc0Size(T,red_size*sizeof(poly),2*red_size*sizeof(poly));
327 if(TEST_OPT_PROT) {Print("+%d+",red_size);mflush();}
328 red_size*=2;
329 }
330 }
331}
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 2311 of file kstd2.cc.

2312{
2313 if (h==NULL) return NULL;
2314 int j,j_ring;
2315 int cnt=REDNF_CANONICALIZE;
2316 max_ind=strat->sl;
2317
2318 if (0 > strat->sl)
2319 {
2320 return h;
2321 }
2322 LObject P(h);
2323 P.SetShortExpVector();
2324 P.t_p=NULL;
2326 if(is_ring) nonorm=TRUE;
2327#ifdef KDEBUG
2328// if (TEST_OPT_DEBUG)
2329// {
2330// PrintS("redNF: starting S:\n");
2331// for( j = 0; j <= max_ind; j++ )
2332// {
2333// Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2334// pWrite(strat->S[j]);
2335// }
2336// };
2337#endif
2338 if (rField_is_Z(currRing))
2339 {
2340 redRing_Z_S(&P,strat);
2341 if (P.bucket!=NULL)
2342 {
2343 P.p=kBucketClear(P.bucket);
2344 kBucketDestroy(&P.bucket);
2345 }
2346 return P.p;
2347 }
2348 else if (rField_is_Ring(currRing))
2349 {
2350 redRing_S(&P,strat);
2351 if (P.bucket!=NULL)
2352 {
2353 P.p=kBucketClear(P.bucket);
2354 kBucketDestroy(&P.bucket);
2355 }
2356 return P.p;
2357 }
2358
2359 P.bucket = kBucketCreate(currRing);
2360 kBucketInit(P.bucket,P.p,pLength(P.p));
2361 kbTest(P.bucket);
2362 P.p=kBucketGetLm(P.bucket);
2363 loop
2364 {
2366 while ((j>=0)
2367 && (nonorm)
2368 && (!n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[j]),currRing->cf)))
2369 j=kFindNextDivisibleByInS(strat,j+1,max_ind,&P);
2370 if (j>=0)
2371 {
2372 int sl=pSize(strat->S[j]);
2373 int jj=j;
2374 loop
2375 {
2376 int sll;
2378 if (jj<0) break;
2379 if ((!nonorm)
2380 || (n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[jj]),currRing->cf)))
2381 {
2382 sll=pSize(strat->S[jj]);
2383 if (sll<sl)
2384 {
2385 #ifdef KDEBUG
2386 if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2387 #endif
2388 //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2389 j=jj;
2390 sl=sll;
2391 }
2392 }
2393 }
2394 if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2395 {
2396 pNorm(strat->S[j]);
2397 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2398 }
2399 nNormalize(pGetCoeff(P.p));
2400#ifdef KDEBUG
2401 if (TEST_OPT_DEBUG)
2402 {
2403 PrintS("red:");
2404 wrp(P.p);
2405 PrintS(" with ");
2406 wrp(strat->S[j]);
2407 }
2408#endif
2409#ifdef HAVE_PLURAL
2411 {
2412 number coef;
2413 nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
2414 nDelete(&coef);
2415 }
2416 else
2417#endif
2418 {
2419 kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),
2420 strat->kNoether);
2421 }
2422 cnt--;
2423 if (cnt==0)
2424 {
2425 kBucketCanonicalize(P.bucket);
2427 }
2428 P.p=kBucketGetLm(P.bucket);
2429 //P.t_p=NULL;
2430#ifdef KDEBUG
2431 if (TEST_OPT_DEBUG)
2432 {
2433 PrintS("\nto:");
2434 wrp(P.p);
2435 PrintLn();
2436 }
2437#endif
2438 if (P.p==NULL)
2439 {
2440 kBucketDestroy(&P.bucket);
2441 return NULL;
2442 }
2443 kbTest(P.bucket);
2444 P.SetShortExpVector();
2445 }
2446 else if (is_ring && (j_ring>=0) && (currRing->cf->cfQuotRem!=ndQuotRem))
2447 {
2448 number r;
2449 number n=n_QuotRem(pGetCoeff(P.p),pGetCoeff(strat->S[j_ring]),&r,currRing->cf);
2450 if(!n_IsZero(n,currRing->cf))
2451 {
2452 poly lm=kBucketGetLm(P.bucket);
2453 poly m=p_Head(lm,currRing);
2454 p_ExpVectorSub(m,strat->S[j_ring],currRing);
2455 if (p_GetComp(strat->S[j_ring], currRing) != p_GetComp(lm, currRing))
2456 {
2458 }
2460 p_Setm(m,currRing);
2461#ifdef KDEBUG
2462 if (TEST_OPT_DEBUG)
2463 {
2464 PrintS("redi (coeff):");
2465 wrp(P.p);
2466 PrintS(" with ");
2467 wrp(strat->S[j]);
2468 }
2469#endif
2470 int l=-1;
2471 kBucket_Minus_m_Mult_p(P.bucket,m,strat->S[j_ring],&l);
2472 P.p=kBucketGetLm(P.bucket);
2474#ifdef KDEBUG
2475 if (TEST_OPT_DEBUG)
2476 {
2477 PrintS("\nto:");
2478 wrp(P.p);
2479 PrintLn();
2480 }
2481#endif
2482 }
2483 else
2484 {
2485 n_Delete(&n,currRing->cf);
2486 }
2487 n_Delete(&r,currRing->cf);
2488 P.p=kBucketClear(P.bucket);
2489 kBucketDestroy(&P.bucket);
2490 pNormalize(P.p);
2491 return P.p;
2492 }
2493 else
2494 {
2495 P.p=kBucketClear(P.bucket);
2496 kBucketDestroy(&P.bucket);
2497 pNormalize(P.p);
2498 return P.p;
2499 }
2500 }
2501}
int m
Definition cfEzgcd.cc:128
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition kbuckets.cc:521
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *l...
Definition kbuckets.cc:722
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
void kBucketPolyRedNF(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition kbuckets.cc:1188
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:571
int kFindDivisibleByInS_noCF(const kStrategy strat, int *max_ind, LObject *L)
Definition kstd2.cc:531
static int redRing_S(LObject *h, kStrategy strat)
Definition kstd2.cc:1094
static int redRing_Z_S(LObject *h, kStrategy strat)
Definition kstd2.cc:882
#define REDNF_CANONICALIZE
Definition kutil.h:38
static void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition nc.h:275
#define nNormalize(n)
Definition numbers.h:30
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
#define pNormalize(p)
Definition polys.h:318
#define pSize(p)
Definition polys.h:319

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

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

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 992 of file kstd2.cc.

993{
994 if (strat->tl<0) return 1;
995 if (h->IsNull()) return 0; // spoly is zero (can only occur with zero divisors)
996
997 int at/*,i*/;
998 long d;
999 int j = 0;
1000 int pass = 0;
1001 // poly zeroPoly = NULL;
1002
1003// TODO warum SetpFDeg notwendig?
1004 h->SetpFDeg();
1005 assume(h->pFDeg() == h->FDeg);
1006 long reddeg = h->GetpFDeg();
1007
1008 h->SetShortExpVector();
1009 loop
1010 {
1011 j = kFindDivisibleByInT(strat, h);
1012 if (j < 0)
1013 {
1014 // over ZZ: cleanup coefficients by complete reduction with monomials
1015 postReduceByMon(h, strat);
1016 if(h->p == NULL)
1017 {
1018 kDeleteLcm(h);
1019 h->Clear();
1020 return 0;
1021 }
1022 if(nIsZero(pGetCoeff(h->p))) return 2;
1023 j = kFindDivisibleByInT(strat, h);
1024 if(j < 0)
1025 {
1026 if(strat->tl >= 0)
1027 h->i_r1 = strat->tl;
1028 else
1029 h->i_r1 = -1;
1030 if (h->GetLmTailRing() == NULL)
1031 {
1032 kDeleteLcm(h);
1033 h->Clear();
1034 return 0;
1035 }
1036 return 1;
1037 }
1038 }
1039 //printf("\nFound one: ");pWrite(strat->T[j].p);
1040 //enterT(*h, strat);
1041 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat); // with debug output
1042 //printf("\nAfter small red: ");pWrite(h->p);
1043 if (h->GetLmTailRing() == NULL)
1044 {
1045 kDeleteLcm(h);
1046 h->Clear();
1047 return 0;
1048 }
1049 h->SetShortExpVector();
1050 d = h->SetpFDeg();
1051 /*- try to reduce the s-polynomial -*/
1052 pass++;
1053 if (!TEST_OPT_REDTHROUGH &&
1054 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
1055 {
1056 h->SetLmCurrRing();
1057 if (strat->posInLDependsOnLength)
1058 h->SetLength(strat->length_pLength);
1059 at = strat->posInL(strat->L,strat->Ll,h,strat);
1060 if (at <= strat->Ll)
1061 {
1062#ifdef KDEBUG
1063 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
1064#endif
1065 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
1066 h->Clear();
1067 return -1;
1068 }
1069 }
1070 if (d != reddeg)
1071 {
1072 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
1073 {
1074 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
1075 {
1076 strat->overflow=TRUE;
1077 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
1078 h->GetP();
1079 at = strat->posInL(strat->L,strat->Ll,h,strat);
1080 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1081 h->Clear();
1082 return -1;
1083 }
1084 }
1085 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
1086 {
1087 Print(".%ld",d);mflush();
1088 reddeg = d;
1089 }
1090 }
1091 }
1092}

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 724 of file kstd2.cc.

725{
726 if (h->IsNull()) return 0; // spoly is zero (can only occur with zero divisors)
727 if (strat->tl<0) return 1;
728
729 int at;
730 long d;
731 int j = 0;
732 int pass = 0;
733
734// TODO warum SetpFDeg notwendig?
735 h->SetpFDeg();
736 assume(h->pFDeg() == h->FDeg);
737 long reddeg = h->GetpFDeg();
738
739 h->SetShortExpVector();
740 loop
741 {
742 /* check if a reducer of the lead term exists */
743 j = kFindDivisibleByInT(strat, h);
744 if (j < 0)
745 {
746#if STDZ_EXCHANGE_DURING_REDUCTION
747 /* check if a reducer with the same lead monomial exists */
748 j = kFindSameLMInT_Z(strat, h);
749 if (j < 0)
750 {
751#endif
752 /* check if a reducer of the lead monomial exists, by the above
753 * check this is a real divisor of the lead monomial */
754 j = kFindDivisibleByInT_Z(strat, h);
755 if (j < 0)
756 {
757 // over ZZ: cleanup coefficients by complete reduction with monomials
759 postReduceByMon(h, strat);
760 if(h->p == NULL)
761 {
762 if (h->lcm!=NULL) pLmDelete(h->lcm);
763 h->Clear();
764 return 0;
765 }
766 if(nIsZero(pGetCoeff(h->p))) return 2;
767 j = kFindDivisibleByInT(strat, h);
768 if(j < 0)
769 {
770 if(strat->tl >= 0)
771 h->i_r1 = strat->tl;
772 else
773 h->i_r1 = -1;
774 if (h->GetLmTailRing() == NULL)
775 {
776 if (h->lcm!=NULL) pLmDelete(h->lcm);
777 h->Clear();
778 return 0;
779 }
780 return 1;
781 }
782 }
783 else
784 {
785 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
786 * => we try to cut down the lead coefficient at least */
787 /* first copy T[j] in order to multiply it with a coefficient later on */
789 TObject tj = strat->T[j];
790 tj.Copy();
791 /* tj.max_exp = strat->T[j].max_exp; */
792 /* compute division with remainder of lc(h) and lc(T[j]) */
793 mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
794 &rest, currRing->cf);
795 /* set corresponding new lead coefficient already. we do not
796 * remove the lead term in ksReducePolyLC, but only apply
797 * a lead coefficient reduction */
798 tj.Mult_nn(mult);
799 ksReducePolyLC(h, &tj, NULL, &rest, strat);
800 tj.Delete();
801 tj.Clear();
802 }
803#if STDZ_EXCHANGE_DURING_REDUCTION
804 }
805 else
806 {
807 /* same lead monomial but lead coefficients do not divide each other:
808 * change the polys to h <- spoly(h,tj) and h2 <- gpoly(h,tj). */
809 LObject h2 = *h;
810 h2.Copy();
811
812 ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat);
813 ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat);
815 {
816 redtailBbaAlsoLC_Z(&h2, j, strat);
817 }
818 /* replace h2 for tj in L (already generated pairs with tj), S and T */
819 replaceInLAndSAndT(h2, j, strat);
820 }
821#endif
822 }
823 else
824 {
825 ksReducePoly(h, &(strat->T[j]), NULL, NULL, NULL, strat);
826 }
827 /* printf("\nAfter small red: ");pWrite(h->p); */
828 if (h->GetLmTailRing() == NULL)
829 {
830 if (h->lcm!=NULL) pLmDelete(h->lcm);
831#ifdef KDEBUG
832 h->lcm=NULL;
833#endif
834 h->Clear();
835 return 0;
836 }
837 h->SetShortExpVector();
838 d = h->SetpFDeg();
839 /*- try to reduce the s-polynomial -*/
840 pass++;
841 if (!TEST_OPT_REDTHROUGH &&
842 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
843 {
844 h->SetLmCurrRing();
845 if (strat->posInLDependsOnLength)
846 h->SetLength(strat->length_pLength);
847 at = strat->posInL(strat->L,strat->Ll,h,strat);
848 if (at <= strat->Ll)
849 {
850#ifdef KDEBUG
851 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
852#endif
853 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER
854 h->Clear();
855 return -1;
856 }
857 }
858 if (d != reddeg)
859 {
860 if (UNLIKELY(d>=(long)strat->tailRing->bitmask))
861 {
862 if (h->pTotalDeg() >= (long)strat->tailRing->bitmask)
863 {
864 strat->overflow=TRUE;
865 //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask);
866 h->GetP();
867 at = strat->posInL(strat->L,strat->Ll,h,strat);
868 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
869 h->Clear();
870 return -1;
871 }
872 }
873 else if ((TEST_OPT_PROT) && (strat->Ll < 0))
874 {
875 Print(".%ld",d);mflush();
876 reddeg = d;
877 }
878 }
879 }
880}
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:477
int kFindDivisibleByInT_Z(const kStrategy strat, const LObject *L, const int start)
Definition kstd2.cc:213
void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat)
Definition kutil.cc:9045
int ksReducePolyGCD(LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int kFindSameLMInT_Z(const kStrategy strat, const LObject *L, const int start=0)
int ksReducePolyZ(LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 1373 of file kstd2.cc.

1374{
1375 if (strat->tl<0) return 1;
1376 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1377 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1378 assume(h->FDeg == h->pFDeg());
1379//#if 1
1380#ifdef DEBUGF5
1381 PrintS("------- IN REDSIG -------\n");
1382 Print("p: ");
1383 pWrite(pHead(h->p));
1384 PrintS("p1: ");
1385 pWrite(pHead(h->p1));
1386 PrintS("p2: ");
1387 pWrite(pHead(h->p2));
1388 PrintS("---------------------------\n");
1389#endif
1390 poly h_p;
1391 int i,j,at,pass, ii;
1392 int start=0;
1393 int sigSafe;
1394 unsigned long not_sev;
1395 // long reddeg,d;
1397 int li;
1398
1399 pass = j = 0;
1400 h->SetShortExpVector();
1401 h_p = h->GetLmTailRing();
1402 not_sev = ~ h->sev;
1403 loop
1404 {
1405 j = kFindDivisibleByInT(strat, h, start);
1406 if (j < 0)
1407 {
1408 return 1;
1409 }
1410
1411 li = strat->T[j].pLength;
1412 if (li<=0) li=strat->T[j].GetpLength();
1413 ii = j;
1414 /*
1415 * the polynomial to reduce with (up to the moment) is;
1416 * pi with length li
1417 */
1418 i = j;
1419#if 1
1420 if (test_opt_length)
1421 loop
1422 {
1423 /*- search the shortest possible with respect to length -*/
1424 i++;
1425 if (i > strat->tl)
1426 break;
1427 if (li==1)
1428 break;
1429 if ((strat->T[i].pLength < li)
1430 &&
1431 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1432 h_p, not_sev, strat->tailRing))
1433 {
1434 /*
1435 * the polynomial to reduce with is now;
1436 */
1437 li = strat->T[i].pLength;
1438 if (li<=0) li=strat->T[i].GetpLength();
1439 ii = i;
1440 }
1441 }
1442 start = ii+1;
1443#endif
1444
1445 /*
1446 * end of search: have to reduce with pi
1447 */
1448#ifdef KDEBUG
1449 if (TEST_OPT_DEBUG)
1450 {
1451 PrintS("red:");
1452 h->wrp();
1453 PrintS(" with ");
1454 strat->T[ii].wrp();
1455 }
1456#endif
1457 assume(strat->fromT == FALSE);
1458//#if 1
1459#ifdef DEBUGF5
1460 Print("BEFORE REDUCTION WITH %d:\n",ii);
1461 PrintS("--------------------------------\n");
1462 pWrite(h->sig);
1463 pWrite(strat->T[ii].sig);
1464 pWrite(h->GetLmCurrRing());
1465 pWrite(pHead(h->p1));
1466 pWrite(pHead(h->p2));
1467 pWrite(pHead(strat->T[ii].p));
1468 PrintS("--------------------------------\n");
1469 printf("INDEX OF REDUCER T: %d\n",ii);
1470#endif
1471 sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1472#if SBA_PRINT_REDUCTION_STEPS
1473 if (sigSafe != 3)
1475#endif
1476#if SBA_PRINT_OPERATIONS
1477 if (sigSafe != 3)
1478 sba_operations += pLength(strat->T[ii].p);
1479#endif
1480 // if reduction has taken place, i.e. the reduction was sig-safe
1481 // otherwise start is already at the next position and the loop
1482 // searching reducers in T goes on from index start
1483//#if 1
1484#ifdef DEBUGF5
1485 Print("SigSAFE: %d\n",sigSafe);
1486#endif
1487 if (sigSafe != 3)
1488 {
1489 // start the next search for reducers in T from the beginning
1490 start = 0;
1491#ifdef KDEBUG
1492 if (TEST_OPT_DEBUG)
1493 {
1494 PrintS("\nto ");
1495 h->wrp();
1496 PrintLn();
1497 }
1498#endif
1499
1500 h_p = h->GetLmTailRing();
1501 if (h_p == NULL)
1502 {
1503 kDeleteLcm(h);
1504 return 0;
1505 }
1506 h->SetShortExpVector();
1507 not_sev = ~ h->sev;
1508 /*
1509 * try to reduce the s-polynomial h
1510 *test first whether h should go to the lazyset L
1511 *-if the degree jumps
1512 *-if the number of pre-defined reductions jumps
1513 */
1514 pass++;
1515 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1516 {
1517 h->SetLmCurrRing();
1518 at = strat->posInL(strat->L,strat->Ll,h,strat);
1519 if (at <= strat->Ll)
1520 {
1521 int dummy=strat->sl;
1522 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1523 {
1524 return 1;
1525 }
1526 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1527#ifdef KDEBUG
1528 if (TEST_OPT_DEBUG)
1529 Print(" lazy: -> L%d\n",at);
1530#endif
1531 h->Clear();
1532 return -1;
1533 }
1534 }
1535 }
1536 }
1537}
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:737

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1540 of file kstd2.cc.

1541{
1542 //Since reduce is really bad for SBA we use the following idea:
1543 // We first check if we can build a gcd pair between h and S
1544 //where the sig remains the same and replace h by this gcd poly
1546 #if GCD_SBA
1547 while(sbaCheckGcdPair(h,strat))
1548 {
1549 h->sev = pGetShortExpVector(h->p);
1550 }
1551 #endif
1552 poly beforeredsig;
1553 beforeredsig = pCopy(h->sig);
1554
1555 if (strat->tl<0) return 1;
1556 //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
1557 //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
1558 assume(h->FDeg == h->pFDeg());
1559//#if 1
1560#ifdef DEBUGF5
1561 Print("------- IN REDSIG -------\n");
1562 Print("p: ");
1563 pWrite(pHead(h->p));
1564 Print("p1: ");
1565 pWrite(pHead(h->p1));
1566 Print("p2: ");
1567 pWrite(pHead(h->p2));
1568 Print("---------------------------\n");
1569#endif
1570 poly h_p;
1571 int i,j,at,pass, ii;
1572 int start=0;
1573 int sigSafe;
1574 unsigned long not_sev;
1575 // long reddeg,d;
1576 int li;
1578
1579 pass = j = 0;
1580 h->SetShortExpVector();
1581 h_p = h->GetLmTailRing();
1582 not_sev = ~ h->sev;
1583 loop
1584 {
1585 j = kFindDivisibleByInT(strat, h, start);
1586 if (j < 0)
1587 {
1588 #if GCD_SBA
1589 while(sbaCheckGcdPair(h,strat))
1590 {
1591 h->sev = pGetShortExpVector(h->p);
1592 h->is_redundant = FALSE;
1593 start = 0;
1594 }
1595 #endif
1596 // over ZZ: cleanup coefficients by complete reduction with monomials
1597 postReduceByMonSig(h, strat);
1598 if(h->p == NULL || nIsZero(pGetCoeff(h->p))) return 2;
1599 j = kFindDivisibleByInT(strat, h,start);
1600 if(j < 0)
1601 {
1602 if(strat->tl >= 0)
1603 h->i_r1 = strat->tl;
1604 else
1605 h->i_r1 = -1;
1606 if (h->GetLmTailRing() == NULL)
1607 {
1608 kDeleteLcm(h);
1609 h->Clear();
1610 return 0;
1611 }
1612 //Check for sigdrop after reduction
1613 if(pLtCmp(beforeredsig,h->sig) == 1)
1614 {
1615 strat->sigdrop = TRUE;
1616 //Reduce it as much as you can
1617 int red_result = redRing(h,strat);
1618 if(red_result == 0)
1619 {
1620 //It reduced to 0, cancel the sigdrop
1621 strat->sigdrop = FALSE;
1622 p_Delete(&h->sig,currRing);h->sig = NULL;
1623 return 0;
1624 }
1625 else
1626 {
1627 //strat->enterS(*h, strat->sl+1, strat, strat->tl);
1628 return 0;
1629 }
1630 }
1632 return 1;
1633 }
1634 }
1635
1636 li = strat->T[j].pLength;
1637 if (li<=0) li=strat->T[j].GetpLength();
1638 ii = j;
1639 /*
1640 * the polynomial to reduce with (up to the moment) is;
1641 * pi with length li
1642 */
1643 i = j;
1644 if (test_opt_length)
1645 loop
1646 {
1647 /*- search the shortest possible with respect to length -*/
1648 i++;
1649 if (i > strat->tl)
1650 break;
1651 if (li==1)
1652 break;
1653 if ((strat->T[i].pLength < li)
1654 && n_DivBy(pGetCoeff(h_p),pGetCoeff(strat->T[i].p),currRing->cf)
1655 && p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
1656 h_p, not_sev, strat->tailRing))
1657 {
1658 /*
1659 * the polynomial to reduce with is now;
1660 */
1661 li = strat->T[i].pLength;
1662 if (li<=0) li=strat->T[i].GetpLength();
1663 ii = i;
1664 }
1665 }
1666
1667 start = ii+1;
1668
1669 /*
1670 * end of search: have to reduce with pi
1671 */
1672#ifdef KDEBUG
1673 if (TEST_OPT_DEBUG)
1674 {
1675 PrintS("red:");
1676 h->wrp();
1677 PrintS(" with ");
1678 strat->T[ii].wrp();
1679 }
1680#endif
1681 assume(strat->fromT == FALSE);
1682//#if 1
1683#ifdef DEBUGF5
1684 Print("BEFORE REDUCTION WITH %d:\n",ii);
1685 Print("--------------------------------\n");
1686 pWrite(h->sig);
1687 pWrite(strat->T[ii].sig);
1688 pWrite(h->GetLmCurrRing());
1689 pWrite(pHead(h->p1));
1690 pWrite(pHead(h->p2));
1691 pWrite(pHead(strat->T[ii].p));
1692 Print("--------------------------------\n");
1693 printf("INDEX OF REDUCER T: %d\n",ii);
1694#endif
1695 sigSafe = ksReducePolySigRing(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
1696 if(h->p == NULL && h->sig == NULL)
1697 {
1698 //Trivial case catch
1699 strat->sigdrop = FALSE;
1700 }
1701 #if 0
1702 //If the reducer has the same lt (+ or -) as the other one, reduce it via redRing
1703 //In some cases this proves to be very bad
1704 if(rField_is_Ring(currRing) && h->p != NULL && pLmCmp(h->p,strat->T[ii].p)==0)
1705 {
1706 int red_result = redRing(h,strat);
1707 if(red_result == 0)
1708 {
1709 pDelete(&h->sig);h->sig = NULL;
1710 return 0;
1711 }
1712 else
1713 {
1714 strat->sigdrop = TRUE;
1715 return 1;
1716 }
1717 }
1718 #endif
1719 if(strat->sigdrop)
1720 return 1;
1721#if SBA_PRINT_REDUCTION_STEPS
1722 if (sigSafe != 3)
1724#endif
1725#if SBA_PRINT_OPERATIONS
1726 if (sigSafe != 3)
1727 sba_operations += pLength(strat->T[ii].p);
1728#endif
1729 // if reduction has taken place, i.e. the reduction was sig-safe
1730 // otherwise start is already at the next position and the loop
1731 // searching reducers in T goes on from index start
1732//#if 1
1733#ifdef DEBUGF5
1734 Print("SigSAFE: %d\n",sigSafe);
1735#endif
1736 if (sigSafe != 3)
1737 {
1738 // start the next search for reducers in T from the beginning
1739 start = 0;
1740#ifdef KDEBUG
1741 if (TEST_OPT_DEBUG)
1742 {
1743 PrintS("\nto ");
1744 h->wrp();
1745 PrintLn();
1746 }
1747#endif
1748
1749 h_p = h->GetLmTailRing();
1750 if (h_p == NULL)
1751 {
1752 kDeleteLcm(h);
1753 return 0;
1754 }
1755 h->SetShortExpVector();
1756 not_sev = ~ h->sev;
1757 /*
1758 * try to reduce the s-polynomial h
1759 *test first whether h should go to the lazyset L
1760 *-if the degree jumps
1761 *-if the number of pre-defined reductions jumps
1762 */
1763 pass++;
1764 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
1765 {
1766 h->SetLmCurrRing();
1767 at = strat->posInL(strat->L,strat->Ll,h,strat);
1768 if (at <= strat->Ll)
1769 {
1770 int dummy=strat->sl;
1771 if (kFindDivisibleByInS(strat, &dummy, h) < 0)
1772 {
1773 return 1;
1774 }
1775 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
1776#ifdef KDEBUG
1777 if (TEST_OPT_DEBUG)
1778 Print(" lazy: -> L%d\n",at);
1779#endif
1780 h->Clear();
1781 return -1;
1782 }
1783 }
1784 }
1785 }
1786}
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:943
void postReduceByMonSig(LObject *h, kStrategy strat)
Definition kutil.cc:10781
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition kutil.cc:1688

◆ redtail() [1/2]

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

Definition at line 6833 of file kutil.cc.

6834{
6835 poly h, hn;
6836 strat->redTailChange=FALSE;
6837
6838 L->GetP();
6839 poly p = L->p;
6840 if (strat->noTailReduction || pNext(p) == NULL)
6841 return p;
6842
6843 LObject Ln(strat->tailRing);
6844 TObject* With;
6845 // placeholder in case strat->tl < 0
6846 TObject With_s(strat->tailRing);
6847 h = p;
6848 hn = pNext(h);
6849 long op = strat->tailRing->pFDeg(hn, strat->tailRing);
6850 long e;
6851 int l;
6852 BOOLEAN save_HE=strat->kAllAxis;
6853 strat->kAllAxis |=
6854 ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
6855
6856 while(hn != NULL)
6857 {
6858 op = strat->tailRing->pFDeg(hn, strat->tailRing);
6859 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
6860 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
6861 loop
6862 {
6863 Ln.Set(hn, strat->tailRing);
6864 Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
6865 if (strat->kAllAxis)
6867 else
6868 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
6869 if (With == NULL) break;
6870 With->length=0;
6871 With->pLength=0;
6872 strat->redTailChange=TRUE;
6873 if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
6874 {
6875 // reducing the tail would violate the exp bound
6876 if (kStratChangeTailRing(strat, L))
6877 {
6878 strat->kAllAxis = save_HE;
6879 return redtail(L, end_pos, strat);
6880 }
6881 else
6882 return NULL;
6883 }
6884 hn = pNext(h);
6885 if (hn == NULL) goto all_done;
6886 op = strat->tailRing->pFDeg(hn, strat->tailRing);
6887 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
6888 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
6889 }
6890 h = hn;
6891 hn = pNext(h);
6892 }
6893
6894 all_done:
6895 if (strat->redTailChange)
6896 {
6897 L->pLength = 0;
6898 }
6899 strat->kAllAxis = save_HE;
6900 return p;
6901}
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition kutil.cc:6694
#define TEST_OPT_INFREDTAIL
Definition options.h:120

◆ redtail() [2/2]

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

Definition at line 6903 of file kutil.cc.

6904{
6905 LObject L(p, currRing);
6906 return redtail(&L, end_pos, strat);
6907}

◆ redtailBba() [1/3]

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

Definition at line 6909 of file kutil.cc.

6910{
6911 strat->redTailChange=FALSE;
6912 if (strat->noTailReduction) return L->GetLmCurrRing();
6913 poly h, p;
6914 p = h = L->GetLmTailRing();
6915 if ((h==NULL) || (pNext(h)==NULL))
6916 return L->GetLmCurrRing();
6917
6918 TObject* With;
6919 // placeholder in case strat->tl < 0
6920 TObject With_s(strat->tailRing);
6921
6922 LObject Ln(pNext(h), strat->tailRing);
6923 Ln.GetpLength();
6924
6925 pNext(h) = NULL;
6926 if (L->p != NULL)
6927 {
6928 pNext(L->p) = NULL;
6929 if (L->t_p != NULL) pNext(L->t_p) = NULL;
6930 }
6931 L->pLength = 1;
6932
6933 Ln.PrepareRed(strat->use_buckets);
6934
6935 int cnt=REDTAIL_CANONICALIZE;
6936 while(!Ln.IsNull())
6937 {
6938 loop
6939 {
6940 if (TEST_OPT_IDLIFT)
6941 {
6942 if (Ln.p!=NULL)
6943 {
6944 if ((int)__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
6945 }
6946 else
6947 {
6948 if ((int)__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
6949 }
6950 }
6951 Ln.SetShortExpVector();
6952 if (withT)
6953 {
6954 int j;
6955 j = kFindDivisibleByInT(strat, &Ln);
6956 if (j < 0) break;
6957 With = &(strat->T[j]);
6958 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
6959 }
6960 else
6961 {
6963 if (With == NULL) break;
6964 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
6965 }
6966 cnt--;
6967 if (cnt==0)
6968 {
6970 /*poly tmp=*/Ln.CanonicalizeP();
6971 if (normalize)
6972 {
6973 Ln.Normalize();
6974 //pNormalize(tmp);
6975 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
6976 }
6977 }
6978 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
6979 {
6980 With->pNorm();
6981 }
6982 strat->redTailChange=TRUE;
6983 if (ksReducePolyTail(L, With, &Ln))
6984 {
6985 // reducing the tail would violate the exp bound
6986 // set a flag and hope for a retry (in bba)
6988 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
6989 do
6990 {
6991 pNext(h) = Ln.LmExtractAndIter();
6992 pIter(h);
6993 L->pLength++;
6994 } while (!Ln.IsNull());
6995 goto all_done;
6996 }
6997 if (Ln.IsNull()) goto all_done;
6998 if (! withT) With_s.Init(currRing);
6999 }
7000 pNext(h) = Ln.LmExtractAndIter();
7001 pIter(h);
7002 pNormalize(h);
7003 L->pLength++;
7004 }
7005
7006 all_done:
7007 Ln.Delete();
7008 if (L->p != NULL) pNext(L->p) = pNext(p);
7009
7010 if (strat->redTailChange)
7011 {
7012 L->length = 0;
7013 L->pLength = 0;
7014 }
7015
7016 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7017 //L->Normalize(); // HANNES: should have a test
7018 kTest_L(L,strat);
7019 return L->GetLmCurrRing();
7020}
#define REDTAIL_CANONICALIZE
Definition kutil.h:39
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition syz3.cc:1027

◆ redtailBba() [2/3]

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

Definition at line 1212 of file kInline.h.

1213{
1214 LObject L(p);
1215 return redtailBba(&L, pos, strat,FALSE, normalize);
1216}

◆ redtailBba() [3/3]

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

◆ redtailBba_NF()

poly redtailBba_NF ( poly  p,
kStrategy  strat 
)

Definition at line 7347 of file kutil.cc.

7348{
7349 strat->redTailChange=FALSE;
7350 if (strat->noTailReduction) return p;
7351 if ((p==NULL) || (pNext(p)==NULL))
7352 return p;
7353
7354 int max_ind;
7355 poly h=p;
7356 p=pNext(p);
7357 pNext(h)=NULL;
7358 while(p!=NULL)
7359 {
7360 p=redNF(p,max_ind,1,strat);
7361 if (p!=NULL)
7362 {
7363 poly hh=p;
7364 p=pNext(p);
7365 pNext(hh)=NULL;
7367 }
7368 }
7369 return h;
7370}

◆ redtailBba_Ring() [1/2]

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

Definition at line 7372 of file kutil.cc.

7374{
7375 strat->redTailChange=FALSE;
7376 if (strat->noTailReduction) return L->GetLmCurrRing();
7377 poly h, p;
7378 p = h = L->GetLmTailRing();
7379 if ((h==NULL) || (pNext(h)==NULL))
7380 return L->GetLmCurrRing();
7381
7382 TObject* With;
7383 // placeholder in case strat->tl < 0
7384 TObject With_s(strat->tailRing);
7385
7386 LObject Ln(pNext(h), strat->tailRing);
7387 Ln.pLength = L->GetpLength() - 1;
7388
7389 pNext(h) = NULL;
7390 if (L->p != NULL) pNext(L->p) = NULL;
7391 L->pLength = 1;
7392
7393 Ln.PrepareRed(strat->use_buckets);
7394
7395 int cnt=REDTAIL_CANONICALIZE;
7396 while(!Ln.IsNull())
7397 {
7398 loop
7399 {
7400 Ln.SetShortExpVector();
7401 With_s.Init(currRing);
7403 if (With == NULL) break;
7404 cnt--;
7405 if (cnt==0)
7406 {
7408 /*poly tmp=*/Ln.CanonicalizeP();
7409 }
7410 // we are in a ring, do not call pNorm
7411 // test divisibility of coefs:
7412 poly p_Ln=Ln.GetLmCurrRing();
7413 poly p_With=With->GetLmCurrRing();
7415 {
7416 strat->redTailChange=TRUE;
7417
7418 if (ksReducePolyTail_Z(L, With, &Ln))
7419 {
7420 // reducing the tail would violate the exp bound
7421 // set a flag and hope for a retry (in bba)
7423 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7424 do
7425 {
7426 pNext(h) = Ln.LmExtractAndIter();
7427 pIter(h);
7428 L->pLength++;
7429 } while (!Ln.IsNull());
7430 goto all_done;
7431 }
7432 }
7433 else break; /*proceed to next monomial*/
7434 if (Ln.IsNull()) goto all_done;
7435 }
7436 pNext(h) = Ln.LmExtractAndIter();
7437 pIter(h);
7438 pNormalize(h);
7439 L->pLength++;
7440 }
7441
7442 all_done:
7443 Ln.Delete();
7444 if (L->p != NULL) pNext(L->p) = pNext(p);
7445
7446 if (strat->redTailChange)
7447 {
7448 L->length = 0;
7449 }
7450
7451 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7452 //L->Normalize(); // HANNES: should have a test
7453 kTest_L(L,strat);
7454 return L->GetLmCurrRing();
7455}
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1125

◆ redtailBba_Ring() [2/2]

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

Definition at line 1224 of file kInline.h.

1225{
1226 LObject L(p, currRing, strat->tailRing);
1227 return redtailBba_Ring(&L, pos, strat);
1228}

◆ redtailBba_Z() [1/2]

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

Definition at line 7266 of file kutil.cc.

7268{
7269 strat->redTailChange=FALSE;
7270 if (strat->noTailReduction) return L->GetLmCurrRing();
7271 poly h, p;
7272 p = h = L->GetLmTailRing();
7273 if ((h==NULL) || (pNext(h)==NULL))
7274 return L->GetLmCurrRing();
7275
7276 TObject* With;
7277 // placeholder in case strat->tl < 0
7278 TObject With_s(strat->tailRing);
7279
7280 LObject Ln(pNext(h), strat->tailRing);
7281 Ln.pLength = L->GetpLength() - 1;
7282
7283 pNext(h) = NULL;
7284 if (L->p != NULL) pNext(L->p) = NULL;
7285 L->pLength = 1;
7286
7287 Ln.PrepareRed(strat->use_buckets);
7288
7289 int cnt=REDTAIL_CANONICALIZE;
7290 while(!Ln.IsNull())
7291 {
7292 loop
7293 {
7294 Ln.SetShortExpVector();
7296 if (With == NULL) break;
7297 cnt--;
7298 if (cnt==0)
7299 {
7301 /*poly tmp=*/Ln.CanonicalizeP();
7302 }
7303 // we are in Z, do not call pNorm
7304 strat->redTailChange=TRUE;
7305 // test divisibility of coefs:
7306 Ln.GetLmCurrRing();
7307 With->GetLmCurrRing();
7308
7309 if (ksReducePolyTail_Z(L, With, &Ln))
7310 {
7311 // reducing the tail would violate the exp bound
7312 // set a flag and hope for a retry (in bba)
7314 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7315 do
7316 {
7317 pNext(h) = Ln.LmExtractAndIter();
7318 pIter(h);
7319 L->pLength++;
7320 } while (!Ln.IsNull());
7321 goto all_done;
7322 }
7323 if (Ln.IsNull()) goto all_done;
7324 With_s.Init(currRing);
7325 }
7326 pNext(h) = Ln.LmExtractAndIter();
7327 pIter(h);
7328 pNormalize(h);
7329 L->pLength++;
7330 }
7331
7332 all_done:
7333 Ln.Delete();
7334 if (L->p != NULL) pNext(L->p) = pNext(p);
7335
7336 if (strat->redTailChange)
7337 {
7338 L->length = 0;
7339 }
7340
7341 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7342 //L->Normalize(); // HANNES: should have a test
7343 kTest_L(L,strat);
7344 return L->GetLmCurrRing();
7345}

◆ redtailBba_Z() [2/2]

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

Definition at line 1229 of file kInline.h.

1230{
1231 LObject L(p, currRing, strat->tailRing);
1232 return redtailBba_Z(&L, pos, strat);
1233}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7137 of file kutil.cc.

7139{
7140 strat->redTailChange=FALSE;
7141
7142 poly h, p;
7143 p = h = L->GetLmTailRing();
7144 if ((h==NULL) || (pNext(h)==NULL))
7145 return;
7146
7147 TObject* With;
7148 LObject Ln(pNext(h), strat->tailRing);
7149 Ln.GetpLength();
7150
7151 pNext(h) = NULL;
7152 if (L->p != NULL)
7153 {
7154 pNext(L->p) = NULL;
7155 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7156 }
7157 L->pLength = 1;
7158
7159 Ln.PrepareRed(strat->use_buckets);
7160
7161 int cnt=REDTAIL_CANONICALIZE;
7162
7163 while(!Ln.IsNull())
7164 {
7165 loop
7166 {
7167 if (TEST_OPT_IDLIFT)
7168 {
7169 if (Ln.p!=NULL)
7170 {
7171 if ((int)__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7172 }
7173 else
7174 {
7175 if ((int)__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7176 }
7177 }
7178 Ln.SetShortExpVector();
7179 int j;
7180 j = kFindDivisibleByInT(strat, &Ln);
7181 if (j < 0)
7182 {
7183 j = kFindDivisibleByInT_Z(strat, &Ln);
7184 if (j < 0)
7185 {
7186 break;
7187 }
7188 else
7189 {
7190 /* reduction not cancelling a tail term, but reducing its coefficient */
7191 With = &(strat->T[j]);
7192 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7193 cnt--;
7194 if (cnt==0)
7195 {
7197 /*poly tmp=*/Ln.CanonicalizeP();
7198 }
7199 strat->redTailChange=TRUE;
7200 /* reduction cancelling a tail term */
7201 if (ksReducePolyTailLC_Z(L, With, &Ln))
7202 {
7203 // reducing the tail would violate the exp bound
7204 // set a flag and hope for a retry (in bba)
7206 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7207 do
7208 {
7209 pNext(h) = Ln.LmExtractAndIter();
7210 pIter(h);
7211 L->pLength++;
7212 } while (!Ln.IsNull());
7213 goto all_done;
7214 }
7215 /* we have to break since we did not cancel the term, but only decreased
7216 * its coefficient. */
7217 break;
7218 }
7219 } else {
7220 With = &(strat->T[j]);
7221 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7222 cnt--;
7223 if (cnt==0)
7224 {
7226 /*poly tmp=*/Ln.CanonicalizeP();
7227 }
7228 strat->redTailChange=TRUE;
7229 /* reduction cancelling a tail term */
7230 if (ksReducePolyTail_Z(L, With, &Ln))
7231 {
7232 // reducing the tail would violate the exp bound
7233 // set a flag and hope for a retry (in bba)
7235 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7236 do
7237 {
7238 pNext(h) = Ln.LmExtractAndIter();
7239 pIter(h);
7240 L->pLength++;
7241 } while (!Ln.IsNull());
7242 goto all_done;
7243 }
7244 }
7245 if (Ln.IsNull()) goto all_done;
7246 }
7247 pNext(h) = Ln.LmExtractAndIter();
7248 pIter(h);
7249 L->pLength++;
7250 }
7251
7252 all_done:
7253 Ln.Delete();
7254 if (L->p != NULL) pNext(L->p) = pNext(p);
7255
7256 if (strat->redTailChange)
7257 {
7258 L->length = 0;
7259 L->pLength = 0;
7260 }
7261
7262 kTest_L(L, strat);
7263 return;
7264}
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1107

◆ redtailBbaBound() [1/2]

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

Definition at line 7022 of file kutil.cc.

7023{
7024 strat->redTailChange=FALSE;
7025 if (strat->noTailReduction) return L->GetLmCurrRing();
7026 poly h, p;
7027 p = h = L->GetLmTailRing();
7028 if ((h==NULL) || (pNext(h)==NULL))
7029 return L->GetLmCurrRing();
7030
7031 TObject* With;
7032 // placeholder in case strat->tl < 0
7033 TObject With_s(strat->tailRing);
7034
7035 LObject Ln(pNext(h), strat->tailRing);
7036 Ln.pLength = L->GetpLength() - 1;
7037
7038 pNext(h) = NULL;
7039 if (L->p != NULL) pNext(L->p) = NULL;
7040 L->pLength = 1;
7041
7042 Ln.PrepareRed(strat->use_buckets);
7043
7044 int cnt=REDTAIL_CANONICALIZE;
7045 while(!Ln.IsNull())
7046 {
7047 loop
7048 {
7049 if (TEST_OPT_IDLIFT)
7050 {
7051 if (Ln.p!=NULL)
7052 {
7053 if ((int)__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7054 }
7055 else
7056 {
7057 if ((int)__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7058 }
7059 }
7060 Ln.SetShortExpVector();
7061 if (withT)
7062 {
7063 int j;
7064 j = kFindDivisibleByInT(strat, &Ln);
7065 if (j < 0) break;
7066 With = &(strat->T[j]);
7067 }
7068 else
7069 {
7071 if (With == NULL) break;
7072 }
7073 cnt--;
7074 if (cnt==0)
7075 {
7077 /*poly tmp=*/Ln.CanonicalizeP();
7078 if (normalize)
7079 {
7080 Ln.Normalize();
7081 //pNormalize(tmp);
7082 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7083 }
7084 }
7085 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7086 {
7087 With->pNorm();
7088 }
7089 strat->redTailChange=TRUE;
7090 if (ksReducePolyTail(L, With, &Ln))
7091 {
7092 // reducing the tail would violate the exp bound
7093 // set a flag and hope for a retry (in bba)
7095 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7096 do
7097 {
7098 pNext(h) = Ln.LmExtractAndIter();
7099 pIter(h);
7100 L->pLength++;
7101 } while (!Ln.IsNull());
7102 goto all_done;
7103 }
7104 if(!Ln.IsNull())
7105 {
7106 Ln.GetP();
7107 Ln.p = pJet(Ln.p,bound);
7108 }
7109 if (Ln.IsNull())
7110 {
7111 goto all_done;
7112 }
7113 if (! withT) With_s.Init(currRing);
7114 }
7115 pNext(h) = Ln.LmExtractAndIter();
7116 pIter(h);
7117 pNormalize(h);
7118 L->pLength++;
7119 }
7120
7121 all_done:
7122 Ln.Delete();
7123 if (L->p != NULL) pNext(L->p) = pNext(p);
7124
7125 if (strat->redTailChange)
7126 {
7127 L->length = 0;
7128 L->pLength = 0;
7129 }
7130
7131 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7132 //L->Normalize(); // HANNES: should have a test
7133 kTest_L(L,strat);
7134 return L->GetLmCurrRing();
7135}
#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 1218 of file kInline.h.

1219{
1220 LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1221 return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1222}

◆ redtailBbaShift()

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

Definition at line 13003 of file kutil.cc.

13004{
13005 /* for the shift case need to run it with withT = TRUE */
13006 strat->redTailChange=FALSE;
13007 if (strat->noTailReduction) return L->GetLmCurrRing();
13008 poly h, p;
13009 p = h = L->GetLmTailRing();
13010 if ((h==NULL) || (pNext(h)==NULL))
13011 return L->GetLmCurrRing();
13012
13013 TObject* With;
13014 // placeholder in case strat->tl < 0
13015 TObject With_s(strat->tailRing);
13016
13017 LObject Ln(pNext(h), strat->tailRing);
13018 Ln.pLength = L->GetpLength() - 1;
13019
13020 pNext(h) = NULL;
13021 if (L->p != NULL) pNext(L->p) = NULL;
13022 L->pLength = 1;
13023
13024 Ln.PrepareRed(strat->use_buckets);
13025
13026 while(!Ln.IsNull())
13027 {
13028 loop
13029 {
13030 Ln.SetShortExpVector();
13031 if (withT)
13032 {
13033 int j;
13034 j = kFindDivisibleByInT(strat, &Ln);
13035 if (j < 0) break;
13036 With = &(strat->T[j]);
13037 }
13038 else
13039 {
13040 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13041 if (With == NULL) break;
13042 }
13043 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13044 {
13045 With->pNorm();
13046 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13047 }
13048 strat->redTailChange=TRUE;
13049 if (ksReducePolyTail(L, With, &Ln))
13050 {
13051 // reducing the tail would violate the exp bound
13052 // set a flag and hope for a retry (in bba)
13054 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13055 do
13056 {
13057 pNext(h) = Ln.LmExtractAndIter();
13058 pIter(h);
13059 L->pLength++;
13060 } while (!Ln.IsNull());
13061 goto all_done;
13062 }
13063 if (Ln.IsNull()) goto all_done;
13064 if (! withT) With_s.Init(currRing);
13065 }
13066 pNext(h) = Ln.LmExtractAndIter();
13067 pIter(h);
13068 L->pLength++;
13069 }
13070
13071 all_done:
13072 Ln.Delete();
13073 if (L->p != NULL) pNext(L->p) = pNext(p);
13074
13075 if (strat->redTailChange)
13076 {
13077 L->length = 0;
13078 }
13079 L->Normalize(); // HANNES: should have a test
13080 kTest_L(L,strat);
13081 return L->GetLmCurrRing();
13082}

◆ redtailSba()

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

Definition at line 1789 of file kstd2.cc.

1790{
1791 strat->redTailChange=FALSE;
1792 if (strat->noTailReduction) return L->GetLmCurrRing();
1793 poly h, p;
1794 p = h = L->GetLmTailRing();
1795 if ((h==NULL) || (pNext(h)==NULL))
1796 return L->GetLmCurrRing();
1797
1798 TObject* With;
1799 // placeholder in case strat->tl < 0
1800 TObject With_s(strat->tailRing);
1801
1802 LObject Ln(pNext(h), strat->tailRing);
1803 Ln.sig = L->sig;
1804 Ln.sevSig = L->sevSig;
1805 Ln.pLength = L->GetpLength() - 1;
1806
1807 pNext(h) = NULL;
1808 if (L->p != NULL) pNext(L->p) = NULL;
1809 L->pLength = 1;
1810
1811 Ln.PrepareRed(strat->use_buckets);
1812
1813 int cnt=REDTAIL_CANONICALIZE;
1814 while(!Ln.IsNull())
1815 {
1816 loop
1817 {
1818 if(rField_is_Ring(currRing) && strat->sigdrop)
1819 break;
1820 Ln.SetShortExpVector();
1821 if (withT)
1822 {
1823 int j;
1824 j = kFindDivisibleByInT(strat, &Ln);
1825 if (j < 0) break;
1826 With = &(strat->T[j]);
1827 }
1828 else
1829 {
1830 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
1831 if (With == NULL) break;
1832 }
1833 cnt--;
1834 if (cnt==0)
1835 {
1837 /*poly tmp=*/Ln.CanonicalizeP();
1839 {
1840 Ln.Normalize();
1841 //pNormalize(tmp);
1842 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
1843 }
1844 }
1846 {
1847 With->pNorm();
1848 }
1849 strat->redTailChange=TRUE;
1850 int ret = ksReducePolyTailSig(L, With, &Ln, strat);
1852 L->sig = Ln.sig;
1853 //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig
1854 // I delete it an then set Ln.sig. Hence L->sig is lost
1855#if SBA_PRINT_REDUCTION_STEPS
1856 if (ret != 3)
1858#endif
1859#if SBA_PRINT_OPERATIONS
1860 if (ret != 3)
1862#endif
1863 if (ret)
1864 {
1865 // reducing the tail would violate the exp bound
1866 // set a flag and hope for a retry (in bba)
1868 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
1869 do
1870 {
1871 pNext(h) = Ln.LmExtractAndIter();
1872 pIter(h);
1873 L->pLength++;
1874 } while (!Ln.IsNull());
1875 goto all_done;
1876 }
1877 if (Ln.IsNull()) goto all_done;
1878 if (! withT) With_s.Init(currRing);
1879 if(rField_is_Ring(currRing) && strat->sigdrop)
1880 {
1881 //Cannot break the loop here so easily
1882 break;
1883 }
1884 }
1885 pNext(h) = Ln.LmExtractAndIter();
1886 pIter(h);
1888 pNormalize(h);
1889 L->pLength++;
1890 }
1891 all_done:
1892 Ln.Delete();
1893 if (L->p != NULL) pNext(L->p) = pNext(p);
1894
1895 if (strat->redTailChange)
1896 {
1897 L->length = 0;
1898 }
1899 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
1900 //L->Normalize(); // HANNES: should have a test
1901 kTest_L(L,strat);
1902 return L->GetLmCurrRing();
1903}
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
Definition kstd2.cc:1335

◆ reorderS()

void reorderS ( int suc,
kStrategy  strat 
)

Definition at line 4610 of file kutil.cc.

4611{
4612 int i,j,at,ecart, s2r;
4613 int fq=0;
4614 unsigned long sev;
4615 poly p;
4616 int new_suc=strat->sl+1;
4617 i= *suc;
4618 if (i<0) i=0;
4619
4620 for (; i<=strat->sl; i++)
4621 {
4622 at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4623 if (at != i)
4624 {
4625 if (new_suc > at) new_suc = at;
4626 p = strat->S[i];
4627 ecart = strat->ecartS[i];
4628 sev = strat->sevS[i];
4629 s2r = strat->S_2_R[i];
4630 if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4631 for (j=i; j>=at+1; j--)
4632 {
4633 strat->S[j] = strat->S[j-1];
4634 strat->ecartS[j] = strat->ecartS[j-1];
4635 strat->sevS[j] = strat->sevS[j-1];
4636 strat->S_2_R[j] = strat->S_2_R[j-1];
4637 }
4638 strat->S[at] = p;
4639 strat->ecartS[at] = ecart;
4640 strat->sevS[at] = sev;
4641 strat->S_2_R[at] = s2r;
4642 if (strat->fromQ!=NULL)
4643 {
4644 for (j=i; j>=at+1; j--)
4645 {
4646 strat->fromQ[j] = strat->fromQ[j-1];
4647 }
4648 strat->fromQ[at]=fq;
4649 }
4650 }
4651 }
4653 else *suc=-1;
4654}

◆ replaceInLAndSAndT()

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

Definition at line 9045 of file kutil.cc.

9046{
9047 p.GetP(strat->lmBin);
9048 if (strat->homog) strat->initEcart(&p);
9049 strat->redTailChange=FALSE;
9051 {
9052 p.pCleardenom();
9054 {
9055#ifdef HAVE_SHIFTBBA
9056 if (rIsLPRing(currRing))
9057 p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9058 else
9059#endif
9060 {
9061 p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9062 }
9063 p.pCleardenom();
9064 if (strat->redTailChange)
9065 p.t_p=NULL;
9066 if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9067 else strat->P.sev=0;
9068 }
9069 }
9070
9071 assume(strat->tailRing == p.tailRing);
9072 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9073
9074 int i, j, pos;
9075 poly tp = strat->T[tj].p;
9076
9077 /* enter p to T set */
9078 enterT(p, strat);
9079
9080 for (j = 0; j <= strat->sl; ++j)
9081 {
9082 if (pLtCmp(tp, strat->S[j]) == 0)
9083 {
9084 break;
9085 }
9086 }
9087 /* it may be that the exchanged element
9088 * is until now only in T and not in S */
9089 if (j <= strat->sl)
9090 {
9091 deleteInS(j, strat);
9092 }
9093
9094 pos = posInS(strat, strat->sl, p.p, p.ecart);
9095
9096 pp_Test(p.p, currRing, p.tailRing);
9097 assume(p.FDeg == p.pFDeg());
9098
9099 /* remove useless pairs from L set */
9100 for (i = 0; i <= strat->Ll; ++i)
9101 {
9102 if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9103 {
9104 deleteInL(strat->L, &(strat->Ll), i, strat);
9105 i--;
9106 continue;
9107 }
9108 if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9109 {
9110 deleteInL(strat->L, &(strat->Ll), i, strat);
9111 i--;
9112 }
9113 }
9114#ifdef HAVE_SHIFTBBA
9115 if (rIsLPRing(currRing))
9116 enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9117 else
9118#endif
9119 {
9120 /* generate new pairs with p, probably removing older, now useless pairs */
9121 superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9122 }
9123 /* enter p to S set */
9124 strat->enterS(p, pos, strat, strat->tl);
9125
9126#ifdef HAVE_SHIFTBBA
9127 /* do this after enterS so that the index in R (which is strat->tl) is correct */
9128 if (rIsLPRing(currRing) && !strat->rightGB)
9129 enterTShift(p,strat);
9130#endif
9131}

◆ sba()

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

Definition at line 2981 of file kstd2.cc.

2982{
2983 // ring order stuff:
2984 // in sba we have (until now) two possibilities:
2985 // 1. an incremental computation w.r.t. (C,monomial order)
2986 // 2. a (possibly non-incremental) computation w.r.t. the
2987 // induced Schreyer order.
2988 // The corresponding orders are computed in sbaRing(), depending
2989 // on the flag strat->sbaOrder
2990#if SBA_PRINT_ZERO_REDUCTIONS
2991 long zeroreductions = 0;
2992#endif
2993#if SBA_PRINT_PRODUCT_CRITERION
2994 long product_criterion = 0;
2995#endif
2996#if SBA_PRINT_SIZE_G
2997 int size_g = 0;
2998 int size_g_non_red = 0;
2999#endif
3000#if SBA_PRINT_SIZE_SYZ
3001 long size_syz = 0;
3002#endif
3003 // global variable
3004#if SBA_PRINT_REDUCTION_STEPS
3007#endif
3008#if SBA_PRINT_OPERATIONS
3009 sba_operations = 0;
3011#endif
3012
3013 ideal F1 = F0;
3016 if (strat->sbaOrder == 1 || strat->sbaOrder == 3)
3017 {
3018 sRing = sbaRing(strat);
3019 if (sRing!=currRingOld)
3020 {
3023 }
3024 }
3025 ideal F;
3026 // sort ideal F
3027 //Put the SigDrop element on the correct position (think of sbaEnterS)
3028 //We also sort them
3029 if(rField_is_Ring(currRing) && strat->sigdrop)
3030 {
3031 #if 1
3032 F = idInit(IDELEMS(F1),F1->rank);
3033 for (int i=0; i<IDELEMS(F1);++i)
3034 F->m[i] = F1->m[i];
3035 if(strat->sbaEnterS >= 0)
3036 {
3037 poly dummy;
3038 dummy = pCopy(F->m[0]); //the sigdrop element
3039 for(int i = 0;i<strat->sbaEnterS;i++)
3040 F->m[i] = F->m[i+1];
3041 F->m[strat->sbaEnterS] = dummy;
3042 }
3043 #else
3044 F = idInit(1,F1->rank);
3045 //printf("\nBefore the initial block sorting:\n");idPrint(F1);
3046 F->m[0] = F1->m[0];
3047 int pos;
3048 if(strat->sbaEnterS >= 0)
3049 {
3050 for(int i=1;i<=strat->sbaEnterS;i++)
3051 {
3052 pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS);
3053 idInsertPolyOnPos(F,F1->m[i],pos);
3054 }
3055 for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++)
3056 {
3057 pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F));
3058 idInsertPolyOnPos(F,F1->m[i],pos);
3059 }
3060 poly dummy;
3061 dummy = pCopy(F->m[0]); //the sigdrop element
3062 for(int i = 0;i<strat->sbaEnterS;i++)
3063 F->m[i] = F->m[i+1];
3064 F->m[strat->sbaEnterS] = dummy;
3065 }
3066 else
3067 {
3068 for(int i=1;i<IDELEMS(F1);i++)
3069 {
3070 pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F));
3071 idInsertPolyOnPos(F,F1->m[i],pos);
3072 }
3073 }
3074 #endif
3075 //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar();
3076 }
3077 else
3078 {
3079 F = idInit(IDELEMS(F1),F1->rank);
3080 intvec *sort = idSort(F1);
3081 for (int i=0; i<sort->length();++i)
3082 F->m[i] = F1->m[(*sort)[i]-1];
3084 {
3085 // put the monomials after the sbaEnterS polynomials
3086 //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F);
3087 int nrmon = 0;
3088 for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--)
3089 {
3090 //pWrite(F->m[i]);
3091 if(F->m[i] != NULL && pNext(F->m[i]) == NULL)
3092 {
3093 poly mon = F->m[i];
3094 for(j = i;j>strat->sbaEnterS+nrmon+1;j--)
3095 {
3096 F->m[j] = F->m[j-1];
3097 }
3098 F->m[j] = mon;
3099 nrmon++;
3100 }
3101 //idPrint(F);
3102 }
3103 }
3104 }
3105 //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar();
3107 strat->sigdrop = FALSE;
3108 strat->nrsyzcrit = 0;
3109 strat->nrrewcrit = 0;
3110#if SBA_INTERRED_START
3111 F = kInterRed(F,NULL);
3112#endif
3113#if F5DEBUG
3114 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
3115 rWrite (currRing);
3116 printf("ordSgn = %d\n",currRing->OrdSgn);
3117 printf("\n");
3118#endif
3119 int srmax,lrmax, red_result = 1;
3120 int olddeg,reduc;
3121 int hilbeledeg=1,hilbcount=0,minimcnt=0;
3122 LObject L;
3123 BOOLEAN withT = TRUE;
3124 strat->max_lower_index = 0;
3125 //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
3126 initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/
3127 initSbaPos(strat);
3128 initHilbCrit(F,Q,&hilb,strat);
3129 initSba(F,strat);
3130 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
3131 /*Shdl=*/initSbaBuchMora(F, Q,strat);
3132 idTest(strat->Shdl);
3133 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
3134 srmax = strat->sl;
3135 reduc = olddeg = lrmax = 0;
3136#ifndef NO_BUCKETS
3138 strat->use_buckets = 1;
3139#endif
3140
3141 // redtailBBa against T for inhomogeneous input
3142 // if (!TEST_OPT_OLDSTD)
3143 // withT = ! strat->homog;
3144
3145 // strat->posInT = posInT_pLength;
3146 kTest_TS(strat);
3147
3148#ifdef HAVE_TAIL_RING
3149 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
3151#endif
3152 if (BVERBOSE(23))
3153 {
3154 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
3155 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
3156 kDebugPrint(strat);
3157 }
3158 // We add the elements directly in S from the previous loop
3159 if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0)
3160 {
3161 for(int i = 0;i<strat->sbaEnterS;i++)
3162 {
3163 //Update: now the element is at the correct place
3164 //i+1 because on the 0 position is the sigdrop element
3165 enterT(strat->L[strat->Ll-(i)],strat);
3166 strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl);
3167 }
3168 strat->Ll = strat->Ll - strat->sbaEnterS;
3169 strat->sbaEnterS = -1;
3170 }
3171 kTest_TS(strat);
3172#ifdef KDEBUG
3173 //kDebugPrint(strat);
3174#endif
3175 /* compute------------------------------------------------------- */
3176 while (strat->Ll >= 0)
3177 {
3178 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
3179 #ifdef KDEBUG
3180 if (TEST_OPT_DEBUG) messageSets(strat);
3181 #endif
3182 if (strat->Ll== 0) strat->interpt=TRUE;
3183 /*
3184 if (TEST_OPT_DEGBOUND
3185 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
3186 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
3187 {
3188
3189 //stops computation if
3190 // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
3191 //a predefined number Kstd1_deg
3192 while ((strat->Ll >= 0)
3193 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
3194 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
3195 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
3196 )
3197 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
3198 if (strat->Ll<0) break;
3199 else strat->noClearS=TRUE;
3200 }
3201 */
3202 if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)
3203 {
3204 strat->currIdx = pGetComp(strat->L[strat->Ll].sig);
3205#if F5C
3206 // 1. interreduction of the current standard basis
3207 // 2. generation of new principal syzygy rules for syzCriterion
3209 lrmax, reduc, Q, w, hilb );
3210#endif
3211 // initialize new syzygy rules for the next iteration step
3212 initSyzRules(strat);
3213 }
3214 /*********************************************************************
3215 * interrreduction step is done, we can go on with the next iteration
3216 * step of the signature-based algorithm
3217 ********************************************************************/
3218 /* picks the last element from the lazyset L */
3219 strat->P = strat->L[strat->Ll];
3220 strat->Ll--;
3221
3223 strat->sbaEnterS = pGetComp(strat->P.sig) - 1;
3224 /* reduction of the element chosen from L */
3225 if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1))
3226 {
3227 //#if 1
3228#ifdef DEBUGF5
3229 PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
3230 PrintS("-------------------------------------------------\n");
3231 pWrite(strat->P.sig);
3232 pWrite(pHead(strat->P.p));
3233 pWrite(pHead(strat->P.p1));
3234 pWrite(pHead(strat->P.p2));
3235 PrintS("-------------------------------------------------\n");
3236#endif
3237 if (pNext(strat->P.p) == strat->tail)
3238 {
3239 // deletes the short spoly
3240 /*
3241 if (rField_is_Ring(currRing))
3242 pLmDelete(strat->P.p);
3243 else
3244 pLmFree(strat->P.p);
3245*/
3246 // TODO: needs some masking
3247 // TODO: masking needs to vanish once the signature
3248 // stuff is completely implemented
3249 strat->P.p = NULL;
3250 poly m1 = NULL, m2 = NULL;
3251
3252 // check that spoly creation is ok
3253 while (strat->tailRing != currRing &&
3254 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
3255 {
3256 assume(m1 == NULL && m2 == NULL);
3257 // if not, change to a ring where exponents are at least
3258 // large enough
3259 if (!kStratChangeTailRing(strat))
3260 {
3261 WerrorS("OVERFLOW...");
3262 break;
3263 }
3264 }
3265 // create the real one
3266 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
3267 strat->tailRing, m1, m2, strat->R);
3268
3269 }
3270 else if (strat->P.p1 == NULL)
3271 {
3272 if (strat->minim > 0)
3273 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
3274 // for input polys, prepare reduction
3276 strat->P.PrepareRed(strat->use_buckets);
3277 }
3278 if (strat->P.p == NULL && strat->P.t_p == NULL)
3279 {
3280 red_result = 0;
3281 }
3282 else
3283 {
3284 //#if 1
3285#ifdef DEBUGF5
3286 PrintS("Poly before red: ");
3287 pWrite(pHead(strat->P.p));
3288 pWrite(strat->P.sig);
3289#endif
3290#if SBA_PRODUCT_CRITERION
3291 if (strat->P.prod_crit)
3292 {
3293#if SBA_PRINT_PRODUCT_CRITERION
3295#endif
3296 int pos = posInSyz(strat, strat->P.sig);
3297 enterSyz(strat->P, strat, pos);
3298 kDeleteLcm(&strat->P);
3299 red_result = 2;
3300 }
3301 else
3302 {
3303 red_result = strat->red(&strat->P,strat);
3304 }
3305#else
3306 red_result = strat->red(&strat->P,strat);
3307#endif
3308 }
3309 }
3310 else
3311 {
3312 /*
3313 if (strat->P.lcm != NULL)
3314 pLmFree(strat->P.lcm);
3315 */
3316 red_result = 2;
3317 }
3319 {
3320 if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig)))
3321 {
3322 strat->P.p = pNeg(strat->P.p);
3323 strat->P.sig = pNeg(strat->P.sig);
3324 }
3325 strat->P.pLength = pLength(strat->P.p);
3326 if(strat->P.sig != NULL)
3327 strat->P.sevSig = pGetShortExpVector(strat->P.sig);
3328 if(strat->P.p != NULL)
3329 strat->P.sev = pGetShortExpVector(strat->P.p);
3330 }
3331 //sigdrop case
3332 if(rField_is_Ring(currRing) && strat->sigdrop)
3333 {
3334 //First reduce it as much as one can
3335 red_result = redRing(&strat->P,strat);
3336 if(red_result == 0)
3337 {
3338 strat->sigdrop = FALSE;
3339 pDelete(&strat->P.sig);
3340 strat->P.sig = NULL;
3341 }
3342 else
3343 {
3344 strat->enterS(strat->P, 0, strat, strat->tl);
3345 if (TEST_OPT_PROT)
3346 PrintS("-");
3347 break;
3348 }
3349 }
3350 if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax)
3351 {
3352 strat->sigdrop = TRUE;
3353 break;
3354 }
3355
3356 if (errorreported) break;
3357
3358//#if 1
3359#ifdef DEBUGF5
3360 if (red_result != 0)
3361 {
3362 PrintS("Poly after red: ");
3363 pWrite(pHead(strat->P.p));
3364 pWrite(strat->P.GetLmCurrRing());
3365 pWrite(strat->P.sig);
3366 printf("%d\n",red_result);
3367 }
3368#endif
3369 if (TEST_OPT_PROT)
3370 {
3371 if(strat->P.p != NULL)
3372 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
3373 &olddeg,&reduc,strat, red_result);
3374 else
3375 message((strat->honey ? strat->P.ecart : 0),
3376 &olddeg,&reduc,strat, red_result);
3377 }
3378
3379 if (strat->overflow)
3380 {
3381 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
3382 }
3383 // reduction to non-zero new poly
3384 if (red_result == 1)
3385 {
3386 // get the polynomial (canonicalize bucket, make sure P.p is set)
3387 strat->P.GetP(strat->lmBin);
3388
3389 // sig-safe computations may lead to wrong FDeg computation, thus we need
3390 // to recompute it to make sure everything is alright
3391 (strat->P).FDeg = (strat->P).pFDeg();
3392 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
3393 // but now, for entering S, T, we reset it
3394 // in the inhomogeneous case: FDeg == pFDeg
3395 if (strat->homog) strat->initEcart(&(strat->P));
3396
3397 /* statistic */
3398 if (TEST_OPT_PROT) PrintS("s");
3399
3400 //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
3401 // in F5E we know that the last reduced element is already the
3402 // the one with highest signature
3403 int pos = strat->sl+1;
3404
3405 // reduce the tail and normalize poly
3406 // in the ring case we cannot expect LC(f) = 1,
3407 poly beforetailred;
3409 beforetailred = pCopy(strat->P.sig);
3410#if SBA_TAIL_RED
3412 {
3414 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3415 }
3416 else
3417 {
3418 if (strat->sbaOrder != 2)
3419 {
3421 {
3422 strat->P.pCleardenom();
3424 {
3425 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3426 strat->P.pCleardenom();
3427 }
3428 }
3429 else
3430 {
3431 strat->P.pNorm();
3433 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);
3434 }
3435 }
3436 }
3437 // It may happen that we have lost the sig in redtailsba
3438 // It cannot reduce to 0 since here we are doing just tail reduction.
3439 // Best case scenario: remains the leading term
3440 if(rField_is_Ring(currRing) && strat->sigdrop)
3441 {
3442 strat->enterS(strat->P, 0, strat, strat->tl);
3443 break;
3444 }
3445#endif
3447 {
3448 if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1)
3449 {
3450 strat->sigdrop = TRUE;
3451 //Reduce it as much as you can
3452 red_result = redRing(&strat->P,strat);
3453 if(red_result == 0)
3454 {
3455 //It reduced to 0, cancel the sigdrop
3456 strat->sigdrop = FALSE;
3457 p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL;
3458 }
3459 else
3460 {
3461 strat->enterS(strat->P, 0, strat, strat->tl);
3462 break;
3463 }
3464 }
3466 // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing
3467 if(strat->P.p == NULL)
3469 }
3470 // remove sigsafe label since it is no longer valid for the next element to
3471 // be reduced
3472 if (strat->sbaOrder == 1)
3473 {
3474 for (int jj = 0; jj<strat->tl+1; jj++)
3475 {
3476 if (pGetComp(strat->T[jj].sig) == strat->currIdx)
3477 {
3478 strat->T[jj].is_sigsafe = FALSE;
3479 }
3480 }
3481 }
3482 else
3483 {
3484 for (int jj = 0; jj<strat->tl+1; jj++)
3485 {
3486 strat->T[jj].is_sigsafe = FALSE;
3487 }
3488 }
3489#ifdef KDEBUG
3490 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
3491#endif /* KDEBUG */
3492
3493 // min_std stuff
3494 if ((strat->P.p1==NULL) && (strat->minim>0))
3495 {
3496 if (strat->minim==1)
3497 {
3498 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
3499 p_Delete(&strat->P.p2, currRing, strat->tailRing);
3500 }
3501 else
3502 {
3503 strat->M->m[minimcnt]=strat->P.p2;
3504 strat->P.p2=NULL;
3505 }
3506 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
3507 pNext(strat->M->m[minimcnt])
3508 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
3509 strat->tailRing, currRing,
3510 currRing->PolyBin);
3511 minimcnt++;
3512 }
3513
3514 // enter into S, L, and T
3515 //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
3516 enterT(strat->P, strat);
3517 strat->T[strat->tl].is_sigsafe = FALSE;
3518 /*
3519 printf("hier\n");
3520 pWrite(strat->P.GetLmCurrRing());
3521 pWrite(strat->P.sig);
3522 */
3524 superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3525 else
3526 enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
3527 if(rField_is_Ring(currRing) && strat->sigdrop)
3528 break;
3530 strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing);
3531 strat->enterS(strat->P, pos, strat, strat->tl);
3532 if(strat->sbaOrder != 1)
3533 {
3535 for (int tk=0; tk<strat->sl+1; tk++)
3536 {
3537 if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))
3538 {
3539 //printf("TK %d / %d\n",tk,strat->sl);
3540 overwrite = FALSE;
3541 break;
3542 }
3543 }
3544 //printf("OVERWRITE %d\n",overwrite);
3545 if (overwrite)
3546 {
3547 int cmp = pGetComp(strat->P.sig);
3548 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3549 p_GetExpV (strat->P.p,vv,currRing);
3550 p_SetExpV (strat->P.sig, vv,currRing);
3551 p_SetComp (strat->P.sig,cmp,currRing);
3552
3553 strat->P.sevSig = pGetShortExpVector (strat->P.sig);
3554 int i;
3555 LObject Q;
3556 for(int ps=0;ps<strat->sl+1;ps++)
3557 {
3558
3559 strat->newt = TRUE;
3560 if (strat->syzl == strat->syzmax)
3561 {
3562 pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);
3563 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
3564 (strat->syzmax)*sizeof(unsigned long),
3565 ((strat->syzmax)+setmaxTinc)
3566 *sizeof(unsigned long));
3567 strat->syzmax += setmaxTinc;
3568 }
3569 Q.sig = pCopy(strat->P.sig);
3570 // add LM(F->m[i]) to the signature to get a Schreyer order
3571 // without changing the underlying polynomial ring at all
3572 if (strat->sbaOrder == 0)
3573 p_ExpVectorAdd (Q.sig,strat->S[ps],currRing);
3574 // since p_Add_q() destroys all input
3575 // data we need to recreate help
3576 // each time
3577 // ----------------------------------------------------------
3578 // in the Schreyer order we always know that the multiplied
3579 // module monomial strat->P.sig gives the leading monomial of
3580 // the corresponding principal syzygy
3581 // => we do not need to compute the "real" syzygy completely
3582 poly help = p_Copy(strat->sig[ps],currRing);
3583 p_ExpVectorAdd (help,strat->P.p,currRing);
3584 Q.sig = p_Add_q(Q.sig,help,currRing);
3585 //printf("%d. SYZ ",i+1);
3586 //pWrite(strat->syz[i]);
3587 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);
3588 i = posInSyz(strat, Q.sig);
3589 enterSyz(Q, strat, i);
3590 }
3591 }
3592 }
3593 // deg - idx - lp/rp
3594 // => we need to add syzygies with indices > pGetComp(strat->P.sig)
3595 if(strat->sbaOrder == 0 || strat->sbaOrder == 3)
3596 {
3597 int cmp = pGetComp(strat->P.sig);
3598 unsigned max_cmp = IDELEMS(F);
3599 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
3600 p_GetExpV (strat->P.p,vv,currRing);
3601 LObject Q;
3602 int pos;
3603 int idx = __p_GetComp(strat->P.sig,currRing);
3604 //printf("++ -- adding syzygies -- ++\n");
3605 // if new element is the first one in this index
3606 if (strat->currIdx < idx)
3607 {
3608 for (int i=0; i<strat->sl; ++i)
3609 {
3610 Q.sig = p_Copy(strat->P.sig,currRing);
3611 p_ExpVectorAdd(Q.sig,strat->S[i],currRing);
3612 poly help = p_Copy(strat->sig[i],currRing);
3613 p_ExpVectorAdd(help,strat->P.p,currRing);
3614 Q.sig = p_Add_q(Q.sig,help,currRing);
3615 //pWrite(Q.sig);
3616 pos = posInSyz(strat, Q.sig);
3617 enterSyz(Q, strat, pos);
3618 }
3619 strat->currIdx = idx;
3620 }
3621 else
3622 {
3623 // if the element is not the first one in the given index we build all
3624 // possible syzygies with elements of higher index
3625 for (unsigned i=cmp+1; i<=max_cmp; ++i)
3626 {
3627 pos = -1;
3628 for (int j=0; j<strat->sl; ++j)
3629 {
3630 if (__p_GetComp(strat->sig[j],currRing) == i)
3631 {
3632 pos = j;
3633 break;
3634 }
3635 }
3636 if (pos != -1)
3637 {
3638 Q.sig = p_One(currRing);
3639 p_SetExpV(Q.sig, vv, currRing);
3640 // F->m[i-1] corresponds to index i
3641 p_ExpVectorAdd(Q.sig,F->m[i-1],currRing);
3642 p_SetComp(Q.sig, i, currRing);
3643 poly help = p_Copy(strat->P.sig,currRing);
3644 p_ExpVectorAdd(help,strat->S[pos],currRing);
3645 Q.sig = p_Add_q(Q.sig,help,currRing);
3646 if (strat->sbaOrder == 0)
3647 {
3648 if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn)
3649 {
3650 pos = posInSyz(strat, Q.sig);
3651 enterSyz(Q, strat, pos);
3652 }
3653 }
3654 else
3655 {
3656 pos = posInSyz(strat, Q.sig);
3657 enterSyz(Q, strat, pos);
3658 }
3659 }
3660 }
3661 //printf("++ -- done adding syzygies -- ++\n");
3662 }
3663 }
3664//#if 1
3665#if DEBUGF50
3666 printf("---------------------------\n");
3667 Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);
3668 PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl]));
3669 PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]);
3670#endif
3671 /*
3672 if (newrules)
3673 {
3674 newrules = FALSE;
3675 }
3676 */
3677#if 0
3678 int pl=pLength(strat->P.p);
3679 if (pl==1)
3680 {
3681 //if (TEST_OPT_PROT)
3682 //PrintS("<1>");
3683 }
3684 else if (pl==2)
3685 {
3686 //if (TEST_OPT_PROT)
3687 //PrintS("<2>");
3688 }
3689#endif
3690 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
3691// Print("[%d]",hilbeledeg);
3692 kDeleteLcm(&strat->P);
3693 if (strat->sl>srmax) srmax = strat->sl;
3694 }
3695 else
3696 {
3698 // adds signature of the zero reduction to
3699 // strat->syz. This is the leading term of
3700 // syzygy and can be used in syzCriterion()
3701 // the signature is added if and only if the
3702 // pair was not detected by the rewritten criterion in strat->red = redSig
3703 if (red_result!=2)
3704 {
3705#if SBA_PRINT_ZERO_REDUCTIONS
3707#endif
3708 if(rField_is_Ring(currRing) && strat->P.p == NULL && strat->P.sig == NULL)
3709 {
3710 //Catch the case when p = 0, sig = 0
3711 }
3712 else
3713 {
3714 int pos = posInSyz(strat, strat->P.sig);
3715 enterSyz(strat->P, strat, pos);
3716 //#if 1
3717 #ifdef DEBUGF5
3718 Print("ADDING STUFF TO SYZ : ");
3719 //pWrite(strat->P.p);
3720 pWrite(strat->P.sig);
3721 #endif
3722 }
3723 }
3724 if (strat->P.p1 == NULL && strat->minim > 0)
3725 {
3726 p_Delete(&strat->P.p2, currRing, strat->tailRing);
3727 }
3728 }
3729
3730#ifdef KDEBUG
3731 strat->P.Init();
3732#endif /* KDEBUG */
3733 kTest_TS(strat);
3734 }
3735 #if 0
3736 if(strat->sigdrop)
3737 printf("\nSigDrop!\n");
3738 else
3739 printf("\nEnded with no SigDrop\n");
3740 #endif
3741// Clean strat->P for the next sba call
3742 if(rField_is_Ring(currRing) && strat->sigdrop)
3743 {
3744 //This is used to know how many elements can we directly add to S in the next run
3745 if(strat->P.sig != NULL)
3746 strat->sbaEnterS = pGetComp(strat->P.sig)-1;
3747 //else we already set it at the beginning of the loop
3748 #ifdef KDEBUG
3749 strat->P.Init();
3750 #endif /* KDEBUG */
3751 }
3752#ifdef KDEBUG
3753 if (TEST_OPT_DEBUG) messageSets(strat);
3754#endif /* KDEBUG */
3755
3756 if (TEST_OPT_SB_1)
3757 {
3759 {
3760 int k=1;
3761 int j;
3762 while(k<=strat->sl)
3763 {
3764 j=0;
3765 loop
3766 {
3767 if (j>=k) break;
3768 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
3769 j++;
3770 }
3771 k++;
3772 }
3773 }
3774 }
3775 /* complete reduction of the standard basis--------- */
3776 if (TEST_OPT_REDSB)
3777 {
3778 completeReduce(strat);
3779 if (strat->completeReduce_retry)
3780 {
3781 // completeReduce needed larger exponents, retry
3782 // to reduce with S (instead of T)
3783 // and in currRing (instead of strat->tailRing)
3784#ifdef HAVE_TAIL_RING
3785 if(currRing->bitmask>strat->tailRing->bitmask)
3786 {
3788 cleanT(strat);strat->tailRing=currRing;
3789 int i;
3790 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
3791 completeReduce(strat);
3792 }
3793 if (strat->completeReduce_retry)
3794#endif
3795 Werror("exponent bound is %ld",currRing->bitmask);
3796 }
3797 }
3798 else if (TEST_OPT_PROT) PrintLn();
3799
3800#if SBA_PRINT_SIZE_SYZ
3801 // that is correct, syzl is counting one too far
3802 size_syz = strat->syzl;
3803#endif
3804// if (TEST_OPT_WEIGHTM)
3805// {
3806// pRestoreDegProcs(pFDegOld, pLDegOld);
3807// if (ecartWeights)
3808// {
3809// omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
3810// ecartWeights=NULL;
3811// }
3812// }
3814 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
3815#if SBA_PRINT_SIZE_G
3816 size_g_non_red = IDELEMS(strat->Shdl);
3817#endif
3819 exitSba(strat);
3820 // I have to add the initial input polynomials which where not used (p1 and p2 = NULL)
3821 int k;
3823 {
3824 //for(k = strat->sl;k>=0;k--)
3825 // {printf("\nS[%i] = %p\n",k,strat->Shdl->m[k]);pWrite(strat->Shdl->m[k]);}
3826 k = strat->Ll;
3827 #if 1
3828 // 1 - adds just the unused ones, 0 - adds everything
3829 for(;k>=0 && (strat->L[k].p1 != NULL || strat->L[k].p2 != NULL);k--)
3830 {
3831 //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);
3832 deleteInL(strat->L,&strat->Ll,k,strat);
3833 }
3834 #endif
3835 //for(int kk = strat->sl;kk>=0;kk--)
3836 // {printf("\nS[%i] = %p\n",kk,strat->Shdl->m[kk]);pWrite(strat->Shdl->m[kk]);}
3837 //idPrint(strat->Shdl);
3838 //printf("\nk = %i\n",k);
3839 for(;k>=0 && strat->L[k].p1 == NULL && strat->L[k].p2 == NULL;k--)
3840 {
3841 //printf("\nAdded k = %i\n",k);
3842 strat->enterS(strat->L[k], strat->sl+1, strat, strat->tl);
3843 //printf("\nThis elements was added from L on pos %i\n",strat->sl);pWrite(strat->S[strat->sl]);pWrite(strat->sig[strat->sl]);
3844 }
3845 }
3846 // 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
3847 #if 0
3848 if(strat->sigdrop && rField_is_Ring(currRing))
3849 {
3850 for(k=strat->sl;k>=0;k--)
3851 {
3852 printf("\nsig[%i] = ",i);pWrite(strat->sig[k]);
3853 if(strat->sig[k] == NULL)
3854 strat->sig[k] = pCopy(strat->sig[k-1]);
3855 }
3856 }
3857 #endif
3858 //Never do this - you will damage S
3859 //idSkipZeroes(strat->Shdl);
3860 //idPrint(strat->Shdl);
3861
3862 if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld)
3863 {
3865 F0 = idrMoveR (F1, sRing, currRing);
3866 strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing);
3869 exitSba(strat);
3871 if(strat->tailRing == sRing)
3872 strat->tailRing = currRing;
3873 rDelete (sRing);
3874 }
3875 if(rField_is_Ring(currRing) && !strat->sigdrop)
3876 id_DelDiv(strat->Shdl, currRing);
3878 id_DelDiv(strat->Shdl, currRing);
3879 idSkipZeroes(strat->Shdl);
3880 idTest(strat->Shdl);
3881
3882#if SBA_PRINT_SIZE_G
3883 size_g = IDELEMS(strat->Shdl);
3884#endif
3885#ifdef DEBUGF5
3886 printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));
3887 int oo = 0;
3888 while (oo<IDELEMS(strat->Shdl))
3889 {
3890 printf(" %d. ",oo+1);
3891 pWrite(pHead(strat->Shdl->m[oo]));
3892 oo++;
3893 }
3894#endif
3895#if SBA_PRINT_ZERO_REDUCTIONS
3896 printf("----------------------------------------------------------\n");
3897 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3898 zeroreductions = 0;
3899#endif
3900#if SBA_PRINT_REDUCTION_STEPS
3901 printf("----------------------------------------------------------\n");
3902 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3903#endif
3904#if SBA_PRINT_OPERATIONS
3905 printf("OPERATIONS: %ld\n",sba_operations);
3906#endif
3907#if SBA_PRINT_REDUCTION_STEPS
3908 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3909 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3910#endif
3911#if SBA_PRINT_OPERATIONS
3912 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3913#endif
3914#if SBA_PRINT_REDUCTION_STEPS
3915 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3916 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3919#endif
3920#if SBA_PRINT_OPERATIONS
3921 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3923 sba_operations = 0;
3924#endif
3925#if SBA_PRINT_SIZE_G
3926 printf("----------------------------------------------------------\n");
3927 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3928 size_g = 0;
3929 size_g_non_red = 0;
3930#endif
3931#if SBA_PRINT_SIZE_SYZ
3932 printf("SIZE OF SYZ: %ld\n",size_syz);
3933 printf("----------------------------------------------------------\n");
3934 size_syz = 0;
3935#endif
3936#if SBA_PRINT_PRODUCT_CRITERION
3937 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3939#endif
3940 return (strat->Shdl);
3941}
static void sort(int **points, int sizePoints)
int blockredmax
Definition kutil.h:365
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:295
int sbaEnterS
Definition kutil.h:362
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:188
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3806
void initSba(ideal F, kStrategy strat)
Definition kstd1.cc:1750
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kstd2.cc:1789
void f5c(kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, bigintmat *hilb)
Definition kstd2.cc:4281
void initSbaPos(kStrategy strat)
Definition kutil.cc:9857
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4513
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4470
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
Definition kutil.cc:11087
void messageStatSBA(int hilbcount, kStrategy strat)
Definition kutil.cc:7514
void initSyzRules(kStrategy strat)
Definition kutil.cc:7928
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9959
void exitSba(kStrategy strat)
Definition kutil.cc:10034
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
Definition kutil.cc:4841
void initSbaCrit(kStrategy strat)
Definition kutil.cc:9491
#define help
Definition libparse.cc:1230
static void p_SetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1565
static void p_GetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1541
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:261
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
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 1688 of file kutil.cc.

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

◆ sbaRing()

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

Definition at line 11087 of file kutil.cc.

11088{
11089 int n = rBlocks(r); // Including trailing zero!
11090 // if sbaOrder == 1 => use (C,monomial order from r)
11091 if (strat->sbaOrder == 1)
11092 {
11093 if (r->order[0] == ringorder_C || r->order[0] == ringorder_c)
11094 {
11095 return r;
11096 }
11097 ring res = rCopy0(r, TRUE, FALSE);
11098 res->order = (rRingOrder_t *)omAlloc0((n+1)*sizeof(rRingOrder_t));
11099 res->block0 = (int *)omAlloc0((n+1)*sizeof(int));
11100 res->block1 = (int *)omAlloc0((n+1)*sizeof(int));
11101 int **wvhdl = (int **)omAlloc0((n+1)*sizeof(int*));
11102 res->wvhdl = wvhdl;
11103 for (int i=1; i<n; i++)
11104 {
11105 res->order[i] = r->order[i-1];
11106 res->block0[i] = r->block0[i-1];
11107 res->block1[i] = r->block1[i-1];
11108 res->wvhdl[i] = r->wvhdl[i-1];
11109 }
11110
11111 // new 1st block
11112 res->order[0] = ringorder_C; // Prefix
11113 // removes useless secondary component order if defined in old ring
11114 for (int i=rBlocks(res); i>0; --i)
11115 {
11116 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11117 {
11118 res->order[i] = (rRingOrder_t)0;
11119 }
11120 }
11121 rComplete(res, 1);
11122#ifdef HAVE_PLURAL
11123 if (rIsPluralRing(r))
11124 {
11125 if ( nc_rComplete(r, res, false) ) // no qideal!
11126 {
11127#ifndef SING_NDEBUG
11128 WarnS("error in nc_rComplete");
11129#endif
11130 // cleanup?
11131
11132 // rDelete(res);
11133 // return r;
11134
11135 // just go on..
11136 }
11137 }
11138#endif
11139 strat->tailRing = res;
11140 return (res);
11141 }
11142 // if sbaOrder == 3 => degree - position - ring order
11143 if (strat->sbaOrder == 3)
11144 {
11145 ring res = rCopy0(r, TRUE, FALSE);
11146 res->order = (rRingOrder_t*)omAlloc0((n+2)*sizeof(rRingOrder_t));
11147 res->block0 = (int *)omAlloc0((n+2)*sizeof(int));
11148 res->block1 = (int *)omAlloc0((n+2)*sizeof(int));
11149 int **wvhdl = (int **)omAlloc0((n+2)*sizeof(int*));
11150 res->wvhdl = wvhdl;
11151 for (int i=2; i<n+2; i++)
11152 {
11153 res->order[i] = r->order[i-2];
11154 res->block0[i] = r->block0[i-2];
11155 res->block1[i] = r->block1[i-2];
11156 res->wvhdl[i] = r->wvhdl[i-2];
11157 }
11158
11159 // new 1st block
11160 res->order[0] = ringorder_a; // Prefix
11161 res->block0[0] = 1;
11162 res->wvhdl[0] = (int *)omAlloc(res->N*sizeof(int));
11163 for (int i=0; i<res->N; ++i)
11164 res->wvhdl[0][i] = 1;
11165 res->block1[0] = si_min(res->N, rVar(res));
11166 // new 2nd block
11167 res->order[1] = ringorder_C; // Prefix
11168 res->wvhdl[1] = NULL;
11169 // removes useless secondary component order if defined in old ring
11170 for (int i=rBlocks(res); i>1; --i)
11171 {
11172 if (res->order[i] == ringorder_C || res->order[i] == ringorder_c)
11173 {
11174 res->order[i] = (rRingOrder_t)0;
11175 }
11176 }
11177 rComplete(res, 1);
11178#ifdef HAVE_PLURAL
11179 if (rIsPluralRing(r))
11180 {
11181 if ( nc_rComplete(r, res, false) ) // no qideal!
11182 {
11183#ifndef SING_NDEBUG
11184 WarnS("error in nc_rComplete");
11185#endif
11186 // cleanup?
11187
11188 // rDelete(res);
11189 // return r;
11190
11191 // just go on..
11192 }
11193 }
11194#endif
11195 strat->tailRing = res;
11196 return (res);
11197 }
11198
11199 // not sbaOrder == 1 => use Schreyer order
11200 // this is done by a trick when initializing the signatures
11201 // in initSLSba():
11202 // Instead of using the signature 1e_i for F->m[i], we start
11203 // with the signature LM(F->m[i])e_i for F->m[i]. Doing this we get a
11204 // Schreyer order w.r.t. the underlying monomial order.
11205 // => we do not need to change the underlying polynomial ring at all!
11206
11207 // UPDATE/NOTE/TODO: use induced Schreyer ordering 'IS'!!!!????
11208
11209 /*
11210 else
11211 {
11212 ring res = rCopy0(r, FALSE, FALSE);
11213 // Create 2 more blocks for prefix/suffix:
11214 res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0 .. n+1
11215 res->block0=(int *)omAlloc0((n+2)*sizeof(int));
11216 res->block1=(int *)omAlloc0((n+2)*sizeof(int));
11217 int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
11218
11219 // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
11220 // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
11221
11222 // new 1st block
11223 int j = 0;
11224 res->order[j] = ringorder_IS; // Prefix
11225 res->block0[j] = res->block1[j] = 0;
11226 // wvhdl[j] = NULL;
11227 j++;
11228
11229 for(int i = 0; (i < n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
11230 {
11231 res->order [j] = r->order [i];
11232 res->block0[j] = r->block0[i];
11233 res->block1[j] = r->block1[i];
11234
11235 if (r->wvhdl[i] != NULL)
11236 {
11237 wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
11238 } // else wvhdl[j] = NULL;
11239 }
11240
11241 // new last block
11242 res->order [j] = ringorder_IS; // Suffix
11243 res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
11244 // wvhdl[j] = NULL;
11245 j++;
11246
11247 // res->order [j] = 0; // The End!
11248 res->wvhdl = wvhdl;
11249
11250 // j == the last zero block now!
11251 assume(j == (n+1));
11252 assume(res->order[0]==ringorder_IS);
11253 assume(res->order[j-1]==ringorder_IS);
11254 assume(res->order[j]==0);
11255
11256 if (complete)
11257 {
11258 rComplete(res, 1);
11259
11260#ifdef HAVE_PLURAL
11261 if (rIsPluralRing(r))
11262 {
11263 if ( nc_rComplete(r, res, false) ) // no qideal!
11264 {
11265 }
11266 }
11267 assume(rIsPluralRing(r) == rIsPluralRing(res));
11268#endif
11269
11270
11271#ifdef HAVE_PLURAL
11272 ring old_ring = r;
11273
11274#endif
11275
11276 if (r->qideal!=NULL)
11277 {
11278 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
11279
11280 assume(idRankFreeModule(res->qideal, res) == 0);
11281
11282#ifdef HAVE_PLURAL
11283 if( rIsPluralRing(res) )
11284 if( nc_SetupQuotient(res, r, true) )
11285 {
11286 // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
11287 }
11288
11289#endif
11290 assume(idRankFreeModule(res->qideal, res) == 0);
11291 }
11292
11293#ifdef HAVE_PLURAL
11294 assume((res->qideal==NULL) == (old_ring->qideal==NULL));
11295 assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
11296 assume(rIsSCA(res) == rIsSCA(old_ring));
11297 assume(ncRingType(res) == ncRingType(old_ring));
11298#endif
11299 }
11300 strat->tailRing = res;
11301 return res;
11302 }
11303 */
11304
11305 assume(FALSE);
11306 return(NULL);
11307}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition ring.cc:5833
static int rBlocks(const ring r)
Definition ring.h:574
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_a
Definition ring.h:71

◆ superenterpairs()

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

Definition at line 4457 of file kutil.cc.

4458{
4460#if HAVE_SHIFTBBA
4461 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4462#endif
4463 // enter also zero divisor * poly, if this is non zero and of smaller degree
4465 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4466 initenterpairs(h, k, ecart, 0, strat, atR);
4467 clearSbatch(h, k, pos, strat);
4468}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition kutil.cc:4433
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4152
void enterExtendedSpoly(poly h, kStrategy strat)
Definition kutil.cc:4232

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

4471{
4473 // enter also zero divisor * poly, if this is non zero and of smaller degree
4475 if(strat->sigdrop) return;
4476 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4477 if(strat->sigdrop) return;
4478 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4479 if(strat->sigdrop) return;
4480 clearSbatch(h, k, pos, strat);
4481}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3934
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4207
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition kutil.cc:4316

◆ syzCriterion()

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

Definition at line 6475 of file kutil.cc.

6476{
6477//#if 1
6478#ifdef DEBUGF5
6479 PrintS("syzygy criterion checks: ");
6480 pWrite(sig);
6481#endif
6482 for (int k=0; k<strat->syzl; k++)
6483 {
6484 //printf("-%d",k);
6485//#if 1
6486#ifdef DEBUGF5
6487 Print("checking with: %d / %d -- \n",k,strat->syzl);
6488 pWrite(pHead(strat->syz[k]));
6489#endif
6490 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6491 && (!rField_is_Ring(currRing) ||
6492 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6493 {
6494//#if 1
6495#ifdef DEBUGF5
6496 PrintS("DELETE!\n");
6497#endif
6498 strat->nrsyzcrit++;
6499 //printf("- T -\n\n");
6500 return TRUE;
6501 }
6502 }
6503 //printf("- F -\n\n");
6504 return FALSE;
6505}

◆ syzCriterionInc()

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

Definition at line 6510 of file kutil.cc.

6511{
6512//#if 1
6513 if(sig == NULL)
6514 return FALSE;
6515#ifdef DEBUGF5
6516 PrintS("--- syzygy criterion checks: ");
6517 pWrite(sig);
6518#endif
6519 int comp = (int)__p_GetComp(sig, currRing);
6520 int min, max;
6521 if (comp<=1)
6522 return FALSE;
6523 else
6524 {
6525 min = strat->syzIdx[comp-2];
6526 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6527 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6528 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6529 if (comp == strat->currIdx)
6530 {
6531 max = strat->syzl;
6532 }
6533 else
6534 {
6535 max = strat->syzIdx[comp-1];
6536 }
6537 for (int k=min; k<max; k++)
6538 {
6539#ifdef F5DEBUG
6540 Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6541 Print("checking with: %d -- ",k);
6542 pWrite(pHead(strat->syz[k]));
6543#endif
6544 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6545 && (!rField_is_Ring(currRing) ||
6546 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6547 {
6548 strat->nrsyzcrit++;
6549 return TRUE;
6550 }
6551 }
6552 return FALSE;
6553 }
6554}
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 10074 of file kutil.cc.

10075{
10076 int l;
10077 if (strat->ak>0)
10078 {
10079 for (l=IDELEMS(r)-1;l>=0;l--)
10080 {
10081 if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0))
10082 {
10083 pDelete(&r->m[l]); // and set it to NULL
10084 }
10085 }
10086 int q;
10087 poly p;
10089 {
10090 for (l=IDELEMS(r)-1;l>=0;l--)
10091 {
10092 if ((r->m[l]!=NULL)
10093 //&& (strat->syzComp>0)
10094 //&& (pGetComp(r->m[l])<=strat->syzComp)
10095 )
10096 {
10097 for(q=IDELEMS(Q)-1; q>=0;q--)
10098 {
10099 if ((Q->m[q]!=NULL)
10100 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10101 {
10102 if (TEST_OPT_REDSB)
10103 {
10104 p=r->m[l];
10105 r->m[l]=kNF(Q,NULL,p);
10106 pDelete(&p);
10107 }
10108 else
10109 {
10110 pDelete(&r->m[l]); // and set it to NULL
10111 }
10112 break;
10113 }
10114 }
10115 }
10116 }
10117 }
10118 else
10119 {
10120 for (l=IDELEMS(r)-1;l>=0;l--)
10121 {
10122 if ((r->m[l]!=NULL)
10123 //&& (strat->syzComp>0)
10124 //&& (pGetComp(r->m[l])<=strat->syzComp)
10125 )
10126 {
10127 for(q=IDELEMS(Q)-1; q>=0;q--)
10128 {
10129 if ((Q->m[q]!=NULL)
10130 &&(pLmDivisibleBy(Q->m[q],r->m[l])))
10131 {
10132 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10133 {
10134 if (TEST_OPT_REDSB)
10135 {
10136 p=r->m[l];
10137 r->m[l]=kNF(Q,NULL,p);
10138 pDelete(&p);
10139 }
10140 else
10141 {
10142 pDelete(&r->m[l]); // and set it to NULL
10143 }
10144 break;
10145 }
10146 }
10147 }
10148 }
10149 }
10150 }
10151 }
10152 else
10153 {
10154 int q;
10155 poly p;
10158 {
10159 for (l=IDELEMS(r)-1;l>=0;l--)
10160 {
10161 if (r->m[l]!=NULL)
10162 {
10163 for(q=IDELEMS(Q)-1; q>=0;q--)
10164 {
10165 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])))
10166 {
10167 if (TEST_OPT_REDSB)
10168 {
10169 p=r->m[l];
10170 r->m[l]=kNF(Q,NULL,p);
10171 pDelete(&p);
10173 }
10174 else
10175 {
10176 pDelete(&r->m[l]); // and set it to NULL
10177 }
10178 break;
10179 }
10180 }
10181 }
10182 }
10183 }
10184 //Also need divisibility of the leading coefficients
10185 else
10186 {
10187 for (l=IDELEMS(r)-1;l>=0;l--)
10188 {
10189 if (r->m[l]!=NULL)
10190 {
10191 for(q=IDELEMS(Q)-1; q>=0;q--)
10192 {
10193 if(n_DivBy(r->m[l]->coef, Q->m[q]->coef, currRing->cf))
10194 {
10195 if ((Q->m[q]!=NULL)&&(pLmEqual(Q->m[q],r->m[l])) && pDivisibleBy(Q->m[q],r->m[l]))
10196 {
10197 if (TEST_OPT_REDSB)
10198 {
10199 p=r->m[l];
10200 r->m[l]=kNF(Q,NULL,p);
10201 pDelete(&p);
10203 }
10204 else
10205 {
10206 pDelete(&r->m[l]); // and set it to NULL
10207 }
10208 break;
10209 }
10210 }
10211 }
10212 }
10213 }
10214 }
10215 if (/*TEST_OPT_REDSB &&*/ reduction_found)
10216 {
10218 {
10219 for (l=IDELEMS(r)-1;l>=0;l--)
10220 {
10221 if (r->m[l]!=NULL)
10222 {
10223 for(q=IDELEMS(r)-1;q>=0;q--)
10224 {
10225 if ((l!=q)
10226 && (r->m[q]!=NULL)
10227 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10228 &&(n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf))
10229 )
10230 {
10231 //If they are equal then take the one with the smallest length
10232 if(pLmDivisibleBy(r->m[q],r->m[l])
10233 && n_DivBy(r->m[q]->coef, r->m[l]->coef, currRing->cf)
10234 && (pLength(r->m[q]) < pLength(r->m[l]) ||
10235 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10236 {
10237 pDelete(&r->m[l]);
10238 break;
10239 }
10240 else
10241 pDelete(&r->m[q]);
10242 }
10243 }
10244 }
10245 }
10246 }
10247 else
10248 {
10249 for (l=IDELEMS(r)-1;l>=0;l--)
10250 {
10251 if (r->m[l]!=NULL)
10252 {
10253 for(q=IDELEMS(r)-1;q>=0;q--)
10254 {
10255 if ((l!=q)
10256 && (r->m[q]!=NULL)
10257 &&(pLmDivisibleBy(r->m[l],r->m[q]))
10258 )
10259 {
10260 //If they are equal then take the one with the smallest length
10261 if(pLmDivisibleBy(r->m[q],r->m[l])
10262 &&(pLength(r->m[q]) < pLength(r->m[l]) ||
10263 (pLength(r->m[q]) == pLength(r->m[l]) && nGreaterZero(r->m[q]->coef))))
10264 {
10265 pDelete(&r->m[l]);
10266 break;
10267 }
10268 else
10269 pDelete(&r->m[q]);
10270 }
10271 }
10272 }
10273 }
10274 }
10275 }
10276 }
10277 idSkipZeroes(r);
10278}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3233

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8552 of file kutil.cc.

8553{
8554 LObject h;
8555 int i, suc=0;
8556 poly redSi=NULL;
8558// Print("nach initS: updateS start mit sl=%d\n",(strat->sl));
8559// for (i=0; i<=(strat->sl); i++)
8560// {
8561// Print("s%d:",i);
8562// if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]);
8563// pWrite(strat->S[i]);
8564// }
8565// Print("currRing->OrdSgn=%d\n", currRing->OrdSgn);
8568 {
8569 while (suc != -1)
8570 {
8571 i=suc+1;
8572 while (i<=strat->sl)
8573 {
8574 change=FALSE;
8576 any_change = FALSE;
8577 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8578 {
8579 redSi = pHead(strat->S[i]);
8580 strat->S[i] = redBba(strat->S[i],i-1,strat);
8581 //if ((strat->ak!=0)&&(strat->S[i]!=NULL))
8582 // strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/
8583 if (pCmp(redSi,strat->S[i])!=0)
8584 {
8585 change=TRUE;
8587 #ifdef KDEBUG
8588 if (TEST_OPT_DEBUG)
8589 {
8590 PrintS("reduce:");
8591 wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn();
8592 }
8593 #endif
8594 if (TEST_OPT_PROT)
8595 {
8596 if (strat->S[i]==NULL)
8597 PrintS("V");
8598 else
8599 PrintS("v");
8600 mflush();
8601 }
8602 }
8603 pLmDelete(&redSi);
8604 if (strat->S[i]==NULL)
8605 {
8606 deleteInS(i,strat);
8607 i--;
8608 }
8609 else if (change)
8610 {
8612 {
8614 {
8615 number n;
8616 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8617 if (!nIsOne(n))
8618 {
8620 denom->n=nInvers(n);
8621 denom->next=DENOMINATOR_LIST;
8623 }
8624 nDelete(&n);
8625 }
8626 else
8627 {
8628 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8629 }
8630 }
8631 else
8632 {
8633 pNorm(strat->S[i]);
8634 }
8635 strat->sevS[i] = pGetShortExpVector(strat->S[i]);
8636 }
8637 }
8638 i++;
8639 }
8640 if (any_change) reorderS(&suc,strat);
8641 else break;
8642 }
8643 if (toT)
8644 {
8645 for (i=0; i<=strat->sl; i++)
8646 {
8647 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8648 {
8649 h.p = redtailBba(strat->S[i],i-1,strat);
8651 {
8652 h.pCleardenom();// also does remove Content
8653 }
8654 }
8655 else
8656 {
8657 h.p = strat->S[i];
8658 }
8659 strat->initEcart(&h);
8660 if (strat->honey)
8661 {
8662 strat->ecartS[i] = h.ecart;
8663 }
8664 if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);}
8665 else assume(strat->sevS[i] == pGetShortExpVector(h.p));
8666 h.sev = strat->sevS[i];
8667 /*puts the elements of S also to T*/
8668 strat->initEcart(&h);
8669 /*if (toT) - already checked*/ enterT(h,strat);
8670 strat->S_2_R[i] = strat->tl;
8671#ifdef HAVE_SHIFTBBA
8672 if (/*(toT) && */(currRing->isLPring))
8673 enterTShift(h, strat);
8674#endif
8675 }
8676 }
8677 }
8678 else
8679 {
8680 while (suc != -1)
8681 {
8682 i=suc;
8683 while (i<=strat->sl)
8684 {
8685 change=FALSE;
8686 if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0))
8687 {
8688 redSi=pHead((strat->S)[i]);
8689 (strat->S)[i] = redMora((strat->S)[i],i-1,strat);
8690 if ((strat->S)[i]==NULL)
8691 {
8692 deleteInS(i,strat);
8693 i--;
8694 }
8695 else if (pCmp((strat->S)[i],redSi)!=0)
8696 {
8698 h.p = strat->S[i];
8699 strat->initEcart(&h);
8700 strat->ecartS[i] = h.ecart;
8702 {
8704 {
8705 number n;
8706 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
8707 if (!nIsOne(n))
8708 {
8710 denom->n=nInvers(n);
8711 denom->next=DENOMINATOR_LIST;
8713 }
8714 nDelete(&n);
8715 }
8716 else
8717 {
8718 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
8719 }
8720 }
8721 else
8722 {
8723 pNorm(strat->S[i]); // == h.p
8724 }
8725 h.sev = pGetShortExpVector(h.p);
8726 strat->sevS[i] = h.sev;
8727 }
8728 pLmDelete(&redSi);
8729 kTest(strat);
8730 }
8731 i++;
8732 }
8733#ifdef KDEBUG
8734 kTest(strat);
8735#endif
8736 if (any_change) reorderS(&suc,strat);
8737 else { suc=-1; break; }
8738 if (h.p!=NULL)
8739 {
8740 if (!strat->kAllAxis)
8741 {
8742 /*strat->kAllAxis =*/ HEckeTest(h.p,strat);
8743 }
8744 if (strat->kAllAxis)
8745 newHEdge(strat);
8746 }
8747 }
8748 for (i=0; i<=strat->sl; i++)
8749 {
8750 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8751 {
8752 strat->S[i] = h.p = redtail(strat->S[i],strat->sl,strat);
8753 strat->initEcart(&h);
8754 strat->ecartS[i] = h.ecart;
8755 h.sev = pGetShortExpVector(h.p);
8756 strat->sevS[i] = h.sev;
8757 }
8758 else
8759 {
8760 h.p = strat->S[i];
8761 h.ecart=strat->ecartS[i];
8762 h.sev = strat->sevS[i];
8763 h.length = h.pLength = pLength(h.p);
8764 }
8765 if ((strat->fromQ==NULL) || (strat->fromQ[i]==0))
8766 cancelunit1(&h,&suc,strat->sl,strat);
8767 h.SetpFDeg();
8768 /*puts the elements of S also to T*/
8769 enterT(h,strat);
8770 strat->S_2_R[i] = strat->tl;
8771#ifdef HAVE_SHIFTBBA
8772 if (currRing->isLPring)
8773 enterTShift(h, strat);
8774#endif
8775 }
8776 if (suc!= -1) updateS(toT,strat);
8777 }
8778#ifdef KDEBUG
8779 kTest(strat);
8780#endif
8781}
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8507
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8483
void cancelunit1(LObject *p, int *suc, int index, kStrategy strat)
Definition kutil.cc:8397
void reorderS(int *suc, kStrategy strat)
Definition kutil.cc:4610

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 67 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 270 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 182 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 878 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 877 of file kutil.h.