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

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