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

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