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

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