Loading...
Searching...
No Matches
kstd1.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT:
*/
// TODO: why the following is here instead of mod2.h???
// define if buckets should be used
#define MORA_USE_BUCKETS
#define PRE_INTEGER_CHECK 0
#include "kernel/mod2.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "polys/weight.h"
#include "kernel/polys.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/khstd.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/ideals.h"
//#include "ipprint.h"
#ifdef HAVE_PLURAL
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#include "kernel/GBEngine/nc.h"
#endif
#include "kernel/GBEngine/kInline.h"
#ifdef HAVE_SHIFTBBA
#include "polys/shiftop.h"
#endif
/* the list of all options which give a warning by test */
VAR BITSET kOptions=Sy_bit(OPT_PROT) /* 0 */
|Sy_bit(OPT_REDSB) /* 1 */
|Sy_bit(OPT_NOT_SUGAR) /* 3 */
|Sy_bit(OPT_INTERRUPT) /* 4 */
|Sy_bit(OPT_SUGARCRIT) /* 5 */
|Sy_bit(OPT_REDTHROUGH)
|Sy_bit(OPT_OLDSTD)
|Sy_bit(OPT_FASTHC) /* 10 */
|Sy_bit(OPT_INTSTRATEGY) /* 26 */
|Sy_bit(OPT_INFREDTAIL) /* 28 */
|Sy_bit(OPT_NOTREGULARITY) /* 30 */
|Sy_bit(OPT_WEIGHTM); /* 31 */
/* the list of all options which may be used by option and test */
/* definition of ALL options: libpolys/misc/options.h */
VAR BITSET validOpts=Sy_bit(0)
|Sy_bit(1)
|Sy_bit(2) // obachman 10/00: replaced by notBucket
|Sy_bit(3)
|Sy_bit(4)
|Sy_bit(5)
|Sy_bit(6)
// |Sy_bit(7) obachman 11/00 tossed: 12/00 used for redThrough
|Sy_bit(7) // OPT_REDTHROUGH
|Sy_bit(8) // obachman 11/00 tossed -> motsak 2011 experimental: OPT_NO_SYZ_MINIM
|Sy_bit(9)
|Sy_bit(10)
|Sy_bit(11)
|Sy_bit(12)
|Sy_bit(13)
|Sy_bit(14)
|Sy_bit(15)
|Sy_bit(16)
|Sy_bit(17)
|Sy_bit(18)
|Sy_bit(19)
// |Sy_bit(20) obachman 11/00 tossed: 12/00 used for redOldStd
|Sy_bit(OPT_OLDSTD)
|Sy_bit(21)
|Sy_bit(22)
/*|Sy_bit(23)*/
/*|Sy_bit(24)*/
|Sy_bit(OPT_REDTAIL)
|Sy_bit(OPT_INTSTRATEGY)
|Sy_bit(27)
|Sy_bit(28)
|Sy_bit(29)
|Sy_bit(30)
|Sy_bit(31);
//static BOOLEAN posInLOldFlag;
/*FALSE, if posInL == posInL10*/
// returns TRUE if mora should use buckets, false otherwise
static BOOLEAN kMoraUseBucket(kStrategy strat);
static void kOptimizeLDeg(pLDegProc ldeg, kStrategy strat)
{
// if (strat->ak == 0 && !rIsSyzIndexRing(currRing))
strat->length_pLength = TRUE;
// else
// strat->length_pLength = FALSE;
if ((ldeg == pLDeg0c /*&& !rIsSyzIndexRing(currRing)*/) ||
(ldeg == pLDeg0 && strat->ak == 0))
{
strat->LDegLast = TRUE;
}
else
{
strat->LDegLast = FALSE;
}
}
static int doRed (LObject* h, TObject* with,BOOLEAN intoT,kStrategy strat, bool redMoraNF)
{
int ret;
#if KDEBUG > 0
kTest_L(h);
kTest_T(with);
#endif
// Hmmm ... why do we do this -- polys from T should already be normalized
if (!TEST_OPT_INTSTRATEGY)
with->pNorm();
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
PrintS("reduce ");h->wrp();PrintS(" with ");with->wrp();PrintLn();
}
#endif
if (intoT)
{
// need to do it exactly like this: otherwise
// we might get errors
LObject L= *h;
L.Copy();
h->GetP();
h->length=h->pLength=pLength(h->p);
ret = ksReducePoly(&L, with, strat->kNoetherTail(), NULL, NULL, strat);
if (ret)
{
if (ret < 0) return ret;
if (h->tailRing != strat->tailRing)
h->ShallowCopyDelete(strat->tailRing,
pGetShallowCopyDeleteProc(h->tailRing,
strat->tailRing));
}
if(redMoraNF && (rField_is_Ring(currRing)))
enterT_strong(h,strat);
else
enterT(h,strat);
*h = L;
}
else
ret = ksReducePoly(h, with, strat->kNoetherTail(), NULL, NULL, strat);
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
PrintS("to ");h->wrp();PrintLn();
}
#endif
return ret;
}
int redEcart (LObject* h,kStrategy strat)
{
int i,at,ei,li,ii;
int j = 0;
int pass = 0;
long d,reddeg;
d = h->GetpFDeg()+ h->ecart;
reddeg = strat->LazyDegree+d;
h->SetShortExpVector();
loop
{
j = kFindDivisibleByInT(strat, h);
if (j < 0)
{
if (strat->honey) h->SetLength(strat->length_pLength);
return 1;
}
ei = strat->T[j].ecart;
ii = j;
if (ei > h->ecart)
{
unsigned long not_sev=~h->sev;
poly h_t= h->GetLmTailRing();
li = strat->T[j].length;
if (li<=0) li=strat->T[j].GetpLength();
// the polynomial to reduce with (up to the moment) is;
// pi with ecart ei and length li
// look for one with smaller ecart
i = j;
loop
{
/*- takes the first possible with respect to ecart -*/
i++;
if (i > strat->tl) break;
#if 1
if (strat->T[i].length<=0) strat->T[i].GetpLength();
if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
strat->T[i].length < li))
&&
p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h_t, not_sev, strat->tailRing))
#else
j = kFindDivisibleByInT(strat, h, i);
if (j < 0) break;
i = j;
if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
strat->T[i].length < li))
#endif
{
// the polynomial to reduce with is now
ii = i;
ei = strat->T[i].ecart;
if (ei <= h->ecart) break;
li = strat->T[i].length;
}
}
}
// end of search: have to reduce with pi
if ((ei > h->ecart)&&(strat->kNoether==NULL))
{
// It is not possible to reduce h with smaller ecart;
// if possible h goes to the lazy-set L,i.e
// if its position in L would be not the last one
strat->fromT = TRUE;
if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
{
h->SetLmCurrRing();
if (strat->honey && strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
assume(h->FDeg == h->pFDeg());
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll)
{
/*- h will not become the next element to reduce -*/
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
#endif
h->Clear();
strat->fromT = FALSE;
return -1;
}
}
}
// now we finally can reduce
doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
strat->fromT=FALSE;
// are we done ???
if (h->IsNull())
{
assume(!rField_is_Ring(currRing));
kDeleteLcm(h);
h->Clear();
return 0;
}
if (TEST_OPT_IDLIFT)
{
if (h->p!=NULL)
{
if(p_GetComp(h->p,currRing)>strat->syzComp)
{
h->Delete();
return 0;
}
}
else // if (h->t_p!=NULL)
{
if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
{
h->Delete();
return 0;
}
}
}
#if 0
else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
{
if (h->p!=NULL)
{
if(p_GetComp(h->p,currRing)>strat->syzComp)
{
return 1;
}
}
else // if (h->t_p!=NULL)
{
if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
{
return 1;
}
}
}
#endif
// done ? NO!
h->SetShortExpVector();
h->SetpFDeg();
if (strat->honey)
{
if (ei <= h->ecart)
h->ecart = d-h->GetpFDeg();
else
h->ecart = d-h->GetpFDeg()+ei-h->ecart;
}
else
// this has the side effect of setting h->length
h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
#if 0
if (strat->syzComp!=0)
{
if ((strat->syzComp>0) && (h->Comp() > strat->syzComp))
{
assume(h->MinComp() > strat->syzComp);
if (strat->honey) h->SetLength();
#ifdef KDEBUG
if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
#endif
return -2;
}
}
#endif
/*- try to reduce the s-polynomial -*/
pass++;
d = h->GetpFDeg()+h->ecart;
/*
*test whether the polynomial should go to the lazyset L
*-if the degree jumps
*-if the number of pre-defined reductions jumps
*/
if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
&& ((d >= reddeg) || (pass > strat->LazyPass)))
{
h->SetLmCurrRing();
if (strat->honey && strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
assume(h->FDeg == h->pFDeg());
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll)
{
int dummy=strat->sl;
if (kFindDivisibleByInS(strat, &dummy, h) < 0)
{
if (strat->honey && !strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
return 1;
}
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
#endif
h->Clear();
return -1;
}
}
else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
{
Print(".%ld",d);mflush();
reddeg = d+1;
if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
{
strat->overflow=TRUE;
//Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
h->GetP();
at = strat->posInL(strat->L,strat->Ll,h,strat);
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
h->Clear();
return -1;
}
}
}
}
int redRiloc (LObject* h,kStrategy strat)
{
int i,at,ei,li,ii;
int j = 0;
int pass = 0;
long d,reddeg;
d = h->GetpFDeg()+ h->ecart;
reddeg = strat->LazyDegree+d;
h->SetShortExpVector();
loop
{
j = kFindDivisibleByInT(strat, h);
if (j < 0)
{
// over ZZ: cleanup coefficients by complete reduction with monomials
postReduceByMon(h, strat);
if(h->p == NULL)
{
kDeleteLcm(h);
h->Clear();
return 0;
}
if (strat->honey) h->SetLength(strat->length_pLength);
if(strat->tl >= 0)
h->i_r1 = strat->tl;
else
h->i_r1 = -1;
if (h->GetLmTailRing() == NULL)
{
kDeleteLcm(h);
h->Clear();
return 0;
}
return 1;
}
ei = strat->T[j].ecart;
ii = j;
if (ei > h->ecart && ii < strat->tl)
{
li = strat->T[j].length;
// the polynomial to reduce with (up to the moment) is;
// pi with ecart ei and length li
// look for one with smaller ecart
i = j;
loop
{
/*- takes the first possible with respect to ecart -*/
i++;
#if 1
if (i > strat->tl) break;
if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
strat->T[i].length < li))
&&
p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)
&&
n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf))
#else
j = kFindDivisibleByInT(strat, h, i);
if (j < 0) break;
i = j;
if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
strat->T[i].length < li))
#endif
{
// the polynomial to reduce with is now
ii = i;
ei = strat->T[i].ecart;
if (ei <= h->ecart) break;
li = strat->T[i].length;
}
}
}
// end of search: have to reduce with pi
if (ei > h->ecart)
{
// It is not possible to reduce h with smaller ecart;
// if possible h goes to the lazy-set L,i.e
// if its position in L would be not the last one
strat->fromT = TRUE;
if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
{
h->SetLmCurrRing();
if (strat->honey && strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
assume(h->FDeg == h->pFDeg());
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef))
{
/*- h will not become the next element to reduce -*/
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
#endif
h->Clear();
strat->fromT = FALSE;
return -1;
}
}
doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE);
}
else
{
// now we finally can reduce
doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
}
strat->fromT=FALSE;
// are we done ???
if (h->IsNull())
{
kDeleteLcm(h);
h->Clear();
return 0;
}
// NO!
h->SetShortExpVector();
h->SetpFDeg();
if (strat->honey)
{
if (ei <= h->ecart)
h->ecart = d-h->GetpFDeg();
else
h->ecart = d-h->GetpFDeg()+ei-h->ecart;
}
else
// this has the side effect of setting h->length
h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
/*- try to reduce the s-polynomial -*/
pass++;
d = h->GetpFDeg()+h->ecart;
/*
*test whether the polynomial should go to the lazyset L
*-if the degree jumps
*-if the number of pre-defined reductions jumps
*/
if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
&& ((d >= reddeg) || (pass > strat->LazyPass)))
{
h->SetLmCurrRing();
if (strat->honey && strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
assume(h->FDeg == h->pFDeg());
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll)
{
int dummy=strat->sl;
if (kFindDivisibleByInS(strat, &dummy, h) < 0)
{
if (strat->honey && !strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
return 1;
}
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
#endif
h->Clear();
return -1;
}
}
else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
{
Print(".%ld",d);mflush();
reddeg = d+1;
if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
{
strat->overflow=TRUE;
//Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
h->GetP();
at = strat->posInL(strat->L,strat->Ll,h,strat);
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
h->Clear();
return -1;
}
}
}
}
int redRiloc_Z (LObject* h,kStrategy strat)
{
int i,at,ei,li,ii;
int j = 0;
int pass = 0;
long d,reddeg;
int docoeffred = 0;
poly T0p = strat->T[0].p;
int T0ecart = strat->T[0].ecart;
d = h->GetpFDeg()+ h->ecart;
reddeg = strat->LazyDegree+d;
h->SetShortExpVector();
if ((strat->tl>=0)
&&strat->T[0].GetpFDeg() == 0
&& strat->T[0].length <= 2)
{
docoeffred = 1;
}
loop
{
/* cut down the lead coefficients, only possible if the degree of
* T[0] is 0 (constant). This is only efficient if T[0] is short, thus
* we ask for the length of T[0] to be <= 2 */
if (docoeffred)
{
j = kTestDivisibleByT0_Z(strat, h);
if (j == 0 && n_DivBy(pGetCoeff(h->p), pGetCoeff(T0p), currRing->cf) == FALSE
&& T0ecart <= h->ecart)
{
/* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
* => we try to cut down the lead coefficient at least */
/* first copy T[j] in order to multiply it with a coefficient later on */
number mult, rest;
TObject tj = strat->T[0];
tj.Copy();
/* compute division with remainder of lc(h) and lc(T[j]) */
mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(T0p),
&rest, currRing->cf);
/* set corresponding new lead coefficient already. we do not
* remove the lead term in ksReducePolyLC, but only apply
* a lead coefficient reduction */
tj.Mult_nn(mult);
ksReducePolyLC(h, &tj, NULL, &rest, strat);
tj.Delete();
tj.Clear();
if (n_IsZero(pGetCoeff(h->GetP()),currRing->cf))
{
h->LmDeleteAndIter();
}
}
}
j = kFindDivisibleByInT(strat, h);
if (j < 0)
{
// over ZZ: cleanup coefficients by complete reduction with monomials
postReduceByMon(h, strat);
if(h->p == NULL)
{
kDeleteLcm(h);
h->Clear();
return 0;
}
if (strat->honey) h->SetLength(strat->length_pLength);
if(strat->tl >= 0)
h->i_r1 = strat->tl;
else
h->i_r1 = -1;
if (h->GetLmTailRing() == NULL)
{
kDeleteLcm(h);
h->Clear();
return 0;
}
return 1;
}
ei = strat->T[j].ecart;
ii = j;
#if 1
if (ei > h->ecart && ii < strat->tl)
{
li = strat->T[j].length;
// the polynomial to reduce with (up to the moment) is;
// pi with ecart ei and length li
// look for one with smaller ecart
i = j;
loop
{
/*- takes the first possible with respect to ecart -*/
i++;
#if 1
if (i > strat->tl) break;
if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
strat->T[i].length < li))
&&
p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)
&&
n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf))
#else
j = kFindDivisibleByInT(strat, h, i);
if (j < 0) break;
i = j;
if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
strat->T[i].length < li))
#endif
{
// the polynomial to reduce with is now
ii = i;
ei = strat->T[i].ecart;
if (ei <= h->ecart) break;
li = strat->T[i].length;
}
}
}
#endif
// end of search: have to reduce with pi
if (ei > h->ecart)
{
// It is not possible to reduce h with smaller ecart;
// if possible h goes to the lazy-set L,i.e
// if its position in L would be not the last one
strat->fromT = TRUE;
if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/
{
h->SetLmCurrRing();
if (strat->honey && strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
assume(h->FDeg == h->pFDeg());
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef))
{
/*- h will not become the next element to reduce -*/
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
#endif
h->Clear();
strat->fromT = FALSE;
return -1;
}
}
doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE);
}
else
{
// now we finally can reduce
doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE);
}
strat->fromT=FALSE;
// are we done ???
if (h->IsNull())
{
kDeleteLcm(h);
h->Clear();
return 0;
}
// NO!
h->SetShortExpVector();
h->SetpFDeg();
if (strat->honey)
{
if (ei <= h->ecart)
h->ecart = d-h->GetpFDeg();
else
h->ecart = d-h->GetpFDeg()+ei-h->ecart;
}
else
// this has the side effect of setting h->length
h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
/*- try to reduce the s-polynomial -*/
pass++;
d = h->GetpFDeg()+h->ecart;
/*
*test whether the polynomial should go to the lazyset L
*-if the degree jumps
*-if the number of pre-defined reductions jumps
*/
if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
&& ((d >= reddeg) || (pass > strat->LazyPass)))
{
h->SetLmCurrRing();
if (strat->honey && strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
assume(h->FDeg == h->pFDeg());
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll)
{
int dummy=strat->sl;
if (kFindDivisibleByInS(strat, &dummy, h) < 0)
{
if (strat->honey && !strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
return 1;
}
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
#endif
h->Clear();
return -1;
}
}
else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
{
Print(".%ld",d);mflush();
reddeg = d+1;
if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
{
strat->overflow=TRUE;
//Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask);
h->GetP();
at = strat->posInL(strat->L,strat->Ll,h,strat);
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
h->Clear();
return -1;
}
}
}
}
/*2
*reduces h with elements from T choosing the first possible
* element in t with respect to the given pDivisibleBy
*/
int redFirst (LObject* h,kStrategy strat)
{
if (strat->tl<0) return 1;
if (h->IsNull()) return 0;
int at;
long reddeg,d;
int pass = 0;
int cnt = RED_CANONICALIZE;
int j = 0;
reddeg = d = h->GetpFDeg();
if (! strat->homog)
{
d += h->ecart;
reddeg = strat->LazyDegree+d;
}
h->SetShortExpVector();
loop
{
j = kFindDivisibleByInT(strat, h);
if (j < 0)
{
h->SetDegStuffReturnLDeg(strat->LDegLast);
return 1;
}
if (!TEST_OPT_INTSTRATEGY)
strat->T[j].pNorm();
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
PrintS("reduce ");
h->wrp();
PrintS(" with ");
strat->T[j].wrp();
}
#endif
ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, NULL, strat);
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
PrintS(" to ");
wrp(h->p);
PrintLn();
}
#endif
if (h->IsNull())
{
assume(!rField_is_Ring(currRing));
kDeleteLcm(h);
h->Clear();
return 0;
}
if (TEST_OPT_IDLIFT)
{
if (h->p!=NULL)
{
if(p_GetComp(h->p,currRing)>strat->syzComp)
{
h->Delete();
return 0;
}
}
else // if (h->t_p!=NULL)
{
if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
{
h->Delete();
return 0;
}
}
}
#if 0
else if ((strat->syzComp > 0)&&(!TEST_OPT_REDTAIL_SYZ))
{
if (h->p!=NULL)
{
if(p_GetComp(h->p,currRing)>strat->syzComp)
{
return 1;
}
}
else // if (h->t_p!=NULL)
{
if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp)
{
return 1;
}
}
}
#endif
h->SetShortExpVector();
#if 0
if ((strat->syzComp!=0) && !strat->honey)
{
if ((strat->syzComp>0) &&
(h->Comp() > strat->syzComp))
{
assume(h->MinComp() > strat->syzComp);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
#endif
if (strat->homog)
h->SetDegStuffReturnLDeg(strat->LDegLast);
return -2;
}
}
#endif
if (!strat->homog)
{
if (!TEST_OPT_OLDSTD && strat->honey)
{
h->SetpFDeg();
if (strat->T[j].ecart <= h->ecart)
h->ecart = d - h->GetpFDeg();
else
h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart;
d = h->GetpFDeg() + h->ecart;
}
else
d = h->SetDegStuffReturnLDeg(strat->LDegLast);
/*- try to reduce the s-polynomial -*/
cnt--;
pass++;
/*
*test whether the polynomial should go to the lazyset L
*-if the degree jumps
*-if the number of pre-defined reductions jumps
*/
if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0)
&& ((d >= reddeg) || (pass > strat->LazyPass)))
{
h->SetLmCurrRing();
if (strat->posInLDependsOnLength)
h->SetLength(strat->length_pLength);
at = strat->posInL(strat->L,strat->Ll,h,strat);
if (at <= strat->Ll)
{
int dummy=strat->sl;
if (kFindDivisibleByInS(strat,&dummy, h) < 0)
return 1;
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
#ifdef KDEBUG
if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
#endif
h->Clear();
return -1;
}
}
if (UNLIKELY(cnt==0))
{
h->CanonicalizeP();
cnt=RED_CANONICALIZE;
//if (TEST_OPT_PROT) { PrintS("!");mflush(); }
}
if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
{
reddeg = d+1;
Print(".%ld",d);mflush();
if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask)
{
strat->overflow=TRUE;
//Print("OVERFLOW in redFirst d=%ld, max=%ld",d,strat->tailRing->bitmask);
h->GetP();
at = strat->posInL(strat->L,strat->Ll,h,strat);
enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
h->Clear();
return -1;
}
}
}
}
}
/*2
* reduces h with elements from T choosing first possible
* element in T with respect to the given ecart
* used for computing normal forms outside kStd
*/
static poly redMoraNF (poly h,kStrategy strat, int flag)
{
LObject H;
H.p = h;
int j = 0;
int z = 10;
int o = H.SetpFDeg();
H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o;
if ((flag & (KSTD_NF_ECART|KSTD_NF_CANCELUNIT)) == KSTD_NF_CANCELUNIT) cancelunit(&H,TRUE);
H.sev = pGetShortExpVector(H.p);
loop
{
if (j > strat->tl)
{
return H.p;
}
if (TEST_V_DEG_STOP)
{
if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p);
if (H.p==NULL) return NULL;
}
unsigned long not_sev = ~ H.sev;
if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)
)
{
/*- remember the found T-poly -*/
// poly pi = strat->T[j].p;
int ei = strat->T[j].ecart;
int li = strat->T[j].length;
int ii = j;
/*
* the polynomial to reduce with (up to the moment) is;
* pi with ecart ei and length li
*/
loop
{
/*- look for a better one with respect to ecart -*/
/*- stop, if the ecart is small enough (<=ecart(H)) -*/
j++;
if (j > strat->tl) break;
if (ei <= H.ecart) break;
if (((strat->T[j].ecart < ei)
|| ((strat->T[j].ecart == ei)
&& (strat->T[j].length < li)))
&& pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)
)
{
/*
* the polynomial to reduce with is now;
*/
// pi = strat->T[j].p;
ei = strat->T[j].ecart;
li = strat->T[j].length;
ii = j;
}
}
/*
* end of search: have to reduce with pi
*/
z++;
if (z>10)
{
pNormalize(H.p);
z=0;
}
if ((ei > H.ecart) && (strat->kNoether==NULL))
{
/*
* It is not possible to reduce h with smaller ecart;
* we have to reduce with bad ecart: H has to enter in T
*/
LObject L= H;
L.Copy();
H.GetP();
H.length=H.pLength=pLength(H.p);
ksReducePoly(&L, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
(flag & KSTD_NF_NONORM)==0);
enterT(&H,strat);
H = L;
}
else
{
/*
* we reduce with good ecart, h need not to be put to T
*/
ksReducePoly(&H, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
(flag & KSTD_NF_NONORM)==0);
}
if (H.p == NULL)
return NULL;
/*- try to reduce the s-polynomial -*/
o = H.SetpFDeg();
if ((flag & KSTD_NF_ECART) == 0) cancelunit(&H,TRUE);
H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o;
j = 0;
H.sev = pGetShortExpVector(H.p);
}
else
{
j++;
}
}
}
static poly redMoraNFRing (poly h,kStrategy strat, int flag)
{
LObject H;
H.p = h;
int j0, j = 0;
int docoeffred = 0;
poly T0p = strat->T[0].p;
int T0ecart = strat->T[0].ecart;
int o = H.SetpFDeg();
H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o;
if ((flag & KSTD_NF_ECART) == 0) cancelunit(&H,TRUE);
H.sev = pGetShortExpVector(H.p);
unsigned long not_sev = ~ H.sev;
if (strat->T[0].GetpFDeg() == 0 && strat->T[0].length <= 2)
{
docoeffred = 1; // euclidean ring required: n_QuotRem
if (currRing->cf->cfQuotRem==ndQuotRem)
{
docoeffred = 0;
}
}
loop
{
/* cut down the lead coefficients, only possible if the degree of
* T[0] is 0 (constant). This is only efficient if T[0] is short, thus
* we ask for the length of T[0] to be <= 2 */
if (docoeffred)
{
j0 = kTestDivisibleByT0_Z(strat, &H);
if ((j0 == 0)
&& (n_DivBy(pGetCoeff(H.p), pGetCoeff(T0p), currRing->cf) == FALSE)
&& (T0ecart <= H.ecart))
{
/* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
* => we try to cut down the lead coefficient at least */
/* first copy T[j0] in order to multiply it with a coefficient later on */
number mult, rest;
TObject tj = strat->T[0];
tj.Copy();
/* compute division with remainder of lc(h) and lc(T[j]) */
mult = n_QuotRem(pGetCoeff(H.p), pGetCoeff(T0p),
&rest, currRing->cf);
/* set corresponding new lead coefficient already. we do not
* remove the lead term in ksReducePolyLC, but only apply
* a lead coefficient reduction */
tj.Mult_nn(mult);
ksReducePolyLC(&H, &tj, NULL, &rest, strat);
tj.Delete();
tj.Clear();
}
}
if (j > strat->tl)
{
return H.p;
}
if (TEST_V_DEG_STOP)
{
if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p);
if (H.p==NULL) return NULL;
}
if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)
&& (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
)
{
/*- remember the found T-poly -*/
// poly pi = strat->T[j].p;
int ei = strat->T[j].ecart;
int li = strat->T[j].length;
int ii = j;
/*
* the polynomial to reduce with (up to the moment) is;
* pi with ecart ei and length li
*/
loop
{
/*- look for a better one with respect to ecart -*/
/*- stop, if the ecart is small enough (<=ecart(H)) -*/
j++;
if (j > strat->tl) break;
if (ei <= H.ecart) break;
if (((strat->T[j].ecart < ei)
|| ((strat->T[j].ecart == ei)
&& (strat->T[j].length < li)))
&& pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)
&& (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
)
{
/*
* the polynomial to reduce with is now;
*/
// pi = strat->T[j].p;
ei = strat->T[j].ecart;
li = strat->T[j].length;
ii = j;
}
}
/*
* end of search: have to reduce with pi
*/
if ((ei > H.ecart) && (strat->kNoether==NULL))
{
/*
* It is not possible to reduce h with smaller ecart;
* we have to reduce with bad ecart: H has to enter in T
*/
LObject L= H;
L.Copy();
H.GetP();
H.length=H.pLength=pLength(H.p);
ksReducePoly(&L, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
(flag & KSTD_NF_NONORM)==0);
enterT_strong(&H,strat);
H = L;
}
else
{
/*
* we reduce with good ecart, h need not to be put to T
*/
ksReducePoly(&H, &(strat->T[ii]), strat->kNoetherTail(), NULL, NULL, strat,
(flag & KSTD_NF_NONORM)==0);
}
if (H.p == NULL)
return NULL;
/*- try to reduce the s-polynomial -*/
o = H.SetpFDeg();
if ((flag &2 ) == 0) cancelunit(&H,TRUE);
H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o;
j = 0;
H.sev = pGetShortExpVector(H.p);
not_sev = ~ H.sev;
}
else
{
j++;
}
}
}
/*2
*reorders L with respect to posInL
*/
static void reorderL(kStrategy strat)
{
int i,j,at;
for (i=1; i<=strat->Ll; i++)
{
at = strat->posInL(strat->L,i-1,&(strat->L[i]),strat);
if (at != i)
{
LObject p = strat->L[i];
for (j=i-1; j>=at; j--) strat->L[j+1] = strat->L[j];
strat->L[at] = p;
}
}
}
/*2
*reorders T with respect to length
*/
static void reorderT(kStrategy strat)
{
int i,j,at;
TObject p;
unsigned long sev;
for (i=1; i<=strat->tl; i++)
{
if (strat->T[i-1].length > strat->T[i].length)
{
p = strat->T[i];
sev = strat->sevT[i];
at = i-1;
loop
{
at--;
if (at < 0) break;
if (strat->T[i].length > strat->T[at].length) break;
}
for (j = i-1; j>at; j--)
{
strat->T[j+1]=strat->T[j];
strat->sevT[j+1]=strat->sevT[j];
strat->R[strat->T[j+1].i_r] = &(strat->T[j+1]);
}
strat->T[at+1]=p;
strat->sevT[at+1] = sev;
strat->R[p.i_r] = &(strat->T[at+1]);
}
}
}
/*2
*looks whether exactly (currRing->N)-1 axis are used
*returns last != 0 in this case
*last is the (first) unused axis
*/
static void missingAxis (int* last,kStrategy strat)
{
int i = 0;
int k = 0;
*last = 0;
if (!rHasMixedOrdering(currRing))
{
loop
{
i++;
if (i > (currRing->N)) break;
if (strat->NotUsedAxis[i])
{
*last = i;
k++;
}
if (k>1)
{
*last = 0;
break;
}
}
}
}
/*2
*last is the only non used axis, it looks
*for a monomial in p being a pure power of this
*variable and returns TRUE in this case
*(*length) gives the length between the pure power and the leading term
*(should be minimal)
*/
static BOOLEAN hasPurePower (const poly p,int last, int *length,kStrategy strat)
{
poly h;
int i;
if (pNext(p) == strat->tail)
return FALSE;
pp_Test(p, currRing, strat->tailRing);
if (strat->ak <= 0 || p_MinComp(p, currRing, strat->tailRing) == strat->ak)
{
i = p_IsPurePower(p, currRing);
if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(p), currRing->cf))) i=0;
if (i == last)
{
*length = 0;
return TRUE;
}
*length = 1;
h = pNext(p);
while (h != NULL)
{
i = p_IsPurePower(h, strat->tailRing);
if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(h), currRing->cf))) i=0;
if (i==last) return TRUE;
(*length)++;
pIter(h);
}
}
return FALSE;
}
static BOOLEAN hasPurePower (LObject *L,int last, int *length,kStrategy strat)
{
if (L->bucket != NULL)
{
poly p = L->GetP();
return hasPurePower(p, last, length, strat);
}
else
{
return hasPurePower(L->p, last, length, strat);
}
}
/*2
* looks up the position of polynomial p in L
* in the case of looking for the pure powers
*/
int posInL10 (const LSet set,const int length, LObject* p,const kStrategy strat)
{
int j,dp,dL;
if (length<0) return 0;
if (hasPurePower(p,strat->lastAxis,&dp,strat))
{
int op= p->GetpFDeg() +p->ecart;
for (j=length; j>=0; j--)
{
if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
return j+1;
if (dp < dL)
return j+1;
if ((dp == dL)
&& (set[j].GetpFDeg()+set[j].ecart >= op))
return j+1;
}
}
j=length;
loop
{
if (j<0) break;
if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
j--;
}
return strat->posInLOld(set,j,p,strat);
}
/*2
* computes the s-polynomials L[ ].p in L
* searchPP should be FALSE if updateL is followed by reorderL
*/
static void updateL(BOOLEAN searchPP, kStrategy strat)
{
// only in mora
assume(rHasLocalOrMixedOrdering(currRing));
int dL;
int j=strat->Ll;
BOOLEAN lastPPfound=FALSE;
if (searchPP && (strat->kNoether==NULL))
{
loop
{
if (j<0) break;
if (hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat))
{
LObject p;
p=strat->L[strat->Ll];
strat->L[strat->Ll]=strat->L[j];
strat->L[j]=p;
lastPPfound=TRUE;
break;
}
j--;
}
}
j=strat->Ll;
loop
{
if (j<0) break;
if (pNext(strat->L[j].p) == strat->tail)
{
if (rField_is_Ring(currRing))
pLmDelete(strat->L[j].p); /*deletes the short spoly and computes*/
else
pLmFree(strat->L[j].p); /*deletes the short spoly and computes*/
strat->L[j].p = NULL;
poly m1 = NULL, m2 = NULL;
// check that spoly creation is ok
while (strat->tailRing != currRing &&
!kCheckSpolyCreation(&(strat->L[j]), strat, m1, m2))
{
assume(m1 == NULL && m2 == NULL);
// if not, change to a ring where exponents are at least
// large enough
kStratChangeTailRing(strat);
}
/* create the real one */
ksCreateSpoly(&(strat->L[j]), strat->kNoetherTail(), FALSE,
strat->tailRing, m1, m2, strat->R);
strat->L[j].SetLmCurrRing();
if (!strat->honey)
strat->initEcart(&strat->L[j]);
else
strat->L[j].SetLength(strat->length_pLength);
BOOLEAN pp = FALSE;
if (searchPP
&& (!lastPPfound)
&& (strat->kNoether==NULL))
pp=hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat);
strat->L[j].PrepareRed(strat->use_buckets);
if (pp)
{
LObject p;
p=strat->L[strat->Ll];
strat->L[strat->Ll]=strat->L[j];
strat->L[j]=p;
break;
}
}
j--;
}
}
/*2
* computes the s-polynomials L[ ].p in L and
* cuts elements in L above noether
*/
static void updateLHC(kStrategy strat)
{
int i = 0;
kTest_TS(strat);
while (i <= strat->Ll)
{
if (pNext(strat->L[i].p) == strat->tail)
{
/*- deletes the int spoly and computes -*/
if (pLmCmp(strat->L[i].p,strat->kNoether) == -1)
{
if (rField_is_Ring(currRing))
pLmDelete(strat->L[i].p);
else
pLmFree(strat->L[i].p);
strat->L[i].p = NULL;
}
else
{
if (rField_is_Ring(currRing))
pLmDelete(strat->L[i].p);
else
pLmFree(strat->L[i].p);
strat->L[i].p = NULL;
poly m1 = NULL, m2 = NULL;
// check that spoly creation is ok
while (strat->tailRing != currRing &&
!kCheckSpolyCreation(&(strat->L[i]), strat, m1, m2))
{
assume(m1 == NULL && m2 == NULL);
// if not, change to a ring where exponents are at least
// large enough
kStratChangeTailRing(strat);
}
/* create the real one */
ksCreateSpoly(&(strat->L[i]), strat->kNoetherTail(), FALSE,
strat->tailRing, m1, m2, strat->R);
if (! strat->L[i].IsNull())
{
strat->L[i].SetLmCurrRing();
strat->L[i].SetpFDeg();
strat->L[i].ecart
= strat->L[i].pLDeg(strat->LDegLast) - strat->L[i].GetpFDeg();
if (strat->use_buckets) strat->L[i].PrepareRed(TRUE);
}
}
}
deleteHC(&(strat->L[i]), strat);
if (strat->L[i].IsNull())
deleteInL(strat->L,&strat->Ll,i,strat);
else
{
#ifdef KDEBUG
kTest_L(&(strat->L[i]), strat, TRUE, i, strat->T, strat->tl);
#endif
i++;
}
}
kTest_TS(strat);
}
/*2
* cuts in T above strat->kNoether and tries to cancel a unit
* changes also S as S is a subset of T
*/
static void updateT(kStrategy strat)
{
int i = 0;
LObject p;
while (i <= strat->tl)
{
p = strat->T[i];
deleteHC(&p,strat, TRUE);
/*- tries to cancel a unit: -*/
cancelunit(&p);
if (TEST_OPT_INTSTRATEGY) /* deleteHC and/or cancelunit may have changed p*/
p.pCleardenom();
if (p.p != strat->T[i].p)
{
strat->sevT[i] = pGetShortExpVector(p.p);
p.SetpFDeg();
}
strat->T[i] = p;
i++;
}
}
/*2
* arranges red, pos and T if strat->kAllAxis (first time)
*/
static void firstUpdate(kStrategy strat)
{
if (strat->update)
{
kTest_TS(strat);
strat->update = (strat->tl == -1);
if (TEST_OPT_WEIGHTM)
{
pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
if (strat->tailRing != currRing)
{
strat->tailRing->pFDeg = strat->pOrigFDeg_TailRing;
strat->tailRing->pLDeg = strat->pOrigLDeg_TailRing;
}
int i;
for (i=strat->Ll; i>=0; i--)
{
strat->L[i].SetpFDeg();
}
for (i=strat->tl; i>=0; i--)
{
strat->T[i].SetpFDeg();
}
if (ecartWeights)
{
omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short));
ecartWeights=NULL;
}
}
if (TEST_OPT_FASTHC)
{
strat->posInL = strat->posInLOld;
strat->lastAxis = 0;
}
if (TEST_OPT_FINDET)
return;
strat->use_buckets = kMoraUseBucket(strat);
updateT(strat);
if ( (!rField_is_Ring(currRing)) || (rHasGlobalOrdering(currRing)))
{
strat->posInT = posInT2;
reorderT(strat);
}
}
kTest_TS(strat);
}
/*2
*-puts p to the standardbasis s at position at
*-reduces the tail of p if TEST_OPT_REDTAIL
*-tries to cancel a unit
*-HEckeTest
* if TRUE
* - decides about reduction-strategies
* - computes noether
* - stops computation if TEST_OPT_FINDET
* - cuts the tails of the polynomials
* in s,t and the elements in L above noether
* and cancels units if possible
* - reorders s,L
*/
void enterSMora (LObject* p,int atS,kStrategy strat, int atR)
{
enterSBba(p, atS, strat, atR);
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
Print("new s%d:",atS);
p_wrp(p->p,currRing,strat->tailRing);
PrintLn();
}
#endif
HEckeTest(p->p,strat);
if (strat->kAllAxis)
{
if (newHEdge(strat))
{
firstUpdate(strat);
if (TEST_OPT_FINDET)
return;
/*- cuts elements in L above noether and reorders L -*/
updateLHC(strat);
/*- reorders L with respect to posInL -*/
reorderL(strat);
}
}
else if ((strat->kNoether==NULL)
&& (TEST_OPT_FASTHC))
{
if (strat->posInLOldFlag)
{
missingAxis(&strat->lastAxis,strat);
if (strat->lastAxis)
{
strat->posInLOld = strat->posInL;
strat->posInLOldFlag = FALSE;
strat->posInL = posInL10;
strat->posInLDependsOnLength = TRUE;
updateL(FALSE,strat);
reorderL(strat);
}
}
else if (strat->lastAxis)
updateL(TRUE,strat);
}
}
/*2
*-puts p to the standardbasis s at position at
*-HEckeTest
* if TRUE
* - computes noether
*/
void enterSMoraNF (LObject* p, int atS,kStrategy strat, int atR)
{
enterSBba(p, atS, strat, atR);
if ((!strat->kAllAxis) || (strat->kNoether!=NULL)) HEckeTest(p->p,strat);
if (strat->kAllAxis)
newHEdge(strat);
}
void initBba(kStrategy strat)
{
/* setting global variables ------------------- */
strat->enterS = enterSBba;
strat->red = redHoney;
if (strat->honey)
strat->red = redHoney;
else if (currRing->pLexOrder && !strat->homog)
strat->red = redLazy;
else
{
strat->LazyPass *=4;
strat->red = redHomog;
}
if (rField_is_Ring(currRing))
{
if (rField_is_Z(currRing))
strat->red = redRing_Z;
else
strat->red = redRing;
}
if (TEST_OPT_IDLIFT
&& (!rIsNCRing(currRing))
&& (!rField_is_Ring(currRing)))
strat->red=redLiftstd;
if (currRing->pLexOrder && strat->honey)
strat->initEcart = initEcartNormal;
else
strat->initEcart = initEcartBBA;
if (strat->honey)
strat->initEcartPair = initEcartPairMora;
else
strat->initEcartPair = initEcartPairBba;
// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
// {
// //interred machen Aenderung
// strat->pOrigFDeg=pFDeg;
// strat->pOrigLDeg=pLDeg;
// //h=ggetid("ecart");
// //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
// //{
// // ecartWeights=iv2array(IDINTVEC(h));
// //}
// //else
// {
// ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
// /*uses automatic computation of the ecartWeights to set them*/
// kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
// }
// pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
// if (TEST_OPT_PROT)
// {
// for(i=1; i<=(currRing->N); i++)
// Print(" %d",ecartWeights[i]);
// PrintLn();
// mflush();
// }
// }
}
void initSba(ideal F,kStrategy strat)
{
int i;
//idhdl h;
/* setting global variables ------------------- */
strat->enterS = enterSSba;
strat->red2 = redHoney;
if (strat->honey)
strat->red2 = redHoney;
else if (currRing->pLexOrder && !strat->homog)
strat->red2 = redLazy;
else
{
strat->LazyPass *=4;
strat->red2 = redHomog;
}
if (rField_is_Ring(currRing))
{
if(rHasLocalOrMixedOrdering(currRing))
{strat->red2 = redRiloc;}
else
{strat->red2 = redRing;}
}
if (currRing->pLexOrder && strat->honey)
strat->initEcart = initEcartNormal;
else
strat->initEcart = initEcartBBA;
if (strat->honey)
strat->initEcartPair = initEcartPairMora;
else
strat->initEcartPair = initEcartPairBba;
//strat->kIdeal = NULL;
//if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
//else strat->kIdeal->rtyp=MODUL_CMD;
//strat->kIdeal->data=(void *)strat->Shdl;
if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
{
//interred machen Aenderung
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
//h=ggetid("ecart");
//if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
//{
// ecartWeights=iv2array(IDINTVEC(h));
//}
//else
{
ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
/*uses automatic computation of the ecartWeights to set them*/
kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights, currRing);
}
pRestoreDegProcs(currRing, totaldegreeWecart, maxdegreeWecart);
if (TEST_OPT_PROT)
{
for(i=1; i<=(currRing->N); i++)
Print(" %d",ecartWeights[i]);
PrintLn();
mflush();
}
}
// for sig-safe reductions in signature-based
// standard basis computations
if(rField_is_Ring(currRing))
strat->red = redSigRing;
else
strat->red = redSig;
//strat->sbaOrder = 1;
strat->currIdx = 1;
}
void initMora(ideal F,kStrategy strat)
{
int i,j;
strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN));
for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE;
strat->enterS = enterSMora;
strat->initEcartPair = initEcartPairMora; /*- ecart approximation -*/
strat->posInLOld = strat->posInL;
strat->posInLOldFlag = TRUE;
strat->initEcart = initEcartNormal;
if (strat->homog)
strat->red = redFirst; /*take the first possible in T*/
else
strat->red = redEcart;/*take the first possible in under ecart-restriction*/
if ( currRing->ppNoether!=NULL )
{
strat->kNoether = pCopy((currRing->ppNoether));
if (TEST_OPT_PROT)
{
Print("H(%ld)",p_FDeg(strat->kNoether,currRing)+1);
mflush();
}
}
if (strat->kNoether!=NULL)
{
HCord = currRing->pFDeg((strat->kNoether),currRing)+1;
}
else
{
HCord = INT_MAX-3;/*- very large -*/
}
if (rField_is_Ring(currRing))
{
if (rField_is_Z(currRing))
strat->red = redRiloc_Z;
else
strat->red = redRiloc;
}
/*reads the ecartWeights used for Graebes method from the
*intvec ecart and set ecartWeights
*/
if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
{
//interred machen Aenderung
strat->pOrigFDeg=currRing->pFDeg;
strat->pOrigLDeg=currRing->pLDeg;
ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
/*uses automatic computation of the ecartWeights to set them*/
kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights,currRing);
pSetDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
if (TEST_OPT_PROT)
{
for(i=1; i<=(currRing->N); i++)
Print(" %d",ecartWeights[i]);
PrintLn();
mflush();
}
}
kOptimizeLDeg(currRing->pLDeg, strat);
}
void kDebugPrint(kStrategy strat);
ideal mora (ideal F, ideal Q,intvec *w,bigintmat *hilb,kStrategy strat)
{
int olddeg = 0;
int reduc = 0;
int red_result = 1;
int hilbeledeg=1,hilbcount=0;
BITSET save1;
SI_SAVE_OPT1(save1);
if (rHasMixedOrdering(currRing))
{
si_opt_1 &= ~Sy_bit(OPT_REDSB);
si_opt_1 &= ~Sy_bit(OPT_REDTAIL);
}
strat->update = TRUE;
/*- setting global variables ------------------- -*/
initBuchMoraCrit(strat);
initHilbCrit(F,Q,&hilb,strat);
initMora(F,strat);
if(rField_is_Ring(currRing))
initBuchMoraPosRing(strat);
else
initBuchMoraPos(strat);
/*Shdl=*/initBuchMora(F,Q,strat);
if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat);
/*updateS in initBuchMora has Hecketest
* and could have put strat->kHEdgdeFound FALSE*/
if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag)
{
strat->posInLOld = strat->posInL;
strat->posInLOldFlag = FALSE;
strat->posInL = posInL10;
updateL(FALSE,strat);
reorderL(strat);
}
kTest_TS(strat);
strat->use_buckets = kMoraUseBucket(strat);
#ifdef HAVE_TAIL_RING
if (strat->homog && strat->red == redFirst)
if(!idIs0(F) &&(!rField_is_Ring(currRing)))
kStratInitChangeTailRing(strat);
#endif
if (BVERBOSE(23)) kDebugPrint(strat);
/*- compute-------------------------------------------*/
while (strat->Ll >= 0)
{
#ifdef KDEBUG
if (TEST_OPT_DEBUG) messageSets(strat);
#endif
if (siCntrlc)
{
while (strat->Ll >= 0)
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
strat->noClearS=TRUE;
}
if (TEST_OPT_DEGBOUND
&& (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg))
{
/*
* stops computation if
* - 24 (degBound)
* && upper degree is bigger than Kstd1_deg
*/
while ((strat->Ll >= 0)
&& (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
&& (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)
)
{
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
//if (TEST_OPT_PROT)
//{
// PrintS("D"); mflush();
//}
}
if (strat->Ll<0) break;
else strat->noClearS=TRUE;
}
strat->P = strat->L[strat->Ll];/*- picks the last element from the lazyset L -*/
if (strat->Ll==0) strat->interpt=TRUE;
strat->Ll--;
// create the real Spoly
if (pNext(strat->P.p) == strat->tail)
{
/*- deletes the short spoly and computes -*/
if (rField_is_Ring(currRing))
pLmDelete(strat->P.p);
else
pLmFree(strat->P.p);
strat->P.p = NULL;
poly m1 = NULL, m2 = NULL;
// check that spoly creation is ok
while (strat->tailRing != currRing &&
!kCheckSpolyCreation(&(strat->P), strat, m1, m2))
{
assume(m1 == NULL && m2 == NULL);
// if not, change to a ring where exponents are large enough
kStratChangeTailRing(strat);
}
/* create the real one */
ksCreateSpoly(&(strat->P), strat->kNoetherTail(), strat->use_buckets,
strat->tailRing, m1, m2, strat->R);
if (!strat->use_buckets)
strat->P.SetLength(strat->length_pLength);
strat->P.PrepareRed(strat->use_buckets);
}
else if (strat->P.p1 == NULL)
{
// for input polys, prepare reduction (buckets !)
strat->P.SetLength(strat->length_pLength);
strat->P.PrepareRed(strat->use_buckets);
}
// the s-poly
if (!strat->P.IsNull())
{
// might be NULL from noether !!!
if (TEST_OPT_PROT)
message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result);
// reduce
red_result = strat->red(&strat->P,strat);
}
// the reduced s-poly
if (! strat->P.IsNull())
{
strat->P.GetP();
// statistics
if (TEST_OPT_PROT) PrintS("s");
// normalization
if (TEST_OPT_INTSTRATEGY)
strat->P.pCleardenom();
else
strat->P.pNorm();
// tailreduction
strat->P.p = redtail(&(strat->P),strat->sl,strat);
if (strat->P.p==NULL)
{
WerrorS("exponent overflow - wrong ordering");
return(idInit(1,1));
}
// set ecart -- might have changed because of tail reductions
if ((!strat->noTailReduction) && (!strat->honey))
strat->initEcart(&strat->P);
// cancel unit
cancelunit(&strat->P);
// for char 0, clear denominators
if ((strat->P.p->next==NULL) /* i.e. cancelunit did something*/
&& TEST_OPT_INTSTRATEGY)
strat->P.pCleardenom();
strat->P.SetShortExpVector();
enterT(&strat->P,strat);
// build new pairs
if (rField_is_Ring(currRing))
superenterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
else
enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
// put in S
strat->enterS(&strat->P,
posInS(strat,strat->sl,strat->P.p, strat->P.ecart),
strat, strat->tl);
// apply hilbert criterion
if (hilb!=NULL)
{
if (strat->homog==isHomog)
khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
else
khCheckLocInhom(Q,w,hilb,hilbcount,strat);
}
// clear strat->P
kDeleteLcm(&strat->P);
#ifdef KDEBUG
// make sure kTest_TS does not complain about strat->P
strat->P.Clear();
#endif
}
if (strat->kAllAxis)
{
if ((TEST_OPT_FINDET)
|| ((TEST_OPT_MULTBOUND) && (scMult0Int(strat->Shdl,NULL) < Kstd1_mu)))
{
// obachman: is this still used ???
/*
* stops computation if strat->kAllAxis and
* - 27 (finiteDeterminacyTest)
* or
* - 23
* (multBound)
* && multiplicity of the ideal is smaller then a predefined number mu
*/
while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
}
}
kTest_TS(strat);
}
/*- complete reduction of the standard basis------------------------ -*/
if (TEST_OPT_REDSB) completeReduce(strat);
else if (TEST_OPT_PROT) PrintLn();
/*- release temp data------------------------------- -*/
exitBuchMora(strat);
/*- polynomials used for HECKE: HC, noether -*/
if (TEST_OPT_FINDET)
{
if (strat->kNoether!=NULL)
Kstd1_mu=currRing->pFDeg(strat->kNoether,currRing);
else
Kstd1_mu=-1;
}
omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
if ((TEST_OPT_PROT)||(TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
// if (TEST_OPT_WEIGHTM)
// {
// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
// if (ecartWeights)
// {
// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
// ecartWeights=NULL;
// }
// }
if(nCoeff_is_Z(currRing->cf))
finalReduceByMon(strat);
if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
SI_RESTORE_OPT1(save1);
idTest(strat->Shdl);
return (strat->Shdl);
}
poly kNF1 (ideal F,ideal Q,poly q, kStrategy strat, int lazyReduce)
{
assume(q!=NULL);
assume(!(idIs0(F)&&(Q==NULL)));
// lazy_reduce flags: can be combined by |
//#define KSTD_NF_LAZY 1
// do only a reduction of the leading term
//#define KSTD_NF_ECART 2
// only local: reduce even with bad ecart
poly p;
int i;
int j;
int o;
LObject h;
BITSET save1;
SI_SAVE_OPT1(save1);
//if ((idIs0(F))&&(Q==NULL))
// return pCopy(q); /*F=0*/
//strat->ak = si_max(idRankFreeModule(F),pMaxComp(q));
/*- creating temp data structures------------------- -*/
strat->kAllAxis = (currRing->ppNoether) != NULL;
strat->kNoether = pCopy((currRing->ppNoether));
si_opt_1|=Sy_bit(OPT_REDTAIL);
if (!rField_is_Ring(currRing))
si_opt_1&=~Sy_bit(OPT_INTSTRATEGY);
if (TEST_OPT_STAIRCASEBOUND
&& (! TEST_V_DEG_STOP)
&& (0<Kstd1_deg)
&& ((strat->kNoether==NULL)
||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg))))
{
pLmDelete(&strat->kNoether);
strat->kNoether=pOne();
pSetExp(strat->kNoether,1, Kstd1_deg+1);
pSetm(strat->kNoether);
// strat->kAllAxis=TRUE;
}
initBuchMoraCrit(strat);
if(rField_is_Ring(currRing))
initBuchMoraPosRing(strat);
else
initBuchMoraPos(strat);
initMora(F,strat);
strat->enterS = enterSMoraNF;
/*- set T -*/
strat->tl = -1;
strat->tmax = setmaxT;
strat->T = initT();
strat->R = initR();
strat->sevT = initsevT();
/*- set S -*/
strat->sl = -1;
/*- init local data struct.-------------------------- -*/
/*Shdl=*/initS(F,Q,strat);
if ((strat->ak!=0)
&& (strat->kAllAxis)) /*never true for ring-cf*/
{
if (strat->ak!=1)
{
pSetComp(strat->kNoether,1);
pSetmComp(strat->kNoether);
poly p=pHead(strat->kNoether);
pSetComp(p,strat->ak);
pSetmComp(p);
p=pAdd(strat->kNoether,p);
strat->kNoether=pNext(p);
p_LmDelete(p,currRing);
}
}
if (((lazyReduce & KSTD_NF_LAZY)==0)
&& (!rField_is_Ring(currRing)))
{
for (i=strat->sl; i>=0; i--)
pNorm(strat->S[i]);
}
/*- puts the elements of S also to T -*/
for (i=0; i<=strat->sl; i++)
{
h.p = strat->S[i];
h.ecart = strat->ecartS[i];
if (strat->sevS[i] == 0) strat->sevS[i] = pGetShortExpVector(h.p);
else assume(strat->sevS[i] == pGetShortExpVector(h.p));
h.length = pLength(h.p);
h.sev = strat->sevS[i];
h.SetpFDeg();
enterT(&h,strat);
}
#ifdef KDEBUG
// kDebugPrint(strat);
#endif
/*- compute------------------------------------------- -*/
p = pCopy(q);
deleteHC(&p,&o,&j,strat);
kTest(strat);
if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
if (BVERBOSE(23)) kDebugPrint(strat);
if(rField_is_Ring(currRing))
{
if (p!=NULL) p = redMoraNFRing(p,strat, lazyReduce & (KSTD_NF_ECART|KSTD_NF_CANCELUNIT));
}
else
{
if (p!=NULL) p = redMoraNF(p,strat, lazyReduce & (KSTD_NF_ECART|KSTD_NF_CANCELUNIT));
}
if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
{
if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
p = redtail(p,strat->sl,strat);
}
/*- release temp data------------------------------- -*/
cleanT(strat);
assume(strat->L==NULL); /*strat->L unused */
assume(strat->B==NULL); /*strat->B unused */
omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
omFree(strat->sevT);
omFree(strat->S_2_R);
omFree(strat->R);
omfree((ADDRESS)strat->fromQ);
strat->fromQ=NULL;
if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
// {
// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
// if (ecartWeights)
// {
// omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short));
// ecartWeights=NULL;
// }
// }
idDelete(&strat->Shdl);
SI_RESTORE_OPT1(save1);
if (TEST_OPT_PROT) PrintLn();
return p;
}
ideal kNF1 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce)
{
assume(!idIs0(q));
assume(!(idIs0(F)&&(Q==NULL)));
// lazy_reduce flags: can be combined by |
//#define KSTD_NF_LAZY 1
// do only a reduction of the leading term
//#define KSTD_NF_ECART 2
// only local: reduce even with bad ecart
poly p;
int i;
int j;
int o;
LObject h;
ideal res;
BITSET save1;
SI_SAVE_OPT1(save1);
//if (idIs0(q)) return idInit(IDELEMS(q),si_max(q->rank,F->rank));
//if ((idIs0(F))&&(Q==NULL))
// return idCopy(q); /*F=0*/
//strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(q));
/*- creating temp data structures------------------- -*/
strat->kAllAxis = (currRing->ppNoether) != NULL;
strat->kNoether=pCopy((currRing->ppNoether));
si_opt_1|=Sy_bit(OPT_REDTAIL);
if (TEST_OPT_STAIRCASEBOUND
&& (0<Kstd1_deg)
&& ((strat->kNoether==NULL)
||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg))))
{
pLmDelete(&strat->kNoether);
strat->kNoether=pOne();
pSetExp(strat->kNoether,1, Kstd1_deg+1);
pSetm(strat->kNoether);
//strat->kAllAxis=TRUE;
}
initBuchMoraCrit(strat);
if(rField_is_Ring(currRing))
initBuchMoraPosRing(strat);
else
initBuchMoraPos(strat);
initMora(F,strat);
strat->enterS = enterSMoraNF;
/*- set T -*/
strat->tl = -1;
strat->tmax = setmaxT;
strat->T = initT();
strat->R = initR();
strat->sevT = initsevT();
/*- set S -*/
strat->sl = -1;
/*- init local data struct.-------------------------- -*/
/*Shdl=*/initS(F,Q,strat);
if ((strat->ak!=0)
&& (strat->kNoether!=NULL))
{
if (strat->ak!=1)
{
pSetComp(strat->kNoether,1);
pSetmComp(strat->kNoether);
poly p=pHead(strat->kNoether);
pSetComp(p,strat->ak);
pSetmComp(p);
p=pAdd(strat->kNoether,p);
strat->kNoether=pNext(p);
p_LmDelete(p,currRing);
}
}
if (((lazyReduce & KSTD_NF_LAZY)==0)
&& (!rField_is_Ring(currRing)))
{
for (i=strat->sl; i>=0; i--)
pNorm(strat->S[i]);
}
/*- compute------------------------------------------- -*/
res=idInit(IDELEMS(q),strat->ak);
for (i=0; i<IDELEMS(q); i++)
{
if (q->m[i]!=NULL)
{
p = pCopy(q->m[i]);
deleteHC(&p,&o,&j,strat);
if (p!=NULL)
{
/*- puts the elements of S also to T -*/
for (j=0; j<=strat->sl; j++)
{
h.p = strat->S[j];
h.ecart = strat->ecartS[j];
h.pLength = h.length = pLength(h.p);
if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p);
else assume(strat->sevS[j] == pGetShortExpVector(h.p));
h.sev = strat->sevS[j];
h.SetpFDeg();
if(rField_is_Ring(currRing) && rHasLocalOrMixedOrdering(currRing))
enterT_strong(&h,strat);
else
enterT(&h,strat);
}
if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
if(rField_is_Ring(currRing))
{
p = redMoraNFRing(p,strat, lazyReduce);
}
else
p = redMoraNF(p,strat, lazyReduce);
if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0))
{
if (TEST_OPT_PROT) { PrintS("t"); mflush(); }
p = redtail(p,strat->sl,strat);
}
cleanT(strat);
}
res->m[i]=p;
}
//else
// res->m[i]=NULL;
}
/*- release temp data------------------------------- -*/
assume(strat->L==NULL); /*strat->L unused */
assume(strat->B==NULL); /*strat->B unused */
omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
omFree(strat->sevT);
omFree(strat->S_2_R);
omFree(strat->R);
omfree((ADDRESS)strat->fromQ);
strat->fromQ=NULL;
if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
// if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
// {
// pFDeg=strat->pOrigFDeg;
// pLDeg=strat->pOrigLDeg;
// if (ecartWeights)
// {
// omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short));
// ecartWeights=NULL;
// }
// }
idDelete(&strat->Shdl);
SI_RESTORE_OPT1(save1);
if (TEST_OPT_PROT) PrintLn();
return res;
}
VAR intvec * kModW, * kHomW;
long kModDeg(poly p,const ring r)
{
long o=p_WDegree(p, r);
long i=__p_GetComp(p, r);
if (i==0) return o;
//assume((i>0) && (i<=kModW->length()));
if (i<=kModW->length())
return o+(*kModW)[i-1];
return o;
}
long kHomModDeg(poly p,const ring r)
{
int i;
long j=0;
for (i=r->N;i>0;i--)
j+=p_GetExp(p,i,r)*(*kHomW)[i-1];
if (kModW == NULL) return j;
i = __p_GetComp(p,r);
if (i==0) return j;
return j+(*kModW)[i-1];
}
ideal kStd_internal(ideal F, ideal Q, tHomog h,intvec ** w, bigintmat *hilb,
int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
{
assume(!idIs0(F));
assume((Q==NULL)||(!idIs0(Q)));
kStrategy strat=new skStrategy;
ideal r;
BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
BOOLEAN delete_w=(w==NULL);
strat->s_poly=sp;
if(!TEST_OPT_RETURN_SB)
strat->syzComp = syzComp;
if (TEST_OPT_SB_1
&&(!rField_is_Ring(currRing))
)
strat->newIdeal = newIdeal;
if (rField_has_simple_inverse(currRing))
strat->LazyPass=20;
else
strat->LazyPass=2;
strat->LazyDegree = 1;
strat->ak = 0;
if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
if (vw != NULL)
{
currRing->pLexOrder=FALSE;
strat->kHomW=kHomW=vw;
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kHomModDeg);
toReset = TRUE;
}
if (h==testHomog)
{
if (strat->ak == 0)
{
h = (tHomog)idHomIdeal(F,Q);
w=NULL;
}
else if (!TEST_OPT_DEGBOUND)
{
if (w!=NULL)
h = (tHomog)idHomModule(F,Q,w);
else
h = (tHomog)idHomIdeal(F,Q);
}
}
currRing->pLexOrder=b;
if (h==isHomog)
{
if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
{
strat->kModW = kModW = *w;
if (vw == NULL)
{
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kModDeg);
toReset = TRUE;
}
}
currRing->pLexOrder = TRUE;
if (hilb==NULL) strat->LazyPass*=2;
}
strat->homog=h;
#ifdef KDEBUG
idTest(F);
if (Q!=NULL) idTest(Q);
#endif
#ifdef HAVE_PLURAL
if (rIsPluralRing(currRing))
{
const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
strat->no_prod_crit = ! bIsSCA;
if (w!=NULL)
r = nc_GB(F, Q, *w, hilb, strat, currRing);
else
r = nc_GB(F, Q, NULL, hilb, strat, currRing);
}
else
#endif
{
#if PRE_INTEGER_CHECK
//the preinteger check strategy is not for modules
if(nCoeff_is_Z(currRing->cf) && strat->ak <= 0)
{
ideal FCopy = idCopy(F);
poly pFmon = preIntegerCheck(FCopy, Q);
if(pFmon != NULL)
{
idInsertPoly(FCopy, pFmon);
strat->kModW=kModW=NULL;
if (h==testHomog)
{
h = (tHomog)idHomIdeal(FCopy,Q);
w=NULL;
}
currRing->pLexOrder=b;
if (h==isHomog)
{
if ((w!=NULL) && (*w!=NULL))
{
strat->kModW = kModW = *w;
if (vw == NULL)
{
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kModDeg);
toReset = TRUE;
}
}
currRing->pLexOrder = TRUE;
if (hilb==NULL) strat->LazyPass*=2;
}
strat->homog=h;
}
omTestMemory(1);
if(w == NULL)
{
if(rHasLocalOrMixedOrdering(currRing))
r=mora(FCopy,Q,NULL,hilb,strat);
else
r=bba(FCopy,Q,NULL,hilb,strat);
}
else
{
if(rHasLocalOrMixedOrdering(currRing))
r=mora(FCopy,Q,*w,hilb,strat);
else
r=bba(FCopy,Q,*w,hilb,strat);
}
idDelete(&FCopy);
}
else
#endif
{
if(w==NULL)
{
if(rHasLocalOrMixedOrdering(currRing))
r=mora(F,Q,NULL,hilb,strat);
else
r=bba(F,Q,NULL,hilb,strat);
}
else
{
if(rHasLocalOrMixedOrdering(currRing))
r=mora(F,Q,*w,hilb,strat);
else
r=bba(F,Q,*w,hilb,strat);
}
}
}
if(errorreported) return NULL;
#ifdef KDEBUG
idTest(r);
#endif
if (toReset)
{
kModW = NULL;
pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
}
currRing->pLexOrder = b;
//Print("%d reductions canceled \n",strat->cel);
delete(strat);
if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
return r;
}
ideal kStd2(ideal F, ideal Q, tHomog h,intvec ** w, bigintmat *hilb,int syzComp,
int newIdeal, intvec *vw, s_poly_proc_t sp)
{
if(idIs0(F))
return idInit(1,F->rank);
if(idIs0(Q)) Q=NULL;
#ifdef HAVE_SHIFTBBA
if(rIsLPRing(currRing)) return kStdShift(F, Q, h, w, hilb, syzComp, newIdeal, vw, FALSE);
#endif
if ((hilb==NULL)
&& (vw==NULL)
&& (newIdeal==0)
&& (sp==NULL)
&& (IDELEMS(F)>1)
&& (!TEST_OPT_SB_1)
&& (currRing->ppNoether==NULL)
&& !rIsPluralRing(currRing) /*!rIsLPRing already tested above*/
&& (!id_IsModule(F,currRing)))
{
/* test HC precomputation*/
if( rField_is_Q(currRing)
&& (!rHasGlobalOrdering(currRing))
&& (rOrd_is_ds(currRing)||rOrd_is_Ds(currRing))
&& (!idIsMonomial(F)))
{
currRing->ppNoether=kTryHC(F,Q);
ideal res=kStd_internal(F,Q,h,w,hilb,syzComp,newIdeal,vw,sp);
if (currRing->ppNoether!=NULL) pLmDelete(currRing->ppNoether);
currRing->ppNoether=NULL;
return res;
}
/* test hilbstd */
if ( rHasGlobalOrdering(currRing)
&& (!TEST_OPT_RETURN_SB)
&& (!TEST_OPT_DEGBOUND)
&& (currRing->LexOrder
|| rHasBlockOrder(currRing))
&& (!idIsMonomial(F)))
{
ideal result=kTryHilbstd(F,Q);
//ideal result=kTryHilbstd_par(F,Q,h,w);
if (result!=NULL)
{
return result;
}
}
}
return kStd_internal(F,Q,h,w,hilb,syzComp,newIdeal,vw,sp);
}
ideal kStd(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
int newIdeal, intvec *vw, s_poly_proc_t sp)
{
bigintmat *hh=iv2biv(hilb,coeffs_BIGINT);
ideal res=kStd2(F,Q,h,w,hh,syzComp,newIdeal,vw,sp);
if (hh!=NULL) delete hh;
return res;
}
ideal kSba(ideal F, ideal Q, tHomog h,intvec ** w, int sbaOrder, int arri, bigintmat *hilb,int syzComp,
int newIdeal, intvec *vw)
{
if(idIs0(F))
return idInit(1,F->rank);
if(!rField_is_Ring(currRing))
{
ideal r;
BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
BOOLEAN delete_w=(w==NULL);
kStrategy strat=new skStrategy;
strat->sbaOrder = sbaOrder;
if (arri!=0)
{
strat->rewCrit1 = arriRewDummy;
strat->rewCrit2 = arriRewCriterion;
strat->rewCrit3 = arriRewCriterionPre;
}
else
{
strat->rewCrit1 = faugereRewCriterion;
strat->rewCrit2 = faugereRewCriterion;
strat->rewCrit3 = faugereRewCriterion;
}
if(!TEST_OPT_RETURN_SB)
strat->syzComp = syzComp;
if (TEST_OPT_SB_1)
//if(!rField_is_Ring(currRing)) // always true here
strat->newIdeal = newIdeal;
if (rField_has_simple_inverse(currRing))
strat->LazyPass=20;
else
strat->LazyPass=2;
strat->LazyDegree = 1;
strat->enterOnePair=enterOnePairNormal;
strat->chainCrit=chainCritNormal;
if (TEST_OPT_SB_1) strat->chainCrit=chainCritOpt_1;
strat->ak = 0;
if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
if (vw != NULL)
{
currRing->pLexOrder=FALSE;
strat->kHomW=kHomW=vw;
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kHomModDeg);
toReset = TRUE;
}
if (h==testHomog)
{
if (strat->ak == 0)
{
h = (tHomog)idHomIdeal(F,Q);
w=NULL;
}
else if (!TEST_OPT_DEGBOUND)
{
if (w!=NULL)
h = (tHomog)idHomModule(F,Q,w);
else
h = (tHomog)idHomIdeal(F,Q);
}
}
currRing->pLexOrder=b;
if (h==isHomog)
{
if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
{
strat->kModW = kModW = *w;
if (vw == NULL)
{
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kModDeg);
toReset = TRUE;
}
}
currRing->pLexOrder = TRUE;
if (hilb==NULL) strat->LazyPass*=2;
}
strat->homog=h;
#ifdef KDEBUG
idTest(F);
if(Q != NULL)
idTest(Q);
#endif
#ifdef HAVE_PLURAL
if (rIsPluralRing(currRing))
{
const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
strat->no_prod_crit = ! bIsSCA;
if (w!=NULL)
r = nc_GB(F, Q, *w, hilb, strat, currRing);
else
r = nc_GB(F, Q, NULL, hilb, strat, currRing);
}
else
#endif
{
if (rHasLocalOrMixedOrdering(currRing))
{
if (w!=NULL)
r=mora(F,Q,*w,hilb,strat);
else
r=mora(F,Q,NULL,hilb,strat);
}
else
{
strat->sigdrop = FALSE;
if (w!=NULL)
r=sba(F,Q,*w,hilb,strat);
else
r=sba(F,Q,NULL,hilb,strat);
}
}
#ifdef KDEBUG
idTest(r);
#endif
if (toReset)
{
kModW = NULL;
pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
}
currRing->pLexOrder = b;
//Print("%d reductions canceled \n",strat->cel);
//delete(strat);
if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
return r;
}
else
{
//--------------------------RING CASE-------------------------
assume(sbaOrder == 1);
assume(arri == 0);
ideal r;
r = idCopy(F);
int sbaEnterS = -1;
bool sigdrop = TRUE;
//This is how we set the SBA algorithm;
int totalsbaruns = 1,blockedreductions = 20,blockred = 0,loops = 0;
while(sigdrop && (loops < totalsbaruns || totalsbaruns == -1)
&& (blockred <= blockedreductions))
{
loops++;
if(loops == 1)
sigdrop = FALSE;
BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
BOOLEAN delete_w=(w==NULL);
kStrategy strat=new skStrategy;
strat->sbaEnterS = sbaEnterS;
strat->sigdrop = sigdrop;
#if 0
strat->blockred = blockred;
#else
strat->blockred = 0;
#endif
strat->blockredmax = blockedreductions;
//printf("\nsbaEnterS beginning = %i\n",strat->sbaEnterS);
//printf("\nsigdrop beginning = %i\n",strat->sigdrop);
strat->sbaOrder = sbaOrder;
if (arri!=0)
{
strat->rewCrit1 = arriRewDummy;
strat->rewCrit2 = arriRewCriterion;
strat->rewCrit3 = arriRewCriterionPre;
}
else
{
strat->rewCrit1 = faugereRewCriterion;
strat->rewCrit2 = faugereRewCriterion;
strat->rewCrit3 = faugereRewCriterion;
}
if(!TEST_OPT_RETURN_SB)
strat->syzComp = syzComp;
if (TEST_OPT_SB_1)
if(!rField_is_Ring(currRing))
strat->newIdeal = newIdeal;
if (rField_has_simple_inverse(currRing))
strat->LazyPass=20;
else
strat->LazyPass=2;
strat->LazyDegree = 1;
strat->enterOnePair=enterOnePairNormal;
strat->chainCrit=chainCritNormal;
if (TEST_OPT_SB_1) strat->chainCrit=chainCritOpt_1;
strat->ak = 0;
if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
if (vw != NULL)
{
currRing->pLexOrder=FALSE;
strat->kHomW=kHomW=vw;
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kHomModDeg);
toReset = TRUE;
}
if (h==testHomog)
{
if (strat->ak == 0)
{
h = (tHomog)idHomIdeal(F,Q);
w=NULL;
}
else if (!TEST_OPT_DEGBOUND)
{
if (w!=NULL)
h = (tHomog)idHomModule(F,Q,w);
else
h = (tHomog)idHomIdeal(F,Q);
}
}
currRing->pLexOrder=b;
if (h==isHomog)
{
if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
{
strat->kModW = kModW = *w;
if (vw == NULL)
{
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kModDeg);
toReset = TRUE;
}
}
currRing->pLexOrder = TRUE;
if (hilb==NULL) strat->LazyPass*=2;
}
strat->homog=h;
#ifdef KDEBUG
idTest(F);
if(Q != NULL)
idTest(Q);
#endif
#ifdef HAVE_PLURAL
if (rIsPluralRing(currRing))
{
const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
strat->no_prod_crit = ! bIsSCA;
if (w!=NULL)
r = nc_GB(F, Q, *w, hilb, strat, currRing);
else
r = nc_GB(F, Q, NULL, hilb, strat, currRing);
}
else
#endif
{
if (rHasLocalOrMixedOrdering(currRing))
{
if (w!=NULL)
r=mora(F,Q,*w,hilb,strat);
else
r=mora(F,Q,NULL,hilb,strat);
}
else
{
if (w!=NULL)
r=sba(r,Q,*w,hilb,strat);
else
{
r=sba(r,Q,NULL,hilb,strat);
}
}
}
#ifdef KDEBUG
idTest(r);
#endif
if (toReset)
{
kModW = NULL;
pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
}
currRing->pLexOrder = b;
//Print("%d reductions canceled \n",strat->cel);
sigdrop = strat->sigdrop;
sbaEnterS = strat->sbaEnterS;
blockred = strat->blockred;
delete(strat);
if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
}
// Go to std
if(sigdrop || blockred > blockedreductions)
{
r = kStd2(r, Q, h, w, hilb, syzComp, newIdeal, vw);
}
return r;
}
}
#ifdef HAVE_SHIFTBBA
ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, bigintmat *hilb,int syzComp,
int newIdeal, intvec *vw, BOOLEAN rightGB)
{
assume(rIsLPRing(currRing));
assume(idIsInV(F));
if (rHasLocalOrMixedOrdering(currRing))
{
/* error: no local ord yet with shifts */
WerrorS("No local ordering possible for shift algebra");
return(NULL);
}
ideal r;
BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
BOOLEAN delete_w=(w==NULL);
kStrategy strat=new skStrategy;
strat->rightGB = rightGB;
if(!TEST_OPT_RETURN_SB)
strat->syzComp = syzComp;
if (TEST_OPT_SB_1)
if(!rField_is_Ring(currRing))
strat->newIdeal = newIdeal;
if (rField_has_simple_inverse(currRing))
strat->LazyPass=20;
else
strat->LazyPass=2;
strat->LazyDegree = 1;
strat->ak = 0;
if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
if (vw != NULL)
{
currRing->pLexOrder=FALSE;
strat->kHomW=kHomW=vw;
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kHomModDeg);
toReset = TRUE;
}
if (h==testHomog)
{
if (strat->ak == 0)
{
h = (tHomog)idHomIdeal(F,Q);
w=NULL;
}
else if (!TEST_OPT_DEGBOUND)
{
if (w!=NULL)
h = (tHomog)idHomModule(F,Q,w);
else
h = (tHomog)idHomIdeal(F,Q);
}
}
currRing->pLexOrder=b;
if (h==isHomog)
{
if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
{
strat->kModW = kModW = *w;
if (vw == NULL)
{
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kModDeg);
toReset = TRUE;
}
}
currRing->pLexOrder = TRUE;
if (hilb==NULL) strat->LazyPass*=2;
}
strat->homog=h;
#ifdef KDEBUG
idTest(F);
#endif
/* global ordering */
if (w!=NULL)
r=bbaShift(F,Q,*w,hilb,strat);
else
r=bbaShift(F,Q,NULL,hilb,strat);
#ifdef KDEBUG
idTest(r);
#endif
if (toReset)
{
kModW = NULL;
pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
}
currRing->pLexOrder = b;
//Print("%d reductions canceled \n",strat->cel);
delete(strat);
if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
assume(idIsInV(r));
return r;
}
#endif
//##############################################################
//##############################################################
//##############################################################
//##############################################################
//##############################################################
ideal kMin_std2(ideal F, ideal Q, tHomog h,intvec ** w, ideal &M, bigintmat *hilb,
int syzComp, int reduced)
{
if(idIs0(F))
{
M=idInit(1,F->rank);
return idInit(1,F->rank);
}
if(rField_is_Ring(currRing))
{
ideal sb;
sb = kStd2(F, Q, h, w, hilb);
idSkipZeroes(sb);
if(IDELEMS(sb) <= IDELEMS(F))
{
M = idCopy(sb);
idSkipZeroes(M);
return(sb);
}
else
{
M = idCopy(F);
idSkipZeroes(M);
return(sb);
}
}
ideal r=NULL;
int Kstd1_OldDeg = Kstd1_deg,i;
intvec* temp_w=NULL;
BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
BOOLEAN delete_w=(w==NULL);
BOOLEAN oldDegBound=TEST_OPT_DEGBOUND;
kStrategy strat=new skStrategy;
if(!TEST_OPT_RETURN_SB)
strat->syzComp = syzComp;
if (rField_has_simple_inverse(currRing))
strat->LazyPass=20;
else
strat->LazyPass=2;
strat->LazyDegree = 1;
strat->minim=(reduced % 2)+1;
strat->ak = 0;
if (id_IsModule(F,currRing)) strat->ak = id_RankFreeModule(F,currRing);
if (delete_w)
{
temp_w=new intvec((strat->ak)+1);
w = &temp_w;
}
if (h==testHomog)
{
if (strat->ak == 0)
{
h = (tHomog)idHomIdeal(F,Q);
w=NULL;
}
else
{
h = (tHomog)idHomModule(F,Q,w);
}
}
if (h==isHomog)
{
if (strat->ak > 0 && (w!=NULL) && (*w!=NULL))
{
kModW = *w;
strat->kModW = *w;
assume(currRing->pFDeg != NULL && currRing->pLDeg != NULL);
strat->pOrigFDeg = currRing->pFDeg;
strat->pOrigLDeg = currRing->pLDeg;
pSetDegProcs(currRing,kModDeg);
toReset = TRUE;
if (reduced>1)
{
Kstd1_OldDeg=Kstd1_deg;
Kstd1_deg = -1;
for (i=IDELEMS(F)-1;i>=0;i--)
{
if ((F->m[i]!=NULL) && (currRing->pFDeg(F->m[i],currRing)>=Kstd1_deg))
Kstd1_deg = currRing->pFDeg(F->m[i],currRing)+1;
}
}
}
currRing->pLexOrder = TRUE;
strat->LazyPass*=2;
}
strat->homog=h;
ideal SB=NULL;
if (rHasLocalOrMixedOrdering(currRing))
{
r=idMinBase(F,&SB); // SB and M via minbase
strat->M=r;
r=SB;
}
else
{
if (w!=NULL)
r=bba(F,Q,*w,hilb,strat);
else
r=bba(F,Q,NULL,hilb,strat);
}
#ifdef KDEBUG
{
int i;
for (i=IDELEMS(r)-1; i>=0; i--) pTest(r->m[i]);
}
#endif
idSkipZeroes(r);
if (toReset)
{
pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
kModW = NULL;
}
currRing->pLexOrder = b;
if ((delete_w)&&(temp_w!=NULL)) delete temp_w;
if ((IDELEMS(r)==1) && (r->m[0]!=NULL) && pIsConstant(r->m[0]) && (strat->ak==0))
{
M=idInit(1,F->rank);
M->m[0]=pOne();
//if (strat->ak!=0) { pSetComp(M->m[0],strat->ak); pSetmComp(M->m[0]); }
if (strat->M!=NULL) idDelete(&strat->M);
}
else if (strat->M==NULL)
{
M=idInit(1,F->rank);
WarnS("no minimal generating set computed");
}
else
{
idSkipZeroes(strat->M);
M=strat->M;
strat->M=NULL;
}
delete(strat);
if (reduced>2)
{
Kstd1_deg=Kstd1_OldDeg;
if (!oldDegBound)
si_opt_1 &= ~Sy_bit(OPT_DEGBOUND);
}
else
{
if (IDELEMS(M)>IDELEMS(r))
{
idDelete(&M);
M=idCopy(r);
}
}
return r;
}
ideal kMin_std(ideal F, ideal Q, tHomog h,intvec ** w, ideal &M, intvec *hilb,
int syzComp, int reduced)
{
bigintmat *hh=iv2biv(hilb,coeffs_BIGINT);
ideal res=kMin_std2(F,Q,h,w,M,hh,syzComp,reduced);
if (hh!=NULL) delete hh;
return res;
}
poly kNF(ideal F, ideal Q, poly p,int syzComp, int lazyReduce)
{
if (p==NULL)
return NULL;
poly pp = p;
#ifdef HAVE_PLURAL
if(rIsSCA(currRing))
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing);
if(Q == currRing->qideal)
Q = SCAQuotient(currRing);
}
#endif
if(idIs0(Q)) Q=NULL;
if ((idIs0(F))&&(Q==NULL))
{
#ifdef HAVE_PLURAL
if(p != pp)
return pp;
#endif
return pCopy(p); /*F+Q=0*/
}
kStrategy strat=new skStrategy;
strat->syzComp = syzComp;
strat->ak = si_max(id_RankFreeModule(F,currRing),pMaxComp(p));
poly res;
if (rHasLocalOrMixedOrdering(currRing))
{
#ifdef HAVE_SHIFTBBA
if (currRing->isLPring)
{
WerrorS("No local ordering possible for shift algebra");
return(NULL);
}
#endif
res=kNF1(F,Q,pp,strat,lazyReduce);
}
else
res=kNF2(F,Q,pp,strat,lazyReduce);
delete(strat);
#ifdef HAVE_PLURAL
if(pp != p)
p_Delete(&pp, currRing);
#endif
return res;
}
poly kNFBound(ideal F, ideal Q, poly p,int bound,int syzComp, int lazyReduce)
{
if (p==NULL)
return NULL;
poly pp = p;
#ifdef HAVE_PLURAL
if(rIsSCA(currRing))
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing);
if(Q == currRing->qideal)
Q = SCAQuotient(currRing);
}
#endif
if ((idIs0(F))&&(Q==NULL))
{
#ifdef HAVE_PLURAL
if(p != pp)
return pp;
#endif
return pCopy(p); /*F+Q=0*/
}
kStrategy strat=new skStrategy;
strat->syzComp = syzComp;
strat->ak = si_max(id_RankFreeModule(F,currRing),pMaxComp(p));
poly res;
res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
delete(strat);
#ifdef HAVE_PLURAL
if(pp != p)
p_Delete(&pp, currRing);
#endif
return res;
}
ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce)
{
ideal res;
if (TEST_OPT_PROT)
{
Print("(S:%d)",IDELEMS(p));mflush();
}
if (idIs0(p))
return idInit(IDELEMS(p),si_max(p->rank,F->rank));
ideal pp = p;
#ifdef HAVE_PLURAL
if(rIsSCA(currRing))
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false);
if(Q == currRing->qideal)
Q = SCAQuotient(currRing);
}
#endif
if (idIs0(Q)) Q=NULL;
if ((idIs0(F))&&(Q==NULL))
{
#ifdef HAVE_PLURAL
if(p != pp)
return pp;
#endif
return idCopy(p); /*F+Q=0*/
}
kStrategy strat=new skStrategy;
strat->syzComp = syzComp;
strat->ak = si_max(id_RankFreeModule(F,currRing),id_RankFreeModule(p,currRing));
if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
{
strat->ak = si_max(strat->ak,(int)F->rank);
}
if (rHasLocalOrMixedOrdering(currRing))
{
#ifdef HAVE_SHIFTBBA
if (currRing->isLPring)
{
WerrorS("No local ordering possible for shift algebra");
return(NULL);
}
#endif
res=kNF1(F,Q,pp,strat,lazyReduce);
}
else
res=kNF2(F,Q,pp,strat,lazyReduce);
delete(strat);
#ifdef HAVE_PLURAL
if(pp != p)
id_Delete(&pp, currRing);
#endif
return res;
}
ideal kNFBound(ideal F, ideal Q, ideal p,int bound,int syzComp,int lazyReduce)
{
ideal res;
if (TEST_OPT_PROT)
{
Print("(S:%d)",IDELEMS(p));mflush();
}
if (idIs0(p))
return idInit(IDELEMS(p),si_max(p->rank,F->rank));
ideal pp = p;
#ifdef HAVE_PLURAL
if(rIsSCA(currRing))
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false);
if(Q == currRing->qideal)
Q = SCAQuotient(currRing);
}
#endif
if ((idIs0(F))&&(Q==NULL))
{
#ifdef HAVE_PLURAL
if(p != pp)
return pp;
#endif
return idCopy(p); /*F+Q=0*/
}
kStrategy strat=new skStrategy;
strat->syzComp = syzComp;
strat->ak = si_max(id_RankFreeModule(F,currRing),id_RankFreeModule(p,currRing));
if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst
{
strat->ak = si_max(strat->ak,(int)F->rank);
}
res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce);
delete(strat);
#ifdef HAVE_PLURAL
if(pp != p)
id_Delete(&pp, currRing);
#endif
return res;
}
poly k_NF (ideal F, ideal Q, poly p,int syzComp, int lazyReduce, const ring _currRing)
{
const ring save = currRing;
if( currRing != _currRing ) rChangeCurrRing(_currRing);
poly ret = kNF(F, Q, p, syzComp, lazyReduce);
if( currRing != save ) rChangeCurrRing(save);
return ret;
}
/*2
*interreduces F
*/
// old version
ideal kInterRedOld (ideal F,const ideal Q)
{
int j;
kStrategy strat = new skStrategy;
ideal tempF = F;
ideal tempQ = Q;
#ifdef HAVE_PLURAL
if(rIsSCA(currRing))
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
// this should be done on the upper level!!! :
// tempQ = SCAQuotient(currRing);
if(Q == currRing->qideal)
tempQ = SCAQuotient(currRing);
}
#endif
// if (TEST_OPT_PROT)
// {
// writeTime("start InterRed:");
// mflush();
// }
//strat->syzComp = 0;
strat->kAllAxis = (currRing->ppNoether) != NULL;
strat->kNoether=pCopy((currRing->ppNoether));
strat->ak = 0;
if (id_IsModule(tempF,currRing)) strat->ak = id_RankFreeModule(tempF,currRing);
initBuchMoraCrit(strat);
strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN));
for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE;
strat->enterS = enterSBba;
strat->posInT = posInT17;
strat->initEcart = initEcartNormal;
strat->sl = -1;
strat->tl = -1;
strat->tmax = setmaxT;
strat->T = initT();
strat->R = initR();
strat->sevT = initsevT();
if (rHasLocalOrMixedOrdering(currRing)) strat->honey = TRUE;
initS(tempF, tempQ, strat);
if (TEST_OPT_REDSB)
strat->noTailReduction=FALSE;
updateS(TRUE,strat);
if (TEST_OPT_REDSB && TEST_OPT_INTSTRATEGY)
completeReduce(strat);
//else if (TEST_OPT_PROT) PrintLn();
cleanT(strat);
if (strat->kNoether!=NULL) pLmFree(&strat->kNoether);
omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN));
omfree(strat->sevT);
omfree(strat->S_2_R);
omfree(strat->R);
if (strat->fromQ)
{
for (j=IDELEMS(strat->Shdl)-1;j>=0;j--)
{
if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]);
}
omFree((ADDRESS)strat->fromQ);
strat->fromQ=NULL;
}
// if (TEST_OPT_PROT)
// {
// writeTime("end Interred:");
// mflush();
// }
ideal shdl=strat->Shdl;
idSkipZeroes(shdl);
if (strat->fromQ)
{
omfree(strat->fromQ);
strat->fromQ=NULL;
ideal res=kInterRed(shdl,NULL);
idDelete(&shdl);
shdl=res;
}
delete(strat);
#ifdef HAVE_PLURAL
if( tempF != F )
id_Delete( &tempF, currRing);
#endif
return shdl;
}
// new version
ideal kInterRedBba (ideal F, ideal Q, int &need_retry)
{
need_retry=0;
int red_result = 1;
int olddeg,reduc;
// BOOLEAN withT = FALSE;
// BOOLEAN toReset=FALSE;
kStrategy strat=new skStrategy;
tHomog h;
if (rField_has_simple_inverse(currRing))
strat->LazyPass=20;
else
strat->LazyPass=2;
strat->LazyDegree = 1;
strat->ak = id_RankFreeModule(F,currRing);
strat->syzComp = strat->ak;
strat->kModW=kModW=NULL;
strat->kHomW=kHomW=NULL;
if (strat->ak == 0)
{
h = (tHomog)idHomIdeal(F,Q);
}
else if (!TEST_OPT_DEGBOUND)
{
h = (tHomog)idHomIdeal(F,Q);
}
else
h = isNotHomog;
if (h==isHomog)
{
strat->LazyPass*=2;
}
strat->homog=h;
#ifdef KDEBUG
idTest(F);
#endif
initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
if(rField_is_Ring(currRing))
initBuchMoraPosRing(strat);
else
initBuchMoraPos(strat);
initBba(strat);
/*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
strat->posInL=posInL0; /* ord according pComp */
/*Shdl=*/initBuchMora(F, Q, strat);
reduc = olddeg = 0;
#ifndef NO_BUCKETS
if (!TEST_OPT_NOT_BUCKETS)
strat->use_buckets = 1;
#endif
// redtailBBa against T for inhomogeneous input
//if (!TEST_OPT_OLDSTD)
// withT = ! strat->homog;
// strat->posInT = posInT_pLength;
kTest_TS(strat);
#ifdef HAVE_TAIL_RING
kStratInitChangeTailRing(strat);
#endif
/* compute------------------------------------------------------- */
while (strat->Ll >= 0)
{
#ifdef KDEBUG
if (TEST_OPT_DEBUG) messageSets(strat);
#endif
if (strat->Ll== 0) strat->interpt=TRUE;
/* picks the last element from the lazyset L */
strat->P = strat->L[strat->Ll];
strat->Ll--;
if (strat->P.p1 == NULL)
{
// for input polys, prepare reduction
strat->P.PrepareRed(strat->use_buckets);
}
if (strat->P.p == NULL && strat->P.t_p == NULL)
{
red_result = 0;
}
else
{
if (TEST_OPT_PROT)
message(strat->P.pFDeg(),
&olddeg,&reduc,strat, red_result);
/* reduction of the element chosen from L */
red_result = strat->red(&strat->P,strat);
}
// reduction to non-zero new poly
if (red_result == 1)
{
/* statistic */
if (TEST_OPT_PROT) PrintS("s");
// get the polynomial (canonicalize bucket, make sure P.p is set)
strat->P.GetP(strat->lmBin);
int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
// reduce the tail and normalize poly
// in the ring case we cannot expect LC(f) = 1,
// therefore we call pCleardenom instead of pNorm
if (TEST_OPT_INTSTRATEGY)
{
strat->P.pCleardenom();
}
else
{
strat->P.pNorm();
}
#ifdef KDEBUG
if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
#endif
// enter into S, L, and T
if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
{
enterT(&strat->P, strat);
// posInS only depends on the leading term
strat->enterS(&strat->P, pos, strat, strat->tl);
if (pos<strat->sl)
{
need_retry++;
// move all "larger" elements fromS to L
// remove them from T
int ii=pos+1;
for(;ii<=strat->sl;ii++)
{
LObject h;
h.Clear();
h.tailRing=strat->tailRing;
h.p=strat->S[ii]; strat->S[ii]=NULL;
strat->initEcart(&h);
h.sev=strat->sevS[ii];
int jj=strat->tl;
while (jj>=0)
{
if (strat->T[jj].p==h.p)
{
strat->T[jj].p=NULL;
if (jj<strat->tl)
{
memmove(&(strat->T[jj]),&(strat->T[jj+1]),
(strat->tl-jj)*sizeof(strat->T[jj]));
memmove(&(strat->sevT[jj]),&(strat->sevT[jj+1]),
(strat->tl-jj)*sizeof(strat->sevT[jj]));
}
strat->tl--;
break;
}
jj--;
}
int lpos=strat->posInL(strat->L,strat->Ll,&h,strat);
enterL(&strat->L,&strat->Ll,&strat->Lmax,h,lpos);
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
Print("move S[%d] -> L[%d]: ",ii,pos);
p_wrp(h.p,currRing, strat->tailRing);
PrintLn();
}
#endif
}
if (strat->fromQ!=NULL)
{
for(ii=pos+1;ii<=strat->sl;ii++) strat->fromQ[ii]=0;
}
strat->sl=pos;
}
}
else
{
// clean P
}
kDeleteLcm(&strat->P);
}
#ifdef KDEBUG
if (TEST_OPT_DEBUG)
{
messageSets(strat);
}
strat->P.Clear();
#endif
//kTest_TS(strat);: i_r out of sync in kInterRedBba, but not used!
}
#ifdef KDEBUG
//if (TEST_OPT_DEBUG) messageSets(strat);
#endif
/* complete reduction of the standard basis--------- */
if((need_retry<=0) && (TEST_OPT_REDSB))
{
completeReduce(strat);
if (strat->completeReduce_retry)
{
// completeReduce needed larger exponents, retry
// hopefully: kStratChangeTailRing already provided a larger tailRing
// (otherwise: it will fail again)
strat->completeReduce_retry=FALSE;
completeReduce(strat);
if (strat->completeReduce_retry)
{
#ifdef HAVE_TAIL_RING
if(currRing->bitmask>strat->tailRing->bitmask)
{
// retry without T
strat->completeReduce_retry=FALSE;
cleanT(strat);strat->tailRing=currRing;
int i;
for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
completeReduce(strat);
}
if (strat->completeReduce_retry)
#endif
Werror("exponent bound is %ld",currRing->bitmask);
}
}
}
else if (TEST_OPT_PROT) PrintLn();
/* release temp data-------------------------------- */
exitBuchMora(strat);
// if (TEST_OPT_WEIGHTM)
// {
// pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg);
// if (ecartWeights)
// {
// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
// ecartWeights=NULL;
// }
// }
//if (TEST_OPT_PROT) messageStat(0/*hilbcount*/,strat);
if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
ideal res=strat->Shdl;
strat->Shdl=NULL;
delete strat;
return res;
}
ideal kInterRed (ideal F,const ideal Q)
{
#ifdef HAVE_PLURAL
if(rIsPluralRing(currRing)) return kInterRedOld(F,Q);
#endif
if ((rHasLocalOrMixedOrdering(currRing))|| (rField_is_numeric(currRing))
||(rField_is_Ring(currRing))
)
return kInterRedOld(F,Q);
//return kInterRedOld(F,Q);
BITSET save1;
SI_SAVE_OPT1(save1);
//si_opt_1|=Sy_bit(OPT_NOT_SUGAR);
si_opt_1|=Sy_bit(OPT_REDTHROUGH);
//si_opt_1&= ~Sy_bit(OPT_REDTAIL);
//si_opt_1&= ~Sy_bit(OPT_REDSB);
//extern char * showOption() ;
//Print("%s\n",showOption());
int need_retry;
int counter=3;
ideal res, res1;
int elems=0;
ideal null=NULL;
if ((Q==NULL) || (!TEST_OPT_REDSB))
{
elems=idElem(F);
res=kInterRedBba(F,Q,need_retry);
}
else
{
ideal FF=idSimpleAdd(F,Q);
res=kInterRedBba(FF,NULL,need_retry);
idDelete(&FF);
null=idInit(1,1);
if (need_retry)
res1=kNF(null,Q,res,0,KSTD_NF_LAZY | KSTD_NF_NONORM);
else
res1=kNF(null,Q,res);
idDelete(&res);
res=res1;
need_retry=1;
}
if (idElem(res)<=1) need_retry=0;
while (need_retry && (counter>0))
{
#ifdef KDEBUG
if (TEST_OPT_DEBUG) { Print("retry counter %d\n",counter); }
#endif
res1=kInterRedBba(res,Q,need_retry);
int new_elems=idElem(res1);
counter -= (new_elems >= elems);
elems = new_elems;
idDelete(&res);
if (idElem(res1)<=1) need_retry=0;
if ((Q!=NULL) && (TEST_OPT_REDSB))
{
if (need_retry)
res=kNF(null,Q,res1,0,KSTD_NF_LAZY | KSTD_NF_NONORM);
else
res=kNF(null,Q,res1);
idDelete(&res1);
}
else
res = res1;
if (idElem(res)<=1) need_retry=0;
}
if (null!=NULL) idDelete(&null);
SI_RESTORE_OPT1(save1);
idSkipZeroes(res);
return res;
}
// returns TRUE if mora should use buckets, false otherwise
static BOOLEAN kMoraUseBucket(kStrategy strat)
{
#ifdef MORA_USE_BUCKETS
if (TEST_OPT_NOT_BUCKETS)
return FALSE;
if ((strat->red == redFirst)
||((strat->red == redEcart)&&(strat->kNoether!=NULL)))
{
#ifdef NO_LDEG
if (strat->syzComp==0)
return TRUE;
#else
if ((strat->homog || strat->honey) && (strat->syzComp==0))
return TRUE;
#endif
}
else
{
assume(strat->red == redEcart || strat->red == redRiloc || strat->red == redRiloc_Z);
if (strat->honey && (strat->syzComp==0))
return TRUE;
}
#endif
return FALSE;
}
BITSET
#define BITSET
Definition auxiliary.h:85
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
UNLIKELY
#define UNLIKELY(X)
Definition auxiliary.h:405
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
bound
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
intvec
Definition intvec.h:24
skStrategy
Definition kutil.h:276
skStrategy::kNoetherTail
KINLINE poly kNoetherTail()
Definition kInline.h:66
skStrategy::kModW
intvec * kModW
Definition kutil.h:334
skStrategy::sigdrop
bool sigdrop
Definition kutil.h:357
skStrategy::syzComp
int syzComp
Definition kutil.h:353
skStrategy::S_2_R
int * S_2_R
Definition kutil.h:341
skStrategy::tailRing
ring tailRing
Definition kutil.h:342
skStrategy::chainCrit
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition kutil.h:290
skStrategy::noTailReduction
char noTailReduction
Definition kutil.h:375
skStrategy::currIdx
int currIdx
Definition kutil.h:316
skStrategy::posInLOldFlag
char posInLOldFlag
Definition kutil.h:379
skStrategy::pOrigFDeg_TailRing
pFDegProc pOrigFDeg_TailRing
Definition kutil.h:297
skStrategy::Ll
int Ll
Definition kutil.h:350
skStrategy::T
TSet T
Definition kutil.h:325
skStrategy::rewCrit1
BOOLEAN(* rewCrit1)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:292
skStrategy::lmBin
omBin lmBin
Definition kutil.h:343
skStrategy::ecartS
intset ecartS
Definition kutil.h:308
skStrategy::honey
char honey
Definition kutil.h:374
skStrategy::rightGB
char rightGB
Definition kutil.h:366
skStrategy::S
polyset S
Definition kutil.h:305
skStrategy::minim
int minim
Definition kutil.h:356
skStrategy::kNoether
poly kNoether
Definition kutil.h:328
skStrategy::NotUsedAxis
BOOLEAN * NotUsedAxis
Definition kutil.h:331
skStrategy::B
LSet B
Definition kutil.h:327
skStrategy::ak
int ak
Definition kutil.h:352
skStrategy::R
TObject ** R
Definition kutil.h:339
skStrategy::rewCrit3
BOOLEAN(* rewCrit3)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:294
skStrategy::lastAxis
int lastAxis
Definition kutil.h:354
skStrategy::M
ideal M
Definition kutil.h:304
skStrategy::tl
int tl
Definition kutil.h:349
skStrategy::red2
int(* red2)(LObject *L, kStrategy strat)
Definition kutil.h:280
skStrategy::sevT
unsigned long * sevT
Definition kutil.h:324
skStrategy::kHomW
intvec * kHomW
Definition kutil.h:335
skStrategy::tail
poly tail
Definition kutil.h:333
skStrategy::posInL
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:283
skStrategy::blockred
int blockred
Definition kutil.h:362
skStrategy::Shdl
ideal Shdl
Definition kutil.h:302
skStrategy::sbaOrder
unsigned sbaOrder
Definition kutil.h:315
skStrategy::pOrigFDeg
pFDegProc pOrigFDeg
Definition kutil.h:295
skStrategy::blockredmax
int blockredmax
Definition kutil.h:363
skStrategy::tmax
int tmax
Definition kutil.h:349
skStrategy::posInLOld
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition kutil.h:287
skStrategy::LDegLast
char LDegLast
Definition kutil.h:382
skStrategy::initEcartPair
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition kutil.h:286
skStrategy::enterS
void(* enterS)(LObject *h, int pos, kStrategy strat, int atR)
Definition kutil.h:285
skStrategy::kAllAxis
char kAllAxis
Definition kutil.h:373
skStrategy::fromQ
intset fromQ
Definition kutil.h:320
skStrategy::use_buckets
char use_buckets
Definition kutil.h:380
skStrategy::interpt
char interpt
Definition kutil.h:368
skStrategy::newIdeal
int newIdeal
Definition kutil.h:355
skStrategy::fromT
char fromT
Definition kutil.h:376
skStrategy::completeReduce_retry
char completeReduce_retry
Definition kutil.h:400
skStrategy::initEcart
void(* initEcart)(TObject *L)
Definition kutil.h:281
skStrategy::P
LObject P
Definition kutil.h:301
skStrategy::noClearS
char noClearS
Definition kutil.h:399
skStrategy::Lmax
int Lmax
Definition kutil.h:350
skStrategy::z2homog
char z2homog
Definition kutil.h:371
skStrategy::LazyPass
int LazyPass
Definition kutil.h:352
skStrategy::no_prod_crit
char no_prod_crit
Definition kutil.h:391
skStrategy::overflow
char overflow
Definition kutil.h:401
skStrategy::enterOnePair
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition kutil.h:289
skStrategy::L
LSet L
Definition kutil.h:326
skStrategy::length_pLength
char length_pLength
Definition kutil.h:384
skStrategy::posInT
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
skStrategy::red
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:279
skStrategy::rewCrit2
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
Definition kutil.h:293
skStrategy::sl
int sl
Definition kutil.h:347
skStrategy::sbaEnterS
int sbaEnterS
Definition kutil.h:360
skStrategy::LazyDegree
int LazyDegree
Definition kutil.h:352
skStrategy::posInLDependsOnLength
char posInLDependsOnLength
Definition kutil.h:386
skStrategy::sevS
unsigned long * sevS
Definition kutil.h:321
skStrategy::homog
char homog
Definition kutil.h:369
skStrategy::pOrigLDeg
pLDegProc pOrigLDeg
Definition kutil.h:296
skStrategy::update
char update
Definition kutil.h:378
skStrategy::s_poly
s_poly_proc_t s_poly
Definition kutil.h:299
skStrategy::pOrigLDeg_TailRing
pLDegProc pOrigLDeg_TailRing
Definition kutil.h:298
nCoeff_is_Z
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition coeffs.h:811
n_IsUnit
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition coeffs.h:521
n_QuotRem
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition coeffs.h:684
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
n_DivBy
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition coeffs.h:750
Print
#define Print
Definition emacs.cc:80
WarnS
#define WarnS
Definition emacs.cc:78
result
return result
Definition facAbsBiFact.cc:76
res
CanonicalForm res
Definition facAbsFact.cc:60
w
const CanonicalForm & w
Definition facAbsFact.cc:51
H
CanonicalForm H
Definition facAbsFact.cc:60
j
int j
Definition facHensel.cc:110
errorreported
VAR short errorreported
Definition feFopen.cc:23
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
VAR
#define VAR
Definition globaldefs.h:5
scMult0Int
long scMult0Int(ideal S, ideal Q)
Definition hdegree.cc:924
last
STATIC_VAR poly last
Definition hdegree.cc:1138
idMinBase
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
ideals.h
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
idSimpleAdd
#define idSimpleAdd(A, B)
Definition ideals.h:42
idInsertPoly
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
Definition simpleideals.cc:832
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition simpleideals.cc:960
idHomModule
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
idTest
#define idTest(id)
Definition ideals.h:47
idHomIdeal
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
idCopy
ideal idCopy(ideal A)
Definition ideals.h:60
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
iv2biv
bigintmat * iv2biv(intvec *hilb, const coeffs cf)
Definition intvec.cc:851
intvec.h
h
STATIC_VAR Poly * h
Definition janet.cc:971
kInline.h
initT
KINLINE TSet initT()
Definition kInline.h:84
initR
KINLINE TObject ** initR()
Definition kInline.h:95
arriRewDummy
KINLINE BOOLEAN arriRewDummy(poly, unsigned long, poly, kStrategy, int)
Definition kInline.h:1258
initsevT
KINLINE unsigned long * initsevT()
Definition kInline.h:100
redLiftstd
int redLiftstd(LObject *h, kStrategy strat)
Definition kLiftstd.cc:167
nc.h
nc_GB
static ideal nc_GB(const ideal F, const ideal Q, const intvec *w, const bigintmat *hilb, kStrategy strat, const ring r)
Definition nc.h:27
khCheck
void khCheck(ideal Q, intvec *w, bigintmat *hilb, int &eledeg, int &count, kStrategy strat)
Definition khstd.cc:28
khCheckLocInhom
void khCheckLocInhom(ideal Q, intvec *w, bigintmat *hilb, int &count, kStrategy strat)
Definition khstd.cc:248
khstd.h
ksReducePolyLC
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition kspoly.cc:477
ksCreateSpoly
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition kspoly.cc:1203
ksReducePoly
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat, BOOLEAN reduce)
Definition kspoly.cc:187
kHomModDeg
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2421
kNFBound
poly kNFBound(ideal F, ideal Q, poly p, int bound, int syzComp, int lazyReduce)
Definition kstd1.cc:3285
initMora
void initMora(ideal F, kStrategy strat)
Definition kstd1.cc:1820
redFirst
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:794
kModDeg
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2411
k_NF
poly k_NF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce, const ring _currRing)
NOTE: this is just a wrapper which sets currRing for the actual kNF call.
Definition kstd1.cc:3443
redEcart
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
enterSMora
void enterSMora(LObject *p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1629
kStd_internal
ideal kStd_internal(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
pure GB/SB computations
Definition kstd1.cc:2434
hasPurePower
static BOOLEAN hasPurePower(const poly p, int last, int *length, kStrategy strat)
Definition kstd1.cc:1312
doRed
static int doRed(LObject *h, TObject *with, BOOLEAN intoT, kStrategy strat, bool redMoraNF)
Definition kstd1.cc:118
firstUpdate
static void firstUpdate(kStrategy strat)
Definition kstd1.cc:1566
kMin_std
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition kstd1.cc:3221
updateL
static void updateL(BOOLEAN searchPP, kStrategy strat)
Definition kstd1.cc:1394
kStdShift
ideal kStdShift(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, BOOLEAN rightGB)
Definition kstd1.cc:2964
updateT
static void updateT(kStrategy strat)
Definition kstd1.cc:1540
missingAxis
static void missingAxis(int *last, kStrategy strat)
Definition kstd1.cc:1279
updateLHC
static void updateLHC(kStrategy strat)
Definition kstd1.cc:1474
posInL10
int posInL10(const LSet set, const int length, LObject *p, const kStrategy strat)
Definition kstd1.cc:1360
kInterRedBba
ideal kInterRedBba(ideal F, ideal Q, int &need_retry)
Definition kstd1.cc:3551
kMin_std2
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3069
kMoraUseBucket
static BOOLEAN kMoraUseBucket(kStrategy strat)
Definition kstd1.cc:3878
kNF1
poly kNF1(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
Definition kstd1.cc:2119
kInterRed
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3802
kOptimizeLDeg
static void kOptimizeLDeg(pLDegProc ldeg, kStrategy strat)
Definition kstd1.cc:100
initBba
void initBba(kStrategy strat)
Definition kstd1.cc:1690
mora
ideal mora(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd1.cc:1887
redRiloc
int redRiloc(LObject *h, kStrategy strat)
Definition kstd1.cc:385
kStd2
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2607
initSba
void initSba(ideal F, kStrategy strat)
Definition kstd1.cc:1750
redMoraNFRing
static poly redMoraNFRing(poly h, kStrategy strat, int flag)
Definition kstd1.cc:1080
reorderL
static void reorderL(kStrategy strat)
Definition kstd1.cc:1222
kSba
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw)
Definition kstd1.cc:2668
kDebugPrint
void kDebugPrint(kStrategy strat)
Definition kutil.cc:11478
kHomW
VAR intvec * kHomW
Definition kstd1.cc:2409
kModW
VAR intvec * kModW
Definition kstd1.cc:2409
kInterRedOld
ideal kInterRedOld(ideal F, const ideal Q)
Definition kstd1.cc:3456
validOpts
VAR BITSET validOpts
Definition kstd1.cc:60
reorderT
static void reorderT(kStrategy strat)
Definition kstd1.cc:1241
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3229
redMoraNF
static poly redMoraNF(poly h, kStrategy strat, int flag)
Definition kstd1.cc:976
kOptions
VAR BITSET kOptions
Definition kstd1.cc:45
redRiloc_Z
int redRiloc_Z(LObject *h, kStrategy strat)
Definition kstd1.cc:566
enterSMoraNF
void enterSMoraNF(LObject *p, int atS, kStrategy strat, int atR)
Definition kstd1.cc:1682
kStd
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations
Definition kstd1.cc:2659
kstd1.h
KSTD_NF_LAZY
#define KSTD_NF_LAZY
Definition kstd1.h:18
Kstd1_deg
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
KSTD_NF_NONORM
#define KSTD_NF_NONORM
Definition kstd1.h:22
KSTD_NF_CANCELUNIT
#define KSTD_NF_CANCELUNIT
Definition kstd1.h:24
s_poly_proc_t
BOOLEAN(* s_poly_proc_t)(kStrategy strat)
Definition kstd1.h:15
KSTD_NF_ECART
#define KSTD_NF_ECART
Definition kstd1.h:20
Kstd1_mu
EXTERN_VAR int Kstd1_mu
Definition kstd1.h:70
kTryHC
poly kTryHC(ideal F, ideal Q)
Definition kstdhelper.cc:38
kTryHilbstd
ideal kTryHilbstd(ideal F, ideal Q)
Definition kstdhelper.cc:323
redRing_Z
int redRing_Z(LObject *h, kStrategy strat)
Definition kstd2.cc:720
sba
ideal sba(ideal F0, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:2971
kFindDivisibleByInS
int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject *L)
return -1 if no divisor is found number of first divisor in S, otherwise
Definition kstd2.cc:464
kTestDivisibleByT0_Z
int kTestDivisibleByT0_Z(const kStrategy strat, const LObject *L)
tests if T[0] divides the leading monomial of L, returns -1 if not
Definition kstd2.cc:142
kNF2
poly kNF2(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
Definition kstd2.cc:3927
redHoney
int redHoney(LObject *h, kStrategy strat)
Definition kstd2.cc:2110
redHomog
int redHomog(LObject *h, kStrategy strat)
Definition kstd2.cc:1150
redLazy
int redLazy(LObject *h, kStrategy strat)
Definition kstd2.cc:1905
redSigRing
int redSigRing(LObject *h, kStrategy strat)
Definition kstd2.cc:1536
bbaShift
ideal bbaShift(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:4577
redSig
int redSig(LObject *h, kStrategy strat)
Definition kstd2.cc:1369
kNF2Bound
poly kNF2Bound(ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
Definition kstd2.cc:4015
redRing
int redRing(LObject *h, kStrategy strat)
Definition kstd2.cc:988
kFindDivisibleByInT
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:317
bba
ideal bba(ideal F, ideal Q, intvec *w, bigintmat *hilb, kStrategy strat)
Definition kstd2.cc:2614
redtail
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:6836
posInT17
int posInT17(const TSet set, const int length, LObject &p)
Definition kutil.cc:5278
initBuchMora
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9749
HCord
VAR int HCord
Definition kutil.cc:239
arriRewCriterionPre
BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int)
Definition kutil.cc:6646
enterSBba
void enterSBba(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8792
message
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7463
arriRewCriterion
BOOLEAN arriRewCriterion(poly, unsigned long, poly, kStrategy strat, int start=0)
Definition kutil.cc:6621
kTest
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1004
enterT_strong
void enterT_strong(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:9242
kTest_TS
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1067
enterOnePairNormal
void enterOnePairNormal(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR=-1)
Definition kutil.cc:1939
enterL
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1269
faugereRewCriterion
BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly, kStrategy strat, int start=0)
Definition kutil.cc:6562
posInT2
int posInT2(const TSet set, const int length, LObject &p)
Definition kutil.cc:4925
enterpairs
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4487
initEcartPairMora
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition kutil.cc:1315
initBuchMoraPos
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9580
initS
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7586
kStratChangeTailRing
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
Definition kutil.cc:10939
posInL0
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition kutil.cc:5611
chainCritOpt_1
void chainCritOpt_1(poly, int, kStrategy strat)
Definition kutil.cc:3445
postReduceByMon
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
Definition kutil.cc:10682
HEckeTest
void HEckeTest(poly pp, kStrategy strat)
Definition kutil.cc:493
kTest_L
BOOLEAN kTest_L(LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
Definition kutil.cc:916
exitBuchMora
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9837
initEcartNormal
void initEcartNormal(TObject *h)
Definition kutil.cc:1293
posInS
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4663
updateS
void updateS(BOOLEAN toT, kStrategy strat)
Definition kutil.cc:8557
kCheckSpolyCreation
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
Definition kutil.cc:10459
enterT
void enterT(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:9143
cleanT
void cleanT(kStrategy strat)
Definition kutil.cc:557
kTest_T
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
Definition kutil.cc:789
deleteHC
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
Definition kutil.cc:286
updateResult
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10051
superenterpairs
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4457
deleteInL
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1208
kStratInitChangeTailRing
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11036
initBuchMoraCrit
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9435
completeReduce
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10257
initBuchMoraPosRing
void initBuchMoraPosRing(kStrategy strat)
Definition kutil.cc:9664
enterSSba
void enterSSba(LObject *p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8915
messageSets
void messageSets(kStrategy strat)
Definition kutil.cc:7536
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 const...
Definition kutil.cc:10518
chainCritNormal
void chainCritNormal(poly p, int ecart, kStrategy strat)
Definition kutil.cc:3204
initEcartBBA
void initEcartBBA(TObject *h)
Definition kutil.cc:1301
initEcartPairBba
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition kutil.cc:1308
messageStat
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7504
finalReduceByMon
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
Definition kutil.cc:10847
newHEdge
BOOLEAN newHEdge(kStrategy strat)
Definition kutil.cc:10379
cancelunit
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365
initHilbCrit
void initHilbCrit(ideal, ideal, bigintmat **hilb, kStrategy strat)
Definition kutil.cc:9417
kutil.h
LSet
LObject * LSet
Definition kutil.h:61
kDeleteLcm
static void kDeleteLcm(LObject *P)
Definition kutil.h:876
setmaxT
#define setmaxT
Definition kutil.h:34
RED_CANONICALIZE
#define RED_CANONICALIZE
Definition kutil.h:37
TObject
class sTObject TObject
Definition kutil.h:58
LObject
class sLObject LObject
Definition kutil.h:59
nc.h
rIsSCA
static bool rIsSCA(const ring r)
Definition nc.h:190
id_KillSquares
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
Definition sca.cc:1518
p_KillSquares
poly p_KillSquares(const poly p, const short iFirstAltVar, const short iLastAltVar, const ring r)
Definition sca.cc:1463
mult
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:647
mod2.h
assume
#define assume(x)
Definition mod2.h:389
p_GetComp
#define p_GetComp(p, r)
Definition monomials.h:64
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
pGetCoeff
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
__p_GetComp
#define __p_GetComp(p, r)
Definition monomials.h:63
ndQuotRem
number ndQuotRem(number a, number b, number *r, const coeffs R)
Definition numbers.cc:356
nEqual
#define nEqual(n1, n2)
Definition numbers.h:20
omfree
#define omfree(addr)
Definition omAllocDecl.h:237
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omTestMemory
omError_t omTestMemory(int check_level)
Definition omDebug.c:94
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
NULL
#define NULL
Definition omList.c:12
siCntrlc
VAR BOOLEAN siCntrlc
Definition options.c:14
si_opt_1
VAR unsigned si_opt_1
Definition options.c:5
options.h
TEST_OPT_WEIGHTM
#define TEST_OPT_WEIGHTM
Definition options.h:123
OPT_SUGARCRIT
#define OPT_SUGARCRIT
Definition options.h:81
OPT_PROT
#define OPT_PROT
Definition options.h:76
OPT_INFREDTAIL
#define OPT_INFREDTAIL
Definition options.h:95
OPT_INTSTRATEGY
#define OPT_INTSTRATEGY
Definition options.h:93
TEST_OPT_IDLIFT
#define TEST_OPT_IDLIFT
Definition options.h:131
TEST_OPT_INTSTRATEGY
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
BVERBOSE
#define BVERBOSE(a)
Definition options.h:35
OPT_WEIGHTM
#define OPT_WEIGHTM
Definition options.h:98
TEST_OPT_FINDET
#define TEST_OPT_FINDET
Definition options.h:113
OPT_REDTAIL
#define OPT_REDTAIL
Definition options.h:92
SI_SAVE_OPT1
#define SI_SAVE_OPT1(A)
Definition options.h:21
SI_RESTORE_OPT1
#define SI_RESTORE_OPT1(A)
Definition options.h:24
OPT_NOT_SUGAR
#define OPT_NOT_SUGAR
Definition options.h:79
TEST_OPT_OLDSTD
#define TEST_OPT_OLDSTD
Definition options.h:125
OPT_REDTHROUGH
#define OPT_REDTHROUGH
Definition options.h:83
OPT_REDSB
#define OPT_REDSB
Definition options.h:77
Sy_bit
#define Sy_bit(x)
Definition options.h:31
TEST_OPT_REDSB
#define TEST_OPT_REDSB
Definition options.h:106
OPT_NOTREGULARITY
#define OPT_NOTREGULARITY
Definition options.h:97
TEST_OPT_DEGBOUND
#define TEST_OPT_DEGBOUND
Definition options.h:115
TEST_OPT_SB_1
#define TEST_OPT_SB_1
Definition options.h:121
TEST_OPT_RETURN_SB
#define TEST_OPT_RETURN_SB
Definition options.h:114
TEST_OPT_MULTBOUND
#define TEST_OPT_MULTBOUND
Definition options.h:116
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
TEST_OPT_REDTHROUGH
#define TEST_OPT_REDTHROUGH
Definition options.h:124
OPT_INTERRUPT
#define OPT_INTERRUPT
Definition options.h:80
OPT_DEGBOUND
#define OPT_DEGBOUND
Definition options.h:91
TEST_V_DEG_STOP
#define TEST_V_DEG_STOP
Definition options.h:140
TEST_OPT_FASTHC
#define TEST_OPT_FASTHC
Definition options.h:111
TEST_OPT_DEBUG
#define TEST_OPT_DEBUG
Definition options.h:110
OPT_FASTHC
#define OPT_FASTHC
Definition options.h:86
TEST_OPT_REDTAIL_SYZ
#define TEST_OPT_REDTAIL_SYZ
Definition options.h:119
OPT_OLDSTD
#define OPT_OLDSTD
Definition options.h:87
TEST_OPT_STAIRCASEBOUND
#define TEST_OPT_STAIRCASEBOUND
Definition options.h:117
TEST_OPT_NOT_BUCKETS
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
pGetShallowCopyDeleteProc
pShallowCopyDeleteProc pGetShallowCopyDeleteProc(ring, ring)
Definition pShallowCopyDelete.cc:50
p_IsPurePower
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition p_polys.cc:1227
pRestoreDegProcs
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3774
pLDeg0c
long pLDeg0c(poly p, int *l, const ring r)
Definition p_polys.cc:771
pLDeg0
long pLDeg0(poly p, int *l, const ring r)
Definition p_polys.cc:740
pSetDegProcs
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3762
p_WDegree
long p_WDegree(poly p, const ring r)
Definition p_polys.cc:715
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
p_FDeg
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:382
p_MinComp
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:315
pp_Test
#define pp_Test(p, lmRing, tailRing)
Definition p_polys.h:163
p_LmShortDivisibleBy
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1931
p_GetExp
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
p_wrp
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition polys.cc:16
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
polys.h
Compatibility layer for legacy polynomial operations (over currRing).
pAdd
#define pAdd(p, q)
Definition polys.h:204
pTest
#define pTest(p)
Definition polys.h:415
pDelete
#define pDelete(p_ptr)
Definition polys.h:187
pHead
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
pSetm
#define pSetm(p)
Definition polys.h:272
pIsConstant
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
pGetComp
#define pGetComp(p)
Component.
Definition polys.h:38
pNorm
void pNorm(poly p)
Definition polys.h:363
pLmShortDivisibleBy
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
Definition polys.h:147
pMaxComp
#define pMaxComp(p)
Definition polys.h:300
pSetComp
#define pSetComp(p, v)
Definition polys.h:39
pLmDelete
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
pGetShortExpVector
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153
wrp
void wrp(poly p)
Definition polys.h:311
pLmFree
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
pSetmComp
#define pSetmComp(p)
TODO:
Definition polys.h:274
pNormalize
#define pNormalize(p)
Definition polys.h:318
pSetExp
#define pSetExp(p, i, v)
Definition polys.h:43
pLmCmp
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
pCopy
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
pOne
#define pOne()
Definition polys.h:316
pWTotaldegree
#define pWTotaldegree(p)
Definition polys.h:284
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
PrintLn
void PrintLn()
Definition reporter.cc:314
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
mflush
#define mflush()
Definition reporter.h:58
rHasBlockOrder
BOOLEAN rHasBlockOrder(const ring r)
Definition ring.cc:1924
rOrd_is_Ds
BOOLEAN rOrd_is_Ds(const ring r)
Definition ring.cc:2076
rOrd_is_ds
BOOLEAN rOrd_is_ds(const ring r)
Definition ring.cc:2066
rField_is_Z
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
rHasLocalOrMixedOrdering
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769
rHasGlobalOrdering
static BOOLEAN rHasGlobalOrdering(const ring r)
Definition ring.h:768
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
pLDegProc
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:38
rIsLPRing
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rIsNCRing
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
rField_is_numeric
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:521
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
rHasMixedOrdering
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:770
rField_has_simple_inverse
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:554
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491
sca.h
SCAQuotient
ideal SCAQuotient(const ring r)
Definition sca.h:10
scaLastAltVar
static short scaLastAltVar(ring r)
Definition sca.h:25
scaFirstAltVar
static short scaFirstAltVar(ring r)
Definition sca.h:18
shiftop.h
idIsInV
#define idIsInV(I)
Definition shiftop.h:49
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
id_IsModule
BOOLEAN id_IsModule(ideal A, const ring src)
Definition simpleideals.cc:1011
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition simpleideals.cc:992
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition simpleideals.cc:201
idIsMonomial
BOOLEAN idIsMonomial(ideal h)
returns true if h is generated by monomials
Definition simpleideals.cc:972
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
idElem
static int idElem(const ideal F)
number of non-zero polys in F
Definition simpleideals.h:69
M
#define M
Definition sirandom.c:25
Q
#define Q
Definition sirandom.c:26
stairc.h
tHomog
tHomog
Definition structs.h:31
isHomog
@ isHomog
Definition structs.h:33
testHomog
@ testHomog
Definition structs.h:34
isNotHomog
@ isNotHomog
Definition structs.h:32
kStrategy
skStrategy * kStrategy
Definition structs.h:54
loop
#define loop
Definition structs.h:71
totaldegreeWecart
long totaldegreeWecart(poly p, ring r)
Definition weight.cc:217
maxdegreeWecart
long maxdegreeWecart(poly p, int *l, ring r)
Definition weight.cc:247
kEcartWeights
void kEcartWeights(poly *s, int sl, short *eweight, const ring R)
Definition weight.cc:182
weight.h
ecartWeights
EXTERN_VAR short * ecartWeights
Definition weight.h:12