Loading...
Searching...
No Matches
khstd.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT:utils for hilbert driven kStd
*/
#include "kernel/mod2.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "polys/simpleideals.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/combinatorics/hilb.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/khstd.h"
#include "kernel/polys.h"
/*2
* compare the given hilbert series with the current one,
* delete not needed pairs (if possible)
*/
void khCheck( ideal Q, intvec *w, bigintmat *hilb, int &eledeg, int &count,
kStrategy strat)
/* ideal S=strat->Shdl, poly p=strat->P.p */
/*
* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
* p is already in S and for all further q going into S yields deg(q) >= deg(p),
* the real computation is only done if the degree has changed,
* then we have eledeg == 0 on this degree and we make:
* - compute the Hilbert series newhilb from S
* (hilb is the final Hilbert series)
* - in module case: check that all comp up to strat->ak are used
* - compute the eledeg from newhilb-hilb for the first degree deg with
* newhilb-hilb != 0
* (Remark: consider the Hilbert series with coeff. up to infinity)
* - clear the set L for degree < deg
* the number count is only for statistics (in the caller initialise count = 0),
* in order to get a first computation, initialise eledeg = 1 in the caller.
* The weights w are needed in the module case, otherwise NULL.
*/
{
bigintmat *newhilb;
int deg,l,ln,mw;
pFDegProc degp;
eledeg--;
if (eledeg == 0)
{
if (strat->ak>0)
{
char *used_comp=(char*)omAlloc0(strat->ak+1);
int i;
for(i=strat->sl;i>0;i--)
{
used_comp[pGetComp(strat->S[i])]='\1';
}
for(i=strat->ak;i>0;i--)
{
if(used_comp[i]=='\0')
{
omFree((ADDRESS)used_comp);
return;
}
}
omFree((ADDRESS)used_comp);
}
degp=currRing->pFDeg;
// if weights for variables were given to std computations,
// then pFDeg == degp == kHomModDeg (see kStd)
if ((degp!=kModDeg) && (degp!=kHomModDeg)) degp=p_Totaldegree;
// degp = pWDegree;
l = hilb->cols();
mw = n_Int(BIMATELEM(*hilb,1,l),coeffs_BIGINT);
newhilb =hFirstSeries0b(strat->Shdl,Q,strat->kHomW,w,currRing,coeffs_BIGINT);
ln = newhilb->cols();
deg = degp(strat->P.p,currRing);
loop // compare the series in degree deg, try to increase deg -----------
{
if (deg < ln) // deg may be out of range
{
if (deg < l)
{
number s=n_Sub(BIMATELEM(*newhilb,1,deg+1),
BIMATELEM(*hilb,1,deg+1),coeffs_BIGINT);
eledeg = n_Int(s,coeffs_BIGINT);
}
else
eledeg = n_Int(BIMATELEM(*newhilb,1,deg+1),coeffs_BIGINT);
}
else
{
if (deg < l)
eledeg = -n_Int(BIMATELEM(*hilb,1,deg+1),coeffs_BIGINT);
else // we have newhilb = hilb
{
while (strat->Ll>=0)
{
count++;
if(TEST_OPT_PROT)
{
PrintS("h");
mflush();
}
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
}
delete newhilb;
return;
}
}
if (eledeg > 0) // elements to delete
break;
else if (eledeg <0) // strange....see bug_43
return;
deg++;
} /* loop */
delete newhilb;
while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
{
count++;
if(TEST_OPT_PROT)
{
PrintS("h");
mflush();
}
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
}
}
}
#if 0
/*2
* compare the given hilbert series with the current one,
* delete not needed pairs (if possible)
*/
void khCheck( ideal Q, intvec *w, poly hilb, const ring Qt, int &eledeg, int &count,
kStrategy strat)
/* ideal S=strat->Shdl, poly p=strat->P.p */
/*
* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
* p is already in S and for all further q going into S yields deg(q) >= deg(p),
* the real computation is only done if the degree has changed,
* then we have eledeg == 0 on this degree and we make:
* - compute the Hilbert series newhilb from S
* (hilb is the final Hilbert series)
* - in module case: check that all comp up to strat->ak are used
* - compute the eledeg from newhilb-hilb for the first degree deg with
* newhilb-hilb != 0
* (Remark: consider the Hilbert series with coeff. up to infinity)
* - clear the set L for degree < deg
* the number count is only for statistics (in the caller initialise count = 0),
* in order to get a first computation, initialise eledeg = 1 in the caller.
* The weights w are needed in the module case, otherwise NULL.
*/
{
poly newhilb;
int deg,l,ln;
mpz_t mw;
pFDegProc degp;
eledeg--;
if (eledeg == 0)
{
if (strat->ak>0)
{
char *used_comp=(char*)omAlloc0(strat->ak+1);
int i;
for(i=strat->sl;i>0;i--)
{
used_comp[pGetComp(strat->S[i])]='\1';
}
for(i=strat->ak;i>0;i--)
{
if(used_comp[i]=='\0')
{
omFree((ADDRESS)used_comp);
return;
}
}
omFree((ADDRESS)used_comp);
}
degp=currRing->pFDeg;
// if weights for variables were given to std computations,
// then pFDeg == degp == kHomModDeg (see kStd)
if ((degp!=kModDeg) && (degp!=kHomModDeg)) degp=p_Totaldegree;
// degp = pWDegree;
l = p_FDeg(hilb,Qt);
number lt=pGetcoeff(hilb);
n_MPZ(mw,&lt,Qt->cf);
newhilb =hFirstSeries0m(strat->Shdl,Q,w,strat->kHomW,currRing,Qt);
ln = p_FDeg(newhilb);
deg = degp(strat->P.p,currRing);
loop // compare the series in degree deg, try to increase deg -----------
{
if (deg < ln) // deg may be out of range
{
if (deg < l)
eledeg = (*newhilb)[deg]-(*hilb)[deg];
else
eledeg = (*newhilb)[deg];
}
else
{
if (deg < l)
eledeg = -(*hilb)[deg];
else // we have newhilb = hilb
{
while (strat->Ll>=0)
{
count++;
if(TEST_OPT_PROT)
{
PrintS("h");
mflush();
}
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
}
delete newhilb;
return;
}
}
if (eledeg > 0) // elements to delete
break;
else if (eledeg <0) // strange....see bug_43
return;
deg++;
} /* loop */
delete newhilb;
while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
{
count++;
if(TEST_OPT_PROT)
{
PrintS("h");
mflush();
}
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
}
}
}
#endif
void khCheckLocInhom(ideal Q, intvec *w, bigintmat *hilb, int &count,
kStrategy strat)
/*
This will be used for the local orderings in the case of the inhomogeneous ideals.
Assume f1,...,fs are already in the standard basis. Test if hilb(LM(f1),...,LM(fs),1)
is equal to the inputted one.
If no, do nothing.
If Yes, we know that all polys that we need are already in the standard basis
so delete all the remaining pairs
*/
{
ideal Lm;
bigintmat *newhilb;
Lm = id_Head(strat->Shdl,currRing);
newhilb =hFirstSeries0b(strat->Shdl,Q,strat->kHomW,w,currRing,coeffs_BIGINT);
if(newhilb->compare(hilb) == 0)
{
while (strat->Ll>=0)
{
count++;
if(TEST_OPT_PROT)
{
PrintS("h");
mflush();
}
deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
}
delete newhilb;
return;
}
id_Delete(&Lm,currRing);
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
BIMATELEM
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
bigintmat::cols
int cols() const
Definition bigintmat.h:144
bigintmat::compare
int compare(const bigintmat *op) const
Definition bigintmat.cc:360
intvec
Definition intvec.h:24
skStrategy::Ll
int Ll
Definition kutil.h:350
skStrategy::S
polyset S
Definition kutil.h:305
skStrategy::ak
int ak
Definition kutil.h:352
skStrategy::kHomW
intvec * kHomW
Definition kutil.h:335
skStrategy::Shdl
ideal Shdl
Definition kutil.h:302
skStrategy::P
LObject P
Definition kutil.h:301
skStrategy::L
LSet L
Definition kutil.h:326
skStrategy::sl
int sl
Definition kutil.h:347
n_Int
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:550
n_MPZ
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
Definition coeffs.h:554
n_Sub
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:658
s
const CanonicalForm int s
Definition facAbsFact.cc:51
w
const CanonicalForm & w
Definition facAbsFact.cc:51
hFirstSeries0m
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:1427
hFirstSeries0b
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2019
hilb.h
intvec.h
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
kHomModDeg
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2421
kModDeg
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2411
kstd1.h
deleteInL
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1208
kutil.h
mod2.h
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
options.h
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
p_FDeg
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:382
p_Totaldegree
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1528
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).
pGetComp
#define pGetComp(p)
Component.
Definition polys.h:38
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
mflush
#define mflush()
Definition reporter.h:58
pFDegProc
long(* pFDegProc)(poly p, ring r)
Definition ring.h:39
count
int status int void size_t count
Definition si_signals.h:69
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
id_Head
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
Definition simpleideals.cc:1483
simpleideals.h
Q
#define Q
Definition sirandom.c:26
stairc.h
kStrategy
skStrategy * kStrategy
Definition structs.h:54
loop
#define loop
Definition structs.h:71