Functions | Variables
simpleideals.cc File Reference
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <misc/options.h>
#include <misc/intvec.h>
#include "matpol.h"
#include "monomials/p_polys.h"
#include "weight.h"
#include "sbuckets.h"
#include "clapsing.h"
#include "simpleideals.h"

Go to the source code of this file.

Functions

ideal idInit (int idsize, int rank)
 
void idShow (const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
 
int id_PosConstant (ideal id, const ring r)
 index of generator with leading term in ground ring (if any); otherwise -1 More...
 
ideal id_MaxIdeal (const ring r)
 
void id_Delete (ideal *h, ring r)
 
void id_ShallowDelete (ideal *h, ring r)
 
void idSkipZeroes (ideal ide)
 
int idElem (const ideal F)
 number of non-zero polys in F More...
 
ideal id_CopyFirstK (const ideal ide, const int k, const ring r)
 
void id_Norm (ideal id, const ring r)
 
void id_DelMultiples (ideal id, const ring r)
 
void id_DelEquals (ideal id, const ring r)
 
void id_DelLmEquals (ideal id, const ring r)
 
void id_DelDiv (ideal id, const ring r)
 
BOOLEAN id_IsConstant (ideal id, const ring r)
 
ideal id_Copy (ideal h1, const ring r)
 
void id_DBTest (ideal h1, int level, const char *f, const int l, const ring r, const ring tailRing)
 
static int p_Comp_RevLex (poly a, poly b, BOOLEAN nolex, const ring R)
 3 for idSort: compare a and b revlex inclusive module comp. More...
 
intvecid_Sort (const ideal id, const BOOLEAN nolex, const ring r)
 sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE More...
 
ideal id_SimpleAdd (ideal h1, ideal h2, const ring R)
 
BOOLEAN idInsertPoly (ideal h1, poly h2)
 
BOOLEAN id_InsertPolyWithTests (ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
 insert h2 into h1 depending on the two boolean parameters: More...
 
ideal id_Add (ideal h1, ideal h2, const ring r)
 
ideal id_Mult (ideal h1, ideal h2, const ring r)
 
BOOLEAN idIs0 (ideal h)
 
long id_RankFreeModule (ideal s, ring lmRing, ring tailRing)
 
BOOLEAN idIsModule (ideal id, ring r)
 
BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r)
 
void idInitChoise (int r, int beg, int end, BOOLEAN *endch, int *choise)
 
void idGetNextChoise (int r, int end, BOOLEAN *endch, int *choise)
 
int idGetNumberOfChoise (int t, int d, int begin, int end, int *choise)
 
int binom (int n, int r)
 
ideal id_FreeModule (int i, const ring r)
 
static void makemonoms (int vars, int actvar, int deg, int monomdeg, const ring r)
 
ideal id_MaxIdeal (int deg, const ring r)
 
static void id_NextPotence (ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, const ring r)
 
ideal id_Power (ideal given, int exp, const ring r)
 
void id_Compactify (ideal id, const ring r)
 
ideal id_Head (ideal h, const ring r)
 
ideal id_Homogen (ideal h, int varnum, const ring r)
 
ideal id_Vec2Ideal (poly vec, const ring R)
 
ideal id_Matrix2Module (matrix mat, const ring R)
 
matrix id_Module2Matrix (ideal mod, const ring R)
 
matrix id_Module2formatedMatrix (ideal mod, int rows, int cols, const ring R)
 
ideal id_Subst (ideal id, int n, poly e, const ring r)
 
BOOLEAN id_HomModule (ideal m, ideal Q, intvec **w, const ring R)
 
ideal id_Jet (ideal i, int d, const ring R)
 
ideal id_JetW (ideal i, int d, intvec *iv, const ring R)
 
int id_ReadOutPivot (ideal arg, int *comp, const ring r)
 
intvecid_QHomWeight (ideal id, const ring r)
 
BOOLEAN id_IsZeroDim (ideal I, const ring r)
 
void id_Normalize (ideal I, const ring r)
 normialize all polys in id More...
 
int id_MinDegW (ideal M, intvec *w, const ring r)
 
ideal id_Transp (ideal a, const ring rRing)
 
ideal id_TensorModuleMult (const int m, const ideal M, const ring rRing)
 
ideal id_ChineseRemainder (ideal *xx, number *q, int rl, const ring r)
 
void id_Shift (ideal M, int s, const ring r)
 

Variables

omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal))
 
static polyidpower
 
static int idpowerpoint
 

Function Documentation

int binom ( int  n,
int  r 
)

Definition at line 877 of file simpleideals.cc.

878 {
879  int i,result;
880 
881  if (r==0) return 1;
882  if (n-r<r) return binom(n,n-r);
883  result = n-r+1;
884  for (i=2;i<=r;i++)
885  {
886  result *= n-r+i;
887  if (result<0)
888  {
889  WarnS("overflow in binomials");
890  return 0;
891  }
892  result /= i;
893  }
894  return result;
895 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define WarnS
Definition: emacs.cc:81
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
int binom(int n, int r)
return result
Definition: facAbsBiFact.cc:76
ideal id_Add ( ideal  h1,
ideal  h2,
const ring  r 
)

Definition at line 656 of file simpleideals.cc.

657 {
658  ideal result = id_SimpleAdd(h1,h2,r);
659  id_Compactify(result,r);
660  return result;
661 }
const ideal
Definition: gb_hack.h:42
const ring r
Definition: syzextra.cc:208
void id_Compactify(ideal id, const ring r)
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
return result
Definition: facAbsBiFact.cc:76
ideal id_ChineseRemainder ( ideal xx,
number *  q,
int  rl,
const ring  r 
)

Definition at line 1709 of file simpleideals.cc.

1710 {
1711  int cnt=IDELEMS(xx[0])*xx[0]->nrows;
1712  ideal result=idInit(cnt,xx[0]->rank);
1713  result->nrows=xx[0]->nrows; // for lifting matrices
1714  result->ncols=xx[0]->ncols; // for lifting matrices
1715  int i,j;
1716  number *x=(number *)omAlloc(rl*sizeof(number));
1717  poly *p=(poly *)omAlloc(rl*sizeof(poly));
1718  for(i=cnt-1;i>=0;i--)
1719  {
1720  for(j=rl-1;j>=0;j--)
1721  {
1722  p[j]=xx[j]->m[i];
1723  }
1724  result->m[i]=p_ChineseRemainder(p,x,q,rl,r);
1725  for(j=rl-1;j>=0;j--)
1726  {
1727  xx[j]->m[i]=p[j];
1728  }
1729  }
1730  omFreeSize(p,rl*sizeof(poly));
1731  omFreeSize(x,rl*sizeof(number));
1732  for(i=rl-1;i>=0;i--) id_Delete(&(xx[i]),r);
1733  omFreeSize(xx,rl*sizeof(ideal));
1734  return result;
1735 }
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
#define omAlloc(size)
Definition: omAllocDecl.h:210
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
poly p_ChineseRemainder(poly *xx, number *x, number *q, int rl, const ring R)
Definition: p_polys.cc:94
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
Variable x
Definition: cfModGcd.cc:4023
return result
Definition: facAbsBiFact.cc:76
void id_Compactify ( ideal  id,
const ring  r 
)

Definition at line 1052 of file simpleideals.cc.

1053 {
1054  int i;
1055  BOOLEAN b=FALSE;
1056 
1057  i = IDELEMS(id)-1;
1058  while ((! b) && (i>=0))
1059  {
1060  b=p_IsUnit(id->m[i],r);
1061  i--;
1062  }
1063  if (b)
1064  {
1065  for(i=IDELEMS(id)-1;i>=0;i--) p_Delete(&id->m[i],r);
1066  id->m[0]=p_One(r);
1067  }
1068  else
1069  {
1070  id_DelMultiples(id,r);
1071  }
1072  idSkipZeroes(id);
1073 }
#define FALSE
Definition: auxiliary.h:140
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition: p_polys.h:1808
const ring r
Definition: syzextra.cc:208
void id_DelMultiples(ideal id, const ring r)
poly p_One(const ring r)
Definition: p_polys.cc:1318
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
void idSkipZeroes(ideal ide)
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
ideal id_Copy ( ideal  h1,
const ring  r 
)

Definition at line 398 of file simpleideals.cc.

399 {
400  int i;
401  ideal h2;
402 
403 //#ifdef TEST
404  if (h1 == NULL)
405  {
406  h2=idInit(1,1);
407  }
408  else
409 //#endif
410  {
411  h2=idInit(IDELEMS(h1),h1->rank);
412  for (i=IDELEMS(h1)-1; i>=0; i--)
413  h2->m[i] = p_Copy(h1->m[i],r);
414  }
415  return h2;
416 }
const ideal
Definition: gb_hack.h:42
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
ideal id_CopyFirstK ( const ideal  ide,
const int  k,
const ring  r 
)

Definition at line 217 of file simpleideals.cc.

218 {
219  ideal newI = idInit(k, 0);
220  for (int i = 0; i < k; i++)
221  newI->m[i] = p_Copy(ide->m[i],r);
222  return newI;
223 }
const ideal
Definition: gb_hack.h:42
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
void id_DBTest ( ideal  h1,
int  level,
const char *  f,
const int  l,
const ring  r,
const ring  tailRing 
)

Definition at line 419 of file simpleideals.cc.

420 {
421  int i;
422 
423  if (h1 != NULL)
424  {
425  // assume(IDELEMS(h1) > 0); for ideal/module, does not apply to matrix
426  omCheckAddrSize(h1,sizeof(*h1));
427  omdebugAddrSize(h1->m,h1->ncols*h1->nrows*sizeof(poly));
428 
429  /* to be able to test matrices: */
430  for (i=(h1->ncols*h1->nrows)-1; i>=0; i--)
431  _pp_Test(h1->m[i], r, tailRing, level);
432 
433  int new_rk=id_RankFreeModule(h1, r, tailRing);
434  if(new_rk > h1->rank)
435  {
436  dReportError("wrong rank %d (should be %d) in %s:%d\n",
437  h1->rank, new_rk, f,l);
438  omPrintAddrInfo(stderr, h1, " for ideal");
439  h1->rank=new_rk;
440  }
441  }
442 }
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
int level(const CanonicalForm &f)
f
Definition: cfModGcd.cc:4022
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level)
Definition: pDebug.cc:332
void omPrintAddrInfo(FILE *fd, void *addr, const char *s)
Definition: omDebugCheck.c:445
const ring r
Definition: syzextra.cc:208
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
#define omdebugAddrSize(addr, size)
Definition: omAllocDecl.h:315
int dReportError(const char *fmt,...)
Definition: dError.cc:45
int l
Definition: cfEzgcd.cc:94
void id_DelDiv ( ideal  id,
const ring  r 
)

Definition at line 334 of file simpleideals.cc.

335 {
336  int i, j;
337  int k = IDELEMS(id)-1;
338  for (i=k; i>=0; i--)
339  {
340  if (id->m[i] != NULL)
341  {
342  for (j=k; j>i; j--)
343  {
344  if (id->m[j]!=NULL)
345  {
346 #ifdef HAVE_RINGS
347  if (rField_is_Ring(r))
348  {
349  if (p_DivisibleByRingCase(id->m[i], id->m[j],r))
350  {
351  p_Delete(&id->m[j],r);
352  }
353  else if (p_DivisibleByRingCase(id->m[j], id->m[i],r))
354  {
355  p_Delete(&id->m[i],r);
356  break;
357  }
358  }
359  else
360  {
361 #endif
362  /* the case of a ground field: */
363  if (p_DivisibleBy(id->m[i], id->m[j],r))
364  {
365  p_Delete(&id->m[j],r);
366  }
367  else if (p_DivisibleBy(id->m[j], id->m[i],r))
368  {
369  p_Delete(&id->m[i],r);
370  break;
371  }
372 #ifdef HAVE_RINGS
373  }
374 #endif
375  }
376  }
377  }
378  }
379 }
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1682
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
BOOLEAN p_DivisibleByRingCase(poly f, poly g, const ring r)
divisibility check over ground ring (which may contain zero divisors); TRUE iff LT(f) divides LT(g)...
Definition: p_polys.cc:1559
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:428
#define NULL
Definition: omList.c:10
void id_DelEquals ( ideal  id,
const ring  r 
)

Definition at line 283 of file simpleideals.cc.

284 {
285  int i, j;
286  int k = IDELEMS(id)-1;
287  for (i=k; i>=0; i--)
288  {
289  if (id->m[i]!=NULL)
290  {
291  for (j=k; j>i; j--)
292  {
293  if ((id->m[j]!=NULL)
294  && (p_EqualPolys(id->m[i], id->m[j],r)))
295  {
296  p_Delete(&id->m[j],r);
297  }
298  }
299  }
300  }
301 }
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4288
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define NULL
Definition: omList.c:10
void id_Delete ( ideal h,
ring  r 
)

Definition at line 119 of file simpleideals.cc.

120 {
121  int j,elems;
122  if (*h == NULL)
123  return;
124  elems=j=(*h)->nrows*(*h)->ncols;
125  if (j>0)
126  {
127  do
128  {
129  j--;
130  poly pp=((*h)->m[j]);
131  if (pp!=NULL) p_Delete(&pp, r);
132  }
133  while (j>0);
134  omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
135  }
137  *h=NULL;
138 }
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
poly pp
Definition: myNF.cc:296
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define NULL
Definition: omList.c:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
void id_DelLmEquals ( ideal  id,
const ring  r 
)

Definition at line 306 of file simpleideals.cc.

307 {
308  int i, j;
309  int k = IDELEMS(id)-1;
310  for (i=k; i>=0; i--)
311  {
312  if (id->m[i] != NULL)
313  {
314  for (j=k; j>i; j--)
315  {
316  if ((id->m[j] != NULL)
317  && p_LmEqual(id->m[i], id->m[j],r)
318 #ifdef HAVE_RINGS
319  && n_IsUnit(pGetCoeff(id->m[i]),r->cf) && n_IsUnit(pGetCoeff(id->m[j]),r->cf)
320 #endif
321  )
322  {
323  p_Delete(&id->m[j],r);
324  }
325  }
326  }
327  }
328 }
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:519
int k
Definition: cfEzgcd.cc:93
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
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1519
#define NULL
Definition: omList.c:10
void id_DelMultiples ( ideal  id,
const ring  r 
)

Definition at line 244 of file simpleideals.cc.

245 {
246  int i, j;
247  int k = IDELEMS(id)-1;
248  for (i=k; i>=0; i--)
249  {
250  if (id->m[i]!=NULL)
251  {
252  for (j=k; j>i; j--)
253  {
254  if (id->m[j]!=NULL)
255  {
256 #ifdef HAVE_RINGS
257  if (rField_is_Ring(r))
258  {
259  /* if id[j] = c*id[i] then delete id[j].
260  In the below cases of a ground field, we
261  check whether id[i] = c*id[j] and, if so,
262  delete id[j] for historical reasons (so
263  that previous output does not change) */
264  if (p_ComparePolys(id->m[j], id->m[i],r)) p_Delete(&id->m[j],r);
265  }
266  else
267  {
268  if (p_ComparePolys(id->m[i], id->m[j],r)) p_Delete(&id->m[j],r);
269  }
270 #else
271  if (p_ComparePolys(id->m[i], id->m[j],r)) p_Delete(&id->m[j],r);
272 #endif
273  }
274  }
275  }
276  }
277 }
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
Definition: p_polys.cc:4352
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:428
#define NULL
Definition: omList.c:10
ideal id_FreeModule ( int  i,
const ring  r 
)

Definition at line 900 of file simpleideals.cc.

901 {
902  int j;
903  ideal h;
904 
905  h=idInit(i,i);
906  for (j=0; j<i; j++)
907  {
908  h->m[j] = p_One(r);
909  p_SetComp(h->m[j],j+1,r);
910  p_SetmComp(h->m[j],r);
911  }
912  return h;
913 }
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
const ideal
Definition: gb_hack.h:42
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1318
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define p_SetmComp
Definition: p_polys.h:233
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
static Poly * h
Definition: janet.cc:978
ideal id_Head ( ideal  h,
const ring  r 
)

Definition at line 1078 of file simpleideals.cc.

1079 {
1080  ideal m = idInit(IDELEMS(h),h->rank);
1081  int i;
1082 
1083  for (i=IDELEMS(h)-1;i>=0; i--)
1084  {
1085  if (h->m[i]!=NULL) m->m[i]=p_Head(h->m[i],r);
1086  }
1087  return m;
1088 }
const ideal
Definition: gb_hack.h:42
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:819
const ring r
Definition: syzextra.cc:208
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
BOOLEAN id_HomIdeal ( ideal  id,
ideal  Q,
const ring  r 
)

Definition at line 769 of file simpleideals.cc.

770 {
771  int i;
772  BOOLEAN b;
773  if ((id == NULL) || (IDELEMS(id) == 0)) return TRUE;
774  i = 0;
775  b = TRUE;
776  while ((i < IDELEMS(id)) && b)
777  {
778  b = p_IsHomogeneous(id->m[i],r);
779  i++;
780  }
781  if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
782  {
783  i=0;
784  while ((i < IDELEMS(Q)) && b)
785  {
786  b = p_IsHomogeneous(Q->m[i],r);
787  i++;
788  }
789  }
790  return b;
791 }
BOOLEAN p_IsHomogeneous(poly p, const ring r)
Definition: p_polys.cc:3158
#define TRUE
Definition: auxiliary.h:144
#define Q
Definition: sirandom.c:25
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
BOOLEAN id_HomModule ( ideal  m,
ideal  Q,
intvec **  w,
const ring  R 
)

Definition at line 1245 of file simpleideals.cc.

1246 {
1247  if (w!=NULL) *w=NULL;
1248  if ((Q!=NULL) && (!id_HomIdeal(Q,NULL,R))) return FALSE;
1249  if (idIs0(m))
1250  {
1251  if (w!=NULL) (*w)=new intvec(m->rank);
1252  return TRUE;
1253  }
1254 
1255  long cmax=1,order=0,ord,* diff,diffmin=32000;
1256  int *iscom;
1257  int i;
1258  poly p=NULL;
1259  pFDegProc d;
1260  if (R->pLexOrder && (R->order[0]==ringorder_lp))
1261  d=p_Totaldegree;
1262  else
1263  d=R->pFDeg;
1264  int length=IDELEMS(m);
1265  poly* P=m->m;
1266  poly* F=(poly*)omAlloc(length*sizeof(poly));
1267  for (i=length-1;i>=0;i--)
1268  {
1269  p=F[i]=P[i];
1270  cmax=si_max(cmax,(long)p_MaxComp(p,R));
1271  }
1272  cmax++;
1273  diff = (long *)omAlloc0(cmax*sizeof(long));
1274  if (w!=NULL) *w=new intvec(cmax-1);
1275  iscom = (int *)omAlloc0(cmax*sizeof(int));
1276  i=0;
1277  while (i<=length)
1278  {
1279  if (i<length)
1280  {
1281  p=F[i];
1282  while ((p!=NULL) && (iscom[p_GetComp(p,R)]==0)) pIter(p);
1283  }
1284  if ((p==NULL) && (i<length))
1285  {
1286  i++;
1287  }
1288  else
1289  {
1290  if (p==NULL) /* && (i==length) */
1291  {
1292  i=0;
1293  while ((i<length) && (F[i]==NULL)) i++;
1294  if (i>=length) break;
1295  p = F[i];
1296  }
1297  //if (pLexOrder && (currRing->order[0]==ringorder_lp))
1298  // order=pTotaldegree(p);
1299  //else
1300  // order = p->order;
1301  // order = pFDeg(p,currRing);
1302  order = d(p,R) +diff[p_GetComp(p,R)];
1303  //order += diff[pGetComp(p)];
1304  p = F[i];
1305 //Print("Actual p=F[%d]: ",i);pWrite(p);
1306  F[i] = NULL;
1307  i=0;
1308  }
1309  while (p!=NULL)
1310  {
1311  if (R->pLexOrder && (R->order[0]==ringorder_lp))
1312  ord=p_Totaldegree(p,R);
1313  else
1314  // ord = p->order;
1315  ord = R->pFDeg(p,R);
1316  if (iscom[p_GetComp(p,R)]==0)
1317  {
1318  diff[p_GetComp(p,R)] = order-ord;
1319  iscom[p_GetComp(p,R)] = 1;
1320 /*
1321 *PrintS("new diff: ");
1322 *for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1323 *PrintLn();
1324 *PrintS("new iscom: ");
1325 *for (j=0;j<cmax;j++) Print("%d ",iscom[j]);
1326 *PrintLn();
1327 *Print("new set %d, order %d, ord %d, diff %d\n",pGetComp(p),order,ord,diff[pGetComp(p)]);
1328 */
1329  }
1330  else
1331  {
1332 /*
1333 *PrintS("new diff: ");
1334 *for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1335 *PrintLn();
1336 *Print("order %d, ord %d, diff %d\n",order,ord,diff[pGetComp(p)]);
1337 */
1338  if (order != (ord+diff[p_GetComp(p,R)]))
1339  {
1340  omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1341  omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1342  omFreeSize((ADDRESS) F,length*sizeof(poly));
1343  delete *w;*w=NULL;
1344  return FALSE;
1345  }
1346  }
1347  pIter(p);
1348  }
1349  }
1350  omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1351  omFreeSize((ADDRESS) F,length*sizeof(poly));
1352  for (i=1;i<cmax;i++) (**w)[i-1]=(int)(diff[i]);
1353  for (i=1;i<cmax;i++)
1354  {
1355  if (diff[i]<diffmin) diffmin=diff[i];
1356  }
1357  if (w!=NULL)
1358  {
1359  for (i=1;i<cmax;i++)
1360  {
1361  (**w)[i-1]=(int)(diff[i]-diffmin);
1362  }
1363  }
1364  omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1365  return TRUE;
1366 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
BOOLEAN idIs0(ideal h)
static gmp_float * diff
Definition: mpr_complex.cc:47
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
#define p_GetComp(p, r)
Definition: monomials.h:72
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define TRUE
Definition: auxiliary.h:144
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1435
void * ADDRESS
Definition: auxiliary.h:161
#define Q
Definition: sirandom.c:25
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define pIter(p)
Definition: monomials.h:44
Definition: intvec.h:16
polyrec * poly
Definition: hilb.h:10
int m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:46
#define R
Definition: sirandom.c:26
const CanonicalForm & w
Definition: facAbsFact.cc:55
kBucketDestroy & P
Definition: myNF.cc:191
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:281
ideal id_Homogen ( ideal  h,
int  varnum,
const ring  r 
)

Definition at line 1090 of file simpleideals.cc.

1091 {
1092  ideal m = idInit(IDELEMS(h),h->rank);
1093  int i;
1094 
1095  for (i=IDELEMS(h)-1;i>=0; i--)
1096  {
1097  m->m[i]=p_Homogen(h->m[i],varnum,r);
1098  }
1099  return m;
1100 }
poly p_Homogen(poly p, int varnum, const ring r)
Definition: p_polys.cc:3109
const ideal
Definition: gb_hack.h:42
const ring r
Definition: syzextra.cc:208
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
static Poly * h
Definition: janet.cc:978
BOOLEAN id_InsertPolyWithTests ( ideal  h1,
const int  validEntries,
const poly  h2,
const bool  zeroOk,
const bool  duplicateOk,
const ring  r 
)

insert h2 into h1 depending on the two boolean parameters:

  • if zeroOk is true, then h2 will also be inserted when it is zero
  • if duplicateOk is true, then h2 will also be inserted when it is already present in h1 return TRUE iff h2 was indeed inserted

Definition at line 629 of file simpleideals.cc.

631 {
632  if ((!zeroOk) && (h2 == NULL)) return FALSE;
633  if (!duplicateOk)
634  {
635  bool h2FoundInH1 = false;
636  int i = 0;
637  while ((i < validEntries) && (!h2FoundInH1))
638  {
639  h2FoundInH1 = p_EqualPolys(h1->m[i], h2,r);
640  i++;
641  }
642  if (h2FoundInH1) return FALSE;
643  }
644  if (validEntries == IDELEMS(h1))
645  {
646  pEnlargeSet(&(h1->m), IDELEMS(h1), 16);
647  IDELEMS(h1) += 16;
648  }
649  h1->m[validEntries] = h2;
650  return TRUE;
651 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4288
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3511
BOOLEAN id_IsConstant ( ideal  id,
const ring  r 
)

Definition at line 384 of file simpleideals.cc.

385 {
386  int k;
387  for (k = IDELEMS(id)-1; k>=0; k--)
388  {
389  if (!p_IsConstantPoly(id->m[k],r))
390  return FALSE;
391  }
392  return TRUE;
393 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
#define IDELEMS(i)
Definition: simpleideals.h:19
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1795
BOOLEAN id_IsZeroDim ( ideal  I,
const ring  r 
)

Definition at line 1535 of file simpleideals.cc.

1536 {
1537  BOOLEAN *UsedAxis=(BOOLEAN *)omAlloc0(rVar(r)*sizeof(BOOLEAN));
1538  int i,n;
1539  poly po;
1540  BOOLEAN res=TRUE;
1541  for(i=IDELEMS(I)-1;i>=0;i--)
1542  {
1543  po=I->m[i];
1544  if ((po!=NULL) &&((n=p_IsPurePower(po,r))!=0)) UsedAxis[n-1]=TRUE;
1545  }
1546  for(i=rVar(r)-1;i>=0;i--)
1547  {
1548  if(UsedAxis[i]==FALSE) {res=FALSE; break;} // not zero-dim.
1549  }
1550  omFreeSize(UsedAxis,rVar(r)*sizeof(BOOLEAN));
1551  return res;
1552 }
#define FALSE
Definition: auxiliary.h:140
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
#define TRUE
Definition: auxiliary.h:144
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition: p_polys.cc:1224
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
#define omAlloc0(size)
Definition: omAllocDecl.h:211
ideal id_Jet ( ideal  i,
int  d,
const ring  R 
)

Definition at line 1368 of file simpleideals.cc.

1369 {
1370  ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1371  r->nrows = i-> nrows;
1372  r->ncols = i-> ncols;
1373  //r->rank = i-> rank;
1374  int k;
1375  for(k=(i->nrows)*(i->ncols)-1;k>=0; k--)
1376  {
1377  r->m[k]=pp_Jet(i->m[k],d,R);
1378  }
1379  return r;
1380 }
const ideal
Definition: gb_hack.h:42
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
int nrows
Definition: cf_linsys.cc:32
int i
Definition: cfEzgcd.cc:123
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define R
Definition: sirandom.c:26
int int ncols
Definition: cf_linsys.cc:32
poly pp_Jet(poly p, int m, const ring R)
Definition: p_polys.cc:4134
ideal id_JetW ( ideal  i,
int  d,
intvec iv,
const ring  R 
)

Definition at line 1382 of file simpleideals.cc.

1383 {
1384  ideal r=idInit(IDELEMS(i),i->rank);
1385  if (ecartWeights!=NULL)
1386  {
1387  WerrorS("cannot compute weighted jets now");
1388  }
1389  else
1390  {
1391  short *w=iv2array(iv,R);
1392  int k;
1393  for(k=0; k<IDELEMS(i); k++)
1394  {
1395  r->m[k]=pp_JetW(i->m[k],d,w,R);
1396  }
1397  omFreeSize((ADDRESS)w,(rVar(R)+1)*sizeof(short));
1398  }
1399  return r;
1400 }
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:208
short * ecartWeights
Definition: weight0.c:32
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
const ideal
Definition: gb_hack.h:42
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
void * ADDRESS
Definition: auxiliary.h:161
void WerrorS(const char *s)
Definition: feFopen.cc:23
int k
Definition: cfEzgcd.cc:93
poly pp_JetW(poly p, int m, short *w, const ring R)
Definition: p_polys.cc:4179
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
const CanonicalForm & w
Definition: facAbsFact.cc:55
ideal id_Matrix2Module ( matrix  mat,
const ring  R 
)

Definition at line 1114 of file simpleideals.cc.

1115 {
1116  int mc=MATCOLS(mat);
1117  int mr=MATROWS(mat);
1118  ideal result = idInit(si_max(mc,1),si_max(mr,1));
1119  int i,j,l;
1120  poly h;
1122 
1123  for(j=0;j<mc /*MATCOLS(mat)*/;j++) /* j is also index in result->m */
1124  {
1125  for (i=1;i<=mr /*MATROWS(mat)*/;i++)
1126  {
1127  h = MATELEM(mat,i,j+1);
1128  if (h!=NULL)
1129  {
1130  l=pLength(h);
1131  MATELEM(mat,i,j+1)=NULL;
1132  p_SetCompP(h,i, R);
1133  sBucket_Merge_p(bucket, h, l);
1134  }
1135  }
1136  sBucketClearMerge(bucket, &(result->m[j]), &l);
1137  }
1138  sBucketDestroy(&bucket);
1139 
1140  // obachman: need to clean this up
1141  id_Delete((ideal*) &mat,R);
1142  return result;
1143 }
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
static int pLength(poly a)
Definition: p_polys.h:189
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:243
void sBucket_Merge_p(sBucket_pt bucket, poly p, int length)
Merges p into Spoly: assumes Bpoly and p have no common monoms destroys p!
Definition: sbuckets.cc:181
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:132
sBucket_pt sBucketCreate(ring r)
Definition: sbuckets.cc:125
P bucket
Definition: myNF.cc:79
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.cc:237
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:27
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
return result
Definition: facAbsBiFact.cc:76
#define MATELEM(mat, i, j)
Definition: matpol.h:29
ideal id_MaxIdeal ( const ring  r)

Definition at line 101 of file simpleideals.cc.

102 {
103  int l;
104  ideal hh=NULL;
105 
106  hh=idInit(rVar(r),1);
107  for (l=0; l<rVar(r); l++)
108  {
109  hh->m[l] = p_One(r);
110  p_SetExp(hh->m[l],l+1,1,r);
111  p_Setm(hh->m[l],r);
112  }
113  return hh;
114 }
const ideal
Definition: gb_hack.h:42
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1318
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
#define NULL
Definition: omList.c:10
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
int l
Definition: cfEzgcd.cc:94
ideal id_MaxIdeal ( int  deg,
const ring  r 
)

Definition at line 970 of file simpleideals.cc.

971 {
972  if (deg < 0)
973  {
974  WarnS("maxideal: power must be non-negative");
975  }
976  if (deg < 1)
977  {
978  ideal I=idInit(1,1);
979  I->m[0]=p_One(r);
980  return I;
981  }
982  if (deg == 1)
983  {
984  return id_MaxIdeal(r);
985  }
986 
987  int vars = rVar(r);
988  int i = binom(vars+deg-1,deg);
989  if (i<=0) return idInit(1,1);
990  ideal id=idInit(i,1);
991  idpower = id->m;
992  idpowerpoint = 0;
993  makemonoms(vars,1,deg,0,r);
994  idpower = NULL;
995  idpowerpoint = 0;
996  return id;
997 }
const ideal
Definition: gb_hack.h:42
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
#define WarnS
Definition: emacs.cc:81
ideal id_MaxIdeal(const ring r)
const ring r
Definition: syzextra.cc:208
static int idpowerpoint
Definition: simpleideals.cc:34
poly p_One(const ring r)
Definition: p_polys.cc:1318
int i
Definition: cfEzgcd.cc:123
int binom(int n, int r)
static void makemonoms(int vars, int actvar, int deg, int monomdeg, const ring r)
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
static poly * idpower
Definition: simpleideals.cc:32
int id_MinDegW ( ideal  M,
intvec w,
const ring  r 
)

Definition at line 1564 of file simpleideals.cc.

1565 {
1566  int d=-1;
1567  for(int i=0;i<IDELEMS(M);i++)
1568  {
1569  if (M->m[i]!=NULL)
1570  {
1571  int d0=p_MinDeg(M->m[i],w,r);
1572  if(-1<d0&&((d0<d)||(d==-1)))
1573  d=d0;
1574  }
1575  }
1576  return d;
1577 }
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4224
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
matrix id_Module2formatedMatrix ( ideal  mod,
int  rows,
int  cols,
const ring  R 
)

Definition at line 1194 of file simpleideals.cc.

1195 {
1196  matrix result = mpNew(rows,cols);
1197  int i,cp,r=id_RankFreeModule(mod,R),c=IDELEMS(mod);
1198  poly p,h;
1199 
1200  if (r>rows) r = rows;
1201  if (c>cols) c = cols;
1202  for(i=0;i<c;i++)
1203  {
1204  p=pReverse(mod->m[i]);
1205  mod->m[i]=NULL;
1206  while (p!=NULL)
1207  {
1208  h=p;
1209  pIter(p);
1210  pNext(h)=NULL;
1211  cp = p_GetComp(h,R);
1212  if (cp<=r)
1213  {
1214  p_SetComp(h,0,R);
1215  p_SetmComp(h,R);
1216  MATELEM(result,cp,i+1) = p_Add_q(MATELEM(result,cp,i+1),h,R);
1217  }
1218  else
1219  p_Delete(&h,R);
1220  }
1221  }
1222  id_Delete(&mod,R);
1223  return result;
1224 }
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
#define p_GetComp(p, r)
Definition: monomials.h:72
void id_Delete(ideal *h, ring r)
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static poly pReverse(poly p)
Definition: p_polys.h:324
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define p_SetmComp
Definition: p_polys.h:233
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:43
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static Poly * h
Definition: janet.cc:978
return result
Definition: facAbsBiFact.cc:76
#define MATELEM(mat, i, j)
Definition: matpol.h:29
matrix id_Module2Matrix ( ideal  mod,
const ring  R 
)

Definition at line 1148 of file simpleideals.cc.

1149 {
1150  matrix result = mpNew(mod->rank,IDELEMS(mod));
1151  long i; long cp;
1152  poly p,h;
1153 
1154  for(i=0;i<IDELEMS(mod);i++)
1155  {
1156  p=pReverse(mod->m[i]);
1157  mod->m[i]=NULL;
1158  while (p!=NULL)
1159  {
1160  h=p;
1161  pIter(p);
1162  pNext(h)=NULL;
1163  cp = si_max((long)1,p_GetComp(h, R)); // if used for ideals too
1164  //cp = p_GetComp(h,R);
1165  p_SetComp(h,0,R);
1166  p_SetmComp(h,R);
1167 #ifdef TEST
1168  if (cp>mod->rank)
1169  {
1170  Print("## inv. rank %ld -> %ld\n",mod->rank,cp);
1171  int k,l,o=mod->rank;
1172  mod->rank=cp;
1173  matrix d=mpNew(mod->rank,IDELEMS(mod));
1174  for (l=1; l<=o; l++)
1175  {
1176  for (k=1; k<=IDELEMS(mod); k++)
1177  {
1178  MATELEM(d,l,k)=MATELEM(result,l,k);
1179  MATELEM(result,l,k)=NULL;
1180  }
1181  }
1182  id_Delete((ideal *)&result,R);
1183  result=d;
1184  }
1185 #endif
1186  MATELEM(result,cp,i+1) = p_Add_q(MATELEM(result,cp,i+1),h,R);
1187  }
1188  }
1189  // obachman 10/99: added the following line, otherwise memory leack!
1190  id_Delete(&mod,R);
1191  return result;
1192 }
#define Print
Definition: emacs.cc:83
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
#define p_GetComp(p, r)
Definition: monomials.h:72
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
int k
Definition: cfEzgcd.cc:93
#define pIter(p)
Definition: monomials.h:44
polyrec * poly
Definition: hilb.h:10
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static poly pReverse(poly p)
Definition: p_polys.h:324
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
#define p_SetmComp
Definition: p_polys.h:233
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:43
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
return result
Definition: facAbsBiFact.cc:76
#define MATELEM(mat, i, j)
Definition: matpol.h:29
ideal id_Mult ( ideal  h1,
ideal  h2,
const ring  r 
)

Definition at line 666 of file simpleideals.cc.

667 {
668  int i,j,k;
669  ideal hh;
670 
671  j = IDELEMS(h1);
672  while ((j > 0) && (h1->m[j-1] == NULL)) j--;
673  i = IDELEMS(h2);
674  while ((i > 0) && (h2->m[i-1] == NULL)) i--;
675  j = j * i;
676  if (j == 0)
677  hh = idInit(1,1);
678  else
679  hh=idInit(j,1);
680  if (h1->rank<h2->rank)
681  hh->rank = h2->rank;
682  else
683  hh->rank = h1->rank;
684  if (j==0) return hh;
685  k = 0;
686  for (i=0; i<IDELEMS(h1); i++)
687  {
688  if (h1->m[i] != NULL)
689  {
690  for (j=0; j<IDELEMS(h2); j++)
691  {
692  if (h2->m[j] != NULL)
693  {
694  hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],r);
695  k++;
696  }
697  }
698  }
699  }
700  {
701  id_Compactify(hh,r);
702  return hh;
703  }
704 }
const ideal
Definition: gb_hack.h:42
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1075
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
void id_Compactify(ideal id, const ring r)
static void id_NextPotence ( ideal  given,
ideal  result,
int  begin,
int  end,
int  deg,
int  restdeg,
poly  ap,
const ring  r 
)
static

Definition at line 999 of file simpleideals.cc.

1001 {
1002  poly p;
1003  int i;
1004 
1005  p = p_Power(p_Copy(given->m[begin],r),restdeg,r);
1006  i = result->nrows;
1007  result->m[i] = p_Mult_q(p_Copy(ap,r),p,r);
1008 //PrintS(".");
1009  (result->nrows)++;
1010  if (result->nrows >= IDELEMS(result))
1011  {
1012  pEnlargeSet(&(result->m),IDELEMS(result),16);
1013  IDELEMS(result) += 16;
1014  }
1015  if (begin == end) return;
1016  for (i=restdeg-1;i>0;i--)
1017  {
1018  p = p_Power(p_Copy(given->m[begin],r),i,r);
1019  p = p_Mult_q(p_Copy(ap,r),p,r);
1020  id_NextPotence(given, result, begin+1, end, deg, restdeg-i, p,r);
1021  p_Delete(&p,r);
1022  }
1023  id_NextPotence(given, result, begin+1, end, deg, restdeg, ap,r);
1024 }
return P p
Definition: myNF.cc:203
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
const ring r
Definition: syzextra.cc:208
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, const ring r)
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3511
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1025
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2100
return result
Definition: facAbsBiFact.cc:76
void id_Norm ( ideal  id,
const ring  r 
)

Definition at line 229 of file simpleideals.cc.

230 {
231  for (int i=IDELEMS(id)-1; i>=0; i--)
232  {
233  if (id->m[i] != NULL)
234  {
235  p_Norm(id->m[i],r);
236  }
237  }
238 }
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3528
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
void id_Normalize ( ideal  I,
const ring  r 
)

normialize all polys in id

Definition at line 1554 of file simpleideals.cc.

1555 {
1556  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
1557  int i;
1558  for(i=I->nrows*I->ncols-1;i>=0;i--)
1559  {
1560  p_Normalize(I->m[i],r);
1561  }
1562 }
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:488
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3584
int id_PosConstant ( ideal  id,
const ring  r 
)

index of generator with leading term in ground ring (if any); otherwise -1

Definition at line 81 of file simpleideals.cc.

82 {
83  id_Test(id, r);
84  const int N = IDELEMS(id) - 1;
85  const poly * m = id->m + N;
86 
87  for (int k = N; k >= 0; --k, --m)
88  {
89  const poly p = *m;
90  if (p!=NULL)
91  if (p_LmIsConstantComp(p, r) == TRUE)
92  return k;
93  }
94 
95  return -1;
96 }
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:937
return P p
Definition: myNF.cc:203
#define id_Test(A, lR)
Definition: simpleideals.h:67
#define TRUE
Definition: auxiliary.h:144
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
polyrec * poly
Definition: hilb.h:10
int m
Definition: cfEzgcd.cc:119
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
ideal id_Power ( ideal  given,
int  exp,
const ring  r 
)

Definition at line 1026 of file simpleideals.cc.

1027 {
1028  ideal result,temp;
1029  poly p1;
1030  int i;
1031 
1032  if (idIs0(given)) return idInit(1,1);
1033  temp = id_Copy(given,r);
1034  idSkipZeroes(temp);
1035  i = binom(IDELEMS(temp)+exp-1,exp);
1036  result = idInit(i,1);
1037  result->nrows = 0;
1038 //Print("ideal contains %d elements\n",i);
1039  p1=p_One(r);
1040  id_NextPotence(temp,result,0,IDELEMS(temp)-1,exp,exp,p1,r);
1041  p_Delete(&p1,r);
1042  id_Delete(&temp,r);
1043  result->nrows = 1;
1044  id_DelEquals(result,r);
1045  idSkipZeroes(result);
1046  return result;
1047 }
BOOLEAN idIs0(ideal h)
ideal id_Copy(ideal h1, const ring r)
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1318
polyrec * poly
Definition: hilb.h:10
void id_DelEquals(ideal id, const ring r)
int i
Definition: cfEzgcd.cc:123
int binom(int n, int r)
#define IDELEMS(i)
Definition: simpleideals.h:19
void idSkipZeroes(ideal ide)
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, const ring r)
p exp[i]
Definition: DebugPrint.cc:39
return result
Definition: facAbsBiFact.cc:76
intvec* id_QHomWeight ( ideal  id,
const ring  r 
)

Definition at line 1488 of file simpleideals.cc.

1489 {
1490  poly head, tail;
1491  int k;
1492  int in=IDELEMS(id)-1, ready=0, all=0,
1493  coldim=rVar(r), rowmax=2*coldim;
1494  if (in<0) return NULL;
1495  intvec *imat=new intvec(rowmax+1,coldim,0);
1496 
1497  do
1498  {
1499  head = id->m[in--];
1500  if (head!=NULL)
1501  {
1502  tail = pNext(head);
1503  while (tail!=NULL)
1504  {
1505  all++;
1506  for (k=1;k<=coldim;k++)
1507  IMATELEM(*imat,all,k) = p_GetExpDiff(head,tail,k,r);
1508  if (all==rowmax)
1509  {
1510  ivTriangIntern(imat, ready, all);
1511  if (ready==coldim)
1512  {
1513  delete imat;
1514  return NULL;
1515  }
1516  }
1517  pIter(tail);
1518  }
1519  }
1520  } while (in>=0);
1521  if (all>ready)
1522  {
1523  ivTriangIntern(imat, ready, all);
1524  if (ready==coldim)
1525  {
1526  delete imat;
1527  return NULL;
1528  }
1529  }
1530  intvec *result = ivSolveKern(imat, ready);
1531  delete imat;
1532  return result;
1533 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
int k
Definition: cfEzgcd.cc:93
#define pIter(p)
Definition: monomials.h:44
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:631
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
polyrec * poly
Definition: hilb.h:10
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition: intvec.cc:399
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
CanonicalForm head(const CanonicalForm &f)
#define pNext(p)
Definition: monomials.h:43
intvec * ivSolveKern(intvec *imat, int dimtr)
Definition: intvec.cc:437
#define IMATELEM(M, I, J)
Definition: intvec.h:76
return result
Definition: facAbsBiFact.cc:76
long id_RankFreeModule ( ideal  s,
ring  lmRing,
ring  tailRing 
)

Definition at line 728 of file simpleideals.cc.

729 {
730  if (s!=NULL)
731  {
732  long j=0;
733 
735  {
736  poly *p=s->m;
737  for (unsigned int l=IDELEMS(s); l != 0; --l, ++p)
738  {
739  if (*p!=NULL)
740  {
741  pp_Test(*p, lmRing, tailRing);
742  const long k = p_MaxComp(*p, lmRing, tailRing);
743  if (k>j) j = k;
744  }
745  }
746  }
747  return j;
748  }
749  return -1;
750 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
BEGIN_NAMESPACE_SINGULARXX const ring lmRing
Definition: DebugPrint.h:30
return P p
Definition: myNF.cc:203
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:162
#define IDELEMS(i)
Definition: simpleideals.h:19
#define rRing_has_Comp(r)
Definition: monomials.h:274
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:281
int id_ReadOutPivot ( ideal  arg,
int comp,
const ring  r 
)

Definition at line 1406 of file simpleideals.cc.

1407 {
1408  if (idIs0(arg)) return -1;
1409  int i=0,j, generator=-1;
1410  int rk_arg=arg->rank; //idRankFreeModule(arg);
1411  int * componentIsUsed =(int *)omAlloc((rk_arg+1)*sizeof(int));
1412  poly p;
1413 
1414  while ((generator<0) && (i<IDELEMS(arg)))
1415  {
1416  memset(componentIsUsed,0,(rk_arg+1)*sizeof(int));
1417  p = arg->m[i];
1418  while (p!=NULL)
1419  {
1420  j = p_GetComp(p,r);
1421  if (componentIsUsed[j]==0)
1422  {
1423 #ifdef HAVE_RINGS
1424  if (p_LmIsConstantComp(p,r) &&
1425  (!rField_is_Ring(r) || n_IsUnit(pGetCoeff(p),r->cf)))
1426  {
1427 #else
1428  if (p_LmIsConstantComp(p,r))
1429  {
1430 #endif
1431  generator = i;
1432  componentIsUsed[j] = 1;
1433  }
1434  else
1435  {
1436  componentIsUsed[j] = -1;
1437  }
1438  }
1439  else if (componentIsUsed[j]>0)
1440  {
1441  (componentIsUsed[j])++;
1442  }
1443  pIter(p);
1444  }
1445  i++;
1446  }
1447  i = 0;
1448  *comp = -1;
1449  for (j=0;j<=rk_arg;j++)
1450  {
1451  if (componentIsUsed[j]>0)
1452  {
1453  if ((*comp==-1) || (componentIsUsed[j]<i))
1454  {
1455  *comp = j;
1456  i= componentIsUsed[j];
1457  }
1458  }
1459  }
1460  omFree(componentIsUsed);
1461  return generator;
1462 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
BOOLEAN idIs0(ideal h)
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:937
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:519
return P p
Definition: myNF.cc:203
#define p_GetComp(p, r)
Definition: monomials.h:72
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 omAlloc(size)
Definition: omAllocDecl.h:210
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:428
#define NULL
Definition: omList.c:10
void id_ShallowDelete ( ideal h,
ring  r 
)

Definition at line 144 of file simpleideals.cc.

145 {
146  int j,elems;
147  if (*h == NULL)
148  return;
149  elems=j=(*h)->nrows*(*h)->ncols;
150  if (j>0)
151  {
152  do
153  {
154  p_ShallowDelete(&((*h)->m[--j]), r);
155  }
156  while (j>0);
157  omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
158  }
160  *h=NULL;
161 }
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
void p_ShallowDelete(poly *p, const ring r)
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
#define NULL
Definition: omList.c:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
void id_Shift ( ideal  M,
int  s,
const ring  r 
)

Definition at line 1737 of file simpleideals.cc.

1738 {
1739  for(int i=IDELEMS(M)-1; i>=0;i--)
1740  {
1741  p_Shift(&(M->m[i]),s,r);
1742  }
1743  M->rank += s;
1744 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4482
ideal id_SimpleAdd ( ideal  h1,
ideal  h2,
const ring  R 
)

Definition at line 575 of file simpleideals.cc.

576 {
577  int i,j,r,l;
578  ideal result;
579 
580  if (h1==NULL) return id_Copy(h2,R);
581  if (h2==NULL) return id_Copy(h1,R);
582  j = IDELEMS(h1)-1;
583  while ((j >= 0) && (h1->m[j] == NULL)) j--;
584  i = IDELEMS(h2)-1;
585  while ((i >= 0) && (h2->m[i] == NULL)) i--;
586  r = si_max(h1->rank,h2->rank);
587  if (i+j==(-2))
588  return idInit(1,r);
589  else
590  result=idInit(i+j+2,r);
591  for (l=j; l>=0; l--)
592  {
593  result->m[l] = p_Copy(h1->m[l],R);
594  }
595  r = i+j+1;
596  for (l=i; l>=0; l--, r--)
597  {
598  result->m[r] = p_Copy(h2->m[l],R);
599  }
600  return result;
601 }
ideal id_Copy(ideal h1, const ring r)
const ideal
Definition: gb_hack.h:42
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94
intvec* id_Sort ( const ideal  id,
const BOOLEAN  nolex,
const ring  r 
)

sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE

Definition at line 480 of file simpleideals.cc.

481 {
482  intvec * result = new intvec(IDELEMS(id));
483  int i, j, actpos=0, newpos;
484  int diff, olddiff, lastcomp, newcomp;
485  BOOLEAN notFound;
486 
487  for (i=0;i<IDELEMS(id);i++)
488  {
489  if (id->m[i]!=NULL)
490  {
491  notFound = TRUE;
492  newpos = actpos / 2;
493  diff = (actpos+1) / 2;
494  diff = (diff+1) / 2;
495  lastcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
496  if (lastcomp<0)
497  {
498  newpos -= diff;
499  }
500  else if (lastcomp>0)
501  {
502  newpos += diff;
503  }
504  else
505  {
506  notFound = FALSE;
507  }
508  //while ((newpos>=0) && (newpos<actpos) && (notFound))
509  while (notFound && (newpos>=0) && (newpos<actpos))
510  {
511  newcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
512  olddiff = diff;
513  if (diff>1)
514  {
515  diff = (diff+1) / 2;
516  if ((newcomp==1)
517  && (actpos-newpos>1)
518  && (diff>1)
519  && (newpos+diff>=actpos))
520  {
521  diff = actpos-newpos-1;
522  }
523  else if ((newcomp==-1)
524  && (diff>1)
525  && (newpos<diff))
526  {
527  diff = newpos;
528  }
529  }
530  if (newcomp<0)
531  {
532  if ((olddiff==1) && (lastcomp>0))
533  notFound = FALSE;
534  else
535  newpos -= diff;
536  }
537  else if (newcomp>0)
538  {
539  if ((olddiff==1) && (lastcomp<0))
540  {
541  notFound = FALSE;
542  newpos++;
543  }
544  else
545  {
546  newpos += diff;
547  }
548  }
549  else
550  {
551  notFound = FALSE;
552  }
553  lastcomp = newcomp;
554  if (diff==0) notFound=FALSE; /*hs*/
555  }
556  if (newpos<0) newpos = 0;
557  if (newpos>actpos) newpos = actpos;
558  while ((newpos<actpos) && (p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r)==0))
559  newpos++;
560  for (j=actpos;j>newpos;j--)
561  {
562  (*result)[j] = (*result)[j-1];
563  }
564  (*result)[newpos] = i;
565  actpos++;
566  }
567  }
568  for (j=0;j<actpos;j++) (*result)[j]++;
569  return result;
570 }
static int p_Comp_RevLex(poly a, poly b, BOOLEAN nolex, const ring R)
3 for idSort: compare a and b revlex inclusive module comp.
static gmp_float * diff
Definition: mpr_complex.cc:47
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
return result
Definition: facAbsBiFact.cc:76
ideal id_Subst ( ideal  id,
int  n,
poly  e,
const ring  r 
)

Definition at line 1230 of file simpleideals.cc.

1231 {
1232  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
1234 
1235  res->rank = id->rank;
1236  for(k--;k>=0;k--)
1237  {
1238  res->m[k]=p_Subst(id->m[k],n,e,r);
1239  id->m[k]=NULL;
1240  }
1241  id_Delete(&id,r);
1242  return res;
1243 }
const ideal
Definition: gb_hack.h:42
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
void id_Delete(ideal *h, ring r)
poly p_Subst(poly p, int n, poly e, const ring r)
Definition: p_polys.cc:3728
int k
Definition: cfEzgcd.cc:93
poly res
Definition: myNF.cc:322
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
long rank
Definition: matpol.h:20
ideal id_TensorModuleMult ( const int  m,
const ideal  M,
const ring  rRing 
)

Definition at line 1629 of file simpleideals.cc.

1630 {
1631 // #ifdef DEBU
1632 // WarnS("tensorModuleMult!!!!");
1633 
1634  assume(m > 0);
1635  assume(M != NULL);
1636 
1637  const int n = rRing->N;
1638 
1639  assume(M->rank <= m * n);
1640 
1641  const int k = IDELEMS(M);
1642 
1643  ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
1644 
1645  for( int i = 0; i < k; i++ ) // for every w \in M
1646  {
1647  poly pTempSum = NULL;
1648 
1649  poly w = M->m[i];
1650 
1651  while(w != NULL) // for each term of w...
1652  {
1653  poly h = p_Head(w, rRing);
1654 
1655  const int gen = p_GetComp(h, rRing); // 1 ...
1656 
1657  assume(gen > 0);
1658  assume(gen <= n*m);
1659 
1660  // TODO: write a formula with %, / instead of while!
1661  /*
1662  int c = gen;
1663  int v = 1;
1664  while(c > m)
1665  {
1666  c -= m;
1667  v++;
1668  }
1669  */
1670 
1671  int cc = gen % m;
1672  if( cc == 0) cc = m;
1673  int vv = 1 + (gen - cc) / m;
1674 
1675 // assume( cc == c );
1676 // assume( vv == v );
1677 
1678  // 1<= c <= m
1679  assume( cc > 0 );
1680  assume( cc <= m );
1681 
1682  assume( vv > 0 );
1683  assume( vv <= n );
1684 
1685  assume( (cc + (vv-1)*m) == gen );
1686 
1687  p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
1688  p_SetComp(h, cc, rRing);
1689 
1690  p_Setm(h, rRing); // addjust degree after the previous steps!
1691 
1692  pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
1693 
1694  pIter(w);
1695  }
1696 
1697  idTemp->m[i] = pTempSum;
1698  }
1699 
1700  // simplify idTemp???
1701 
1702  ideal idResult = id_Transp(idTemp, rRing);
1703 
1704  id_Delete(&idTemp, rRing);
1705 
1706  return(idResult);
1707 }
ideal id_Transp(ideal a, const ring rRing)
static long p_IncrExp(poly p, int v, ring r)
Definition: p_polys.h:587
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
#define p_GetComp(p, r)
Definition: monomials.h:72
const ideal
Definition: gb_hack.h:42
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
void id_Delete(ideal *h, ring r)
int k
Definition: cfEzgcd.cc:93
#define pIter(p)
Definition: monomials.h:44
#define M
Definition: sirandom.c:24
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:819
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static Poly * h
Definition: janet.cc:978
ideal id_Transp ( ideal  a,
const ring  rRing 
)

Definition at line 1584 of file simpleideals.cc.

1585 {
1586  int r = a->rank, c = IDELEMS(a);
1587  ideal b = idInit(r,c);
1588 
1589  for (int i=c; i>0; i--)
1590  {
1591  poly p=a->m[i-1];
1592  while(p!=NULL)
1593  {
1594  poly h=p_Head(p, rRing);
1595  int co=p_GetComp(h, rRing)-1;
1596  p_SetComp(h, i, rRing);
1597  p_Setm(h, rRing);
1598  b->m[co] = p_Add_q(b->m[co], h, rRing);
1599  pIter(p);
1600  }
1601  }
1602  return b;
1603 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
#define p_GetComp(p, r)
Definition: monomials.h:72
const ideal
Definition: gb_hack.h:42
#define pIter(p)
Definition: monomials.h:44
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:819
const ring r
Definition: syzextra.cc:208
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static Poly * h
Definition: janet.cc:978
const poly b
Definition: syzextra.cc:213
ideal id_Vec2Ideal ( poly  vec,
const ring  R 
)

Definition at line 1103 of file simpleideals.cc.

1104 {
1105  ideal result=idInit(1,1);
1106  omFree((ADDRESS)result->m);
1107  result->m=NULL; // remove later
1108  p_Vec2Polys(vec, &(result->m), &(IDELEMS(result)),R);
1109  return result;
1110 }
const ideal
Definition: gb_hack.h:42
void * ADDRESS
Definition: auxiliary.h:161
fq_nmod_poly_t * vec
Definition: facHensel.cc:103
#define omFree(addr)
Definition: omAllocDecl.h:261
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3430
#define IDELEMS(i)
Definition: simpleideals.h:19
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
return result
Definition: facAbsBiFact.cc:76
int idElem ( const ideal  F)

number of non-zero polys in F

Definition at line 200 of file simpleideals.cc.

201 {
202  int i=0,j=IDELEMS(F)-1;
203 
204  while(j>=0)
205  {
206  if ((F->m)[j]!=NULL) i++;
207  j--;
208  }
209  return i;
210 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
void idGetNextChoise ( int  r,
int  end,
BOOLEAN endch,
int choise 
)

Definition at line 819 of file simpleideals.cc.

820 {
821  int i = r-1,j;
822  while ((i >= 0) && (choise[i] == end))
823  {
824  i--;
825  end--;
826  }
827  if (i == -1)
828  *endch = TRUE;
829  else
830  {
831  choise[i]++;
832  for (j=i+1; j<r; j++)
833  {
834  choise[j] = choise[i]+j-i;
835  }
836  *endch = FALSE;
837  }
838 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int idGetNumberOfChoise ( int  t,
int  d,
int  begin,
int  end,
int choise 
)

Definition at line 845 of file simpleideals.cc.

846 {
847  int * localchoise,i,result=0;
848  BOOLEAN b=FALSE;
849 
850  if (d<=1) return 1;
851  localchoise=(int*)omAlloc((d-1)*sizeof(int));
852  idInitChoise(d-1,begin,end,&b,localchoise);
853  while (!b)
854  {
855  result++;
856  i = 0;
857  while ((i<t) && (localchoise[i]==choise[i])) i++;
858  if (i>=t)
859  {
860  i = t+1;
861  while ((i<d) && (localchoise[i-1]==choise[i])) i++;
862  if (i>=d)
863  {
864  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
865  return result;
866  }
867  }
868  idGetNextChoise(d-1,end,&b,localchoise);
869  }
870  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
871  return 0;
872 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
#define FALSE
Definition: auxiliary.h:140
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
#define omAlloc(size)
Definition: omAllocDecl.h:210
int i
Definition: cfEzgcd.cc:123
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
return result
Definition: facAbsBiFact.cc:76
ideal idInit ( int  idsize,
int  rank 
)

Definition at line 40 of file simpleideals.cc.

41 {
42  /*- initialise an ideal -*/
44  hh->nrows = 1;
45  hh->rank = rank;
46  IDELEMS(hh) = idsize;
47  if (idsize>0)
48  {
49  hh->m = (poly *)omAlloc0(idsize*sizeof(poly));
50  }
51  else
52  hh->m=NULL;
53  return hh;
54 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
omBin sip_sideal_bin
Definition: simpleideals.cc:30
const ideal
Definition: gb_hack.h:42
polyrec * poly
Definition: hilb.h:10
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void idInitChoise ( int  r,
int  beg,
int  end,
BOOLEAN endch,
int choise 
)

Definition at line 797 of file simpleideals.cc.

798 {
799  /*returns the first choise of r numbers between beg and end*/
800  int i;
801  for (i=0; i<r; i++)
802  {
803  choise[i] = 0;
804  }
805  if (r <= end-beg+1)
806  for (i=0; i<r; i++)
807  {
808  choise[i] = beg+i;
809  }
810  if (r > end-beg+1)
811  *endch = TRUE;
812  else
813  *endch = FALSE;
814 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
BOOLEAN idInsertPoly ( ideal  h1,
poly  h2 
)

Definition at line 607 of file simpleideals.cc.

608 {
609  if (h2==NULL) return FALSE;
610  int j = IDELEMS(h1)-1;
611  while ((j >= 0) && (h1->m[j] == NULL)) j--;
612  j++;
613  if (j==IDELEMS(h1))
614  {
615  pEnlargeSet(&(h1->m),IDELEMS(h1),16);
616  IDELEMS(h1)+=16;
617  }
618  h1->m[j]=h2;
619  return TRUE;
620 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
int j
Definition: myNF.cc:70
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3511
BOOLEAN idIs0 ( ideal  h)

Definition at line 709 of file simpleideals.cc.

710 {
711  int i;
712 
713  if (h == NULL) return TRUE;
714  i = IDELEMS(h)-1;
715  while ((i >= 0) && (h->m[i] == NULL))
716  {
717  i--;
718  }
719  if (i < 0)
720  return TRUE;
721  else
722  return FALSE;
723 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
BOOLEAN idIsModule ( ideal  id,
ring  r 
)

Definition at line 752 of file simpleideals.cc.

753 {
754  if (id != NULL && rRing_has_Comp(r))
755  {
756  int j, l = IDELEMS(id);
757  for (j=0; j<l; j++)
758  {
759  if (id->m[j] != NULL && p_GetComp(id->m[j], r) > 0) return TRUE;
760  }
761  }
762  return FALSE;
763 }
#define FALSE
Definition: auxiliary.h:140
#define p_GetComp(p, r)
Definition: monomials.h:72
#define TRUE
Definition: auxiliary.h:144
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define IDELEMS(i)
Definition: simpleideals.h:19
#define rRing_has_Comp(r)
Definition: monomials.h:274
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
void idShow ( const ideal  id,
const ring  lmRing,
const ring  tailRing,
const int  debugPrint 
)

Definition at line 58 of file simpleideals.cc.

59 {
60  assume( debugPrint >= 0 );
61 
62  if( id == NULL )
63  PrintS("(NULL)");
64  else
65  {
66  Print("Module of rank %ld,real rank %ld and %d generators.\n",
67  id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id));
68 
69  int j = (id->ncols*id->nrows) - 1;
70  while ((j > 0) && (id->m[j]==NULL)) j--;
71  for (int i = 0; i <= j; i++)
72  {
73  Print("generator %d: ",i); p_DebugPrint(id->m[i], lmRing, tailRing, debugPrint);
74  }
75  }
76 }
void p_DebugPrint(poly p, const ring r)
Definition: ring.cc:4176
#define Print
Definition: emacs.cc:83
BEGIN_NAMESPACE_SINGULARXX const ring lmRing
Definition: DebugPrint.h:30
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
void idSkipZeroes ( ideal  ide)

Definition at line 166 of file simpleideals.cc.

167 {
168  int k;
169  int j = -1;
170  BOOLEAN change=FALSE;
171  for (k=0; k<IDELEMS(ide); k++)
172  {
173  if (ide->m[k] != NULL)
174  {
175  j++;
176  if (change)
177  {
178  ide->m[j] = ide->m[k];
179  }
180  }
181  else
182  {
183  change=TRUE;
184  }
185  }
186  if (change)
187  {
188  if (j == -1)
189  j = 0;
190  else
191  {
192  for (k=j+1; k<IDELEMS(ide); k++)
193  ide->m[k] = NULL;
194  }
195  pEnlargeSet(&(ide->m),IDELEMS(ide),j+1-IDELEMS(ide));
196  IDELEMS(ide) = j+1;
197  }
198 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
#define IDELEMS(i)
Definition: simpleideals.h:19
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3511
int BOOLEAN
Definition: auxiliary.h:131
static void makemonoms ( int  vars,
int  actvar,
int  deg,
int  monomdeg,
const ring  r 
)
static

Definition at line 927 of file simpleideals.cc.

928 {
929  poly p;
930  int i=0;
931 
932  if ((idpowerpoint == 0) && (actvar ==1))
933  {
935  monomdeg = 0;
936  }
937  while (i<=deg)
938  {
939  if (deg == monomdeg)
940  {
942  idpowerpoint++;
943  return;
944  }
945  if (actvar == vars)
946  {
947  p_SetExp(idpower[idpowerpoint],actvar,deg-monomdeg,r);
950  idpowerpoint++;
951  return;
952  }
953  else
954  {
956  makemonoms(vars,actvar+1,deg,monomdeg,r);
958  }
959  monomdeg++;
960  p_SetExp(idpower[idpowerpoint],actvar,p_GetExp(idpower[idpowerpoint],actvar,r)+1,r);
961  p_Setm(idpower[idpowerpoint],r);
962  p_Test(idpower[idpowerpoint],r);
963  i++;
964  }
965 }
return P p
Definition: myNF.cc:203
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
const ring r
Definition: syzextra.cc:208
static int idpowerpoint
Definition: simpleideals.cc:34
poly p_One(const ring r)
Definition: p_polys.cc:1318
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:465
polyrec * poly
Definition: hilb.h:10
int i
Definition: cfEzgcd.cc:123
#define p_Test(p, r)
Definition: p_polys.h:160
static void makemonoms(int vars, int actvar, int deg, int monomdeg, const ring r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
static poly * idpower
Definition: simpleideals.cc:32
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
static int p_Comp_RevLex ( poly  a,
poly  b,
BOOLEAN  nolex,
const ring  R 
)
static

3 for idSort: compare a and b revlex inclusive module comp.

Definition at line 446 of file simpleideals.cc.

447 {
448  if (b==NULL) return 1;
449  if (a==NULL) return -1;
450 
451  if (nolex)
452  {
453  int r=p_LmCmp(a,b,R);
454  if (r!=0) return r;
455  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
456  r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
457  n_Delete(&h, R->cf);
458  return r;
459  }
460  int l=rVar(R);
461  while ((l>0) && (p_GetExp(a,l,R)==p_GetExp(b,l,R))) l--;
462  if (l==0)
463  {
464  if (p_GetComp(a,R)==p_GetComp(b,R))
465  {
466  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
467  int r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
468  n_Delete(&h,R->cf);
469  return r;
470  }
471  if (p_GetComp(a,R)>p_GetComp(b,R)) return 1;
472  }
473  else if (p_GetExp(a,l,R)>p_GetExp(b,l,R))
474  return 1;
475  return -1;
476 }
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:666
const poly a
Definition: syzextra.cc:212
#define p_GetComp(p, r)
Definition: monomials.h:72
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
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
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:465
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1472
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:494
static Poly * h
Definition: janet.cc:978
const poly b
Definition: syzextra.cc:213
int l
Definition: cfEzgcd.cc:94

Variable Documentation

poly* idpower
static

Definition at line 32 of file simpleideals.cc.

int idpowerpoint
static

Definition at line 34 of file simpleideals.cc.

omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal))

Definition at line 30 of file simpleideals.cc.