1 | #ifndef STRUCTS_H |
---|
2 | #define STRUCTS_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: structs.h,v 1.50 2000-12-19 18:31:46 obachman Exp $ */ |
---|
7 | /* |
---|
8 | * ABSTRACT |
---|
9 | */ |
---|
10 | |
---|
11 | /* standard types */ |
---|
12 | typedef unsigned char uchar ; |
---|
13 | typedef unsigned short CARDINAL; |
---|
14 | typedef short BOOLEAN; |
---|
15 | |
---|
16 | typedef void * Sy_reference; |
---|
17 | #define ADDRESS Sy_reference |
---|
18 | #define BITSET unsigned int |
---|
19 | |
---|
20 | /* EXPONENT_TYPE is determined by configure und defined in mod2.h */ |
---|
21 | /* the following defines should really go into mod2.h, |
---|
22 | but configure dislikes it */ |
---|
23 | |
---|
24 | |
---|
25 | typedef long Exponent_t; |
---|
26 | typedef long Order_t; |
---|
27 | |
---|
28 | enum tHomog |
---|
29 | { |
---|
30 | isNotHomog = FALSE, |
---|
31 | isHomog = TRUE, |
---|
32 | testHomog |
---|
33 | }; |
---|
34 | enum noeof_t |
---|
35 | { |
---|
36 | noeof_brace = 1, |
---|
37 | noeof_asstring, |
---|
38 | noeof_block, |
---|
39 | noeof_bracket, |
---|
40 | noeof_comment, |
---|
41 | noeof_procname, |
---|
42 | noeof_string |
---|
43 | }; |
---|
44 | |
---|
45 | enum n_coeffType |
---|
46 | { |
---|
47 | n_unknown=0, |
---|
48 | n_Zp, |
---|
49 | n_Q, |
---|
50 | n_R, |
---|
51 | n_GF, |
---|
52 | n_long_R, |
---|
53 | n_Zp_a, |
---|
54 | n_Q_a, |
---|
55 | n_long_C |
---|
56 | }; |
---|
57 | |
---|
58 | #ifdef HAVE_PLURAL |
---|
59 | enum nc_type |
---|
60 | { |
---|
61 | nc_general, |
---|
62 | nc_skew, |
---|
63 | nc_lie |
---|
64 | }; |
---|
65 | #endif |
---|
66 | |
---|
67 | |
---|
68 | /* C++-part */ |
---|
69 | #ifdef __cplusplus |
---|
70 | class ip_smatrix; |
---|
71 | class idrec; |
---|
72 | class intvec; |
---|
73 | class sleftv; |
---|
74 | class slists; |
---|
75 | class sattr; |
---|
76 | class skStrategy; |
---|
77 | class ssyStrategy; |
---|
78 | class procinfo; |
---|
79 | class namerec; |
---|
80 | class kBucket; |
---|
81 | #endif |
---|
82 | |
---|
83 | struct n_Procs_s; |
---|
84 | struct sip_sring; |
---|
85 | struct sip_sideal; |
---|
86 | struct sip_link; |
---|
87 | struct spolynom; |
---|
88 | struct _ssubexpr; |
---|
89 | struct _sssym; |
---|
90 | struct snumber; |
---|
91 | struct sip_command; |
---|
92 | struct sip_package; |
---|
93 | struct s_si_link_extension; |
---|
94 | struct reca; |
---|
95 | |
---|
96 | typedef struct n_Procs_s n_Procs_s; |
---|
97 | |
---|
98 | #ifdef HAVE_PLURAL |
---|
99 | struct nc_struct; |
---|
100 | typedef struct nc_struct nc_struct; |
---|
101 | #endif |
---|
102 | |
---|
103 | typedef struct _ssubexpr sSubexpr; |
---|
104 | typedef struct _sssym ssym; |
---|
105 | typedef struct spolyrec polyrec; |
---|
106 | typedef struct snumber rnumber; |
---|
107 | typedef struct sip_sideal ip_sideal; |
---|
108 | typedef struct sip_smap ip_smap; |
---|
109 | typedef struct sip_sring ip_sring; |
---|
110 | typedef struct sip_link ip_link; |
---|
111 | typedef struct sip_command ip_command; |
---|
112 | typedef struct sip_package ip_package; |
---|
113 | |
---|
114 | /* the pointer types */ |
---|
115 | typedef char * char_ptr; |
---|
116 | typedef int * int_ptr; |
---|
117 | typedef short * short_ptr; |
---|
118 | typedef void * void_ptr; |
---|
119 | typedef ip_sring * ring; |
---|
120 | typedef int idtyp; |
---|
121 | typedef rnumber * number; |
---|
122 | typedef polyrec * poly; |
---|
123 | typedef poly * polyset; |
---|
124 | typedef ip_sideal * ideal; |
---|
125 | typedef ip_smap * map; |
---|
126 | typedef ideal * resolvente; |
---|
127 | typedef union uutypes utypes; |
---|
128 | typedef ip_command * command; |
---|
129 | typedef struct s_si_link_extension *si_link_extension; |
---|
130 | typedef struct reca * alg; |
---|
131 | #define napoly alg |
---|
132 | |
---|
133 | #ifdef __cplusplus |
---|
134 | typedef idrec * idhdl; |
---|
135 | typedef ip_smatrix * matrix; |
---|
136 | typedef ip_link * si_link; |
---|
137 | typedef sleftv * leftv; |
---|
138 | typedef slists * lists; |
---|
139 | typedef sSubexpr * Subexpr; |
---|
140 | typedef sattr * attr; |
---|
141 | typedef skStrategy * kStrategy; |
---|
142 | typedef ip_package * package; |
---|
143 | typedef ssyStrategy * syStrategy; |
---|
144 | typedef procinfo * procinfov; |
---|
145 | typedef namerec * namehdl; |
---|
146 | typedef kBucket* kBucket_pt; |
---|
147 | typedef struct p_Procs_s p_Procs_s; |
---|
148 | |
---|
149 | // for hdegree.cc |
---|
150 | typedef struct sindlist indlist; |
---|
151 | typedef indlist * indset; |
---|
152 | struct sindlist |
---|
153 | { |
---|
154 | indset nx; |
---|
155 | intvec * set; |
---|
156 | }; |
---|
157 | |
---|
158 | // for longalg.cc |
---|
159 | struct snaIdeal |
---|
160 | { |
---|
161 | int anz; |
---|
162 | alg *liste; |
---|
163 | }; |
---|
164 | typedef struct snaIdeal * naIdeal; |
---|
165 | |
---|
166 | |
---|
167 | // for sparsemat.cc |
---|
168 | typedef struct smprec sm_prec; |
---|
169 | typedef sm_prec * smpoly; |
---|
170 | struct smprec |
---|
171 | { |
---|
172 | smpoly n; // the next element |
---|
173 | int pos; // position |
---|
174 | int e; // level |
---|
175 | poly m; // the element |
---|
176 | float f; // complexity of the element |
---|
177 | }; |
---|
178 | |
---|
179 | struct _scmdnames |
---|
180 | { |
---|
181 | char *name; |
---|
182 | short alias; |
---|
183 | short tokval; |
---|
184 | short toktype; |
---|
185 | }; |
---|
186 | typedef struct _scmdnames cmdnames; |
---|
187 | |
---|
188 | typedef number (*numberfunc)(number a,number b); |
---|
189 | typedef number (*nMapFunc)(number a); |
---|
190 | struct n_Procs_s |
---|
191 | { |
---|
192 | n_Procs_s* next; |
---|
193 | int nChar; |
---|
194 | n_coeffType type; |
---|
195 | int char_flag; |
---|
196 | int ref; |
---|
197 | // the union stuff |
---|
198 | // Zp: |
---|
199 | int npPrimeM; |
---|
200 | int npPminus1M; |
---|
201 | CARDINAL *npExpTable; |
---|
202 | CARDINAL *npLogTable; |
---|
203 | // Zp_a, Q_a |
---|
204 | |
---|
205 | // general stuff |
---|
206 | numberfunc nMult, nSub ,nAdd ,nDiv, nIntDiv, nIntMod, nExactDiv; |
---|
207 | void (*nNew)(number * a); |
---|
208 | number (*nInit)(int i); |
---|
209 | number (*nPar)(int i); |
---|
210 | int (*nParDeg)(number n); |
---|
211 | int (*nSize)(number n); |
---|
212 | int (*nInt)(number &n); |
---|
213 | number (*nNeg)(number a); |
---|
214 | number (*nInvers)(number a); |
---|
215 | number (*nCopy)(number a); |
---|
216 | number (*nRePart)(number a); |
---|
217 | number (*nImPart)(number a); |
---|
218 | void (*nWrite)(number &a); |
---|
219 | char * (*nRead)(char * s, number * a); |
---|
220 | void (*nNormalize)(number &a); |
---|
221 | BOOLEAN (*nGreater)(number a,number b), |
---|
222 | (*nEqual)(number a,number b), |
---|
223 | (*nIsZero)(number a), |
---|
224 | (*nIsOne)(number a), |
---|
225 | (*nIsMOne)(number a), |
---|
226 | (*nGreaterZero)(number a); |
---|
227 | void (*nPower)(number a, int i, number * result); |
---|
228 | number (*nGetDenom)(number &n); |
---|
229 | numberfunc nGcd, nLcm; |
---|
230 | nMapFunc (*nSetMap)(ring src, ring dst); |
---|
231 | #ifdef LDEBUG |
---|
232 | BOOLEAN (*nDBTest)(number a, char *f, int l); |
---|
233 | void (*nDBDelete)(number * a,char *f, int l); |
---|
234 | #else |
---|
235 | void (*nDelete)(number * a); |
---|
236 | #endif |
---|
237 | char * (*nName)(number n); |
---|
238 | //extern number (*nMap)(number from); |
---|
239 | |
---|
240 | number nNULL; /* the 0 as constant */ |
---|
241 | }; |
---|
242 | |
---|
243 | /* the function pointer types */ |
---|
244 | |
---|
245 | extern ring currRing; |
---|
246 | typedef long (*pLDegProc)(poly p, int *length, ring r= currRing); |
---|
247 | typedef long (*pFDegProc)(poly p, ring r = currRing); |
---|
248 | typedef void (*p_SetmProc)(poly p, ring r = currRing); |
---|
249 | |
---|
250 | typedef enum |
---|
251 | { |
---|
252 | ro_dp, // ordering is a degree ordering |
---|
253 | ro_wp, // ordering is a weighted degree ordering |
---|
254 | ro_wp_neg, // ordering is a weighted degree ordering |
---|
255 | // with possibly negative weights |
---|
256 | ro_cp, // ordering duplicates variables |
---|
257 | ro_syzcomp, // ordering indicates "subset" of component number |
---|
258 | ro_syz, // ordering with component number >syzcomp is lower |
---|
259 | ro_none |
---|
260 | } |
---|
261 | ro_typ; |
---|
262 | |
---|
263 | // ordering is a degree ordering |
---|
264 | struct sro_dp |
---|
265 | { |
---|
266 | short place; // where degree is stored (in L): |
---|
267 | short start; // bounds of ordering (in E): |
---|
268 | short end; |
---|
269 | }; |
---|
270 | typedef struct sro_dp sro_dp; |
---|
271 | |
---|
272 | // ordering is a weighted degree ordering |
---|
273 | struct sro_wp |
---|
274 | { |
---|
275 | short place; // where weighted degree is stored (in L) |
---|
276 | short start; // bounds of ordering (in E) |
---|
277 | short end; |
---|
278 | int *weights; // pointers into wvhdl field |
---|
279 | }; |
---|
280 | typedef struct sro_wp sro_wp; |
---|
281 | |
---|
282 | // ordering duplicates variables |
---|
283 | struct sro_cp |
---|
284 | { |
---|
285 | short place; // where start is copied to (in E) |
---|
286 | short start; // bounds of sources of copied variables (in E) |
---|
287 | short end; |
---|
288 | }; |
---|
289 | typedef struct sro_cp sro_cp; |
---|
290 | |
---|
291 | // ordering indicates "subset" of component number |
---|
292 | struct sro_syzcomp |
---|
293 | { |
---|
294 | short place; // where the index is stored (in L) |
---|
295 | long *ShiftedComponents; // pointer into index field |
---|
296 | int* Components; |
---|
297 | #ifdef PDEBUG |
---|
298 | long length; |
---|
299 | #endif |
---|
300 | }; |
---|
301 | typedef struct sro_syzcomp sro_syzcomp; |
---|
302 | |
---|
303 | // ordering with component number >syzcomp is lower |
---|
304 | struct sro_syz |
---|
305 | { |
---|
306 | short place; // where the index is stored (in L) |
---|
307 | int limit; // syzcomp |
---|
308 | int* syz_index; // mapping Component -> SyzIndex for Comp <= limit |
---|
309 | int curr_index; // SyzIndex for Component > limit |
---|
310 | }; |
---|
311 | |
---|
312 | typedef struct sro_syz sro_syz; |
---|
313 | |
---|
314 | #ifndef OM_ALLOC_H |
---|
315 | struct omBin_s; |
---|
316 | #endif |
---|
317 | |
---|
318 | struct sro_ord |
---|
319 | { |
---|
320 | ro_typ ord_typ; |
---|
321 | int order_index; // comes from r->order[order_index] |
---|
322 | union |
---|
323 | { |
---|
324 | sro_dp dp; |
---|
325 | sro_wp wp; |
---|
326 | sro_cp cp; |
---|
327 | sro_syzcomp syzcomp; |
---|
328 | sro_syz syz; |
---|
329 | } data; |
---|
330 | }; |
---|
331 | |
---|
332 | #ifdef HAVE_PLURAL |
---|
333 | struct nc_struct |
---|
334 | { |
---|
335 | nc_type type; |
---|
336 | matrix C; |
---|
337 | matrix D; |
---|
338 | matrix *MT; |
---|
339 | int *MTsize; |
---|
340 | }; |
---|
341 | #endif |
---|
342 | |
---|
343 | struct sip_sring |
---|
344 | { |
---|
345 | idhdl idroot; /* local objects */ |
---|
346 | int* order; /* array of orderings */ |
---|
347 | int* block0; /* starting pos.*/ |
---|
348 | int* block1; /* ending pos.*/ |
---|
349 | char** parameter; /* names of parameters */ |
---|
350 | number minpoly; |
---|
351 | int** wvhdl; /* array of weight vectors */ |
---|
352 | char ** names; /* array of variable names */ |
---|
353 | |
---|
354 | unsigned long options; /* ring dependent options */ |
---|
355 | |
---|
356 | // what follows below here should be set by rComplete, _only_ |
---|
357 | long *ordsgn; /* array of +/- 1 (or 0) for comparing monomials */ |
---|
358 | /* ExpL_Size entries*/ |
---|
359 | |
---|
360 | // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */ |
---|
361 | sro_ord* typ; /* array of orderings + sizes, OrdSize entries */ |
---|
362 | |
---|
363 | ideal qideal; /* extension to the ring structure: qring */ |
---|
364 | |
---|
365 | |
---|
366 | int *VarOffset; |
---|
367 | int* firstwv; |
---|
368 | |
---|
369 | struct omBin_s* PolyBin; /* Bin from where monoms are allocated */ |
---|
370 | short ch; /* characteristic */ |
---|
371 | short ch_flags; /* additional char-flags */ |
---|
372 | |
---|
373 | short N; /* number of vars */ |
---|
374 | |
---|
375 | short P; /* number of pars */ |
---|
376 | short OrdSgn; /* 1 for polynomial rings, -1 otherwise */ |
---|
377 | |
---|
378 | short firstBlockEnds; |
---|
379 | |
---|
380 | |
---|
381 | BOOLEAN VectorOut; |
---|
382 | BOOLEAN ShortOut; |
---|
383 | BOOLEAN CanShortOut; |
---|
384 | BOOLEAN LexOrder; |
---|
385 | // TRUE if the monomial ordering has polynomial and power series blocks |
---|
386 | BOOLEAN MixedOrder; |
---|
387 | // 1 for lex ordering (except ls), -1 otherwise |
---|
388 | BOOLEAN ComponentOrder; |
---|
389 | |
---|
390 | |
---|
391 | // what follows below here should be set by rComplete, _only_ |
---|
392 | // contains component, but no weight fields in E */ |
---|
393 | short ExpL_Size; // size of exponent vector in long |
---|
394 | short CmpL_Size; // portions which need to be compared |
---|
395 | /* number of long vars in exp vector: |
---|
396 | long vars are those longs in the exponent vector which are |
---|
397 | occupied by variables, only */ |
---|
398 | short VarL_Size; |
---|
399 | |
---|
400 | short BitsPerExp; /* number of bits per exponent */ |
---|
401 | short ExpPerLong; /* maximal number of Exponents per long */ |
---|
402 | |
---|
403 | short pCompIndex; /* p->exp.e[pCompIndex] is the component */ |
---|
404 | short pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */ |
---|
405 | |
---|
406 | short OrdSize; /* size of ord vector (in sro_ord) */ |
---|
407 | |
---|
408 | |
---|
409 | short ref; /* reference counter to the ring */ |
---|
410 | |
---|
411 | /* if >= 0, long vars in exp vector are consecutive and start there |
---|
412 | if < 0, long vars in exp vector are not consecutive */ |
---|
413 | short VarL_LowIndex; |
---|
414 | // number of exponents in r->VarL_Offset[0] |
---|
415 | // is minimal number of exponents in a long var |
---|
416 | short MinExpPerLong; |
---|
417 | |
---|
418 | /* if this is > 0, then NegWeightL_Offset[0..size_1] is index of longs in |
---|
419 | ExpVector whose values need an offset due to negative weights */ |
---|
420 | short NegWeightL_Size; |
---|
421 | /* array of NegWeigtL_Size indicies */ |
---|
422 | int* NegWeightL_Offset; |
---|
423 | |
---|
424 | /* array of size VarL_Size, |
---|
425 | VarL_Offset[i] gets i-th long var in exp vector */ |
---|
426 | int* VarL_Offset; |
---|
427 | |
---|
428 | /* mask for getting single exponents */ |
---|
429 | unsigned long bitmask; |
---|
430 | /* mask used for divisiblity tests */ |
---|
431 | unsigned long divmask; |
---|
432 | |
---|
433 | p_Procs_s* p_Procs; |
---|
434 | pFDegProc pFDeg; |
---|
435 | pLDegProc pLDeg; |
---|
436 | p_SetmProc p_Setm; |
---|
437 | n_Procs_s* cf; |
---|
438 | ring algring; |
---|
439 | #ifdef HAVE_PLURAL |
---|
440 | nc_struct *nc; |
---|
441 | #endif |
---|
442 | }; |
---|
443 | |
---|
444 | struct sip_sideal |
---|
445 | { |
---|
446 | poly* m; |
---|
447 | long rank; |
---|
448 | int nrows; |
---|
449 | int ncols; |
---|
450 | #define IDELEMS(i) ((i)->ncols) |
---|
451 | inline int& idelems(void) { return ncols; } |
---|
452 | }; |
---|
453 | |
---|
454 | struct sip_smap |
---|
455 | { |
---|
456 | poly *m; |
---|
457 | char *preimage; |
---|
458 | int nrows; |
---|
459 | int ncols; |
---|
460 | }; |
---|
461 | #endif /* __cplusplus */ |
---|
462 | |
---|
463 | |
---|
464 | |
---|
465 | /* |
---|
466 | ** 7. runtime procedures/global data |
---|
467 | */ |
---|
468 | |
---|
469 | /* 7.1 C-routines : */ |
---|
470 | |
---|
471 | |
---|
472 | #ifdef __cplusplus |
---|
473 | extern "C" { |
---|
474 | #endif |
---|
475 | void m2_end(short i); |
---|
476 | #ifdef __cplusplus |
---|
477 | } |
---|
478 | #endif |
---|
479 | |
---|
480 | /* 7.2 C++-routines : */ |
---|
481 | |
---|
482 | #ifdef __cplusplus |
---|
483 | int inits(void); |
---|
484 | #ifdef buildin_rand |
---|
485 | extern int siSeed; |
---|
486 | int siRand(); |
---|
487 | #endif |
---|
488 | #endif |
---|
489 | |
---|
490 | /*the general set of std-options --> kutil.cc */ |
---|
491 | extern BITSET test; |
---|
492 | /*the general set of verbose-options --> febase.cc */ |
---|
493 | #ifdef __cplusplus |
---|
494 | extern "C" BITSET verbose; |
---|
495 | #else |
---|
496 | extern BITSET verbose; |
---|
497 | #endif |
---|
498 | /*debugging the bison grammar --> grammar.cc*/ |
---|
499 | #ifdef YYDEBUG |
---|
500 | #if YYDEBUG |
---|
501 | extern int yydebug; |
---|
502 | #endif |
---|
503 | #endif |
---|
504 | |
---|
505 | #ifdef HAVE_LIBPARSER |
---|
506 | #ifdef __cplusplus |
---|
507 | class libstack; |
---|
508 | typedef libstack * libstackv; |
---|
509 | #endif |
---|
510 | #endif /* HAVE_LIBPARSER */ |
---|
511 | |
---|
512 | extern struct omBin_s* MP_INT_bin; |
---|
513 | extern struct omBin_s* char_ptr_bin; |
---|
514 | extern struct omBin_s* ideal_bin; |
---|
515 | extern struct omBin_s* int_bin; |
---|
516 | extern struct omBin_s* poly_bin; |
---|
517 | extern struct omBin_s* void_ptr_bin; |
---|
518 | extern struct omBin_s* indlist_bin; |
---|
519 | extern struct omBin_s* naIdeal_bin; |
---|
520 | extern struct omBin_s* snaIdeal_bin; |
---|
521 | extern struct omBin_s* sm_prec_bin; |
---|
522 | extern struct omBin_s* smprec_bin; |
---|
523 | extern struct omBin_s* sip_sideal_bin; |
---|
524 | extern struct omBin_s* sip_smap_bin; |
---|
525 | extern struct omBin_s* sip_sring_bin; |
---|
526 | extern struct omBin_s* ip_sideal_bin; |
---|
527 | extern struct omBin_s* ip_smap_bin; |
---|
528 | extern struct omBin_s* ip_sring_bin; |
---|
529 | |
---|
530 | #endif |
---|
531 | |
---|