source: git/Singular/ring.h @ 754c547

spielwiese
Last change on this file since 754c547 was 754c547, checked in by Olaf Bachmann <obachman@…>, 22 years ago
fixed maMonomoial_Insert git-svn-id: file:///usr/local/Singular/svn/trunk@5745 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 7.7 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/* $Id: ring.h,v 1.69 2002-01-19 14:48:19 obachman Exp $ */
10
11/* includes */
12#include "structs.h"
13#include "polys-impl.h"
14
15#define SHORT_REAL_LENGTH 6 // use short reals for real <= 6 digits
16
17
18void   rChangeCurrRing(ring r);
19void   rSetHdl(idhdl h);
20ring   rInit(sleftv* pn, sleftv* rv, sleftv* ord);
21idhdl  rDefault(char *s);
22ring   rDefault(int ch, int N, char **n);
23#define rIsRingVar(A) r_IsRingVar(A,currRing)
24int    r_IsRingVar(char *n, ring r);
25void   rWrite(ring r);
26void   rKill(idhdl h);
27void   rKill(ring r);
28ring   rCopy(ring r);
29
30
31
32#ifdef PDEBUG
33#define rChangeSComps(c,s,l) rDBChangeSComps(c,s,l)
34#define rGetSComps(c,s,l) rDBGetSComps(c,s,l)
35void rDBChangeSComps(int* currComponents,
36                     long* currShiftedComponents,
37                     int length,
38                     ring r = currRing);
39void rDBGetSComps(int** currComponents,
40                  long** currShiftedComponents,
41                  int *length,
42                  ring r = currRing);
43#else
44#define rChangeSComps(c,s,l) rNChangeSComps(c,s)
45#define rGetSComps(c,s,l) rNGetSComps(c,s)
46#endif
47
48void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r = currRing);
49void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r = currRing);
50
51idhdl  rFindHdl(ring r, idhdl n, idhdl w);
52int rOrderName(char * ordername);
53char * rOrdStr(ring r);
54char * rVarStr(ring r);
55char * rCharStr(ring r);
56char * rString(ring r);
57int    rChar(ring r=currRing);
58#define rPar(r) (r->P)
59char * rParStr(ring r);
60int    rIsExtension(ring r);
61int    rIsExtension();
62int    rSum(ring r1, ring r2, ring &sum);
63
64BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1);
65void   rUnComplete(ring r);
66
67#define  rInternalChar(r) ((r)->ch)
68#ifndef ABS
69#define ABS(x) ((x) < 0 ? (-(x)) : (x))
70#endif
71
72BOOLEAN rRing_is_Homog(ring r=currRing);
73BOOLEAN rRing_has_CompLastBlock(ring r=currRing);
74
75inline BOOLEAN rField_is_Zp(ring r=currRing)
76{ return (r->ch > 1) && (r->parameter==NULL); }
77
78inline BOOLEAN rField_is_Zp(ring r, int p)
79{ return (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); }
80
81inline BOOLEAN rField_is_Q(ring r=currRing)
82{ return (r->ch == 0) && (r->parameter==NULL); }
83
84inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */
85{ return (r->ch ==  -1); }
86
87inline BOOLEAN rField_is_R(ring r=currRing)
88{
89  if (rField_is_numeric(r) && (r->float_len <= (short)SHORT_REAL_LENGTH))
90    return (r->parameter==NULL);
91  return FALSE;
92}
93
94inline BOOLEAN rField_is_GF(ring r=currRing)
95{ return (r->ch > 1) && (r->parameter!=NULL); }
96
97inline BOOLEAN rField_is_GF(ring r, int q)
98{ return (r->ch == q); }
99
100inline BOOLEAN rField_is_Zp_a(ring r=currRing)
101{ return (r->ch < -1); }
102
103inline BOOLEAN rField_is_Zp_a(ring r, int p)
104{ return (r->ch < -1 ) && (-(r->ch) == ABS(p)); }
105
106inline BOOLEAN rField_is_Q_a(ring r=currRing)
107{ return (r->ch == 1); }
108
109inline BOOLEAN rField_is_long_R(ring r=currRing)
110{
111  if (rField_is_numeric(r) && (r->float_len >(short)SHORT_REAL_LENGTH))
112    return (r->parameter==NULL);
113  return FALSE;
114}
115
116inline BOOLEAN rField_is_long_C(ring r=currRing)
117{
118  if (rField_is_numeric(r))
119    return (r->parameter!=NULL);
120  return FALSE;
121}
122
123inline BOOLEAN rField_has_simple_inverse(ring r=currRing)
124/* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/
125{ return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/
126
127inline BOOLEAN rField_has_simple_Alloc(ring r=currRing)
128{ return (rField_is_Zp(r) || rField_is_GF(r) || rField_is_R(r)); }
129
130/* Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies*/
131inline BOOLEAN rField_is_Extension(ring r=currRing)
132{ return (rField_is_Q_a(r)) || (rField_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/
133
134n_coeffType rFieldType(ring r);
135
136// this needs to be called whenever a new ring is created: new fields
137// in ring are created (like VarOffset), unless they already exist
138// with force == 1, new fields are _always_ created (overwritten),
139// even if they exist
140BOOLEAN rComplete(ring r, int force = 0);
141// use this to free fields created by rComplete
142void rUnComplete(ring r);
143inline int rBlocks(ring r)
144{
145  int i=0;
146  while (r->order[i]!=0) i++;
147  return i+1;
148}
149
150// misc things
151inline char* rRingVar(short i)
152{
153  return currRing->names[i];
154}
155inline char* rRingVar(short i, ring r)
156{
157  return r->names[i];
158}
159inline BOOLEAN rShortOut(ring r)
160{
161  return (r->ShortOut);
162}
163
164// order stuff
165typedef enum rRingOrder_t
166{
167  ringorder_no = 0,
168  ringorder_a,
169  ringorder_c,
170  ringorder_C,
171  ringorder_M,
172  ringorder_S,
173  ringorder_s,
174  ringorder_lp,
175  ringorder_dp,
176  ringorder_rp,
177  ringorder_Dp,
178  ringorder_wp,
179  ringorder_Wp,
180  ringorder_ls,
181  ringorder_ds,
182  ringorder_Ds,
183  ringorder_ws,
184  ringorder_Ws,
185  ringorder_L,
186  // the following are only used internally
187  ringorder_aa, // for idElimination, like a, except pFDeg, pWeigths ignore it
188  ringorder_unspec
189} rRingOrder_t;
190
191typedef enum rOrderType_t
192{
193  rOrderType_General = 0, // non-simple ordering as specified by currRing
194  rOrderType_CompExp,     // simple ordering, component has priority
195  rOrderType_ExpComp,     // simple ordering, exponent vector has priority
196                          // component not compatible with exp-vector order
197  rOrderType_Exp,         // simple ordering, exponent vector has priority
198                          // component is compatible with exp-vector order
199  rOrderType_Syz,         // syzygy ordering
200  rOrderType_Schreyer,    // Schreyer ordering
201  rOrderType_Syz2dpc,     // syzcomp2dpc
202  rOrderType_ExpNoComp    // simple ordering, differences in component are
203                          // not considered
204} rOrderType_t;
205
206inline BOOLEAN rIsSyzIndexRing(ring r)
207{ return r->order[0] == ringorder_s;}
208
209inline int rGetCurrSyzLimit(ring r = currRing)
210{ return (r->order[0] == ringorder_s ?
211          r->typ[0].data.syz.limit : 0);}
212
213// Ring Manipulations
214ring   rCurrRingAssure_SyzComp();
215void   rSetSyzComp(int k);
216ring   rCurrRingAssure_dp_S();
217ring   rCurrRingAssure_dp_C();
218ring   rCurrRingAssure_C_dp();
219// makes sure that c/C ordering is last ordering
220ring   rCurrRingAssure_CompLastBlock();
221// makes sure that c/C ordering is last ordering and SyzIndex is first
222ring   rCurrRingAssure_SyzComp_CompLastBlock();
223
224// return the max-comonent wchich has syzIndex i
225// Assume: i<= syzIndex_limit
226int rGetMaxSyzComp(int i);
227
228BOOLEAN rHasSimpleOrder(ring r);
229// returns TRUE, if simple lp or ls ordering
230BOOLEAN rHasSimpleLexOrder(ring r);
231// return TRUE if p->exp[r->pOrdIndex] holds total degree of p */
232BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing);
233// return TRUE if p_SetComp requires p_Setm
234BOOLEAN rOrd_SetCompRequiresSetm(ring r);
235rOrderType_t    rGetOrderType(ring r);
236/* returns TRUE if var(i) belongs to p-block */
237BOOLEAN rIsPolyVar(int i, ring r = currRing);
238
239inline BOOLEAN rOrd_is_Comp_dp(ring r)
240{
241  return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) &&
242          r->order[1] == ringorder_dp &&
243          r->order[2] == 0);
244}
245
246#ifdef HAVE_PLURAL
247inline BOOLEAN rIsPluralRing(ring r)
248{
249  return r->nc != NULL;
250}
251#endif
252
253#ifdef RDEBUG
254#define rTest(r)    rDBTest(r, __FILE__, __LINE__)
255extern BOOLEAN rDBTest(ring r, char* fn, int l);
256#else
257#define rTest(r)
258#endif
259
260ring rModifyRing(ring r, BOOLEAN omit_degree,
261                         BOOLEAN omit_comp,
262                         unsigned long exp_limit);
263// construct Wp, C ring
264ring rModifyRing_Wp(ring r, int* weights);
265
266void rKillModifiedRing(ring r);
267// also frees weights
268void rKillModified_Wp_Ring(ring r);
269
270void rDebugPrint(ring r);
271void pDebugPrint(poly p);
272
273int * rGetWeightVec(ring r);
274void rSetWeightVec(ring r, int *);
275
276lists rDecompose(ring r);
277ring rCompose(lists  L);
278#endif
Note: See TracBrowser for help on using the repository browser.