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