Loading...
Searching...
No Matches
initial.cc
Go to the documentation of this file.
#include "kernel/ideals.h"
#include "polys/monomials/p_polys.h"
#include "gfanlib/gfanlib.h"
long wDeg(const poly p, const ring r, const gfan::ZVector &w)
{
long d=0;
for (unsigned i=0; i<w.size(); i++)
{
if (!w[i].fitsInInt())
{
WerrorS("wDeg: overflow in weight vector");
throw 0; // weightOverflow;
}
d += p_GetExp(p,i+1,r)*w[i].toInt();
}
return d;
}
gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
{
gfan::ZVector d = gfan::ZVector(W.getHeight()+1);
d[0] = wDeg(p,r,w);
for (int i=0; i<W.getHeight(); i++)
d[i+1] = wDeg(p,r,W[i]);
return d;
}
poly initial(const poly p, const ring r, const gfan::ZVector &w)
{
if (p==NULL)
return NULL;
poly q0 = p_Head(p,r);
poly q1 = q0;
long d = wDeg(p,r,w);
for (poly currentTerm = p->next; currentTerm; pIter(currentTerm))
{
long e = wDeg(currentTerm,r,w);
if (d<e)
{
p_Delete(&q0,r);
q0 = p_Head(currentTerm,r);
q1 = q0;
d = e;
}
else
if (e==d)
{
pNext(q1) = p_Head(currentTerm,r);
pIter(q1);
}
}
return q0;
}
ideal initial(const ideal I, const ring r, const gfan::ZVector &w)
{
int k = IDELEMS(I); ideal inI = idInit(k);
for (int i=0; i<k; i++)
inI->m[i] = initial(I->m[i],r,w);
return inI;
}
poly initial(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
{
if (p==NULL)
return NULL;
poly q0 = p_Head(p,r);
poly q1 = q0;
gfan::ZVector d = WDeg(p,r,w,W);
for (poly currentTerm = p->next; currentTerm; pIter(currentTerm))
{
gfan::ZVector e = WDeg(currentTerm,r,w,W);
if (d<e)
{
p_Delete(&q0,r);
q0 = p_Head(p,r);
q1 = q0;
d = e;
}
else
if (d==e)
{
pNext(q1) = p_Head(currentTerm,r);
pIter(q1);
}
}
return q0;
}
ideal initial(const ideal I, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
{
int k = IDELEMS(I); ideal inI = idInit(k);
for (int i=0; i<k; i++)
inI->m[i] = initial(I->m[i],r,w,W);
return inI;
}
void initial(poly* pStar, const ring r, const gfan::ZVector &w)
{
poly p = *pStar;
if (p==NULL)
return;
long d = wDeg(p,r,w);
poly q0 = p;
poly q1 = q0;
pNext(q1) = NULL;
pIter(p);
while(p)
{
long e = wDeg(p,r,w);
if (d<e)
{
p_Delete(&q0,r);
q0 = p;
q1 = q0;
pNext(q1) = NULL;
d = e;
pIter(p);
}
else
if (e==d)
{
pNext(q1) = p;
pIter(q1);
pNext(q1) = NULL;
pIter(p);
}
else
p = p_LmDeleteAndNext(p,r);
}
pStar = &q0;
return;
}
void initial(ideal* IStar, const ring r, const gfan::ZVector &w)
{
ideal I = *IStar;
int k = IDELEMS(I);
for (int i=0; i<k; i++)
initial(&I->m[i],r,w);
return;
}
void initial(poly* pStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
{
poly p = *pStar;
if (p==NULL)
return;
gfan::ZVector d = WDeg(p,r,w,W);
poly q0 = p;
poly q1 = q0;
pNext(q1) = NULL;
pIter(p);
while(p)
{
gfan::ZVector e = WDeg(p,r,w,W);
if (d<e)
{
p_Delete(&q0,r);
q0 = p;
q1 = q0;
pNext(q1) = NULL;
d = e;
pIter(p);
}
else
if (d==e)
{
pNext(q1) = p;
pIter(q1);
pNext(q1) = NULL;
pIter(p);
}
else
p = p_LmDeleteAndNext(p,r);
}
pStar = &q0;
return;
}
void initial(ideal* IStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
{
ideal I = *IStar;
int k = IDELEMS(I);
for (int i=0; i<k; i++)
initial(&I->m[i],r,w,W);
return;
}
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
p
int p
Definition cfModGcd.cc:4086
w
const CanonicalForm & w
Definition facAbsFact.cc:51
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
ideals.h
WDeg
gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
Returns the weighted multidegree of the leading term of p with respect to (w,W).
Definition initial.cc:21
wDeg
long wDeg(const poly p, const ring r, const gfan::ZVector &w)
various functions to compute the initial form of polynomials and ideals
Definition initial.cc:6
initial
poly initial(const poly p, const ring r, const gfan::ZVector &w)
Returns the initial form of p with respect to w.
Definition initial.cc:30
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
NULL
#define NULL
Definition omList.c:12
p_polys.h
p_Head
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
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_LmDeleteAndNext
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23