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

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