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

Go to the source code of this file.

Data Structures

struct  denominator_list_s
 
class  sTObject
 
class  sLObject
 
class  skStrategy
 

Macros

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

Typedefs

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

Functions

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

Variables

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

Data Structure Documentation

◆ denominator_list_s

struct denominator_list_s

Definition at line 65 of file kutil.h.

Data Fields
number n
denominator_list next

Macro Definition Documentation

◆ ALLOW_PROD_CRIT

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

Definition at line 399 of file kutil.h.

◆ HAVE_TAIL_RING

#define HAVE_TAIL_RING

Definition at line 27 of file kutil.h.

◆ KINLINE

#define KINLINE

Definition at line 49 of file kutil.h.

◆ NO_KINLINE

#define NO_KINLINE   1

Definition at line 50 of file kutil.h.

◆ RED_CANONICALIZE

#define RED_CANONICALIZE   200

Definition at line 36 of file kutil.h.

◆ REDNF_CANONICALIZE

#define REDNF_CANONICALIZE   60

Definition at line 37 of file kutil.h.

◆ REDTAIL_CANONICALIZE

#define REDTAIL_CANONICALIZE   100

Definition at line 38 of file kutil.h.

◆ setmax

#define setmax   128

Definition at line 29 of file kutil.h.

◆ setmaxL

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

Definition at line 30 of file kutil.h.

◆ setmaxLinc

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

Definition at line 31 of file kutil.h.

◆ setmaxT

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

Definition at line 33 of file kutil.h.

◆ setmaxTinc

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

Definition at line 34 of file kutil.h.

Typedef Documentation

◆ denominator_list

Definition at line 63 of file kutil.h.

◆ intset

typedef int* intset

Definition at line 53 of file kutil.h.

◆ LObject

typedef class sLObject LObject

Definition at line 58 of file kutil.h.

◆ LSet

typedef LObject* LSet

Definition at line 60 of file kutil.h.

◆ TObject

typedef class sTObject TObject

Definition at line 57 of file kutil.h.

◆ TSet

typedef TObject* TSet

Definition at line 59 of file kutil.h.

◆ wlen_set

typedef wlen_type* wlen_set

Definition at line 55 of file kutil.h.

◆ wlen_type

typedef int64 wlen_type

Definition at line 54 of file kutil.h.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6851 of file kutil.cc.

6852{
6854 return FALSE;
6855 poly p1 = pOne();
6856 poly p2 = pOne();
6857 for (int ii=strat->sl; ii>start; ii--)
6858 {
6859 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6860 {
6861 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6862 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6863 if (!(pLmCmp(p1,p2) == 1))
6864 {
6865 pDelete(&p1);
6866 pDelete(&p2);
6867 return TRUE;
6868 }
6869 }
6870 }
6871 pDelete(&p1);
6872 pDelete(&p2);
6873 return FALSE;
6874}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
polyset S
Definition: kutil.h:307
unsigned long * sevSig
Definition: kutil.h:325
polyset sig
Definition: kutil.h:309
LObject P
Definition: kutil.h:303
int sl
Definition: kutil.h:351
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1385
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1897
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
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:486

◆ arriRewCriterionPre()

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

Definition at line 6876 of file kutil.cc.

6877{
6878 //Over Rings, there are still some changes to do: considering coeffs
6880 return FALSE;
6881 int found = -1;
6882 for (int i=strat->Bl; i>-1; i--)
6883 {
6884 if (pLmEqual(strat->B[i].sig,sig))
6885 {
6886 found = i;
6887 break;
6888 }
6889 }
6890 if (found != -1)
6891 {
6892 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6893 {
6894 deleteInL(strat->B,&strat->Bl,found,strat);
6895 }
6896 else
6897 {
6898 return TRUE;
6899 }
6900 }
6901 poly p1 = pOne();
6902 poly p2 = pOne();
6903 for (int ii=strat->sl; ii>-1; ii--)
6904 {
6905 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6906 {
6907 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6908 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6909 if (!(pLmCmp(p1,p2) == 1))
6910 {
6911 pDelete(&p1);
6912 pDelete(&p2);
6913 return TRUE;
6914 }
6915 }
6916 }
6917 pDelete(&p1);
6918 pDelete(&p2);
6919 return FALSE;
6920}
int i
Definition: cfEzgcd.cc:132
int Bl
Definition: kutil.h:355
LSet B
Definition: kutil.h:329
bool found
Definition: facFactorize.cc:55
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1244
#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 1230 of file kInline.h.

1231{
1232 return FALSE;
1233}

◆ bba()

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

Definition at line 2374 of file kstd2.cc.

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

◆ bbaShift()

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

Definition at line 4345 of file kstd2.cc.

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

344{
345 if(rHasGlobalOrdering (currRing)) return;
346 if(TEST_OPT_CANCELUNIT) return;
347
348 ring r = L->tailRing;
349 poly p = L->GetLmTailRing();
350 if(p_GetComp(p, r) != 0 && !p_OneComp(p, r)) return;
351
352 number lc=NULL; /*dummy, is always set if rField_is_Ring(r) */
353 if (rField_is_Ring(r) /*&& (rHasLocalOrMixedOrdering(r))*/)
354 lc = pGetCoeff(p);
355
356 // Leading coef have to be a unit
357 // example 2x+4x2 should be simplified to 2x*(1+2x)
358 // and 2 is not a unit in Z
359 //if ( !(n_IsUnit(pGetCoeff(p), r->cf)) ) return;
360
361// for(i=r->N;i>0;i--)
362// {
363// if ((p_GetExp(p,i,r)>0) && (rIsPolyVar(i, r)==TRUE)) return;
364// }
365 poly h = pNext(p);
366 int i;
367
369 {
370 loop
371 {
372 if (h==NULL)
373 {
374 p_Delete(&pNext(p), r);
375 if (!inNF)
376 {
377 number eins= nCopy(lc);
378 if (L->p != NULL)
379 {
380 pSetCoeff(L->p,eins);
381 if (L->t_p != NULL)
382 pSetCoeff0(L->t_p,eins);
383 }
384 else
385 pSetCoeff(L->t_p,eins);
386 /* p and t_p share the same coeff, if both are !=NULL */
387 /* p==NULL==t_p cannot happen here */
388 }
389 L->ecart = 0;
390 L->length = 1;
391 //if (L->pLength > 0)
392 L->pLength = 1;
393 L->max_exp = NULL;
394
395 if (L->t_p != NULL && pNext(L->t_p) != NULL)
396 p_Delete(&pNext(L->t_p),r);
397 if (L->p != NULL && pNext(L->p) != NULL)
398 pNext(L->p) = NULL;
399 return;
400 }
401 i = rVar(r);
402 loop
403 {
404 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
405 i--;
406 if (i == 0) break; // does divide, try next monom
407 }
408 //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
409 // Note: As long as qring j forbidden if j contains integer (i.e. ground rings are
410 // domains), no zerodivisor test needed CAUTION
411 if (!n_DivBy(pGetCoeff(h),lc,r->cf))
412 {
413 return;
414 }
415 pIter(h);
416 }
417 }
418 else
419 {
420 loop
421 {
422 if (h==NULL)
423 {
424 p_Delete(&pNext(p), r);
425 if (!inNF)
426 {
427 number eins=nInit(1);
428 if (L->p != NULL)
429 {
430 pSetCoeff(L->p,eins);
431 if (L->t_p != NULL)
432 pSetCoeff0(L->t_p,eins);
433 }
434 else
435 pSetCoeff(L->t_p,eins);
436 /* p and t_p share the same coeff, if both are !=NULL */
437 /* p==NULL==t_p cannot happen here */
438 }
439 L->ecart = 0;
440 L->length = 1;
441 //if (L->pLength > 0)
442 L->pLength = 1;
443 L->max_exp = NULL;
444
445 if (L->t_p != NULL && pNext(L->t_p) != NULL)
446 p_Delete(&pNext(L->t_p),r);
447 if (L->p != NULL && pNext(L->p) != NULL)
448 pNext(L->p) = NULL;
449
450 return;
451 }
452 i = rVar(r);
453 loop
454 {
455 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide
456 i--;
457 if (i == 0) break; // does divide, try next monom
458 }
459 //wrp(p); PrintS(" divide ");wrp(h); PrintLn();
460 pIter(h);
461 }
462 }
463}
CanonicalForm lc(const CanonicalForm &f)
int p
Definition: cfModGcd.cc:4080
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:777
STATIC_VAR Poly * h
Definition: janet.cc:971
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define nCopy(n)
Definition: numbers.h:15
#define nInit(i)
Definition: numbers.h:24
#define TEST_OPT_CANCELUNIT
Definition: options.h:128
BOOLEAN p_OneComp(poly p, const ring r)
return TRUE if all monoms have the same component
Definition: p_polys.cc:1203
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:594
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:761

◆ chainCritNormal()

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

Definition at line 3240 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3476 of file kutil.cc.

3477{
3478 if (strat->pairtest!=NULL)
3479 {
3480 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3481 strat->pairtest=NULL;
3482 }
3483 /*
3484 *the elements of B enter L
3485 */
3486 kMergeBintoL(strat);
3487}

◆ chainCritSig()

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

Definition at line 3492 of file kutil.cc.

3493{
3494 int i,j,l;
3495 kMergeBintoLSba(strat);
3496 j = strat->Ll;
3497 loop /*cannot be changed into a for !!! */
3498 {
3499 if (j <= 0)
3500 {
3501 /*now L[0] cannot be canceled any more and the tail can be removed*/
3502 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3503 break;
3504 }
3505 if (strat->L[j].p2 == p)
3506 {
3507 i = j-1;
3508 loop
3509 {
3510 if (i < 0) break;
3511 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3512 {
3513 /*L[i] could be canceled but we search for a better one to cancel*/
3514 strat->c3++;
3515 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3516 && (pNext(strat->L[l].p) == strat->tail)
3517 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3518 && pDivisibleBy(p,strat->L[l].lcm))
3519 {
3520 /*
3521 *"NOT equal(...)" because in case of "equal" the element L[l]
3522 *is "older" and has to be from theoretical point of view behind
3523 *L[i], but we do not want to reorder L
3524 */
3525 strat->L[i].p2 = strat->tail;
3526 /*
3527 *L[l] will be canceled, we cannot cancel L[i] later on,
3528 *so we mark it with "tail"
3529 */
3530 deleteInL(strat->L,&strat->Ll,l,strat);
3531 i--;
3532 }
3533 else
3534 {
3535 deleteInL(strat->L,&strat->Ll,i,strat);
3536 }
3537 j--;
3538 }
3539 i--;
3540 }
3541 }
3542 else if (strat->L[j].p2 == strat->tail)
3543 {
3544 /*now L[j] cannot be canceled any more and the tail can be removed*/
3545 strat->L[j].p2 = p;
3546 }
3547 j--;
3548 }
3549}
void kMergeBintoLSba(kStrategy strat)
Definition: kutil.cc:3218

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 545 of file kutil.cc.

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

◆ clearS()

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

Definition at line 1205 of file kInline.h.

1207{
1208 assume(p_sev == pGetShortExpVector(p));
1209 if (strat->noClearS) return;
1210 #ifdef HAVE_RINGS
1212 {
1213 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1214 return;
1215 if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1216 return;
1217 }
1218 else
1219 #endif
1220 {
1221 if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1222 }
1223 deleteInS((*at),strat);
1224 (*at)--;
1225 (*k)--;
1226}

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT = FALSE 
)

Definition at line 10532 of file kutil.cc.

10533{
10534 int i;
10535 int low = (((rHasGlobalOrdering(currRing)) && (strat->ak==0)) ? 1 : 0);
10536 LObject L;
10537
10538#ifdef KDEBUG
10539 // need to set this: during tailreductions of T[i], T[i].max is out of
10540 // sync
10541 sloppy_max = TRUE;
10542#endif
10543
10544 strat->noTailReduction = FALSE;
10545 //if(rHasMixedOrdering(currRing)) strat->noTailReduction = TRUE;
10546 if (TEST_OPT_PROT)
10547 {
10548 PrintLn();
10549// if (timerv) writeTime("standard base computed:");
10550 }
10551 if (TEST_OPT_PROT)
10552 {
10553 Print("(S:%d)",strat->sl);mflush();
10554 }
10555 for (i=strat->sl; i>=low; i--)
10556 {
10557 int end_pos=strat->sl;
10558 if ((strat->fromQ!=NULL) && (strat->fromQ[i])) continue; // do not reduce Q_i
10559 if (strat->ak==0) end_pos=i-1;
10560 TObject* T_j = strat->s_2_t(i);
10561 if ((T_j != NULL)&&(T_j->p==strat->S[i]))
10562 {
10563 L = *T_j;
10564 #ifdef KDEBUG
10565 if (TEST_OPT_DEBUG)
10566 {
10567 Print("test S[%d]:",i);
10568 p_wrp(L.p,currRing,strat->tailRing);
10569 PrintLn();
10570 }
10571 #endif
10573 strat->S[i] = redtailBba(&L, end_pos, strat, withT);
10574 else
10575 strat->S[i] = redtail(&L, strat->sl, strat);
10576 #ifdef KDEBUG
10577 if (TEST_OPT_DEBUG)
10578 {
10579 Print("to (tailR) S[%d]:",i);
10580 p_wrp(strat->S[i],currRing,strat->tailRing);
10581 PrintLn();
10582 }
10583 #endif
10584
10585 if (strat->redTailChange)
10586 {
10587 if (T_j->max_exp != NULL) p_LmFree(T_j->max_exp, strat->tailRing);
10588 if (pNext(T_j->p) != NULL)
10589 T_j->max_exp = p_GetMaxExpP(pNext(T_j->p), strat->tailRing);
10590 else
10591 T_j->max_exp = NULL;
10592 }
10594 T_j->pCleardenom();
10595 }
10596 else
10597 {
10598 assume(currRing == strat->tailRing);
10599 #ifdef KDEBUG
10600 if (TEST_OPT_DEBUG)
10601 {
10602 Print("test S[%d]:",i);
10603 p_wrp(strat->S[i],currRing,strat->tailRing);
10604 PrintLn();
10605 }
10606 #endif
10608 strat->S[i] = redtailBba(strat->S[i], end_pos, strat, withT);
10609 else
10610 strat->S[i] = redtail(strat->S[i], strat->sl, strat);
10612 {
10614 {
10615 number n;
10616 p_Cleardenom_n(strat->S[i], currRing, n);// also does remove Content
10617 if (!nIsOne(n))
10618 {
10620 denom->n=nInvers(n);
10621 denom->next=DENOMINATOR_LIST;
10622 DENOMINATOR_LIST=denom;
10623 }
10624 nDelete(&n);
10625 }
10626 else
10627 {
10628 strat->S[i]=p_Cleardenom(strat->S[i], currRing);// also does remove Content
10629 }
10630 }
10631 #ifdef KDEBUG
10632 if (TEST_OPT_DEBUG)
10633 {
10634 Print("to (-tailR) S[%d]:",i);
10635 p_wrp(strat->S[i],currRing,strat->tailRing);
10636 PrintLn();
10637 }
10638 #endif
10639 }
10640 if (TEST_OPT_PROT)
10641 PrintS("-");
10642 }
10643 if (TEST_OPT_PROT) PrintLn();
10644#ifdef KDEBUG
10645 sloppy_max = FALSE;
10646#endif
10647}
char noTailReduction
Definition: kutil.h:382
int ak
Definition: kutil.h:356
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:7069
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition: kutil.cc:7145
STATIC_VAR BOOLEAN sloppy_max
Definition: kutil.cc:800
VAR denominator_list DENOMINATOR_LIST
Definition: kutil.cc:84
denominator_list_s * denominator_list
Definition: kutil.h:63
denominator_list next
Definition: kutil.h:65
class sTObject TObject
Definition: kutil.h:57
class sLObject LObject
Definition: kutil.h:58
#define nDelete(n)
Definition: numbers.h:16
#define nInvers(a)
Definition: numbers.h:33
#define nIsOne(n)
Definition: numbers.h:25
#define omAlloc(size)
Definition: omAllocDecl.h:210
poly p_GetMaxExpP(poly p, const ring r)
return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0,...
Definition: p_polys.cc:1133
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:3009
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2900
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 254 of file kutil.cc.

255{
256 if (strat->kHEdgeFound)
257 {
258 kTest_L(L,strat->tailRing);
259 poly p1;
260 poly p = L->GetLmTailRing();
261 int l = 1;
262 kBucket_pt bucket = NULL;
263 if (L->bucket != NULL)
264 {
265 kBucketClear(L->bucket, &pNext(p), &L->pLength);
266 L->pLength++;
267 bucket = L->bucket;
268 L->bucket = NULL;
269 }
270
271 if (!fromNext && p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
272 {
273 L->Delete();
274 L->Clear();
275 L->ecart = -1;
276 if (bucket != NULL) kBucketDestroy(&bucket);
277 return;
278 }
279 p1 = p;
280 while (pNext(p1)!=NULL)
281 {
282 if (p_LmCmp(pNext(p1), strat->kNoetherTail(), L->tailRing) == -1)
283 {
284 p_Delete(&pNext(p1), L->tailRing);
285 if (p1 == p)
286 {
287 if (L->t_p != NULL)
288 {
289 assume(L->p != NULL && p == L->t_p);
290 pNext(L->p) = NULL;
291 }
292 L->max_exp = NULL;
293 }
294 else if (fromNext)
295 L->max_exp = p_GetMaxExpP(pNext(L->p), L->tailRing ); // p1;
296 //if (L->pLength != 0)
297 L->pLength = l;
298 // Hmmm when called from updateT, then only
299 // reset ecart when cut
300 if (fromNext)
301 L->ecart = L->pLDeg() - L->GetpFDeg();
302 break;
303 }
304 l++;
305 pIter(p1);
306 }
307 if (! fromNext)
308 {
309 L->SetpFDeg();
310 L->ecart = L->pLDeg(strat->LDegLast) - L->GetpFDeg();
311 }
312 if (bucket != NULL)
313 {
314 if (L->pLength > 1)
315 {
316 kBucketInit(bucket, pNext(p), L->pLength - 1);
317 pNext(p) = NULL;
318 if (L->t_p != NULL) pNext(L->t_p) = NULL;
319 L->pLength = 0;
320 L->bucket = bucket;
321 }
322 else
323 kBucketDestroy(&bucket);
324 }
325 kTest_L(L,strat->tailRing);
326 }
327}
KINLINE poly kNoetherTail()
Definition: kInline.h:66
char LDegLast
Definition: kutil.h:389
char kHEdgeFound
Definition: kutil.h:380
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:521
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:216
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:493
BOOLEAN kTest_L(LObject *L, ring strat_tailRing, BOOLEAN testp, int lpos, TSet T, int tlength)
Definition: kutil.cc:925
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1695
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1540

◆ deleteHC() [2/2]

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

Definition at line 329 of file kutil.cc.

330{
331 LObject L(*p, currRing, strat->tailRing);
332
333 deleteHC(&L, strat);
334 *p = L.p;
335 *e = L.ecart;
336 *l = L.length;
337 if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
338}
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition: kutil.cc:254

◆ deleteInL()

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

Definition at line 1244 of file kutil.cc.

1245{
1246 if (set[j].lcm!=NULL)
1247 {
1248 kDeleteLcm(&set[j]);
1249 }
1250 if (set[j].sig!=NULL)
1251 {
1252#ifdef HAVE_RINGS
1253 if (pGetCoeff(set[j].sig) != NULL)
1254 pLmDelete(set[j].sig);
1255 else
1256#endif
1257 pLmFree(set[j].sig);
1258 }
1259 if (set[j].p!=NULL)
1260 {
1261 if (pNext(set[j].p) == strat->tail)
1262 {
1263#ifdef HAVE_RINGS
1264 if (pGetCoeff(set[j].p) != NULL)
1265 pLmDelete(set[j].p);
1266 else
1267#endif
1268 pLmFree(set[j].p);
1269 /*- tail belongs to several int spolys -*/
1270 }
1271 else
1272 {
1273 // search p in T, if it is there, do not delete it
1274 if (rHasGlobalOrdering(currRing) || (kFindInT(set[j].p, strat) < 0))
1275 {
1276 // assure that for global orderings kFindInT fails
1277 //assume((rHasLocalOrMixedOrdering(currRing)) && (kFindInT(set[j].p, strat) >= 0));
1278 set[j].Delete();
1279 }
1280 }
1281 }
1282 if (*length > 0 && j < *length)
1283 {
1284#ifdef ENTER_USE_MEMMOVE
1285 memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject));
1286#else
1287 int i;
1288 for (i=j; i < (*length); i++)
1289 set[i] = set[i+1];
1290#endif
1291 }
1292#ifdef KDEBUG
1293 memset(&(set[*length]),0,sizeof(LObject));
1294#endif
1295 (*length)--;
1296}
CanonicalForm lcm(const CanonicalForm &, const CanonicalForm &)
CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g )
Definition: cf_gcd.cc:763
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:718

◆ deleteInS()

void deleteInS ( int  i,
kStrategy  strat 
)

Definition at line 1137 of file kutil.cc.

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

◆ deleteInSSba()

void deleteInSSba ( int  i,
kStrategy  strat 
)

Definition at line 1189 of file kutil.cc.

1190{
1191#ifdef ENTER_USE_MEMMOVE
1192 memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly));
1193 memmove(&(strat->sig[i]), &(strat->sig[i+1]), (strat->sl - i)*sizeof(poly));
1194 memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl - i)*sizeof(int));
1195 memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl - i)*sizeof(unsigned long));
1196 memmove(&(strat->sevSig[i]),&(strat->sevSig[i+1]),(strat->sl - i)*sizeof(unsigned long));
1197 memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl - i)*sizeof(int));
1198#else
1199 int j;
1200 for (j=i; j<strat->sl; j++)
1201 {
1202 strat->S[j] = strat->S[j+1];
1203 strat->sig[j] = strat->sig[j+1];
1204 strat->ecartS[j] = strat->ecartS[j+1];
1205 strat->sevS[j] = strat->sevS[j+1];
1206 strat->sevSig[j] = strat->sevSig[j+1];
1207 strat->S_2_R[j] = strat->S_2_R[j+1];
1208 }
1209#endif
1210 if (strat->lenS!=NULL)
1211 {
1212#ifdef ENTER_USE_MEMMOVE
1213 memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl - i)*sizeof(int));
1214#else
1215 for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1];
1216#endif
1217 }
1218 if (strat->lenSw!=NULL)
1219 {
1220#ifdef ENTER_USE_MEMMOVE
1221 memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl - i)*sizeof(wlen_type));
1222#else
1223 for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1];
1224#endif
1225 }
1226 if (strat->fromQ!=NULL)
1227 {
1228#ifdef ENTER_USE_MEMMOVE
1229 memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl - i)*sizeof(int));
1230#else
1231 for (j=i; j<strat->sl; j++)
1232 {
1233 strat->fromQ[j] = strat->fromQ[j+1];
1234 }
1235#endif
1236 }
1237 strat->S[strat->sl] = NULL;
1238 strat->sl--;
1239}

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4267 of file kutil.cc.

4268{
4269 if (nIsOne(pGetCoeff(h))) return;
4270 number gcd;
4271 bool go = false;
4272 if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4273 {
4274 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4275 go = true;
4276 }
4277 else
4278 gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4279 if (go || !nIsOne(gcd))
4280 {
4281 poly p = h->next;
4282 if (!go)
4283 {
4284 number tmp = gcd;
4285 gcd = n_Ann(gcd,currRing->cf);
4286 nDelete(&tmp);
4287 }
4288 p_Test(p,strat->tailRing);
4289 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4290 nDelete(&gcd);
4291
4292 if (p != NULL)
4293 {
4294 if (TEST_OPT_PROT)
4295 {
4296 PrintS("Z");
4297 }
4298#ifdef KDEBUG
4299 if (TEST_OPT_DEBUG)
4300 {
4301 PrintS("--- create zero spoly: ");
4302 p_wrp(h,currRing,strat->tailRing);
4303 PrintS(" ---> ");
4304 }
4305#endif
4306 poly tmp = pInit();
4307 pSetCoeff0(tmp, pGetCoeff(p));
4308 for (int i = 1; i <= rVar(currRing); i++)
4309 {
4310 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4311 }
4313 {
4314 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4315 }
4316 p_Setm(tmp, currRing);
4317 p = p_LmFreeAndNext(p, strat->tailRing);
4318 pNext(tmp) = p;
4319 LObject Lp;
4320 Lp.Init();
4321 Lp.p = tmp;
4322 Lp.tailRing = strat->tailRing;
4323 int posx;
4324 if (Lp.p!=NULL)
4325 {
4326 strat->initEcart(&Lp);
4327 if (strat->Ll==-1)
4328 posx =0;
4329 else
4330 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4331 Lp.sev = pGetShortExpVector(Lp.p);
4332 if (strat->tailRing != currRing)
4333 {
4334 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4335 }
4336#ifdef KDEBUG
4337 if (TEST_OPT_DEBUG)
4338 {
4339 p_wrp(tmp,currRing,strat->tailRing);
4340 PrintLn();
4341 }
4342#endif
4343 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4344 }
4345 }
4346 }
4347 nDelete(&gcd);
4348}
CanonicalForm FACTORY_PUBLIC gcd(const CanonicalForm &, const CanonicalForm &)
Definition: cf_gcd.cc:685
int Lmax
Definition: kutil.h:354
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:687
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:702
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:927
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1301
#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:962
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:703
#define p_Test(p, r)
Definition: p_polys.h:162
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
#define pSetExp(p, i, v)
Definition: polys.h:42

◆ enterExtendedSpolySig()

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

Definition at line 4350 of file kutil.cc.

4351{
4352 if (nIsOne(pGetCoeff(h))) return;
4353 number gcd;
4354 bool go = false;
4355 if (n_DivBy((number) 0, pGetCoeff(h), currRing->cf))
4356 {
4357 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4358 go = true;
4359 }
4360 else
4361 gcd = n_Gcd((number) 0, pGetCoeff(h), strat->tailRing->cf);
4362 if (go || !nIsOne(gcd))
4363 {
4364 poly p = h->next;
4365 if (!go)
4366 {
4367 number tmp = gcd;
4368 gcd = n_Ann(gcd,currRing->cf);
4369 nDelete(&tmp);
4370 }
4371 p_Test(p,strat->tailRing);
4372 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4373
4374 if (p != NULL)
4375 {
4376 if (TEST_OPT_PROT)
4377 {
4378 PrintS("Z");
4379 }
4380#ifdef KDEBUG
4381 if (TEST_OPT_DEBUG)
4382 {
4383 PrintS("--- create zero spoly: ");
4384 p_wrp(h,currRing,strat->tailRing);
4385 PrintS(" ---> ");
4386 }
4387#endif
4388 poly tmp = pInit();
4389 pSetCoeff0(tmp, pGetCoeff(p));
4390 for (int i = 1; i <= rVar(currRing); i++)
4391 {
4392 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4393 }
4395 {
4396 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4397 }
4398 p_Setm(tmp, currRing);
4399 p = p_LmFreeAndNext(p, strat->tailRing);
4400 pNext(tmp) = p;
4401 LObject Lp;
4402 Lp.Init();
4403 Lp.p = tmp;
4404 //printf("\nOld\n");pWrite(h);pWrite(hSig);
4405 #if EXT_POLY_NEW
4406 Lp.sig = __pp_Mult_nn(hSig, gcd, currRing);
4407 if(Lp.sig == NULL || nIsZero(pGetCoeff(Lp.sig)))
4408 {
4409 strat->sigdrop = TRUE;
4410 //Try to reduce it as far as we can via redRing
4411 int red_result = redRing(&Lp,strat);
4412 if(red_result == 0)
4413 {
4414 // Cancel the sigdrop
4415 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
4416 strat->sigdrop = FALSE;
4417 return;
4418 }
4419 else
4420 {
4421 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
4422 #if 1
4423 strat->enterS(Lp,0,strat,strat->tl);
4424 #endif
4425 return;
4426 }
4427
4428 }
4429 #else
4430 Lp.sig = pOne();
4431 if(strat->Ll >= 0)
4432 p_SetComp(Lp.sig,pGetComp(strat->L[0].sig)+1,currRing);
4433 else
4434 p_SetComp(Lp.sig,pGetComp(hSig)+1,currRing);
4435 #endif
4436 Lp.tailRing = strat->tailRing;
4437 int posx;
4438 if (Lp.p!=NULL)
4439 {
4440 strat->initEcart(&Lp);
4441 if (strat->Ll==-1)
4442 posx =0;
4443 else
4444 posx = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
4445 Lp.sev = pGetShortExpVector(Lp.p);
4446 if (strat->tailRing != currRing)
4447 {
4448 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4449 }
4450#ifdef KDEBUG
4451 if (TEST_OPT_DEBUG)
4452 {
4453 p_wrp(tmp,currRing,strat->tailRing);
4454 PrintLn();
4455 }
4456#endif
4457 //pWrite(h);pWrite(hSig);pWrite(Lp.p);pWrite(Lp.sig);printf("\n------------------\n");getchar();
4458 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4459 }
4460 }
4461 nDelete(&gcd);
4462 }
4463 nDelete(&gcd);
4464}
bool sigdrop
Definition: kutil.h:363
int(* posInLSba)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:283
int redRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:822
#define nIsZero(n)
Definition: numbers.h:19

◆ enterL()

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

Definition at line 1301 of file kutil.cc.

1302{
1303 // this should be corrected
1304 assume(p.FDeg == p.pFDeg());
1305
1306 if ((*length)>=0)
1307 {
1308 if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc);
1309 if (at <= (*length))
1310#ifdef ENTER_USE_MEMMOVE
1311 memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
1312#else
1313 for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
1314#endif
1315 }
1316 else at = 0;
1317 (*set)[at] = p;
1318 (*length)++;
1319}
static void enlargeL(LSet *L, int *length, const int incr)
Definition: kutil.cc:663
#define setmaxLinc
Definition: kutil.h:31

◆ enterOnePairNormal()

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

Definition at line 1975 of file kutil.cc.

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

◆ enterOnePairShift()

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

Definition at line 12535 of file kutil.cc.

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

4526{
4527 int j=pos;
4528
4530 initenterpairs(h,k,ecart,0,strat, atR);
4531 if ( (!strat->fromT)
4532 && ((strat->syzComp==0)
4533 ||(pGetComp(h)<=strat->syzComp)))
4534 {
4535 unsigned long h_sev = pGetShortExpVector(h);
4536 loop
4537 {
4538 if (j > k) break;
4539 clearS(h,h_sev, &j,&k,strat);
4540 j++;
4541 }
4542 }
4543}
void initenterpairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:3840

◆ enterpairsShift()

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

Definition at line 13309 of file kutil.cc.

13310{
13311 /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
13312 /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
13313 int j=pos;
13314
13315 /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
13316 initenterpairsShift(h,k,ecart,0,strat, atR);
13317 if ( (!strat->fromT)
13318 && ((strat->syzComp==0)
13319 ||(pGetComp(h)<=strat->syzComp)))
13320 {
13321 unsigned long h_sev = pGetShortExpVector(h);
13322 loop
13323 {
13324 if (j > k) break;
13325 // TODO this currently doesn't clear all possible elements because of commutative division
13326 if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
13327 clearS(h,h_sev, &j,&k,strat);
13328 j++;
13329 }
13330 }
13331}
void initenterpairsShift(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:12876

◆ enterpairsSig()

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

Definition at line 4551 of file kutil.cc.

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

◆ enterSBba()

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

Definition at line 9023 of file kutil.cc.

9024{
9025 strat->news = TRUE;
9026 /*- puts p to the standardbasis s at position at -*/
9027 if (strat->sl == IDELEMS(strat->Shdl)-1)
9028 {
9029 strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS,
9030 IDELEMS(strat->Shdl)*sizeof(unsigned long),
9031 (IDELEMS(strat->Shdl)+setmaxTinc)
9032 *sizeof(unsigned long));
9033 strat->ecartS = (intset)omReallocSize(strat->ecartS,
9034 IDELEMS(strat->Shdl)*sizeof(int),
9035 (IDELEMS(strat->Shdl)+setmaxTinc)
9036 *sizeof(int));
9037 strat->S_2_R = (int*) omRealloc0Size(strat->S_2_R,
9038 IDELEMS(strat->Shdl)*sizeof(int),
9039 (IDELEMS(strat->Shdl)+setmaxTinc)
9040 *sizeof(int));
9041 if (strat->lenS!=NULL)
9042 strat->lenS=(int*)omRealloc0Size(strat->lenS,
9043 IDELEMS(strat->Shdl)*sizeof(int),
9044 (IDELEMS(strat->Shdl)+setmaxTinc)
9045 *sizeof(int));
9046 if (strat->lenSw!=NULL)
9047 strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw,
9048 IDELEMS(strat->Shdl)*sizeof(wlen_type),
9049 (IDELEMS(strat->Shdl)+setmaxTinc)
9050 *sizeof(wlen_type));
9051 if (strat->fromQ!=NULL)
9052 {
9053 strat->fromQ = (intset)omReallocSize(strat->fromQ,
9054 IDELEMS(strat->Shdl)*sizeof(int),
9055 (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int));
9056 }
9057 pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc);
9058 IDELEMS(strat->Shdl)+=setmaxTinc;
9059 strat->Shdl->m=strat->S;
9060 }
9061 if (atS <= strat->sl)
9062 {
9063#ifdef ENTER_USE_MEMMOVE
9064 memmove(&(strat->S[atS+1]), &(strat->S[atS]),
9065 (strat->sl - atS + 1)*sizeof(poly));
9066 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
9067 (strat->sl - atS + 1)*sizeof(int));
9068 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
9069 (strat->sl - atS + 1)*sizeof(unsigned long));
9070 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
9071 (strat->sl - atS + 1)*sizeof(int));
9072 if (strat->lenS!=NULL)
9073 memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]),
9074 (strat->sl - atS + 1)*sizeof(int));
9075 if (strat->lenSw!=NULL)
9076 memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]),
9077 (strat->sl - atS + 1)*sizeof(wlen_type));
9078#else
9079 for (i=strat->sl+1; i>=atS+1; i--)
9080 {
9081 strat->S[i] = strat->S[i-1];
9082 strat->ecartS[i] = strat->ecartS[i-1];
9083 strat->sevS[i] = strat->sevS[i-1];
9084 strat->S_2_R[i] = strat->S_2_R[i-1];
9085 }
9086 if (strat->lenS!=NULL)
9087 for (i=strat->sl+1; i>=atS+1; i--)
9088 strat->lenS[i] = strat->lenS[i-1];
9089 if (strat->lenSw!=NULL)
9090 for (i=strat->sl+1; i>=atS+1; i--)
9091 strat->lenSw[i] = strat->lenSw[i-1];
9092#endif
9093 }
9094 if (strat->fromQ!=NULL)
9095 {
9096#ifdef ENTER_USE_MEMMOVE
9097 memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]),
9098 (strat->sl - atS + 1)*sizeof(int));
9099#else
9100 for (i=strat->sl+1; i>=atS+1; i--)
9101 {
9102 strat->fromQ[i] = strat->fromQ[i-1];
9103 }
9104#endif
9105 strat->fromQ[atS]=0;
9106 }
9107
9108 /*- save result -*/
9109 poly pp=p.p;
9110 strat->S[atS] = pp;
9111 if (strat->honey) strat->ecartS[atS] = p.ecart;
9112 if (p.sev == 0)
9113 p.sev = pGetShortExpVector(pp);
9114 else
9115 assume(p.sev == pGetShortExpVector(pp));
9116 strat->sevS[atS] = p.sev;
9117 strat->ecartS[atS] = p.ecart;
9118 strat->S_2_R[atS] = atR;
9119 strat->sl++;
9120}
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
char news
Definition: kutil.h:404
#define setmaxTinc
Definition: kutil.h:34
int * intset
Definition: kutil.h:53
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3766

◆ enterSBbaShift()

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

Definition at line 9123 of file kutil.cc.

9124{
9125 enterSBba(p, atS, strat, atR);
9126
9127 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
9128 for (int i = maxPossibleShift; i > 0; i--)
9129 {
9130 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
9131 // in `kNF2` because of lazy poly normalizations.
9132 LObject qq(p_Copy(p.p, strat->tailRing));
9133 p_mLPshift(qq.p, i, strat->tailRing);
9134 qq.shift = i;
9135 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
9136 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
9137 enterSBba(qq, atS, strat, -1);
9138 }
9139}
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9023
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:359

◆ entersets()

void entersets ( LObject  h)

◆ enterSSba()

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

Definition at line 9146 of file kutil.cc.

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

9575{
9576 int i;
9577 strat->newt = TRUE;
9578 if (strat->syzl == strat->syzmax-1)
9579 {
9580 pEnlargeSet(&strat->syz,strat->syzmax,setmax);
9581 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
9582 (strat->syzmax)*sizeof(unsigned long),
9583 ((strat->syzmax)+setmax)
9584 *sizeof(unsigned long));
9585 strat->syzmax += setmax;
9586 }
9587 if (atT < strat->syzl)
9588 {
9589#ifdef ENTER_USE_MEMMOVE
9590 memmove(&(strat->syz[atT+1]), &(strat->syz[atT]),
9591 (strat->syzl-atT+1)*sizeof(poly));
9592 memmove(&(strat->sevSyz[atT+1]), &(strat->sevSyz[atT]),
9593 (strat->syzl-atT+1)*sizeof(unsigned long));
9594#endif
9595 for (i=strat->syzl; i>=atT+1; i--)
9596 {
9597#ifndef ENTER_USE_MEMMOVE
9598 strat->syz[i] = strat->syz[i-1];
9599 strat->sevSyz[i] = strat->sevSyz[i-1];
9600#endif
9601 }
9602 }
9603 //i = strat->syzl;
9604 i = atT;
9605 //Makes sure the syz saves just the signature
9606 #ifdef HAVE_RINGS
9608 pNext(p.sig) = NULL;
9609 #endif
9610 strat->syz[atT] = p.sig;
9611 strat->sevSyz[atT] = p.sevSig;
9612 strat->syzl++;
9613#if F5DEBUG
9614 Print("element in strat->syz: %d--%d ",atT+1,strat->syzmax);
9615 pWrite(strat->syz[atT]);
9616#endif
9617 // recheck pairs in strat->L with new rule and delete correspondingly
9618 int cc = strat->Ll;
9619 while (cc>-1)
9620 {
9621 //printf("\nCheck if syz is div by L\n");pWrite(strat->syz[atT]);pWrite(strat->L[cc].sig);
9622 //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);
9623 if (p_LmShortDivisibleBy( strat->syz[atT], strat->sevSyz[atT],
9624 strat->L[cc].sig, ~strat->L[cc].sevSig, currRing)
9625 #ifdef HAVE_RINGS
9627 || (n_DivBy(pGetCoeff(strat->L[cc].sig),pGetCoeff(strat->syz[atT]),currRing->cf) && (pLtCmp(strat->L[cc].sig,strat->syz[atT])==1)))
9628 #endif
9629 )
9630 {
9631 //printf("\nYES!\n");
9632 deleteInL(strat->L,&strat->Ll,cc,strat);
9633 }
9634 cc--;
9635 }
9636//#if 1
9637#ifdef DEBUGF5
9638 PrintS("--- Syzygies ---\n");
9639 Print("syzl %d\n",strat->syzl);
9640 Print("syzmax %d\n",strat->syzmax);
9641 PrintS("--------------------------------\n");
9642 for(i=0;i<=strat->syzl-1;i++)
9643 {
9644 Print("%d - ",i);
9645 pWrite(strat->syz[i]);
9646 }
9647 PrintS("--------------------------------\n");
9648#endif
9649}
unsigned long * sevSyz
Definition: kutil.h:324
int syzmax
Definition: kutil.h:352
int syzl
Definition: kutil.h:352
polyset syz
Definition: kutil.h:308
char newt
Definition: kutil.h:405
#define pLtCmp(p, q)
Definition: polys.h:123

◆ enterT()

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

Definition at line 9372 of file kutil.cc.

9373{
9374 int i;
9375
9376#ifdef PDEBUG
9377#ifdef HAVE_SHIFTBBA
9378 if (currRing->isLPring && p.shift > 0)
9379 {
9380 // in this case, the order is not correct. test LM and tail separately
9381 p_LmTest(p.p, currRing);
9382 p_Test(pNext(p.p), currRing);
9383 }
9384 else
9385#endif
9386 {
9387 pp_Test(p.p, currRing, p.tailRing);
9388 }
9389#endif
9390 assume(strat->tailRing == p.tailRing);
9391 // redMoraNF complains about this -- but, we don't really
9392 // neeed this so far
9393 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9394 assume(p.FDeg == p.pFDeg());
9395 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9396
9397#ifdef KDEBUG
9398 // do not put an LObject twice into T:
9399 for(i=strat->tl;i>=0;i--)
9400 {
9401 if (p.p==strat->T[i].p)
9402 {
9403 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9404 return;
9405 }
9406 }
9407#endif
9408
9409#ifdef HAVE_TAIL_RING
9410 if (currRing!=strat->tailRing)
9411 {
9412 p.t_p=p.GetLmTailRing();
9413 }
9414#endif
9415 strat->newt = TRUE;
9416 if (atT < 0)
9417 atT = strat->posInT(strat->T, strat->tl, p);
9418 if (strat->tl == strat->tmax-1)
9419 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9420 if (atT <= strat->tl)
9421 {
9422#ifdef ENTER_USE_MEMMOVE
9423 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9424 (strat->tl-atT+1)*sizeof(TObject));
9425 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9426 (strat->tl-atT+1)*sizeof(unsigned long));
9427#endif
9428 for (i=strat->tl+1; i>=atT+1; i--)
9429 {
9430#ifndef ENTER_USE_MEMMOVE
9431 strat->T[i] = strat->T[i-1];
9432 strat->sevT[i] = strat->sevT[i-1];
9433#endif
9434 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9435 }
9436 }
9437
9438 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9439 {
9440#ifdef HAVE_SHIFTBBA
9441 // letterplace: if p.shift > 0 then pNext(p.p) is already in the tailBin
9442 if (!(currRing->isLPring && p.shift > 0))
9443#endif
9444 {
9446 (strat->tailRing != NULL ?
9447 strat->tailRing : currRing),
9448 strat->tailBin);
9449 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9450 }
9451 }
9452 strat->T[atT] = (TObject) p;
9453 //printf("\nenterT: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9454
9455 if (pNext(p.p) != NULL)
9456 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9457 else
9458 strat->T[atT].max_exp = NULL;
9459
9460 strat->tl++;
9461 strat->R[strat->tl] = &(strat->T[atT]);
9462 strat->T[atT].i_r = strat->tl;
9463 assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9464 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9465 kTest_T(&(strat->T[atT]));
9466}
int tmax
Definition: kutil.h:353
omBin tailBin
Definition: kutil.h:348
static void enlargeT(TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
Definition: kutil.cc:524
BOOLEAN kTest_T(TObject *T, ring strat_tailRing, int i, char TN)
Definition: kutil.cc:801
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:164
static poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
Definition: p_polys.h:888
#define p_LmTest(p, r)
Definition: p_polys.h:163
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:722

◆ enterT_strong()

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

Definition at line 9472 of file kutil.cc.

9473{
9475 int i;
9476
9477 pp_Test(p.p, currRing, p.tailRing);
9478 assume(strat->tailRing == p.tailRing);
9479 // redMoraNF complains about this -- but, we don't really
9480 // neeed this so far
9481 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9482 assume(p.FDeg == p.pFDeg());
9483 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
9484
9485#ifdef KDEBUG
9486 // do not put an LObject twice into T:
9487 for(i=strat->tl;i>=0;i--)
9488 {
9489 if (p.p==strat->T[i].p)
9490 {
9491 printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT);
9492 return;
9493 }
9494 }
9495#endif
9496
9497#ifdef HAVE_TAIL_RING
9498 if (currRing!=strat->tailRing)
9499 {
9500 p.t_p=p.GetLmTailRing();
9501 }
9502#endif
9503 strat->newt = TRUE;
9504 if (atT < 0)
9505 atT = strat->posInT(strat->T, strat->tl, p);
9506 if (strat->tl == strat->tmax-1)
9507 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc);
9508 if (atT <= strat->tl)
9509 {
9510#ifdef ENTER_USE_MEMMOVE
9511 memmove(&(strat->T[atT+1]), &(strat->T[atT]),
9512 (strat->tl-atT+1)*sizeof(TObject));
9513 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
9514 (strat->tl-atT+1)*sizeof(unsigned long));
9515#endif
9516 for (i=strat->tl+1; i>=atT+1; i--)
9517 {
9518#ifndef ENTER_USE_MEMMOVE
9519 strat->T[i] = strat->T[i-1];
9520 strat->sevT[i] = strat->sevT[i-1];
9521#endif
9522 strat->R[strat->T[i].i_r] = &(strat->T[i]);
9523 }
9524 }
9525
9526 if ((strat->tailBin != NULL) && (pNext(p.p) != NULL))
9527 {
9529 (strat->tailRing != NULL ?
9530 strat->tailRing : currRing),
9531 strat->tailBin);
9532 if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
9533 }
9534 strat->T[atT] = (TObject) p;
9535 //printf("\nenterT_strong: add new: length = %i, ecart = %i\n",p.length,p.ecart);
9536
9537 if (pNext(p.p) != NULL)
9538 strat->T[atT].max_exp = p_GetMaxExpP(pNext(p.p), strat->tailRing);
9539 else
9540 strat->T[atT].max_exp = NULL;
9541
9542 strat->tl++;
9543 strat->R[strat->tl] = &(strat->T[atT]);
9544 strat->T[atT].i_r = strat->tl;
9545 assume(p.sev == 0 || pGetShortExpVector(p.p) == p.sev);
9546 strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev);
9547 #if 1
9549 && !n_IsUnit(p.p->coef, currRing->cf))
9550 {
9551 for(i=strat->tl;i>=0;i--)
9552 {
9553 if(strat->T[i].ecart <= p.ecart && pLmDivisibleBy(strat->T[i].p,p.p))
9554 {
9555 enterOneStrongPoly(i,p.p,p.ecart,0,strat,0 , TRUE);
9556 }
9557 }
9558 }
9559 /*
9560 printf("\nThis is T:\n");
9561 for(i=strat->tl;i>=0;i--)
9562 {
9563 pWrite(strat->T[i].p);
9564 }
9565 //getchar();*/
9566 #endif
9567 kTest_T(&(strat->T[atT]));
9568}
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:516
static BOOLEAN enterOneStrongPoly(int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
Definition: kutil.cc:1571
#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 13339 of file kutil.cc.

13340{
13341 /* determine how many elements we have to insert */
13342 /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
13343 /* hence, a total number of elt's to add is: */
13344 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */
13345 pAssume(p.p != NULL);
13346
13347 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
13348
13349 for (int i = 1; i <= maxPossibleShift; i++)
13350 {
13351 LObject qq;
13352 qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
13353 qq.shift = i;
13354 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
13355
13356 enterT(qq, strat, atT); // enterT is modified, so it doesn't copy and delete the tail of shifted polys
13357 }
13358}
#define pAssume(cond)
Definition: monomials.h:90
#define pLPCopyAndShiftLM(p, sh)
Definition: shiftgb.h:15

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 10079 of file kutil.cc.

10080{
10081 /*- release temp data -*/
10082 cleanT(strat);
10083 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10084 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10085 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10086 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10087 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10088 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10089 /*- set L: should be empty -*/
10090 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10091 /*- set B: should be empty -*/
10092 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10093 pLmFree(&strat->tail);
10094 strat->syzComp=0;
10095
10096#ifdef HAVE_SHIFTBBA
10097 if (rIsLPRing(currRing) && strat->rightGB)
10098 {
10099 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10100 strat->fromQ=NULL;
10101 }
10102#endif
10103}
void * ADDRESS
Definition: auxiliary.h:119

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10280 of file kutil.cc.

10281{
10282 /*- release temp data -*/
10284 cleanTSbaRing(strat);
10285 else
10286 cleanT(strat);
10287 omFreeSize(strat->T,(strat->tmax)*sizeof(TObject));
10288 omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*));
10289 omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long));
10290 omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
10291 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10292 omFreeSize((ADDRESS)strat->sevSig,IDELEMS(strat->Shdl)*sizeof(unsigned long));
10293 if(strat->syzmax>0)
10294 {
10295 omFreeSize((ADDRESS)strat->syz,(strat->syzmax)*sizeof(poly));
10296 omFreeSize((ADDRESS)strat->sevSyz,(strat->syzmax)*sizeof(unsigned long));
10297 if (strat->sbaOrder == 1)
10298 {
10299 omFreeSize(strat->syzIdx,(strat->syzidxmax)*sizeof(int));
10300 }
10301 }
10302 omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int));
10303 /*- set L: should be empty -*/
10304 omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject));
10305 /*- set B: should be empty -*/
10306 omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject));
10307 /*- set sig: no need for the signatures anymore -*/
10308 omFreeSize(strat->sig,IDELEMS(strat->Shdl)*sizeof(poly));
10309 pLmDelete(&strat->tail);
10310 strat->syzComp=0;
10311}
int syzidxmax
Definition: kutil.h:352
intset syzIdx
Definition: kutil.h:314
unsigned sbaOrder
Definition: kutil.h:317
void cleanTSbaRing(kStrategy strat)
Definition: kutil.cc:604

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

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

◆ faugereRewCriterion()

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

Definition at line 6792 of file kutil.cc.

6793{
6794 //printf("Faugere Rewritten Criterion\n");
6796 return FALSE;
6797//#if 1
6798#ifdef DEBUGF5
6799 PrintS("rewritten criterion checks: ");
6800 pWrite(sig);
6801#endif
6802 for(int k = strat->sl; k>=start; k--)
6803 {
6804//#if 1
6805#ifdef DEBUGF5
6806 PrintS("checking with: ");
6807 pWrite(strat->sig[k]);
6808 pWrite(pHead(strat->S[k]));
6809#endif
6810 if (p_LmShortDivisibleBy(strat->sig[k], strat->sevSig[k], sig, not_sevSig, currRing))
6811 {
6812//#if 1
6813#ifdef DEBUGF5
6814 PrintS("DELETE!\n");
6815#endif
6816 strat->nrrewcrit++;
6817 return TRUE;
6818 }
6819 //k--;
6820 }
6821#ifdef DEBUGF5
6822 PrintS("ALL ELEMENTS OF S\n----------------------------------------\n");
6823 for(int kk = 0; kk<strat->sl+1; kk++)
6824 {
6825 pWrite(pHead(strat->S[kk]));
6826 }
6827 PrintS("------------------------------\n");
6828#endif
6829 return FALSE;
6830}
int nrrewcrit
Definition: kutil.h:365

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

11113{
11114 assume(strat->tl<0); /* can only be called with no elements in T:
11115 i.e. after exitBuchMora */
11116 /* do not use strat->S, strat->sl as they may be out of sync*/
11117 if(!nCoeff_is_Z(currRing->cf))
11118 return;
11119 poly p,pp;
11120 for(int j = 0; j<IDELEMS(strat->Shdl); j++)
11121 {
11122 if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL))
11123 {
11124 for(int i = 0; i<IDELEMS(strat->Shdl); i++)
11125 {
11126 if((i != j) && (strat->Shdl->m[i] != NULL))
11127 {
11128 p = strat->Shdl->m[i];
11129 while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
11130#if HAVE_SHIFTBBA
11131 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
11132#endif
11133 ))
11134 {
11135 number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
11136 if (!nEqual(dummy,p->coef))
11137 {
11138 if (nIsZero(dummy))
11139 {
11140 nDelete(&dummy);
11141 pLmDelete(&strat->Shdl->m[i]);
11142 p=strat->Shdl->m[i];
11143 }
11144 else
11145 {
11146 p_SetCoeff(p,dummy,currRing);
11147 break;
11148 }
11149 }
11150 else
11151 {
11152 nDelete(&dummy);
11153 break;
11154 }
11155 }
11156 if (p!=NULL)
11157 {
11158 pp = pNext(p);
11159 while(pp != NULL)
11160 {
11161 if(pLmDivisibleBy(strat->Shdl->m[j], pp)
11162#if HAVE_SHIFTBBA
11163 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
11164#endif
11165 )
11166 {
11167 number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
11168 if (!nEqual(dummy,pp->coef))
11169 {
11170 p_SetCoeff(pp,dummy,currRing);
11171 if(nIsZero(pp->coef))
11172 {
11173 pLmDelete(&pNext(p));
11174 pp = pNext(p);
11175 }
11176 else
11177 {
11178 p = pp;
11179 pp = pNext(p);
11180 }
11181 }
11182 else
11183 {
11184 nDelete(&dummy);
11185 p = pp;
11186 pp = pNext(p);
11187 }
11188 }
11189 else
11190 {
11191 p = pp;
11192 pp = pNext(p);
11193 }
11194 }
11195 }
11196 }
11197 }
11198 //idPrint(strat->Shdl);
11199 }
11200 }
11201 idSkipZeroes(strat->Shdl);
11202}
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:840
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:412
#define pLPLmDivisibleBy(a, b)
Definition: shiftop.h:58
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ findMinLMPair()

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

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 475 of file kutil.cc.

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

◆ homogTest()

BOOLEAN homogTest ( polyset  F,
int  Fmax 
)

◆ initBba()

void initBba ( kStrategy  strat)

Definition at line 1670 of file kstd1.cc.

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

◆ initBuchMora()

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

Definition at line 9995 of file kutil.cc.

9996{
9997 strat->interpt = BTEST1(OPT_INTERRUPT);
9998 strat->kHEdge=NULL;
10000 /*- creating temp data structures------------------- -*/
10001 strat->cp = 0;
10002 strat->c3 = 0;
10003#ifdef HAVE_SHIFTBBA
10004 strat->cv = 0;
10005#endif
10006 strat->tail = pInit();
10007 /*- set s -*/
10008 strat->sl = -1;
10009 /*- set L -*/
10010 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10011 strat->Ll = -1;
10012 strat->L = initL(strat->Lmax);
10013 /*- set B -*/
10014 strat->Bmax = setmaxL;
10015 strat->Bl = -1;
10016 strat->B = initL();
10017 /*- set T -*/
10018 strat->tl = -1;
10019 strat->tmax = setmaxT;
10020 strat->T = initT();
10021 strat->R = initR();
10022 strat->sevT = initsevT();
10023 /*- init local data struct.---------------------------------------- -*/
10024 strat->P.ecart=0;
10025 strat->P.length=0;
10026 strat->P.pLength=0;
10028 {
10029 if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10030 if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10031 }
10033 {
10034 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10035 }
10036 else
10037 {
10038 if(TEST_OPT_SB_1)
10039 {
10040 int i;
10041 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10042 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10043 {
10044 P->m[i-strat->newIdeal] = F->m[i];
10045 F->m[i] = NULL;
10046 }
10047 initSSpecial(F,Q,P,strat);
10048 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10049 {
10050 F->m[i] = P->m[i-strat->newIdeal];
10051 P->m[i-strat->newIdeal] = NULL;
10052 }
10053 idDelete(&P);
10054 }
10055 else
10056 {
10057 /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
10058 // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
10059 }
10060 }
10061 strat->fromT = FALSE;
10063 if ((!TEST_OPT_SB_1)
10065 )
10066 {
10067 updateS(TRUE,strat);
10068 }
10069#ifdef HAVE_SHIFTBBA
10070 if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
10071#endif
10072 {
10073 if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10074 strat->fromQ=NULL;
10075 }
10076 assume(kTest_TS(strat));
10077}
poly kNoether
Definition: kutil.h:331
poly kHEdge
Definition: kutil.h:330
int newIdeal
Definition: kutil.h:360
#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:8325
void updateS(BOOLEAN toT, kStrategy strat)
Definition: kutil.cc:8788
void initSL(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:7923
#define setmaxL
Definition: kutil.h:30
static LSet initL(int nr=setmaxL)
Definition: kutil.h:425
#define setmaxT
Definition: kutil.h:33
#define OPT_INTERRUPT
Definition: options.h:79
#define BTEST1(a)
Definition: options.h:33
#define pSetComp(p, v)
Definition: polys.h:38

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9670 of file kutil.cc.

9671{
9674 if (TEST_OPT_SB_1)
9676#ifdef HAVE_RINGS
9678 {
9680 strat->chainCrit=chainCritRing;
9681 }
9682#endif
9683#ifdef HAVE_RATGRING
9684 if (rIsRatGRing(currRing))
9685 {
9686 strat->chainCrit=chainCritPart;
9687 /* enterOnePairNormal get rational part in it */
9688 }
9689#endif
9690 if (TEST_OPT_IDLIFT
9691 && (strat->syzComp==1)
9692 && (!rIsPluralRing(currRing)))
9694
9696 strat->Gebauer = strat->homog || strat->sugarCrit;
9697 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9698 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9699 strat->pairtest = NULL;
9700 /* alway use tailreduction, except:
9701 * - in local rings, - in lex order case, -in ring over extensions */
9703 //if(rHasMixedOrdering(currRing)==2)
9704 //{
9705 // strat->noTailReduction =TRUE;
9706 //}
9707
9708#ifdef HAVE_PLURAL
9709 // and r is plural_ring
9710 // hence this holds for r a rational_plural_ring
9711 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9712 { //or it has non-quasi-comm type... later
9713 strat->sugarCrit = FALSE;
9714 strat->Gebauer = FALSE;
9715 strat->honey = FALSE;
9716 }
9717#endif
9718
9719 // Coefficient ring?
9721 {
9722 strat->sugarCrit = FALSE;
9723 strat->Gebauer = FALSE ;
9724 strat->honey = FALSE;
9725 }
9726 #ifdef KDEBUG
9727 if (TEST_OPT_DEBUG)
9728 {
9729 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9730 else PrintS("ideal/module is not homogeneous\n");
9731 }
9732 #endif
9733}
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:292
char z2homog
Definition: kutil.h:378
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.h:291
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:1975
void chainCritOpt_1(poly, int, kStrategy strat)
Definition: kutil.cc:3476
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition: kutil.cc:1367
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:2257
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3551
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition: kutil.cc:3240
void chainCritRing(poly p, int, kStrategy strat)
Definition: kutil.cc:4027
static bool rIsSCA(const ring r)
Definition: nc.h:190
#define TEST_OPT_WEIGHTM
Definition: options.h:121
#define TEST_OPT_SUGARCRIT
Definition: options.h:107
#define TEST_OPT_NOT_SUGAR
Definition: options.h:106

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9822 of file kutil.cc.

9823{
9825 {
9826 if (strat->honey)
9827 {
9828 strat->posInL = posInL15;
9829 // ok -- here is the deal: from my experiments for Singular-2-0
9830 // I conclude that that posInT_EcartpLength is the best of
9831 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9832 // see the table at the end of this file
9833 if (TEST_OPT_OLDSTD)
9834 strat->posInT = posInT15;
9835 else
9836 strat->posInT = posInT_EcartpLength;
9837 }
9838 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9839 {
9840 strat->posInL = posInL11;
9841 strat->posInT = posInT11;
9842 }
9843 else if (TEST_OPT_INTSTRATEGY)
9844 {
9845 strat->posInL = posInL11;
9846 strat->posInT = posInT11;
9847 }
9848 else
9849 {
9850 strat->posInL = posInL0;
9851 strat->posInT = posInT0;
9852 }
9853 //if (strat->minim>0) strat->posInL =posInLSpecial;
9854 if (strat->homog)
9855 {
9856 strat->posInL = posInL110;
9857 strat->posInT = posInT110;
9858 }
9859 }
9860 else
9861 {
9862 if (strat->homog)
9863 {
9864 strat->posInL = posInL11;
9865 strat->posInT = posInT11;
9866 }
9867 else
9868 {
9869 if ((currRing->order[0]==ringorder_c)
9870 ||(currRing->order[0]==ringorder_C))
9871 {
9872 strat->posInL = posInL17_c;
9873 strat->posInT = posInT17_c;
9874 }
9875 else
9876 {
9877 strat->posInL = posInL17;
9878 strat->posInT = posInT17;
9879 }
9880 }
9881 }
9882 if (strat->minim>0) strat->posInL =posInLSpecial;
9883 // for further tests only
9884 if ((BTEST1(11)) || (BTEST1(12)))
9885 strat->posInL = posInL11;
9886 else if ((BTEST1(13)) || (BTEST1(14)))
9887 strat->posInL = posInL13;
9888 else if ((BTEST1(15)) || (BTEST1(16)))
9889 strat->posInL = posInL15;
9890 else if ((BTEST1(17)) || (BTEST1(18)))
9891 strat->posInL = posInL17;
9892 if (BTEST1(11))
9893 strat->posInT = posInT11;
9894 else if (BTEST1(13))
9895 strat->posInT = posInT13;
9896 else if (BTEST1(15))
9897 strat->posInT = posInT15;
9898 else if ((BTEST1(17)))
9899 strat->posInT = posInT17;
9900 else if ((BTEST1(19)))
9901 strat->posInT = posInT19;
9902 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9903 strat->posInT = posInT1;
9905}
char posInLDependsOnLength
Definition: kutil.h:393
int posInL110(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6284
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5394
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4990
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4934
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5261
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:4923
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6372
BOOLEAN kPosInLDependsOnLength(int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
Definition: kutil.cc:9806
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5232
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5728
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6407
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5501
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5299
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5685
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6483
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5143
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5628
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6577
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5986
@ ringorder_C
Definition: ring.h:73
@ ringorder_c
Definition: ring.h:72

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9908 of file kutil.cc.

9909{
9911 {
9912 if (strat->honey)
9913 {
9914 strat->posInL = posInL15Ring;
9915 // ok -- here is the deal: from my experiments for Singular-2-0
9916 // I conclude that that posInT_EcartpLength is the best of
9917 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
9918 // see the table at the end of this file
9919 if (TEST_OPT_OLDSTD)
9920 strat->posInT = posInT15Ring;
9921 else
9922 strat->posInT = posInT_EcartpLength;
9923 }
9924 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
9925 {
9926 strat->posInL = posInL11Ring;
9927 strat->posInT = posInT11;
9928 }
9929 else if (TEST_OPT_INTSTRATEGY)
9930 {
9931 strat->posInL = posInL11Ring;
9932 strat->posInT = posInT11;
9933 }
9934 else
9935 {
9936 strat->posInL = posInL0Ring;
9937 strat->posInT = posInT0;
9938 }
9939 //if (strat->minim>0) strat->posInL =posInLSpecial;
9940 if (strat->homog)
9941 {
9942 strat->posInL = posInL110Ring;
9943 strat->posInT = posInT110Ring;
9944 }
9945 }
9946 else
9947 {
9948 if (strat->homog)
9949 {
9950 //printf("\nHere 3\n");
9951 strat->posInL = posInL11Ring;
9952 strat->posInT = posInT11Ring;
9953 }
9954 else
9955 {
9956 if ((currRing->order[0]==ringorder_c)
9957 ||(currRing->order[0]==ringorder_C))
9958 {
9959 strat->posInL = posInL17_cRing;
9960 strat->posInT = posInT17_cRing;
9961 }
9962 else
9963 {
9964 strat->posInL = posInL11Ringls;
9965 strat->posInT = posInT17Ring;
9966 }
9967 }
9968 }
9969 if (strat->minim>0) strat->posInL =posInLSpecial;
9970 // for further tests only
9971 if ((BTEST1(11)) || (BTEST1(12)))
9972 strat->posInL = posInL11Ring;
9973 else if ((BTEST1(13)) || (BTEST1(14)))
9974 strat->posInL = posInL13;
9975 else if ((BTEST1(15)) || (BTEST1(16)))
9976 strat->posInL = posInL15Ring;
9977 else if ((BTEST1(17)) || (BTEST1(18)))
9978 strat->posInL = posInL17Ring;
9979 if (BTEST1(11))
9980 strat->posInT = posInT11Ring;
9981 else if (BTEST1(13))
9982 strat->posInT = posInT13;
9983 else if (BTEST1(15))
9984 strat->posInT = posInT15Ring;
9985 else if ((BTEST1(17)))
9986 strat->posInT = posInT17Ring;
9987 else if ((BTEST1(19)))
9988 strat->posInT = posInT19;
9989 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
9990 strat->posInT = posInT1;
9992}
int posInL17Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6527
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6641
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6028
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5185
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6325
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5754
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5026
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6098
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6442
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5353
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5455
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5562

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1333 of file kutil.cc.

1334{
1335 h->FDeg = h->pFDeg();
1336 (*h).ecart = 0;
1337 h->length=h->pLength=pLength(h->p);
1338}

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1325 of file kutil.cc.

1326{
1327 h->FDeg = h->pFDeg();
1328 h->ecart = h->pLDeg() - h->FDeg;
1329 // h->length is set by h->pLDeg
1330 h->length=h->pLength=pLength(h->p);
1331}

◆ initEcartPairBba()

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

Definition at line 1340 of file kutil.cc.

1341{
1342 Lp->FDeg = Lp->pFDeg();
1343 (*Lp).ecart = 0;
1344 (*Lp).length = 0;
1345}

◆ initEcartPairMora()

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

Definition at line 1347 of file kutil.cc.

1348{
1349 Lp->FDeg = Lp->pFDeg();
1350 (*Lp).ecart = si_max(ecartF,ecartG);
1351 (*Lp).ecart = (*Lp).ecart- (Lp->FDeg -p_FDeg((*Lp).lcm,currRing));
1352 (*Lp).length = 0;
1353}
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:380

◆ initenterpairs()

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

Definition at line 3840 of file kutil.cc.

3841{
3842
3843 if ((strat->syzComp==0)
3844 || (pGetComp(h)<=strat->syzComp))
3845 {
3846 int j;
3847 BOOLEAN new_pair=FALSE;
3848
3849 if (pGetComp(h)==0)
3850 {
3851 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3852 if ((isFromQ)&&(strat->fromQ!=NULL))
3853 {
3854 for (j=0; j<=k; j++)
3855 {
3856 if (!strat->fromQ[j])
3857 {
3858 new_pair=TRUE;
3859 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3860 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3861 }
3862 }
3863 }
3864 else
3865 {
3866 new_pair=TRUE;
3867 for (j=0; j<=k; j++)
3868 {
3869 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3870 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3871 }
3872 }
3873 }
3874 else
3875 {
3876 for (j=0; j<=k; j++)
3877 {
3878 if ((pGetComp(h)==pGetComp(strat->S[j]))
3879 || (pGetComp(strat->S[j])==0))
3880 {
3881 new_pair=TRUE;
3882 strat->enterOnePair(j,h,ecart,isFromQ,strat, atR);
3883 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3884 }
3885 }
3886 }
3887 if (new_pair)
3888 {
3889 #ifdef HAVE_RATGRING
3890 if (currRing->real_var_start>0)
3891 chainCritPart(h,ecart,strat);
3892 else
3893 #endif
3894 strat->chainCrit(h,ecart,strat);
3895 }
3896 kMergeBintoL(strat);
3897 }
3898}

◆ initHilbCrit()

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

Definition at line 9652 of file kutil.cc.

9653{
9654
9655 //if the ordering is local, then hilb criterion
9656 //can be used also if the ideal is not homogenous
9658 {
9660 *hilb=NULL;
9661 else
9662 return;
9663 }
9664 if (strat->homog!=isHomog)
9665 {
9666 *hilb=NULL;
9667 }
9668}
@ isHomog
Definition: structs.h:42

◆ initL()

static LSet initL ( int  nr = setmaxL)
inlinestatic

Definition at line 425 of file kutil.h.

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

◆ initR()

KINLINE TObject ** initR ( )

Definition at line 95 of file kInline.h.

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

◆ initS()

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

Definition at line 7829 of file kutil.cc.

7830{
7831 int i,pos;
7832
7834 else i=((IDELEMS(F)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc;
7835 strat->ecartS=initec(i);
7836 strat->sevS=initsevS(i);
7837 strat->S_2_R=initS_2_R(i);
7838 strat->fromQ=NULL;
7839 strat->Shdl=idInit(i,F->rank);
7840 strat->S=strat->Shdl->m;
7841 /*- put polys into S -*/
7842 if (Q!=NULL)
7843 {
7844 strat->fromQ=initec(i);
7845 memset(strat->fromQ,0,i*sizeof(int));
7846 for (i=0; i<IDELEMS(Q); i++)
7847 {
7848 if (Q->m[i]!=NULL)
7849 {
7850 LObject h;
7851 h.p = pCopy(Q->m[i]);
7853 {
7854 h.pCleardenom(); // also does remove Content
7855 }
7856 else
7857 {
7858 h.pNorm();
7859 }
7861 {
7862 deleteHC(&h, strat);
7863 }
7864 if (h.p!=NULL)
7865 {
7866 strat->initEcart(&h);
7867 if (strat->sl==-1)
7868 pos =0;
7869 else
7870 {
7871 pos = posInS(strat,strat->sl,h.p,h.ecart);
7872 }
7873 h.sev = pGetShortExpVector(h.p);
7874 strat->enterS(h,pos,strat,-1);
7875 strat->fromQ[pos]=1;
7876 }
7877 }
7878 }
7879 }
7880 for (i=0; i<IDELEMS(F); i++)
7881 {
7882 if (F->m[i]!=NULL)
7883 {
7884 LObject h;
7885 h.p = pCopy(F->m[i]);
7887 {
7888 cancelunit(&h); /*- tries to cancel a unit -*/
7889 deleteHC(&h, strat);
7890 }
7891 if (h.p!=NULL)
7892 // do not rely on the input being a SB!
7893 {
7895 {
7896 h.pCleardenom(); // also does remove Content
7897 }
7898 else
7899 {
7900 h.pNorm();
7901 }
7902 strat->initEcart(&h);
7903 if (strat->sl==-1)
7904 pos =0;
7905 else
7906 pos = posInS(strat,strat->sl,h.p,h.ecart);
7907 h.sev = pGetShortExpVector(h.p);
7908 strat->enterS(h,pos,strat,-1);
7909 }
7910 }
7911 }
7912 /*- test, if a unit is in F -*/
7913 if ((strat->sl>=0)
7914#ifdef HAVE_RINGS
7915 && n_IsUnit(pGetCoeff(strat->S[0]),currRing->cf)
7916#endif
7917 && pIsConstant(strat->S[0]))
7918 {
7919 while (strat->sl>0) deleteInS(strat->sl,strat);
7920 }
7921}
static intset initec(const int maxnr)
Definition: kutil.cc:510
static int * initS_2_R(const int maxnr)
Definition: kutil.cc:519
static unsigned long * initsevS(const int maxnr)
Definition: kutil.cc:515
#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 1728 of file kstd1.cc.

1729{
1730 int i;
1731 //idhdl h;
1732 /* setting global variables ------------------- */
1733 strat->enterS = enterSSba;
1734 strat->red2 = redHoney;
1735 if (strat->honey)
1736 strat->red2 = redHoney;
1737 else if (currRing->pLexOrder && !strat->homog)
1738 strat->red2 = redLazy;
1739 else
1740 {
1741 strat->LazyPass *=4;
1742 strat->red2 = redHomog;
1743 }
1745 {
1747 {strat->red2 = redRiloc;}
1748 else
1749 {strat->red2 = redRing;}
1750 }
1751 if (currRing->pLexOrder && strat->honey)
1752 strat->initEcart = initEcartNormal;
1753 else
1754 strat->initEcart = initEcartBBA;
1755 if (strat->honey)
1757 else
1759 //strat->kIdeal = NULL;
1760 //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
1761 //else strat->kIdeal->rtyp=MODUL_CMD;
1762 //strat->kIdeal->data=(void *)strat->Shdl;
1763 if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1764 {
1765 //interred machen Aenderung
1766 strat->pOrigFDeg = currRing->pFDeg;
1767 strat->pOrigLDeg = currRing->pLDeg;
1768 //h=ggetid("ecart");
1769 //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
1770 //{
1771 // ecartWeights=iv2array(IDINTVEC(h));
1772 //}
1773 //else
1774 {
1775 ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1776 /*uses automatic computation of the ecartWeights to set them*/
1778 }
1780 if (TEST_OPT_PROT)
1781 {
1782 for(i=1; i<=(currRing->N); i++)
1783 Print(" %d",ecartWeights[i]);
1784 PrintLn();
1785 mflush();
1786 }
1787 }
1788 // for sig-safe reductions in signature-based
1789 // standard basis computations
1791 strat->red = redSigRing;
1792 else
1793 strat->red = redSig;
1794 //strat->sbaOrder = 1;
1795 strat->currIdx = 1;
1796}
pFDegProc pOrigFDeg
Definition: kutil.h:297
pLDegProc pOrigLDeg
Definition: kutil.h:298
int redRiloc(LObject *h, kStrategy strat)
Definition: kstd1.cc:385
int redSigRing(LObject *h, kStrategy strat)
Definition: kstd2.cc:1317
int redSig(LObject *h, kStrategy strat)
Definition: kstd2.cc:1149
void enterSSba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9146
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3719
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 10207 of file kutil.cc.

10208{
10209 strat->interpt = BTEST1(OPT_INTERRUPT);
10210 strat->kHEdge=NULL;
10212 /*- creating temp data structures------------------- -*/
10213 strat->cp = 0;
10214 strat->c3 = 0;
10215 strat->tail = pInit();
10216 /*- set s -*/
10217 strat->sl = -1;
10218 /*- set ps -*/
10219 strat->syzl = -1;
10220 /*- set L -*/
10221 strat->Lmax = ((IDELEMS(F)+setmaxLinc-1)/setmaxLinc)*setmaxLinc;
10222 strat->Ll = -1;
10223 strat->L = initL(strat->Lmax);
10224 /*- set B -*/
10225 strat->Bmax = setmaxL;
10226 strat->Bl = -1;
10227 strat->B = initL();
10228 /*- set T -*/
10229 strat->tl = -1;
10230 strat->tmax = setmaxT;
10231 strat->T = initT();
10232 strat->R = initR();
10233 strat->sevT = initsevT();
10234 /*- init local data struct.---------------------------------------- -*/
10235 strat->P.ecart=0;
10236 strat->P.length=0;
10238 {
10239 if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
10240 if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
10241 }
10243 {
10244 /*Shdl=*/initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10245 }
10246 else
10247 {
10248 if(TEST_OPT_SB_1)
10249 {
10250 int i;
10251 ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
10252 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10253 {
10254 P->m[i-strat->newIdeal] = F->m[i];
10255 F->m[i] = NULL;
10256 }
10257 initSSpecialSba(F,Q,P,strat);
10258 for (i=strat->newIdeal;i<IDELEMS(F);i++)
10259 {
10260 F->m[i] = P->m[i-strat->newIdeal];
10261 P->m[i-strat->newIdeal] = NULL;
10262 }
10263 idDelete(&P);
10264 }
10265 else
10266 {
10267 initSLSba(F, Q,strat); /*sets also S, ecartS, fromQ */
10268 }
10269 }
10270 strat->fromT = FALSE;
10271 if (!TEST_OPT_SB_1)
10272 {
10273 if(!rField_is_Ring(currRing)) updateS(TRUE,strat);
10274 }
10275 //if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
10276 //strat->fromQ=NULL;
10277 assume(kTest_TS(strat));
10278}
void initSLSba(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:8020
void initSSpecialSba(ideal F, ideal Q, ideal P, kStrategy strat)
Definition: kutil.cc:8469

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9735 of file kutil.cc.

9736{
9737 //strat->enterOnePair=enterOnePairNormal;
9739 //strat->chainCrit=chainCritNormal;
9740 strat->chainCrit = chainCritSig;
9741 /******************************************
9742 * rewCrit1 and rewCrit2 are already set in
9743 * kSba() in kstd1.cc
9744 *****************************************/
9745 //strat->rewCrit1 = faugereRewCriterion;
9746 if (strat->sbaOrder == 1)
9747 {
9748 strat->syzCrit = syzCriterionInc;
9749 }
9750 else
9751 {
9752 strat->syzCrit = syzCriterion;
9753 }
9754#ifdef HAVE_RINGS
9756 {
9758 strat->chainCrit=chainCritRing;
9759 }
9760#endif
9761#ifdef HAVE_RATGRING
9762 if (rIsRatGRing(currRing))
9763 {
9764 strat->chainCrit=chainCritPart;
9765 /* enterOnePairNormal get rational part in it */
9766 }
9767#endif
9768
9770 strat->Gebauer = strat->homog || strat->sugarCrit;
9771 strat->honey = !strat->homog || strat->sugarCrit || TEST_OPT_WEIGHTM;
9772 if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE;
9773 strat->pairtest = NULL;
9774 /* alway use tailreduction, except:
9775 * - in local rings, - in lex order case, -in ring over extensions */
9778
9779#ifdef HAVE_PLURAL
9780 // and r is plural_ring
9781 // hence this holds for r a rational_plural_ring
9782 if( rIsPluralRing(currRing) || (rIsSCA(currRing) && !strat->z2homog) )
9783 { //or it has non-quasi-comm type... later
9784 strat->sugarCrit = FALSE;
9785 strat->Gebauer = FALSE;
9786 strat->honey = FALSE;
9787 }
9788#endif
9789
9790 // Coefficient ring?
9792 {
9793 strat->sugarCrit = FALSE;
9794 strat->Gebauer = FALSE ;
9795 strat->honey = FALSE;
9796 }
9797 #ifdef KDEBUG
9798 if (TEST_OPT_DEBUG)
9799 {
9800 if (strat->homog) PrintS("ideal/module is homogeneous\n");
9801 else PrintS("ideal/module is not homogeneous\n");
9802 }
9803 #endif
9804}
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.h:293
BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6743
void chainCritSig(poly p, int, kStrategy strat)
Definition: kutil.cc:3492
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition: kutil.cc:6708

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 10105 of file kutil.cc.

10106{
10108 {
10109 if (strat->honey)
10110 {
10111 strat->posInL = posInL15;
10112 // ok -- here is the deal: from my experiments for Singular-2-0
10113 // I conclude that that posInT_EcartpLength is the best of
10114 // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength
10115 // see the table at the end of this file
10116 if (TEST_OPT_OLDSTD)
10117 strat->posInT = posInT15;
10118 else
10119 strat->posInT = posInT_EcartpLength;
10120 }
10121 else if (currRing->pLexOrder && !TEST_OPT_INTSTRATEGY)
10122 {
10123 strat->posInL = posInL11;
10124 strat->posInT = posInT11;
10125 }
10126 else if (TEST_OPT_INTSTRATEGY)
10127 {
10128 strat->posInL = posInL11;
10129 strat->posInT = posInT11;
10130 }
10131 else
10132 {
10133 strat->posInL = posInL0;
10134 strat->posInT = posInT0;
10135 }
10136 //if (strat->minim>0) strat->posInL =posInLSpecial;
10137 if (strat->homog)
10138 {
10139 strat->posInL = posInL110;
10140 strat->posInT = posInT110;
10141 }
10142 }
10143 else
10144 {
10145 if (strat->homog)
10146 {
10147 strat->posInL = posInL11;
10148 strat->posInT = posInT11;
10149 }
10150 else
10151 {
10152 if ((currRing->order[0]==ringorder_c)
10153 ||(currRing->order[0]==ringorder_C))
10154 {
10155 strat->posInL = posInL17_c;
10156 strat->posInT = posInT17_c;
10157 }
10158 else
10159 {
10160 strat->posInL = posInL17;
10161 strat->posInT = posInT17;
10162 }
10163 }
10164 }
10165 if (strat->minim>0) strat->posInL =posInLSpecial;
10166 // for further tests only
10167 if ((BTEST1(11)) || (BTEST1(12)))
10168 strat->posInL = posInL11;
10169 else if ((BTEST1(13)) || (BTEST1(14)))
10170 strat->posInL = posInL13;
10171 else if ((BTEST1(15)) || (BTEST1(16)))
10172 strat->posInL = posInL15;
10173 else if ((BTEST1(17)) || (BTEST1(18)))
10174 strat->posInL = posInL17;
10175 if (BTEST1(11))
10176 strat->posInT = posInT11;
10177 else if (BTEST1(13))
10178 strat->posInT = posInT13;
10179 else if (BTEST1(15))
10180 strat->posInT = posInT15;
10181 else if ((BTEST1(17)))
10182 strat->posInT = posInT17;
10183 else if ((BTEST1(19)))
10184 strat->posInT = posInT19;
10185 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
10186 strat->posInT = posInT1;
10188 {
10189 strat->posInL = posInL11Ring;
10190 if(rHasLocalOrMixedOrdering(currRing) && currRing->pLexOrder == TRUE)
10191 strat->posInL = posInL11Ringls;
10192 strat->posInT = posInT11;
10193 }
10195 strat->posInLSba = posInLSig;
10196 //strat->posInL = posInLSig;
10197 strat->posInL = posInLF5C;
10198 /*
10199 if (rField_is_Ring(currRing))
10200 {
10201 strat->posInLSba = posInLSigRing;
10202 strat->posInL = posInL11Ring;
10203 }*/
10204 //strat->posInT = posInTSig;
10205}
int posInLSig(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5786
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition: kutil.cc:5974

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

7924{
7925 int i,pos;
7926
7928 else i=setmaxT;
7929 strat->ecartS=initec(i);
7930 strat->sevS=initsevS(i);
7931 strat->S_2_R=initS_2_R(i);
7932 strat->fromQ=NULL;
7933 strat->Shdl=idInit(i,F->rank);
7934 strat->S=strat->Shdl->m;
7935 /*- put polys into S -*/
7936 if (Q!=NULL)
7937 {
7938 strat->fromQ=initec(i);
7939 memset(strat->fromQ,0,i*sizeof(int));
7940 for (i=0; i<IDELEMS(Q); i++)
7941 {
7942 if (Q->m[i]!=NULL)
7943 {
7944 LObject h;
7945 h.p = pCopy(Q->m[i]);
7947 {
7948 deleteHC(&h,strat);
7949 }
7951 {
7952 h.pCleardenom(); // also does remove Content
7953 }
7954 else
7955 {
7956 h.pNorm();
7957 }
7958 if (h.p!=NULL)
7959 {
7960 strat->initEcart(&h);
7961 if (strat->sl==-1)
7962 pos =0;
7963 else
7964 {
7965 pos = posInS(strat,strat->sl,h.p,h.ecart);
7966 }
7967 h.sev = pGetShortExpVector(h.p);
7968 strat->enterS(h,pos,strat,-1);
7969 strat->fromQ[pos]=1;
7970 }
7971 }
7972 }
7973 }
7974 for (i=0; i<IDELEMS(F); i++)
7975 {
7976 if (F->m[i]!=NULL)
7977 {
7978 LObject h;
7979 h.p = pCopy(F->m[i]);
7980 if (h.p!=NULL)
7981 {
7983 {
7984 cancelunit(&h); /*- tries to cancel a unit -*/
7985 deleteHC(&h, strat);
7986 }
7987 if (h.p!=NULL)
7988 {
7990 {
7991 h.pCleardenom(); // also does remove Content
7992 }
7993 else
7994 {
7995 h.pNorm();
7996 }
7997 strat->initEcart(&h);
7998 if (strat->Ll==-1)
7999 pos =0;
8000 else
8001 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
8002 h.sev = pGetShortExpVector(h.p);
8003 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
8004 }
8005 }
8006 }
8007 }
8008 /*- test, if a unit is in F -*/
8009
8010 if ((strat->Ll>=0)
8011#ifdef HAVE_RINGS
8012 && n_IsUnit(pGetCoeff(strat->L[strat->Ll].p), currRing->cf)
8013#endif
8014 && pIsConstant(strat->L[strat->Ll].p))
8015 {
8016 while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat);
8017 }
8018}

◆ initSLSba()

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

Definition at line 8020 of file kutil.cc.

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

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 8170 of file kutil.cc.

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

◆ initT()

KINLINE TSet initT ( )

Definition at line 84 of file kInline.h.

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

◆ k_GetLeadTerms()

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

Definition at line 986 of file kInline.h.

988{
989 p_LmCheckPolyRing(p1, p_r);
990 p_LmCheckPolyRing(p2, p_r);
991
992 int i;
993 long x;
994 m1 = p_Init(m_r,m_r->PolyBin);
995 m2 = p_Init(m_r,m_r->PolyBin);
996
997 for (i = p_r->N; i; i--)
998 {
999 x = p_GetExpDiff(p1, p2, i, p_r);
1000 if (x > 0)
1001 {
1002 if (x > (long) m_r->bitmask) goto false_return;
1003 p_SetExp(m2,i,x, m_r);
1004 p_SetExp(m1,i,0, m_r);
1005 }
1006 else
1007 {
1008 if (-x > (long) m_r->bitmask) goto false_return;
1009 p_SetExp(m1,i,-x, m_r);
1010 p_SetExp(m2,i,0, m_r);
1011 }
1012 }
1013
1014 p_Setm(m1, m_r);
1015 p_Setm(m2, m_r);
1016 return TRUE;
1017
1018 false_return:
1019 p_LmFree(m1, m_r);
1020 p_LmFree(m2, m_r);
1021 m1 = m2 = NULL;
1022 return FALSE;
1023}
Variable x
Definition: cfModGcd.cc:4084
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:635
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:118
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1280

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

1031{
1032 p_LmCheckPolyRing(p1, leadRing);
1033 p_LmCheckPolyRing(p2, leadRing);
1034
1035 int i;
1036 int x;
1037 int e1;
1038 int e2;
1039 int s;
1040 m1 = p_Init(tailRing,tailRing->PolyBin);
1041 m2 = p_Init(tailRing,tailRing->PolyBin);
1042 lcm = p_Init(leadRing,leadRing->PolyBin);
1043
1044 for (i = leadRing->N; i>=0; i--)
1045 {
1046 e1 = p_GetExp(p1,i,leadRing);
1047 e2 = p_GetExp(p2,i,leadRing);
1048 x = e1 - e2;
1049 if (x > 0)
1050 {
1051 p_SetExp(m2,i,x, tailRing);
1052 //p_SetExp(m1,i,0, tailRing); // done by p_Init
1053 s = e1;
1054 }
1055 else if (x<0)
1056 {
1057 p_SetExp(m1,i,-x, tailRing);
1058 //p_SetExp(m2,i,0, tailRing); // done by p_Init
1059 s = e2;
1060 }
1061 else
1062 s = e1; // e1==e2
1063 p_SetExp(lcm,i,s, leadRing);
1064 }
1065
1066 p_Setm(m1, tailRing);
1067 p_Setm(m2, tailRing);
1068 p_Setm(lcm, leadRing);
1069}
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 959 of file kInline.h.

960{
961 return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
962}

◆ k_LmInit_currRing_2_tailRing() [2/2]

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

Definition at line 927 of file kInline.h.

928{
929
930 poly t_p = p_LmInit(p, currRing, tailRing, tailBin);
931 pNext(t_p) = pNext(p);
932 pSetCoeff0(t_p, pGetCoeff(p));
933 return t_p;
934}
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1295

◆ k_LmInit_tailRing_2_currRing() [1/2]

KINLINE poly k_LmInit_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 964 of file kInline.h.

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

◆ k_LmInit_tailRing_2_currRing() [2/2]

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

Definition at line 936 of file kInline.h.

937{
938 poly p = p_LmInit(t_p, tailRing, currRing, lmBin);
939 pNext(p) = pNext(t_p);
940 pSetCoeff0(p, pGetCoeff(t_p));
941 return p;
942}

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing ( poly  p,
ring  tailRing 
)

Definition at line 969 of file kInline.h.

970{
971 return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
972}
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:945

◆ k_LmShallowCopyDelete_currRing_2_tailRing() [2/2]

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

Definition at line 945 of file kInline.h.

946{
947 poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
949 return np;
950}

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [1/2]

KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing ( poly  p,
ring  tailRing 
)

Definition at line 974 of file kInline.h.

975{
976 return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
977}
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:952

◆ k_LmShallowCopyDelete_tailRing_2_currRing() [2/2]

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

Definition at line 952 of file kInline.h.

953{
954 poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
955 p_LmFree(p, tailRing);
956 return np;
957}

◆ kCheckSpolyCreation()

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

Definition at line 10718 of file kutil.cc.

10719{
10720 if (strat->overflow) return FALSE;
10721 assume(L->p1 != NULL && L->p2 != NULL);
10722 // shift changes: from 0 to -1
10723 assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
10724 assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
10725
10726 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
10727 return FALSE;
10728 // shift changes: extra case inserted
10729 if ((L->i_r1 == -1) || (L->i_r2 == -1) )
10730 {
10731 return TRUE;
10732 }
10733 poly p1_max=NULL;
10734 if ((L->i_r1>=0)&&(strat->R[L->i_r1]!=NULL)) p1_max = (strat->R[L->i_r1])->max_exp;
10735 poly p2_max=NULL;
10736 if ((L->i_r2>=0)&&(strat->R[L->i_r2]!=NULL)) p2_max = (strat->R[L->i_r2])->max_exp;
10737
10738 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10739 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10740 {
10741 p_LmFree(m1, strat->tailRing);
10742 p_LmFree(m2, strat->tailRing);
10743 m1 = NULL;
10744 m2 = NULL;
10745 return FALSE;
10746 }
10747 return TRUE;
10748}
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:986
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition: p_polys.h:2007

◆ kCheckStrongCreation()

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

Definition at line 10757 of file kutil.cc.

10758{
10759 assume(strat->S_2_R[atS] >= -1 && strat->S_2_R[atS] <= strat->tl);
10760 //assume(strat->tailRing != currRing);
10761
10762 poly p1_max = (strat->R[atR])->max_exp;
10763 poly p2_max = (strat->R[strat->S_2_R[atS]])->max_exp;
10764
10765 if (((p1_max != NULL) && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
10766 ((p2_max != NULL) && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing)))
10767 {
10768 return FALSE;
10769 }
10770 return TRUE;
10771}

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11753 of file kutil.cc.

11754{
11755 PrintS("red: ");
11756 if (strat->red==redFirst) PrintS("redFirst\n");
11757 else if (strat->red==redHoney) PrintS("redHoney\n");
11758 else if (strat->red==redEcart) PrintS("redEcart\n");
11759 else if (strat->red==redHomog) PrintS("redHomog\n");
11760 else if (strat->red==redLazy) PrintS("redLazy\n");
11761 else if (strat->red==redLiftstd) PrintS("redLiftstd\n");
11762 else Print("%p\n",(void*)strat->red);
11763 PrintS("posInT: ");
11764 if (strat->posInT==posInT0) PrintS("posInT0\n");
11765 else if (strat->posInT==posInT1) PrintS("posInT1\n");
11766 else if (strat->posInT==posInT11) PrintS("posInT11\n");
11767 else if (strat->posInT==posInT110) PrintS("posInT110\n");
11768 else if (strat->posInT==posInT13) PrintS("posInT13\n");
11769 else if (strat->posInT==posInT15) PrintS("posInT15\n");
11770 else if (strat->posInT==posInT17) PrintS("posInT17\n");
11771 else if (strat->posInT==posInT17_c) PrintS("posInT17_c\n");
11772 else if (strat->posInT==posInT19) PrintS("posInT19\n");
11773 else if (strat->posInT==posInT2) PrintS("posInT2\n");
11774 #ifdef HAVE_RINGS
11775 else if (strat->posInT==posInT11Ring) PrintS("posInT11Ring\n");
11776 else if (strat->posInT==posInT110Ring) PrintS("posInT110Ring\n");
11777 else if (strat->posInT==posInT15Ring) PrintS("posInT15Ring\n");
11778 else if (strat->posInT==posInT17Ring) PrintS("posInT17Ring\n");
11779 else if (strat->posInT==posInT17_cRing) PrintS("posInT17_cRing\n");
11780 #endif
11781#ifdef HAVE_MORE_POS_IN_T
11782 else if (strat->posInT==posInT_EcartFDegpLength) PrintS("posInT_EcartFDegpLength\n");
11783 else if (strat->posInT==posInT_FDegpLength) PrintS("posInT_FDegpLength\n");
11784 else if (strat->posInT==posInT_pLength) PrintS("posInT_pLength\n");
11785#endif
11786 else if (strat->posInT==posInT_EcartpLength) PrintS("posInT_EcartpLength\n");
11787 else if (strat->posInT==posInTrg0) PrintS("posInTrg0\n");
11788 else Print("%p\n",(void*)strat->posInT);
11789 PrintS("posInL: ");
11790 if (strat->posInL==posInL0) PrintS("posInL0\n");
11791 else if (strat->posInL==posInL10) PrintS("posInL10\n");
11792 else if (strat->posInL==posInL11) PrintS("posInL11\n");
11793 else if (strat->posInL==posInL110) PrintS("posInL110\n");
11794 else if (strat->posInL==posInL13) PrintS("posInL13\n");
11795 else if (strat->posInL==posInL15) PrintS("posInL15\n");
11796 else if (strat->posInL==posInL17) PrintS("posInL17\n");
11797 else if (strat->posInL==posInL17_c) PrintS("posInL17_c\n");
11798 #ifdef HAVE_RINGS
11799 else if (strat->posInL==posInL0) PrintS("posInL0Ring\n");
11800 else if (strat->posInL==posInL11Ring) PrintS("posInL11Ring\n");
11801 else if (strat->posInL==posInL11Ringls) PrintS("posInL11Ringls\n");
11802 else if (strat->posInL==posInL110Ring) PrintS("posInL110Ring\n");
11803 else if (strat->posInL==posInL15Ring) PrintS("posInL15Ring\n");
11804 else if (strat->posInL==posInL17Ring) PrintS("posInL17Ring\n");
11805 else if (strat->posInL==posInL17_cRing) PrintS("posInL17_cRing\n");
11806 #endif
11807 else if (strat->posInL==posInLSpecial) PrintS("posInLSpecial\n");
11808 else if (strat->posInL==posInLrg0) PrintS("posInLrg0\n");
11809 else Print("%p\n",(void*)strat->posInL);
11810 PrintS("enterS: ");
11811 if (strat->enterS==enterSBba) PrintS("enterSBba\n");
11812 else if (strat->enterS==enterSMora) PrintS("enterSMora\n");
11813 else if (strat->enterS==enterSMoraNF) PrintS("enterSMoraNF\n");
11814 else Print("%p\n",(void*)strat->enterS);
11815 PrintS("initEcart: ");
11816 if (strat->initEcart==initEcartBBA) PrintS("initEcartBBA\n");
11817 else if (strat->initEcart==initEcartNormal) PrintS("initEcartNormal\n");
11818 else Print("%p\n",(void*)strat->initEcart);
11819 PrintS("initEcartPair: ");
11820 if (strat->initEcartPair==initEcartPairBba) PrintS("initEcartPairBba\n");
11821 else if (strat->initEcartPair==initEcartPairMora) PrintS("initEcartPairMora\n");
11822 else Print("%p\n",(void*)strat->initEcartPair);
11823 Print("homog=%d, LazyDegree=%d, LazyPass=%d, ak=%d,\n",
11824 strat->homog, strat->LazyDegree,strat->LazyPass, strat->ak);
11825 Print("honey=%d, sugarCrit=%d, Gebauer=%d, noTailReduction=%d, use_buckets=%d\n",
11826 strat->honey,strat->sugarCrit,strat->Gebauer,strat->noTailReduction,strat->use_buckets);
11827 PrintS("chainCrit: ");
11828 if (strat->chainCrit==chainCritNormal) PrintS("chainCritNormal\n");
11829 else if (strat->chainCrit==chainCritOpt_1) PrintS("chainCritOpt_1\n");
11830 else Print("%p\n",(void*)strat->chainCrit);
11831 Print("posInLDependsOnLength=%d\n",
11832 strat->posInLDependsOnLength);
11834 PrintS("LDeg: ");
11835 if (currRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11836 else if (currRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11837 else if (currRing->pLDeg==pLDegb) PrintS("pLDegb");
11838 else if (currRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11839 else if (currRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11840 else if (currRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11841 else if (currRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11842 else if (currRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11843 else if (currRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11844 else if (currRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11845 else if (currRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11846 else if (currRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11847 else Print("? (%lx)", (long)currRing->pLDeg);
11848 PrintS(" / ");
11849 if (strat->tailRing->pLDeg==pLDeg0) PrintS("pLDeg0");
11850 else if (strat->tailRing->pLDeg==pLDeg0c) PrintS("pLDeg0c");
11851 else if (strat->tailRing->pLDeg==pLDegb) PrintS("pLDegb");
11852 else if (strat->tailRing->pLDeg==pLDeg1) PrintS("pLDeg1");
11853 else if (strat->tailRing->pLDeg==pLDeg1c) PrintS("pLDeg1c");
11854 else if (strat->tailRing->pLDeg==pLDeg1_Deg) PrintS("pLDeg1_Deg");
11855 else if (strat->tailRing->pLDeg==pLDeg1c_Deg) PrintS("pLDeg1c_Deg");
11856 else if (strat->tailRing->pLDeg==pLDeg1_Totaldegree) PrintS("pLDeg1_Totaldegree");
11857 else if (strat->tailRing->pLDeg==pLDeg1c_Totaldegree) PrintS("pLDeg1c_Totaldegree");
11858 else if (strat->tailRing->pLDeg==pLDeg1_WFirstTotalDegree) PrintS("pLDeg1_WFirstTotalDegree");
11859 else if (strat->tailRing->pLDeg==pLDeg1c_WFirstTotalDegree) PrintS("pLDeg1c_WFirstTotalDegree");
11860 else if (strat->tailRing->pLDeg==maxdegreeWecart) PrintS("maxdegreeWecart");
11861 else Print("? (%lx)", (long)strat->tailRing->pLDeg);
11862 PrintLn();
11863 PrintS("currRing->pFDeg: ");
11864 if (currRing->pFDeg==p_Totaldegree) PrintS("p_Totaldegree");
11865 else if (currRing->pFDeg==p_WFirstTotalDegree) PrintS("pWFirstTotalDegree");
11866 else if (currRing->pFDeg==p_Deg) PrintS("p_Deg");
11867 else if (currRing->pFDeg==kHomModDeg) PrintS("kHomModDeg");
11868 else if (currRing->pFDeg==totaldegreeWecart) PrintS("totaldegreeWecart");
11869 else if (currRing->pFDeg==p_WTotaldegree) PrintS("p_WTotaldegree");
11870 else Print("? (%lx)", (long)currRing->pFDeg);
11871 PrintLn();
11872 Print(" syzring:%d, syzComp(strat):%d limit:%d\n",rIsSyzIndexRing(currRing),strat->syzComp,rGetCurrSyzLimit(currRing));
11874 Print(" degBound: %d\n", Kstd1_deg);
11875
11876 if( ecartWeights != NULL )
11877 {
11878 PrintS("ecartWeights: ");
11879 for (int i = rVar(currRing); i > 0; i--)
11880 Print("%hd ", ecartWeights[i]);
11881 PrintLn();
11883 }
11884
11885#ifndef SING_NDEBUG
11887#endif
11888}
int LazyDegree
Definition: kutil.h:356
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition: kstd1.cc:1342
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2417
int posInTrg0(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5067
int redFirst(LObject *h, kStrategy strat)
Definition: kstd1.cc:786
int redEcart(LObject *h, kStrategy strat)
Definition: kstd1.cc:169
void enterSMoraNF(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1660
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4962
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11719
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11628
VAR int Kstd1_deg
Definition: kutil.cc:247
int posInLrg0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:6200
void enterSMora(LObject &p, int atS, kStrategy strat, int atR=-1)
Definition: kstd1.cc:1606
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11682
char * showOption()
Definition: misc_ip.cc:717
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:806
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:970
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:591
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1033
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1063
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:936
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:836
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:905
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:608
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:872
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1000
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:765
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:734
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1467
void rDebugPrint(const ring r)
Definition: ring.cc:4072
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:725

◆ kDeleteLcm()

static void kDeleteLcm ( LObject P)
inlinestatic

Definition at line 877 of file kutil.h.

878{
879 if (P->lcm!=NULL)
880 {
881 #ifdef HAVE_RINGS
883 pLmDelete(P->lcm);
884 else
885 #endif
886 pLmFree(P->lcm);
887 P->lcm=NULL;
888 }
889}

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

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6927 of file kutil.cc.

6928{
6929 int j = 0;
6930 const unsigned long not_sev = ~L->sev;
6931 const unsigned long* sev = strat->sevS;
6932 poly p;
6933 ring r;
6934 L->GetLm(p, r);
6935
6936 assume(~not_sev == p_GetShortExpVector(p, r));
6937
6938 if (r == currRing)
6939 {
6940 if(!rField_is_Ring(r))
6941 {
6942 loop
6943 {
6944 if (j > end_pos) return NULL;
6945 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6946 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6947 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
6948 {
6949 break;
6950 }
6951 #else
6952 if (!(sev[j] & not_sev) &&
6953 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
6954 p_LmDivisibleBy(strat->S[j], p, r))
6955 {
6956 break;
6957 }
6958 #endif
6959 j++;
6960 }
6961 }
6962 #ifdef HAVE_RINGS
6963 else
6964 {
6965 loop
6966 {
6967 if (j > end_pos) return NULL;
6968 #if defined(PDEBUG) || defined(PDIV_DEBUG)
6969 if (strat->S[j]!= NULL && p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
6970 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6971 {
6972 break;
6973 }
6974 #else
6975 if (!(sev[j] & not_sev) &&
6976 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
6977 p_LmDivisibleBy(strat->S[j], p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), r->cf))
6978 {
6979 break;
6980 }
6981 #endif
6982 j++;
6983 }
6984 }
6985 #endif
6986 // if called from NF, T objects do not exist:
6987 if (strat->tl < 0 || strat->S_2_R[j] == -1)
6988 {
6989 T->Set(strat->S[j], r, strat->tailRing);
6990 assume(T->GetpLength()==pLength(T->p != __null ? T->p : T->t_p));
6991 return T;
6992 }
6993 else
6994 {
6995///// assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL
6996///// && strat->S_2_T(j)->p == strat->S[j]); // wrong?
6997// assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]);
6998 return strat->S_2_T(j);
6999 }
7000 }
7001 else
7002 {
7003 TObject* t;
7004 if(!rField_is_Ring(r))
7005 {
7006 loop
7007 {
7008 if (j > end_pos) return NULL;
7009 assume(strat->S_2_R[j] != -1);
7010 #if defined(PDEBUG) || defined(PDIV_DEBUG)
7011 t = strat->S_2_T(j);
7012 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7013 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7014 (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7015 {
7016 t->pLength=pLength(t->t_p);
7017 return t;
7018 }
7019 #else
7020 if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7021 {
7022 t = strat->S_2_T(j);
7023 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7024 if (p_LmDivisibleBy(t->t_p, p, r))
7025 {
7026 t->pLength=pLength(t->t_p);
7027 return t;
7028 }
7029 }
7030 #endif
7031 j++;
7032 }
7033 }
7034 #ifdef HAVE_RINGS
7035 else
7036 {
7037 loop
7038 {
7039 if (j > end_pos) return NULL;
7040 assume(strat->S_2_R[j] != -1);
7041 #if defined(PDEBUG) || defined(PDIV_DEBUG)
7042 t = strat->S_2_T(j);
7043 assume(t != NULL && t->t_p != NULL && t->tailRing == r);
7044 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
7045 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7046 {
7047 t->pLength=pLength(t->t_p);
7048 return t;
7049 }
7050 #else
7051 if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
7052 {
7053 t = strat->S_2_T(j);
7054 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]);
7055 if (p_LmDivisibleBy(t->t_p, p, r) && n_DivBy(pGetCoeff(p), pGetCoeff(t->t_p), r->cf))
7056 {
7057 t->pLength=pLength(t->t_p);
7058 return t;
7059 }
7060 }
7061 #endif
7062 j++;
7063 }
7064 }
7065 #endif
7066 }
7067}
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 288 of file kstd2.cc.

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

◆ kFindDivisibleByInT_Z()

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

Definition at line 207 of file kstd2.cc.

208{
209 unsigned long not_sev = ~L->sev;
210 int j = start;
211 int o = -1;
212
213 const TSet T=strat->T;
214 const unsigned long* sevT=strat->sevT;
215 number rest, orest, mult;
216 if (L->p!=NULL)
217 {
218 const ring r=currRing;
219 const poly p=L->p;
220 orest = pGetCoeff(p);
221
222 pAssume(~not_sev == p_GetShortExpVector(p, r));
223
224 loop
225 {
226 if (j > strat->tl) return o;
227#if defined(PDEBUG) || defined(PDIV_DEBUG)
228 if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r))
229 {
230 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
231 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
232 {
233 o = j;
234 orest = rest;
235 }
236 }
237#else
238 if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].p, p, r))
239 {
240 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
241 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
242 {
243 o = j;
244 orest = rest;
245 }
246 }
247#endif
248 j++;
249 }
250 }
251 else
252 {
253 const ring r=strat->tailRing;
254 const poly p=L->t_p;
255 orest = pGetCoeff(p);
256 loop
257 {
258 if (j > strat->tl) return o;
259#if defined(PDEBUG) || defined(PDIV_DEBUG)
260 if (p_LmShortDivisibleBy(T[j].t_p, sevT[j],
261 p, not_sev, r))
262 {
263 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf);
264 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
265 {
266 o = j;
267 orest = rest;
268 }
269 }
270#else
271 if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].t_p, p, r))
272 {
273 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf);
274 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
275 {
276 o = j;
277 orest = rest;
278 }
279 }
280#endif
281 j++;
282 }
283 }
284}
void mult(CFList &L1, const CFList &L2)
multiply two lists componentwise
Definition: cfModGcd.cc:2178
static FORCE_INLINE number n_EucNorm(number a, const coeffs r)
Definition: coeffs.h:698
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:704
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:512
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465

◆ kFindInT()

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

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

Definition at line 718 of file kutil.cc.

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

◆ kFindInTShift()

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

Definition at line 743 of file kutil.cc.

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

◆ kFindNextDivisibleByInS()

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

Definition at line 467 of file kstd2.cc.

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

◆ kFindSameLMInT_Z()

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

Definition at line 84 of file kstd2.cc.

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

◆ kFindZeroPoly()

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

Definition at line 553 of file kstd2.cc.

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

◆ kFreeStrat()

void kFreeStrat ( kStrategy  strat)

◆ kNF2() [1/2]

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

Definition at line 3857 of file kstd2.cc.

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

◆ kNF2() [2/2]

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

Definition at line 3701 of file kstd2.cc.

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

◆ kNF2Bound() [1/2]

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

Definition at line 3945 of file kstd2.cc.

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

◆ kNF2Bound() [2/2]

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

Definition at line 3783 of file kstd2.cc.

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

◆ ksCreateShortSpoly()

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

Definition at line 1415 of file kspoly.cc.

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

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

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

◆ ksOldCreateSpoly()

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

Definition at line 1162 of file kInline.h.

1163{
1164 LObject L(r);
1165 L.p1 = p1;
1166 L.p2 = p2;
1167
1168 ksCreateSpoly(&L, spNoether);
1169 return L.GetLmCurrRing();
1170}

◆ ksOldSpolyRed()

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

Definition at line 1142 of file kInline.h.

1143{
1144 LObject L(p2);
1145 TObject T(p1);
1146
1147 ksReducePoly(&L, &T, spNoether);
1148
1149 return L.GetLmCurrRing();
1150}
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat)
Definition: kspoly.cc:185

◆ ksOldSpolyRedNew()

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

Definition at line 1152 of file kInline.h.

1153{
1154 LObject L(p_Copy(p2, currRing));
1155 TObject T(p1);
1156
1157 ksReducePoly(&L, &T, spNoether);
1158
1159 return L.GetLmCurrRing();
1160}

◆ ksOldSpolyTail()

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

Definition at line 1172 of file kInline.h.

1173{
1174 LObject L(q, currRing, r);
1175 TObject T(p1, currRing, r);
1176
1177 ksReducePolyTail(&L, &T, q2, spNoether);
1178}
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1115

◆ ksReducePoly()

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

Definition at line 185 of file kspoly.cc.

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

◆ ksReducePolyBound()

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

Definition at line 563 of file kspoly.cc.

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

◆ ksReducePolyGCD()

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

Definition at line 316 of file kspoly.cc.

321{
322#ifdef KDEBUG
323 red_count++;
324#ifdef TEST_OPT_DEBUG_RED
325// if (TEST_OPT_DEBUG)
326// {
327// Print("Red %d:", red_count); PR->wrp(); Print(" with:");
328// PW->wrp();
329// //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart);
330// //pWrite(PR->p);
331// }
332#endif
333#endif
334 int ret = 0;
335 ring tailRing = PR->tailRing;
336 kTest_L(PR, tailRing);
337 kTest_T(PW);
338
339 poly p1 = PR->GetLmTailRing();
340 poly p2 = PW->GetLmTailRing();
341 poly t2 = pNext(p2), lm = pOne();
342 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
343 p_CheckPolyRing(p1, tailRing);
344 p_CheckPolyRing(p2, tailRing);
345
346 pAssume1(p2 != NULL && p1 != NULL &&
347 p_DivisibleBy(p2, p1, tailRing));
348
349 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
350 (p_GetComp(p2, tailRing) == 0 &&
351 p_MaxComp(pNext(p2),tailRing) == 0));
352
353#ifdef HAVE_PLURAL
355 {
356 // for the time being: we know currRing==strat->tailRing
357 // no exp-bound checking needed
358 // (only needed if exp-bound(tailring)<exp-b(currRing))
359 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef);
360 else
361 {
362 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
363 assume(_p != NULL);
364 nc_PolyPolyRed(_p, p2,coef, currRing);
365 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
366 PR->pLength=0; // usually not used, GetpLength re-computes it if needed
367 }
368 return 0;
369 }
370#endif
371 // check that reduction does not violate exp bound
372 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing))
373 {
374 // undo changes of lm
375 p_ExpVectorAdd(lm, p2, tailRing);
376 if (strat == NULL) return 2;
377 if (! kStratChangeTailRing(strat, PR, PW)) return -1;
378 tailRing = strat->tailRing;
379 p1 = PR->GetLmTailRing();
380 p2 = PW->GetLmTailRing();
381 t2 = pNext(p2);
382 lm = p1;
383 p_ExpVectorSub(lm, p2, tailRing);
384 ret = 1;
385 }
386
387#ifdef HAVE_SHIFTBBA
388 poly lmRight;
389 if (tailRing->isLPring)
390 {
391 assume(PR->shift == 0);
392 assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
393 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
394 }
395#endif
396
397 number ct, an, bn;
398 // take care of coef buisness
399 if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
400 {
401 ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing->cf); // Calculate GCD
402#ifdef HAVE_SHIFTBBA
403 if(rIsLPRing(tailRing)) /* with this test: error at New/stdZtests.tst, infinite : Long/primdecint.tst */
404 {
405 if (n_IsZero(an, tailRing->cf) || n_IsZero(bn, tailRing->cf))
406 {
407 // NOTE: not sure why this is not checked in the commutative case, this *does* happen and then zero coeff errors are reported
408 // NOTE: we are probably leaking memory of lm=pOne(), but we cannot delete it since it could also be lm=p1
409 n_Delete(&an, tailRing->cf);
410 n_Delete(&bn, tailRing->cf);
411 n_Delete(&ct, tailRing->cf);
412 return ret;
413 }
414 }
415#endif
416 /* negate bn since we subtract in Tail_Minus_mm_Mult_qq */
417 bn = n_InpNeg(bn, tailRing->cf);
418 p_SetCoeff(lm, bn, tailRing);
419 PR->Tail_Mult_nn(an);
420 }
421 else
422 {
423 if (coef != NULL) *coef = n_Init(1, tailRing->cf);
424 }
425
426
427 // and finally,
428#ifdef HAVE_SHIFTBBA
429 if (tailRing->isLPring)
430 {
431 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
432 }
433 else
434#endif
435 {
436 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
437 }
438 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
439 pSetCoeff(PR->p, ct);
440
441 return ret;
442}
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 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:694

◆ ksReducePolyLC()

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

Definition at line 452 of file kspoly.cc.

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

◆ ksReducePolySig()

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

Definition at line 707 of file kspoly.cc.

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

◆ ksReducePolySigRing()

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

Definition at line 910 of file kspoly.cc.

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

1116{
1117 BOOLEAN ret;
1118 number coef;
1119
1120 assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1121 Red->HeadNormalize();
1122 ret = ksReducePoly(Red, PW, NULL, &coef);
1123
1124 if (!ret)
1125 {
1126 if (! n_IsOne(coef, currRing->cf))
1127 {
1128 PR->Mult_nn(coef);
1129 // HANNES: mark for Normalize
1130 }
1131 n_Delete(&coef, currRing->cf);
1132 }
1133 return ret;
1134}

◆ ksReducePolyTail() [2/2]

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

Definition at line 1315 of file kspoly.cc.

1316{
1317 BOOLEAN ret;
1318 number coef;
1319 poly Lp = PR->GetLmCurrRing();
1320 poly Save = PW->GetLmCurrRing();
1321
1322 kTest_L(PR,PR->tailRing);
1323 kTest_T(PW);
1324 pAssume(pIsMonomOf(Lp, Current));
1325
1326 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL);
1327 assume(PR->bucket == NULL);
1328
1329 LObject Red(pNext(Current), PR->tailRing);
1330 TObject With(PW, Lp == Save);
1331
1332 pAssume(!pHaveCommonMonoms(Red.p, With.p));
1333 ret = ksReducePoly(&Red, &With, spNoether, &coef);
1334
1335 if (!ret)
1336 {
1337 if (! n_IsOne(coef, currRing->cf))
1338 {
1339 pNext(Current) = NULL;
1340 if (Current == PR->p && PR->t_p != NULL)
1341 pNext(PR->t_p) = NULL;
1342 PR->Mult_nn(coef);
1343 }
1344
1345 n_Delete(&coef, currRing->cf);
1346 pNext(Current) = Red.GetLmTailRing();
1347 if (Current == PR->p && PR->t_p != NULL)
1348 pNext(PR->t_p) = pNext(Current);
1349 }
1350
1351 if (Lp == Save)
1352 With.Delete();
1353
1354 return ret;
1355}
BOOLEAN pIsMonomOf(poly p, poly m)
Definition: pDebug.cc:163
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition: pDebug.cc:173

◆ ksReducePolyZ()

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

Definition at line 44 of file kspoly.cc.

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

◆ kStratChangeTailRing()

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

Definition at line 11205 of file kutil.cc.

11206{
11207 assume((strat->tailRing == currRing) || (strat->tailRing->bitmask <= currRing->bitmask));
11208 /* initial setup or extending */
11209
11210 if (rIsLPRing(currRing)) return TRUE;
11211 if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
11212 if (expbound >= currRing->bitmask) return FALSE;
11213 strat->overflow=FALSE;
11214 ring new_tailRing = rModifyRing(currRing,
11215 // Hmmm .. the condition pFDeg == p_Deg
11216 // might be too strong
11217 (strat->homog && currRing->pFDeg == p_Deg && !(rField_is_Ring(currRing))), // omit degree
11218 (strat->ak==0), // omit_comp if the input is an ideal
11219 expbound); // exp_limit
11220
11221 if (new_tailRing == currRing) return TRUE;
11222
11223 strat->pOrigFDeg_TailRing = new_tailRing->pFDeg;
11224 strat->pOrigLDeg_TailRing = new_tailRing->pLDeg;
11225
11226 if (currRing->pFDeg != currRing->pFDegOrig)
11227 {
11228 new_tailRing->pFDeg = currRing->pFDeg;
11229 new_tailRing->pLDeg = currRing->pLDeg;
11230 }
11231
11232 if (TEST_OPT_PROT)
11233 Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size);
11234 kTest_TS(strat);
11235 assume(new_tailRing != strat->tailRing);
11236 pShallowCopyDeleteProc p_shallow_copy_delete
11237 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
11238
11239 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
11240
11241 int i;
11242 for (i=0; i<=strat->tl; i++)
11243 {
11244 strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin,
11245 p_shallow_copy_delete);
11246 }
11247 for (i=0; i<=strat->Ll; i++)
11248 {
11249 assume(strat->L[i].p != NULL);
11250 if (pNext(strat->L[i].p) != strat->tail)
11251 strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11252 }
11253 if ((strat->P.t_p != NULL) ||
11254 ((strat->P.p != NULL) && pNext(strat->P.p) != strat->tail))
11255 strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11256
11257 if ((L != NULL) && (L->tailRing != new_tailRing))
11258 {
11259 if (L->i_r < 0)
11260 L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete);
11261 else
11262 {
11263 assume(L->i_r <= strat->tl);
11264 TObject* t_l = strat->R[L->i_r];
11265 assume(t_l != NULL);
11266 L->tailRing = new_tailRing;
11267 L->p = t_l->p;
11268 L->t_p = t_l->t_p;
11269 L->max_exp = t_l->max_exp;
11270 }
11271 }
11272
11273 if ((T != NULL) && (T->tailRing != new_tailRing && T->i_r < 0))
11274 T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete);
11275
11276 omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin);
11277 if (strat->tailRing != currRing)
11279
11280 strat->tailRing = new_tailRing;
11281 strat->tailBin = new_tailBin;
11283 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11284
11285 if (strat->kHEdge != NULL)
11286 {
11287 if (strat->t_kHEdge != NULL)
11288 p_LmFree(strat->t_kHEdge, strat->tailRing);
11289 strat->t_kHEdge=k_LmInit_currRing_2_tailRing(strat->kHEdge, new_tailRing);
11290 }
11291
11292 if (strat->kNoether != NULL)
11293 {
11294 if (strat->t_kNoether != NULL)
11295 p_LmFree(strat->t_kNoether, strat->tailRing);
11297 new_tailRing);
11298 }
11299 kTest_TS(strat);
11300 if (TEST_OPT_PROT)
11301 PrintS("]");
11302 return TRUE;
11303}
poly t_kNoether
Definition: kutil.h:334
pFDegProc pOrigFDeg_TailRing
Definition: kutil.h:299
poly t_kHEdge
Definition: kutil.h:332
pLDegProc pOrigLDeg_TailRing
Definition: kutil.h:300
omBin_t * omBin
Definition: omStructs.h:12
void rKillModifiedRing(ring r)
Definition: ring.cc:3004
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2643
#define omGetStickyBinOfBin(B)
Definition: xalloc.h:294
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:323

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11305 of file kutil.cc.

11306{
11307 unsigned long l = 0;
11308 int i;
11309 long e;
11310
11311 assume(strat->tailRing == currRing);
11312
11313 for (i=0; i<= strat->Ll; i++)
11314 {
11315 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11316 }
11317 for (i=0; i<=strat->tl; i++)
11318 {
11319 // Hmm ... this we could do in one Step
11320 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11321 }
11323 {
11324 l *= 2;
11325 }
11326 e = p_GetMaxExp(l, currRing);
11327 if (e <= 1) e = 2;
11328 if (rIsLPRing(currRing)) e = 1;
11329
11330 kStratChangeTailRing(strat, NULL, NULL, e);
11331}
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:1170
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:747

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1010 of file kutil.cc.

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

◆ kTest_L()

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

Definition at line 925 of file kutil.cc.

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1053 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 801 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1071 of file kutil.cc.

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

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

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

◆ message()

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

Definition at line 7706 of file kutil.cc.

7707{
7708 if (i != *olddeg)
7709 {
7710 Print("%d",i);
7711 *olddeg = i;
7712 }
7713 if (TEST_OPT_OLDSTD)
7714 {
7715 if (strat->Ll != *reduc)
7716 {
7717 if (strat->Ll != *reduc-1)
7718 Print("(%d)",strat->Ll+1);
7719 else
7720 PrintS("-");
7721 *reduc = strat->Ll;
7722 }
7723 else
7724 PrintS(".");
7725 mflush();
7726 }
7727 else
7728 {
7729 if (red_result == 0)
7730 PrintS("-");
7731 else if (red_result < 0)
7732 PrintS(".");
7733 if ((red_result > 0) || ((strat->Ll % 100)==99))
7734 {
7735 if (strat->Ll != *reduc && strat->Ll > 0)
7736 {
7737 Print("(%d)",strat->Ll+1);
7738 *reduc = strat->Ll;
7739 }
7740 }
7741 }
7742}

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7779 of file kutil.cc.

7780{
7781 int i;
7782 if (strat->news)
7783 {
7784 PrintS("set S");
7785 for (i=0; i<=strat->sl; i++)
7786 {
7787 Print("\n %d:",i);
7788 p_wrp(strat->S[i], currRing, strat->tailRing);
7789 if (strat->fromQ!=NULL && strat->fromQ[i])
7790 Print(" (from Q)");
7791 }
7792 strat->news = FALSE;
7793 }
7794 if (strat->newt)
7795 {
7796 PrintS("\nset T");
7797 for (i=0; i<=strat->tl; i++)
7798 {
7799 Print("\n %d:",i);
7800 strat->T[i].wrp();
7801 if (strat->T[i].length==0) strat->T[i].length=pLength(strat->T[i].p);
7802 Print(" o:%ld e:%d l:%d",
7803 strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length);
7804 }
7805 strat->newt = FALSE;
7806 }
7807 PrintS("\nset L");
7808 for (i=strat->Ll; i>=0; i--)
7809 {
7810 Print("\n%d:",i);
7811 p_wrp(strat->L[i].p1, currRing, strat->tailRing);
7812 PrintS(" ");
7813 p_wrp(strat->L[i].p2, currRing, strat->tailRing);
7814 PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing);
7815 PrintS("\n p : ");
7816 strat->L[i].wrp();
7817 Print(" o:%ld e:%d l:%d",
7818 strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length);
7819 }
7820 PrintLn();
7821}

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7747 of file kutil.cc.

7748{
7749 //PrintS("\nUsage/Allocation of temporary storage:\n");
7750 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7751 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7752 Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7753 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7754 #ifdef HAVE_SHIFTBBA
7755 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7756 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7757 #endif
7758}

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7760 of file kutil.cc.

7761{
7762 //PrintS("\nUsage/Allocation of temporary storage:\n");
7763 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7764 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7765 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7766 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7767 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7768 #ifdef HAVE_SHIFTBBA
7769 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7770 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7771 #endif
7772}
int nrsyzcrit
Definition: kutil.h:364

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10654 of file kutil.cc.

10655{
10656 if (currRing->pLexOrder || rHasMixedOrdering(currRing))
10657 return FALSE;
10658 int i,j;
10659 poly newNoether;
10660
10661#if 0
10662 if (currRing->weight_all_1)
10663 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10664 else
10665 scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10666#else
10667 scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing);
10668#endif
10669 if (strat->kHEdge==NULL) return FALSE;
10670 if (strat->t_kHEdge != NULL) p_LmFree(strat->t_kHEdge, strat->tailRing);
10671 if (strat->tailRing != currRing)
10672 strat->t_kHEdge = k_LmInit_currRing_2_tailRing(strat->kHEdge, strat->tailRing);
10673 /* compare old and new noether*/
10674 newNoether = pLmInit(strat->kHEdge);
10675 pSetCoeff0(newNoether,nInit(1));
10676 j = p_FDeg(newNoether,currRing);
10677 for (i=1; i<=(currRing->N); i++)
10678 {
10679 if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10680 }
10681 pSetm(newNoether);
10682 if (j < strat->HCord) /*- statistics -*/
10683 {
10684 if (TEST_OPT_PROT)
10685 {
10686 Print("H(%d)",j);
10687 mflush();
10688 }
10689 strat->HCord=j;
10690 #ifdef KDEBUG
10691 if (TEST_OPT_DEBUG)
10692 {
10693 Print("H(%d):",j);
10694 wrp(strat->kHEdge);
10695 PrintLn();
10696 }
10697 #endif
10698 }
10699 if (pCmp(strat->kNoether,newNoether)!=1)
10700 {
10701 if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether);
10702 strat->kNoether=newNoether;
10703 if (strat->t_kNoether != NULL) p_LmFree(strat->t_kNoether, strat->tailRing);
10704 if (strat->tailRing != currRing)
10706
10707 return TRUE;
10708 }
10709 pLmDelete(newNoether);
10710 return FALSE;
10711}
int HCord
Definition: kutil.h:358
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1078
VAR int HCord
Definition: kutil.cc:246
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition: polys.h:115
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pDecrExp(p, i)
Definition: polys.h:44

◆ pairs()

void pairs ( )

◆ pCopyL2p()

poly pCopyL2p ( LObject  h,
kStrategy  strat 
)

Definition at line 11922 of file kutil.cc.

11923{
11924 /* restores a poly in currRing from LObject */
11925 LObject h = H;
11926 h.Copy();
11927 poly p;
11928 if (h.p == NULL)
11929 {
11930 if (h.t_p != NULL)
11931 {
11932 p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
11933 return(p);
11934 }
11935 else
11936 {
11937 /* h.tp == NULL -> the object is NULL */
11938 return(NULL);
11939 }
11940 }
11941 /* we're here if h.p != NULL */
11942 if (h.t_p == NULL)
11943 {
11944 /* then h.p is the whole poly in currRing */
11945 p = h.p;
11946 return(p);
11947 }
11948 /* we're here if h.p != NULL and h.t_p != NULL */
11949 // clean h.p, get poly from t_p
11950 pNext(h.p)=NULL;
11951 pLmDelete(&h.p);
11952 p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
11953 /* dest. ring: */ currRing);
11954 // no need to clean h: we re-used the polys
11955 return(p);
11956}
CanonicalForm H
Definition: facAbsFact.cc:60
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:89

◆ pMove2CurrTail()

poly pMove2CurrTail ( poly  p,
kStrategy  strat 
)

Definition at line 11891 of file kutil.cc.

11892{
11893 /* assume: p is completely in currRing */
11894 /* produces an object with LM in curring
11895 and TAIL in tailring */
11896 if (pNext(p)!=NULL)
11897 {
11898 pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
11899 }
11900 return(p);
11901}

◆ pMoveCurrTail2poly()

poly pMoveCurrTail2poly ( poly  p,
kStrategy  strat 
)

Definition at line 11905 of file kutil.cc.

11906{
11907 /* assume: p has LM in curring and TAIL in tailring */
11908 /* convert it to complete currRing */
11909
11910 /* check that LM is in currRing */
11912
11913 if (pNext(p)!=NULL)
11914 {
11915 pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
11916 }
11917 return(p);
11918}

◆ posInIdealMonFirst()

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

Definition at line 4879 of file kutil.cc.

4880{
4881 if(end < 0 || end >= IDELEMS(F))
4882 end = IDELEMS(F);
4883 if (end<0) return 0;
4884 if(pNext(p) == NULL) return start;
4885 polyset set=F->m;
4886 int o = p_Deg(p,currRing);
4887 int op;
4888 int i;
4889 int an = start;
4890 for(i=start;i<end;i++)
4891 if(set[i] != NULL && pNext(set[i]) == NULL)
4892 an++;
4893 if(an == end-1)
4894 return end;
4895 int en= end;
4896 loop
4897 {
4898 if(an>=en)
4899 return en;
4900 if (an == en-1)
4901 {
4902 op = p_Deg(set[an],currRing);
4903 if ((op < o)
4904 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4905 return en;
4906 return an;
4907 }
4908 i=(an+en) / 2;
4909 op = p_Deg(set[i],currRing);
4910 if ((op < o)
4911 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4912 an=i;
4913 else
4914 en=i;
4915 }
4916}
poly * polyset
Definition: polys.h:259

◆ posInL0()

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

Definition at line 5728 of file kutil.cc.

5730{
5731 if (length<0) return 0;
5732
5733 if (pLmCmp(set[length].p,p->p)== currRing->OrdSgn)
5734 return length+1;
5735
5736 int i;
5737 int an = 0;
5738 int en= length;
5739 loop
5740 {
5741 if (an >= en-1)
5742 {
5743 if (pLmCmp(set[an].p,p->p) == currRing->OrdSgn) return en;
5744 return an;
5745 }
5746 i=(an+en) / 2;
5747 if (pLmCmp(set[i].p,p->p) == currRing->OrdSgn) an=i;
5748 else en=i;
5749 /*aend. fuer lazy == in !=- machen */
5750 }
5751}

◆ posInL10()

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

Definition at line 1342 of file kstd1.cc.

1343{
1344 int j,dp,dL;
1345
1346 if (length<0) return 0;
1347 if (hasPurePower(p,strat->lastAxis,&dp,strat))
1348 {
1349 int op= p->GetpFDeg() +p->ecart;
1350 for (j=length; j>=0; j--)
1351 {
1352 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
1353 return j+1;
1354 if (dp < dL)
1355 return j+1;
1356 if ((dp == dL)
1357 && (set[j].GetpFDeg()+set[j].ecart >= op))
1358 return j+1;
1359 }
1360 }
1361 j=length;
1362 loop
1363 {
1364 if (j<0) break;
1365 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
1366 j--;
1367 }
1368 return strat->posInLOld(set,j,p,strat);
1369}
int lastAxis
Definition: kutil.h:359
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition: kutil.h:289
BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition: kstd1.cc:1294

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

5988{
5989 if (length<0) return 0;
5990
5991 int o = p->GetpFDeg();
5992 int op = set[length].GetpFDeg();
5993
5994 if ((op > o)
5995 || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
5996 return length+1;
5997 int i;
5998 int an = 0;
5999 int en= length;
6000 loop
6001 {
6002 if (an >= en-1)
6003 {
6004 op = set[an].GetpFDeg();
6005 if ((op > o)
6006 || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6007 return en;
6008 return an;
6009 }
6010 i=(an+en) / 2;
6011 op = set[i].GetpFDeg();
6012 if ((op > o)
6013 || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6014 an=i;
6015 else
6016 en=i;
6017 }
6018}

◆ posInL110()

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

Definition at line 6284 of file kutil.cc.

6286{
6287 if (length<0) return 0;
6288
6289 int o = p->GetpFDeg();
6290 int op = set[length].GetpFDeg();
6291
6292 if ((op > o)
6293 || ((op == o) && (set[length].length >p->length))
6294 || ((op == o) && (set[length].length <= p->length)
6295 && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6296 return length+1;
6297 int i;
6298 int an = 0;
6299 int en= length;
6300 loop
6301 {
6302 if (an >= en-1)
6303 {
6304 op = set[an].GetpFDeg();
6305 if ((op > o)
6306 || ((op == o) && (set[an].length >p->length))
6307 || ((op == o) && (set[an].length <=p->length)
6308 && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6309 return en;
6310 return an;
6311 }
6312 i=(an+en) / 2;
6313 op = set[i].GetpFDeg();
6314 if ((op > o)
6315 || ((op == o) && (set[i].length > p->length))
6316 || ((op == o) && (set[i].length <= p->length)
6317 && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6318 an=i;
6319 else
6320 en=i;
6321 }
6322}

◆ posInL11Ring()

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

Definition at line 6028 of file kutil.cc.

6030{
6031 if (length<0) return 0;
6032
6033 int o = p->GetpFDeg();
6034 int op = set[length].GetpFDeg();
6035
6036 if ((op > o)
6037 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6038 return length+1;
6039 int i;
6040 int an = 0;
6041 int en= length;
6042 loop
6043 {
6044 if (an >= en-1)
6045 {
6046 op = set[an].GetpFDeg();
6047 if ((op > o)
6048 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6049 return en;
6050 return an;
6051 }
6052 i=(an+en) / 2;
6053 op = set[i].GetpFDeg();
6054 if ((op > o)
6055 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6056 an=i;
6057 else
6058 en=i;
6059 }
6060}
#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 6098 of file kutil.cc.

6100{
6101 if (length < 0) return 0;
6102 int an,en,i;
6103 an = 0;
6104 en = length+1;
6105 loop
6106 {
6107 if (an >= en-1)
6108 {
6109 if(an == en)
6110 return en;
6111 if (set[an].FDeg > p->FDeg)
6112 return en;
6113 if (set[an].FDeg < p->FDeg)
6114 return an;
6115 if (set[an].FDeg == p->FDeg)
6116 {
6117 number lcset,lcp;
6118 lcset = pGetCoeff(set[an].p);
6119 lcp = pGetCoeff(p->p);
6120 if(!nGreaterZero(lcset))
6121 {
6122 set[an].p=p_Neg(set[an].p,currRing);
6123 if (set[an].t_p!=NULL)
6124 pSetCoeff0(set[an].t_p,pGetCoeff(set[an].p));
6125 lcset=pGetCoeff(set[an].p);
6126 }
6127 if(!nGreaterZero(lcp))
6128 {
6129 p->p=p_Neg(p->p,currRing);
6130 if (p->t_p!=NULL)
6131 pSetCoeff0(p->t_p,pGetCoeff(p->p));
6132 lcp=pGetCoeff(p->p);
6133 }
6134 if(nGreater(lcset, lcp))
6135 {
6136 return en;
6137 }
6138 else
6139 {
6140 return an;
6141 }
6142 }
6143 }
6144 i=(an+en) / 2;
6145 if (set[i].FDeg > p->FDeg)
6146 an=i;
6147 if (set[i].FDeg < p->FDeg)
6148 en=i;
6149 if (set[i].FDeg == p->FDeg)
6150 {
6151 number lcset,lcp;
6152 lcset = pGetCoeff(set[i].p);
6153 lcp = pGetCoeff(p->p);
6154 if(!nGreaterZero(lcset))
6155 {
6156 set[i].p=p_Neg(set[i].p,currRing);
6157 if (set[i].t_p!=NULL)
6158 pSetCoeff0(set[i].t_p,pGetCoeff(set[i].p));
6159 lcset=pGetCoeff(set[i].p);
6160 }
6161 if(!nGreaterZero(lcp))
6162 {
6163 p->p=p_Neg(p->p,currRing);
6164 if (p->t_p!=NULL)
6165 pSetCoeff0(p->t_p,pGetCoeff(p->p));
6166 lcp=pGetCoeff(p->p);
6167 }
6168 if(nGreater(lcset, lcp))
6169 {
6170 an = i;
6171 }
6172 else
6173 {
6174 en = i;
6175 }
6176 }
6177 }
6178}
#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 6372 of file kutil.cc.

6374{
6375 if (length<0) return 0;
6376
6377 int o = p->GetpFDeg();
6378
6379 if (set[length].GetpFDeg() > o)
6380 return length+1;
6381
6382 int i;
6383 int an = 0;
6384 int en= length;
6385 loop
6386 {
6387 if (an >= en-1)
6388 {
6389 if (set[an].GetpFDeg() >= o)
6390 return en;
6391 return an;
6392 }
6393 i=(an+en) / 2;
6394 if (set[i].GetpFDeg() >= o)
6395 an=i;
6396 else
6397 en=i;
6398 }
6399}

◆ posInL15()

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

Definition at line 6407 of file kutil.cc.

6409{
6410 if (length<0) return 0;
6411
6412 int o = p->GetpFDeg() + p->ecart;
6413 int op = set[length].GetpFDeg() + set[length].ecart;
6414
6415 if ((op > o)
6416 || ((op == o) && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6417 return length+1;
6418 int i;
6419 int an = 0;
6420 int en= length;
6421 loop
6422 {
6423 if (an >= en-1)
6424 {
6425 op = set[an].GetpFDeg() + set[an].ecart;
6426 if ((op > o)
6427 || ((op == o) && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6428 return en;
6429 return an;
6430 }
6431 i=(an+en) / 2;
6432 op = set[i].GetpFDeg() + set[i].ecart;
6433 if ((op > o)
6434 || ((op == o) && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6435 an=i;
6436 else
6437 en=i;
6438 }
6439}

◆ posInL15Ring()

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

Definition at line 6442 of file kutil.cc.

6444{
6445 if (length<0) return 0;
6446
6447 int o = p->GetpFDeg() + p->ecart;
6448 int op = set[length].GetpFDeg() + set[length].ecart;
6449
6450 if ((op > o)
6451 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6452 return length+1;
6453 int i;
6454 int an = 0;
6455 int en= length;
6456 loop
6457 {
6458 if (an >= en-1)
6459 {
6460 op = set[an].GetpFDeg() + set[an].ecart;
6461 if ((op > o)
6462 || ((op == o) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6463 return en;
6464 return an;
6465 }
6466 i=(an+en) / 2;
6467 op = set[i].GetpFDeg() + set[i].ecart;
6468 if ((op > o)
6469 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6470 an=i;
6471 else
6472 en=i;
6473 }
6474}

◆ posInL17()

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

Definition at line 6483 of file kutil.cc.

6485{
6486 if (length<0) return 0;
6487
6488 int o = p->GetpFDeg() + p->ecart;
6489
6490 if ((set[length].GetpFDeg() + set[length].ecart > o)
6491 || ((set[length].GetpFDeg() + set[length].ecart == o)
6492 && (set[length].ecart > p->ecart))
6493 || ((set[length].GetpFDeg() + set[length].ecart == o)
6494 && (set[length].ecart == p->ecart)
6495 && (pLmCmp(set[length].p,p->p) != -currRing->OrdSgn)))
6496 return length+1;
6497 int i;
6498 int an = 0;
6499 int en= length;
6500 loop
6501 {
6502 if (an >= en-1)
6503 {
6504 if ((set[an].GetpFDeg() + set[an].ecart > o)
6505 || ((set[an].GetpFDeg() + set[an].ecart == o)
6506 && (set[an].ecart > p->ecart))
6507 || ((set[an].GetpFDeg() + set[an].ecart == o)
6508 && (set[an].ecart == p->ecart)
6509 && (pLmCmp(set[an].p,p->p) != -currRing->OrdSgn)))
6510 return en;
6511 return an;
6512 }
6513 i=(an+en) / 2;
6514 if ((set[i].GetpFDeg() + set[i].ecart > o)
6515 || ((set[i].GetpFDeg() + set[i].ecart == o)
6516 && (set[i].ecart > p->ecart))
6517 || ((set[i].GetpFDeg() +set[i].ecart == o)
6518 && (set[i].ecart == p->ecart)
6519 && (pLmCmp(set[i].p,p->p) != -currRing->OrdSgn)))
6520 an=i;
6521 else
6522 en=i;
6523 }
6524}

◆ posInLF5C()

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

Definition at line 5974 of file kutil.cc.

5976{
5977 return strat->Ll+1;
5978}

◆ posInLF5CRing()

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

Definition at line 6062 of file kutil.cc.

6064{
6065 if (length<0) return 0;
6066 if(start == (length +1)) return (length+1);
6067 int o = p->GetpFDeg();
6068 int op = set[length].GetpFDeg();
6069
6070 if ((op > o)
6071 || ((op == o) && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6072 return length+1;
6073 int i;
6074 int an = start;
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) && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6083 return en;
6084 return an;
6085 }
6086 i=(an+en) / 2;
6087 op = set[i].GetpFDeg();
6088 if ((op > o)
6089 || ((op == o) && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6090 an=i;
6091 else
6092 en=i;
6093 }
6094}

◆ posInLRing()

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

Definition at line 5873 of file kutil.cc.

5875{
5876 if (length < 0) return 0;
5877 if (set[length].FDeg > p->FDeg)
5878 return length+1;
5879 if (set[length].FDeg == p->FDeg)
5880 if(set[length].GetpLength() > p->GetpLength())
5881 return length+1;
5882 int i;
5883 int an = 0;
5884 int en= length+1;
5885 loop
5886 {
5887 if (an >= en-1)
5888 {
5889 if(an == en)
5890 return en;
5891 if (set[an].FDeg > p->FDeg)
5892 return en;
5893 if(set[an].FDeg == p->FDeg)
5894 {
5895 if(set[an].GetpLength() > p->GetpLength())
5896 return en;
5897 else
5898 {
5899 if(set[an].GetpLength() == p->GetpLength())
5900 {
5901 if(nGreater(set[an].p->coef, p->p->coef))
5902 return en;
5903 else
5904 return an;
5905 }
5906 else
5907 {
5908 return an;
5909 }
5910 }
5911 }
5912 else
5913 return an;
5914 }
5915 i=(an+en) / 2;
5916 if (set[i].FDeg > p->FDeg)
5917 an=i;
5918 else
5919 {
5920 if(set[i].FDeg == p->FDeg)
5921 {
5922 if(set[i].GetpLength() > p->GetpLength())
5923 an=i;
5924 else
5925 {
5926 if(set[i].GetpLength() == p->GetpLength())
5927 {
5928 if(nGreater(set[i].p->coef, p->p->coef))
5929 an = i;
5930 else
5931 en = i;
5932 }
5933 else
5934 {
5935 en=i;
5936 }
5937 }
5938 }
5939 else
5940 en=i;
5941 }
5942 }
5943}

◆ posInLSig()

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

Definition at line 5786 of file kutil.cc.

5788{
5789 if (length<0) return 0;
5790 if (pLtCmp(set[length].sig,p->sig)== currRing->OrdSgn)
5791 return length+1;
5792
5793 int i;
5794 int an = 0;
5795 int en= length;
5796 loop
5797 {
5798 if (an >= en-1)
5799 {
5800 if (pLtCmp(set[an].sig,p->sig) == currRing->OrdSgn) return en;
5801 return an;
5802 }
5803 i=(an+en) / 2;
5804 if (pLtCmp(set[i].sig,p->sig) == currRing->OrdSgn) an=i;
5805 else en=i;
5806 /*aend. fuer lazy == in !=- machen */
5807 }
5808}

◆ posInLSigRing()

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

Definition at line 5810 of file kutil.cc.

5812{
5813 assume(currRing->OrdSgn == 1 && rField_is_Ring(currRing));
5814 if (length<0) return 0;
5815 if (pLtCmp(set[length].sig,p->sig)== 1)
5816 return length+1;
5817
5818 int an,en,i;
5819 an = 0;
5820 en = length+1;
5821 int cmp;
5822 loop
5823 {
5824 if (an >= en-1)
5825 {
5826 if(an == en)
5827 return en;
5828 cmp = pLtCmp(set[an].sig,p->sig);
5829 if (cmp == 1)
5830 return en;
5831 if (cmp == -1)
5832 return an;
5833 if (cmp == 0)
5834 {
5835 if (set[an].FDeg > p->FDeg)
5836 return en;
5837 if (set[an].FDeg < p->FDeg)
5838 return an;
5839 if (set[an].FDeg == p->FDeg)
5840 {
5841 cmp = pLtCmp(set[an].p,p->p);
5842 if(cmp == 1)
5843 return en;
5844 else
5845 return an;
5846 }
5847 }
5848 }
5849 i=(an+en) / 2;
5850 cmp = pLtCmp(set[i].sig,p->sig);
5851 if (cmp == 1)
5852 an = i;
5853 if (cmp == -1)
5854 en = i;
5855 if (cmp == 0)
5856 {
5857 if (set[i].FDeg > p->FDeg)
5858 an = i;
5859 if (set[i].FDeg < p->FDeg)
5860 en = i;
5861 if (set[i].FDeg == p->FDeg)
5862 {
5863 cmp = pLtCmp(set[i].p,p->p);
5864 if(cmp == 1)
5865 an = i;
5866 else
5867 en = i;
5868 }
5869 }
5870 }
5871}

◆ posInS()

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

Definition at line 4701 of file kutil.cc.

4703{
4704 if(length==-1) return 0;
4705 polyset set=strat->S;
4706 int i;
4707 int an = 0;
4708 int en = length;
4709 int cmp_int = currRing->OrdSgn;
4711#ifdef HAVE_PLURAL
4712 && (currRing->real_var_start==0)
4713#endif
4714#if 0
4715 || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C))))
4716#endif
4717 )
4718 {
4719 int o=p_Deg(p,currRing);
4720 int oo=p_Deg(set[length],currRing);
4721
4722 if ((oo<o)
4723 || ((o==oo) && (pLmCmp(set[length],p)!= cmp_int)))
4724 return length+1;
4725
4726 loop
4727 {
4728 if (an >= en-1)
4729 {
4730 if ((p_Deg(set[an],currRing)>=o) && (pLmCmp(set[an],p) == cmp_int))
4731 {
4732 return an;
4733 }
4734 return en;
4735 }
4736 i=(an+en) / 2;
4737 if ((p_Deg(set[i],currRing)>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i;
4738 else an=i;
4739 }
4740 }
4741 else
4742 {
4744 {
4745 if (pLmCmp(set[length],p)== -cmp_int)
4746 return length+1;
4747 int cmp;
4748 loop
4749 {
4750 if (an >= en-1)
4751 {
4752 cmp = pLmCmp(set[an],p);
4753 if (cmp == cmp_int) return an;
4754 if (cmp == -cmp_int) return en;
4755 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[an]), currRing->cf)) return en;
4756 return an;
4757 }
4758 i = (an+en) / 2;
4759 cmp = pLmCmp(set[i],p);
4760 if (cmp == cmp_int) en = i;
4761 else if (cmp == -cmp_int) an = i;
4762 else
4763 {
4764 if (n_DivBy(pGetCoeff(p), pGetCoeff(set[i]), currRing->cf)) an = i;
4765 else en = i;
4766 }
4767 }
4768 }
4769 else
4770 if (pLmCmp(set[length],p)== -cmp_int)
4771 return length+1;
4772
4773 loop
4774 {
4775 if (an >= en-1)
4776 {
4777 if (pLmCmp(set[an],p) == cmp_int) return an;
4778 if (pLmCmp(set[an],p) == -cmp_int) return en;
4779 if ((cmp_int!=1)
4780 && ((strat->ecartS[an])>ecart_p))
4781 return an;
4782 return en;
4783 }
4784 i=(an+en) / 2;
4785 if (pLmCmp(set[i],p) == cmp_int) en=i;
4786 else if (pLmCmp(set[i],p) == -cmp_int) an=i;
4787 else
4788 {
4789 if ((cmp_int!=1)
4790 &&((strat->ecartS[i])<ecart_p))
4791 en=i;
4792 else
4793 an=i;
4794 }
4795 }
4796 }
4797}

◆ posInSMonFirst()

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

Definition at line 4802 of file kutil.cc.

4803{
4804 if (length<0) return 0;
4805 polyset set=strat->S;
4806 if(pNext(p) == NULL)
4807 {
4808 int mon = 0;
4809 for(int i = 0;i<=length;i++)
4810 {
4811 if(set[i] != NULL && pNext(set[i]) == NULL)
4812 mon++;
4813 }
4814 int o = p_Deg(p,currRing);
4815 int op = p_Deg(set[mon],currRing);
4816
4817 if ((op < o)
4818 || ((op == o) && (pLtCmp(set[mon],p) == -1)))
4819 return length+1;
4820 int i;
4821 int an = 0;
4822 int en= mon;
4823 loop
4824 {
4825 if (an >= en-1)
4826 {
4827 op = p_Deg(set[an],currRing);
4828 if ((op < o)
4829 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4830 return en;
4831 return an;
4832 }
4833 i=(an+en) / 2;
4834 op = p_Deg(set[i],currRing);
4835 if ((op < o)
4836 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4837 an=i;
4838 else
4839 en=i;
4840 }
4841 }
4842 else /*if(pNext(p) != NULL)*/
4843 {
4844 int o = p_Deg(p,currRing);
4845 int op = p_Deg(set[length],currRing);
4846
4847 if ((op < o)
4848 || ((op == o) && (pLtCmp(set[length],p) == -1)))
4849 return length+1;
4850 int i;
4851 int an = 0;
4852 for(i=0;i<=length;i++)
4853 if(set[i] != NULL && pNext(set[i]) == NULL)
4854 an++;
4855 int en= length;
4856 loop
4857 {
4858 if (an >= en-1)
4859 {
4860 op = p_Deg(set[an],currRing);
4861 if ((op < o)
4862 || ((op == o) && (pLtCmp(set[an],p) == -1)))
4863 return en;
4864 return an;
4865 }
4866 i=(an+en) / 2;
4867 op = p_Deg(set[i],currRing);
4868 if ((op < o)
4869 || ((op == o) && (pLtCmp(set[i],p) == -1)))
4870 an=i;
4871 else
4872 en=i;
4873 }
4874 }
4875}

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
const poly  sig 
)

Definition at line 5946 of file kutil.cc.

5947{
5948 if (strat->syzl==0) return 0;
5949 if (pLtCmp(strat->syz[strat->syzl-1],sig) != currRing->OrdSgn)
5950 return strat->syzl;
5951 int i;
5952 int an = 0;
5953 int en= strat->syzl-1;
5954 loop
5955 {
5956 if (an >= en-1)
5957 {
5958 if (pLtCmp(strat->syz[an],sig) != currRing->OrdSgn) return en;
5959 return an;
5960 }
5961 i=(an+en) / 2;
5962 if (pLtCmp(strat->syz[i],sig) != currRing->OrdSgn) an=i;
5963 else en=i;
5964 /*aend. fuer lazy == in !=- machen */
5965 }
5966}

◆ posInT0()

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

Definition at line 4923 of file kutil.cc.

4924{
4925 return (length+1);
4926}

◆ posInT1()

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

Definition at line 4934 of file kutil.cc.

4935{
4936 if (length==-1) return 0;
4937
4938 if (pLmCmp(set[length].p,p.p)!= currRing->OrdSgn) return length+1;
4939
4940 int i;
4941 int an = 0;
4942 int en= length;
4943
4944 loop
4945 {
4946 if (an >= en-1)
4947 {
4948 if (pLmCmp(set[an].p,p.p) == currRing->OrdSgn) return an;
4949 return en;
4950 }
4951 i=(an+en) / 2;
4952 if (pLmCmp(set[i].p,p.p) == currRing->OrdSgn) en=i;
4953 else an=i;
4954 }
4955}

◆ posInT11()

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

Definition at line 4990 of file kutil.cc.

4991{
4992 if (length==-1) return 0;
4993
4994 int o = p.GetpFDeg();
4995 int op = set[length].GetpFDeg();
4996
4997 if ((op < o)
4998 || ((op == o) && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
4999 return length+1;
5000
5001 int i;
5002 int an = 0;
5003 int en= length;
5004
5005 loop
5006 {
5007 if (an >= en-1)
5008 {
5009 op= set[an].GetpFDeg();
5010 if ((op > o)
5011 || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5012 return an;
5013 return en;
5014 }
5015 i=(an+en) / 2;
5016 op = set[i].GetpFDeg();
5017 if (( op > o)
5018 || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5019 en=i;
5020 else
5021 an=i;
5022 }
5023}

◆ posInT110()

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

Definition at line 5143 of file kutil.cc.

5144{
5145 if (length==-1) return 0;
5146 p.GetpLength();
5147
5148 int o = p.GetpFDeg();
5149 int op = set[length].GetpFDeg();
5150
5151 if (( op < o)
5152 || (( op == o) && (set[length].length<p.length))
5153 || (( op == o) && (set[length].length == p.length)
5154 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5155 return length+1;
5156
5157 int i;
5158 int an = 0;
5159 int en= length;
5160 loop
5161 {
5162 if (an >= en-1)
5163 {
5164 op = set[an].GetpFDeg();
5165 if (( op > o)
5166 || (( op == o) && (set[an].length > p.length))
5167 || (( op == o) && (set[an].length == p.length)
5168 && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5169 return an;
5170 return en;
5171 }
5172 i=(an+en) / 2;
5173 op = set[i].GetpFDeg();
5174 if (( op > o)
5175 || (( op == o) && (set[i].length > p.length))
5176 || (( op == o) && (set[i].length == p.length)
5177 && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5178 en=i;
5179 else
5180 an=i;
5181 }
5182}

◆ posInT13()

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

Definition at line 5232 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5299 of file kutil.cc.

5318{
5319 if (length==-1) return 0;
5320
5321 int o = p.GetpFDeg() + p.ecart;
5322 int op = set[length].GetpFDeg()+set[length].ecart;
5323
5324 if ((op < o)
5325 || ((op == o)
5326 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5327 return length+1;
5328
5329 int i;
5330 int an = 0;
5331 int en= length;
5332 loop
5333 {
5334 if (an >= en-1)
5335 {
5336 op = set[an].GetpFDeg()+set[an].ecart;
5337 if (( op > o)
5338 || (( op == o) && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5339 return an;
5340 return en;
5341 }
5342 i=(an+en) / 2;
5343 op = set[i].GetpFDeg()+set[i].ecart;
5344 if (( op > o)
5345 || (( op == o) && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5346 en=i;
5347 else
5348 an=i;
5349 }
5350}

◆ posInT17()

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

Definition at line 5394 of file kutil.cc.

5415{
5416 if (length==-1) return 0;
5417
5418 int o = p.GetpFDeg() + p.ecart;
5419 int op = set[length].GetpFDeg()+set[length].ecart;
5420
5421 if ((op < o)
5422 || (( op == o) && (set[length].ecart > p.ecart))
5423 || (( op == o) && (set[length].ecart==p.ecart)
5424 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5425 return length+1;
5426
5427 int i;
5428 int an = 0;
5429 int en= length;
5430 loop
5431 {
5432 if (an >= en-1)
5433 {
5434 op = set[an].GetpFDeg()+set[an].ecart;
5435 if (( op > o)
5436 || (( op == o) && (set[an].ecart < p.ecart))
5437 || (( op == o) && (set[an].ecart==p.ecart)
5438 && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5439 return an;
5440 return en;
5441 }
5442 i=(an+en) / 2;
5443 op = set[i].GetpFDeg()+set[i].ecart;
5444 if ((op > o)
5445 || (( op == o) && (set[i].ecart < p.ecart))
5446 || (( op == o) && (set[i].ecart == p.ecart)
5447 && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5448 en=i;
5449 else
5450 an=i;
5451 }
5452}

◆ posInT17_c()

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

Definition at line 5501 of file kutil.cc.

5502{
5503 if (length==-1) return 0;
5504
5505 int cc = (-1+2*currRing->order[0]==ringorder_c);
5506 /* cc==1 for (c,..), cc==-1 for (C,..) */
5507 int o = p.GetpFDeg() + p.ecart;
5508 int c = pGetComp(p.p)*cc;
5509
5510 if (pGetComp(set[length].p)*cc < c)
5511 return length+1;
5512 if (pGetComp(set[length].p)*cc == c)
5513 {
5514 int op = set[length].GetpFDeg()+set[length].ecart;
5515 if ((op < o)
5516 || ((op == o) && (set[length].ecart > p.ecart))
5517 || ((op == o) && (set[length].ecart==p.ecart)
5518 && (pLmCmp(set[length].p,p.p) != currRing->OrdSgn)))
5519 return length+1;
5520 }
5521
5522 int i;
5523 int an = 0;
5524 int en= length;
5525 loop
5526 {
5527 if (an >= en-1)
5528 {
5529 if (pGetComp(set[an].p)*cc < c)
5530 return en;
5531 if (pGetComp(set[an].p)*cc == c)
5532 {
5533 int op = set[an].GetpFDeg()+set[an].ecart;
5534 if ((op > o)
5535 || ((op == o) && (set[an].ecart < p.ecart))
5536 || ((op == o) && (set[an].ecart==p.ecart)
5537 && (pLmCmp(set[an].p,p.p) == currRing->OrdSgn)))
5538 return an;
5539 }
5540 return en;
5541 }
5542 i=(an+en) / 2;
5543 if (pGetComp(set[i].p)*cc > c)
5544 en=i;
5545 else if (pGetComp(set[i].p)*cc == c)
5546 {
5547 int op = set[i].GetpFDeg()+set[i].ecart;
5548 if ((op > o)
5549 || ((op == o) && (set[i].ecart < p.ecart))
5550 || ((op == o) && (set[i].ecart == p.ecart)
5551 && (pLmCmp(set[i].p,p.p) == currRing->OrdSgn)))
5552 en=i;
5553 else
5554 an=i;
5555 }
5556 else
5557 an=i;
5558 }
5559}

◆ posInT19()

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

Definition at line 5628 of file kutil.cc.

5629{
5630 p.GetpLength();
5631 if (length==-1) return 0;
5632
5633 int o = p.ecart;
5634 int op=p.GetpFDeg();
5635
5636 if (set[length].ecart < o)
5637 return length+1;
5638 if (set[length].ecart == o)
5639 {
5640 int oo=set[length].GetpFDeg();
5641 if ((oo < op) || ((oo==op) && (set[length].length < p.length)))
5642 return length+1;
5643 }
5644
5645 int i;
5646 int an = 0;
5647 int en= length;
5648 loop
5649 {
5650 if (an >= en-1)
5651 {
5652 if (set[an].ecart > o)
5653 return an;
5654 if (set[an].ecart == o)
5655 {
5656 int oo=set[an].GetpFDeg();
5657 if((oo > op)
5658 || ((oo==op) && (set[an].length > p.length)))
5659 return an;
5660 }
5661 return en;
5662 }
5663 i=(an+en) / 2;
5664 if (set[i].ecart > o)
5665 en=i;
5666 else if (set[i].ecart == o)
5667 {
5668 int oo=set[i].GetpFDeg();
5669 if ((oo > op)
5670 || ((oo == op) && (set[i].length > p.length)))
5671 en=i;
5672 else
5673 an=i;
5674 }
5675 else
5676 an=i;
5677 }
5678}

◆ posInT2()

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

Definition at line 4962 of file kutil.cc.

4963{
4964 if (length==-1) return 0;
4965 p.GetpLength();
4966 if (set[length].length<p.length) return length+1;
4967
4968 int i;
4969 int an = 0;
4970 int en= length;
4971
4972 loop
4973 {
4974 if (an >= en-1)
4975 {
4976 if (set[an].length>p.length) return an;
4977 return en;
4978 }
4979 i=(an+en) / 2;
4980 if (set[i].length>p.length) en=i;
4981 else an=i;
4982 }
4983}

◆ posInT_EcartFDegpLength()

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

Definition at line 11628 of file kutil.cc.

11629{
11630
11631 if (length==-1) return 0;
11632
11633 int o = p.ecart;
11634 int op=p.GetpFDeg();
11635 int ol = p.GetpLength();
11636
11637 if (set[length].ecart < o)
11638 return length+1;
11639 if (set[length].ecart == o)
11640 {
11641 int oo=set[length].GetpFDeg();
11642 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11643 return length+1;
11644 }
11645
11646 int i;
11647 int an = 0;
11648 int en= length;
11649 loop
11650 {
11651 if (an >= en-1)
11652 {
11653 if (set[an].ecart > o)
11654 return an;
11655 if (set[an].ecart == o)
11656 {
11657 int oo=set[an].GetpFDeg();
11658 if((oo > op)
11659 || ((oo==op) && (set[an].pLength > ol)))
11660 return an;
11661 }
11662 return en;
11663 }
11664 i=(an+en) / 2;
11665 if (set[i].ecart > o)
11666 en=i;
11667 else if (set[i].ecart == o)
11668 {
11669 int oo=set[i].GetpFDeg();
11670 if ((oo > op)
11671 || ((oo == op) && (set[i].pLength > ol)))
11672 en=i;
11673 else
11674 an=i;
11675 }
11676 else
11677 an=i;
11678 }
11679}

◆ posInT_EcartpLength()

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

Definition at line 5261 of file kutil.cc.

5262{
5263 if (length==-1) return 0;
5264 int ol = p.GetpLength();
5265 int op=p.ecart;
5266 int oo=set[length].ecart;
5267
5268 if ((oo < op) || ((oo==op) && (set[length].length <= ol)))
5269 return length+1;
5270
5271 int i;
5272 int an = 0;
5273 int en= length;
5274 loop
5275 {
5276 if (an >= en-1)
5277 {
5278 int oo=set[an].ecart;
5279 if((oo > op)
5280 || ((oo==op) && (set[an].pLength > ol)))
5281 return an;
5282 return en;
5283 }
5284 i=(an+en) / 2;
5285 int oo=set[i].ecart;
5286 if ((oo > op)
5287 || ((oo == op) && (set[i].pLength > ol)))
5288 en=i;
5289 else
5290 an=i;
5291 }
5292}

◆ posInT_FDegpLength()

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

Definition at line 11682 of file kutil.cc.

11683{
11684
11685 if (length==-1) return 0;
11686
11687 int op=p.GetpFDeg();
11688 int ol = p.GetpLength();
11689
11690 int oo=set[length].GetpFDeg();
11691 if ((oo < op) || ((oo==op) && (set[length].length < ol)))
11692 return length+1;
11693
11694 int i;
11695 int an = 0;
11696 int en= length;
11697 loop
11698 {
11699 if (an >= en-1)
11700 {
11701 int oo=set[an].GetpFDeg();
11702 if((oo > op)
11703 || ((oo==op) && (set[an].pLength > ol)))
11704 return an;
11705 return en;
11706 }
11707 i=(an+en) / 2;
11708 int oo=set[i].GetpFDeg();
11709 if ((oo > op)
11710 || ((oo == op) && (set[i].pLength > ol)))
11711 en=i;
11712 else
11713 an=i;
11714 }
11715}

◆ posInT_pLength()

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

Definition at line 11719 of file kutil.cc.

11720{
11721 int ol = p.GetpLength();
11722 if (length==-1)
11723 return 0;
11724 if (set[length].length<p.length)
11725 return length+1;
11726
11727 int i;
11728 int an = 0;
11729 int en= length;
11730
11731 loop
11732 {
11733 if (an >= en-1)
11734 {
11735 if (set[an].pLength>ol) return an;
11736 return en;
11737 }
11738 i=(an+en) / 2;
11739 if (set[i].pLength>ol) en=i;
11740 else an=i;
11741 }
11742}

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

10948{
10949 if(!nCoeff_is_Z(currRing->cf))
10950 return;
10951 poly pH = h->GetP();
10952 poly p,pp;
10953 p = pH;
10954 bool deleted = FALSE, ok = FALSE;
10955 for(int i = 0; i<=strat->sl; i++)
10956 {
10957 p = pH;
10958 if(pNext(strat->S[i]) == NULL)
10959 {
10960 //pWrite(p);
10961 //pWrite(strat->S[i]);
10962 while(ok == FALSE && p != NULL)
10963 {
10964 if(pLmDivisibleBy(strat->S[i], p)
10965#ifdef HAVE_SHIFTBBA
10966 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
10967#endif
10968 )
10969 {
10970 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
10971 p_SetCoeff(p,dummy,currRing);
10972 }
10973 if(nIsZero(p->coef))
10974 {
10975 pLmDelete(&p);
10976 h->p = p;
10977 deleted = TRUE;
10978 }
10979 else
10980 {
10981 ok = TRUE;
10982 }
10983 }
10984 if (p!=NULL)
10985 {
10986 pp = pNext(p);
10987 while(pp != NULL)
10988 {
10989 if(pLmDivisibleBy(strat->S[i], pp)
10990#ifdef HAVE_SHIFTBBA
10991 || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
10992#endif
10993 )
10994 {
10995 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
10996 p_SetCoeff(pp,dummy,currRing);
10997 if(nIsZero(pp->coef))
10998 {
10999 pLmDelete(&pNext(p));
11000 pp = pNext(p);
11001 deleted = TRUE;
11002 }
11003 else
11004 {
11005 p = pp;
11006 pp = pNext(p);
11007 }
11008 }
11009 else
11010 {
11011 p = pp;
11012 pp = pNext(p);
11013 }
11014 }
11015 }
11016 }
11017 }
11018 h->SetLmCurrRing();
11019 if((deleted)&&(h->p!=NULL))
11020 strat->initEcart(h);
11021}

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 11023 of file kutil.cc.

11024{
11025 if(!nCoeff_is_Z(currRing->cf))
11026 return;
11027 poly hSig = h->sig;
11028 poly pH = h->GetP();
11029 poly p,pp;
11030 p = pH;
11031 bool deleted = FALSE, ok = FALSE;
11032 for(int i = 0; i<=strat->sl; i++)
11033 {
11034 p = pH;
11035 if(pNext(strat->S[i]) == NULL)
11036 {
11037 while(ok == FALSE && p!=NULL)
11038 {
11039 if(pLmDivisibleBy(strat->S[i], p))
11040 {
11041 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11042 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11043 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11044 {
11045 number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
11046 p_SetCoeff(p,dummy,currRing);
11047 }
11048 pDelete(&sigMult);
11049 }
11050 if(nIsZero(p->coef))
11051 {
11052 pLmDelete(&p);
11053 h->p = p;
11054 deleted = TRUE;
11055 }
11056 else
11057 {
11058 ok = TRUE;
11059 }
11060 }
11061 if(p == NULL)
11062 return;
11063 pp = pNext(p);
11064 while(pp != NULL)
11065 {
11066 if(pLmDivisibleBy(strat->S[i], pp))
11067 {
11068 poly sigMult = pDivideM(pHead(p),pHead(strat->S[i]));
11069 sigMult = ppMult_mm(sigMult,pCopy(strat->sig[i]));
11070 if(sigMult!= NULL && pLtCmp(hSig,sigMult) == 1)
11071 {
11072 number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
11073 p_SetCoeff(pp,dummy,currRing);
11074 if(nIsZero(pp->coef))
11075 {
11076 pLmDelete(&pNext(p));
11077 pp = pNext(p);
11078 deleted = TRUE;
11079 }
11080 else
11081 {
11082 p = pp;
11083 pp = pNext(p);
11084 }
11085 }
11086 else
11087 {
11088 p = pp;
11089 pp = pNext(p);
11090 }
11091 pDelete(&sigMult);
11092 }
11093 else
11094 {
11095 p = pp;
11096 pp = pNext(p);
11097 }
11098 }
11099 }
11100 }
11101 h->SetLmCurrRing();
11102 if(deleted)
11103 strat->initEcart(h);
11104
11105}
#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 10780 of file kutil.cc.

10781{
10782 if(!nCoeff_is_Z(currRing->cf))
10783 return NULL;
10784 ideal F = idCopy(Forig);
10785 idSkipZeroes(F);
10786 poly pmon;
10787 ring origR = currRing;
10788 ideal monred = idInit(1,1);
10789 for(int i=0; i<idElem(F); i++)
10790 {
10791 if(pNext(F->m[i]) == NULL)
10792 idInsertPoly(monred, pCopy(F->m[i]));
10793 }
10794 int posconst = idPosConstant(F);
10795 if((posconst != -1) && (!nIsZero(F->m[posconst]->coef)))
10796 {
10797 idDelete(&F);
10798 idDelete(&monred);
10799 return NULL;
10800 }
10801 int idelemQ = 0;
10802 if(Q!=NULL)
10803 {
10804 idelemQ = IDELEMS(Q);
10805 for(int i=0; i<idelemQ; i++)
10806 {
10807 if(pNext(Q->m[i]) == NULL)
10808 idInsertPoly(monred, pCopy(Q->m[i]));
10809 }
10810 idSkipZeroes(monred);
10811 posconst = idPosConstant(monred);
10812 //the constant, if found, will be from Q
10813 if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef)))
10814 {
10815 pmon = pCopy(monred->m[posconst]);
10816 idDelete(&F);
10817 idDelete(&monred);
10818 return pmon;
10819 }
10820 }
10821 ring QQ_ring = rCopy0(currRing,FALSE);
10822 nKillChar(QQ_ring->cf);
10823 QQ_ring->cf = nInitChar(n_Q, NULL);
10824 rComplete(QQ_ring,1);
10825 QQ_ring = rAssure_c_dp(QQ_ring);
10826 rChangeCurrRing(QQ_ring);
10827 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10828 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
10829 for(int i = 0, j = 0; i<IDELEMS(F); i++)
10830 II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring);
10831 for(int i = 0, j = IDELEMS(F); i<idelemQ; i++)
10832 II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring);
10833 ideal one = kStd(II, NULL, isNotHomog, NULL);
10834 idSkipZeroes(one);
10835 if(idIsConstant(one))
10836 {
10837 //one should be <1>
10838 for(int i = IDELEMS(II)-1; i>=0; i--)
10839 if(II->m[i] != NULL)
10840 II->m[i+1] = II->m[i];
10841 II->m[0] = pOne();
10842 ideal syz = idSyzygies(II, isNotHomog, NULL);
10843 poly integer = NULL;
10844 for(int i = IDELEMS(syz)-1;i>=0; i--)
10845 {
10846 if(pGetComp(syz->m[i]) == 1)
10847 {
10848 pSetComp(syz->m[i],0);
10849 if(pIsConstant(pHead(syz->m[i])))
10850 {
10851 integer = pHead(syz->m[i]);
10852 break;
10853 }
10854 }
10855 }
10856 rChangeCurrRing(origR);
10857 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10858 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10859 idDelete(&monred);
10860 idDelete(&F);
10861 id_Delete(&II,QQ_ring);
10862 id_Delete(&one,QQ_ring);
10863 id_Delete(&syz,QQ_ring);
10864 p_Delete(&integer,QQ_ring);
10865 rDelete(QQ_ring);
10866 return pmon;
10867 }
10868 else
10869 {
10870 if(idIs0(monred))
10871 {
10872 poly mindegmon = NULL;
10873 for(int i = 0; i<IDELEMS(one); i++)
10874 {
10875 if(pNext(one->m[i]) == NULL)
10876 {
10877 if(mindegmon == NULL)
10878 mindegmon = pCopy(one->m[i]);
10879 else
10880 {
10881 if(p_Deg(one->m[i], QQ_ring) < p_Deg(mindegmon, QQ_ring))
10882 mindegmon = pCopy(one->m[i]);
10883 }
10884 }
10885 }
10886 if(mindegmon != NULL)
10887 {
10888 for(int i = IDELEMS(II)-1; i>=0; i--)
10889 if(II->m[i] != NULL)
10890 II->m[i+1] = II->m[i];
10891 II->m[0] = pCopy(mindegmon);
10892 ideal syz = idSyzygies(II, isNotHomog, NULL);
10893 bool found = FALSE;
10894 for(int i = IDELEMS(syz)-1;i>=0; i--)
10895 {
10896 if(pGetComp(syz->m[i]) == 1)
10897 {
10898 pSetComp(syz->m[i],0);
10899 if(pIsConstant(pHead(syz->m[i])))
10900 {
10901 pSetCoeff(mindegmon, nCopy(syz->m[i]->coef));
10902 found = TRUE;
10903 break;
10904 }
10905 }
10906 }
10907 id_Delete(&syz,QQ_ring);
10908 if (found == FALSE)
10909 {
10910 rChangeCurrRing(origR);
10911 idDelete(&monred);
10912 idDelete(&F);
10913 id_Delete(&II,QQ_ring);
10914 id_Delete(&one,QQ_ring);
10915 rDelete(QQ_ring);
10916 return NULL;
10917 }
10918 rChangeCurrRing(origR);
10919 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10920 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10921 idDelete(&monred);
10922 idDelete(&F);
10923 id_Delete(&II,QQ_ring);
10924 id_Delete(&one,QQ_ring);
10925 id_Delete(&syz,QQ_ring);
10926 rDelete(QQ_ring);
10927 return pmon;
10928 }
10929 }
10930 }
10931 rChangeCurrRing(origR);
10932 idDelete(&monred);
10933 idDelete(&F);
10934 id_Delete(&II,QQ_ring);
10935 id_Delete(&one,QQ_ring);
10936 rDelete(QQ_ring);
10937 return NULL;
10938}
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:723
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:358
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:526
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:2430
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:3400
ring rAssure_c_dp(const ring r)
Definition: ring.cc:4937
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1363
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:449
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int idElem(const ideal F)
count non-zero elements
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
@ isNotHomog
Definition: structs.h:41

◆ redFirstShift()

int redFirstShift ( LObject h,
kStrategy  strat 
)

Definition at line 4724 of file kstd2.cc.

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

◆ redHomog()

int redHomog ( LObject h,
kStrategy  strat 
)

Definition at line 929 of file kstd2.cc.

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

◆ redHoney()

int redHoney ( LObject h,
kStrategy  strat 
)

Definition at line 1892 of file kstd2.cc.

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

◆ redLazy()

int redLazy ( LObject h,
kStrategy  strat 
)

TEST_OPT_REDTHROUGH &&

Definition at line 1687 of file kstd2.cc.

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

◆ redLiftstd()

int redLiftstd ( LObject h,
kStrategy  strat 
)

Definition at line 152 of file kLiftstd.cc.

153{
154 if (strat->tl<0) return 1;
155 assume(h->FDeg == h->pFDeg());
157 poly h_p;
158 int i,j,pass,ei, ii, h_d,ci;
159 unsigned long not_sev;
160 long reddeg,d;
161 number A[500];
162 poly C[500];
163 poly T[500];
164 memset(T,0,sizeof(T));
165 memset(C,0,sizeof(T));
166 const ring tailRing=strat->tailRing;
167
168 pass = j = 0;
169 d = reddeg = h->GetpFDeg() + h->ecart;
170 h->SetShortExpVector();
171 int li;
172 h_p = h->GetLmTailRing();
173 not_sev = ~ h->sev;
174
175 // split h into mina part (h) and tail (h_tail)
176 poly h_tail=kSplitAt(strat->syzComp,h,strat);
177 // fix h-pLength
178 h->pLength=0;
179 // remove content
180 //number cont;
181 //p_Content_n(h_p,cont,strat->tailRing);
182 //if (!n_IsOne(cont,strat->tailRing))
183 // h_tail=p_Div_nn(h_tail,cont,tailRing);
184
185 h->PrepareRed(strat->use_buckets);
186 loop
187 {
188 j=kFindDivisibleByInT(strat, h);
189 if (j < 0)
190 {
191 // lazy computation:
192 int l;
193 poly p=lazyComp(A,C,T,pass,h_tail,&l,strat->tailRing);
194 kBucket_Add_q(h->bucket,p,&l);
195 return 1;
196 }
197
198 ei = strat->T[j].ecart;
199 li = strat->T[j].pLength;
200 ci = nSize(pGetCoeff(strat->T[j].p));
201 ii = j;
202 /*
203 * the polynomial to reduce with (up to the moment) is;
204 * pi with ecart ei (T[ii])
205 */
206 i = j;
207 if (TEST_OPT_LENGTH)
208 {
209 if (li<=0) li=strat->T[j].GetpLength();
210 if (li>1)
211 loop
212 {
213 /*- possible with respect to ecart, minimal nSize -*/
214 i++;
215 if (i > strat->tl)
216 break;
217 //if (ei < h->ecart)
218 // break;
219 if ((((strat->T[i].ecart < ei) && (ei> h->ecart))
220 || ((strat->T[i].ecart <= h->ecart)
221 && (strat->T[i].pLength <= li)
222 && (nSize(pGetCoeff(strat->T[i].p)) <ci)))
223 &&
224 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
225 h_p, not_sev, tailRing))
226 {
227 /*
228 * the polynomial to reduce with is now;
229 */
230 ei = strat->T[i].ecart;
231 li = strat->T[i].pLength;
232 if (li<=0) li=strat->T[i].GetpLength();
233 ii = i;
234 if (li==1) break;
235 }
236 }
237 }
238
239 /*
240 * end of search: have to reduce with pi
241 */
242#ifdef KDEBUG
243 if (TEST_OPT_DEBUG)
244 {
245 PrintS("red:");
246 h->wrp();
247 Print("\nwith T[%d]:",ii);
248 strat->T[ii].wrp();
249 }
250#endif
251 assume(strat->fromT == FALSE);
252
253 //strat->T[ii].pCleardenom();
254 // split T[ii]:
255 // remember pLength of strat->T[ii]
256 int l_orig=strat->T[ii].pLength;
257 // split strat->T[ii]
258 poly T_tail=kSplitAt(strat->syzComp,&strat->T[ii],strat);
259 h->pLength=0; // force re-computation of length
260 ksReducePoly(h,&(strat->T[ii]),NULL,&A[pass],&C[pass], strat);
261 // restore T[ii]:
262 kAppend(T_tail,&strat->T[ii]);
263 strat->T[ii].pLength=l_orig;
264 // store T_tail
265 T[pass]=T_tail;
266 // delayed computation: A[pass]*tail-M[pass]*T[pass]
267#ifdef KDEBUG
268 if (TEST_OPT_DEBUG)
269 {
270 PrintS("\nto:");
271 h->wrp();
272 PrintLn();
273 }
274#endif
275 if(h->IsNull())
276 {
277 // clean up A,C,h_tail:
278 for(int i=0;i<=pass;i++)
279 {
280 n_Delete(&A[i],tailRing->cf);
281 p_Delete(&C[i],tailRing);
282 }
283 p_Delete(&h_tail,tailRing);
284 kDeleteLcm(h);
285 h->Clear();
286 return 0;
287 }
288 h->SetShortExpVector();
289 not_sev = ~ h->sev;
290 h_d = h->SetpFDeg();
291 /* compute the ecart */
292 if (ei <= h->ecart)
293 h->ecart = d-h_d;
294 else
295 h->ecart = d-h_d+ei-h->ecart;
296
297 /*
298 * try to reduce the s-polynomial h
299 *test first whether h should go to the lazyset L
300 *-if the degree jumps
301 *-if the number of pre-defined reductions jumps
302 */
303 pass++;
304 d = h_d + h->ecart;
305 if (pass%RED_CANONICALIZE==0) kBucketCanonicalize(h->bucket);
306 }
307}
static poly lazyComp(number *A, poly *M, poly *T, int index, poly s, int *l, const ring tailR)
Definition: kLiftstd.cc:118
static void kAppend(poly t, TObject *h)
Definition: kLiftstd.cc:107
static poly kSplitAt(int k, TObject *h, kStrategy strat)
Definition: kLiftstd.cc:27
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 2126 of file kstd2.cc.

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

◆ redNF0()

int redNF0 ( LObject P,
kStrategy  strat 
)

◆ redNFTail()

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

◆ redRiloc()

int redRiloc ( LObject h,
kStrategy  strat 
)

Definition at line 385 of file kstd1.cc.

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

◆ redRing()

int redRing ( LObject h,
kStrategy  strat 
)

Definition at line 822 of file kstd2.cc.

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

◆ redRing_Z()

int redRing_Z ( LObject h,
kStrategy  strat 
)

Definition at line 667 of file kstd2.cc.

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

◆ redSig()

int redSig ( LObject h,
kStrategy  strat 
)

Definition at line 1149 of file kstd2.cc.

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

◆ redSigRing()

int redSigRing ( LObject h,
kStrategy  strat 
)

Definition at line 1317 of file kstd2.cc.

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

◆ redtail() [1/2]

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

Definition at line 7069 of file kutil.cc.

7070{
7071 poly h, hn;
7072 strat->redTailChange=FALSE;
7073
7074 L->GetP();
7075 poly p = L->p;
7076 if (strat->noTailReduction || pNext(p) == NULL)
7077 return p;
7078
7079 LObject Ln(strat->tailRing);
7080 TObject* With;
7081 // placeholder in case strat->tl < 0
7082 TObject With_s(strat->tailRing);
7083 h = p;
7084 hn = pNext(h);
7085 long op = strat->tailRing->pFDeg(hn, strat->tailRing);
7086 long e;
7087 int l;
7088 BOOLEAN save_HE=strat->kHEdgeFound;
7089 strat->kHEdgeFound |=
7090 ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
7091
7092 while(hn != NULL)
7093 {
7094 op = strat->tailRing->pFDeg(hn, strat->tailRing);
7095 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7096 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7097 loop
7098 {
7099 Ln.Set(hn, strat->tailRing);
7100 Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
7101 if (strat->kHEdgeFound)
7102 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7103 else
7104 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s, e);
7105 if (With == NULL) break;
7106 With->length=0;
7107 With->pLength=0;
7108 strat->redTailChange=TRUE;
7109 if (ksReducePolyTail(L, With, h, strat->kNoetherTail()))
7110 {
7111 // reducing the tail would violate the exp bound
7112 if (kStratChangeTailRing(strat, L))
7113 {
7114 strat->kHEdgeFound = save_HE;
7115 return redtail(L, end_pos, strat);
7116 }
7117 else
7118 return NULL;
7119 }
7120 hn = pNext(h);
7121 if (hn == NULL) goto all_done;
7122 op = strat->tailRing->pFDeg(hn, strat->tailRing);
7123 if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done;
7124 e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op;
7125 }
7126 h = hn;
7127 hn = pNext(h);
7128 }
7129
7130 all_done:
7131 if (strat->redTailChange)
7132 {
7133 L->pLength = 0;
7134 }
7135 strat->kHEdgeFound = save_HE;
7136 return p;
7137}
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
Definition: kutil.cc:6927
#define TEST_OPT_INFREDTAIL
Definition: options.h:118

◆ redtail() [2/2]

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

Definition at line 7139 of file kutil.cc.

7140{
7141 LObject L(p, currRing);
7142 return redtail(&L, end_pos, strat);
7143}

◆ redtailBba() [1/3]

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

Definition at line 7145 of file kutil.cc.

7146{
7147 strat->redTailChange=FALSE;
7148 if (strat->noTailReduction) return L->GetLmCurrRing();
7149 poly h, p;
7150 p = h = L->GetLmTailRing();
7151 if ((h==NULL) || (pNext(h)==NULL))
7152 return L->GetLmCurrRing();
7153
7154 TObject* With;
7155 // placeholder in case strat->tl < 0
7156 TObject With_s(strat->tailRing);
7157
7158 LObject Ln(pNext(h), strat->tailRing);
7159 Ln.GetpLength();
7160
7161 pNext(h) = NULL;
7162 if (L->p != NULL)
7163 {
7164 pNext(L->p) = NULL;
7165 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7166 }
7167 L->pLength = 1;
7168
7169 Ln.PrepareRed(strat->use_buckets);
7170
7171 int cnt=REDTAIL_CANONICALIZE;
7172 while(!Ln.IsNull())
7173 {
7174 loop
7175 {
7176 if (TEST_OPT_IDLIFT)
7177 {
7178 if (Ln.p!=NULL)
7179 {
7180 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7181 }
7182 else
7183 {
7184 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7185 }
7186 }
7187 Ln.SetShortExpVector();
7188 if (withT)
7189 {
7190 int j;
7191 j = kFindDivisibleByInT(strat, &Ln);
7192 if (j < 0) break;
7193 With = &(strat->T[j]);
7194 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7195 }
7196 else
7197 {
7198 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7199 if (With == NULL) break;
7200 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7201 }
7202 cnt--;
7203 if (cnt==0)
7204 {
7206 /*poly tmp=*/Ln.CanonicalizeP();
7207 if (normalize)
7208 {
7209 Ln.Normalize();
7210 //pNormalize(tmp);
7211 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
7212 }
7213 }
7214 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
7215 {
7216 With->pNorm();
7217 }
7218 strat->redTailChange=TRUE;
7219 if (ksReducePolyTail(L, With, &Ln))
7220 {
7221 // reducing the tail would violate the exp bound
7222 // set a flag and hope for a retry (in bba)
7224 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7225 do
7226 {
7227 pNext(h) = Ln.LmExtractAndIter();
7228 pIter(h);
7229 L->pLength++;
7230 } while (!Ln.IsNull());
7231 goto all_done;
7232 }
7233 if (Ln.IsNull()) goto all_done;
7234 if (! withT) With_s.Init(currRing);
7235 }
7236 pNext(h) = Ln.LmExtractAndIter();
7237 pIter(h);
7238 pNormalize(h);
7239 L->pLength++;
7240 }
7241
7242 all_done:
7243 Ln.Delete();
7244 if (L->p != NULL) pNext(L->p) = pNext(p);
7245
7246 if (strat->redTailChange)
7247 {
7248 L->length = 0;
7249 L->pLength = 0;
7250 }
7251
7252 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7253 //L->Normalize(); // HANNES: should have a test
7254 kTest_L(L,strat->tailRing);
7255 return L->GetLmCurrRing();
7256}
CanonicalForm normalize(const CanonicalForm &F)
normalize a poly, i.e. in char 0 clear denominators, remove integer content in char p divide by leadi...
#define REDTAIL_CANONICALIZE
Definition: kutil.h:38

◆ redtailBba() [2/3]

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

Definition at line 1180 of file kInline.h.

1181{
1182 LObject L(p);
1183 return redtailBba(&L, pos, strat,FALSE, normalize);
1184}

◆ redtailBba() [3/3]

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

◆ redtailBba_Ring() [1/2]

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

Definition at line 7617 of file kutil.cc.

7619{
7620 strat->redTailChange=FALSE;
7621 if (strat->noTailReduction) return L->GetLmCurrRing();
7622 poly h, p;
7623 p = h = L->GetLmTailRing();
7624 if ((h==NULL) || (pNext(h)==NULL))
7625 return L->GetLmCurrRing();
7626
7627 TObject* With;
7628 // placeholder in case strat->tl < 0
7629 TObject With_s(strat->tailRing);
7630
7631 LObject Ln(pNext(h), strat->tailRing);
7632 Ln.pLength = L->GetpLength() - 1;
7633
7634 pNext(h) = NULL;
7635 if (L->p != NULL) pNext(L->p) = NULL;
7636 L->pLength = 1;
7637
7638 Ln.PrepareRed(strat->use_buckets);
7639
7640 int cnt=REDTAIL_CANONICALIZE;
7641 while(!Ln.IsNull())
7642 {
7643 loop
7644 {
7645 Ln.SetShortExpVector();
7646 With_s.Init(currRing);
7647 With = kFindDivisibleByInS_T(strat, end_pos, &Ln, &With_s);
7648 if (With == NULL) break;
7649 cnt--;
7650 if (cnt==0)
7651 {
7653 /*poly tmp=*/Ln.CanonicalizeP();
7654 }
7655 // we are in a ring, do not call pNorm
7656 // test divisibility of coefs:
7657 poly p_Ln=Ln.GetLmCurrRing();
7658 poly p_With=With->GetLmCurrRing();
7659 if (n_DivBy(pGetCoeff(p_Ln),pGetCoeff(p_With), currRing->cf))
7660 {
7661 strat->redTailChange=TRUE;
7662
7663 if (ksReducePolyTail_Z(L, With, &Ln))
7664 {
7665 // reducing the tail would violate the exp bound
7666 // set a flag and hope for a retry (in bba)
7668 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7669 do
7670 {
7671 pNext(h) = Ln.LmExtractAndIter();
7672 pIter(h);
7673 L->pLength++;
7674 } while (!Ln.IsNull());
7675 goto all_done;
7676 }
7677 }
7678 else break; /*proceed to next monomial*/
7679 if (Ln.IsNull()) goto all_done;
7680 }
7681 pNext(h) = Ln.LmExtractAndIter();
7682 pIter(h);
7683 pNormalize(h);
7684 L->pLength++;
7685 }
7686
7687 all_done:
7688 Ln.Delete();
7689 if (L->p != NULL) pNext(L->p) = pNext(p);
7690
7691 if (strat->redTailChange)
7692 {
7693 L->length = 0;
7694 }
7695
7696 //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
7697 //L->Normalize(); // HANNES: should have a test
7698 kTest_L(L,strat->tailRing);
7699 return L->GetLmCurrRing();
7700}
KINLINE int ksReducePolyTail_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1095

◆ redtailBba_Ring() [2/2]

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

Definition at line 1193 of file kInline.h.

1194{
1195 LObject L(p, currRing, strat->tailRing);
1196 return redtailBba_Ring(&L, pos, strat);
1197}

◆ redtailBba_Z() [1/2]

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

Definition at line 7503 of file kutil.cc.

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

◆ redtailBba_Z() [2/2]

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

Definition at line 1198 of file kInline.h.

1199{
1200 LObject L(p, currRing, strat->tailRing);
1201 return redtailBba_Z(&L, pos, strat);
1202}

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7374 of file kutil.cc.

7376{
7377 strat->redTailChange=FALSE;
7378
7379 poly h, p;
7380 p = h = L->GetLmTailRing();
7381 if ((h==NULL) || (pNext(h)==NULL))
7382 return;
7383
7384 TObject* With;
7385 LObject Ln(pNext(h), strat->tailRing);
7386 Ln.GetpLength();
7387
7388 pNext(h) = NULL;
7389 if (L->p != NULL)
7390 {
7391 pNext(L->p) = NULL;
7392 if (L->t_p != NULL) pNext(L->t_p) = NULL;
7393 }
7394 L->pLength = 1;
7395
7396 Ln.PrepareRed(strat->use_buckets);
7397
7398 int cnt=REDTAIL_CANONICALIZE;
7399
7400 while(!Ln.IsNull())
7401 {
7402 loop
7403 {
7404 if (TEST_OPT_IDLIFT)
7405 {
7406 if (Ln.p!=NULL)
7407 {
7408 if (__p_GetComp(Ln.p,currRing)> strat->syzComp) break;
7409 }
7410 else
7411 {
7412 if (__p_GetComp(Ln.t_p,strat->tailRing)> strat->syzComp) break;
7413 }
7414 }
7415 Ln.SetShortExpVector();
7416 int j;
7417 j = kFindDivisibleByInT(strat, &Ln);
7418 if (j < 0)
7419 {
7420 j = kFindDivisibleByInT_Z(strat, &Ln);
7421 if (j < 0)
7422 {
7423 break;
7424 }
7425 else
7426 {
7427 /* reduction not cancelling a tail term, but reducing its coefficient */
7428 With = &(strat->T[j]);
7429 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7430 cnt--;
7431 if (cnt==0)
7432 {
7434 /*poly tmp=*/Ln.CanonicalizeP();
7435 }
7436 strat->redTailChange=TRUE;
7437 /* reduction cancelling a tail term */
7438 if (ksReducePolyTailLC_Z(L, With, &Ln))
7439 {
7440 // reducing the tail would violate the exp bound
7441 // set a flag and hope for a retry (in bba)
7443 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7444 do
7445 {
7446 pNext(h) = Ln.LmExtractAndIter();
7447 pIter(h);
7448 L->pLength++;
7449 } while (!Ln.IsNull());
7450 goto all_done;
7451 }
7452 /* we have to break since we did not cancel the term, but only decreased
7453 * its coefficient. */
7454 break;
7455 }
7456 } else {
7457 With = &(strat->T[j]);
7458 assume(With->GetpLength()==pLength(With->p != __null ? With->p : With->t_p));
7459 cnt--;
7460 if (cnt==0)
7461 {
7463 /*poly tmp=*/Ln.CanonicalizeP();
7464 }
7465 strat->redTailChange=TRUE;
7466 /* reduction cancelling a tail term */
7467 if (ksReducePolyTail_Z(L, With, &Ln))
7468 {
7469 // reducing the tail would violate the exp bound
7470 // set a flag and hope for a retry (in bba)
7472 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
7473 do
7474 {
7475 pNext(h) = Ln.LmExtractAndIter();
7476 pIter(h);
7477 L->pLength++;
7478 } while (!Ln.IsNull());
7479 goto all_done;
7480 }
7481 }
7482 if (Ln.IsNull()) goto all_done;
7483 }
7484 pNext(h) = Ln.LmExtractAndIter();
7485 pIter(h);
7486 L->pLength++;
7487 }
7488
7489 all_done:
7490 Ln.Delete();
7491 if (L->p != NULL) pNext(L->p) = pNext(p);
7492
7493 if (strat->redTailChange)
7494 {
7495 L->length = 0;
7496 L->pLength = 0;
7497 }
7498
7499 kTest_L(L, strat->tailRing);
7500 return;
7501}
KINLINE int ksReducePolyTailLC_Z(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1077

◆ redtailBbaBound() [1/2]

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

Definition at line 7258 of file kutil.cc.

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

◆ redtailBbaBound() [2/2]

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

Definition at line 1186 of file kInline.h.

1187{
1188 LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1189 return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1190}

◆ redtailBbaShift()

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

Definition at line 13362 of file kutil.cc.

13363{
13364 /* for the shift case need to run it with withT = TRUE */
13365 strat->redTailChange=FALSE;
13366 if (strat->noTailReduction) return L->GetLmCurrRing();
13367 poly h, p;
13368 p = h = L->GetLmTailRing();
13369 if ((h==NULL) || (pNext(h)==NULL))
13370 return L->GetLmCurrRing();
13371
13372 TObject* With;
13373 // placeholder in case strat->tl < 0
13374 TObject With_s(strat->tailRing);
13375
13376 LObject Ln(pNext(h), strat->tailRing);
13377 Ln.pLength = L->GetpLength() - 1;
13378
13379 pNext(h) = NULL;
13380 if (L->p != NULL) pNext(L->p) = NULL;
13381 L->pLength = 1;
13382
13383 Ln.PrepareRed(strat->use_buckets);
13384
13385 while(!Ln.IsNull())
13386 {
13387 loop
13388 {
13389 Ln.SetShortExpVector();
13390 if (withT)
13391 {
13392 int j;
13393 j = kFindDivisibleByInT(strat, &Ln);
13394 if (j < 0) break;
13395 With = &(strat->T[j]);
13396 }
13397 else
13398 {
13399 With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s);
13400 if (With == NULL) break;
13401 }
13402 if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p))))
13403 {
13404 With->pNorm();
13405 //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
13406 }
13407 strat->redTailChange=TRUE;
13408 if (ksReducePolyTail(L, With, &Ln))
13409 {
13410 // reducing the tail would violate the exp bound
13411 // set a flag and hope for a retry (in bba)
13413 if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL;
13414 do
13415 {
13416 pNext(h) = Ln.LmExtractAndIter();
13417 pIter(h);
13418 L->pLength++;
13419 } while (!Ln.IsNull());
13420 goto all_done;
13421 }
13422 if (Ln.IsNull()) goto all_done;
13423 if (! withT) With_s.Init(currRing);
13424 }
13425 pNext(h) = Ln.LmExtractAndIter();
13426 pIter(h);
13427 L->pLength++;
13428 }
13429
13430 all_done:
13431 Ln.Delete();
13432 if (L->p != NULL) pNext(L->p) = pNext(p);
13433
13434 if (strat->redTailChange)
13435 {
13436 L->length = 0;
13437 }
13438 L->Normalize(); // HANNES: should have a test
13439 kTest_L(L,strat->tailRing);
13440 return L->GetLmCurrRing();
13441}

◆ redtailSba()

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

Definition at line 1567 of file kstd2.cc.

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

◆ reorderS()

void reorderS ( int *  suc,
kStrategy  strat 
)

Definition at line 4648 of file kutil.cc.

4649{
4650 int i,j,at,ecart, s2r;
4651 int fq=0;
4652 unsigned long sev;
4653 poly p;
4654 int new_suc=strat->sl+1;
4655 i= *suc;
4656 if (i<0) i=0;
4657
4658 for (; i<=strat->sl; i++)
4659 {
4660 at = posInS(strat,i-1,strat->S[i],strat->ecartS[i]);
4661 if (at != i)
4662 {
4663 if (new_suc > at) new_suc = at;
4664 p = strat->S[i];
4665 ecart = strat->ecartS[i];
4666 sev = strat->sevS[i];
4667 s2r = strat->S_2_R[i];
4668 if (strat->fromQ!=NULL) fq=strat->fromQ[i];
4669 for (j=i; j>=at+1; j--)
4670 {
4671 strat->S[j] = strat->S[j-1];
4672 strat->ecartS[j] = strat->ecartS[j-1];
4673 strat->sevS[j] = strat->sevS[j-1];
4674 strat->S_2_R[j] = strat->S_2_R[j-1];
4675 }
4676 strat->S[at] = p;
4677 strat->ecartS[at] = ecart;
4678 strat->sevS[at] = sev;
4679 strat->S_2_R[at] = s2r;
4680 if (strat->fromQ!=NULL)
4681 {
4682 for (j=i; j>=at+1; j--)
4683 {
4684 strat->fromQ[j] = strat->fromQ[j-1];
4685 }
4686 strat->fromQ[at]=fq;
4687 }
4688 }
4689 }
4690 if (new_suc <= strat->sl) *suc=new_suc;
4691 else *suc=-1;
4692}

◆ replaceInLAndSAndT()

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

Definition at line 9281 of file kutil.cc.

9282{
9283 p.GetP(strat->lmBin);
9284 if (strat->homog) strat->initEcart(&p);
9285 strat->redTailChange=FALSE;
9287 {
9288 p.pCleardenom();
9290 {
9291#ifdef HAVE_SHIFTBBA
9292 if (rIsLPRing(currRing))
9293 p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
9294 else
9295#endif
9296 {
9297 p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
9298 }
9299 p.pCleardenom();
9300 if (strat->redTailChange)
9301 p.t_p=NULL;
9302 if (strat->P.p!=NULL) strat->P.sev=p_GetShortExpVector(strat->P.p,currRing);
9303 else strat->P.sev=0;
9304 }
9305 }
9306
9307 assume(strat->tailRing == p.tailRing);
9308 assume(p.pLength == 0 || pLength(p.p) == p.pLength || rIsSyzIndexRing(currRing)); // modulo syzring
9309
9310 int i, j, pos;
9311 poly tp = strat->T[tj].p;
9312
9313 /* enter p to T set */
9314 enterT(p, strat);
9315
9316 for (j = 0; j <= strat->sl; ++j)
9317 {
9318 if (pLtCmp(tp, strat->S[j]) == 0)
9319 {
9320 break;
9321 }
9322 }
9323 /* it may be that the exchanged element
9324 * is until now only in T and not in S */
9325 if (j <= strat->sl)
9326 {
9327 deleteInS(j, strat);
9328 }
9329
9330 pos = posInS(strat, strat->sl, p.p, p.ecart);
9331
9332 pp_Test(p.p, currRing, p.tailRing);
9333 assume(p.FDeg == p.pFDeg());
9334
9335 /* remove useless pairs from L set */
9336 for (i = 0; i <= strat->Ll; ++i)
9337 {
9338 if (strat->L[i].p1 != NULL && pLtCmp(tp, strat->L[i].p1) == 0)
9339 {
9340 deleteInL(strat->L, &(strat->Ll), i, strat);
9341 i--;
9342 continue;
9343 }
9344 if (strat->L[i].p2 != NULL && pLtCmp(tp, strat->L[i].p2) == 0)
9345 {
9346 deleteInL(strat->L, &(strat->Ll), i, strat);
9347 i--;
9348 }
9349 }
9350#ifdef HAVE_SHIFTBBA
9351 if (rIsLPRing(currRing))
9352 enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
9353 else
9354#endif
9355 {
9356 /* generate new pairs with p, probably removing older, now useless pairs */
9357 superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
9358 }
9359 /* enter p to S set */
9360 strat->enterS(p, pos, strat, strat->tl);
9361
9362#ifdef HAVE_SHIFTBBA
9363 /* do this after enterS so that the index in R (which is strat->tl) is correct */
9364 if (rIsLPRing(currRing) && !strat->rightGB)
9365 enterTShift(p,strat);
9366#endif
9367}

◆ sba()

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

Definition at line 2734 of file kstd2.cc.

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

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject h,
kStrategy  strat 
)

Definition at line 1722 of file kutil.cc.

1723{
1724 if(strat->sl < 0) return FALSE;
1725 int i;
1726 for(i=0;i<strat->sl;i++)
1727 {
1728 //Construct the gcd pair between h and S[i]
1729 number d, s, t;
1730 poly m1, m2, gcd;
1731 d = n_ExtGcd(pGetCoeff(h->p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1732 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1733 {
1734 nDelete(&d);
1735 nDelete(&s);
1736 nDelete(&t);
1737 }
1738 else
1739 {
1740 k_GetStrongLeadTerms(h->p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing);
1741 pSetCoeff0(m1, s);
1742 pSetCoeff0(m2, t);
1743 pSetCoeff0(gcd, d);
1744 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);
1745 poly pSigMult = p_Copy(h->sig,currRing);
1746 poly sSigMult = p_Copy(strat->sig[i],currRing);
1747 pSigMult = p_Mult_mm(pSigMult,m1,currRing);
1748 sSigMult = p_Mult_mm(sSigMult,m2,currRing);
1749 p_LmDelete(m1, strat->tailRing);
1750 p_LmDelete(m2, strat->tailRing);
1751 poly pairsig = p_Add_q(pSigMult,sSigMult,currRing);
1752 if(pairsig!= NULL && pLtCmp(pairsig,h->sig) == 0)
1753 {
1754 pDelete(&h->p);
1755 h->p = gcd;
1756 pDelete(&h->sig);
1757 h->sig = pairsig;
1758 pNext(h->sig) = NULL;
1759 strat->initEcart(h);
1760 h->sev = pGetShortExpVector(h->p);
1761 h->sevSig = pGetShortExpVector(h->sig);
1762 h->i_r1 = -1;h->i_r2 = -1;
1763 if(h->lcm != NULL)
1764 {
1765 pLmDelete(h->lcm);
1766 h->lcm = NULL;
1767 }
1768 if (currRing!=strat->tailRing)
1769 h->t_p = k_LmInit_currRing_2_tailRing(h->p, strat->tailRing);
1770 return TRUE;
1771 }
1772 //Delete what you didn't use
1773 pDelete(&gcd);
1774 pDelete(&pairsig);
1775 }
1776 }
1777 return FALSE;
1778}
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:1029
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:991

◆ sbaRing()

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

Definition at line 11333 of file kutil.cc.

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

4495{
4497#if HAVE_SHIFTBBA
4498 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4499#endif
4500 // enter also zero divisor * poly, if this is non zero and of smaller degree
4502 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4503 initenterpairs(h, k, ecart, 0, strat, atR);
4504 clearSbatch(h, k, pos, strat);
4505}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition: kutil.cc:4468
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4185
void enterExtendedSpoly(poly h, kStrategy strat)
Definition: kutil.cc:4267

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

4508{
4510 // enter also zero divisor * poly, if this is non zero and of smaller degree
4511 if (!(rField_is_Domain(currRing))) enterExtendedSpolySig(h, hSig, strat);
4512 if(strat->sigdrop) return;
4513 initenterpairsSigRing(h, hSig, hFrom, k, ecart, 0, strat, atR);
4514 if(strat->sigdrop) return;
4515 initenterstrongPairsSig(h, hSig, k, ecart, 0, strat, atR);
4516 if(strat->sigdrop) return;
4517 clearSbatch(h, k, pos, strat);
4518}
void initenterpairsSigRing(poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:3965
static void initenterstrongPairsSig(poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition: kutil.cc:4240
void enterExtendedSpolySig(poly h, poly hSig, kStrategy strat)
Definition: kutil.cc:4350

◆ syzCriterion()

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

Definition at line 6708 of file kutil.cc.

6709{
6710//#if 1
6711#ifdef DEBUGF5
6712 PrintS("syzygy criterion checks: ");
6713 pWrite(sig);
6714#endif
6715 for (int k=0; k<strat->syzl; k++)
6716 {
6717 //printf("-%d",k);
6718//#if 1
6719#ifdef DEBUGF5
6720 Print("checking with: %d / %d -- \n",k,strat->syzl);
6721 pWrite(pHead(strat->syz[k]));
6722#endif
6723 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6724 && (!rField_is_Ring(currRing) ||
6725 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6726 {
6727//#if 1
6728#ifdef DEBUGF5
6729 PrintS("DELETE!\n");
6730#endif
6731 strat->nrsyzcrit++;
6732 //printf("- T -\n\n");
6733 return TRUE;
6734 }
6735 }
6736 //printf("- F -\n\n");
6737 return FALSE;
6738}

◆ syzCriterionInc()

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

Definition at line 6743 of file kutil.cc.

6744{
6745//#if 1
6746 if(sig == NULL)
6747 return FALSE;
6748#ifdef DEBUGF5
6749 PrintS("--- syzygy criterion checks: ");
6750 pWrite(sig);
6751#endif
6752 int comp = __p_GetComp(sig, currRing);
6753 int min, max;
6754 if (comp<=1)
6755 return FALSE;
6756 else
6757 {
6758 min = strat->syzIdx[comp-2];
6759 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-2],comp-2);
6760 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp-1],comp-1);
6761 //printf("SYZIDX %d/%d\n",strat->syzIdx[comp],comp);
6762 if (comp == strat->currIdx)
6763 {
6764 max = strat->syzl;
6765 }
6766 else
6767 {
6768 max = strat->syzIdx[comp-1];
6769 }
6770 for (int k=min; k<max; k++)
6771 {
6772#ifdef F5DEBUG
6773 Print("COMP %d/%d - MIN %d - MAX %d - SYZL %ld\n",comp,strat->currIdx,min,max,strat->syzl);
6774 Print("checking with: %d -- ",k);
6775 pWrite(pHead(strat->syz[k]));
6776#endif
6777 if (p_LmShortDivisibleBy(strat->syz[k], strat->sevSyz[k], sig, not_sevSig, currRing)
6778 && (!rField_is_Ring(currRing) ||
6779 (n_DivBy(pGetCoeff(sig), pGetCoeff(strat->syz[k]),currRing->cf) && pLtCmp(sig,strat->syz[k]) == 1)))
6780 {
6781 strat->nrsyzcrit++;
6782 return TRUE;
6783 }
6784 }
6785 return FALSE;
6786 }
6787}
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 10320 of file kutil.cc.

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

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8788 of file kutil.cc.

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

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 270 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 874 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 873 of file kutil.h.