source: git/kernel/structs.h @ fe7424

spielwiese
Last change on this file since fe7424 was fe7424, checked in by Hans Schönemann <hannes@…>, 16 years ago
hannes:var for Part in ring git-svn-id: file:///usr/local/Singular/svn/trunk@10907 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.53 2008-07-25 10:44:16 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  inline int& idelems(void) { return ncols; }
700};
701
702struct sip_smap
703{
704  poly *m;
705  char *preimage;
706  int nrows;
707  int ncols;
708};
709
710struct sideal_list
711{
712  ideal_list next;
713  ideal      d;
714#ifndef NDEBUG
715  int nr;
716#endif
717};
718#endif /* __cplusplus */
719
720
721
722/*
723**  7. runtime procedures/global data
724*/
725
726/* 7.1 C-routines : */
727
728
729#ifdef __cplusplus
730extern "C" {
731#endif
732void  m2_end(int i);
733#ifdef __cplusplus
734}
735#endif
736
737/* 7.2 C++-routines : */
738
739#ifdef __cplusplus
740int   inits(void);
741int   IsPrime(int i);
742#ifdef buildin_rand
743extern int siSeed;
744int siRand();
745#endif
746#endif
747
748/*the general set of std-options --> kutil.cc */
749extern BITSET test;
750/*the general set of verbose-options --> febase.cc */
751#ifdef __cplusplus
752extern "C" BITSET verbose;
753#else
754extern BITSET verbose;
755#endif
756/*debugging the bison grammar --> grammar.cc*/
757#ifdef YYDEBUG
758#if YYDEBUG
759extern int    yydebug;
760#endif
761#endif
762
763extern int      yylineno;
764extern char     my_yylinebuf[80];
765
766#define loop for(;;)
767
768#ifndef ABS
769#define ABS(x) ((x)<0?(-(x)):(x))
770#endif
771
772#if defined(__cplusplus)
773inline int si_max(const int a, const int b)  { return (a>b) ? a : b; }
774inline int si_min(const int a, const int b)  { return (a<b) ? a : b; }
775#if defined(DecAlpha_Linux) || defined(IA64_Linux)
776inline long si_max(const long a, const long b)  { return (a>b) ? a : b; }
777inline long si_min(const long a, const long b)  { return (a<b) ? a : b; }
778#endif
779#else
780#define si_max(A,B) ((A) > (B) ? (A) : (B))
781#define si_min(A,B) ((A) < (B) ? (A) : (B))
782#endif
783
784/*
785**  Set operations (small sets only)
786*/
787
788#define Sy_bit(x)     ((unsigned)1<<(x))
789#define Sy_inset(x,s) ((Sy_bit(x)&(s))?TRUE:FALSE)
790#define BTEST1(a)     Sy_inset((a), test)
791#define BVERBOSE(a)   Sy_inset((a), verbose)
792
793/*
794** defines for BITSETs
795*/
796
797#define V_SHOW_MEM    2
798#define V_YACC        3
799#define V_REDEFINE    4
800#define V_READING     5
801#define V_LOAD_LIB    6
802#define V_DEBUG_LIB   7
803#define V_LOAD_PROC   8
804#define V_DEF_RES     9
805#define V_DEBUG_MEM  10
806#define V_SHOW_USE   11
807#define V_IMAP       12
808#define V_PROMPT     13
809#define V_NSB        14
810#define V_CONTENTSB  15
811#define V_CANCELUNIT 16
812#define V_MODPSOLVSB 17
813#define V_UPTORADICAL 18
814#define V_FINDMONOM  19
815#define V_COEFSTRAT  20
816#define V_IDLIFT     21
817#define V_LENGTH     22
818#define V_DEG_STOP   31
819
820
821#define OPT_PROT           0
822#define OPT_REDSB          1
823#define OPT_NOT_BUCKETS    2
824#define OPT_NOT_SUGAR      3
825#define OPT_INTERRUPT      4
826#define OPT_SUGARCRIT      5
827#define OPT_DEBUG          6
828#define OPT_REDTHROUGH     7
829#define OPT_RETURN_SB      9
830#define OPT_FASTHC        10
831#define OPT_OLDSTD        20
832#define OPT_KEEPVARS      21
833#define OPT_STAIRCASEBOUND 22
834#define OPT_MULTBOUND     23
835#define OPT_DEGBOUND      24
836#define OPT_REDTAIL       25
837#define OPT_INTSTRATEGY   26
838#define OPT_INFREDTAIL    28
839#define OPT_SB_1          29
840#define OPT_NOTREGULARITY 30
841#define OPT_WEIGHTM       31
842
843/* define ring dependent options */
844#define TEST_RINGDEP_OPTS \
845 (Sy_bit(OPT_INTSTRATEGY) | Sy_bit(OPT_REDTHROUGH) | Sy_bit(OPT_REDTAIL))
846
847#define TEST_OPT_PROT              BTEST1(OPT_PROT)
848#define TEST_OPT_REDSB             BTEST1(OPT_REDSB)
849#define TEST_OPT_NOT_BUCKETS       BTEST1(OPT_NOT_BUCKETS)
850#define TEST_OPT_NOT_SUGAR         BTEST1(OPT_NOT_SUGAR)
851#define TEST_OPT_SUGARCRIT         BTEST1(OPT_SUGARCRIT)
852#define TEST_OPT_DEBUG             BTEST1(OPT_DEBUG)
853#define TEST_OPT_FASTHC            BTEST1(OPT_FASTHC)
854#define TEST_OPT_INTSTRATEGY       BTEST1(OPT_INTSTRATEGY)
855#define TEST_OPT_RETURN_SB         BTEST1(OPT_RETURN_SB)
856#define TEST_OPT_KEEPVARS          BTEST1(OPT_KEEPVARS)
857#define TEST_OPT_DEGBOUND          BTEST1(OPT_DEGBOUND)
858#define TEST_OPT_MULTBOUND         BTEST1(OPT_MULTBOUND)
859#define TEST_OPT_STAIRCASEBOUND    BTEST1(OPT_STAIRCASEBOUND)
860#define TEST_OPT_REDTAIL           BTEST1(OPT_REDTAIL)
861#define TEST_OPT_INFREDTAIL        BTEST1(OPT_INFREDTAIL)
862#define TEST_OPT_SB_1              BTEST1(OPT_SB_1)
863#define TEST_OPT_NOTREGULARITY     BTEST1(OPT_NOTREGULARITY)
864#define TEST_OPT_WEIGHTM           BTEST1(OPT_WEIGHTM)
865#define TEST_OPT_REDTHROUGH        BTEST1(OPT_REDTHROUGH)
866#define TEST_OPT_OLDSTD            BTEST1(OPT_OLDSTD)
867#define TEST_OPT_CONTENTSB         BVERBOSE(V_CONTENTSB)
868#define TEST_OPT_CANCELUNIT        BVERBOSE(V_CANCELUNIT)
869#define TEST_OPT_IDLIFT            BVERBOSE(V_IDLIFT)
870#define TEST_OPT_LENGTH            BVERBOSE(V_LENGTH)
871
872#define TEST_VERB_NSB              BVERBOSE(V_NSB)
873#define TEST_V_DEG_STOP            BVERBOSE(V_DEG_STOP)
874#define TEST_V_MODPSOLVSB          BVERBOSE(V_MODPSOLVSB)
875#define TEST_V_COEFSTRAT           BVERBOSE(V_COEFSTRAT)
876#define TEST_V_UPTORADICAL         BVERBOSE(V_UPTORADICAL)
877#define TEST_V_FINDMONOM           BVERBOSE(V_FINDMONOM)
878#ifdef HAVE_LIBPARSER
879#ifdef __cplusplus
880class libstack;
881typedef libstack *  libstackv;
882#endif
883#endif /* HAVE_LIBPARSER */
884
885extern struct omBin_s* MP_INT_bin;
886extern struct omBin_s* char_ptr_bin;
887extern struct omBin_s* ideal_bin;
888extern struct omBin_s* int_bin;
889extern struct omBin_s* poly_bin;
890extern struct omBin_s* void_ptr_bin;
891extern struct omBin_s* indlist_bin;
892extern struct omBin_s* naIdeal_bin;
893extern struct omBin_s* snaIdeal_bin;
894extern struct omBin_s* sm_prec_bin;
895extern struct omBin_s* smprec_bin;
896extern struct omBin_s* sip_sideal_bin;
897extern struct omBin_s* sip_smap_bin;
898extern struct omBin_s* sip_sring_bin;
899extern struct omBin_s* ip_sideal_bin;
900extern struct omBin_s* ip_smap_bin;
901extern struct omBin_s* ip_sring_bin;
902extern struct omBin_s* sleftv_bin;
903
904#ifdef __cplusplus
905union uutypes
906{
907  int           i;
908  ring          uring;
909  poly          p;
910  number        n;
911  ideal         uideal;
912  map           umap;
913  matrix        umatrix;
914  char *        ustring;
915  intvec *      iv;
916  lists         l;
917  si_link       li;
918  package       pack;
919  procinfo *    pinf;
920};
921
922class idrec
923{
924  public:
925  /* !! do not change the first 6 entries !! (see subexpr.h: sleftv) */
926  idhdl      next;
927  const char *id;
928  utypes     data;
929  attr       attribute;
930  BITSET     flag;
931  idtyp      typ;
932
933  short      lev;
934  short      ref;
935#ifdef HAVE_IDI
936  int        id_i;
937#endif
938
939#define IDNEXT(a)    ((a)->next)
940#define IDTYP(a)     ((a)->typ)
941#define IDFLAG(a)    ((a)->flag)
942#define IDLEV(a)     ((a)->lev)
943#define IDID(a)      ((a)->id)
944#define IDATTR(a)    ((a)->attribute)
945
946#define IDINT(a)    ((int)(long)((a)->data.ustring))
947#define IDDATA(a)   ((a)->data.ustring)
948#define IDRING(a)   ((a)->data.uring)
949#define IDINTVEC(a) ((a)->data.iv)
950#define IDPOLY(a)   ((a)->data.p)
951#define IDBIGINT(a) ((a)->data.n)
952#define IDNUMBER(a) ((a)->data.n)
953#define IDIDEAL(a)  (((a)->data).uideal)
954#define IDMATRIX(a) (((a)->data).umatrix)
955#define IDMAP(a)    (((a)->data).umap)
956#define IDSTRING(a) ((a)->data.ustring)
957#define IDLIST(a)   ((a)->data.l)
958#define IDLINK(a)   ((a)->data.li)
959#define IDPACKAGE(a) ((a)->data.pack)
960#define IDPROC(a)   ((a)->data.pinf)
961
962  idrec() { memset(this,0,sizeof(*this)); }
963  idhdl get(const char * s, int lev);
964  idhdl set(const char * s, int lev, idtyp t, BOOLEAN init=TRUE);
965  char * String();
966//  ~idrec();
967};
968
969class proc_singular
970{
971public:
972  long   proc_start;       // position where proc is starting
973  long   def_end;          // position where proc header is ending
974  long   help_start;       // position where help is starting
975  long   help_end;         // position where help is starting
976  long   body_start;       // position where proc-body is starting
977  long   body_end;         // position where proc-body is ending
978  long   example_start;    // position where example is starting
979  long   proc_end;         // position where proc is ending
980  int    proc_lineno;
981  int    body_lineno;
982  int    example_lineno;
983  char   *body;
984  long help_chksum;
985};
986
987struct proc_object
988{
989//public:
990  BOOLEAN (*function)(leftv res, leftv v);
991};
992
993union uprocinfodata;
994
995union uprocinfodata
996{
997public:
998  proc_singular  s;        // data of Singular-procedure
999  struct proc_object    o; // pointer to binary-function
1000};
1001
1002typedef union uprocinfodata procinfodata;
1003
1004typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
1005// LANG_TOP     : Toplevel package only
1006// LANG_SINGULAR:
1007// LANG_C       :
1008class procinfo
1009{
1010public:
1011  char          *libname;
1012  char          *procname;
1013#ifdef HAVE_NS
1014  package       pack;
1015#endif
1016  language_defs language;
1017  short         ref;
1018  char          is_static;        // if set, proc not accessible for user
1019  char          trace_flag;
1020  procinfodata  data;
1021};
1022
1023#endif
1024
1025#endif
1026
Note: See TracBrowser for help on using the repository browser.