source: git/kernel/structs.h @ eab144e

spielwiese
Last change on this file since eab144e was 14193f, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: sip_sring reorg. git-svn-id: file:///usr/local/Singular/svn/trunk@11288 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 27.2 KB
Line 
1#ifndef STRUCTS_H
2#define STRUCTS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: structs.h,v 1.60 2009-01-07 15:22:01 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  (*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// each entry must have a description and a procedure defining it,
572// general ordering: pointer/structs, long, int, short, BOOLEAN/char/enum
573// general defining procedures: rInit, rComplete, interpreter, ??
574  idhdl      idroot; /* local objects , interpreter*/
575  int*       order;  /* array of orderings, rInit/rSleftvOrdering2Ordering */
576  int*       block0; /* starting pos., rInit/rSleftvOrdering2Ordering*/
577  int*       block1; /* ending pos., rInit/rSleftvOrdering2Ordering*/
578  char**     parameter; /* names of parameters, rInit */
579  number     minpoly;  /* for Q_a/Zp_a, rInit */
580  ideal      minideal;
581  int**      wvhdl;  /* array of weight vectors, rInit/rSleftvOrdering2Ordering */
582  char **    names;  /* array of variable names, rInit */
583
584  // what follows below here should be set by rComplete, _only_
585  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
586                       /*  ExpL_Size entries*/
587
588  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
589  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
590  /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs
591  in ExpVector whose values need an offset due to negative weights */
592  /* array of NegWeigtL_Size indicies */
593  int*      NegWeightL_Offset;
594
595  int*     VarOffset;
596
597  ideal      qideal; /* extension to the ring structure: qring, rInit */
598
599
600  int*     firstwv;
601
602  struct omBin_s*   PolyBin; /* Bin from where monoms are allocated */
603#ifdef HAVE_RINGS
604  unsigned int  ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
605  int_number    ringflaga;
606  unsigned long ringflagb;
607#endif
608  unsigned long options; /* ring dependent options */
609
610  int        ch;  /* characteristic, rInit */
611  int        ref; /* reference counter to the ring, interpreter */
612
613  short      float_len; /* additional char-flags, rInit */
614  short      float_len2; /* additional char-flags, rInit */
615
616  short      N;      /* number of vars, rInit */
617
618  short      P;      /* number of pars, rInit */
619  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */
620
621  short     firstBlockEnds;
622#ifdef HAVE_PLURAL
623  short     real_var_start, real_var_end;
624#endif
625
626#ifdef HAVE_SHIFTBBA
627  short          isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
628#endif
629
630  BOOLEAN   VectorOut;
631  BOOLEAN   ShortOut;
632  BOOLEAN   CanShortOut;
633  BOOLEAN   LexOrder;
634  // TRUE if the monomial ordering has polynomial and power series blocks
635  BOOLEAN   MixedOrder;
636  // TRUE for global/local mixed orderings, FALSE otherwise
637  BOOLEAN   ComponentOrder;
638
639
640  // what follows below here should be set by rComplete, _only_
641  // contains component, but no weight fields in E */
642  short      ExpL_Size; // size of exponent vector in long
643  short      CmpL_Size; // portions which need to be compared
644  /* number of long vars in exp vector:
645     long vars are those longs in the exponent vector which are
646     occupied by variables, only */
647  short     VarL_Size;
648  short      BitsPerExp; /* number of bits per exponent */
649  short      ExpPerLong; /* maximal number of Exponents per long */
650  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
651  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
652  short      OrdSize; /* size of ord vector (in sro_ord) */
653
654  /* if >= 0, long vars in exp vector are consecutive and start there
655     if <  0, long vars in exp vector are not consecutive */
656  short     VarL_LowIndex;
657  // number of exponents in r->VarL_Offset[0]
658  // is minimal number of exponents in a long var
659  short     MinExpPerLong;
660
661  short     NegWeightL_Size;
662  /* array of size VarL_Size,
663     VarL_Offset[i] gets i-th long var in exp vector */
664  int*      VarL_Offset;
665
666  /* mask for getting single exponents */
667  unsigned long bitmask;
668  /* mask used for divisiblity tests */
669  unsigned long divmask; // rComplete
670
671  p_Procs_s*    p_Procs; // rComplete/p_ProcsSet
672
673  /* FDeg and LDeg */
674  pFDegProc     pFDeg; // rComplete/rSetDegStuff
675  pLDegProc     pLDeg; // rComplete/rSetDegStuff
676
677  /* as it was determined by rComplete */
678  pFDegProc     pFDegOrig;
679  /* and as it was determined before rOptimizeLDeg */
680  pLDegProc     pLDegOrig;
681
682  p_SetmProc    p_Setm;
683  n_Procs_s*    cf;
684  ring          algring;
685#ifdef HAVE_PLURAL
686  private:
687    nc_struct*    _nc; // private
688  public:
689    inline const nc_struct* GetNC() const { return _nc; }; // public!!!
690    inline nc_struct*& GetNC() { return _nc; }; // public!!!
691#endif
692};
693
694struct sip_sideal
695{
696  poly*  m;
697  long rank;
698  int nrows;
699  int ncols;
700  #define IDELEMS(i) ((i)->ncols)
701};
702
703struct sip_smap
704{
705  poly *m;
706  char *preimage;
707  int nrows;
708  int ncols;
709};
710
711struct sideal_list
712{
713  ideal_list next;
714  ideal      d;
715#ifndef NDEBUG
716  int nr;
717#endif
718};
719#endif /* __cplusplus */
720
721
722
723/*
724**  7. runtime procedures/global data
725*/
726
727/* 7.1 C-routines : */
728
729
730#ifdef __cplusplus
731extern "C" {
732#endif
733void  m2_end(int i) __attribute__((noreturn));
734#ifdef __cplusplus
735}
736#endif
737
738/* 7.2 C++-routines : */
739
740#ifdef __cplusplus
741int   inits(void);
742int   IsPrime(int i);
743#ifdef buildin_rand
744extern int siSeed;
745int siRand();
746#endif
747#endif
748
749/*the general set of std-options --> kutil.cc */
750extern BITSET test;
751/*the general set of verbose-options --> febase.cc */
752#ifdef __cplusplus
753extern "C" BITSET verbose;
754#else
755extern BITSET verbose;
756#endif
757/*debugging the bison grammar --> grammar.cc*/
758#ifdef YYDEBUG
759#if YYDEBUG
760extern int    yydebug;
761#endif
762#endif
763
764extern int      yylineno;
765extern char     my_yylinebuf[80];
766
767#define loop for(;;)
768
769#ifndef ABS
770#define ABS(x) ((x)<0?(-(x)):(x))
771#endif
772
773#if defined(__cplusplus)
774static inline int si_max(const int a, const int b)  { return (a>b) ? a : b; }
775static inline int si_min(const int a, const int b)  { return (a<b) ? a : b; }
776static inline long si_max(const long a, const long b)  { return (a>b) ? a : b; }
777static inline long si_min(const long a, const long b)  { return (a<b) ? a : b; }
778#else
779#define si_max(A,B) ((A) > (B) ? (A) : (B))
780#define si_min(A,B) ((A) < (B) ? (A) : (B))
781#endif
782
783/*
784**  Set operations (small sets only)
785*/
786
787#define Sy_bit(x)     ((unsigned)1<<(x))
788#define Sy_inset(x,s) ((Sy_bit(x)&(s))?TRUE:FALSE)
789#define BTEST1(a)     Sy_inset((a), test)
790#define BVERBOSE(a)   Sy_inset((a), verbose)
791
792/*
793** defines for BITSETs
794*/
795
796#define V_SHOW_MEM    2
797#define V_YACC        3
798#define V_REDEFINE    4
799#define V_READING     5
800#define V_LOAD_LIB    6
801#define V_DEBUG_LIB   7
802#define V_LOAD_PROC   8
803#define V_DEF_RES     9
804#define V_DEBUG_MEM  10
805#define V_SHOW_USE   11
806#define V_IMAP       12
807#define V_PROMPT     13
808#define V_NSB        14
809#define V_CONTENTSB  15
810#define V_CANCELUNIT 16
811#define V_MODPSOLVSB 17
812#define V_UPTORADICAL 18
813#define V_FINDMONOM  19
814#define V_COEFSTRAT  20
815#define V_IDLIFT     21
816#define V_LENGTH     22
817#define V_DEG_STOP   31
818
819
820#define OPT_PROT           0
821#define OPT_REDSB          1
822#define OPT_NOT_BUCKETS    2
823#define OPT_NOT_SUGAR      3
824#define OPT_INTERRUPT      4
825#define OPT_SUGARCRIT      5
826#define OPT_DEBUG          6
827#define OPT_REDTHROUGH     7
828#define OPT_RETURN_SB      9
829#define OPT_FASTHC        10
830#define OPT_OLDSTD        20
831#define OPT_KEEPVARS      21
832#define OPT_STAIRCASEBOUND 22
833#define OPT_MULTBOUND     23
834#define OPT_DEGBOUND      24
835#define OPT_REDTAIL       25
836#define OPT_INTSTRATEGY   26
837#define OPT_INFREDTAIL    28
838#define OPT_SB_1          29
839#define OPT_NOTREGULARITY 30
840#define OPT_WEIGHTM       31
841
842/* define ring dependent options */
843#define TEST_RINGDEP_OPTS \
844 (Sy_bit(OPT_INTSTRATEGY) | Sy_bit(OPT_REDTHROUGH) | Sy_bit(OPT_REDTAIL))
845
846#define TEST_OPT_PROT              BTEST1(OPT_PROT)
847#define TEST_OPT_REDSB             BTEST1(OPT_REDSB)
848#define TEST_OPT_NOT_BUCKETS       BTEST1(OPT_NOT_BUCKETS)
849#define TEST_OPT_NOT_SUGAR         BTEST1(OPT_NOT_SUGAR)
850#define TEST_OPT_SUGARCRIT         BTEST1(OPT_SUGARCRIT)
851#define TEST_OPT_DEBUG             BTEST1(OPT_DEBUG)
852#define TEST_OPT_FASTHC            BTEST1(OPT_FASTHC)
853#define TEST_OPT_INTSTRATEGY       BTEST1(OPT_INTSTRATEGY)
854#define TEST_OPT_RETURN_SB         BTEST1(OPT_RETURN_SB)
855#define TEST_OPT_KEEPVARS          BTEST1(OPT_KEEPVARS)
856#define TEST_OPT_DEGBOUND          BTEST1(OPT_DEGBOUND)
857#define TEST_OPT_MULTBOUND         BTEST1(OPT_MULTBOUND)
858#define TEST_OPT_STAIRCASEBOUND    BTEST1(OPT_STAIRCASEBOUND)
859#define TEST_OPT_REDTAIL           BTEST1(OPT_REDTAIL)
860#define TEST_OPT_INFREDTAIL        BTEST1(OPT_INFREDTAIL)
861#define TEST_OPT_SB_1              BTEST1(OPT_SB_1)
862#define TEST_OPT_NOTREGULARITY     BTEST1(OPT_NOTREGULARITY)
863#define TEST_OPT_WEIGHTM           BTEST1(OPT_WEIGHTM)
864#define TEST_OPT_REDTHROUGH        BTEST1(OPT_REDTHROUGH)
865#define TEST_OPT_OLDSTD            BTEST1(OPT_OLDSTD)
866#define TEST_OPT_CONTENTSB         BVERBOSE(V_CONTENTSB)
867#define TEST_OPT_CANCELUNIT        BVERBOSE(V_CANCELUNIT)
868#define TEST_OPT_IDLIFT            BVERBOSE(V_IDLIFT)
869#define TEST_OPT_LENGTH            BVERBOSE(V_LENGTH)
870
871#define TEST_VERB_NSB              BVERBOSE(V_NSB)
872#define TEST_V_DEG_STOP            BVERBOSE(V_DEG_STOP)
873#define TEST_V_MODPSOLVSB          BVERBOSE(V_MODPSOLVSB)
874#define TEST_V_COEFSTRAT           BVERBOSE(V_COEFSTRAT)
875#define TEST_V_UPTORADICAL         BVERBOSE(V_UPTORADICAL)
876#define TEST_V_FINDMONOM           BVERBOSE(V_FINDMONOM)
877#ifdef HAVE_LIBPARSER
878#ifdef __cplusplus
879class libstack;
880typedef libstack *  libstackv;
881#endif
882#endif /* HAVE_LIBPARSER */
883
884extern struct omBin_s* MP_INT_bin;
885extern struct omBin_s* char_ptr_bin;
886extern struct omBin_s* ideal_bin;
887extern struct omBin_s* int_bin;
888extern struct omBin_s* poly_bin;
889extern struct omBin_s* void_ptr_bin;
890extern struct omBin_s* indlist_bin;
891extern struct omBin_s* naIdeal_bin;
892extern struct omBin_s* snaIdeal_bin;
893extern struct omBin_s* sm_prec_bin;
894extern struct omBin_s* smprec_bin;
895extern struct omBin_s* sip_sideal_bin;
896extern struct omBin_s* sip_smap_bin;
897extern struct omBin_s* sip_sring_bin;
898extern struct omBin_s* ip_sideal_bin;
899extern struct omBin_s* ip_smap_bin;
900extern struct omBin_s* ip_sring_bin;
901extern struct omBin_s* sleftv_bin;
902
903#ifdef __cplusplus
904union uutypes
905{
906  int           i;
907  ring          uring;
908  poly          p;
909  number        n;
910  ideal         uideal;
911  map           umap;
912  matrix        umatrix;
913  char *        ustring;
914  intvec *      iv;
915  lists         l;
916  si_link       li;
917  package       pack;
918  procinfo *    pinf;
919};
920
921class idrec
922{
923  public:
924  /* !! do not change the first 6 entries !! (see subexpr.h: sleftv) */
925  idhdl      next;
926  const char *id;
927  utypes     data;
928  attr       attribute;
929  BITSET     flag;
930  idtyp      typ;
931
932  short      lev;
933  short      ref;
934#ifdef HAVE_IDI
935  int        id_i;
936#endif
937
938#define IDNEXT(a)    ((a)->next)
939#define IDTYP(a)     ((a)->typ)
940#define IDFLAG(a)    ((a)->flag)
941#define IDLEV(a)     ((a)->lev)
942#define IDID(a)      ((a)->id)
943#define IDATTR(a)    ((a)->attribute)
944
945#define IDINT(a)    ((int)(long)((a)->data.ustring))
946#define IDDATA(a)   ((a)->data.ustring)
947#define IDRING(a)   ((a)->data.uring)
948#define IDINTVEC(a) ((a)->data.iv)
949#define IDPOLY(a)   ((a)->data.p)
950#define IDBIGINT(a) ((a)->data.n)
951#define IDNUMBER(a) ((a)->data.n)
952#define IDIDEAL(a)  (((a)->data).uideal)
953#define IDMATRIX(a) (((a)->data).umatrix)
954#define IDMAP(a)    (((a)->data).umap)
955#define IDSTRING(a) ((a)->data.ustring)
956#define IDLIST(a)   ((a)->data.l)
957#define IDLINK(a)   ((a)->data.li)
958#define IDPACKAGE(a) ((a)->data.pack)
959#define IDPROC(a)   ((a)->data.pinf)
960
961  idrec() { memset(this,0,sizeof(*this)); }
962  idhdl get(const char * s, int lev);
963  idhdl set(const char * s, int lev, idtyp t, BOOLEAN init=TRUE);
964  char * String();
965//  ~idrec();
966};
967
968class proc_singular
969{
970public:
971  long   proc_start;       // position where proc is starting
972  long   def_end;          // position where proc header is ending
973  long   help_start;       // position where help is starting
974  long   help_end;         // position where help is starting
975  long   body_start;       // position where proc-body is starting
976  long   body_end;         // position where proc-body is ending
977  long   example_start;    // position where example is starting
978  long   proc_end;         // position where proc is ending
979  int    proc_lineno;
980  int    body_lineno;
981  int    example_lineno;
982  char   *body;
983  long help_chksum;
984};
985
986struct proc_object
987{
988//public:
989  BOOLEAN (*function)(leftv res, leftv v);
990};
991
992union uprocinfodata;
993
994union uprocinfodata
995{
996public:
997  proc_singular  s;        // data of Singular-procedure
998  struct proc_object    o; // pointer to binary-function
999};
1000
1001typedef union uprocinfodata procinfodata;
1002
1003typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
1004// LANG_TOP     : Toplevel package only
1005// LANG_SINGULAR:
1006// LANG_C       :
1007class procinfo
1008{
1009public:
1010  char          *libname;
1011  char          *procname;
1012#ifdef HAVE_NS
1013  package       pack;
1014#endif
1015  language_defs language;
1016  short         ref;
1017  char          is_static;        // if set, proc not accessible for user
1018  char          trace_flag;
1019  procinfodata  data;
1020};
1021
1022#endif
1023
1024#endif
1025
Note: See TracBrowser for help on using the repository browser.