source: git/libpolys/polys/monomials/ring.h @ 353a42

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