source: git/libpolys/polys/monomials/ring.h @ 3a8a0d9

spielwiese
Last change on this file since 3a8a0d9 was 3a8a0d9, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
fixes to _am ordering add: additional int* weights_m pointer in struct sro_am fix: rO_WMDegree should not mess around with start/end fix: rCompose: _am ordering was not treated (fixed also by Hans)
  • Property mode set to 100644
File size: 23.7 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
394BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1);
395BOOLEAN rSamePolyRep(ring r1, ring r2);
396void   rUnComplete(ring r);
397
398BOOLEAN rRing_is_Homog(ring r);
399BOOLEAN rRing_has_CompLastBlock(ring r);
400
401#ifdef HAVE_RINGS
402static inline BOOLEAN rField_is_Ring_2toM(const ring r)
403{ assume(r != NULL); assume(r->cf != NULL); return ( getCoeffType(r->cf) == n_Z2m && nCoeff_is_Ring_2toM(r->cf) ); }
404
405static inline BOOLEAN rField_is_Ring_ModN(const ring r)
406{ assume(r != NULL); assume(r->cf != NULL); return ( getCoeffType(r->cf) == n_Zn && nCoeff_is_Ring_ModN(r->cf) ); }
407
408static inline BOOLEAN rField_is_Ring_PtoM(const ring r)
409{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zpn && nCoeff_is_Ring_PtoM(r->cf) ); }
410
411static inline BOOLEAN rField_is_Ring_Z(const ring r)
412{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Z && nCoeff_is_Ring_Z(r->cf) ); }
413
414static inline BOOLEAN rField_is_Ring(const ring r)
415{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Ring(r->cf); }
416
417static inline BOOLEAN rField_is_Domain(const ring r)
418{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Domain(r->cf); }
419
420static inline BOOLEAN rField_has_Units(const ring r)
421{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_Units(r->cf); }
422#else
423#define rField_is_Ring(A) (0)
424#define rField_is_Ring_2toM(A) (0)
425#define rField_is_Ring_ModN(A) (0)
426#define rField_is_Ring_PtoM(A) (0)
427#define rField_is_Ring_Z(A) (0)
428#define rField_is_Domain(A) (1)
429#define rField_has_Units(A) (1)
430#endif
431
432static inline BOOLEAN rField_is_Zp(const ring r)
433{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp); }
434
435static inline BOOLEAN rField_is_Zp(const ring r, int p)
436{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp) && (r->cf->ch == p); }
437
438static inline BOOLEAN rField_is_Q(const ring r)
439{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q(r->cf); }
440
441static inline BOOLEAN rField_is_numeric(const ring r) /* R, long R, long C */
442{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_numeric(r->cf); }
443
444static inline BOOLEAN rField_is_R(const ring r)
445{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_R(r->cf); }
446
447static inline BOOLEAN rField_is_GF(const ring r)
448{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf); }
449
450static inline BOOLEAN rField_is_GF(const ring r, int q)
451{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf, q); }
452
453/* DO NOT USE; just here for compatibility reasons towards
454   the SINGULAR svn trunk */
455static inline BOOLEAN rField_is_Zp_a(const ring r)
456{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf); }
457
458/* DO NOT USE; just here for compatibility reasons towards
459   the SINGULAR svn trunk */
460static inline BOOLEAN rField_is_Zp_a(const ring r, int p)
461{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf, p); }
462
463/* DO NOT USE; just here for compatibility reasons towards
464   the SINGULAR svn trunk */
465static inline BOOLEAN rField_is_Q_a(const ring r)
466{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q_a(r->cf); }
467   
468static inline BOOLEAN rField_is_long_R(const ring r)
469{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_R(r->cf); }
470
471static inline BOOLEAN rField_is_long_C(const ring r)
472{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_C(r->cf); }
473
474static inline BOOLEAN rField_has_simple_inverse(const ring r)
475{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_inverse(r->cf); }
476
477/// Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies
478static inline BOOLEAN rField_has_simple_Alloc(const ring r)
479{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_Alloc(r->cf); }
480
481/// Alg. or trans. ext.
482static inline BOOLEAN rField_is_Extension(const ring r)
483{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Extension(r->cf); } /* Z/p(a) and Q(a)*/
484
485n_coeffType rFieldType(const ring r);
486
487/// this needs to be called whenever a new ring is created: new fields
488/// in ring are created (like VarOffset), unless they already exist
489/// with force == 1, new fields are _always_ created (overwritten),
490/// even if they exist
491BOOLEAN rComplete(ring r, int force = 0);
492// use this to free fields created by rComplete //?
493
494/// set all properties of a new ring - also called by rComplete
495void p_SetGlobals(const ring r, BOOLEAN complete = TRUE);
496
497static inline int rBlocks(ring r)
498{
499  assume(r != NULL);
500  int i=0;
501  while (r->order[i]!=0) i++;
502  return i+1;
503}
504
505// misc things
506static inline char* rRingVar(short i, const ring r)
507{
508  assume(r != NULL); assume(r->cf != NULL); return r->names[i];
509}
510static inline BOOLEAN rShortOut(const ring r)
511{
512  assume(r != NULL); assume(r->cf != NULL); return (r->ShortOut);
513}
514
515/// #define rVar(r) (r->N)
516static inline short rVar(const ring r)
517{
518  assume(r != NULL);
519  return r->N;
520}
521
522/// (r->cf->P)
523static inline short rPar(const ring r)
524{
525  assume(r != NULL);
526  const coeffs C = r->cf;
527  assume(C != NULL);
528
529  if( rField_is_Extension(r) )
530  {
531    const ring R = C->extRing;
532    assume( R != NULL );
533    return rVar( R );
534  }
535  else if (nCoeff_is_long_C(C))
536  {
537    return 1;
538  }
539  return 0;
540}
541
542
543/// (r->cf->parameter)
544static inline char** rParameter(const ring r)
545{
546  assume(r != NULL);
547  const coeffs C = r->cf;
548  assume(C != NULL);
549
550  if( rField_is_Extension(r) ) // only alg / trans. exts...
551  {
552    const ring R = C->extRing;
553    assume( R != NULL );
554    return R->names;
555  }
556  else if (nCoeff_is_GF(C))
557  {
558    return &(C->m_nfParameter);
559  }
560  else if (nCoeff_is_long_C(C))
561  {
562    return &(C->complex_parameter);
563  }
564  return NULL;
565}
566
567/// return the specified parameter as a (new!) number in the given
568/// polynomial ring, or NULL if invalid
569/// parameters (as variables) begin with 1!
570number n_Param(const short iParameter, const ring r);
571
572/// if m == var(i)/1 => return i,
573int n_IsParam(number m, const ring r);
574
575//#define  rInternalChar(r) ((r)->cf->ch)
576static inline int rInternalChar(const ring r)
577{
578  assume(r != NULL);
579  const coeffs C = r->cf;
580  assume(C != NULL);
581  return C->ch;
582}
583
584   
585/* R, Q, Fp: FALSE */
586static inline BOOLEAN rIsExtension(const ring r)
587{
588//  assume( (rParameter(r)!=NULL) == rField_is_Extension(r) ); // ?
589  return rField_is_Extension(r) || nCoeff_is_GF(r->cf) ;
590}
591
592/// Tests whether '(r->cf->minpoly) == NULL'
593BOOLEAN rMinpolyIsNULL(const ring r);
594
595
596/// order stuff
597typedef enum rRingOrder_t
598{
599  ringorder_no = 0,
600  ringorder_a,
601  ringorder_a64, ///< for int64 weights
602  ringorder_c,
603  ringorder_C,
604  ringorder_M,
605  ringorder_S, ///< S?
606  ringorder_s, ///< s?
607  ringorder_lp,
608  ringorder_dp,
609  ringorder_rp,
610  ringorder_Dp,
611  ringorder_wp,
612  ringorder_Wp,
613  ringorder_ls,
614  ringorder_ds,
615  ringorder_Ds,
616  ringorder_ws,
617  ringorder_Ws,
618  ringorder_am,
619  ringorder_L,
620  // the following are only used internally
621  ringorder_aa, ///< for idElimination, like a, except pFDeg, pWeigths ignore it
622  ringorder_rs, ///< opposite of ls
623  ringorder_IS, ///< Induced (Schreyer) ordering
624  ringorder_unspec
625} rRingOrder_t;
626
627typedef enum rOrderType_t
628{
629  rOrderType_General = 0, ///< non-simple ordering as specified by currRing
630  rOrderType_CompExp,     ///< simple ordering, component has priority
631  rOrderType_ExpComp,     ///< simple ordering, exponent vector has priority
632                          ///< component not compatible with exp-vector order
633  rOrderType_Exp,         ///< simple ordering, exponent vector has priority
634                          ///< component is compatible with exp-vector order
635  rOrderType_Syz,         ///< syzygy ordering
636  rOrderType_Schreyer,    ///< Schreyer ordering
637  rOrderType_Syz2dpc,     ///< syzcomp2dpc
638  rOrderType_ExpNoComp    ///< simple ordering, differences in component are
639                          ///< not considered
640} rOrderType_t;
641
642static inline BOOLEAN rIsSyzIndexRing(const ring r)
643{ assume(r != NULL); assume(r->cf != NULL); return r->order[0] == ringorder_s;}
644
645static inline int rGetCurrSyzLimit(const ring r)
646{ assume(r != NULL); assume(r->cf != NULL); return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}
647
648void   rSetSyzComp(int k, const ring r);
649
650// Ring Manipulations
651ring   rAssure_HasComp(const ring r);
652ring   rAssure_SyzComp(const ring r, BOOLEAN complete = TRUE);
653
654ring   rAssure_dp_S(const ring r);
655ring   rAssure_dp_C(const ring r);
656ring   rAssure_C_dp(const ring r);
657
658/// makes sure that c/C ordering is last ordering
659ring   rAssure_CompLastBlock(const ring r, BOOLEAN complete = TRUE);
660
661/// makes sure that c/C ordering is last ordering and SyzIndex is first
662ring   rAssure_SyzComp_CompLastBlock(const ring r, BOOLEAN complete = TRUE);
663ring   rAssure_TDeg(const ring r, int start_var, int end_var, int &pos);
664
665/// return the max-comonent wchich has syzIndex i
666/// Assume: i<= syzIndex_limit
667int rGetMaxSyzComp(int i, const ring r);
668
669BOOLEAN rHasSimpleOrder(const ring r);
670
671/// returns TRUE, if simple lp or ls ordering
672BOOLEAN rHasSimpleLexOrder(const ring r);
673
674//???? return TRUE if p->exp[r->pOrdIndex] holds total degree of p ???
675
676
677inline BOOLEAN rHasGlobalOrdering(const ring r){ return (r->OrdSgn==1); }
678inline BOOLEAN rHasLocalOrMixedOrdering(const ring r){ return (r->OrdSgn==-1); }
679
680// #define rHasGlobalOrdering(R) ((R)->OrdSgn==1)
681// #define rHasLocalOrMixedOrdering(R) ((R)->OrdSgn==-1)
682
683#define rHasGlobalOrdering_currRing() rHasGlobalOrdering(currRing)
684#define rHasLocalOrMixedOrdering_currRing() rHasLocalOrMixedOrdering(currRing)
685
686BOOLEAN rOrd_is_Totaldegree_Ordering(ring r );
687
688/// return TRUE if p_SetComp requires p_Setm
689BOOLEAN rOrd_SetCompRequiresSetm(ring r);
690rOrderType_t    rGetOrderType(ring r);
691
692/// returns TRUE if var(i) belongs to p-block
693BOOLEAN rIsPolyVar(int i, ring r);
694
695static inline BOOLEAN rOrd_is_Comp_dp(ring r)
696{
697  assume(r != NULL);
698  assume(r->cf != NULL);
699  return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) &&
700          r->order[1] == ringorder_dp &&
701          r->order[2] == 0);
702}
703
704#ifdef RDEBUG
705#define rTest(r)    rDBTest(r, __FILE__, __LINE__)
706extern BOOLEAN rDBTest(ring r, const char* fn, const int l);
707#else
708#define rTest(r)
709#endif
710
711ring rModifyRing(ring r, BOOLEAN omit_degree,
712                         BOOLEAN omit_comp,
713                         unsigned long exp_limit);
714
715/// construct Wp, C ring
716ring rModifyRing_Wp(ring r, int* weights);
717void rModify_a_to_A(ring r);
718
719void rKillModifiedRing(ring r);
720// also frees weights
721void rKillModified_Wp_Ring(ring r);
722
723ring rModifyRing_Simple(ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit, BOOLEAN &simple);
724void rKillModifiedRing_Simple(ring r);
725
726#ifdef RDEBUG
727void rDebugPrint(ring r);
728// void pDebugPrint(poly p);
729void p_DebugPrint(poly p, const ring r);
730#endif
731
732#ifndef NDEBUG
733/// debug-print at most nTerms (2 by default) terms from poly/vector p,
734/// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
735void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms = 2);
736#endif
737
738int64 * rGetWeightVec(ring r);
739void rSetWeightVec(ring r, int64 *wv);
740
741/////////////////////////////
742// Auxillary functions
743//
744
745/* return the varIndex-th ring variable as a poly;
746   varIndex starts at index 1 */
747poly rGetVar(const int varIndex, const ring r);
748
749BOOLEAN rSetISReference(const ring r, const ideal F, const int i = 0, const int p = 0);
750
751/// return the position of the p^th IS block order block in r->typ[]...
752int rGetISPos(const int p, const ring r);
753
754BOOLEAN rCheckIV(intvec *iv);
755int rTypeOfMatrixOrder(intvec * order);
756
757void rDelete(ring r); // To be used instead of rKill!
758
759extern omBin sip_sring_bin;
760#endif
Note: See TracBrowser for help on using the repository browser.