source: git/kernel/structs.h @ 645a19

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