My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
kutil.cc File Reference
#include "kernel/mod2.h"
#include "misc/mylimits.h"
#include "misc/options.h"
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#include "polys/weight.h"
#include <stdlib.h>
#include <string.h>
#include "kernel/GBEngine/kutil.h"
#include "polys/kbuckets.h"
#include "coeffs/numbers.h"
#include "kernel/polys.h"
#include "polys/monomials/ring.h"
#include "kernel/ideals.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/GBEngine/kstd1.h"
#include "polys/operations/pShallowCopyDelete.h"
#include "polys/shiftop.h"
#include "polys/prCopy.h"
#include "kernel/GBEngine/ratgring.h"

Go to the source code of this file.

Macros

#define KUTIL_CC
 
#define MYTEST   0
 
#define ALL_VS_JUST   0
 
#define EXT_POLY_NEW   0
 
#define KDEBUG   2
 
#define ENTER_USE_MEMMOVE
 
#define KDEBUG   2
 
#define pDivComp_EQUAL   2
 
#define pDivComp_LESS   1
 
#define pDivComp_GREATER   -1
 
#define pDivComp_INCOMP   0
 
#define kFalseReturn(x)   do { if (!x) return FALSE;} while (0)
 

Functions

static poly redMora (poly h, int maxIndex, kStrategy strat)
 
static poly redBba (poly h, int maxIndex, kStrategy strat)
 
static int pDivCompRing (poly p, poly q)
 
static int pDivComp (poly p, poly q)
 
static int pLPDivComp (poly p, poly q)
 
static void deleteHCBucket (LObject *L, kStrategy strat)
 
void deleteHC (LObject *L, kStrategy strat, BOOLEAN fromNext)
 
void deleteHC (poly *p, int *e, int *l, kStrategy strat)
 
void cancelunit (LObject *L, BOOLEAN inNF)
 
void HEckeTest (poly pp, kStrategy strat)
 
static intset initec (const int maxnr)
 
static unsigned longinitsevS (const int maxnr)
 
static intinitS_2_R (const int maxnr)
 
static void enlargeT (TSet &T, TObject **&R, unsigned long *&sevT, int &length, const int incr)
 
void cleanT (kStrategy strat)
 
void cleanTSbaRing (kStrategy strat)
 
static void enlargeL (LSet *L, int *length, const int incr)
 
void initPairtest (kStrategy strat)
 
BOOLEAN isInPairsetL (int length, poly p1, poly p2, int *k, kStrategy strat)
 
int kFindInT (poly p, TSet T, int tlength)
 returns index of p in TSet, or -1 if not found
 
int kFindInT (poly p, kStrategy strat)
 
int kFindInTShift (poly p, TSet T, int tlength)
 
int kFindInTShift (poly p, kStrategy strat)
 
static const charkTest_LmEqual (poly p, poly t_p, ring tailRing)
 
BOOLEAN kTest_T (TObject *T, kStrategy strat, int i, char TN)
 
BOOLEAN kTest_L (LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
 
BOOLEAN kTest (kStrategy strat)
 
BOOLEAN kTest_S (kStrategy strat)
 
BOOLEAN kTest_TS (kStrategy strat)
 
void deleteInS (int i, kStrategy strat)
 
static BOOLEAN is_shifted_p1 (const poly p, const kStrategy strat)
 
void deleteInL (LSet set, int *length, int j, kStrategy strat)
 
void enterL (LSet *set, int *length, int *LSetmax, LObject p, int at)
 
void initEcartNormal (TObject *h)
 
void initEcartBBA (TObject *h)
 
void initEcartPairBba (LObject *Lp, poly, poly, int, int)
 
void initEcartPairMora (LObject *Lp, poly, poly, int ecartF, int ecartG)
 
static BOOLEAN sugarDivisibleBy (int ecart1, int ecart2)
 
static void enterOnePairRing (int i, poly p, int, int isFromQ, kStrategy strat, int atR)
 
static BOOLEAN enterOneStrongPoly (int i, poly p, int, int, kStrategy strat, int atR, bool enterTstrong)
 
BOOLEAN sbaCheckGcdPair (LObject *h, kStrategy strat)
 
static BOOLEAN enterOneStrongPolySig (int i, poly p, poly sig, int, int, kStrategy strat, int atR)
 
void enterOnePairNormal (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static BOOLEAN p_HasNotCF_Lift (poly p1, poly p2, const ring r)
 p_HasNotCF for the IDLIFT case and syzComp==1: ignore component
 
static void enterOnePairLift (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static void enterOnePairSig (int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static void enterOnePairSigRing (int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void enterOnePairSpecial (int i, poly p, int ecart, kStrategy strat, int atR=-1)
 
void kMergeBintoL (kStrategy strat)
 
void kMergeBintoLSba (kStrategy strat)
 
void chainCritNormal (poly p, int ecart, kStrategy strat)
 
void chainCritOpt_1 (poly, int, kStrategy strat)
 
void chainCritSig (poly p, int, kStrategy strat)
 
void chainCritPart (poly p, int ecart, kStrategy strat)
 
void initenterpairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
 
void initenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void initenterpairsSigRing (poly h, poly hSig, int hFrom, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void chainCritRing (poly p, int, kStrategy strat)
 
void initenterstrongPairs (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
static void initenterstrongPairsSig (poly h, poly hSig, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
 
void enterExtendedSpoly (poly h, kStrategy strat)
 
void enterExtendedSpolySig (poly h, poly hSig, kStrategy strat)
 
void clearSbatch (poly h, int k, int pos, kStrategy strat)
 
void superenterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void superenterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterpairs (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterpairsSig (poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterpairsSpecial (poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
 
void reorderS (int *suc, kStrategy strat)
 
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, int end)
 
int posInT0 (const TSet, const int length, LObject &)
 
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 posInT11Ring (const TSet set, const int length, LObject &p)
 
int posInT110 (const TSet set, const int length, LObject &p)
 
int posInT110Ring (const TSet set, const int length, LObject &p)
 
int posInT13 (const TSet set, const int length, LObject &p)
 
int posInT_EcartpLength (const TSet set, const int length, LObject &p)
 
int posInT15 (const TSet set, const int length, LObject &p)
 
int posInT15Ring (const TSet set, const int length, LObject &p)
 
int posInT17 (const TSet set, const int length, LObject &p)
 
int posInT17Ring (const TSet set, const int length, LObject &p)
 
int posInT17_c (const TSet set, const int length, LObject &p)
 
int posInT17_cRing (const TSet set, const int length, LObject &p)
 
int posInT19 (const TSet set, const int length, LObject &p)
 
int posInLSpecial (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL0 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL0Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInLSig (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInLSigRing (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInSyz (const kStrategy strat, poly sig)
 
int posInLF5C (const LSet, const int, LObject *, const kStrategy strat)
 
int posInL11 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL11Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInLF5CRing (const LSet set, int start, const int length, LObject *p, const kStrategy)
 
int posInL11Ringls (const LSet set, const int length, LObject *p, const kStrategy)
 
int getIndexRng (long coeff)
 
int posInL110 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL110Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL13 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL15 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL15Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17 (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17Ring (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17_c (const LSet set, const int length, LObject *p, const kStrategy)
 
int posInL17_cRing (const LSet set, const int length, LObject *p, const kStrategy)
 
BOOLEAN syzCriterion (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN syzCriterionInc (poly sig, unsigned long not_sevSig, kStrategy strat)
 
BOOLEAN faugereRewCriterion (poly sig, unsigned long not_sevSig, poly, kStrategy strat, int start=0)
 
BOOLEAN arriRewCriterion (poly, unsigned long, poly, kStrategy strat, int start=0)
 
BOOLEAN arriRewCriterionPre (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int)
 
TObjectkFindDivisibleByInS_T (kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
 
poly redtail (LObject *L, int end_pos, kStrategy strat)
 
poly redtail (poly p, int end_pos, kStrategy strat)
 
poly redtailBba (LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 
poly redtailBbaBound (LObject *L, int end_pos, kStrategy strat, int bound, BOOLEAN withT, BOOLEAN normalize)
 
void redtailBbaAlsoLC_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_Z (LObject *L, int end_pos, kStrategy strat)
 
poly redtailBba_NF (poly p, kStrategy strat)
 
poly redtailBba_Ring (LObject *L, int end_pos, 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 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 initSSpecial (ideal F, ideal Q, ideal P, kStrategy strat)
 
void initSSpecialSba (ideal F, ideal Q, ideal P, kStrategy strat)
 
static poly redBba1 (poly h, int maxIndex, kStrategy strat)
 
void cancelunit1 (LObject *p, int *suc, int index, kStrategy strat)
 
void updateS (BOOLEAN toT, kStrategy strat)
 
void enterSBba (LObject &p, int atS, kStrategy strat, int atR)
 
void enterSBbaShift (LObject &p, int atS, kStrategy strat, int atR)
 
void enterSSba (LObject &p, int atS, kStrategy strat, int atR)
 
void replaceInLAndSAndT (LObject &p, int tj, kStrategy strat)
 
void enterT (LObject &p, kStrategy strat, int atT)
 
void enterT_strong (LObject &p, kStrategy strat, int atT)
 
void enterSyz (LObject &p, kStrategy strat, int atT)
 
void initHilbCrit (ideal, ideal, intvec **hilb, kStrategy strat)
 
void initBuchMoraCrit (kStrategy strat)
 
void initSbaCrit (kStrategy strat)
 
BOOLEAN kPosInLDependsOnLength (int(*pos_in_l)(const LSet set, const int length, LObject *L, const kStrategy strat))
 
void initBuchMoraPos (kStrategy strat)
 
void initBuchMoraPosRing (kStrategy strat)
 
void initBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitBuchMora (kStrategy strat)
 
void initSbaPos (kStrategy strat)
 
void initSbaBuchMora (ideal F, ideal Q, kStrategy strat)
 
void exitSba (kStrategy strat)
 
void updateResult (ideal r, ideal Q, kStrategy strat)
 
void completeReduce (kStrategy strat, BOOLEAN withT)
 
BOOLEAN newHEdge (kStrategy strat)
 
BOOLEAN kCheckSpolyCreation (LObject *L, kStrategy strat, poly &m1, poly &m2)
 
BOOLEAN kCheckStrongCreation (int atR, poly m1, int atS, poly m2, kStrategy strat)
 
poly preIntegerCheck (const ideal Forig, const ideal Q)
 used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMon (LObject *h, kStrategy strat)
 used for GB over ZZ: intermediate reduction by monomial elements background: any known constant element of ideal suppresses intermediate coefficient swell
 
void postReduceByMonSig (LObject *h, kStrategy strat)
 
void finalReduceByMon (kStrategy strat)
 used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output
 
BOOLEAN kStratChangeTailRing (kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
 
void kStratInitChangeTailRing (kStrategy strat)
 
ring sbaRing (kStrategy strat, const ring r, BOOLEAN, int)
 
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)
 
int redFirst (LObject *h, kStrategy strat)
 
int redEcart (LObject *h, kStrategy strat)
 
void enterSMora (LObject &p, int atS, kStrategy strat, int atR=-1)
 
void enterSMoraNF (LObject &p, int atS, kStrategy strat, int atR=-1)
 
charshowOption ()
 
void kDebugPrint (kStrategy strat)
 Output some debug info about a given strategy.
 
static BOOLEAN enterOneStrongPolyShift (poly q, poly p, int, int, kStrategy strat, int atR, int, int, int shiftcount, int ifromS)
 
static void enterOnePairRingShift (poly q, poly p, int, int isFromQ, kStrategy strat, int atR, int, int qisFromQ, int shiftcount, int ifromS)
 
static BOOLEAN enterOneStrongPolyAndEnterOnePairRingShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
static BOOLEAN enterOnePairWithShifts (int q_inS, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int, int p_lastVblock, int q_lastVblock)
 
static BOOLEAN enterOnePairWithoutShifts (int p_inS, poly q, poly p, int ecartq, int q_isFromQ, kStrategy strat, int, int p_lastVblock, int q_shift)
 
BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
 
void initenterpairsShift (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
 
void initenterstrongPairsShift (poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR)
 
void enterpairsShift (poly h, int k, int ecart, int pos, kStrategy strat, int atR)
 
void enterTShift (LObject p, kStrategy strat, int atT)
 
poly redtailBbaShift (LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
 

Variables

VAR denominator_list DENOMINATOR_LIST =NULL
 
VAR int HCord
 
VAR int Kstd1_deg
 
VAR int Kstd1_mu =INT_MAX
 
STATIC_VAR BOOLEAN sloppy_max = FALSE
 

Macro Definition Documentation

◆ ALL_VS_JUST

#define ALL_VS_JUST   0

Definition at line 17 of file kutil.cc.

◆ ENTER_USE_MEMMOVE

#define ENTER_USE_MEMMOVE

Definition at line 47 of file kutil.cc.

◆ EXT_POLY_NEW

#define EXT_POLY_NEW   0

Definition at line 21 of file kutil.cc.

◆ KDEBUG [1/2]

#define KDEBUG   2

Definition at line 36 of file kutil.cc.

◆ KDEBUG [2/2]

#define KDEBUG   2

Definition at line 36 of file kutil.cc.

◆ kFalseReturn

#define kFalseReturn (   x)    do { if (!x) return FALSE;} while (0)

Definition at line 777 of file kutil.cc.

◆ KUTIL_CC

#define KUTIL_CC

Definition at line 10 of file kutil.cc.

◆ MYTEST

#define MYTEST   0

Definition at line 12 of file kutil.cc.

◆ pDivComp_EQUAL

#define pDivComp_EQUAL   2

Definition at line 134 of file kutil.cc.

◆ pDivComp_GREATER

#define pDivComp_GREATER   -1

Definition at line 136 of file kutil.cc.

◆ pDivComp_INCOMP

#define pDivComp_INCOMP   0

Definition at line 137 of file kutil.cc.

◆ pDivComp_LESS

#define pDivComp_LESS   1

Definition at line 135 of file kutil.cc.

Function Documentation

◆ arriRewCriterion()

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

Definition at line 6622 of file kutil.cc.

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

◆ arriRewCriterionPre()

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

Definition at line 6647 of file kutil.cc.

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

◆ cancelunit()

void cancelunit ( LObject L,
BOOLEAN  inNF 
)

Definition at line 370 of file kutil.cc.

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

◆ cancelunit1()

void cancelunit1 ( LObject p,
int suc,
int  index,
kStrategy  strat 
)

Definition at line 8401 of file kutil.cc.

8402{
8403 int k;
8404 poly r,h,h1,q;
8405
8406 if (!pIsVector((*p).p) && ((*p).ecart != 0))
8407 {
8408 // Leading coef have to be a unit: no
8409 // example 2x+4x2 should be simplified to 2x*(1+2x)
8410 // and 2 is not a unit in Z
8411 //if ( !(n_IsUnit(pGetCoeff((*p).p), currRing->cf)) ) return;
8412 k = 0;
8413 h1 = r = pCopy((*p).p);
8414 h =pNext(r);
8415 loop
8416 {
8417 if (h==NULL)
8418 {
8419 pDelete(&r);
8420 pDelete(&(pNext((*p).p)));
8421 (*p).ecart = 0;
8422 (*p).length = 1;
8423 (*p).pLength = 1;
8424 (*suc)=0;
8425 return;
8426 }
8427 if (!pDivisibleBy(r,h))
8428 {
8429 q=redBba1(h,index ,strat);
8430 if (q != h)
8431 {
8432 k++;
8433 pDelete(&h);
8434 pNext(h1) = h = q;
8435 }
8436 else
8437 {
8438 pDelete(&r);
8439 return;
8440 }
8441 }
8442 else
8443 {
8444 h1 = h;
8445 pIter(h);
8446 }
8447 if (k > 10)
8448 {
8449 pDelete(&r);
8450 return;
8451 }
8452 }
8453 }
8454}
int k
Definition cfEzgcd.cc:99
static poly redBba1(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8384
static int index(p_Length length, p_Ord ord)
#define pIsVector(p)
Definition polys.h:250
#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
#define pCopy(p)
return a copy of the poly
Definition polys.h:185

◆ chainCritNormal()

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

Definition at line 3208 of file kutil.cc.

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

◆ chainCritOpt_1()

void chainCritOpt_1 ( poly  ,
int  ,
kStrategy  strat 
)

Definition at line 3449 of file kutil.cc.

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

◆ chainCritPart()

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

Definition at line 3524 of file kutil.cc.

3525{
3526 int i,j,l;
3527
3528 /*
3529 *pairtest[i] is TRUE if spoly(S[i],p) == 0.
3530 *In this case all elements in B such
3531 *that their lcm is divisible by the leading term of S[i] can be canceled
3532 */
3533 if (strat->pairtest!=NULL)
3534 {
3535 /*- i.e. there is an i with pairtest[i]==TRUE -*/
3536 for (j=0; j<=strat->sl; j++)
3537 {
3538 if (strat->pairtest[j])
3539 {
3540 for (i=strat->Bl; i>=0; i--)
3541 {
3542 if (_p_LmDivisibleByPart(strat->S[j],currRing,
3543 strat->B[i].lcm,currRing,
3544 currRing->real_var_start,currRing->real_var_end))
3545 {
3546 if(TEST_OPT_DEBUG)
3547 {
3548 Print("chain-crit-part: S[%d]=",j);
3549 p_wrp(strat->S[j],currRing);
3550 Print(" divide B[%d].lcm=",i);
3551 p_wrp(strat->B[i].lcm,currRing);
3552 PrintLn();
3553 }
3554 deleteInL(strat->B,&strat->Bl,i,strat);
3555 strat->c3++;
3556 }
3557 }
3558 }
3559 }
3560 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
3561 strat->pairtest=NULL;
3562 }
3563 if (strat->Gebauer || strat->fromT)
3564 {
3565 if (strat->sugarCrit)
3566 {
3567 /*
3568 *suppose L[j] == (s,r) and p/lcm(s,r)
3569 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3570 *and in case the sugar is o.k. then L[j] can be canceled
3571 */
3572 for (j=strat->Ll; j>=0; j--)
3573 {
3574 if (sugarDivisibleBy(ecart,strat->L[j].ecart)
3575 && ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
3576 && pCompareChainPart(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3577 {
3578 if (strat->L[j].p == strat->tail)
3579 {
3580 if(TEST_OPT_DEBUG)
3581 {
3582 PrintS("chain-crit-part: pCompareChainPart p=");
3583 p_wrp(p,currRing);
3584 Print(" delete L[%d]",j);
3585 p_wrp(strat->L[j].lcm,currRing);
3586 PrintLn();
3587 }
3588 deleteInL(strat->L,&strat->Ll,j,strat);
3589 strat->c3++;
3590 }
3591 }
3592 }
3593 /*
3594 *this is GEBAUER-MOELLER:
3595 *in B all elements with the same lcm except the "best"
3596 *(i.e. the last one in B with this property) will be canceled
3597 */
3598 j = strat->Bl;
3599 loop /*cannot be changed into a for !!! */
3600 {
3601 if (j <= 0) break;
3602 i = j-1;
3603 loop
3604 {
3605 if (i < 0) break;
3606 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3607 {
3608 strat->c3++;
3609 if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart))
3610 {
3611 if(TEST_OPT_DEBUG)
3612 {
3613 Print("chain-crit-part: sugar B[%d].lcm=",j);
3614 p_wrp(strat->B[j].lcm,currRing);
3615 Print(" delete B[%d]",i);
3616 p_wrp(strat->B[i].lcm,currRing);
3617 PrintLn();
3618 }
3619 deleteInL(strat->B,&strat->Bl,i,strat);
3620 j--;
3621 }
3622 else
3623 {
3624 if(TEST_OPT_DEBUG)
3625 {
3626 Print("chain-crit-part: sugar B[%d].lcm=",i);
3627 p_wrp(strat->B[i].lcm,currRing);
3628 Print(" delete B[%d]",j);
3629 p_wrp(strat->B[j].lcm,currRing);
3630 PrintLn();
3631 }
3632 deleteInL(strat->B,&strat->Bl,j,strat);
3633 break;
3634 }
3635 }
3636 i--;
3637 }
3638 j--;
3639 }
3640 }
3641 else /*sugarCrit*/
3642 {
3643 /*
3644 *suppose L[j] == (s,r) and p/lcm(s,r)
3645 *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p)
3646 *and in case the sugar is o.k. then L[j] can be canceled
3647 */
3648 for (j=strat->Ll; j>=0; j--)
3649 {
3650 if (pCompareChainPart(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3651 {
3652 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3653 {
3654 if(TEST_OPT_DEBUG)
3655 {
3656 PrintS("chain-crit-part: sugar:pCompareChainPart p=");
3657 p_wrp(p,currRing);
3658 Print(" delete L[%d]",j);
3659 p_wrp(strat->L[j].lcm,currRing);
3660 PrintLn();
3661 }
3662 deleteInL(strat->L,&strat->Ll,j,strat);
3663 strat->c3++;
3664 }
3665 }
3666 }
3667 /*
3668 *this is GEBAUER-MOELLER:
3669 *in B all elements with the same lcm except the "best"
3670 *(i.e. the last one in B with this property) will be canceled
3671 */
3672 j = strat->Bl;
3673 loop /*cannot be changed into a for !!! */
3674 {
3675 if (j <= 0) break;
3676 for(i=j-1; i>=0; i--)
3677 {
3678 if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm))
3679 {
3680 if(TEST_OPT_DEBUG)
3681 {
3682 Print("chain-crit-part: equal lcm B[%d].lcm=",j);
3683 p_wrp(strat->B[j].lcm,currRing);
3684 Print(" delete B[%d]\n",i);
3685 }
3686 strat->c3++;
3687 deleteInL(strat->B,&strat->Bl,i,strat);
3688 j--;
3689 }
3690 }
3691 j--;
3692 }
3693 }
3694 /*
3695 *the elements of B enter L
3696 */
3697 kMergeBintoL(strat);
3698 }
3699 else
3700 {
3701 for (j=strat->Ll; j>=0; j--)
3702 {
3703 if (pCompareChainPart(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
3704 {
3705 if ((pNext(strat->L[j].p) == strat->tail)||(rHasGlobalOrdering(currRing)))
3706 {
3707 if(TEST_OPT_DEBUG)
3708 {
3709 PrintS("chain-crit-part: pCompareChainPart p=");
3710 p_wrp(p,currRing);
3711 Print(" delete L[%d]",j);
3712 p_wrp(strat->L[j].lcm,currRing);
3713 PrintLn();
3714 }
3715 deleteInL(strat->L,&strat->Ll,j,strat);
3716 strat->c3++;
3717 }
3718 }
3719 }
3720 /*
3721 *this is our MODIFICATION of GEBAUER-MOELLER:
3722 *First the elements of B enter L,
3723 *then we fix a lcm and the "best" element in L
3724 *(i.e the last in L with this lcm and of type (s,p))
3725 *and cancel all the other elements of type (r,p) with this lcm
3726 *except the case the element (s,r) has also the same lcm
3727 *and is on the worst position with respect to (s,p) and (r,p)
3728 */
3729 /*
3730 *B enters to L/their order with respect to B is permutated for elements
3731 *B[i].p with the same leading term
3732 */
3733 kMergeBintoL(strat);
3734 j = strat->Ll;
3735 loop /*cannot be changed into a for !!! */
3736 {
3737 if (j <= 0)
3738 {
3739 /*now L[0] cannot be canceled any more and the tail can be removed*/
3740 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
3741 break;
3742 }
3743 if (strat->L[j].p2 == p)
3744 {
3745 i = j-1;
3746 loop
3747 {
3748 if (i < 0) break;
3749 if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
3750 {
3751 /*L[i] could be canceled but we search for a better one to cancel*/
3752 strat->c3++;
3753 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
3754 && (pNext(strat->L[l].p) == strat->tail)
3755 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
3757 strat->L[l].lcm,currRing,
3758 currRing->real_var_start, currRing->real_var_end))
3759
3760 {
3761 /*
3762 *"NOT equal(...)" because in case of "equal" the element L[l]
3763 *is "older" and has to be from theoretical point of view behind
3764 *L[i], but we do not want to reorder L
3765 */
3766 strat->L[i].p2 = strat->tail;
3767 /*
3768 *L[l] will be canceled, we cannot cancel L[i] later on,
3769 *so we mark it with "tail"
3770 */
3771 if(TEST_OPT_DEBUG)
3772 {
3773 PrintS("chain-crit-part: divisible_by p=");
3774 p_wrp(p,currRing);
3775 Print(" delete L[%d]",l);
3776 p_wrp(strat->L[l].lcm,currRing);
3777 PrintLn();
3778 }
3779 deleteInL(strat->L,&strat->Ll,l,strat);
3780 i--;
3781 }
3782 else
3783 {
3784 if(TEST_OPT_DEBUG)
3785 {
3786 PrintS("chain-crit-part: divisible_by(2) p=");
3787 p_wrp(p,currRing);
3788 Print(" delete L[%d]",i);
3789 p_wrp(strat->L[i].lcm,currRing);
3790 PrintLn();
3791 }
3792 deleteInL(strat->L,&strat->Ll,i,strat);
3793 }
3794 j--;
3795 }
3796 i--;
3797 }
3798 }
3799 else if (strat->L[j].p2 == strat->tail)
3800 {
3801 /*now L[j] cannot be canceled any more and the tail can be removed*/
3802 strat->L[j].p2 = p;
3803 }
3804 j--;
3805 }
3806 }
3807}
#define Print
Definition emacs.cc:80
BOOLEAN pCompareChainPart(poly p, poly p1, poly p2, poly lcm, const ring R)
Definition kpolys.cc:71
#define TEST_OPT_DEBUG
Definition options.h:110
static BOOLEAN _p_LmDivisibleByPart(poly a, const ring r_a, poly b, const ring r_b, const int start, const int end)
Definition p_polys.h:1871
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310

◆ chainCritRing()

void chainCritRing ( poly  p,
int  ,
kStrategy  strat 
)

Definition at line 4000 of file kutil.cc.

4001{
4002 int i,j,l;
4003 /*
4004 *pairtest[i] is TRUE if spoly(S[i],p) == 0.
4005 *In this case all elements in B such
4006 *that their lcm is divisible by the leading term of S[i] can be canceled
4007 */
4008 if (strat->pairtest!=NULL)
4009 {
4010 {
4011 /*- i.e. there is an i with pairtest[i]==TRUE -*/
4012 for (j=0; j<=strat->sl; j++)
4013 {
4014 if (strat->pairtest[j])
4015 {
4016 for (i=strat->Bl; i>=0; i--)
4017 {
4018 if (pDivisibleBy(strat->S[j],strat->B[i].lcm) && n_DivBy(pGetCoeff(strat->B[i].lcm), pGetCoeff(strat->S[j]),currRing->cf))
4019 {
4020#ifdef KDEBUG
4021 if (TEST_OPT_DEBUG)
4022 {
4023 PrintS("--- chain criterion func chainCritRing type 1\n");
4024 PrintS("strat->S[j]:");
4025 wrp(strat->S[j]);
4026 PrintS(" strat->B[i].lcm:");
4027 wrp(strat->B[i].lcm);PrintLn();
4028 pWrite(strat->B[i].p);
4029 pWrite(strat->B[i].p1);
4030 pWrite(strat->B[i].p2);
4031 wrp(strat->B[i].lcm);
4032 PrintLn();
4033 }
4034#endif
4035 deleteInL(strat->B,&strat->Bl,i,strat);
4036 strat->c3++;
4037 }
4038 }
4039 }
4040 }
4041 }
4042 omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN));
4043 strat->pairtest=NULL;
4044 }
4045 assume(!(strat->Gebauer || strat->fromT));
4046 for (j=strat->Ll; j>=0; j--)
4047 {
4048 if ((strat->L[j].lcm != NULL) && n_DivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(p), currRing->cf))
4049 {
4050 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm))
4051 {
4052 if ((pNext(strat->L[j].p) == strat->tail) || (rHasGlobalOrdering(currRing)))
4053 {
4054 deleteInL(strat->L,&strat->Ll,j,strat);
4055 strat->c3++;
4056#ifdef KDEBUG
4057 if (TEST_OPT_DEBUG)
4058 {
4059 PrintS("--- chain criterion func chainCritRing type 2\n");
4060 PrintS("strat->L[j].p:");
4061 wrp(strat->L[j].p);
4062 PrintS(" p:");
4063 wrp(p);
4064 PrintLn();
4065 }
4066#endif
4067 }
4068 }
4069 }
4070 }
4071 /*
4072 *this is our MODIFICATION of GEBAUER-MOELLER:
4073 *First the elements of B enter L,
4074 *then we fix a lcm and the "best" element in L
4075 *(i.e the last in L with this lcm and of type (s,p))
4076 *and cancel all the other elements of type (r,p) with this lcm
4077 *except the case the element (s,r) has also the same lcm
4078 *and is on the worst position with respect to (s,p) and (r,p)
4079 */
4080 /*
4081 *B enters to L/their order with respect to B is permutated for elements
4082 *B[i].p with the same leading term
4083 */
4084 kMergeBintoL(strat);
4085 j = strat->Ll;
4086 loop /*cannot be changed into a for !!! */
4087 {
4088 if (j <= 0)
4089 {
4090 /*now L[0] cannot be canceled any more and the tail can be removed*/
4091 if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p;
4092 break;
4093 }
4094 if (strat->L[j].p2 == p) // Was the element added from B?
4095 {
4096 i = j-1;
4097 loop
4098 {
4099 if (i < 0) break;
4100 // Element is from B and has the same lcm as L[j]
4101 if ((strat->L[i].p2 == p) && n_DivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(strat->L[i].lcm), currRing->cf)
4102 && pLmEqual(strat->L[j].lcm,strat->L[i].lcm))
4103 {
4104 /*L[i] could be canceled but we search for a better one to cancel*/
4105 strat->c3++;
4106#ifdef KDEBUG
4107 if (TEST_OPT_DEBUG)
4108 {
4109 PrintS("--- chain criterion func chainCritRing type 3\n");
4110 PrintS("strat->L[j].lcm:");
4111 wrp(strat->L[j].lcm);
4112 PrintS(" strat->L[i].lcm:");
4113 wrp(strat->L[i].lcm);
4114 PrintLn();
4115 }
4116#endif
4117 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat)
4118 && (pNext(strat->L[l].p) == strat->tail)
4119 && (!pLmEqual(strat->L[i].p,strat->L[l].p))
4120 && pDivisibleBy(p,strat->L[l].lcm))
4121 {
4122 /*
4123 *"NOT equal(...)" because in case of "equal" the element L[l]
4124 *is "older" and has to be from theoretical point of view behind
4125 *L[i], but we do not want to reorder L
4126 */
4127 strat->L[i].p2 = strat->tail;
4128 /*
4129 *L[l] will be canceled, we cannot cancel L[i] later on,
4130 *so we mark it with "tail"
4131 */
4132 deleteInL(strat->L,&strat->Ll,l,strat);
4133 i--;
4134 }
4135 else
4136 {
4137 deleteInL(strat->L,&strat->Ll,i,strat);
4138 }
4139 j--;
4140 }
4141 i--;
4142 }
4143 }
4144 else if (strat->L[j].p2 == strat->tail)
4145 {
4146 /*now L[j] cannot be canceled any more and the tail can be removed*/
4147 strat->L[j].p2 = p;
4148 }
4149 j--;
4150 }
4151}
#define assume(x)
Definition mod2.h:389
void wrp(poly p)
Definition polys.h:310
void pWrite(poly p)
Definition polys.h:308

◆ chainCritSig()

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

Definition at line 3465 of file kutil.cc.

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

◆ cleanT()

void cleanT ( kStrategy  strat)

Definition at line 562 of file kutil.cc.

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

◆ cleanTSbaRing()

void cleanTSbaRing ( kStrategy  strat)

Definition at line 621 of file kutil.cc.

622{
623 int i,j;
624 poly p;
625 assume(currRing == strat->tailRing || strat->tailRing != NULL);
626
627 pShallowCopyDeleteProc p_shallow_copy_delete =
628 (strat->tailRing != currRing ?
630 NULL);
631 for (j=0; j<=strat->tl; j++)
632 {
633 p = strat->T[j].p;
634 strat->T[j].p=NULL;
635 if (strat->T[j].max_exp != NULL)
636 {
637 p_LmFree(strat->T[j].max_exp, strat->tailRing);
638 }
639 i = -1;
640 loop
641 {
642 i++;
643 if (i>strat->sl)
644 {
645 if (strat->T[j].t_p != NULL)
646 {
647 p_Delete(&(strat->T[j].t_p), strat->tailRing);
649 }
650 else
651 {
652 //pDelete(&p);
653 p = NULL;
654 }
655 break;
656 }
657 if (p == strat->S[i])
658 {
659 if (strat->T[j].t_p != NULL)
660 {
661 assume(p_shallow_copy_delete != NULL);
662 pNext(p) = p_shallow_copy_delete(pNext(p),strat->tailRing,currRing,
663 currRing->PolyBin);
664 p_LmFree(strat->T[j].t_p, strat->tailRing);
665 }
666 break;
667 }
668 }
669 }
670 strat->tl=-1;
671}

◆ clearSbatch()

void clearSbatch ( poly  h,
int  k,
int  pos,
kStrategy  strat 
)

Definition at line 4437 of file kutil.cc.

4438{
4439 int j = pos;
4440 if ( (!strat->fromT)
4441 && ((strat->syzComp==0)
4442 ||(pGetComp(h)<=strat->syzComp)
4443 ))
4444 {
4445 // Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl);
4446 unsigned long h_sev = pGetShortExpVector(h);
4447 loop
4448 {
4449 if (j > k) break;
4450 clearS(h,h_sev, &j,&k,strat);
4451 j++;
4452 }
4453 // Print("end clearS sl=%d\n",strat->sl);
4454 }
4455}
int syzComp
Definition kutil.h:354
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition kInline.h:1232
#define pGetComp(p)
Component.
Definition polys.h:37
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:152

◆ completeReduce()

void completeReduce ( kStrategy  strat,
BOOLEAN  withT 
)

Definition at line 10282 of file kutil.cc.

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

◆ deleteHC() [1/2]

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

Definition at line 291 of file kutil.cc.

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

◆ deleteHC() [2/2]

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

Definition at line 356 of file kutil.cc.

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

◆ deleteHCBucket()

static void deleteHCBucket ( LObject L,
kStrategy  strat 
)
static

Definition at line 248 of file kutil.cc.

249{
250 if ((strat->kNoether!=NULL)
251 && (L->bucket != NULL))
252 {
253 for (int i=1; i<= (int) L->bucket->buckets_used; i++)
254 {
255 poly p=L->bucket->buckets[i];
256 if(p!=NULL)
257 {
258 if (p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1)
259 {
260 L->bucket->buckets[i]=NULL;
261 L->bucket->buckets_length[i]=0;
262 }
263 else
264 {
265 do
266 {
267 if (p_Cmp(pNext(p),strat->kNoetherTail(), L->tailRing) == -1)
268 {
269 p_Delete(&pNext(p), L->tailRing);
270 L->bucket->buckets_length[i]=pLength(L->bucket->buckets[i]);
271 break;
272 }
273 pIter(p);
274 } while(p!=NULL);
275 }
276 }
277 }
278 int i=L->bucket->buckets_used;
279 while ((i>0)&&(L->bucket->buckets[i]==NULL))
280 {
281 i--;
282 L->bucket->buckets_used=i;
283 }
284 }
285}
static int pLength(poly a)
Definition p_polys.h:190

◆ deleteInL()

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

Definition at line 1212 of file kutil.cc.

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

◆ deleteInS()

void deleteInS ( int  i,
kStrategy  strat 
)

Definition at line 1136 of file kutil.cc.

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

◆ enlargeL()

static void enlargeL ( LSet L,
int length,
const int  incr 
)
inlinestatic

Definition at line 680 of file kutil.cc.

681{
682 assume((*L)!=NULL);
683 assume(((*length)+incr)>0);
684
685 *L = (LSet)omReallocSize((*L),(*length)*sizeof(LObject),
686 ((*length)+incr)*sizeof(LObject));
687 (*length) += incr;
688}
LObject * LSet
Definition kutil.h:60
#define omReallocSize(addr, o_size, size)

◆ enlargeT()

static void enlargeT ( TSet T,
TObject **&  R,
unsigned long *&  sevT,
int length,
const int  incr 
)
inlinestatic

Definition at line 541 of file kutil.cc.

543{
544 assume(T!=NULL);
545 assume(sevT!=NULL);
546 assume(R!=NULL);
547 assume((length+incr) > 0);
548
549 int i;
550 T = (TSet)omRealloc0Size(T, length*sizeof(TObject),
551 (length+incr)*sizeof(TObject));
552
553 sevT = (unsigned long*) omReallocSize(sevT, length*sizeof(long*),
554 (length+incr)*sizeof(long*));
555
556 R = (TObject**)omRealloc0Size(R,length*sizeof(TObject*),
557 (length+incr)*sizeof(TObject*));
558 for (i=length-1;i>=0;i--) R[T[i].i_r] = &(T[i]);
559 length += incr;
560}
STATIC_VAR jList * T
Definition janet.cc:30
TObject * TSet
Definition kutil.h:59
#define omRealloc0Size(addr, o_size, size)
#define R
Definition sirandom.c:27

◆ enterExtendedSpoly()

void enterExtendedSpoly ( poly  h,
kStrategy  strat 
)

Definition at line 4236 of file kutil.cc.

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

◆ enterExtendedSpolySig()

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

Definition at line 4320 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1273 of file kutil.cc.

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

◆ enterOnePairLift()

static void enterOnePairLift ( int  i,
poly  p,
int  ecart,
int  isFromQ,
kStrategy  strat,
int  atR = -1 
)
static

Definition at line 2225 of file kutil.cc.

2226{
2227 assume(ALLOW_PROD_CRIT(strat));
2229 assume(i<=strat->sl);
2230 assume(strat->syzComp==1);
2231
2232 if ((strat->S[i]==NULL) || (p==NULL))
2233 return;
2234
2235 int l,j,compare;
2236 LObject Lp;
2237 Lp.i_r = -1;
2238
2239#ifdef KDEBUG
2240 Lp.ecart=0; Lp.length=0;
2241#endif
2242 /*- computes the lcm(s[i],p) -*/
2243 Lp.lcm = p_Lcm(p,strat->S[i],currRing);
2244
2245 if (strat->sugarCrit)
2246 {
2247 if((!((strat->ecartS[i]>0)&&(ecart>0)))
2248 && p_HasNotCF_Lift(p,strat->S[i],currRing))
2249 {
2250 /*
2251 *the product criterion has applied for (s,p),
2252 *i.e. lcm(s,p)=product of the leading terms of s and p.
2253 *Suppose (s,r) is in L and the leading term
2254 *of p divides lcm(s,r)
2255 *(==> the leading term of p divides the leading term of r)
2256 *but the leading term of s does not divide the leading term of r
2257 *(notice that tis condition is automatically satisfied if r is still
2258 *in S), then (s,r) can be cancelled.
2259 *This should be done here because the
2260 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2261 *
2262 *Moreover, skipping (s,r) holds also for the noncommutative case.
2263 */
2264 strat->cp++;
2265 pLmFree(Lp.lcm);
2266 return;
2267 }
2268 else
2269 Lp.ecart = si_max(ecart,strat->ecartS[i]);
2270 if (strat->fromT && (strat->ecartS[i]>ecart))
2271 {
2272 pLmFree(Lp.lcm);
2273 return;
2274 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2275 }
2276 /*
2277 *the set B collects the pairs of type (S[j],p)
2278 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2279 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2280 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2281 */
2282 {
2283 j = strat->Bl;
2284 loop
2285 {
2286 if (j < 0) break;
2287 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2288 if ((compare==1)
2289 &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart)))
2290 {
2291 strat->c3++;
2292 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2293 {
2294 pLmFree(Lp.lcm);
2295 return;
2296 }
2297 break;
2298 }
2299 else
2300 if ((compare ==-1)
2301 && sugarDivisibleBy(Lp.ecart,strat->B[j].ecart))
2302 {
2303 deleteInL(strat->B,&strat->Bl,j,strat);
2304 strat->c3++;
2305 }
2306 j--;
2307 }
2308 }
2309 }
2310 else /*sugarcrit*/
2311 {
2312 if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/
2313 p_HasNotCF_Lift(p,strat->S[i],currRing))
2314 {
2315 /*
2316 *the product criterion has applied for (s,p),
2317 *i.e. lcm(s,p)=product of the leading terms of s and p.
2318 *Suppose (s,r) is in L and the leading term
2319 *of p divides lcm(s,r)
2320 *(==> the leading term of p divides the leading term of r)
2321 *but the leading term of s does not divide the leading term of r
2322 *(notice that tis condition is automatically satisfied if r is still
2323 *in S), then (s,r) can be canceled.
2324 *This should be done here because the
2325 *case lcm(s,r)=lcm(s,p) is not covered by chainCrit.
2326 */
2327 strat->cp++;
2328 pLmFree(Lp.lcm);
2329 return;
2330 }
2331 if (strat->fromT && (strat->ecartS[i]>ecart))
2332 {
2333 pLmFree(Lp.lcm);
2334 return;
2335 /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
2336 }
2337 /*
2338 *the set B collects the pairs of type (S[j],p)
2339 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p)
2340 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
2341 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
2342 */
2343 for(j = strat->Bl;j>=0;j--)
2344 {
2345 compare=pDivComp(strat->B[j].lcm,Lp.lcm);
2346 if (compare==1)
2347 {
2348 strat->c3++;
2349 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
2350 {
2351 pLmFree(Lp.lcm);
2352 return;
2353 }
2354 break;
2355 }
2356 else
2357 if (compare ==-1)
2358 {
2359 deleteInL(strat->B,&strat->Bl,j,strat);
2360 strat->c3++;
2361 }
2362 }
2363 }
2364 /*
2365 *the pair (S[i],p) enters B if the spoly != 0
2366 */
2367 /*- compute the short s-polynomial -*/
2368 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2369 pNorm(p);
2370
2371 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2372 Lp.p=NULL;
2373 else
2374 {
2376 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2377 }
2378 if (Lp.p == NULL)
2379 {
2380 /*- the case that the s-poly is 0 -*/
2381 if (strat->pairtest==NULL) initPairtest(strat);
2382 strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
2383 strat->pairtest[strat->sl+1] = TRUE;
2384 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
2385 /*
2386 *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
2387 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
2388 *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
2389 *term of p divides the lcm(s,r)
2390 *(this canceling should be done here because
2391 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
2392 *the first case is handled in chainCrit
2393 */
2394 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2395 }
2396 else
2397 {
2398 /*- the pair (S[i],p) enters B -*/
2399 Lp.p1 = strat->S[i];
2400 Lp.p2 = p;
2401
2402 pNext(Lp.p) = strat->tail; // !!!
2403
2404 if (atR >= 0)
2405 {
2406 Lp.i_r1 = strat->S_2_R[i];
2407 Lp.i_r2 = atR;
2408 }
2409 else
2410 {
2411 Lp.i_r1 = -1;
2412 Lp.i_r2 = -1;
2413 }
2414 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2415
2417 {
2420 && (Lp.p->coef!=NULL))
2421 nDelete(&(Lp.p->coef));
2422 }
2423
2424 l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
2425 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2426 }
2427}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
int cp
Definition kutil.h:347
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition kutil.h:287
int Bmax
Definition kutil.h:352
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition kspoly.cc:1446
void initPairtest(kStrategy strat)
Definition kutil.cc:690
static BOOLEAN p_HasNotCF_Lift(poly p1, poly p2, const ring r)
p_HasNotCF for the IDLIFT case and syzComp==1: ignore component
Definition kutil.cc:2206
static int pDivComp(poly p, poly q)
Definition kutil.cc:181
#define ALLOW_PROD_CRIT(A)
Definition kutil.h:393
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659
void pNorm(poly p)
Definition polys.h:362
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:405

◆ enterOnePairNormal()

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

Definition at line 1943 of file kutil.cc.

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

◆ enterOnePairRing()

static void enterOnePairRing ( int  i,
poly  p,
int  ,
int  isFromQ,
kStrategy  strat,
int  atR 
)
static

Definition at line 1338 of file kutil.cc.

1339{
1340 assume(atR >= 0);
1341 assume(i<=strat->sl);
1342 assume(p!=NULL);
1344 #if ALL_VS_JUST
1345 //Over rings, if we construct the strong pair, do not add the spair
1347 {
1348 number s,t,d;
1349 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
1350
1351 if (!nIsZero(s) && !nIsZero(t)) // evtl. durch divBy tests ersetzen
1352 {
1353 nDelete(&d);
1354 nDelete(&s);
1355 nDelete(&t);
1356 return;
1357 }
1358 nDelete(&d);
1359 nDelete(&s);
1360 nDelete(&t);
1361 }
1362 #endif
1363 int j,compare,compareCoeff;
1364 LObject h;
1365
1366#ifdef KDEBUG
1367 h.ecart=0; h.length=0;
1368#endif
1369 /*- computes the lcm(s[i],p) -*/
1370 if(pHasNotCFRing(p,strat->S[i]))
1371 {
1372 strat->cp++;
1373 return;
1374 }
1375 h.lcm = p_Lcm(p,strat->S[i],currRing);
1376 pSetCoeff0(h.lcm, n_Lcm(pGetCoeff(p), pGetCoeff(strat->S[i]), currRing->cf));
1377 if (nIsZero(pGetCoeff(h.lcm)))
1378 {
1379 strat->cp++;
1380 pLmDelete(h.lcm);
1381 return;
1382 }
1383 // basic chain criterion
1384 /*
1385 *the set B collects the pairs of type (S[j],p)
1386 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
1387 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
1388 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
1389 */
1390
1391 for(j = strat->Bl;j>=0;j--)
1392 {
1393 compare=pDivCompRing(strat->B[j].lcm,h.lcm);
1394 compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(h.lcm), currRing->cf);
1395 if(compare == pDivComp_EQUAL)
1396 {
1397 //They have the same LM
1399 {
1400 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1401 {
1402 strat->c3++;
1403 pLmDelete(h.lcm);
1404 return;
1405 }
1406 break;
1407 }
1409 {
1410 deleteInL(strat->B,&strat->Bl,j,strat);
1411 strat->c3++;
1412 }
1414 {
1415 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1416 {
1417 strat->c3++;
1418 pLmDelete(h.lcm);
1419 return;
1420 }
1421 break;
1422 }
1423 }
1424 if(compareCoeff == compare || compareCoeff == pDivComp_EQUAL)
1425 {
1426 if(compare == pDivComp_LESS)
1427 {
1428 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
1429 {
1430 strat->c3++;
1431 pLmDelete(h.lcm);
1432 return;
1433 }
1434 break;
1435 }
1436 if(compare == pDivComp_GREATER)
1437 {
1438 deleteInL(strat->B,&strat->Bl,j,strat);
1439 strat->c3++;
1440 }
1441 }
1442 }
1443 number s, t;
1444 poly m1, m2, gcd = NULL;
1445 s = pGetCoeff(strat->S[i]);
1446 t = pGetCoeff(p);
1447 k_GetLeadTerms(p,strat->S[i],currRing,m1,m2,currRing);
1448 ksCheckCoeff(&s, &t, currRing->cf);
1449 pSetCoeff0(m1, s);
1450 pSetCoeff0(m2, t);
1451 m2 = pNeg(m2);
1452 p_Test(m1,strat->tailRing);
1453 p_Test(m2,strat->tailRing);
1454 poly si = pCopy(strat->S[i]);
1455 poly pm1 = pp_Mult_mm(pNext(p), m1, strat->tailRing);
1456 poly sim2 = pp_Mult_mm(pNext(si), m2, strat->tailRing);
1457 pDelete(&si);
1458 p_LmDelete(m1, currRing);
1459 p_LmDelete(m2, currRing);
1460 if(sim2 == NULL)
1461 {
1462 if(pm1 == NULL)
1463 {
1464 if(h.lcm != NULL)
1465 {
1466 pLmDelete(h.lcm);
1467 h.lcm=NULL;
1468 }
1469 h.Clear();
1470 if (strat->pairtest==NULL) initPairtest(strat);
1471 strat->pairtest[i] = TRUE;
1472 strat->pairtest[strat->sl+1] = TRUE;
1473 return;
1474 }
1475 else
1476 {
1477 gcd = pm1;
1478 pm1 = NULL;
1479 }
1480 }
1481 else
1482 {
1483 if((pGetComp(strat->S[i]) == 0) && (0 != pGetComp(p)))
1484 {
1485 p_SetCompP(sim2, pGetComp(p), strat->tailRing);
1486 pSetmComp(sim2);
1487 }
1488 //p_Write(pm1,strat->tailRing);p_Write(sim2,strat->tailRing);
1489 gcd = p_Add_q(pm1, sim2, strat->tailRing);
1490 }
1491 p_Test(gcd, strat->tailRing);
1492#ifdef KDEBUG
1493 if (TEST_OPT_DEBUG)
1494 {
1495 wrp(gcd);
1496 PrintLn();
1497 }
1498#endif
1499 h.p = gcd;
1500 h.i_r = -1;
1501 if(h.p == NULL)
1502 {
1503 if (strat->pairtest==NULL) initPairtest(strat);
1504 strat->pairtest[i] = TRUE;
1505 strat->pairtest[strat->sl+1] = TRUE;
1506 return;
1507 }
1508 h.tailRing = strat->tailRing;
1509 int posx;
1510 //h.pCleardenom();
1511 //pSetm(h.p);
1512 h.i_r1 = -1;h.i_r2 = -1;
1513 strat->initEcart(&h);
1514 #if 1
1515 h.p2 = strat->S[i];
1516 h.p1 = p;
1517 #endif
1518 #if 1
1519 if (atR >= 0)
1520 {
1521 h.i_r1 = atR;
1522 h.i_r2 = strat->S_2_R[i];
1523 }
1524 #endif
1525 if (strat->Bl==-1)
1526 posx =0;
1527 else
1528 posx = strat->posInL(strat->B,strat->Bl,&h,strat);
1529 h.sev = pGetShortExpVector(h.p);
1530 if (currRing!=strat->tailRing)
1531 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
1532 if (strat->P.p!=NULL) strat->P.sev = pGetShortExpVector(strat->P.p);
1533 else strat->P.sev=0L;
1534 enterL(&strat->B,&strat->Bl,&strat->Bmax,h,posx);
1535 kTest_TS(strat);
1536}
static FORCE_INLINE number n_Lcm(number a, number b, const coeffs r)
in Z: return the lcm of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:691
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:672
static FORCE_INLINE int n_DivComp(number a, number b, const coeffs r)
Definition coeffs.h:525
const CanonicalForm int s
Definition facAbsFact.cc:51
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
Definition kInline.h:1015
int ksCheckCoeff(number *a, number *b, const coeffs r)
Definition kbuckets.cc:1504
#define pDivComp_LESS
Definition kutil.cc:135
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1070
static int pDivCompRing(poly p, poly q)
Definition kutil.cc:143
#define pDivComp_GREATER
Definition kutil.cc:136
#define pDivComp_EQUAL
Definition kutil.cc:134
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:937
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:724
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1032
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:255
#define pNeg(p)
Definition polys.h:198
#define pSetmComp(p)
TODO:
Definition polys.h:273
#define pHasNotCFRing(p1, p2)
Definition polys.h:262

◆ enterOnePairRingShift()

static void enterOnePairRingShift ( poly  q,
poly  p,
int  ,
int  isFromQ,
kStrategy  strat,
int  atR,
int  ,
int  qisFromQ,
int  shiftcount,
int  ifromS 
)
static

Definition at line 11808 of file kutil.cc.

11809{
11810 /* assume(atR >= 0); */
11811 /* assume(i<=strat->sl); */
11812 assume(p!=NULL);
11814 assume(pIsInV(p));
11815 #if ALL_VS_JUST
11816 //Over rings, if we construct the strong pair, do not add the spair
11818 {
11819 number s,t,d;
11820 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(q, &s, &t, currRing->cf);
11821
11822 if (!nIsZero(s) && !nIsZero(t)) // evtl. durch divBy tests ersetzen
11823 {
11824 nDelete(&d);
11825 nDelete(&s);
11826 nDelete(&t);
11827 return;
11828 }
11829 nDelete(&d);
11830 nDelete(&s);
11831 nDelete(&t);
11832 }
11833 #endif
11834 int j,compare,compareCoeff;
11835 LObject h;
11836
11837#ifdef KDEBUG
11838 h.ecart=0; h.length=0;
11839#endif
11840 /*- computes the lcm(s[i],p) -*/
11841 if(pHasNotCFRing(p,q))
11842 {
11843 strat->cp++;
11844 return;
11845 }
11846 h.lcm = p_Lcm(p,q,currRing);
11847 pSetCoeff0(h.lcm, n_Lcm(pGetCoeff(p), pGetCoeff(q), currRing->cf));
11848 if (nIsZero(pGetCoeff(h.lcm)))
11849 {
11850 strat->cp++;
11851 pLmDelete(h.lcm);
11852 return;
11853 }
11854
11855 /* the V criterion */
11856 if (!pmIsInV(h.lcm))
11857 {
11858 strat->cv++;
11859 pLmDelete(h.lcm);
11860 return;
11861 }
11862 // basic chain criterion
11863 /*
11864 *the set B collects the pairs of type (S[j],p)
11865 *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
11866 *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
11867 *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
11868 */
11869
11870 for(j = strat->Bl;j>=0;j--)
11871 {
11872 compare=pDivCompRing(strat->B[j].lcm,h.lcm);
11873 compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(h.lcm), currRing->cf);
11874 if(compare == pDivComp_EQUAL)
11875 {
11876 //They have the same LM
11878 {
11879 if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
11880 {
11881 strat->c3++;
11882 pLmDelete(h.lcm);
11883 return;
11884 }
11885 break;
11886 }
11888 {
11889 deleteInL(strat->B,&strat->Bl,j,strat);
11890 strat->c3++;
11891 }
11893 {
11894 if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
11895 {
11896 strat->c3++;
11897 pLmDelete(h.lcm);
11898 return;
11899 }
11900 break;
11901 }
11902 }
11903 if(compareCoeff == compare || compareCoeff == pDivComp_EQUAL)
11904 {
11905 if(compare == pDivComp_LESS)
11906 {
11907 if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
11908 {
11909 strat->c3++;
11910 pLmDelete(h.lcm);
11911 return;
11912 }
11913 break;
11914 }
11915 if(compare == pDivComp_GREATER)
11916 {
11917 deleteInL(strat->B,&strat->Bl,j,strat);
11918 strat->c3++;
11919 }
11920 }
11921 }
11922 number s, t;
11923 poly m1, m2, gcd = NULL;
11924 s = pGetCoeff(q);
11925 t = pGetCoeff(p);
11927
11928 poly m12, m22;
11932 // manually free the coeffs, because pSetCoeff0 is used in the next step
11933 n_Delete(&(m1->coef), currRing->cf);
11934 n_Delete(&(m2->coef), currRing->cf);
11935
11936 ksCheckCoeff(&s, &t, currRing->cf);
11937 pSetCoeff0(m1, s);
11938 pSetCoeff0(m2, t);
11939 m2 = pNeg(m2);
11940 p_Test(m1,strat->tailRing);
11941 p_Test(m2,strat->tailRing);
11942 p_Test(m12,strat->tailRing);
11943 p_Test(m22,strat->tailRing);
11944 assume(pmIsInV(m1));
11945 assume(pmIsInV(m2));
11946 assume(pmIsInV(m12));
11947 assume(pmIsInV(m22));
11948 poly pm1 = pp_Mult_mm(pp_mm_Mult(pNext(p), m1, strat->tailRing), m12, strat->tailRing);
11949 poly sim2 = pp_Mult_mm(pp_mm_Mult(pNext(q), m2, strat->tailRing), m22, strat->tailRing);
11950 assume(pIsInV(pm1));
11951 assume(pIsInV(sim2));
11952 p_LmDelete(m1, currRing);
11953 p_LmDelete(m2, currRing);
11956 if(sim2 == NULL)
11957 {
11958 if(pm1 == NULL)
11959 {
11960 if(h.lcm != NULL)
11961 {
11962 pLmDelete(h.lcm);
11963 h.lcm=NULL;
11964 }
11965 h.Clear();
11966 /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
11967 /* if (strat->pairtest==NULL) initPairtest(strat); */
11968 /* strat->pairtest[i] = TRUE; */
11969 /* strat->pairtest[strat->sl+1] = TRUE; */
11970 return;
11971 }
11972 else
11973 {
11974 gcd = pm1;
11975 pm1 = NULL;
11976 }
11977 }
11978 else
11979 {
11980 if((pGetComp(q) == 0) && (0 != pGetComp(p)))
11981 {
11982 p_SetCompP(sim2, pGetComp(p), strat->tailRing);
11983 pSetmComp(sim2);
11984 }
11985 //p_Write(pm1,strat->tailRing);p_Write(sim2,strat->tailRing);
11986 gcd = p_Add_q(pm1, sim2, strat->tailRing);
11987 }
11988 p_Test(gcd, strat->tailRing);
11989 assume(pIsInV(gcd));
11990#ifdef KDEBUG
11991 if (TEST_OPT_DEBUG)
11992 {
11993 wrp(gcd);
11994 PrintLn();
11995 }
11996#endif
11997 h.p = gcd;
11998 h.i_r = -1;
11999 if(h.p == NULL)
12000 {
12001 /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
12002 /* if (strat->pairtest==NULL) initPairtest(strat); */
12003 /* strat->pairtest[i] = TRUE; */
12004 /* strat->pairtest[strat->sl+1] = TRUE; */
12005 return;
12006 }
12007 h.tailRing = strat->tailRing;
12008 int posx;
12009 //h.pCleardenom();
12010 //pSetm(h.p);
12011 h.i_r1 = -1;h.i_r2 = -1;
12012 strat->initEcart(&h);
12013 #if 1
12014 h.p1 = p;
12015 h.p2 = q;
12016 #endif
12017 #if 1
12018 /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
12019 /* at the beginning we DO NOT set atR = -1 ANYMORE*/
12020 if (atR >= 0 && shiftcount == 0 && ifromS >= 0)
12021 {
12022 h.i_r2 = kFindInT(h.p1, strat); //strat->S_2_R[i];
12023 h.i_r1 = atR;
12024 }
12025 else
12026 {
12027 /* END _ TEMPORARILY DISABLED FOR SHIFTS */
12028 h.i_r1 = -1;
12029 h.i_r2 = -1;
12030 }
12031 #endif
12032 if (strat->Bl==-1)
12033 posx =0;
12034 else
12035 posx = strat->posInL(strat->B,strat->Bl,&h,strat);
12036 h.sev = pGetShortExpVector(h.p);
12037 if (currRing!=strat->tailRing)
12038 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
12039
12040 assume(pIsInV(h.p));
12041 assume(pIsInV(h.p1));
12042 assume(h.lcm != NULL);
12043 assume(pIsInV(h.lcm));
12044
12045 enterL(&strat->B,&strat->Bl,&strat->Bmax,h,posx);
12046 kTest_TS(strat);
12047}
int cv
Definition kutil.h:366
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static poly pp_mm_Mult(poly p, poly m, const ring r)
Definition p_polys.h:1042
int p_mFirstVblock(poly p, const ring ri)
Definition shiftop.cc:478
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)
Definition shiftop.cc:600
#define pIsInV(p)
Definition shiftop.h:50
#define pmIsInV(p)
Definition shiftop.h:51

◆ enterOnePairShift()

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

Definition at line 12161 of file kutil.cc.

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

◆ enterOnePairSig()

static void enterOnePairSig ( int  i,
poly  p,
poly  pSig,
int  ,
int  ecart,
int  isFromQ,
kStrategy  strat,
int  atR = -1 
)
static

Definition at line 2437 of file kutil.cc.

2439{
2440 assume(i<=strat->sl);
2441
2442 int l;
2443 poly m1 = NULL,m2 = NULL; // we need the multipliers for the s-polynomial to compute
2444 // the corresponding signatures for criteria checks
2445 LObject Lp;
2446 poly pSigMult = p_Copy(pSig,currRing);
2447 poly sSigMult = p_Copy(strat->sig[i],currRing);
2448 unsigned long pSigMultNegSev,sSigMultNegSev;
2449 Lp.i_r = -1;
2450
2451#ifdef KDEBUG
2452 Lp.ecart=0; Lp.length=0;
2453#endif
2454 /*- computes the lcm(s[i],p) -*/
2455 Lp.lcm = pInit();
2456 k_GetLeadTerms(p,strat->S[i],currRing,m1,m2,currRing);
2457#ifndef HAVE_RATGRING
2458 pLcm(p,strat->S[i],Lp.lcm);
2459#elif defined(HAVE_RATGRING)
2460 if (rIsRatGRing(currRing))
2461 pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
2462 else
2463 pLcm(p,strat->S[i],Lp.lcm);
2464#endif
2465 pSetm(Lp.lcm);
2466
2467 // set coeffs of multipliers m1 and m2
2468 pSetCoeff0(m1, nInit(1));
2469 pSetCoeff0(m2, nInit(1));
2470//#if 1
2471#ifdef DEBUGF5
2472 PrintS("P1 ");
2473 pWrite(pHead(p));
2474 PrintS("P2 ");
2475 pWrite(pHead(strat->S[i]));
2476 PrintS("M1 ");
2477 pWrite(m1);
2478 PrintS("M2 ");
2479 pWrite(m2);
2480#endif
2481 // get multiplied signatures for testing
2482 pSigMult = currRing->p_Procs->pp_Mult_mm(pSigMult,m1,currRing);
2483 pSigMultNegSev = ~p_GetShortExpVector(pSigMult,currRing);
2484 sSigMult = currRing->p_Procs->pp_Mult_mm(sSigMult,m2,currRing);
2485 sSigMultNegSev = ~p_GetShortExpVector(sSigMult,currRing);
2486
2487//#if 1
2488#ifdef DEBUGF5
2489 PrintS("----------------\n");
2492 PrintS("----------------\n");
2493 Lp.checked = 0;
2494#endif
2496//#if 1
2497#if DEBUGF5
2498 Print("IN PAIR GENERATION - COMPARING SIGS: %d\n",sigCmp);
2501#endif
2502 if(sigCmp==0)
2503 {
2504 // printf("!!!! EQUAL SIGS !!!!\n");
2505 // pSig = sSig, delete element due to Rewritten Criterion
2506 pDelete(&pSigMult);
2507 pDelete(&sSigMult);
2509 pLmDelete(Lp.lcm);
2510 else
2511 pLmFree(Lp.lcm);
2512 pDelete (&m1);
2513 pDelete (&m2);
2514 return;
2515 }
2516 // testing by syzCrit = F5 Criterion
2517 // testing by rewCrit1 = Rewritten Criterion
2518 // NOTE: Arri's Rewritten Criterion is tested below, we need Lp.p for it!
2519 if ( strat->syzCrit(pSigMult,pSigMultNegSev,strat) ||
2520 strat->syzCrit(sSigMult,sSigMultNegSev,strat)
2521 || strat->rewCrit1(sSigMult,sSigMultNegSev,Lp.lcm,strat,i+1)
2522 )
2523 {
2524 pDelete(&pSigMult);
2525 pDelete(&sSigMult);
2527 pLmDelete(Lp.lcm);
2528 else
2529 pLmFree(Lp.lcm);
2530 pDelete (&m1);
2531 pDelete (&m2);
2532 return;
2533 }
2534 /*
2535 *the pair (S[i],p) enters B if the spoly != 0
2536 */
2537 /*- compute the short s-polynomial -*/
2538 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2539 pNorm(p);
2540
2541 if ((strat->S[i]==NULL) || (p==NULL))
2542 return;
2543
2544 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2545 Lp.p=NULL;
2546 else
2547 {
2548 #ifdef HAVE_PLURAL
2549 if ( rIsPluralRing(currRing) )
2550 {
2551 if(pHasNotCF(p, strat->S[i]))
2552 {
2553 if(ncRingType(currRing) == nc_lie)
2554 {
2555 // generalized prod-crit for lie-type
2556 strat->cp++;
2557 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2558 }
2559 else
2560 if( ALLOW_PROD_CRIT(strat) )
2561 {
2562 // product criterion for homogeneous case in SCA
2563 strat->cp++;
2564 Lp.p = NULL;
2565 }
2566 else
2567 {
2568 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2569 nc_CreateShortSpoly(strat->S[i], p, currRing);
2570
2571 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2572 pNext(Lp.p) = strat->tail; // !!!
2573 }
2574 }
2575 else
2576 {
2577 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2578 nc_CreateShortSpoly(strat->S[i], p, currRing);
2579
2580 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2581 pNext(Lp.p) = strat->tail; // !!!
2582 }
2583 }
2584 else
2585 #endif
2586 {
2588 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2589 }
2590 }
2591 // store from which element this pair comes from for further tests
2592 //Lp.from = strat->sl+1;
2593 if(sigCmp==currRing->OrdSgn)
2594 {
2595 // pSig > sSig
2596 pDelete (&sSigMult);
2597 Lp.sig = pSigMult;
2598 Lp.sevSig = ~pSigMultNegSev;
2599 }
2600 else
2601 {
2602 // pSig < sSig
2603 pDelete (&pSigMult);
2604 Lp.sig = sSigMult;
2605 Lp.sevSig = ~sSigMultNegSev;
2606 }
2607 if (Lp.p == NULL)
2608 {
2609 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2610 int pos = posInSyz(strat, Lp.sig);
2611 enterSyz(Lp, strat, pos);
2612 }
2613 else
2614 {
2615 // testing by rewCrit3 = Arris Rewritten Criterion (for F5 nothing happens!)
2616 if (strat->rewCrit3(Lp.sig,~Lp.sevSig,Lp.p,strat,strat->sl+1))
2617 {
2618 pLmFree(Lp.lcm);
2619 pDelete(&Lp.sig);
2620 pDelete (&m1);
2621 pDelete (&m2);
2622 return;
2623 }
2624 // in any case Lp is checked up to the next strat->P which is added
2625 // to S right after this critical pair creation.
2626 // NOTE: this even holds if the 2nd generator gives the bigger signature
2627 // moreover, this improves rewCriterion,
2628 // i.e. strat->checked > strat->from if and only if the 2nd generator
2629 // gives the bigger signature.
2630 Lp.checked = strat->sl+1;
2631 // at this point it is clear that the pair will be added to L, since it has
2632 // passed all tests up to now
2633
2634 // adds buchberger's first criterion
2635 if (pLmCmp(m2,pHead(p)) == 0)
2636 {
2637 Lp.prod_crit = TRUE; // Product Criterion
2638#if 0
2639 int pos = posInSyz(strat, Lp.sig);
2640 enterSyz(Lp, strat, pos);
2641 pDelete (&m1);
2642 pDelete (&m2);
2643 return;
2644#endif
2645 }
2646 pDelete (&m1);
2647 pDelete (&m2);
2648#if DEBUGF5
2649 PrintS("SIGNATURE OF PAIR: ");
2650 pWrite(Lp.sig);
2651#endif
2652 /*- the pair (S[i],p) enters B -*/
2653 Lp.p1 = strat->S[i];
2654 Lp.p2 = p;
2655
2656 if (
2658// || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
2659 )
2660 {
2661 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2662 pNext(Lp.p) = strat->tail; // !!!
2663 }
2664
2665 if (atR >= 0)
2666 {
2667 Lp.i_r1 = strat->S_2_R[i];
2668 Lp.i_r2 = atR;
2669 }
2670 else
2671 {
2672 Lp.i_r1 = -1;
2673 Lp.i_r2 = -1;
2674 }
2675 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
2676
2678 {
2681 && (Lp.p->coef!=NULL))
2682 nDelete(&(Lp.p->coef));
2683 }
2684
2685 l = strat->posInLSba(strat->B,strat->Bl,&Lp,strat);
2686 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
2687 }
2688}
BOOLEAN(* rewCrit1)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:293
BOOLEAN(* rewCrit3)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:295
BOOLEAN(* syzCrit)(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.h:292
void enterSyz(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9340
int posInSyz(const kStrategy strat, poly sig)
Definition kutil.cc:5762
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:847

◆ enterOnePairSigRing()

static void enterOnePairSigRing ( int  i,
poly  p,
poly  pSig,
int  ,
int  ecart,
int  isFromQ,
kStrategy  strat,
int  atR = -1 
)
static

Definition at line 2694 of file kutil.cc.

2696{
2697 #if ALL_VS_JUST
2698 //Over rings, if we construct the strong pair, do not add the spair
2700 {
2701 number s,t,d;
2702 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(strat->S[i]), &s, &t, currRing->cf);
2703
2704 if (!nIsZero(s) && !nIsZero(t)) // evtl. durch divBy tests ersetzen
2705 {
2706 nDelete(&d);
2707 nDelete(&s);
2708 nDelete(&t);
2709 return;
2710 }
2711 nDelete(&d);
2712 nDelete(&s);
2713 nDelete(&t);
2714 }
2715 #endif
2716 assume(i<=strat->sl);
2717 int l;
2718 poly m1 = NULL,m2 = NULL; // we need the multipliers for the s-polynomial to compute
2719 // the corresponding signatures for criteria checks
2720 LObject Lp;
2721 poly pSigMult = p_Copy(pSig,currRing);
2722 poly sSigMult = p_Copy(strat->sig[i],currRing);
2723 unsigned long pSigMultNegSev,sSigMultNegSev;
2724 Lp.i_r = -1;
2725
2726#ifdef KDEBUG
2727 Lp.ecart=0; Lp.length=0;
2728#endif
2729 /*- computes the lcm(s[i],p) -*/
2730 Lp.lcm = pInit();
2731 k_GetLeadTerms(p,strat->S[i],currRing,m1,m2,currRing);
2732#ifndef HAVE_RATGRING
2733 pLcm(p,strat->S[i],Lp.lcm);
2734#elif defined(HAVE_RATGRING)
2735 if (rIsRatGRing(currRing))
2736 pLcmRat(p,strat->S[i],Lp.lcm, currRing->real_var_start); // int rat_shift
2737 else
2738 pLcm(p,strat->S[i],Lp.lcm);
2739#endif
2740 pSetm(Lp.lcm);
2741
2742 // set coeffs of multipliers m1 and m2
2744 {
2745 number s = nCopy(pGetCoeff(strat->S[i]));
2746 number t = nCopy(pGetCoeff(p));
2747 pSetCoeff0(Lp.lcm, n_Lcm(s, t, currRing->cf));
2748 ksCheckCoeff(&s, &t, currRing->cf);
2749 pSetCoeff0(m1,s);
2750 pSetCoeff0(m2,t);
2751 }
2752 else
2753 {
2754 pSetCoeff0(m1, nInit(1));
2755 pSetCoeff0(m2, nInit(1));
2756 }
2757#ifdef DEBUGF5
2758 Print("P1 ");
2759 pWrite(pHead(p));
2760 Print("P2 ");
2761 pWrite(pHead(strat->S[i]));
2762 Print("M1 ");
2763 pWrite(m1);
2764 Print("M2 ");
2765 pWrite(m2);
2766#endif
2767
2768 // get multiplied signatures for testing
2770 if(pSigMult != NULL)
2771 pSigMultNegSev = ~p_GetShortExpVector(pSigMult,currRing);
2773 if(sSigMult != NULL)
2774 sSigMultNegSev = ~p_GetShortExpVector(sSigMult,currRing);
2775//#if 1
2776#ifdef DEBUGF5
2777 Print("----------------\n");
2780 Print("----------------\n");
2781 Lp.checked = 0;
2782#endif
2783 int sigCmp;
2784 if(pSigMult != NULL && sSigMult != NULL)
2785 {
2788 else
2790 }
2791 else
2792 {
2793 if(pSigMult == NULL)
2794 {
2795 if(sSigMult == NULL)
2796 sigCmp = 0;
2797 else
2798 sigCmp = -1;
2799 }
2800 else
2801 sigCmp = 1;
2802 }
2803//#if 1
2804#if DEBUGF5
2805 Print("IN PAIR GENERATION - COMPARING SIGS: %d\n",sigCmp);
2808#endif
2809 //In the ring case we already build the sig
2811 {
2812 if(sigCmp == 0)
2813 {
2814 //sigdrop since we loose the signature
2815 strat->sigdrop = TRUE;
2816 //Try to reduce it as far as we can via redRing
2818 {
2819 poly p1 = p_Copy(p,currRing);
2820 poly p2 = p_Copy(strat->S[i],currRing);
2821 p1 = p_Mult_mm(p1,m1,currRing);
2822 p2 = p_Mult_mm(p2,m2,currRing);
2823 Lp.p = p_Sub(p1,p2,currRing);
2824 if(Lp.p != NULL)
2826 }
2827 int red_result = redRing(&Lp,strat);
2828 if(red_result == 0)
2829 {
2830 // Cancel the sigdrop
2831 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
2832 strat->sigdrop = FALSE;
2833 return;
2834 }
2835 else
2836 {
2837 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
2838 #if 1
2839 strat->enterS(Lp,0,strat,strat->tl);
2840 #endif
2841 return;
2842 }
2843 }
2845 {
2846 //Same lm, have to subtract
2848 }
2849 else
2850 {
2851 if(sigCmp == 1)
2852 {
2853 Lp.sig = pCopy(pSigMult);
2854 }
2855 if(sigCmp == -1)
2856 {
2857 Lp.sig = pNeg(pCopy(sSigMult));
2858 }
2859 }
2860 Lp.sevSig = p_GetShortExpVector(Lp.sig,currRing);
2861 }
2862
2863 #if 0
2864 if(sigCmp==0)
2865 {
2866 // printf("!!!! EQUAL SIGS !!!!\n");
2867 // pSig = sSig, delete element due to Rewritten Criterion
2868 pDelete(&pSigMult);
2869 pDelete(&sSigMult);
2871 pLmDelete(Lp.lcm);
2872 else
2873 pLmFree(Lp.lcm);
2874 pDelete (&m1);
2875 pDelete (&m2);
2876 return;
2877 }
2878 #endif
2879 // testing by syzCrit = F5 Criterion
2880 // testing by rewCrit1 = Rewritten Criterion
2881 // NOTE: Arri's Rewritten Criterion is tested below, we need Lp.p for it!
2882 if ( strat->syzCrit(pSigMult,pSigMultNegSev,strat) ||
2883 strat->syzCrit(sSigMult,sSigMultNegSev,strat)
2884 // With this rewCrit activated i get a wrong deletion in sba_int_56.tst
2885 //|| strat->rewCrit1(sSigMult,sSigMultNegSev,Lp.lcm,strat,i+1)
2886 )
2887 {
2888 pDelete(&pSigMult);
2889 pDelete(&sSigMult);
2891 pLmDelete(Lp.lcm);
2892 else
2893 pLmFree(Lp.lcm);
2894 pDelete (&m1);
2895 pDelete (&m2);
2896 return;
2897 }
2898 /*
2899 *the pair (S[i],p) enters B if the spoly != 0
2900 */
2901 /*- compute the short s-polynomial -*/
2902 if (strat->fromT && !TEST_OPT_INTSTRATEGY)
2903 pNorm(p);
2904
2905 if ((strat->S[i]==NULL) || (p==NULL))
2906 return;
2907
2908 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
2909 Lp.p=NULL;
2910 else
2911 {
2912 //Build p
2914 {
2915 poly p1 = p_Copy(p,currRing);
2916 poly p2 = p_Copy(strat->S[i],currRing);
2917 p1 = p_Mult_mm(p1,m1,currRing);
2918 p2 = p_Mult_mm(p2,m2,currRing);
2919 Lp.p = p_Sub(p1,p2,currRing);
2920 if(Lp.p != NULL)
2922 }
2923 else
2924 {
2925 #ifdef HAVE_PLURAL
2926 if ( rIsPluralRing(currRing) )
2927 {
2928 if(ncRingType(currRing) == nc_lie)
2929 {
2930 // generalized prod-crit for lie-type
2931 strat->cp++;
2932 Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i], currRing);
2933 }
2934 else
2935 if( ALLOW_PROD_CRIT(strat) )
2936 {
2937 // product criterion for homogeneous case in SCA
2938 strat->cp++;
2939 Lp.p = NULL;
2940 }
2941 else
2942 {
2943 Lp.p = // nc_CreateSpoly(strat->S[i],p,currRing);
2944 nc_CreateShortSpoly(strat->S[i], p, currRing);
2945
2946 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
2947 pNext(Lp.p) = strat->tail; // !!!
2948 }
2949 }
2950 else
2951 #endif
2952 {
2954 Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
2955 }
2956 }
2957 }
2958 // store from which element this pair comes from for further tests
2959 //Lp.from = strat->sl+1;
2961 {
2962 //Put the sig to be > 0
2963 if(!nGreaterZero(pGetCoeff(Lp.sig)))
2964 {
2965 Lp.sig = pNeg(Lp.sig);
2966 Lp.p = pNeg(Lp.p);
2967 }
2968 }
2969 else
2970 {
2971 if(sigCmp==currRing->OrdSgn)
2972 {
2973 // pSig > sSig
2974 pDelete (&sSigMult);
2975 Lp.sig = pSigMult;
2976 Lp.sevSig = ~pSigMultNegSev;
2977 }
2978 else
2979 {
2980 // pSig < sSig
2981 pDelete (&pSigMult);
2982 Lp.sig = sSigMult;
2983 Lp.sevSig = ~sSigMultNegSev;
2984 }
2985 }
2986 if (Lp.p == NULL)
2987 {
2988 if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
2989 int pos = posInSyz(strat, Lp.sig);
2990 enterSyz(Lp, strat, pos);
2991 }
2992 else
2993 {
2994 // testing by rewCrit3 = Arris Rewritten Criterion (for F5 nothing happens!)
2995 if (strat->rewCrit3(Lp.sig,~Lp.sevSig,Lp.p,strat,strat->sl+1))
2996 {
2997 pLmFree(Lp.lcm);
2998 pDelete(&Lp.sig);
2999 pDelete (&m1);
3000 pDelete (&m2);
3001 return;
3002 }
3003 // in any case Lp is checked up to the next strat->P which is added
3004 // to S right after this critical pair creation.
3005 // NOTE: this even holds if the 2nd generator gives the bigger signature
3006 // moreover, this improves rewCriterion,
3007 // i.e. strat->checked > strat->from if and only if the 2nd generator
3008 // gives the bigger signature.
3009 Lp.checked = strat->sl+1;
3010 // at this point it is clear that the pair will be added to L, since it has
3011 // passed all tests up to now
3012
3013 // adds buchberger's first criterion
3014 if (pLmCmp(m2,pHead(p)) == 0)
3015 {
3016 Lp.prod_crit = TRUE; // Product Criterion
3017#if 0
3018 int pos = posInSyz(strat, Lp.sig);
3019 enterSyz(Lp, strat, pos);
3020 pDelete (&m1);
3021 pDelete (&m2);
3022 return;
3023#endif
3024 }
3025 pDelete (&m1);
3026 pDelete (&m2);
3027#if DEBUGF5
3028 PrintS("SIGNATURE OF PAIR: ");
3029 pWrite(Lp.sig);
3030#endif
3031 /*- the pair (S[i],p) enters B -*/
3032 Lp.p1 = strat->S[i];
3033 Lp.p2 = p;
3034
3035 if (
3037// || (rIsPluralRing(currRing) && (ncRingType(currRing) != nc_lie))
3039 )
3040 {
3041 assume(pNext(Lp.p)==NULL); // TODO: this may be violated whenever ext.prod.crit. for Lie alg. is used
3042 pNext(Lp.p) = strat->tail; // !!!
3043 }
3044
3045 if (atR >= 0)
3046 {
3047 Lp.i_r1 = strat->S_2_R[i];
3048 Lp.i_r2 = atR;
3049 }
3050 else
3051 {
3052 Lp.i_r1 = -1;
3053 Lp.i_r2 = -1;
3054 }
3055 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
3056
3058 {
3061 && (Lp.p->coef!=NULL))
3062 nDelete(&(Lp.p->coef));
3063 }
3064 // Check for sigdrop
3065 if(rField_is_Ring(currRing) && pLtCmp(Lp.sig,pSig) == -1)
3066 {
3067 strat->sigdrop = TRUE;
3068 // Completely reduce it
3069 int red_result = redRing(&Lp,strat);
3070 if(red_result == 0)
3071 {
3072 // Reduced to 0
3073 strat->sigdrop = FALSE;
3074 p_Delete(&Lp.sig,currRing);Lp.sig = NULL;
3075 return;
3076 }
3077 else
3078 {
3079 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
3080 // 0 - add just the original poly causing the sigdrop, 1 - add also this
3081 #if 1
3082 strat->enterS(Lp,0,strat, strat->tl+1);
3083 #endif
3084 return;
3085 }
3086 }
3087 l = strat->posInLSba(strat->L,strat->Ll,&Lp,strat);
3088 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l);
3089 }
3090}
#define nGreaterZero(n)
Definition numbers.h:27
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4849
poly p_Sub(poly p1, poly p2, const ring r)
Definition p_polys.cc:1994
static int p_LtCmpNoAbs(poly p, poly q, const ring r)
Definition p_polys.h:1662
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1052
#define pLtCmp(p, q)
Definition polys.h:123

◆ enterOnePairSpecial()

void enterOnePairSpecial ( int  i,
poly  p,
int  ecart,
kStrategy  strat,
int  atR = -1 
)

Definition at line 3096 of file kutil.cc.

3097{
3098 //PrintS("try ");wrp(strat->S[i]);PrintS(" and ");wrp(p);PrintLn();
3099 if(pHasNotCF(p,strat->S[i]))
3100 {
3101 //PrintS("prod-crit\n");
3102 if(ALLOW_PROD_CRIT(strat))
3103 {
3104 //PrintS("prod-crit\n");
3105 strat->cp++;
3106 return;
3107 }
3108 }
3109
3110 int l;
3111 LObject Lp;
3112 Lp.i_r = -1;
3113
3114 Lp.lcm = p_Lcm(p,strat->S[i],currRing);
3115 /*- compute the short s-polynomial -*/
3116
3117 #ifdef HAVE_PLURAL
3119 {
3120 Lp.p = nc_CreateShortSpoly(strat->S[i],p, currRing); // ??? strat->tailRing?
3121 }
3122 else
3123 #endif
3124 Lp.p = ksCreateShortSpoly(strat->S[i],p,strat->tailRing);
3125
3126 if (Lp.p == NULL)
3127 {
3128 //PrintS("short spoly==NULL\n");
3129 pLmFree(Lp.lcm);
3130 }
3131 else
3132 {
3133 /*- the pair (S[i],p) enters L -*/
3134 Lp.p1 = strat->S[i];
3135 Lp.p2 = p;
3136 if (atR >= 0)
3137 {
3138 Lp.i_r1 = strat->S_2_R[i];
3139 Lp.i_r2 = atR;
3140 }
3141 else
3142 {
3143 Lp.i_r1 = -1;
3144 Lp.i_r2 = -1;
3145 }
3146 assume(pNext(Lp.p) == NULL);
3147 pNext(Lp.p) = strat->tail;
3148 strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
3150 {
3153 && (Lp.p->coef!=NULL))
3154 nDelete(&(Lp.p->coef));
3155 }
3156 l = strat->posInL(strat->L,strat->Ll,&Lp,strat);
3157 //Print("-> L[%d]\n",l);
3158 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l);
3159 }
3160}

◆ enterOnePairWithoutShifts()

static BOOLEAN enterOnePairWithoutShifts ( int  p_inS,
poly  q,
poly  p,
int  ecartq,
int  q_isFromQ,
kStrategy  strat,
int  ,
int  p_lastVblock,
int  q_shift 
)
static

Definition at line 12123 of file kutil.cc.

12124{
12125 // note: ecart and isFromQ is for p
12126 assume(p_inS < 0 || strat->S[p_inS] == p); // if p is from S, p_inS should be the index of p in S
12127 assume(pmFirstVblock(p) == 1);
12129 assume(q_shift == pmFirstVblock(q) - 1);
12130
12131 // TODO: is ecartp = 0 still ok?
12132 int ecartp = 0; //Hans says it's ok; we're in the homog e:, no ecart
12133
12134 int p_isFromQ = 0;
12135 if (strat->fromQ != NULL && p_inS >= 0)
12136 p_isFromQ = strat->fromQ[p_inS];
12137
12139 {
12140 assume(q_shift <= p_lastVblock); // we allow the special case where there is no overlap
12142 }
12143 else
12144 {
12145 assume(q_shift <= p_lastVblock - ((pGetComp(q) > 0 || pGetComp(p) > 0) ? 0 : 1)); // there should be an overlap (in the module case epsilon overlap is also allowed)
12146 return enterOnePairShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
12147 }
12148}
static BOOLEAN enterOneStrongPolyAndEnterOnePairRingShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
Definition kutil.cc:12052
BOOLEAN enterOnePairShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
Definition kutil.cc:12161
#define pmFirstVblock(p)
Definition shiftop.h:35
#define pmLastVblock(p)
Definition shiftop.h:33

◆ enterOnePairWithShifts()

static BOOLEAN enterOnePairWithShifts ( int  q_inS,
poly  q,
poly  p,
int  ecartp,
int  p_isFromQ,
kStrategy  strat,
int  ,
int  p_lastVblock,
int  q_lastVblock 
)
static

Definition at line 12062 of file kutil.cc.

12063{
12064 // note: ecart and isFromQ is for p
12065 assume(q_inS < 0 || strat->S[q_inS] == q); // if q is from S, q_inS should be the index of q in S
12066 assume(pmFirstVblock(p) == 1);
12067 assume(pmFirstVblock(q) == 1);
12070
12071 // TODO: is ecartq = 0 still ok?
12072 int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
12073
12074 int q_isFromQ = 0;
12075 if (strat->fromQ != NULL && q_inS >= 0)
12076 q_isFromQ = strat->fromQ[q_inS];
12077
12078 BOOLEAN (*enterPair)(poly, poly, int, int, kStrategy, int, int, int, int, int);
12081 else
12083
12084 int degbound = currRing->N/currRing->isLPring;
12085 int neededShift = p_lastVblock - ((pGetComp(p) > 0 || pGetComp(q) > 0) ? 0 : 1); // in the module case, product criterion does not hold
12088 int firstShift = (q == p ? 1 : 0); // do not add (q,p) if q=p
12090 for (int j = firstShift; j <= maxShift; j++)
12091 {
12092 poly qq = pLPCopyAndShiftLM(q, j);
12093 if (enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, j, q_inS))
12094 {
12095 if (j>0) pLmDelete(qq);
12096 // delete qq, if not it does not enter the pair set
12097 }
12098 else
12100 }
12101
12103 {
12104 // add pairs (m*shifts(q), p) where m is a monomial and the pair has no overlap
12105 for (int j = p_lastVblock; j <= maxPossibleShift; j++)
12106 {
12108 for (int k = 0; k < IDELEMS(fillers); k++)
12109 {
12112 }
12113 idDelete(&fillers);
12114 }
12115 }
12116 return delete_pair;
12117}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define pLPCopyAndShiftLM(p, sh)
Definition shiftgb.h:15
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
#define IDELEMS(i)
skStrategy * kStrategy
Definition structs.h:54
#define degbound(p)
Definition tgb.cc:153

◆ enterOneStrongPoly()

static BOOLEAN enterOneStrongPoly ( int  i,
poly  p,
int  ,
int  ,
kStrategy  strat,
int  atR,
bool  enterTstrong 
)
static

Definition at line 1542 of file kutil.cc.

1543{
1544 number d, s, t;
1545 assume(atR >= 0);
1547 poly m1, m2, gcd,si;
1548 if(!enterTstrong)
1549 {
1550 assume(i<=strat->sl);
1551 si = strat->S[i];
1552 }
1553 else
1554 {
1555 assume(i<=strat->tl);
1556 si = strat->T[i].p;
1557 }
1558 //printf("\n--------------------------------\n");
1559 //pWrite(p);pWrite(si);
1560 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(si), &s, &t, currRing->cf);
1561
1562 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1563 {
1564 nDelete(&d);
1565 nDelete(&s);
1566 nDelete(&t);
1567 return FALSE;
1568 }
1569
1570 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1571
1573 {
1574 unsigned long sev = pGetShortExpVector(gcd);
1575
1576 for (int j = 0; j < strat->sl; j++)
1577 {
1578 if (j == i)
1579 continue;
1580
1581 if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf)
1582 && !(strat->sevS[j] & ~sev)
1583 && p_LmDivisibleBy(strat->S[j], gcd, currRing))
1584 {
1585 nDelete(&d);
1586 nDelete(&s);
1587 nDelete(&t);
1588 return FALSE;
1589 }
1590 }
1591 }
1592
1593 //p_Test(m1,strat->tailRing);
1594 //p_Test(m2,strat->tailRing);
1595 /*if(!enterTstrong)
1596 {
1597 while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
1598 {
1599 memset(&(strat->P), 0, sizeof(strat->P));
1600 kStratChangeTailRing(strat);
1601 strat->P = *(strat->R[atR]);
1602 p_LmFree(m1, strat->tailRing);
1603 p_LmFree(m2, strat->tailRing);
1604 p_LmFree(gcd, currRing);
1605 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1606 }
1607 }*/
1608 pSetCoeff0(m1, s);
1609 pSetCoeff0(m2, t);
1610 pSetCoeff0(gcd, d);
1611 p_Test(m1,strat->tailRing);
1612 p_Test(m2,strat->tailRing);
1613 //printf("\n===================================\n");
1614 //pWrite(m1);pWrite(m2);pWrite(gcd);
1615#ifdef KDEBUG
1616 if (TEST_OPT_DEBUG)
1617 {
1618 // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
1619 PrintS("m1 = ");
1620 p_wrp(m1, strat->tailRing);
1621 PrintS(" ; m2 = ");
1622 p_wrp(m2, strat->tailRing);
1623 PrintS(" ; gcd = ");
1624 wrp(gcd);
1625 PrintS("\n--- create strong gcd poly: ");
1626 Print("\n p: %d", i);
1627 wrp(p);
1628 Print("\n strat->S[%d]: ", i);
1629 wrp(si);
1630 PrintS(" ---> ");
1631 }
1632#endif
1633
1634 pNext(gcd) = p_Add_q(pp_Mult_mm(pNext(p), m1, strat->tailRing), pp_Mult_mm(pNext(si), m2, strat->tailRing), strat->tailRing);
1635 p_LmDelete(m1, strat->tailRing);
1636 p_LmDelete(m2, strat->tailRing);
1637#ifdef KDEBUG
1638 if (TEST_OPT_DEBUG)
1639 {
1640 wrp(gcd);
1641 PrintLn();
1642 }
1643#endif
1644
1645 LObject h;
1646 h.p = gcd;
1647 h.tailRing = strat->tailRing;
1648 int posx;
1649 strat->initEcart(&h);
1650 h.sev = pGetShortExpVector(h.p);
1651 h.i_r1 = -1;h.i_r2 = -1;
1652 if (currRing!=strat->tailRing)
1653 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
1654 if(!enterTstrong)
1655 {
1656 #if 1
1657 h.p1 = p;h.p2 = strat->S[i];
1658 #endif
1659 if (atR >= 0)
1660 {
1661 h.i_r2 = strat->S_2_R[i];
1662 h.i_r1 = atR;
1663 }
1664 else
1665 {
1666 h.i_r1 = -1;
1667 h.i_r2 = -1;
1668 }
1669 if (strat->Ll==-1)
1670 posx =0;
1671 else
1672 posx = strat->posInL(strat->L,strat->Ll,&h,strat);
1673 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
1674 }
1675 else
1676 {
1677 if(h.IsNull()) return FALSE;
1678 //int red_result;
1679 //reduzieren ist teur!!!
1680 //if(strat->L != NULL)
1681 //red_result = strat->red(&h,strat);
1682 if(!h.IsNull())
1683 {
1684 enterT(h, strat,-1);
1685 //int pos = posInS(strat,strat->sl,h.p,h.ecart);
1686 //strat->enterS(h,pos,strat,-1);
1687 }
1688 }
1689 return TRUE;
1690}
KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring tailRing)
Definition kInline.h:1057
void enterT(LObject &p, kStrategy strat, int atT)
Definition kutil.cc:9140
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1906
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:767

◆ enterOneStrongPolyAndEnterOnePairRingShift()

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

Definition at line 12052 of file kutil.cc.

12053{
12054 enterOneStrongPolyShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "gpoly"
12055 enterOnePairRingShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "spoly"
12056 return FALSE; // TODO: delete q?
12057}
static void enterOnePairRingShift(poly q, poly p, int, int isFromQ, kStrategy strat, int atR, int, int qisFromQ, int shiftcount, int ifromS)
Definition kutil.cc:11808
static BOOLEAN enterOneStrongPolyShift(poly q, poly p, int, int, kStrategy strat, int atR, int, int, int shiftcount, int ifromS)
Definition kutil.cc:11639

◆ enterOneStrongPolyShift()

static BOOLEAN enterOneStrongPolyShift ( poly  q,
poly  p,
int  ,
int  ,
kStrategy  strat,
int  atR,
int  ,
int  ,
int  shiftcount,
int  ifromS 
)
static

Definition at line 11639 of file kutil.cc.

11640{
11641 number d, s, t;
11642 /* assume(atR >= 0); */
11645 poly m1, m2, gcd;
11646 //printf("\n--------------------------------\n");
11647 //pWrite(p);pWrite(si);
11648 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(q), &s, &t, currRing->cf);
11649
11650 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
11651 {
11652 nDelete(&d);
11653 nDelete(&s);
11654 nDelete(&t);
11655 return FALSE;
11656 }
11657
11658 assume(pIsInV(p));
11659
11660 k_GetStrongLeadTerms(p, q, currRing, m1, m2, gcd, strat->tailRing);
11661
11662 /* the V criterion */
11663 if (!pmIsInV(gcd))
11664 {
11665 strat->cv++;
11666 nDelete(&d);
11667 nDelete(&s);
11668 nDelete(&t);
11669 pLmFree(gcd);
11670 return FALSE;
11671 }
11672
11673 // disabled for Letterplace because it is not so easy to check
11674 /* if (!rHasLocalOrMixedOrdering(currRing)) { */
11675 /* unsigned long sev = pGetShortExpVector(gcd); */
11676
11677 /* for (int j = 0; j < strat->sl; j++) { */
11678 /* if (j == i) */
11679 /* continue; */
11680
11681 /* if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf) && */
11682 /* !(strat->sevS[j] & ~sev) && */
11683 /* p_LmDivisibleBy(strat->S[j], gcd, currRing)) { */
11684 /* nDelete(&d); */
11685 /* nDelete(&s); */
11686 /* nDelete(&t); */
11687 /* return FALSE; */
11688 /* } */
11689 /* } */
11690 /* } */
11691
11692 poly m12, m22;
11696 // manually free the coeffs, because pSetCoeff0 is used in the next step
11697 n_Delete(&(m1->coef), currRing->cf);
11698 n_Delete(&(m2->coef), currRing->cf);
11699
11700 //p_Test(m1,strat->tailRing);
11701 //p_Test(m2,strat->tailRing);
11702 /*if(!enterTstrong)
11703 {
11704 while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
11705 {
11706 memset(&(strat->P), 0, sizeof(strat->P));
11707 kStratChangeTailRing(strat);
11708 strat->P = *(strat->R[atR]);
11709 p_LmFree(m1, strat->tailRing);
11710 p_LmFree(m2, strat->tailRing);
11711 p_LmFree(gcd, currRing);
11712 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
11713 }
11714 }*/
11715 pSetCoeff0(m1, s);
11716 pSetCoeff0(m2, t);
11717 pSetCoeff0(gcd, d);
11718 p_Test(m1,strat->tailRing);
11719 p_Test(m2,strat->tailRing);
11720 p_Test(m12,strat->tailRing);
11721 p_Test(m22,strat->tailRing);
11722 assume(pmIsInV(m1));
11723 assume(pmIsInV(m2));
11724 assume(pmIsInV(m12));
11725 assume(pmIsInV(m22));
11726 //printf("\n===================================\n");
11727 //pWrite(m1);pWrite(m2);pWrite(gcd);
11728#ifdef KDEBUG
11729 if (TEST_OPT_DEBUG)
11730 {
11731 // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
11732 PrintS("m1 = ");
11733 p_wrp(m1, strat->tailRing);
11734 PrintS("m12 = ");
11735 p_wrp(m12, strat->tailRing);
11736 PrintS(" ; m2 = ");
11737 p_wrp(m2, strat->tailRing);
11738 PrintS(" ; m22 = ");
11739 p_wrp(m22, strat->tailRing);
11740 PrintS(" ; gcd = ");
11741 wrp(gcd);
11742 PrintS("\n--- create strong gcd poly: ");
11743 PrintS("\n p: ");
11744 wrp(p);
11745 Print("\n q (strat->S[%d]): ", ifromS);
11746 wrp(q);
11747 PrintS(" ---> ");
11748 }
11749#endif
11750
11751 pNext(gcd) = p_Add_q(pp_Mult_mm(pp_mm_Mult(pNext(p), m1, strat->tailRing), m12, strat->tailRing), pp_Mult_mm(pp_mm_Mult(pNext(q), m2, strat->tailRing), m22, strat->tailRing), strat->tailRing);
11752 p_LmDelete(m1, strat->tailRing);
11753 p_LmDelete(m2, strat->tailRing);
11754 p_LmDelete(m12, strat->tailRing);
11755 p_LmDelete(m22, strat->tailRing);
11756
11757 assume(pIsInV(gcd));
11758
11759#ifdef KDEBUG
11760 if (TEST_OPT_DEBUG)
11761 {
11762 wrp(gcd);
11763 PrintLn();
11764 }
11765#endif
11766
11767 LObject h;
11768 h.p = gcd;
11769 h.tailRing = strat->tailRing;
11770 int posx;
11771 strat->initEcart(&h);
11772 h.sev = pGetShortExpVector(h.p);
11773 h.i_r1 = -1;h.i_r2 = -1;
11774 if (currRing!=strat->tailRing)
11775 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
11776#if 1
11777 h.p1 = p;
11778 h.p2 = q;
11779#endif
11780 if (atR >= 0 && shiftcount == 0 && ifromS >= 0)
11781 {
11782 h.i_r2 = kFindInT(h.p1, strat);
11783 h.i_r1 = atR;
11784 }
11785 else
11786 {
11787 h.i_r1 = -1;
11788 h.i_r2 = -1;
11789 }
11790 if (strat->Ll==-1)
11791 posx =0;
11792 else
11793 posx = strat->posInL(strat->L,strat->Ll,&h,strat);
11794
11795 assume(pIsInV(h.p));
11796 assume(pIsInV(h.p1));
11797
11798 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
11799 return TRUE;
11800}

◆ enterOneStrongPolySig()

static BOOLEAN enterOneStrongPolySig ( int  i,
poly  p,
poly  sig,
int  ,
int  ,
kStrategy  strat,
int  atR 
)
static

Definition at line 1750 of file kutil.cc.

1751{
1752 number d, s, t;
1753 assume(atR >= 0);
1754 poly m1, m2, gcd,si;
1755 assume(i<=strat->sl);
1756 si = strat->S[i];
1757 //printf("\n--------------------------------\n");
1758 //pWrite(p);pWrite(si);
1759 d = n_ExtGcd(pGetCoeff(p), pGetCoeff(si), &s, &t, currRing->cf);
1760
1761 if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen
1762 {
1763 nDelete(&d);
1764 nDelete(&s);
1765 nDelete(&t);
1766 return FALSE;
1767 }
1768
1769 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1770 //p_Test(m1,strat->tailRing);
1771 //p_Test(m2,strat->tailRing);
1772 /*if(!enterTstrong)
1773 {
1774 while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
1775 {
1776 memset(&(strat->P), 0, sizeof(strat->P));
1777 kStratChangeTailRing(strat);
1778 strat->P = *(strat->R[atR]);
1779 p_LmFree(m1, strat->tailRing);
1780 p_LmFree(m2, strat->tailRing);
1781 p_LmFree(gcd, currRing);
1782 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
1783 }
1784 }*/
1785 pSetCoeff0(m1, s);
1786 pSetCoeff0(m2, t);
1787 pSetCoeff0(gcd, d);
1788 p_Test(m1,strat->tailRing);
1789 p_Test(m2,strat->tailRing);
1790 //printf("\n===================================\n");
1791 //pWrite(m1);pWrite(m2);pWrite(gcd);
1792#ifdef KDEBUG
1793 if (TEST_OPT_DEBUG)
1794 {
1795 // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
1796 PrintS("m1 = ");
1797 p_wrp(m1, strat->tailRing);
1798 PrintS(" ; m2 = ");
1799 p_wrp(m2, strat->tailRing);
1800 PrintS(" ; gcd = ");
1801 wrp(gcd);
1802 PrintS("\n--- create strong gcd poly: ");
1803 Print("\n p: %d", i);
1804 wrp(p);
1805 Print("\n strat->S[%d]: ", i);
1806 wrp(si);
1807 PrintS(" ---> ");
1808 }
1809#endif
1810
1811 pNext(gcd) = p_Add_q(pp_Mult_mm(pNext(p), m1, strat->tailRing), pp_Mult_mm(pNext(si), m2, strat->tailRing), strat->tailRing);
1812
1813#ifdef KDEBUG
1814 if (TEST_OPT_DEBUG)
1815 {
1816 wrp(gcd);
1817 PrintLn();
1818 }
1819#endif
1820
1821 //Check and set the signatures
1822 poly pSigMult = p_Copy(sig,currRing);
1823 poly sSigMult = p_Copy(strat->sig[i],currRing);
1826 p_LmDelete(m1, strat->tailRing);
1827 p_LmDelete(m2, strat->tailRing);
1828 poly pairsig;
1829 if(pLmCmp(pSigMult,sSigMult) == 0)
1830 {
1831 //Same lm, have to add them
1833 //This might be zero
1834 }
1835 else
1836 {
1837 //Set the sig to either pSigMult or sSigMult
1838 if(pLtCmp(pSigMult,sSigMult)==1)
1839 {
1840 pairsig = pSigMult;
1841 pDelete(&sSigMult);
1842 }
1843 else
1844 {
1845 pairsig = sSigMult;
1846 pDelete(&pSigMult);
1847 }
1848 }
1849
1850 LObject h;
1851 h.p = gcd;
1852 h.tailRing = strat->tailRing;
1853 h.sig = pairsig;
1854 int posx;
1855 strat->initEcart(&h);
1856 h.sev = pGetShortExpVector(h.p);
1857 h.i_r1 = -1;h.i_r2 = -1;
1858 if (currRing!=strat->tailRing)
1859 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
1860 if(h.sig == NULL)
1861 {
1862 //sigdrop since we loose the signature
1863 strat->sigdrop = TRUE;
1864 //Try to reduce it as far as we can via redRing
1865 int red_result = redRing(&h,strat);
1866 if(red_result == 0)
1867 {
1868 // Cancel the sigdrop
1869 p_Delete(&h.sig,currRing);h.sig = NULL;
1870 strat->sigdrop = FALSE;
1871 return FALSE;
1872 }
1873 else
1874 {
1875 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
1876 #if 1
1877 strat->enterS(h,0,strat,strat->tl);
1878 #endif
1879 return FALSE;
1880 }
1881 }
1882 if(!nGreaterZero(pGetCoeff(h.sig)))
1883 {
1884 h.sig = pNeg(h.sig);
1885 h.p = pNeg(h.p);
1886 }
1887
1888 if(rField_is_Ring(currRing) && pLtCmp(h.sig,sig) == -1)
1889 {
1890 strat->sigdrop = TRUE;
1891 // Completely reduce it
1892 int red_result = redRing(&h,strat);
1893 if(red_result == 0)
1894 {
1895 // Reduced to 0
1896 strat->sigdrop = FALSE;
1897 p_Delete(&h.sig,currRing);h.sig = NULL;
1898 return FALSE;
1899 }
1900 else
1901 {
1902 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
1903 // 0 - add just the original poly causing the sigdrop, 1 - add also this
1904 #if 1
1905 strat->enterS(h,0,strat, strat->tl+1);
1906 #endif
1907 return FALSE;
1908 }
1909 }
1910 //Check for sigdrop
1911 if(gcd != NULL && pLtCmp(sig,pairsig) > 0 && pLtCmp(strat->sig[i],pairsig) > 0)
1912 {
1913 strat->sigdrop = TRUE;
1914 //Enter this element to S
1915 strat->enterS(strat->P,strat->sl+1,strat, strat->tl+1);
1916 strat->enterS(h,strat->sl+1,strat,strat->tl+1);
1917 }
1918 #if 1
1919 h.p1 = p;h.p2 = strat->S[i];
1920 #endif
1921 if (atR >= 0)
1922 {
1923 h.i_r2 = strat->S_2_R[i];
1924 h.i_r1 = atR;
1925 }
1926 else
1927 {
1928 h.i_r1 = -1;
1929 h.i_r2 = -1;
1930 }
1931 if (strat->Ll==-1)
1932 posx =0;
1933 else
1934 posx = strat->posInLSba(strat->L,strat->Ll,&h,strat);
1935 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
1936 return TRUE;
1937}

◆ enterpairs()

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

Definition at line 4491 of file kutil.cc.

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

◆ enterpairsShift()

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

Definition at line 12945 of file kutil.cc.

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

◆ enterpairsSig()

void enterpairsSig ( poly  h,
poly  hSig,
int  hFrom,
int  k,
int  ecart,
int  pos,
kStrategy  strat,
int  atR 
)

Definition at line 4517 of file kutil.cc.

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

◆ enterpairsSpecial()

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

Definition at line 4540 of file kutil.cc.

4541{
4542 int j;
4543 const int iCompH = pGetComp(h);
4544
4546 {
4547 for (j=0; j<=k; j++)
4548 {
4549 const int iCompSj = pGetComp(strat->S[j]);
4550 if ((iCompH==iCompSj)
4551 //|| (0==iCompH) // can only happen,if iCompSj==0
4552 || (0==iCompSj))
4553 {
4554 enterOnePairRing(j,h,ecart,FALSE,strat, atR);
4555 }
4556 }
4557 kMergeBintoL(strat);
4558 }
4559 else
4560 {
4561 for (j=0; j<=k; j++)
4562 {
4563 const int iCompSj = pGetComp(strat->S[j]);
4564 if ((iCompH==iCompSj)
4565 //|| (0==iCompH) // can only happen,if iCompSj==0
4566 || (0==iCompSj))
4567 {
4568 enterOnePairSpecial(j,h,ecart,strat, atR);
4569 }
4570 }
4571 }
4572
4573 if (strat->noClearS) return;
4574
4575// #ifdef HAVE_PLURAL
4576/*
4577 if (rIsPluralRing(currRing))
4578 {
4579 j=pos;
4580 loop
4581 {
4582 if (j > k) break;
4583
4584 if (pLmDivisibleBy(h, strat->S[j]))
4585 {
4586 deleteInS(j, strat);
4587 j--;
4588 k--;
4589 }
4590
4591 j++;
4592 }
4593 }
4594 else
4595*/
4596// #endif // ??? Why was the following cancellation disabled for non-commutative rings?
4597 {
4598 j=pos;
4599 loop
4600 {
4601 unsigned long h_sev = pGetShortExpVector(h);
4602 if (j > k) break;
4603 clearS(h,h_sev,&j,&k,strat);
4604 j++;
4605 }
4606 }
4607}
char noClearS
Definition kutil.h:400
static void enterOnePairRing(int i, poly p, int, int isFromQ, kStrategy strat, int atR)
Definition kutil.cc:1338
void enterOnePairSpecial(int i, poly p, int ecart, kStrategy strat, int atR=-1)
Definition kutil.cc:3096

◆ enterSBba()

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

Definition at line 8791 of file kutil.cc.

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

◆ enterSBbaShift()

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

Definition at line 8891 of file kutil.cc.

8892{
8893 enterSBba(p, atS, strat, atR);
8894
8896 for (int i = maxPossibleShift; i > 0; i--)
8897 {
8898 // NOTE: don't use "shared tails" here. In rare cases it can cause problems
8899 // in `kNF2` because of lazy poly normalizations.
8900 LObject qq(p_Copy(p.p, strat->tailRing));
8901 p_mLPshift(qq.p, i, strat->tailRing);
8902 qq.shift = i;
8903 strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
8904 int atS = posInS(strat, strat->sl, qq.p, qq.ecart); // S needs to stay sorted because this is for example assumed when searching S later
8905 enterSBba(qq, atS, strat, -1);
8906 }
8907}
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4667
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8791
int p_mLPmaxPossibleShift(poly p, const ring r)
Definition shiftgb.cc:45
void p_mLPshift(poly m, int sh, const ring ri)
Definition shiftop.cc:362

◆ enterSMora()

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

Definition at line 1621 of file kstd1.cc.

1622{
1623 enterSBba(p, atS, strat, atR);
1624 #ifdef KDEBUG
1625 if (TEST_OPT_DEBUG)
1626 {
1627 Print("new s%d:",atS);
1628 p_wrp(p.p,currRing,strat->tailRing);
1629 PrintLn();
1630 }
1631 #endif
1632 HEckeTest(p.p,strat);
1633 if (strat->kAllAxis)
1634 {
1635 if (newHEdge(strat))
1636 {
1637 firstUpdate(strat);
1638 if (TEST_OPT_FINDET)
1639 return;
1640
1641 /*- cuts elements in L above noether and reorders L -*/
1642 updateLHC(strat);
1643 /*- reorders L with respect to posInL -*/
1644 reorderL(strat);
1645 }
1646 }
1647 else if ((strat->kNoether==NULL)
1648 && (TEST_OPT_FASTHC))
1649 {
1650 if (strat->posInLOldFlag)
1651 {
1652 missingAxis(&strat->lastAxis,strat);
1653 if (strat->lastAxis)
1654 {
1655 strat->posInLOld = strat->posInL;
1656 strat->posInLOldFlag = FALSE;
1657 strat->posInL = posInL10;
1658 strat->posInLDependsOnLength = TRUE;
1659 updateL(strat);
1660 reorderL(strat);
1661 }
1662 }
1663 else if (strat->lastAxis)
1664 updateL(strat);
1665 }
1666}
char posInLOldFlag
Definition kutil.h:380
int lastAxis
Definition kutil.h:355
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:288
char kAllAxis
Definition kutil.h:374
char posInLDependsOnLength
Definition kutil.h:387
void firstUpdate(kStrategy strat)
Definition kstd1.cc:1558
void updateLHC(kStrategy strat)
Definition kstd1.cc:1466
void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1280
void reorderL(kStrategy strat)
Definition kstd1.cc:1223
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1361
void updateL(kStrategy strat)
Definition kstd1.cc:1394
void HEckeTest(poly pp, kStrategy strat)
Definition kutil.cc:498
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10404
#define TEST_OPT_FINDET
Definition options.h:113
#define TEST_OPT_FASTHC
Definition options.h:111

◆ enterSMoraNF()

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

Definition at line 1674 of file kstd1.cc.

1675{
1676 enterSBba(p, atS, strat, atR);
1677 if ((!strat->kAllAxis) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat);
1678 if (strat->kAllAxis)
1679 newHEdge(strat);
1680}

◆ enterSSba()

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

Definition at line 8914 of file kutil.cc.

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

◆ enterSyz()

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

Definition at line 9340 of file kutil.cc.

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

◆ enterT()

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

Definition at line 9140 of file kutil.cc.

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

◆ enterT_strong()

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

Definition at line 9239 of file kutil.cc.

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

◆ enterTShift()

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

Definition at line 12975 of file kutil.cc.

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

◆ exitBuchMora()

void exitBuchMora ( kStrategy  strat)

Definition at line 9833 of file kutil.cc.

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

◆ exitSba()

void exitSba ( kStrategy  strat)

Definition at line 10036 of file kutil.cc.

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

◆ faugereRewCriterion()

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

Definition at line 6563 of file kutil.cc.

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

◆ finalReduceByMon()

void finalReduceByMon ( kStrategy  strat)

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

Definition at line 10865 of file kutil.cc.

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

◆ getIndexRng()

int getIndexRng ( long  coeff)
inline

Definition at line 6001 of file kutil.cc.

6002{
6003 if (coeff == 0) return -1;
6004 long tmp = coeff;
6005 int ind = 0;
6006 while (tmp % 2 == 0)
6007 {
6008 tmp = tmp / 2;
6009 ind++;
6010 }
6011 return ind;
6012}

◆ HEckeTest()

void HEckeTest ( poly  pp,
kStrategy  strat 
)

Definition at line 498 of file kutil.cc.

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

◆ initBuchMora()

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

Definition at line 9748 of file kutil.cc.

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

◆ initBuchMoraCrit()

void initBuchMoraCrit ( kStrategy  strat)

Definition at line 9432 of file kutil.cc.

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

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy  strat)

Definition at line 9577 of file kutil.cc.

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

◆ initBuchMoraPosRing()

void initBuchMoraPosRing ( kStrategy  strat)

Definition at line 9662 of file kutil.cc.

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

◆ initec()

static intset initec ( const int  maxnr)
inlinestatic

Definition at line 527 of file kutil.cc.

528{
529 return (intset)omAlloc(maxnr*sizeof(int));
530}

◆ initEcartBBA()

void initEcartBBA ( TObject h)

Definition at line 1305 of file kutil.cc.

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

◆ initEcartNormal()

void initEcartNormal ( TObject h)

Definition at line 1297 of file kutil.cc.

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

◆ initEcartPairBba()

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

Definition at line 1312 of file kutil.cc.

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

◆ initEcartPairMora()

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

Definition at line 1319 of file kutil.cc.

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

◆ initenterpairs()

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

Definition at line 3813 of file kutil.cc.

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

◆ initenterpairsShift()

void initenterpairsShift ( poly  h,
int  k,
int  ecart,
int  isFromQ,
kStrategy  strat,
int  atR 
)

Definition at line 12503 of file kutil.cc.

12504{
12507 // TODO: is it allowed to skip pairs with constants? also with constants from other components?
12508 if (h_lastVblock == 0) return;
12509 assume(pmFirstVblock(h) == 1);
12510 /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12511 // atR = -1;
12512 if ((strat->syzComp==0)
12513 || (pGetComp(h)<=strat->syzComp))
12514 {
12515 int i,j;
12517
12518 int degbound = currRing->N/currRing->isLPring;
12520
12521 if (pGetComp(h)==0)
12522 {
12523 if (strat->rightGB)
12524 {
12525 if (isFromQ)
12526 {
12527 // pairs (shifts(h),s[1..k]), (h, s[1..k])
12528 for (i=0; i<=maxShift; i++)
12529 {
12530 poly hh = pLPCopyAndShiftLM(h, i);
12532 for (j=0; j<=k; j++)
12533 {
12534 if (strat->fromQ == NULL || !strat->fromQ[j])
12535 {
12536 new_pair=TRUE;
12537 poly s = strat->S[j];
12538 if (!enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i))
12540 }
12541 }
12542 if (delete_hh) pLmDelete(hh);
12543 }
12544 }
12545 else
12546 {
12547 new_pair=TRUE;
12548 for (j=0; j<=k; j++)
12549 {
12550 poly s = strat->S[j];
12551 if (strat->fromQ != NULL && strat->fromQ[j])
12552 {
12553 // pairs (shifts(s[j]),h), (s[j],h)
12555 }
12556 else
12557 {
12558 // pair (h, s[j])
12559 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12560 }
12561 }
12562 }
12563 }
12564 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
12565 else if ((isFromQ)&&(strat->fromQ!=NULL))
12566 {
12567 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12568 for (j=0; j<=k; j++)
12569 {
12570 if (!strat->fromQ[j])
12571 {
12572 new_pair=TRUE;
12573 poly s = strat->S[j];
12575 }
12576 }
12577 // pairs (shifts(h),s[1..k])
12578 if (new_pair)
12579 {
12580 for (i=1; i<=maxShift; i++)
12581 {
12583 poly hh = pLPCopyAndShiftLM(h, i);
12584 for (j=0; j<=k; j++)
12585 {
12586 if (!strat->fromQ[j])
12587 {
12588 poly s = strat->S[j];
12590 if (i < s_lastVblock || (pGetComp(s) > 0 && i == s_lastVblock)) // in the module case, product criterion does not hold (note: comp h is always zero here)
12591 {
12592 if(!enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i))
12594 }
12595 else if (rField_is_Ring(currRing))
12596 {
12597 assume(i >= s_lastVblock); // this is always the case, but just to be very sure
12599 for (int k = 0; k < IDELEMS(fillers); k++)
12600 {
12603 }
12604 idDelete(&fillers);
12605 }
12606 }
12607 }
12609 }
12610 }
12611 }
12612 else
12613 {
12614 new_pair=TRUE;
12615 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12616 for (j=0; j<=k; j++)
12617 {
12618 poly s = strat->S[j];
12620 }
12621 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12622 for (i=1; i<=maxShift; i++)
12623 {
12624 poly hh = pLPCopyAndShiftLM(h, i);
12626 for (j=0; j<=k; j++)
12627 {
12628 poly s = strat->S[j];
12630 if (i < s_lastVblock || (pGetComp(s) > 0 && i == s_lastVblock)) // in the module case, product criterion does not hold (note: comp h is always zero here)
12632 && delete_hh;
12633 else if (rField_is_Ring(currRing))
12634 {
12635 assume(i >= s_lastVblock); // this is always the case, but just to be very sure
12637 for (int k = 0; k < IDELEMS(fillers); k++)
12638 {
12641 }
12642 idDelete(&fillers);
12643 }
12644 }
12645 if (i < h_lastVblock) // in the module case, product criterion does not hold (note: comp h is always zero here)
12647 && delete_hh;
12648 else if (rField_is_Ring(currRing))
12649 {
12650 assume(i >= h_lastVblock); // this is always the case, but just to be very sure
12652 for (int k = 0; k < IDELEMS(fillers); k++)
12653 {
12656 }
12657 idDelete(&fillers);
12658 }
12659 if (delete_hh) pLmDelete(hh);
12660 }
12661 }
12662 }
12663 else
12664 {
12665 assume(isFromQ == 0); // an element from Q should always has 0 component
12666 new_pair=TRUE;
12667 if (strat->rightGB)
12668 {
12669 for (j=0; j<=k; j++)
12670 {
12671 if ((pGetComp(h)==pGetComp(strat->S[j]))
12672 || (pGetComp(strat->S[j])==0))
12673 {
12674 poly s = strat->S[j];
12675 if (strat->fromQ != NULL && strat->fromQ[j])
12676 {
12677 // pairs (shifts(s[j]),h), (s[j],h)
12679 }
12680 else
12681 {
12682 // pair (h, s[j])
12683 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12684 }
12685 }
12686 }
12687 }
12688 else
12689 {
12690 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12691 for (j=0; j<=k; j++)
12692 {
12693 if ((pGetComp(h)==pGetComp(strat->S[j]))
12694 || (pGetComp(strat->S[j])==0))
12695 {
12696 poly s = strat->S[j];
12698 }
12699 }
12700 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12701 for (i=1; i<=maxShift; i++)
12702 {
12703 poly hh = pLPCopyAndShiftLM(h, i);
12704 for (j=0; j<=k; j++)
12705 {
12706 if ((pGetComp(h)==pGetComp(strat->S[j]))
12707 || (pGetComp(strat->S[j])==0))
12708 {
12709 poly s = strat->S[j];
12711 if (i <= s_lastVblock) // in the module case, product criterion does not hold
12712 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i);
12713 else if (rField_is_Ring(currRing))
12714 {
12715 assume(i >= s_lastVblock); // this is always the case, but just to be very sure
12717 for (int k = 0; k < IDELEMS(fillers); k++)
12718 {
12721 }
12722 idDelete(&fillers);
12723 }
12724 }
12725 }
12726 if (i <= h_lastVblock) // in the module case, product criterion does not hold
12727 enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
12728 else if (rField_is_Ring(currRing))
12729 {
12730 assume(i >= h_lastVblock); // this is always the case, but just to be very sure
12732 for (int k = 0; k < IDELEMS(fillers); k++)
12733 {
12739 }
12740 idDelete(&fillers);
12741 }
12742 }
12743 }
12744 }
12745
12746 if (new_pair)
12747 {
12748 strat->chainCrit(h,ecart,strat);
12749 }
12750 kMergeBintoL(strat);
12751 }
12752}
static BOOLEAN enterOnePairWithShifts(int q_inS, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int, int p_lastVblock, int q_lastVblock)
Definition kutil.cc:12062
static BOOLEAN enterOnePairWithoutShifts(int p_inS, poly q, poly p, int ecartq, int q_isFromQ, kStrategy strat, int, int p_lastVblock, int q_shift)
Definition kutil.cc:12123
#define pLmIsConstantComp(p)
like above, except that p must be != NULL
Definition polys.h:242

◆ initenterpairsSig()

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

Definition at line 3878 of file kutil.cc.

3879{
3880
3881 if ((strat->syzComp==0)
3882 || (pGetComp(h)<=strat->syzComp))
3883 {
3884 int j;
3886
3887 if (pGetComp(h)==0)
3888 {
3889 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3890 if ((isFromQ)&&(strat->fromQ!=NULL))
3891 {
3892 for (j=0; j<=k; j++)
3893 {
3894 if (!strat->fromQ[j])
3895 {
3896 new_pair=TRUE;
3897 enterOnePairSig(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3898 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3899 }
3900 }
3901 }
3902 else
3903 {
3904 new_pair=TRUE;
3905 for (j=0; j<=k; j++)
3906 {
3907 enterOnePairSig(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3908 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3909 }
3910 }
3911 }
3912 else
3913 {
3914 for (j=0; j<=k; j++)
3915 {
3916 if ((pGetComp(h)==pGetComp(strat->S[j]))
3917 || (pGetComp(strat->S[j])==0))
3918 {
3919 new_pair=TRUE;
3920 enterOnePairSig(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3921 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3922 }
3923 }
3924 }
3925
3926 if (new_pair)
3927 {
3928#ifdef HAVE_RATGRING
3929 if (currRing->real_var_start>0)
3930 chainCritPart(h,ecart,strat);
3931 else
3932#endif
3933 strat->chainCrit(h,ecart,strat);
3934 }
3935 }
3936}
static void enterOnePairSig(int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2437

◆ initenterpairsSigRing()

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

Definition at line 3938 of file kutil.cc.

3939{
3940
3941 if ((strat->syzComp==0)
3942 || (pGetComp(h)<=strat->syzComp))
3943 {
3944 int j;
3945
3946 if (pGetComp(h)==0)
3947 {
3948 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
3949 if ((isFromQ)&&(strat->fromQ!=NULL))
3950 {
3951 for (j=0; j<=k && !strat->sigdrop; j++)
3952 {
3953 if (!strat->fromQ[j])
3954 {
3955 enterOnePairSigRing(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3956 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3957 }
3958 }
3959 }
3960 else
3961 {
3962 for (j=0; j<=k && !strat->sigdrop; j++)
3963 {
3964 enterOnePairSigRing(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3965 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3966 }
3967 }
3968 }
3969 else
3970 {
3971 for (j=0; j<=k && !strat->sigdrop; j++)
3972 {
3973 if ((pGetComp(h)==pGetComp(strat->S[j]))
3974 || (pGetComp(strat->S[j])==0))
3975 {
3976 enterOnePairSigRing(j,h,hSig,hFrom,ecart,isFromQ,strat, atR);
3977 //Print("j:%d, Ll:%d\n",j,strat->Ll);
3978 }
3979 }
3980 }
3981
3982#if 0
3983 if (new_pair)
3984 {
3985#ifdef HAVE_RATGRING
3986 if (currRing->real_var_start>0)
3987 chainCritPart(h,ecart,strat);
3988 else
3989#endif
3990 strat->chainCrit(h,ecart,strat);
3991 }
3992#endif
3993 }
3994}
static void enterOnePairSigRing(int i, poly p, poly pSig, int, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2694

◆ initenterstrongPairs()

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

Definition at line 4156 of file kutil.cc.

4157{
4158 if (!nIsOne(pGetCoeff(h)))
4159 {
4160 int j;
4162
4163 if (pGetComp(h)==0)
4164 {
4165 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
4166 if ((isFromQ)&&(strat->fromQ!=NULL))
4167 {
4168 for (j=0; j<=k; j++)
4169 {
4170 if (!strat->fromQ[j])
4171 {
4172 new_pair=TRUE;
4173 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR, FALSE);
4174 }
4175 }
4176 }
4177 else
4178 {
4179 new_pair=TRUE;
4180 for (j=0; j<=k; j++)
4181 {
4182 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR, FALSE);
4183 }
4184 }
4185 }
4186 else
4187 {
4188 for (j=0; j<=k; j++)
4189 {
4190 if ((pGetComp(h)==pGetComp(strat->S[j]))
4191 || (pGetComp(strat->S[j])==0))
4192 {
4193 new_pair=TRUE;
4194 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR, FALSE);
4195 }
4196 }
4197 }
4198 if (new_pair)
4199 {
4200 #ifdef HAVE_RATGRING
4201 if (currRing->real_var_start>0)
4202 chainCritPart(h,ecart,strat);
4203 else
4204 #endif
4205 strat->chainCrit(h,ecart,strat);
4206 }
4207 kMergeBintoL(strat);
4208 }
4209}

◆ initenterstrongPairsShift()

void initenterstrongPairsShift ( poly  h,
int  k,
int  ecart,
int  isFromQ,
kStrategy  strat,
int  atR 
)

Definition at line 12761 of file kutil.cc.

12762{
12765 // TODO: is it allowed to skip pairs with constants? also with constants from other components?
12766 if (h_lastVblock == 0) return;
12767 assume(pmFirstVblock(h) == 1);
12768 /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
12769 // atR = -1;
12770 if ((strat->syzComp==0)
12771 || (pGetComp(h)<=strat->syzComp))
12772 {
12773 int i,j;
12775
12776 int degbound = currRing->N/currRing->isLPring;
12778
12779 if (pGetComp(h)==0)
12780 {
12781 if (strat->rightGB)
12782 {
12783 if (isFromQ)
12784 {
12785 // pairs (shifts(h),s[1..k]), (h, s[1..k])
12786 for (i=0; i<=maxShift; i++)
12787 {
12788 poly hh = pLPCopyAndShiftLM(h, i);
12789 for (j=0; j<=k; j++)
12790 {
12791 if (strat->fromQ == NULL || !strat->fromQ[j])
12792 {
12793 new_pair=TRUE;
12794 poly s = strat->S[j];
12795 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
12796 }
12797 }
12798 }
12799 }
12800 else
12801 {
12802 new_pair=TRUE;
12803 for (j=0; j<=k; j++)
12804 {
12805 poly s = strat->S[j];
12806 if (strat->fromQ != NULL && strat->fromQ[j])
12807 {
12808 // pairs (shifts(s[j]),h), (s[j],h)
12810 }
12811 else
12812 {
12813 // pair (h, s[j])
12814 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12815 }
12816 }
12817 }
12818 }
12819 /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
12820 else if ((isFromQ)&&(strat->fromQ!=NULL))
12821 {
12822 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12823 for (j=0; j<=k; j++)
12824 {
12825 if (!strat->fromQ[j])
12826 {
12827 new_pair=TRUE;
12828 poly s = strat->S[j];
12830 }
12831 }
12832 // pairs (shifts(h),s[1..k])
12833 if (new_pair)
12834 {
12835 for (i=1; i<=maxShift; i++)
12836 {
12837 poly hh = pLPCopyAndShiftLM(h, i);
12838 for (j=0; j<=k; j++)
12839 {
12840 if (!strat->fromQ[j])
12841 {
12842 poly s = strat->S[j];
12843 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
12844 }
12845 }
12846 }
12847 }
12848 }
12849 else
12850 {
12851 new_pair=TRUE;
12852 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12853 for (j=0; j<=k; j++)
12854 {
12855 poly s = strat->S[j];
12856 // TODO: cache lastVblock of s[1..k] for later use
12858 }
12859 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12860 for (i=1; i<=maxShift; i++)
12861 {
12862 poly hh = pLPCopyAndShiftLM(h, i);
12864 for (j=0; j<=k; j++)
12865 {
12866 poly s = strat->S[j];
12867 if(!enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i))
12869 }
12870 if(!enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i))
12873 }
12874 }
12875 }
12876 else
12877 {
12878 new_pair=TRUE;
12879 if (strat->rightGB)
12880 {
12881 for (j=0; j<=k; j++)
12882 {
12883 if ((pGetComp(h)==pGetComp(strat->S[j]))
12884 || (pGetComp(strat->S[j])==0))
12885 {
12886 assume(isFromQ == 0); // this case is not handled here and should also never happen
12887 poly s = strat->S[j];
12888 if (strat->fromQ != NULL && strat->fromQ[j])
12889 {
12890 // pairs (shifts(s[j]),h), (s[j],h)
12892 }
12893 else
12894 {
12895 // pair (h, s[j])
12896 enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
12897 }
12898 }
12899 }
12900 }
12901 else
12902 {
12903 // pairs (shifts(s[1..k]),h), (s[1..k],h)
12904 for (j=0; j<=k; j++)
12905 {
12906 if ((pGetComp(h)==pGetComp(strat->S[j]))
12907 || (pGetComp(strat->S[j])==0))
12908 {
12909 poly s = strat->S[j];
12911 }
12912 }
12913 // pairs (shifts(h),s[1..k]), (shifts(h), h)
12914 for (i=1; i<=maxShift; i++)
12915 {
12916 poly hh = pLPCopyAndShiftLM(h, i);
12917 for (j=0; j<=k; j++)
12918 {
12919 if ((pGetComp(h)==pGetComp(strat->S[j]))
12920 || (pGetComp(strat->S[j])==0))
12921 {
12922 poly s = strat->S[j];
12923 enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
12924 }
12925 }
12926 enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
12927 }
12928 }
12929 }
12930
12931 if (new_pair)
12932 {
12933 strat->chainCrit(h,ecart,strat);
12934 }
12935 kMergeBintoL(strat);
12936 }
12937}

◆ initenterstrongPairsSig()

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

Definition at line 4211 of file kutil.cc.

4212{
4213 const int iCompH = pGetComp(h);
4214 if (!nIsOne(pGetCoeff(h)))
4215 {
4216 int j;
4217
4218 for (j=0; j<=k && !strat->sigdrop; j++)
4219 {
4220 // Print("j:%d, Ll:%d\n",j,strat->Ll);
4221// if (((unsigned long) pGetCoeff(h) % (unsigned long) pGetCoeff(strat->S[j]) != 0) &&
4222// ((unsigned long) pGetCoeff(strat->S[j]) % (unsigned long) pGetCoeff(h) != 0))
4223 if (((iCompH == pGetComp(strat->S[j]))
4224 || (0 == pGetComp(strat->S[j])))
4225 && ((iCompH<=strat->syzComp)||(strat->syzComp==0)))
4226 {
4227 enterOneStrongPolySig(j,h,hSig,ecart,isFromQ,strat, atR);
4228 }
4229 }
4230 }
4231}
static BOOLEAN enterOneStrongPolySig(int i, poly p, poly sig, int, int, kStrategy strat, int atR)
Definition kutil.cc:1750

◆ initHilbCrit()

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

Definition at line 9414 of file kutil.cc.

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

◆ initPairtest()

void initPairtest ( kStrategy  strat)

Definition at line 690 of file kutil.cc.

691{
692 strat->pairtest = (BOOLEAN *)omAlloc0((strat->sl+2)*sizeof(BOOLEAN));
693}
#define omAlloc0(size)

◆ initS()

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

Definition at line 7587 of file kutil.cc.

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

◆ initS_2_R()

static int * initS_2_R ( const int  maxnr)
inlinestatic

Definition at line 536 of file kutil.cc.

537{
538 return (int*)omAlloc0(maxnr*sizeof(int));
539}

◆ initSbaBuchMora()

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

Definition at line 9961 of file kutil.cc.

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

◆ initSbaCrit()

void initSbaCrit ( kStrategy  strat)

Definition at line 9495 of file kutil.cc.

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

◆ initSbaPos()

void initSbaPos ( kStrategy  strat)

Definition at line 9859 of file kutil.cc.

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

◆ initsevS()

static unsigned long * initsevS ( const int  maxnr)
inlinestatic

Definition at line 532 of file kutil.cc.

533{
534 return (unsigned long*)omAlloc0(maxnr*sizeof(unsigned long));
535}

◆ initSL()

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

Definition at line 7680 of file kutil.cc.

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

◆ initSLSba()

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

Definition at line 7780 of file kutil.cc.

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

◆ initSSpecial()

void initSSpecial ( ideal  F,
ideal  Q,
ideal  P,
kStrategy  strat 
)

Definition at line 8087 of file kutil.cc.

8088{
8089 int i,pos;
8090
8091 if (Q!=NULL)
8092 {
8094 if (i<setmaxTinc) i=setmaxT;
8095 }
8096 else i=setmaxT;
8097 i=((i+IDELEMS(F)+IDELEMS(P)+setmax-1)/setmax)*setmax;
8098 strat->ecartS=initec(i);
8099 strat->sevS=initsevS(i);
8100 strat->S_2_R=initS_2_R(i);
8101 strat->fromQ=NULL;
8102 strat->Shdl=idInit(i,F->rank);
8103 strat->S=strat->Shdl->m;
8104
8105 /*- put polys into S -*/
8106 if (Q!=NULL)
8107 {
8108 strat->fromQ=initec(i);
8109 memset(strat->fromQ,0,i*sizeof(int));
8110 for (i=0; i<IDELEMS(Q); i++)
8111 {
8112 if (Q->m[i]!=NULL)
8113 {
8114 LObject h;
8115 h.p = pCopy(Q->m[i]);
8116 //if (TEST_OPT_INTSTRATEGY)
8117 //{
8118 // h.pCleardenom(); // also does remove Content
8119 //}
8120 //else
8121 //{
8122 // h.pNorm();
8123 //}
8125 {
8126 deleteHC(&h,strat);
8127 }
8128 if (h.p!=NULL)
8129 {
8130 strat->initEcart(&h);
8131 if (strat->sl==-1)
8132 pos =0;
8133 else
8134 {
8135 pos = posInS(strat,strat->sl,h.p,h.ecart);
8136 }
8137 h.sev = pGetShortExpVector(h.p);
8138 strat->enterS(h,pos,strat, strat->tl+1);
8139 enterT(h, strat);
8140 strat->fromQ[pos]=1;
8141 }
8142 }
8143 }
8144 }
8145 /*- put polys into S -*/
8146 for (i=0; i<IDELEMS(F); i++)
8147 {
8148 if (F->m[i]!=NULL)
8149 {
8150 LObject h;
8151 h.p = pCopy(F->m[i]);
8153 {
8154 deleteHC(&h,strat);
8155 }
8156 else if (TEST_OPT_REDTAIL || TEST_OPT_REDSB)
8157 {
8158 h.p=redtailBba(h.p,strat->sl,strat);
8159 }
8160 if (h.p!=NULL)
8161 {
8162 strat->initEcart(&h);
8163 if (strat->sl==-1)
8164 pos =0;
8165 else
8166 pos = posInS(strat,strat->sl,h.p,h.ecart);
8167 h.sev = pGetShortExpVector(h.p);
8168 strat->enterS(h,pos,strat, strat->tl+1);
8169 enterT(h,strat);
8170 }
8171 }
8172 }
8173 for (i=0; i<IDELEMS(P); i++)
8174 {
8175 if (P->m[i]!=NULL)
8176 {
8177 LObject h;
8178 h.p=pCopy(P->m[i]);
8180 {
8181 h.pCleardenom();
8182 }
8183 else
8184 {
8185 h.pNorm();
8186 }
8187 if(strat->sl>=0)
8188 {
8190 {
8191 h.p=redBba(h.p,strat->sl,strat);
8192 if ((h.p!=NULL)&&(TEST_OPT_REDTAIL || TEST_OPT_REDSB))
8193 {
8194 h.p=redtailBba(h.p,strat->sl,strat);
8195 }
8196 }
8197 else
8198 {
8199 h.p=redMora(h.p,strat->sl,strat);
8200 }
8201 if(h.p!=NULL)
8202 {
8203 strat->initEcart(&h);
8205 {
8206 h.pCleardenom();
8207 }
8208 else
8209 {
8210 h.is_normalized = 0;
8211 h.pNorm();
8212 }
8213 h.sev = pGetShortExpVector(h.p);
8214 h.SetpFDeg();
8215 pos = posInS(strat,strat->sl,h.p,h.ecart);
8216 enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1);
8217 strat->enterS(h,pos,strat, strat->tl+1);
8218 enterT(h,strat);
8219 }
8220 }
8221 else
8222 {
8223 h.sev = pGetShortExpVector(h.p);
8224 strat->initEcart(&h);
8225 strat->enterS(h,0,strat, strat->tl+1);
8226 enterT(h,strat);
8227 }
8228 }
8229 }
8230}
static poly redMora(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8511
static poly redBba(poly h, int maxIndex, kStrategy strat)
Definition kutil.cc:8487
void enterpairsSpecial(poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
Definition kutil.cc:4540
#define TEST_OPT_REDSB
Definition options.h:106

◆ initSSpecialSba()

void initSSpecialSba ( ideal  F,
ideal  Q,
ideal  P,
kStrategy  strat 
)

Definition at line 8235 of file kutil.cc.

8236{
8237 int i,pos;
8238
8239 if (Q!=NULL)
8240 {
8242 if (i<setmaxTinc) i=setmaxT;
8243 }
8244 else i=setmaxT;
8245 i=((i+IDELEMS(F)+IDELEMS(P)+setmax-1)/setmax)*setmax;
8246 strat->sevS=initsevS(i);
8247 strat->sevSig=initsevS(i);
8248 strat->S_2_R=initS_2_R(i);
8249 strat->fromQ=NULL;
8250 strat->Shdl=idInit(i,F->rank);
8251 strat->S=strat->Shdl->m;
8252 strat->sig=(poly *)omAlloc0(i*sizeof(poly));
8253 /*- put polys into S -*/
8254 if (Q!=NULL)
8255 {
8256 strat->fromQ=initec(i);
8257 memset(strat->fromQ,0,i*sizeof(int));
8258 for (i=0; i<IDELEMS(Q); i++)
8259 {
8260 if (Q->m[i]!=NULL)
8261 {
8262 LObject h;
8263 h.p = pCopy(Q->m[i]);
8264 //if (TEST_OPT_INTSTRATEGY)
8265 //{
8266 // h.pCleardenom(); // also does remove Content
8267 //}
8268 //else
8269 //{
8270 // h.pNorm();
8271 //}
8273 {
8274 deleteHC(&h,strat);
8275 }
8276 if (h.p!=NULL)
8277 {
8278 strat->initEcart(&h);
8279 if (strat->sl==-1)
8280 pos =0;
8281 else
8282 {
8283 pos = posInS(strat,strat->sl,h.p,h.ecart);
8284 }
8285 h.sev = pGetShortExpVector(h.p);
8286 strat->enterS(h,pos,strat, strat->tl+1);
8287 enterT(h, strat);
8288 strat->fromQ[pos]=1;
8289 }
8290 }
8291 }
8292 }
8293 /*- put polys into S -*/
8294 for (i=0; i<IDELEMS(F); i++)
8295 {
8296 if (F->m[i]!=NULL)
8297 {
8298 LObject h;
8299 h.p = pCopy(F->m[i]);
8301 {
8302 deleteHC(&h,strat);
8303 }
8304 else if (TEST_OPT_REDTAIL || TEST_OPT_REDSB)
8305 {
8306 h.p=redtailBba(h.p,strat->sl,strat);
8307 }
8308 if (h.p!=NULL)
8309 {
8310 strat->initEcart(&h);
8311 if (strat->sl==-1)
8312 pos =0;
8313 else
8314 pos = posInS(strat,strat->sl,h.p,h.ecart);
8315 h.sev = pGetShortExpVector(h.p);
8316 strat->enterS(h,pos,strat, strat->tl+1);
8317 enterT(h,strat);
8318 }
8319 }
8320 }
8321 for (i=0; i<IDELEMS(P); i++)
8322 {
8323 if (P->m[i]!=NULL)
8324 {
8325 LObject h;
8326 h.p=pCopy(P->m[i]);
8328 {
8329 h.pCleardenom();
8330 }
8331 else
8332 {
8333 h.pNorm();
8334 }
8335 if(strat->sl>=0)
8336 {
8338 {
8339 h.p=redBba(h.p,strat->sl,strat);
8340 if ((h.p!=NULL)&&(TEST_OPT_REDTAIL || TEST_OPT_REDSB))
8341 {
8342 h.p=redtailBba(h.p,strat->sl,strat);
8343 }
8344 }
8345 else
8346 {
8347 h.p=redMora(h.p,strat->sl,strat);
8348 }
8349 if(h.p!=NULL)
8350 {
8351 strat->initEcart(&h);
8353 {
8354 h.pCleardenom();
8355 }
8356 else
8357 {
8358 h.is_normalized = 0;
8359 h.pNorm();
8360 }
8361 h.sev = pGetShortExpVector(h.p);
8362 h.SetpFDeg();
8363 pos = posInS(strat,strat->sl,h.p,h.ecart);
8364 enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1);
8365 strat->enterS(h,pos,strat, strat->tl+1);
8366 enterT(h,strat);
8367 }
8368 }
8369 else
8370 {
8371 h.sev = pGetShortExpVector(h.p);
8372 strat->initEcart(&h);
8373 strat->enterS(h,0,strat, strat->tl+1);
8374 enterT(h,strat);
8375 }
8376 }
8377 }
8378}

◆ initSyzRules()

void initSyzRules ( kStrategy  strat)

Definition at line 7932 of file kutil.cc.

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

◆ is_shifted_p1()

static BOOLEAN is_shifted_p1 ( const poly  p,
const kStrategy  strat 
)
static

Definition at line 1185 of file kutil.cc.

1186{
1187 if (rIsLPRing(currRing)
1188 && (strat->P.p1!=NULL))
1189 {
1190 // clean up strat->P.p1: may be shifted
1191 poly p=strat->P.p1;
1192 int lv=currRing->isLPring;
1194 for (int i=lv;i>0;i--)
1195 {
1196 if (pGetExp(p,i)!=0) { is_shifted=FALSE; break;}
1197 }
1198 if (is_shifted
1199 && (kFindInL1(p, strat)<0)
1200 && (kFindInT(p, strat->T, strat->tl) < 0)
1201 )
1202 {
1203 return TRUE;
1204 }
1205 }
1206 return FALSE;
1207}
static int kFindInL1(const poly p, const kStrategy strat)
Definition kutil.h:840
#define pGetExp(p, i)
Exponent.
Definition polys.h:41

◆ isInPairsetL()

BOOLEAN isInPairsetL ( int  length,
poly  p1,
poly  p2,
int k,
kStrategy  strat 
)

Definition at line 699 of file kutil.cc.

700{
701 LObject *p=&(strat->L[length]);
702
703 *k = length;
704 loop
705 {
706 if ((*k) < 0) return FALSE;
707 if (((p1 == (*p).p1) && (p2 == (*p).p2))
708 || ((p1 == (*p).p2) && (p2 == (*p).p1)))
709 return TRUE;
710 (*k)--;
711 p--;
712 }
713}

◆ kCheckSpolyCreation()

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

Definition at line 10476 of file kutil.cc.

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

◆ kCheckStrongCreation()

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

Definition at line 10514 of file kutil.cc.

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

◆ kDebugPrint()

void kDebugPrint ( kStrategy  strat)

Output some debug info about a given strategy.

Definition at line 11497 of file kutil.cc.

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

◆ kFindDivisibleByInS_T()

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

Definition at line 6698 of file kutil.cc.

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

◆ kFindInT() [1/2]

int kFindInT ( poly  p,
kStrategy  strat 
)

Definition at line 726 of file kutil.cc.

727{
728 int i;
729 do
730 {
731 i = kFindInT(p, strat->T, strat->tl);
732 if (i >= 0) return i;
733 strat = strat->next;
734 }
735 while (strat != NULL);
736 return -1;
737}
kStrategy next
Definition kutil.h:277

◆ kFindInT() [2/2]

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

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

Definition at line 715 of file kutil.cc.

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

◆ kFindInTShift() [1/2]

int kFindInTShift ( poly  p,
kStrategy  strat 
)

Definition at line 754 of file kutil.cc.

755{
756 int i;
757 do
758 {
759 i = kFindInTShift(p, strat->T, strat->tl);
760 if (i >= 0) return i;
761 strat = strat->next;
762 }
763 while (strat != NULL);
764 return -1;
765}
int kFindInTShift(poly p, TSet T, int tlength)
Definition kutil.cc:740

◆ kFindInTShift() [2/2]

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

Definition at line 740 of file kutil.cc.

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

◆ kMergeBintoL()

void kMergeBintoL ( kStrategy  strat)

Definition at line 3165 of file kutil.cc.

3166{
3167 int j=strat->Ll+strat->Bl+1;
3168 if (j>strat->Lmax)
3169 {
3170 j=((j+setmaxLinc-1)/setmaxLinc)*setmaxLinc-strat->Lmax;
3171 enlargeL(&(strat->L),&(strat->Lmax),j);
3172 }
3173 j = strat->Ll;
3174 int i;
3175 for (i=strat->Bl; i>=0; i--)
3176 {
3177 j = strat->posInL(strat->L,j,&(strat->B[i]),strat);
3178 enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j);
3179 }
3180 strat->Bl = -1;
3181}

◆ kMergeBintoLSba()

void kMergeBintoLSba ( kStrategy  strat)

Definition at line 3186 of file kutil.cc.

3187{
3188 int j=strat->Ll+strat->Bl+1;
3189 if (j>strat->Lmax)
3190 {
3191 j=((j+setmaxLinc-1)/setmaxLinc)*setmaxLinc-strat->Lmax;
3192 enlargeL(&(strat->L),&(strat->Lmax),j);
3193 }
3194 j = strat->Ll;
3195 int i;
3196 for (i=strat->Bl; i>=0; i--)
3197 {
3198 j = strat->posInLSba(strat->L,j,&(strat->B[i]),strat);
3199 enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j);
3200 }
3201 strat->Bl = -1;
3202}

◆ kPosInLDependsOnLength()

BOOLEAN kPosInLDependsOnLength ( int(*)(const LSet set, const int length, LObject *L, const kStrategy strat)  pos_in_l)

Definition at line 9564 of file kutil.cc.

9567{
9568 if (pos_in_l == posInL110
9569 || pos_in_l == posInL10
9571 )
9572 return TRUE;
9573
9574 return FALSE;
9575}

◆ kStratChangeTailRing()

BOOLEAN kStratChangeTailRing ( kStrategy  strat,
LObject L,
TObject T,
unsigned long  expbound 
)

Definition at line 10957 of file kutil.cc.

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

◆ kStratInitChangeTailRing()

void kStratInitChangeTailRing ( kStrategy  strat)

Definition at line 11050 of file kutil.cc.

11051{
11052 unsigned long l = 0;
11053 int i;
11054 long e;
11055
11056 assume(strat->tailRing == currRing);
11057
11058 for (i=0; i<= strat->Ll; i++)
11059 {
11060 l = p_GetMaxExpL(strat->L[i].p, currRing, l);
11061 }
11062 for (i=0; i<=strat->tl; i++)
11063 {
11064 // Hmm ... this we could do in one Step
11065 l = p_GetMaxExpL(strat->T[i].p, currRing, l);
11066 }
11068 {
11069 l *= 2;
11070 }
11071 e = p_GetMaxExp(l, currRing);
11072 if (e <= 1) e = 2;
11073 if (rIsLPRing(currRing)) e = 1;
11074
11075 kStratChangeTailRing(strat, NULL, NULL, e);
11076}
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10957
unsigned long p_GetMaxExpL(poly p, const ring r, unsigned long l_max)
return the maximal exponent of p in form of the maximal long var
Definition p_polys.cc:1176
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition p_polys.h:782

◆ kTest()

BOOLEAN kTest ( kStrategy  strat)

Definition at line 1009 of file kutil.cc.

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

◆ kTest_L()

BOOLEAN kTest_L ( LObject L,
kStrategy  strat,
BOOLEAN  testp,
int  lpos,
TSet  T,
int  tlength 
)

Definition at line 923 of file kutil.cc.

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

◆ kTest_LmEqual()

static const char * kTest_LmEqual ( poly  p,
poly  t_p,
ring  tailRing 
)
static

Definition at line 780 of file kutil.cc.

781{
782 int i;
783 for (i=1; i<=tailRing->N; i++)
784 {
785 if (p_GetExp(p, i, currRing) != p_GetExp(t_p, i, tailRing))
786 return "Lm[i] different";
787 }
788 if (p_GetComp(p, currRing) != p_GetComp(t_p, tailRing))
789 return "Lm[0] different";
790 if (pNext(p) != pNext(t_p))
791 return "Lm.next different";
792 if (pGetCoeff(p) != pGetCoeff(t_p))
793 return "Lm.coeff different";
794 return NULL;
795}

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy  strat)

Definition at line 1052 of file kutil.cc.

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

◆ kTest_T()

BOOLEAN kTest_T ( TObject T,
kStrategy  strat,
int  i,
char  TN 
)

Definition at line 798 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy  strat)

Definition at line 1070 of file kutil.cc.

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

◆ message()

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

Definition at line 7464 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy  strat)

Definition at line 7537 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7505 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int  hilbcount,
kStrategy  strat 
)

Definition at line 7518 of file kutil.cc.

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

◆ newHEdge()

BOOLEAN newHEdge ( kStrategy  strat)

Definition at line 10404 of file kutil.cc.

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

◆ p_HasNotCF_Lift()

static BOOLEAN p_HasNotCF_Lift ( poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

p_HasNotCF for the IDLIFT case and syzComp==1: ignore component

Definition at line 2206 of file kutil.cc.

2207{
2208 int i = rVar(r);
2209 loop
2210 {
2211 if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
2212 return FALSE;
2213 i--;
2214 if (i == 0)
2215 return TRUE;
2216 }
2217}

◆ pDivComp()

static int pDivComp ( poly  p,
poly  q 
)
inlinestatic

Definition at line 181 of file kutil.cc.

182{
183 if ((currRing->pCompIndex < 0)
185 {
186#ifdef HAVE_RATGRING
188 {
190 q,currRing,
191 currRing->real_var_start, currRing->real_var_end))
192 return 0;
193 return pLmCmp(q,p); // ONLY FOR GLOBAL ORDER!
194 }
195#endif
196 BOOLEAN a=FALSE, b=FALSE;
197 int i;
198 unsigned long la, lb;
199 unsigned long divmask = currRing->divmask;
200 for (i=0; i<currRing->VarL_Size; i++)
201 {
202 la = p->exp[currRing->VarL_Offset[i]];
203 lb = q->exp[currRing->VarL_Offset[i]];
204 if (la != lb)
205 {
206 if (la < lb)
207 {
208 if (b) return 0;
209 if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))
210 return 0;
211 a = TRUE;
212 }
213 else
214 {
215 if (a) return 0;
216 if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask))
217 return 0;
218 b = TRUE;
219 }
220 }
221 }
222 if (a) { /*assume(pLmCmp(q,p)==1);*/ return 1; }
223 if (b) { /*assume(pLmCmp(q,p)==-1);*/return -1; }
224 /*assume(pLmCmp(q,p)==0);*/
225 }
226 return 0;
227}
CanonicalForm b
Definition cfModGcd.cc:4111

◆ pDivCompRing()

static int pDivCompRing ( poly  p,
poly  q 
)
inlinestatic

Definition at line 143 of file kutil.cc.

144{
145 if ((currRing->pCompIndex < 0)
147 {
148 BOOLEAN a=FALSE, b=FALSE;
149 int i;
150 unsigned long la, lb;
151 unsigned long divmask = currRing->divmask;
152 for (i=0; i<currRing->VarL_Size; i++)
153 {
154 la = p->exp[currRing->VarL_Offset[i]];
155 lb = q->exp[currRing->VarL_Offset[i]];
156 if (la != lb)
157 {
158 if (la < lb)
159 {
160 if (b) return pDivComp_INCOMP;
161 if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))
162 return pDivComp_INCOMP;
163 a = TRUE;
164 }
165 else
166 {
167 if (a) return pDivComp_INCOMP;
168 if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask))
169 return pDivComp_INCOMP;
170 b = TRUE;
171 }
172 }
173 }
174 if (a) return pDivComp_LESS;
175 if (b) return pDivComp_GREATER;
176 if (!a & !b) return pDivComp_EQUAL;
177 }
178 return pDivComp_INCOMP;
179}
#define pDivComp_INCOMP
Definition kutil.cc:137

◆ pLPDivComp()

static int pLPDivComp ( poly  p,
poly  q 
)
inlinestatic

Definition at line 230 of file kutil.cc.

231{
232 if ((currRing->pCompIndex < 0) || (__p_GetComp(p,currRing) == __p_GetComp(q,currRing)))
233 {
234 // maybe there is a more performant way to do this? This will get called quite often in bba.
235 if (_p_LPLmDivisibleByNoComp(p, q, currRing)) return 1;
236 if (_p_LPLmDivisibleByNoComp(q, p, currRing)) return -1;
237 }
238
239 return 0;
240}
BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r)
Definition shiftop.cc:796

◆ posInIdealMonFirst()

int posInIdealMonFirst ( const ideal  F,
const poly  p,
int  start,
int  end 
)

Definition at line 4845 of file kutil.cc.

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

◆ posInL0()

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

Definition at line 5615 of file kutil.cc.

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

◆ posInL0Ring()

int posInL0Ring ( const LSet  set,
const int  length,
LObject p,
const kStrategy   
)

Definition at line 5642 of file kutil.cc.

5644{
5645 if (length<0) return 0;
5646
5647 if (pLtCmpOrdSgnEqP(set[length].p,p->p))
5648 return length+1;
5649
5650 int i;
5651 int an = 0;
5652 int en= length;
5653 loop
5654 {
5655 if (an >= en-1)
5656 {
5657 if (pLtCmpOrdSgnEqP(set[an].p,p->p)) return en;
5658 return an;
5659 }
5660 i=(an+en) / 2;
5661 if (pLtCmpOrdSgnEqP(set[i].p,p->p)) an=i;
5662 else en=i;
5663 /*aend. fuer lazy == in !=- machen */
5664 }
5665}
#define pLtCmpOrdSgnEqP(p, q)
Definition polys.h:128

◆ posInL11()

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

Definition at line 5803 of file kutil.cc.

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

◆ posInL110()

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

Definition at line 6059 of file kutil.cc.

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

◆ posInL110Ring()

int posInL110Ring ( const LSet  set,
const int  length,
LObject p,
const kStrategy   
)

Definition at line 6100 of file kutil.cc.

6102{
6103 if (length<0) return 0;
6104
6105 int o = p->GetpFDeg();
6106 int op = set[length].GetpFDeg();
6107
6108 if ((op > o)
6109 || ((op == o) && (set[length].length >p->length))
6110 || ((op == o) && (set[length].length <= p->length)
6111 && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6112 return length+1;
6113 int i;
6114 int an = 0;
6115 int en= length;
6116 loop
6117 {
6118 if (an >= en-1)
6119 {
6120 op = set[an].GetpFDeg();
6121 if ((op > o)
6122 || ((op == o) && (set[an].length >p->length))
6123 || ((op == o) && (set[an].length <=p->length)
6124 && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6125 return en;
6126 return an;
6127 }
6128 i=(an+en) / 2;
6129 op = set[i].GetpFDeg();
6130 if ((op > o)
6131 || ((op == o) && (set[i].length > p->length))
6132 || ((op == o) && (set[i].length <= p->length)
6133 && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6134 an=i;
6135 else
6136 en=i;
6137 }
6138}
#define pLtCmpOrdSgnDiffM(p, q)
Definition polys.h:125

◆ posInL11Ring()

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

Definition at line 5845 of file kutil.cc.

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

◆ posInL11Ringls()

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

Definition at line 5913 of file kutil.cc.

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

◆ posInL13()

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

Definition at line 6146 of file kutil.cc.

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

◆ posInL15()

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

Definition at line 6181 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6216 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6256 of file kutil.cc.

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

◆ posInL17_c()

int posInL17_c ( const LSet  set,
const int  length,
LObject p,
const kStrategy   
)

Definition at line 6349 of file kutil.cc.

6351{
6352 if (length<0) return 0;
6353
6354 int cc = (-1+2*currRing->order[0]==ringorder_c);
6355 /* cc==1 for (c,..), cc==-1 for (C,..) */
6356 long c = pGetComp(p->p)*cc;
6357 int o = p->GetpFDeg() + p->ecart;
6358 int cmp_int= -currRing->OrdSgn;
6359
6360 if (pGetComp(set[length].p)*cc > c)
6361 return length+1;
6362 if (pGetComp(set[length].p)*cc == c)
6363 {
6364 if ((set[length].GetpFDeg() + set[length].ecart > o)
6365 || ((set[length].GetpFDeg() + set[length].ecart == o)
6366 && (set[length].ecart > p->ecart))
6367 || ((set[length].GetpFDeg() + set[length].ecart == o)
6368 && (set[length].ecart == p->ecart)
6369 && (pLmCmp(set[length].p,p->p) != cmp_int)))
6370 return length+1;
6371 }
6372 int i;
6373 int an = 0;
6374 int en= length;
6375 loop
6376 {
6377 if (an >= en-1)
6378 {
6379 if (pGetComp(set[an].p)*cc > c)
6380 return en;
6381 if (pGetComp(set[an].p)*cc == c)
6382 {
6383 if ((set[an].GetpFDeg() + set[an].ecart > o)
6384 || ((set[an].GetpFDeg() + set[an].ecart == o)
6385 && (set[an].ecart > p->ecart))
6386 || ((set[an].GetpFDeg() + set[an].ecart == o)
6387 && (set[an].ecart == p->ecart)
6388 && (pLmCmp(set[an].p,p->p) != cmp_int)))
6389 return en;
6390 }
6391 return an;
6392 }
6393 i=(an+en) / 2;
6394 if (pGetComp(set[i].p)*cc > c)
6395 an=i;
6396 else if (pGetComp(set[i].p)*cc == c)
6397 {
6398 if ((set[i].GetpFDeg() + set[i].ecart > o)
6399 || ((set[i].GetpFDeg() + set[i].ecart == o)
6400 && (set[i].ecart > p->ecart))
6401 || ((set[i].GetpFDeg() +set[i].ecart == o)
6402 && (set[i].ecart == p->ecart)
6403 && (pLmCmp(set[i].p,p->p) != cmp_int)))
6404 an=i;
6405 else
6406 en=i;
6407 }
6408 else
6409 en=i;
6410 }
6411}

◆ posInL17_cRing()

int posInL17_cRing ( const LSet  set,
const int  length,
LObject p,
const kStrategy   
)

Definition at line 6413 of file kutil.cc.

6415{
6416 if (length<0) return 0;
6417
6418 int cc = (-1+2*currRing->order[0]==ringorder_c);
6419 /* cc==1 for (c,..), cc==-1 for (C,..) */
6420 long c = pGetComp(p->p)*cc;
6421 int o = p->GetpFDeg() + p->ecart;
6422
6423 if (pGetComp(set[length].p)*cc > c)
6424 return length+1;
6425 if (pGetComp(set[length].p)*cc == c)
6426 {
6427 if ((set[length].GetpFDeg() + set[length].ecart > o)
6428 || ((set[length].GetpFDeg() + set[length].ecart == o)
6429 && (set[length].ecart > p->ecart))
6430 || ((set[length].GetpFDeg() + set[length].ecart == o)
6431 && (set[length].ecart == p->ecart)
6432 && (pLtCmpOrdSgnDiffM(set[length].p,p->p))))
6433 return length+1;
6434 }
6435 int i;
6436 int an = 0;
6437 int en= length;
6438 loop
6439 {
6440 if (an >= en-1)
6441 {
6442 if (pGetComp(set[an].p)*cc > c)
6443 return en;
6444 if (pGetComp(set[an].p)*cc == c)
6445 {
6446 if ((set[an].GetpFDeg() + set[an].ecart > o)
6447 || ((set[an].GetpFDeg() + set[an].ecart == o)
6448 && (set[an].ecart > p->ecart))
6449 || ((set[an].GetpFDeg() + set[an].ecart == o)
6450 && (set[an].ecart == p->ecart)
6451 && (pLtCmpOrdSgnDiffM(set[an].p,p->p))))
6452 return en;
6453 }
6454 return an;
6455 }
6456 i=(an+en) / 2;
6457 if (pGetComp(set[i].p)*cc > c)
6458 an=i;
6459 else if (pGetComp(set[i].p)*cc == c)
6460 {
6461 if ((set[i].GetpFDeg() + set[i].ecart > o)
6462 || ((set[i].GetpFDeg() + set[i].ecart == o)
6463 && (set[i].ecart > p->ecart))
6464 || ((set[i].GetpFDeg() +set[i].ecart == o)
6465 && (set[i].ecart == p->ecart)
6466 && (pLtCmpOrdSgnDiffM(set[i].p,p->p))))
6467 an=i;
6468 else
6469 en=i;
6470 }
6471 else
6472 en=i;
6473 }
6474}

◆ posInL17Ring()

int posInL17Ring ( const LSet  set,
const int  length,
LObject p,
const kStrategy   
)

Definition at line 6300 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 5791 of file kutil.cc.

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

◆ posInLF5CRing()

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

Definition at line 5879 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5673 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5698 of file kutil.cc.

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

◆ posInLSpecial()

int posInLSpecial ( const LSet  set,
const int  length,
LObject p,
const kStrategy   
)

Definition at line 5571 of file kutil.cc.

5573{
5574 if (length<0) return 0;
5575
5576 int d=p->GetpFDeg();
5577 int op=set[length].GetpFDeg();
5578 int cmp_int=currRing->OrdSgn;
5579
5580 if ((op > d)
5581 || ((op == d) && (p->p1!=NULL)&&(set[length].p1==NULL))
5582 || (pLmCmp(set[length].p,p->p)== cmp_int))
5583 return length+1;
5584
5585 int i;
5586 int an = 0;
5587 int en= length;
5588 loop
5589 {
5590 if (an >= en-1)
5591 {
5592 op=set[an].GetpFDeg();
5593 if ((op > d)
5594 || ((op == d) && (p->p1!=NULL) && (set[an].p1==NULL))
5595 || (pLmCmp(set[an].p,p->p)== cmp_int))
5596 return en;
5597 return an;
5598 }
5599 i=(an+en) / 2;
5600 op=set[i].GetpFDeg();
5601 if ((op>d)
5602 || ((op==d) && (p->p1!=NULL) && (set[i].p1==NULL))
5603 || (pLmCmp(set[i].p,p->p) == cmp_int))
5604 an=i;
5605 else
5606 en=i;
5607 }
5608}

◆ posInS()

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

Definition at line 4667 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4768 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy  strat,
poly  sig 
)

Definition at line 5762 of file kutil.cc.

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

◆ posInT0()

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

Definition at line 4889 of file kutil.cc.

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

◆ posInT1()

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

Definition at line 4900 of file kutil.cc.

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

◆ posInT11()

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

Definition at line 4957 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5033 of file kutil.cc.

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

◆ posInT110Ring()

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

Definition at line 5075 of file kutil.cc.

5076{
5077 if (length==-1) return 0;
5078 p.GetpLength();
5079
5080 int o = p.GetpFDeg();
5081 int op = set[length].GetpFDeg();
5082
5083 if (( op < o)
5084 || (( op == o) && (set[length].length<p.length))
5085 || (( op == o) && (set[length].length == p.length)
5086 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5087 return length+1;
5088
5089 int i;
5090 int an = 0;
5091 int en= length;
5092 loop
5093 {
5094 if (an >= en-1)
5095 {
5096 op = set[an].GetpFDeg();
5097 if (( op > o)
5098 || (( op == o) && (set[an].length > p.length))
5099 || (( op == o) && (set[an].length == p.length)
5100 && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5101 return an;
5102 return en;
5103 }
5104 i=(an+en) / 2;
5105 op = set[i].GetpFDeg();
5106 if (( op > o)
5107 || (( op == o) && (set[i].length > p.length))
5108 || (( op == o) && (set[i].length == p.length)
5109 && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5110 en=i;
5111 else
5112 an=i;
5113 }
5114}
#define pLtCmpOrdSgnDiffP(p, q)
Definition polys.h:126

◆ posInT11Ring()

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

Definition at line 4993 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5121 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5188 of file kutil.cc.

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

◆ posInT15Ring()

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

Definition at line 5242 of file kutil.cc.

5243{
5244 if (length==-1) return 0;
5245
5246 int o = p.GetpFDeg() + p.ecart;
5247 int op = set[length].GetpFDeg()+set[length].ecart;
5248
5249 if ((op < o)
5250 || ((op == o)
5251 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5252 return length+1;
5253
5254 int i;
5255 int an = 0;
5256 int en= length;
5257 loop
5258 {
5259 if (an >= en-1)
5260 {
5261 op = set[an].GetpFDeg()+set[an].ecart;
5262 if (( op > o)
5263 || (( op == o) && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5264 return an;
5265 return en;
5266 }
5267 i=(an+en) / 2;
5268 op = set[i].GetpFDeg()+set[i].ecart;
5269 if (( op > o)
5270 || (( op == o) && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5271 en=i;
5272 else
5273 an=i;
5274 }
5275}

◆ posInT17()

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

Definition at line 5282 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5388 of file kutil.cc.

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

◆ posInT17_cRing()

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

Definition at line 5449 of file kutil.cc.

5450{
5451 if (length==-1) return 0;
5452
5453 int cc = (-1+2*currRing->order[0]==ringorder_c);
5454 /* cc==1 for (c,..), cc==-1 for (C,..) */
5455 int o = p.GetpFDeg() + p.ecart;
5456 int c = pGetComp(p.p)*cc;
5457
5458 if (pGetComp(set[length].p)*cc < c)
5459 return length+1;
5460 if (pGetComp(set[length].p)*cc == c)
5461 {
5462 int op = set[length].GetpFDeg()+set[length].ecart;
5463 if ((op < o)
5464 || ((op == o) && (set[length].ecart > p.ecart))
5465 || ((op == o) && (set[length].ecart==p.ecart)
5466 && (pLtCmpOrdSgnDiffP(set[length].p,p.p))))
5467 return length+1;
5468 }
5469
5470 int i;
5471 int an = 0;
5472 int en= length;
5473 loop
5474 {
5475 if (an >= en-1)
5476 {
5477 if (pGetComp(set[an].p)*cc < c)
5478 return en;
5479 if (pGetComp(set[an].p)*cc == c)
5480 {
5481 int op = set[an].GetpFDeg()+set[an].ecart;
5482 if ((op > o)
5483 || ((op == o) && (set[an].ecart < p.ecart))
5484 || ((op == o) && (set[an].ecart==p.ecart)
5485 && (pLtCmpOrdSgnEqP(set[an].p,p.p))))
5486 return an;
5487 }
5488 return en;
5489 }
5490 i=(an+en) / 2;
5491 if (pGetComp(set[i].p)*cc > c)
5492 en=i;
5493 else if (pGetComp(set[i].p)*cc == c)
5494 {
5495 int op = set[i].GetpFDeg()+set[i].ecart;
5496 if ((op > o)
5497 || ((op == o) && (set[i].ecart < p.ecart))
5498 || ((op == o) && (set[i].ecart == p.ecart)
5499 && (pLtCmpOrdSgnEqP(set[i].p,p.p))))
5500 en=i;
5501 else
5502 an=i;
5503 }
5504 else
5505 an=i;
5506 }
5507}

◆ posInT17Ring()

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

Definition at line 5343 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5514 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4929 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11372 of file kutil.cc.

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

◆ posInT_EcartpLength()

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

Definition at line 5150 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11426 of file kutil.cc.

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

◆ posInT_pLength()

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

Definition at line 11463 of file kutil.cc.

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

◆ postReduceByMon()

void postReduceByMon ( LObject h,
kStrategy  strat 
)

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

Definition at line 10700 of file kutil.cc.

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

◆ postReduceByMonSig()

void postReduceByMonSig ( LObject h,
kStrategy  strat 
)

Definition at line 10776 of file kutil.cc.

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

◆ preIntegerCheck()

poly preIntegerCheck ( const ideal  Forig,
const ideal  Q 
)

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

Definition at line 10535 of file kutil.cc.

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

◆ redBba()

static poly redBba ( poly  h,
int  maxIndex,
kStrategy  strat 
)
static

Definition at line 8487 of file kutil.cc.

8488{
8489 int j = 0;
8490 unsigned long not_sev = ~ pGetShortExpVector(h);
8491
8492 while (j <= maxIndex)
8493 {
8494 if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev))
8495 {
8496 h = ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail());
8497 if (h==NULL) return NULL;
8498 j = 0;
8500 }
8501 else j++;
8502 }
8503 return h;
8504}
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition kInline.h:1171
#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

◆ redBba1()

static poly redBba1 ( poly  h,
int  maxIndex,
kStrategy  strat 
)
static

Definition at line 8384 of file kutil.cc.

8385{
8386 int j = 0;
8387 unsigned long not_sev = ~ pGetShortExpVector(h);
8388
8389 while (j <= maxIndex)
8390 {
8391 if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j],h, not_sev))
8392 return ksOldSpolyRedNew(strat->S[j],h,strat->kNoetherTail());
8393 else j++;
8394 }
8395 return h;
8396}
KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether)
Definition kInline.h:1181

◆ redEcart()

int redEcart ( LObject h,
kStrategy  strat 
)

Definition at line 169 of file kstd1.cc.

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

◆ redFirst()

int redFirst ( LObject h,
kStrategy  strat 
)

Definition at line 795 of file kstd1.cc.

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

◆ redMora()

static poly redMora ( poly  h,
int  maxIndex,
kStrategy  strat 
)
static

Definition at line 8511 of file kutil.cc.

8512{
8513 int j=0;
8514 int e,l;
8515 unsigned long not_sev = ~ pGetShortExpVector(h);
8516
8517 if (maxIndex >= 0)
8518 {
8519 e = currRing->pLDeg(h,&l,currRing)-p_FDeg(h,currRing);
8520 do
8521 {
8522 if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev)
8523 && ((e >= strat->ecartS[j]) || (strat->kNoether!=NULL)))
8524 {
8525#ifdef KDEBUG
8526 if (TEST_OPT_DEBUG)
8527 {
8528 PrintS("reduce ");wrp(h);Print(" with S[%d] (",j);wrp(strat->S[j]);
8529 }
8530#endif
8531 h = ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail());
8532#ifdef KDEBUG
8533 if(TEST_OPT_DEBUG)
8534 {
8535 PrintS(")\nto "); wrp(h); PrintLn();
8536 }
8537#endif
8538 // pDelete(&h);
8539 if (h == NULL) return NULL;
8540 e = currRing->pLDeg(h,&l,currRing)-p_FDeg(h,currRing);
8541 j = 0;
8543 }
8544 else j++;
8545 }
8546 while (j <= maxIndex);
8547 }
8548 return h;
8549}

◆ redtail() [1/2]

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

Definition at line 6837 of file kutil.cc.

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

◆ redtail() [2/2]

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

Definition at line 6907 of file kutil.cc.

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

◆ redtailBba()

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

Definition at line 6913 of file kutil.cc.

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

◆ redtailBba_NF()

poly redtailBba_NF ( poly  p,
kStrategy  strat 
)

Definition at line 7351 of file kutil.cc.

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

◆ redtailBba_Ring()

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

Definition at line 7376 of file kutil.cc.

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

◆ redtailBba_Z()

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

Definition at line 7270 of file kutil.cc.

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

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7141 of file kutil.cc.

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

◆ redtailBbaBound()

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

Definition at line 7026 of file kutil.cc.

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

◆ redtailBbaShift()

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

Definition at line 12998 of file kutil.cc.

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

◆ reorderS()

void reorderS ( int suc,
kStrategy  strat 
)

Definition at line 4614 of file kutil.cc.

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

◆ replaceInLAndSAndT()

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

Definition at line 9049 of file kutil.cc.

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

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject h,
kStrategy  strat 
)

Definition at line 1692 of file kutil.cc.

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

◆ sbaRing()

ring sbaRing ( kStrategy  strat,
const ring  r,
BOOLEAN  complete,
int  sgn 
)

Definition at line 11078 of file kutil.cc.

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

◆ showOption()

char * showOption ( )
extern

Definition at line 711 of file misc_ip.cc.

712{
713 int i;
714 BITSET tmp;
715
716 StringSetS("//options:");
717 if ((si_opt_1!=0)||(si_opt_2!=0))
718 {
720 if(tmp)
721 {
722 for (i=0; optionStruct[i].setval!=0; i++)
723 {
724 if (optionStruct[i].setval & tmp)
725 {
727 tmp &=optionStruct[i].resetval;
728 }
729 }
730 for (i=0; i<32; i++)
731 {
732 if (tmp & Sy_bit(i)) StringAppend(" %d",i);
733 }
734 }
736 if (tmp)
737 {
738 for (i=0; verboseStruct[i].setval!=0; i++)
739 {
740 if (verboseStruct[i].setval & tmp)
741 {
743 tmp &=verboseStruct[i].resetval;
744 }
745 }
746 for (i=1; i<32; i++)
747 {
748 if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
749 }
750 }
751 return StringEndS();
752 }
753 StringAppendS(" none");
754 return StringEndS();
755}
#define BITSET
Definition auxiliary.h:85
#define StringAppend
Definition emacs.cc:79
char name(const Variable &v)
Definition factory.h:189
const struct soptionStruct verboseStruct[]
Definition misc_ip.cc:539
const struct soptionStruct optionStruct[]
Definition misc_ip.cc:508
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
#define Sy_bit(x)
Definition options.h:31
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151

◆ sugarDivisibleBy()

static BOOLEAN sugarDivisibleBy ( int  ecart1,
int  ecart2 
)
inlinestatic

Definition at line 1330 of file kutil.cc.

1331{
1332 return (ecart1 <= ecart2);
1333}

◆ superenterpairs()

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

Definition at line 4461 of file kutil.cc.

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

◆ superenterpairsSig()

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

Definition at line 4474 of file kutil.cc.

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

◆ syzCriterion()

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

Definition at line 6479 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6514 of file kutil.cc.

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

◆ updateResult()

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

Definition at line 10076 of file kutil.cc.

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

◆ updateS()

void updateS ( BOOLEAN  toT,
kStrategy  strat 
)

Definition at line 8556 of file kutil.cc.

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

Variable Documentation

◆ DENOMINATOR_LIST

VAR denominator_list DENOMINATOR_LIST =NULL

Definition at line 84 of file kutil.cc.

◆ HCord

VAR int HCord

Definition at line 244 of file kutil.cc.

◆ Kstd1_deg

VAR int Kstd1_deg

Definition at line 245 of file kutil.cc.

◆ Kstd1_mu

VAR int Kstd1_mu =INT_MAX

Definition at line 246 of file kutil.cc.

◆ sloppy_max

STATIC_VAR BOOLEAN sloppy_max = FALSE

Definition at line 797 of file kutil.cc.