source: git/kernel/structs.h @ 8391d8

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