source: git/libpolys/polys/monomials/ring.h @ 83db8d

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