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)
 initialise an ideal / module More...
 
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)
 initialise the maximal ideal (at 0) More...
 
void id_Delete (ideal *h, ring r)
 deletes an ideal/module/matrix More...
 
void id_ShallowDelete (ideal *h, ring r)
 Shallowdeletes an ideal/matrix. More...
 
void idSkipZeroes (ideal ide)
 gives an ideal/module the minimal possible size More...
 
int idElem (const ideal F)
 count non-zero elements More...
 
ideal id_CopyFirstK (const ideal ide, const int k, const ring r)
 copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (Note that the copied entries may be zero.) More...
 
void id_Norm (ideal id, const ring r)
 ideal id = (id[i]), result is leadcoeff(id[i]) = 1 More...
 
void id_DelMultiples (ideal id, const ring r)
 ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i More...
 
void id_DelEquals (ideal id, const ring r)
 ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i More...
 
void id_DelLmEquals (ideal id, const ring r)
 Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i. More...
 
void id_DelDiv (ideal id, const ring r)
 delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*LT(j) More...
 
BOOLEAN id_IsConstant (ideal id, const ring r)
 test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant More...
 
ideal id_Copy (ideal h1, const ring r)
 copy an ideal More...
 
void id_DBTest (ideal h1, int level, const char *f, const int l, const ring r, const ring tailRing)
 Internal verification for ideals/modules and dense matrices! More...
 
static int p_Comp_RevLex (poly a, poly b, BOOLEAN nolex, const ring R)
 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)
 concat the lists h1 and h2 without zeros More...
 
BOOLEAN idInsertPoly (ideal h1, poly h2)
 insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted More...
 
BOOLEAN idInsertPolyOnPos (ideal I, poly p, int pos)
 insert p into I on position pos More...
 
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)
 h1 + h2 More...
 
ideal id_Mult (ideal h1, ideal h2, const ring R)
 h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no columns at all) More...
 
BOOLEAN idIs0 (ideal h)
 returns true if h is the zero ideal More...
 
long id_RankFreeModule (ideal s, ring lmRing, ring tailRing)
 return the maximal component number found in any polynomial in s More...
 
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)
 the free module of rank i More...
 
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)
 returns the ideals of initial terms More...
 
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)
 transpose a module More...
 
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

◆ binom()

int binom ( int  n,
int  r 
)

Definition at line 911 of file simpleideals.cc.

912 {
913  int i,result;
914 
915  if (r==0) return 1;
916  if (n-r<r) return binom(n,n-r);
917  result = n-r+1;
918  for (i=2;i<=r;i++)
919  {
920  result *= n-r+i;
921  if (result<0)
922  {
923  WarnS("overflow in binomials");
924  return 0;
925  }
926  result /= i;
927  }
928  return result;
929 }
#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

◆ id_Add()

ideal id_Add ( ideal  h1,
ideal  h2,
const ring  r 
)

h1 + h2

Definition at line 712 of file simpleideals.cc.

713 {
714  id_Test(h1, r);
715  id_Test(h2, r);
716 
717  ideal result = id_SimpleAdd(h1,h2,r);
719  return result;
720 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
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)
concat the lists h1 and h2 without zeros
return result
Definition: facAbsBiFact.cc:76

◆ id_ChineseRemainder()

ideal id_ChineseRemainder ( ideal *  xx,
number *  q,
int  rl,
const ring  r 
)

Definition at line 1741 of file simpleideals.cc.

1742 {
1743  int cnt=0;int rw=0; int cl=0;
1744  int i,j;
1745  // find max. size of xx[.]:
1746  for(j=rl-1;j>=0;j--)
1747  {
1748  i=IDELEMS(xx[j])*xx[j]->nrows;
1749  if (i>cnt) cnt=i;
1750  if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices
1751  if (xx[j]->ncols >cl) cl=xx[j]->ncols; // for lifting matrices
1752  }
1753  if (rw*cl !=cnt)
1754  {
1755  WerrorS("format mismatch in CRT");
1756  return NULL;
1757  }
1758  ideal result=idInit(cnt,xx[0]->rank);
1759  result->nrows=rw; // for lifting matrices
1760  result->ncols=cl; // for lifting matrices
1761  number *x=(number *)omAlloc(rl*sizeof(number));
1762  poly *p=(poly *)omAlloc(rl*sizeof(poly));
1763  CFArray inv_cache(rl);
1764  for(i=cnt-1;i>=0;i--)
1765  {
1766  for(j=rl-1;j>=0;j--)
1767  {
1768  if(i>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal
1769  p[j]=NULL;
1770  else
1771  p[j]=xx[j]->m[i];
1772  }
1773  result->m[i]=p_ChineseRemainder(p,x,q,rl,inv_cache,r);
1774  for(j=rl-1;j>=0;j--)
1775  {
1776  if(i<IDELEMS(xx[j])*xx[j]->nrows) xx[j]->m[i]=p[j];
1777  }
1778  }
1779  omFreeSize(p,rl*sizeof(poly));
1780  omFreeSize(x,rl*sizeof(number));
1781  for(i=rl-1;i>=0;i--) id_Delete(&(xx[i]),r);
1782  omFreeSize(xx,rl*sizeof(ideal));
1783  return result;
1784 }
return P p
Definition: myNF.cc:203
cl
Definition: cfModGcd.cc:4041
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define omAlloc(size)
Definition: omAllocDecl.h:210
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int nrows
Definition: cf_linsys.cc:32
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
#define NULL
Definition: omList.c:10
int int ncols
Definition: cf_linsys.cc:32
poly p_ChineseRemainder(poly *xx, number *x, number *q, int rl, CFArray &inv_cache, const ring R)
Definition: p_polys.cc:94
Variable x
Definition: cfModGcd.cc:4023
polyrec * poly
Definition: hilb.h:10
return result
Definition: facAbsBiFact.cc:76

◆ id_Compactify()

void id_Compactify ( ideal  id,
const ring  r 
)

Definition at line 1085 of file simpleideals.cc.

1086 {
1087  int i;
1088  BOOLEAN b=FALSE;
1089 
1090  i = IDELEMS(id)-1;
1091  while ((! b) && (i>=0))
1092  {
1093  b=p_IsUnit(id->m[i],r);
1094  i--;
1095  }
1096  if (b)
1097  {
1098  for(i=IDELEMS(id)-1;i>=0;i--) p_Delete(&id->m[i],r);
1099  id->m[0]=p_One(r);
1100  }
1101  else
1102  {
1103  id_DelMultiples(id,r);
1104  }
1105  idSkipZeroes(id);
1106 }
#define FALSE
Definition: auxiliary.h:94
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition: p_polys.h:1903
const ring r
Definition: syzextra.cc:208
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i ...
poly p_One(const ring r)
Definition: p_polys.cc:1314
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213

◆ id_Copy()

ideal id_Copy ( ideal  h1,
const ring  r 
)

copy an ideal

Definition at line 402 of file simpleideals.cc.

403 {
404  id_Test(h1, r);
405 
406  ideal h2 = idInit(IDELEMS(h1), h1->rank);
407  for (int i=IDELEMS(h1)-1; i>=0; i--)
408  h2->m[i] = p_Copy(h1->m[i],r);
409  return h2;
410 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
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

◆ id_CopyFirstK()

ideal id_CopyFirstK ( const ideal  ide,
const int  k,
const ring  r 
)

copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (Note that the copied entries may be zero.)

Definition at line 224 of file simpleideals.cc.

225 {
226  id_Test(ide, r);
227 
228  assume( ide != NULL );
229  assume( k <= IDELEMS(ide) );
230 
231  ideal newI = idInit(k, ide->rank);
232 
233  for (int i = 0; i < k; i++)
234  newI->m[i] = p_Copy(ide->m[i],r);
235 
236  return newI;
237 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
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
#define NULL
Definition: omList.c:10

◆ id_DBTest()

void id_DBTest ( ideal  h1,
int  level,
const char *  f,
const int  l,
const ring  r,
const ring  tailRing 
)

Internal verification for ideals/modules and dense matrices!

Definition at line 414 of file simpleideals.cc.

415 {
416  if (h1 != NULL)
417  {
418  // assume(IDELEMS(h1) > 0); for ideal/module, does not apply to matrix
419  omCheckAddrSize(h1,sizeof(*h1));
420 
421  assume( h1->ncols >= 0 );
422  assume( h1->nrows >= 0 ); // matrix case!
423 
424  assume( h1->rank >= 0 );
425 
426  const int n = (h1->ncols * h1->nrows);
427 
428  assume( !( n > 0 && h1->m == NULL) );
429 
430  if( h1->m != NULL && n > 0 )
431  omdebugAddrSize(h1->m, n * sizeof(poly));
432 
433  long new_rk = 0; // inlining id_RankFreeModule(h1, r, tailRing);
434 
435  /* to be able to test matrices: */
436  for (int i=n - 1; i >= 0; i--)
437  {
438  _pp_Test(h1->m[i], r, tailRing, level);
439  const long k = p_MaxComp(h1->m[i], r, tailRing);
440  if (k > new_rk) new_rk = k;
441  }
442 
443  // dense matrices only contain polynomials:
444  // h1->nrows == h1->rank > 1 && new_rk == 0!
445  assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) ); //
446 
447  if(new_rk > h1->rank)
448  {
449  dReportError("wrong rank %d (should be %d) in %s:%d\n",
450  h1->rank, new_rk, f,l);
451  omPrintAddrInfo(stderr, h1, " for ideal");
452  h1->rank = new_rk;
453  }
454  }
455  else
456  {
457  Print("error: ideal==NULL in %s:%d\n",f,l);
458  assume( h1 != NULL );
459  }
460 }
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
int level(const CanonicalForm &f)
#define Print
Definition: emacs.cc:83
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
int k
Definition: cfEzgcd.cc:93
void omPrintAddrInfo(FILE *fd, void *addr, const char *s)
Definition: omDebugCheck.c:445
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
FILE * f
Definition: checklibs.c:9
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
polyrec * poly
Definition: hilb.h:10
int l
Definition: cfEzgcd.cc:94
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:287

◆ id_DelDiv()

void id_DelDiv ( ideal  id,
const ring  r 
)

delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*LT(j)

Definition at line 340 of file simpleideals.cc.

341 {
342  id_Test(id, r);
343 
344  int i, j;
345  int k = IDELEMS(id)-1;
346  for (i=k; i>=0; i--)
347  {
348  if (id->m[i] != NULL)
349  {
350  for (j=k; j>i; j--)
351  {
352  if (id->m[j]!=NULL)
353  {
354 #ifdef HAVE_RINGS
355  if (rField_is_Ring(r))
356  {
357  if (p_DivisibleByRingCase(id->m[i], id->m[j],r))
358  {
359  p_Delete(&id->m[j],r);
360  }
361  else if (p_DivisibleByRingCase(id->m[j], id->m[i],r))
362  {
363  p_Delete(&id->m[i],r);
364  break;
365  }
366  }
367  else
368 #endif
369  {
370  /* the case of a coefficient field: */
371  if (p_DivisibleBy(id->m[i], id->m[j],r))
372  {
373  p_Delete(&id->m[j],r);
374  }
375  else if (p_DivisibleBy(id->m[j], id->m[i],r))
376  {
377  p_Delete(&id->m[i],r);
378  break;
379  }
380  }
381  }
382  }
383  }
384  }
385 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
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:1777
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
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:1603
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10

◆ id_DelEquals()

void id_DelEquals ( ideal  id,
const ring  r 
)

ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i

Definition at line 289 of file simpleideals.cc.

290 {
291  id_Test(id, r);
292 
293  int i, j;
294  int k = IDELEMS(id)-1;
295  for (i=k; i>=0; i--)
296  {
297  if (id->m[i]!=NULL)
298  {
299  for (j=k; j>i; j--)
300  {
301  if ((id->m[j]!=NULL)
302  && (p_EqualPolys(id->m[i], id->m[j],r)))
303  {
304  p_Delete(&id->m[j],r);
305  }
306  }
307  }
308  }
309 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
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:24
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4367
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define NULL
Definition: omList.c:10

◆ id_Delete()

void id_Delete ( ideal *  h,
ring  r 
)

deletes an ideal/module/matrix

Definition at line 115 of file simpleideals.cc.

116 {
117  if (*h == NULL)
118  return;
119 
120  id_Test(*h, r);
121 
122  const int elems = (*h)->nrows * (*h)->ncols;
123 
124  if ( elems > 0 )
125  {
126  assume( (*h)->m != NULL );
127 
128  int j = elems;
129  do
130  {
131  j--;
132  poly pp=((*h)->m[j]);
133  if (pp!=NULL) p_Delete(&pp, r);
134  }
135  while (j>0);
136 
137  omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
138  }
139 
141  *h=NULL;
142 }
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define id_Test(A, lR)
Definition: simpleideals.h:80
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
poly pp
Definition: myNF.cc:296
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978

◆ id_DelLmEquals()

void id_DelLmEquals ( ideal  id,
const ring  r 
)

Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.

Definition at line 312 of file simpleideals.cc.

313 {
314  id_Test(id, r);
315 
316  int i, j;
317  int k = IDELEMS(id)-1;
318  for (i=k; i>=0; i--)
319  {
320  if (id->m[i] != NULL)
321  {
322  for (j=k; j>i; j--)
323  {
324  if ((id->m[j] != NULL)
325  && p_LmEqual(id->m[i], id->m[j],r)
326 #ifdef HAVE_RINGS
327  && n_IsUnit(pGetCoeff(id->m[i]),r->cf) && n_IsUnit(pGetCoeff(id->m[j]),r->cf)
328 #endif
329  )
330  {
331  p_Delete(&id->m[j],r);
332  }
333  }
334  }
335  }
336 }
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
#define id_Test(A, lR)
Definition: simpleideals.h:80
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:24
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1611
#define NULL
Definition: omList.c:10

◆ id_DelMultiples()

void id_DelMultiples ( ideal  id,
const ring  r 
)

ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i

Definition at line 254 of file simpleideals.cc.

255 {
256  id_Test(id, r);
257 
258  int i, j;
259  int k = IDELEMS(id)-1;
260  for (i=k; i>=0; i--)
261  {
262  if (id->m[i]!=NULL)
263  {
264  for (j=k; j>i; j--)
265  {
266  if (id->m[j]!=NULL)
267  {
268  if (rField_is_Ring(r))
269  {
270  /* if id[j] = c*id[i] then delete id[j].
271  In the below cases of a ground field, we
272  check whether id[i] = c*id[j] and, if so,
273  delete id[j] for historical reasons (so
274  that previous output does not change) */
275  if (p_ComparePolys(id->m[j], id->m[i],r)) p_Delete(&id->m[j],r);
276  }
277  else
278  {
279  if (p_ComparePolys(id->m[i], id->m[j],r)) p_Delete(&id->m[j],r);
280  }
281  }
282  }
283  }
284  }
285 }
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:4431
#define id_Test(A, lR)
Definition: simpleideals.h:80
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:24
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10

◆ id_FreeModule()

ideal id_FreeModule ( int  i,
const ring  r 
)

the free module of rank i

Definition at line 933 of file simpleideals.cc.

934 {
935  assume(i >= 0);
936  ideal h = idInit(i, i);
937 
938  for (int j=0; j<i; j++)
939  {
940  h->m[j] = p_One(r);
941  p_SetComp(h->m[j],j+1,r);
942  p_SetmComp(h->m[j],r);
943  }
944 
945  return h;
946 }
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1314
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
#define p_SetmComp
Definition: p_polys.h:239
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
static Poly * h
Definition: janet.cc:978

◆ id_Head()

ideal id_Head ( ideal  h,
const ring  r 
)

returns the ideals of initial terms

Definition at line 1109 of file simpleideals.cc.

1110 {
1111  ideal m = idInit(IDELEMS(h),h->rank);
1112 
1113  for (int i=IDELEMS(h)-1;i>=0; i--)
1114  if (h->m[i]!=NULL)
1115  m->m[i]=p_Head(h->m[i],r);
1116 
1117  return m;
1118 }
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
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:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978

◆ id_HomIdeal()

BOOLEAN id_HomIdeal ( ideal  id,
ideal  Q,
const ring  r 
)

Definition at line 804 of file simpleideals.cc.

805 {
806  int i;
807  BOOLEAN b;
808  i = 0;
809  b = TRUE;
810  while ((i < IDELEMS(id)) && b)
811  {
812  b = p_IsHomogeneous(id->m[i],r);
813  i++;
814  }
815  if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
816  {
817  i=0;
818  while ((i < IDELEMS(Q)) && b)
819  {
820  b = p_IsHomogeneous(Q->m[i],r);
821  i++;
822  }
823  }
824  return b;
825 }
BOOLEAN p_IsHomogeneous(poly p, const ring r)
Definition: p_polys.cc:3249
#define TRUE
Definition: auxiliary.h:98
#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:24
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213

◆ id_HomModule()

BOOLEAN id_HomModule ( ideal  m,
ideal  Q,
intvec **  w,
const ring  R 
)

Definition at line 1275 of file simpleideals.cc.

1276 {
1277  if (w!=NULL) *w=NULL;
1278  if ((Q!=NULL) && (!id_HomIdeal(Q,NULL,R))) return FALSE;
1279  if (idIs0(m))
1280  {
1281  if (w!=NULL) (*w)=new intvec(m->rank);
1282  return TRUE;
1283  }
1284 
1285  long cmax=1,order=0,ord,* diff,diffmin=32000;
1286  int *iscom;
1287  int i;
1288  poly p=NULL;
1289  pFDegProc d;
1290  if (R->pLexOrder && (R->order[0]==ringorder_lp))
1291  d=p_Totaldegree;
1292  else
1293  d=R->pFDeg;
1294  int length=IDELEMS(m);
1295  poly* P=m->m;
1296  poly* F=(poly*)omAlloc(length*sizeof(poly));
1297  for (i=length-1;i>=0;i--)
1298  {
1299  p=F[i]=P[i];
1300  cmax=si_max(cmax,p_MaxComp(p,R));
1301  }
1302  cmax++;
1303  diff = (long *)omAlloc0(cmax*sizeof(long));
1304  if (w!=NULL) *w=new intvec(cmax-1);
1305  iscom = (int *)omAlloc0(cmax*sizeof(int));
1306  i=0;
1307  while (i<=length)
1308  {
1309  if (i<length)
1310  {
1311  p=F[i];
1312  while ((p!=NULL) && (iscom[p_GetComp(p,R)]==0)) pIter(p);
1313  }
1314  if ((p==NULL) && (i<length))
1315  {
1316  i++;
1317  }
1318  else
1319  {
1320  if (p==NULL) /* && (i==length) */
1321  {
1322  i=0;
1323  while ((i<length) && (F[i]==NULL)) i++;
1324  if (i>=length) break;
1325  p = F[i];
1326  }
1327  //if (pLexOrder && (currRing->order[0]==ringorder_lp))
1328  // order=pTotaldegree(p);
1329  //else
1330  // order = p->order;
1331  // order = pFDeg(p,currRing);
1332  order = d(p,R) +diff[p_GetComp(p,R)];
1333  //order += diff[pGetComp(p)];
1334  p = F[i];
1335 //Print("Actual p=F[%d]: ",i);pWrite(p);
1336  F[i] = NULL;
1337  i=0;
1338  }
1339  while (p!=NULL)
1340  {
1341  if (R->pLexOrder && (R->order[0]==ringorder_lp))
1342  ord=p_Totaldegree(p,R);
1343  else
1344  // ord = p->order;
1345  ord = R->pFDeg(p,R);
1346  if (iscom[p_GetComp(p,R)]==0)
1347  {
1348  diff[p_GetComp(p,R)] = order-ord;
1349  iscom[p_GetComp(p,R)] = 1;
1350 /*
1351 *PrintS("new diff: ");
1352 *for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1353 *PrintLn();
1354 *PrintS("new iscom: ");
1355 *for (j=0;j<cmax;j++) Print("%d ",iscom[j]);
1356 *PrintLn();
1357 *Print("new set %d, order %d, ord %d, diff %d\n",pGetComp(p),order,ord,diff[pGetComp(p)]);
1358 */
1359  }
1360  else
1361  {
1362 /*
1363 *PrintS("new diff: ");
1364 *for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1365 *PrintLn();
1366 *Print("order %d, ord %d, diff %d\n",order,ord,diff[pGetComp(p)]);
1367 */
1368  if (order != (ord+diff[p_GetComp(p,R)]))
1369  {
1370  omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1371  omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1372  omFreeSize((ADDRESS) F,length*sizeof(poly));
1373  delete *w;*w=NULL;
1374  return FALSE;
1375  }
1376  }
1377  pIter(p);
1378  }
1379  }
1380  omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1381  omFreeSize((ADDRESS) F,length*sizeof(poly));
1382  for (i=1;i<cmax;i++) (**w)[i-1]=(int)(diff[i]);
1383  for (i=1;i<cmax;i++)
1384  {
1385  if (diff[i]<diffmin) diffmin=diff[i];
1386  }
1387  if (w!=NULL)
1388  {
1389  for (i=1;i<cmax;i++)
1390  {
1391  (**w)[i-1]=(int)(diff[i]-diffmin);
1392  }
1393  }
1394  omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1395  return TRUE;
1396 }
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static gmp_float * diff
Definition: mpr_complex.cc:47
#define FALSE
Definition: auxiliary.h:94
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:98
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1430
void * ADDRESS
Definition: auxiliary.h:115
#define Q
Definition: sirandom.c:25
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define pIter(p)
Definition: monomials.h:44
Definition: intvec.h:14
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:46
const CanonicalForm & w
Definition: facAbsFact.cc:55
kBucketDestroy & P
Definition: myNF.cc:191
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:287

◆ id_Homogen()

ideal id_Homogen ( ideal  h,
int  varnum,
const ring  r 
)

Definition at line 1120 of file simpleideals.cc.

1121 {
1122  ideal m = idInit(IDELEMS(h),h->rank);
1123  int i;
1124 
1125  for (i=IDELEMS(h)-1;i>=0; i--)
1126  {
1127  m->m[i]=p_Homogen(h->m[i],varnum,r);
1128  }
1129  return m;
1130 }
poly p_Homogen(poly p, int varnum, const ring r)
Definition: p_polys.cc:3200
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:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
static Poly * h
Definition: janet.cc:978

◆ id_InsertPolyWithTests()

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 684 of file simpleideals.cc.

686 {
687  id_Test(h1, r);
688  p_Test(h2, r);
689 
690  if ((!zeroOk) && (h2 == NULL)) return FALSE;
691  if (!duplicateOk)
692  {
693  bool h2FoundInH1 = false;
694  int i = 0;
695  while ((i < validEntries) && (!h2FoundInH1))
696  {
697  h2FoundInH1 = p_EqualPolys(h1->m[i], h2,r);
698  i++;
699  }
700  if (h2FoundInH1) return FALSE;
701  }
702  if (validEntries == IDELEMS(h1))
703  {
704  pEnlargeSet(&(h1->m), IDELEMS(h1), 16);
705  IDELEMS(h1) += 16;
706  }
707  h1->m[validEntries] = h2;
708  return TRUE;
709 }
#define FALSE
Definition: auxiliary.h:94
#define id_Test(A, lR)
Definition: simpleideals.h:80
#define TRUE
Definition: auxiliary.h:98
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4367
#define p_Test(p, r)
Definition: p_polys.h:160
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3602

◆ id_IsConstant()

BOOLEAN id_IsConstant ( ideal  id,
const ring  r 
)

test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant

Definition at line 389 of file simpleideals.cc.

390 {
391  id_Test(id, r);
392 
393  for (int k = IDELEMS(id)-1; k>=0; k--)
394  {
395  if (!p_IsConstantPoly(id->m[k],r))
396  return FALSE;
397  }
398  return TRUE;
399 }
#define FALSE
Definition: auxiliary.h:94
#define id_Test(A, lR)
Definition: simpleideals.h:80
#define TRUE
Definition: auxiliary.h:98
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
#define IDELEMS(i)
Definition: simpleideals.h:24
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1890

◆ id_IsZeroDim()

BOOLEAN id_IsZeroDim ( ideal  I,
const ring  r 
)

Definition at line 1559 of file simpleideals.cc.

1560 {
1561  BOOLEAN *UsedAxis=(BOOLEAN *)omAlloc0(rVar(r)*sizeof(BOOLEAN));
1562  int i,n;
1563  poly po;
1564  BOOLEAN res=TRUE;
1565  for(i=IDELEMS(I)-1;i>=0;i--)
1566  {
1567  po=I->m[i];
1568  if ((po!=NULL) &&((n=p_IsPurePower(po,r))!=0)) UsedAxis[n-1]=TRUE;
1569  }
1570  for(i=rVar(r)-1;i>=0;i--)
1571  {
1572  if(UsedAxis[i]==FALSE) {res=FALSE; break;} // not zero-dim.
1573  }
1574  omFreeSize(UsedAxis,rVar(r)*sizeof(BOOLEAN));
1575  return res;
1576 }
#define FALSE
Definition: auxiliary.h:94
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#define TRUE
Definition: auxiliary.h:98
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition: p_polys.cc:1227
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:85
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ id_Jet()

ideal id_Jet ( ideal  i,
int  d,
const ring  R 
)

Definition at line 1398 of file simpleideals.cc.

1399 {
1400  ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1401  r->nrows = i-> nrows;
1402  r->ncols = i-> ncols;
1403  //r->rank = i-> rank;
1404 
1405  for(int k=(i->nrows)*(i->ncols)-1;k>=0; k--)
1406  r->m[k]=pp_Jet(i->m[k],d,R);
1407 
1408  return r;
1409 }
int k
Definition: cfEzgcd.cc:93
const ring r
Definition: syzextra.cc:208
int nrows
Definition: cf_linsys.cc:32
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
int int ncols
Definition: cf_linsys.cc:32
poly pp_Jet(poly p, int m, const ring R)
Definition: p_polys.cc:4213

◆ id_JetW()

ideal id_JetW ( ideal  i,
int  d,
intvec iv,
const ring  R 
)

Definition at line 1411 of file simpleideals.cc.

1412 {
1413  ideal r=idInit(IDELEMS(i),i->rank);
1414  if (ecartWeights!=NULL)
1415  {
1416  WerrorS("cannot compute weighted jets now");
1417  }
1418  else
1419  {
1420  short *w=iv2array(iv,R);
1421  int k;
1422  for(k=0; k<IDELEMS(i); k++)
1423  {
1424  r->m[k]=pp_JetW(i->m[k],d,w,R);
1425  }
1426  omFreeSize((ADDRESS)w,(rVar(R)+1)*sizeof(short));
1427  }
1428  return r;
1429 }
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:208
short * ecartWeights
Definition: weight0.c:28
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void * ADDRESS
Definition: auxiliary.h:115
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
poly pp_JetW(poly p, int m, short *w, const ring R)
Definition: p_polys.cc:4258
const ring r
Definition: syzextra.cc:208
const ring R
Definition: DebugPrint.cc:36
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
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ id_Matrix2Module()

ideal id_Matrix2Module ( matrix  mat,
const ring  R 
)

Definition at line 1144 of file simpleideals.cc.

1145 {
1146  int mc=MATCOLS(mat);
1147  int mr=MATROWS(mat);
1148  ideal result = idInit(mc,mr);
1149  int i,j,l;
1150  poly h;
1152 
1153  for(j=0;j<mc /*MATCOLS(mat)*/;j++) /* j is also index in result->m */
1154  {
1155  for (i=1;i<=mr /*MATROWS(mat)*/;i++)
1156  {
1157  h = MATELEM(mat,i,j+1);
1158  if (h!=NULL)
1159  {
1160  l=pLength(h);
1161  MATELEM(mat,i,j+1)=NULL;
1162  p_SetCompP(h,i, R);
1164  }
1165  }
1166  sBucketClearMerge(bucket, &(result->m[j]), &l);
1167  }
1169 
1170  // obachman: need to clean this up
1171  id_Delete((ideal*) &mat,R);
1172  return result;
1173 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
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:176
int j
Definition: myNF.cc:70
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:127
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:120
const ring R
Definition: DebugPrint.cc:36
P bucket
Definition: myNF.cc:79
int i
Definition: cfEzgcd.cc:123
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.cc:232
static unsigned pLength(poly a)
Definition: p_polys.h:189
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
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

◆ id_MaxIdeal() [1/2]

ideal id_MaxIdeal ( const ring  r)

initialise the maximal ideal (at 0)

Definition at line 101 of file simpleideals.cc.

102 {
103  ideal hh = idInit(rVar(r), 1);
104  for (int l=rVar(r)-1; l>=0; l--)
105  {
106  hh->m[l] = p_One(r);
107  p_SetExp(hh->m[l],l+1,1,r);
108  p_Setm(hh->m[l],r);
109  }
110  id_Test(hh, r);
111  return hh;
112 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1314
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
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:483
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
int l
Definition: cfEzgcd.cc:94

◆ id_MaxIdeal() [2/2]

ideal id_MaxIdeal ( int  deg,
const ring  r 
)

Definition at line 1003 of file simpleideals.cc.

1004 {
1005  if (deg < 0)
1006  {
1007  WarnS("maxideal: power must be non-negative");
1008  }
1009  if (deg < 1)
1010  {
1011  ideal I=idInit(1,1);
1012  I->m[0]=p_One(r);
1013  return I;
1014  }
1015  if (deg == 1)
1016  {
1017  return id_MaxIdeal(r);
1018  }
1019 
1020  int vars = rVar(r);
1021  int i = binom(vars+deg-1,deg);
1022  if (i<=0) return idInit(1,1);
1023  ideal id=idInit(i,1);
1024  idpower = id->m;
1025  idpowerpoint = 0;
1026  makemonoms(vars,1,deg,0,r);
1027  idpower = NULL;
1028  idpowerpoint = 0;
1029  return id;
1030 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#define WarnS
Definition: emacs.cc:81
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
const ring r
Definition: syzextra.cc:208
static int idpowerpoint
Definition: simpleideals.cc:34
poly p_One(const ring r)
Definition: p_polys.cc:1314
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)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
static poly * idpower
Definition: simpleideals.cc:32

◆ id_MinDegW()

int id_MinDegW ( ideal  M,
intvec w,
const ring  r 
)

Definition at line 1588 of file simpleideals.cc.

1589 {
1590  int d=-1;
1591  for(int i=0;i<IDELEMS(M);i++)
1592  {
1593  if (M->m[i]!=NULL)
1594  {
1595  int d0=p_MinDeg(M->m[i],w,r);
1596  if(-1<d0&&((d0<d)||(d==-1)))
1597  d=d0;
1598  }
1599  }
1600  return d;
1601 }
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4303
#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:24
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55

◆ id_Module2formatedMatrix()

matrix id_Module2formatedMatrix ( ideal  mod,
int  rows,
int  cols,
const ring  R 
)

Definition at line 1224 of file simpleideals.cc.

1225 {
1226  matrix result = mpNew(rows,cols);
1227  int i,cp,r=id_RankFreeModule(mod,R),c=IDELEMS(mod);
1228  poly p,h;
1229 
1230  if (r>rows) r = rows;
1231  if (c>cols) c = cols;
1232  for(i=0;i<c;i++)
1233  {
1234  p=pReverse(mod->m[i]);
1235  mod->m[i]=NULL;
1236  while (p!=NULL)
1237  {
1238  h=p;
1239  pIter(p);
1240  pNext(h)=NULL;
1241  cp = p_GetComp(h,R);
1242  if (cp<=r)
1243  {
1244  p_SetComp(h,0,R);
1245  p_SetmComp(h,R);
1246  MATELEM(result,cp,i+1) = p_Add_q(MATELEM(result,cp,i+1),h,R);
1247  }
1248  else
1249  p_Delete(&h,R);
1250  }
1251  }
1252  id_Delete(&mod,R);
1253  return result;
1254 }
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:242
#define p_GetComp(p, r)
Definition: monomials.h:72
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
static poly pReverse(poly p)
Definition: p_polys.h:330
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define p_SetmComp
Definition: p_polys.h:239
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static Poly * h
Definition: janet.cc:978
return result
Definition: facAbsBiFact.cc:76
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ id_Module2Matrix()

matrix id_Module2Matrix ( ideal  mod,
const ring  R 
)

Definition at line 1178 of file simpleideals.cc.

1179 {
1180  matrix result = mpNew(mod->rank,IDELEMS(mod));
1181  long i; long cp;
1182  poly p,h;
1183 
1184  for(i=0;i<IDELEMS(mod);i++)
1185  {
1186  p=pReverse(mod->m[i]);
1187  mod->m[i]=NULL;
1188  while (p!=NULL)
1189  {
1190  h=p;
1191  pIter(p);
1192  pNext(h)=NULL;
1193  cp = si_max(1L,p_GetComp(h, R)); // if used for ideals too
1194  //cp = p_GetComp(h,R);
1195  p_SetComp(h,0,R);
1196  p_SetmComp(h,R);
1197 #ifdef TEST
1198  if (cp>mod->rank)
1199  {
1200  Print("## inv. rank %ld -> %ld\n",mod->rank,cp);
1201  int k,l,o=mod->rank;
1202  mod->rank=cp;
1203  matrix d=mpNew(mod->rank,IDELEMS(mod));
1204  for (l=1; l<=o; l++)
1205  {
1206  for (k=1; k<=IDELEMS(mod); k++)
1207  {
1208  MATELEM(d,l,k)=MATELEM(result,l,k);
1209  MATELEM(result,l,k)=NULL;
1210  }
1211  }
1212  id_Delete((ideal *)&result,R);
1213  result=d;
1214  }
1215 #endif
1216  MATELEM(result,cp,i+1) = p_Add_q(MATELEM(result,cp,i+1),h,R);
1217  }
1218  }
1219  // obachman 10/99: added the following line, otherwise memory leack!
1220  id_Delete(&mod,R);
1221  return result;
1222 }
#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:242
#define p_GetComp(p, r)
Definition: monomials.h:72
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int k
Definition: cfEzgcd.cc:93
#define pIter(p)
Definition: monomials.h:44
const ring R
Definition: DebugPrint.cc:36
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
static poly pReverse(poly p)
Definition: p_polys.h:330
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define p_SetmComp
Definition: p_polys.h:239
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
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

◆ id_Mult()

ideal id_Mult ( ideal  h1,
ideal  h2,
const ring  R 
)

h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no columns at all)

Definition at line 725 of file simpleideals.cc.

726 {
727  id_Test(h1, R);
728  id_Test(h2, R);
729 
730  int j = IDELEMS(h1);
731  while ((j > 0) && (h1->m[j-1] == NULL)) j--;
732 
733  int i = IDELEMS(h2);
734  while ((i > 0) && (h2->m[i-1] == NULL)) i--;
735 
736  j *= i;
737  int r = si_max( h2->rank, h1->rank );
738  if (j==0)
739  {
740  if ((IDELEMS(h1)>0) && (IDELEMS(h2)>0)) j=1;
741  return idInit(j, r);
742  }
743  ideal hh = idInit(j, r);
744 
745  int k = 0;
746  for (i=0; i<IDELEMS(h1); i++)
747  {
748  if (h1->m[i] != NULL)
749  {
750  for (j=0; j<IDELEMS(h2); j++)
751  {
752  if (h2->m[j] != NULL)
753  {
754  hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],R);
755  k++;
756  }
757  }
758  }
759  }
760 
761  id_Compactify(hh,R);
762  return hh;
763 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
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:1070
const ring R
Definition: DebugPrint.cc:36
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
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
#define NULL
Definition: omList.c:10
void id_Compactify(ideal id, const ring r)

◆ id_NextPotence()

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 1032 of file simpleideals.cc.

1034 {
1035  poly p;
1036  int i;
1037 
1038  p = p_Power(p_Copy(given->m[begin],r),restdeg,r);
1039  i = result->nrows;
1040  result->m[i] = p_Mult_q(p_Copy(ap,r),p,r);
1041 //PrintS(".");
1042  (result->nrows)++;
1043  if (result->nrows >= IDELEMS(result))
1044  {
1045  pEnlargeSet(&(result->m),IDELEMS(result),16);
1046  IDELEMS(result) += 16;
1047  }
1048  if (begin == end) return;
1049  for (i=restdeg-1;i>0;i--)
1050  {
1051  p = p_Power(p_Copy(given->m[begin],r),i,r);
1052  p = p_Mult_q(p_Copy(ap,r),p,r);
1053  id_NextPotence(given, result, begin+1, end, deg, restdeg-i, p,r);
1054  p_Delete(&p,r);
1055  }
1056  id_NextPotence(given, result, begin+1, end, deg, restdeg, ap,r);
1057 }
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:804
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
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:3602
polyrec * poly
Definition: hilb.h:10
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1020
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2158
return result
Definition: facAbsBiFact.cc:76

◆ id_Norm()

void id_Norm ( ideal  id,
const ring  r 
)

ideal id = (id[i]), result is leadcoeff(id[i]) = 1

Definition at line 240 of file simpleideals.cc.

241 {
242  id_Test(id, r);
243  for (int i=IDELEMS(id)-1; i>=0; i--)
244  {
245  if (id->m[i] != NULL)
246  {
247  p_Norm(id->m[i],r);
248  }
249  }
250 }
#define id_Test(A, lR)
Definition: simpleideals.h:80
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3627
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10

◆ id_Normalize()

void id_Normalize ( ideal  I,
const ring  r 
)

normialize all polys in id

Definition at line 1578 of file simpleideals.cc.

1579 {
1580  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
1581  int i;
1582  for(i=I->nrows*I->ncols-1;i>=0;i--)
1583  {
1584  p_Normalize(I->m[i],r);
1585  }
1586 }
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:540
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:3680

◆ id_PosConstant()

int id_PosConstant ( ideal  id,
const ring  r 
)

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

Definition at line 83 of file simpleideals.cc.

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

◆ id_Power()

ideal id_Power ( ideal  given,
int  exp,
const ring  r 
)

Definition at line 1059 of file simpleideals.cc.

1060 {
1061  ideal result,temp;
1062  poly p1;
1063  int i;
1064 
1065  if (idIs0(given)) return idInit(1,1);
1066  temp = id_Copy(given,r);
1067  idSkipZeroes(temp);
1068  i = binom(IDELEMS(temp)+exp-1,exp);
1069  result = idInit(i,1);
1070  result->nrows = 0;
1071 //Print("ideal contains %d elements\n",i);
1072  p1=p_One(r);
1073  id_NextPotence(temp,result,0,IDELEMS(temp)-1,exp,exp,p1,r);
1074  p_Delete(&p1,r);
1075  id_Delete(&temp,r);
1076  result->nrows = 1;
1079  return result;
1080 }
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal id_Copy(ideal h1, const ring r)
copy an ideal
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1314
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
int i
Definition: cfEzgcd.cc:123
int binom(int n, int r)
#define IDELEMS(i)
Definition: simpleideals.h:24
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
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
polyrec * poly
Definition: hilb.h:10
return result
Definition: facAbsBiFact.cc:76

◆ id_QHomWeight()

intvec* id_QHomWeight ( ideal  id,
const ring  r 
)

Definition at line 1512 of file simpleideals.cc.

1513 {
1514  poly head, tail;
1515  int k;
1516  int in=IDELEMS(id)-1, ready=0, all=0,
1517  coldim=rVar(r), rowmax=2*coldim;
1518  if (in<0) return NULL;
1519  intvec *imat=new intvec(rowmax+1,coldim,0);
1520 
1521  do
1522  {
1523  head = id->m[in--];
1524  if (head!=NULL)
1525  {
1526  tail = pNext(head);
1527  while (tail!=NULL)
1528  {
1529  all++;
1530  for (k=1;k<=coldim;k++)
1531  IMATELEM(*imat,all,k) = p_GetExpDiff(head,tail,k,r);
1532  if (all==rowmax)
1533  {
1534  ivTriangIntern(imat, ready, all);
1535  if (ready==coldim)
1536  {
1537  delete imat;
1538  return NULL;
1539  }
1540  }
1541  pIter(tail);
1542  }
1543  }
1544  } while (in>=0);
1545  if (all>ready)
1546  {
1547  ivTriangIntern(imat, ready, all);
1548  if (ready==coldim)
1549  {
1550  delete imat;
1551  return NULL;
1552  }
1553  }
1554  intvec *result = ivSolveKern(imat, ready);
1555  delete imat;
1556  return result;
1557 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
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:630
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition: intvec.cc:387
#define IDELEMS(i)
Definition: simpleideals.h:24
#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:425
polyrec * poly
Definition: hilb.h:10
#define IMATELEM(M, I, J)
Definition: intvec.h:77
return result
Definition: facAbsBiFact.cc:76

◆ id_RankFreeModule()

long id_RankFreeModule ( ideal  s,
ring  lmRing,
ring  tailRing 
)

return the maximal component number found in any polynomial in s

Definition at line 780 of file simpleideals.cc.

781 {
783 
784  long j = 0;
785 
787  {
788  poly *p=s->m;
789  for (unsigned int l=IDELEMS(s); l > 0; --l, ++p)
790  if (*p != NULL)
791  {
792  pp_Test(*p, lmRing, tailRing);
793  const long k = p_MaxComp(*p, lmRing, tailRing);
794  if (k>j) j = k;
795  }
796  }
797 
798  return j; // return -1;
799 }
#define id_TestTail(A, lR, tR)
Definition: simpleideals.h:79
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
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:162
#define IDELEMS(i)
Definition: simpleideals.h:24
#define rRing_has_Comp(r)
Definition: monomials.h:274
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
int l
Definition: cfEzgcd.cc:94
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:287

◆ id_ReadOutPivot()

int id_ReadOutPivot ( ideal  arg,
int *  comp,
const ring  r 
)

Definition at line 1435 of file simpleideals.cc.

1436 {
1437  if (idIs0(arg)) return -1;
1438  int i=0,j, generator=-1;
1439  int rk_arg=arg->rank; //idRankFreeModule(arg);
1440  int * componentIsUsed =(int *)omAlloc((rk_arg+1)*sizeof(int));
1441  poly p;
1442 
1443  while ((generator<0) && (i<IDELEMS(arg)))
1444  {
1445  memset(componentIsUsed,0,(rk_arg+1)*sizeof(int));
1446  p = arg->m[i];
1447  while (p!=NULL)
1448  {
1449  j = p_GetComp(p,r);
1450  if (componentIsUsed[j]==0)
1451  {
1452  if (p_LmIsConstantComp(p,r) &&
1453  (!rField_is_Ring(r) || n_IsUnit(pGetCoeff(p),r->cf)))
1454  {
1455  generator = i;
1456  componentIsUsed[j] = 1;
1457  }
1458  else
1459  {
1460  componentIsUsed[j] = -1;
1461  }
1462  }
1463  else if (componentIsUsed[j]>0)
1464  {
1465  (componentIsUsed[j])++;
1466  }
1467  pIter(p);
1468  }
1469  i++;
1470  }
1471  i = 0;
1472  *comp = -1;
1473  for (j=0;j<=rk_arg;j++)
1474  {
1475  if (componentIsUsed[j]>0)
1476  {
1477  if ((*comp==-1) || (componentIsUsed[j]<i))
1478  {
1479  *comp = j;
1480  i= componentIsUsed[j];
1481  }
1482  }
1483  }
1484  omFree(componentIsUsed);
1485  return generator;
1486 }
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:932
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
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10

◆ id_ShallowDelete()

void id_ShallowDelete ( ideal *  h,
ring  r 
)

Shallowdeletes an ideal/matrix.

Definition at line 146 of file simpleideals.cc.

147 {
148  id_Test(*h, r);
149 
150  if (*h == NULL)
151  return;
152 
153  int j,elems;
154  elems=j=(*h)->nrows*(*h)->ncols;
155  if (j>0)
156  {
157  assume( (*h)->m != NULL );
158  do
159  {
160  p_ShallowDelete(&((*h)->m[--j]), r);
161  }
162  while (j>0);
163  omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
164  }
166  *h=NULL;
167 }
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define id_Test(A, lR)
Definition: simpleideals.h:80
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
void p_ShallowDelete(poly *p, const ring r)
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978

◆ id_Shift()

void id_Shift ( ideal  M,
int  s,
const ring  r 
)

Definition at line 1786 of file simpleideals.cc.

1787 {
1788 // id_Test( M, r );
1789 
1790 // assume( s >= 0 ); // negative is also possible // TODO: verify input ideal in such a case!?
1791 
1792  for(int i=IDELEMS(M)-1; i>=0;i--)
1793  p_Shift(&(M->m[i]),s,r);
1794 
1795  M->rank += s;
1796 
1797 // id_Test( M, r );
1798 }
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:24
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4561

◆ id_SimpleAdd()

ideal id_SimpleAdd ( ideal  h1,
ideal  h2,
const ring  R 
)

concat the lists h1 and h2 without zeros

Definition at line 596 of file simpleideals.cc.

597 {
598  id_Test(h1, R);
599  id_Test(h2, R);
600 
601  if ( idIs0(h1) )
602  {
603  ideal res=id_Copy(h2,R);
604  if (res->rank<h1->rank) res->rank=h1->rank;
605  return res;
606  }
607  if ( idIs0(h2) )
608  {
609  ideal res=id_Copy(h1,R);
610  if (res->rank<h2->rank) res->rank=h2->rank;
611  return res;
612  }
613 
614  int j = IDELEMS(h1)-1;
615  while ((j >= 0) && (h1->m[j] == NULL)) j--;
616 
617  int i = IDELEMS(h2)-1;
618  while ((i >= 0) && (h2->m[i] == NULL)) i--;
619 
620  const int r = si_max(h1->rank, h2->rank);
621 
622  ideal result = idInit(i+j+2,r);
623 
624  int l;
625 
626  for (l=j; l>=0; l--)
627  result->m[l] = p_Copy(h1->m[l],R);
628 
629  j = i+j+1;
630  for (l=i; l>=0; l--, j--)
631  result->m[j] = p_Copy(h2->m[l],R);
632 
633  return result;
634 }
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal id_Copy(ideal h1, const ring r)
copy an ideal
#define id_Test(A, lR)
Definition: simpleideals.h:80
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
const ring R
Definition: DebugPrint.cc:36
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
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
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
return result
Definition: facAbsBiFact.cc:76

◆ id_Sort()

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 501 of file simpleideals.cc.

502 {
503  id_Test(id, r);
504 
505  intvec * result = new intvec(IDELEMS(id));
506  int i, j, actpos=0, newpos;
507  int diff, olddiff, lastcomp, newcomp;
508  BOOLEAN notFound;
509 
510  for (i=0;i<IDELEMS(id);i++)
511  {
512  if (id->m[i]!=NULL)
513  {
514  notFound = TRUE;
515  newpos = actpos / 2;
516  diff = (actpos+1) / 2;
517  diff = (diff+1) / 2;
518  lastcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
519  if (lastcomp<0)
520  {
521  newpos -= diff;
522  }
523  else if (lastcomp>0)
524  {
525  newpos += diff;
526  }
527  else
528  {
529  notFound = FALSE;
530  }
531  //while ((newpos>=0) && (newpos<actpos) && (notFound))
532  while (notFound && (newpos>=0) && (newpos<actpos))
533  {
534  newcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
535  olddiff = diff;
536  if (diff>1)
537  {
538  diff = (diff+1) / 2;
539  if ((newcomp==1)
540  && (actpos-newpos>1)
541  && (diff>1)
542  && (newpos+diff>=actpos))
543  {
544  diff = actpos-newpos-1;
545  }
546  else if ((newcomp==-1)
547  && (diff>1)
548  && (newpos<diff))
549  {
550  diff = newpos;
551  }
552  }
553  if (newcomp<0)
554  {
555  if ((olddiff==1) && (lastcomp>0))
556  notFound = FALSE;
557  else
558  newpos -= diff;
559  }
560  else if (newcomp>0)
561  {
562  if ((olddiff==1) && (lastcomp<0))
563  {
564  notFound = FALSE;
565  newpos++;
566  }
567  else
568  {
569  newpos += diff;
570  }
571  }
572  else
573  {
574  notFound = FALSE;
575  }
576  lastcomp = newcomp;
577  if (diff==0) notFound=FALSE; /*hs*/
578  }
579  if (newpos<0) newpos = 0;
580  if (newpos>actpos) newpos = actpos;
581  while ((newpos<actpos) && (p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r)==0))
582  newpos++;
583  for (j=actpos;j>newpos;j--)
584  {
585  (*result)[j] = (*result)[j-1];
586  }
587  (*result)[newpos] = i;
588  actpos++;
589  }
590  }
591  for (j=0;j<actpos;j++) (*result)[j]++;
592  return result;
593 }
static int p_Comp_RevLex(poly a, poly b, BOOLEAN nolex, const ring R)
for idSort: compare a and b revlex inclusive module comp.
static gmp_float * diff
Definition: mpr_complex.cc:47
#define FALSE
Definition: auxiliary.h:94
#define id_Test(A, lR)
Definition: simpleideals.h:80
#define TRUE
Definition: auxiliary.h:98
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:85
return result
Definition: facAbsBiFact.cc:76

◆ id_Subst()

ideal id_Subst ( ideal  id,
int  n,
poly  e,
const ring  r 
)

Definition at line 1260 of file simpleideals.cc.

1261 {
1262  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
1263  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
1264 
1265  res->rank = id->rank;
1266  for(k--;k>=0;k--)
1267  {
1268  res->m[k]=p_Subst(id->m[k],n,e,r);
1269  id->m[k]=NULL;
1270  }
1271  id_Delete(&id,r);
1272  return res;
1273 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
poly p_Subst(poly p, int n, poly e, const ring r)
Definition: p_polys.cc:3822
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:44
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27

◆ id_TensorModuleMult()

ideal id_TensorModuleMult ( const int  m,
const ideal  M,
const ring  rRing 
)

Definition at line 1661 of file simpleideals.cc.

1662 {
1663 // #ifdef DEBU
1664 // WarnS("tensorModuleMult!!!!");
1665 
1666  assume(m > 0);
1667  assume(M != NULL);
1668 
1669  const int n = rRing->N;
1670 
1671  assume(M->rank <= m * n);
1672 
1673  const int k = IDELEMS(M);
1674 
1675  ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
1676 
1677  for( int i = 0; i < k; i++ ) // for every w \in M
1678  {
1679  poly pTempSum = NULL;
1680 
1681  poly w = M->m[i];
1682 
1683  while(w != NULL) // for each term of w...
1684  {
1685  poly h = p_Head(w, rRing);
1686 
1687  const int gen = p_GetComp(h, rRing); // 1 ...
1688 
1689  assume(gen > 0);
1690  assume(gen <= n*m);
1691 
1692  // TODO: write a formula with %, / instead of while!
1693  /*
1694  int c = gen;
1695  int v = 1;
1696  while(c > m)
1697  {
1698  c -= m;
1699  v++;
1700  }
1701  */
1702 
1703  int cc = gen % m;
1704  if( cc == 0) cc = m;
1705  int vv = 1 + (gen - cc) / m;
1706 
1707 // assume( cc == c );
1708 // assume( vv == v );
1709 
1710  // 1<= c <= m
1711  assume( cc > 0 );
1712  assume( cc <= m );
1713 
1714  assume( vv > 0 );
1715  assume( vv <= n );
1716 
1717  assume( (cc + (vv-1)*m) == gen );
1718 
1719  p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
1720  p_SetComp(h, cc, rRing);
1721 
1722  p_Setm(h, rRing); // addjust degree after the previous steps!
1723 
1724  pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
1725 
1726  pIter(w);
1727  }
1728 
1729  idTemp->m[i] = pTempSum;
1730  }
1731 
1732  // simplify idTemp???
1733 
1734  ideal idResult = id_Transp(idTemp, rRing);
1735 
1736  id_Delete(&idTemp, rRing);
1737 
1738  return(idResult);
1739 }
ideal id_Transp(ideal a, const ring rRing)
transpose a module
static long p_IncrExp(poly p, int v, ring r)
Definition: p_polys.h:586
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
#define p_GetComp(p, r)
Definition: monomials.h:72
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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:812
#define assume(x)
Definition: mod2.h:394
int m
Definition: cfEzgcd.cc:119
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
#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:228
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static Poly * h
Definition: janet.cc:978

◆ id_Transp()

ideal id_Transp ( ideal  a,
const ring  rRing 
)

transpose a module

Definition at line 1608 of file simpleideals.cc.

1609 {
1610  int r = a->rank, c = IDELEMS(a);
1611  ideal b = idInit(r,c);
1612 
1613  int i;
1614  for (i=c; i>0; i--)
1615  {
1616  poly p=a->m[i-1];
1617  while(p!=NULL)
1618  {
1619  poly h=p_Head(p, rRing);
1620  int co=p_GetComp(h, rRing)-1;
1621  p_SetComp(h, i, rRing);
1622  p_Setm(h, rRing);
1623  h->next=b->m[co];
1624  b->m[co]=h;
1625  pIter(p);
1626  }
1627  }
1628  for (i=IDELEMS(b)-1; i>=0; i--)
1629  {
1630  poly p=b->m[i];
1631  if(p!=NULL)
1632  {
1633  b->m[i]=p_SortMerge(p,rRing,TRUE);
1634  }
1635  }
1636  return b;
1637 }
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition: p_polys.h:1152
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:242
#define p_GetComp(p, r)
Definition: monomials.h:72
#define TRUE
Definition: auxiliary.h:98
#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
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
#define NULL
Definition: omList.c:10
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
const poly b
Definition: syzextra.cc:213

◆ id_Vec2Ideal()

ideal id_Vec2Ideal ( poly  vec,
const ring  R 
)

Definition at line 1133 of file simpleideals.cc.

1134 {
1135  ideal result=idInit(1,1);
1136  omFree((ADDRESS)result->m);
1137  result->m=NULL; // remove later
1138  p_Vec2Polys(vec, &(result->m), &(IDELEMS(result)),R);
1139  return result;
1140 }
void * ADDRESS
Definition: auxiliary.h:115
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:3521
const ring R
Definition: DebugPrint.cc:36
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
return result
Definition: facAbsBiFact.cc:76

◆ idElem()

int idElem ( const ideal  F)

count non-zero elements

number of non-zero polys in F

Definition at line 208 of file simpleideals.cc.

209 {
210  assume (F != NULL);
211 
212  int i=0;
213 
214  for(int j=IDELEMS(F)-1;j>=0;j--)
215  {
216  if ((F->m)[j]!=NULL) i++;
217  }
218  return i;
219 }
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10

◆ idGetNextChoise()

void idGetNextChoise ( int  r,
int  end,
BOOLEAN endch,
int *  choise 
)

Definition at line 853 of file simpleideals.cc.

854 {
855  int i = r-1,j;
856  while ((i >= 0) && (choise[i] == end))
857  {
858  i--;
859  end--;
860  }
861  if (i == -1)
862  *endch = TRUE;
863  else
864  {
865  choise[i]++;
866  for (j=i+1; j<r; j++)
867  {
868  choise[j] = choise[i]+j-i;
869  }
870  *endch = FALSE;
871  }
872 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123

◆ idGetNumberOfChoise()

int idGetNumberOfChoise ( int  t,
int  d,
int  begin,
int  end,
int *  choise 
)

Definition at line 879 of file simpleideals.cc.

880 {
881  int * localchoise,i,result=0;
882  BOOLEAN b=FALSE;
883 
884  if (d<=1) return 1;
885  localchoise=(int*)omAlloc((d-1)*sizeof(int));
886  idInitChoise(d-1,begin,end,&b,localchoise);
887  while (!b)
888  {
889  result++;
890  i = 0;
891  while ((i<t) && (localchoise[i]==choise[i])) i++;
892  if (i>=t)
893  {
894  i = t+1;
895  while ((i<d) && (localchoise[i-1]==choise[i])) i++;
896  if (i>=d)
897  {
898  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
899  return result;
900  }
901  }
902  idGetNextChoise(d-1,end,&b,localchoise);
903  }
904  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
905  return 0;
906 }
#define FALSE
Definition: auxiliary.h:94
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
#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:85
const poly b
Definition: syzextra.cc:213
return result
Definition: facAbsBiFact.cc:76

◆ idInit()

ideal idInit ( int  idsize,
int  rank 
)

initialise an ideal / module

creates an ideal / module

Definition at line 38 of file simpleideals.cc.

39 {
40  assume( idsize >= 0 && rank >= 0 );
41 
42  ideal hh = (ideal)omAllocBin(sip_sideal_bin);
43 
44  IDELEMS(hh) = idsize; // ncols
45  hh->nrows = 1; // ideal/module!
46 
47  hh->rank = rank; // ideal: 1, module: >= 0!
48 
49  if (idsize>0)
50  hh->m = (poly *)omAlloc0(idsize*sizeof(poly));
51  else
52  hh->m = NULL;
53 
54  return hh;
55 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define assume(x)
Definition: mod2.h:394
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ idInitChoise()

void idInitChoise ( int  r,
int  beg,
int  end,
BOOLEAN endch,
int *  choise 
)

Definition at line 831 of file simpleideals.cc.

832 {
833  /*returns the first choise of r numbers between beg and end*/
834  int i;
835  for (i=0; i<r; i++)
836  {
837  choise[i] = 0;
838  }
839  if (r <= end-beg+1)
840  for (i=0; i<r; i++)
841  {
842  choise[i] = beg+i;
843  }
844  if (r > end-beg+1)
845  *endch = TRUE;
846  else
847  *endch = FALSE;
848 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123

◆ idInsertPoly()

BOOLEAN idInsertPoly ( ideal  h1,
poly  h2 
)

insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted

Definition at line 638 of file simpleideals.cc.

639 {
640  if (h2==NULL) return FALSE;
641  assume (h1 != NULL);
642 
643  int j = IDELEMS(h1) - 1;
644 
645  while ((j >= 0) && (h1->m[j] == NULL)) j--;
646  j++;
647  if (j==IDELEMS(h1))
648  {
649  pEnlargeSet(&(h1->m),IDELEMS(h1),16);
650  IDELEMS(h1)+=16;
651  }
652  h1->m[j]=h2;
653  return TRUE;
654 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3602

◆ idInsertPolyOnPos()

BOOLEAN idInsertPolyOnPos ( ideal  I,
poly  p,
int  pos 
)

insert p into I on position pos

Definition at line 657 of file simpleideals.cc.

658 {
659  if (p==NULL) return FALSE;
660  assume (I != NULL);
661 
662  int j = IDELEMS(I) - 1;
663 
664  while ((j >= 0) && (I->m[j] == NULL)) j--;
665  j++;
666  if (j==IDELEMS(I))
667  {
668  pEnlargeSet(&(I->m),IDELEMS(I),IDELEMS(I)+1);
669  IDELEMS(I)+=1;
670  }
671  for(j = IDELEMS(I)-1;j>pos;j--)
672  I->m[j] = I->m[j-1];
673  I->m[pos]=p;
674  return TRUE;
675 }
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:98
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3602

◆ idIs0()

BOOLEAN idIs0 ( ideal  h)

returns true if h is the zero ideal

Definition at line 766 of file simpleideals.cc.

767 {
768  assume (h != NULL); // will fail :(
769 // if (h == NULL) return TRUE;
770 
771  for( int i = IDELEMS(h)-1; i >= 0; i-- )
772  if(h->m[i] != NULL)
773  return FALSE;
774 
775  return TRUE;
776 
777 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978

◆ idShow()

void idShow ( const ideal  id,
const ring  lmRing,
const ring  tailRing,
const int  debugPrint 
)

Definition at line 60 of file simpleideals.cc.

61 {
62  assume( debugPrint >= 0 );
63 
64  if( id == NULL )
65  PrintS("(NULL)");
66  else
67  {
68  Print("Module of rank %ld,real rank %ld and %d generators.\n",
69  id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id));
70 
71  int j = (id->ncols*id->nrows) - 1;
72  while ((j > 0) && (id->m[j]==NULL)) j--;
73  for (int i = 0; i <= j; i++)
74  {
75  Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing);PrintLn();
76  }
77  }
78 }
void PrintLn()
Definition: reporter.cc:310
#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)
return the maximal component number found in any polynomial in s
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:237

◆ idSkipZeroes()

void idSkipZeroes ( ideal  ide)

gives an ideal/module the minimal possible size

Definition at line 170 of file simpleideals.cc.

171 {
172  assume (ide != NULL);
173 
174  int k;
175  int j = -1;
176  BOOLEAN change=FALSE;
177 
178  for (k=0; k<IDELEMS(ide); k++)
179  {
180  if (ide->m[k] != NULL)
181  {
182  j++;
183  if (change)
184  {
185  ide->m[j] = ide->m[k];
186  }
187  }
188  else
189  {
190  change=TRUE;
191  }
192  }
193  if (change)
194  {
195  if (j == -1)
196  j = 0;
197  else
198  {
199  for (k=j+1; k<IDELEMS(ide); k++)
200  ide->m[k] = NULL;
201  }
202  pEnlargeSet(&(ide->m),IDELEMS(ide),j+1-IDELEMS(ide));
203  IDELEMS(ide) = j+1;
204  }
205 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3602
int BOOLEAN
Definition: auxiliary.h:85

◆ makemonoms()

static void makemonoms ( int  vars,
int  actvar,
int  deg,
int  monomdeg,
const ring  r 
)
static

Definition at line 960 of file simpleideals.cc.

961 {
962  poly p;
963  int i=0;
964 
965  if ((idpowerpoint == 0) && (actvar ==1))
966  {
968  monomdeg = 0;
969  }
970  while (i<=deg)
971  {
972  if (deg == monomdeg)
973  {
975  idpowerpoint++;
976  return;
977  }
978  if (actvar == vars)
979  {
980  p_SetExp(idpower[idpowerpoint],actvar,deg-monomdeg,r);
983  idpowerpoint++;
984  return;
985  }
986  else
987  {
989  makemonoms(vars,actvar+1,deg,monomdeg,r);
991  }
992  monomdeg++;
996  i++;
997  }
998 }
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:804
const ring r
Definition: syzextra.cc:208
static int idpowerpoint
Definition: simpleideals.cc:34
poly p_One(const ring r)
Definition: p_polys.cc:1314
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
#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:483
static poly * idpower
Definition: simpleideals.cc:32
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10

◆ p_Comp_RevLex()

static int p_Comp_RevLex ( poly  a,
poly  b,
BOOLEAN  nolex,
const ring  R 
)
static

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

Definition at line 464 of file simpleideals.cc.

465 {
466  if (b==NULL) return 1;
467  if (a==NULL) return -1;
468 
469  if (nolex)
470  {
471  int r=p_LtCmp(a,b,R);
472  return r;
473  #if 0
474  if (r!=0) return r;
475  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
476  r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
477  n_Delete(&h, R->cf);
478  return r;
479  #endif
480  }
481  int l=rVar(R);
482  while ((l>0) && (p_GetExp(a,l,R)==p_GetExp(b,l,R))) l--;
483  if (l==0)
484  {
485  if (p_GetComp(a,R)==p_GetComp(b,R))
486  {
487  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
488  int r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
489  n_Delete(&h,R->cf);
490  return r;
491  }
492  if (p_GetComp(a,R)>p_GetComp(b,R)) return 1;
493  }
494  else if (p_GetExp(a,l,R)>p_GetExp(b,l,R))
495  return 1;
496  return -1;
497 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
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:583
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:464
const ring R
Definition: DebugPrint.cc:36
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
#define NULL
Definition: omList.c:10
static int p_LtCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1501
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; 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)/<p(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:498
static Poly * h
Definition: janet.cc:978
const poly b
Definition: syzextra.cc:213
int l
Definition: cfEzgcd.cc:94

Variable Documentation

◆ idpower

poly* idpower
static

Definition at line 32 of file simpleideals.cc.

◆ idpowerpoint

int idpowerpoint
static

Definition at line 34 of file simpleideals.cc.

◆ sip_sideal_bin

omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal))

Definition at line 30 of file simpleideals.cc.