source: git/kernel/structs.h @ 835d83

spielwiese
Last change on this file since 835d83 was 835d83, checked in by Hans Schönemann <hannes@…>, 14 years ago
move stuff from structs.h git-svn-id: file:///usr/local/Singular/svn/trunk@12398 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 26.7 KB
Line 
1#ifndef STRUCTS_H
2#define STRUCTS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id$ */
7/*
8* ABSTRACT
9*/
10
11#include <string.h> /* for memset */
12#ifdef HAVE_RINGS
13#include <si_gmp.h>
14#endif
15
16#ifndef NATNUMBER
17#define NATNUMBER unsigned long
18#endif
19
20/* standard types */
21typedef unsigned char  uchar;
22typedef unsigned short CARDINAL;
23#ifdef HAVE_RINGS
24typedef MP_INT *int_number;
25#endif
26#if (SIZEOF_LONG == 8)
27typedef int BOOLEAN;
28/* testet on x86_64, gcc 3.4.6: 2 % */
29/* testet on IA64, gcc 3.4.6: 1 % */
30#else
31/* testet on athlon, gcc 2.95.4: 1 % */
32typedef short BOOLEAN;
33#endif
34
35typedef void * Sy_reference;
36#define ADDRESS Sy_reference
37#define BITSET  unsigned int
38
39/* EXPONENT_TYPE is determined by configure und defined in mod2.h */
40/* the following defines should really go into mod2.h,
41   but configure dislikes it */
42
43#define HAVE_IDI 1
44
45#if defined(SI_CPU_I386) || defined(SI_CPU_X86_64)
46  // the following settings seems to be better on i386 and x86_64 processors
47  // define if a*b is with mod instead of tables
48  #define HAVE_MULT_MOD
49  // #define HAVE_GENERIC_ADD
50  // #ifdef HAVE_MULT_MOD
51  // #define HAVE_DIV_MOD
52  // #endif
53#elif defined(SI_CPU_IA64)
54  // the following settings seems to be better on itanium processors
55  // #define HAVE_MULT_MOD
56  #define HAVE_GENERIC_ADD
57  // #ifdef HAVE_MULT_MOD
58  // #define HAVE_DIV_MOD
59  // #endif
60#elif defined(SI_CPU_SPARC)
61  // #define HAVE_GENERIC_ADD
62  #define HAVE_MULT_MOD
63  #ifdef HAVE_MULT_MOD
64  #define HAVE_DIV_MOD
65  #endif
66#elif defined(SI_CPU_PPC)
67  // the following settings seems to be better on ppc processors
68  // testet on: ppc_Linux, 740/750 PowerMac G3, 512k L2 cache
69  #define HAVE_MULT_MOD
70  // #ifdef HAVE_MULT_MOD
71  // #define HAVE_DIV_MOD
72  // #endif
73#endif
74
75#if SIZEOF_LONG == 4
76typedef long long int64;
77#elif SIZEOF_LONG == 8
78typedef long int64;
79#else
80#error int64 undefined
81#endif
82
83
84typedef long Exponent_t;
85typedef long Order_t;
86
87enum tHomog
88{
89   isNotHomog = FALSE,
90   isHomog    = TRUE,
91   testHomog
92};
93enum noeof_t
94{
95  noeof_brace = 1,
96  noeof_asstring,
97  noeof_block,
98  noeof_bracket,
99  noeof_comment,
100  noeof_procname,
101  noeof_string
102};
103
104enum n_coeffType
105{
106  n_unknown=0,
107  n_Zp,
108  n_Q,
109  n_R,
110  n_GF,
111  n_long_R,
112  n_Zp_a,
113  n_Q_a,
114  n_long_C
115};
116
117// #ifdef HAVE_PLURAL
118enum nc_type
119{
120  nc_error = -1, // Something's gone wrong!
121  nc_general = 0, /* yx=q xy+... */
122  nc_skew, /*1*/ /* yx=q xy */
123  nc_comm, /*2*/ /* yx= xy */
124  nc_lie,  /*3*/ /* yx=xy+... */
125  nc_undef, /*4*/  /* for internal reasons */
126
127  nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0
128};
129// #endif
130
131typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX, LT_MACH_O} lib_types;
132
133/* C++-part */
134#ifdef __cplusplus
135class ip_smatrix;
136class idrec;
137class intvec;
138class sleftv;
139class slists;
140class sattr;
141class skStrategy;
142class ssyStrategy;
143class procinfo;
144class namerec;
145class kBucket;
146class sBucket;
147class CPolynomialSummator;
148class CGlobalMultiplier;
149class CFormulaPowerMultiplier;
150#endif
151
152struct n_Procs_s;
153struct sip_sring;
154struct sip_sideal;
155struct sip_link;
156struct spolynom;
157struct _ssubexpr;
158struct _sssym;
159struct snumber;
160struct sip_command;
161struct sip_package;
162struct s_si_link_extension;
163
164typedef struct  n_Procs_s  n_Procs_s;
165
166// #ifdef HAVE_PLURAL
167struct nc_struct;
168typedef struct nc_struct   nc_struct;
169// #endif
170
171typedef struct _ssubexpr   sSubexpr;
172typedef struct _sssym      ssym;
173typedef struct spolyrec    polyrec;
174typedef struct sip_sideal  ip_sideal;
175typedef struct sip_smap    ip_smap;
176typedef struct sip_sring   ip_sring;
177typedef struct sip_link    ip_link;
178typedef struct sip_command ip_command;
179typedef struct sip_package ip_package;
180
181/* the pointer types */
182typedef char *             char_ptr;
183typedef int  *             int_ptr;
184typedef short *            short_ptr;
185typedef ip_sring *         ring;
186typedef int                idtyp;
187typedef struct snumber *   number;
188typedef polyrec *          poly;
189typedef poly *             polyset;
190typedef ip_sideal *        ideal;
191typedef ip_smap *          map;
192typedef struct sideal_list *      ideal_list;
193typedef ideal *            resolvente;
194typedef union uutypes      utypes;
195typedef ip_command *       command;
196typedef struct s_si_link_extension *si_link_extension;
197typedef polyrec *   napoly;
198
199#ifdef __cplusplus
200typedef idrec *            idhdl;
201typedef ip_smatrix *       matrix;
202typedef ip_link *          si_link;
203typedef sleftv *           leftv;
204typedef slists *           lists;
205typedef sSubexpr *         Subexpr;
206typedef sattr *            attr;
207typedef skStrategy *       kStrategy;
208typedef ip_package *       package;
209typedef ssyStrategy *      syStrategy;
210typedef procinfo *         procinfov;
211typedef namerec *          namehdl;
212typedef kBucket*           kBucket_pt;
213typedef sBucket*           sBucket_pt;
214typedef struct p_Procs_s p_Procs_s;
215
216// for hdegree.cc
217typedef struct sindlist indlist;
218typedef indlist * indset;
219struct sindlist
220{
221  indset nx;
222  intvec * set;
223};
224
225// for longalg.cc
226struct snaIdeal
227{
228  int anz;
229  napoly *liste;
230};
231typedef struct snaIdeal * naIdeal;
232
233
234// for sparsemat.cc
235typedef struct smprec sm_prec;
236typedef sm_prec * smpoly;
237struct smprec
238{
239  smpoly n;            // the next element
240  int pos;             // position
241  int e;               // level
242  poly m;              // the element
243  float f;             // complexity of the element
244};
245
246struct _scmdnames
247{
248  char *name;
249  short alias;
250  short tokval;
251  short toktype;
252};
253typedef struct _scmdnames cmdnames;
254
255typedef number (*numberfunc)(number a,number b);
256typedef number (*nMapFunc)(number a);
257struct n_Procs_s
258{
259   n_Procs_s* next;
260   // the union stuff
261   // Zp:
262   int npPrimeM;
263   int npPminus1M;
264   #ifdef HAVE_DIV_MOD
265   CARDINAL *npInvTable;
266   #endif
267   #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
268   CARDINAL *npExpTable;
269   CARDINAL *npLogTable;
270   #endif
271   // Zp_a, Q_a
272
273   // general stuff
274   numberfunc nMult, nSub ,nAdd ,nDiv, nIntDiv, nIntMod, nExactDiv;
275   number  (*cfInit)(int i,const ring r);
276   number  (*nPar)(int i);
277   int     (*nParDeg)(number n);
278   int     (*nSize)(number n);
279   int     (*n_Int)(number &n, const ring r);
280#ifdef HAVE_RINGS
281   int     (*nDivComp)(number a,number b);
282   BOOLEAN (*nIsUnit)(number a);
283   number  (*nGetUnit)(number a);
284   number  (*nExtGcd)(number a, number b, number *s, number *t);
285#endif
286   number  (*nNeg)(number a);
287   number  (*nInvers)(number a);
288   number  (*nCopy)(number a);
289   number  (*cfCopy)(number a, const ring r);
290   number  (*nRePart)(number a);
291   number  (*nImPart)(number a);
292   void    (*cfWrite)(number &a, const ring r);
293   const char *  (*nRead)(const char * s, number * a);
294   void    (*nNormalize)(number &a);
295   BOOLEAN (*nGreater)(number a,number b),
296#ifdef HAVE_RINGS
297           (*nDivBy)(number a, number b),
298#endif
299           (*nEqual)(number a,number b),
300           (*nIsZero)(number a),
301           (*nIsOne)(number a),
302           (*nIsMOne)(number a),
303           (*nGreaterZero)(number a);
304   void    (*nPower)(number a, int i, number * result);
305   number  (*cfGetDenom)(number &n, const ring r);
306   number  (*cfGetNumerator)(number &n, const ring r);
307   number  (*nGcd)(number a, number b, const ring r);
308   number  (*nLcm)(number a, number b, const ring r);
309   void    (*cfDelete)(number * a, const ring r);
310   nMapFunc (*cfSetMap)(const ring src, const ring dst);
311   char *  (*nName)(number n);
312   void    (*nInpMult)(number &a, number b, ring r);
313#ifdef LDEBUG
314   BOOLEAN (*nDBTest)(number a, const char *f,const int l);
315#endif
316
317   number nNULL; /* the 0 as constant */
318   int     char_flag;
319   int     ref;
320   short   nChar;
321   n_coeffType type;
322};
323
324extern idhdl currPackHdl;
325extern idhdl basePackHdl;
326extern package currPack;
327extern package basePack;
328#define IDROOT (currPack->idroot)
329
330/* the function pointer types */
331
332typedef long     (*pLDegProc)(poly p, int *length, ring r);
333typedef long     (*pFDegProc)(poly p, ring r);
334typedef void     (*p_SetmProc)(poly p, const ring r);
335
336typedef enum
337{
338  ro_dp, // ordering is a degree ordering
339  ro_wp, // ordering is a weighted degree ordering
340  ro_wp64, // ordering is a weighted64 degree ordering
341  ro_wp_neg, // ordering is a weighted degree ordering
342             // with possibly negative weights
343  ro_cp,    // ordering duplicates variables
344  ro_syzcomp, // ordering indicates "subset" of component number (ringorder_S)
345  ro_syz, // ordering  with component number >syzcomp is lower (ringorder_s)
346  ro_isTemp, ro_is, // Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS)
347  ro_none
348}
349ro_typ;
350
351// ordering is a degree ordering
352struct sro_dp
353{
354  short place;  // where degree is stored (in L):
355  short start;  // bounds of ordering (in E):
356  short end;
357};
358typedef struct sro_dp sro_dp;
359
360// ordering is a weighted degree ordering
361struct sro_wp
362{
363  short place;  // where weighted degree is stored (in L)
364  short start;  // bounds of ordering (in E)
365  short end;
366  int *weights; // pointers into wvhdl field
367};
368typedef struct sro_wp sro_wp;
369
370// ordering is a weighted degree ordering
371struct sro_wp64
372{
373    short place;  // where weighted degree is stored (in L)
374    short start;  // bounds of ordering (in E)
375    short end;
376    int64 *weights64; // pointers into wvhdl field
377};
378typedef struct sro_wp64 sro_wp64;
379
380// ordering duplicates variables
381struct sro_cp
382{
383  short place;  // where start is copied to (in E)
384  short start;  // bounds of sources of copied variables (in E)
385  short end;
386};
387typedef struct sro_cp sro_cp;
388
389// ordering indicates "subset" of component number
390struct sro_syzcomp
391{
392  short place;  // where the index is stored (in L)
393  long *ShiftedComponents; // pointer into index field
394  int* Components;
395#ifdef PDEBUG
396  long length;
397#endif
398};
399typedef struct sro_syzcomp sro_syzcomp;
400
401// ordering  with component number >syzcomp is lower
402struct sro_syz
403{
404  short place;       // where the index is stored (in L)
405  int limit;         // syzcomp
406  int* syz_index;    // mapping Component -> SyzIndex for Comp <= limit
407  int  curr_index;   // SyzIndex for Component > limit
408};
409
410typedef struct sro_syz sro_syz;
411// Induced Syzygy (Schreyer) ordering is built inductively as follows:
412// we look for changes made by ordering blocks which are between prefix/suffix markers:
413// that is: which variables where placed by them and where (judging by v)
414
415// due to prefix/suffix nature we need some placeholder:
416// prefix stores here initial state
417// suffix cleares this up
418struct sro_ISTemp
419{
420  short start; // 1st member SHOULD be short "place"
421  int   suffixpos;
422  int*  pVarOffset; // copy!
423};
424
425// So this is the actuall thing!
426// suffix uses last sro_ISTemp (cleares it up afterwards) and
427// creates this block
428struct sro_IS
429{
430  short start, end;  // which part of L we want to want to update...
431  int*  pVarOffset; // same as prefix!
432
433  int limit; // first referenced component
434
435  // reference poly set?? // Should it be owned by ring?!!!
436  ideal F; // reference leading (module)-monomials set. owned by ring...
437  const intvec* componentWeights; // component weights! owned by ring...
438};
439
440typedef struct sro_IS sro_IS;
441typedef struct sro_ISTemp sro_ISTemp;
442
443#ifndef OM_ALLOC_H
444struct omBin_s;
445#endif
446
447struct sro_ord
448{
449  ro_typ  ord_typ;
450  int     order_index; // comes from r->order[order_index]
451  union
452  {
453     sro_dp dp;
454     sro_wp wp;
455     sro_wp64 wp64;
456     sro_cp cp;
457     sro_syzcomp syzcomp;
458     sro_syz syz;
459     sro_IS is;
460     sro_ISTemp isTemp;
461  } data;
462};
463
464#ifdef HAVE_PLURAL
465// NC pProcs:
466typedef poly (*mm_Mult_p_Proc_Ptr)(const poly m, poly p, const ring r);
467typedef poly (*mm_Mult_pp_Proc_Ptr)(const poly m, const poly p, const ring r);
468
469typedef ideal (*GB_Proc_Ptr)(const ideal F, const ideal Q, const intvec *w, const intvec *hilb, kStrategy strat);
470
471typedef poly (*SPoly_Proc_Ptr)(const poly p1, const poly p2, const ring r);
472typedef poly (*SPolyReduce_Proc_Ptr)(const poly p1, poly p2, const ring r);
473
474typedef void (*bucket_Proc_Ptr)(kBucket_pt b, poly p, number *c);
475
476struct nc_pProcs
477{
478public:
479  mm_Mult_p_Proc_Ptr                    mm_Mult_p;
480  mm_Mult_pp_Proc_Ptr                   mm_Mult_pp;
481
482  bucket_Proc_Ptr                       BucketPolyRed;
483  bucket_Proc_Ptr                       BucketPolyRed_Z;
484
485  SPoly_Proc_Ptr                        SPoly;
486  SPolyReduce_Proc_Ptr                  ReduceSPoly;
487
488  GB_Proc_Ptr                           GB;
489//                                         GlobalGB, // BBA
490//                                         LocalGB;  // MORA
491};
492
493
494struct nc_struct
495{
496  short ref;
497  nc_type type;
498  ring basering; // the ring C,D,.. live in (commutative ring with this NC structure!)
499
500  // initial data: square matrices rVar() x rVar()
501  // logically: upper triangular!!!
502  // TODO: eliminate this waste of memory!!!!
503  matrix C; 
504  matrix D;
505
506  // computed data:
507  matrix *MT; // size 0.. (rVar()*rVar()-1)/2
508  matrix COM;
509  int *MTsize; // size 0.. (rVar()*rVar()-1)/2
510
511  // IsSkewConstant indicates whethere coeffs C_ij are all equal,
512  // effective together with nc_type=nc_skew
513  int IsSkewConstant;
514
515  private:
516    // internal data for different implementations
517    // if dynamic => must be deallocated in destructor (nc_rKill!)
518    union {
519      struct {
520        // treat variables from iAltVarsStart till iAltVarsEnd as alternating vars.
521        // these variables should have odd degree, though that will not be checked
522        // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior
523        // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N
524        unsigned int iFirstAltVar, iLastAltVar; // = 0 by default
525
526        // for factors of super-commutative algebras we need
527        // the part of general quotient ideal modulo squares!   
528        ideal idSCAQuotient; // = NULL by default. // must be deleted in Kill!
529      } sca;
530
531    } data;
532
533    CGlobalMultiplier* m_Multiplier;
534    CFormulaPowerMultiplier* m_PowerMultiplier;
535
536  public:
537   
538    inline nc_type& ncRingType() { return (type); };
539    inline nc_type ncRingType() const { return (type); };
540
541    inline unsigned int& FirstAltVar() 
542        { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
543    inline unsigned int& LastAltVar () 
544        { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
545
546    inline unsigned int FirstAltVar() const 
547        { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
548    inline unsigned int LastAltVar () const 
549        { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
550
551    inline ideal& SCAQuotient() 
552        { assume(ncRingType() == nc_exterior); return (data.sca.idSCAQuotient); };
553
554    inline CGlobalMultiplier* GetGlobalMultiplier() const
555        { assume(ncRingType() != nc_exterior); return (m_Multiplier); };
556
557    inline CGlobalMultiplier*& GetGlobalMultiplier()
558        { assume(ncRingType() != nc_exterior); return (m_Multiplier); };
559
560
561    inline CFormulaPowerMultiplier* GetFormulaPowerMultiplier() const
562        { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); };
563
564    inline CFormulaPowerMultiplier*& GetFormulaPowerMultiplier()
565        { assume(ncRingType() != nc_exterior); return (m_PowerMultiplier); };
566   
567  public:
568    nc_pProcs p_Procs; // NC procedures.
569
570};
571#endif
572#if 0
573struct nc_struct
574{
575  short ref;
576  nc_type type;
577  ring basering; // the ring C,D,.. live in
578  matrix C;
579  matrix D;
580  matrix *MT;
581  matrix COM;
582  int *MTsize;
583  int IsSkewConstant; /* indicates whethere coeffs C_ij are all equal */
584  /* effective together with nc_type=nc_skew */
585};
586#endif
587
588
589struct sip_sring
590{
591// each entry must have a description and a procedure defining it,
592// general ordering: pointer/structs, long, int, short, BOOLEAN/char/enum
593// general defining procedures: rInit, rComplete, interpreter, ??
594  idhdl      idroot; /* local objects , interpreter*/
595  int*       order;  /* array of orderings, rInit/rSleftvOrdering2Ordering */
596  int*       block0; /* starting pos., rInit/rSleftvOrdering2Ordering*/
597  int*       block1; /* ending pos., rInit/rSleftvOrdering2Ordering*/
598  char**     parameter; /* names of parameters, rInit */
599  number     minpoly;  /* for Q_a/Zp_a, rInit */
600  ideal      minideal;
601  int**      wvhdl;  /* array of weight vectors, rInit/rSleftvOrdering2Ordering */
602  char **    names;  /* array of variable names, rInit */
603
604  // what follows below here should be set by rComplete, _only_
605  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
606                       /*  ExpL_Size entries*/
607
608  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
609  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
610  /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs
611  in ExpVector whose values need an offset due to negative weights */
612  /* array of NegWeigtL_Size indicies */
613  int*      NegWeightL_Offset;
614
615  int*     VarOffset;
616
617  ideal      qideal; /* extension to the ring structure: qring, rInit */
618
619
620  int*     firstwv;
621
622  struct omBin_s*   PolyBin; /* Bin from where monoms are allocated */
623#ifdef HAVE_RINGS
624  unsigned int  ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
625  int_number    ringflaga; /* Z/(ringflag^ringflagb)=Z/nrnModul*/
626  unsigned long ringflagb;
627  unsigned long nr2mModul;  /* Z/nr2mModul */
628  int_number    nrnModul;
629#endif
630  unsigned long options; /* ring dependent options */
631
632  int        ch;  /* characteristic, rInit */
633  int        ref; /* reference counter to the ring, interpreter */
634
635  short      float_len; /* additional char-flags, rInit */
636  short      float_len2; /* additional char-flags, rInit */
637
638  short      N;      /* number of vars, rInit */
639
640  short      P;      /* number of pars, rInit */
641  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */
642
643  short     firstBlockEnds;
644#ifdef HAVE_PLURAL
645  short     real_var_start, real_var_end;
646#endif
647
648#ifdef HAVE_SHIFTBBA
649  short          isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
650#endif
651
652  BOOLEAN   VectorOut;
653  BOOLEAN   ShortOut;
654  BOOLEAN   CanShortOut;
655  BOOLEAN   LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
656  BOOLEAN   MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise
657
658  BOOLEAN   ComponentOrder; // ???
659
660
661  // what follows below here should be set by rComplete, _only_
662  // contains component, but no weight fields in E */
663  short      ExpL_Size; // size of exponent vector in long
664  short      CmpL_Size; // portions which need to be compared
665  /* number of long vars in exp vector:
666     long vars are those longs in the exponent vector which are
667     occupied by variables, only */
668  short     VarL_Size;
669  short      BitsPerExp; /* number of bits per exponent */
670  short      ExpPerLong; /* maximal number of Exponents per long */
671  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
672  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
673  short      OrdSize; /* size of ord vector (in sro_ord) */
674
675  /* if >= 0, long vars in exp vector are consecutive and start there
676     if <  0, long vars in exp vector are not consecutive */
677  short     VarL_LowIndex;
678  // number of exponents in r->VarL_Offset[0]
679  // is minimal number of exponents in a long var
680  short     MinExpPerLong;
681
682  short     NegWeightL_Size;
683  /* array of size VarL_Size,
684     VarL_Offset[i] gets i-th long var in exp vector */
685  int*      VarL_Offset;
686
687  /* mask for getting single exponents */
688  unsigned long bitmask;
689  /* mask used for divisiblity tests */
690  unsigned long divmask; // rComplete
691
692  p_Procs_s*    p_Procs; // rComplete/p_ProcsSet
693
694  /* FDeg and LDeg */
695  pFDegProc     pFDeg; // rComplete/rSetDegStuff
696  pLDegProc     pLDeg; // rComplete/rSetDegStuff
697
698  /* as it was determined by rComplete */
699  pFDegProc     pFDegOrig;
700  /* and as it was determined before rOptimizeLDeg */
701  pLDegProc     pLDegOrig;
702
703  p_SetmProc    p_Setm;
704  n_Procs_s*    cf;
705  ring          algring;
706#ifdef HAVE_PLURAL
707  private:
708    nc_struct*    _nc; // private
709  public:
710    inline const nc_struct* GetNC() const { return _nc; }; // public!!!
711    inline nc_struct*& GetNC() { return _nc; }; // public!!!
712#endif
713};
714
715struct sip_sideal
716{
717  poly*  m;
718  long rank;
719  int nrows;
720  int ncols;
721  #define IDELEMS(i) ((i)->ncols)
722};
723
724struct sip_smap
725{
726  poly *m;
727  char *preimage;
728  int nrows;
729  int ncols;
730};
731
732struct sideal_list
733{
734  ideal_list next;
735  ideal      d;
736#ifndef NDEBUG
737  int nr;
738#endif
739};
740#endif /* __cplusplus */
741
742
743
744/*
745**  7. runtime procedures/global data
746*/
747
748/* 7.1 C-routines : */
749
750
751#ifdef __cplusplus
752extern "C" {
753#endif
754void  m2_end(int i) __attribute__((noreturn));
755#ifdef __cplusplus
756}
757#endif
758
759/* 7.2 C++-routines : */
760
761#ifdef __cplusplus
762int   inits(void);
763int   IsPrime(int i);
764#ifdef buildin_rand
765extern int siSeed;
766int siRand();
767#endif
768#endif
769
770/*the general set of std-options --> kutil.cc */
771extern BITSET test;
772/*the general set of verbose-options --> febase.cc */
773#ifdef __cplusplus
774extern "C" BITSET verbose;
775#else
776extern BITSET verbose;
777#endif
778/*debugging the bison grammar --> grammar.cc*/
779#ifdef YYDEBUG
780#if YYDEBUG
781extern int    yydebug;
782#endif
783#endif
784
785#define loop for(;;)
786
787#ifndef ABS
788#define ABS(x) ((x)<0?(-(x)):(x))
789#endif
790
791#if defined(__cplusplus)
792static inline int si_max(const int a, const int b)  { return (a>b) ? a : b; }
793static inline int si_min(const int a, const int b)  { return (a<b) ? a : b; }
794static inline long si_max(const long a, const long b)  { return (a>b) ? a : b; }
795static inline long si_min(const long a, const long b)  { return (a<b) ? a : b; }
796#else
797#define si_max(A,B) ((A) > (B) ? (A) : (B))
798#define si_min(A,B) ((A) < (B) ? (A) : (B))
799#endif
800
801/*
802**  Set operations (small sets only)
803*/
804
805#define Sy_bit(x)     ((unsigned)1<<(x))
806#define Sy_inset(x,s) ((Sy_bit(x)&(s))?TRUE:FALSE)
807#define BTEST1(a)     Sy_inset((a), test)
808#define BVERBOSE(a)   Sy_inset((a), verbose)
809
810/*
811** defines for BITSETs
812*/
813
814#define V_SHOW_MEM    2
815#define V_YACC        3
816#define V_REDEFINE    4
817#define V_READING     5
818#define V_LOAD_LIB    6
819#define V_DEBUG_LIB   7
820#define V_LOAD_PROC   8
821#define V_DEF_RES     9
822#define V_DEBUG_MEM  10
823#define V_SHOW_USE   11
824#define V_IMAP       12
825#define V_PROMPT     13
826#define V_NSB        14
827#define V_CONTENTSB  15
828#define V_CANCELUNIT 16
829#define V_MODPSOLVSB 17
830#define V_UPTORADICAL 18
831#define V_FINDMONOM  19
832#define V_COEFSTRAT  20
833#define V_IDLIFT     21
834#define V_LENGTH     22
835/* for tests: 23-30 */
836#define V_DEG_STOP   31
837
838
839#define OPT_PROT           0
840#define OPT_REDSB          1
841#define OPT_NOT_BUCKETS    2
842#define OPT_NOT_SUGAR      3
843#define OPT_INTERRUPT      4
844#define OPT_SUGARCRIT      5
845#define OPT_DEBUG          6
846#define OPT_REDTHROUGH     7
847#define OPT_RETURN_SB      9
848#define OPT_FASTHC        10
849#define OPT_OLDSTD        20
850#define OPT_KEEPVARS      21
851#define OPT_STAIRCASEBOUND 22
852#define OPT_MULTBOUND     23
853#define OPT_DEGBOUND      24
854#define OPT_REDTAIL       25
855#define OPT_INTSTRATEGY   26
856#define OPT_FINDET        27
857#define OPT_INFREDTAIL    28
858#define OPT_SB_1          29
859#define OPT_NOTREGULARITY 30
860#define OPT_WEIGHTM       31
861
862/* define ring dependent options */
863#define TEST_RINGDEP_OPTS \
864 (Sy_bit(OPT_INTSTRATEGY) | Sy_bit(OPT_REDTHROUGH) | Sy_bit(OPT_REDTAIL))
865
866#define TEST_OPT_PROT              BTEST1(OPT_PROT)
867#define TEST_OPT_REDSB             BTEST1(OPT_REDSB)
868#define TEST_OPT_NOT_BUCKETS       BTEST1(OPT_NOT_BUCKETS)
869#define TEST_OPT_NOT_SUGAR         BTEST1(OPT_NOT_SUGAR)
870#define TEST_OPT_SUGARCRIT         BTEST1(OPT_SUGARCRIT)
871#define TEST_OPT_DEBUG             BTEST1(OPT_DEBUG)
872#define TEST_OPT_FASTHC            BTEST1(OPT_FASTHC)
873#define TEST_OPT_INTSTRATEGY       BTEST1(OPT_INTSTRATEGY)
874#define TEST_OPT_FINDET            BTEST1(OPT_FINDET)
875#define TEST_OPT_RETURN_SB         BTEST1(OPT_RETURN_SB)
876#define TEST_OPT_KEEPVARS          BTEST1(OPT_KEEPVARS)
877#define TEST_OPT_DEGBOUND          BTEST1(OPT_DEGBOUND)
878#define TEST_OPT_MULTBOUND         BTEST1(OPT_MULTBOUND)
879#define TEST_OPT_STAIRCASEBOUND    BTEST1(OPT_STAIRCASEBOUND)
880#define TEST_OPT_REDTAIL           BTEST1(OPT_REDTAIL)
881#define TEST_OPT_INFREDTAIL        BTEST1(OPT_INFREDTAIL)
882#define TEST_OPT_SB_1              BTEST1(OPT_SB_1)
883#define TEST_OPT_NOTREGULARITY     BTEST1(OPT_NOTREGULARITY)
884#define TEST_OPT_WEIGHTM           BTEST1(OPT_WEIGHTM)
885#define TEST_OPT_REDTHROUGH        BTEST1(OPT_REDTHROUGH)
886#define TEST_OPT_OLDSTD            BTEST1(OPT_OLDSTD)
887#define TEST_OPT_CONTENTSB         BVERBOSE(V_CONTENTSB)
888#define TEST_OPT_CANCELUNIT        BVERBOSE(V_CANCELUNIT)
889#define TEST_OPT_IDLIFT            BVERBOSE(V_IDLIFT)
890#define TEST_OPT_LENGTH            BVERBOSE(V_LENGTH)
891
892#define TEST_VERB_NSB              BVERBOSE(V_NSB)
893#define TEST_V_DEG_STOP            BVERBOSE(V_DEG_STOP)
894#define TEST_V_MODPSOLVSB          BVERBOSE(V_MODPSOLVSB)
895#define TEST_V_COEFSTRAT           BVERBOSE(V_COEFSTRAT)
896#define TEST_V_UPTORADICAL         BVERBOSE(V_UPTORADICAL)
897#define TEST_V_FINDMONOM           BVERBOSE(V_FINDMONOM)
898#ifdef HAVE_LIBPARSER
899#ifdef __cplusplus
900class libstack;
901typedef libstack *  libstackv;
902#endif
903#endif /* HAVE_LIBPARSER */
904
905extern struct omBin_s* char_ptr_bin;
906extern struct omBin_s* ideal_bin;
907extern struct omBin_s* int_bin;
908extern struct omBin_s* poly_bin;
909extern struct omBin_s* indlist_bin;
910extern struct omBin_s* naIdeal_bin;
911extern struct omBin_s* snaIdeal_bin;
912extern struct omBin_s* sm_prec_bin;
913extern struct omBin_s* smprec_bin;
914extern struct omBin_s* sip_sideal_bin;
915extern struct omBin_s* sip_smap_bin;
916extern struct omBin_s* sip_sring_bin;
917extern struct omBin_s* ip_sideal_bin;
918extern struct omBin_s* ip_sring_bin;
919extern struct omBin_s* sleftv_bin;
920
921#ifdef __cplusplus
922union uutypes
923{
924  int           i;
925  ring          uring;
926  poly          p;
927  number        n;
928  ideal         uideal;
929  map           umap;
930  matrix        umatrix;
931  char *        ustring;
932  intvec *      iv;
933  lists         l;
934  si_link       li;
935  package       pack;
936  procinfo *    pinf;
937};
938
939class idrec
940{
941  public:
942  /* !! do not change the first 6 entries !! (see subexpr.h: sleftv) */
943  idhdl      next;
944  const char *id;
945  utypes     data;
946  attr       attribute;
947  BITSET     flag;
948  idtyp      typ;
949
950  short      lev;
951  short      ref;
952#ifdef HAVE_IDI
953  int        id_i;
954#endif
955
956#define IDNEXT(a)    ((a)->next)
957#define IDTYP(a)     ((a)->typ)
958#define IDFLAG(a)    ((a)->flag)
959#define IDLEV(a)     ((a)->lev)
960#define IDID(a)      ((a)->id)
961#define IDATTR(a)    ((a)->attribute)
962
963#define IDINT(a)    ((int)(long)((a)->data.ustring))
964#define IDDATA(a)   ((a)->data.ustring)
965#define IDRING(a)   ((a)->data.uring)
966#define IDINTVEC(a) ((a)->data.iv)
967#define IDPOLY(a)   ((a)->data.p)
968#define IDBIGINT(a) ((a)->data.n)
969#define IDNUMBER(a) ((a)->data.n)
970#define IDIDEAL(a)  (((a)->data).uideal)
971#define IDMATRIX(a) (((a)->data).umatrix)
972#define IDMAP(a)    (((a)->data).umap)
973#define IDSTRING(a) ((a)->data.ustring)
974#define IDLIST(a)   ((a)->data.l)
975#define IDLINK(a)   ((a)->data.li)
976#define IDPACKAGE(a) ((a)->data.pack)
977#define IDPROC(a)   ((a)->data.pinf)
978
979  idrec() { memset(this,0,sizeof(*this)); }
980  idhdl get(const char * s, int lev);
981  idhdl set(const char * s, int lev, idtyp t, BOOLEAN init=TRUE);
982  char * String();
983//  ~idrec();
984};
985
986#endif
987
988#endif
989
Note: See TracBrowser for help on using the repository browser.