Functions
initial.cc File Reference
#include <kernel/ideals.h>
#include <polys/monomials/p_polys.h>
#include <gfanlib/gfanlib.h>
#include <exception>

Go to the source code of this file.

Functions

long wDeg (const poly p, const ring r, const gfan::ZVector &w)
 various functions to compute the initial form of polynomials and ideals More...
 
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). More...
 
poly initial (const poly p, const ring r, const gfan::ZVector &w)
 Returns the initial form of p with respect to w. More...
 
ideal initial (const ideal I, const ring r, const gfan::ZVector &w)
 Returns the initial form of I with respect to w. More...
 
poly initial (const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
 Returns the initial form of p with respect to w and W. More...
 
ideal initial (const ideal I, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
 Returns the initial form of I with respect to w and W. More...
 
void initial (poly *pStar, const ring r, const gfan::ZVector &w)
 Stores the initial form of *pStar with respect to w in pStar. More...
 
void initial (ideal *IStar, const ring r, const gfan::ZVector &w)
 Stores the initial form of *IStar with respect to w in IStar. More...
 
void initial (poly *pStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
 Stores the initial form of *pStar with respect to w and W in pStar. More...
 
void initial (ideal *IStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
 Stores the initial form of *IStar with respect to w and W in IStar. More...
 

Function Documentation

◆ initial() [1/8]

poly initial ( const poly  p,
const ring  r,
const gfan::ZVector &  w 
)

Returns the initial form of p with respect to w.

Definition at line 32 of file initial.cc.

33 {
34  if (p==NULL)
35  return NULL;
36 
37  poly q0 = p_Head(p,r);
38  poly q1 = q0;
39  long d = wDeg(p,r,w);
40  for (poly currentTerm = p->next; currentTerm; pIter(currentTerm))
41  {
42  long e = wDeg(currentTerm,r,w);
43  if (d<e)
44  {
45  p_Delete(&q0,r);
46  q0 = p_Head(currentTerm,r);
47  q1 = q0;
48  d = e;
49  }
50  else
51  if (e==d)
52  {
53  pNext(q1) = p_Head(currentTerm,r);
54  pIter(q1);
55  }
56  }
57  return q0;
58 }
return P p
Definition: myNF.cc:203
#define pIter(p)
Definition: monomials.h:44
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
const ring r
Definition: syzextra.cc:208
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
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:8
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10

◆ initial() [2/8]

ideal initial ( const ideal  I,
const ring  r,
const gfan::ZVector &  w 
)

Returns the initial form of I with respect to w.

Definition at line 60 of file initial.cc.

61 {
62  int k = IDELEMS(I); ideal inI = idInit(k);
63  for (int i=0; i<k; i++)
64  inI->m[i] = initial(I->m[i],r,w);
65  return inI;
66 }
int k
Definition: cfEzgcd.cc:93
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:32
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ initial() [3/8]

poly initial ( const poly  p,
const ring  r,
const gfan::ZVector &  w,
const gfan::ZMatrix &  W 
)

Returns the initial form of p with respect to w and W.

Definition at line 68 of file initial.cc.

69 {
70  if (p==NULL)
71  return NULL;
72 
73  poly q0 = p_Head(p,r);
74  poly q1 = q0;
75  gfan::ZVector d = WDeg(p,r,w,W);
76  for (poly currentTerm = p->next; currentTerm; pIter(currentTerm))
77  {
78  gfan::ZVector e = WDeg(currentTerm,r,w,W);
79  if (d<e)
80  {
81  p_Delete(&q0,r);
82  q0 = p_Head(p,r);
83  q1 = q0;
84  d = e;
85  }
86  else
87  if (d==e)
88  {
89  pNext(q1) = p_Head(currentTerm,r);
90  pIter(q1);
91  }
92  }
93  return q0;
94 }
return P p
Definition: myNF.cc:203
#define pIter(p)
Definition: monomials.h:44
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
const ring r
Definition: syzextra.cc:208
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
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:23

◆ initial() [4/8]

ideal initial ( const ideal  I,
const ring  r,
const gfan::ZVector &  w,
const gfan::ZMatrix &  W 
)

Returns the initial form of I with respect to w and W.

Definition at line 96 of file initial.cc.

97 {
98  int k = IDELEMS(I); ideal inI = idInit(k);
99  for (int i=0; i<k; i++)
100  inI->m[i] = initial(I->m[i],r,w,W);
101  return inI;
102 }
int k
Definition: cfEzgcd.cc:93
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:32
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ initial() [5/8]

void initial ( poly pStar,
const ring  r,
const gfan::ZVector &  w 
)

Stores the initial form of *pStar with respect to w in pStar.

Definition at line 104 of file initial.cc.

105 {
106  poly p = *pStar;
107  if (p==NULL)
108  return;
109 
110  long d = wDeg(p,r,w);
111  poly q0 = p;
112  poly q1 = q0;
113  pNext(q1) = NULL;
114  pIter(p);
115 
116  while(p)
117  {
118  long e = wDeg(p,r,w);
119  if (d<e)
120  {
121  p_Delete(&q0,r);
122  q0 = p;
123  q1 = q0;
124  pNext(q1) = NULL;
125  d = e;
126  pIter(p);
127  }
128  else
129  if (e==d)
130  {
131  pNext(q1) = p;
132  pIter(q1);
133  pNext(q1) = NULL;
134  pIter(p);
135  }
136  else
137  p = p_LmDeleteAndNext(p,r);
138  }
139  pStar = &q0;
140  return;
141 }
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:720
return P p
Definition: myNF.cc:203
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
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:8
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10

◆ initial() [6/8]

void initial ( ideal *  IStar,
const ring  r,
const gfan::ZVector &  w 
)

Stores the initial form of *IStar with respect to w in IStar.

Definition at line 143 of file initial.cc.

144 {
145  ideal I = *IStar;
146  int k = IDELEMS(I);
147  for (int i=0; i<k; i++)
148  initial(&I->m[i],r,w);
149  return;
150 }
int k
Definition: cfEzgcd.cc:93
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:32
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ initial() [7/8]

void initial ( poly pStar,
const ring  r,
const gfan::ZVector &  w,
const gfan::ZMatrix &  W 
)

Stores the initial form of *pStar with respect to w and W in pStar.

Definition at line 152 of file initial.cc.

153 {
154  poly p = *pStar;
155  if (p==NULL)
156  return;
157 
158  gfan::ZVector d = WDeg(p,r,w,W);
159  poly q0 = p;
160  poly q1 = q0;
161  pNext(q1) = NULL;
162  pIter(p);
163 
164  while(p)
165  {
166  gfan::ZVector e = WDeg(p,r,w,W);
167  if (d<e)
168  {
169  p_Delete(&q0,r);
170  q0 = p;
171  q1 = q0;
172  pNext(q1) = NULL;
173  d = e;
174  pIter(p);
175  }
176  else
177  if (d==e)
178  {
179  pNext(q1) = p;
180  pIter(q1);
181  pNext(q1) = NULL;
182  pIter(p);
183  }
184  else
185  p = p_LmDeleteAndNext(p,r);
186  }
187  pStar = &q0;
188  return;
189 }
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:720
return P p
Definition: myNF.cc:203
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
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:23

◆ initial() [8/8]

void initial ( ideal *  IStar,
const ring  r,
const gfan::ZVector &  w,
const gfan::ZMatrix &  W 
)

Stores the initial form of *IStar with respect to w and W in IStar.

Definition at line 191 of file initial.cc.

192 {
193  ideal I = *IStar;
194  int k = IDELEMS(I);
195  for (int i=0; i<k; i++)
196  initial(&I->m[i],r,w,W);
197  return;
198 }
int k
Definition: cfEzgcd.cc:93
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:32
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ wDeg()

long wDeg ( const poly  p,
const ring  r,
const gfan::ZVector &  w 
)

various functions to compute the initial form of polynomials and ideals

Returns the weighted degree of the leading term of p with respect to w

Definition at line 8 of file initial.cc.

9 {
10  long d=0;
11  for (unsigned i=0; i<w.size(); i++)
12  {
13  if (!w[i].fitsInInt())
14  {
15  WerrorS("wDeg: overflow in weight vector");
16  throw 0; // weightOverflow;
17  }
18  d += p_GetExp(p,i+1,r)*w[i].toInt();
19  }
20  return d;
21 }
return P p
Definition: myNF.cc:203
void WerrorS(const char *s)
Definition: feFopen.cc:24
const ring r
Definition: syzextra.cc:208
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
int i
Definition: cfEzgcd.cc:123
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ 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).

The weighted multidegree is a vector of length one higher than the column vectors of W. The first entry is the weighted degree with respect to w and the i+1st entry is the weighted degree with respect to the i-th row vector of W.

Definition at line 23 of file initial.cc.

24 {
25  gfan::ZVector d = gfan::ZVector(W.getHeight()+1);
26  d[0] = wDeg(p,r,w);
27  for (int i=0; i<W.getHeight(); i++)
28  d[i+1] = wDeg(p,r,W[i]);
29  return d;
30 }
return P p
Definition: myNF.cc:203
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
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:8
const CanonicalForm & w
Definition: facAbsFact.cc:55