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

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