My Project  debian-1:4.1.1-p2+ds-4build4
Functions | Variables
pcv.cc File Reference
#include "kernel/mod2.h"
#include "Singular/tok.h"
#include "Singular/ipid.h"
#include "coeffs/numbers.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "Singular/lists.h"
#include "polys/matpol.h"
#include "Singular/ipshell.h"
#include "Singular/pcv.h"

Go to the source code of this file.

Functions

lists pcvLAddL (lists l1, lists l2)
 
lists pcvPMulL (poly p, lists l1)
 
BOOLEAN pcvLAddL (leftv res, leftv h)
 
BOOLEAN pcvPMulL (leftv res, leftv h)
 
int pcvDeg (poly p)
 
int pcvMinDeg (poly p)
 
int pcvMinDeg (matrix m)
 
BOOLEAN pcvMinDeg (leftv res, leftv h)
 
void pcvInit (int d)
 
void pcvClean ()
 
int pcvM2N (poly m)
 
poly pcvN2M (int n)
 
poly pcvP2CV (poly p, int d0, int d1)
 
poly pcvCV2P (poly cv, int d0, int d1)
 
lists pcvP2CV (lists pl, int d0, int d1)
 
lists pcvCV2P (lists cvl, int d0, int d1)
 
BOOLEAN pcvP2CV (leftv res, leftv h)
 
BOOLEAN pcvCV2P (leftv res, leftv h)
 
int pcvDim (int d0, int d1)
 
BOOLEAN pcvDim (leftv res, leftv h)
 
int pcvBasis (lists b, int i, poly m, int d, int n)
 
lists pcvBasis (int d0, int d1)
 
BOOLEAN pcvBasis (leftv res, leftv h)
 

Variables

static int pcvMaxDegree
 
static int pcvTableSize
 
static int pcvIndexSize
 
static unsigned * pcvTable =NULL
 
static unsigned ** pcvIndex =NULL
 

Function Documentation

◆ pcvBasis() [1/3]

lists pcvBasis ( int  d0,
int  d1 
)

Definition at line 411 of file pcv.cc.

412 {
413  if(d0<0) d0=0;
414  if(d1<0) d1=0;
416  b->Init(pcvDim(d0,d1));
417  poly m=pOne();
418  for(int d=d0,i=0;d<d1;d++)
419  i=pcvBasis(b,i,m,d,1);
420  pLmDelete(&m);
421  return b;
422 }
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
CanonicalForm b
Definition: cfModGcd.cc:4044
Definition: lists.h:23
omBin slists_bin
Definition: lists.cc:23
slists * lists
Definition: mpr_numeric.h:146
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
int pcvBasis(lists b, int i, poly m, int d, int n)
Definition: pcv.cc:391
int pcvDim(int d0, int d1)
Definition: pcv.cc:361
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
#define pOne()
Definition: polys.h:301

◆ pcvBasis() [2/3]

BOOLEAN pcvBasis ( leftv  res,
leftv  h 
)

Definition at line 424 of file pcv.cc.

425 {
426  if(currRing)
427  {
428  const short t[]={2,INT_CMD,INT_CMD};
429  if (iiCheckTypes(h,t,1))
430  {
431  int d0=(int)(long)h->Data();
432  h=h->next;
433  int d1=(int)(long)h->Data();
434  res->rtyp=LIST_CMD;
435  res->data=(void*)pcvBasis(d0,d1);
436  return FALSE;
437  }
438  return TRUE;
439  }
440  WerrorS("no ring active");
441  return TRUE;
442 }
#define TRUE
Definition: auxiliary.h:98
#define FALSE
Definition: auxiliary.h:94
CanonicalForm res
Definition: facAbsFact.cc:64
void WerrorS(const char *s)
Definition: feFopen.cc:24
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition: ipshell.cc:6503
static Poly * h
Definition: janet.cc:972
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
@ LIST_CMD
Definition: tok.h:118
@ INT_CMD
Definition: tok.h:96

◆ pcvBasis() [3/3]

int pcvBasis ( lists  b,
int  i,
poly  m,
int  d,
int  n 
)

Definition at line 391 of file pcv.cc.

392 {
393  if(n<currRing->N)
394  {
395  for(int k=0,l=d;k<=l;k++,d--)
396  {
397  pSetExp(m,n,k);
398  i=pcvBasis(b,i,m,d,n+1);
399  }
400  }
401  else
402  {
403  pSetExp(m,n,d);
404  pSetm(m);
405  b->m[i].rtyp=POLY_CMD;
406  b->m[i++].data=pCopy(m);
407  }
408  return i;
409 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int l
Definition: cfEzgcd.cc:93
int k
Definition: cfEzgcd.cc:92
@ POLY_CMD
Definition: grammar.cc:288
#define pSetm(p)
Definition: polys.h:257
#define pSetExp(p, i, v)
Definition: polys.h:42
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172

◆ pcvClean()

void pcvClean ( )

Definition at line 189 of file pcv.cc.

190 {
191  if(pcvTable)
192  {
194  pcvTable=NULL;
195  }
196  if(pcvIndex)
197  {
199  pcvIndex=NULL;
200  }
201 }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define NULL
Definition: omList.c:10
static unsigned * pcvTable
Definition: pcv.cc:28
static unsigned ** pcvIndex
Definition: pcv.cc:29
static int pcvIndexSize
Definition: pcv.cc:27
static int pcvTableSize
Definition: pcv.cc:26

◆ pcvCV2P() [1/3]

BOOLEAN pcvCV2P ( leftv  res,
leftv  h 
)

Definition at line 339 of file pcv.cc.

340 {
341  if(currRing)
342  {
343  const short t[]={3,LIST_CMD,INT_CMD,INT_CMD};
344  if (iiCheckTypes(h,t,1))
345  {
346  lists pl=(lists)h->Data();
347  h=h->next;
348  int d0=(int)(long)h->Data();
349  h=h->next;
350  int d1=(int)(long)h->Data();
351  res->rtyp=LIST_CMD;
352  res->data=(void*)pcvCV2P(pl,d0,d1);
353  return FALSE;
354  }
355  return TRUE;
356  }
357  WerrorS("no ring active");
358  return TRUE;
359 }
poly pcvCV2P(poly cv, int d0, int d1)
Definition: pcv.cc:263

◆ pcvCV2P() [2/3]

lists pcvCV2P ( lists  cvl,
int  d0,
int  d1 
)

Definition at line 300 of file pcv.cc.

301 {
303  pl->Init(cvl->nr+1);
304  pcvInit(d1);
305  for(int i=cvl->nr;i>=0;i--)
306  {
307  if(cvl->m[i].rtyp==VECTOR_CMD)
308  {
309  pl->m[i].rtyp=POLY_CMD;
310  pl->m[i].data=pcvCV2P((poly)cvl->m[i].data,d0,d1);
311  }
312  }
313  pcvClean();
314  return pl;
315 }
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
sleftv * m
Definition: lists.h:45
INLINE_THIS void Init(int l=0)
int nr
Definition: lists.h:43
@ VECTOR_CMD
Definition: grammar.cc:290
void pcvInit(int d)
Definition: pcv.cc:159
void pcvClean()
Definition: pcv.cc:189

◆ pcvCV2P() [3/3]

poly pcvCV2P ( poly  cv,
int  d0,
int  d1 
)

Definition at line 263 of file pcv.cc.

264 {
265  poly p=NULL;
266  while(cv)
267  {
268  poly m=pcvN2M(pGetComp(cv));
269  if(m)
270  {
271  int d=pcvDeg(m);
272  if(d0<=d&&d<d1)
273  {
274  pSetCoeff(m,nCopy(pGetCoeff(cv)));
275  p=pAdd(p,m);
276  }
277  }
278  pIter(cv);
279  }
280  return p;
281 }
int p
Definition: cfModGcd.cc:4019
#define pIter(p)
Definition: monomials.h:44
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:51
#define nCopy(n)
Definition: numbers.h:16
int pcvDeg(poly p)
Definition: pcv.cc:101
poly pcvN2M(int n)
Definition: pcv.cc:220
#define pAdd(p, q)
Definition: polys.h:190
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31

◆ pcvDeg()

int pcvDeg ( poly  p)

Definition at line 101 of file pcv.cc.

102 {
103  int d=0;
104  for(int i=currRing->N;i>=1;i--) d+=pGetExp(p,i);
105  return d;
106 }
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41

◆ pcvDim() [1/2]

int pcvDim ( int  d0,
int  d1 
)

Definition at line 361 of file pcv.cc.

362 {
363  if(d0<0) d0=0;
364  if(d1<0) d1=0;
365  pcvInit(d1);
366  int d=pcvIndex[currRing->N-1][d1]-pcvIndex[currRing->N-1][d0];
367  pcvClean();
368  return d;
369 }

◆ pcvDim() [2/2]

BOOLEAN pcvDim ( leftv  res,
leftv  h 
)

Definition at line 371 of file pcv.cc.

372 {
373  if(currRing)
374  {
375  const short t[]={2,INT_CMD,INT_CMD};
376  if (iiCheckTypes(h,t,1))
377  {
378  int d0=(int)(long)h->Data();
379  h=h->next;
380  int d1=(int)(long)h->Data();
381  res->rtyp=INT_CMD;
382  res->data=(void*)(long)pcvDim(d0,d1);
383  return FALSE;
384  }
385  return TRUE;
386  }
387  WerrorS("no ring active");
388  return TRUE;
389 }

◆ pcvInit()

void pcvInit ( int  d)

Definition at line 159 of file pcv.cc.

160 {
161  if(d<0) d=1;
162  pcvMaxDegree=d+1;
163  pcvTableSize=currRing->N*pcvMaxDegree*sizeof(unsigned);
164  pcvTable=(unsigned*)omAlloc0(pcvTableSize);
165  pcvIndexSize=currRing->N*sizeof(unsigned*);
166  pcvIndex=(unsigned**)omAlloc(pcvIndexSize);
167  for(int i=0;i<currRing->N;i++)
169  for(int i=0;i<pcvMaxDegree;i++)
170  pcvIndex[0][i]=i;
171  unsigned k,l;
172  for(int i=1;i<currRing->N;i++)
173  {
174  k=0;
175  for(int j=0;j<pcvMaxDegree;j++)
176  {
177  l=pcvIndex[i-1][j];
178  if(l>unsigned(~0)-k)
179  {
180  j=pcvMaxDegree;
181  i=currRing->N;
182  WerrorS("unsigned overflow");
183  }
184  else pcvIndex[i][j]=k+=l;
185  }
186  }
187 }
int j
Definition: facHensel.cc:105
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static int pcvMaxDegree
Definition: pcv.cc:25

◆ pcvLAddL() [1/2]

BOOLEAN pcvLAddL ( leftv  res,
leftv  h 
)

Definition at line 71 of file pcv.cc.

72 {
73  const short t[]={2,LIST_CMD,LIST_CMD};
74  if (iiCheckTypes(h,t,1))
75  {
76  lists l1=(lists)h->Data();
77  h=h->next;
78  lists l2=(lists)h->Data();
79  res->rtyp=LIST_CMD;
80  res->data=(void*)pcvLAddL(l1,l2);
81  return FALSE;
82  }
83  return TRUE;
84 }
lists pcvLAddL(lists l1, lists l2)
Definition: pcv.cc:31

◆ pcvLAddL() [2/2]

lists pcvLAddL ( lists  l1,
lists  l2 
)

Definition at line 31 of file pcv.cc.

32 {
34  int i=l1->nr;
35  if(l1->nr<l2->nr) i=l2->nr;
36  l0->Init(i+1);
37  for(;i>=0;i--)
38  {
39  if(i<=l1->nr&&(l1->m[i].rtyp==POLY_CMD||l1->m[i].rtyp==VECTOR_CMD))
40  {
41  l0->m[i].rtyp=l1->m[i].rtyp;
42  l0->m[i].data=pCopy((poly)l1->m[i].data);
43  if(i<=l2->nr&&l2->m[i].rtyp==l1->m[i].rtyp)
44  l0->m[i].data=pAdd((poly)l0->m[i].data,pCopy((poly)l2->m[i].data));
45  }
46  else
47  if(i<=l2->nr&&(l2->m[i].rtyp==POLY_CMD||l2->m[i].rtyp==VECTOR_CMD))
48  {
49  l0->m[i].rtyp=l2->m[i].rtyp;
50  l0->m[i].data=pCopy((poly)l2->m[i].data);
51  }
52  }
53  return(l0);
54 }

◆ pcvM2N()

int pcvM2N ( poly  m)

Definition at line 203 of file pcv.cc.

204 {
205  unsigned n=0,dn,d=0;
206  for(int i=0;i<currRing->N;i++)
207  {
208  d+=pGetExp(m,i+1);
209  dn=pcvIndex[i][d];
210  if(dn>MAX_INT_VAL-n)
211  {
212  i=currRing->N;
213  WerrorS("component overflow");
214  }
215  else n+=dn;
216  }
217  return n+1;
218 }
const int MAX_INT_VAL
Definition: mylimits.h:12

◆ pcvMinDeg() [1/3]

BOOLEAN pcvMinDeg ( leftv  res,
leftv  h 
)

Definition at line 137 of file pcv.cc.

138 {
139  if(h)
140  {
141  if(h->Typ()==POLY_CMD)
142  {
143  res->rtyp=INT_CMD;
144  res->data=(void*)(long)pcvMinDeg((poly)h->Data());
145  return FALSE;
146  }
147  else
148  if(h->Typ()==MATRIX_CMD)
149  {
150  res->rtyp=INT_CMD;
151  res->data=(void*)(long)pcvMinDeg((matrix)h->Data());
152  return FALSE;
153  }
154  }
155  WerrorS("<poly> expected");
156  return TRUE;
157 }
@ MATRIX_CMD
Definition: grammar.cc:285
int pcvMinDeg(poly p)
Definition: pcv.cc:108

◆ pcvMinDeg() [2/3]

int pcvMinDeg ( matrix  m)

Definition at line 122 of file pcv.cc.

123 {
124  int i,j,d;
125  int md=-1;
126  for(i=1;i<=MATROWS(m);i++)
127  {
128  for(j=1;j<=MATCOLS(m);j++)
129  {
130  d=pcvMinDeg(MATELEM(m,i,j));
131  if((d>=0&&md>d)||md==-1) md=d;
132  }
133  }
134  return(md);
135 }
#define MATELEM(mat, i, j)
Definition: matpol.h:28
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27

◆ pcvMinDeg() [3/3]

int pcvMinDeg ( poly  p)

Definition at line 108 of file pcv.cc.

109 {
110  if(!p) return -1;
111  int md=pcvDeg(p);
112  pIter(p);
113  while(p)
114  {
115  int d=pcvDeg(p);
116  if(d<md) md=d;
117  pIter(p);
118  }
119  return md;
120 }

◆ pcvN2M()

poly pcvN2M ( int  n)

Definition at line 220 of file pcv.cc.

221 {
222  n--;
223  poly m=pOne();
224  int i,j=0,k;
225  for(i=currRing->N-1;i>=0;i--)
226  {
227  k=j;
228  for(j=0; (j<pcvMaxDegree) && (pcvIndex[i][j]<=(unsigned)n); j++);
229  j--;
230  n-=pcvIndex[i][j];
231  if(i<currRing->N-1) pSetExp(m,i+2,k-j);
232  }
233  if(n==0)
234  {
235  pSetExp(m,1,j);
236  pSetm(m);
237  return m;
238  }
239  else
240  {
241  pLmDelete(&m);
242  return NULL;
243  }
244 }

◆ pcvP2CV() [1/3]

BOOLEAN pcvP2CV ( leftv  res,
leftv  h 
)

Definition at line 317 of file pcv.cc.

318 {
319  if(currRing)
320  {
321  const short t[]={3,LIST_CMD,INT_CMD,INT_CMD};
322  if (iiCheckTypes(h,t,1))
323  {
324  lists p=(lists)h->Data();
325  h=h->next;
326  int d0=(int)(long)h->Data();
327  h=h->next;
328  int d1=(int)(long)h->Data();
329  res->rtyp=LIST_CMD;
330  res->data=(void*)pcvP2CV(p,d0,d1);
331  return FALSE;
332  }
333  return TRUE;
334  }
335  WerrorS("no ring active");
336  return TRUE;
337 }
poly pcvP2CV(poly p, int d0, int d1)
Definition: pcv.cc:246

◆ pcvP2CV() [2/3]

lists pcvP2CV ( lists  pl,
int  d0,
int  d1 
)

Definition at line 283 of file pcv.cc.

284 {
286  cvl->Init(pl->nr+1);
287  pcvInit(d1);
288  for(int i=pl->nr;i>=0;i--)
289  {
290  if(pl->m[i].rtyp==POLY_CMD)
291  {
292  cvl->m[i].rtyp=VECTOR_CMD;
293  cvl->m[i].data=pcvP2CV((poly)pl->m[i].data,d0,d1);
294  }
295  }
296  pcvClean();
297  return cvl;
298 }

◆ pcvP2CV() [3/3]

poly pcvP2CV ( poly  p,
int  d0,
int  d1 
)

Definition at line 246 of file pcv.cc.

247 {
248  poly cv=NULL;
249  while(p)
250  {
251  int d=pcvDeg(p);
252  if(d0<=d&&d<d1)
253  {
254  poly c=pNSet(nCopy(pGetCoeff(p)));
255  pSetComp(c,pcvM2N(p));
256  cv=pAdd(cv,c);
257  }
258  pIter(p);
259  }
260  return cv;
261 }
int pcvM2N(poly m)
Definition: pcv.cc:203
#define pNSet(n)
Definition: polys.h:299
#define pSetComp(p, v)
Definition: polys.h:38

◆ pcvPMulL() [1/2]

BOOLEAN pcvPMulL ( leftv  res,
leftv  h 
)

Definition at line 86 of file pcv.cc.

87 {
88  const short t[]={2,POLY_CMD,LIST_CMD};
89  if (iiCheckTypes(h,t,1))
90  {
91  poly p=(poly)h->Data();
92  h=h->next;
93  lists l=(lists)h->Data();
94  res->rtyp=LIST_CMD;
95  res->data=(void*)pcvPMulL(p,l);
96  return FALSE;
97  }
98  return TRUE;
99 }
lists pcvPMulL(poly p, lists l1)
Definition: pcv.cc:56

◆ pcvPMulL() [2/2]

lists pcvPMulL ( poly  p,
lists  l1 
)

Definition at line 56 of file pcv.cc.

57 {
59  l0->Init(l1->nr+1);
60  for(int i=l1->nr;i>=0;i--)
61  {
62  if(l1->m[i].rtyp==POLY_CMD)
63  {
64  l0->m[i].rtyp=POLY_CMD;
65  l0->m[i].data=ppMult_qq(p,(poly)l1->m[i].data);
66  }
67  }
68  return(l0);
69 }
#define ppMult_qq(p, q)
Definition: polys.h:195

Variable Documentation

◆ pcvIndex

unsigned** pcvIndex =NULL
static

Definition at line 29 of file pcv.cc.

◆ pcvIndexSize

int pcvIndexSize
static

Definition at line 27 of file pcv.cc.

◆ pcvMaxDegree

int pcvMaxDegree
static

Definition at line 25 of file pcv.cc.

◆ pcvTable

unsigned* pcvTable =NULL
static

Definition at line 28 of file pcv.cc.

◆ pcvTableSize

int pcvTableSize
static

Definition at line 26 of file pcv.cc.