1 | #ifndef STRUCTS_H |
---|
2 | #define STRUCTS_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: structs.h,v 1.22 2006-05-02 16:24:22 Singular Exp $ */ |
---|
7 | /* |
---|
8 | * ABSTRACT |
---|
9 | */ |
---|
10 | |
---|
11 | #include <string.h> /* for memset */ |
---|
12 | |
---|
13 | /* standard types */ |
---|
14 | typedef unsigned char uchar; |
---|
15 | typedef unsigned short CARDINAL; |
---|
16 | #if (SIZEOF_LONG == 8) |
---|
17 | typedef int BOOLEAN; |
---|
18 | /* testet on x86_64, gcc 3.4.6: 2 % */ |
---|
19 | /* testet on IA64, gcc 3.4.6: 1 % */ |
---|
20 | #else |
---|
21 | /* testet on athlon, gcc 2.95.4: 1 % */ |
---|
22 | typedef short BOOLEAN; |
---|
23 | #endif |
---|
24 | |
---|
25 | typedef void * Sy_reference; |
---|
26 | #define ADDRESS Sy_reference |
---|
27 | #define BITSET unsigned int |
---|
28 | |
---|
29 | /* EXPONENT_TYPE is determined by configure und defined in mod2.h */ |
---|
30 | /* the following defines should really go into mod2.h, |
---|
31 | but configure dislikes it */ |
---|
32 | |
---|
33 | |
---|
34 | #if defined(i386) || defined(x86_64_Linux) |
---|
35 | // the following settings seems to be better on i386 and x86_64 processors |
---|
36 | // define if a*b is with mod instead of tables |
---|
37 | #define HAVE_MULT_MOD |
---|
38 | // #define HAVE_GENERIC_ADD |
---|
39 | // #ifdef HAVE_MULT_MOD |
---|
40 | // #define HAVE_DIV_MOD |
---|
41 | // #endif |
---|
42 | #endif |
---|
43 | |
---|
44 | #ifdef IA64_Linux |
---|
45 | // the following settings seems to be better on itanium processors |
---|
46 | // #define HAVE_MULT_MOD |
---|
47 | #define HAVE_GENERIC_ADD |
---|
48 | // #ifdef HAVE_MULT_MOD |
---|
49 | // #define HAVE_DIV_MOD |
---|
50 | // #endif |
---|
51 | #endif |
---|
52 | |
---|
53 | #ifdef SunOS_5 |
---|
54 | // #define HAVE_GENERIC_ADD |
---|
55 | #define HAVE_MULT_MOD |
---|
56 | #ifdef HAVE_MULT_MOD |
---|
57 | #define HAVE_DIV_MOD |
---|
58 | #endif |
---|
59 | #endif |
---|
60 | |
---|
61 | #if SIZEOF_LONG == 4 |
---|
62 | typedef long long int64; |
---|
63 | #elif SIZEOF_LONG == 8 |
---|
64 | typedef long int64; |
---|
65 | #else |
---|
66 | #error int64 undefined |
---|
67 | #endif |
---|
68 | |
---|
69 | |
---|
70 | typedef long Exponent_t; |
---|
71 | typedef long Order_t; |
---|
72 | |
---|
73 | enum tHomog |
---|
74 | { |
---|
75 | isNotHomog = FALSE, |
---|
76 | isHomog = TRUE, |
---|
77 | testHomog |
---|
78 | }; |
---|
79 | enum noeof_t |
---|
80 | { |
---|
81 | noeof_brace = 1, |
---|
82 | noeof_asstring, |
---|
83 | noeof_block, |
---|
84 | noeof_bracket, |
---|
85 | noeof_comment, |
---|
86 | noeof_procname, |
---|
87 | noeof_string |
---|
88 | }; |
---|
89 | |
---|
90 | enum n_coeffType |
---|
91 | { |
---|
92 | n_unknown=0, |
---|
93 | n_Zp, |
---|
94 | n_Q, |
---|
95 | n_R, |
---|
96 | n_GF, |
---|
97 | n_long_R, |
---|
98 | n_Zp_a, |
---|
99 | n_Q_a, |
---|
100 | n_long_C |
---|
101 | }; |
---|
102 | |
---|
103 | #ifdef HAVE_PLURAL |
---|
104 | enum nc_type |
---|
105 | { |
---|
106 | nc_general=0, /* yx=q xy+... */ |
---|
107 | nc_skew, /*1*/ /* yx=q xy */ |
---|
108 | nc_comm, /*2*/ /* yx= xy */ |
---|
109 | nc_lie, /*3*/ /* yx=xy+... */ |
---|
110 | nc_undef /*4*/ /* for internal reasons */ |
---|
111 | }; |
---|
112 | #endif |
---|
113 | |
---|
114 | typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX, LT_MACH_O} lib_types; |
---|
115 | |
---|
116 | /* C++-part */ |
---|
117 | #ifdef __cplusplus |
---|
118 | class ip_smatrix; |
---|
119 | class idrec; |
---|
120 | class intvec; |
---|
121 | class sleftv; |
---|
122 | class slists; |
---|
123 | class sattr; |
---|
124 | class skStrategy; |
---|
125 | class ssyStrategy; |
---|
126 | class procinfo; |
---|
127 | class namerec; |
---|
128 | class kBucket; |
---|
129 | class sBucket; |
---|
130 | #endif |
---|
131 | |
---|
132 | struct n_Procs_s; |
---|
133 | struct sip_sring; |
---|
134 | struct sip_sideal; |
---|
135 | struct sip_link; |
---|
136 | struct spolynom; |
---|
137 | struct _ssubexpr; |
---|
138 | struct _sssym; |
---|
139 | struct snumber; |
---|
140 | struct sip_command; |
---|
141 | struct sip_package; |
---|
142 | struct s_si_link_extension; |
---|
143 | |
---|
144 | typedef struct n_Procs_s n_Procs_s; |
---|
145 | |
---|
146 | #ifdef HAVE_PLURAL |
---|
147 | struct nc_struct; |
---|
148 | typedef struct nc_struct nc_struct; |
---|
149 | #endif |
---|
150 | |
---|
151 | typedef struct _ssubexpr sSubexpr; |
---|
152 | typedef struct _sssym ssym; |
---|
153 | typedef struct spolyrec polyrec; |
---|
154 | typedef struct sip_sideal ip_sideal; |
---|
155 | typedef struct sip_smap ip_smap; |
---|
156 | typedef struct sip_sring ip_sring; |
---|
157 | typedef struct sip_link ip_link; |
---|
158 | typedef struct sip_command ip_command; |
---|
159 | typedef struct sip_package ip_package; |
---|
160 | |
---|
161 | /* the pointer types */ |
---|
162 | typedef char * char_ptr; |
---|
163 | typedef int * int_ptr; |
---|
164 | typedef short * short_ptr; |
---|
165 | typedef void * void_ptr; |
---|
166 | typedef ip_sring * ring; |
---|
167 | typedef int idtyp; |
---|
168 | typedef struct snumber * number; |
---|
169 | typedef polyrec * poly; |
---|
170 | typedef poly * polyset; |
---|
171 | typedef ip_sideal * ideal; |
---|
172 | typedef ip_smap * map; |
---|
173 | typedef struct sideal_list * ideal_list; |
---|
174 | typedef ideal * resolvente; |
---|
175 | typedef union uutypes utypes; |
---|
176 | typedef ip_command * command; |
---|
177 | typedef struct s_si_link_extension *si_link_extension; |
---|
178 | typedef polyrec * napoly; |
---|
179 | |
---|
180 | #ifdef __cplusplus |
---|
181 | typedef idrec * idhdl; |
---|
182 | typedef ip_smatrix * matrix; |
---|
183 | typedef ip_link * si_link; |
---|
184 | typedef sleftv * leftv; |
---|
185 | typedef slists * lists; |
---|
186 | typedef sSubexpr * Subexpr; |
---|
187 | typedef sattr * attr; |
---|
188 | typedef skStrategy * kStrategy; |
---|
189 | typedef ip_package * package; |
---|
190 | typedef ssyStrategy * syStrategy; |
---|
191 | typedef procinfo * procinfov; |
---|
192 | typedef namerec * namehdl; |
---|
193 | typedef kBucket* kBucket_pt; |
---|
194 | typedef sBucket* sBucket_pt; |
---|
195 | typedef struct p_Procs_s p_Procs_s; |
---|
196 | |
---|
197 | // for hdegree.cc |
---|
198 | typedef struct sindlist indlist; |
---|
199 | typedef indlist * indset; |
---|
200 | struct sindlist |
---|
201 | { |
---|
202 | indset nx; |
---|
203 | intvec * set; |
---|
204 | }; |
---|
205 | |
---|
206 | // for longalg.cc |
---|
207 | struct snaIdeal |
---|
208 | { |
---|
209 | int anz; |
---|
210 | napoly *liste; |
---|
211 | }; |
---|
212 | typedef struct snaIdeal * naIdeal; |
---|
213 | |
---|
214 | |
---|
215 | // for sparsemat.cc |
---|
216 | typedef struct smprec sm_prec; |
---|
217 | typedef sm_prec * smpoly; |
---|
218 | struct smprec |
---|
219 | { |
---|
220 | smpoly n; // the next element |
---|
221 | int pos; // position |
---|
222 | int e; // level |
---|
223 | poly m; // the element |
---|
224 | float f; // complexity of the element |
---|
225 | }; |
---|
226 | |
---|
227 | struct _scmdnames |
---|
228 | { |
---|
229 | char *name; |
---|
230 | short alias; |
---|
231 | short tokval; |
---|
232 | short toktype; |
---|
233 | }; |
---|
234 | typedef struct _scmdnames cmdnames; |
---|
235 | |
---|
236 | typedef number (*numberfunc)(number a,number b); |
---|
237 | typedef number (*nMapFunc)(number a); |
---|
238 | struct n_Procs_s |
---|
239 | { |
---|
240 | n_Procs_s* next; |
---|
241 | // the union stuff |
---|
242 | // Zp: |
---|
243 | int npPrimeM; |
---|
244 | int npPminus1M; |
---|
245 | #ifdef HAVE_DIV_MOD |
---|
246 | CARDINAL *npInvTable; |
---|
247 | #endif |
---|
248 | #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD) |
---|
249 | CARDINAL *npExpTable; |
---|
250 | CARDINAL *npLogTable; |
---|
251 | #endif |
---|
252 | // Zp_a, Q_a |
---|
253 | |
---|
254 | // general stuff |
---|
255 | numberfunc nMult, nSub ,nAdd ,nDiv, nIntDiv, nIntMod, nExactDiv; |
---|
256 | void (*nNew)(number * a); |
---|
257 | number (*nInit)(int i); |
---|
258 | number (*nPar)(int i); |
---|
259 | int (*nParDeg)(number n); |
---|
260 | int (*nSize)(number n); |
---|
261 | int (*nInt)(number &n); |
---|
262 | number (*nNeg)(number a); |
---|
263 | number (*nInvers)(number a); |
---|
264 | number (*nCopy)(number a); |
---|
265 | number (*cfCopy)(number a, const ring r); |
---|
266 | number (*nRePart)(number a); |
---|
267 | number (*nImPart)(number a); |
---|
268 | void (*nWrite)(number &a); |
---|
269 | char * (*nRead)(char * s, number * a); |
---|
270 | void (*nNormalize)(number &a); |
---|
271 | BOOLEAN (*nGreater)(number a,number b), |
---|
272 | (*nEqual)(number a,number b), |
---|
273 | (*nIsZero)(number a), |
---|
274 | (*nIsOne)(number a), |
---|
275 | (*nIsMOne)(number a), |
---|
276 | (*nGreaterZero)(number a); |
---|
277 | void (*nPower)(number a, int i, number * result); |
---|
278 | number (*n_GetDenom)(number &n, const ring r); |
---|
279 | number (*nGcd)(number a, number b, const ring r); |
---|
280 | number (*nLcm)(number a, number b, const ring r); |
---|
281 | void (*cfDelete)(number * a, const ring r); |
---|
282 | nMapFunc (*cfSetMap)(ring src, ring dst); |
---|
283 | char * (*nName)(number n); |
---|
284 | void (*nInpMult)(number &a, number b, ring r); |
---|
285 | //extern number (*nMap)(number from); |
---|
286 | |
---|
287 | number nNULL; /* the 0 as constant */ |
---|
288 | int char_flag; |
---|
289 | int ref; |
---|
290 | short nChar; |
---|
291 | n_coeffType type; |
---|
292 | }; |
---|
293 | /* current ring stuff */ |
---|
294 | |
---|
295 | extern ring currRing; |
---|
296 | extern ideal currQuotient; |
---|
297 | extern idhdl currRingHdl; |
---|
298 | |
---|
299 | #ifndef HAVE_NS |
---|
300 | extern idhdl idroot; |
---|
301 | #define IDROOT idroot |
---|
302 | #endif /* ! HAVE_NS */ |
---|
303 | |
---|
304 | #ifdef HAVE_NS |
---|
305 | extern idhdl currPackHdl; |
---|
306 | extern idhdl basePackHdl; |
---|
307 | extern package currPack; |
---|
308 | extern package basePack; |
---|
309 | #define IDROOT (currPack->idroot) |
---|
310 | #endif /* HAVE_NS */ |
---|
311 | |
---|
312 | /* the function pointer types */ |
---|
313 | |
---|
314 | typedef long (*pLDegProc)(poly p, int *length, ring r); |
---|
315 | typedef long (*pFDegProc)(poly p, ring r); |
---|
316 | typedef void (*p_SetmProc)(poly p, ring r); |
---|
317 | |
---|
318 | typedef enum |
---|
319 | { |
---|
320 | ro_dp, // ordering is a degree ordering |
---|
321 | ro_wp, // ordering is a weighted degree ordering |
---|
322 | ro_wp64, // ordering is a weighted64 degree ordering |
---|
323 | ro_wp_neg, // ordering is a weighted degree ordering |
---|
324 | // with possibly negative weights |
---|
325 | ro_cp, // ordering duplicates variables |
---|
326 | ro_syzcomp, // ordering indicates "subset" of component number |
---|
327 | ro_syz, // ordering with component number >syzcomp is lower |
---|
328 | ro_none |
---|
329 | } |
---|
330 | ro_typ; |
---|
331 | |
---|
332 | // ordering is a degree ordering |
---|
333 | struct sro_dp |
---|
334 | { |
---|
335 | short place; // where degree is stored (in L): |
---|
336 | short start; // bounds of ordering (in E): |
---|
337 | short end; |
---|
338 | }; |
---|
339 | typedef struct sro_dp sro_dp; |
---|
340 | |
---|
341 | // ordering is a weighted degree ordering |
---|
342 | struct sro_wp |
---|
343 | { |
---|
344 | short place; // where weighted degree is stored (in L) |
---|
345 | short start; // bounds of ordering (in E) |
---|
346 | short end; |
---|
347 | int *weights; // pointers into wvhdl field |
---|
348 | }; |
---|
349 | typedef struct sro_wp sro_wp; |
---|
350 | |
---|
351 | // ordering is a weighted degree ordering |
---|
352 | struct sro_wp64 |
---|
353 | { |
---|
354 | short place; // where weighted degree is stored (in L) |
---|
355 | short start; // bounds of ordering (in E) |
---|
356 | short end; |
---|
357 | int64 *weights64; // pointers into wvhdl field |
---|
358 | }; |
---|
359 | typedef struct sro_wp64 sro_wp64; |
---|
360 | |
---|
361 | // ordering duplicates variables |
---|
362 | struct sro_cp |
---|
363 | { |
---|
364 | short place; // where start is copied to (in E) |
---|
365 | short start; // bounds of sources of copied variables (in E) |
---|
366 | short end; |
---|
367 | }; |
---|
368 | typedef struct sro_cp sro_cp; |
---|
369 | |
---|
370 | // ordering indicates "subset" of component number |
---|
371 | struct sro_syzcomp |
---|
372 | { |
---|
373 | short place; // where the index is stored (in L) |
---|
374 | long *ShiftedComponents; // pointer into index field |
---|
375 | int* Components; |
---|
376 | #ifdef PDEBUG |
---|
377 | long length; |
---|
378 | #endif |
---|
379 | }; |
---|
380 | typedef struct sro_syzcomp sro_syzcomp; |
---|
381 | |
---|
382 | // ordering with component number >syzcomp is lower |
---|
383 | struct sro_syz |
---|
384 | { |
---|
385 | short place; // where the index is stored (in L) |
---|
386 | int limit; // syzcomp |
---|
387 | int* syz_index; // mapping Component -> SyzIndex for Comp <= limit |
---|
388 | int curr_index; // SyzIndex for Component > limit |
---|
389 | }; |
---|
390 | |
---|
391 | typedef struct sro_syz sro_syz; |
---|
392 | |
---|
393 | #ifndef OM_ALLOC_H |
---|
394 | struct omBin_s; |
---|
395 | #endif |
---|
396 | |
---|
397 | struct sro_ord |
---|
398 | { |
---|
399 | ro_typ ord_typ; |
---|
400 | int order_index; // comes from r->order[order_index] |
---|
401 | union |
---|
402 | { |
---|
403 | sro_dp dp; |
---|
404 | sro_wp wp; |
---|
405 | sro_wp64 wp64; |
---|
406 | sro_cp cp; |
---|
407 | sro_syzcomp syzcomp; |
---|
408 | sro_syz syz; |
---|
409 | } data; |
---|
410 | }; |
---|
411 | |
---|
412 | #ifdef HAVE_PLURAL |
---|
413 | struct nc_struct |
---|
414 | { |
---|
415 | short ref; |
---|
416 | nc_type type; |
---|
417 | ring basering; // the ring C,D,.. live in |
---|
418 | matrix C; |
---|
419 | matrix D; |
---|
420 | matrix *MT; |
---|
421 | matrix COM; |
---|
422 | int *MTsize; |
---|
423 | int IsSkewConstant; /* indicates whethere coeffs C_ij are all equal */ |
---|
424 | /* effective together with nc_type=nc_skew */ |
---|
425 | }; |
---|
426 | #endif |
---|
427 | |
---|
428 | struct sip_sring |
---|
429 | { |
---|
430 | idhdl idroot; /* local objects */ |
---|
431 | int* order; /* array of orderings */ |
---|
432 | int* block0; /* starting pos.*/ |
---|
433 | int* block1; /* ending pos.*/ |
---|
434 | char** parameter; /* names of parameters */ |
---|
435 | number minpoly; |
---|
436 | ideal minideal; |
---|
437 | int** wvhdl; /* array of weight vectors */ |
---|
438 | char ** names; /* array of variable names */ |
---|
439 | |
---|
440 | unsigned long options; /* ring dependent options */ |
---|
441 | |
---|
442 | // what follows below here should be set by rComplete, _only_ |
---|
443 | long *ordsgn; /* array of +/- 1 (or 0) for comparing monomials */ |
---|
444 | /* ExpL_Size entries*/ |
---|
445 | |
---|
446 | // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */ |
---|
447 | sro_ord* typ; /* array of orderings + sizes, OrdSize entries */ |
---|
448 | |
---|
449 | ideal qideal; /* extension to the ring structure: qring */ |
---|
450 | |
---|
451 | |
---|
452 | int* VarOffset; |
---|
453 | int* firstwv; |
---|
454 | |
---|
455 | struct omBin_s* PolyBin; /* Bin from where monoms are allocated */ |
---|
456 | int ch; /* characteristic */ |
---|
457 | #ifdef HAVE_RING2TOM |
---|
458 | int cring; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ |
---|
459 | #endif |
---|
460 | int ref; /* reference counter to the ring */ |
---|
461 | |
---|
462 | short float_len; /* additional char-flags */ |
---|
463 | short float_len2; /* additional char-flags */ |
---|
464 | |
---|
465 | short N; /* number of vars */ |
---|
466 | |
---|
467 | short P; /* number of pars */ |
---|
468 | short OrdSgn; /* 1 for polynomial rings, -1 otherwise */ |
---|
469 | |
---|
470 | short firstBlockEnds; |
---|
471 | |
---|
472 | |
---|
473 | BOOLEAN VectorOut; |
---|
474 | BOOLEAN ShortOut; |
---|
475 | BOOLEAN CanShortOut; |
---|
476 | BOOLEAN LexOrder; |
---|
477 | // TRUE if the monomial ordering has polynomial and power series blocks |
---|
478 | BOOLEAN MixedOrder; |
---|
479 | // 1 for lex ordering (except ls), -1 otherwise |
---|
480 | BOOLEAN ComponentOrder; |
---|
481 | |
---|
482 | |
---|
483 | // what follows below here should be set by rComplete, _only_ |
---|
484 | // contains component, but no weight fields in E */ |
---|
485 | short ExpL_Size; // size of exponent vector in long |
---|
486 | short CmpL_Size; // portions which need to be compared |
---|
487 | /* number of long vars in exp vector: |
---|
488 | long vars are those longs in the exponent vector which are |
---|
489 | occupied by variables, only */ |
---|
490 | short VarL_Size; |
---|
491 | |
---|
492 | short BitsPerExp; /* number of bits per exponent */ |
---|
493 | short ExpPerLong; /* maximal number of Exponents per long */ |
---|
494 | |
---|
495 | short pCompIndex; /* p->exp.e[pCompIndex] is the component */ |
---|
496 | short pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */ |
---|
497 | |
---|
498 | short OrdSize; /* size of ord vector (in sro_ord) */ |
---|
499 | |
---|
500 | |
---|
501 | /* if >= 0, long vars in exp vector are consecutive and start there |
---|
502 | if < 0, long vars in exp vector are not consecutive */ |
---|
503 | short VarL_LowIndex; |
---|
504 | // number of exponents in r->VarL_Offset[0] |
---|
505 | // is minimal number of exponents in a long var |
---|
506 | short MinExpPerLong; |
---|
507 | |
---|
508 | /* if this is > 0, then NegWeightL_Offset[0..size_1] is index of longs in |
---|
509 | ExpVector whose values need an offset due to negative weights */ |
---|
510 | short NegWeightL_Size; |
---|
511 | /* array of NegWeigtL_Size indicies */ |
---|
512 | int* NegWeightL_Offset; |
---|
513 | |
---|
514 | /* array of size VarL_Size, |
---|
515 | VarL_Offset[i] gets i-th long var in exp vector */ |
---|
516 | int* VarL_Offset; |
---|
517 | |
---|
518 | /* mask for getting single exponents */ |
---|
519 | unsigned long bitmask; |
---|
520 | /* mask used for divisiblity tests */ |
---|
521 | unsigned long divmask; |
---|
522 | |
---|
523 | p_Procs_s* p_Procs; |
---|
524 | |
---|
525 | /* FDeg and LDeg */ |
---|
526 | pFDegProc pFDeg; |
---|
527 | pLDegProc pLDeg; |
---|
528 | |
---|
529 | /* as it was determined by rComplete */ |
---|
530 | pFDegProc pFDegOrig; |
---|
531 | /* and as it was determined before rOptimizeLDeg */ |
---|
532 | pLDegProc pLDegOrig; |
---|
533 | |
---|
534 | p_SetmProc p_Setm; |
---|
535 | n_Procs_s* cf; |
---|
536 | ring algring; |
---|
537 | #ifdef HAVE_PLURAL |
---|
538 | nc_struct *nc; |
---|
539 | #endif |
---|
540 | }; |
---|
541 | |
---|
542 | struct sip_sideal |
---|
543 | { |
---|
544 | poly* m; |
---|
545 | long rank; |
---|
546 | int nrows; |
---|
547 | int ncols; |
---|
548 | #define IDELEMS(i) ((i)->ncols) |
---|
549 | inline int& idelems(void) { return ncols; } |
---|
550 | }; |
---|
551 | |
---|
552 | struct sip_smap |
---|
553 | { |
---|
554 | poly *m; |
---|
555 | char *preimage; |
---|
556 | int nrows; |
---|
557 | int ncols; |
---|
558 | }; |
---|
559 | |
---|
560 | struct sideal_list |
---|
561 | { |
---|
562 | ideal_list next; |
---|
563 | ideal d; |
---|
564 | #ifndef NDEBUG |
---|
565 | int nr; |
---|
566 | #endif |
---|
567 | }; |
---|
568 | #endif /* __cplusplus */ |
---|
569 | |
---|
570 | |
---|
571 | |
---|
572 | /* |
---|
573 | ** 7. runtime procedures/global data |
---|
574 | */ |
---|
575 | |
---|
576 | /* 7.1 C-routines : */ |
---|
577 | |
---|
578 | |
---|
579 | #ifdef __cplusplus |
---|
580 | extern "C" { |
---|
581 | #endif |
---|
582 | void m2_end(int i); |
---|
583 | #ifdef __cplusplus |
---|
584 | } |
---|
585 | #endif |
---|
586 | |
---|
587 | /* 7.2 C++-routines : */ |
---|
588 | |
---|
589 | #ifdef __cplusplus |
---|
590 | int inits(void); |
---|
591 | int IsPrime(int i); |
---|
592 | #ifdef buildin_rand |
---|
593 | extern int siSeed; |
---|
594 | int siRand(); |
---|
595 | #endif |
---|
596 | #endif |
---|
597 | |
---|
598 | /*the general set of std-options --> kutil.cc */ |
---|
599 | extern BITSET test; |
---|
600 | /*the general set of verbose-options --> febase.cc */ |
---|
601 | #ifdef __cplusplus |
---|
602 | extern "C" BITSET verbose; |
---|
603 | #else |
---|
604 | extern BITSET verbose; |
---|
605 | #endif |
---|
606 | /*debugging the bison grammar --> grammar.cc*/ |
---|
607 | #ifdef YYDEBUG |
---|
608 | #if YYDEBUG |
---|
609 | extern int yydebug; |
---|
610 | #endif |
---|
611 | #endif |
---|
612 | |
---|
613 | extern int yylineno; |
---|
614 | extern char my_yylinebuf[80]; |
---|
615 | |
---|
616 | #define loop for(;;) |
---|
617 | |
---|
618 | #ifndef ABS |
---|
619 | #define ABS(x) ((x)<0?(-(x)):(x)) |
---|
620 | #endif |
---|
621 | |
---|
622 | #if defined(__cplusplus) |
---|
623 | inline int si_max(const int a, const int b) { return (a>b) ? a : b; } |
---|
624 | inline int si_min(const int a, const int b) { return (a<b) ? a : b; } |
---|
625 | #if defined(DecAlpha_Linux) || defined(IA64_Linux) |
---|
626 | inline long si_max(const long a, const long b) { return (a>b) ? a : b; } |
---|
627 | inline long si_min(const long a, const long b) { return (a<b) ? a : b; } |
---|
628 | #endif |
---|
629 | #else |
---|
630 | #define si_max(A,B) ((A) > (B) ? (A) : (B)) |
---|
631 | #define si_min(A,B) ((A) < (B) ? (A) : (B)) |
---|
632 | #endif |
---|
633 | |
---|
634 | /* |
---|
635 | ** Set operations (small sets only) |
---|
636 | */ |
---|
637 | |
---|
638 | #define Sy_bit(x) ((unsigned)1<<(x)) |
---|
639 | #define Sy_inset(x,s) ((Sy_bit(x)&(s))?TRUE:FALSE) |
---|
640 | #define BTEST1(a) Sy_inset((a), test) |
---|
641 | #define BVERBOSE(a) Sy_inset((a), verbose) |
---|
642 | |
---|
643 | /* |
---|
644 | ** defines for BITSETs |
---|
645 | */ |
---|
646 | |
---|
647 | #define V_SHOW_MEM 2 |
---|
648 | #define V_YACC 3 |
---|
649 | #define V_REDEFINE 4 |
---|
650 | #define V_READING 5 |
---|
651 | #define V_LOAD_LIB 6 |
---|
652 | #define V_DEBUG_LIB 7 |
---|
653 | #define V_LOAD_PROC 8 |
---|
654 | #define V_DEF_RES 9 |
---|
655 | #define V_DEBUG_MEM 10 |
---|
656 | #define V_SHOW_USE 11 |
---|
657 | #define V_IMAP 12 |
---|
658 | #define V_PROMPT 13 |
---|
659 | #define V_NSB 14 |
---|
660 | #define V_CONTENTSB 15 |
---|
661 | #define V_CANCELUNIT 16 |
---|
662 | #define V_MODPSOLVSB 17 |
---|
663 | #define V_UPTORADICAL 18 |
---|
664 | #define V_FINDMONOM 19 |
---|
665 | #define V_COEFSTRAT 20 |
---|
666 | #define V_DEG_STOP 31 |
---|
667 | |
---|
668 | |
---|
669 | #define OPT_PROT 0 |
---|
670 | #define OPT_REDSB 1 |
---|
671 | #define OPT_NOT_BUCKETS 2 |
---|
672 | #define OPT_NOT_SUGAR 3 |
---|
673 | #define OPT_INTERRUPT 4 |
---|
674 | #define OPT_SUGARCRIT 5 |
---|
675 | #define OPT_DEBUG 6 |
---|
676 | #define OPT_REDTHROUGH 7 |
---|
677 | #define OPT_RETURN_SB 9 |
---|
678 | #define OPT_FASTHC 10 |
---|
679 | #define OPT_OLDSTD 20 |
---|
680 | #define OPT_KEEPVARS 21 |
---|
681 | #define OPT_STAIRCASEBOUND 22 |
---|
682 | #define OPT_MULTBOUND 23 |
---|
683 | #define OPT_DEGBOUND 24 |
---|
684 | #define OPT_REDTAIL 25 |
---|
685 | #define OPT_INTSTRATEGY 26 |
---|
686 | #define OPT_INFREDTAIL 28 |
---|
687 | #define OPT_SB_1 29 |
---|
688 | #define OPT_NOTREGULARITY 30 |
---|
689 | #define OPT_WEIGHTM 31 |
---|
690 | |
---|
691 | /* define ring dependent options */ |
---|
692 | #define TEST_RINGDEP_OPTS \ |
---|
693 | (Sy_bit(OPT_INTSTRATEGY) | Sy_bit(OPT_REDTHROUGH) | Sy_bit(OPT_REDTAIL)) |
---|
694 | |
---|
695 | #define TEST_OPT_PROT BTEST1(OPT_PROT) |
---|
696 | #define TEST_OPT_REDSB BTEST1(OPT_REDSB) |
---|
697 | #define TEST_OPT_NOT_BUCKETS BTEST1(OPT_NOT_BUCKETS) |
---|
698 | #define TEST_OPT_NOT_SUGAR BTEST1(OPT_NOT_SUGAR) |
---|
699 | #define TEST_OPT_SUGARCRIT BTEST1(OPT_SUGARCRIT) |
---|
700 | #define TEST_OPT_DEBUG BTEST1(OPT_DEBUG) |
---|
701 | #define TEST_OPT_FASTHC BTEST1(OPT_FASTHC) |
---|
702 | #define TEST_OPT_INTSTRATEGY BTEST1(OPT_INTSTRATEGY) |
---|
703 | #define TEST_OPT_RETURN_SB BTEST1(OPT_RETURN_SB) |
---|
704 | #define TEST_OPT_KEEPVARS BTEST1(OPT_KEEPVARS) |
---|
705 | #define TEST_OPT_DEGBOUND BTEST1(OPT_DEGBOUND) |
---|
706 | #define TEST_OPT_MULTBOUND BTEST1(OPT_MULTBOUND) |
---|
707 | #define TEST_OPT_STAIRCASEBOUND BTEST1(OPT_STAIRCASEBOUND) |
---|
708 | #define TEST_OPT_REDTAIL BTEST1(OPT_REDTAIL) |
---|
709 | #define TEST_OPT_INFREDTAIL BTEST1(OPT_INFREDTAIL) |
---|
710 | #define TEST_OPT_SB_1 BTEST1(OPT_SB_1) |
---|
711 | #define TEST_OPT_NOTREGULARITY BTEST1(OPT_NOTREGULARITY) |
---|
712 | #define TEST_OPT_WEIGHTM BTEST1(OPT_WEIGHTM) |
---|
713 | #define TEST_OPT_REDTHROUGH BTEST1(OPT_REDTHROUGH) |
---|
714 | #define TEST_OPT_OLDSTD BTEST1(OPT_OLDSTD) |
---|
715 | #define TEST_OPT_CONTENTSB BVERBOSE(V_CONTENTSB) |
---|
716 | #define TEST_OPT_CANCELUNIT BVERBOSE(V_CANCELUNIT) |
---|
717 | |
---|
718 | #define TEST_VERB_NSB BVERBOSE(V_NSB) |
---|
719 | #define TEST_V_DEG_STOP BVERBOSE(V_DEG_STOP) |
---|
720 | #define TEST_V_MODPSOLVSB BVERBOSE(V_MODPSOLVSB) |
---|
721 | #define TEST_V_COEFSTRAT BVERBOSE(V_COEFSTRAT) |
---|
722 | #define TEST_V_UPTORADICAL BVERBOSE(V_UPTORADICAL) |
---|
723 | #define TEST_V_FINDMONOM BVERBOSE(V_FINDMONOM) |
---|
724 | #ifdef HAVE_LIBPARSER |
---|
725 | #ifdef __cplusplus |
---|
726 | class libstack; |
---|
727 | typedef libstack * libstackv; |
---|
728 | #endif |
---|
729 | #endif /* HAVE_LIBPARSER */ |
---|
730 | |
---|
731 | extern struct omBin_s* MP_INT_bin; |
---|
732 | extern struct omBin_s* char_ptr_bin; |
---|
733 | extern struct omBin_s* ideal_bin; |
---|
734 | extern struct omBin_s* int_bin; |
---|
735 | extern struct omBin_s* poly_bin; |
---|
736 | extern struct omBin_s* void_ptr_bin; |
---|
737 | extern struct omBin_s* indlist_bin; |
---|
738 | extern struct omBin_s* naIdeal_bin; |
---|
739 | extern struct omBin_s* snaIdeal_bin; |
---|
740 | extern struct omBin_s* sm_prec_bin; |
---|
741 | extern struct omBin_s* smprec_bin; |
---|
742 | extern struct omBin_s* sip_sideal_bin; |
---|
743 | extern struct omBin_s* sip_smap_bin; |
---|
744 | extern struct omBin_s* sip_sring_bin; |
---|
745 | extern struct omBin_s* ip_sideal_bin; |
---|
746 | extern struct omBin_s* ip_smap_bin; |
---|
747 | extern struct omBin_s* ip_sring_bin; |
---|
748 | extern struct omBin_s* sleftv_bin; |
---|
749 | |
---|
750 | #ifdef __cplusplus |
---|
751 | union uutypes |
---|
752 | { |
---|
753 | int i; |
---|
754 | ring uring; |
---|
755 | poly p; |
---|
756 | number n; |
---|
757 | ideal uideal; |
---|
758 | map umap; |
---|
759 | matrix umatrix; |
---|
760 | char * ustring; |
---|
761 | intvec * iv; |
---|
762 | lists l; |
---|
763 | si_link li; |
---|
764 | package pack; |
---|
765 | procinfo * pinf; |
---|
766 | }; |
---|
767 | |
---|
768 | class idrec |
---|
769 | { |
---|
770 | public: |
---|
771 | /* !! do not change the first 6 entries !! (see subexpr.h: sleftv) */ |
---|
772 | idhdl next; |
---|
773 | char * id; |
---|
774 | utypes data; |
---|
775 | attr attribute; |
---|
776 | BITSET flag; |
---|
777 | idtyp typ; |
---|
778 | |
---|
779 | short lev; |
---|
780 | short ref; |
---|
781 | |
---|
782 | #define IDNEXT(a) ((a)->next) |
---|
783 | #define IDTYP(a) ((a)->typ) |
---|
784 | #define IDFLAG(a) ((a)->flag) |
---|
785 | #define IDLEV(a) ((a)->lev) |
---|
786 | #define IDID(a) ((a)->id) |
---|
787 | #define IDATTR(a) ((a)->attribute) |
---|
788 | |
---|
789 | #define IDINT(a) ((int)(long)((a)->data.ustring)) |
---|
790 | #define IDDATA(a) ((a)->data.ustring) |
---|
791 | #define IDRING(a) ((a)->data.uring) |
---|
792 | #define IDINTVEC(a) ((a)->data.iv) |
---|
793 | #define IDPOLY(a) ((a)->data.p) |
---|
794 | #define IDBIGINT(a) ((a)->data.n) |
---|
795 | #define IDNUMBER(a) ((a)->data.n) |
---|
796 | #define IDIDEAL(a) (((a)->data).uideal) |
---|
797 | #define IDMATRIX(a) (((a)->data).umatrix) |
---|
798 | #define IDMAP(a) (((a)->data).umap) |
---|
799 | #define IDSTRING(a) ((a)->data.ustring) |
---|
800 | #define IDLIST(a) ((a)->data.l) |
---|
801 | #define IDLINK(a) ((a)->data.li) |
---|
802 | #define IDPACKAGE(a) ((a)->data.pack) |
---|
803 | #define IDPROC(a) ((a)->data.pinf) |
---|
804 | |
---|
805 | idrec() { memset(this,0,sizeof(*this)); } |
---|
806 | idhdl get(const char * s, int lev); |
---|
807 | idhdl set(char * s, int lev, idtyp t, BOOLEAN init=TRUE); |
---|
808 | char * String(); |
---|
809 | // ~idrec(); |
---|
810 | }; |
---|
811 | |
---|
812 | class proc_singular |
---|
813 | { |
---|
814 | public: |
---|
815 | long proc_start; // position where proc is starting |
---|
816 | long def_end; // position where proc header is ending |
---|
817 | long help_start; // position where help is starting |
---|
818 | long help_end; // position where help is starting |
---|
819 | long body_start; // position where proc-body is starting |
---|
820 | long body_end; // position where proc-body is ending |
---|
821 | long example_start; // position where example is starting |
---|
822 | long proc_end; // position where proc is ending |
---|
823 | int proc_lineno; |
---|
824 | int body_lineno; |
---|
825 | int example_lineno; |
---|
826 | char *body; |
---|
827 | long help_chksum; |
---|
828 | }; |
---|
829 | |
---|
830 | struct proc_object |
---|
831 | { |
---|
832 | //public: |
---|
833 | BOOLEAN (*function)(leftv res, leftv v); |
---|
834 | }; |
---|
835 | |
---|
836 | union uprocinfodata; |
---|
837 | |
---|
838 | union uprocinfodata |
---|
839 | { |
---|
840 | public: |
---|
841 | proc_singular s; // data of Singular-procedure |
---|
842 | struct proc_object o; // pointer to binary-function |
---|
843 | }; |
---|
844 | |
---|
845 | typedef union uprocinfodata procinfodata; |
---|
846 | |
---|
847 | typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs; |
---|
848 | // LANG_TOP : Toplevel package only |
---|
849 | // LANG_SINGULAR: |
---|
850 | // LANG_C : |
---|
851 | class procinfo |
---|
852 | { |
---|
853 | public: |
---|
854 | char *libname; |
---|
855 | char *procname; |
---|
856 | #ifdef HAVE_NS |
---|
857 | package pack; |
---|
858 | #endif |
---|
859 | language_defs language; |
---|
860 | short ref; |
---|
861 | char is_static; // if set, proc not accessible for user |
---|
862 | char trace_flag; |
---|
863 | procinfodata data; |
---|
864 | }; |
---|
865 | |
---|
866 | #endif |
---|
867 | |
---|
868 | #endif |
---|
869 | |
---|