My Project
Loading...
Searching...
No Matches
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 long * initsevS (const int maxnr)
 
static int * initS_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 char * kTest_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)
 
char * showOption ()
 
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 778 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 6623 of file kutil.cc.

6624{
6626 return FALSE;
6627 poly p1 = pOne();
6628 poly p2 = pOne();
6629 for (int ii=strat->sl; ii>start; ii--)
6630 {
6631 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], strat->P.sig, ~strat->P.sevSig, currRing))
6632 {
6633 p_ExpVectorSum(p1,strat->P.sig,strat->S[ii],currRing);
6634 p_ExpVectorSum(p2,strat->sig[ii],strat->P.p,currRing);
6635 if (!(pLmCmp(p1,p2) == 1))
6636 {
6637 pDelete(&p1);
6638 pDelete(&p2);
6639 return TRUE;
6640 }
6641 }
6642 }
6643 pDelete(&p1);
6644 pDelete(&p2);
6645 return FALSE;
6646}
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
polyset S
Definition kutil.h:306
unsigned long * sevSig
Definition kutil.h:324
polyset sig
Definition kutil.h:308
LObject P
Definition kutil.h:302
int sl
Definition kutil.h:348
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1439
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1924
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 6648 of file kutil.cc.

6649{
6650 //Over Rings, there are still some changes to do: considering coeffs
6652 return FALSE;
6653 int found = -1;
6654 for (int i=strat->Bl; i>-1; i--)
6655 {
6656 if (pLmEqual(strat->B[i].sig,sig))
6657 {
6658 found = i;
6659 break;
6660 }
6661 }
6662 if (found != -1)
6663 {
6664 if (pLmCmp(lm,strat->B[found].GetLmCurrRing()) == -1)
6665 {
6666 deleteInL(strat->B,&strat->Bl,found,strat);
6667 }
6668 else
6669 {
6670 return TRUE;
6671 }
6672 }
6673 poly p1 = pOne();
6674 poly p2 = pOne();
6675 for (int ii=strat->sl; ii>-1; ii--)
6676 {
6677 if (p_LmShortDivisibleBy(strat->sig[ii], strat->sevSig[ii], sig, not_sevSig, currRing))
6678 {
6679 p_ExpVectorSum(p1,sig,strat->S[ii],currRing);
6680 p_ExpVectorSum(p2,strat->sig[ii],lm,currRing);
6681 if (!(pLmCmp(p1,p2) == 1))
6682 {
6683 pDelete(&p1);
6684 pDelete(&p2);
6685 return TRUE;
6686 }
6687 }
6688 }
6689 pDelete(&p1);
6690 pDelete(&p2);
6691 return FALSE;
6692}
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:1213
#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 {
400 number eins= nCopy(lc);
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:128
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:469
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:901
#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:75

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

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

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

◆ chainCritPart()

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

Definition at line 3525 of file kutil.cc.

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

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

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

◆ cleanT()

void cleanT ( kStrategy strat)

Definition at line 563 of file kutil.cc.

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

◆ cleanTSbaRing()

void cleanTSbaRing ( kStrategy strat)

Definition at line 622 of file kutil.cc.

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

◆ clearSbatch()

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

Definition at line 4438 of file kutil.cc.

4439{
4440 int j = pos;
4441 if ( (!strat->fromT)
4442 && ((strat->syzComp==0)
4443 ||(pGetComp(h)<=strat->syzComp)
4444 ))
4445 {
4446 // Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl);
4447 unsigned long h_sev = pGetShortExpVector(h);
4448 loop
4449 {
4450 if (j > k) break;
4451 clearS(h,h_sev, &j,&k,strat);
4452 j++;
4453 }
4454 // Print("end clearS sl=%d\n",strat->sl);
4455 }
4456}
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;
10372 DENOMINATOR_LIST=denom;
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:6838
poly redtailBba(LObject *L, int end_pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
Definition kutil.cc:6914
STATIC_VAR BOOLEAN sloppy_max
Definition kutil.cc:798
VAR denominator_list DENOMINATOR_LIST
Definition kutil.cc:84
denominator_list_s * denominator_list
Definition kutil.h:63
denominator_list next
Definition kutil.h:65
class sTObject TObject
Definition kutil.h:57
class sLObject LObject
Definition kutil.h:58
#define nDelete(n)
Definition numbers.h:16
#define nInvers(a)
Definition numbers.h:33
#define nIsOne(n)
Definition numbers.h:25
#define omAlloc(size)
#define TEST_OPT_INTSTRATEGY
Definition options.h:110
#define TEST_OPT_PROT
Definition options.h:103
#define TEST_OPT_CONTENTSB
Definition options.h:127
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 }
313 BOOLEAN cut=FALSE;
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:924
static int p_Cmp(poly p1, poly p2, ring r)
Definition p_polys.h:1741
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1594

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

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

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

682{
683 assume((*L)!=NULL);
684 assume(((*length)+incr)>0);
685
686 *L = (LSet)omReallocSize((*L),(*length)*sizeof(LObject),
687 ((*length)+incr)*sizeof(LObject));
688 (*length) += incr;
689}
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 542 of file kutil.cc.

544{
545 assume(T!=NULL);
546 assume(sevT!=NULL);
547 assume(R!=NULL);
548 assume((length+incr) > 0);
549
550 int i;
551 T = (TSet)omRealloc0Size(T, length*sizeof(TObject),
552 (length+incr)*sizeof(TObject));
553
554 sevT = (unsigned long*) omReallocSize(sevT, length*sizeof(long*),
555 (length+incr)*sizeof(long*));
556
557 R = (TObject**)omRealloc0Size(R,length*sizeof(TObject*),
558 (length+incr)*sizeof(TObject*));
559 for (i=length-1;i>=0;i--) R[T[i].i_r] = &(T[i]);
560 length += incr;
561}
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 4237 of file kutil.cc.

4238{
4239 if (nIsOne(pGetCoeff(h))) return;
4240 number gcd;
4241 number zero=n_Init(0,currRing->cf);
4242 bool go = false;
4243 if (n_DivBy(zero, pGetCoeff(h), currRing->cf))
4244 {
4245 gcd = n_Ann(pGetCoeff(h),currRing->cf);
4246 go = true;
4247 }
4248 else
4249 gcd = n_Gcd(zero, pGetCoeff(h), strat->tailRing->cf);
4250 if (go || !nIsOne(gcd))
4251 {
4252 poly p = h->next;
4253 if (!go)
4254 {
4255 number tmp = gcd;
4256 gcd = n_Ann(gcd,currRing->cf);
4257 nDelete(&tmp);
4258 }
4259 p_Test(p,strat->tailRing);
4260 p = __pp_Mult_nn(p, gcd, strat->tailRing);
4261
4262 if (p != NULL)
4263 {
4264 if (TEST_OPT_PROT)
4265 {
4266 PrintS("Z");
4267 }
4268#ifdef KDEBUG
4269 if (TEST_OPT_DEBUG)
4270 {
4271 PrintS("--- create zero spoly: ");
4272 p_wrp(h,currRing,strat->tailRing);
4273 PrintS(" ---> ");
4274 }
4275#endif
4276 poly tmp = pInit();
4277 pSetCoeff0(tmp, pGetCoeff(p));
4278 for (int i = 1; i <= rVar(currRing); i++)
4279 {
4280 pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing));
4281 }
4283 {
4284 p_SetComp(tmp, __p_GetComp(p, strat->tailRing), currRing);
4285 }
4286 p_Setm(tmp, currRing);
4287 p = p_LmFreeAndNext(p, strat->tailRing);
4288 pNext(tmp) = p;
4289 LObject Lp;
4290 Lp.Init();
4291 Lp.p = tmp;
4292 Lp.tailRing = strat->tailRing;
4293 int posx;
4294 if (Lp.p!=NULL)
4295 {
4296 strat->initEcart(&Lp);
4297 if (strat->Ll==-1)
4298 posx =0;
4299 else
4300 posx = strat->posInL(strat->L,strat->Ll,&Lp,strat);
4301 Lp.sev = pGetShortExpVector(Lp.p);
4302 if (strat->tailRing != currRing)
4303 {
4304 Lp.t_p = k_LmInit_currRing_2_tailRing(Lp.p, strat->tailRing);
4305 }
4306#ifdef KDEBUG
4307 if (TEST_OPT_DEBUG)
4308 {
4309 p_wrp(tmp,currRing,strat->tailRing);
4310 PrintLn();
4311 }
4312#endif
4313 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,posx);
4314 }
4315 }
4316 }
4317 nDelete(&zero);
4318 nDelete(&gcd);
4319}
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:1274
#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:1002
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition p_polys.h:233
static poly p_LmFreeAndNext(poly p, ring)
Definition p_polys.h:711
#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 4321 of file kutil.cc.

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

◆ enterL()

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

Definition at line 1274 of file kutil.cc.

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

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

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

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

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

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

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

◆ enterOnePairSigRing()

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

Definition at line 2695 of file kutil.cc.

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

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

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

12123{
12124 // note: ecart and isFromQ is for p
12125 assume(p_inS < 0 || strat->S[p_inS] == p); // if p is from S, p_inS should be the index of p in S
12126 assume(pmFirstVblock(p) == 1);
12127 assume(p_lastVblock == pmLastVblock(p));
12128 assume(q_shift == pmFirstVblock(q) - 1);
12129
12130 // TODO: is ecartp = 0 still ok?
12131 int ecartp = 0; //Hans says it's ok; we're in the homog e:, no ecart
12132
12133 int p_isFromQ = 0;
12134 if (strat->fromQ != NULL && p_inS >= 0)
12135 p_isFromQ = strat->fromQ[p_inS];
12136
12138 {
12139 assume(q_shift <= p_lastVblock); // we allow the special case where there is no overlap
12140 return enterOneStrongPolyAndEnterOnePairRingShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
12141 }
12142 else
12143 {
12144 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)
12145 return enterOnePairShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
12146 }
12147}
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:12051
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:12160
#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 12061 of file kutil.cc.

12062{
12063 // note: ecart and isFromQ is for p
12064 assume(q_inS < 0 || strat->S[q_inS] == q); // if q is from S, q_inS should be the index of q in S
12065 assume(pmFirstVblock(p) == 1);
12066 assume(pmFirstVblock(q) == 1);
12067 assume(p_lastVblock == pmLastVblock(p));
12068 assume(q_lastVblock == pmLastVblock(q));
12069
12070 // TODO: is ecartq = 0 still ok?
12071 int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
12072
12073 int q_isFromQ = 0;
12074 if (strat->fromQ != NULL && q_inS >= 0)
12075 q_isFromQ = strat->fromQ[q_inS];
12076
12077 BOOLEAN (*enterPair)(poly, poly, int, int, kStrategy, int, int, int, int, int);
12080 else
12081 enterPair = enterOnePairShift;
12082
12083 int degbound = currRing->N/currRing->isLPring;
12084 int neededShift = p_lastVblock - ((pGetComp(p) > 0 || pGetComp(q) > 0) ? 0 : 1); // in the module case, product criterion does not hold
12085 int maxPossibleShift = degbound - q_lastVblock;
12086 int maxShift = si_min(neededShift, maxPossibleShift);
12087 int firstShift = (q == p ? 1 : 0); // do not add (q,p) if q=p
12088 BOOLEAN delete_pair=TRUE;
12089 for (int j = firstShift; j <= maxShift; j++)
12090 {
12091 poly qq = pLPCopyAndShiftLM(q, j);
12092 if (enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, j, q_inS))
12093 {
12094 if (j>0) pLmDelete(qq);
12095 // delete qq, if not it does not enter the pair set
12096 }
12097 else
12098 delete_pair=FALSE;
12099 }
12100
12101 if (rField_is_Ring(currRing) && p_lastVblock >= firstShift && p_lastVblock <= maxPossibleShift)
12102 {
12103 // add pairs (m*shifts(q), p) where m is a monomial and the pair has no overlap
12104 for (int j = p_lastVblock; j <= maxPossibleShift; j++)
12105 {
12106 ideal fillers = id_MaxIdeal(j - p_lastVblock, currRing);
12107 for (int k = 0; k < IDELEMS(fillers); k++)
12108 {
12109 poly qq = pLPCopyAndShiftLM(pp_mm_Mult(q, fillers->m[k], currRing), p_lastVblock);
12110 enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, p_lastVblock, q_inS);
12111 }
12112 idDelete(&fillers);
12113 }
12114 }
12115 return delete_pair;
12116}
static int si_min(const int a, const int b)
Definition auxiliary.h:125
#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:58
#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 1543 of file kutil.cc.

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

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

◆ enterOneStrongPolyShift()

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

Definition at line 11638 of file kutil.cc.

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

◆ enterOneStrongPolySig()

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

Definition at line 1751 of file kutil.cc.

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

◆ enterpairs()

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

Definition at line 4492 of file kutil.cc.

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

◆ enterpairsShift()

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

Definition at line 12944 of file kutil.cc.

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

◆ enterpairsSig()

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

Definition at line 4518 of file kutil.cc.

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

◆ enterpairsSpecial()

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

Definition at line 4541 of file kutil.cc.

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

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

◆ 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
8895 int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
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:4668
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 1624 of file kstd1.cc.

1625{
1626 enterSBba(p, atS, strat, atR);
1627 #ifdef KDEBUG
1628 if (TEST_OPT_DEBUG)
1629 {
1630 Print("new s%d:",atS);
1631 p_wrp(p.p,currRing,strat->tailRing);
1632 PrintLn();
1633 }
1634 #endif
1635 HEckeTest(p.p,strat);
1636 if (strat->kAllAxis)
1637 {
1638 if (newHEdge(strat))
1639 {
1640 firstUpdate(strat);
1641 if (TEST_OPT_FINDET)
1642 return;
1643
1644 /*- cuts elements in L above noether and reorders L -*/
1645 updateLHC(strat);
1646 /*- reorders L with respect to posInL -*/
1647 reorderL(strat);
1648 }
1649 }
1650 else if ((strat->kNoether==NULL)
1651 && (TEST_OPT_FASTHC))
1652 {
1653 if (strat->posInLOldFlag)
1654 {
1655 missingAxis(&strat->lastAxis,strat);
1656 if (strat->lastAxis)
1657 {
1658 strat->posInLOld = strat->posInL;
1659 strat->posInLOldFlag = FALSE;
1660 strat->posInL = posInL10;
1661 strat->posInLDependsOnLength = TRUE;
1662 updateL(strat);
1663 reorderL(strat);
1664 }
1665 }
1666 else if (strat->lastAxis)
1667 updateL(strat);
1668 }
1669}
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:1557
void updateLHC(kStrategy strat)
Definition kstd1.cc:1465
void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1280
void reorderL(kStrategy strat)
Definition kstd1.cc:1222
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:111
#define TEST_OPT_FASTHC
Definition options.h:109

◆ enterSMoraNF()

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

Definition at line 1677 of file kstd1.cc.

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

◆ 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:542
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition kutil.cc:799
#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:928
#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:1543
#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 12974 of file kutil.cc.

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

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

◆ faugereRewCriterion()

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

Definition at line 6564 of file kutil.cc.

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

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

◆ 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 else return; /*nothing new*/
513 /*- the leading term of pp is a power of the p-th variable -*/
514 for (j=(currRing->N);j>0; j--)
515 {
516 if (strat->NotUsedAxis[j])
517 {
518 strat->kAllAxis=FALSE;
519 return;
520 }
521 }
522 strat->kAllAxis=TRUE;
523}
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:7681
#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:116
#define TEST_OPT_SB_1
Definition options.h:119
#define OPT_INTERRUPT
Definition options.h:79
#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:1944
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3450
static void enterOnePairLift(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:2226
void chainCritPart(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3525
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3209
void chainCritRing(poly p, int, kStrategy strat)
Definition kutil.cc:4001
static bool rIsSCA(const ring r)
Definition nc.h:190
#define TEST_OPT_WEIGHTM
Definition options.h:121
#define TEST_OPT_IDLIFT
Definition options.h:129
#define TEST_OPT_SUGARCRIT
Definition options.h:107
#define TEST_OPT_NOT_SUGAR
Definition options.h:106

◆ initBuchMoraPos()

void initBuchMoraPos ( kStrategy strat)

Definition at line 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:6060
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5283
int posInT11(const TSet set, const int length, LObject &p)
Definition kutil.cc:4958
int posInT1(const TSet set, const int length, LObject &p)
Definition kutil.cc:4901
int posInT_EcartpLength(const TSet set, const int length, LObject &p)
Definition kutil.cc:5151
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4890
int posInL13(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6147
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:5122
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5616
int posInL15(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6182
int posInT17_c(const TSet set, const int length, LObject &p)
Definition kutil.cc:5389
int posInT15(const TSet set, const int length, LObject &p)
Definition kutil.cc:5189
int posInLSpecial(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5572
int posInL17(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6257
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5034
int posInT19(const TSet set, const int length, LObject &p)
Definition kutil.cc:5515
int posInL17_c(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6350
int posInL11(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5804
#define TEST_OPT_OLDSTD
Definition options.h:123
@ 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:6301
int posInL17_cRing(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6414
int posInL11Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5846
int posInT110Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5076
int posInL110Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6101
int posInL0Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5643
int posInT11Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:4994
int posInL11Ringls(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5914
int posInL15Ring(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:6217
int posInT15Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5243
int posInT17Ring(const TSet set, const int length, LObject &p)
Definition kutil.cc:5344
int posInT17_cRing(const TSet set, const int length, LObject &p)
Definition kutil.cc:5450

◆ initec()

static intset initec ( const int maxnr)
inlinestatic

Definition at line 528 of file kutil.cc.

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

◆ initEcartBBA()

void initEcartBBA ( TObject * h)

Definition at line 1306 of file kutil.cc.

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

◆ initEcartNormal()

void initEcartNormal ( TObject * h)

Definition at line 1298 of file kutil.cc.

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

◆ initEcartPairBba()

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

Definition at line 1313 of file kutil.cc.

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

◆ initEcartPairMora()

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

Definition at line 1320 of file kutil.cc.

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

◆ initenterpairs()

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

Definition at line 3814 of file kutil.cc.

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

◆ initenterpairsShift()

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

Definition at line 12502 of file kutil.cc.

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

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

◆ initenterpairsSigRing()

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

Definition at line 3939 of file kutil.cc.

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

◆ initenterstrongPairs()

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

Definition at line 4157 of file kutil.cc.

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

◆ initenterstrongPairsShift()

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

Definition at line 12760 of file kutil.cc.

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

◆ initenterstrongPairsSig()

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

Definition at line 4212 of file kutil.cc.

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

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

◆ initPairtest()

void initPairtest ( kStrategy strat)

Definition at line 691 of file kutil.cc.

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

◆ initS()

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

Definition at line 7588 of file kutil.cc.

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

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

◆ 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:6515
void chainCritSig(poly p, int, kStrategy strat)
Definition kutil.cc:3466
BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat)
Definition kutil.cc:6480

◆ 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:5674
int posInLF5C(const LSet, const int, LObject *, const kStrategy strat)
Definition kutil.cc:5792

◆ initsevS()

static unsigned long * initsevS ( const int maxnr)
inlinestatic

Definition at line 533 of file kutil.cc.

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

◆ initSL()

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

Definition at line 7681 of file kutil.cc.

7682{
7683 int i,pos;
7684
7685 if (Q!=NULL)
7686 {
7688 if (i<setmaxTinc) i=setmaxT;
7689 }
7690 else i=setmaxT;
7691 strat->ecartS=initec(i);
7692 strat->sevS=initsevS(i);
7693 strat->S_2_R=initS_2_R(i);
7694 strat->fromQ=NULL;
7695 strat->Shdl=idInit(i,F->rank);
7696 strat->S=strat->Shdl->m;
7697 /*- put polys into S -*/
7698 if (Q!=NULL)
7699 {
7700 strat->fromQ=initec(i);
7701 memset(strat->fromQ,0,i*sizeof(int));
7702 for (i=0; i<IDELEMS(Q); i++)
7703 {
7704 if (Q->m[i]!=NULL)
7705 {
7706 LObject h;
7707 h.p = pCopy(Q->m[i]);
7709 {
7710 deleteHC(&h,strat);
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:1425

◆ 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:4541
#define TEST_OPT_REDSB
Definition options.h:104

◆ 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:1107
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition p_polys.h:1327

◆ is_shifted_p1()

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

Definition at line 1186 of file kutil.cc.

1187{
1188 if (rIsLPRing(currRing)
1189 && (strat->P.p1!=NULL))
1190 {
1191 // clean up strat->P.p1: may be shifted
1192 poly p=strat->P.p1;
1193 int lv=currRing->isLPring;
1194 BOOLEAN is_shifted=TRUE;
1195 for (int i=lv;i>0;i--)
1196 {
1197 if (pGetExp(p,i)!=0) { is_shifted=FALSE; break;}
1198 }
1199 if (is_shifted
1200 && (kFindInL1(p, strat)<0)
1201 && (kFindInT(p, strat->T, strat->tl) < 0)
1202 )
1203 {
1204 return TRUE;
1205 }
1206 }
1207 return FALSE;
1208}
static int kFindInL1(const poly p, const kStrategy strat)
Definition kutil.h:839
#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 700 of file kutil.cc.

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

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

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

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

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

◆ kFindInT() [1/2]

int kFindInT ( poly p,
kStrategy strat )

Definition at line 727 of file kutil.cc.

728{
729 int i;
730 do
731 {
732 i = kFindInT(p, strat->T, strat->tl);
733 if (i >= 0) return i;
734 strat = strat->next;
735 }
736 while (strat != NULL);
737 return -1;
738}
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 716 of file kutil.cc.

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

◆ kFindInTShift() [1/2]

int kFindInTShift ( poly p,
kStrategy strat )

Definition at line 755 of file kutil.cc.

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

◆ kFindInTShift() [2/2]

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

Definition at line 741 of file kutil.cc.

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

◆ kMergeBintoL()

void kMergeBintoL ( kStrategy strat)

Definition at line 3166 of file kutil.cc.

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

◆ kMergeBintoLSba()

void kMergeBintoLSba ( kStrategy strat)

Definition at line 3187 of file kutil.cc.

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

◆ kPosInLDependsOnLength()

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

Definition at line 9564 of file kutil.cc.

9567{
9568 if (pos_in_l == posInL110
9569 || pos_in_l == posInL10
9570 || pos_in_l == posInL110Ring
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;
10966 ring new_tailRing = rModifyRing(currRing,
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
10989 = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing);
10990
10991 omBin new_tailBin = omGetStickyBinOfBin(new_tailRing->PolyBin);
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;
11035 = pGetShallowCopyDeleteProc(currRing, new_tailRing);
11036
11037 if (strat->kNoether != NULL)
11038 {
11039 if (strat->t_kNoether != NULL)
11040 p_LmFree(strat->t_kNoether, strat->tailRing);
11041 strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, new_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:3076
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition ring.cc:2715
#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:781

◆ kTest()

BOOLEAN kTest ( kStrategy strat)

Definition at line 1010 of file kutil.cc.

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

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

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

◆ kTest_S()

BOOLEAN kTest_S ( kStrategy strat)

Definition at line 1053 of file kutil.cc.

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

◆ kTest_T()

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

Definition at line 799 of file kutil.cc.

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

◆ kTest_TS()

BOOLEAN kTest_TS ( kStrategy strat)

Definition at line 1071 of file kutil.cc.

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

◆ message()

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

Definition at line 7465 of file kutil.cc.

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

◆ messageSets()

void messageSets ( kStrategy strat)

Definition at line 7538 of file kutil.cc.

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

◆ messageStat()

void messageStat ( int hilbcount,
kStrategy strat )

Definition at line 7506 of file kutil.cc.

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

◆ messageStatSBA()

void messageStatSBA ( int hilbcount,
kStrategy strat )

Definition at line 7519 of file kutil.cc.

7520{
7521 //PrintS("\nUsage/Allocation of temporary storage:\n");
7522 //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl));
7523 //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax);
7524 Print("syz criterion:%d rew criterion:%d\n",strat->nrsyzcrit,strat->nrrewcrit);
7525 //Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3);
7526 if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount);
7527 #ifdef HAVE_SHIFTBBA
7528 /* in usual case strat->cv is 0, it gets changed only in shift routines */
7529 if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv);
7530 #endif
7531}
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);
10429 pSetCoeff0(newNoether,nInit(1));
10430 j = p_FDeg(newNoether,currRing);
10431 for (i=1; i<=(currRing->N); i++)
10432 {
10433 if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i);
10434 }
10435 pSetm(newNoether);
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 }
10467 pLmDelete(newNoether);
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:733
#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 2207 of file kutil.cc.

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

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

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

◆ posInL0()

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

Definition at line 5616 of file kutil.cc.

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

◆ posInL0Ring()

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

Definition at line 5643 of file kutil.cc.

5645{
5646 if (length<0) return 0;
5647
5648 if (pLtCmpOrdSgnEqP(set[length].p,p->p))
5649 return length+1;
5650
5651 int i;
5652 int an = 0;
5653 int en= length;
5654 loop
5655 {
5656 if (an >= en-1)
5657 {
5658 if (pLtCmpOrdSgnEqP(set[an].p,p->p)) return en;
5659 return an;
5660 }
5661 i=(an+en) / 2;
5662 if (pLtCmpOrdSgnEqP(set[i].p,p->p)) an=i;
5663 else en=i;
5664 /*aend. fuer lazy == in !=- machen */
5665 }
5666}
#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 5804 of file kutil.cc.

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

◆ posInL110()

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

Definition at line 6060 of file kutil.cc.

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

◆ posInL110Ring()

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

Definition at line 6101 of file kutil.cc.

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

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

◆ posInL11Ringls()

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

Definition at line 5914 of file kutil.cc.

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

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

◆ posInL15()

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

Definition at line 6182 of file kutil.cc.

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

◆ posInL15Ring()

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

Definition at line 6217 of file kutil.cc.

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

◆ posInL17()

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

Definition at line 6257 of file kutil.cc.

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

◆ posInL17_c()

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

Definition at line 6350 of file kutil.cc.

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

◆ posInL17_cRing()

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

Definition at line 6414 of file kutil.cc.

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

◆ posInL17Ring()

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

Definition at line 6301 of file kutil.cc.

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

◆ posInLF5C()

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

Definition at line 5792 of file kutil.cc.

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

◆ posInLF5CRing()

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

Definition at line 5880 of file kutil.cc.

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

◆ posInLSig()

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

Definition at line 5674 of file kutil.cc.

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

◆ posInLSigRing()

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

Definition at line 5699 of file kutil.cc.

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

◆ posInLSpecial()

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

Definition at line 5572 of file kutil.cc.

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

◆ posInS()

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

Definition at line 4668 of file kutil.cc.

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

◆ posInSMonFirst()

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

Definition at line 4769 of file kutil.cc.

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

◆ posInSyz()

int posInSyz ( const kStrategy strat,
poly sig )

Definition at line 5763 of file kutil.cc.

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

◆ posInT0()

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

Definition at line 4890 of file kutil.cc.

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

◆ posInT1()

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

Definition at line 4901 of file kutil.cc.

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

◆ posInT11()

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

Definition at line 4958 of file kutil.cc.

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

◆ posInT110()

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

Definition at line 5034 of file kutil.cc.

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

◆ posInT110Ring()

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

Definition at line 5076 of file kutil.cc.

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

◆ posInT11Ring()

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

Definition at line 4994 of file kutil.cc.

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

◆ posInT13()

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

Definition at line 5122 of file kutil.cc.

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

◆ posInT15()

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

Definition at line 5189 of file kutil.cc.

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

◆ posInT15Ring()

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

Definition at line 5243 of file kutil.cc.

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

◆ posInT17()

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

Definition at line 5283 of file kutil.cc.

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

◆ posInT17_c()

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

Definition at line 5389 of file kutil.cc.

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

◆ posInT17_cRing()

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

Definition at line 5450 of file kutil.cc.

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

◆ posInT17Ring()

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

Definition at line 5344 of file kutil.cc.

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

◆ posInT19()

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

Definition at line 5515 of file kutil.cc.

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

◆ posInT2()

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

Definition at line 4930 of file kutil.cc.

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

◆ posInT_EcartFDegpLength()

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

Definition at line 11371 of file kutil.cc.

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

◆ posInT_EcartpLength()

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

Definition at line 5151 of file kutil.cc.

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

◆ posInT_FDegpLength()

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

Definition at line 11425 of file kutil.cc.

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

◆ posInT_pLength()

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

Definition at line 11462 of file kutil.cc.

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

◆ 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)
10718#ifdef HAVE_SHIFTBBA
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);
10724 p_SetCoeff(p,dummy,currRing);
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)
10743#ifdef HAVE_SHIFTBBA
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);
10749 p_SetCoeff(pp,dummy,currRing);
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);
10799 p_SetCoeff(p,dummy,currRing);
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);
10826 p_SetCoeff(pp,dummy,currRing);
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;
10542 ring origR = currRing;
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 }
10565 idSkipZeroes(monred);
10566 posconst = idPosConstant(monred);
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 }
10576 ring QQ_ring = rCopy0(currRing,FALSE);
10577 nKillChar(QQ_ring->cf);
10578 QQ_ring->cf = nInitChar(n_Q, NULL);
10579 rComplete(QQ_ring,1);
10580 QQ_ring = rAssure_c_dp(QQ_ring);
10581 rChangeCurrRing(QQ_ring);
10582 nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf);
10583 ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR));
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();
10597 ideal syz = idSyzygies(II, isNotHomog, NULL);
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 }
10611 rChangeCurrRing(origR);
10612 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10613 pmon = prMapR(integer, nMap2, QQ_ring, origR);
10614 idDelete(&monred);
10615 idDelete(&F);
10616 id_Delete(&II,QQ_ring);
10617 id_Delete(&one,QQ_ring);
10618 id_Delete(&syz,QQ_ring);
10619 p_Delete(&integer,QQ_ring);
10620 rDelete(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);
10647 ideal syz = idSyzygies(II, isNotHomog, NULL);
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 {
10665 rChangeCurrRing(origR);
10666 idDelete(&monred);
10667 idDelete(&F);
10668 id_Delete(&II,QQ_ring);
10669 id_Delete(&one,QQ_ring);
10670 rDelete(QQ_ring);
10671 return NULL;
10672 }
10673 rChangeCurrRing(origR);
10674 nMapFunc nMap2 = n_SetMap(QQ_ring->cf, origR->cf);
10675 pmon = prMapR(mindegmon, nMap2, QQ_ring, origR);
10676 idDelete(&monred);
10677 idDelete(&F);
10678 id_Delete(&II,QQ_ring);
10679 id_Delete(&one,QQ_ring);
10680 id_Delete(&syz,QQ_ring);
10681 rDelete(QQ_ring);
10682 return pmon;
10683 }
10684 }
10685 }
10686 rChangeCurrRing(origR);
10687 idDelete(&monred);
10688 idDelete(&F);
10689 id_Delete(&II,QQ_ring);
10690 id_Delete(&one,QQ_ring);
10691 rDelete(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:2471
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:3465
ring rAssure_c_dp(const ring r)
Definition ring.cc:5073
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:36

◆ 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;
8499 not_sev = ~ pGetShortExpVector(h);
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 && ii < strat->tl)
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 1
206 if (i > strat->tl) break;
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)
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:421
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:122
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:117

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

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

◆ redtail() [2/2]

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

Definition at line 6908 of file kutil.cc.

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

◆ redtailBba()

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

Definition at line 6914 of file kutil.cc.

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

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

◆ redtailBba_Ring()

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

Definition at line 7377 of file kutil.cc.

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

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

◆ redtailBbaAlsoLC_Z()

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

Definition at line 7142 of file kutil.cc.

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

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

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

◆ reorderS()

void reorderS ( int * suc,
kStrategy strat )

Definition at line 4615 of file kutil.cc.

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

◆ 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:12974
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:12944
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4462

◆ sbaCheckGcdPair()

BOOLEAN sbaCheckGcdPair ( LObject * h,
kStrategy strat )

Definition at line 1693 of file kutil.cc.

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

◆ 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:5772
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 709 of file misc_ip.cc.

710{
711 int i;
712 BITSET tmp;
713
714 StringSetS("//options:");
715 if ((si_opt_1!=0)||(si_opt_2!=0))
716 {
717 tmp=si_opt_1;
718 if(tmp)
719 {
720 for (i=0; optionStruct[i].setval!=0; i++)
721 {
722 if (optionStruct[i].setval & tmp)
723 {
725 tmp &=optionStruct[i].resetval;
726 }
727 }
728 for (i=0; i<32; i++)
729 {
730 if (tmp & Sy_bit(i)) StringAppend(" %d",i);
731 }
732 }
733 tmp=si_opt_2;
734 if (tmp)
735 {
736 for (i=0; verboseStruct[i].setval!=0; i++)
737 {
738 if (verboseStruct[i].setval & tmp)
739 {
741 tmp &=verboseStruct[i].resetval;
742 }
743 }
744 for (i=1; i<32; i++)
745 {
746 if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
747 }
748 }
749 return StringEndS();
750 }
751 StringAppendS(" none");
752 return StringEndS();
753}
#define StringAppend
Definition emacs.cc:79
unsigned resetval
Definition ipid.h:154
unsigned setval
Definition ipid.h:153
const struct soptionStruct verboseStruct[]
Definition misc_ip.cc:538
const struct soptionStruct optionStruct[]
Definition misc_ip.cc:507
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
#define BITSET
Definition structs.h:16
int name
New type name for int.

◆ sugarDivisibleBy()

static BOOLEAN sugarDivisibleBy ( int ecart1,
int ecart2 )
inlinestatic

Definition at line 1331 of file kutil.cc.

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

◆ superenterpairs()

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

Definition at line 4462 of file kutil.cc.

4463{
4465#if HAVE_SHIFTBBA
4466 assume(!rIsLPRing(currRing)); /* LP should use enterpairsShift */
4467#endif
4468 // enter also zero divisor * poly, if this is non zero and of smaller degree
4470 initenterstrongPairs(h, k, ecart, 0, strat, atR);
4471 initenterpairs(h, k, ecart, 0, strat, atR);
4472 clearSbatch(h, k, pos, strat);
4473}
void clearSbatch(poly h, int k, int pos, kStrategy strat)
Definition kutil.cc:4438
void initenterstrongPairs(poly h, int k, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:4157
void enterExtendedSpoly(poly h, kStrategy strat)
Definition kutil.cc:4237
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 4475 of file kutil.cc.

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

◆ syzCriterion()

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

Definition at line 6480 of file kutil.cc.

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

◆ syzCriterionInc()

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

Definition at line 6515 of file kutil.cc.

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

◆ 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;
8561 BOOLEAN change,any_change;
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);
8570 any_change=FALSE;
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;
8590 any_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;
8626 DENOMINATOR_LIST=denom;
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 {
8701 any_change=TRUE;
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;
8716 DENOMINATOR_LIST=denom;
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:4615

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