My Project  UNKNOWN_GIT_VERSION
simpleideals.h
Go to the documentation of this file.
1 #ifndef SIMPLEIDEALS_H
2 #define SIMPLEIDEALS_H
3 /****************************************
4 * Computer Algebra System SINGULAR *
5 ****************************************/
6 /*
7 * ABSTRACT - all basic methods to manipulate ideals
8 */
9 #include "omalloc/omalloc.h"
10 #include "polys/monomials/ring.h"
11 #include "polys/matpol.h"
12 
13 /// The following sip_sideal structure has many different uses
14 /// thoughout Singular. Basic use-cases for it are:
15 /// * ideal/module: nrows = 1, ncols >=0 and rank:1 for ideals, rank>=0 for modules
16 /// * matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures
17 /// NOTE: the m member point to memory chunk of size (ncols*nrows*sizeof(poly)) or is NULL
18 struct sip_sideal
19 {
20  poly* m;
21  long rank;
22  int nrows;
23  int ncols;
24  #define IDELEMS(i) ((i)->ncols)
25  #define MATCOLS(i) ((i)->ncols)
26  #define MATROWS(i) ((i)->nrows)
27  #define MATELEM(mat,i,j) ((mat)->m)[MATCOLS((mat)) * ((i)-1) + (j)-1]
28 
29 };
30 /* the settings of rank, nrows, ncols, m , entries:
31  * for IDEAL_CMD: 1 1 n size n poly (n>=0)
32  * for MODUL_CMD: r 1 n size n vector of rank<=r (n>=0, r>=0)
33  * for MATRIX_CMD r r c size r*c poly (r>=0, c>=0)
34  * for MAP_CMD: char* 1 n size n poly (n>=0)
35  */
36 
37 struct sip_smap
38 {
39  poly *m;
40  char *preimage;
41  int nrows;
42  int ncols;
43 };
44 
45 //typedef struct sip_smap * map;
46 
47 struct sideal_list;
48 typedef struct sideal_list * ideal_list;
49 
51 {
52  ideal_list next;
53  ideal d;
54 #ifdef KDEBUG
55  int nr;
56 #endif
57 };
58 
59 extern omBin sip_sideal_bin;
60 
61 /// creates an ideal / module
62 ideal idInit (int size, int rank=1);
63 
64 /*- deletes an ideal -*/
65 void id_Delete (ideal* h, ring r);
66 void id_ShallowDelete (ideal* h, ring r);
67 void idSkipZeroes (ideal ide);
68  /*gives an ideal the minimal possible size*/
69 
70 /// number of non-zero polys in F
71 int idElem(const ideal F);
72 /// normialize all polys in id
73 void id_Normalize(ideal id, const ring r);
74 
75 int id_MinDegW(ideal M,intvec *w, const ring r);
76 
77 #ifdef PDEBUG
78 void id_DBTest(ideal h1, int level, const char *f,const int l, const ring lR, const ring tR );
79 #define id_TestTail(A, lR, tR) id_DBTest(A, PDEBUG, __FILE__,__LINE__, lR, tR)
80 #define id_Test(A, lR) id_DBTest(A, PDEBUG, __FILE__,__LINE__, lR, lR)
81 #else
82 #define id_TestTail(A, lR, tR) do {} while (0)
83 #define id_Test(A, lR) do {} while (0)
84 #endif
85 
86 ideal id_Copy (ideal h1,const ring r);
87 
88  /*adds two ideals without simplifying the result*/
89 ideal id_SimpleAdd (ideal h1,ideal h2, const ring r);
90  /*adds the quotient ideal*/
91 ideal id_Add (ideal h1,ideal h2,const ring r);
92  /* h1 + h2 */
93 
94 ideal id_Power(ideal given,int exp, const ring r);
95 BOOLEAN idIs0 (ideal h);
96 
97 long id_RankFreeModule(ideal m, ring lmRing, ring tailRing);
98 static inline long id_RankFreeModule(ideal m, ring r)
99 {return id_RankFreeModule(m, r, r);}
100 
101 ideal id_FreeModule (int i, const ring r);
102 int idElem(const ideal F);
103 int id_PosConstant(ideal id, const ring r);
104 ideal id_Head(ideal h,const ring r);
105 ideal id_MaxIdeal (const ring r);
106 ideal id_MaxIdeal(int deg, const ring r);
107 ideal id_CopyFirstK (const ideal ide, const int k,const ring r);
108 void id_DelMultiples(ideal id, const ring r);
109 void id_Norm(ideal id, const ring r);
110 void id_DelEquals(ideal id, const ring r);
111 void id_DelLmEquals(ideal id, const ring r);
112 void id_DelDiv(ideal id, const ring r);
113 BOOLEAN id_IsConstant(ideal id, const ring r);
114 
115 /// sorts the ideal w.r.t. the actual ringordering
116 /// uses lex-ordering when nolex = FALSE
117 intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r);
118 
119 /// transpose a module
120 ideal id_Transp(ideal a, const ring rRing);
121 
122 void id_Compactify(ideal id, const ring r);
123 ideal id_Mult (ideal h1,ideal h2, const ring r);
124 ideal id_Homogen(ideal h, int varnum,const ring r);
125 BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r);
126 BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R);
127 BOOLEAN id_IsZeroDim(ideal I, const ring r);
128 ideal id_Jet(const ideal i,int d, const ring R);
129 ideal id_JetW(const ideal i,int d, intvec * iv, const ring R);
130 ideal id_Subst(ideal id, int n, poly e, const ring r);
131 matrix id_Module2Matrix(ideal mod, const ring R);
132 matrix id_Module2formatedMatrix(ideal mod,int rows, int cols, const ring R);
133 ideal id_ResizeModule(ideal mod,int rows, int cols, const ring R);
134 ideal id_Matrix2Module(matrix mat, const ring R);
135 ideal id_Vec2Ideal(poly vec, const ring R);
136 
137 int id_ReadOutPivot(ideal arg, int* comp, const ring r);
138 
139 int binom (int n,int r);
140 
141  /*- verschiebt die Indizes der Modulerzeugenden um i -*/
142 void idInitChoise (int r,int beg,int end,BOOLEAN *endch,int * choise);
143 void idGetNextChoise (int r,int end,BOOLEAN *endch,int * choise);
144 int idGetNumberOfChoise(int t, int d, int begin, int end, int * choise);
145 
146 #ifdef PDEBUG
147 void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint = 0);
148 #define id_Print(id, lR, tR) idShow(id, lR, tR)
149 #else
150 #define id_Print(A, lR, tR) do {} while (0)
151 #endif
152 
153 
154 
155 /// insert h2 into h1 depending on the two boolean parameters:
156 /// - if zeroOk is true, then h2 will also be inserted when it is zero
157 /// - if duplicateOk is true, then h2 will also be inserted when it is
158 /// already present in h1
159 /// return TRUE iff h2 was indeed inserted
160 BOOLEAN id_InsertPolyWithTests (ideal h1, const int validEntries,
161  const poly h2, const bool zeroOk,
162  const bool duplicateOk, const ring r);
163 
164 
165 intvec * id_QHomWeight(ideal id, const ring r);
166 
167 
168 ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r);
169 
170 void id_Shift(ideal M, int s, const ring r);
171 ideal id_Delete_Pos(const ideal I, const int pos, const ring r);
172 
173 /// for julia: convert an array of poly to vector
174 poly id_Array2Vector(poly *m, unsigned n, const ring R);
175 #endif
omalloc.h
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition: simpleideals.cc:768
id_IsZeroDim
BOOLEAN id_IsZeroDim(ideal I, const ring r)
Definition: simpleideals.cc:1615
id_DBTest
void id_DBTest(ideal h1, int level, const char *f, const int l, const ring lR, const ring tR)
Internal verification for ideals/modules and dense matrices!
Definition: simpleideals.cc:416
ip_smatrix
Definition: matpol.h:15
f
FILE * f
Definition: checklibs.c:9
id_Compactify
void id_Compactify(ideal id, const ring r)
Definition: simpleideals.cc:1087
id_Vec2Ideal
ideal id_Vec2Ideal(poly vec, const ring R)
Definition: simpleideals.cc:1135
k
int k
Definition: cfEzgcd.cc:92
id_MinDegW
int id_MinDegW(ideal M, intvec *w, const ring r)
Definition: simpleideals.cc:1644
id_DelDiv
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
Definition: simpleideals.cc:342
idGetNumberOfChoise
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
Definition: simpleideals.cc:881
idGetNextChoise
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
Definition: simpleideals.cc:855
id_MaxIdeal
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
Definition: simpleideals.cc:100
id_Sort
intvec * id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE
Definition: simpleideals.cc:503
id_CopyFirstK
ideal id_CopyFirstK(const ideal ide, const int k, const ring r)
copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (...
Definition: simpleideals.cc:226
idInit
ideal idInit(int size, int rank=1)
creates an ideal / module
Definition: simpleideals.cc:37
level
int level(const CanonicalForm &f)
Definition: canonicalform.h:324
mod
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
id_Matrix2Module
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
Definition: simpleideals.cc:1167
id_Subst
ideal id_Subst(ideal id, int n, poly e, const ring r)
Definition: simpleideals.cc:1316
id_HomModule
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
Definition: simpleideals.cc:1331
sip_smap
Definition: simpleideals.h:38
id_ReadOutPivot
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
Definition: simpleideals.cc:1491
sideal_list::next
ideal_list next
Definition: simpleideals.h:52
id_Transp
ideal id_Transp(ideal a, const ring rRing)
transpose a module
Definition: simpleideals.cc:1664
idShow
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint=0)
Definition: simpleideals.cc:59
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
id_Normalize
void id_Normalize(ideal id, const ring r)
normialize all polys in id
Definition: simpleideals.cc:1634
sip_smap::preimage
char * preimage
Definition: simpleideals.h:40
id_HomIdeal
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
Definition: simpleideals.cc:806
id_Add
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
Definition: simpleideals.cc:714
i
int i
Definition: cfEzgcd.cc:125
id_ResizeModule
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
Definition: simpleideals.cc:1279
matpol.h
sip_smap::m
poly * m
Definition: simpleideals.h:39
M
#define M
Definition: sirandom.c:24
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
sip_sideal::ncols
int ncols
Definition: simpleideals.h:23
sip_sideal::m
poly * m
Definition: simpleideals.h:20
id_DelLmEquals
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
Definition: simpleideals.cc:314
h
static Poly * h
Definition: janet.cc:972
idInitChoise
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
Definition: simpleideals.cc:833
id_FreeModule
ideal id_FreeModule(int i, const ring r)
the free module of rank i
Definition: simpleideals.cc:935
id_Shift
void id_Shift(ideal M, int s, const ring r)
Definition: simpleideals.cc:1846
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
intvec
Definition: intvec.h:21
id_ShallowDelete
void id_ShallowDelete(ideal *h, ring r)
Shallowdeletes an ideal/matrix.
Definition: simpleideals.cc:148
sip_sideal_bin
omBin sip_sideal_bin
Definition: simpleideals.cc:29
binom
int binom(int n, int r)
Definition: simpleideals.cc:913
id_RankFreeModule
long id_RankFreeModule(ideal m, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition: simpleideals.cc:782
id_DelMultiples
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
Definition: simpleideals.cc:256
id_Delete_Pos
ideal id_Delete_Pos(const ideal I, const int pos, const ring r)
Definition: simpleideals.cc:1860
id_InsertPolyWithTests
BOOLEAN id_InsertPolyWithTests(ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
insert h2 into h1 depending on the two boolean parameters:
Definition: simpleideals.cc:686
sip_smap::ncols
int ncols
Definition: simpleideals.h:42
sideal_list
Definition: simpleideals.h:51
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
ring.h
omBin
omBin_t * omBin
Definition: omStructs.h:12
id_Norm
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
Definition: simpleideals.cc:242
idElem
int idElem(const ideal F)
number of non-zero polys in F
Definition: simpleideals.cc:210
id_PosConstant
int id_PosConstant(ideal id, const ring r)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: simpleideals.cc:82
sip_sideal
The following sip_sideal structure has many different uses thoughout Singular. Basic use-cases for it...
Definition: simpleideals.h:19
id_Mult
ideal id_Mult(ideal h1, ideal h2, const ring r)
h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no co...
Definition: simpleideals.cc:727
id_Head
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
Definition: simpleideals.cc:1111
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:114
sip_sideal::nrows
int nrows
Definition: simpleideals.h:22
id_Module2Matrix
matrix id_Module2Matrix(ideal mod, const ring R)
Definition: simpleideals.cc:1201
id_JetW
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
Definition: simpleideals.cc:1467
m
int m
Definition: cfEzgcd.cc:121
id_SimpleAdd
ideal id_SimpleAdd(ideal h1, ideal h2, const ring r)
concat the lists h1 and h2 without zeros
Definition: simpleideals.cc:598
l
int l
Definition: cfEzgcd.cc:93
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition: simpleideals.cc:172
id_ChineseRemainder
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
Definition: simpleideals.cc:1797
sideal_list::nr
int nr
Definition: simpleideals.h:55
R
#define R
Definition: sirandom.c:26
sideal_list::d
ideal d
Definition: simpleideals.h:53
id_DelEquals
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
Definition: simpleideals.cc:291
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition: simpleideals.cc:404
comp
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
Definition: facSparseHensel.h:25
Q
#define Q
Definition: sirandom.c:25
id_Module2formatedMatrix
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
Definition: simpleideals.cc:1247
id_Array2Vector
poly id_Array2Vector(poly *m, unsigned n, const ring R)
for julia: convert an array of poly to vector
Definition: simpleideals.cc:1144
id_IsConstant
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
Definition: simpleideals.cc:391
id_Homogen
ideal id_Homogen(ideal h, int varnum, const ring r)
Definition: simpleideals.cc:1122
sip_sideal::rank
long rank
Definition: simpleideals.h:21
id_Power
ideal id_Power(ideal given, int exp, const ring r)
Definition: simpleideals.cc:1061
sip_smap::nrows
int nrows
Definition: simpleideals.h:41
id_QHomWeight
intvec * id_QHomWeight(ideal id, const ring r)
Definition: simpleideals.cc:1568
id_Jet
ideal id_Jet(const ideal i, int d, const ring R)
Definition: simpleideals.cc:1454
vec
fq_nmod_poly_t * vec
Definition: facHensel.cc:103