My Project
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions
ideals.h File Reference
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "kernel/structs.h"

Go to the source code of this file.

Macros

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

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.) More...
 
void idDelEquals (ideal id)
 
ideal id_Copy (ideal h1, const ring r)
 copy an ideal More...
 
ideal idCopy (ideal A)
 
ideal idAdd (ideal h1, ideal h2)
 h1 + h2 More...
 
BOOLEAN idInsertPoly (ideal h1, poly h2)
 insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted More...
 
BOOLEAN idInsertPolyOnPos (ideal I, poly p, int pos)
 insert p into I on position pos More...
 
BOOLEAN 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 More...
 
BOOLEAN idIs0 (ideal h)
 returns true if h is the zero ideal More...
 
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)
 
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 More...
 
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 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) More...
 
ideal idMinEmbedding (ideal arg, BOOLEAN inPlace=FALSE, intvec **w=NULL)
 
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)
 
GbVariant syGetAlgorithm (char *n, const ring r, const ideal M)
 

Macro Definition Documentation

◆ idDelete

#define idDelete (   H)    id_Delete((H),currRing)

delete an ideal

Definition at line 29 of file ideals.h.

◆ idIsConstant

#define idIsConstant (   I)    id_IsConstant(I,currRing)

Definition at line 40 of file ideals.h.

◆ idMaxIdeal

#define idMaxIdeal (   D)    id_MaxIdeal(D,currRing)

initialise the maximal ideal (at 0)

Definition at line 33 of file ideals.h.

◆ idPosConstant

#define idPosConstant (   I)    id_PosConstant(I,currRing)

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)    id_Print(id, currRing, currRing)

Definition at line 46 of file ideals.h.

◆ idSimpleAdd

#define idSimpleAdd (   A,
  B 
)    id_SimpleAdd(A,B,currRing)

Definition at line 42 of file ideals.h.

◆ idTest

#define idTest (   id)    id_Test(id, currRing)

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};
@ 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 1106 of file simpleideals.cc.

1107{
1108 int i;
1109 int64 result;
1110
1111 if (r==0) return 1;
1112 if (n-r<r) return binom(n,n-r);
1113 result = n-r+1;
1114 for (i=2;i<=r;i++)
1115 {
1116 result *= n-r+i;
1117 result /= i;
1118 }
1119 if (result>MAX_INT_VAL)
1120 {
1121 WarnS("overflow in binomials");
1122 result=0;
1123 }
1124 return (int)result;
1125}
long int64
Definition: auxiliary.h:68
int i
Definition: cfEzgcd.cc:132
#define WarnS
Definition: emacs.cc:78
return result
Definition: facAbsBiFact.cc:75
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 499 of file simpleideals.cc.

500{
501 id_Test(h1, r);
502
503 ideal h2 = idInit(IDELEMS(h1), h1->rank);
504 for (int i=IDELEMS(h1)-1; i>=0; i--)
505 h2->m[i] = p_Copy(h1->m[i],r);
506 return h2;
507}
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define IDELEMS(i)
Definition: simpleideals.h:23
#define id_Test(A, lR)
Definition: simpleideals.h:87

◆ id_Farey()

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

Definition at line 2848 of file ideals.cc.

2849{
2850 int cnt=IDELEMS(x)*x->nrows;
2851 ideal result=idInit(cnt,x->rank);
2852 result->nrows=x->nrows; // for lifting matrices
2853 result->ncols=x->ncols; // for lifting matrices
2854
2855 int i;
2856 for(i=cnt-1;i>=0;i--)
2857 {
2858 result->m[i]=p_Farey(x->m[i],N,r);
2859 }
2860 return result;
2861}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
Variable x
Definition: cfModGcd.cc:4082
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 2745 of file ideals.cc.

2746{
2747 ideal I=idInit(2,1); I->m[0]=f; I->m[1]=g;
2748 intvec *w = NULL;
2749
2750 ring save_r = currRing;
2751 rChangeCurrRing(r);
2752 ideal S=idSyzygies(I,testHomog,&w);
2753 rChangeCurrRing(save_r);
2754
2755 if (w!=NULL) delete w;
2756 poly gg=p_TakeOutComp(&(S->m[0]), 2, r);
2757 id_Delete(&S, r);
2758 poly gcd_p=singclap_pdivide(f,gg, r);
2759 p_Delete(&gg, r);
2760
2761 return gcd_p;
2762}
g
Definition: cfModGcd.cc:4090
FILE * f
Definition: checklibs.c:9
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:624
Definition: intvec.h:23
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:830
void p_TakeOutComp(poly *p, long comp, poly *q, int *lq, const ring r)
Definition: p_polys.cc:3496
#define NULL
Definition: omList.c:12
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
void rChangeCurrRing(ring r)
Definition: polys.cc:15
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
@ testHomog
Definition: structs.h:38

◆ id_Satstd()

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

Definition at line 3108 of file ideals.cc.

3109{
3110 ring save=currRing;
3111 if (currRing!=r) rChangeCurrRing(r);
3112 idSkipZeroes(J);
3113 id_satstdSaturatingVariables=(int*)omAlloc0((1+rVar(currRing))*sizeof(int));
3114 int k=IDELEMS(J);
3115 if (k>1)
3116 {
3117 for (int i=0; i<k; i++)
3118 {
3119 poly x = J->m[i];
3120 int li = p_Var(x,r);
3121 if (li>0)
3123 else
3124 {
3125 if (currRing!=save) rChangeCurrRing(save);
3126 WerrorS("ideal generators must be variables");
3127 return NULL;
3128 }
3129 }
3130 }
3131 else
3132 {
3133 poly x = J->m[0];
3134 for (int i=1; i<=r->N; i++)
3135 {
3136 int li = p_GetExp(x,i,r);
3137 if (li==1)
3139 else if (li>1)
3140 {
3141 if (currRing!=save) rChangeCurrRing(save);
3142 Werror("exponent(x(%d)^%d) must be 0 or 1",i,li);
3143 return NULL;
3144 }
3145 }
3146 }
3147 ideal res=kStd(I,r->qideal,testHomog,NULL,NULL,0,0,NULL,id_sat_vars_sp);
3150 if (currRing!=save) rChangeCurrRing(save);
3151 return res;
3152}
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:2993
static BOOLEAN id_sat_vars_sp(kStrategy strat)
Definition: ideals.cc:2995
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2447
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int p_Var(poly m, const ring r)
Definition: p_polys.cc:4656
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:467
void Werror(const char *fmt,...)
Definition: reporter.cc:189
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ id_TensorModuleMult()

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

Definition at line 1992 of file simpleideals.cc.

1993{
1994// #ifdef DEBU
1995// WarnS("tensorModuleMult!!!!");
1996
1997 assume(m > 0);
1998 assume(M != NULL);
1999
2000 const int n = rRing->N;
2001
2002 assume(M->rank <= m * n);
2003
2004 const int k = IDELEMS(M);
2005
2006 ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
2007
2008 for( int i = 0; i < k; i++ ) // for every w \in M
2009 {
2010 poly pTempSum = NULL;
2011
2012 poly w = M->m[i];
2013
2014 while(w != NULL) // for each term of w...
2015 {
2016 poly h = p_Head(w, rRing);
2017
2018 const int gen = __p_GetComp(h, rRing); // 1 ...
2019
2020 assume(gen > 0);
2021 assume(gen <= n*m);
2022
2023 // TODO: write a formula with %, / instead of while!
2024 /*
2025 int c = gen;
2026 int v = 1;
2027 while(c > m)
2028 {
2029 c -= m;
2030 v++;
2031 }
2032 */
2033
2034 int cc = gen % m;
2035 if( cc == 0) cc = m;
2036 int vv = 1 + (gen - cc) / m;
2037
2038// assume( cc == c );
2039// assume( vv == v );
2040
2041 // 1<= c <= m
2042 assume( cc > 0 );
2043 assume( cc <= m );
2044
2045 assume( vv > 0 );
2046 assume( vv <= n );
2047
2048 assume( (cc + (vv-1)*m) == gen );
2049
2050 p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
2051 p_SetComp(h, cc, rRing);
2052
2053 p_Setm(h, rRing); // addjust degree after the previous steps!
2054
2055 pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
2056
2057 pIter(w);
2058 }
2059
2060 idTemp->m[i] = pTempSum;
2061 }
2062
2063 // simplify idTemp???
2064
2065 ideal idResult = id_Transp(idTemp, rRing);
2066
2067 id_Delete(&idTemp, rRing);
2068
2069 return(idResult);
2070}
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:934
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:245
static long p_IncrExp(poly p, int v, ring r)
Definition: p_polys.h:589
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition: p_polys.h:858
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 2621 of file ideals.cc.

2622{
2623 matrix result;
2624 ideal tempKbase;
2625 poly p,q;
2626 intvec * convert;
2627 int i=IDELEMS(kbase),j=IDELEMS(arg),k,pos;
2628#if 0
2629 while ((i>0) && (kbase->m[i-1]==NULL)) i--;
2630 if (idIs0(arg))
2631 return mpNew(i,1);
2632 while ((j>0) && (arg->m[j-1]==NULL)) j--;
2633 result = mpNew(i,j);
2634#else
2635 result = mpNew(i, j);
2636 while ((j>0) && (arg->m[j-1]==NULL)) j--;
2637#endif
2638
2639 tempKbase = idCreateSpecialKbase(kbase,&convert);
2640 for (k=0;k<j;k++)
2641 {
2642 p = arg->m[k];
2643 while (p!=NULL)
2644 {
2645 q = idDecompose(p,how,tempKbase,&pos);
2646 if (pos>=0)
2647 {
2648 MATELEM(result,(*convert)[pos],k+1) =
2649 pAdd(MATELEM(result,(*convert)[pos],k+1),q);
2650 }
2651 else
2652 p_Delete(&q,currRing);
2653 pIter(p);
2654 }
2655 }
2656 idDelete(&tempKbase);
2657 return result;
2658}
int p
Definition: cfModGcd.cc:4078
int j
Definition: facHensel.cc:110
ideal idCreateSpecialKbase(ideal kBase, intvec **convert)
Definition: ideals.cc:2535
poly idDecompose(poly monom, poly how, ideal kbase, int *pos)
Definition: ideals.cc:2589
#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
#define pAdd(p, q)
Definition: polys.h:203

◆ idCopy()

ideal idCopy ( ideal  A)
inline

Definition at line 60 of file ideals.h.

61{
62 return id_Copy(A, currRing);
63}
ideal id_Copy(ideal h1, const ring r)
copy an ideal
#define A
Definition: sirandom.c:24

◆ idCopyFirstK()

static 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 2956 of file ideals.cc.

2957{
2958 int idsize = IDELEMS(id);
2959 poly_sort *id_sort = (poly_sort *)omAlloc0(idsize*sizeof(poly_sort));
2960 for (int i = 0; i < idsize; i++)
2961 {
2962 id_sort[i].p = id->m[i];
2963 id_sort[i].index = i;
2964 }
2965 idSort_qsort(id_sort, idsize);
2966 int index, index_i, index_j;
2967 int i = 0;
2968 for (int j = 1; j < idsize; j++)
2969 {
2970 if (id_sort[i].p != NULL && pEqualPolys(id_sort[i].p, id_sort[j].p))
2971 {
2972 index_i = id_sort[i].index;
2973 index_j = id_sort[j].index;
2974 if (index_j > index_i)
2975 {
2976 index = index_j;
2977 }
2978 else
2979 {
2980 index = index_i;
2981 i = j;
2982 }
2983 pDelete(&id->m[index]);
2984 }
2985 else
2986 {
2987 i = j;
2988 }
2989 }
2990 omFreeSize((ADDRESS)(id_sort), idsize*sizeof(poly_sort));
2991}
void * ADDRESS
Definition: auxiliary.h:119
int index
Definition: ideals.cc:2939
poly p
Definition: ideals.cc:2938
void idSort_qsort(poly_sort *id_sort, int idsize)
Definition: ideals.cc:2947
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
#define pDelete(p_ptr)
Definition: polys.h:186
#define pEqualPolys(p1, p2)
Definition: polys.h:399

◆ idDiff()

matrix idDiff ( matrix  i,
int  k 
)

Definition at line 2138 of file ideals.cc.

2139{
2140 int e=MATCOLS(i)*MATROWS(i);
2142 r->rank=i->rank;
2143 int j;
2144 for(j=0; j<e; j++)
2145 {
2146 r->m[j]=pDiff(i->m[j],k);
2147 }
2148 return r;
2149}
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:296

◆ idDiffOp()

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

Definition at line 2151 of file ideals.cc.

2152{
2153 matrix r=mpNew(IDELEMS(I),IDELEMS(J));
2154 int i,j;
2155 for(i=0; i<IDELEMS(I); i++)
2156 {
2157 for(j=0; j<IDELEMS(J); j++)
2158 {
2159 MATELEM(r,i+1,j+1)=pDiffOp(I->m[i],J->m[j],multiply);
2160 }
2161 }
2162 return r;
2163}
#define pDiffOp(a, b, m)
Definition: polys.h:297

◆ idElimination()

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

Definition at line 1593 of file ideals.cc.

1594{
1595 int i,j=0,k,l;
1596 ideal h,hh, h3;
1597 rRingOrder_t *ord;
1598 int *block0,*block1;
1599 int ordersize=2;
1600 int **wv;
1601 tHomog hom;
1602 intvec * w;
1603 ring tmpR;
1604 ring origR = currRing;
1605
1606 if (delVar==NULL)
1607 {
1608 return idCopy(h1);
1609 }
1610 if ((currRing->qideal!=NULL) && rIsPluralRing(origR))
1611 {
1612 WerrorS("cannot eliminate in a qring");
1613 return NULL;
1614 }
1615 if (idIs0(h1)) return idInit(1,h1->rank);
1616#ifdef HAVE_PLURAL
1617 if (rIsPluralRing(origR))
1618 /* in the NC case, we have to check the admissibility of */
1619 /* the subalgebra to be intersected with */
1620 {
1621 if ((ncRingType(origR) != nc_skew) && (ncRingType(origR) != nc_exterior)) /* in (quasi)-commutative algebras every subalgebra is admissible */
1622 {
1623 if (nc_CheckSubalgebra(delVar,origR))
1624 {
1625 WerrorS("no elimination is possible: subalgebra is not admissible");
1626 return NULL;
1627 }
1628 }
1629 }
1630#endif
1631 hom=(tHomog)idHomModule(h1,NULL,&w); //sets w to weight vector or NULL
1632 h3=idInit(16,h1->rank);
1633 ordersize=rBlocks(origR)+1;
1634#if 0
1635 if (rIsPluralRing(origR)) // we have too keep the odering: it may be needed
1636 // for G-algebra
1637 {
1638 for (k=0;k<ordersize-1; k++)
1639 {
1640 block0[k+1] = origR->block0[k];
1641 block1[k+1] = origR->block1[k];
1642 ord[k+1] = origR->order[k];
1643 if (origR->wvhdl[k]!=NULL) wv[k+1] = (int*) omMemDup(origR->wvhdl[k]);
1644 }
1645 }
1646 else
1647 {
1648 block0[1] = 1;
1649 block1[1] = (currRing->N);
1650 if (origR->OrdSgn==1) ord[1] = ringorder_wp;
1651 else ord[1] = ringorder_ws;
1652 wv[1]=(int*)omAlloc0((currRing->N)*sizeof(int));
1653 double wNsqr = (double)2.0 / (double)(currRing->N);
1655 int *x= (int * )omAlloc(2 * ((currRing->N) + 1) * sizeof(int));
1656 int sl=IDELEMS(h1) - 1;
1657 wCall(h1->m, sl, x, wNsqr);
1658 for (sl = (currRing->N); sl!=0; sl--)
1659 wv[1][sl-1] = x[sl + (currRing->N) + 1];
1660 omFreeSize((ADDRESS)x, 2 * ((currRing->N) + 1) * sizeof(int));
1661
1662 ord[2]=ringorder_C;
1663 ord[3]=0;
1664 }
1665#else
1666#endif
1667 if ((hom==TRUE) && (origR->OrdSgn==1) && (!rIsPluralRing(origR)))
1668 {
1669 #if 1
1670 // we change to an ordering:
1671 // aa(1,1,1,...,0,0,0),wp(...),C
1672 // this seems to be better than version 2 below,
1673 // according to Tst/../elimiate_[3568].tat (- 17 %)
1674 ord=(rRingOrder_t*)omAlloc0(4*sizeof(rRingOrder_t));
1675 block0=(int*)omAlloc0(4*sizeof(int));
1676 block1=(int*)omAlloc0(4*sizeof(int));
1677 wv=(int**) omAlloc0(4*sizeof(int**));
1678 block0[0] = block0[1] = 1;
1679 block1[0] = block1[1] = rVar(origR);
1680 wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1681 // use this special ordering: like ringorder_a, except that pFDeg, pWeights
1682 // ignore it
1683 ord[0] = ringorder_aa;
1684 for (j=0;j<rVar(origR);j++)
1685 if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
1686 BOOLEAN wp=FALSE;
1687 for (j=0;j<rVar(origR);j++)
1688 if (p_Weight(j+1,origR)!=1) { wp=TRUE;break; }
1689 if (wp)
1690 {
1691 wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1692 for (j=0;j<rVar(origR);j++)
1693 wv[1][j]=p_Weight(j+1,origR);
1694 ord[1] = ringorder_wp;
1695 }
1696 else
1697 ord[1] = ringorder_dp;
1698 #else
1699 // we change to an ordering:
1700 // a(w1,...wn),wp(1,...0.....),C
1701 ord=(int*)omAlloc0(4*sizeof(int));
1702 block0=(int*)omAlloc0(4*sizeof(int));
1703 block1=(int*)omAlloc0(4*sizeof(int));
1704 wv=(int**) omAlloc0(4*sizeof(int**));
1705 block0[0] = block0[1] = 1;
1706 block1[0] = block1[1] = rVar(origR);
1707 wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1708 wv[1]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1709 ord[0] = ringorder_a;
1710 for (j=0;j<rVar(origR);j++)
1711 wv[0][j]=pWeight(j+1,origR);
1712 ord[1] = ringorder_wp;
1713 for (j=0;j<rVar(origR);j++)
1714 if (pGetExp(delVar,j+1)!=0) wv[1][j]=1;
1715 #endif
1716 ord[2] = ringorder_C;
1717 ord[3] = (rRingOrder_t)0;
1718 }
1719 else
1720 {
1721 // we change to an ordering:
1722 // aa(....),orig_ordering
1723 ord=(rRingOrder_t*)omAlloc0(ordersize*sizeof(rRingOrder_t));
1724 block0=(int*)omAlloc0(ordersize*sizeof(int));
1725 block1=(int*)omAlloc0(ordersize*sizeof(int));
1726 wv=(int**) omAlloc0(ordersize*sizeof(int**));
1727 for (k=0;k<ordersize-1; k++)
1728 {
1729 block0[k+1] = origR->block0[k];
1730 block1[k+1] = origR->block1[k];
1731 ord[k+1] = origR->order[k];
1732 if (origR->wvhdl[k]!=NULL)
1733 #ifdef HAVE_OMALLOC
1734 wv[k+1] = (int*) omMemDup(origR->wvhdl[k]);
1735 #else
1736 {
1737 int l=(origR->block1[k]-origR->block0[k]+1)*sizeof(int);
1738 if (origR->order[k]==ringorder_a64) l*=2;
1739 wv[k+1]=(int*)omalloc(l);
1740 memcpy(wv[k+1],origR->wvhdl[k],l);
1741 }
1742 #endif
1743 }
1744 block0[0] = 1;
1745 block1[0] = rVar(origR);
1746 wv[0]=(int*)omAlloc0((rVar(origR) + 1)*sizeof(int));
1747 for (j=0;j<rVar(origR);j++)
1748 if (pGetExp(delVar,j+1)!=0) wv[0][j]=1;
1749 // use this special ordering: like ringorder_a, except that pFDeg, pWeights
1750 // ignore it
1751 ord[0] = ringorder_aa;
1752 }
1753 // fill in tmp ring to get back the data later on
1754 tmpR = rCopy0(origR,FALSE,FALSE); // qring==NULL
1755 //rUnComplete(tmpR);
1756 tmpR->p_Procs=NULL;
1757 tmpR->order = ord;
1758 tmpR->block0 = block0;
1759 tmpR->block1 = block1;
1760 tmpR->wvhdl = wv;
1761 rComplete(tmpR, 1);
1762
1763#ifdef HAVE_PLURAL
1764 /* update nc structure on tmpR */
1765 if (rIsPluralRing(origR))
1766 {
1767 if ( nc_rComplete(origR, tmpR, false) ) // no quotient ideal!
1768 {
1769 WerrorS("no elimination is possible: ordering condition is violated");
1770 // cleanup
1771 rDelete(tmpR);
1772 if (w!=NULL)
1773 delete w;
1774 return NULL;
1775 }
1776 }
1777#endif
1778 // change into the new ring
1779 //pChangeRing((currRing->N),currRing->OrdSgn,ord,block0,block1,wv);
1780 rChangeCurrRing(tmpR);
1781
1782 //h = idInit(IDELEMS(h1),h1->rank);
1783 // fetch data from the old ring
1784 //for (k=0;k<IDELEMS(h1);k++) h->m[k] = prCopyR( h1->m[k], origR);
1785 h=idrCopyR(h1,origR,currRing);
1786 if (origR->qideal!=NULL)
1787 {
1788 WarnS("eliminate in q-ring: experimental");
1789 ideal q=idrCopyR(origR->qideal,origR,currRing);
1790 ideal s=idSimpleAdd(h,q);
1791 idDelete(&h);
1792 idDelete(&q);
1793 h=s;
1794 }
1795 // compute GB
1796 if ((alg!=GbDefault)
1797 && (alg!=GbGroebner)
1798 && (alg!=GbModstd)
1799 && (alg!=GbSlimgb)
1800 && (alg!=GbSba)
1801 && (alg!=GbStd))
1802 {
1803 WarnS("wrong algorithm for GB");
1804 alg=GbDefault;
1805 }
1806 BITSET save2;
1807 SI_SAVE_OPT2(save2);
1809 hh=idGroebner(h,0,alg,hilb);
1810 SI_RESTORE_OPT2(save2);
1811 // go back to the original ring
1812 rChangeCurrRing(origR);
1813 i = IDELEMS(hh)-1;
1814 while ((i >= 0) && (hh->m[i] == NULL)) i--;
1815 j = -1;
1816 // fetch data from temp ring
1817 for (k=0; k<=i; k++)
1818 {
1819 l=(currRing->N);
1820 while ((l>0) && (p_GetExp( hh->m[k],l,tmpR)*pGetExp(delVar,l)==0)) l--;
1821 if (l==0)
1822 {
1823 j++;
1824 if (j >= IDELEMS(h3))
1825 {
1826 pEnlargeSet(&(h3->m),IDELEMS(h3),16);
1827 IDELEMS(h3) += 16;
1828 }
1829 h3->m[j] = prMoveR( hh->m[k], tmpR,origR);
1830 hh->m[k] = NULL;
1831 }
1832 }
1833 id_Delete(&hh, tmpR);
1834 idSkipZeroes(h3);
1835 rDelete(tmpR);
1836 if (w!=NULL)
1837 delete w;
1838 return h3;
1839}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int l
Definition: cfEzgcd.cc:100
const CanonicalForm int s
Definition: facAbsFact.cc:51
static ideal idGroebner(ideal temp, int syzComp, GbVariant alg, intvec *hilb=NULL, intvec *w=NULL, tHomog hom=testHomog)
Definition: ideals.cc:201
#define idSimpleAdd(A, B)
Definition: ideals.h:42
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)
Definition: old.gring.cc:2576
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omalloc(size)
Definition: omAllocDecl.h:228
#define omMemDup(s)
Definition: omAllocDecl.h:264
VAR unsigned si_opt_2
Definition: options.c:6
#define SI_SAVE_OPT2(A)
Definition: options.h:22
#define SI_RESTORE_OPT2(A)
Definition: options.h:25
#define TEST_OPT_RETURN_SB
Definition: options.h:113
#define V_IDELIM
Definition: options.h:71
int p_Weight(int i, const ring r)
Definition: p_polys.cc:705
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3696
#define pWeight(i)
Definition: polys.h:280
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition: prCopy.cc:90
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:3450
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5685
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1421
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static int rBlocks(const ring r)
Definition: ring.h:568
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_a
Definition: ring.h:70
@ ringorder_a64
for int64 weights
Definition: ring.h:71
@ ringorder_C
Definition: ring.h:73
@ ringorder_dp
Definition: ring.h:78
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:91
@ ringorder_ws
Definition: ring.h:86
@ ringorder_wp
Definition: ring.h:81
tHomog
Definition: structs.h:35
#define BITSET
Definition: structs.h:16
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 1048 of file simpleideals.cc.

1049{
1050 int i = r-1,j;
1051 while ((i >= 0) && (choise[i] == end))
1052 {
1053 i--;
1054 end--;
1055 }
1056 if (i == -1)
1057 *endch = TRUE;
1058 else
1059 {
1060 choise[i]++;
1061 for (j=i+1; j<r; j++)
1062 {
1063 choise[j] = choise[i]+j-i;
1064 }
1065 *endch = FALSE;
1066 }
1067}

◆ idGetNumberOfChoise()

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

Definition at line 1074 of file simpleideals.cc.

1075{
1076 int * localchoise,i,result=0;
1077 BOOLEAN b=FALSE;
1078
1079 if (d<=1) return 1;
1080 localchoise=(int*)omAlloc((d-1)*sizeof(int));
1081 idInitChoise(d-1,begin,end,&b,localchoise);
1082 while (!b)
1083 {
1084 result++;
1085 i = 0;
1086 while ((i<t) && (localchoise[i]==choise[i])) i++;
1087 if (i>=t)
1088 {
1089 i = t+1;
1090 while ((i<d) && (localchoise[i-1]==choise[i])) i++;
1091 if (i>=d)
1092 {
1093 omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
1094 return result;
1095 }
1096 }
1097 idGetNextChoise(d-1,end,&b,localchoise);
1098 }
1099 omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
1100 return 0;
1101}
CanonicalForm b
Definition: cfModGcd.cc:4103
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()

static 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()

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

1027{
1028 /*returns the first choise of r numbers between beg and end*/
1029 int i;
1030 for (i=0; i<r; i++)
1031 {
1032 choise[i] = 0;
1033 }
1034 if (r <= end-beg+1)
1035 for (i=0; i<r; i++)
1036 {
1037 choise[i] = beg+i;
1038 }
1039 if (r > end-beg+1)
1040 *endch = TRUE;
1041 else
1042 *endch = FALSE;
1043}

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

790{
791 if (h2==NULL) return FALSE;
792 assume (h1 != NULL);
793
794 int j = IDELEMS(h1) - 1;
795
796 while ((j >= 0) && (h1->m[j] == NULL)) j--;
797 j++;
798 if (j==IDELEMS(h1))
799 {
800 pEnlargeSet(&(h1->m),IDELEMS(h1),16);
801 IDELEMS(h1)+=16;
802 }
803 h1->m[j]=h2;
804 return TRUE;
805}

◆ idInsertPolyOnPos()

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

insert p into I on position pos

Definition at line 808 of file simpleideals.cc.

809{
810 if (p==NULL) return FALSE;
811 assume (I != NULL);
812
813 int j = IDELEMS(I) - 1;
814
815 while ((j >= 0) && (I->m[j] == NULL)) j--;
816 j++;
817 if (j==IDELEMS(I))
818 {
819 pEnlargeSet(&(I->m),IDELEMS(I),IDELEMS(I)+1);
820 IDELEMS(I)+=1;
821 }
822 for(j = IDELEMS(I)-1;j>pos;j--)
823 I->m[j] = I->m[j-1];
824 I->m[pos]=p;
825 return TRUE;
826}

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

918{
919 assume (h != NULL); // will fail :(
920// if (h == NULL) return TRUE;
921
922 for( int i = IDELEMS(h)-1; i >= 0; i-- )
923 if(h->m[i] != NULL)
924 return FALSE;
925
926 return TRUE;
927
928}

◆ idIsSubModule()

BOOLEAN idIsSubModule ( ideal  id1,
ideal  id2 
)

Definition at line 2048 of file ideals.cc.

2049{
2050 int i;
2051 poly p;
2052
2053 if (idIs0(id1)) return TRUE;
2054 for (i=0;i<IDELEMS(id1);i++)
2055 {
2056 if (id1->m[i] != NULL)
2057 {
2058 p = kNF(id2,currRing->qideal,id1->m[i]);
2059 if (p != NULL)
2060 {
2062 return FALSE;
2063 }
2064 }
2065 }
2066 return TRUE;
2067}
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3182

◆ idIsZeroDim()

static BOOLEAN idIsZeroDim ( ideal  i)
inlinestatic

Definition at line 176 of file ideals.h.

177{
178 return id_IsZeroDim(i, currRing);
179}
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 2924 of file ideals.cc.

2925{
2926 for (int i = IDELEMS(id)-1; i >= k; i--)
2927 {
2928 if (id->m[i] != NULL) pDelete(&id->m[i]);
2929 }
2930 int kk=k;
2931 if (k==0) kk=1; /* ideals must have at least one element(0)*/
2932 pEnlargeSet(&(id->m), IDELEMS(id), kk-IDELEMS(id));
2933 IDELEMS(id) = kk;
2934}

◆ 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 1105 of file ideals.cc.

1107{
1108 int lsmod =id_RankFreeModule(submod,currRing), j, k;
1109 int comps_to_add=0;
1110 int idelems_mod=IDELEMS(mod);
1111 int idelems_submod=IDELEMS(submod);
1112 poly p;
1113
1114 if (idIs0(submod))
1115 {
1116 if (rest!=NULL)
1117 {
1118 *rest=idInit(1,mod->rank);
1119 }
1120 idLift_setUnit(idelems_submod,unit);
1121 return idInit(1,idelems_mod);
1122 }
1123 if (idIs0(mod)) /* and not idIs0(submod) */
1124 {
1125 if (rest!=NULL)
1126 {
1127 *rest=idCopy(submod);
1128 idLift_setUnit(idelems_submod,unit);
1129 return idInit(1,idelems_mod);
1130 }
1131 else
1132 {
1133 WerrorS("2nd module does not lie in the first");
1134 return NULL;
1135 }
1136 }
1137 if (unit!=NULL)
1138 {
1139 comps_to_add = idelems_submod;
1140 while ((comps_to_add>0) && (submod->m[comps_to_add-1]==NULL))
1141 comps_to_add--;
1142 }
1144 if ((k!=0) && (lsmod==0)) lsmod=1;
1145 k=si_max(k,(int)mod->rank);
1146 if (k<submod->rank) { WarnS("rk(submod) > rk(mod) ?");k=submod->rank; }
1147
1148 ring orig_ring=currRing;
1149 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
1150 rSetSyzComp(k,syz_ring);
1151 rChangeCurrRing(syz_ring);
1152
1153 ideal s_mod, s_temp;
1154 if (orig_ring != syz_ring)
1155 {
1156 s_mod = idrCopyR_NoSort(mod,orig_ring,syz_ring);
1157 s_temp = idrCopyR_NoSort(submod,orig_ring,syz_ring);
1158 }
1159 else
1160 {
1161 s_mod = mod;
1162 s_temp = idCopy(submod);
1163 }
1164 ideal s_h3;
1165 if (isSB)
1166 {
1167 s_h3 = idCopy(s_mod);
1168 idPrepareStd(s_h3, k+comps_to_add);
1169 }
1170 else
1171 {
1172 s_h3 = idPrepare(s_mod,NULL,(tHomog)FALSE,k+comps_to_add,NULL,alg);
1173 }
1174 if (!goodShape)
1175 {
1176 for (j=0;j<IDELEMS(s_h3);j++)
1177 {
1178 if ((s_h3->m[j] != NULL) && (pMinComp(s_h3->m[j]) > k))
1179 p_Delete(&(s_h3->m[j]),currRing);
1180 }
1181 }
1182 idSkipZeroes(s_h3);
1183 if (lsmod==0)
1184 {
1185 id_Shift(s_temp,1,currRing);
1186 }
1187 if (unit!=NULL)
1188 {
1189 for(j = 0;j<comps_to_add;j++)
1190 {
1191 p = s_temp->m[j];
1192 if (p!=NULL)
1193 {
1194 while (pNext(p)!=NULL) pIter(p);
1195 pNext(p) = pOne();
1196 pIter(p);
1197 pSetComp(p,1+j+k);
1198 pSetmComp(p);
1199 p = pNeg(p);
1200 }
1201 }
1202 s_temp->rank += (k+comps_to_add);
1203 }
1204 ideal s_result = kNF(s_h3,currRing->qideal,s_temp,k);
1205 s_result->rank = s_h3->rank;
1206 ideal s_rest = idInit(IDELEMS(s_result),k);
1207 idDelete(&s_h3);
1208 idDelete(&s_temp);
1209
1210 for (j=0;j<IDELEMS(s_result);j++)
1211 {
1212 if (s_result->m[j]!=NULL)
1213 {
1214 if (pGetComp(s_result->m[j])<=k)
1215 {
1216 if (!divide)
1217 {
1218 if (rest==NULL)
1219 {
1220 if (isSB)
1221 {
1222 WarnS("first module not a standardbasis\n"
1223 "// ** or second not a proper submodule");
1224 }
1225 else
1226 WerrorS("2nd module does not lie in the first");
1227 }
1228 idDelete(&s_result);
1229 idDelete(&s_rest);
1230 if(syz_ring!=orig_ring)
1231 {
1232 idDelete(&s_mod);
1233 rChangeCurrRing(orig_ring);
1234 rDelete(syz_ring);
1235 }
1236 if (unit!=NULL)
1237 {
1238 idLift_setUnit(idelems_submod,unit);
1239 }
1240 if (rest!=NULL) *rest=idCopy(submod);
1241 s_result=idInit(idelems_submod,idelems_mod);
1242 return s_result;
1243 }
1244 else
1245 {
1246 p = s_rest->m[j] = s_result->m[j];
1247 while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k)) pIter(p);
1248 s_result->m[j] = pNext(p);
1249 pNext(p) = NULL;
1250 }
1251 }
1252 p_Shift(&(s_result->m[j]),-k,currRing);
1253 pNeg(s_result->m[j]);
1254 }
1255 }
1256 if ((lsmod==0) && (s_rest!=NULL))
1257 {
1258 for (j=IDELEMS(s_rest);j>0;j--)
1259 {
1260 if (s_rest->m[j-1]!=NULL)
1261 {
1262 p_Shift(&(s_rest->m[j-1]),-1,currRing);
1263 }
1264 }
1265 }
1266 if(syz_ring!=orig_ring)
1267 {
1268 idDelete(&s_mod);
1269 rChangeCurrRing(orig_ring);
1270 s_result = idrMoveR_NoSort(s_result, syz_ring, orig_ring);
1271 s_rest = idrMoveR_NoSort(s_rest, syz_ring, orig_ring);
1272 rDelete(syz_ring);
1273 }
1274 if (rest!=NULL)
1275 {
1276 s_rest->rank=mod->rank;
1277 *rest = s_rest;
1278 }
1279 else
1280 idDelete(&s_rest);
1281 if (unit!=NULL)
1282 {
1283 *unit=mpNew(idelems_submod,idelems_submod);
1284 int i;
1285 for(i=0;i<IDELEMS(s_result);i++)
1286 {
1287 poly p=s_result->m[i];
1288 poly q=NULL;
1289 while(p!=NULL)
1290 {
1291 if(pGetComp(p)<=comps_to_add)
1292 {
1293 pSetComp(p,0);
1294 if (q!=NULL)
1295 {
1296 pNext(q)=pNext(p);
1297 }
1298 else
1299 {
1300 pIter(s_result->m[i]);
1301 }
1302 pNext(p)=NULL;
1303 MATELEM(*unit,i+1,i+1)=pAdd(MATELEM(*unit,i+1,i+1),p);
1304 if(q!=NULL) p=pNext(q);
1305 else p=s_result->m[i];
1306 }
1307 else
1308 {
1309 q=p;
1310 pIter(p);
1311 }
1312 }
1313 p_Shift(&s_result->m[i],-comps_to_add,currRing);
1314 }
1315 }
1316 s_result->rank=idelems_mod;
1317 return s_result;
1318}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
CanonicalForm divide(const CanonicalForm &ff, const CanonicalForm &f, const CFList &as)
static void idPrepareStd(ideal s_temp, int k)
Definition: ideals.cc:1041
static void idLift_setUnit(int e_mod, matrix *unit)
Definition: ideals.cc:1082
static ideal idPrepare(ideal h1, ideal h11, tHomog hom, int syzcomp, intvec **w, GbVariant alg)
Definition: ideals.cc:607
#define pNext(p)
Definition: monomials.h:36
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4706
#define pNeg(p)
Definition: polys.h:198
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pSetComp(p, v)
Definition: polys.h:38
#define pSetmComp(p)
TODO:
Definition: polys.h:273
#define pOne()
Definition: polys.h:315
#define pMinComp(p)
Definition: polys.h:300
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:4430
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5086
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 976 of file ideals.cc.

978{
979 int inputIsIdeal=id_RankFreeModule(h1,currRing);
980 long k;
981 intvec *w=NULL;
982
983 idDelete((ideal*)T);
984 BOOLEAN lift3=FALSE;
985 if (S!=NULL) { lift3=TRUE; idDelete(S); }
986 if (idIs0(h1))
987 {
988 *T=mpNew(1,IDELEMS(h1));
989 if (lift3)
990 {
991 *S=idFreeModule(IDELEMS(h1));
992 }
993 return idInit(1,h1->rank);
994 }
995
996 BITSET save2;
997 SI_SAVE_OPT2(save2);
998
999 k=si_max(1,inputIsIdeal);
1000
1001 if ((!lift3)&&(!TEST_OPT_RETURN_SB)) si_opt_2 |=Sy_bit(V_IDLIFT);
1002
1003 ring orig_ring = currRing;
1004 ring syz_ring = rAssure_SyzOrder(orig_ring,TRUE);
1005 rSetSyzComp(k,syz_ring);
1006 rChangeCurrRing(syz_ring);
1007
1008 ideal s_h1;
1009
1010 if (orig_ring != syz_ring)
1011 s_h1 = idrCopyR_NoSort(h1,orig_ring,syz_ring);
1012 else
1013 s_h1 = h1;
1014 ideal s_h11=NULL;
1015 if (h11!=NULL)
1016 {
1017 s_h11=idrCopyR_NoSort(h11,orig_ring,syz_ring);
1018 }
1019
1020
1021 ideal s_h3=idPrepare(s_h1,s_h11,hi,k,&w,alg); // main (syz) GB computation
1022
1023
1024 if (w!=NULL) delete w;
1025 if (syz_ring!=orig_ring)
1026 {
1027 idDelete(&s_h1);
1028 if (s_h11!=NULL) idDelete(&s_h11);
1029 }
1030
1031 if (S!=NULL) (*S)=idInit(IDELEMS(s_h3),IDELEMS(h1));
1032
1033 s_h3=idExtractG_T_S(s_h3,T,S,k,IDELEMS(h1),inputIsIdeal,orig_ring,syz_ring);
1034
1035 if (syz_ring!=orig_ring) rDelete(syz_ring);
1036 s_h3->rank=h1->rank;
1037 SI_RESTORE_OPT2(save2);
1038 return s_h3;
1039}
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:709
ideal idFreeModule(int i)
Definition: ideals.h:111
STATIC_VAR jList * T
Definition: janet.cc:30
#define Sy_bit(x)
Definition: options.h:31
#define V_IDLIFT
Definition: options.h:63

◆ idLiftW()

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

Definition at line 1324 of file ideals.cc.

1325{
1326 long N=0;
1327 int i;
1328 for(i=IDELEMS(Q)-1;i>=0;i--)
1329 if(w==NULL)
1330 N=si_max(N,p_Deg(Q->m[i],currRing));
1331 else
1332 N=si_max(N,p_DegW(Q->m[i],w,currRing));
1333 N+=n;
1334
1335 T=mpNew(IDELEMS(Q),IDELEMS(P));
1336 R=idInit(IDELEMS(P),P->rank);
1337
1338 for(i=IDELEMS(P)-1;i>=0;i--)
1339 {
1340 poly p;
1341 if(w==NULL)
1342 p=ppJet(P->m[i],N);
1343 else
1344 p=ppJetW(P->m[i],N,w);
1345
1346 int j=IDELEMS(Q)-1;
1347 while(p!=NULL)
1348 {
1349 if(pDivisibleBy(Q->m[j],p))
1350 {
1351 poly p0=p_DivideM(pHead(p),pHead(Q->m[j]),currRing);
1352 if(w==NULL)
1353 p=pJet(pSub(p,ppMult_mm(Q->m[j],p0)),N);
1354 else
1355 p=pJetW(pSub(p,ppMult_mm(Q->m[j],p0)),N,w);
1356 pNormalize(p);
1357 if(((w==NULL)&&(p_Deg(p0,currRing)>n))||((w!=NULL)&&(p_DegW(p0,w,currRing)>n)))
1358 p_Delete(&p0,currRing);
1359 else
1360 MATELEM(T,j+1,i+1)=pAdd(MATELEM(T,j+1,i+1),p0);
1361 j=IDELEMS(Q)-1;
1362 }
1363 else
1364 {
1365 if(j==0)
1366 {
1367 poly p0=p;
1368 pIter(p);
1369 pNext(p0)=NULL;
1370 if(((w==NULL)&&(p_Deg(p0,currRing)>n))
1371 ||((w!=NULL)&&(p_DegW(p0,w,currRing)>n)))
1372 p_Delete(&p0,currRing);
1373 else
1374 R->m[i]=pAdd(R->m[i],p0);
1375 j=IDELEMS(Q)-1;
1376 }
1377 else
1378 j--;
1379 }
1380 }
1381 }
1382}
poly p_DivideM(poly a, poly b, const ring r)
Definition: p_polys.cc:1578
long p_DegW(poly p, const int *w, const ring R)
Definition: p_polys.cc:690
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587
#define ppJet(p, m)
Definition: polys.h:366
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
#define ppMult_mm(p, m)
Definition: polys.h:201
#define pJet(p, m)
Definition: polys.h:367
#define pSub(a, b)
Definition: polys.h:287
#define ppJetW(p, m, iv)
Definition: polys.h:368
#define pJetW(p, m, iv)
Definition: polys.h:369
#define pNormalize(p)
Definition: polys.h:317
#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:138
#define R
Definition: sirandom.c:27

◆ idMinBase()

ideal idMinBase ( ideal  h1)

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_std(h1,currRing->qideal,(tHomog)homog,&wth,h2,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 pEnlargeSet(&(e->m),IDELEMS(e),15);
86 IDELEMS(e) = 16;
87 h2 = kStd(h1,currRing->qideal,isNotHomog,NULL);
88 h3 = idMaxIdeal(1);
89 h4=idMult(h2,h3);
90 idDelete(&h3);
91 h3=kStd(h4,currRing->qideal,isNotHomog,NULL);
92 k = IDELEMS(h3);
93 while ((k > 0) && (h3->m[k-1] == NULL)) k--;
94 j = -1;
95 l = IDELEMS(h2);
96 while ((l > 0) && (h2->m[l-1] == NULL)) l--;
97 for (i=l-1; i>=0; i--)
98 {
99 if (h2->m[i] != NULL)
100 {
101 ll = 0;
102 while ((ll < k) && ((h3->m[ll] == NULL)
103 || !pDivisibleBy(h3->m[ll],h2->m[i])))
104 ll++;
105 if (ll >= k)
106 {
107 j++;
108 if (j > IDELEMS(e)-1)
109 {
110 pEnlargeSet(&(e->m),IDELEMS(e),16);
111 IDELEMS(e) += 16;
112 }
113 e->m[j] = pCopy(h2->m[i]);
114 }
115 }
116 }
117 idDelete(&h2);
118 idDelete(&h3);
119 idDelete(&h4);
120 if (currRing->qideal!=NULL)
121 {
122 h3=idInit(1,e->rank);
123 h2=kNF(h3,currRing->qideal,e);
124 idDelete(&h3);
125 idDelete(&e);
126 e=h2;
127 }
128 idSkipZeroes(e);
129 return e;
130}
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_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition: kstd1.cc:3034
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
BOOLEAN rHasGlobalOrdering(const ring r)
Definition: ring.h:759
#define rField_is_Ring(R)
Definition: ring.h:485
@ isNotHomog
Definition: structs.h:36

◆ idMinEmbedding()

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

Definition at line 2687 of file ideals.cc.

2688{
2689 if (idIs0(arg)) return idInit(1,arg->rank);
2690 int i,next_gen,next_comp;
2691 ideal res=arg;
2692 if (!inPlace) res = idCopy(arg);
2694 int *red_comp=(int*)omAlloc((res->rank+1)*sizeof(int));
2695 for (i=res->rank;i>=0;i--) red_comp[i]=i;
2696
2697 int del=0;
2698 loop
2699 {
2700 next_gen = id_ReadOutPivot(res, &next_comp, currRing);
2701 if (next_gen<0) break;
2702 del++;
2703 syGaussForOne(res,next_gen,next_comp,0,IDELEMS(res));
2704 for(i=next_comp+1;i<=arg->rank;i++) red_comp[i]--;
2705 if ((w !=NULL)&&(*w!=NULL))
2706 {
2707 for(i=next_comp;i<(*w)->length();i++) (**w)[i-1]=(**w)[i];
2708 }
2709 }
2710
2711 idDeleteComps(res,red_comp,del);
2713 omFree(red_comp);
2714
2715 if ((w !=NULL)&&(*w!=NULL) &&(del>0))
2716 {
2717 int nl=si_max((*w)->length()-del,1);
2718 intvec *wtmp=new intvec(nl);
2719 for(i=0;i<res->rank;i++) (*wtmp)[i]=(**w)[i];
2720 delete *w;
2721 *w=wtmp;
2722 }
2723 return res;
2724}
static void idDeleteComps(ideal arg, int *red_comp, int del)
Definition: ideals.cc:2660
#define omFree(addr)
Definition: omAllocDecl.h:261
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
#define loop
Definition: structs.h:75
void syGaussForOne(ideal syz, int elnum, int ModComp, int from, int till)
Definition: syz.cc:218

◆ 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 1980 of file ideals.cc.

1981{
1982
1983 const ring origR=currRing;
1984 id_Test((ideal)a, origR);
1985
1986 const int r = a->nrows;
1987 const int c = a->ncols;
1988
1989 if((ar<=0) || (ar>r) || (ar>c))
1990 {
1991 Werror("%d-th minor, matrix is %dx%d",ar,r,c);
1992 return NULL;
1993 }
1994
1995 ideal h = id_Matrix2Module(mp_Copy(a,origR),origR);
1996 long bound = sm_ExpBound(h,c,r,ar,origR);
1997 id_Delete(&h, origR);
1998
1999 ring tmpR = sm_RingChange(origR,bound);
2000
2001 matrix b = mpNew(r,c);
2002
2003 for (int i=r*c-1;i>=0;i--)
2004 if (a->m[i] != NULL)
2005 b->m[i] = prCopyR(a->m[i],origR,tmpR);
2006
2007 id_Test( (ideal)b, tmpR);
2008
2009 if (R!=NULL)
2010 {
2011 R = idrCopyR(R,origR,tmpR); // TODO: overwrites R? memory leak?
2012 //if (ar>1) // otherwise done in mpMinorToResult
2013 //{
2014 // matrix bb=(matrix)kNF(R,currRing->qideal,(ideal)b);
2015 // bb->rank=b->rank; bb->nrows=b->nrows; bb->ncols=b->ncols;
2016 // idDelete((ideal*)&b); b=bb;
2017 //}
2018 id_Test( R, tmpR);
2019 }
2020
2021 int size=binom(r,ar)*binom(c,ar);
2022 ideal result = idInit(size,1);
2023
2024 int elems = 0;
2025
2026 if(ar>1)
2027 mp_RecMin(ar-1,result,elems,b,r,c,NULL,R,tmpR);
2028 else
2029 mp_MinorToResult(result,elems,b,r,c,R,tmpR);
2030
2031 id_Test( (ideal)b, tmpR);
2032
2033 id_Delete((ideal *)&b, tmpR);
2034
2035 if (R!=NULL) id_Delete(&R,tmpR);
2036
2037 rChangeCurrRing(origR);
2038 result = idrMoveR(result,tmpR,origR);
2039 sm_KillModifiedRing(tmpR);
2040 idTest(result);
2041 return result;
2042}
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)
#define idTest(id)
Definition: ideals.h:47
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:1500
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:1596
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
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 2414 of file ideals.cc.

2415{
2416#ifdef HAVE_SHIFTBBA
2417 if (rIsLPRing(currRing))
2418 return idModuloLP(h2,h1,hom,w,T,alg);
2419#endif
2420 intvec *wtmp=NULL;
2421 if (T!=NULL) idDelete((ideal*)T);
2422
2423 int i,flength=0,slength,length;
2424
2425 if (idIs0(h2))
2426 return idFreeModule(si_max(1,h2->ncols));
2427 if (!idIs0(h1))
2428 flength = id_RankFreeModule(h1,currRing);
2429 slength = id_RankFreeModule(h2,currRing);
2430 length = si_max(flength,slength);
2431 BOOLEAN inputIsIdeal=FALSE;
2432 if (length==0)
2433 {
2434 length = 1;
2435 inputIsIdeal=TRUE;
2436 }
2437 if ((w!=NULL)&&((*w)!=NULL))
2438 {
2439 //Print("input weights:");(*w)->show(1);PrintLn();
2440 int d;
2441 int k;
2442 wtmp=new intvec(length+IDELEMS(h2));
2443 for (i=0;i<length;i++)
2444 ((*wtmp)[i])=(**w)[i];
2445 for (i=0;i<IDELEMS(h2);i++)
2446 {
2447 poly p=h2->m[i];
2448 if (p!=NULL)
2449 {
2450 d = p_Deg(p,currRing);
2451 k= pGetComp(p);
2452 if (slength>0) k--;
2453 d +=((**w)[k]);
2454 ((*wtmp)[i+length]) = d;
2455 }
2456 }
2457 //Print("weights:");wtmp->show(1);PrintLn();
2458 }
2459 ideal s_temp1;
2460 ring orig_ring=currRing;
2461 ring syz_ring=rAssure_SyzOrder(orig_ring, TRUE);
2462 rSetSyzComp(length,syz_ring);
2463 {
2464 rChangeCurrRing(syz_ring);
2465 ideal s1,s2;
2466
2467 if (syz_ring != orig_ring)
2468 {
2469 s1 = idrCopyR_NoSort(h1, orig_ring, syz_ring);
2470 s2 = idrCopyR_NoSort(h2, orig_ring, syz_ring);
2471 }
2472 else
2473 {
2474 s1=idCopy(h1);
2475 s2=idCopy(h2);
2476 }
2477
2478 unsigned save_opt,save_opt2;
2479 SI_SAVE_OPT1(save_opt);
2480 SI_SAVE_OPT2(save_opt2);
2481 if (T==NULL) si_opt_1 |= Sy_bit(OPT_REDTAIL);
2483 s_temp1 = idPrepare(s2,s1,testHomog,length,w,alg);
2484 SI_RESTORE_OPT1(save_opt);
2485 SI_RESTORE_OPT2(save_opt2);
2486 }
2487
2488 //if (wtmp!=NULL) Print("output weights:");wtmp->show(1);PrintLn();
2489 if ((w!=NULL) && (*w !=NULL) && (wtmp!=NULL))
2490 {
2491 delete *w;
2492 *w=new intvec(IDELEMS(h2));
2493 for (i=0;i<IDELEMS(h2);i++)
2494 ((**w)[i])=(*wtmp)[i+length];
2495 }
2496 if (wtmp!=NULL) delete wtmp;
2497
2498 ideal result=idInit(IDELEMS(s_temp1),IDELEMS(h2));
2499 s_temp1=idExtractG_T_S(s_temp1,T,&result,length,IDELEMS(h2),inputIsIdeal,orig_ring,syz_ring);
2500
2501 idDelete(&s_temp1);
2502 if (syz_ring!=orig_ring)
2503 {
2504 rDelete(syz_ring);
2505 }
2506 idTest(h2);
2507 idTest(h1);
2508 idTest(result);
2509 if (T!=NULL) idTest((ideal)*T);
2510 return result;
2511}
ideal idModuloLP(ideal h2, ideal h1, tHomog, intvec **w, matrix *T, GbVariant alg)
Definition: ideals.cc:2221
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
#define SI_SAVE_OPT1(A)
Definition: options.h:21
#define SI_RESTORE_OPT1(A)
Definition: options.h:24
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411

◆ idMult()

static 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 ring orig_ring=currRing;
508 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
509 rSetSyzComp(syzComp,syz_ring);
510 rChangeCurrRing(syz_ring);
511
512 bigmat = idInit(j,(k+1)*maxrk);
513 /* create unit matrices ------------------------------------------*/
514 for (i=0;i<maxrk;i++)
515 {
516 for (j=0;j<=k;j++)
517 {
518 p = pOne();
519 pSetComp(p,i+1+j*maxrk);
520 pSetmComp(p);
521 bigmat->m[i] = pAdd(bigmat->m[i],p);
522 }
523 }
524 /* enter given ideals ------------------------------------------*/
525 i = maxrk;
526 k = 0;
527 for (j=0;j<length;j++)
528 {
529 if (arg[j]!=NULL)
530 {
531 for (l=0;l<IDELEMS(arg[j]);l++)
532 {
533 if (arg[j]->m[l]!=NULL)
534 {
535 if (syz_ring==orig_ring)
536 bigmat->m[i] = pCopy(arg[j]->m[l]);
537 else
538 bigmat->m[i] = prCopyR(arg[j]->m[l], orig_ring,currRing);
539 p_Shift(&(bigmat->m[i]),k*maxrk+isIdeal,currRing);
540 i++;
541 }
542 }
543 k++;
544 }
545 }
546 /* std computation --------------------------------------------*/
547 if ((alg!=GbDefault)
548 && (alg!=GbGroebner)
549 && (alg!=GbModstd)
550 && (alg!=GbSlimgb)
551 && (alg!=GbStd))
552 {
553 WarnS("wrong algorithm for GB");
554 alg=GbDefault;
555 }
556 tempstd=idGroebner(bigmat,syzComp,alg);
557
558 if(syz_ring!=orig_ring)
559 rChangeCurrRing(orig_ring);
560
561 /* interpret result ----------------------------------------*/
562 result = idInit(IDELEMS(tempstd),maxrk);
563 k = 0;
564 for (j=0;j<IDELEMS(tempstd);j++)
565 {
566 if ((tempstd->m[j]!=NULL) && (__p_GetComp(tempstd->m[j],syz_ring)>syzComp))
567 {
568 if (syz_ring==orig_ring)
569 p = pCopy(tempstd->m[j]);
570 else
571 p = prCopyR(tempstd->m[j], syz_ring,currRing);
572 p_Shift(&p,-syzComp-isIdeal,currRing);
573 result->m[k] = p;
574 k++;
575 }
576 }
577 /* clean up ----------------------------------------------------*/
578 if(syz_ring!=orig_ring)
579 rChangeCurrRing(syz_ring);
580 idDelete(&tempstd);
581 if(syz_ring!=orig_ring)
582 {
583 rChangeCurrRing(orig_ring);
584 rDelete(syz_ring);
585 }
587 return result;
588}

◆ idQuot()

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

Definition at line 1494 of file ideals.cc.

1495{
1496 // first check for special case h1:(0)
1497 if (idIs0(h2))
1498 {
1499 ideal res;
1500 if (resultIsIdeal)
1501 {
1502 res = idInit(1,1);
1503 res->m[0] = pOne();
1504 }
1505 else
1506 res = idFreeModule(h1->rank);
1507 return res;
1508 }
1509 int i, kmax;
1510 BOOLEAN addOnlyOne=TRUE;
1511 tHomog hom=isNotHomog;
1512 intvec * weights1;
1513
1514 ideal s_h4 = idInitializeQuot (h1,h2,h1IsStb,&addOnlyOne,&kmax);
1515
1516 hom = (tHomog)idHomModule(s_h4,currRing->qideal,&weights1);
1517
1518 ring orig_ring=currRing;
1519 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
1520 rSetSyzComp(kmax-1,syz_ring);
1521 rChangeCurrRing(syz_ring);
1522 if (orig_ring!=syz_ring)
1523 // s_h4 = idrMoveR_NoSort(s_h4,orig_ring, syz_ring);
1524 s_h4 = idrMoveR(s_h4,orig_ring, syz_ring);
1525 idTest(s_h4);
1526
1527 #if 0
1528 matrix m=idModule2Matrix(idCopy(s_h4));
1529 PrintS("start:\n");
1530 ipPrint_MA0(m,"Q");
1531 idDelete((ideal *)&m);
1532 PrintS("last elem:");wrp(s_h4->m[IDELEMS(s_h4)-1]);PrintLn();
1533 #endif
1534
1535 ideal s_h3;
1536 BITSET old_test1;
1537 SI_SAVE_OPT1(old_test1);
1539 if (addOnlyOne)
1540 {
1542 s_h3 = kStd(s_h4,currRing->qideal,hom,&weights1,NULL,0/*kmax-1*/,IDELEMS(s_h4)-1);
1543 }
1544 else
1545 {
1546 s_h3 = kStd(s_h4,currRing->qideal,hom,&weights1,NULL,kmax-1);
1547 }
1548 SI_RESTORE_OPT1(old_test1);
1549
1550 #if 0
1551 // only together with the above debug stuff
1552 idSkipZeroes(s_h3);
1553 m=idModule2Matrix(idCopy(s_h3));
1554 Print("result, kmax=%d:\n",kmax);
1555 ipPrint_MA0(m,"S");
1556 idDelete((ideal *)&m);
1557 #endif
1558
1559 idTest(s_h3);
1560 if (weights1!=NULL) delete weights1;
1561 idDelete(&s_h4);
1562
1563 for (i=0;i<IDELEMS(s_h3);i++)
1564 {
1565 if ((s_h3->m[i]!=NULL) && (pGetComp(s_h3->m[i])>=kmax))
1566 {
1567 if (resultIsIdeal)
1568 p_Shift(&s_h3->m[i],-kmax,currRing);
1569 else
1570 p_Shift(&s_h3->m[i],-kmax+1,currRing);
1571 }
1572 else
1573 p_Delete(&s_h3->m[i],currRing);
1574 }
1575 if (resultIsIdeal)
1576 s_h3->rank = 1;
1577 else
1578 s_h3->rank = h1->rank;
1579 if(syz_ring!=orig_ring)
1580 {
1581 rChangeCurrRing(orig_ring);
1582 s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
1583 rDelete(syz_ring);
1584 }
1585 idSkipZeroes(s_h3);
1586 idTest(s_h3);
1587 return s_h3;
1588}
#define Print
Definition: emacs.cc:80
static ideal idInitializeQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN *addOnlyOne, int *kkmax)
Definition: ideals.cc:1389
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:310
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310

◆ idSect()

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

Definition at line 316 of file ideals.cc.

317{
318 int i,j,k;
319 unsigned length;
320 int flength = id_RankFreeModule(h1,currRing);
321 int slength = id_RankFreeModule(h2,currRing);
322 int rank=si_max(h1->rank,h2->rank);
323 if ((idIs0(h1)) || (idIs0(h2))) return idInit(1,rank);
324
325 BITSET save_opt;
326 SI_SAVE_OPT1(save_opt);
328
329 ideal first,second,temp,temp1,result;
330 poly p,q;
331
332 if (IDELEMS(h1)<IDELEMS(h2))
333 {
334 first = h1;
335 second = h2;
336 }
337 else
338 {
339 first = h2;
340 second = h1;
341 int t=flength; flength=slength; slength=t;
342 }
343 length = si_max(flength,slength);
344 if (length==0)
345 {
346 if ((currRing->qideal==NULL)
347 && (currRing->OrdSgn==1)
350 return idSectWithElim(first,second,alg);
351 else length = 1;
352 }
353 if (TEST_OPT_PROT) PrintS("intersect by syzygy methods\n");
354 j = IDELEMS(first);
355
356 ring orig_ring=currRing;
357 ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE);
358 rSetSyzComp(length,syz_ring);
359 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=kStd(result,currRing->qideal,testHomog,&w);
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:133
#define TEST_V_INTERSECT_ELIM
Definition: options.h:145
#define TEST_V_INTERSECT_SYZ
Definition: options.h:146
#define TEST_OPT_PROT
Definition: options.h:104
#define pMult(p, q)
Definition: polys.h:207

◆ idSeries()

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

Definition at line 2121 of file ideals.cc.

2122{
2123 for(int i=IDELEMS(M)-1;i>=0;i--)
2124 {
2125 if(U==NULL)
2126 M->m[i]=pSeries(n,M->m[i],NULL,w);
2127 else
2128 {
2129 M->m[i]=pSeries(n,M->m[i],MATELEM(U,i+1,i+1),w);
2130 MATELEM(U,i+1,i+1)=NULL;
2131 }
2132 }
2133 if(U!=NULL)
2134 idDelete((ideal*)&U);
2135 return M;
2136}
#define pSeries(n, p, u, w)
Definition: polys.h:371

◆ idSort()

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

Definition at line 184 of file ideals.h.

185{
186 return id_Sort(id, nolex, currRing);
187}
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 830 of file ideals.cc.

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

2070{
2071 if ((Q!=NULL) && (!idHomIdeal(Q,NULL))) { PrintS(" Q not hom\n"); return FALSE;}
2072 if (idIs0(m)) return TRUE;
2073
2074 int cmax=-1;
2075 int i;
2076 poly p=NULL;
2077 int length=IDELEMS(m);
2078 polyset P=m->m;
2079 for (i=length-1;i>=0;i--)
2080 {
2081 p=P[i];
2082 if (p!=NULL) cmax=si_max(cmax,(int)pMaxComp(p)+1);
2083 }
2084 if (w != NULL)
2085 if (w->length()+1 < cmax)
2086 {
2087 // Print("length: %d - %d \n", w->length(),cmax);
2088 return FALSE;
2089 }
2090
2091 if(w!=NULL)
2093
2094 for (i=length-1;i>=0;i--)
2095 {
2096 p=P[i];
2097 if (p!=NULL)
2098 {
2099 int d=currRing->pFDeg(p,currRing);
2100 loop
2101 {
2102 pIter(p);
2103 if (p==NULL) break;
2104 if (d!=currRing->pFDeg(p,currRing))
2105 {
2106 //pWrite(q); wrp(p); Print(" -> %d - %d\n",d,pFDeg(p,currRing));
2107 if(w!=NULL)
2109 return FALSE;
2110 }
2111 }
2112 }
2113 }
2114
2115 if(w!=NULL)
2117
2118 return TRUE;
2119}
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition: ideals.h:91
void p_SetModDeg(intvec *w, ring r)
Definition: p_polys.cc:3673
#define pMaxComp(p)
Definition: polys.h:299
poly * polyset
Definition: polys.h:259

◆ idVec2Ideal()

static ideal idVec2Ideal ( poly  vec)
inlinestatic

Definition at line 169 of file ideals.h.

170{
171 return id_Vec2Ideal(vec, currRing);
172}
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 3154 of file ideals.cc.

3155{
3156 GbVariant alg=GbDefault;
3157 if (strcmp(n,"default")==0) alg=GbDefault;
3158 else if (strcmp(n,"slimgb")==0) alg=GbSlimgb;
3159 else if (strcmp(n,"std")==0) alg=GbStd;
3160 else if (strcmp(n,"sba")==0) alg=GbSba;
3161 else if (strcmp(n,"singmatic")==0) alg=GbSingmatic;
3162 else if (strcmp(n,"groebner")==0) alg=GbGroebner;
3163 else if (strcmp(n,"modstd")==0) alg=GbModstd;
3164 else if (strcmp(n,"ffmod")==0) alg=GbFfmod;
3165 else if (strcmp(n,"nfmod")==0) alg=GbNfmod;
3166 else if (strcmp(n,"std:sat")==0) alg=GbStdSat;
3167 else Warn(">>%s<< is an unknown algorithm",n);
3168
3169 if (alg==GbSlimgb) // test conditions for slimgb
3170 {
3171 if(rHasGlobalOrdering(r)
3172 &&(!rIsNCRing(r))
3173 &&(r->qideal==NULL)
3174 &&(!rField_is_Ring(r)))
3175 {
3176 return GbSlimgb;
3177 }
3178 if (TEST_OPT_PROT)
3179 WarnS("requires: coef:field, commutative, global ordering, not qring");
3180 }
3181 else if (alg==GbSba) // cond. for sba
3182 {
3183 if(rField_is_Domain(r)
3184 &&(!rIsNCRing(r))
3185 &&(rHasGlobalOrdering(r)))
3186 {
3187 return GbSba;
3188 }
3189 if (TEST_OPT_PROT)
3190 WarnS("requires: coef:domain, commutative, global ordering");
3191 }
3192 else if (alg==GbGroebner) // cond. for groebner
3193 {
3194 return GbGroebner;
3195 }
3196 else if(alg==GbModstd) // cond for modstd: Q or Q(a)
3197 {
3198 if(ggetid("modStd")==NULL)
3199 {
3200 WarnS(">>modStd<< not found");
3201 }
3202 else if(rField_is_Q(r)
3203 &&(!rIsNCRing(r))
3204 &&(rHasGlobalOrdering(r)))
3205 {
3206 return GbModstd;
3207 }
3208 if (TEST_OPT_PROT)
3209 WarnS("requires: coef:QQ, commutative, global ordering");
3210 }
3211 else if(alg==GbStdSat) // cond for std:sat: 2 blocks of variables
3212 {
3213 if(ggetid("satstd")==NULL)
3214 {
3215 WarnS(">>satstd<< not found");
3216 }
3217 else
3218 {
3219 return GbStdSat;
3220 }
3221 }
3222
3223 return GbStd; // no conditions for std
3224}
#define Warn
Definition: emacs.cc:77
GbVariant
Definition: ideals.h:119
idhdl ggetid(const char *n)
Definition: ipid.cc:581
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:487
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:506
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421