source: git/Singular/structs.h @ 3095a1

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