My Project
Loading...
Searching...
No Matches
simpleideals.h File Reference
#include "polys/monomials/ring.h"
#include "polys/matpol.h"

Go to the source code of this file.

Data Structures

struct  const_ideal
 The following sip_sideal structure has many different uses throughout Singular. Basic use-cases for it are: More...
struct  const_map
struct  ideal_list

Macros

#define IDELEMS(i)
#define id_Init(s, r, R)
#define id_Elem(F, R)
#define id_Test(A, lR)
#define id_LmTest(A, lR)
#define id_Print(id, lR, tR)

Functions

ideal idInit (int size, int rank=1)
 creates an ideal / module
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)
static int idElem (const ideal F)
 number of non-zero polys in F
void id_Normalize (ideal id, const ring r)
 normialize all polys in id
int id_MinDegW (ideal M, intvec *w, const ring r)
void id_DBTest (ideal h1, int level, const char *f, const int l, const ring lR, const ring tR)
 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!
ideal id_Copy (ideal h1, const ring r)
 copy an ideal
ideal id_SimpleAdd (ideal h1, ideal h2, const ring r)
 concat the lists h1 and h2 without zeros
ideal id_SimpleMove (ideal h1, ideal h2, const ring R)
 concat the lists h1 and h2 without zeros, destroys h1,h2
ideal id_Add (ideal h1, ideal h2, const ring r)
 h1 + h2
ideal id_Power (ideal given, int exp, const ring r)
BOOLEAN idIs0 (ideal h)
 returns true if h is the zero ideal
BOOLEAN idIsMonomial (ideal h)
 returns true if h is generated by monomials
BOOLEAN idIsSimpleGB (ideal F, ideal Q)
 returns true if F in R/Q has a "simple" GB
BOOLEAN id_IsModule (ideal A, const ring src)
long id_RankFreeModule (ideal m, ring lmRing, ring tailRing)
 return the maximal component number found in any polynomial in s
static long id_RankFreeModule (ideal m, ring r)
ideal id_FreeModule (int i, const ring r)
 the free module of rank i
int id_PosConstant (ideal id, const ring r)
 index of generator with leading term in ground ring (if any); otherwise -1
ideal id_Head (ideal h, const ring r)
 returns the ideals of initial terms
ideal id_MaxIdeal (const ring r)
 initialise the maximal ideal (at 0)
ideal id_MaxIdeal (int deg, const ring r)
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_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_Norm (ideal id, const ring r)
 ideal id = (id[i]), result is leadcoeff(id[i]) = 1
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.
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
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_Transp (ideal a, const ring rRing)
 transpose a module
void id_Compactify (ideal id, const ring r)
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)
ideal id_Homogen (ideal h, int varnum, const ring r)
ideal id_HomogenDP (ideal h, int varnum, const ring r)
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)
BOOLEAN id_HomModule (ideal m, ideal Q, intvec **w, const ring R)
BOOLEAN id_IsZeroDim (ideal I, 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)
ideal id_Subst (ideal id, int n, poly e, 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_ResizeModule (ideal mod, int rows, int cols, const ring R)
ideal id_Matrix2Module (matrix mat, const ring R)
 converts mat to module, destroys mat
ideal id_Vec2Ideal (poly vec, const ring R)
int binom (int n, int 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)
void idShow (const ideal id, const ring lmRing, const ring tailRing, const int debugPrint=0)
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:
intvecid_QHomWeight (ideal id, const ring r)
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 pos, const ring r)
poly id_Array2Vector (poly *m, unsigned n, const ring R)
 for julia: convert an array of poly to vector
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

EXTERN_VAR omBin sip_sideal_bin

Data Structure Documentation

◆ sip_sideal

struct sip_sideal

The following sip_sideal structure has many different uses throughout Singular. Basic use-cases for it are:

  • ideal/module: nrows = 1, ncols >=0 and rank:1 for ideals, rank>=0 for modules
  • matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures NOTE: the m member point to memory chunk of size (ncols*nrows*sizeof(poly)) or is NULL

Definition at line 17 of file simpleideals.h.

Data Fields
poly * m
int ncols
int nrows
long rank

◆ sip_smap

struct sip_smap

Definition at line 32 of file simpleideals.h.

Data Fields
poly * m
int ncols
int nrows
char * preimage

◆ sideal_list

struct sideal_list

Definition at line 45 of file simpleideals.h.

Data Fields
ideal d
ideal_list next
int nr

Macro Definition Documentation

◆ id_Elem

#define id_Elem ( F,
R )
Value:
static int idElem(const ideal F)
number of non-zero polys in F

Definition at line 79 of file simpleideals.h.

◆ id_Init

#define id_Init ( s,
r,
R )
Value:
const CanonicalForm int s
Definition facAbsFact.cc:51
ideal idInit(int idsize, int rank)
initialise an ideal / module

Definition at line 58 of file simpleideals.h.

◆ id_LmTest

#define id_LmTest ( A,
lR )
Value:
id_DBLmTest(A, PDEBUG, __FILE__,__LINE__, lR)
#define PDEBUG
Definition auxiliary.h:171
void id_DBLmTest(ideal h1, int level, const char *f, const int l, const ring r)
Internal verification for ideals/modules and dense matrices!
#define A
Definition sirandom.c:24

Definition at line 90 of file simpleideals.h.

◆ id_Print

#define id_Print ( id,
lR,
tR )
Value:
idShow(id, lR, tR)
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)

Definition at line 165 of file simpleideals.h.

◆ id_Test

#define id_Test ( A,
lR )
Value:
id_DBTest(A, PDEBUG, __FILE__,__LINE__, lR, lR)
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 89 of file simpleideals.h.

◆ IDELEMS

#define IDELEMS ( i)
Value:
((i)->ncols)
int i
Definition cfEzgcd.cc:132

Definition at line 23 of file simpleideals.h.

Function Documentation

◆ binom()

int binom ( int n,
int r )

Definition at line 1293 of file simpleideals.cc.

1294{
1295 int i;
1296 int64 result;
1297
1298 if (r==0) return 1;
1299 if (n-r<r) return binom(n,n-r);
1300 result = n-r+1;
1301 for (i=2;i<=r;i++)
1302 {
1303 result *= n-r+i;
1304 result /= i;
1305 }
1306 if (result>MAX_INT_VAL)
1307 {
1308 WarnS("overflow in binomials");
1309 result=0;
1310 }
1311 return (int)result;
1312}
long int64
Definition auxiliary.h:68
#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 954 of file simpleideals.cc.

955{
956 id_Test(h1, r);
957 id_Test(h2, r);
958
959 ideal result = id_SimpleAdd(h1,h2,r);
961 return result;
962}
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 1618 of file simpleideals.cc.

1619{
1620 poly h;
1621 int l;
1622 sBucket_pt bucket = sBucketCreate(R);
1623
1624 for(unsigned j=0;j<n ;j++)
1625 {
1626 h = m[j];
1627 if (h!=NULL)
1628 {
1629 h=p_Copy(h, R);
1630 l=pLength(h);
1631 p_SetCompP(h,j+1, R);
1632 sBucket_Merge_p(bucket, h, l);
1633 }
1634 }
1635 sBucketClearMerge(bucket, &h, &l);
1636 sBucketDestroy(&bucket);
1637 return h;
1638}
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
sBucket * sBucket_pt
Definition sbuckets.h:16
#define R
Definition sirandom.c:27

◆ id_ChineseRemainder()

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

Definition at line 2228 of file simpleideals.cc.

2229{
2230 int cnt=0;int rw=0; int cl=0;
2231 int i,j;
2232 // find max. size of xx[.]:
2233 for(j=rl-1;j>=0;j--)
2234 {
2235 i=IDELEMS(xx[j])*xx[j]->nrows;
2236 if (i>cnt) cnt=i;
2237 if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices
2238 if (xx[j]->ncols >cl) cl=xx[j]->ncols; // for lifting matrices
2239 }
2240 if (rw*cl !=cnt)
2241 {
2242 WerrorS("format mismatch in CRT");
2243 return NULL;
2244 }
2245 ideal result=idInit(cnt,xx[0]->rank);
2246 result->nrows=rw; // for lifting matrices
2247 result->ncols=cl; // for lifting matrices
2248 number *x=(number *)omAlloc(rl*sizeof(number));
2249 poly *p=(poly *)omAlloc(rl*sizeof(poly));
2250 CFArray inv_cache(rl);
2251 EXTERN_VAR int n_SwitchChinRem; //TEST
2252 int save_n_SwitchChinRem=n_SwitchChinRem;
2254 for(i=cnt-1;i>=0;i--)
2255 {
2256 for(j=rl-1;j>=0;j--)
2257 {
2258 if(i>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal
2259 p[j]=NULL;
2260 else
2261 p[j]=xx[j]->m[i];
2262 }
2263 result->m[i]=p_ChineseRemainder(p,x,q,rl,inv_cache,r);
2264 for(j=rl-1;j>=0;j--)
2265 {
2266 if(i<IDELEMS(xx[j])*xx[j]->nrows) xx[j]->m[i]=p[j];
2267 }
2268 }
2269 n_SwitchChinRem=save_n_SwitchChinRem;
2270 omFreeSize(p,rl*sizeof(poly));
2271 omFreeSize(x,rl*sizeof(number));
2272 for(i=rl-1;i>=0;i--) id_Delete(&(xx[i]),r);
2273 omFreeSize(xx,rl*sizeof(ideal));
2274 return result;
2275}
Array< CanonicalForm > CFArray
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:3075
#define omFreeSize(addr, size)
#define omAlloc(size)
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 1540 of file simpleideals.cc.

1541{
1542 int i;
1543 BOOLEAN b=FALSE;
1544
1545 i = IDELEMS(id)-1;
1546 while ((! b) && (i>=0))
1547 {
1548 b=p_IsUnit(id->m[i],r);
1549 i--;
1550 }
1551 if (b)
1552 {
1553 for(i=IDELEMS(id)-1;i>=0;i--) p_Delete(&id->m[i],r);
1554 id->m[0]=p_One(r);
1555 }
1556 else
1557 {
1558 id_DelMultiples(id,r);
1559 }
1560 idSkipZeroes(id);
1561}
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 lR,
const ring tR )

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_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:4679

◆ 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}
void * ADDRESS
Definition auxiliary.h:120
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 pos,
const ring r )

Definition at line 2291 of file simpleideals.cc.

2292{
2293 if ((p<0)||(p>=IDELEMS(I))) return NULL;
2294 ideal ret=idInit(IDELEMS(I)-1,I->rank);
2295 for(int i=0;i<p;i++) ret->m[i]=p_Copy(I->m[i],r);
2296 for(int i=p+1;i<IDELEMS(I);i++) ret->m[i-1]=p_Copy(I->m[i],r);
2297 return ret;
2298}

◆ 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)
368#ifdef HAVE_RINGS
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:4743

◆ id_FreeModule()

ideal id_FreeModule ( int i,
const ring r )

the free module of rank i

Definition at line 1316 of file simpleideals.cc.

1317{
1318 assume(i >= 0);
1319 if (r->isLPring)
1320 {
1321 PrintS("In order to address bimodules, the command freeAlgebra should be used.");
1322 }
1323 ideal h = idInit(i, i);
1324
1325 for (int j=0; j<i; j++)
1326 {
1327 h->m[j] = p_One(r);
1328 p_SetComp(h->m[j],j+1,r);
1329 p_SetmComp(h->m[j],r);
1330 }
1331
1332 return h;
1333}
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 1564 of file simpleideals.cc.

1565{
1566 ideal m = idInit(IDELEMS(h),h->rank);
1567
1568 if (r->cf->has_simple_Alloc)
1569 {
1570 for (int i=IDELEMS(h)-1;i>=0; i--)
1571 if (h->m[i]!=NULL)
1572 m->m[i]=p_CopyPowerProduct0(h->m[i],pGetCoeff(h->m[i]),r);
1573 }
1574 else
1575 {
1576 for (int i=IDELEMS(h)-1;i>=0; i--)
1577 if (h->m[i]!=NULL)
1578 m->m[i]=p_Head(h->m[i],r);
1579 }
1580
1581 return m;
1582}
poly p_CopyPowerProduct0(const poly p, number n, const ring r)
like p_Head, but with coefficient n
Definition p_polys.cc:5135
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 1114 of file simpleideals.cc.

1115{
1116 int i;
1117 BOOLEAN b;
1118 i = 0;
1119 b = TRUE;
1120 while ((i < IDELEMS(id)) && b)
1121 {
1122 b = p_IsHomogeneous(id->m[i],r);
1123 i++;
1124 }
1125 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1126 {
1127 i=0;
1128 while ((i < IDELEMS(Q)) && b)
1129 {
1130 b = p_IsHomogeneous(Q->m[i],r);
1131 i++;
1132 }
1133 }
1134 return b;
1135}
#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 1140 of file simpleideals.cc.

1141{
1142 int i;
1143 BOOLEAN b;
1144 i = 0;
1145 b = TRUE;
1146 while ((i < IDELEMS(id)) && b)
1147 {
1148 b = p_IsHomogeneousDP(id->m[i],r);
1149 i++;
1150 }
1151 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1152 {
1153 i=0;
1154 while ((i < IDELEMS(Q)) && b)
1155 {
1156 b = p_IsHomogeneousDP(Q->m[i],r);
1157 i++;
1158 }
1159 }
1160 return b;
1161}
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 1163 of file simpleideals.cc.

1164{
1165 int i;
1166 BOOLEAN b;
1167 i = 0;
1168 b = TRUE;
1169 while ((i < IDELEMS(id)) && b)
1170 {
1171 b = p_IsHomogeneousW(id->m[i],w,r);
1172 i++;
1173 }
1174 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1175 {
1176 i=0;
1177 while ((i < IDELEMS(Q)) && b)
1178 {
1179 b = p_IsHomogeneousW(Q->m[i],w,r);
1180 i++;
1181 }
1182 }
1183 return b;
1184}
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 1805 of file simpleideals.cc.

1806{
1807 if (w!=NULL) *w=NULL;
1808 if ((Q!=NULL) && (!id_HomIdeal(Q,NULL,R))) return FALSE;
1809 if (idIs0(m))
1810 {
1811 if (w!=NULL) (*w)=new intvec(m->rank);
1812 return TRUE;
1813 }
1814
1815 long cmax=1,order=0,ord,* diff,diffmin=32000;
1816 int *iscom;
1817 int i;
1818 poly p=NULL;
1819 pFDegProc d;
1820 if (R->pLexOrder && (R->order[0]==ringorder_lp))
1821 d=p_Totaldegree;
1822 else
1823 d=R->pFDeg;
1824 int length=IDELEMS(m);
1825 poly* P=m->m;
1826 poly* F=(poly*)omAlloc(length*sizeof(poly));
1827 for (i=length-1;i>=0;i--)
1828 {
1829 p=F[i]=P[i];
1830 cmax=si_max(cmax,p_MaxComp(p,R));
1831 }
1832 cmax++;
1833 diff = (long *)omAlloc0(cmax*sizeof(long));
1834 if (w!=NULL) *w=new intvec(cmax-1);
1835 iscom = (int *)omAlloc0(cmax*sizeof(int));
1836 i=0;
1837 while (i<=length)
1838 {
1839 if (i<length)
1840 {
1841 p=F[i];
1842 while ((p!=NULL) && (iscom[__p_GetComp(p,R)]==0)) pIter(p);
1843 }
1844 if ((p==NULL) && (i<length))
1845 {
1846 i++;
1847 }
1848 else
1849 {
1850 if (p==NULL) /* && (i==length) */
1851 {
1852 i=0;
1853 while ((i<length) && (F[i]==NULL)) i++;
1854 if (i>=length) break;
1855 p = F[i];
1856 }
1857 //if (pLexOrder && (currRing->order[0]==ringorder_lp))
1858 // order=pTotaldegree(p);
1859 //else
1860 // order = p->order;
1861 // order = pFDeg(p,currRing);
1862 order = d(p,R) +diff[__p_GetComp(p,R)];
1863 //order += diff[pGetComp(p)];
1864 p = F[i];
1865//Print("Actual p=F[%d]: ",i);pWrite(p);
1866 F[i] = NULL;
1867 i=0;
1868 }
1869 while (p!=NULL)
1870 {
1871 if (R->pLexOrder && (R->order[0]==ringorder_lp))
1872 ord=p_Totaldegree(p,R);
1873 else
1874 // ord = p->order;
1875 ord = R->pFDeg(p,R);
1876 if (iscom[__p_GetComp(p,R)]==0)
1877 {
1878 diff[__p_GetComp(p,R)] = order-ord;
1879 iscom[__p_GetComp(p,R)] = 1;
1880/*
1881*PrintS("new diff: ");
1882*for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1883*PrintLn();
1884*PrintS("new iscom: ");
1885*for (j=0;j<cmax;j++) Print("%d ",iscom[j]);
1886*PrintLn();
1887*Print("new set %d, order %d, ord %d, diff %d\n",pGetComp(p),order,ord,diff[pGetComp(p)]);
1888*/
1889 }
1890 else
1891 {
1892/*
1893*PrintS("new diff: ");
1894*for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1895*PrintLn();
1896*Print("order %d, ord %d, diff %d\n",order,ord,diff[pGetComp(p)]);
1897*/
1898 if (order != (ord+diff[__p_GetComp(p,R)]))
1899 {
1900 omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1901 omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1902 omFreeSize((ADDRESS) F,length*sizeof(poly));
1903 delete *w;*w=NULL;
1904 return FALSE;
1905 }
1906 }
1907 pIter(p);
1908 }
1909 }
1910 omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1911 omFreeSize((ADDRESS) F,length*sizeof(poly));
1912 for (i=1;i<cmax;i++) (**w)[i-1]=(int)(diff[i]);
1913 for (i=1;i<cmax;i++)
1914 {
1915 if (diff[i]<diffmin) diffmin=diff[i];
1916 }
1917 if (w!=NULL)
1918 {
1919 for (i=1;i<cmax;i++)
1920 {
1921 (**w)[i-1]=(int)(diff[i]-diffmin);
1922 }
1923 }
1924 omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1925 return TRUE;
1926}
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
#define omAlloc0(size)
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 1186 of file simpleideals.cc.

1187{
1188 int i;
1189 BOOLEAN b;
1190 i = 0;
1191 b = TRUE;
1192 while ((i < IDELEMS(id)) && b)
1193 {
1194 b = p_IsHomogeneousW(id->m[i],w,module_w,r);
1195 i++;
1196 }
1197 if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
1198 {
1199 i=0;
1200 while ((i < IDELEMS(Q)) && b)
1201 {
1202 b = p_IsHomogeneousW(Q->m[i],w,r);
1203 i++;
1204 }
1205 }
1206 return b;
1207}

◆ id_Homogen()

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

Definition at line 1584 of file simpleideals.cc.

1585{
1586 ideal m = idInit(IDELEMS(h),h->rank);
1587 int i;
1588
1589 for (i=IDELEMS(h)-1;i>=0; i--)
1590 {
1591 m->m[i]=p_Homogen(h->m[i],varnum,r);
1592 }
1593 return m;
1594}
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 1596 of file simpleideals.cc.

1597{
1598 ideal m = idInit(IDELEMS(h),h->rank);
1599 int i;
1600
1601 for (i=IDELEMS(h)-1;i>=0; i--)
1602 {
1603 m->m[i]=p_HomogenDP(h->m[i],varnum,r);
1604 }
1605 return m;
1606}
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 926 of file simpleideals.cc.

928{
929 id_Test(h1, r);
930 p_Test(h2, r);
931
932 if ((!zeroOk) && (h2 == NULL)) return FALSE;
933 if (!duplicateOk)
934 {
935 bool h2FoundInH1 = false;
936 int i = 0;
937 while ((i < validEntries) && (!h2FoundInH1))
938 {
939 h2FoundInH1 = p_EqualPolys(h1->m[i], h2,r);
940 i++;
941 }
942 if (h2FoundInH1) return FALSE;
943 }
944 if (validEntries == IDELEMS(h1))
945 {
946 pEnlargeSet(&(h1->m), IDELEMS(h1), 16);
947 IDELEMS(h1) += 16;
948 }
949 h1->m[validEntries] = h2;
950 return TRUE;
951}
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 1092 of file simpleideals.cc.

1093{
1094 if ((src->VarOffset[0]== -1)
1095 || (src->pCompIndex<0))
1096 return FALSE; // ring without components
1097 for (int i=IDELEMS(A)-1;i>=0;i--)
1098 {
1099 if (A->m[i]!=NULL)
1100 {
1101 if (p_GetComp(A->m[i],src)>0)
1102 return TRUE;
1103 else
1104 return FALSE;
1105 }
1106 }
1107 return A->rank>1;
1108}

◆ id_IsZeroDim()

BOOLEAN id_IsZeroDim ( ideal I,
const ring r )

Definition at line 2045 of file simpleideals.cc.

2046{
2047 BOOLEAN *UsedAxis=(BOOLEAN *)omAlloc0(rVar(r)*sizeof(BOOLEAN));
2048 int i,n;
2049 poly po;
2051 for(i=IDELEMS(I)-1;i>=0;i--)
2052 {
2053 po=I->m[i];
2054 if ((po!=NULL) &&((n=p_IsPurePower(po,r))!=0)) UsedAxis[n-1]=TRUE;
2055 }
2056 for(i=rVar(r)-1;i>=0;i--)
2057 {
2058 if(UsedAxis[i]==FALSE) {res=FALSE; break;} // not zero-dim.
2059 }
2060 omFreeSize(UsedAxis,rVar(r)*sizeof(BOOLEAN));
2061 return res;
2062}
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:603

◆ id_Jet()

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

Definition at line 1928 of file simpleideals.cc.

1929{
1930 ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1931 r->nrows = i-> nrows;
1932 r->ncols = i-> ncols;
1933 //r->rank = i-> rank;
1934
1935 for(long k=((long)(i->nrows))*((long)(i->ncols))-1;k>=0; k--)
1936 r->m[k]=pp_Jet(i->m[k],d,R);
1937
1938 return r;
1939}
poly pp_Jet(poly p, int m, const ring R)
Definition p_polys.cc:4497

◆ id_Jet0()

ideal id_Jet0 ( const ideal i,
const ring R )

Definition at line 1941 of file simpleideals.cc.

1942{
1943 ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1944 r->nrows = i-> nrows;
1945 r->ncols = i-> ncols;
1946 //r->rank = i-> rank;
1947
1948 for(long k=((long)(i->nrows))*((long)(i->ncols))-1;k>=0; k--)
1949 r->m[k]=pp_Jet0(i->m[k],R);
1950
1951 return r;
1952}
poly pp_Jet0(poly p, const ring R)
Definition p_polys.cc:4525

◆ id_JetW()

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

Definition at line 1954 of file simpleideals.cc.

1955{
1956 ideal r=idInit(IDELEMS(i),i->rank);
1957 if (ecartWeights!=NULL)
1958 {
1959 WerrorS("cannot compute weighted jets now");
1960 }
1961 else
1962 {
1963 int *w=iv2array(iv,R);
1964 int k;
1965 for(k=0; k<IDELEMS(i); k++)
1966 {
1967 r->m[k]=pp_JetW(i->m[k],d,w,R);
1968 }
1969 omFreeSize((ADDRESS)w,(rVar(R)+1)*sizeof(int));
1970 }
1971 return r;
1972}
poly pp_JetW(poly p, int m, int *w, const ring R)
Definition p_polys.cc:4570
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 1641 of file simpleideals.cc.

1642{
1643 int mc=MATCOLS(mat);
1644 int mr=MATROWS(mat);
1645 ideal result = idInit(mc,mr);
1646 int i,j,l;
1647 poly h;
1648 sBucket_pt bucket = sBucketCreate(R);
1649
1650 for(j=0;j<mc /*MATCOLS(mat)*/;j++) /* j is also index in result->m */
1651 {
1652 for (i=0;i<mr /*MATROWS(mat)*/;i++)
1653 {
1654 h = MATELEM0(mat,i,j);
1655 if (h!=NULL)
1656 {
1657 l=pLength(h);
1658 MATELEM0(mat,i,j)=NULL;
1659 p_SetCompP(h,i+1, R);
1660 sBucket_Merge_p(bucket, h, l);
1661 }
1662 }
1663 sBucketClearMerge(bucket, &(result->m[j]), &l);
1664 }
1665 sBucketDestroy(&bucket);
1666
1667 // obachman: need to clean this up
1668 id_Delete((ideal*) &mat,R);
1669 return result;
1670}
#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 1433 of file simpleideals.cc.

1434{
1435 if (deg < 1)
1436 {
1437 ideal I=idInit(1,1);
1438 I->m[0]=p_One(r);
1439 return I;
1440 }
1441 if (deg == 1
1442#ifdef HAVE_SHIFTBBA
1443 && !r->isLPring
1444#endif
1445 )
1446 {
1447 return id_MaxIdeal(r);
1448 }
1449
1450 int vars, i;
1451#ifdef HAVE_SHIFTBBA
1452 if (r->isLPring)
1453 {
1454 vars = r->isLPring - r->LPncGenCount;
1455 i = 1;
1456 // i = vars^deg
1457 for (int j = 0; j < deg; j++)
1458 {
1459 i *= vars;
1460 }
1461 }
1462 else
1463#endif
1464 {
1465 vars = rVar(r);
1466 i = binom(vars+deg-1,deg);
1467 }
1468 if (i<=0) return idInit(1,1);
1469 ideal id=idInit(i,1);
1470 idpower = id->m;
1471 idpowerpoint = 0;
1472#ifdef HAVE_SHIFTBBA
1473 if (r->isLPring)
1474 {
1475 lpmakemonoms(vars, deg, r);
1476 }
1477 else
1478#endif
1479 {
1480 makemonoms(vars,1,deg,0,r);
1481 }
1482 idpower = NULL;
1483 idpowerpoint = 0;
1484 return id;
1485}
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 2075 of file simpleideals.cc.

2076{
2077 int d=-1;
2078 for(int i=0;i<IDELEMS(M);i++)
2079 {
2080 if (M->m[i]!=NULL)
2081 {
2082 int d0=p_MinDeg(M->m[i],w,r);
2083 if(-1<d0&&((d0<d)||(d==-1)))
2084 d=d0;
2085 }
2086 }
2087 return d;
2088}
int p_MinDeg(poly p, intvec *w, const ring R)
Definition p_polys.cc:4615
#define M
Definition sirandom.c:25

◆ id_Module2formatedMatrix()

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

Definition at line 1721 of file simpleideals.cc.

1722{
1723 matrix result = mpNew(rows,cols);
1724 int i,cp,r=id_RankFreeModule(mod,R),c=IDELEMS(mod);
1725 poly p,h;
1726
1727 if (r>rows) r = rows;
1728 if (c>cols) c = cols;
1729 for(i=0;i<c;i++)
1730 {
1731 p=pReverse(mod->m[i]);
1732 mod->m[i]=NULL;
1733 while (p!=NULL)
1734 {
1735 h=p;
1736 pIter(p);
1737 pNext(h)=NULL;
1738 cp = p_GetComp(h,R);
1739 if (cp<=r)
1740 {
1741 p_SetComp(h,0,R);
1742 p_SetmComp(h,R);
1743 MATELEM0(result,cp-1,i) = p_Add_q(MATELEM0(result,cp-1,i),h,R);
1744 }
1745 else
1746 p_Delete(&h,R);
1747 }
1748 }
1749 id_Delete(&mod,R);
1750 return result;
1751}
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
ip_smatrix * matrix
Definition matpol.h:43
#define pNext(p)
Definition monomials.h:36
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 1675 of file simpleideals.cc.

1676{
1677 matrix result = mpNew(mod->rank,IDELEMS(mod));
1678 long i; long cp;
1679 poly p,h;
1680
1681 for(i=0;i<IDELEMS(mod);i++)
1682 {
1683 p=pReverse(mod->m[i]);
1684 mod->m[i]=NULL;
1685 while (p!=NULL)
1686 {
1687 h=p;
1688 pIter(p);
1689 pNext(h)=NULL;
1690 cp = si_max(1L,p_GetComp(h, R)); // if used for ideals too
1691 //cp = p_GetComp(h,R);
1692 p_SetComp(h,0,R);
1693 p_SetmComp(h,R);
1694#ifdef TEST
1695 if (cp>mod->rank)
1696 {
1697 Print("## inv. rank %ld -> %ld\n",mod->rank,cp);
1698 int k,l,o=mod->rank;
1699 mod->rank=cp;
1700 matrix d=mpNew(mod->rank,IDELEMS(mod));
1701 for (l=0; l<o; l++)
1702 {
1703 for (k=0; k<IDELEMS(mod); k++)
1704 {
1707 }
1708 }
1709 id_Delete((ideal *)&result,R);
1710 result=d;
1711 }
1712#endif
1713 MATELEM0(result,cp-1,i) = p_Add_q(MATELEM0(result,cp-1,i),h,R);
1714 }
1715 }
1716 // obachman 10/99: added the following line, otherwise memory leak!
1717 id_Delete(&mod,R);
1718 return result;
1719}

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

968{
969 id_Test(h1, R);
970 id_Test(h2, R);
971
972 int j = IDELEMS(h1);
973 while ((j > 0) && (h1->m[j-1] == NULL)) j--;
974
975 int i = IDELEMS(h2);
976 while ((i > 0) && (h2->m[i-1] == NULL)) i--;
977
978 j *= i;
979 int r = si_max( h2->rank, h1->rank );
980 if (j==0)
981 {
982 if ((IDELEMS(h1)>0) && (IDELEMS(h2)>0)) j=1;
983 return idInit(j, r);
984 }
985 ideal hh = idInit(j, r);
986
987 int k = 0;
988 for (i=0; i<IDELEMS(h1); i++)
989 {
990 if (h1->m[i] != NULL)
991 {
992 for (j=0; j<IDELEMS(h2); j++)
993 {
994 if (h2->m[j] != NULL)
995 {
996 hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],R);
997 k++;
998 }
999 }
1000 }
1001 }
1002
1003 id_Compactify(hh,R);
1004 return hh;
1005}
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167

◆ 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 id,
const ring r )

normialize all polys in id

Definition at line 2064 of file simpleideals.cc.

2065{
2066 if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
2067 int i;
2068 for(i=I->nrows*I->ncols-1;i>=0;i--)
2069 {
2070 poly p=I->m[i];
2071 if (p!=NULL) p_Normalize(p,r);
2072 }
2073}
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3952
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:559

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

2302{
2303 ideal II=(ideal)mpNew(R,C);
2304 II->rank=I->rank;
2305 for(int i=R*C-1; i>=0; i--)
2306 {
2307 II->m[i]=p_PermPoly(I->m[i],perm,src,dst,nMap,par_perm,P,use_mult);
2308 }
2309 return II;
2310}
long rank
Definition matpol.h:19
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:4269

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

1515{
1516 ideal result,temp;
1517 poly p1;
1518 int i;
1519
1520 if (idIs0(given)) return idInit(1,1);
1521 temp = id_Copy(given,r);
1522 idSkipZeroes(temp);
1523 i = binom(IDELEMS(temp)+exp-1,exp);
1524 result = idInit(i,1);
1525 result->nrows = 0;
1526//Print("ideal contains %d elements\n",i);
1527 p1=p_One(r);
1528 id_NextPotence(temp,result,0,IDELEMS(temp)-1,exp,exp,p1,r);
1529 p_Delete(&p1,r);
1530 id_Delete(&temp,r);
1531 result->nrows = 1;
1534 return result;
1535}
gmp_float exp(const gmp_float &a)
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, const ring r)
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 1998 of file simpleideals.cc.

1999{
2000 poly head, tail;
2001 int k;
2002 int in=IDELEMS(id)-1, ready=0, all=0,
2003 coldim=rVar(r), rowmax=2*coldim;
2004 if (in<0) return NULL;
2005 intvec *imat=new intvec(rowmax+1,coldim,0);
2006
2007 do
2008 {
2009 head = id->m[in--];
2010 if (head!=NULL)
2011 {
2012 tail = pNext(head);
2013 while (tail!=NULL)
2014 {
2015 all++;
2016 for (k=1;k<=coldim;k++)
2017 IMATELEM(*imat,all,k) = p_GetExpDiff(head,tail,k,r);
2018 if (all==rowmax)
2019 {
2020 ivTriangIntern(imat, ready, all);
2021 if (ready==coldim)
2022 {
2023 delete imat;
2024 return NULL;
2025 }
2026 }
2027 pIter(tail);
2028 }
2029 }
2030 } while (in>=0);
2031 if (all>ready)
2032 {
2033 ivTriangIntern(imat, ready, all);
2034 if (ready==coldim)
2035 {
2036 delete imat;
2037 return NULL;
2038 }
2039 }
2040 intvec *result = ivSolveKern(imat, ready);
2041 delete imat;
2042 return result;
2043}
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() [1/2]

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

return the maximal component number found in any polynomial in s

Definition at line 1073 of file simpleideals.cc.

1074{
1075 long j = 0;
1076
1077 if (rRing_has_Comp(tailRing) && rRing_has_Comp(lmRing))
1078 {
1079 poly *p=s->m;
1080 for (unsigned int l=IDELEMS(s); l > 0; --l, ++p)
1081 if (*p != NULL)
1082 {
1083 pp_Test(*p, lmRing, tailRing);
1084 const long k = p_MaxComp(*p, lmRing, tailRing);
1085 if (k>j) j = k;
1086 }
1087 }
1088
1089 return j; // return -1;
1090}
#define rRing_has_Comp(r)
Definition monomials.h:266
#define pp_Test(p, lmRing, tailRing)
Definition p_polys.h:163

◆ id_RankFreeModule() [2/2]

long id_RankFreeModule ( ideal m,
ring r )
inlinestatic

Definition at line 112 of file simpleideals.h.

113{return id_RankFreeModule(m, r, r);}
long id_RankFreeModule(ideal m, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s

◆ id_ResizeModule()

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

Definition at line 1753 of file simpleideals.cc.

1754{
1755 // columns?
1756 if (cols!=IDELEMS(mod))
1757 {
1758 for(int i=IDELEMS(mod)-1;i>=cols;i--) p_Delete(&mod->m[i],R);
1759 pEnlargeSet(&(mod->m),IDELEMS(mod),cols-IDELEMS(mod));
1760 IDELEMS(mod)=cols;
1761 }
1762 // rows?
1763 if (rows<mod->rank)
1764 {
1765 for(int i=IDELEMS(mod)-1;i>=0;i--)
1766 {
1767 if (mod->m[i]!=NULL)
1768 {
1769 while((mod->m[i]!=NULL) && (p_GetComp(mod->m[i],R)>rows))
1770 mod->m[i]=p_LmDeleteAndNext(mod->m[i],R);
1771 poly p=mod->m[i];
1772 while(pNext(p)!=NULL)
1773 {
1774 if (p_GetComp(pNext(p),R)>rows)
1776 else
1777 pIter(p);
1778 }
1779 }
1780 }
1781 }
1782 mod->rank=rows;
1783 return mod;
1784}
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 2277 of file simpleideals.cc.

2278{
2279// id_Test( M, r );
2280
2281// assume( s >= 0 ); // negative is also possible // TODO: verify input ideal in such a case!?
2282
2283 for(int i=IDELEMS(M)-1; i>=0;i--)
2284 p_Shift(&(M->m[i]),s,r);
2285
2286 M->rank += s;
2287
2288// id_Test( M, r );
2289}
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4873

◆ 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 {
797 ideal res=id_Copy(h2,R);
798 if (res->rank<h1->rank) res->rank=h1->rank;
799 return res;
800 }
801 if ( idIs0(h2) )
802 {
803 ideal res=id_Copy(h1,R);
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_SimpleMove()

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

concat the lists h1 and h2 without zeros, destroys h1,h2

Definition at line 831 of file simpleideals.cc.

832{
833 if ( idIs0(h1) )
834 {
835 ideal res=h2;
836 if (res->rank<h1->rank) res->rank=h1->rank;
837 id_Delete(&h1,R);
838 return res;
839 }
840 if ( idIs0(h2) )
841 {
842 ideal res=h1;
843 if (res->rank<h2->rank) res->rank=h2->rank;
844 id_Delete(&h2,R);
845 return res;
846 }
847
848 int j = IDELEMS(h1)-1;
849 while ((j >= 0) && (h1->m[j] == NULL)) j--;
850
851 int i = IDELEMS(h2)-1;
852 while ((i >= 0) && (h2->m[i] == NULL)) i--;
853
854 const int r = si_max(h1->rank, h2->rank);
855
856 ideal result = idInit(i+j+2,r);
857
858 int l;
859
860 for (l=j; l>=0; l--)
861 {
862 result->m[l] = h1->m[l];
863 h1->m[l] = NULL;
864 }
865
866 j = i+j+1;
867 for (l=i; l>=0; l--, j--)
868 {
869 result->m[j] = h2->m[l];
870 h2->m[l] = NULL;
871 }
872
873 id_Delete(&h1,R);
874 id_Delete(&h2,R);
875 return result;
876}

◆ 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;
701 int diff, olddiff, lastcomp, newcomp;
702 BOOLEAN notFound;
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 }
770 lastcomp = newcomp;
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 1790 of file simpleideals.cc.

1791{
1792 int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
1793 ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
1794
1795 res->rank = id->rank;
1796 for(k--;k>=0;k--)
1797 {
1798 res->m[k]=p_Subst(id->m[k],n,e,r);
1799 id->m[k]=NULL;
1800 }
1801 id_Delete(&id,r);
1802 return res;
1803}
poly * m
Definition matpol.h:18
poly p_Subst(poly p, int n, poly e, const ring r)
Definition p_polys.cc:4097

◆ id_Transp()

ideal id_Transp ( ideal a,
const ring rRing )

transpose a module

Definition at line 2095 of file simpleideals.cc.

2096{
2097 int r = a->rank, c = IDELEMS(a);
2098 ideal b = idInit(r,c);
2099
2100 int i;
2101 for (i=c; i>0; i--)
2102 {
2103 poly p=a->m[i-1];
2104 while(p!=NULL)
2105 {
2106 poly h=p_Head(p, rRing);
2107 int co=__p_GetComp(h, rRing)-1;
2108 p_SetComp(h, i, rRing);
2109 p_Setm(h, rRing);
2110 h->next=b->m[co];
2111 b->m[co]=h;
2112 pIter(p);
2113 }
2114 }
2115 for (i=IDELEMS(b)-1; i>=0; i--)
2116 {
2117 poly p=b->m[i];
2118 if(p!=NULL)
2119 {
2120 b->m[i]=p_SortMerge(p,rRing,TRUE);
2121 }
2122 }
2123 return b;
2124}
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 1609 of file simpleideals.cc.

1610{
1611 ideal result=idInit(1,1);
1613 p_Vec2Polys(vec, &(result->m), &(IDELEMS(result)),R);
1614 return result;
1615}
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

◆ idElem()

int idElem ( const ideal F)
inlinestatic

number of non-zero polys in F

Definition at line 69 of file simpleideals.h.

70{
71 int i=0;
72 for(int j=IDELEMS(F)-1;j>=0;j--)
73 {
74 if ((F->m)[j]!=NULL) i++;
75 }
76 return i;
77}

◆ idGetNextChoise()

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

Definition at line 1235 of file simpleideals.cc.

1236{
1237 int i = r-1,j;
1238 while ((i >= 0) && (choise[i] == end))
1239 {
1240 i--;
1241 end--;
1242 }
1243 if (i == -1)
1244 *endch = TRUE;
1245 else
1246 {
1247 choise[i]++;
1248 for (j=i+1; j<r; j++)
1249 {
1250 choise[j] = choise[i]+j-i;
1251 }
1252 *endch = FALSE;
1253 }
1254}

◆ idGetNumberOfChoise()

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

Definition at line 1261 of file simpleideals.cc.

1262{
1263 int * localchoise,i,result=0;
1264 BOOLEAN b=FALSE;
1265
1266 if (d<=1) return 1;
1267 localchoise=(int*)omAlloc((d-1)*sizeof(int));
1268 idInitChoise(d-1,begin,end,&b,localchoise);
1269 while (!b)
1270 {
1271 result++;
1272 i = 0;
1273 while ((i<t) && (localchoise[i]==choise[i])) i++;
1274 if (i>=t)
1275 {
1276 i = t+1;
1277 while ((i<d) && (localchoise[i-1]==choise[i])) i++;
1278 if (i>=d)
1279 {
1280 omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
1281 return result;
1282 }
1283 }
1284 idGetNextChoise(d-1,end,&b,localchoise);
1285 }
1286 omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
1287 return 0;
1288}
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 )

creates an ideal / module

creates an ideal / module

Definition at line 35 of file simpleideals.cc.

36{
37 assume( idsize >= 0 && rank >= 0 );
38
39 ideal hh = (ideal)omAllocBin(sip_sideal_bin);
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 1213 of file simpleideals.cc.

1214{
1215 /*returns the first choise of r numbers between beg and end*/
1216 int i;
1217 for (i=0; i<r; i++)
1218 {
1219 choise[i] = 0;
1220 }
1221 if (r <= end-beg+1)
1222 for (i=0; i<r; i++)
1223 {
1224 choise[i] = beg+i;
1225 }
1226 if (r > end-beg+1)
1227 *endch = TRUE;
1228 else
1229 *endch = FALSE;
1230}

◆ idIs0()

BOOLEAN idIs0 ( ideal h)

returns true if h is the zero ideal

Definition at line 1008 of file simpleideals.cc.

1009{
1010 if ((h!=NULL) && (h->m!=NULL))
1011 {
1012 for( int i = IDELEMS(h)-1; i >= 0; i-- )
1013 if(h->m[i] != NULL)
1014 return FALSE;
1015 }
1016 return TRUE;
1017}

◆ idIsMonomial()

BOOLEAN idIsMonomial ( ideal h)

returns true if h is generated by monomials

Definition at line 1020 of file simpleideals.cc.

1021{
1022 assume (h != NULL);
1023
1024 BOOLEAN found_mon=FALSE;
1025 if (h->m!=NULL)
1026 {
1027 for( int i = IDELEMS(h)-1; i >= 0; i-- )
1028 {
1029 if(h->m[i] != NULL)
1030 {
1031 if(pNext(h->m[i])!=NULL) return FALSE;
1032 found_mon=TRUE;
1033 }
1034 }
1035 }
1036 return found_mon;
1037}

◆ idIsSimpleGB()

BOOLEAN idIsSimpleGB ( ideal F,
ideal Q )

returns true if F in R/Q has a "simple" GB

Definition at line 1040 of file simpleideals.cc.

1041{
1042 assume (F != NULL);
1043 int non_zero=0;
1044 int triple=0;
1045
1046 if (LIKELY(F->m!=NULL))
1047 {
1048 for( int i = IDELEMS(F)-1; i >= 0; i-- )
1049 {
1050 poly p;
1051 if((p=F->m[i]) != NULL)
1052 {
1053 non_zero++;
1054 if (Q!=NULL) return FALSE;
1055 if(pNext(p)!=NULL)
1056 {
1057 if(pNext(pNext(p))!=NULL)
1058 {
1059 triple++;
1060 if (non_zero>1) return FALSE;
1061 }
1062 }
1063 }
1064 }
1065 }
1066 if (non_zero<=1) return TRUE; // no zerodivisors
1067 if (triple>1) return FALSE;
1068 if ((triple==1)&&(non_zero>1)) return FALSE;
1069 return TRUE;
1070}
#define LIKELY(X)
Definition auxiliary.h:404

◆ idShow()

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

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);
208 BOOLEAN change=FALSE;
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}

Variable Documentation

◆ sip_sideal_bin

EXTERN_VAR omBin sip_sideal_bin

Definition at line 54 of file simpleideals.h.