source: git/kernel/structs.h @ 04deab

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