Loading...
Searching...
No Matches
containsMonomial.cc File Reference
`#include "kernel/polys.h"`
`#include "kernel/GBEngine/kstd1.h"`
`#include "polys/prCopy.h"`
`#include "callgfanlib_conversion.h"`
`#include "bbcone.h"`
`#include "std_wrapper.h"`

Go to the source code of this file.

## Functions

poly | checkForMonomialViaSuddenSaturation (const ideal I, const ring r)
poly | searchForMonomialViaStepwiseSaturation (const ideal I, const ring r, const gfan::ZVector w0)
BOOLEAN | checkForMonomial (leftv res, leftv args)
BOOLEAN | searchForMonomialViaStepwiseSaturation (leftv res, leftv args)

## Function Documentation

## checkForMonomial()

BOOLEAN checkForMonomial | ( | leftv | res,
|  | leftv | args )

Definition at line 212 of file containsMonomial.cc.

{
leftv u = args;
if ((u != NULL) && (u->Typ() == IDEAL_CMD))
{
ideal I; poly monom;
omUpdateInfo();
Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
I = (ideal) u->CopyD();
monom = checkForMonomialViaSuddenSaturation(I,currRing);
id_Delete(&I,currRing);
p_Delete(&monom,currRing);
omUpdateInfo();
Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
I = (ideal) u->Data();
res->rtyp = POLY_CMD;
res->data = (char*) checkForMonomialViaSuddenSaturation(I,currRing);
return FALSE;
}
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
sleftv::CopyD
void * CopyD(int t)
Definition subexpr.cc:714
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::Data
void * Data()
Definition subexpr.cc:1192
checkForMonomialViaSuddenSaturation
poly checkForMonomialViaSuddenSaturation(const ideal I, const ring r)
Definition containsMonomial.cc:9
Print
#define Print
Definition emacs.cc:80
res
CanonicalForm res
Definition facAbsFact.cc:60
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
POLY_CMD
@ POLY_CMD
Definition grammar.cc:290
NULL
#define NULL
Definition omList.c:12
om_Info
omInfo_t om_Info
Definition omStats.c:16
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
leftv
sleftv * leftv
Definition structs.h:53
omUpdateInfo
#define omUpdateInfo()
Definition xalloc.h:230

## checkForMonomialViaSuddenSaturation()

poly checkForMonomialViaSuddenSaturation | ( | const ideal | I,
|  | const ring | r )

Definition at line 9 of file containsMonomial.cc.

{
ring origin = currRing;
if (currRing != r)
rChangeCurrRing(r);
ideal M = idInit(1);
M->m[0] = p_Init(r);
for (int i=1; i<=rVar(r); i++)
p_SetExp(M->m[0],i,1,r);
p_SetCoeff(M->m[0],n_Init(1,r->cf),r);
p_Setm(M->m[0],r); p_Test(M->m[0],r);
ideal J = id_Copy(I,r); bool b; int k = 0;
if (currRing != r) rChangeCurrRing(r);
intvec* nullVector = NULL;
do
{
ideal Jstd = kStd2(J,currRing->qideal,testHomog,&nullVector,(bigintmat*)NULL);
ideal JquotM = idQuot(Jstd,M,true,true);
ideal JquotMredJ = kNF(Jstd,currRing->qideal,JquotM);
b = idIs0(JquotMredJ);
id_Delete(&Jstd,r);
id_Delete(&J,r);
J = JquotM;
id_Delete(&JquotMredJ,r);
k++;
} while (!b);
poly monom = NULL;
if (id_IsConstant(J,r))
{
monom = p_Init(r);
for (int i=1; i<=rVar(r); i++)
p_SetExp(monom,i,k,r);
p_SetCoeff(monom,n_Init(1,r->cf),r);
p_Setm(monom,r);
}
id_Delete(&M,r);
id_Delete(&J,r);
if (currRing != origin)
rChangeCurrRing(origin);
return monom;
}
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
b
CanonicalForm b
Definition cfModGcd.cc:4111
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
intvec
Definition intvec.h:24
n_Init
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
idQuot
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1539
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition simpleideals.cc:542
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition simpleideals.cc:960
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
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3229
p_SetExp
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
p_Setm
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
p_Init
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341
p_Test
#define p_Test(p, r)
Definition p_polys.h:161
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition polys.cc:16
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_IsConstant
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
Definition simpleideals.cc:529
M
#define M
Definition sirandom.c:25
testHomog
@ testHomog
Definition structs.h:34

## searchForMonomialViaStepwiseSaturation() [1/2]

poly searchForMonomialViaStepwiseSaturation | ( | const ideal | I,
|  | const ring | r,
|  | const gfan::ZVector | w0 )

Definition at line 55 of file containsMonomial.cc.

{
gfan::ZVector w = w0;
ring origin = currRing;
if (currRing != r)
rChangeCurrRing(r);
// copy ring including qideal but without ordering
// set ordering to be wp(w)
int n = rVar(r);
ring rGraded = rCopy0(r,TRUE,FALSE);
rGraded->order = (rRingOrder_t*) omAlloc0(3*sizeof(rRingOrder_t));
rGraded->block0 = (int*) omAlloc0(3*sizeof(int));
rGraded->block1 = (int*) omAlloc0(3*sizeof(int));
rGraded->wvhdl = (int**) omAlloc0(3*sizeof(int**));
rGraded->order[0] = ringorder_wp;
rGraded->block0[0] = 1;
rGraded->block1[0] = n;
bool overflow;
rGraded->wvhdl[0] = ZVectorToIntStar(w,overflow);
rGraded->order[1] = ringorder_C;
rComplete(rGraded);
rTest(rGraded);
// map I into the new ring so that it becomes a graded ideal
int k = IDELEMS(I);
nMapFunc identity = n_SetMap(r->cf,rGraded->cf);
ideal Jold = idInit(k);
for (int i=0; i<k; i++)
Jold->m[i] = p_PermPoly(I->m[i],NULL,r,rGraded,identity,NULL,0);
// compute std and check whether result contains a monomial,
// wrap up computation if it does
ideal Jnew = gfanlib_monomialabortStd_wrapper(Jold,rGraded);
id_Delete(&Jold,rGraded);
k = IDELEMS(Jnew);
for (int i=0; i<k; i++)
{
poly g = Jnew->m[i];
if (g!=NULL && pNext(g)==NULL && n_IsUnit(p_GetCoeff(g,r),r->cf))
{
poly monomial = p_One(r);
for (int j=1; j<=rVar(r); j++)
p_SetExp(monomial,j,p_GetExp(g,j,rGraded),r);
p_Setm(monomial,r);
id_Delete(&Jnew,rGraded);
rDelete(rGraded);
if (currRing != origin)
rChangeCurrRing(origin);
return monomial;
}
}
// prepare permutation to cycle all variables
int* cycleAllVariables = (int*) omAlloc0((n+1)*sizeof(int));
for (int i=1; i<n; i++)
cycleAllVariables[i]=i+1;
cycleAllVariables[n]=1;
// prepare storage of maximal powers that are being divided with
int* maxPowers = (int*) omAlloc0((n+1)*sizeof(int));
for(int currentSaturationVariable=n-1; currentSaturationVariable>0; currentSaturationVariable--)
{
// divide out the maximal power in the last variable,
// storing the maximum of all powers.
for (int i=0; i<k; i++)
{
poly g = Jnew->m[i];
int d = p_GetExp(g,n,rGraded);
if (d>0)
{
for (; g!=NULL; pIter(g))
{
p_SubExp(g,n,d,rGraded);
p_Setm(g,rGraded);
}
if (d>maxPowers[currentSaturationVariable+1])
maxPowers[currentSaturationVariable+1]=d;
}
}
// cycle all variables, i.e. x_1->x_2, x_2->x_3, ..., x_n->x_1
// so that a new variable is at the last position
gfan::Integer cache = w[n-1];
for (int i=n-1; i>0; i--)
w[i] = w[i-1];
w[0] = cache;
ring rGradedNew = rCopy0(r,FALSE,FALSE); // cannot copy q-ideal without ordering
rGradedNew->order = (rRingOrder_t*) omAlloc0(3*sizeof(rRingOrder_t));
rGradedNew->block0 = (int*) omAlloc0(3*sizeof(int));
rGradedNew->block1 = (int*) omAlloc0(3*sizeof(int));
rGradedNew->wvhdl = (int**) omAlloc0(3*sizeof(int**));
rGradedNew->order[0] = ringorder_wp;
rGradedNew->block0[0] = 1;
rGradedNew->block1[0] = n;
bool overflow;
rGradedNew->wvhdl[0] = ZVectorToIntStar(w,overflow);
rGradedNew->order[1] = ringorder_C;
rComplete(rGradedNew);
rTest(rGradedNew);
identity = n_SetMap(rGraded->cf,rGradedNew->cf);
Jold = idInit(k);
for (int i=0; i<k; i++)
Jold->m[i] = p_PermPoly(Jnew->m[i],cycleAllVariables,rGraded,rGradedNew,identity,NULL,0);
id_Delete(&Jnew,rGraded);
rDelete(rGraded);
rGraded = rGradedNew;
rGradedNew = NULL;
// compute std and check whether result contains a monomial,
// wrap up computation if it does
// adjust for the powers already divided out of the ideal
// and the shift of variables!
Jnew = gfanlib_monomialabortStd_wrapper(Jold,rGraded);
id_Delete(&Jold,rGraded);
k = IDELEMS(Jnew);
for (int i=0; i<k; i++)
{
poly g = Jnew->m[i];
if (g!=NULL && pNext(g)==NULL && n_IsUnit(p_GetCoeff(g,rGraded),rGraded->cf))
{
poly monomial = p_One(r);
for (int j=1; j<=rVar(r); j++)
{
int jDeshifted = (j-currentSaturationVariable)%n;
if (jDeshifted<=0) jDeshifted = jDeshifted+n;
p_SetExp(monomial,j,p_GetExp(g,jDeshifted,rGraded)+maxPowers[j],r);
}
p_Setm(monomial,r);
id_Delete(&Jnew,rGraded);
rDelete(rGraded);
omFree(cycleAllVariables);
omFree(maxPowers);
if (currRing != origin)
rChangeCurrRing(origin);
return monomial;
}
}
}
if (currRing != origin)
rChangeCurrRing(origin);
id_Delete(&Jnew,rGraded);
rDelete(rGraded);
omFree(cycleAllVariables);
omFree(maxPowers);
return NULL;
}
ZVectorToIntStar
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
Definition callgfanlib_conversion.cc:110
g
g
Definition cfModGcd.cc:4098
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_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:703
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
w
const CanonicalForm & w
Definition facAbsFact.cc:51
j
int j
Definition facHensel.cc:110
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
p_GetCoeff
#define p_GetCoeff(p, r)
Definition monomials.h:50
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
p_PermPoly
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition p_polys.cc:4256
p_One
poly p_One(const ring r)
Definition p_polys.cc:1314
p_SubExp
static long p_SubExp(poly p, int v, long ee, ring r)
Definition p_polys.h:615
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
rComplete
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3527
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rRingOrder_t
rRingOrder_t
order stuff
Definition ring.h:69
ringorder_C
@ ringorder_C
Definition ring.h:74
ringorder_wp
@ ringorder_wp
Definition ring.h:82
rTest
#define rTest(r)
Definition ring.h:794
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
gfanlib_monomialabortStd_wrapper
ideal gfanlib_monomialabortStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition std_wrapper.cc:172

## searchForMonomialViaStepwiseSaturation() [2/2]

BOOLEAN searchForMonomialViaStepwiseSaturation | ( | leftv | res,
|  | leftv | args )

Definition at line 234 of file containsMonomial.cc.

{
leftv u = args;
if ((u != NULL) && (u->Typ() == IDEAL_CMD))
{
leftv v = u->next;
if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
{
ideal I = (ideal) u->Data();
bigintmat* w0=NULL;
if (v->Typ() == INTVEC_CMD)
{
intvec* w00 = (intvec*) v->Data();
bigintmat* w0t = iv2bim(w00,coeffs_BIGINT);
w0 = w0t->transpose();
delete w0t;
}
else
w0 = (bigintmat*) v->Data();
gfan::ZVector* w = bigintmatToZVector(w0);
res->rtyp = POLY_CMD;
res->data = (char*) searchForMonomialViaStepwiseSaturation(I,currRing,*w);
delete w;
if (v->Typ() == INTVEC_CMD)
delete w0;
return FALSE;
}
}
WerrorS("searchForMonomialViaStepwiseSaturation: unexpected parameters");
return TRUE;
}
iv2bim
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition bigintmat.cc:347
bigintmatToZVector
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
Definition callgfanlib_conversion.cc:73
bigintmat::transpose
bigintmat * transpose()
Definition bigintmat.cc:35
sleftv::next
leftv next
Definition subexpr.h:86
searchForMonomialViaStepwiseSaturation
poly searchForMonomialViaStepwiseSaturation(const ideal I, const ring r, const gfan::ZVector w0)
Definition containsMonomial.cc:55
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
BIGINTMAT_CMD
@ BIGINTMAT_CMD
Definition grammar.cc:278
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101