source: git/libpolys/polys/monomials/ring.h @ 7e53d9

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