source: git/Singular/structs.h @ c880d63

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