source: git/kernel/structs.h @ cfb8edb

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