My Project
Loading...
Searching...
No Matches
Functions | Variables
simpleideals.cc File Reference
#include "misc/auxiliary.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
 
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
 
ideal id_MaxIdeal (const ring r)
 initialise the maximal ideal (at 0)
 
void id_Delete (ideal *h, ring r)
 deletes an ideal/module/matrix
 
void id_Delete0 (ideal *h, ring r)
 
void id_ShallowDelete (ideal *h, ring r)
 Shallowdeletes an ideal/matrix.
 
void idSkipZeroes (ideal ide)
 gives an ideal/module the minimal possible size
 
int idSkipZeroes0 (ideal ide)
 
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.)
 
void id_Norm (ideal id, const ring r)
 ideal id = (id[i]), result is leadcoeff(id[i]) = 1
 
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
 
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
 
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.
 
static void id_DelDiv_SEV (ideal id, int k, const ring r)
 delete id[j], if LT(j) == coeff*mon*LT(i)
 
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)
 
BOOLEAN id_IsConstant (ideal id, const ring r)
 test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
 
ideal id_Copy (ideal h1, const ring r)
 copy an ideal
 
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!
 
void id_DBLmTest (ideal h1, int level, const char *f, const int l, const ring r)
 Internal verification for ideals/modules and dense matrices!
 
static int p_Comp_RevLex (poly a, poly b, BOOLEAN nolex, const ring R)
 for idSort: compare a and b revlex inclusive module comp.
 
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
 
ideal id_SimpleAdd (ideal h1, ideal h2, const ring R)
 concat the lists h1 and h2 without zeros
 
BOOLEAN idInsertPoly (ideal h1, poly h2)
 insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
 
BOOLEAN idInsertPolyOnPos (ideal I, poly p, int pos)
 insert p into I on position pos
 
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:
 
ideal id_Add (ideal h1, ideal h2, const ring r)
 h1 + h2
 
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)
 
BOOLEAN idIs0 (ideal h)
 returns true if h is the zero ideal
 
BOOLEAN idIsMonomial (ideal h)
 returns true if h is generated by monomials
 
long id_RankFreeModule (ideal s, ring lmRing, ring tailRing)
 return the maximal component number found in any polynomial in s
 
BOOLEAN id_IsModule (ideal A, const ring src)
 
BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r)
 
BOOLEAN id_HomIdealDP (ideal id, ideal Q, const ring r)
 
BOOLEAN id_HomIdealW (ideal id, ideal Q, const intvec *w, const ring r)
 
BOOLEAN id_HomModuleW (ideal id, ideal Q, const intvec *w, const intvec *module_w, 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
 
static void makemonoms (int vars, int actvar, int deg, int monomdeg, const ring r)
 
static void lpmakemonoms (int vars, int deg, 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
 
ideal id_Homogen (ideal h, int varnum, const ring r)
 
ideal id_HomogenDP (ideal h, int varnum, const ring r)
 
ideal id_Vec2Ideal (poly vec, const ring R)
 
poly id_Array2Vector (poly *m, unsigned n, const ring R)
 for julia: convert an array of poly to vector
 
ideal id_Matrix2Module (matrix mat, const ring R)
 converts mat to module, destroys mat
 
matrix id_Module2Matrix (ideal mod, const ring R)
 
matrix id_Module2formatedMatrix (ideal mod, int rows, int cols, const ring R)
 
ideal id_ResizeModule (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 (const ideal i, int d, const ring R)
 
ideal id_Jet0 (const ideal i, const ring R)
 
ideal id_JetW (const ideal i, int d, intvec *iv, 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
 
int id_MinDegW (ideal M, intvec *w, const ring r)
 
ideal id_Transp (ideal a, const ring rRing)
 transpose a module
 
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)
 
ideal id_Delete_Pos (const ideal I, const int p, const ring r)
 
ideal id_PermIdeal (ideal I, int R, int C, const int *perm, const ring src, const ring dst, nMapFunc nMap, const int *par_perm, int P, BOOLEAN use_mult)
 mapping ideals/matrices to other rings
 

Variables

VAR omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal))
 
STATIC_VAR poly * idpower
 
STATIC_VAR int idpowerpoint
 

Function Documentation

◆ binom()

int binom ( int  n,
int  r 
)

Definition at line 1212 of file simpleideals.cc.

1213{
1214 int i;
1215 int64 result;
1216
1217 if (r==0) return 1;
1218 if (n-r<r) return binom(n,n-r);
1219 result = n-r+1;
1220 for (i=2;i<=r;i++)
1221 {
1222 result *= n-r+i;
1223 result /= i;
1224 }
1225 if (result>MAX_INT_VAL)
1226 {
1227 WarnS("overflow in binomials");
1228 result=0;
1229 }
1230 return (int)result;
1231}
long int64
Definition auxiliary.h:68
int i
Definition cfEzgcd.cc:132
#define WarnS
Definition emacs.cc:78
return result
const int MAX_INT_VAL
Definition mylimits.h:12
int binom(int n, int r)

◆ id_Add()

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

h1 + h2

Definition at line 906 of file simpleideals.cc.

907{
908 id_Test(h1, r);
909 id_Test(h2, r);
910
913 return result;
914}
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
void id_Compactify(ideal id, const ring r)
#define id_Test(A, lR)

◆ id_Array2Vector()

poly id_Array2Vector ( poly *  m,
unsigned  n,
const ring  R 
)

for julia: convert an array of poly to vector

Definition at line 1537 of file simpleideals.cc.

1538{
1539 poly h;
1540 int l;
1541 sBucket_pt bucket = sBucketCreate(R);
1542
1543 for(unsigned j=0;j<n ;j++)
1544 {
1545 h = m[j];
1546 if (h!=NULL)
1547 {
1548 h=p_Copy(h, R);
1549 l=pLength(h);
1550 p_SetCompP(h,j+1, R);
1551 sBucket_Merge_p(bucket, h, l);
1552 }
1553 }
1554 sBucketClearMerge(bucket, &h, &l);
1555 sBucketDestroy(&bucket);
1556 return h;
1557}
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int j
Definition facHensel.cc:110
STATIC_VAR Poly * h
Definition janet.cc:971
#define NULL
Definition omList.c:12
static int pLength(poly a)
Definition p_polys.h:190
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:256
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.cc:237
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:148
void sBucketDestroy(sBucket_pt *bucket)
Definition sbuckets.cc:103
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
#define R
Definition sirandom.c:27

◆ id_ChineseRemainder()

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

Definition at line 2147 of file simpleideals.cc.

2148{
2149 int cnt=0;int rw=0; int cl=0;
2150 int i,j;
2151 // find max. size of xx[.]:
2152 for(j=rl-1;j>=0;j--)
2153 {
2154 i=IDELEMS(xx[j])*xx[j]->nrows;
2155 if (i>cnt) cnt=i;
2156 if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices
2157 if (xx[j]->ncols >cl) cl=xx[j]->ncols; // for lifting matrices
2158 }
2159 if (rw*cl !=cnt)
2160 {
2161 WerrorS("format mismatch in CRT");
2162 return NULL;
2163 }
2164 ideal result=idInit(cnt,xx[0]->rank);
2165 result->nrows=rw; // for lifting matrices
2166 result->ncols=cl; // for lifting matrices
2167 number *x=(number *)omAlloc(rl*sizeof(number));
2168 poly *p=(poly *)omAlloc(rl*sizeof(poly));
2170 EXTERN_VAR int n_SwitchChinRem; //TEST
2173 for(i=cnt-1;i>=0;i--)
2174 {
2175 for(j=rl-1;j>=0;j--)
2176 {
2177 if(i>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal
2178 p[j]=NULL;
2179 else
2180 p[j]=xx[j]->m[i];
2181 }
2183 for(j=rl-1;j>=0;j--)
2184 {
2185 if(i<IDELEMS(xx[j])*xx[j]->nrows) xx[j]->m[i]=p[j];
2186 }
2187 }
2189 omFreeSize(p,rl*sizeof(poly));
2190 omFreeSize(x,rl*sizeof(number));
2191 for(i=rl-1;i>=0;i--) id_Delete(&(xx[i]),r);
2192 omFreeSize(xx,rl*sizeof(ideal));
2193 return result;
2194}
Variable x
Definition cfModGcd.cc:4090
int p
Definition cfModGcd.cc:4086
cl
Definition cfModGcd.cc:4108
int int ncols
Definition cf_linsys.cc:32
int nrows
Definition cf_linsys.cc:32
void WerrorS(const char *s)
Definition feFopen.cc:24
#define EXTERN_VAR
Definition globaldefs.h:6
poly p_ChineseRemainder(poly *xx, mpz_ptr *x, mpz_ptr *q, int rl, mpz_ptr *C, const ring R)
VAR int n_SwitchChinRem
Definition longrat.cc:3074
#define omFreeSize(addr, size)
#define omAlloc(size)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)

◆ id_Compactify()

void id_Compactify ( ideal  id,
const ring  r 
)

Definition at line 1459 of file simpleideals.cc.

1460{
1461 int i;
1462 BOOLEAN b=FALSE;
1463
1464 i = IDELEMS(id)-1;
1465 while ((! b) && (i>=0))
1466 {
1467 b=p_IsUnit(id->m[i],r);
1468 i--;
1469 }
1470 if (b)
1471 {
1472 for(i=IDELEMS(id)-1;i>=0;i--) p_Delete(&id->m[i],r);
1473 id->m[0]=p_One(r);
1474 }
1475 else
1476 {
1477 id_DelMultiples(id,r);
1478 }
1479 idSkipZeroes(id);
1480}
int BOOLEAN
Definition auxiliary.h:88
#define FALSE
Definition auxiliary.h:97
CanonicalForm b
Definition cfModGcd.cc:4111
poly p_One(const ring r)
Definition p_polys.cc:1314
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition p_polys.h:2012
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
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ id_Copy()

ideal id_Copy ( ideal  h1,
const ring  r 
)

copy an ideal

Definition at line 542 of file simpleideals.cc.

543{
544 id_Test(h1, r);
545
546 ideal h2 = idInit(IDELEMS(h1), h1->rank);
547 for (int i=IDELEMS(h1)-1; i>=0; i--)
548 h2->m[i] = p_Copy(h1->m[i],r);
549 return h2;
550}

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

267{
268 id_Test(ide, r);
269
270 assume( ide != NULL );
271 assume( k <= IDELEMS(ide) );
272
273 ideal newI = idInit(k, ide->rank);
274
275 for (int i = 0; i < k; i++)
276 newI->m[i] = p_Copy(ide->m[i],r);
277
278 return newI;
279}
int k
Definition cfEzgcd.cc:99
#define assume(x)
Definition mod2.h:389

◆ id_DBLmTest()

void id_DBLmTest ( ideal  h1,
int  level,
const char f,
const int  l,
const ring  r 
)

Internal verification for ideals/modules and dense matrices!

Definition at line 605 of file simpleideals.cc.

606{
607 if (h1 != NULL)
608 {
609 // assume(IDELEMS(h1) > 0); for ideal/module, does not apply to matrix
610 omCheckAddrSize(h1,sizeof(*h1));
611
612 assume( h1->ncols >= 0 );
613 assume( h1->nrows >= 0 ); // matrix case!
614
615 assume( h1->rank >= 0 );
616
617 const long n = ((long)h1->ncols * (long)h1->nrows);
618
619 assume( !( n > 0 && h1->m == NULL) );
620
621 if( h1->m != NULL && n > 0 )
622 omdebugAddrSize(h1->m, n * sizeof(poly));
623
624 long new_rk = 0; // inlining id_RankFreeModule(h1, r, tailRing);
625
626 /* to be able to test matrices: */
627 for (long i=n - 1; i >= 0; i--)
628 {
629 if (h1->m[i]!=NULL)
630 {
631 _p_LmTest(h1->m[i], r, level);
632 const long k = p_GetComp(h1->m[i], r);
633 if (k > new_rk) new_rk = k;
634 }
635 }
636
637 // dense matrices only contain polynomials:
638 // h1->nrows == h1->rank > 1 && new_rk == 0!
639 assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) ); //
640
641 if(new_rk > h1->rank)
642 {
643 dReportError("wrong rank %d (should be %d) in %s:%d\n",
644 h1->rank, new_rk, f,l);
645 omPrintAddrInfo(stderr, h1, " for ideal");
646 h1->rank = new_rk;
647 }
648 }
649 else
650 {
651 Print("error: ideal==NULL in %s:%d\n",f,l);
652 assume( h1 != NULL );
653 }
654}
int level(const CanonicalForm &f)
FILE * f
Definition checklibs.c:9
#define Print
Definition emacs.cc:80
int dReportError(const char *fmt,...)
Definition dError.cc:44
#define p_GetComp(p, r)
Definition monomials.h:64
#define omdebugAddrSize(addr, size)
#define omCheckAddrSize(addr, size)
BOOLEAN _p_LmTest(poly p, ring r, int level)
Definition pDebug.cc:322
#define omPrintAddrInfo(A, B, C)
Definition xalloc.h:270

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

555{
556 if (h1 != NULL)
557 {
558 // assume(IDELEMS(h1) > 0); for ideal/module, does not apply to matrix
559 omCheckAddrSize(h1,sizeof(*h1));
560
561 assume( h1->ncols >= 0 );
562 assume( h1->nrows >= 0 ); // matrix case!
563
564 assume( h1->rank >= 0 );
565
566 const long n = ((long)h1->ncols * (long)h1->nrows);
567
568 assume( !( n > 0 && h1->m == NULL) );
569
570 if( h1->m != NULL && n > 0 )
571 omdebugAddrSize(h1->m, n * sizeof(poly));
572
573 long new_rk = 0; // inlining id_RankFreeModule(h1, r, tailRing);
574
575 /* to be able to test matrices: */
576 for (long i=n - 1; i >= 0; i--)
577 {
578 _pp_Test(h1->m[i], r, tailRing, level);
579 const long k = p_MaxComp(h1->m[i], r, tailRing);
580 if (k > new_rk) new_rk = k;
581 }
582
583 // dense matrices only contain polynomials:
584 // h1->nrows == h1->rank > 1 && new_rk == 0!
585 assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) ); //
586
587 if(new_rk > h1->rank)
588 {
589 dReportError("wrong rank %d (should be %d) in %s:%d\n",
590 h1->rank, new_rk, f,l);
591 omPrintAddrInfo(stderr, h1, " for ideal");
592 h1->rank = new_rk;
593 }
594 }
595 else
596 {
597 Print("error: ideal==NULL in %s:%d\n",f,l);
598 assume( h1 != NULL );
599 }
600}
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:294
BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level)
Definition pDebug.cc:332

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

464{
465 id_Test(id, r);
466
467 int i, j;
468 int k = IDELEMS(id)-1;
469#ifdef HAVE_RINGS
470 if (rField_is_Ring(r))
471 {
472 for (i=k-1; i>=0; i--)
473 {
474 if (id->m[i] != NULL)
475 {
476 for (j=k; j>i; j--)
477 {
478 if (id->m[j]!=NULL)
479 {
480 if (p_DivisibleByRingCase(id->m[i], id->m[j],r))
481 {
482 p_Delete(&id->m[j],r);
483 }
484 else if (p_DivisibleByRingCase(id->m[j], id->m[i],r))
485 {
486 p_Delete(&id->m[i],r);
487 break;
488 }
489 }
490 }
491 }
492 }
493 }
494 else
495#endif
496 {
497 /* the case of a coefficient field: */
498 if (k>9)
499 {
500 id_DelDiv_SEV(id,k,r);
501 return;
502 }
503 for (i=k-1; i>=0; i--)
504 {
505 if (id->m[i] != NULL)
506 {
507 for (j=k; j>i; j--)
508 {
509 if (id->m[j]!=NULL)
510 {
511 if (p_LmDivisibleBy(id->m[i], id->m[j],r))
512 {
513 p_Delete(&id->m[j],r);
514 }
515 else if (p_LmDivisibleBy(id->m[j], id->m[i],r))
516 {
517 p_Delete(&id->m[i],r);
518 break;
519 }
520 }
521 }
522 }
523 }
524 }
525}
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:1646
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1912
#define rField_is_Ring(R)
Definition ring.h:491
static void id_DelDiv_SEV(ideal id, int k, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i)

◆ id_DelDiv_SEV()

static void id_DelDiv_SEV ( ideal  id,
int  k,
const ring  r 
)
static

delete id[j], if LT(j) == coeff*mon*LT(i)

Definition at line 381 of file simpleideals.cc.

382{
383 int kk = k+1;
384 long *sev=(long*)omAlloc0(kk*sizeof(long));
385 while(id->m[k]==NULL) k--;
386 BOOLEAN only_lm=r->cf->has_simple_Alloc;
387 if (only_lm)
388 {
389 for (int i=k; i>=0; i--)
390 {
391 if((id->m[i]!=NULL) && (pNext(id->m[i])!=NULL))
392 {
394 break;
395 }
396 }
397 }
398 for (int i=k; i>=0; i--)
399 {
400 if(id->m[i]!=NULL)
401 {
402 sev[i]=p_GetShortExpVector(id->m[i],r);
403 }
404 }
405 if (only_lm)
406 {
407 for (int i=0; i<k; i++)
408 {
409 if (id->m[i] != NULL)
410 {
411 poly m_i=id->m[i];
412 long sev_i=sev[i];
413 for (int j=i+1; j<=k; j++)
414 {
415 if (id->m[j]!=NULL)
416 {
417 if (p_LmShortDivisibleBy(m_i, sev_i,id->m[j],~sev[j],r))
418 {
419 p_LmFree(&id->m[j],r);
420 }
421 else if (p_LmShortDivisibleBy(id->m[j],sev[j], m_i,~sev_i,r))
422 {
423 p_LmFree(&id->m[i],r);
424 break;
425 }
426 }
427 }
428 }
429 }
430 }
431 else
432 {
433 for (int i=0; i<k; i++)
434 {
435 if (id->m[i] != NULL)
436 {
437 poly m_i=id->m[i];
438 long sev_i=sev[i];
439 for (int j=i+1; j<=k; j++)
440 {
441 if (id->m[j]!=NULL)
442 {
443 if (p_LmShortDivisibleBy(m_i, sev_i, id->m[j],~sev[j],r))
444 {
445 p_Delete(&id->m[j],r);
446 }
447 else if (p_LmShortDivisibleBy(id->m[j],sev[j], m_i,~sev_i,r))
448 {
449 p_Delete(&id->m[i],r);
450 break;
451 }
452 }
453 }
454 }
455 }
456 }
457 omFreeSize(sev,kk*sizeof(long));
458}
#define pNext(p)
Definition monomials.h:36
#define omAlloc0(size)
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4934
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1931
static void p_LmFree(poly p, ring)
Definition p_polys.h:685

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

332{
333 id_Test(id, r);
334
335 int i, j;
336 int k = IDELEMS(id)-1;
337 for (i=k; i>=0; i--)
338 {
339 if (id->m[i]!=NULL)
340 {
341 for (j=k; j>i; j--)
342 {
343 if ((id->m[j]!=NULL)
344 && (p_EqualPolys(id->m[i], id->m[j],r)))
345 {
346 p_Delete(&id->m[j],r);
347 }
348 }
349 }
350 }
351}
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition p_polys.cc:4666

◆ id_Delete()

void id_Delete ( ideal h,
ring  r 
)

deletes an ideal/module/matrix

Definition at line 123 of file simpleideals.cc.

124{
125 if (*h == NULL)
126 return;
127
128 id_Test(*h, r);
129
130 const long elems = (long)(*h)->nrows * (long)(*h)->ncols;
131
132 if ( elems > 0 )
133 {
134 assume( (*h)->m != NULL );
135
136 if (r!=NULL)
137 {
138 long j = elems;
139 do
140 {
141 j--;
142 poly pp=((*h)->m[j]);
143 if (pp!=NULL) p_Delete(&pp, r);
144 }
145 while (j>0);
146 }
147
148 omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
149 }
150
152 *h=NULL;
153}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
#define omFreeBin(addr, bin)
VAR omBin sip_sideal_bin

◆ id_Delete0()

void id_Delete0 ( ideal h,
ring  r 
)

Definition at line 155 of file simpleideals.cc.

156{
157 long j = IDELEMS(*h);
158
159 if(j>0)
160 {
161 do
162 {
163 j--;
164 poly pp=((*h)->m[j]);
165 if (pp!=NULL) p_Delete(&pp, r);
166 }
167 while (j>0);
168 omFree((ADDRESS)((*h)->m));
169 }
170
172 *h=NULL;
173}
#define omFree(addr)

◆ id_Delete_Pos()

ideal id_Delete_Pos ( const ideal  I,
const int  p,
const ring  r 
)

Definition at line 2210 of file simpleideals.cc.

2211{
2212 if ((p<0)||(p>=IDELEMS(I))) return NULL;
2213 ideal ret=idInit(IDELEMS(I)-1,I->rank);
2214 for(int i=0;i<p;i++) ret->m[i]=p_Copy(I->m[i],r);
2215 for(int i=p+1;i<IDELEMS(I);i++) ret->m[i-1]=p_Copy(I->m[i],r);
2216 return ret;
2217}

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

355{
356 id_Test(id, r);
357
358 int i, j;
359 int k = IDELEMS(id)-1;
360 for (i=k; i>=0; i--)
361 {
362 if (id->m[i] != NULL)
363 {
364 for (j=k; j>i; j--)
365 {
366 if ((id->m[j] != NULL)
367 && p_LmEqual(id->m[i], id->m[j],r)
369 && n_IsUnit(pGetCoeff(id->m[i]),r->cf) && n_IsUnit(pGetCoeff(id->m[j]),r->cf)
370#endif
371 )
372 {
373 p_Delete(&id->m[j],r);
374 }
375 }
376 }
377 }
378}
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:521
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1744

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

297{
298 id_Test(id, r);
299
300 int i, j;
301 int k = IDELEMS(id)-1;
302 for (i=k; i>=0; i--)
303 {
304 if (id->m[i]!=NULL)
305 {
306 for (j=k; j>i; j--)
307 {
308 if (id->m[j]!=NULL)
309 {
310 if (rField_is_Ring(r))
311 {
312 /* if id[j] = c*id[i] then delete id[j].
313 In the below cases of a ground field, we
314 check whether id[i] = c*id[j] and, if so,
315 delete id[j] for historical reasons (so
316 that previous output does not change) */
317 if (p_ComparePolys(id->m[j], id->m[i],r)) p_Delete(&id->m[j],r);
318 }
319 else
320 {
321 if (p_ComparePolys(id->m[i], id->m[j],r)) p_Delete(&id->m[j],r);
322 }
323 }
324 }
325 }
326 }
327}
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:4730

◆ id_FreeModule()

ideal id_FreeModule ( int  i,
const ring  r 
)

the free module of rank i

Definition at line 1235 of file simpleideals.cc.

1236{
1237 assume(i >= 0);
1238 if (r->isLPring)
1239 {
1240 PrintS("In order to address bimodules, the command freeAlgebra should be used.");
1241 }
1242 ideal h = idInit(i, i);
1243
1244 for (int j=0; j<i; j++)
1245 {
1246 h->m[j] = p_One(r);
1247 p_SetComp(h->m[j],j+1,r);
1248 p_SetmComp(h->m[j],r);
1249 }
1250
1251 return h;
1252}
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
#define p_SetmComp
Definition p_polys.h:246
void PrintS(const char *s)
Definition reporter.cc:288

◆ id_Head()

ideal id_Head ( ideal  h,
const ring  r 
)

returns the ideals of initial terms

Definition at line 1483 of file simpleideals.cc.

1484{
1485 ideal m = idInit(IDELEMS(h),h->rank);
1486
1487 if (r->cf->has_simple_Alloc)
1488 {
1489 for (int i=IDELEMS(h)-1;i>=0; i--)
1490 if (h->m[i]!=NULL)
1491 m->m[i]=p_CopyPowerProduct0(h->m[i],pGetCoeff(h->m[i]),r);
1492 }
1493 else
1494 {
1495 for (int i=IDELEMS(h)-1;i>=0; i--)
1496 if (h->m[i]!=NULL)
1497 m->m[i]=p_Head(h->m[i],r);
1498 }
1499
1500 return m;
1501}
poly p_CopyPowerProduct0(const poly p, number n, const ring r)
like p_Head, but with coefficient n
Definition p_polys.cc:5122
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862

◆ id_HomIdeal()

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

Definition at line 1033 of file simpleideals.cc.

1034{
1035 int i;
1036 BOOLEAN b;
1037 i = 0;
1038 b = TRUE;
1039 while ((i < IDELEMS(id)) && b)
1040 {
1041 b = p_IsHomogeneous(id->m[i],r);
1042 i++;
1043 }
1044 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1045 {
1046 i=0;
1047 while ((i < IDELEMS(Q)) && b)
1048 {
1049 b = p_IsHomogeneous(Q->m[i],r);
1050 i++;
1051 }
1052 }
1053 return b;
1054}
#define TRUE
Definition auxiliary.h:101
BOOLEAN p_IsHomogeneous(poly p, const ring r)
Definition p_polys.cc:3408
#define Q
Definition sirandom.c:26

◆ id_HomIdealDP()

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

Definition at line 1059 of file simpleideals.cc.

1060{
1061 int i;
1062 BOOLEAN b;
1063 i = 0;
1064 b = TRUE;
1065 while ((i < IDELEMS(id)) && b)
1066 {
1067 b = p_IsHomogeneousDP(id->m[i],r);
1068 i++;
1069 }
1070 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1071 {
1072 i=0;
1073 while ((i < IDELEMS(Q)) && b)
1074 {
1075 b = p_IsHomogeneousDP(Q->m[i],r);
1076 i++;
1077 }
1078 }
1079 return b;
1080}
BOOLEAN p_IsHomogeneousDP(poly p, const ring r)
Definition p_polys.cc:3432

◆ id_HomIdealW()

BOOLEAN id_HomIdealW ( ideal  id,
ideal  Q,
const intvec w,
const ring  r 
)

Definition at line 1082 of file simpleideals.cc.

1083{
1084 int i;
1085 BOOLEAN b;
1086 i = 0;
1087 b = TRUE;
1088 while ((i < IDELEMS(id)) && b)
1089 {
1090 b = p_IsHomogeneousW(id->m[i],w,r);
1091 i++;
1092 }
1093 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1094 {
1095 i=0;
1096 while ((i < IDELEMS(Q)) && b)
1097 {
1098 b = p_IsHomogeneousW(Q->m[i],w,r);
1099 i++;
1100 }
1101 }
1102 return b;
1103}
const CanonicalForm & w
Definition facAbsFact.cc:51
BOOLEAN p_IsHomogeneousW(poly p, const intvec *w, const ring r)
Definition p_polys.cc:3451

◆ id_HomModule()

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

Definition at line 1724 of file simpleideals.cc.

1725{
1726 if (w!=NULL) *w=NULL;
1727 if ((Q!=NULL) && (!id_HomIdeal(Q,NULL,R))) return FALSE;
1728 if (idIs0(m))
1729 {
1730 if (w!=NULL) (*w)=new intvec(m->rank);
1731 return TRUE;
1732 }
1733
1734 long cmax=1,order=0,ord,* diff,diffmin=32000;
1735 int *iscom;
1736 int i;
1737 poly p=NULL;
1738 pFDegProc d;
1739 if (R->pLexOrder && (R->order[0]==ringorder_lp))
1740 d=p_Totaldegree;
1741 else
1742 d=R->pFDeg;
1743 int length=IDELEMS(m);
1744 poly* P=m->m;
1745 poly* F=(poly*)omAlloc(length*sizeof(poly));
1746 for (i=length-1;i>=0;i--)
1747 {
1748 p=F[i]=P[i];
1750 }
1751 cmax++;
1752 diff = (long *)omAlloc0(cmax*sizeof(long));
1753 if (w!=NULL) *w=new intvec(cmax-1);
1754 iscom = (int *)omAlloc0(cmax*sizeof(int));
1755 i=0;
1756 while (i<=length)
1757 {
1758 if (i<length)
1759 {
1760 p=F[i];
1761 while ((p!=NULL) && (iscom[__p_GetComp(p,R)]==0)) pIter(p);
1762 }
1763 if ((p==NULL) && (i<length))
1764 {
1765 i++;
1766 }
1767 else
1768 {
1769 if (p==NULL) /* && (i==length) */
1770 {
1771 i=0;
1772 while ((i<length) && (F[i]==NULL)) i++;
1773 if (i>=length) break;
1774 p = F[i];
1775 }
1776 //if (pLexOrder && (currRing->order[0]==ringorder_lp))
1777 // order=pTotaldegree(p);
1778 //else
1779 // order = p->order;
1780 // order = pFDeg(p,currRing);
1781 order = d(p,R) +diff[__p_GetComp(p,R)];
1782 //order += diff[pGetComp(p)];
1783 p = F[i];
1784//Print("Actual p=F[%d]: ",i);pWrite(p);
1785 F[i] = NULL;
1786 i=0;
1787 }
1788 while (p!=NULL)
1789 {
1790 if (R->pLexOrder && (R->order[0]==ringorder_lp))
1791 ord=p_Totaldegree(p,R);
1792 else
1793 // ord = p->order;
1794 ord = R->pFDeg(p,R);
1795 if (iscom[__p_GetComp(p,R)]==0)
1796 {
1797 diff[__p_GetComp(p,R)] = order-ord;
1798 iscom[__p_GetComp(p,R)] = 1;
1799/*
1800*PrintS("new diff: ");
1801*for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1802*PrintLn();
1803*PrintS("new iscom: ");
1804*for (j=0;j<cmax;j++) Print("%d ",iscom[j]);
1805*PrintLn();
1806*Print("new set %d, order %d, ord %d, diff %d\n",pGetComp(p),order,ord,diff[pGetComp(p)]);
1807*/
1808 }
1809 else
1810 {
1811/*
1812*PrintS("new diff: ");
1813*for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1814*PrintLn();
1815*Print("order %d, ord %d, diff %d\n",order,ord,diff[pGetComp(p)]);
1816*/
1817 if (order != (ord+diff[__p_GetComp(p,R)]))
1818 {
1819 omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1820 omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1821 omFreeSize((ADDRESS) F,length*sizeof(poly));
1822 delete *w;*w=NULL;
1823 return FALSE;
1824 }
1825 }
1826 pIter(p);
1827 }
1828 }
1829 omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1830 omFreeSize((ADDRESS) F,length*sizeof(poly));
1831 for (i=1;i<cmax;i++) (**w)[i-1]=(int)(diff[i]);
1832 for (i=1;i<cmax;i++)
1833 {
1834 if (diff[i]<diffmin) diffmin=diff[i];
1835 }
1836 if (w!=NULL)
1837 {
1838 for (i=1;i<cmax;i++)
1839 {
1840 (**w)[i-1]=(int)(diff[i]-diffmin);
1841 }
1842 }
1843 omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1844 return TRUE;
1845}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
#define pIter(p)
Definition monomials.h:37
#define __p_GetComp(p, r)
Definition monomials.h:63
STATIC_VAR gmp_float * diff
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1528
long(* pFDegProc)(poly p, ring r)
Definition ring.h:39
@ ringorder_lp
Definition ring.h:78
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal

◆ id_HomModuleW()

BOOLEAN id_HomModuleW ( ideal  id,
ideal  Q,
const intvec w,
const intvec module_w,
const ring  r 
)

Definition at line 1105 of file simpleideals.cc.

1106{
1107 int i;
1108 BOOLEAN b;
1109 i = 0;
1110 b = TRUE;
1111 while ((i < IDELEMS(id)) && b)
1112 {
1113 b = p_IsHomogeneousW(id->m[i],w,module_w,r);
1114 i++;
1115 }
1116 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1117 {
1118 i=0;
1119 while ((i < IDELEMS(Q)) && b)
1120 {
1121 b = p_IsHomogeneousW(Q->m[i],w,r);
1122 i++;
1123 }
1124 }
1125 return b;
1126}

◆ id_Homogen()

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

Definition at line 1503 of file simpleideals.cc.

1504{
1505 ideal m = idInit(IDELEMS(h),h->rank);
1506 int i;
1507
1508 for (i=IDELEMS(h)-1;i>=0; i--)
1509 {
1510 m->m[i]=p_Homogen(h->m[i],varnum,r);
1511 }
1512 return m;
1513}
poly p_Homogen(poly p, int varnum, const ring r)
Definition p_polys.cc:3319

◆ id_HomogenDP()

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

Definition at line 1515 of file simpleideals.cc.

1516{
1517 ideal m = idInit(IDELEMS(h),h->rank);
1518 int i;
1519
1520 for (i=IDELEMS(h)-1;i>=0; i--)
1521 {
1522 m->m[i]=p_HomogenDP(h->m[i],varnum,r);
1523 }
1524 return m;
1525}
poly p_HomogenDP(poly p, int varnum, const ring r)
Definition p_polys.cc:3365

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

880{
881 id_Test(h1, r);
882 p_Test(h2, r);
883
884 if ((!zeroOk) && (h2 == NULL)) return FALSE;
885 if (!duplicateOk)
886 {
887 bool h2FoundInH1 = false;
888 int i = 0;
889 while ((i < validEntries) && (!h2FoundInH1))
890 {
891 h2FoundInH1 = p_EqualPolys(h1->m[i], h2,r);
892 i++;
893 }
894 if (h2FoundInH1) return FALSE;
895 }
896 if (validEntries == IDELEMS(h1))
897 {
898 pEnlargeSet(&(h1->m), IDELEMS(h1), 16);
899 IDELEMS(h1) += 16;
900 }
901 h1->m[validEntries] = h2;
902 return TRUE;
903}
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3821
#define p_Test(p, r)
Definition p_polys.h:161

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

530{
531 id_Test(id, r);
532
533 for (int k = IDELEMS(id)-1; k>=0; k--)
534 {
535 if (!p_IsConstantPoly(id->m[k],r))
536 return FALSE;
537 }
538 return TRUE;
539}
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition p_polys.h:1999

◆ id_IsModule()

BOOLEAN id_IsModule ( ideal  A,
const ring  src 
)

Definition at line 1011 of file simpleideals.cc.

1012{
1013 if ((src->VarOffset[0]== -1)
1014 || (src->pCompIndex<0))
1015 return FALSE; // ring without components
1016 for (int i=IDELEMS(A)-1;i>=0;i--)
1017 {
1018 if (A->m[i]!=NULL)
1019 {
1020 if (p_GetComp(A->m[i],src)>0)
1021 return TRUE;
1022 else
1023 return FALSE;
1024 }
1025 }
1026 return A->rank>1;
1027}
#define A
Definition sirandom.c:24

◆ id_IsZeroDim()

BOOLEAN id_IsZeroDim ( ideal  I,
const ring  r 
)

Definition at line 1964 of file simpleideals.cc.

1965{
1966 BOOLEAN *UsedAxis=(BOOLEAN *)omAlloc0(rVar(r)*sizeof(BOOLEAN));
1967 int i,n;
1968 poly po;
1970 for(i=IDELEMS(I)-1;i>=0;i--)
1971 {
1972 po=I->m[i];
1973 if ((po!=NULL) &&((n=p_IsPurePower(po,r))!=0)) UsedAxis[n-1]=TRUE;
1974 }
1975 for(i=rVar(r)-1;i>=0;i--)
1976 {
1977 if(UsedAxis[i]==FALSE) {res=FALSE; break;} // not zero-dim.
1978 }
1979 omFreeSize(UsedAxis,rVar(r)*sizeof(BOOLEAN));
1980 return res;
1981}
CanonicalForm res
Definition facAbsFact.cc:60
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition p_polys.cc:1227
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598

◆ id_Jet()

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

Definition at line 1847 of file simpleideals.cc.

1848{
1849 ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1850 r->nrows = i-> nrows;
1851 r->ncols = i-> ncols;
1852 //r->rank = i-> rank;
1853
1854 for(long k=((long)(i->nrows))*((long)(i->ncols))-1;k>=0; k--)
1855 r->m[k]=pp_Jet(i->m[k],d,R);
1856
1857 return r;
1858}
poly pp_Jet(poly p, int m, const ring R)
Definition p_polys.cc:4484

◆ id_Jet0()

ideal id_Jet0 ( const ideal  i,
const ring  R 
)

Definition at line 1860 of file simpleideals.cc.

1861{
1862 ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1863 r->nrows = i-> nrows;
1864 r->ncols = i-> ncols;
1865 //r->rank = i-> rank;
1866
1867 for(long k=((long)(i->nrows))*((long)(i->ncols))-1;k>=0; k--)
1868 r->m[k]=pp_Jet0(i->m[k],R);
1869
1870 return r;
1871}
poly pp_Jet0(poly p, const ring R)
Definition p_polys.cc:4512

◆ id_JetW()

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

Definition at line 1873 of file simpleideals.cc.

1874{
1875 ideal r=idInit(IDELEMS(i),i->rank);
1876 if (ecartWeights!=NULL)
1877 {
1878 WerrorS("cannot compute weighted jets now");
1879 }
1880 else
1881 {
1882 int *w=iv2array(iv,R);
1883 int k;
1884 for(k=0; k<IDELEMS(i); k++)
1885 {
1886 r->m[k]=pp_JetW(i->m[k],d,w,R);
1887 }
1888 omFreeSize((ADDRESS)w,(rVar(R)+1)*sizeof(int));
1889 }
1890 return r;
1891}
poly pp_JetW(poly p, int m, int *w, const ring R)
Definition p_polys.cc:4557
int * iv2array(intvec *iv, const ring R)
Definition weight.cc:200
EXTERN_VAR short * ecartWeights
Definition weight.h:12

◆ id_Matrix2Module()

ideal id_Matrix2Module ( matrix  mat,
const ring  R 
)

converts mat to module, destroys mat

Definition at line 1560 of file simpleideals.cc.

1561{
1562 int mc=MATCOLS(mat);
1563 int mr=MATROWS(mat);
1564 ideal result = idInit(mc,mr);
1565 int i,j,l;
1566 poly h;
1567 sBucket_pt bucket = sBucketCreate(R);
1568
1569 for(j=0;j<mc /*MATCOLS(mat)*/;j++) /* j is also index in result->m */
1570 {
1571 for (i=0;i<mr /*MATROWS(mat)*/;i++)
1572 {
1573 h = MATELEM0(mat,i,j);
1574 if (h!=NULL)
1575 {
1576 l=pLength(h);
1577 MATELEM0(mat,i,j)=NULL;
1578 p_SetCompP(h,i+1, R);
1579 sBucket_Merge_p(bucket, h, l);
1580 }
1581 }
1582 sBucketClearMerge(bucket, &(result->m[j]), &l);
1583 }
1584 sBucketDestroy(&bucket);
1585
1586 // obachman: need to clean this up
1587 id_Delete((ideal*) &mat,R);
1588 return result;
1589}
#define MATELEM0(mat, i, j)
0-based access to matrix
Definition matpol.h:31
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27

◆ id_MaxIdeal() [1/2]

ideal id_MaxIdeal ( const ring  r)

initialise the maximal ideal (at 0)

Definition at line 98 of file simpleideals.cc.

99{
100 int nvars;
101#ifdef HAVE_SHIFTBBA
102 if (r->isLPring)
103 {
104 nvars = r->isLPring;
105 }
106 else
107#endif
108 {
109 nvars = rVar(r);
110 }
111 ideal hh = idInit(nvars, 1);
112 for (int l=nvars-1; l>=0; l--)
113 {
114 hh->m[l] = p_One(r);
115 p_SetExp(hh->m[l],l+1,1,r);
116 p_Setm(hh->m[l],r);
117 }
118 id_Test(hh, r);
119 return hh;
120}
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235

◆ id_MaxIdeal() [2/2]

ideal id_MaxIdeal ( int  deg,
const ring  r 
)

Definition at line 1352 of file simpleideals.cc.

1353{
1354 if (deg < 1)
1355 {
1356 ideal I=idInit(1,1);
1357 I->m[0]=p_One(r);
1358 return I;
1359 }
1360 if (deg == 1
1362 && !r->isLPring
1363#endif
1364 )
1365 {
1366 return id_MaxIdeal(r);
1367 }
1368
1369 int vars, i;
1370#ifdef HAVE_SHIFTBBA
1371 if (r->isLPring)
1372 {
1373 vars = r->isLPring - r->LPncGenCount;
1374 i = 1;
1375 // i = vars^deg
1376 for (int j = 0; j < deg; j++)
1377 {
1378 i *= vars;
1379 }
1380 }
1381 else
1382#endif
1383 {
1384 vars = rVar(r);
1385 i = binom(vars+deg-1,deg);
1386 }
1387 if (i<=0) return idInit(1,1);
1388 ideal id=idInit(i,1);
1389 idpower = id->m;
1390 idpowerpoint = 0;
1391#ifdef HAVE_SHIFTBBA
1392 if (r->isLPring)
1393 {
1394 lpmakemonoms(vars, deg, r);
1395 }
1396 else
1397#endif
1398 {
1399 makemonoms(vars,1,deg,0,r);
1400 }
1401 idpower = NULL;
1402 idpowerpoint = 0;
1403 return id;
1404}
STATIC_VAR int idpowerpoint
STATIC_VAR poly * idpower
static void makemonoms(int vars, int actvar, int deg, int monomdeg, const ring r)
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
static void lpmakemonoms(int vars, int deg, const ring r)

◆ id_MinDegW()

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

Definition at line 1994 of file simpleideals.cc.

1995{
1996 int d=-1;
1997 for(int i=0;i<IDELEMS(M);i++)
1998 {
1999 if (M->m[i]!=NULL)
2000 {
2001 int d0=p_MinDeg(M->m[i],w,r);
2002 if(-1<d0&&((d0<d)||(d==-1)))
2003 d=d0;
2004 }
2005 }
2006 return d;
2007}
int p_MinDeg(poly p, intvec *w, const ring R)
Definition p_polys.cc:4602
#define M
Definition sirandom.c:25

◆ id_Module2formatedMatrix()

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

Definition at line 1640 of file simpleideals.cc.

1641{
1642 matrix result = mpNew(rows,cols);
1643 int i,cp,r=id_RankFreeModule(mod,R),c=IDELEMS(mod);
1644 poly p,h;
1645
1646 if (r>rows) r = rows;
1647 if (c>cols) c = cols;
1648 for(i=0;i<c;i++)
1649 {
1650 p=pReverse(mod->m[i]);
1651 mod->m[i]=NULL;
1652 while (p!=NULL)
1653 {
1654 h=p;
1655 pIter(p);
1656 pNext(h)=NULL;
1657 cp = p_GetComp(h,R);
1658 if (cp<=r)
1659 {
1660 p_SetComp(h,0,R);
1661 p_SetmComp(h,R);
1662 MATELEM0(result,cp-1,i) = p_Add_q(MATELEM0(result,cp-1,i),h,R);
1663 }
1664 else
1665 p_Delete(&h,R);
1666 }
1667 }
1668 id_Delete(&mod,R);
1669 return result;
1670}
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static poly pReverse(poly p)
Definition p_polys.h:337
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s

◆ id_Module2Matrix()

matrix id_Module2Matrix ( ideal  mod,
const ring  R 
)

Definition at line 1594 of file simpleideals.cc.

1595{
1596 matrix result = mpNew(mod->rank,IDELEMS(mod));
1597 long i; long cp;
1598 poly p,h;
1599
1600 for(i=0;i<IDELEMS(mod);i++)
1601 {
1602 p=pReverse(mod->m[i]);
1603 mod->m[i]=NULL;
1604 while (p!=NULL)
1605 {
1606 h=p;
1607 pIter(p);
1608 pNext(h)=NULL;
1609 cp = si_max(1L,p_GetComp(h, R)); // if used for ideals too
1610 //cp = p_GetComp(h,R);
1611 p_SetComp(h,0,R);
1612 p_SetmComp(h,R);
1613#ifdef TEST
1614 if (cp>mod->rank)
1615 {
1616 Print("## inv. rank %ld -> %ld\n",mod->rank,cp);
1617 int k,l,o=mod->rank;
1618 mod->rank=cp;
1619 matrix d=mpNew(mod->rank,IDELEMS(mod));
1620 for (l=0; l<o; l++)
1621 {
1622 for (k=0; k<IDELEMS(mod); k++)
1623 {
1626 }
1627 }
1628 id_Delete((ideal *)&result,R);
1629 result=d;
1630 }
1631#endif
1632 MATELEM0(result,cp-1,i) = p_Add_q(MATELEM0(result,cp-1,i),h,R);
1633 }
1634 }
1635 // obachman 10/99: added the following line, otherwise memory leak!
1636 id_Delete(&mod,R);
1637 return result;
1638}

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

920{
921 id_Test(h1, R);
922 id_Test(h2, R);
923
924 int j = IDELEMS(h1);
925 while ((j > 0) && (h1->m[j-1] == NULL)) j--;
926
927 int i = IDELEMS(h2);
928 while ((i > 0) && (h2->m[i-1] == NULL)) i--;
929
930 j *= i;
931 int r = si_max( h2->rank, h1->rank );
932 if (j==0)
933 {
934 if ((IDELEMS(h1)>0) && (IDELEMS(h2)>0)) j=1;
935 return idInit(j, r);
936 }
937 ideal hh = idInit(j, r);
938
939 int k = 0;
940 for (i=0; i<IDELEMS(h1); i++)
941 {
942 if (h1->m[i] != NULL)
943 {
944 for (j=0; j<IDELEMS(h2); j++)
945 {
946 if (h2->m[j] != NULL)
947 {
948 hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],R);
949 k++;
950 }
951 }
952 }
953 }
954
956 return hh;
957}
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167

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

1408{
1409 poly p;
1410 int i;
1411
1412 p = p_Power(p_Copy(given->m[begin],r),restdeg,r);
1413 i = result->nrows;
1414 result->m[i] = p_Mult_q(p_Copy(ap,r),p,r);
1415//PrintS(".");
1416 (result->nrows)++;
1417 if (result->nrows >= IDELEMS(result))
1418 {
1419 pEnlargeSet(&(result->m),IDELEMS(result),16);
1420 IDELEMS(result) += 16;
1421 }
1422 if (begin == end) return;
1423 for (i=restdeg-1;i>0;i--)
1424 {
1425 p = p_Power(p_Copy(given->m[begin],r),i,r);
1426 p = p_Mult_q(p_Copy(ap,r),p,r);
1427 id_NextPotence(given, result, begin+1, end, deg, restdeg-i, p,r);
1428 p_Delete(&p,r);
1429 }
1430 id_NextPotence(given, result, begin+1, end, deg, restdeg, ap,r);
1431}
Definition ap.h:40
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2245
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, const ring r)

◆ id_Norm()

void id_Norm ( ideal  id,
const ring  r 
)

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

Definition at line 282 of file simpleideals.cc.

283{
284 id_Test(id, r);
285 for (int i=IDELEMS(id)-1; i>=0; i--)
286 {
287 if (id->m[i] != NULL)
288 {
289 p_Norm(id->m[i],r);
290 }
291 }
292}
void p_Norm(poly p1, const ring r)
Definition p_polys.cc:3844

◆ id_Normalize()

void id_Normalize ( ideal  I,
const ring  r 
)

normialize all polys in id

Definition at line 1983 of file simpleideals.cc.

1984{
1985 if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
1986 int i;
1987 for(i=I->nrows*I->ncols-1;i>=0;i--)
1988 {
1989 poly p=I->m[i];
1990 if (p!=NULL) p_Normalize(p,r);
1991 }
1992}
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3939
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:554

◆ id_PermIdeal()

ideal id_PermIdeal ( ideal  I,
int  R,
int  C,
const int perm,
const ring  src,
const ring  dst,
nMapFunc  nMap,
const int par_perm,
int  P,
BOOLEAN  use_mult 
)

mapping ideals/matrices to other rings

Definition at line 2219 of file simpleideals.cc.

2221{
2222 ideal II=(ideal)mpNew(R,C);
2223 II->rank=I->rank;
2224 for(int i=R*C-1; i>=0; i--)
2225 {
2226 II->m[i]=p_PermPoly(I->m[i],perm,src,dst,nMap,par_perm,P,use_mult);
2227 }
2228 return II;
2229}
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition p_polys.cc:4256

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

81{
82 id_Test(id, r);
83 const int N = IDELEMS(id) - 1;
84 const poly * m = id->m + N;
85
86 for (int k = N; k >= 0; --k, --m)
87 {
88 const poly p = *m;
89 if (p!=NULL)
90 if (p_LmIsConstantComp(p, r) == TRUE)
91 return k;
92 }
93
94 return -1;
95}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition p_polys.h:1008

◆ id_Power()

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

Definition at line 1433 of file simpleideals.cc.

1434{
1436 poly p1;
1437 int i;
1438
1439 if (idIs0(given)) return idInit(1,1);
1440 temp = id_Copy(given,r);
1442 i = binom(IDELEMS(temp)+exp-1,exp);
1443 result = idInit(i,1);
1444 result->nrows = 0;
1445//Print("ideal contains %d elements\n",i);
1446 p1=p_One(r);
1448 p_Delete(&p1,r);
1449 id_Delete(&temp,r);
1450 result->nrows = 1;
1453 return result;
1454}
gmp_float exp(const gmp_float &a)
ideal id_Copy(ideal h1, const ring r)
copy an ideal
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

◆ id_QHomWeight()

intvec * id_QHomWeight ( ideal  id,
const ring  r 
)

Definition at line 1917 of file simpleideals.cc.

1918{
1919 poly head, tail;
1920 int k;
1921 int in=IDELEMS(id)-1, ready=0, all=0,
1922 coldim=rVar(r), rowmax=2*coldim;
1923 if (in<0) return NULL;
1924 intvec *imat=new intvec(rowmax+1,coldim,0);
1925
1926 do
1927 {
1928 head = id->m[in--];
1929 if (head!=NULL)
1930 {
1931 tail = pNext(head);
1932 while (tail!=NULL)
1933 {
1934 all++;
1935 for (k=1;k<=coldim;k++)
1936 IMATELEM(*imat,all,k) = p_GetExpDiff(head,tail,k,r);
1937 if (all==rowmax)
1938 {
1939 ivTriangIntern(imat, ready, all);
1940 if (ready==coldim)
1941 {
1942 delete imat;
1943 return NULL;
1944 }
1945 }
1946 pIter(tail);
1947 }
1948 }
1949 } while (in>=0);
1950 if (all>ready)
1951 {
1952 ivTriangIntern(imat, ready, all);
1953 if (ready==coldim)
1954 {
1955 delete imat;
1956 return NULL;
1957 }
1958 }
1959 intvec *result = ivSolveKern(imat, ready);
1960 delete imat;
1961 return result;
1962}
CanonicalForm head(const CanonicalForm &f)
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition intvec.cc:404
intvec * ivSolveKern(intvec *imat, int dimtr)
Definition intvec.cc:442
#define IMATELEM(M, I, J)
Definition intvec.h:86
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition p_polys.h:637

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

993{
994 long j = 0;
995
996 if (rRing_has_Comp(tailRing) && rRing_has_Comp(lmRing))
997 {
998 poly *p=s->m;
999 for (unsigned int l=IDELEMS(s); l > 0; --l, ++p)
1000 if (*p != NULL)
1001 {
1002 pp_Test(*p, lmRing, tailRing);
1003 const long k = p_MaxComp(*p, lmRing, tailRing);
1004 if (k>j) j = k;
1005 }
1006 }
1007
1008 return j; // return -1;
1009}
const CanonicalForm int s
Definition facAbsFact.cc:51
#define rRing_has_Comp(r)
Definition monomials.h:266
#define pp_Test(p, lmRing, tailRing)
Definition p_polys.h:163

◆ id_ResizeModule()

ideal id_ResizeModule ( ideal  mod,
int  rows,
int  cols,
const ring  R 
)

Definition at line 1672 of file simpleideals.cc.

1673{
1674 // columns?
1675 if (cols!=IDELEMS(mod))
1676 {
1677 for(int i=IDELEMS(mod)-1;i>=cols;i--) p_Delete(&mod->m[i],R);
1678 pEnlargeSet(&(mod->m),IDELEMS(mod),cols-IDELEMS(mod));
1679 IDELEMS(mod)=cols;
1680 }
1681 // rows?
1682 if (rows<mod->rank)
1683 {
1684 for(int i=IDELEMS(mod)-1;i>=0;i--)
1685 {
1686 if (mod->m[i]!=NULL)
1687 {
1688 while((mod->m[i]!=NULL) && (p_GetComp(mod->m[i],R)>rows))
1689 mod->m[i]=p_LmDeleteAndNext(mod->m[i],R);
1690 poly p=mod->m[i];
1691 while(pNext(p)!=NULL)
1692 {
1693 if (p_GetComp(pNext(p),R)>rows)
1695 else
1696 pIter(p);
1697 }
1698 }
1699 }
1700 }
1701 mod->rank=rows;
1702 return mod;
1703}
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757

◆ id_ShallowDelete()

void id_ShallowDelete ( ideal h,
ring  r 
)

Shallowdeletes an ideal/matrix.

Definition at line 177 of file simpleideals.cc.

178{
179 id_Test(*h, r);
180
181 if (*h == NULL)
182 return;
183
184 int j,elems;
185 elems=j=(*h)->nrows*(*h)->ncols;
186 if (j>0)
187 {
188 assume( (*h)->m != NULL );
189 do
190 {
191 p_ShallowDelete(&((*h)->m[--j]), r);
192 }
193 while (j>0);
194 omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
195 }
197 *h=NULL;
198}
void p_ShallowDelete(poly *p, const ring r)

◆ id_Shift()

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

Definition at line 2196 of file simpleideals.cc.

2197{
2198// id_Test( M, r );
2199
2200// assume( s >= 0 ); // negative is also possible // TODO: verify input ideal in such a case!?
2201
2202 for(int i=IDELEMS(M)-1; i>=0;i--)
2203 p_Shift(&(M->m[i]),s,r);
2204
2205 M->rank += s;
2206
2207// id_Test( M, r );
2208}
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4860

◆ id_SimpleAdd()

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

concat the lists h1 and h2 without zeros

Definition at line 790 of file simpleideals.cc.

791{
792 id_Test(h1, R);
793 id_Test(h2, R);
794
795 if ( idIs0(h1) )
796 {
798 if (res->rank<h1->rank) res->rank=h1->rank;
799 return res;
800 }
801 if ( idIs0(h2) )
802 {
804 if (res->rank<h2->rank) res->rank=h2->rank;
805 return res;
806 }
807
808 int j = IDELEMS(h1)-1;
809 while ((j >= 0) && (h1->m[j] == NULL)) j--;
810
811 int i = IDELEMS(h2)-1;
812 while ((i >= 0) && (h2->m[i] == NULL)) i--;
813
814 const int r = si_max(h1->rank, h2->rank);
815
816 ideal result = idInit(i+j+2,r);
817
818 int l;
819
820 for (l=j; l>=0; l--)
821 result->m[l] = p_Copy(h1->m[l],R);
822
823 j = i+j+1;
824 for (l=i; l>=0; l--, j--)
825 result->m[j] = p_Copy(h2->m[l],R);
826
827 return result;
828}

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

696{
697 id_Test(id, r);
698
699 intvec * result = new intvec(IDELEMS(id));
700 int i, j, actpos=0, newpos;
703
704 for (i=0;i<IDELEMS(id);i++)
705 {
706 if (id->m[i]!=NULL)
707 {
708 notFound = TRUE;
709 newpos = actpos / 2;
710 diff = (actpos+1) / 2;
711 diff = (diff+1) / 2;
712 lastcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
713 if (lastcomp<0)
714 {
715 newpos -= diff;
716 }
717 else if (lastcomp>0)
718 {
719 newpos += diff;
720 }
721 else
722 {
723 notFound = FALSE;
724 }
725 //while ((newpos>=0) && (newpos<actpos) && (notFound))
726 while (notFound && (newpos>=0) && (newpos<actpos))
727 {
728 newcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
729 olddiff = diff;
730 if (diff>1)
731 {
732 diff = (diff+1) / 2;
733 if ((newcomp==1)
734 && (actpos-newpos>1)
735 && (diff>1)
736 && (newpos+diff>=actpos))
737 {
738 diff = actpos-newpos-1;
739 }
740 else if ((newcomp==-1)
741 && (diff>1)
742 && (newpos<diff))
743 {
744 diff = newpos;
745 }
746 }
747 if (newcomp<0)
748 {
749 if ((olddiff==1) && (lastcomp>0))
750 notFound = FALSE;
751 else
752 newpos -= diff;
753 }
754 else if (newcomp>0)
755 {
756 if ((olddiff==1) && (lastcomp<0))
757 {
758 notFound = FALSE;
759 newpos++;
760 }
761 else
762 {
763 newpos += diff;
764 }
765 }
766 else
767 {
768 notFound = FALSE;
769 }
771 if (diff==0) notFound=FALSE; /*hs*/
772 }
773 if (newpos<0) newpos = 0;
774 if (newpos>actpos) newpos = actpos;
775 while ((newpos<actpos) && (p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r)==0))
776 newpos++;
777 for (j=actpos;j>newpos;j--)
778 {
779 (*result)[j] = (*result)[j-1];
780 }
781 (*result)[newpos] = i;
782 actpos++;
783 }
784 }
785 for (j=0;j<actpos;j++) (*result)[j]++;
786 return result;
787}
static int p_Comp_RevLex(poly a, poly b, BOOLEAN nolex, const ring R)
for idSort: compare a and b revlex inclusive module comp.

◆ id_Subst()

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

Definition at line 1709 of file simpleideals.cc.

1710{
1711 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
1713
1714 res->rank = id->rank;
1715 for(k--;k>=0;k--)
1716 {
1717 res->m[k]=p_Subst(id->m[k],n,e,r);
1718 id->m[k]=NULL;
1719 }
1720 id_Delete(&id,r);
1721 return res;
1722}
poly * m
Definition matpol.h:18
poly p_Subst(poly p, int n, poly e, const ring r)
Definition p_polys.cc:4084

◆ id_TensorModuleMult()

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

Definition at line 2067 of file simpleideals.cc.

2068{
2069// #ifdef DEBU
2070// WarnS("tensorModuleMult!!!!");
2071
2072 assume(m > 0);
2073 assume(M != NULL);
2074
2075 const int n = rRing->N;
2076
2077 assume(M->rank <= m * n);
2078
2079 const int k = IDELEMS(M);
2080
2081 ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
2082
2083 for( int i = 0; i < k; i++ ) // for every w \in M
2084 {
2085 poly pTempSum = NULL;
2086
2087 poly w = M->m[i];
2088
2089 while(w != NULL) // for each term of w...
2090 {
2091 poly h = p_Head(w, rRing);
2092
2093 const int gen = __p_GetComp(h, rRing); // 1 ...
2094
2095 assume(gen > 0);
2096 assume(gen <= n*m);
2097
2098 // TODO: write a formula with %, / instead of while!
2099 /*
2100 int c = gen;
2101 int v = 1;
2102 while(c > m)
2103 {
2104 c -= m;
2105 v++;
2106 }
2107 */
2108
2109 int cc = gen % m;
2110 if( cc == 0) cc = m;
2111 int vv = 1 + (gen - cc) / m;
2112
2113// assume( cc == c );
2114// assume( vv == v );
2115
2116 // 1<= c <= m
2117 assume( cc > 0 );
2118 assume( cc <= m );
2119
2120 assume( vv > 0 );
2121 assume( vv <= n );
2122
2123 assume( (cc + (vv-1)*m) == gen );
2124
2125 p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
2126 p_SetComp(h, cc, rRing);
2127
2128 p_Setm(h, rRing); // adjust degree after the previous steps!
2129
2130 pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
2131
2132 pIter(w);
2133 }
2134
2135 idTemp->m[i] = pTempSum;
2136 }
2137
2138 // simplify idTemp???
2139
2141
2143
2144 return(idResult);
2145}
static long p_IncrExp(poly p, int v, ring r)
Definition p_polys.h:593
ideal id_Transp(ideal a, const ring rRing)
transpose a module

◆ id_Transp()

ideal id_Transp ( ideal  a,
const ring  rRing 
)

transpose a module

Definition at line 2014 of file simpleideals.cc.

2015{
2016 int r = a->rank, c = IDELEMS(a);
2017 ideal b = idInit(r,c);
2018
2019 int i;
2020 for (i=c; i>0; i--)
2021 {
2022 poly p=a->m[i-1];
2023 while(p!=NULL)
2024 {
2025 poly h=p_Head(p, rRing);
2026 int co=__p_GetComp(h, rRing)-1;
2027 p_SetComp(h, i, rRing);
2028 p_Setm(h, rRing);
2029 h->next=b->m[co];
2030 b->m[co]=h;
2031 pIter(p);
2032 }
2033 }
2034 for (i=IDELEMS(b)-1; i>=0; i--)
2035 {
2036 poly p=b->m[i];
2037 if(p!=NULL)
2038 {
2039 b->m[i]=p_SortMerge(p,rRing,TRUE);
2040 }
2041 }
2042 return b;
2043}
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition p_polys.h:1250

◆ id_Vec2Ideal()

ideal id_Vec2Ideal ( poly  vec,
const ring  R 
)

Definition at line 1528 of file simpleideals.cc.

1529{
1530 ideal result=idInit(1,1);
1532 p_Vec2Polys(vec, &(result->m), &(IDELEMS(result)),R);
1533 return result;
1534}
fq_nmod_poly_t * vec
Definition facHensel.cc:108
#define omFreeBinAddr(addr)
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition p_polys.cc:3750

◆ idGetNextChoise()

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

Definition at line 1154 of file simpleideals.cc.

1155{
1156 int i = r-1,j;
1157 while ((i >= 0) && (choise[i] == end))
1158 {
1159 i--;
1160 end--;
1161 }
1162 if (i == -1)
1163 *endch = TRUE;
1164 else
1165 {
1166 choise[i]++;
1167 for (j=i+1; j<r; j++)
1168 {
1169 choise[j] = choise[i]+j-i;
1170 }
1171 *endch = FALSE;
1172 }
1173}

◆ idGetNumberOfChoise()

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

Definition at line 1180 of file simpleideals.cc.

1181{
1182 int * localchoise,i,result=0;
1183 BOOLEAN b=FALSE;
1184
1185 if (d<=1) return 1;
1186 localchoise=(int*)omAlloc((d-1)*sizeof(int));
1187 idInitChoise(d-1,begin,end,&b,localchoise);
1188 while (!b)
1189 {
1190 result++;
1191 i = 0;
1192 while ((i<t) && (localchoise[i]==choise[i])) i++;
1193 if (i>=t)
1194 {
1195 i = t+1;
1196 while ((i<d) && (localchoise[i-1]==choise[i])) i++;
1197 if (i>=d)
1198 {
1199 omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
1200 return result;
1201 }
1202 }
1203 idGetNextChoise(d-1,end,&b,localchoise);
1204 }
1205 omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
1206 return 0;
1207}
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)

◆ idInit()

ideal idInit ( int  idsize,
int  rank 
)

initialise an ideal / module

creates an ideal / module

Definition at line 35 of file simpleideals.cc.

36{
37 assume( idsize >= 0 && rank >= 0 );
38
40
41 IDELEMS(hh) = idsize; // ncols
42 hh->nrows = 1; // ideal/module!
43
44 hh->rank = rank; // ideal: 1, module: >= 0!
45
46 if (idsize>0)
47 hh->m = (poly *)omAlloc0(idsize*sizeof(poly));
48 else
49 hh->m = NULL;
50
51 return hh;
52}
#define omAllocBin(bin)

◆ idInitChoise()

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

Definition at line 1132 of file simpleideals.cc.

1133{
1134 /*returns the first choise of r numbers between beg and end*/
1135 int i;
1136 for (i=0; i<r; i++)
1137 {
1138 choise[i] = 0;
1139 }
1140 if (r <= end-beg+1)
1141 for (i=0; i<r; i++)
1142 {
1143 choise[i] = beg+i;
1144 }
1145 if (r > end-beg+1)
1146 *endch = TRUE;
1147 else
1148 *endch = FALSE;
1149}

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

833{
834 if (h2==NULL) return FALSE;
835 assume (h1 != NULL);
836
837 int j = IDELEMS(h1) - 1;
838
839 while ((j >= 0) && (h1->m[j] == NULL)) j--;
840 j++;
841 if (j==IDELEMS(h1))
842 {
843 pEnlargeSet(&(h1->m),IDELEMS(h1),16);
844 IDELEMS(h1)+=16;
845 }
846 h1->m[j]=h2;
847 return TRUE;
848}

◆ idInsertPolyOnPos()

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

insert p into I on position pos

Definition at line 851 of file simpleideals.cc.

852{
853 if (p==NULL) return FALSE;
854 assume (I != NULL);
855
856 int j = IDELEMS(I) - 1;
857
858 while ((j >= 0) && (I->m[j] == NULL)) j--;
859 j++;
860 if (j==IDELEMS(I))
861 {
862 pEnlargeSet(&(I->m),IDELEMS(I),IDELEMS(I)+1);
863 IDELEMS(I)+=1;
864 }
865 for(j = IDELEMS(I)-1;j>pos;j--)
866 I->m[j] = I->m[j-1];
867 I->m[pos]=p;
868 return TRUE;
869}

◆ idIs0()

BOOLEAN idIs0 ( ideal  h)

returns true if h is the zero ideal

Definition at line 960 of file simpleideals.cc.

961{
962 if ((h!=NULL) && (h->m!=NULL))
963 {
964 for( int i = IDELEMS(h)-1; i >= 0; i-- )
965 if(h->m[i] != NULL)
966 return FALSE;
967 }
968 return TRUE;
969}

◆ idIsMonomial()

BOOLEAN idIsMonomial ( ideal  h)

returns true if h is generated by monomials

Definition at line 972 of file simpleideals.cc.

973{
974 assume (h != NULL);
975
977 if (h->m!=NULL)
978 {
979 for( int i = IDELEMS(h)-1; i >= 0; i-- )
980 {
981 if(h->m[i] != NULL)
982 {
983 if(pNext(h->m[i])!=NULL) return FALSE;
985 }
986 }
987 }
988 return found_mon;
989}

◆ idShow()

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

Definition at line 57 of file simpleideals.cc.

58{
59 assume( debugPrint >= 0 );
60
61 if( id == NULL )
62 PrintS("(NULL)");
63 else
64 {
65 Print("Module of rank %ld,real rank %ld and %d generators.\n",
66 id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id));
67
68 int j = (id->ncols*id->nrows) - 1;
69 while ((j > 0) && (id->m[j]==NULL)) j--;
70 for (int i = 0; i <= j; i++)
71 {
72 Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing);PrintLn();
73 }
74 }
75}
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
void PrintLn()
Definition reporter.cc:314

◆ idSkipZeroes()

void idSkipZeroes ( ideal  ide)

gives an ideal/module the minimal possible size

Definition at line 201 of file simpleideals.cc.

202{
203 if(ide!=NULL)
204 {
205 int k;
206 int j = -1;
207 int idelems=IDELEMS(ide);
209
210 for (k=0; k<idelems; k++)
211 {
212 if (ide->m[k] != NULL)
213 {
214 j++;
215 if (change)
216 {
217 ide->m[j] = ide->m[k];
218 ide->m[k] = NULL;
219 }
220 }
221 else
222 {
223 change=TRUE;
224 }
225 }
226 if (change)
227 {
228 if (j == -1)
229 j = 0;
230 j++;
231 pEnlargeSet(&(ide->m),idelems,j-idelems);
232 IDELEMS(ide) = j;
233 }
234 }
235}

◆ idSkipZeroes0()

int idSkipZeroes0 ( ideal  ide)

Definition at line 237 of file simpleideals.cc.

238{
239 assume (ide != NULL);
240
241 int k;
242 int j = -1;
243 int idelems=IDELEMS(ide);
244
245 k=0;
246 while((k<idelems)&&(ide->m[k] != NULL)) k++;
247 if (k==idelems) return idelems;
248 // now: k: pos of first NULL entry
249 j=k; k=k+1;
250 for (; k<idelems; k++)
251 {
252 if (ide->m[k] != NULL)
253 {
254 ide->m[j] = ide->m[k];
255 ide->m[k] = NULL;
256 j++;
257 }
258 }
259 if (j<=1) return 1;
260 return j;
261}

◆ lpmakemonoms()

static void lpmakemonoms ( int  vars,
int  deg,
const ring  r 
)
static

Definition at line 1314 of file simpleideals.cc.

1315{
1316 assume(deg <= r->N/r->isLPring);
1317 if (deg == 0)
1318 {
1319 idpower[0] = p_One(r);
1320 return;
1321 }
1322 else
1323 {
1324 lpmakemonoms(vars, deg - 1, r);
1325 }
1326
1327 int size = idpowerpoint + 1;
1328 for (int j = 2; j <= vars; j++)
1329 {
1330 for (int i = 0; i < size; i++)
1331 {
1332 idpowerpoint = (j-1)*size + i;
1334 }
1335 }
1336 for (int j = 1; j <= vars; j++)
1337 {
1338 for (int i = 0; i < size; i++)
1339 {
1340 idpowerpoint = (j-1)*size + i;
1341 p_SetExp(idpower[idpowerpoint], ((deg - 1) * r->isLPring) + j, 1, r);
1344 }
1345 }
1346}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600

◆ makemonoms()

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

Definition at line 1266 of file simpleideals.cc.

1267{
1268 poly p;
1269 int i=0;
1270
1271 if ((idpowerpoint == 0) && (actvar ==1))
1272 {
1274 monomdeg = 0;
1275 }
1276 while (i<=deg)
1277 {
1278 if (deg == monomdeg)
1279 {
1281 idpowerpoint++;
1282 return;
1283 }
1284 if (actvar == vars)
1285 {
1289 idpowerpoint++;
1290 return;
1291 }
1292 else
1293 {
1295 makemonoms(vars,actvar+1,deg,monomdeg,r);
1297 }
1298 monomdeg++;
1302 i++;
1303 }
1304}
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471

◆ p_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 658 of file simpleideals.cc.

659{
660 if (b==NULL) return 1;
661 if (a==NULL) return -1;
662
663 if (nolex)
664 {
665 int r=p_LtCmp(a,b,R);
666 return r;
667 #if 0
668 if (r!=0) return r;
670 r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
671 n_Delete(&h, R->cf);
672 return r;
673 #endif
674 }
675 int l=rVar(R);
676 while ((l>0) && (p_GetExp(a,l,R)==p_GetExp(b,l,R))) l--;
677 if (l==0)
678 {
679 if (p_GetComp(a,R)==p_GetComp(b,R))
680 {
682 int r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
683 n_Delete(&h,R->cf);
684 return r;
685 }
686 if (p_GetComp(a,R)>p_GetComp(b,R)) return 1;
687 }
688 else if (p_GetExp(a,l,R)>p_GetExp(b,l,R))
689 return 1;
690 return -1;
691}
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),...
Definition coeffs.h:500
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
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:658
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
static int p_LtCmp(poly p, poly q, const ring r)
Definition p_polys.h:1642

Variable Documentation

◆ idpower

STATIC_VAR poly* idpower

Definition at line 29 of file simpleideals.cc.

◆ idpowerpoint

STATIC_VAR int idpowerpoint

Definition at line 31 of file simpleideals.cc.

◆ sip_sideal_bin

VAR omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal))

Definition at line 27 of file simpleideals.cc.