source: git/Singular/structs.h @ a3bc95e

spielwiese
Last change on this file since a3bc95e was a3bc95e, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: namespaces ->ns git-svn-id: file:///usr/local/Singular/svn/trunk@5651 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 12.8 KB
Line 
1#ifndef STRUCTS_H
2#define STRUCTS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: structs.h,v 1.60 2001-10-09 16:36:24 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,
71  nc_skew,
72  nc_lie
73};
74#endif
75
76
77/* C++-part */
78#ifdef __cplusplus
79class ip_smatrix;
80class idrec;
81class intvec;
82class sleftv;
83class slists;
84class sattr;
85class skStrategy;
86class ssyStrategy;
87class procinfo;
88class namerec;
89class kBucket;
90class sBucket;
91#endif
92
93struct n_Procs_s;
94struct sip_sring;
95struct sip_sideal;
96struct sip_link;
97struct spolynom;
98struct _ssubexpr;
99struct _sssym;
100struct snumber;
101struct sip_command;
102struct sip_package;
103struct s_si_link_extension;
104#ifndef LONGALGNEW
105struct reca;
106#endif /* not LONGALGNEW */
107
108typedef struct  n_Procs_s  n_Procs_s;
109
110#ifdef HAVE_PLURAL
111struct nc_struct;
112typedef struct nc_struct   nc_struct;
113#endif
114
115typedef struct _ssubexpr   sSubexpr;
116typedef struct _sssym      ssym;
117typedef struct spolyrec    polyrec;
118typedef struct snumber     rnumber;
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 rnumber *          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   int     nChar;
210   n_coeffType type;
211   int     char_flag;
212   int     ref;
213   // the union stuff
214   // Zp:
215   int npPrimeM;
216   int npPminus1M;
217   #ifdef HAVE_DIV_MOD
218   CARDINAL *npInvTable;
219   #else
220   CARDINAL *npExpTable;
221   CARDINAL *npLogTable;
222   #endif
223   // Zp_a, Q_a
224
225   // general stuff
226   numberfunc nMult, nSub ,nAdd ,nDiv, nIntDiv, nIntMod, nExactDiv;
227   void    (*nNew)(number * a);
228   number  (*nInit)(int i);
229   number  (*nPar)(int i);
230   int     (*nParDeg)(number n);
231   int     (*nSize)(number n);
232   int     (*nInt)(number &n);
233   number  (*nNeg)(number a);
234   number  (*nInvers)(number a);
235   number  (*nCopy)(number a);
236   number  (*cfCopy)(number a, ring r);
237   number  (*nRePart)(number a);
238   number  (*nImPart)(number a);
239   void    (*nWrite)(number &a);
240   char *  (*nRead)(char * s, number * a);
241   void    (*nNormalize)(number &a);
242   BOOLEAN (*nGreater)(number a,number b),
243           (*nEqual)(number a,number b),
244           (*nIsZero)(number a),
245           (*nIsOne)(number a),
246           (*nIsMOne)(number a),
247           (*nGreaterZero)(number a);
248   void    (*nPower)(number a, int i, number * result);
249   number  (*nGetDenom)(number &n);
250   number  (*nGcd)(number a, number b, const ring r);
251   number  (*nLcm)(number a, number b, const ring r);
252   void    (*cfDelete)(number * a, const ring r);
253   nMapFunc (*cfSetMap)(ring src, ring dst);
254   char *  (*nName)(number n);
255//extern number  (*nMap)(number from);
256
257   number nNULL; /* the 0 as constant */
258};
259
260/* the function pointer types */
261
262extern ring      currRing;
263typedef long     (*pLDegProc)(poly p, int *length, ring r= currRing);
264typedef long     (*pFDegProc)(poly p, ring r = currRing);
265typedef void     (*p_SetmProc)(poly p, ring r = currRing);
266
267typedef enum
268{
269  ro_dp, // ordering is a degree ordering
270  ro_wp, // ordering is a weighted degree ordering
271  ro_wp_neg, // ordering is a weighted degree ordering
272             // with possibly negative weights
273  ro_cp,    // ordering duplicates variables
274  ro_syzcomp, // ordering indicates "subset" of component number
275  ro_syz, // ordering  with component number >syzcomp is lower
276  ro_none
277}
278ro_typ;
279
280// ordering is a degree ordering
281struct sro_dp
282{
283  short place;  // where degree is stored (in L):
284  short start;  // bounds of ordering (in E):
285  short end;
286};
287typedef struct sro_dp sro_dp;
288
289// ordering is a weighted degree ordering
290struct sro_wp
291{
292  short place;  // where weighted degree is stored (in L)
293  short start;  // bounds of ordering (in E)
294  short end;
295  int *weights; // pointers into wvhdl field
296};
297typedef struct sro_wp sro_wp;
298
299// ordering duplicates variables
300struct sro_cp
301{
302  short place;  // where start is copied to (in E)
303  short start;  // bounds of sources of copied variables (in E)
304  short end;
305};
306typedef struct sro_cp sro_cp;
307
308// ordering indicates "subset" of component number
309struct sro_syzcomp
310{
311  short place;  // where the index is stored (in L)
312  long *ShiftedComponents; // pointer into index field
313  int* Components;
314#ifdef PDEBUG
315  long length;
316#endif
317};
318typedef struct sro_syzcomp sro_syzcomp;
319
320// ordering  with component number >syzcomp is lower
321struct sro_syz
322{
323  short place;       // where the index is stored (in L)
324  int limit;         // syzcomp
325  int* syz_index;    // mapping Component -> SyzIndex for Comp <= limit
326  int  curr_index;   // SyzIndex for Component > limit
327};
328
329typedef struct sro_syz sro_syz;
330
331#ifndef OM_ALLOC_H
332struct omBin_s;
333#endif
334
335struct sro_ord
336{
337  ro_typ  ord_typ;
338  int     order_index; // comes from r->order[order_index]
339  union
340  {
341     sro_dp dp;
342     sro_wp wp;
343     sro_cp cp;
344     sro_syzcomp syzcomp;
345     sro_syz syz;
346  } data;
347};
348
349#ifdef HAVE_PLURAL
350struct nc_struct
351{
352  nc_type type;
353  matrix C;
354  matrix D;
355  matrix *MT;
356  matrix COM;
357  int *MTsize;
358};
359#endif
360
361struct sip_sring
362{
363  idhdl      idroot; /* local objects */
364  int*       order;  /* array of orderings */
365  int*       block0; /* starting pos.*/
366  int*       block1; /* ending pos.*/
367  char**     parameter; /* names of parameters */
368  number     minpoly;
369  int**      wvhdl;  /* array of weight vectors */
370  char **    names;  /* array of variable names */
371
372  unsigned long options; /* ring dependent options */
373
374  // what follows below here should be set by rComplete, _only_
375  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
376                       /*  ExpL_Size entries*/
377
378  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
379  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
380
381  ideal      qideal; /* extension to the ring structure: qring */
382
383
384  int      *VarOffset;
385  int*     firstwv;
386
387  struct omBin_s*   PolyBin; /* Bin from where monoms are allocated */
388  short      ch;     /* characteristic */
389  short      float_len; /* additional char-flags */
390  short      float_len2; /* additional char-flags */
391
392  short      N;      /* number of vars */
393
394  short      P;      /* number of pars */
395  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise */
396
397  short     firstBlockEnds;
398
399
400  BOOLEAN   VectorOut;
401  BOOLEAN   ShortOut;
402  BOOLEAN   CanShortOut;
403  BOOLEAN   LexOrder;
404  // TRUE if the monomial ordering has polynomial and power series blocks
405  BOOLEAN   MixedOrder;
406  // 1 for lex ordering (except ls), -1 otherwise
407  BOOLEAN   ComponentOrder;
408
409
410  // what follows below here should be set by rComplete, _only_
411  // contains component, but no weight fields in E */
412  short      ExpL_Size; // size of exponent vector in long
413  short      CmpL_Size; // portions which need to be compared
414  /* number of long vars in exp vector:
415     long vars are those longs in the exponent vector which are
416     occupied by variables, only */
417  short     VarL_Size;
418
419  short      BitsPerExp; /* number of bits per exponent */
420  short      ExpPerLong; /* maximal number of Exponents per long */
421
422  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
423  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
424
425  short      OrdSize; /* size of ord vector (in sro_ord) */
426
427
428  short      ref; /* reference counter to the ring */
429
430  /* if >= 0, long vars in exp vector are consecutive and start there
431     if <  0, long vars in exp vector are not consecutive */
432  short     VarL_LowIndex;
433  // number of exponents in r->VarL_Offset[0]
434  // is minimal number of exponents in a long var
435  short     MinExpPerLong;
436
437  /* if this is > 0, then NegWeightL_Offset[0..size_1] is index of longs in
438   ExpVector whose values need an offset due to negative weights */
439  short     NegWeightL_Size;
440  /* array of NegWeigtL_Size indicies */
441  int*      NegWeightL_Offset;
442
443  /* array of size VarL_Size,
444     VarL_Offset[i] gets i-th long var in exp vector */
445  int*      VarL_Offset;
446
447  /* mask for getting single exponents */
448  unsigned long bitmask;
449  /* mask used for divisiblity tests */
450  unsigned long divmask;
451
452  p_Procs_s*    p_Procs;
453
454  /* FDeg and LDeg */
455  pFDegProc     pFDeg;
456  pLDegProc     pLDeg;
457
458  /* as it was determined by rComplete */
459  pFDegProc     pFDegOrig;
460  /* and as it was determined before rOptimizeLDeg */
461  pLDegProc     pLDegOrig;
462
463  p_SetmProc    p_Setm;
464  n_Procs_s*    cf;
465  ring          algring;
466#ifdef HAVE_PLURAL
467  nc_struct     *nc;
468#endif
469};
470
471struct sip_sideal
472{
473  poly*  m;
474  long rank;
475  int nrows;
476  int ncols;
477  #define IDELEMS(i) ((i)->ncols)
478  inline int& idelems(void) { return ncols; }
479};
480
481struct sip_smap
482{
483  poly *m;
484  char *preimage;
485  int nrows;
486  int ncols;
487};
488#endif /* __cplusplus */
489
490
491
492/*
493**  7. runtime procedures/global data
494*/
495
496/* 7.1 C-routines : */
497
498
499#ifdef __cplusplus
500extern "C" {
501#endif
502void  m2_end(short i);
503#ifdef __cplusplus
504}
505#endif
506
507/* 7.2 C++-routines : */
508
509#ifdef __cplusplus
510int   inits(void);
511#ifdef buildin_rand
512extern int siSeed;
513int siRand();
514#endif
515#endif
516
517/*the general set of std-options --> kutil.cc */
518extern BITSET test;
519/*the general set of verbose-options --> febase.cc */
520#ifdef __cplusplus
521extern "C" BITSET verbose;
522#else
523extern BITSET verbose;
524#endif
525/*debugging the bison grammar --> grammar.cc*/
526#ifdef YYDEBUG
527#if YYDEBUG
528extern int    yydebug;
529#endif
530#endif
531
532#ifdef HAVE_LIBPARSER
533#ifdef __cplusplus
534class libstack;
535typedef libstack *  libstackv;
536#endif
537#endif /* HAVE_LIBPARSER */
538
539extern struct omBin_s* MP_INT_bin;
540extern struct omBin_s* char_ptr_bin;
541extern struct omBin_s* ideal_bin;
542extern struct omBin_s* int_bin;
543extern struct omBin_s* poly_bin;
544extern struct omBin_s* void_ptr_bin;
545extern struct omBin_s* indlist_bin;
546extern struct omBin_s* naIdeal_bin;
547extern struct omBin_s* snaIdeal_bin;
548extern struct omBin_s* sm_prec_bin;
549extern struct omBin_s* smprec_bin;
550extern struct omBin_s* sip_sideal_bin;
551extern struct omBin_s* sip_smap_bin;
552extern struct omBin_s* sip_sring_bin;
553extern struct omBin_s* ip_sideal_bin;
554extern struct omBin_s* ip_smap_bin;
555extern struct omBin_s* ip_sring_bin;
556
557#endif
558
Note: See TracBrowser for help on using the repository browser.