source: git/libpolys/polys/monomials/ring.h @ da0565b

spielwiese
Last change on this file since da0565b was 90934a, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
better rEqual & rSamePolyRep fix: they both should test the equality of coeffs directly (NOT via type & rPar/Minpoly) fix: rEqual should use rSamePolyRep chg: moved documentation to header in doxygen style
  • Property mode set to 100644
File size: 24.0 KB
Line 
1#ifndef RING_H
2#define RING_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT - the interpreter related ring operations
8*/
9
10/* includes */
11#include <omalloc/omalloc.h>
12#include <misc/auxiliary.h>
13#include <coeffs/coeffs.h>
14//#include <polys/monomials/polys-impl.h>
15//
16
17/* forward declaration of types */
18class idrec;
19typedef idrec *   idhdl; // _only_ for idhdl ip_sring::idroot
20struct  spolyrec;
21typedef struct spolyrec    polyrec;
22typedef polyrec *          poly;
23struct ip_sring;
24typedef struct ip_sring *         ring;
25class intvec;
26class int64vec;
27struct p_Procs_s;
28typedef struct p_Procs_s p_Procs_s;
29//class slists;
30//typedef slists *           lists;
31class kBucket;
32typedef kBucket*           kBucket_pt;
33
34struct sip_sideal;
35typedef struct sip_sideal *       ideal;
36
37struct sip_smap;
38typedef struct sip_smap *         map;
39
40/* the function pointer types */
41
42typedef long     (*pLDegProc)(poly p, int *length, ring r);
43typedef long     (*pFDegProc)(poly p, ring r);
44typedef void     (*p_SetmProc)(poly p, const ring r);
45
46
47/// returns a poly from dest_r which is a ShallowCopy of s_p from source_r
48/// assumes that source_r->N == dest_r->N and that orderings are the same
49typedef poly (*pShallowCopyDeleteProc)(poly s_p, ring source_r, ring dest_r, 
50                                       omBin dest_bin);
51
52
53typedef enum
54{
55  ro_dp, // ordering is a degree ordering
56  ro_wp, // ordering is a weighted degree ordering
57  ro_am, // ordering is am: weights for vars + weights for gen
58  ro_wp64, // ordering is a weighted64 degree ordering
59  ro_wp_neg, // ordering is a weighted degree ordering
60             // with possibly negative weights
61  ro_cp,    // ordering duplicates variables
62  ro_syzcomp, // ordering indicates "subset" of component number (ringorder_S)
63  ro_syz, // ordering  with component number >syzcomp is lower (ringorder_s)
64  ro_isTemp, ro_is, // Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS)
65  ro_none
66}
67ro_typ;
68
69// ordering is a degree ordering
70struct sro_dp
71{
72  short place;  // where degree is stored (in L):
73  short start;  // bounds of ordering (in E):
74  short end;
75};
76typedef struct sro_dp sro_dp;
77
78// ordering is a weighted degree ordering
79struct sro_wp
80{
81  short place;  // where weighted degree is stored (in L)
82  short start;  // bounds of ordering (in E)
83  short end;
84  int *weights; // pointers into wvhdl field
85};
86typedef struct sro_wp sro_wp;
87
88// ordering is a weighted degree ordering
89struct sro_am
90{
91  short place;  // where weighted degree is stored (in L)
92  short start;  // bounds of ordering (in E)
93  short end;
94  short len_gen; // i>len_gen: weight(gen(i)):=0
95  int *weights; // pointers into wvhdl field of length (end-start+1) + len_gen + 1
96                // contents w_{start},... w_{end}, len, mod_w_1, .. mod_w_len, 0
97  int *weights_m; // pointers into wvhdl field of length len_gen + 1
98                // len_gen, mod_w_1, .. mod_w_len, 0
99 
100};
101typedef struct sro_am sro_am;
102
103// ordering is a weighted degree ordering
104struct sro_wp64
105{
106    short place;  // where weighted degree is stored (in L)
107    short start;  // bounds of ordering (in E)
108    short end;
109    int64 *weights64; // pointers into wvhdl field
110};
111typedef struct sro_wp64 sro_wp64;
112
113// ordering duplicates variables
114struct sro_cp
115{
116  short place;  // where start is copied to (in E)
117  short start;  // bounds of sources of copied variables (in E)
118  short end;
119};
120typedef struct sro_cp sro_cp;
121
122// ordering indicates "subset" of component number
123struct sro_syzcomp
124{
125  short place;  // where the index is stored (in L)
126  long *ShiftedComponents; // pointer into index field
127  int* Components;
128#ifdef PDEBUG
129  long length;
130#endif
131};
132typedef struct sro_syzcomp sro_syzcomp;
133
134// ordering  with component number >syzcomp is lower
135struct sro_syz
136{
137  short place;       // where the index is stored (in L)
138  int limit;         // syzcomp
139  int* syz_index;    // mapping Component -> SyzIndex for Comp <= limit
140  int  curr_index;   // SyzIndex for Component > limit
141};
142
143typedef struct sro_syz sro_syz;
144// Induced Syzygy (Schreyer) ordering is built inductively as follows:
145// we look for changes made by ordering blocks which are between prefix/suffix markers:
146// that is: which variables where placed by them and where (judging by v)
147
148// due to prefix/suffix nature we need some placeholder:
149// prefix stores here initial state
150// suffix cleares this up
151struct sro_ISTemp
152{
153  short start; // 1st member SHOULD be short "place"
154  int   suffixpos;
155  int*  pVarOffset; // copy!
156};
157
158// So this is the actuall thing!
159// suffix uses last sro_ISTemp (cleares it up afterwards) and
160// creates this block
161struct sro_IS
162{
163  short start, end;  // which part of L we want to want to update...
164  int*  pVarOffset; // same as prefix!
165
166  int limit; // first referenced component
167
168  // reference poly set?? // Should it be owned by ring?!!!
169  ideal F; // reference leading (module)-monomials set. owned by ring...
170};
171
172typedef struct sro_IS sro_IS;
173typedef struct sro_ISTemp sro_ISTemp;
174
175struct sro_ord
176{
177  ro_typ  ord_typ;
178  int     order_index; // comes from r->order[order_index]
179  union
180  {
181     sro_dp dp;
182     sro_wp wp;
183     sro_am am;
184     sro_wp64 wp64;
185     sro_cp cp;
186     sro_syzcomp syzcomp;
187     sro_syz syz;
188     sro_IS is;
189     sro_ISTemp isTemp;
190  } data;
191};
192
193#ifdef HAVE_PLURAL
194struct nc_struct;
195typedef struct nc_struct   nc_struct;
196#endif
197
198struct ip_sring
199{
200// each entry must have a description and a procedure defining it,
201// general ordering: pointer/structs, long, int, short, BOOLEAN/char/enum
202// general defining procedures: rInit, rComplete, interpreter, ??
203  idhdl      idroot; /* local objects , interpreter*/
204  int*       order;  /* array of orderings, rInit/rSleftvOrdering2Ordering */
205  int*       block0; /* starting pos., rInit/rSleftvOrdering2Ordering*/
206  int*       block1; /* ending pos., rInit/rSleftvOrdering2Ordering*/
207//  char**     parameter; /* names of parameters, rInit */
208//  number     minpoly;  /* replaced by minideal->m[0] */
209  ideal      minideal;   /* for Q_a/Zp_a, rInit;
210                            for a start, we assume that there is either no
211                            or exactly one generator in minideal, playing
212                            the role of the former minpoly; minideal may
213                            also be NULL which coincides with the
214                            no-generator-case */
215  int**      wvhdl;  /* array of weight vectors, rInit/rSleftvOrdering2Ordering */
216  char **    names;  /* array of variable names, rInit */
217
218  // what follows below here should be set by rComplete, _only_
219  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
220                       /*  ExpL_Size entries*/
221
222  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
223  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
224  /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs
225  in ExpVector whose values need an offset due to negative weights */
226  /* array of NegWeigtL_Size indicies */
227  int*      NegWeightL_Offset;
228
229  int*     VarOffset;
230
231  ideal      qideal; /* extension to the ring structure: qring, rInit */
232
233  int*     firstwv;
234
235  omBin    PolyBin; /* Bin from where monoms are allocated */
236  intvec * pModW;   /* std: module weights */
237  poly      ppNoether; /*  variables, set by procedures from hecke/kstd1:
238
239                            the highest monomial below pHEdge */
240// #ifdef HAVE_RINGS
241//   unsigned int  cf->ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
242//   int_number    cf->modBase; /* Z/(ringflag^cf->modExponent)=Z/cf->modNumber*/
243//   unsigned long cf->modExponent;
244//   unsigned long cf->modNumber;  /* Z/cf->modNumber */
245//   int_number    cf->modNumber;
246// #endif
247 
248  unsigned long options; /* ring dependent options */
249
250//  int        ch;  /* characteristic, rInit */
251  int        ref; /* reference counter to the ring, interpreter */
252
253  short      N;      /* number of vars, rInit */
254
255  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */
256
257  short     firstBlockEnds;
258#ifdef HAVE_PLURAL
259  short     real_var_start, real_var_end;
260#endif
261
262#ifdef HAVE_SHIFTBBA
263  short          isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
264#endif
265
266  BOOLEAN   VectorOut;
267  BOOLEAN   ShortOut;
268  BOOLEAN   CanShortOut;
269  BOOLEAN   LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
270  BOOLEAN   MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise
271  BOOLEAN   pLexOrder; /* TRUE if the monomial ordering is not compatible with pFDeg */
272
273  BOOLEAN   ComponentOrder; // ???
274
275  // what follows below here should be set by rComplete, _only_
276  // contains component, but no weight fields in E */
277  short      ExpL_Size; // size of exponent vector in long
278  short      CmpL_Size; // portions which need to be compared
279  /* number of long vars in exp vector:
280     long vars are those longs in the exponent vector which are
281     occupied by variables, only */
282  short      VarL_Size;
283  short      BitsPerExp; /* number of bits per exponent */
284  short      ExpPerLong; /* maximal number of Exponents per long */
285  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
286  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
287  short      OrdSize; /* size of ord vector (in sro_ord) */
288
289  /* if >= 0, long vars in exp vector are consecutive and start there
290     if <  0, long vars in exp vector are not consecutive */
291  short     VarL_LowIndex;
292  // number of exponents in r->VarL_Offset[0]
293  // is minimal number of exponents in a long var
294  short     MinExpPerLong;
295
296  short     NegWeightL_Size;
297  /* array of size VarL_Size,
298     VarL_Offset[i] gets i-th long var in exp vector */
299  int*      VarL_Offset;
300
301  /* mask for getting single exponents */
302  unsigned long bitmask;
303  /* mask used for divisiblity tests */
304  unsigned long divmask; // rComplete
305
306  p_Procs_s*    p_Procs; // rComplete/p_ProcsSet
307
308  /* FDeg and LDeg */
309  pFDegProc     pFDeg; // rComplete/rSetDegStuff
310  pLDegProc     pLDeg; // rComplete/rSetDegStuff
311
312  /* as it was determined by rComplete */
313  pFDegProc     pFDegOrig;
314  /* and as it was determined before rOptimizeLDeg */
315  pLDegProc     pLDegOrig;
316
317  p_SetmProc    p_Setm;
318  n_Procs_s*    cf;
319#ifdef HAVE_PLURAL
320  private:
321    nc_struct*    _nc; // private
322  public:
323    inline const nc_struct* GetNC() const { return _nc; }; // public!!!
324    inline nc_struct*& GetNC() { return _nc; }; // public!!!
325#endif
326 public:
327  operator coeffs() const { return cf; }
328};
329
330////////// DEPRECATED
331/////// void   rChangeCurrRing(ring r);
332
333ring   rDefault(int ch, int N, char **n);
334ring   rDefault(const coeffs cf, int N, char **n);
335ring   rDefault(int ch, int N, char **n,int ord_size, int *ord, int *block0, int *block1, int **wvhdl=NULL);
336ring   rDefault(const coeffs cf, int N, char **n,int ord_size, int *ord, int *block0, int *block1, int **wvhdl=NULL);
337
338// #define rIsRingVar(A) r_IsRingVar(A,currRing)
339int    r_IsRingVar(const char *n, ring r);
340void   rWrite(ring r, BOOLEAN details = FALSE);
341ring   rCopy(ring r);
342ring   rCopy0(const ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE);
343ring rCopy0AndAddA(ring r, int64vec *wv64, BOOLEAN copy_qideal = TRUE,
344                   BOOLEAN copy_ordering = TRUE);
345ring   rOpposite(ring r);
346ring   rEnvelope(ring r);
347
348/// we must always have this test!
349static inline bool rIsPluralRing(const ring r)
350{
351  assume(r != NULL); assume(r->cf != NULL);   
352#ifdef HAVE_PLURAL
353  nc_struct *n;
354  return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/;
355#else
356  return false;
357#endif
358}
359
360static inline bool rIsRatGRing(const ring r)
361{
362  assume(r != NULL);
363#ifdef HAVE_PLURAL
364  /* nc_struct *n; */
365  return (r != NULL) /* && ((n=r->GetNC()) != NULL) */
366          && (r->real_var_start>1);
367#else
368  return false;
369#endif
370}
371
372
373
374
375// The following are for LaScala3 only!
376void rChangeSComps(int* currComponents, long* currShiftedComponents, int length, ring r);
377void rGetSComps(int** currComponents, long** currShiftedComponents, int *length, ring r);
378
379
380
381const char * rSimpleOrdStr(int ord);
382int rOrderName(char * ordername);
383char * rOrdStr(ring r);
384char * rVarStr(ring r);
385char * rCharStr(ring r);
386char * rString(ring r);
387int    rChar(ring r);
388
389char * rParStr(ring r);
390
391int    rSum(ring r1, ring r2, ring &sum);
392int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp);
393
394/// returns TRUE, if r1 equals r2 FALSE, otherwise Equality is
395/// determined componentwise, if qr == 1, then qrideal equality is
396/// tested, as well
397BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = TRUE);
398
399/// returns TRUE, if r1 and r2 represents the monomials in the same way
400/// FALSE, otherwise
401/// this is an analogue to rEqual but not so strict
402BOOLEAN rSamePolyRep(ring r1, ring r2);
403
404void   rUnComplete(ring r);
405
406BOOLEAN rRing_is_Homog(ring r);
407BOOLEAN rRing_has_CompLastBlock(ring r);
408
409#ifdef HAVE_RINGS
410static inline BOOLEAN rField_is_Ring_2toM(const ring r)
411{ assume(r != NULL); assume(r->cf != NULL); return ( getCoeffType(r->cf) == n_Z2m && nCoeff_is_Ring_2toM(r->cf) ); }
412
413static inline BOOLEAN rField_is_Ring_ModN(const ring r)
414{ assume(r != NULL); assume(r->cf != NULL); return ( getCoeffType(r->cf) == n_Zn && nCoeff_is_Ring_ModN(r->cf) ); }
415
416static inline BOOLEAN rField_is_Ring_PtoM(const ring r)
417{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zpn && nCoeff_is_Ring_PtoM(r->cf) ); }
418
419static inline BOOLEAN rField_is_Ring_Z(const ring r)
420{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Z && nCoeff_is_Ring_Z(r->cf) ); }
421
422static inline BOOLEAN rField_is_Ring(const ring r)
423{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Ring(r->cf); }
424
425static inline BOOLEAN rField_is_Domain(const ring r)
426{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Domain(r->cf); }
427
428static inline BOOLEAN rField_has_Units(const ring r)
429{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_Units(r->cf); }
430#else
431#define rField_is_Ring(A) (0)
432#define rField_is_Ring_2toM(A) (0)
433#define rField_is_Ring_ModN(A) (0)
434#define rField_is_Ring_PtoM(A) (0)
435#define rField_is_Ring_Z(A) (0)
436#define rField_is_Domain(A) (1)
437#define rField_has_Units(A) (1)
438#endif
439
440static inline BOOLEAN rField_is_Zp(const ring r)
441{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp); }
442
443static inline BOOLEAN rField_is_Zp(const ring r, int p)
444{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp) && (r->cf->ch == p); }
445
446static inline BOOLEAN rField_is_Q(const ring r)
447{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q(r->cf); }
448
449static inline BOOLEAN rField_is_numeric(const ring r) /* R, long R, long C */
450{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_numeric(r->cf); }
451
452static inline BOOLEAN rField_is_R(const ring r)
453{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_R(r->cf); }
454
455static inline BOOLEAN rField_is_GF(const ring r)
456{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf); }
457
458static inline BOOLEAN rField_is_GF(const ring r, int q)
459{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf, q); }
460
461/* DO NOT USE; just here for compatibility reasons towards
462   the SINGULAR svn trunk */
463static inline BOOLEAN rField_is_Zp_a(const ring r)
464{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf); }
465
466/* DO NOT USE; just here for compatibility reasons towards
467   the SINGULAR svn trunk */
468static inline BOOLEAN rField_is_Zp_a(const ring r, int p)
469{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf, p); }
470
471/* DO NOT USE; just here for compatibility reasons towards
472   the SINGULAR svn trunk */
473static inline BOOLEAN rField_is_Q_a(const ring r)
474{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q_a(r->cf); }
475   
476static inline BOOLEAN rField_is_long_R(const ring r)
477{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_R(r->cf); }
478
479static inline BOOLEAN rField_is_long_C(const ring r)
480{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_C(r->cf); }
481
482static inline BOOLEAN rField_has_simple_inverse(const ring r)
483{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_inverse(r->cf); }
484
485/// Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies
486static inline BOOLEAN rField_has_simple_Alloc(const ring r)
487{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_Alloc(r->cf); }
488
489/// Alg. or trans. ext.
490static inline BOOLEAN rField_is_Extension(const ring r)
491{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Extension(r->cf); } /* Z/p(a) and Q(a)*/
492
493n_coeffType rFieldType(const ring r);
494
495/// this needs to be called whenever a new ring is created: new fields
496/// in ring are created (like VarOffset), unless they already exist
497/// with force == 1, new fields are _always_ created (overwritten),
498/// even if they exist
499BOOLEAN rComplete(ring r, int force = 0);
500// use this to free fields created by rComplete //?
501
502/// set all properties of a new ring - also called by rComplete
503void p_SetGlobals(const ring r, BOOLEAN complete = TRUE);
504
505static inline int rBlocks(ring r)
506{
507  assume(r != NULL);
508  int i=0;
509  while (r->order[i]!=0) i++;
510  return i+1;
511}
512
513// misc things
514static inline char* rRingVar(short i, const ring r)
515{
516  assume(r != NULL); assume(r->cf != NULL); return r->names[i];
517}
518static inline BOOLEAN rShortOut(const ring r)
519{
520  assume(r != NULL); assume(r->cf != NULL); return (r->ShortOut);
521}
522
523/// #define rVar(r) (r->N)
524static inline short rVar(const ring r)
525{
526  assume(r != NULL);
527  return r->N;
528}
529
530/// (r->cf->P)
531static inline short rPar(const ring r)
532{
533  assume(r != NULL);
534  const coeffs C = r->cf;
535  assume(C != NULL);
536
537  if( rField_is_Extension(r) )
538  {
539    const ring R = C->extRing;
540    assume( R != NULL );
541    return rVar( R );
542  }
543  else if (nCoeff_is_long_C(C))
544  {
545    return 1;
546  }
547  return 0;
548}
549
550
551/// (r->cf->parameter)
552static inline char** rParameter(const ring r)
553{
554  assume(r != NULL);
555  const coeffs C = r->cf;
556  assume(C != NULL);
557
558  if( rField_is_Extension(r) ) // only alg / trans. exts...
559  {
560    const ring R = C->extRing;
561    assume( R != NULL );
562    return R->names;
563  }
564  else if (nCoeff_is_GF(C))
565  {
566    return &(C->m_nfParameter);
567  }
568  else if (nCoeff_is_long_C(C))
569  {
570    return &(C->complex_parameter);
571  }
572  return NULL;
573}
574
575/// return the specified parameter as a (new!) number in the given
576/// polynomial ring, or NULL if invalid
577/// parameters (as variables) begin with 1!
578number n_Param(const short iParameter, const ring r);
579
580/// if m == var(i)/1 => return i,
581int n_IsParam(number m, const ring r);
582
583//#define  rInternalChar(r) ((r)->cf->ch)
584static inline int rInternalChar(const ring r)
585{
586  assume(r != NULL);
587  const coeffs C = r->cf;
588  assume(C != NULL);
589  return C->ch;
590}
591
592   
593/* R, Q, Fp: FALSE */
594static inline BOOLEAN rIsExtension(const ring r)
595{
596//  assume( (rParameter(r)!=NULL) == rField_is_Extension(r) ); // ?
597  return rField_is_Extension(r) || nCoeff_is_GF(r->cf) ;
598}
599
600/// Tests whether '(r->cf->minpoly) == NULL'
601BOOLEAN rMinpolyIsNULL(const ring r);
602
603
604/// order stuff
605typedef enum rRingOrder_t
606{
607  ringorder_no = 0,
608  ringorder_a,
609  ringorder_a64, ///< for int64 weights
610  ringorder_c,
611  ringorder_C,
612  ringorder_M,
613  ringorder_S, ///< S?
614  ringorder_s, ///< s?
615  ringorder_lp,
616  ringorder_dp,
617  ringorder_rp,
618  ringorder_Dp,
619  ringorder_wp,
620  ringorder_Wp,
621  ringorder_ls,
622  ringorder_ds,
623  ringorder_Ds,
624  ringorder_ws,
625  ringorder_Ws,
626  ringorder_am,
627  ringorder_L,
628  // the following are only used internally
629  ringorder_aa, ///< for idElimination, like a, except pFDeg, pWeigths ignore it
630  ringorder_rs, ///< opposite of ls
631  ringorder_IS, ///< Induced (Schreyer) ordering
632  ringorder_unspec
633} rRingOrder_t;
634
635typedef enum rOrderType_t
636{
637  rOrderType_General = 0, ///< non-simple ordering as specified by currRing
638  rOrderType_CompExp,     ///< simple ordering, component has priority
639  rOrderType_ExpComp,     ///< simple ordering, exponent vector has priority
640                          ///< component not compatible with exp-vector order
641  rOrderType_Exp,         ///< simple ordering, exponent vector has priority
642                          ///< component is compatible with exp-vector order
643  rOrderType_Syz,         ///< syzygy ordering
644  rOrderType_Schreyer,    ///< Schreyer ordering
645  rOrderType_Syz2dpc,     ///< syzcomp2dpc
646  rOrderType_ExpNoComp    ///< simple ordering, differences in component are
647                          ///< not considered
648} rOrderType_t;
649
650static inline BOOLEAN rIsSyzIndexRing(const ring r)
651{ assume(r != NULL); assume(r->cf != NULL); return r->order[0] == ringorder_s;}
652
653static inline int rGetCurrSyzLimit(const ring r)
654{ assume(r != NULL); assume(r->cf != NULL); return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}
655
656void   rSetSyzComp(int k, const ring r);
657
658// Ring Manipulations
659ring   rAssure_HasComp(const ring r);
660ring   rAssure_SyzComp(const ring r, BOOLEAN complete = TRUE);
661
662ring   rAssure_dp_S(const ring r);
663ring   rAssure_dp_C(const ring r);
664ring   rAssure_C_dp(const ring r);
665
666/// makes sure that c/C ordering is last ordering
667ring   rAssure_CompLastBlock(const ring r, BOOLEAN complete = TRUE);
668
669/// makes sure that c/C ordering is last ordering and SyzIndex is first
670ring   rAssure_SyzComp_CompLastBlock(const ring r, BOOLEAN complete = TRUE);
671ring   rAssure_TDeg(const ring r, int start_var, int end_var, int &pos);
672
673/// return the max-comonent wchich has syzIndex i
674/// Assume: i<= syzIndex_limit
675int rGetMaxSyzComp(int i, const ring r);
676
677BOOLEAN rHasSimpleOrder(const ring r);
678
679/// returns TRUE, if simple lp or ls ordering
680BOOLEAN rHasSimpleLexOrder(const ring r);
681
682//???? return TRUE if p->exp[r->pOrdIndex] holds total degree of p ???
683
684
685inline BOOLEAN rHasGlobalOrdering(const ring r){ return (r->OrdSgn==1); }
686inline BOOLEAN rHasLocalOrMixedOrdering(const ring r){ return (r->OrdSgn==-1); }
687
688// #define rHasGlobalOrdering(R) ((R)->OrdSgn==1)
689// #define rHasLocalOrMixedOrdering(R) ((R)->OrdSgn==-1)
690
691#define rHasGlobalOrdering_currRing() rHasGlobalOrdering(currRing)
692#define rHasLocalOrMixedOrdering_currRing() rHasLocalOrMixedOrdering(currRing)
693
694BOOLEAN rOrd_is_Totaldegree_Ordering(ring r );
695
696/// return TRUE if p_SetComp requires p_Setm
697BOOLEAN rOrd_SetCompRequiresSetm(ring r);
698rOrderType_t    rGetOrderType(ring r);
699
700/// returns TRUE if var(i) belongs to p-block
701BOOLEAN rIsPolyVar(int i, ring r);
702
703static inline BOOLEAN rOrd_is_Comp_dp(ring r)
704{
705  assume(r != NULL);
706  assume(r->cf != NULL);
707  return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) &&
708          r->order[1] == ringorder_dp &&
709          r->order[2] == 0);
710}
711
712#ifdef RDEBUG
713#define rTest(r)    rDBTest(r, __FILE__, __LINE__)
714extern BOOLEAN rDBTest(ring r, const char* fn, const int l);
715#else
716#define rTest(r)
717#endif
718
719ring rModifyRing(ring r, BOOLEAN omit_degree,
720                         BOOLEAN omit_comp,
721                         unsigned long exp_limit);
722
723/// construct Wp, C ring
724ring rModifyRing_Wp(ring r, int* weights);
725void rModify_a_to_A(ring r);
726
727void rKillModifiedRing(ring r);
728// also frees weights
729void rKillModified_Wp_Ring(ring r);
730
731ring rModifyRing_Simple(ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit, BOOLEAN &simple);
732void rKillModifiedRing_Simple(ring r);
733
734#ifdef RDEBUG
735void rDebugPrint(ring r);
736// void pDebugPrint(poly p);
737void p_DebugPrint(poly p, const ring r);
738#endif
739
740#ifndef NDEBUG
741/// debug-print at most nTerms (2 by default) terms from poly/vector p,
742/// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
743void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms = 2);
744#endif
745
746int64 * rGetWeightVec(ring r);
747void rSetWeightVec(ring r, int64 *wv);
748
749/////////////////////////////
750// Auxillary functions
751//
752
753/* return the varIndex-th ring variable as a poly;
754   varIndex starts at index 1 */
755poly rGetVar(const int varIndex, const ring r);
756
757BOOLEAN rSetISReference(const ring r, const ideal F, const int i = 0, const int p = 0);
758
759/// return the position of the p^th IS block order block in r->typ[]...
760int rGetISPos(const int p, const ring r);
761
762BOOLEAN rCheckIV(intvec *iv);
763int rTypeOfMatrixOrder(intvec * order);
764
765void rDelete(ring r); // To be used instead of rKill!
766
767extern omBin sip_sring_bin;
768#endif
Note: See TracBrowser for help on using the repository browser.