1 | #ifndef STRUCTS_H |
---|
2 | #define STRUCTS_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT |
---|
9 | */ |
---|
10 | |
---|
11 | /* for memset: */ |
---|
12 | #include <string.h> |
---|
13 | #ifdef HAVE_RINGS |
---|
14 | #include <si_gmp.h> |
---|
15 | #endif |
---|
16 | |
---|
17 | |
---|
18 | /* standard types */ |
---|
19 | #ifdef HAVE_RINGS |
---|
20 | typedef unsigned long NATNUMBER; |
---|
21 | typedef MP_INT *int_number; |
---|
22 | #endif |
---|
23 | #if (SIZEOF_LONG == 8) |
---|
24 | typedef int BOOLEAN; |
---|
25 | /* testet on x86_64, gcc 3.4.6: 2 % */ |
---|
26 | /* testet on IA64, gcc 3.4.6: 1 % */ |
---|
27 | #else |
---|
28 | /* testet on athlon, gcc 2.95.4: 1 % */ |
---|
29 | typedef short BOOLEAN; |
---|
30 | #endif |
---|
31 | |
---|
32 | typedef void * Sy_reference; |
---|
33 | #define ADDRESS Sy_reference |
---|
34 | #define BITSET unsigned int |
---|
35 | |
---|
36 | #if defined(SI_CPU_I386) || defined(SI_CPU_X86_64) |
---|
37 | // the following settings seems to be better on i386 and x86_64 processors |
---|
38 | // define if a*b is with mod instead of tables |
---|
39 | #define HAVE_MULT_MOD |
---|
40 | // #define HAVE_GENERIC_ADD |
---|
41 | // #ifdef HAVE_MULT_MOD |
---|
42 | // #define HAVE_DIV_MOD |
---|
43 | // #endif |
---|
44 | #elif defined(SI_CPU_IA64) |
---|
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 | #elif defined(SI_CPU_SPARC) |
---|
52 | // #define HAVE_GENERIC_ADD |
---|
53 | #define HAVE_MULT_MOD |
---|
54 | #ifdef HAVE_MULT_MOD |
---|
55 | #define HAVE_DIV_MOD |
---|
56 | #endif |
---|
57 | #elif defined(SI_CPU_PPC) |
---|
58 | // the following settings seems to be better on ppc processors |
---|
59 | // testet on: ppc_Linux, 740/750 PowerMac G3, 512k L2 cache |
---|
60 | #define HAVE_MULT_MOD |
---|
61 | // #ifdef HAVE_MULT_MOD |
---|
62 | // #define HAVE_DIV_MOD |
---|
63 | // #endif |
---|
64 | #endif |
---|
65 | |
---|
66 | #if SIZEOF_LONG == 4 |
---|
67 | typedef long long int64; |
---|
68 | #elif SIZEOF_LONG == 8 |
---|
69 | typedef long int64; |
---|
70 | #else |
---|
71 | #error int64 undefined |
---|
72 | #endif |
---|
73 | |
---|
74 | |
---|
75 | enum n_coeffType |
---|
76 | { |
---|
77 | n_unknown=0, |
---|
78 | n_Zp, |
---|
79 | n_Q, |
---|
80 | n_R, |
---|
81 | n_GF, |
---|
82 | n_long_R, |
---|
83 | n_Zp_a, |
---|
84 | n_Q_a, |
---|
85 | n_long_C |
---|
86 | #ifdef HAVE_RINGS |
---|
87 | ,n_Z, |
---|
88 | n_Zm, |
---|
89 | n_Zpn, |
---|
90 | n_Z2n |
---|
91 | #endif |
---|
92 | }; |
---|
93 | |
---|
94 | // #ifdef HAVE_PLURAL |
---|
95 | enum nc_type |
---|
96 | { |
---|
97 | nc_error = -1, // Something's gone wrong! |
---|
98 | nc_general = 0, /* yx=q xy+... */ |
---|
99 | nc_skew, /*1*/ /* yx=q xy */ |
---|
100 | nc_comm, /*2*/ /* yx= xy */ |
---|
101 | nc_lie, /*3*/ /* yx=xy+... */ |
---|
102 | nc_undef, /*4*/ /* for internal reasons */ |
---|
103 | |
---|
104 | nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0 |
---|
105 | }; |
---|
106 | // #endif |
---|
107 | |
---|
108 | typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX, LT_MACH_O} lib_types; |
---|
109 | |
---|
110 | struct snumber; |
---|
111 | typedef struct snumber * number; |
---|
112 | typedef number (*numberfunc)(number a,number b); |
---|
113 | typedef number (*nMapFunc)(number a); |
---|
114 | |
---|
115 | /* C++-part */ |
---|
116 | #ifdef __cplusplus |
---|
117 | class ip_smatrix; |
---|
118 | class idrec; |
---|
119 | class intvec; |
---|
120 | class sleftv; |
---|
121 | class slists; |
---|
122 | class sattr; |
---|
123 | class skStrategy; |
---|
124 | class ssyStrategy; |
---|
125 | class procinfo; |
---|
126 | class kBucket; |
---|
127 | class sBucket; |
---|
128 | class CPolynomialSummator; |
---|
129 | class CGlobalMultiplier; |
---|
130 | class CFormulaPowerMultiplier; |
---|
131 | #endif |
---|
132 | |
---|
133 | struct n_Procs_s; |
---|
134 | struct sip_sring; |
---|
135 | struct sip_link; |
---|
136 | struct spolynom; |
---|
137 | struct _ssubexpr; |
---|
138 | struct _sssym; |
---|
139 | struct sip_command; |
---|
140 | struct sip_package; |
---|
141 | struct s_si_link_extension; |
---|
142 | |
---|
143 | // forward for ideals.h: |
---|
144 | struct sip_sideal; |
---|
145 | struct sip_smap; |
---|
146 | typedef struct sip_smap * map; |
---|
147 | typedef struct sip_sideal * ideal; |
---|
148 | |
---|
149 | |
---|
150 | typedef struct n_Procs_s n_Procs_s; |
---|
151 | |
---|
152 | // #ifdef HAVE_PLURAL |
---|
153 | struct nc_struct; |
---|
154 | typedef struct nc_struct nc_struct; |
---|
155 | // #endif |
---|
156 | |
---|
157 | typedef struct _ssubexpr sSubexpr; |
---|
158 | typedef struct _sssym ssym; |
---|
159 | typedef struct spolyrec polyrec; |
---|
160 | typedef struct sip_sring ip_sring; |
---|
161 | typedef struct sip_link ip_link; |
---|
162 | typedef struct sip_command ip_command; |
---|
163 | typedef struct sip_package ip_package; |
---|
164 | |
---|
165 | /* the pointer types */ |
---|
166 | typedef char * char_ptr; |
---|
167 | typedef int * int_ptr; |
---|
168 | typedef short * short_ptr; |
---|
169 | typedef ip_sring * ring; |
---|
170 | typedef int idtyp; |
---|
171 | typedef polyrec * poly; |
---|
172 | typedef poly * polyset; |
---|
173 | typedef union uutypes utypes; |
---|
174 | typedef ip_command * command; |
---|
175 | typedef struct s_si_link_extension *si_link_extension; |
---|
176 | typedef polyrec * napoly; |
---|
177 | |
---|
178 | #ifdef __cplusplus |
---|
179 | typedef idrec * idhdl; |
---|
180 | typedef ip_smatrix * matrix; |
---|
181 | typedef ip_link * si_link; |
---|
182 | typedef sleftv * leftv; |
---|
183 | typedef slists * lists; |
---|
184 | typedef sSubexpr * Subexpr; |
---|
185 | typedef sattr * attr; |
---|
186 | typedef skStrategy * kStrategy; |
---|
187 | typedef ip_package * package; |
---|
188 | typedef ssyStrategy * syStrategy; |
---|
189 | typedef procinfo * procinfov; |
---|
190 | typedef kBucket* kBucket_pt; |
---|
191 | typedef sBucket* sBucket_pt; |
---|
192 | typedef struct p_Procs_s p_Procs_s; |
---|
193 | |
---|
194 | struct n_Procs_s |
---|
195 | { |
---|
196 | n_Procs_s* next; |
---|
197 | // the union stuff |
---|
198 | // Zp: |
---|
199 | int npPrimeM; |
---|
200 | int npPminus1M; |
---|
201 | #ifdef HAVE_DIV_MOD |
---|
202 | unsigned short *npInvTable; |
---|
203 | #endif |
---|
204 | #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD) |
---|
205 | unsigned short *npExpTable; |
---|
206 | unsigned short *npLogTable; |
---|
207 | #endif |
---|
208 | // Zp_a, Q_a |
---|
209 | |
---|
210 | // general stuff |
---|
211 | numberfunc nMult, nSub ,nAdd ,nDiv, nIntDiv, nIntMod, nExactDiv; |
---|
212 | number (*cfInit)(int i,const ring r); |
---|
213 | number (*nPar)(int i); |
---|
214 | int (*nParDeg)(number n); |
---|
215 | int (*nSize)(number n); |
---|
216 | int (*n_Int)(number &n, const ring r); |
---|
217 | #ifdef HAVE_RINGS |
---|
218 | int (*nDivComp)(number a,number b); |
---|
219 | BOOLEAN (*nIsUnit)(number a); |
---|
220 | number (*nGetUnit)(number a); |
---|
221 | number (*nExtGcd)(number a, number b, number *s, number *t); |
---|
222 | #endif |
---|
223 | number (*nNeg)(number a); |
---|
224 | number (*nInvers)(number a); |
---|
225 | number (*nCopy)(number a); |
---|
226 | number (*cfCopy)(number a, const ring r); |
---|
227 | number (*nRePart)(number a); |
---|
228 | number (*nImPart)(number a); |
---|
229 | void (*cfWrite)(number &a, const ring r); |
---|
230 | const char * (*nRead)(const char * s, number * a); |
---|
231 | void (*nNormalize)(number &a); |
---|
232 | BOOLEAN (*nGreater)(number a,number b), |
---|
233 | #ifdef HAVE_RINGS |
---|
234 | (*nDivBy)(number a, number b), |
---|
235 | #endif |
---|
236 | (*nEqual)(number a,number b), |
---|
237 | (*nIsZero)(number a), |
---|
238 | (*nIsOne)(number a), |
---|
239 | (*nIsMOne)(number a), |
---|
240 | (*nGreaterZero)(number a); |
---|
241 | void (*nPower)(number a, int i, number * result); |
---|
242 | number (*cfGetDenom)(number &n, const ring r); |
---|
243 | number (*cfGetNumerator)(number &n, const ring r); |
---|
244 | number (*nGcd)(number a, number b, const ring r); |
---|
245 | number (*nLcm)(number a, number b, const ring r); |
---|
246 | void (*cfDelete)(number * a, const ring r); |
---|
247 | nMapFunc (*cfSetMap)(const ring src, const ring dst); |
---|
248 | char * (*nName)(number n); |
---|
249 | void (*nInpMult)(number &a, number b, ring r); |
---|
250 | #ifdef LDEBUG |
---|
251 | BOOLEAN (*nDBTest)(number a, const char *f,const int l); |
---|
252 | #endif |
---|
253 | |
---|
254 | number nNULL; /* the 0 as constant */ |
---|
255 | int char_flag; |
---|
256 | int ref; |
---|
257 | n_coeffType type; |
---|
258 | short nChar; |
---|
259 | }; |
---|
260 | |
---|
261 | /* the function pointer types */ |
---|
262 | |
---|
263 | typedef long (*pLDegProc)(poly p, int *length, ring r); |
---|
264 | typedef long (*pFDegProc)(poly p, ring r); |
---|
265 | typedef void (*p_SetmProc)(poly p, const ring r); |
---|
266 | |
---|
267 | typedef enum |
---|
268 | { |
---|
269 | ro_dp, // ordering is a degree ordering |
---|
270 | ro_wp, // ordering is a weighted degree ordering |
---|
271 | ro_wp64, // ordering is a weighted64 degree ordering |
---|
272 | ro_wp_neg, // ordering is a weighted degree ordering |
---|
273 | // with possibly negative weights |
---|
274 | ro_cp, // ordering duplicates variables |
---|
275 | ro_syzcomp, // ordering indicates "subset" of component number (ringorder_S) |
---|
276 | ro_syz, // ordering with component number >syzcomp is lower (ringorder_s) |
---|
277 | ro_isTemp, ro_is, // Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS) |
---|
278 | ro_none |
---|
279 | } |
---|
280 | ro_typ; |
---|
281 | |
---|
282 | // ordering is a degree ordering |
---|
283 | struct sro_dp |
---|
284 | { |
---|
285 | short place; // where degree is stored (in L): |
---|
286 | short start; // bounds of ordering (in E): |
---|
287 | short end; |
---|
288 | }; |
---|
289 | typedef struct sro_dp sro_dp; |
---|
290 | |
---|
291 | // ordering is a weighted degree ordering |
---|
292 | struct sro_wp |
---|
293 | { |
---|
294 | short place; // where weighted degree is stored (in L) |
---|
295 | short start; // bounds of ordering (in E) |
---|
296 | short end; |
---|
297 | int *weights; // pointers into wvhdl field |
---|
298 | }; |
---|
299 | typedef struct sro_wp sro_wp; |
---|
300 | |
---|
301 | // ordering is a weighted degree ordering |
---|
302 | struct sro_wp64 |
---|
303 | { |
---|
304 | short place; // where weighted degree is stored (in L) |
---|
305 | short start; // bounds of ordering (in E) |
---|
306 | short end; |
---|
307 | int64 *weights64; // pointers into wvhdl field |
---|
308 | }; |
---|
309 | typedef struct sro_wp64 sro_wp64; |
---|
310 | |
---|
311 | // ordering duplicates variables |
---|
312 | struct sro_cp |
---|
313 | { |
---|
314 | short place; // where start is copied to (in E) |
---|
315 | short start; // bounds of sources of copied variables (in E) |
---|
316 | short end; |
---|
317 | }; |
---|
318 | typedef struct sro_cp sro_cp; |
---|
319 | |
---|
320 | // ordering indicates "subset" of component number |
---|
321 | struct sro_syzcomp |
---|
322 | { |
---|
323 | short place; // where the index is stored (in L) |
---|
324 | long *ShiftedComponents; // pointer into index field |
---|
325 | int* Components; |
---|
326 | #ifdef PDEBUG |
---|
327 | long length; |
---|
328 | #endif |
---|
329 | }; |
---|
330 | typedef struct sro_syzcomp sro_syzcomp; |
---|
331 | |
---|
332 | // ordering with component number >syzcomp is lower |
---|
333 | struct sro_syz |
---|
334 | { |
---|
335 | short place; // where the index is stored (in L) |
---|
336 | int limit; // syzcomp |
---|
337 | int* syz_index; // mapping Component -> SyzIndex for Comp <= limit |
---|
338 | int curr_index; // SyzIndex for Component > limit |
---|
339 | }; |
---|
340 | |
---|
341 | typedef struct sro_syz sro_syz; |
---|
342 | // Induced Syzygy (Schreyer) ordering is built inductively as follows: |
---|
343 | // we look for changes made by ordering blocks which are between prefix/suffix markers: |
---|
344 | // that is: which variables where placed by them and where (judging by v) |
---|
345 | |
---|
346 | // due to prefix/suffix nature we need some placeholder: |
---|
347 | // prefix stores here initial state |
---|
348 | // suffix cleares this up |
---|
349 | struct sro_ISTemp |
---|
350 | { |
---|
351 | short start; // 1st member SHOULD be short "place" |
---|
352 | int suffixpos; |
---|
353 | int* pVarOffset; // copy! |
---|
354 | }; |
---|
355 | |
---|
356 | // So this is the actuall thing! |
---|
357 | // suffix uses last sro_ISTemp (cleares it up afterwards) and |
---|
358 | // creates this block |
---|
359 | struct sro_IS |
---|
360 | { |
---|
361 | short start, end; // which part of L we want to want to update... |
---|
362 | int* pVarOffset; // same as prefix! |
---|
363 | |
---|
364 | int limit; // first referenced component |
---|
365 | |
---|
366 | // reference poly set?? // Should it be owned by ring?!!! |
---|
367 | ideal F; // reference leading (module)-monomials set. owned by ring... |
---|
368 | const intvec* componentWeights; // component weights! owned by ring... |
---|
369 | }; |
---|
370 | |
---|
371 | typedef struct sro_IS sro_IS; |
---|
372 | typedef struct sro_ISTemp sro_ISTemp; |
---|
373 | |
---|
374 | #ifndef OM_ALLOC_H |
---|
375 | struct omBin_s; |
---|
376 | #endif |
---|
377 | |
---|
378 | struct sro_ord |
---|
379 | { |
---|
380 | ro_typ ord_typ; |
---|
381 | int order_index; // comes from r->order[order_index] |
---|
382 | union |
---|
383 | { |
---|
384 | sro_dp dp; |
---|
385 | sro_wp wp; |
---|
386 | sro_wp64 wp64; |
---|
387 | sro_cp cp; |
---|
388 | sro_syzcomp syzcomp; |
---|
389 | sro_syz syz; |
---|
390 | sro_IS is; |
---|
391 | sro_ISTemp isTemp; |
---|
392 | } data; |
---|
393 | }; |
---|
394 | |
---|
395 | #ifdef HAVE_PLURAL |
---|
396 | // NC pProcs: |
---|
397 | typedef poly (*mm_Mult_p_Proc_Ptr)(const poly m, poly p, const ring r); |
---|
398 | typedef poly (*mm_Mult_pp_Proc_Ptr)(const poly m, const poly p, const ring r); |
---|
399 | |
---|
400 | typedef ideal (*GB_Proc_Ptr)(const ideal F, const ideal Q, const intvec *w, const intvec *hilb, kStrategy strat); |
---|
401 | |
---|
402 | typedef poly (*SPoly_Proc_Ptr)(const poly p1, const poly p2, const ring r); |
---|
403 | typedef poly (*SPolyReduce_Proc_Ptr)(const poly p1, poly p2, const ring r); |
---|
404 | |
---|
405 | typedef void (*bucket_Proc_Ptr)(kBucket_pt b, poly p, number *c); |
---|
406 | |
---|
407 | struct nc_pProcs |
---|
408 | { |
---|
409 | public: |
---|
410 | mm_Mult_p_Proc_Ptr mm_Mult_p; |
---|
411 | mm_Mult_pp_Proc_Ptr mm_Mult_pp; |
---|
412 | |
---|
413 | bucket_Proc_Ptr BucketPolyRed; |
---|
414 | bucket_Proc_Ptr BucketPolyRed_Z; |
---|
415 | |
---|
416 | SPoly_Proc_Ptr SPoly; |
---|
417 | SPolyReduce_Proc_Ptr ReduceSPoly; |
---|
418 | |
---|
419 | GB_Proc_Ptr GB; |
---|
420 | // GlobalGB, // BBA |
---|
421 | // LocalGB; // MORA |
---|
422 | }; |
---|
423 | |
---|
424 | |
---|
425 | struct nc_struct |
---|
426 | { |
---|
427 | nc_type type; |
---|
428 | //ring basering; // the ring C,D,.. live in (commutative ring with this NC structure!) |
---|
429 | |
---|
430 | // initial data: square matrices rVar() x rVar() |
---|
431 | // logically: upper triangular!!! |
---|
432 | // TODO: eliminate this waste of memory!!!! |
---|
433 | matrix C; |
---|
434 | matrix D; |
---|
435 | |
---|
436 | // computed data: |
---|
437 | matrix *MT; // size 0.. (rVar()*rVar()-1)/2 |
---|
438 | matrix COM; |
---|
439 | int *MTsize; // size 0.. (rVar()*rVar()-1)/2 |
---|
440 | |
---|
441 | // IsSkewConstant indicates whethere coeffs C_ij are all equal, |
---|
442 | // effective together with nc_type=nc_skew |
---|
443 | int IsSkewConstant; |
---|
444 | |
---|
445 | private: |
---|
446 | // internal data for different implementations |
---|
447 | // if dynamic => must be deallocated in destructor (nc_rKill!) |
---|
448 | union |
---|
449 | { |
---|
450 | struct |
---|
451 | { |
---|
452 | // treat variables from iAltVarsStart till iAltVarsEnd as alternating vars. |
---|
453 | // these variables should have odd degree, though that will not be checked |
---|
454 | // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior |
---|
455 | // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N |
---|
456 | unsigned int iFirstAltVar, iLastAltVar; // = 0 by default |
---|
457 | |
---|
458 | // for factors of super-commutative algebras we need |
---|
459 | // the part of general quotient ideal modulo squares! |
---|
460 | ideal idSCAQuotient; // = NULL by default. // must be deleted in Kill! |
---|
461 | } sca; |
---|
462 | } data; |
---|
463 | |
---|
464 | CGlobalMultiplier* m_Multiplier; |
---|
465 | CFormulaPowerMultiplier* m_PowerMultiplier; |
---|
466 | |
---|
467 | public: |
---|
468 | |
---|
469 | inline nc_type& ncRingType() { return (type); }; |
---|
470 | inline nc_type ncRingType() const { return (type); }; |
---|
471 | |
---|
472 | inline unsigned int& FirstAltVar() |
---|
473 | { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); }; |
---|
474 | inline unsigned int& LastAltVar () |
---|
475 | { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); }; |
---|
476 | |
---|
477 | inline unsigned int FirstAltVar() const |
---|
478 | { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); }; |
---|
479 | inline unsigned int LastAltVar () const |
---|
480 | { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); }; |
---|
481 | |
---|
482 | inline ideal& SCAQuotient() |
---|
483 | { assume(ncRingType() == nc_exterior); return (data.sca.idSCAQuotient); }; |
---|
484 | |
---|
485 | inline CGlobalMultiplier* GetGlobalMultiplier() const |
---|
486 | { assume(ncRingType() != nc_exterior); return (m_Multiplier); }; |
---|
487 | |
---|
488 | inline CGlobalMultiplier*& GetGlobalMultiplier() |
---|
489 | { assume(ncRingType() != nc_exterior); return (m_Multiplier); }; |
---|
490 | |
---|
491 | |
---|
492 | inline CFormulaPowerMultiplier* GetFormulaPowerMultiplier() const |
---|
493 | { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); }; |
---|
494 | |
---|
495 | inline CFormulaPowerMultiplier*& GetFormulaPowerMultiplier() |
---|
496 | { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); }; |
---|
497 | |
---|
498 | public: |
---|
499 | nc_pProcs p_Procs; // NC procedures. |
---|
500 | |
---|
501 | }; |
---|
502 | #endif |
---|
503 | |
---|
504 | struct sip_sring |
---|
505 | { |
---|
506 | // each entry must have a description and a procedure defining it, |
---|
507 | // general ordering: pointer/structs, long, int, short, BOOLEAN/char/enum |
---|
508 | // general defining procedures: rInit, rComplete, interpreter, ?? |
---|
509 | idhdl idroot; /* local objects , interpreter*/ |
---|
510 | int* order; /* array of orderings, rInit/rSleftvOrdering2Ordering */ |
---|
511 | int* block0; /* starting pos., rInit/rSleftvOrdering2Ordering*/ |
---|
512 | int* block1; /* ending pos., rInit/rSleftvOrdering2Ordering*/ |
---|
513 | char** parameter; /* names of parameters, rInit */ |
---|
514 | number minpoly; /* for Q_a/Zp_a, rInit */ |
---|
515 | ideal minideal; |
---|
516 | int** wvhdl; /* array of weight vectors, rInit/rSleftvOrdering2Ordering */ |
---|
517 | char ** names; /* array of variable names, rInit */ |
---|
518 | |
---|
519 | // what follows below here should be set by rComplete, _only_ |
---|
520 | long *ordsgn; /* array of +/- 1 (or 0) for comparing monomials */ |
---|
521 | /* ExpL_Size entries*/ |
---|
522 | |
---|
523 | // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */ |
---|
524 | sro_ord* typ; /* array of orderings + sizes, OrdSize entries */ |
---|
525 | /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs |
---|
526 | in ExpVector whose values need an offset due to negative weights */ |
---|
527 | /* array of NegWeigtL_Size indicies */ |
---|
528 | int* NegWeightL_Offset; |
---|
529 | |
---|
530 | int* VarOffset; |
---|
531 | |
---|
532 | ideal qideal; /* extension to the ring structure: qring, rInit */ |
---|
533 | |
---|
534 | int* firstwv; |
---|
535 | |
---|
536 | struct omBin_s* PolyBin; /* Bin from where monoms are allocated */ |
---|
537 | #ifdef HAVE_RINGS |
---|
538 | unsigned int ringtype; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ |
---|
539 | int_number ringflaga; /* Z/(ringflag^ringflagb)=Z/nrnModul*/ |
---|
540 | unsigned long ringflagb; |
---|
541 | unsigned long nr2mModul; /* Z/nr2mModul */ |
---|
542 | int_number nrnModul; |
---|
543 | #endif |
---|
544 | unsigned long options; /* ring dependent options */ |
---|
545 | |
---|
546 | int ch; /* characteristic, rInit */ |
---|
547 | int ref; /* reference counter to the ring, interpreter */ |
---|
548 | |
---|
549 | short float_len; /* additional char-flags, rInit */ |
---|
550 | short float_len2; /* additional char-flags, rInit */ |
---|
551 | |
---|
552 | short N; /* number of vars, rInit */ |
---|
553 | |
---|
554 | short P; /* number of pars, rInit */ |
---|
555 | short OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */ |
---|
556 | |
---|
557 | short firstBlockEnds; |
---|
558 | #ifdef HAVE_PLURAL |
---|
559 | short real_var_start, real_var_end; |
---|
560 | #endif |
---|
561 | |
---|
562 | #ifdef HAVE_SHIFTBBA |
---|
563 | short isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */ |
---|
564 | #endif |
---|
565 | |
---|
566 | BOOLEAN VectorOut; |
---|
567 | BOOLEAN ShortOut; |
---|
568 | BOOLEAN CanShortOut; |
---|
569 | BOOLEAN LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks |
---|
570 | BOOLEAN MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise |
---|
571 | |
---|
572 | BOOLEAN ComponentOrder; // ??? |
---|
573 | |
---|
574 | // what follows below here should be set by rComplete, _only_ |
---|
575 | // contains component, but no weight fields in E */ |
---|
576 | short ExpL_Size; // size of exponent vector in long |
---|
577 | short CmpL_Size; // portions which need to be compared |
---|
578 | /* number of long vars in exp vector: |
---|
579 | long vars are those longs in the exponent vector which are |
---|
580 | occupied by variables, only */ |
---|
581 | short VarL_Size; |
---|
582 | short BitsPerExp; /* number of bits per exponent */ |
---|
583 | short ExpPerLong; /* maximal number of Exponents per long */ |
---|
584 | short pCompIndex; /* p->exp.e[pCompIndex] is the component */ |
---|
585 | short pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */ |
---|
586 | short OrdSize; /* size of ord vector (in sro_ord) */ |
---|
587 | |
---|
588 | /* if >= 0, long vars in exp vector are consecutive and start there |
---|
589 | if < 0, long vars in exp vector are not consecutive */ |
---|
590 | short VarL_LowIndex; |
---|
591 | // number of exponents in r->VarL_Offset[0] |
---|
592 | // is minimal number of exponents in a long var |
---|
593 | short MinExpPerLong; |
---|
594 | |
---|
595 | short NegWeightL_Size; |
---|
596 | /* array of size VarL_Size, |
---|
597 | VarL_Offset[i] gets i-th long var in exp vector */ |
---|
598 | int* VarL_Offset; |
---|
599 | |
---|
600 | /* mask for getting single exponents */ |
---|
601 | unsigned long bitmask; |
---|
602 | /* mask used for divisiblity tests */ |
---|
603 | unsigned long divmask; // rComplete |
---|
604 | |
---|
605 | p_Procs_s* p_Procs; // rComplete/p_ProcsSet |
---|
606 | |
---|
607 | /* FDeg and LDeg */ |
---|
608 | pFDegProc pFDeg; // rComplete/rSetDegStuff |
---|
609 | pLDegProc pLDeg; // rComplete/rSetDegStuff |
---|
610 | |
---|
611 | /* as it was determined by rComplete */ |
---|
612 | pFDegProc pFDegOrig; |
---|
613 | /* and as it was determined before rOptimizeLDeg */ |
---|
614 | pLDegProc pLDegOrig; |
---|
615 | |
---|
616 | p_SetmProc p_Setm; |
---|
617 | n_Procs_s* cf; |
---|
618 | ring algring; |
---|
619 | #ifdef HAVE_PLURAL |
---|
620 | private: |
---|
621 | nc_struct* _nc; // private |
---|
622 | public: |
---|
623 | inline const nc_struct* GetNC() const { return _nc; }; // public!!! |
---|
624 | inline nc_struct*& GetNC() { return _nc; }; // public!!! |
---|
625 | #endif |
---|
626 | }; |
---|
627 | |
---|
628 | #endif /* __cplusplus */ |
---|
629 | |
---|
630 | |
---|
631 | |
---|
632 | /* |
---|
633 | ** 7. runtime procedures/global data |
---|
634 | */ |
---|
635 | |
---|
636 | /* 7.1 C-routines : */ |
---|
637 | |
---|
638 | |
---|
639 | #ifdef __cplusplus |
---|
640 | extern "C" { |
---|
641 | #endif |
---|
642 | void m2_end(int i) __attribute__((noreturn)); |
---|
643 | #ifdef __cplusplus |
---|
644 | } |
---|
645 | #endif |
---|
646 | |
---|
647 | /* 7.2 C++-routines : */ |
---|
648 | |
---|
649 | #ifdef __cplusplus |
---|
650 | int inits(void); |
---|
651 | int IsPrime(int i); |
---|
652 | #ifdef buildin_rand |
---|
653 | extern int siSeed; |
---|
654 | int siRand(); |
---|
655 | #endif |
---|
656 | #endif |
---|
657 | |
---|
658 | #define loop for(;;) |
---|
659 | |
---|
660 | #ifndef ABS |
---|
661 | #define ABS(x) ((x)<0?(-(x)):(x)) |
---|
662 | #endif |
---|
663 | |
---|
664 | #if defined(__cplusplus) |
---|
665 | static inline int si_max(const int a, const int b) { return (a>b) ? a : b; } |
---|
666 | static inline int si_min(const int a, const int b) { return (a<b) ? a : b; } |
---|
667 | static inline long si_max(const long a, const long b) { return (a>b) ? a : b; } |
---|
668 | static inline long si_min(const long a, const long b) { return (a<b) ? a : b; } |
---|
669 | #else |
---|
670 | #define si_max(A,B) ((A) > (B) ? (A) : (B)) |
---|
671 | #define si_min(A,B) ((A) < (B) ? (A) : (B)) |
---|
672 | #endif |
---|
673 | |
---|
674 | extern struct omBin_s* char_ptr_bin; |
---|
675 | extern struct omBin_s* sleftv_bin; |
---|
676 | |
---|
677 | #ifdef __cplusplus |
---|
678 | union uutypes |
---|
679 | { |
---|
680 | int i; |
---|
681 | ring uring; |
---|
682 | poly p; |
---|
683 | number n; |
---|
684 | ideal uideal; |
---|
685 | map umap; |
---|
686 | matrix umatrix; |
---|
687 | char * ustring; |
---|
688 | intvec * iv; |
---|
689 | lists l; |
---|
690 | si_link li; |
---|
691 | package pack; |
---|
692 | procinfo * pinf; |
---|
693 | }; |
---|
694 | |
---|
695 | class idrec |
---|
696 | { |
---|
697 | public: |
---|
698 | /* !! do not change the first 6 entries !! (see subexpr.h: sleftv) */ |
---|
699 | idhdl next; |
---|
700 | const char *id; |
---|
701 | utypes data; |
---|
702 | attr attribute; |
---|
703 | BITSET flag; |
---|
704 | idtyp typ; |
---|
705 | |
---|
706 | short lev; |
---|
707 | short ref; |
---|
708 | int id_i; |
---|
709 | |
---|
710 | idrec() { memset(this,0,sizeof(*this)); } |
---|
711 | idhdl get(const char * s, int lev); |
---|
712 | idhdl set(const char * s, int lev, idtyp t, BOOLEAN init=TRUE); |
---|
713 | char * String(); |
---|
714 | // ~idrec(); |
---|
715 | }; |
---|
716 | |
---|
717 | #endif |
---|
718 | |
---|
719 | #endif |
---|
720 | |
---|