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 "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 *reduc, int *olddeg, kStrategy strat, int red_result)
 
void messageStat (int hilbcount, kStrategy strat)
 
void messageStatSBA (int hilbcount, kStrategy strat)
 
void messageSets (kStrategy strat)
 
void initEcartNormal (TObject *h)
 
void initEcartBBA (TObject *h)
 
void initS (ideal F, ideal Q, kStrategy strat)
 
void initSL (ideal F, ideal Q, kStrategy strat)
 
void initSLSba (ideal F, ideal Q, kStrategy strat)
 
void initSyzRules (kStrategy strat)
 
void updateS (BOOLEAN toT, kStrategy strat)
 
void enterSyz (LObject &p, kStrategy strat, int atT)
 
void enterT (LObject &p, kStrategy strat, int atT=-1)
 
void replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
void enterT_strong (LObject &p, kStrategy strat, int atT=-1)
 
void cancelunit (LObject *p, BOOLEAN inNF=FALSE)
 
void HEckeTest (poly pp, kStrategy strat)
 
void initBuchMoraCrit (kStrategy strat)
 
void initSbaCrit (kStrategy strat)
 
void initHilbCrit (ideal F, ideal Q, intvec **hilb, kStrategy strat)
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT=FALSE)
 
void kFreeStrat (kStrategy strat)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int ecart, kStrategy strat)
 
BOOLEAN homogTest (polyset F, int Fmax)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
KINLINE BOOLEAN arriRewDummy (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
 
BOOLEAN findMinLMPair (poly sig, unsigned long not_sevSig, kStrategy strat, int start)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
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)
 
poly kFindZeroPoly (poly input_p, ring leadRing, ring tailRing)
 
ideal bba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
ideal sba (ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
 
poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
 
ideal kNF2 (ideal F, ideal Q, ideal q, kStrategy strat, int lazyReduce)
 
poly kNF2Bound (ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
 
ideal kNF2Bound (ideal F, ideal Q, ideal q, int bound, kStrategy strat, int lazyReduce)
 
void initBba (kStrategy strat)
 
void initSba (ideal F, kStrategy strat)
 
void f5c (kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, intvec *hilb)
 
int ksReducePoly (LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, poly *mon=NULL, kStrategy strat=NULL, 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, intvec *hilb, kStrategy strat)
 
static void kDeleteLcm (LObject *P)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 

Variables

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

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 65 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

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

Definition at line 393 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 27 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 49 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 50 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 36 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 37 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 38 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 29 of file kutil.h.

◆ setmaxL

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

Definition at line 30 of file kutil.h.

◆ setmaxLinc

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

Definition at line 31 of file kutil.h.

◆ setmaxT

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

Definition at line 33 of file kutil.h.

◆ setmaxTinc

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

Definition at line 34 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 63 of file kutil.h.

◆ intset

Definition at line 53 of file kutil.h.

◆ LObject

Definition at line 58 of file kutil.h.

◆ LSet

Definition at line 60 of file kutil.h.

◆ TObject

Definition at line 57 of file kutil.h.

◆ TSet

Definition at line 59 of file kutil.h.

◆ wlen_set

Definition at line 55 of file kutil.h.

◆ wlen_type

Definition at line 54 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6622 of file kutil.cc.

6623{
6625 return FALSE;
6626 poly p1 = pOne();
6627 poly p2 = pOne();
6628 for (int ii=strat->sl; ii>start; ii--)
6629 {
6630 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6631 {
6632 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6633 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6634 if (!(pLmCmp(p1,p2) == 1))
6635 {
6636 pDelete(&p1);
6637 pDelete(&p2);
6638 return TRUE;
6639 }
6640 }
6641 }
6642 pDelete(&p1);
6643 pDelete(&p2);
6644 return FALSE;
6645}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
polyset S
Definition kutil.h:306
unsigned long * sevSig
Definition kutil.h:324
polyset sig
Definition kutil.h:308
LObject P
Definition kutil.h:302
int sl
Definition kutil.h:348
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1440
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1925
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pDelete(p_ptr)
Definition polys.h:186
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:105
#define pOne()
Definition polys.h:315
#define rField_is_Ring(R)
Definition ring.h:490

◆ arriRewCriterionPre()

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

Definition at line 6647 of file kutil.cc.

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

◆ arriRewDummy()

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

Definition at line 1255 of file kInline.h.

1256{
1257 return FALSE;
1258}

◆ bba()

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

Definition at line 2622 of file kstd2.cc.

2623{
2624 int red_result = 1;
2625 int olddeg,reduc;
2626 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2628 BITSET save;
2630
2631 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
2633 initBuchMoraPosRing(strat);
2634 else
2635 initBuchMoraPos(strat);
2636 initHilbCrit(F,Q,&hilb,strat);
2637 initBba(strat);
2638 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
2639 /*Shdl=*/initBuchMora(F, Q,strat);
2640 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
2641 reduc = olddeg = 0;
2642
2643#ifndef NO_BUCKETS
2645 strat->use_buckets = 1;
2646#endif
2647 // redtailBBa against T for inhomogeneous input
2648 if (!TEST_OPT_OLDSTD)
2649 withT = ! strat->homog;
2650
2651 // strat->posInT = posInT_pLength;
2652 kTest_TS(strat);
2653
2654#ifdef HAVE_TAIL_RING
2655 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed
2657#endif
2658 if (BVERBOSE(23))
2659 {
2660 if (test_PosInT!=NULL) strat->posInT=test_PosInT;
2661 if (test_PosInL!=NULL) strat->posInL=test_PosInL;
2662 kDebugPrint(strat);
2663 }
2664
2665
2666#ifdef KDEBUG
2667 //kDebugPrint(strat);
2668#endif
2669 /* compute------------------------------------------------------- */
2670 while (strat->Ll >= 0)
2671 {
2672 #ifdef KDEBUG
2673 if (TEST_OPT_DEBUG) messageSets(strat);
2674 #endif
2675 if (siCntrlc)
2676 {
2677 while (strat->Ll >= 0)
2678 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2679 strat->noClearS=TRUE;
2680 }
2682 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2683 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
2684 {
2685 /*
2686 *stops computation if
2687 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
2688 *a predefined number Kstd1_deg
2689 */
2690 while ((strat->Ll >= 0)
2691 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
2692 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
2693 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
2694 )
2695 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
2696 if (strat->Ll<0) break;
2697 else strat->noClearS=TRUE;
2698 }
2699 if (strat->Ll== 0) strat->interpt=TRUE;
2700 /* picks the last element from the lazyset L */
2701 strat->P = strat->L[strat->Ll];
2702 strat->Ll--;
2703
2704 if (pNext(strat->P.p) == strat->tail)
2705 {
2706 // deletes the short spoly
2708 pLmDelete(strat->P.p);
2709 else
2710 pLmFree(strat->P.p);
2711 strat->P.p = NULL;
2712 poly m1 = NULL, m2 = NULL;
2713
2714 // check that spoly creation is ok
2715 while (strat->tailRing != currRing &&
2716 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
2717 {
2718 assume(m1 == NULL && m2 == NULL);
2719 // if not, change to a ring where exponents are at least
2720 // large enough
2721 if (!kStratChangeTailRing(strat))
2722 {
2723 WerrorS("OVERFLOW...");
2724 break;
2725 }
2726 }
2727 // create the real one
2728 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
2729 strat->tailRing, m1, m2, strat->R);
2730 }
2731 else if (strat->P.p1 == NULL)
2732 {
2733 if (strat->minim > 0)
2734 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
2735 // for input polys, prepare reduction
2736 strat->P.PrepareRed(strat->use_buckets);
2737 }
2738
2739 if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
2740 {
2741 red_result = 0;
2742 }
2743 else
2744 {
2745 if (TEST_OPT_PROT)
2746 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
2747 &olddeg,&reduc,strat, red_result);
2748
2749 /* reduction of the element chosen from L */
2750 red_result = strat->red(&strat->P,strat);
2751 if (errorreported) break;
2752 }
2753
2754 if (strat->overflow)
2755 {
2756 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
2757 }
2758
2759 // reduction to non-zero new poly
2760 if (red_result == 1)
2761 {
2762 // get the polynomial (canonicalize bucket, make sure P.p is set)
2763 strat->P.GetP(strat->lmBin);
2764 // in the homogeneous case FDeg >= pFDeg (sugar/honey)
2765 // but now, for entering S, T, we reset it
2766 // in the inhomogeneous case: FDeg == pFDeg
2767 if (strat->homog) strat->initEcart(&(strat->P));
2768
2769 /* statistic */
2770 if (TEST_OPT_PROT) PrintS("s");
2771
2772 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2773
2774 // reduce the tail and normalize poly
2775 // in the ring case we cannot expect LC(f) = 1,
2776 strat->redTailChange=FALSE;
2777
2778 /* if we are computing over Z we always want to try and cut down
2779 * the coefficients in the tail terms */
2781 {
2782 redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
2783 }
2784
2786 {
2787 strat->P.pCleardenom();
2789 {
2790 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
2791 strat->P.pCleardenom();
2792 if (strat->redTailChange) { strat->P.t_p=NULL; }
2793 }
2794 }
2795 else
2796 {
2797 strat->P.pNorm();
2799 {
2800 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
2801 if (strat->redTailChange) { strat->P.t_p=NULL; }
2802 }
2803 }
2804
2805#ifdef KDEBUG
2806 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
2807#endif /* KDEBUG */
2808
2809 // min_std stuff
2810 if ((strat->P.p1==NULL) && (strat->minim>0))
2811 {
2812 if (strat->minim==1)
2813 {
2814 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
2815 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2816 }
2817 else
2818 {
2819 strat->M->m[minimcnt]=strat->P.p2;
2820 strat->P.p2=NULL;
2821 }
2822 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
2823 pNext(strat->M->m[minimcnt])
2824 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
2825 strat->tailRing, currRing,
2826 currRing->PolyBin);
2827 minimcnt++;
2828 }
2829
2830 // enter into S, L, and T
2831 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
2832 {
2833 strat->P.SetShortExpVector();
2834 enterT(strat->P, strat);
2836 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2837 else
2838 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2839 // posInS only depends on the leading term
2840 strat->enterS(strat->P, pos, strat, strat->tl);
2841#if 0
2842 int pl=pLength(strat->P.p);
2843 if (pl==1)
2844 {
2845 //if (TEST_OPT_PROT)
2846 //PrintS("<1>");
2847 }
2848 else if (pl==2)
2849 {
2850 //if (TEST_OPT_PROT)
2851 //PrintS("<2>");
2852 }
2853#endif
2854 }
2855 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
2856// Print("[%d]",hilbeledeg);
2857 kDeleteLcm(&strat->P);
2858 if (strat->s_poly!=NULL)
2859 {
2860 // the only valid entries are: strat->P.p,
2861 // strat->tailRing (read-only, keep it)
2862 // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
2863 if (strat->s_poly(strat))
2864 {
2865 // we are called AFTER enterS, i.e. if we change P
2866 // we have to add it also to S/T
2867 // and add pairs
2868 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
2869 enterT(strat->P, strat);
2871 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2872 else
2873 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
2874 strat->enterS(strat->P, pos, strat, strat->tl);
2875 }
2876 }
2877 }
2878 else if (strat->P.p1 == NULL && strat->minim > 0)
2879 {
2880 p_Delete(&strat->P.p2, currRing, strat->tailRing);
2881 }
2882
2883#ifdef KDEBUG
2884 strat->P.Init();
2885#endif /* KDEBUG */
2886 kTest_TS(strat);
2887 }
2888#ifdef KDEBUG
2889 if (TEST_OPT_DEBUG) messageSets(strat);
2890#endif /* KDEBUG */
2891
2892 if (TEST_OPT_SB_1)
2893 {
2895 {
2896 int k=1;
2897 int j;
2898 while(k<=strat->sl)
2899 {
2900 j=0;
2901 loop
2902 {
2903 if (j>=k) break;
2904 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
2905 j++;
2906 }
2907 k++;
2908 }
2909 }
2910 }
2911 /* complete reduction of the standard basis--------- */
2912 if (TEST_OPT_REDSB)
2913 {
2914 completeReduce(strat);
2915 if (strat->completeReduce_retry)
2916 {
2917 // completeReduce needed larger exponents, retry
2918 // to reduce with S (instead of T)
2919 // and in currRing (instead of strat->tailRing)
2920#ifdef HAVE_TAIL_RING
2921 if(currRing->bitmask>strat->tailRing->bitmask)
2922 {
2924 cleanT(strat);strat->tailRing=currRing;
2925 int i;
2926 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
2927 completeReduce(strat);
2928 }
2929 if (strat->completeReduce_retry)
2930#endif
2931 Werror("exponent bound is %ld",currRing->bitmask);
2932 }
2933 }
2934 else if (TEST_OPT_PROT) PrintLn();
2935 /* release temp data-------------------------------- */
2936 exitBuchMora(strat);
2937 /* postprocessing for GB over ZZ --------------------*/
2938 if (!errorreported)
2939 {
2941 {
2942 for(int i = 0;i<=strat->sl;i++)
2943 {
2944 if(!nGreaterZero(pGetCoeff(strat->S[i])))
2945 {
2946 strat->S[i] = pNeg(strat->S[i]);
2947 }
2948 }
2949 finalReduceByMon(strat);
2950 for(int i = 0;i<IDELEMS(strat->Shdl);i++)
2951 {
2952 if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
2953 {
2954 strat->S[i] = pNeg(strat->Shdl->m[i]);
2955 }
2956 }
2957 }
2958 //else if (rField_is_Ring(currRing))
2959 // finalReduceByMon(strat);
2960 }
2961// if (TEST_OPT_WEIGHTM)
2962// {
2963// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
2964// if (ecartWeights)
2965// {
2966// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
2967// ecartWeights=NULL;
2968// }
2969// }
2972 /* postprocessing for GB over Q-rings ------------------*/
2973 if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
2974
2975 idTest(strat->Shdl);
2976
2977 return (strat->Shdl);
2978}
#define BITSET
Definition auxiliary.h:85
int BOOLEAN
Definition auxiliary.h:88
int k
Definition cfEzgcd.cc:99
int syzComp
Definition kutil.h:354
int * S_2_R
Definition kutil.h:342
ring tailRing
Definition kutil.h:343
int Ll
Definition kutil.h:351
omBin lmBin
Definition kutil.h:344
char honey
Definition kutil.h:375
int minim
Definition kutil.h:357
TObject ** R
Definition kutil.h:340
ideal M
Definition kutil.h:305
int tl
Definition kutil.h:350
poly tail
Definition kutil.h:334
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:284
ideal Shdl
Definition kutil.h:303
pShallowCopyDeleteProc p_shallow_copy_delete
Definition kutil.h:338
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:286
char use_buckets
Definition kutil.h:381
char interpt
Definition kutil.h:369
char redTailChange
Definition kutil.h:397
char completeReduce_retry
Definition kutil.h:401
void(* initEcart)(TObject *L)
Definition kutil.h:280
char noClearS
Definition kutil.h:400
char overflow
Definition kutil.h:402
LSet L
Definition kutil.h:327
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:281
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:278
unsigned long * sevS
Definition kutil.h:322
char homog
Definition kutil.h:370
s_poly_proc_t s_poly
Definition kutil.h:300
const CanonicalForm & w
Definition facAbsFact.cc:51
int j
Definition facHensel.cc:110
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define idTest(id)
Definition ideals.h:47
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition kInline.h:1209
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition kInline.h:1232
void khCheck(ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count, kStrategy strat)
Definition khstd.cc:28
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition kspoly.cc:1203
void initBba(kStrategy strat)
Definition kstd1.cc:1682
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:52
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:11497
VAR int(* test_PosInT)(const TSet T, const int tl, LObject &h)
Definition kstd2.cc:82
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition kutil.cc:7464
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9748
void enterT(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9140
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1070
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4491
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:7141
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
Definition kutil.cc:9414
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9577
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10957
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9833
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4667
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10476
void cleanT(kStrategy strat)
Definition kutil.cc:562
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10076
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4461
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11050
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9432
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10282
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9662
void messageSets(kStrategy strat)
Definition kutil.cc:7537
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7505
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10865
static void kDeleteLcm(LObject *P)
Definition kutil.h:869
#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:902
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:847
#define pNeg(p)
Definition polys.h:198
#define pGetComp(p)
Component.
Definition polys.h:37
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:76
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:70
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310
void Werror(const char *fmt,...)
Definition reporter.cc:189
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:514
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:767
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,
intvec hilb,
kStrategy  strat 
)

Definition at line 4590 of file kstd2.cc.

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

◆ cancelunit()

void cancelunit ( LObject p,
BOOLEAN  inNF = FALSE 
)

Definition at line 370 of file kutil.cc.

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

◆ chainCritNormal()

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

Definition at line 3208 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3449 of file kutil.cc.

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

◆ chainCritSig()

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

Definition at line 3465 of file kutil.cc.

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

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 562 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1232 of file kInline.h.

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

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10282 of file kutil.cc.

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

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

◆ deleteHC() [2/2]

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

Definition at line 356 of file kutil.cc.

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

◆ deleteInL()

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

Definition at line 1212 of file kutil.cc.

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

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

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4236 of file kutil.cc.

4237{
4238 if (nIsOne(pGetCoeff(h))) return;
4239 number gcd;
4240 number zero=n_Init(0,currRing->cf);
4241 bool go = false;
4242 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4243 {
4244 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4245 go = true;
4246 }
4247 else
4248 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4249 if (go || !nIsOne(gcd))
4250 {
4251 poly p = h->next;
4252 if (!go)
4253 {
4254 number tmp = gcd;
4255 gcd = n_Ann(gcd,currRing->cf);
4256 nDelete(&tmp);
4257 }
4258 p_Test(p,strat->tailRing);
4259 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4260
4261 if (p != NULL)
4262 {
4263 if (TEST_OPT_PROT)
4264 {
4265 PrintS("Z");
4266 }
4267#ifdef KDEBUG
4268 if (TEST_OPT_DEBUG)
4269 {
4270 PrintS("--- create zero spoly: ");
4271 p_wrp(h,currRing,strat->tailRing);
4272 PrintS(" ---> ");
4273 }
4274#endif
4275 poly tmp = pInit();
4277 for (int i = 1; i <= rVar(currRing); i++)
4278 {
4279 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4280 }
4282 {
4284 }
4286 p = p_LmFreeAndNext(p, strat->tailRing);
4287 pNext(tmp) = p;
4288 LObject Lp;
4289 Lp.Init();
4290 Lp.p = tmp;
4291 Lp.tailRing = strat->tailRing;
4292 int posx;
4293 if (Lp.p!=NULL)
4294 {
4295 strat->initEcart(&Lp);
4296 if (strat->Ll==-1)
4297 posx =0;
4298 else
4299 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4300 Lp.sev = pGetShortExpVector(Lp.p);
4301 if (strat->tailRing != currRing)
4302 {
4303 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4304 }
4305#ifdef KDEBUG
4306 if (TEST_OPT_DEBUG)
4307 {
4308 p_wrp(tmp,currRing,strat->tailRing);
4309 PrintLn();
4310 }
4311#endif
4312 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4313 }
4314 }
4315 }
4316 nDelete(&zero);
4317 nDelete(&gcd);
4318}
int Lmax
Definition kutil.h:351
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:665
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:680
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:956
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1273
#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:1003
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:248
static void p_Setm(poly p, const ring r)
Definition p_polys.h:234
static poly p_LmFreeAndNext(poly p, ring)
Definition p_polys.h:712
#define p_Test(p, r)
Definition p_polys.h:161
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:61
#define pSetExp(p, i, v)
Definition polys.h:42
int gcd(int a, int b)

◆ enterExtendedSpolySig()

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

Definition at line 4320 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1273 of file kutil.cc.

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

◆ enterOnePairNormal()

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

Definition at line 1943 of file kutil.cc.

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

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

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

◆ enterpairs()

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

Definition at line 4491 of file kutil.cc.

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

◆ enterpairsShift()

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

Definition at line 12945 of file kutil.cc.

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

◆ enterpairsSig()

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

Definition at line 4517 of file kutil.cc.

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

◆ enterSBba()

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

Definition at line 8791 of file kutil.cc.

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

◆ enterSBbaShift()

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

Definition at line 8891 of file kutil.cc.

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

◆ enterSSba()

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

Definition at line 8914 of file kutil.cc.

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

◆ enterSyz()

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

Definition at line 9340 of file kutil.cc.

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

◆ enterT()

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

Definition at line 9140 of file kutil.cc.

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

◆ enterT_strong()

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

Definition at line 9239 of file kutil.cc.

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

◆ enterTShift()

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

Definition at line 12975 of file kutil.cc.

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

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 9833 of file kutil.cc.

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

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10036 of file kutil.cc.

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

◆ f5c()

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

Definition at line 4278 of file kstd2.cc.

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

◆ faugereRewCriterion()

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

Definition at line 6563 of file kutil.cc.

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

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy  strat)

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

Definition at line 10865 of file kutil.cc.

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

499{
500 int j,p;
501
502 if (currRing->pLexOrder
504 || (strat->ak >1)
506 {
507 return;
508 }
510 if (p!=0)
511 strat->NotUsedAxis[p] = FALSE;
512 /*- the leading term of pp is a power of the p-th variable -*/
513 for (j=(currRing->N);j>0; j--)
514 {
515 if (strat->NotUsedAxis[j])
516 {
517 strat->kAllAxis=FALSE;
518 return;
519 }
520 }
521 strat->kAllAxis=TRUE;
522}
BOOLEAN * NotUsedAxis
Definition kutil.h:332
char kAllAxis
Definition kutil.h:374
#define pIsPurePower(p)
Definition polys.h:248
BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:768

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1682 of file kstd1.cc.

1683{
1684 /* setting global variables ------------------- */
1685 strat->enterS = enterSBba;
1686 strat->red = redHoney;
1687 if (strat->honey)
1688 strat->red = redHoney;
1689 else if (currRing->pLexOrder && !strat->homog)
1690 strat->red = redLazy;
1691 else
1692 {
1693 strat->LazyPass *=4;
1694 strat->red = redHomog;
1695 }
1697 {
1698 if (rField_is_Z(currRing))
1699 strat->red = redRing_Z;
1700 else
1701 strat->red = redRing;
1702 }
1703 if (TEST_OPT_IDLIFT
1704 && (!rIsNCRing(currRing))
1705 && (!rField_is_Ring(currRing)))
1706 strat->red=redLiftstd;
1707 if (currRing->pLexOrder && strat->honey)
1708 strat->initEcart = initEcartNormal;
1709 else
1710 strat->initEcart = initEcartBBA;
1711 if (strat->honey)
1713 else
1715// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1716// {
1717// //interred machen Aenderung
1718// strat->pOrigFDeg=pFDeg;
1719// strat->pOrigLDeg=pLDeg;
1720// //h=ggetid("ecart");
1721// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1722// //{
1723// // ecartWeights=iv2array(IDINTVEC(h));
1724// //}
1725// //else
1726// {
1727// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1728// /*uses automatic computation of the ecartWeights to set them*/
1729// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1730// }
1731// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
1732// if (TEST_OPT_PROT)
1733// {
1734// for(i=1; i<=(currRing->N); i++)
1735// Print(" %d",ecartWeights[i]);
1736// PrintLn();
1737// mflush();
1738// }
1739// }
1740}
int LazyPass
Definition kutil.h:353
int redLiftstd(LObject *h, kStrategy strat)
Definition kLiftstd.cc:167
int redRing_Z(LObject *h, kStrategy strat)
Definition kstd2.cc: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:1319
void initEcartNormal(TObject *h)
Definition kutil.cc:1297
void initEcartBBA(TObject *h)
Definition kutil.cc:1305
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition kutil.cc:1312
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:426

◆ initBuchMora()

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

Definition at line 9748 of file kutil.cc.

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

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9432 of file kutil.cc.

9433{
9436 if (TEST_OPT_SB_1)
9439 {
9441 strat->chainCrit=chainCritRing;
9442 }
9443#ifdef HAVE_RATGRING
9444 if (rIsRatGRing(currRing))
9445 {
9446 strat->chainCrit=chainCritPart;
9447 /* enterOnePairNormal get rational part in it */
9448 }
9449#endif
9450 if (TEST_OPT_IDLIFT
9451 && (strat->syzComp==1)
9452 && (!rIsPluralRing(currRing)))
9454
9456 strat->Gebauer = strat->homog || strat->sugarCrit;
9457 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9458 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9459 strat->pairtest = NULL;
9460 /* always use tailreduction, except:
9461 * - in local rings, - in lex order case, -in ring over extensions */
9463 //if(rHasMixedOrdering(currRing)==2)
9464 //{
9465 // strat->noTailReduction =TRUE;
9466 //}
9467
9468#ifdef HAVE_PLURAL
9469 // and r is plural_ring
9470 // hence this holds for r a rational_plural_ring
9471 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9472 { //or it has non-quasi-comm type... later
9473 strat->sugarCrit = FALSE;
9474 strat->Gebauer = FALSE;
9475 strat->honey = FALSE;
9476 }
9477#endif
9478
9479 // Coefficient ring?
9481 {
9482 strat->sugarCrit = FALSE;
9483 strat->Gebauer = FALSE;
9484 strat->honey = FALSE;
9485 }
9486 #ifdef KDEBUG
9487 if (TEST_OPT_DEBUG)
9488 {
9489 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9490 else PrintS("ideal/module is not homogeneous\n");
9491 }
9492 #endif
9493}
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition kutil.h:291
char z2homog
Definition kutil.h:372
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:290
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:1943
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3449
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:1338
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2225
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3524
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3208
void chainCritRing(poly p, int, kStrategy strat)
Definition kutil.cc:4000
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 9577 of file kutil.cc.

9578{
9580 {
9581 if (strat->honey)
9582 {
9583 strat->posInL = posInL15;
9584 // ok -- here is the deal: from my experiments for Singular-2-0
9585 // I conclude that that posInT_EcartpLength is the best of
9586 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9587 // see the table at the end of this file
9588 if (TEST_OPT_OLDSTD)
9589 strat->posInT = posInT15;
9590 else
9591 strat->posInT = posInT_EcartpLength;
9592 }
9593 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9594 {
9595 strat->posInL = posInL11;
9596 strat->posInT = posInT11;
9597 }
9598 else if (TEST_OPT_INTSTRATEGY)
9599 {
9600 strat->posInL = posInL11;
9601 strat->posInT = posInT11;
9602 }
9603 else
9604 {
9605 strat->posInL = posInL0;
9606 strat->posInT = posInT0;
9607 }
9608 //if (strat->minim>0) strat->posInL =posInLSpecial;
9609 if (strat->homog)
9610 {
9611 strat->posInL = posInL110;
9612 strat->posInT = posInT110;
9613 }
9614 }
9615 else /* local/mixed ordering */
9616 {
9617 if (strat->homog)
9618 {
9619 strat->posInL = posInL11;
9620 strat->posInT = posInT11;
9621 }
9622 else
9623 {
9624 if ((currRing->order[0]==ringorder_c)
9625 ||(currRing->order[0]==ringorder_C))
9626 {
9627 strat->posInL = posInL17_c;
9628 strat->posInT = posInT17_c;
9629 }
9630 else
9631 {
9632 strat->posInL = posInL17;
9633 strat->posInT = posInT17;
9634 }
9635 }
9636 }
9637 if (strat->minim>0) strat->posInL =posInLSpecial;
9638 // for further tests only
9639 if ((BTEST1(11)) || (BTEST1(12)))
9640 strat->posInL = posInL11;
9641 else if ((BTEST1(13)) || (BTEST1(14)))
9642 strat->posInL = posInL13;
9643 else if ((BTEST1(15)) || (BTEST1(16)))
9644 strat->posInL = posInL15;
9645 else if ((BTEST1(17)) || (BTEST1(18)))
9646 strat->posInL = posInL17;
9647 if (BTEST1(11))
9648 strat->posInT = posInT11;
9649 else if (BTEST1(13))
9650 strat->posInT = posInT13;
9651 else if (BTEST1(15))
9652 strat->posInT = posInT15;
9653 else if ((BTEST1(17)))
9654 strat->posInT = posInT17;
9655 else if ((BTEST1(19)))
9656 strat->posInT = posInT19;
9657 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9658 strat->posInT = posInT1;
9660}
char posInLDependsOnLength
Definition kutil.h:387
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6059
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5282
int posInT11(const TSet set, const int length, LObject &p)
Definition kutil.cc:4957
int posInT1(const TSet set, const int length, LObject &p)
Definition kutil.cc:4900
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:5150
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4889
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6146
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition kutil.cc:9564
int posInT13(const TSet set, const int length, LObject &p)
Definition kutil.cc:5121
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5615
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6181
int posInT17_c(const TSet set, const int length, LObject &p)
Definition kutil.cc:5388
int posInT15(const TSet set, const int length, LObject &p)
Definition kutil.cc:5188
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5571
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6256
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5033
int posInT19(const TSet set, const int length, LObject &p)
Definition kutil.cc:5514
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6349
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5803
@ ringorder_C
Definition ring.h:73
@ ringorder_c
Definition ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9662 of file kutil.cc.

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

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1305 of file kutil.cc.

1306{
1307 h->FDeg = h->pFDeg();
1308 (*h).ecart = 0;
1309 h->length=h->pLength=pLength(h->p);
1310}

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1297 of file kutil.cc.

1298{
1299 h->FDeg = h->pFDeg();
1300 h->ecart = h->pLDeg() - h->FDeg;
1301 // h->length is set by h->pLDeg
1302 h->length=h->pLength=pLength(h->p);
1303}

◆ initEcartPairBba()

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

Definition at line 1312 of file kutil.cc.

1313{
1314 Lp->FDeg = Lp->pFDeg();
1315 (*Lp).ecart = 0;
1316 (*Lp).length = 0;
1317}

◆ initEcartPairMora()

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

Definition at line 1319 of file kutil.cc.

1320{
1321 Lp->FDeg = Lp->pFDeg();
1322 (*Lp).ecart = si_max(ecartF,ecartG);
1323 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1324 (*Lp).length = 0;
1325}
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:381

◆ initenterpairs()

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

Definition at line 3813 of file kutil.cc.

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

◆ initHilbCrit()

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

Definition at line 9414 of file kutil.cc.

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

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 418 of file kutil.h.

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

◆ initR()

KINLINE TObject ** initR ( )

Definition at line 95 of file kInline.h.

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

◆ initS()

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

Definition at line 7587 of file kutil.cc.

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

◆ initSba()

void initSba ( ideal  F,
kStrategy  strat 
)

Definition at line 1742 of file kstd1.cc.

1743{
1744 int i;
1745 //idhdl h;
1746 /* setting global variables ------------------- */
1747 strat->enterS = enterSSba;
1748 strat->red2 = redHoney;
1749 if (strat->honey)
1750 strat->red2 = redHoney;
1751 else if (currRing->pLexOrder && !strat->homog)
1752 strat->red2 = redLazy;
1753 else
1754 {
1755 strat->LazyPass *=4;
1756 strat->red2 = redHomog;
1757 }
1759 {
1761 {strat->red2 = redRiloc;}
1762 else
1763 {strat->red2 = redRing;}
1764 }
1765 if (currRing->pLexOrder && strat->honey)
1766 strat->initEcart = initEcartNormal;
1767 else
1768 strat->initEcart = initEcartBBA;
1769 if (strat->honey)
1771 else
1773 //strat->kIdeal = NULL;
1774 //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1775 //else strat->kIdeal->rtyp=MODUL_CMD;
1776 //strat->kIdeal->data=(void *)strat->Shdl;
1777 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1778 {
1779 //interred machen Aenderung
1780 strat->pOrigFDeg = currRing->pFDeg;
1781 strat->pOrigLDeg = currRing->pLDeg;
1782 //h=ggetid("ecart");
1783 //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1784 //{
1785 // ecartWeights=iv2array(IDINTVEC(h));
1786 //}
1787 //else
1788 {
1789 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1790 /*uses automatic computation of the ecartWeights to set them*/
1792 }
1794 if (TEST_OPT_PROT)
1795 {
1796 for(i=1; i<=(currRing->N); i++)
1797 Print(" %d",ecartWeights[i]);
1798 PrintLn();
1799 mflush();
1800 }
1801 }
1802 // for sig-safe reductions in signature-based
1803 // standard basis computations
1805 strat->red = redSigRing;
1806 else
1807 strat->red = redSig;
1808 //strat->sbaOrder = 1;
1809 strat->currIdx = 1;
1810}
pFDegProc pOrigFDeg
Definition kutil.h:296
pLDegProc pOrigLDeg
Definition kutil.h:297
int redRiloc(LObject *h, kStrategy strat)
Definition kstd1.cc:386
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:8914
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3689
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 9961 of file kutil.cc.

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

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9495 of file kutil.cc.

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

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 9859 of file kutil.cc.

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

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

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

◆ initSLSba()

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

Definition at line 7780 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 7932 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

◆ k_GetLeadTerms()

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

Definition at line 1015 of file kInline.h.

1017{
1020
1021 int i;
1022 long x;
1023 m1 = p_Init(m_r,m_r->PolyBin);
1024 m2 = p_Init(m_r,m_r->PolyBin);
1025
1026 for (i = p_r->N; i; i--)
1027 {
1028 x = p_GetExpDiff(p1, p2, i, p_r);
1029 if (x > 0)
1030 {
1031 if (x > (long) m_r->bitmask) goto false_return;
1032 p_SetExp(m2,i,x, m_r);
1033 p_SetExp(m1,i,0, m_r);
1034 }
1035 else
1036 {
1037 if (-x > (long) m_r->bitmask) goto false_return;
1038 p_SetExp(m1,i,-x, m_r);
1039 p_SetExp(m2,i,0, m_r);
1040 }
1041 }
1042
1043 p_Setm(m1, m_r);
1044 p_Setm(m2, m_r);
1045 return TRUE;
1046
1048 p_LmFree(m1, m_r);
1049 p_LmFree(m2, m_r);
1050 m1 = m2 = NULL;
1051 return FALSE;
1052}
Variable x
Definition cfModGcd.cc:4090
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition p_polys.h:636
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:489
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1335

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

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

989{
990 return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
991}

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 956 of file kInline.h.

957{
958
959 poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
960 pNext(t_p) = pNext(p);
961 pSetCoeff0(t_p, pGetCoeff(p));
962 return t_p;
963}
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1350

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 993 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 965 of file kInline.h.

966{
967 poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
968 pNext(p) = pNext(t_p);
969 pSetCoeff0(p, pGetCoeff(t_p));
970 return p;
971}

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 998 of file kInline.h.

999{
1000 return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
1001}
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition kInline.h:974

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 974 of file kInline.h.

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

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 1003 of file kInline.h.

1004{
1005 return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
1006}
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition kInline.h:981

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 981 of file kInline.h.

982{
983 poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
984 p_LmFree(p, tailRing);
985 return np;
986}

◆ kCheckSpolyCreation()

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

Definition at line 10476 of file kutil.cc.

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

◆ kCheckStrongCreation()

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

Definition at line 10514 of file kutil.cc.

10515{
10516 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10517 //assume(strat->tailRing != currRing);
10518
10519 poly p1_max = (strat->R[atR])->max_exp;
10520 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10521
10522 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10523 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10524 {
10525 return FALSE;
10526 }
10527 return TRUE;
10528}

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11497 of file kutil.cc.

11498{
11499 printf("red: ");
11500 if (strat->red==redFirst) printf("redFirst\n");
11501 else if (strat->red==redHoney) printf("redHoney\n");
11502 else if (strat->red==redEcart) printf("redEcart\n");
11503 else if (strat->red==redHomog) printf("redHomog\n");
11504 else if (strat->red==redLazy) printf("redLazy\n");
11505 else if (strat->red==redLiftstd) printf("redLiftstd\n");
11506 else printf("%p\n",(void*)strat->red);
11507 printf("posInT: ");
11508 if (strat->posInT==posInT0) printf("posInT0\n");
11509 else if (strat->posInT==posInT1) printf("posInT1\n");
11510 else if (strat->posInT==posInT11) printf("posInT11\n");
11511 else if (strat->posInT==posInT110) printf("posInT110\n");
11512 else if (strat->posInT==posInT13) printf("posInT13\n");
11513 else if (strat->posInT==posInT15) printf("posInT15\n");
11514 else if (strat->posInT==posInT17) printf("posInT17\n");
11515 else if (strat->posInT==posInT17_c) printf("posInT17_c\n");
11516 else if (strat->posInT==posInT19) printf("posInT19\n");
11517 else if (strat->posInT==posInT2) printf("posInT2\n");
11518 else if (strat->posInT==posInT11Ring) printf("posInT11Ring\n");
11519 else if (strat->posInT==posInT110Ring) printf("posInT110Ring\n");
11520 else if (strat->posInT==posInT15Ring) printf("posInT15Ring\n");
11521 else if (strat->posInT==posInT17Ring) printf("posInT17Ring\n");
11522 else if (strat->posInT==posInT17_cRing) printf("posInT17_cRing\n");
11523#ifdef HAVE_MORE_POS_IN_T
11524 else if (strat->posInT==posInT_EcartFDegpLength) printf("posInT_EcartFDegpLength\n");
11525 else if (strat->posInT==posInT_FDegpLength) printf("posInT_FDegpLength\n");
11526 else if (strat->posInT==posInT_pLength) printf("posInT_pLength\n");
11527#endif
11528 else if (strat->posInT==posInT_EcartpLength) printf("posInT_EcartpLength\n");
11529 else printf("%p\n",(void*)strat->posInT);
11530 printf("posInL: ");
11531 if (strat->posInL==posInL0) printf("posInL0\n");
11532 else if (strat->posInL==posInL10) printf("posInL10\n");
11533 else if (strat->posInL==posInL11) printf("posInL11\n");
11534 else if (strat->posInL==posInL110) printf("posInL110\n");
11535 else if (strat->posInL==posInL13) printf("posInL13\n");
11536 else if (strat->posInL==posInL15) printf("posInL15\n");
11537 else if (strat->posInL==posInL17) printf("posInL17\n");
11538 else if (strat->posInL==posInL17_c) printf("posInL17_c\n");
11539 else if (strat->posInL==posInL0) printf("posInL0Ring\n");
11540 else if (strat->posInL==posInL11Ring) printf("posInL11Ring\n");
11541 else if (strat->posInL==posInL11Ringls) printf("posInL11Ringls\n");
11542 else if (strat->posInL==posInL110Ring) printf("posInL110Ring\n");
11543 else if (strat->posInL==posInL15Ring) printf("posInL15Ring\n");
11544 else if (strat->posInL==posInL17Ring) printf("posInL17Ring\n");
11545 else if (strat->posInL==posInL17_cRing) printf("posInL17_cRing\n");
11546 else if (strat->posInL==posInLSpecial) printf("posInLSpecial\n");
11547 else printf("%p\n",(void*)strat->posInL);
11548 printf("enterS: ");
11549 if (strat->enterS==enterSBba) printf("enterSBba\n");
11550 else if (strat->enterS==enterSMora) printf("enterSMora\n");
11551 else if (strat->enterS==enterSMoraNF) printf("enterSMoraNF\n");
11552 else printf("%p\n",(void*)strat->enterS);
11553 printf("initEcart: ");
11554 if (strat->initEcart==initEcartBBA) printf("initEcartBBA\n");
11555 else if (strat->initEcart==initEcartNormal) printf("initEcartNormal\n");
11556 else printf("%p\n",(void*)strat->initEcart);
11557 printf("initEcartPair: ");
11558 if (strat->initEcartPair==initEcartPairBba) printf("initEcartPairBba\n");
11559 else if (strat->initEcartPair==initEcartPairMora) printf("initEcartPairMora\n");
11560 else printf("%p\n",(void*)strat->initEcartPair);
11561 printf("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11562 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11563 printf("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11564 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11565 printf("chainCrit: ");
11566 if (strat->chainCrit==chainCritNormal) printf("chainCritNormal\n");
11567 else if (strat->chainCrit==chainCritOpt_1) printf("chainCritOpt_1\n");
11568 else printf("%p\n",(void*)strat->chainCrit);
11569 printf("posInLDependsOnLength=%d\n",
11570 strat->posInLDependsOnLength);
11571 printf("%s\n",showOption());
11572 printf("LDeg: ");
11573 if (currRing->pLDeg==pLDeg0) printf("pLDeg0");
11574 else if (currRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11575 else if (currRing->pLDeg==pLDegb) printf("pLDegb");
11576 else if (currRing->pLDeg==pLDeg1) printf("pLDeg1");
11577 else if (currRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11578 else if (currRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11579 else if (currRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11580 else if (currRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11581 else if (currRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11582 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11583 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11584 else if (currRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11585 else printf("? (%lx)", (long)currRing->pLDeg);
11586 printf(" / ");
11587 if (strat->tailRing->pLDeg==pLDeg0) printf("pLDeg0");
11588 else if (strat->tailRing->pLDeg==pLDeg0c) printf("pLDeg0c");
11589 else if (strat->tailRing->pLDeg==pLDegb) printf("pLDegb");
11590 else if (strat->tailRing->pLDeg==pLDeg1) printf("pLDeg1");
11591 else if (strat->tailRing->pLDeg==pLDeg1c) printf("pLDeg1c");
11592 else if (strat->tailRing->pLDeg==pLDeg1_Deg) printf("pLDeg1_Deg");
11593 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) printf("pLDeg1c_Deg");
11594 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) printf("pLDeg1_Totaldegree");
11595 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) printf("pLDeg1c_Totaldegree");
11596 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) printf("pLDeg1_WFirstTotalDegree");
11597 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) printf("pLDeg1c_WFirstTotalDegree");
11598 else if (strat->tailRing->pLDeg==maxdegreeWecart) printf("maxdegreeWecart");
11599 else printf("? (%lx)", (long)strat->tailRing->pLDeg);
11600 printf("\n");
11601 printf("currRing->pFDeg: ");
11602 if (currRing->pFDeg==p_Totaldegree) printf("p_Totaldegree");
11603 else if (currRing->pFDeg==p_WFirstTotalDegree) printf("pWFirstTotalDegree");
11604 else if (currRing->pFDeg==p_Deg) printf("p_Deg");
11605 else if (currRing->pFDeg==kHomModDeg) printf("kHomModDeg");
11606 else if (currRing->pFDeg==totaldegreeWecart) printf("totaldegreeWecart");
11607 else if (currRing->pFDeg==p_WTotaldegree) printf("p_WTotaldegree");
11608 else printf("? (%lx)", (long)currRing->pFDeg);
11609 printf("\n");
11610 printf(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11612 printf(" degBound: %d\n", Kstd1_deg);
11613
11614 if( ecartWeights != NULL )
11615 {
11616 printf("ecartWeights: ");
11617 for (int i = rVar(currRing); i > 0; i--)
11618 printf("%hd ", ecartWeights[i]);
11619 printf("\n");
11621 }
11622
11623#ifndef SING_NDEBUG
11625#endif
11626}
int LazyDegree
Definition kutil.h:353
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2418
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1361
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:795
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:169
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition kstd1.cc:1674
int posInT2(const TSet set, const int length, LObject &p)
Definition kutil.cc:4929
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11463
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11372
VAR int Kstd1_deg
Definition kutil.cc:245
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition kstd1.cc:1621
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:11426
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:1522
void rDebugPrint(const ring r)
Definition ring.cc:4169
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:728

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 869 of file kutil.h.

870{
871 if (P->lcm!=NULL)
872 {
874 pLmDelete(P->lcm);
875 else
876 pLmFree(P->lcm);
877 P->lcm=NULL;
878 }
879}

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6698 of file kutil.cc.

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

841{
842 for(int i=strat->Ll;i>=0;i--)
843 {
844 if (p==strat->L[i].p1) return i;
845 }
846 return -1;
847}

◆ kFindInT()

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

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

Definition at line 715 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 740 of file kutil.cc.

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

◆ 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:448
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:1119
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1052
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:756
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 4103 of file kstd2.cc.

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

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

◆ kNF2Bound() [1/2]

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

Definition at line 4189 of file kstd2.cc.

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

◆ kNF2Bound() [2/2]

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

Definition at line 4028 of file kstd2.cc.

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

◆ 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:724
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:492
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 1191 of file kInline.h.

1192{
1193 LObject L(r);
1194 L.p1 = p1;
1195 L.p2 = p2;
1196
1198 return L.GetLmCurrRing();
1199}

◆ ksOldSpolyRed()

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

Definition at line 1171 of file kInline.h.

1172{
1173 LObject L(p2);
1174 TObject T(p1);
1175
1176 ksReducePoly(&L, &T, spNoether);
1177
1178 return L.GetLmCurrRing();
1179}
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 1181 of file kInline.h.

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

◆ ksOldSpolyTail()

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

Definition at line 1201 of file kInline.h.

1202{
1203 LObject L(q, currRing, r);
1204 TObject T(p1, currRing, r);
1205
1207}
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition kInline.h:1144

◆ 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:476
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:558
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:592
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472
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:1455
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1915
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:293
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:1471

◆ 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:363
#define nDiv(a, b)
Definition numbers.h:32
#define pSub(a, b)
Definition polys.h:287

◆ ksReducePolyTail() [1/2]

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

Definition at line 1144 of file kInline.h.

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

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

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

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11050 of file kutil.cc.

11051{
11052 unsigned long l = 0;
11053 int i;
11054 long e;
11055
11056 assume(strat->tailRing == currRing);
11057
11058 for (i=0; i<= strat->Ll; i++)
11059 {
11060 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11061 }
11062 for (i=0; i<=strat->tl; i++)
11063 {
11064 // Hmm ... this we could do in one Step
11065 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11066 }
11068 {
11069 l *= 2;
11070 }
11071 e = p_GetMaxExp(l, currRing);
11072 if (e <= 1) e = 2;
11073 if (rIsLPRing(currRing)) e = 1;
11074
11075 kStratChangeTailRing(strat, NULL, NULL, e);
11076}
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:782

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1009 of file kutil.cc.

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

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

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

◆ kTest_T()

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

Definition at line 798 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1070 of file kutil.cc.

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

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

◆ message()

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

Definition at line 7464 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7537 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7505 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7518 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10404 of file kutil.cc.

10405{
10406 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10407 return FALSE;
10408 int i,j;
10409 poly newNoether;
10410
10411#if 0
10412 if (currRing->weight_all_1)
10413 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10414 else
10415 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kNoether);
10416#else
10417 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kNoether);
10418#endif
10419 if (strat->kNoether==NULL) return FALSE;
10420 if (strat->t_kNoether != NULL)
10421 {
10422 p_LmFree(strat->t_kNoether, strat->tailRing);
10423 strat->t_kNoether=NULL;
10424 }
10425 if (strat->tailRing != currRing)
10427 /* compare old and new noether*/
10428 newNoether = pLmInit(strat->kNoether);
10431 for (i=1; i<=(currRing->N); i++)
10432 {
10434 }
10436 if (j < HCord) /*- statistics -*/
10437 {
10438 if (TEST_OPT_PROT)
10439 {
10440 Print("H(%d)",j);
10441 mflush();
10442 }
10443 HCord=j;
10444 #ifdef KDEBUG
10445 if (TEST_OPT_DEBUG)
10446 {
10447 Print("H(%d):",j);
10448 wrp(strat->kNoether);
10449 PrintLn();
10450 }
10451 #endif
10452 }
10453 if (pCmp(strat->kNoether,newNoether)!=1)
10454 {
10455 if (strat->kNoether!=NULL) p_LmDelete0(strat->kNoether,currRing);
10456 strat->kNoether=newNoether;
10457 if (strat->t_kNoether != NULL)
10458 {
10459 p_LmFree(strat->t_kNoether, strat->tailRing);
10460 strat->t_kNoether=NULL;
10461 }
10462 if (strat->tailRing != currRing)
10464
10465 return TRUE;
10466 }
10468 return FALSE;
10469}
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge)
Definition hdegree.cc:1074
VAR int HCord
Definition kutil.cc:244
static void p_LmDelete0(poly p, const ring r)
Definition p_polys.h:734
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition polys.h:115
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:64
#define pGetExp(p, i)
Exponent.
Definition polys.h:41
#define pDecrExp(p, i)
Definition polys.h:44

◆ pairs()

void pairs ( )

◆ posInIdealMonFirst()

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

Definition at line 4845 of file kutil.cc.

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

◆ posInL0()

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

Definition at line 5615 of file kutil.cc.

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

◆ posInL10()

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

Definition at line 1361 of file kstd1.cc.

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

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

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

◆ posInL110()

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

Definition at line 6059 of file kutil.cc.

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

◆ posInL11Ring()

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

Definition at line 5845 of file kutil.cc.

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

◆ posInL11Ringls()

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

Definition at line 5913 of file kutil.cc.

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

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

◆ posInL15()

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

Definition at line 6181 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6216 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6256 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 5791 of file kutil.cc.

5793{
5794 return strat->Ll+1;
5795}

◆ posInLF5CRing()

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

Definition at line 5879 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5673 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5698 of file kutil.cc.

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

◆ posInS()

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

Definition at line 4667 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4768 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 5762 of file kutil.cc.

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

◆ posInT0()

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

Definition at line 4889 of file kutil.cc.

4890{
4891 return (length+1);
4892}

◆ posInT1()

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

Definition at line 4900 of file kutil.cc.

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

◆ posInT11()

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

Definition at line 4957 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5033 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5121 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5188 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5282 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5388 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5514 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4929 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11372 of file kutil.cc.

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

◆ posInT_EcartpLength()

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

Definition at line 5150 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11426 of file kutil.cc.

11427{
11428
11429 if (length==-1) return 0;
11430
11431 int op=p.GetpFDeg();
11432 int ol = p.GetpLength();
11433
11434 int oo=set[length].GetpFDeg();
11435 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11436 return length+1;
11437
11438 int i;
11439 int an = 0;
11440 int en= length;
11441 loop
11442 {
11443 if (an >= en-1)
11444 {
11445 int oo=set[an].GetpFDeg();
11446 if((oo > op)
11447 || ((oo==op) && (set[an].pLength > ol)))
11448 return an;
11449 return en;
11450 }
11451 i=(an+en) / 2;
11452 int oo=set[i].GetpFDeg();
11453 if ((oo > op)
11454 || ((oo == op) && (set[i].pLength > ol)))
11455 en=i;
11456 else
11457 an=i;
11458 }
11459}

◆ posInT_pLength()

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

Definition at line 11463 of file kutil.cc.

11464{
11465 int ol = p.GetpLength();
11466 if (length==-1)
11467 return 0;
11468 if (set[length].length<p.length)
11469 return length+1;
11470
11471 int i;
11472 int an = 0;
11473 int en= length;
11474
11475 loop
11476 {
11477 if (an >= en-1)
11478 {
11479 if (set[an].pLength>ol) return an;
11480 return en;
11481 }
11482 i=(an+en) / 2;
11483 if (set[i].pLength>ol) en=i;
11484 else an=i;
11485 }
11486}

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

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

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 10776 of file kutil.cc.

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

◆ preIntegerCheck()

poly preIntegerCheck ( ideal  F,
ideal  Q 
)

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

Definition at line 10535 of file kutil.cc.

10536{
10537 if(!nCoeff_is_Z(currRing->cf))
10538 return NULL;
10539 ideal F = idCopy(Forig);
10540 idSkipZeroes(F);
10541 poly pmon;
10543 ideal monred = idInit(1,1);
10544 for(int i=0; i<idElem(F); i++)
10545 {
10546 if(pNext(F->m[i]) == NULL)
10547 idInsertPoly(monred, pCopy(F->m[i]));
10548 }
10549 int posconst = idPosConstant(F);
10550 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10551 {
10552 idDelete(&F);
10553 idDelete(&monred);
10554 return NULL;
10555 }
10556 int idelemQ = 0;
10557 if(Q!=NULL)
10558 {
10559 idelemQ = IDELEMS(Q);
10560 for(int i=0; i<idelemQ; i++)
10561 {
10562 if(pNext(Q->m[i]) == NULL)
10563 idInsertPoly(monred, pCopy(Q->m[i]));
10564 }
10567 //the constant, if found, will be from Q
10568 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10569 {
10570 pmon = pCopy(monred->m[posconst]);
10571 idDelete(&F);
10572 idDelete(&monred);
10573 return pmon;
10574 }
10575 }
10577 nKillChar(QQ_ring->cf);
10578 QQ_ring->cf = nInitChar(n_Q, NULL);
10579 rComplete(QQ_ring,1);
10582 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10584 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10585 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10586 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10587 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10588 ideal one = kStd(II, NULL, isNotHomog, NULL);
10589 idSkipZeroes(one);
10590 if(idIsConstant(one))
10591 {
10592 //one should be <1>
10593 for(int i = IDELEMS(II)-1; i>=0; i--)
10594 if(II->m[i] != NULL)
10595 II->m[i+1] = II->m[i];
10596 II->m[0] = pOne();
10598 poly integer = NULL;
10599 for(int i = IDELEMS(syz)-1;i>=0; i--)
10600 {
10601 if(pGetComp(syz->m[i]) == 1)
10602 {
10603 pSetComp(syz->m[i],0);
10604 if(pIsConstant(pHead(syz->m[i])))
10605 {
10606 integer = pHead(syz->m[i]);
10607 break;
10608 }
10609 }
10610 }
10612 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10614 idDelete(&monred);
10615 idDelete(&F);
10617 id_Delete(&one,QQ_ring);
10618 id_Delete(&syz,QQ_ring);
10621 return pmon;
10622 }
10623 else
10624 {
10625 if(idIs0(monred))
10626 {
10627 poly mindegmon = NULL;
10628 for(int i = 0; i<IDELEMS(one); i++)
10629 {
10630 if(pNext(one->m[i]) == NULL)
10631 {
10632 if(mindegmon == NULL)
10633 mindegmon = pCopy(one->m[i]);
10634 else
10635 {
10636 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10637 mindegmon = pCopy(one->m[i]);
10638 }
10639 }
10640 }
10641 if(mindegmon != NULL)
10642 {
10643 for(int i = IDELEMS(II)-1; i>=0; i--)
10644 if(II->m[i] != NULL)
10645 II->m[i+1] = II->m[i];
10646 II->m[0] = pCopy(mindegmon);
10648 bool found = FALSE;
10649 for(int i = IDELEMS(syz)-1;i>=0; i--)
10650 {
10651 if(pGetComp(syz->m[i]) == 1)
10652 {
10653 pSetComp(syz->m[i],0);
10654 if(pIsConstant(pHead(syz->m[i])))
10655 {
10656 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10657 found = TRUE;
10658 break;
10659 }
10660 }
10661 }
10662 id_Delete(&syz,QQ_ring);
10663 if (found == FALSE)
10664 {
10666 idDelete(&monred);
10667 idDelete(&F);
10669 id_Delete(&one,QQ_ring);
10671 return NULL;
10672 }
10674 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10676 idDelete(&monred);
10677 idDelete(&F);
10679 id_Delete(&one,QQ_ring);
10680 id_Delete(&syz,QQ_ring);
10682 return pmon;
10683 }
10684 }
10685 }
10687 idDelete(&monred);
10688 idDelete(&F);
10690 id_Delete(&one,QQ_ring);
10692 return NULL;
10693}
@ 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:701
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406
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:556
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:830
#define idIsConstant(I)
Definition ideals.h:40
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
ideal idCopy(ideal A)
Definition ideals.h:60
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition ideals.h:37
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition kstd1.cc:2674
void rChangeCurrRing(ring r)
Definition polys.cc:15
poly prMapR(poly src, nMapFunc nMap, ring src_r, ring dest_r)
Definition prCopy.cc:45
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3481
ring rAssure_c_dp(const ring r)
Definition ring.cc:5089
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1424
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:452
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

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4970 of file kstd2.cc.

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

◆ 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}
#define UNLIKELY(X)
Definition auxiliary.h:405
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 RED_CANONICALIZE
Definition kutil.h:36
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:119

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

2316{
2317 if (h==NULL) return NULL;
2318 int j,j_ring;
2319 int cnt=REDNF_CANONICALIZE;
2320 max_ind=strat->sl;
2321
2322 if (0 > strat->sl)
2323 {
2324 return h;
2325 }
2326 LObject P(h);
2327 P.SetShortExpVector();
2328 P.t_p=NULL;
2330 if(is_ring) nonorm=TRUE;
2331#ifdef KDEBUG
2332// if (TEST_OPT_DEBUG)
2333// {
2334// PrintS("redNF: starting S:\n");
2335// for( j = 0; j <= max_ind; j++ )
2336// {
2337// Print("S[%d] (of size: %d): ", j, pSize(strat->S[j]));
2338// pWrite(strat->S[j]);
2339// }
2340// };
2341#endif
2342 if (rField_is_Z(currRing))
2343 {
2344 redRing_Z_S(&P,strat);
2345 if (P.bucket!=NULL)
2346 {
2347 P.p=kBucketClear(P.bucket);
2348 kBucketDestroy(&P.bucket);
2349 }
2350 return P.p;
2351 }
2352 else if (rField_is_Ring(currRing))
2353 {
2354 redRing_S(&P,strat);
2355 if (P.bucket!=NULL)
2356 {
2357 P.p=kBucketClear(P.bucket);
2358 kBucketDestroy(&P.bucket);
2359 }
2360 return P.p;
2361 }
2362
2363 P.bucket = kBucketCreate(currRing);
2364 kBucketInit(P.bucket,P.p,pLength(P.p));
2365 kbTest(P.bucket);
2366 P.p=kBucketGetLm(P.bucket);
2367 loop
2368 {
2370 while ((j>=0)
2371 && (nonorm)
2372 && (!n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[j]),currRing->cf)))
2373 j=kFindNextDivisibleByInS(strat,j+1,max_ind,&P);
2374 if (j>=0)
2375 {
2376 int sl=pSize(strat->S[j]);
2377 int jj=j;
2378 loop
2379 {
2380 int sll;
2382 if (jj<0) break;
2383 if ((!nonorm)
2384 || (n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[jj]),currRing->cf)))
2385 {
2386 sll=pSize(strat->S[jj]);
2387 if (sll<sl)
2388 {
2389 #ifdef KDEBUG
2390 if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
2391 #endif
2392 //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
2393 j=jj;
2394 sl=sll;
2395 }
2396 }
2397 }
2398 if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
2399 {
2400 pNorm(strat->S[j]);
2401 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
2402 }
2403 nNormalize(pGetCoeff(P.p));
2404#ifdef KDEBUG
2405 if (TEST_OPT_DEBUG)
2406 {
2407 PrintS("red:");
2408 wrp(P.p);
2409 PrintS(" with ");
2410 wrp(strat->S[j]);
2411 }
2412#endif
2413#ifdef HAVE_PLURAL
2415 {
2416 number coef;
2417 nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
2418 nDelete(&coef);
2419 }
2420 else
2421#endif
2422 {
2423 kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),
2424 strat->kNoether);
2425 }
2426 cnt--;
2427 if (cnt==0)
2428 {
2429 kBucketCanonicalize(P.bucket);
2431 }
2432 P.p=kBucketGetLm(P.bucket);
2433 //P.t_p=NULL;
2434#ifdef KDEBUG
2435 if (TEST_OPT_DEBUG)
2436 {
2437 PrintS("\nto:");
2438 wrp(P.p);
2439 PrintLn();
2440 }
2441#endif
2442 if (P.p==NULL)
2443 {
2444 kBucketDestroy(&P.bucket);
2445 return NULL;
2446 }
2447 kbTest(P.bucket);
2448 P.SetShortExpVector();
2449 }
2450 else if (is_ring && (j_ring>=0) && (currRing->cf->cfQuotRem!=ndQuotRem))
2451 {
2452 number r;
2453 number n=n_QuotRem(pGetCoeff(P.p),pGetCoeff(strat->S[j_ring]),&r,currRing->cf);
2454 if(!n_IsZero(n,currRing->cf))
2455 {
2456 poly lm=kBucketGetLm(P.bucket);
2457 poly m=p_Head(lm,currRing);
2458 p_ExpVectorSub(m,strat->S[j_ring],currRing);
2459 if (p_GetComp(strat->S[j_ring], currRing) != p_GetComp(lm, currRing))
2460 {
2462 }
2464 p_Setm(m,currRing);
2465#ifdef KDEBUG
2466 if (TEST_OPT_DEBUG)
2467 {
2468 PrintS("redi (coeff):");
2469 wrp(P.p);
2470 PrintS(" with ");
2471 wrp(strat->S[j]);
2472 }
2473#endif
2474 int l=-1;
2475 kBucket_Minus_m_Mult_p(P.bucket,m,strat->S[j_ring],&l);
2476 P.p=kBucketGetLm(P.bucket);
2478#ifdef KDEBUG
2479 if (TEST_OPT_DEBUG)
2480 {
2481 PrintS("\nto:");
2482 wrp(P.p);
2483 PrintLn();
2484 }
2485#endif
2486 }
2487 else
2488 {
2489 n_Delete(&n,currRing->cf);
2490 }
2491 n_Delete(&r,currRing->cf);
2492 P.p=kBucketClear(P.bucket);
2493 kBucketDestroy(&P.bucket);
2494 pNormalize(P.p);
2495 return P.p;
2496 }
2497 else
2498 {
2499 P.p=kBucketClear(P.bucket);
2500 kBucketDestroy(&P.bucket);
2501 pNormalize(P.p);
2502 return P.p;
2503 }
2504 }
2505}
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:37
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:861
#define pNormalize(p)
Definition polys.h:317
#define pSize(p)
Definition polys.h:318

◆ redNF0()

int redNF0 ( LObject P,
kStrategy  strat 
)

◆ redNFTail()

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

◆ redRiloc()

int redRiloc ( LObject h,
kStrategy  strat 
)

Definition at line 386 of file kstd1.cc.

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

◆ 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:9049
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:10776
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
Definition kutil.cc:1692

◆ redtail() [1/2]

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

Definition at line 6837 of file kutil.cc.

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

◆ redtail() [2/2]

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

Definition at line 6907 of file kutil.cc.

6908{
6909 LObject L(p, currRing);
6910 return redtail(&L, end_pos, strat);
6911}

◆ redtailBba() [1/3]

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

Definition at line 6913 of file kutil.cc.

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

◆ redtailBba() [2/3]

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

Definition at line 1209 of file kInline.h.

1210{
1211 LObject L(p);
1212 return redtailBba(&L, pos, strat,FALSE, normalize);
1213}

◆ redtailBba() [3/3]

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

◆ redtailBba_NF()

poly redtailBba_NF ( poly  p,
kStrategy  strat 
)

Definition at line 7351 of file kutil.cc.

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7376 of file kutil.cc.

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

◆ redtailBba_Ring() [2/2]

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

Definition at line 1221 of file kInline.h.

1222{
1223 LObject L(p, currRing, strat->tailRing);
1224 return redtailBba_Ring(&L, pos, strat);
1225}

◆ redtailBba_Z() [1/2]

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

Definition at line 7270 of file kutil.cc.

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

◆ redtailBba_Z() [2/2]

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

Definition at line 1226 of file kInline.h.

1227{
1228 LObject L(p, currRing, strat->tailRing);
1229 return redtailBba_Z(&L, pos, strat);
1230}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7141 of file kutil.cc.

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

◆ redtailBbaBound() [1/2]

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

Definition at line 7026 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

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

Definition at line 1215 of file kInline.h.

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

◆ redtailBbaShift()

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

Definition at line 12998 of file kutil.cc.

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

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

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

◆ replaceInLAndSAndT()

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

Definition at line 9049 of file kutil.cc.

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

◆ sba()

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

Definition at line 2980 of file kstd2.cc.

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

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

◆ sbaRing()

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

Definition at line 11078 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4461 of file kutil.cc.

4462{
4464#if HAVE_SHIFTBBA
4465 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4466#endif
4467 // enter also zero divisor * poly, if this is non zero and of smaller degree
4469 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4470 initenterpairs(h, k, ecart, 0, strat, atR);
4471 clearSbatch(h, k, pos, strat);
4472}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition kutil.cc:4437
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4156
void enterExtendedSpoly(poly h, kStrategy strat)
Definition kutil.cc:4236

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

4475{
4477 // enter also zero divisor * poly, if this is non zero and of smaller degree
4479 if(strat->sigdrop) return;
4480 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4481 if(strat->sigdrop) return;
4482 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4483 if(strat->sigdrop) return;
4484 clearSbatch(h, k, pos, strat);
4485}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:3938
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4211
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition kutil.cc:4320

◆ syzCriterion()

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

Definition at line 6479 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6514 of file kutil.cc.

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

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

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8556 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

EXTERN_VAR denominator_list DENOMINATOR_LIST

Definition at line 66 of file kutil.h.

◆ HCord

EXTERN_VAR int HCord

Definition at line 269 of file kutil.h.

◆ strat_nr

EXTERN_VAR int strat_nr

Definition at line 181 of file kutil.h.

◆ test_PosInL

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

Definition at line 866 of file kutil.h.

◆ test_PosInT

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

Definition at line 865 of file kutil.h.