source: git/Singular/structs.h @ b197b06

fieker-DuValspielwiese
Last change on this file since b197b06 was b197b06, checked in by Hans Schönemann <hannes@…>, 21 years ago
*hannes: basering to nc git-svn-id: file:///usr/local/Singular/svn/trunk@6444 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 13.1 KB
Line 
1#ifndef STRUCTS_H
2#define STRUCTS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: structs.h,v 1.69 2003-01-29 17:48:37 Singular Exp $ */
7/*
8* ABSTRACT
9*/
10#define LONGALGNEW
11/* standard types */
12typedef unsigned char  uchar ;
13typedef unsigned short CARDINAL;
14typedef short BOOLEAN;
15
16typedef void * Sy_reference;
17#define ADDRESS Sy_reference
18#define BITSET  unsigned int
19
20/* EXPONENT_TYPE is determined by configure und defined in mod2.h */
21/* the following defines should really go into mod2.h,
22   but configure dislikes it */
23
24
25// define if a*b is with mod instead of tables
26#if defined(i386)
27// seems to be better on i386 processors
28#define HAVE_MULT_MOD
29#ifdef HAVE_MULT_MOD
30/* #define HAVE_DIV_MOD*/
31#endif
32#endif
33
34typedef long Exponent_t;
35typedef long Order_t;
36
37enum tHomog
38{
39   isNotHomog = FALSE,
40   isHomog    = TRUE,
41   testHomog
42};
43enum noeof_t
44{
45  noeof_brace = 1,
46  noeof_asstring,
47  noeof_block,
48  noeof_bracket,
49  noeof_comment,
50  noeof_procname,
51  noeof_string
52};
53
54enum n_coeffType
55{
56  n_unknown=0,
57  n_Zp,
58  n_Q,
59  n_R,
60  n_GF,
61  n_long_R,
62  n_Zp_a,
63  n_Q_a,
64  n_long_C
65};
66
67#ifdef HAVE_PLURAL
68enum nc_type
69{
70  nc_general=0, /* yx=q xy+... */
71  nc_skew, /*1*/ /* yx=q xy */
72  nc_lie,  /*2*/ /* yx=xy+... */
73  nc_undef /*3*/  /* for internal reasons */
74};
75#endif
76
77
78/* C++-part */
79#ifdef __cplusplus
80class ip_smatrix;
81class idrec;
82class intvec;
83class sleftv;
84class slists;
85class sattr;
86class skStrategy;
87class ssyStrategy;
88class procinfo;
89class namerec;
90class kBucket;
91class sBucket;
92#endif
93
94struct n_Procs_s;
95struct sip_sring;
96struct sip_sideal;
97struct sip_link;
98struct spolynom;
99struct _ssubexpr;
100struct _sssym;
101struct snumber;
102struct sip_command;
103struct sip_package;
104struct s_si_link_extension;
105#ifndef LONGALGNEW
106struct reca;
107#endif /* not LONGALGNEW */
108
109typedef struct  n_Procs_s  n_Procs_s;
110
111#ifdef HAVE_PLURAL
112struct nc_struct;
113typedef struct nc_struct   nc_struct;
114#endif
115
116typedef struct _ssubexpr   sSubexpr;
117typedef struct _sssym      ssym;
118typedef struct spolyrec    polyrec;
119typedef struct sip_sideal  ip_sideal;
120typedef struct sip_smap    ip_smap;
121typedef struct sip_sring   ip_sring;
122typedef struct sip_link    ip_link;
123typedef struct sip_command ip_command;
124typedef struct sip_package ip_package;
125
126/* the pointer types */
127typedef char *             char_ptr;
128typedef int  *             int_ptr;
129typedef short *            short_ptr;
130typedef void *             void_ptr;
131typedef ip_sring *         ring;
132typedef int                idtyp;
133typedef struct snumber *   number;
134typedef polyrec *          poly;
135typedef poly *             polyset;
136typedef ip_sideal *        ideal;
137typedef ip_smap *          map;
138typedef ideal *            resolvente;
139typedef union uutypes      utypes;
140typedef ip_command *       command;
141typedef struct s_si_link_extension *si_link_extension;
142#ifndef LONGALGNEW
143typedef struct reca *      napoly;
144#else /* LONGALGNEW */
145typedef polyrec *   napoly;
146#endif /* LONGALGNEW */
147
148#ifdef __cplusplus
149typedef idrec *            idhdl;
150typedef ip_smatrix *       matrix;
151typedef ip_link *          si_link;
152typedef sleftv *           leftv;
153typedef slists *           lists;
154typedef sSubexpr *         Subexpr;
155typedef sattr *            attr;
156typedef skStrategy *       kStrategy;
157typedef ip_package *       package;
158typedef ssyStrategy *      syStrategy;
159typedef procinfo *         procinfov;
160typedef namerec *          namehdl;
161typedef kBucket*           kBucket_pt;
162typedef sBucket*           sBucket_pt;
163typedef struct p_Procs_s p_Procs_s;
164
165// for hdegree.cc
166typedef struct sindlist indlist;
167typedef indlist * indset;
168struct sindlist
169{
170  indset nx;
171  intvec * set;
172};
173
174// for longalg.cc
175struct snaIdeal
176{
177  int anz;
178  napoly *liste;
179};
180typedef struct snaIdeal * naIdeal;
181
182
183// for sparsemat.cc
184typedef struct smprec sm_prec;
185typedef sm_prec * smpoly;
186struct smprec
187{
188  smpoly n;            // the next element
189  int pos;             // position
190  int e;               // level
191  poly m;              // the element
192  float f;             // complexity of the element
193};
194
195struct _scmdnames
196{
197  char *name;
198  short alias;
199  short tokval;
200  short toktype;
201};
202typedef struct _scmdnames cmdnames;
203
204typedef number (*numberfunc)(number a,number b);
205typedef number (*nMapFunc)(number a);
206struct n_Procs_s
207{
208   n_Procs_s* next;
209   // the union stuff
210   // Zp:
211   int npPrimeM;
212   int npPminus1M;
213   #ifdef HAVE_DIV_MOD
214   CARDINAL *npInvTable;
215   #endif
216   #if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
217   CARDINAL *npExpTable;
218   CARDINAL *npLogTable;
219   #endif
220   // Zp_a, Q_a
221
222   // general stuff
223   numberfunc nMult, nSub ,nAdd ,nDiv, nIntDiv, nIntMod, nExactDiv;
224   void    (*nNew)(number * a);
225   number  (*nInit)(int i);
226   number  (*nPar)(int i);
227   int     (*nParDeg)(number n);
228   int     (*nSize)(number n);
229   int     (*nInt)(number &n);
230   number  (*nNeg)(number a);
231   number  (*nInvers)(number a);
232   number  (*nCopy)(number a);
233   number  (*cfCopy)(number a, const ring r);
234   number  (*nRePart)(number a);
235   number  (*nImPart)(number a);
236   void    (*nWrite)(number &a);
237   char *  (*nRead)(char * s, number * a);
238   void    (*nNormalize)(number &a);
239   BOOLEAN (*nGreater)(number a,number b),
240           (*nEqual)(number a,number b),
241           (*nIsZero)(number a),
242           (*nIsOne)(number a),
243           (*nIsMOne)(number a),
244           (*nGreaterZero)(number a);
245   void    (*nPower)(number a, int i, number * result);
246   number  (*n_GetDenom)(number &n, const ring r);
247   number  (*nGcd)(number a, number b, const ring r);
248   number  (*nLcm)(number a, number b, const ring r);
249   void    (*cfDelete)(number * a, const ring r);
250   nMapFunc (*cfSetMap)(ring src, ring dst);
251   char *  (*nName)(number n);
252   void    (*nInpMult)(number &a, number b, ring r);
253//extern number  (*nMap)(number from);
254
255   number nNULL; /* the 0 as constant */
256   int     char_flag;
257   int     ref;
258   short   nChar;
259   n_coeffType type;
260};
261
262/* the function pointer types */
263
264extern ring      currRing;
265typedef long     (*pLDegProc)(poly p, int *length, ring r= currRing);
266typedef long     (*pFDegProc)(poly p, ring r = currRing);
267typedef void     (*p_SetmProc)(poly p, ring r = currRing);
268
269typedef enum
270{
271  ro_dp, // ordering is a degree ordering
272  ro_wp, // ordering is a weighted degree ordering
273  ro_wp_neg, // ordering is a weighted degree ordering
274             // with possibly negative weights
275  ro_cp,    // ordering duplicates variables
276  ro_syzcomp, // ordering indicates "subset" of component number
277  ro_syz, // ordering  with component number >syzcomp is lower
278  ro_none
279}
280ro_typ;
281
282// ordering is a degree ordering
283struct sro_dp
284{
285  short place;  // where degree is stored (in L):
286  short start;  // bounds of ordering (in E):
287  short end;
288};
289typedef struct sro_dp sro_dp;
290
291// ordering is a weighted degree ordering
292struct sro_wp
293{
294  short place;  // where weighted degree is stored (in L)
295  short start;  // bounds of ordering (in E)
296  short end;
297  int *weights; // pointers into wvhdl field
298};
299typedef struct sro_wp sro_wp;
300
301// ordering duplicates variables
302struct sro_cp
303{
304  short place;  // where start is copied to (in E)
305  short start;  // bounds of sources of copied variables (in E)
306  short end;
307};
308typedef struct sro_cp sro_cp;
309
310// ordering indicates "subset" of component number
311struct sro_syzcomp
312{
313  short place;  // where the index is stored (in L)
314  long *ShiftedComponents; // pointer into index field
315  int* Components;
316#ifdef PDEBUG
317  long length;
318#endif
319};
320typedef struct sro_syzcomp sro_syzcomp;
321
322// ordering  with component number >syzcomp is lower
323struct sro_syz
324{
325  short place;       // where the index is stored (in L)
326  int limit;         // syzcomp
327  int* syz_index;    // mapping Component -> SyzIndex for Comp <= limit
328  int  curr_index;   // SyzIndex for Component > limit
329};
330
331typedef struct sro_syz sro_syz;
332
333#ifndef OM_ALLOC_H
334struct omBin_s;
335#endif
336
337struct sro_ord
338{
339  ro_typ  ord_typ;
340  int     order_index; // comes from r->order[order_index]
341  union
342  {
343     sro_dp dp;
344     sro_wp wp;
345     sro_cp cp;
346     sro_syzcomp syzcomp;
347     sro_syz syz;
348  } data;
349};
350
351#ifdef HAVE_PLURAL
352struct nc_struct
353{
354  short ref;
355  nc_type type;
356  ring basering; // the ring C,D,.. live in
357  matrix C;
358  matrix D;
359  matrix *MT;
360  matrix COM;
361  int *MTsize;
362};
363#endif
364
365struct sip_sring
366{
367  idhdl      idroot; /* local objects */
368  int*       order;  /* array of orderings */
369  int*       block0; /* starting pos.*/
370  int*       block1; /* ending pos.*/
371  char**     parameter; /* names of parameters */
372  number     minpoly;
373  int**      wvhdl;  /* array of weight vectors */
374  char **    names;  /* array of variable names */
375
376  unsigned long options; /* ring dependent options */
377
378  // what follows below here should be set by rComplete, _only_
379  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
380                       /*  ExpL_Size entries*/
381
382  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
383  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
384
385  ideal      qideal; /* extension to the ring structure: qring */
386
387
388  int      *VarOffset;
389  int*     firstwv;
390
391  struct omBin_s*   PolyBin; /* Bin from where monoms are allocated */
392  short      ch;     /* characteristic */
393  short      float_len; /* additional char-flags */
394  short      float_len2; /* additional char-flags */
395
396  short      N;      /* number of vars */
397
398  short      P;      /* number of pars */
399  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise */
400
401  short     firstBlockEnds;
402
403
404  BOOLEAN   VectorOut;
405  BOOLEAN   ShortOut;
406  BOOLEAN   CanShortOut;
407  BOOLEAN   LexOrder;
408  // TRUE if the monomial ordering has polynomial and power series blocks
409  BOOLEAN   MixedOrder;
410  // 1 for lex ordering (except ls), -1 otherwise
411  BOOLEAN   ComponentOrder;
412
413
414  // what follows below here should be set by rComplete, _only_
415  // contains component, but no weight fields in E */
416  short      ExpL_Size; // size of exponent vector in long
417  short      CmpL_Size; // portions which need to be compared
418  /* number of long vars in exp vector:
419     long vars are those longs in the exponent vector which are
420     occupied by variables, only */
421  short     VarL_Size;
422
423  short      BitsPerExp; /* number of bits per exponent */
424  short      ExpPerLong; /* maximal number of Exponents per long */
425
426  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
427  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
428
429  short      OrdSize; /* size of ord vector (in sro_ord) */
430
431
432  short      ref; /* reference counter to the ring */
433
434  /* if >= 0, long vars in exp vector are consecutive and start there
435     if <  0, long vars in exp vector are not consecutive */
436  short     VarL_LowIndex;
437  // number of exponents in r->VarL_Offset[0]
438  // is minimal number of exponents in a long var
439  short     MinExpPerLong;
440
441  /* if this is > 0, then NegWeightL_Offset[0..size_1] is index of longs in
442   ExpVector whose values need an offset due to negative weights */
443  short     NegWeightL_Size;
444  /* array of NegWeigtL_Size indicies */
445  int*      NegWeightL_Offset;
446
447  /* array of size VarL_Size,
448     VarL_Offset[i] gets i-th long var in exp vector */
449  int*      VarL_Offset;
450
451  /* mask for getting single exponents */
452  unsigned long bitmask;
453  /* mask used for divisiblity tests */
454  unsigned long divmask;
455
456  p_Procs_s*    p_Procs;
457
458  /* FDeg and LDeg */
459  pFDegProc     pFDeg;
460  pLDegProc     pLDeg;
461
462  /* as it was determined by rComplete */
463  pFDegProc     pFDegOrig;
464  /* and as it was determined before rOptimizeLDeg */
465  pLDegProc     pLDegOrig;
466
467  p_SetmProc    p_Setm;
468  n_Procs_s*    cf;
469  ring          algring;
470#ifdef HAVE_PLURAL
471  nc_struct     *nc;
472#endif
473};
474
475struct sip_sideal
476{
477  poly*  m;
478  long rank;
479  int nrows;
480  int ncols;
481  #define IDELEMS(i) ((i)->ncols)
482  inline int& idelems(void) { return ncols; }
483};
484
485struct sip_smap
486{
487  poly *m;
488  char *preimage;
489  int nrows;
490  int ncols;
491};
492#endif /* __cplusplus */
493
494
495
496/*
497**  7. runtime procedures/global data
498*/
499
500/* 7.1 C-routines : */
501
502
503#ifdef __cplusplus
504extern "C" {
505#endif
506void  m2_end(short i);
507#ifdef __cplusplus
508}
509#endif
510
511/* 7.2 C++-routines : */
512
513#ifdef __cplusplus
514int   inits(void);
515#ifdef buildin_rand
516extern int siSeed;
517int siRand();
518#endif
519#endif
520
521/*the general set of std-options --> kutil.cc */
522extern BITSET test;
523/*the general set of verbose-options --> febase.cc */
524#ifdef __cplusplus
525extern "C" BITSET verbose;
526#else
527extern BITSET verbose;
528#endif
529/*debugging the bison grammar --> grammar.cc*/
530#ifdef YYDEBUG
531#if YYDEBUG
532extern int    yydebug;
533#endif
534#endif
535
536#ifdef HAVE_LIBPARSER
537#ifdef __cplusplus
538class libstack;
539typedef libstack *  libstackv;
540#endif
541#endif /* HAVE_LIBPARSER */
542
543extern struct omBin_s* MP_INT_bin;
544extern struct omBin_s* char_ptr_bin;
545extern struct omBin_s* ideal_bin;
546extern struct omBin_s* int_bin;
547extern struct omBin_s* poly_bin;
548extern struct omBin_s* void_ptr_bin;
549extern struct omBin_s* indlist_bin;
550extern struct omBin_s* naIdeal_bin;
551extern struct omBin_s* snaIdeal_bin;
552extern struct omBin_s* sm_prec_bin;
553extern struct omBin_s* smprec_bin;
554extern struct omBin_s* sip_sideal_bin;
555extern struct omBin_s* sip_smap_bin;
556extern struct omBin_s* sip_sring_bin;
557extern struct omBin_s* ip_sideal_bin;
558extern struct omBin_s* ip_smap_bin;
559extern struct omBin_s* ip_sring_bin;
560extern struct omBin_s* sleftv_bin;
561
562#endif
563
Note: See TracBrowser for help on using the repository browser.