My Project
Loading...
Searching...
No Matches
ideals.h File Reference

Go to the source code of this file.

Macros

#define idDelete(H)
 delete an ideal
#define idMaxIdeal(D)
 initialise the maximal ideal (at 0)
#define idPosConstant(I)
 index of generator with leading term in ground ring (if any); otherwise -1
#define idIsConstant(I)
#define idSimpleAdd(A, B)
#define idPrint(id)
#define idTest(id)

Typedefs

typedef ideal * resolvente

Enumerations

enum  GbVariant {
  GbDefault =0 , GbStd , GbSlimgb , GbSba ,
  GbGroebner , GbModstd , GbFfmod , GbNfmod ,
  GbStdSat , GbSingmatic
}

Functions

static ideal idCopyFirstK (const ideal ide, const int k)
void idKeepFirstK (ideal ide, const int k)
 keeps the first k (>= 1) entries of the given ideal (Note that the kept polynomials may be zero.)
void idDelEquals (ideal id)
ideal id_Copy (ideal h1, const ring r)
 copy an ideal
ideal idCopy (ideal A)
ideal idAdd (ideal h1, ideal h2)
 h1 + h2
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 idInsertPolyWithTests (ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk)
static ideal idMult (ideal h1, ideal h2)
 hh := h1 * h2
BOOLEAN idIs0 (ideal h)
 returns true if h is the zero ideal
static BOOLEAN idHomIdeal (ideal id, ideal Q=NULL)
static BOOLEAN idHomModule (ideal m, ideal Q, intvec **w)
BOOLEAN idTestHomModule (ideal m, ideal Q, intvec *w)
ideal idMinBase (ideal h1, ideal *SB=NULL)
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 idFreeModule (int i)
ideal idSect (ideal h1, ideal h2, GbVariant a=GbDefault)
ideal idMultSect (resolvente arg, int length, GbVariant a=GbDefault)
ideal idSyzygies (ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp=TRUE, BOOLEAN setRegularity=FALSE, int *deg=NULL, GbVariant a=GbDefault)
ideal idLiftStd (ideal h1, matrix *m, tHomog h=testHomog, ideal *syz=NULL, GbVariant a=GbDefault, ideal h11=NULL)
ideal idLift (ideal mod, ideal submod, ideal *rest=NULL, BOOLEAN goodShape=FALSE, BOOLEAN isSB=TRUE, BOOLEAN divide=FALSE, matrix *unit=NULL, GbVariant a=GbDefault)
 represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = Matrix(M)*Matrix(result) goodShape: maximal non-zero index in generators of SM <= that of M isSB: generators of M form a Groebner basis divide: allow SM not to be a submodule of M U is an diagonal matrix of units (non-constant only in local rings) rest is: 0 if SM in M, SM if not divide, NF(SM,std(M)) if divide
void idLiftW (ideal P, ideal Q, int n, matrix &T, ideal &R, int *w=NULL)
ideal idQuot (ideal h1, ideal h2, BOOLEAN h1IsStb=FALSE, BOOLEAN resultIsIdeal=FALSE)
ideal idElimination (ideal h1, poly delVar, intvec *hilb=NULL, GbVariant a=GbDefault)
ideal idElimination2 (ideal h1, poly delVar, bigintmat *hilb=NULL, GbVariant a=GbDefault)
ideal idMinors (matrix a, int ar, ideal R=NULL)
 compute all ar-minors of the matrix a the caller of mpRecMin the elements of the result are not in R (if R!=NULL)
ideal idMinEmbedding (ideal arg, BOOLEAN inPlace=FALSE, intvec **w=NULL)
ideal idMinEmbedding_with_map (ideal arg, intvec **w, ideal &trans)
ideal idMinEmbedding_with_map_v (ideal arg, intvec **w, ideal &trans, int *red_comp)
ideal idHead (ideal h)
BOOLEAN idIsSubModule (ideal id1, ideal id2)
static ideal idVec2Ideal (poly vec)
ideal idSeries (int n, ideal M, matrix U=NULL, intvec *w=NULL)
static BOOLEAN idIsZeroDim (ideal i)
matrix idDiff (matrix i, int k)
matrix idDiffOp (ideal I, ideal J, BOOLEAN multiply=TRUE)
static intvecidSort (ideal id, BOOLEAN nolex=TRUE)
ideal idModulo (ideal h1, ideal h2, tHomog h=testHomog, intvec **w=NULL, matrix *T=NULL, GbVariant a=GbDefault)
matrix idCoeffOfKBase (ideal arg, ideal kbase, poly how)
poly id_GCD (poly f, poly g, const ring r)
ideal id_Farey (ideal x, number N, const ring r)
ideal id_TensorModuleMult (const int m, const ideal M, const ring rRing)
ideal id_Satstd (const ideal I, ideal J, const ring r)
ideal id_Sat_principal (const ideal I, ideal J, const ring r)
ideal idSaturate_intern (ideal I, ideal J, int &ki, BOOLEAN isIdeal, BOOLEAN isSB)
ideal idSaturate (ideal I, ideal J, int &ki, BOOLEAN isIdeal=TRUE)
ideal idSaturateGB (ideal I, ideal J, int &ki, BOOLEAN isIdeal=TRUE)
ideal id_Homogenize (ideal I, int var_num, const ring r)
ideal id_HomogenizeW (ideal I, int var_num, intvec *w, const ring r)
GbVariant syGetAlgorithm (char *n, const ring r, const ideal M)

Macro Definition Documentation

◆ idDelete

#define idDelete ( H)
Value:
CanonicalForm H
Definition facAbsFact.cc:60
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix

delete an ideal

Definition at line 29 of file ideals.h.

◆ idIsConstant

#define idIsConstant ( I)
Value:
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 40 of file ideals.h.

◆ idMaxIdeal

#define idMaxIdeal ( D)
Value:
#define D(A)
Definition gentable.cc:128
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)

initialise the maximal ideal (at 0)

Definition at line 33 of file ideals.h.

◆ idPosConstant

#define idPosConstant ( I)
Value:
int id_PosConstant(ideal id, const ring r)
index of generator with leading term in ground ring (if any); otherwise -1

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

Definition at line 37 of file ideals.h.

◆ idPrint

#define idPrint ( id)
Value:
#define id_Print(id, lR, tR)

Definition at line 46 of file ideals.h.

◆ idSimpleAdd

#define idSimpleAdd ( A,
B )
Value:
b *CanonicalForm B
Definition facBivar.cc:52
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
#define A
Definition sirandom.c:24

Definition at line 42 of file ideals.h.

◆ idTest

#define idTest ( id)
Value:
#define id_Test(A, lR)

Definition at line 47 of file ideals.h.

Typedef Documentation

◆ resolvente

typedef ideal* resolvente

Definition at line 18 of file ideals.h.

Enumeration Type Documentation

◆ GbVariant

enum GbVariant
Enumerator
GbDefault 
GbStd 
GbSlimgb 
GbSba 
GbGroebner 
GbModstd 
GbFfmod 
GbNfmod 
GbStdSat 
GbSingmatic 

Definition at line 118 of file ideals.h.

119{
120 GbDefault=0,
121 // internal variants:
122 GbStd,
123 GbSlimgb,
124 GbSba,
125 // and the library functions:
127 GbModstd,
128 GbFfmod,
129 GbNfmod,
130 GbStdSat,
132 // and test variants
133};
@ GbGroebner
Definition ideals.h:126
@ GbModstd
Definition ideals.h:127
@ GbStdSat
Definition ideals.h:130
@ GbSlimgb
Definition ideals.h:123
@ GbFfmod
Definition ideals.h:128
@ GbNfmod
Definition ideals.h:129
@ GbDefault
Definition ideals.h:120
@ GbStd
Definition ideals.h:122
@ GbSingmatic
Definition ideals.h:131
@ GbSba
Definition ideals.h:124

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
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_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}
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define IDELEMS(i)

◆ id_Farey()

ideal id_Farey ( ideal x,
number N,
const ring r )

Definition at line 3108 of file ideals.cc.

3109{
3110 int cnt=IDELEMS(x)*x->nrows;
3111 ideal result=idInit(cnt,x->rank);
3112 result->nrows=x->nrows; // for lifting matrices
3113 result->ncols=x->ncols; // for lifting matrices
3114
3115 int i;
3116 for(i=cnt-1;i>=0;i--)
3117 {
3118 result->m[i]=p_Farey(x->m[i],N,r);
3119 }
3120 return result;
3121}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
Variable x
Definition cfModGcd.cc:4090
poly p_Farey(poly p, number N, const ring r)
Definition p_polys.cc:54

◆ id_GCD()

poly id_GCD ( poly f,
poly g,
const ring r )

Definition at line 3005 of file ideals.cc.

3006{
3007 ideal I=idInit(2,1); I->m[0]=f; I->m[1]=g;
3008 intvec *w = NULL;
3009
3010 ring save_r = currRing;
3011 rChangeCurrRing(r);
3012 ideal S=idSyzygies(I,testHomog,&w);
3013 rChangeCurrRing(save_r);
3014
3015 if (w!=NULL) delete w;
3016 poly gg=p_TakeOutComp(&(S->m[0]), 2, r);
3017 id_Delete(&S, r);
3018 poly gcd_p=singclap_pdivide(f,gg, r);
3019 p_Delete(&gg, r);
3020
3021 return gcd_p;
3022}
g
Definition cfModGcd.cc:4098
FILE * f
Definition checklibs.c:9
poly singclap_pdivide(poly f, poly g, const ring r)
Definition clapsing.cc:649
const CanonicalForm & w
Definition facAbsFact.cc:51
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:834
void p_TakeOutComp(poly *p, long comp, poly *q, int *lq, const ring r)
Definition p_polys.cc:3620
#define NULL
Definition omList.c:12
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
void rChangeCurrRing(ring r)
Definition polys.cc:16
@ testHomog
Definition structs.h:34

◆ id_Homogenize()

ideal id_Homogenize ( ideal I,
int var_num,
const ring r )

Definition at line 3611 of file ideals.cc.

3612{
3613 ideal II=id_Copy(I,r);
3614 if (var_num==1)
3615 {
3616 ring tmpR=rAssure_Dp_C(r);
3617 if (tmpR!=r)
3618 {
3619 rChangeCurrRing(tmpR);
3620 II=idrMoveR(II,r,tmpR);
3621 }
3622 ideal III=id_Homogen(II,1,tmpR);
3623 id_Delete(&II,tmpR);
3624 intvec *ww=NULL;
3625 II=kStd2(III,currRing->qideal,(tHomog)TRUE,&ww,(bigintmat*)NULL);
3626 if (ww!=NULL) delete ww;
3627 id_Delete(&III,tmpR);
3628 if (tmpR!=r)
3629 {
3630 rChangeCurrRing(r);
3631 II=idrMoveR(II,tmpR,r);
3632 }
3633 return II;
3634 }
3635 ideal III=idInit(IDELEMS(II),1);
3636 int *perm=(int*)omAlloc0((rVar(r)+1)*sizeof(int));
3637 for(int i=rVar(r)-1; i>0; i--) perm[i]=i;
3638 perm[var_num]=1;
3639 perm[1]=var_num;
3640 for(int i=IDELEMS(II)-1; i>=0;i--)
3641 {
3642 III->m[i]=p_PermPoly(II->m[i],perm,r,r,ndCopyMap,NULL,0,FALSE);
3643 }
3644 id_Delete(&II,r);
3645 II=id_Homogenize(III,1,r);
3646 id_Delete(&III,r);
3647 III=idInit(IDELEMS(II),1);
3648 for(int i=IDELEMS(II)-1; i>=0;i--)
3649 {
3650 III->m[i]=p_PermPoly(II->m[i],perm,r,r,ndCopyMap,NULL,0,FALSE);
3651 }
3652 id_Delete(&II,r);
3653 return III;
3654}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
Matrices of numbers.
Definition bigintmat.h:51
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:293
ideal id_Homogenize(ideal I, int var_num, const ring r)
Definition ideals.cc:3611
ideal id_Copy(ideal h1, const ring r)
copy an ideal
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2607
#define omAlloc0(size)
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
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
ring rAssure_Dp_C(const ring r)
Definition ring.cc:5124
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603
ideal id_Homogen(ideal h, int varnum, const ring r)
tHomog
Definition structs.h:31

◆ id_HomogenizeW()

ideal id_HomogenizeW ( ideal I,
int var_num,
intvec * w,
const ring r )

Definition at line 3656 of file ideals.cc.

3657{
3658 ideal II=id_Copy(I,r);
3659 if (var_num==1)
3660 {
3661 ring tmpR=rAssure_Wp_C(r,w);
3662 if (tmpR!=r)
3663 {
3664 rChangeCurrRing(tmpR);
3665 II=idrMoveR(II,r,tmpR);
3666 }
3667 ideal III=id_Homogen(II,1,tmpR);
3668 id_Delete(&II,tmpR);
3669 intvec *ww=NULL;
3670 II=kStd2(III,currRing->qideal,(tHomog)TRUE,&ww,(bigintmat*)NULL);
3671 if (ww!=NULL) delete ww;
3672 id_Delete(&III,tmpR);
3673 if (tmpR!=r)
3674 {
3675 rChangeCurrRing(r);
3676 II=idrMoveR(II,tmpR,r);
3677 }
3678 return II;
3679 }
3680 ideal III=idInit(IDELEMS(II),1);
3681 int *perm=(int*)omAlloc0((rVar(r)+1)*sizeof(int));
3682 for(int i=rVar(r)-1; i>0; i--) perm[i]=i;
3683 perm[var_num]=1;
3684 perm[1]=var_num;
3685 for(int i=IDELEMS(II)-1; i>=0;i--)
3686 {
3687 III->m[i]=p_PermPoly(II->m[i],perm,r,r,ndCopyMap,NULL,0,FALSE);
3688 }
3689 id_Delete(&II,r);
3690 II=id_HomogenizeW(III,1,w,r);
3691 id_Delete(&III,r);
3692 III=idInit(IDELEMS(II),1);
3693 for(int i=IDELEMS(II)-1; i>=0;i--)
3694 {
3695 III->m[i]=p_PermPoly(II->m[i],perm,r,r,ndCopyMap,NULL,0,FALSE);
3696 }
3697 id_Delete(&II,r);
3698 return III;
3699}
ideal id_HomogenizeW(ideal I, int var_num, intvec *w, const ring r)
Definition ideals.cc:3656
ring rAssure_Wp_C(const ring r, intvec *w)
Definition ring.cc:4942

◆ id_Sat_principal()

ideal id_Sat_principal ( const ideal I,
ideal J,
const ring r )

Definition at line 3420 of file ideals.cc.

3421{
3422 rRingOrder_t *ord;
3423 int *block0,*block1;
3424 int **wv;
3425
3426 // construction extension ring
3427 ord=(rRingOrder_t*)omAlloc0(4*sizeof(rRingOrder_t));
3428 block0=(int*)omAlloc0(4*sizeof(int));
3429 block1=(int*)omAlloc0(4*sizeof(int));
3430 wv=(int**) omAlloc0(4*sizeof(int**));
3431 wv[0]=(int*)omAlloc0((rVar(origR) + 2)*sizeof(int));
3432 block0[0] = block0[1] = 1;
3433 block1[0] = block1[1] = rVar(origR)+1;
3434 // use this special ordering: like ringorder_a, except that pFDeg, pWeights
3435 // ignore it
3436 ord[0] = ringorder_aa;
3437 wv[0][rVar(origR)]=1;
3438 BOOLEAN wp=FALSE;
3439 for (int j=0;j<rVar(origR);j++)
3440 if (p_Weight(j+1,origR)!=1) { wp=TRUE;break; }
3441 if (wp)
3442 {
3443 wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
3444 for (int j=0;j<rVar(origR);j++)
3445 wv[1][j]=p_Weight(j+1,origR);
3446 ord[1] = ringorder_wp;
3447 }
3448 else
3449 ord[1] = ringorder_dp;
3450 ord[2] = ringorder_C;
3451 ord[3] = (rRingOrder_t)0;
3452 char **names=(char**)omAlloc0((origR->N+1) * sizeof(char *));
3453 for (int j=0;j<rVar(origR);j++)
3454 names[j]=origR->names[j];
3455 names[rVar(origR)]=(char*)"@";
3456 ring tmpR=rDefault(nCopyCoeff(origR->cf),rVar(origR)+1,names,4,ord,block0,block1,wv);
3457 omFree(names);
3458 rComplete(tmpR, 1);
3459 rChangeCurrRing(tmpR);
3460 // map I
3461 ideal II=idrCopyR(I,origR,tmpR);
3462 // map J
3463 ideal JJ=idrCopyR(J,origR,tmpR);
3464 // J[1]*t-1
3465 poly t=pOne();
3466 p_SetExp(t,rVar(tmpR),1,tmpR);
3467 p_Setm(t,tmpR);
3468 poly p=JJ->m[0];
3469 p_Norm(p,currRing);
3470 p=p_Mult_q(p,t,tmpR);
3471 p=p_Sub(p,pOne(),tmpR);
3472 JJ->m[0]=p;
3473 ideal T=id_SimpleMove(II,JJ,tmpR);
3474 idTest(T);
3475 // elimination
3476 t=pOne();
3477 p_SetExp(t,rVar(tmpR),1,tmpR);
3478 p_Setm(t,tmpR);
3479 ideal TT=idGroebner(T,0,GbStd);
3480 p_Delete(&t,tmpR);
3481 for(int j=0;j<IDELEMS(TT);j++)
3482 {
3483 if ((TT->m[j]!=NULL)
3484 && (p_GetExp(TT->m[j],rVar(tmpR),tmpR)>0))
3485 {
3486 p_Delete(&TT->m[j],tmpR);
3487 }
3488 }
3489 // map back
3490 ideal TTT=idrCopyR(TT,tmpR,origR);
3491 id_Delete(&TT,tmpR);
3492 rChangeCurrRing(origR);
3493 rDelete(tmpR);
3494 idSkipZeroes(TTT);
3495 return TTT;
3496}
int BOOLEAN
Definition auxiliary.h:88
int p
Definition cfModGcd.cc:4086
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition coeffs.h:439
int j
Definition facHensel.cc:110
static ideal idGroebner(ideal temp, int syzComp, GbVariant alg, bigintmat *hilb=NULL, intvec *w=NULL, tHomog hom=testHomog)
Definition ideals.cc:200
#define idTest(id)
Definition ideals.h:47
STATIC_VAR jList * T
Definition janet.cc:30
#define omFree(addr)
int p_Weight(int i, const ring r)
Definition p_polys.cc:706
void p_Norm(poly p1, const ring r)
Definition p_polys.cc:3844
poly p_Sub(poly p1, poly p2, const ring r)
Definition p_polys.cc:1994
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
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
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
#define pOne()
Definition polys.h:316
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:192
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3527
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_C
Definition ring.h:74
@ ringorder_dp
Definition ring.h:79
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition ring.h:93
@ ringorder_wp
Definition ring.h:82
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal id_SimpleMove(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros, destroys h1,h2

◆ id_Satstd()

ideal id_Satstd ( const ideal I,
ideal J,
const ring r )

Definition at line 3368 of file ideals.cc.

3369{
3370 ring save=currRing;
3371 if (currRing!=r) rChangeCurrRing(r);
3372 idSkipZeroes(J);
3373 id_satstdSaturatingVariables=(int*)omAlloc0((1+rVar(currRing))*sizeof(int));
3374 int k=IDELEMS(J);
3375 if (k>1)
3376 {
3377 for (int i=0; i<k; i++)
3378 {
3379 poly x = J->m[i];
3380 int li = p_Var(x,r);
3381 if (li>0)
3383 else
3384 {
3385 if (currRing!=save) rChangeCurrRing(save);
3386 WerrorS("ideal generators must be variables");
3387 return NULL;
3388 }
3389 }
3390 }
3391 else
3392 {
3393 poly x = J->m[0];
3394 if (pNext(x)!=NULL)
3395 {
3396 Werror("generator must be a monomial");
3397 if (currRing!=save) rChangeCurrRing(save);
3398 return NULL;
3399 }
3400 for (int i=1; i<=r->N; i++)
3401 {
3402 int li = p_GetExp(x,i,r);
3403 if (li==1)
3405 else if (li>1)
3406 {
3407 if (currRing!=save) rChangeCurrRing(save);
3408 Werror("exponent(x(%d)^%d) must be 0 or 1",i,li);
3409 return NULL;
3410 }
3411 }
3412 }
3413 ideal res=kStd2(I,r->qideal,testHomog,NULL,(bigintmat*)NULL,0,0,NULL,id_sat_vars_sp);
3416 if (currRing!=save) rChangeCurrRing(save);
3417 return res;
3418}
int k
Definition cfEzgcd.cc:99
CanonicalForm res
Definition facAbsFact.cc:60
void WerrorS(const char *s)
Definition feFopen.cc:24
STATIC_VAR int * id_satstdSaturatingVariables
Definition ideals.cc:3253
static BOOLEAN id_sat_vars_sp(kStrategy strat)
Definition ideals.cc:3255
#define pNext(p)
Definition monomials.h:36
#define omFreeSize(addr, size)
int p_Var(poly m, const ring r)
Definition p_polys.cc:4823
void Werror(const char *fmt,...)
Definition reporter.cc:189

◆ id_TensorModuleMult()

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

Definition at line 2148 of file simpleideals.cc.

2149{
2150// #ifdef DEBU
2151// WarnS("tensorModuleMult!!!!");
2152
2153 assume(m > 0);
2154 assume(M != NULL);
2155
2156 const int n = rRing->N;
2157
2158 assume(M->rank <= m * n);
2159
2160 const int k = IDELEMS(M);
2161
2162 ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
2163
2164 for( int i = 0; i < k; i++ ) // for every w \in M
2165 {
2166 poly pTempSum = NULL;
2167
2168 poly w = M->m[i];
2169
2170 while(w != NULL) // for each term of w...
2171 {
2172 poly h = p_Head(w, rRing);
2173
2174 const int gen = __p_GetComp(h, rRing); // 1 ...
2175
2176 assume(gen > 0);
2177 assume(gen <= n*m);
2178
2179 // TODO: write a formula with %, / instead of while!
2180 /*
2181 int c = gen;
2182 int v = 1;
2183 while(c > m)
2184 {
2185 c -= m;
2186 v++;
2187 }
2188 */
2189
2190 int cc = gen % m;
2191 if( cc == 0) cc = m;
2192 int vv = 1 + (gen - cc) / m;
2193
2194// assume( cc == c );
2195// assume( vv == v );
2196
2197 // 1<= c <= m
2198 assume( cc > 0 );
2199 assume( cc <= m );
2200
2201 assume( vv > 0 );
2202 assume( vv <= n );
2203
2204 assume( (cc + (vv-1)*m) == gen );
2205
2206 p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
2207 p_SetComp(h, cc, rRing);
2208
2209 p_Setm(h, rRing); // adjust degree after the previous steps!
2210
2211 pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
2212
2213 pIter(w);
2214 }
2215
2216 idTemp->m[i] = pTempSum;
2217 }
2218
2219 // simplify idTemp???
2220
2221 ideal idResult = id_Transp(idTemp, rRing);
2222
2223 id_Delete(&idTemp, rRing);
2224
2225 return(idResult);
2226}
int m
Definition cfEzgcd.cc:128
STATIC_VAR Poly * h
Definition janet.cc:971
#define assume(x)
Definition mod2.h:389
#define pIter(p)
Definition monomials.h:37
#define __p_GetComp(p, r)
Definition monomials.h:63
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static long p_IncrExp(poly p, int v, ring r)
Definition p_polys.h:593
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
ideal id_Transp(ideal a, const ring rRing)
transpose a module
#define M
Definition sirandom.c:25

◆ idAdd()

ideal idAdd ( ideal h1,
ideal h2 )
inline

h1 + h2

Definition at line 68 of file ideals.h.

69{
70 return id_Add(h1, h2, currRing);
71}
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2

◆ idCoeffOfKBase()

matrix idCoeffOfKBase ( ideal arg,
ideal kbase,
poly how )

Definition at line 2673 of file ideals.cc.

2674{
2675 matrix result;
2676 ideal tempKbase;
2677 poly p,q;
2678 intvec * convert;
2679 int i=IDELEMS(kbase),j=IDELEMS(arg),k,pos;
2680#if 0
2681 while ((i>0) && (kbase->m[i-1]==NULL)) i--;
2682 if (idIs0(arg))
2683 return mpNew(i,1);
2684 while ((j>0) && (arg->m[j-1]==NULL)) j--;
2685 result = mpNew(i,j);
2686#else
2687 result = mpNew(i, j);
2688 while ((j>0) && (arg->m[j-1]==NULL)) j--;
2689#endif
2690
2691 tempKbase = idCreateSpecialKbase(kbase,&convert);
2692 for (k=0;k<j;k++)
2693 {
2694 p = arg->m[k];
2695 while (p!=NULL)
2696 {
2697 q = idDecompose(p,how,tempKbase,&pos);
2698 if (pos>=0)
2699 {
2700 MATELEM(result,(*convert)[pos],k+1) =
2701 pAdd(MATELEM(result,(*convert)[pos],k+1),q);
2702 }
2703 else
2704 p_Delete(&q,currRing);
2705 pIter(p);
2706 }
2707 }
2708 idDelete(&tempKbase);
2709 return result;
2710}
ideal idCreateSpecialKbase(ideal kBase, intvec **convert)
Definition ideals.cc:2587
poly idDecompose(poly monom, poly how, ideal kbase, int *pos)
Definition ideals.cc:2641
#define idDelete(H)
delete an ideal
Definition ideals.h:29
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
#define pAdd(p, q)
Definition polys.h:204

◆ idCopy()

ideal idCopy ( ideal A)
inline

Definition at line 60 of file ideals.h.

61{
62 return id_Copy(A, currRing);
63}

◆ idCopyFirstK()

ideal idCopyFirstK ( const ideal ide,
const int k )
inlinestatic

Definition at line 20 of file ideals.h.

21{
22 return id_CopyFirstK(ide, k, currRing);
23}
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 (...

◆ idDelEquals()

void idDelEquals ( ideal id)

Definition at line 3216 of file ideals.cc.

3217{
3218 int idsize = IDELEMS(id);
3219 poly_sort *id_sort = (poly_sort *)omAlloc0(idsize*sizeof(poly_sort));
3220 for (int i = 0; i < idsize; i++)
3221 {
3222 id_sort[i].p = id->m[i];
3223 id_sort[i].index = i;
3224 }
3225 idSort_qsort(id_sort, idsize);
3226 int index, index_i, index_j;
3227 int i = 0;
3228 for (int j = 1; j < idsize; j++)
3229 {
3230 if (id_sort[i].p != NULL && pEqualPolys(id_sort[i].p, id_sort[j].p))
3231 {
3232 index_i = id_sort[i].index;
3233 index_j = id_sort[j].index;
3234 if (index_j > index_i)
3235 {
3236 index = index_j;
3237 }
3238 else
3239 {
3240 index = index_i;
3241 i = j;
3242 }
3243 pDelete(&id->m[index]);
3244 }
3245 else
3246 {
3247 i = j;
3248 }
3249 }
3250 omFreeSize((ADDRESS)(id_sort), idsize*sizeof(poly_sort));
3251}
void * ADDRESS
Definition auxiliary.h:120
int index
Definition ideals.cc:3199
void idSort_qsort(poly_sort *id_sort, int idsize)
Definition ideals.cc:3207
static int index(p_Length length, p_Ord ord)
#define pDelete(p_ptr)
Definition polys.h:187
#define pEqualPolys(p1, p2)
Definition polys.h:400

◆ idDiff()

matrix idDiff ( matrix i,
int k )

Definition at line 2194 of file ideals.cc.

2195{
2196 int e=MATCOLS(i)*MATROWS(i);
2198 r->rank=i->rank;
2199 int j;
2200 for(j=0; j<e; j++)
2201 {
2202 r->m[j]=pDiff(i->m[j],k);
2203 }
2204 return r;
2205}
long rank
Definition matpol.h:19
poly * m
Definition matpol.h:18
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
#define pDiff(a, b)
Definition polys.h:297

◆ idDiffOp()

matrix idDiffOp ( ideal I,
ideal J,
BOOLEAN multiply = TRUE )

Definition at line 2207 of file ideals.cc.

2208{
2209 matrix r=mpNew(IDELEMS(I),IDELEMS(J));
2210 int i,j;
2211 for(i=0; i<IDELEMS(I); i++)
2212 {
2213 for(j=0; j<IDELEMS(J); j++)
2214 {
2215 MATELEM(r,i+1,j+1)=pDiffOp(I->m[i],J->m[j],multiply);
2216 }
2217 }
2218 return r;
2219}
#define pDiffOp(a, b, m)
Definition polys.h:298

◆ idElimination()

ideal idElimination ( ideal h1,
poly delVar,
intvec * hilb = NULL,
GbVariant a = GbDefault )

Definition at line 1889 of file ideals.cc.

1890{
1891 bigintmat *hh=iv2biv(hilb,coeffs_BIGINT);
1892 ideal res=idElimination2(h1,delVar,hh,alg);
1893 if (hh!=NULL) delete hh;
1894 return res;
1895}
ideal idElimination2(ideal h1, poly delVar, bigintmat *hilb, GbVariant alg)
Definition ideals.cc:1647
bigintmat * iv2biv(intvec *hilb, const coeffs cf)
Definition intvec.cc:851
VAR coeffs coeffs_BIGINT
Definition polys.cc:14

◆ idElimination2()

ideal idElimination2 ( ideal h1,
poly delVar,
bigintmat * hilb = NULL,
GbVariant a = GbDefault )

Definition at line 1647 of file ideals.cc.

1648{
1649 int i,j=0,k,l;
1650 ideal h,hh, h3;
1651 rRingOrder_t *ord;
1652 int *block0,*block1;
1653 int ordersize=2;
1654 int **wv;
1655 tHomog hom;
1656 intvec * w;
1657 ring tmpR;
1658 ring origR = currRing;
1659
1660 if (delVar==NULL)
1661 {
1662 return idCopy(h1);
1663 }
1664 if ((currRing->qideal!=NULL) && rIsPluralRing(origR))
1665 {
1666 WerrorS("cannot eliminate in a qring");
1667 return NULL;
1668 }
1669 if (idIs0(h1)) return idInit(1,h1->rank);
1670#ifdef HAVE_PLURAL
1671 if (rIsPluralRing(origR))
1672 /* in the NC case, we have to check the admissibility of */
1673 /* the subalgebra to be intersected with */
1674 {
1675 if ((ncRingType(origR) != nc_skew) && (ncRingType(origR) != nc_exterior)) /* in (quasi)-commutative algebras every subalgebra is admissible */
1676 {
1677 if (nc_CheckSubalgebra(delVar,origR))
1678 {
1679 WerrorS("no elimination is possible: subalgebra is not admissible");
1680 return NULL;
1681 }
1682 }
1683 }
1684#endif
1685 hom=(tHomog)idHomModule(h1,NULL,&w); //sets w to weight vector or NULL
1686 h3=idInit(16,h1->rank);
1687 ordersize=rBlocks(origR)+1;
1688#if 0
1689 if (rIsPluralRing(origR)) // we have too keep the ordering: it may be needed
1690 // for G-algebra
1691 {
1692 for (k=0;k<ordersize-1; k++)
1693 {
1694 block0[k+1] = origR->block0[k];
1695 block1[k+1] = origR->block1[k];
1696 ord[k+1] = origR->order[k];
1697 if (origR->wvhdl[k]!=NULL) wv[k+1] = (int*) omMemDup(origR->wvhdl[k]);
1698 }
1699 }
1700 else
1701 {
1702 block0[1] = 1;
1703 block1[1] = (currRing->N);
1704 if (origR->OrdSgn==1) ord[1] = ringorder_wp;
1705 else ord[1] = ringorder_ws;
1706 wv[1]=(int*)omAlloc0((currRing->N)*sizeof(int));
1707 double wNsqr = (double)2.0 / (double)(currRing->N);
1709 int *x= (int * )omAlloc(2 * ((currRing->N) + 1) * sizeof(int));
1710 int sl=IDELEMS(h1) - 1;
1711 wCall(h1->m, sl, x, wNsqr);
1712 for (sl = (currRing->N); sl!=0; sl--)
1713 wv[1][sl-1] = x[sl + (currRing->N) + 1];
1714 omFreeSize((ADDRESS)x, 2 * ((currRing->N) + 1) * sizeof(int));
1715
1716 ord[2]=ringorder_C;
1717 ord[3]=0;
1718 }
1719#else
1720#endif
1721 if ((hom==TRUE) && (origR->OrdSgn==1) && (!rIsPluralRing(origR)))
1722 {
1723 #if 1
1724 // we change to an ordering:
1725 // aa(1,1,1,...,0,0,0),wp(...),C
1726 // this seems to be better than version 2 below,
1727 // according to Tst/../elimiate_[3568].tat (- 17 %)
1728 ord=(rRingOrder_t*)omAlloc0(4*sizeof(rRingOrder_t));
1729 block0=(int*)omAlloc0(4*sizeof(int));
1730 block1=(int*)omAlloc0(4*sizeof(int));
1731 wv=(int**) omAlloc0(4*sizeof(int**));
1732 block0[0] = block0[1] = 1;
1733 block1[0] = block1[1] = rVar(origR);
1734 wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1735 // use this special ordering: like ringorder_a, except that pFDeg, pWeights
1736 // ignore it
1737 ord[0] = ringorder_aa;
1738 for (j=0;j<rVar(origR);j++)
1739 if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
1740 BOOLEAN wp=FALSE;
1741 for (j=0;j<rVar(origR);j++)
1742 if (p_Weight(j+1,origR)!=1) { wp=TRUE;break; }
1743 if (wp)
1744 {
1745 wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1746 for (j=0;j<rVar(origR);j++)
1747 wv[1][j]=p_Weight(j+1,origR);
1748 ord[1] = ringorder_wp;
1749 }
1750 else
1751 ord[1] = ringorder_dp;
1752 #else
1753 // we change to an ordering:
1754 // a(w1,...wn),wp(1,...0.....),C
1755 ord=(int*)omAlloc0(4*sizeof(int));
1756 block0=(int*)omAlloc0(4*sizeof(int));
1757 block1=(int*)omAlloc0(4*sizeof(int));
1758 wv=(int**) omAlloc0(4*sizeof(int**));
1759 block0[0] = block0[1] = 1;
1760 block1[0] = block1[1] = rVar(origR);
1761 wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1762 wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1763 ord[0] = ringorder_a;
1764 for (j=0;j<rVar(origR);j++)
1765 wv[0][j]=pWeight(j+1,origR);
1766 ord[1] = ringorder_wp;
1767 for (j=0;j<rVar(origR);j++)
1768 if (pGetExp(delVar,j+1)!=0) wv[1][j]=1;
1769 #endif
1770 ord[2] = ringorder_C;
1771 ord[3] = (rRingOrder_t)0;
1772 }
1773 else
1774 {
1775 // we change to an ordering:
1776 // aa(....),orig_ordering
1777 ord=(rRingOrder_t*)omAlloc0(ordersize*sizeof(rRingOrder_t));
1778 block0=(int*)omAlloc0(ordersize*sizeof(int));
1779 block1=(int*)omAlloc0(ordersize*sizeof(int));
1780 wv=(int**) omAlloc0(ordersize*sizeof(int**));
1781 for (k=0;k<ordersize-1; k++)
1782 {
1783 block0[k+1] = origR->block0[k];
1784 block1[k+1] = origR->block1[k];
1785 ord[k+1] = origR->order[k];
1786 if (origR->wvhdl[k]!=NULL)
1787 #ifdef HAVE_OMALLOC
1788 wv[k+1] = (int*) omMemDup(origR->wvhdl[k]);
1789 #else
1790 {
1791 int l=(origR->block1[k]-origR->block0[k]+1)*sizeof(int);
1792 if (origR->order[k]==ringorder_a64) l*=2;
1793 wv[k+1]=(int*)omalloc(l);
1794 memcpy(wv[k+1],origR->wvhdl[k],l);
1795 }
1796 #endif
1797 }
1798 block0[0] = 1;
1799 block1[0] = rVar(origR);
1800 wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1801 for (j=0;j<rVar(origR);j++)
1802 if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
1803 // use this special ordering: like ringorder_a, except that pFDeg, pWeights
1804 // ignore it
1805 ord[0] = ringorder_aa;
1806 }
1807 // fill in tmp ring to get back the data later on
1808 tmpR = rCopy0(origR,FALSE,FALSE); // qring==NULL
1809 //rUnComplete(tmpR);
1810 tmpR->p_Procs=NULL;
1811 tmpR->order = ord;
1812 tmpR->block0 = block0;
1813 tmpR->block1 = block1;
1814 tmpR->wvhdl = wv;
1815 rComplete(tmpR, 1);
1816
1817#ifdef HAVE_PLURAL
1818 /* update nc structure on tmpR */
1819 if (rIsPluralRing(origR))
1820 {
1821 if ( nc_rComplete(origR, tmpR, false) ) // no quotient ideal!
1822 {
1823 WerrorS("no elimination is possible: ordering condition is violated");
1824 // cleanup
1825 rDelete(tmpR);
1826 if (w!=NULL)
1827 delete w;
1828 return NULL;
1829 }
1830 }
1831#endif
1832 // change into the new ring
1833 //pChangeRing((currRing->N),currRing->OrdSgn,ord,block0,block1,wv);
1834 rChangeCurrRing(tmpR);
1835
1836 //h = idInit(IDELEMS(h1),h1->rank);
1837 // fetch data from the old ring
1838 //for (k=0;k<IDELEMS(h1);k++) h->m[k] = prCopyR( h1->m[k], origR);
1839 h=idrCopyR(h1,origR,currRing);
1840 if (origR->qideal!=NULL)
1841 {
1842 WarnS("eliminate in q-ring: experimental");
1843 ideal q=idrCopyR(origR->qideal,origR,currRing);
1844 ideal s=id_SimpleMove(h,q,currRing);
1845 h=s;
1846 }
1847 // compute GB
1848 if ((alg!=GbDefault)
1849 && (alg!=GbGroebner)
1850 && (alg!=GbModstd)
1851 && (alg!=GbSlimgb)
1852 && (alg!=GbSba)
1853 && (alg!=GbStd))
1854 {
1855 WarnS("wrong algorithm for GB");
1856 alg=GbDefault;
1857 }
1858 hh=idGroebner(h,0,alg,hilb);
1859 // go back to the original ring
1860 rChangeCurrRing(origR);
1861 i = IDELEMS(hh)-1;
1862 while ((i >= 0) && (hh->m[i] == NULL)) i--;
1863 j = -1;
1864 // fetch data from temp ring
1865 for (k=0; k<=i; k++)
1866 {
1867 l=(currRing->N);
1868 while ((l>0) && (p_GetExp( hh->m[k],l,tmpR)*pGetExp(delVar,l)==0)) l--;
1869 if (l==0)
1870 {
1871 j++;
1872 if (j >= IDELEMS(h3))
1873 {
1874 pEnlargeSet(&(h3->m),IDELEMS(h3),16);
1875 IDELEMS(h3) += 16;
1876 }
1877 h3->m[j] = prMoveR( hh->m[k], tmpR,origR);
1878 hh->m[k] = NULL;
1879 }
1880 }
1881 id_Delete(&hh, tmpR);
1882 idSkipZeroes(h3);
1883 rDelete(tmpR);
1884 if (w!=NULL)
1885 delete w;
1886 return h3;
1887}
int l
Definition cfEzgcd.cc:100
const CanonicalForm int s
Definition facAbsFact.cc:51
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
ideal idCopy(ideal A)
Definition ideals.h:60
@ nc_skew
Definition nc.h:16
@ nc_exterior
Definition nc.h:21
static nc_type & ncRingType(nc_struct *p)
Definition nc.h:159
BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r)
#define omAlloc(size)
#define omalloc(size)
#define omMemDup(s)
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3821
#define pWeight(i)
Definition polys.h:281
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition prCopy.cc:90
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition ring.cc:5833
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
static int rBlocks(const ring r)
Definition ring.h:579
@ ringorder_a
Definition ring.h:71
@ ringorder_a64
for int64 weights
Definition ring.h:72
@ ringorder_ws
Definition ring.h:88
THREAD_VAR double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition weight.cc:20
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
Definition weight.cc:108
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition weight0.cc:78

◆ idFreeModule()

ideal idFreeModule ( int i)
inline

Definition at line 111 of file ideals.h.

112{
113 return id_FreeModule (i, currRing);
114}
ideal id_FreeModule(int i, const ring r)
the free module of rank i

◆ 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}
CanonicalForm b
Definition cfModGcd.cc:4111
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)

◆ idHead()

ideal idHead ( ideal h)

◆ idHomIdeal()

BOOLEAN idHomIdeal ( ideal id,
ideal Q = NULL )
inlinestatic

Definition at line 91 of file ideals.h.

92{
93 return id_HomIdeal(id, Q, currRing);
94}
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
#define Q
Definition sirandom.c:26

◆ idHomModule()

BOOLEAN idHomModule ( ideal m,
ideal Q,
intvec ** w )
inlinestatic

Definition at line 96 of file ideals.h.

97{
98 return id_HomModule(m, Q, w, currRing);
99}
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)

◆ 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}

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

881{
882 if (h2==NULL) return FALSE;
883 assume (h1 != NULL);
884
885 int j = IDELEMS(h1) - 1;
886
887 while ((j >= 0) && (h1->m[j] == NULL)) j--;
888 j++;
889 if (j==IDELEMS(h1))
890 {
891 pEnlargeSet(&(h1->m),IDELEMS(h1),16);
892 IDELEMS(h1)+=16;
893 }
894 h1->m[j]=h2;
895 return TRUE;
896}

◆ idInsertPolyOnPos()

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

insert p into I on position pos

Definition at line 899 of file simpleideals.cc.

900{
901 if (p==NULL) return FALSE;
902 assume (I != NULL);
903
904 int j = IDELEMS(I) - 1;
905
906 while ((j >= 0) && (I->m[j] == NULL)) j--;
907 j++;
908 if (j==IDELEMS(I))
909 {
910 pEnlargeSet(&(I->m),IDELEMS(I),IDELEMS(I)+1);
911 IDELEMS(I)+=1;
912 }
913 for(j = IDELEMS(I)-1;j>pos;j--)
914 I->m[j] = I->m[j-1];
915 I->m[pos]=p;
916 return TRUE;
917}

◆ idInsertPolyWithTests()

BOOLEAN idInsertPolyWithTests ( ideal h1,
const int validEntries,
const poly h2,
const bool zeroOk,
const bool duplicateOk )
inline

Definition at line 75 of file ideals.h.

76{
77 return id_InsertPolyWithTests (h1, validEntries, h2, zeroOk, duplicateOk, currRing);
78}
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:

◆ 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}

◆ idIsSubModule()

BOOLEAN idIsSubModule ( ideal id1,
ideal id2 )

Definition at line 2104 of file ideals.cc.

2105{
2106 int i;
2107 poly p;
2108
2109 if (idIs0(id1)) return TRUE;
2110 for (i=0;i<IDELEMS(id1);i++)
2111 {
2112 if (id1->m[i] != NULL)
2113 {
2114 p = kNF(id2,currRing->qideal,id1->m[i]);
2115 if (p != NULL)
2116 {
2118 return FALSE;
2119 }
2120 }
2121 }
2122 return TRUE;
2123}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3230

◆ idIsZeroDim()

BOOLEAN idIsZeroDim ( ideal i)
inlinestatic

Definition at line 180 of file ideals.h.

181{
182 return id_IsZeroDim(i, currRing);
183}
BOOLEAN id_IsZeroDim(ideal I, const ring r)

◆ idKeepFirstK()

void idKeepFirstK ( ideal ide,
const int k )

keeps the first k (>= 1) entries of the given ideal (Note that the kept polynomials may be zero.)

Definition at line 3184 of file ideals.cc.

3185{
3186 for (int i = IDELEMS(id)-1; i >= k; i--)
3187 {
3188 if (id->m[i] != NULL) pDelete(&id->m[i]);
3189 }
3190 int kk=k;
3191 if (k==0) kk=1; /* ideals must have at least one element(0)*/
3192 pEnlargeSet(&(id->m), IDELEMS(id), kk-IDELEMS(id));
3193 IDELEMS(id) = kk;
3194}

◆ idLift()

ideal idLift ( ideal mod,
ideal submod,
ideal * rest = NULL,
BOOLEAN goodShape = FALSE,
BOOLEAN isSB = TRUE,
BOOLEAN divide = FALSE,
matrix * unit = NULL,
GbVariant a = GbDefault )

represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = Matrix(M)*Matrix(result) goodShape: maximal non-zero index in generators of SM <= that of M isSB: generators of M form a Groebner basis divide: allow SM not to be a submodule of M U is an diagonal matrix of units (non-constant only in local rings) rest is: 0 if SM in M, SM if not divide, NF(SM,std(M)) if divide

Definition at line 1109 of file ideals.cc.

1111{
1112 int lsmod =id_RankFreeModule(submod,currRing), j, k;
1113 int comps_to_add=0;
1114 int idelems_mod=IDELEMS(mod);
1115 int idelems_submod=IDELEMS(submod);
1116 poly p;
1117
1118 if (idIs0(submod))
1119 {
1120 if (rest!=NULL)
1121 {
1122 *rest=idInit(1,mod->rank);
1123 }
1124 idLift_setUnit(idelems_submod,unit);
1125 return idInit(1,idelems_mod);
1126 }
1127 if (idIs0(mod)) /* and not idIs0(submod) */
1128 {
1129 if (rest!=NULL)
1130 {
1131 *rest=idCopy(submod);
1132 idLift_setUnit(idelems_submod,unit);
1133 return idInit(1,idelems_mod);
1134 }
1135 else
1136 {
1137 WerrorS("2nd module does not lie in the first");
1138 return NULL;
1139 }
1140 }
1141 if (unit!=NULL)
1142 {
1143 comps_to_add = idelems_submod;
1144 while ((comps_to_add>0) && (submod->m[comps_to_add-1]==NULL))
1145 comps_to_add--;
1146 }
1148 if ((k!=0) && (lsmod==0)) lsmod=1;
1149 k=si_max(k,(int)mod->rank);
1150 if (k<submod->rank) { WarnS("rk(submod) > rk(mod) ?");k=submod->rank; }
1151
1152 ring orig_ring=currRing;
1153 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
1154 rSetSyzComp(k,syz_ring);
1155 rChangeCurrRing(syz_ring);
1156
1157 ideal s_mod, s_temp;
1158 if (orig_ring != syz_ring)
1159 {
1160 s_mod = idrCopyR_NoSort(mod,orig_ring,syz_ring);
1161 s_temp = idrCopyR_NoSort(submod,orig_ring,syz_ring);
1162 }
1163 else
1164 {
1165 s_mod = idCopy(mod);
1166 s_temp = idCopy(submod);
1167 }
1168 BITSET save2;
1169 SI_SAVE_OPT2(save2);
1170
1171 if ((rest==NULL)
1173 && (!rIsNCRing(currRing))
1174 && (!TEST_OPT_RETURN_SB))
1176 else
1178 ideal s_h3;
1179 if (isSB && !TEST_OPT_IDLIFT)
1180 {
1181 s_h3 = idCopy(s_mod);
1182 idPrepareStd(s_h3, k+comps_to_add);
1183 }
1184 else
1185 {
1186 s_h3 = idPrepare(s_mod,NULL,(tHomog)FALSE,k+comps_to_add,NULL,alg);
1187 }
1188 SI_RESTORE_OPT2(save2);
1189 if (errorreported)
1190 {
1191 rChangeCurrRing(orig_ring);
1192 return NULL;
1193 }
1194
1195 if (!goodShape)
1196 {
1197 for (j=0;j<IDELEMS(s_h3);j++)
1198 {
1199 if ((s_h3->m[j] != NULL) && (pMinComp(s_h3->m[j]) > k))
1200 p_Delete(&(s_h3->m[j]),currRing);
1201 }
1202 }
1203 idSkipZeroes(s_h3);
1204 if (lsmod==0)
1205 {
1206 id_Shift(s_temp,1,currRing);
1207 }
1208 if (unit!=NULL)
1209 {
1210 for(j = 0;j<comps_to_add;j++)
1211 {
1212 p = s_temp->m[j];
1213 if (p!=NULL)
1214 {
1215 while (pNext(p)!=NULL) pIter(p);
1216 pNext(p) = pOne();
1217 pIter(p);
1218 pSetComp(p,1+j+k);
1219 pSetmComp(p);
1220 p = pNeg(p);
1221 }
1222 }
1223 s_temp->rank += (k+comps_to_add);
1224 }
1225 ideal s_result = kNF(s_h3,currRing->qideal,s_temp,k);
1226 s_result->rank = s_h3->rank;
1227 ideal s_rest = idInit(IDELEMS(s_result),k);
1228 idDelete(&s_h3);
1229 idDelete(&s_temp);
1230
1231 for (j=0;j<IDELEMS(s_result);j++)
1232 {
1233 if (s_result->m[j]!=NULL)
1234 {
1235 if (pGetComp(s_result->m[j])<=k)
1236 {
1237 if (!divide)
1238 {
1239 if (rest==NULL)
1240 {
1241 if (isSB)
1242 {
1243 WarnS("first module not a standardbasis\n"
1244 "// ** or second not a proper submodule");
1245 }
1246 else
1247 WerrorS("2nd module does not lie in the first");
1248 }
1249 idDelete(&s_result);
1250 idDelete(&s_rest);
1251 if(syz_ring!=orig_ring)
1252 {
1253 idDelete(&s_mod);
1254 rChangeCurrRing(orig_ring);
1255 rDelete(syz_ring);
1256 }
1257 if (unit!=NULL)
1258 {
1259 idLift_setUnit(idelems_submod,unit);
1260 }
1261 if (rest!=NULL) *rest=idCopy(submod);
1262 s_result=idInit(idelems_submod,idelems_mod);
1263 return s_result;
1264 }
1265 else
1266 {
1267 p = s_rest->m[j] = s_result->m[j];
1268 while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k)) pIter(p);
1269 s_result->m[j] = pNext(p);
1270 pNext(p) = NULL;
1271 }
1272 }
1273 p_Shift(&(s_result->m[j]),-k,currRing);
1274 pNeg(s_result->m[j]);
1275 }
1276 }
1277 if ((lsmod==0) && (s_rest!=NULL))
1278 {
1279 for (j=IDELEMS(s_rest);j>0;j--)
1280 {
1281 if (s_rest->m[j-1]!=NULL)
1282 {
1283 p_Shift(&(s_rest->m[j-1]),-1,currRing);
1284 }
1285 }
1286 }
1287 if(syz_ring!=orig_ring)
1288 {
1289 idDelete(&s_mod);
1290 rChangeCurrRing(orig_ring);
1291 s_result = idrMoveR_NoSort(s_result, syz_ring, orig_ring);
1292 s_rest = idrMoveR_NoSort(s_rest, syz_ring, orig_ring);
1293 rDelete(syz_ring);
1294 }
1295 if (rest!=NULL)
1296 {
1297 s_rest->rank=mod->rank;
1298 *rest = s_rest;
1299 }
1300 else
1301 idDelete(&s_rest);
1302 if (unit!=NULL)
1303 {
1304 *unit=mpNew(idelems_submod,idelems_submod);
1305 int i;
1306 for(i=0;i<IDELEMS(s_result);i++)
1307 {
1308 poly p=s_result->m[i];
1309 poly q=NULL;
1310 while(p!=NULL)
1311 {
1312 if(pGetComp(p)<=comps_to_add)
1313 {
1314 pSetComp(p,0);
1315 if (q!=NULL)
1316 {
1317 pNext(q)=pNext(p);
1318 }
1319 else
1320 {
1321 pIter(s_result->m[i]);
1322 }
1323 pNext(p)=NULL;
1324 MATELEM(*unit,i+1,i+1)=pAdd(MATELEM(*unit,i+1,i+1),p);
1325 if(q!=NULL) p=pNext(q);
1326 else p=s_result->m[i];
1327 }
1328 else
1329 {
1330 q=p;
1331 pIter(p);
1332 }
1333 }
1334 p_Shift(&s_result->m[i],-comps_to_add,currRing);
1335 }
1336 }
1337 s_result->rank=idelems_mod;
1338 return s_result;
1339}
#define BITSET
Definition auxiliary.h:85
static int si_max(const int a, const int b)
Definition auxiliary.h:125
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
CanonicalForm divide(const CanonicalForm &ff, const CanonicalForm &f, const CFList &as)
VAR short errorreported
Definition feFopen.cc:23
static void idPrepareStd(ideal s_temp, int k)
Definition ideals.cc:1045
static void idLift_setUnit(int e_mod, matrix *unit)
Definition ideals.cc:1086
static ideal idPrepare(ideal h1, ideal h11, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
Definition ideals.cc:613
VAR unsigned si_opt_2
Definition options.c:6
#define TEST_OPT_IDLIFT
Definition options.h:131
#define SI_SAVE_OPT2(A)
Definition options.h:22
#define SI_RESTORE_OPT2(A)
Definition options.h:25
#define Sy_bit(x)
Definition options.h:31
#define TEST_OPT_RETURN_SB
Definition options.h:114
#define V_IDLIFT
Definition options.h:63
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4873
#define pNeg(p)
Definition polys.h:199
#define pGetComp(p)
Component.
Definition polys.h:38
#define pSetComp(p, v)
Definition polys.h:39
#define pSetmComp(p)
TODO:
Definition polys.h:274
#define pMinComp(p)
Definition polys.h:301
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:261
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:205
ring rAssure_SyzOrder(const ring r, BOOLEAN complete)
Definition ring.cc:4522
void rSetSyzComp(int k, const ring r)
Definition ring.cc:5230
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
#define rField_is_Ring(R)
Definition ring.h:491
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_Shift(ideal M, int s, const ring r)

◆ idLiftStd()

ideal idLiftStd ( ideal h1,
matrix * m,
tHomog h = testHomog,
ideal * syz = NULL,
GbVariant a = GbDefault,
ideal h11 = NULL )

Definition at line 980 of file ideals.cc.

982{
983 int inputIsIdeal=id_RankFreeModule(h1,currRing);
984 long k;
985 intvec *w=NULL;
986
987 idDelete((ideal*)T);
988 BOOLEAN lift3=FALSE;
989 if (S!=NULL) { lift3=TRUE; idDelete(S); }
990 if (idIs0(h1))
991 {
992 *T=mpNew(1,IDELEMS(h1));
993 if (lift3)
994 {
995 *S=idFreeModule(IDELEMS(h1));
996 }
997 return idInit(1,h1->rank);
998 }
999
1000 BITSET saveOpt1,saveOpt2;
1001 SI_SAVE_OPT(saveOpt1,saveOpt2);
1003 k=si_max(1,inputIsIdeal);
1004
1005 if ((!lift3)&&(!TEST_OPT_RETURN_SB)) si_opt_2 |=Sy_bit(V_IDLIFT);
1006
1007 ring orig_ring = currRing;
1008 ring syz_ring = rAssure_SyzOrder(orig_ring,TRUE);
1009 rSetSyzComp(k,syz_ring);
1010 rChangeCurrRing(syz_ring);
1011
1012 ideal s_h1;
1013
1014 if (orig_ring != syz_ring)
1015 s_h1 = idrCopyR_NoSort(h1,orig_ring,syz_ring);
1016 else
1017 s_h1 = h1;
1018 ideal s_h11=NULL;
1019 if (h11!=NULL)
1020 {
1021 s_h11=idrCopyR_NoSort(h11,orig_ring,syz_ring);
1022 }
1023
1024
1025 ideal s_h3=idPrepare(s_h1,s_h11,hi,k,&w,alg); // main (syz) GB computation
1026
1027
1028 if (w!=NULL) delete w;
1029 if (syz_ring!=orig_ring)
1030 {
1031 idDelete(&s_h1);
1032 if (s_h11!=NULL) idDelete(&s_h11);
1033 }
1034
1035 if (S!=NULL) (*S)=idInit(IDELEMS(s_h3),IDELEMS(h1));
1036
1037 s_h3=idExtractG_T_S(s_h3,T,S,k,IDELEMS(h1),inputIsIdeal,orig_ring,syz_ring);
1038
1039 if (syz_ring!=orig_ring) rDelete(syz_ring);
1040 s_h3->rank=h1->rank;
1041 SI_RESTORE_OPT(saveOpt1,saveOpt2);
1042 return s_h3;
1043}
ideal idExtractG_T_S(ideal s_h3, matrix *T, ideal *S, long syzComp, int h1_size, BOOLEAN inputIsIdeal, const ring oring, const ring sring)
Definition ideals.cc:713
ideal idFreeModule(int i)
Definition ideals.h:111
#define SI_SAVE_OPT(A, B)
Definition options.h:20
#define V_PURE_GB
Definition options.h:71
#define SI_RESTORE_OPT(A, B)
Definition options.h:23

◆ idLiftW()

void idLiftW ( ideal P,
ideal Q,
int n,
matrix & T,
ideal & R,
int * w = NULL )

Definition at line 1345 of file ideals.cc.

1346{
1347 long N=0;
1348 int i;
1349 for(i=IDELEMS(Q)-1;i>=0;i--)
1350 if(w==NULL)
1351 N=si_max(N,p_Deg(Q->m[i],currRing));
1352 else
1353 N=si_max(N,p_DegW(Q->m[i],w,currRing));
1354 N+=n;
1355
1356 T=mpNew(IDELEMS(Q),IDELEMS(P));
1357 R=idInit(IDELEMS(P),P->rank);
1358
1359 for(i=IDELEMS(P)-1;i>=0;i--)
1360 {
1361 poly p;
1362 if(w==NULL)
1363 p=ppJet(P->m[i],N);
1364 else
1365 p=ppJetW(P->m[i],N,w);
1366
1367 int j=IDELEMS(Q)-1;
1368 while(p!=NULL)
1369 {
1370 if(pDivisibleBy(Q->m[j],p))
1371 {
1372 poly p0=p_DivideM(pHead(p),pHead(Q->m[j]),currRing);
1373 if(w==NULL)
1374 p=pJet(pSub(p,ppMult_mm(Q->m[j],p0)),N);
1375 else
1376 p=pJetW(pSub(p,ppMult_mm(Q->m[j],p0)),N,w);
1377 pNormalize(p);
1378 if(((w==NULL)&&(p_Deg(p0,currRing)>n))||((w!=NULL)&&(p_DegW(p0,w,currRing)>n)))
1379 p_Delete(&p0,currRing);
1380 else
1381 MATELEM(T,j+1,i+1)=pAdd(MATELEM(T,j+1,i+1),p0);
1382 j=IDELEMS(Q)-1;
1383 }
1384 else
1385 {
1386 if(j==0)
1387 {
1388 poly p0=p;
1389 pIter(p);
1390 pNext(p0)=NULL;
1391 if(((w==NULL)&&(p_Deg(p0,currRing)>n))
1392 ||((w!=NULL)&&(p_DegW(p0,w,currRing)>n)))
1393 p_Delete(&p0,currRing);
1394 else
1395 R->m[i]=pAdd(R->m[i],p0);
1396 j=IDELEMS(Q)-1;
1397 }
1398 else
1399 j--;
1400 }
1401 }
1402 }
1403}
poly p_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1582
long p_DegW(poly p, const int *w, const ring R)
Definition p_polys.cc:691
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
#define ppJet(p, m)
Definition polys.h:367
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
#define ppMult_mm(p, m)
Definition polys.h:202
#define pJet(p, m)
Definition polys.h:368
#define pSub(a, b)
Definition polys.h:288
#define ppJetW(p, m, iv)
Definition polys.h:369
#define pJetW(p, m, iv)
Definition polys.h:370
#define pNormalize(p)
Definition polys.h:318
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition polys.h:139
#define R
Definition sirandom.c:27

◆ idMinBase()

ideal idMinBase ( ideal h1,
ideal * SB = NULL )

Definition at line 51 of file ideals.cc.

52{
53 ideal h2, h3,h4,e;
54 int j,k;
55 int i,l,ll;
56 intvec * wth;
57 BOOLEAN homog;
59 {
60 WarnS("minbase applies only to the local or homogeneous case over coefficient fields");
61 e=idCopy(h1);
62 return e;
63 }
64 homog = idHomModule(h1,currRing->qideal,&wth);
66 {
67 if(!homog)
68 {
69 WarnS("minbase applies only to the local or homogeneous case over coefficient fields");
70 e=idCopy(h1);
71 return e;
72 }
73 else
74 {
75 ideal re=kMin_std2(h1,currRing->qideal,(tHomog)homog,&wth,h2,(bigintmat*)NULL,0,3);
76 idDelete(&re);
77 return h2;
78 }
79 }
80 e=idInit(1,h1->rank);
81 if (idIs0(h1))
82 {
83 return e;
84 }
85 h2 = kStd2(h1,currRing->qideal,isNotHomog,NULL,(bigintmat*)NULL);
86 if (SB!=NULL) *SB=h2;
87 h3 = idMaxIdeal(1);
88 h4=idMult(h2,h3);
89 idDelete(&h3);
90 h3=kStd2(h4,currRing->qideal,isNotHomog,NULL,(bigintmat*)NULL);
91 k = IDELEMS(h3);
92 while ((k > 0) && (h3->m[k-1] == NULL)) k--;
93 j = -1;
94 l = IDELEMS(h2);
95 while ((l > 0) && (h2->m[l-1] == NULL)) l--;
96 for (i=l-1; i>=0; i--)
97 {
98 if (h2->m[i] != NULL)
99 {
100 ll = 0;
101 while ((ll < k) && ((h3->m[ll] == NULL)
102 || !pDivisibleBy(h3->m[ll],h2->m[i])))
103 ll++;
104 if (ll >= k)
105 {
106 j++;
107 if (j > IDELEMS(e)-1)
108 {
109 pEnlargeSet(&(e->m),IDELEMS(e),16);
110 IDELEMS(e) += 16;
111 }
112 e->m[j] = pCopy(h2->m[i]);
113 }
114 }
115 }
116 if (SB==NULL) idDelete(&h2);
117 idDelete(&h3);
118 idDelete(&h4);
119 if (currRing->qideal!=NULL)
120 {
121 h3=idInit(1,e->rank);
122 h2=kNF(h3,currRing->qideal,e);
123 idDelete(&h3);
124 idDelete(&e);
125 e=h2;
126 }
127 idSkipZeroes(e);
128 return e;
129}
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition ideals.h:84
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition ideals.h:33
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3070
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
static BOOLEAN rHasGlobalOrdering(const ring r)
Definition ring.h:773
@ isNotHomog
Definition structs.h:32

◆ idMinEmbedding()

ideal idMinEmbedding ( ideal arg,
BOOLEAN inPlace = FALSE,
intvec ** w = NULL )

Definition at line 2858 of file ideals.cc.

2859{
2860 int *red_comp=(int*)omAlloc((arg->rank+1)*sizeof(int));
2861 int del=0;
2862 ideal res=idMinEmbedding1(arg,inPlace,w,red_comp,del);
2863 idDeleteComps(res,red_comp,del);
2864 omFree(red_comp);
2865 return res;
2866}
static ideal idMinEmbedding1(ideal arg, BOOLEAN inPlace, intvec **w, int *red_comp, int &del)
Definition ideals.cc:2822
static void idDeleteComps(ideal arg, int *red_comp, int del)
Definition ideals.cc:2712

◆ idMinEmbedding_with_map()

ideal idMinEmbedding_with_map ( ideal arg,
intvec ** w,
ideal & trans )

Definition at line 2868 of file ideals.cc.

2869{
2870 int *red_comp=(int*)omAlloc((arg->rank+1)*sizeof(int));
2871 int del=0;
2872 ideal res=idMinEmbedding1(arg,FALSE,w,red_comp,del);
2873 trans=idLift(arg,res,NULL,TRUE,FALSE,FALSE,NULL);
2874 //idDeleteComps(res,red_comp,del);
2875 omFree(red_comp);
2876 return res;
2877}
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1109

◆ idMinEmbedding_with_map_v()

ideal idMinEmbedding_with_map_v ( ideal arg,
intvec ** w,
ideal & trans,
int * red_comp )

Definition at line 2879 of file ideals.cc.

2880{
2881 if (idIs0(arg))
2882 {
2883 trans=idFreeModule(arg->rank);
2884 if (g!=NULL)
2885 {
2886 for(int i=0;i<arg->rank;i++) g[i]=i+1;
2887 }
2888 return arg;
2889 }
2890 int *red_comp=(int*)omAlloc((arg->rank+1)*sizeof(int));
2891 int del=0;
2892 ideal res=idMinEmbedding1(arg,FALSE,w,red_comp,del);
2893 trans=idLift(arg,res,NULL,TRUE,FALSE,FALSE,NULL);
2894 for(int i=1;i<=arg->rank;i++)
2895 {
2896 g[i-1]=red_comp[i];
2897 }
2898 idDeleteComps(res,red_comp,del);
2899 return res;
2900}

◆ idMinors()

ideal idMinors ( matrix a,
int ar,
ideal R = NULL )

compute all ar-minors of the matrix a the caller of mpRecMin the elements of the result are not in R (if R!=NULL)

Definition at line 2036 of file ideals.cc.

2037{
2038
2039 const ring origR=currRing;
2040 id_Test((ideal)a, origR);
2041
2042 const int r = a->nrows;
2043 const int c = a->ncols;
2044
2045 if((ar<=0) || (ar>r) || (ar>c))
2046 {
2047 Werror("%d-th minor, matrix is %dx%d",ar,r,c);
2048 return NULL;
2049 }
2050
2051 ideal h = id_Matrix2Module(mp_Copy(a,origR),origR);
2052 long bound = sm_ExpBound(h,c,r,ar,origR);
2053 id_Delete(&h, origR);
2054
2055 ring tmpR = sm_RingChange(origR,bound);
2056
2057 matrix b = mpNew(r,c);
2058
2059 for (int i=r*c-1;i>=0;i--)
2060 if (a->m[i] != NULL)
2061 b->m[i] = prCopyR(a->m[i],origR,tmpR);
2062
2063 id_Test( (ideal)b, tmpR);
2064
2065 if (R!=NULL)
2066 {
2067 R = idrCopyR(R,origR,tmpR); // TODO: overwrites R? memory leak?
2068 //if (ar>1) // otherwise done in mpMinorToResult
2069 //{
2070 // matrix bb=(matrix)kNF(R,currRing->qideal,(ideal)b);
2071 // bb->rank=b->rank; bb->nrows=b->nrows; bb->ncols=b->ncols;
2072 // idDelete((ideal*)&b); b=bb;
2073 //}
2074 id_Test( R, tmpR);
2075 }
2076
2077 int size=binom(r,ar)*binom(c,ar);
2078 ideal result = idInit(size,1);
2079
2080 int elems = 0;
2081
2082 if(ar>1)
2083 mp_RecMin(ar-1,result,elems,b,r,c,NULL,R,tmpR);
2084 else
2085 mp_MinorToResult(result,elems,b,r,c,R,tmpR);
2086
2087 id_Test( (ideal)b, tmpR);
2088
2089 id_Delete((ideal *)&b, tmpR);
2090
2091 if (R!=NULL) id_Delete(&R,tmpR);
2092
2093 rChangeCurrRing(origR);
2094 result = idrMoveR(result,tmpR,origR);
2095 sm_KillModifiedRing(tmpR);
2096 idTest(result);
2097 return result;
2098}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
int nrows
Definition matpol.h:20
int ncols
Definition matpol.h:21
int binom(int n, int r)
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
void mp_MinorToResult(ideal result, int &elems, matrix a, int r, int c, ideal R, const ring)
entries of a are minors and go to result (only if not in R)
Definition matpol.cc:1501
void mp_RecMin(int ar, ideal result, int &elems, matrix a, int lr, int lc, poly barDiv, ideal R, const ring r)
produces recursively the ideal of all arxar-minors of a
Definition matpol.cc:1597
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition prCopy.cc:34
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
long sm_ExpBound(ideal m, int di, int ra, int t, const ring currRing)
Definition sparsmat.cc:188
ring sm_RingChange(const ring origR, long bound)
Definition sparsmat.cc:258
void sm_KillModifiedRing(ring r)
Definition sparsmat.cc:289

◆ idModulo()

ideal idModulo ( ideal h1,
ideal h2,
tHomog h = testHomog,
intvec ** w = NULL,
matrix * T = NULL,
GbVariant a = GbDefault )

Definition at line 2468 of file ideals.cc.

2469{
2470#ifdef HAVE_SHIFTBBA
2471 if (rIsLPRing(currRing))
2472 return idModuloLP(h2,h1,hom,w,T,alg);
2473#endif
2474 intvec *wtmp=NULL;
2475 if (T!=NULL) idDelete((ideal*)T);
2476
2477 int i,flength=0,slength,length;
2478
2479 if (idIs0(h2))
2480 return idFreeModule(si_max(1,h2->ncols));
2481 if (!idIs0(h1))
2482 flength = id_RankFreeModule(h1,currRing);
2483 slength = id_RankFreeModule(h2,currRing);
2484 length = si_max(flength,slength);
2485 BOOLEAN inputIsIdeal=FALSE;
2486 if (length==0)
2487 {
2488 length = 1;
2489 inputIsIdeal=TRUE;
2490 }
2491 if ((w!=NULL)&&((*w)!=NULL))
2492 {
2493 //Print("input weights:");(*w)->show(1);PrintLn();
2494 int d;
2495 int k;
2496 wtmp=new intvec(length+IDELEMS(h2));
2497 for (i=0;i<length;i++)
2498 ((*wtmp)[i])=(**w)[i];
2499 for (i=0;i<IDELEMS(h2);i++)
2500 {
2501 poly p=h2->m[i];
2502 if (p!=NULL)
2503 {
2504 d = p_Deg(p,currRing);
2505 k= pGetComp(p);
2506 if (slength>0) k--;
2507 d +=((**w)[k]);
2508 ((*wtmp)[i+length]) = d;
2509 }
2510 }
2511 //Print("weights:");wtmp->show(1);PrintLn();
2512 }
2513 ideal s_temp1;
2514 ring orig_ring=currRing;
2515 ring syz_ring=rAssure_SyzOrder(orig_ring, TRUE);
2516 rSetSyzComp(length,syz_ring);
2517 {
2518 rChangeCurrRing(syz_ring);
2519 ideal s1,s2;
2520
2521 if (syz_ring != orig_ring)
2522 {
2523 s1 = idrCopyR_NoSort(h1, orig_ring, syz_ring);
2524 s2 = idrCopyR_NoSort(h2, orig_ring, syz_ring);
2525 }
2526 else
2527 {
2528 s1=idCopy(h1);
2529 s2=idCopy(h2);
2530 }
2531
2532 BITSET save_opt,save_opt2;
2533 SI_SAVE_OPT(save_opt,save_opt2);
2534 if (T==NULL) si_opt_1 |= Sy_bit(OPT_REDTAIL);
2536 s_temp1 = idPrepare(s2,s1,testHomog,length,w,alg);
2537 SI_RESTORE_OPT(save_opt,save_opt2);
2538 }
2539
2540 //if (wtmp!=NULL) Print("output weights:");wtmp->show(1);PrintLn();
2541 if ((w!=NULL) && (*w !=NULL) && (wtmp!=NULL))
2542 {
2543 delete *w;
2544 *w=new intvec(IDELEMS(h2));
2545 for (i=0;i<IDELEMS(h2);i++)
2546 ((**w)[i])=(*wtmp)[i+length];
2547 }
2548 if (wtmp!=NULL) delete wtmp;
2549
2550 ideal result=idInit(IDELEMS(s_temp1),IDELEMS(h2));
2551 s_temp1=idExtractG_T_S(s_temp1,T,&result,length,IDELEMS(h2),inputIsIdeal,orig_ring,syz_ring);
2552
2553 idDelete(&s_temp1);
2554 if (syz_ring!=orig_ring)
2555 {
2556 rDelete(syz_ring);
2557 }
2558 idTest(h2);
2559 idTest(h1);
2560 idTest(result);
2561 if (T!=NULL) idTest((ideal)*T);
2562 return result;
2563}
ideal idModuloLP(ideal h2, ideal h1, tHomog, intvec **w, matrix *T, GbVariant alg)
Definition ideals.cc:2277
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
VAR unsigned si_opt_1
Definition options.c:5
#define OPT_REDTAIL_SYZ
Definition options.h:88
#define OPT_REDTAIL
Definition options.h:92
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417

◆ idMult()

ideal idMult ( ideal h1,
ideal h2 )
inlinestatic

hh := h1 * h2

Definition at line 84 of file ideals.h.

85{
86 return id_Mult(h1, h2, currRing);
87}
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 co...

◆ idMultSect()

ideal idMultSect ( resolvente arg,
int length,
GbVariant a = GbDefault )

Definition at line 472 of file ideals.cc.

473{
474 int i,j=0,k=0,l,maxrk=-1,realrki;
475 unsigned syzComp;
476 ideal bigmat,tempstd,result;
477 poly p;
478 int isIdeal=0;
479
480 /* find 0-ideals and max rank -----------------------------------*/
481 for (i=0;i<length;i++)
482 {
483 if (!idIs0(arg[i]))
484 {
485 realrki=id_RankFreeModule(arg[i],currRing);
486 k++;
487 j += IDELEMS(arg[i]);
488 if (realrki>maxrk) maxrk = realrki;
489 }
490 else
491 {
492 if (arg[i]!=NULL)
493 {
494 return idInit(1,arg[i]->rank);
495 }
496 }
497 }
498 if (maxrk == 0)
499 {
500 isIdeal = 1;
501 maxrk = 1;
502 }
503 /* init -----------------------------------------------------------*/
504 j += maxrk;
505 syzComp = k*maxrk;
506
507 BITSET save_opt;
508 SI_SAVE_OPT1(save_opt);
510
511 ring orig_ring=currRing;
512 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
513 rSetSyzComp(syzComp,syz_ring);
514 rChangeCurrRing(syz_ring);
515
516 bigmat = idInit(j,(k+1)*maxrk);
517 /* create unit matrices ------------------------------------------*/
518 for (i=0;i<maxrk;i++)
519 {
520 for (j=0;j<=k;j++)
521 {
522 p = pOne();
523 pSetComp(p,i+1+j*maxrk);
524 pSetmComp(p);
525 bigmat->m[i] = pAdd(bigmat->m[i],p);
526 }
527 }
528 /* enter given ideals ------------------------------------------*/
529 i = maxrk;
530 k = 0;
531 for (j=0;j<length;j++)
532 {
533 if (arg[j]!=NULL)
534 {
535 for (l=0;l<IDELEMS(arg[j]);l++)
536 {
537 if (arg[j]->m[l]!=NULL)
538 {
539 if (syz_ring==orig_ring)
540 bigmat->m[i] = pCopy(arg[j]->m[l]);
541 else
542 bigmat->m[i] = prCopyR(arg[j]->m[l], orig_ring,currRing);
543 p_Shift(&(bigmat->m[i]),k*maxrk+isIdeal,currRing);
544 i++;
545 }
546 }
547 k++;
548 }
549 }
550 /* std computation --------------------------------------------*/
551 if ((alg!=GbDefault)
552 && (alg!=GbGroebner)
553 && (alg!=GbModstd)
554 && (alg!=GbSlimgb)
555 && (alg!=GbStd))
556 {
557 WarnS("wrong algorithm for GB");
558 alg=GbDefault;
559 }
560 tempstd=idGroebner(bigmat,syzComp,alg);
561
562 if(syz_ring!=orig_ring)
563 rChangeCurrRing(orig_ring);
564
565 /* interpret result ----------------------------------------*/
566 result = idInit(IDELEMS(tempstd),maxrk);
567 k = 0;
568 for (j=0;j<IDELEMS(tempstd);j++)
569 {
570 if ((tempstd->m[j]!=NULL) && (__p_GetComp(tempstd->m[j],syz_ring)>syzComp))
571 {
572 if (syz_ring==orig_ring)
573 p = pCopy(tempstd->m[j]);
574 else
575 p = prCopyR(tempstd->m[j], syz_ring,currRing);
576 p_Shift(&p,-syzComp-isIdeal,currRing);
577 result->m[k] = p;
578 k++;
579 }
580 }
581 /* clean up ----------------------------------------------------*/
582 if(syz_ring!=orig_ring)
583 rChangeCurrRing(syz_ring);
584 idDelete(&tempstd);
585 if(syz_ring!=orig_ring)
586 {
587 rChangeCurrRing(orig_ring);
588 rDelete(syz_ring);
589 }
590 SI_RESTORE_OPT1(save_opt);
592 return result;
593}
#define SI_SAVE_OPT1(A)
Definition options.h:21
#define SI_RESTORE_OPT1(A)
Definition options.h:24

◆ idQuot()

ideal idQuot ( ideal h1,
ideal h2,
BOOLEAN h1IsStb = FALSE,
BOOLEAN resultIsIdeal = FALSE )

Definition at line 1537 of file ideals.cc.

1538{
1539 // first check for special case h1:(0)
1540 if (idIs0(h2))
1541 {
1542 ideal res;
1543 if (resultIsIdeal)
1544 {
1545 res = idInit(1,1);
1546 res->m[0] = pOne();
1547 }
1548 else
1549 res = idFreeModule(h1->rank);
1550 return res;
1551 }
1552 int i, kmax,q_len;
1553 BOOLEAN addOnlyOne=TRUE;
1554 tHomog hom=isNotHomog;
1555 intvec * weights1;
1556
1557 ideal s_h4 = idInitializeQuot (h1,h2,h1IsStb,&addOnlyOne,&kmax,&q_len);
1558
1559 hom = (tHomog)idHomModule(s_h4,currRing->qideal,&weights1);
1560
1561 ring orig_ring=currRing;
1562 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
1563 rSetSyzComp(kmax-1,syz_ring);
1564 rChangeCurrRing(syz_ring);
1565 if (orig_ring!=syz_ring)
1566 // s_h4 = idrMoveR_NoSort(s_h4,orig_ring, syz_ring);
1567 s_h4 = idrMoveR(s_h4,orig_ring, syz_ring);
1568 idTest(s_h4);
1569
1570 #if 0
1571 matrix m=idModule2Matrix(idCopy(s_h4));
1572 PrintS("start:\n");
1573 ipPrint_MA0(m,"Q");
1574 idDelete((ideal *)&m);
1575 PrintS("last elem:");wrp(s_h4->m[IDELEMS(s_h4)-1]);PrintLn();
1576 #endif
1577
1578 ideal s_h3;
1579 BITSET old_test1;
1580 SI_SAVE_OPT1(old_test1);
1582 if (addOnlyOne)
1583 {
1585 s_h3 = kStd2(s_h4,currRing->qideal,hom,&weights1,(bigintmat*)NULL,0/*kmax-1*/,IDELEMS(s_h4)-1);
1586 }
1587 else
1588 {
1589 //s_h3 = kStd2(s_h4,currRing->qideal,hom,&weights1,(bigintmat*)NULL,kmax-1);
1590 // qideal added in idInitializeQuotient
1591 if (q_len>0)
1592 {
1593 BITSET save1;
1594 SI_SAVE_OPT1(save1);
1596 s_h3 = kStd2(s_h4,NULL,hom,&weights1,(bigintmat*)NULL,kmax-1,q_len);
1597 SI_RESTORE_OPT1(save1);
1598 }
1599 else
1600 s_h3 = kStd2(s_h4,NULL,hom,&weights1,(bigintmat*)NULL,kmax-1);
1601 }
1602 SI_RESTORE_OPT1(old_test1);
1603
1604 #if 0
1605 // only together with the above debug stuff
1606 idSkipZeroes(s_h3);
1607 m=idModule2Matrix(idCopy(s_h3));
1608 Print("result, kmax=%d:\n",kmax);
1609 ipPrint_MA0(m,"S");
1610 idDelete((ideal *)&m);
1611 #endif
1612
1613 idTest(s_h3);
1614 if (weights1!=NULL) delete weights1;
1615 idDelete(&s_h4);
1616
1617 for (i=0;i<IDELEMS(s_h3);i++)
1618 {
1619 if ((s_h3->m[i]!=NULL) && (pGetComp(s_h3->m[i])>=kmax))
1620 {
1621 if (resultIsIdeal)
1622 p_Shift(&s_h3->m[i],-kmax,currRing);
1623 else
1624 p_Shift(&s_h3->m[i],-kmax+1,currRing);
1625 }
1626 else
1627 p_Delete(&s_h3->m[i],currRing);
1628 }
1629 if (resultIsIdeal)
1630 s_h3->rank = 1;
1631 else
1632 s_h3->rank = h1->rank;
1633 if(syz_ring!=orig_ring)
1634 {
1635 rChangeCurrRing(orig_ring);
1636 s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
1637 rDelete(syz_ring);
1638 }
1639 idSkipZeroes(s_h3);
1640 idTest(s_h3);
1641 return s_h3;
1642}
#define Print
Definition emacs.cc:80
static ideal idInitializeQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN *addOnlyOne, int *kkmax, int *q_len)
Definition ideals.cc:1410
void ipPrint_MA0(matrix m, const char *name)
Definition ipprint.cc:57
#define OPT_SB_1
Definition options.h:96
void wrp(poly p)
Definition polys.h:311
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314

◆ idSaturate()

ideal idSaturate ( ideal I,
ideal J,
int & ki,
BOOLEAN isIdeal = TRUE )

Definition at line 3602 of file ideals.cc.

3603{
3604 return idSaturate_intern(I,J,k,isIdeal,FALSE);
3605}
ideal idSaturate_intern(ideal I, ideal J, int &k, BOOLEAN isIdeal, BOOLEAN isSB)
Definition ideals.cc:3498

◆ idSaturate_intern()

ideal idSaturate_intern ( ideal I,
ideal J,
int & ki,
BOOLEAN isIdeal,
BOOLEAN isSB )

Definition at line 3498 of file ideals.cc.

3499{
3500 if(idIs0(J))
3501 {
3502 ideal res;
3503 if(isIdeal)
3504 {
3505 res=idInit(1,1);
3506 res->m[0]=pOne();
3507 }
3508 else
3509 {
3510 res=idFreeModule(I->rank);
3511 }
3512 k=1;
3513 return(res);
3514 }
3515 BITSET save_opt;SI_SAVE_OPT2(save_opt);
3516 //if (idElem(J)==1)
3517 //{
3518 // idSkipZeroes(J);
3519 // return id_Sat_principal(I,J,currRing);
3520 //}
3521 //---------------------------------------------------
3523 {
3524 BOOLEAN only_vars=TRUE; // enabled for I:x_i
3525 if (idElem(J)==1)
3526 {
3527 for(int j=IDELEMS(J)-1;j>=0;j--)
3528 {
3529 poly p=J->m[j];
3530 if (p!=NULL)
3531 {
3532 if (pVar(p)==0)
3533 {
3534 only_vars=FALSE;
3535 break;
3536 }
3537 }
3538 }
3539 }
3540 if (only_vars && isIdeal && rOrd_is_Totaldegree_Ordering(currRing)
3541 && (idElem(J)==1))
3542 {
3543 ideal Iquot,Istd;
3544 intvec *w=NULL;
3545 Istd=id_Satstd(I,J,currRing);
3547 k=0;
3548 loop
3549 {
3550 k++;
3551 Iquot=idQuot(Istd,J,TRUE,isIdeal);
3552 ideal tmp=kNF(Istd,currRing->qideal,Iquot,5);
3553 int elem=idElem(tmp);
3554 id_Delete(&tmp,currRing);
3555 id_Delete(&Istd,currRing);
3556 Istd=Iquot;
3557 w=NULL;
3558 Istd=kStd2(Iquot,currRing->qideal,testHomog,&w,(bigintmat*)NULL);
3559 if (w!=NULL) delete w;
3560 id_Delete(&Iquot,currRing);
3561 if (elem==0) break;
3562 }
3563 k--;
3564 idSkipZeroes(Istd);
3565 //PrintS("\nSatstd:\n");
3566 //iiWriteMatrix((matrix)I,"I",1,currRing,0); PrintLn();
3567 //iiWriteMatrix((matrix)J,"J",1,currRing,0); PrintLn();
3568 //iiWriteMatrix((matrix)Istd,"res",1,currRing,0);PrintLn();
3569 //id_Delete(&Istd,currRing);
3570 SI_RESTORE_OPT2(save_opt);
3571 return Istd;
3572 }
3573 }
3574 //--------------------------------------------------
3575 ideal Iquot,Istd;
3576 intvec *w=NULL;
3577 Istd=idCopy(I);
3578 k=0;
3579 loop
3580 {
3581 k++;
3582 Iquot=idQuot(Istd,J,isSB,isIdeal);
3583 isSB=FALSE;
3584 si_opt_2|=Sy_bit(V_PURE_GB); // used from 2nd loop on
3585 ideal tmp=kNF(Istd,currRing->qideal,Iquot,5);
3586 int elem=idElem(tmp);
3587 id_Delete(&tmp,currRing);
3588 id_Delete(&Istd,currRing);
3589 Istd=Iquot;
3590 if (elem==0) break;
3591 }
3592 k--;
3593 Istd=kStd2(Iquot,currRing->qideal,testHomog,&w,(bigintmat*)NULL);
3594 idSkipZeroes(Istd);
3595 SI_RESTORE_OPT2(save_opt);
3596 //if (only_vars)
3597 //{
3598 // iiWriteMatrix((matrix)Istd,"org",1,currRing,0);
3599 //}
3600 return Istd;
3601}
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1537
ideal id_Satstd(const ideal I, ideal J, const ring r)
Definition ideals.cc:3368
#define pVar(m)
Definition polys.h:381
BOOLEAN rOrd_is_Totaldegree_Ordering(const ring r)
Definition ring.cc:2043
static int idElem(const ideal F)
number of non-zero polys in F
#define loop
Definition structs.h:71

◆ idSaturateGB()

ideal idSaturateGB ( ideal I,
ideal J,
int & ki,
BOOLEAN isIdeal = TRUE )

Definition at line 3606 of file ideals.cc.

3607{
3608 return idSaturate_intern(I,J,k,isIdeal,TRUE);
3609}

◆ idSect()

ideal idSect ( ideal h1,
ideal h2,
GbVariant a = GbDefault )

Definition at line 315 of file ideals.cc.

316{
317 int i,j,k;
318 unsigned length;
319 int flength = id_RankFreeModule(h1,currRing);
320 int slength = id_RankFreeModule(h2,currRing);
321 int rank=si_max(h1->rank,h2->rank);
322 if ((idIs0(h1)) || (idIs0(h2))) return idInit(1,rank);
323
324 BITSET save_opt;
325 SI_SAVE_OPT1(save_opt);
327
328 ideal first,second,temp,temp1,result;
329 poly p,q;
330
331 if (IDELEMS(h1)<IDELEMS(h2))
332 {
333 first = h1;
334 second = h2;
335 }
336 else
337 {
338 first = h2;
339 second = h1;
340 int t=flength; flength=slength; slength=t;
341 }
342 length = si_max(flength,slength);
343 if (length==0)
344 {
345 if ((currRing->qideal==NULL)
346 && (currRing->OrdSgn==1)
349 return idSectWithElim(first,second,alg);
350 else length = 1;
351 }
352 if (TEST_OPT_PROT) PrintS("intersect by syzygy methods\n");
353 j = IDELEMS(first);
354
355 ring orig_ring=currRing;
356 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
357 rSetSyzComp(length,syz_ring);
358 rChangeCurrRing(syz_ring);
360
361 while ((j>0) && (first->m[j-1]==NULL)) j--;
362 temp = idInit(j /*IDELEMS(first)*/+IDELEMS(second),length+j);
363 k = 0;
364 for (i=0;i<j;i++)
365 {
366 if (first->m[i]!=NULL)
367 {
368 if (syz_ring==orig_ring)
369 temp->m[k] = pCopy(first->m[i]);
370 else
371 temp->m[k] = prCopyR(first->m[i], orig_ring, syz_ring);
372 q = pOne();
373 pSetComp(q,i+1+length);
374 pSetmComp(q);
375 if (flength==0) p_Shift(&(temp->m[k]),1,currRing);
376 p = temp->m[k];
377 while (pNext(p)!=NULL) pIter(p);
378 pNext(p) = q;
379 k++;
380 }
381 }
382 for (i=0;i<IDELEMS(second);i++)
383 {
384 if (second->m[i]!=NULL)
385 {
386 if (syz_ring==orig_ring)
387 temp->m[k] = pCopy(second->m[i]);
388 else
389 temp->m[k] = prCopyR(second->m[i], orig_ring,currRing);
390 if (slength==0) p_Shift(&(temp->m[k]),1,currRing);
391 k++;
392 }
393 }
394 intvec *w=NULL;
395
396 if ((alg!=GbDefault)
397 && (alg!=GbGroebner)
398 && (alg!=GbModstd)
399 && (alg!=GbSlimgb)
400 && (alg!=GbStd))
401 {
402 WarnS("wrong algorithm for GB");
403 alg=GbDefault;
404 }
405 temp1=idGroebner(temp,length,alg);
406
407 if(syz_ring!=orig_ring)
408 rChangeCurrRing(orig_ring);
409
410 result = idInit(IDELEMS(temp1),rank);
411 j = 0;
412 for (i=0;i<IDELEMS(temp1);i++)
413 {
414 if ((temp1->m[i]!=NULL)
415 && (__p_GetComp(temp1->m[i],syz_ring)>length))
416 {
417 if(syz_ring==orig_ring)
418 {
419 p = temp1->m[i];
420 }
421 else
422 {
423 p = prMoveR(temp1->m[i], syz_ring,orig_ring);
424 }
425 temp1->m[i]=NULL;
426 while (p!=NULL)
427 {
428 q = pNext(p);
429 pNext(p) = NULL;
430 k = pGetComp(p)-1-length;
431 pSetComp(p,0);
432 pSetmComp(p);
433 /* Warning! multiply only from the left! it's very important for Plural */
434 result->m[j] = pAdd(result->m[j],pMult(p,pCopy(first->m[k])));
435 p = q;
436 }
437 j++;
438 }
439 }
440 if(syz_ring!=orig_ring)
441 {
442 rChangeCurrRing(syz_ring);
443 idDelete(&temp1);
444 rChangeCurrRing(orig_ring);
445 rDelete(syz_ring);
446 }
447 else
448 {
449 idDelete(&temp1);
450 }
451
453 SI_RESTORE_OPT1(save_opt);
455 {
456 w=NULL;
457 temp1=kStd2(result,currRing->qideal,testHomog,&w,(bigintmat*)NULL);
458 if (w!=NULL) delete w;
460 idSkipZeroes(temp1);
461 return temp1;
462 }
463 //else
464 // temp1=kInterRed(result,currRing->qideal);
465 return result;
466}
static ideal idSectWithElim(ideal h1, ideal h2, GbVariant alg)
Definition ideals.cc:132
#define TEST_V_INTERSECT_ELIM
Definition options.h:146
#define TEST_V_INTERSECT_SYZ
Definition options.h:147
#define TEST_OPT_PROT
Definition options.h:105
#define pMult(p, q)
Definition polys.h:208

◆ idSeries()

ideal idSeries ( int n,
ideal M,
matrix U = NULL,
intvec * w = NULL )

Definition at line 2177 of file ideals.cc.

2178{
2179 for(int i=IDELEMS(M)-1;i>=0;i--)
2180 {
2181 if(U==NULL)
2182 M->m[i]=pSeries(n,M->m[i],NULL,w);
2183 else
2184 {
2185 M->m[i]=pSeries(n,M->m[i],MATELEM(U,i+1,i+1),w);
2186 MATELEM(U,i+1,i+1)=NULL;
2187 }
2188 }
2189 if(U!=NULL)
2190 idDelete((ideal*)&U);
2191 return M;
2192}
#define pSeries(n, p, u, w)
Definition polys.h:372

◆ idSort()

intvec * idSort ( ideal id,
BOOLEAN nolex = TRUE )
inlinestatic

Definition at line 188 of file ideals.h.

189{
190 return id_Sort(id, nolex, currRing);
191}
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

◆ idSyzygies()

ideal idSyzygies ( ideal h1,
tHomog h,
intvec ** w,
BOOLEAN setSyzComp = TRUE,
BOOLEAN setRegularity = FALSE,
int * deg = NULL,
GbVariant a = GbDefault )

Definition at line 834 of file ideals.cc.

836{
837 ideal s_h1;
838 int j, k, length=0,reg;
839 BOOLEAN isMonomial=TRUE;
840 int ii, idElemens_h1;
841
842 assume(h1 != NULL);
843
844 idElemens_h1=IDELEMS(h1);
845#ifdef PDEBUG
846 for(ii=0;ii<idElemens_h1 /*IDELEMS(h1)*/;ii++) pTest(h1->m[ii]);
847#endif
848 if (idIs0(h1))
849 {
850 ideal result=idFreeModule(idElemens_h1/*IDELEMS(h1)*/);
851 return result;
852 }
853 int slength=(int)id_RankFreeModule(h1,currRing);
854 k=si_max(1,slength /*id_RankFreeModule(h1)*/);
855
856 assume(currRing != NULL);
857 ring orig_ring=currRing;
858 ring syz_ring=rAssure_SyzComp(orig_ring,TRUE);
859 if (setSyzComp) rSetSyzComp(k,syz_ring);
860
861 if (orig_ring != syz_ring)
862 {
863 rChangeCurrRing(syz_ring);
864 s_h1=idrCopyR_NoSort(h1,orig_ring,syz_ring);
865 }
866 else
867 {
868 s_h1 = h1;
869 }
870
871 idTest(s_h1);
872
873 BITSET save_opt;
874 SI_SAVE_OPT1(save_opt);
876
877 ideal s_h3=idPrepare(s_h1,NULL,h,k,w,alg); // main (syz) GB computation
878
879 SI_RESTORE_OPT1(save_opt);
880
881 if (orig_ring != syz_ring)
882 {
883 idDelete(&s_h1);
884 for (j=0; j<IDELEMS(s_h3); j++)
885 {
886 if (s_h3->m[j] != NULL)
887 {
888 if (p_MinComp(s_h3->m[j],syz_ring) > k)
889 p_Shift(&s_h3->m[j], -k,syz_ring);
890 else
891 p_Delete(&s_h3->m[j],syz_ring);
892 }
893 }
894 idSkipZeroes(s_h3);
895 s_h3->rank -= k;
896 rChangeCurrRing(orig_ring);
897 s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
898 rDelete(syz_ring);
899 #ifdef HAVE_PLURAL
900 if (rIsPluralRing(orig_ring))
901 {
902 id_DelMultiples(s_h3,orig_ring);
903 idSkipZeroes(s_h3);
904 }
905 #endif
906 idTest(s_h3);
907 return s_h3;
908 }
909
910 ideal e = idInit(IDELEMS(s_h3), s_h3->rank);
911
912 for (j=IDELEMS(s_h3)-1; j>=0; j--)
913 {
914 if (s_h3->m[j] != NULL)
915 {
916 if (p_MinComp(s_h3->m[j],syz_ring) <= k)
917 {
918 e->m[j] = s_h3->m[j];
919 isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL);
920 p_Delete(&pNext(s_h3->m[j]),syz_ring);
921 s_h3->m[j] = NULL;
922 }
923 }
924 }
925
926 idSkipZeroes(s_h3);
927 idSkipZeroes(e);
928
929 if ((deg != NULL)
930 && (!isMonomial)
932 && (setRegularity)
933 && (h==isHomog)
936 )
937 {
938 assume(orig_ring==syz_ring);
939 ring dp_C_ring = rAssure_dp_C(syz_ring); // will do rChangeCurrRing later
940 if (dp_C_ring != syz_ring)
941 {
942 rChangeCurrRing(dp_C_ring);
943 e = idrMoveR_NoSort(e, syz_ring, dp_C_ring);
944 }
946 intvec * dummy = syBetti(res,length,&reg, *w);
947 *deg = reg+2;
948 delete dummy;
949 for (j=0;j<length;j++)
950 {
951 if (res[j]!=NULL) idDelete(&(res[j]));
952 }
953 omFreeSize((ADDRESS)res,length*sizeof(ideal));
954 idDelete(&e);
955 if (dp_C_ring != orig_ring)
956 {
957 rChangeCurrRing(orig_ring);
958 rDelete(dp_C_ring);
959 }
960 }
961 else
962 {
963 idDelete(&e);
964 }
965 assume(orig_ring==currRing);
966 idTest(s_h3);
967 if (currRing->qideal != NULL)
968 {
969 ideal ts_h3=kStd2(s_h3,currRing->qideal,h,w,(bigintmat*)NULL);
970 idDelete(&s_h3);
971 s_h3 = ts_h3;
972 }
973 return s_h3;
974}
ideal * resolvente
Definition ideals.h:18
#define TEST_OPT_NOTREGULARITY
Definition options.h:122
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:315
#define pTest(p)
Definition polys.h:415
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition ring.cc:4527
ring rAssure_dp_C(const ring r)
Definition ring.cc:5119
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
@ isHomog
Definition structs.h:33
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
Definition syz.cc:787
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition syz0.cc:855

◆ idTestHomModule()

BOOLEAN idTestHomModule ( ideal m,
ideal Q,
intvec * w )

Definition at line 2125 of file ideals.cc.

2126{
2127 if ((Q!=NULL) && (!idHomIdeal(Q,NULL))) { PrintS(" Q not hom\n"); return FALSE;}
2128 if (idIs0(m)) return TRUE;
2129
2130 int cmax=-1;
2131 int i;
2132 poly p=NULL;
2133 int length=IDELEMS(m);
2134 polyset P=m->m;
2135 for (i=length-1;i>=0;i--)
2136 {
2137 p=P[i];
2138 if (p!=NULL) cmax=si_max(cmax,(int)pMaxComp(p)+1);
2139 }
2140 if (w != NULL)
2141 if (w->length()+1 < cmax)
2142 {
2143 // Print("length: %d - %d \n", w->length(),cmax);
2144 return FALSE;
2145 }
2146
2147 if(w!=NULL)
2149
2150 for (i=length-1;i>=0;i--)
2151 {
2152 p=P[i];
2153 if (p!=NULL)
2154 {
2155 int d=currRing->pFDeg(p,currRing);
2156 loop
2157 {
2158 pIter(p);
2159 if (p==NULL) break;
2160 if (d!=currRing->pFDeg(p,currRing))
2161 {
2162 //pWrite(q); wrp(p); Print(" -> %d - %d\n",d,pFDeg(p,currRing));
2163 if(w!=NULL)
2165 return FALSE;
2166 }
2167 }
2168 }
2169 }
2170
2171 if(w!=NULL)
2173
2174 return TRUE;
2175}
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3798
#define pMaxComp(p)
Definition polys.h:300
poly * polyset
Definition polys.h:260

◆ idVec2Ideal()

ideal idVec2Ideal ( poly vec)
inlinestatic

Definition at line 173 of file ideals.h.

174{
175 return id_Vec2Ideal(vec, currRing);
176}
fq_nmod_poly_t * vec
Definition facHensel.cc:108
ideal id_Vec2Ideal(poly vec, const ring R)

◆ syGetAlgorithm()

GbVariant syGetAlgorithm ( char * n,
const ring r,
const ideal M )

Definition at line 3701 of file ideals.cc.

3702{
3703 GbVariant alg=GbDefault;
3704 if (strcmp(n,"default")==0) alg=GbDefault;
3705 else if (strcmp(n,"slimgb")==0) alg=GbSlimgb;
3706 else if (strcmp(n,"std")==0) alg=GbStd;
3707 else if (strcmp(n,"sba")==0) alg=GbSba;
3708 else if (strcmp(n,"singmatic")==0) alg=GbSingmatic;
3709 else if (strcmp(n,"groebner")==0) alg=GbGroebner;
3710 else if (strcmp(n,"modstd")==0) alg=GbModstd;
3711 else if (strcmp(n,"ffmod")==0) alg=GbFfmod;
3712 else if (strcmp(n,"nfmod")==0) alg=GbNfmod;
3713 else if (strcmp(n,"std:sat")==0) alg=GbStdSat;
3714 else Warn(">>%s<< is an unknown algorithm",n);
3715
3716 if (alg==GbSlimgb) // test conditions for slimgb
3717 {
3718 if(rHasGlobalOrdering(r)
3719 &&(!rIsNCRing(r))
3720 &&(r->qideal==NULL)
3721 &&(!rField_is_Ring(r)))
3722 {
3723 return GbSlimgb;
3724 }
3725 if (TEST_OPT_PROT)
3726 WarnS("requires: coef:field, commutative, global ordering, not qring");
3727 }
3728 else if (alg==GbSba) // cond. for sba
3729 {
3730 if(rField_is_Domain(r)
3731 &&(!rIsNCRing(r))
3732 &&(rHasGlobalOrdering(r)))
3733 {
3734 return GbSba;
3735 }
3736 if (TEST_OPT_PROT)
3737 WarnS("requires: coef:domain, commutative, global ordering");
3738 }
3739 else if (alg==GbGroebner) // cond. for groebner
3740 {
3741 return GbGroebner;
3742 }
3743 else if(alg==GbModstd) // cond for modstd: Q or Q(a)
3744 {
3745 if(ggetid("modStd")==NULL)
3746 {
3747 WarnS(">>modStd<< not found");
3748 }
3749 else if(rField_is_Q(r)
3750 &&(!rIsNCRing(r))
3751 &&(rHasGlobalOrdering(r)))
3752 {
3753 return GbModstd;
3754 }
3755 if (TEST_OPT_PROT)
3756 WarnS("requires: coef:QQ, commutative, global ordering");
3757 }
3758 else if(alg==GbStdSat) // cond for std:sat: 2 blocks of variables
3759 {
3760 if(ggetid("satstd")==NULL)
3761 {
3762 WarnS(">>satstd<< not found");
3763 }
3764 else
3765 {
3766 return GbStdSat;
3767 }
3768 }
3769
3770 return GbStd; // no conditions for std
3771}
#define Warn
Definition emacs.cc:77
GbVariant
Definition ideals.h:119
idhdl ggetid(const char *n)
Definition ipid.cc:558
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:517