source: git/libpolys/polys/monomials/ring.h @ 805d0b1

spielwiese
Last change on this file since 805d0b1 was bcfd11a, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
elimination of rMinpolyIsNULL in favour of nCoeff_is_algExt fix rMinpolyIsNULL (idIs0) TODO: remove rMinpolyIsNULL it completely!
  • Property mode set to 100644
File size: 25.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 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  int**      wvhdl;  /* array of weight vectors, rInit/rSleftvOrdering2Ordering */
213  char **    names;  /* array of variable names, rInit */
214
215  // what follows below here should be set by rComplete, _only_
216  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
217                       /*  ExpL_Size entries*/
218
219  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
220  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
221  /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs
222  in ExpVector whose values need an offset due to negative weights */
223  /* array of NegWeigtL_Size indicies */
224  int*      NegWeightL_Offset;
225
226  int*     VarOffset;
227
228//  ideal      minideal;
229//  number     minpoly;  /* replaced by minideal->m[0] */
230  ideal      qideal; /**< extension to the ring structure: qring, rInit, OR
231                          for Q_a/Zp_a, rInit (replaces minideal!);
232                          for a start, we assume that there is either no
233                          or exactly one generator in minideal, playing
234                          the role of the former minpoly; minideal may
235                          also be NULL which coincides with the
236                          no-generator-case **/
237
238  int*     firstwv;
239
240  omBin    PolyBin; /* Bin from where monoms are allocated */
241  intvec * pModW;   /* std: module weights */
242  poly      ppNoether; /*  variables, set by procedures from hecke/kstd1:
243
244                            the highest monomial below pHEdge */
245// #ifdef HAVE_RINGS
246//   unsigned int  cf->ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
247//   int_number    cf->modBase; /* Z/(ringflag^cf->modExponent)=Z/cf->modNumber*/
248//   unsigned long cf->modExponent;
249//   unsigned long cf->modNumber;  /* Z/cf->modNumber */
250//   int_number    cf->modNumber;
251// #endif
252 
253  unsigned long options; /* ring dependent options */
254
255//  int        ch;  /* characteristic, rInit */
256  int        ref; /* reference counter to the ring, interpreter */
257
258  short      N;      /* number of vars, rInit */
259
260  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */
261
262  short     firstBlockEnds;
263#ifdef HAVE_PLURAL
264  short     real_var_start, real_var_end;
265#endif
266
267#ifdef HAVE_SHIFTBBA
268  short          isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
269#endif
270
271  BOOLEAN   VectorOut;
272  BOOLEAN   ShortOut;
273  BOOLEAN   CanShortOut;
274  BOOLEAN   LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
275  BOOLEAN   MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise
276  BOOLEAN   pLexOrder; /* TRUE if the monomial ordering is not compatible with pFDeg */
277
278  BOOLEAN   ComponentOrder; // ???
279
280  // what follows below here should be set by rComplete, _only_
281  // contains component, but no weight fields in E */
282  short      ExpL_Size; // size of exponent vector in long
283  short      CmpL_Size; // portions which need to be compared
284  /* number of long vars in exp vector:
285     long vars are those longs in the exponent vector which are
286     occupied by variables, only */
287  short      VarL_Size;
288  short      BitsPerExp; /* number of bits per exponent */
289  short      ExpPerLong; /* maximal number of Exponents per long */
290  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
291  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
292  short      OrdSize; /* size of ord vector (in sro_ord) */
293
294  /* if >= 0, long vars in exp vector are consecutive and start there
295     if <  0, long vars in exp vector are not consecutive */
296  short     VarL_LowIndex;
297  // number of exponents in r->VarL_Offset[0]
298  // is minimal number of exponents in a long var
299  short     MinExpPerLong;
300
301  short     NegWeightL_Size;
302  /* array of size VarL_Size,
303     VarL_Offset[i] gets i-th long var in exp vector */
304  int*      VarL_Offset;
305
306  /* mask for getting single exponents */
307  unsigned long bitmask;
308  /* mask used for divisiblity tests */
309  unsigned long divmask; // rComplete
310
311  p_Procs_s*    p_Procs; // rComplete/p_ProcsSet
312
313  /* FDeg and LDeg */
314  pFDegProc     pFDeg; // rComplete/rSetDegStuff
315  pLDegProc     pLDeg; // rComplete/rSetDegStuff
316
317  /* as it was determined by rComplete */
318  pFDegProc     pFDegOrig;
319  /* and as it was determined before rOptimizeLDeg */
320  pLDegProc     pLDegOrig;
321
322  p_SetmProc    p_Setm;
323  n_Procs_s*    cf;
324#ifdef HAVE_PLURAL
325  private:
326    nc_struct*    _nc; // private
327  public:
328    inline const nc_struct* GetNC() const { return _nc; }; // public!!!
329    inline nc_struct*& GetNC() { return _nc; }; // public!!!
330#endif
331 public:
332  operator coeffs() const { return cf; }
333};
334
335////////// DEPRECATED
336/////// void   rChangeCurrRing(ring r);
337
338ring   rDefault(int ch, int N, char **n);
339ring   rDefault(const coeffs cf, int N, char **n);
340ring   rDefault(int ch, int N, char **n,int ord_size, int *ord, int *block0, int *block1, int **wvhdl=NULL);
341ring   rDefault(const coeffs cf, int N, char **n,int ord_size, int *ord, int *block0, int *block1, int **wvhdl=NULL);
342
343// #define rIsRingVar(A) r_IsRingVar(A,currRing)
344int    r_IsRingVar(const char *n, ring r);
345void   rWrite(ring r, BOOLEAN details = FALSE);
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
386const char * rSimpleOrdStr(int ord);
387int rOrderName(char * ordername);
388char * rOrdStr(ring r);
389char * rVarStr(ring r);
390char * rCharStr(ring r);
391char * rString(ring r);
392int    rChar(ring r);
393
394char * rParStr(ring r);
395
396int    rSum(ring r1, ring r2, ring &sum);
397int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp);
398
399/// returns TRUE, if r1 equals r2 FALSE, otherwise Equality is
400/// determined componentwise, if qr == 1, then qrideal equality is
401/// tested, as well
402BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = TRUE);
403
404/// returns TRUE, if r1 and r2 represents the monomials in the same way
405/// FALSE, otherwise
406/// this is an analogue to rEqual but not so strict
407BOOLEAN rSamePolyRep(ring r1, ring r2);
408
409void   rUnComplete(ring r);
410
411BOOLEAN rRing_is_Homog(ring r);
412BOOLEAN rRing_has_CompLastBlock(ring r);
413
414#ifdef HAVE_RINGS
415static inline BOOLEAN rField_is_Ring_2toM(const ring r)
416{ assume(r != NULL); assume(r->cf != NULL); return ( getCoeffType(r->cf) == n_Z2m && nCoeff_is_Ring_2toM(r->cf) ); }
417
418static inline BOOLEAN rField_is_Ring_ModN(const ring r)
419{ assume(r != NULL); assume(r->cf != NULL); return ( getCoeffType(r->cf) == n_Zn && nCoeff_is_Ring_ModN(r->cf) ); }
420
421static inline BOOLEAN rField_is_Ring_PtoM(const ring r)
422{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zpn && nCoeff_is_Ring_PtoM(r->cf) ); }
423
424static inline BOOLEAN rField_is_Ring_Z(const ring r)
425{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Z && nCoeff_is_Ring_Z(r->cf) ); }
426
427static inline BOOLEAN rField_is_Ring(const ring r)
428{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Ring(r->cf); }
429
430static inline BOOLEAN rField_is_Domain(const ring r)
431{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Domain(r->cf); }
432
433static inline BOOLEAN rField_has_Units(const ring r)
434{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_Units(r->cf); }
435#else
436#define rField_is_Ring(A) (0)
437#define rField_is_Ring_2toM(A) (0)
438#define rField_is_Ring_ModN(A) (0)
439#define rField_is_Ring_PtoM(A) (0)
440#define rField_is_Ring_Z(A) (0)
441#define rField_is_Domain(A) (1)
442#define rField_has_Units(A) (1)
443#endif
444
445static inline BOOLEAN rField_is_Zp(const ring r)
446{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp); }
447
448static inline BOOLEAN rField_is_Zp(const ring r, int p)
449{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp) && (r->cf->ch == p); }
450
451static inline BOOLEAN rField_is_Q(const ring r)
452{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q(r->cf); }
453
454static inline BOOLEAN rField_is_numeric(const ring r) /* R, long R, long C */
455{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_numeric(r->cf); }
456
457static inline BOOLEAN rField_is_R(const ring r)
458{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_R(r->cf); }
459
460static inline BOOLEAN rField_is_GF(const ring r)
461{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf); }
462
463static inline BOOLEAN rField_is_GF(const ring r, int q)
464{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf, q); }
465
466/* DO NOT USE; just here for compatibility reasons towards
467   the SINGULAR svn trunk */
468static inline BOOLEAN rField_is_Zp_a(const ring r)
469{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf); }
470
471/* DO NOT USE; just here for compatibility reasons towards
472   the SINGULAR svn trunk */
473static inline BOOLEAN rField_is_Zp_a(const ring r, int p)
474{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf, p); }
475
476/* DO NOT USE; just here for compatibility reasons towards
477   the SINGULAR svn trunk */
478static inline BOOLEAN rField_is_Q_a(const ring r)
479{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q_a(r->cf); }
480   
481static inline BOOLEAN rField_is_long_R(const ring r)
482{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_R(r->cf); }
483
484static inline BOOLEAN rField_is_long_C(const ring r)
485{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_C(r->cf); }
486
487static inline BOOLEAN rField_has_simple_inverse(const ring r)
488{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_inverse(r->cf); }
489
490/// Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies
491static inline BOOLEAN rField_has_simple_Alloc(const ring r)
492{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_Alloc(r->cf); }
493
494/// Alg. or trans. ext.
495static inline BOOLEAN rField_is_Extension(const ring r)
496{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Extension(r->cf); } /* Z/p(a) and Q(a)*/
497
498n_coeffType rFieldType(const ring r);
499
500/// this needs to be called whenever a new ring is created: new fields
501/// in ring are created (like VarOffset), unless they already exist
502/// with force == 1, new fields are _always_ created (overwritten),
503/// even if they exist
504BOOLEAN rComplete(ring r, int force = 0);
505// use this to free fields created by rComplete //?
506
507/// set all properties of a new ring - also called by rComplete
508void p_SetGlobals(const ring r, BOOLEAN complete = TRUE);
509
510static inline int rBlocks(ring r)
511{
512  assume(r != NULL);
513  int i=0;
514  while (r->order[i]!=0) i++;
515  return i+1;
516}
517
518// misc things
519static inline char* rRingVar(short i, const ring r)
520{
521  assume(r != NULL); assume(r->cf != NULL); return r->names[i];
522}
523static inline BOOLEAN rShortOut(const ring r)
524{
525  assume(r != NULL); return (r->ShortOut);
526}
527
528static inline BOOLEAN rCanShortOut(const ring r)
529{
530  assume(r != NULL); return (r->CanShortOut);
531}
532
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 int rPar(const ring r)
542{
543  assume(r != NULL);
544  const coeffs C = r->cf;
545  assume(C != NULL);
546
547  return n_NumberOfParameters(C);
548//   if( nCoeff_is_Extension(C) )
549//   {
550//     const ring R = C->extRing;
551//     assume( R != NULL );
552//     return rVar( R );
553//   }
554//   else if (nCoeff_is_GF(C))
555//   {
556//     return 1;
557//   }
558//   else if (nCoeff_is_long_C(C))
559//   {
560//     return 1;
561//   }
562//   return 0;
563}
564
565
566/// (r->cf->parameter)
567static inline char const * const * rParameter(const ring r)
568{
569  assume(r != NULL);
570  const coeffs C = r->cf;
571  assume(C != NULL);
572
573  return n_ParameterNames(C);
574//   if( nCoeff_is_Extension(C) ) // only alg / trans. exts...
575//   {
576//     const ring R = C->extRing;
577//     assume( R != NULL );
578//     return R->names;
579//   }
580//   else if (nCoeff_is_GF(C))
581//   {
582//     return &(C->m_nfParameter);
583//   }
584//   else if (nCoeff_is_long_C(C))
585//   {
586//     return &(C->complex_parameter);
587//   }
588//   return NULL;
589}
590
591/// return the specified parameter as a (new!) number in the given
592/// polynomial ring, or NULL if invalid
593/// parameters (as variables) begin with 1!
594static inline number n_Param(const short iParameter, const ring r)
595{
596  assume(r != NULL);
597  const coeffs C = r->cf;
598  assume(C != NULL);
599  return n_Param(iParameter, C);
600//   const n_coeffType _filed_type = getCoeffType(C);
601//
602//   if ( iParameter <= 0 || iParameter > rPar(r) )
603//     // Wrong parameter
604//     return NULL;
605//
606//   if( _filed_type == n_algExt )
607//     return naParameter(iParameter, C);
608//
609//   if( _filed_type == n_transExt )
610//     return ntParameter(iParameter, C);
611//
612//   if (_filed_type == n_GF)// if (nCoeff_is_GF(C))
613//   {
614//     number nfPar (int i, const coeffs);
615//     return nfPar(iParameter, C);
616//   }
617//   
618//   if (_filed_type == n_long_C) // if (nCoeff_is_long_C(C))
619//   {
620//     number   ngcPar(int i, const coeffs r);   
621//     return ngcPar(iParameter, C);
622//   }
623//
624//   return NULL;
625}
626
627/// if m == var(i)/1 => return i,
628int n_IsParam(number m, const ring r);
629
630//#define  rInternalChar(r) ((r)->cf->ch)
631static inline int rInternalChar(const ring r)
632{
633  assume(r != NULL);
634  const coeffs C = r->cf;
635  assume(C != NULL);
636  return C->ch;
637}
638
639   
640/* R, Q, Fp: FALSE */
641static inline BOOLEAN rIsExtension(const ring r)
642{
643  assume(r != NULL);
644  const coeffs C = r->cf;
645  assume(C != NULL);
646//  assume( (rParameter(r)!=NULL) == rField_is_Extension(r) ); // ?
647  return nCoeff_is_Extension(C) || nCoeff_is_GF(C) || nCoeff_is_long_C(C);
648}
649
650/// Tests whether '(r->cf->minpoly) == NULL'
651static inline BOOLEAN rMinpolyIsNULL(const ring r)
652{
653  assume(r != NULL);
654  const coeffs C = r->cf;
655  assume(C != NULL);
656
657  const BOOLEAN ret = nCoeff_is_algExt(C); //  || nCoeff_is_GF(C) || nCoeff_is_long_C(C);
658
659  if( ret )
660  {
661    const ring R = C->extRing;
662    assume( R != NULL );
663    BOOLEAN idIs0 (ideal h);
664    assume( !idIs0(R->qideal) );
665  }
666
667  // TODO: this leads to test fails (due to rDecompose?)
668  return !ret;
669}
670
671
672
673/// order stuff
674typedef enum rRingOrder_t
675{
676  ringorder_no = 0,
677  ringorder_a,
678  ringorder_a64, ///< for int64 weights
679  ringorder_c,
680  ringorder_C,
681  ringorder_M,
682  ringorder_S, ///< S?
683  ringorder_s, ///< s?
684  ringorder_lp,
685  ringorder_dp,
686  ringorder_rp,
687  ringorder_Dp,
688  ringorder_wp,
689  ringorder_Wp,
690  ringorder_ls,
691  ringorder_ds,
692  ringorder_Ds,
693  ringorder_ws,
694  ringorder_Ws,
695  ringorder_am,
696  ringorder_L,
697  // the following are only used internally
698  ringorder_aa, ///< for idElimination, like a, except pFDeg, pWeigths ignore it
699  ringorder_rs, ///< opposite of ls
700  ringorder_IS, ///< Induced (Schreyer) ordering
701  ringorder_unspec
702} rRingOrder_t;
703
704typedef enum rOrderType_t
705{
706  rOrderType_General = 0, ///< non-simple ordering as specified by currRing
707  rOrderType_CompExp,     ///< simple ordering, component has priority
708  rOrderType_ExpComp,     ///< simple ordering, exponent vector has priority
709                          ///< component not compatible with exp-vector order
710  rOrderType_Exp,         ///< simple ordering, exponent vector has priority
711                          ///< component is compatible with exp-vector order
712  rOrderType_Syz,         ///< syzygy ordering
713  rOrderType_Schreyer,    ///< Schreyer ordering
714  rOrderType_Syz2dpc,     ///< syzcomp2dpc
715  rOrderType_ExpNoComp    ///< simple ordering, differences in component are
716                          ///< not considered
717} rOrderType_t;
718
719static inline BOOLEAN rIsSyzIndexRing(const ring r)
720{ assume(r != NULL); assume(r->cf != NULL); return r->order[0] == ringorder_s;}
721
722static inline int rGetCurrSyzLimit(const ring r)
723{ assume(r != NULL); assume(r->cf != NULL); return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}
724
725void   rSetSyzComp(int k, const ring r);
726
727// Ring Manipulations
728ring   rAssure_HasComp(const ring r);
729ring   rAssure_SyzComp(const ring r, BOOLEAN complete = TRUE);
730
731ring   rAssure_dp_S(const ring r);
732ring   rAssure_dp_C(const ring r);
733ring   rAssure_C_dp(const ring r);
734
735/// makes sure that c/C ordering is last ordering
736ring   rAssure_CompLastBlock(const ring r, BOOLEAN complete = TRUE);
737
738/// makes sure that c/C ordering is last ordering and SyzIndex is first
739ring   rAssure_SyzComp_CompLastBlock(const ring r, BOOLEAN complete = TRUE);
740ring   rAssure_TDeg(const ring r, int start_var, int end_var, int &pos);
741
742/// return the max-comonent wchich has syzIndex i
743/// Assume: i<= syzIndex_limit
744int rGetMaxSyzComp(int i, const ring r);
745
746BOOLEAN rHasSimpleOrder(const ring r);
747
748/// returns TRUE, if simple lp or ls ordering
749BOOLEAN rHasSimpleLexOrder(const ring r);
750
751//???? return TRUE if p->exp[r->pOrdIndex] holds total degree of p ???
752
753
754inline BOOLEAN rHasGlobalOrdering(const ring r){ return (r->OrdSgn==1); }
755inline BOOLEAN rHasLocalOrMixedOrdering(const ring r){ return (r->OrdSgn==-1); }
756
757// #define rHasGlobalOrdering(R) ((R)->OrdSgn==1)
758// #define rHasLocalOrMixedOrdering(R) ((R)->OrdSgn==-1)
759
760#define rHasGlobalOrdering_currRing() rHasGlobalOrdering(currRing)
761#define rHasLocalOrMixedOrdering_currRing() rHasLocalOrMixedOrdering(currRing)
762
763BOOLEAN rOrd_is_Totaldegree_Ordering(ring r );
764
765/// return TRUE if p_SetComp requires p_Setm
766BOOLEAN rOrd_SetCompRequiresSetm(ring r);
767rOrderType_t    rGetOrderType(ring r);
768
769/// returns TRUE if var(i) belongs to p-block
770BOOLEAN rIsPolyVar(int i, ring r);
771
772static inline BOOLEAN rOrd_is_Comp_dp(ring r)
773{
774  assume(r != NULL);
775  assume(r->cf != NULL);
776  return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) &&
777          r->order[1] == ringorder_dp &&
778          r->order[2] == 0);
779}
780
781#ifdef RDEBUG
782#define rTest(r)    rDBTest(r, __FILE__, __LINE__)
783extern BOOLEAN rDBTest(ring r, const char* fn, const int l);
784#else
785#define rTest(r)
786#endif
787
788ring rModifyRing(ring r, BOOLEAN omit_degree,
789                         BOOLEAN omit_comp,
790                         unsigned long exp_limit);
791
792/// construct Wp, C ring
793ring rModifyRing_Wp(ring r, int* weights);
794void rModify_a_to_A(ring r);
795
796void rKillModifiedRing(ring r);
797// also frees weights
798void rKillModified_Wp_Ring(ring r);
799
800ring rModifyRing_Simple(ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit, BOOLEAN &simple);
801void rKillModifiedRing_Simple(ring r);
802
803#ifdef RDEBUG
804void rDebugPrint(ring r);
805// void pDebugPrint(poly p);
806void p_DebugPrint(poly p, const ring r);
807#endif
808
809#ifndef NDEBUG
810/// debug-print at most nTerms (2 by default) terms from poly/vector p,
811/// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
812void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms = 2);
813#endif
814
815int64 * rGetWeightVec(ring r);
816void rSetWeightVec(ring r, int64 *wv);
817
818/////////////////////////////
819// Auxillary functions
820//
821
822/* return the varIndex-th ring variable as a poly;
823   varIndex starts at index 1 */
824poly rGetVar(const int varIndex, const ring r);
825
826BOOLEAN rSetISReference(const ring r, const ideal F, const int i = 0, const int p = 0);
827
828/// return the position of the p^th IS block order block in r->typ[]...
829int rGetISPos(const int p, const ring r);
830
831BOOLEAN rCheckIV(intvec *iv);
832int rTypeOfMatrixOrder(intvec * order);
833
834void rDelete(ring r); // To be used instead of rKill!
835
836extern omBin sip_sring_bin;
837#endif
Note: See TracBrowser for help on using the repository browser.