source: git/kernel/structs.h @ 3c38b38

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