1 | #ifndef IDEALS_H |
---|
2 | #define IDEALS_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT - all basic methods to manipulate ideals |
---|
9 | */ |
---|
10 | // #include <kernel/structs.h> |
---|
11 | |
---|
12 | #include <polys/monomials/ring.h> |
---|
13 | |
---|
14 | struct sip_sideal |
---|
15 | { |
---|
16 | poly* m; |
---|
17 | long rank; |
---|
18 | int nrows; |
---|
19 | int ncols; |
---|
20 | #define IDELEMS(i) ((i)->ncols) |
---|
21 | #define MATCOLS(i) ((i)->ncols) |
---|
22 | #define MATROWS(i) ((i)->nrows) |
---|
23 | #define MATELEM(mat,i,j) ((mat)->m)[MATCOLS((mat)) * ((i)-1) + (j)-1] |
---|
24 | |
---|
25 | }; |
---|
26 | |
---|
27 | struct sip_smap |
---|
28 | { |
---|
29 | poly *m; |
---|
30 | char *preimage; |
---|
31 | int nrows; |
---|
32 | int ncols; |
---|
33 | }; |
---|
34 | |
---|
35 | class ip_smatrix; |
---|
36 | typedef ip_smatrix * matrix; |
---|
37 | |
---|
38 | struct sideal_list; |
---|
39 | typedef struct sideal_list * ideal_list; |
---|
40 | |
---|
41 | struct sideal_list |
---|
42 | { |
---|
43 | ideal_list next; |
---|
44 | ideal d; |
---|
45 | #ifndef NDEBUG |
---|
46 | int nr; |
---|
47 | #endif |
---|
48 | }; |
---|
49 | |
---|
50 | //typedef struct sip_sideal * ideal; |
---|
51 | //typedef struct sip_smap * map; |
---|
52 | typedef ideal * resolvente; |
---|
53 | |
---|
54 | |
---|
55 | extern omBin sip_sideal_bin; |
---|
56 | |
---|
57 | /*- creates an ideal -*/ |
---|
58 | ideal idInit (int size, int rank=1); |
---|
59 | ideal idCopyFirstK (const ideal ide, const int k); |
---|
60 | |
---|
61 | /// delete an ideal |
---|
62 | // #define idDelete(h) id_Delete(h, currRing) |
---|
63 | void id_Delete (ideal* h, ring r); |
---|
64 | void id_ShallowDelete (ideal* h, ring r); |
---|
65 | /*- initialise an ideal -*/ // ? |
---|
66 | |
---|
67 | /// initialise the maximal ideal (at 0) |
---|
68 | ideal idMaxIdeal (int deg); |
---|
69 | |
---|
70 | /// gives an ideal the minimal possible size |
---|
71 | void idSkipZeroes (ideal ide); |
---|
72 | |
---|
73 | /// index of generator with leading term in ground ring (if any); otherwise -1 |
---|
74 | int idPosConstant (ideal id); |
---|
75 | |
---|
76 | /// Count the effective size of an ideal |
---|
77 | /// (without the trailing allocated zero-elements) |
---|
78 | static inline int idSize(const ideal id) |
---|
79 | { |
---|
80 | int j = IDELEMS(id) - 1; |
---|
81 | poly* mm = id->m; |
---|
82 | while ((j >= 0) && (mm[j] == NULL)) j--; |
---|
83 | return (j + 1); |
---|
84 | } |
---|
85 | |
---|
86 | void idNorm(ideal id); |
---|
87 | void idDelMultiples(ideal id); |
---|
88 | void idDelEquals(ideal id); |
---|
89 | void idDelLmEquals(ideal id); |
---|
90 | void idDelDiv(ideal id); |
---|
91 | BOOLEAN idIsConstant(ideal id); |
---|
92 | |
---|
93 | #ifdef PDEBUG |
---|
94 | void idDBTest(ideal h1, int level, const char *f,const int l); |
---|
95 | #define idTest(A) idDBTest(A, PDEBUG, __FILE__,__LINE__) |
---|
96 | #define idPrint(id) idShow(id) |
---|
97 | #else |
---|
98 | #define idTest(A) (TRUE) |
---|
99 | #define idPrint(A) ((void)0) |
---|
100 | #endif |
---|
101 | |
---|
102 | ideal id_Copy (ideal h1,const ring r); |
---|
103 | #ifdef PDEBUG |
---|
104 | ideal idDBCopy(ideal h1,const char *f,int l,const ring r); |
---|
105 | #define id_DBCopy(A,r) idDBCopy(A,__FILE__,__LINE__,r) |
---|
106 | #define idCopy(A,r) id_DBCopy(A,r) |
---|
107 | #else |
---|
108 | #define idCopy(A,r) id_Copy(A,r) |
---|
109 | #endif |
---|
110 | |
---|
111 | |
---|
112 | /*adds two ideals without simplifying the result*/ |
---|
113 | ideal idSimpleAdd (ideal h1,ideal h2); |
---|
114 | /*adds the quotient ideal*/ |
---|
115 | ideal idAdd (ideal h1,ideal h2); |
---|
116 | /* h1 + h2 */ |
---|
117 | BOOLEAN idInsertPoly (ideal h1,poly h2); |
---|
118 | /* h1 + h2 */ |
---|
119 | BOOLEAN idInsertPolyWithTests (ideal h1, const int validEntries, |
---|
120 | const poly h2, const bool zeroOk, const bool duplicateOk); |
---|
121 | /* h1 + h2 */ |
---|
122 | ideal idMult (ideal h1,ideal h2); |
---|
123 | /*hh := h1 * h2*/ |
---|
124 | |
---|
125 | BOOLEAN idIs0 (ideal h); |
---|
126 | |
---|
127 | long idRankFreeModule(ideal m, ring lmRing, ring tailRing); |
---|
128 | |
---|
129 | static inline long idRankFreeModule(ideal m, ring r){ return idRankFreeModule(m, r, r); } |
---|
130 | |
---|
131 | // returns TRUE, if idRankFreeModule(m) > 0 |
---|
132 | BOOLEAN idIsModule(ideal m, const ring r); |
---|
133 | BOOLEAN idHomIdeal (ideal id, ideal Q=NULL); |
---|
134 | BOOLEAN idHomModule(ideal m, ideal Q,intvec **w); |
---|
135 | BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w); |
---|
136 | |
---|
137 | ideal idMinBase (ideal h1); |
---|
138 | /*returns a minimized set of generators of h1*/ |
---|
139 | int pLowVar (poly p); |
---|
140 | /*-the minimal index of used variables - 1-*/ |
---|
141 | void pShift (poly * p,int i); |
---|
142 | /*- verschiebt die Indizes der Modulerzeugenden um i -*/ |
---|
143 | void idInitChoise (int r,int beg,int end,BOOLEAN *endch,int * choise); |
---|
144 | void idGetNextChoise (int r,int end,BOOLEAN *endch,int * choise); |
---|
145 | int idGetNumberOfChoise(int t, int d, int begin, int end, int * choise); |
---|
146 | |
---|
147 | int binom (int n,int r); |
---|
148 | |
---|
149 | ideal idFreeModule (int i); |
---|
150 | |
---|
151 | ideal idSect (ideal h1,ideal h2); |
---|
152 | ideal idMultSect(resolvente arg, int length); |
---|
153 | |
---|
154 | //ideal idSyzygies (ideal h1, tHomog h,intvec **w); |
---|
155 | ideal idSyzygies (ideal h1, tHomog h,intvec **w, BOOLEAN setSyzComp=TRUE, |
---|
156 | BOOLEAN setRegularity=FALSE, int *deg = NULL); |
---|
157 | ideal idLiftStd (ideal h1, matrix *m, tHomog h=testHomog, ideal *syz=NULL); |
---|
158 | |
---|
159 | ideal idLift (ideal mod, ideal sumod,ideal * rest=NULL, |
---|
160 | BOOLEAN goodShape=FALSE, BOOLEAN isSB=TRUE,BOOLEAN divide=FALSE, |
---|
161 | matrix *unit=NULL); |
---|
162 | |
---|
163 | void idLiftW(ideal P,ideal Q,int n,matrix &T, ideal &R, short *w= NULL ); |
---|
164 | |
---|
165 | intvec * idMWLift(ideal mod,intvec * weights); |
---|
166 | |
---|
167 | ideal idQuot (ideal h1,ideal h2, |
---|
168 | BOOLEAN h1IsStb=FALSE, BOOLEAN resultIsIdeal=FALSE); |
---|
169 | |
---|
170 | ideal idPower(ideal gid,int deg); |
---|
171 | |
---|
172 | //ideal idElimination (ideal h1,poly delVar); |
---|
173 | ideal idElimination (ideal h1,poly delVar, intvec *hilb=NULL); |
---|
174 | |
---|
175 | poly idMinor(matrix a, int ar, unsigned long which, ideal R=NULL); |
---|
176 | |
---|
177 | ideal idMinors(matrix a, int ar, ideal R=NULL); |
---|
178 | |
---|
179 | void idCompactify(ideal id); |
---|
180 | |
---|
181 | ideal idMinEmbedding(ideal arg,BOOLEAN inPlace=FALSE, intvec **w=NULL); |
---|
182 | |
---|
183 | ideal idHead(ideal h); |
---|
184 | |
---|
185 | ideal idHomogen(ideal h, int varnum); |
---|
186 | |
---|
187 | BOOLEAN idIsSubModule(ideal id1,ideal id2); |
---|
188 | |
---|
189 | ideal idVec2Ideal(poly vec); |
---|
190 | |
---|
191 | ideal idMatrix2Module(matrix mat); |
---|
192 | |
---|
193 | matrix idModule2Matrix(ideal mod); |
---|
194 | |
---|
195 | matrix idModule2formatedMatrix(ideal mod,int rows, int cols); |
---|
196 | |
---|
197 | ideal idSubst(ideal i, int n, poly e); |
---|
198 | |
---|
199 | ideal idJet(ideal i,int d); |
---|
200 | ideal idJetW(ideal i,int d, intvec * iv); |
---|
201 | int idMinDegW(ideal M,intvec *w); |
---|
202 | ideal idSeries(int n,ideal M,matrix U=NULL,intvec *w=NULL); |
---|
203 | |
---|
204 | BOOLEAN idIsZeroDim(ideal i); |
---|
205 | matrix idDiff(matrix i, int k); |
---|
206 | matrix idDiffOp(ideal I, ideal J,BOOLEAN multiply=TRUE); |
---|
207 | |
---|
208 | intvec *idSort(ideal id,BOOLEAN nolex=TRUE); |
---|
209 | ideal idModulo (ideal h1,ideal h2, tHomog h=testHomog, intvec ** w=NULL); |
---|
210 | int idElem(const ideal F); |
---|
211 | matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how); |
---|
212 | // transpose a module |
---|
213 | ideal idTransp(ideal a); |
---|
214 | // version of "ideal idTransp(ideal)" which works within a given ring. |
---|
215 | ideal id_Transp(ideal a, const ring rRing); |
---|
216 | |
---|
217 | intvec *idQHomWeight(ideal id); |
---|
218 | |
---|
219 | void idNormalize(ideal id); |
---|
220 | |
---|
221 | ideal idXXX (ideal h1, int k); |
---|
222 | |
---|
223 | poly id_GCD(poly f, poly g, const ring r); |
---|
224 | |
---|
225 | ideal idChineseRemainder(ideal *x, number *q, int rl); |
---|
226 | //ideal idChineseRemainder(ideal *x, intvec *iv); /* currently unused */ |
---|
227 | ideal idFarey(ideal x, number N); |
---|
228 | |
---|
229 | ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing); // image of certain map for BGG |
---|
230 | |
---|
231 | #ifdef PDEBUG |
---|
232 | /* Shows an ideal -- only for debugging */ |
---|
233 | void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint = 0); |
---|
234 | #else |
---|
235 | #define idShow(id, lmRing, tailRing, debugPrint) ((void)0) |
---|
236 | #endif |
---|
237 | #endif |
---|