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.52 2000-10-16 12:06:40 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 | |
---|
18 | void rChangeCurrRing(ring r, BOOLEAN complete = TRUE); |
---|
19 | void rSetHdl(idhdl h, BOOLEAN complete = TRUE); |
---|
20 | ring rInit(sleftv* pn, sleftv* rv, sleftv* ord); |
---|
21 | idhdl rDefault(char *s); |
---|
22 | int rIsRingVar(char *n); |
---|
23 | char * RingVar(short); |
---|
24 | void rWrite(ring r); |
---|
25 | void rKill(idhdl h); |
---|
26 | void rKill(ring r); |
---|
27 | ring rCopy(ring r); |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | #ifdef PDEBUG |
---|
32 | #define rChangeSComps(c,s,l) rDBChangeSComps(c,s,l) |
---|
33 | #define rGetSComps(c,s,l) rDBGetSComps(c,s,l) |
---|
34 | void rDBChangeSComps(int* currComponents, |
---|
35 | long* currShiftedComponents, |
---|
36 | int length, |
---|
37 | ring r = currRing); |
---|
38 | void rDBGetSComps(int** currComponents, |
---|
39 | long** currShiftedComponents, |
---|
40 | int *length, |
---|
41 | ring r = currRing); |
---|
42 | #else |
---|
43 | #define rChangeSComps(c,s,l) rNChangeSComps(c,s) |
---|
44 | #define rGetSComps(c,s,l) rNGetSComps(c,s) |
---|
45 | #endif |
---|
46 | |
---|
47 | void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r = currRing); |
---|
48 | void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r = currRing); |
---|
49 | |
---|
50 | idhdl rFindHdl(ring r, idhdl n, idhdl w); |
---|
51 | int rOrderName(char * ordername); |
---|
52 | char * rOrdStr(ring r); |
---|
53 | char * rVarStr(ring r); |
---|
54 | char * rCharStr(ring r); |
---|
55 | char * rString(ring r); |
---|
56 | int rChar(ring r=currRing); |
---|
57 | #define rPar(r) (r->P) |
---|
58 | char * rParStr(ring r); |
---|
59 | int rIsExtension(ring r); |
---|
60 | int rIsExtension(); |
---|
61 | int rSum(ring r1, ring r2, ring &sum); |
---|
62 | |
---|
63 | BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1); |
---|
64 | void rUnComplete(ring r); |
---|
65 | |
---|
66 | #define rInternalChar(r) ((r)->ch) |
---|
67 | #ifndef ABS |
---|
68 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) |
---|
69 | #endif |
---|
70 | |
---|
71 | BOOLEAN rRing_is_Homog(ring r=currRing); |
---|
72 | BOOLEAN rRing_has_CompLastBlock(ring r=currRing); |
---|
73 | |
---|
74 | inline BOOLEAN rField_is_Zp(ring r=currRing) |
---|
75 | { return (r->ch > 1) && (r->parameter==NULL); } |
---|
76 | |
---|
77 | inline BOOLEAN rField_is_Zp(ring r, int p) |
---|
78 | { return (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); } |
---|
79 | |
---|
80 | inline BOOLEAN rField_is_Q(ring r=currRing) |
---|
81 | { return (r->ch == 0) && (r->parameter==NULL); } |
---|
82 | |
---|
83 | inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */ |
---|
84 | { return (r->ch == -1); } |
---|
85 | |
---|
86 | inline BOOLEAN rField_is_R(ring r=currRing) |
---|
87 | { |
---|
88 | if (rField_is_numeric(r) && (r->ch_flags <= (short)SHORT_REAL_LENGTH)) |
---|
89 | return (r->parameter==NULL); |
---|
90 | return FALSE; |
---|
91 | } |
---|
92 | |
---|
93 | inline BOOLEAN rField_is_GF(ring r=currRing) |
---|
94 | { return (r->ch > 1) && (r->parameter!=NULL); } |
---|
95 | |
---|
96 | inline BOOLEAN rField_is_GF(ring r, int q) |
---|
97 | { return (r->ch == q); } |
---|
98 | |
---|
99 | inline BOOLEAN rField_is_Zp_a(ring r=currRing) |
---|
100 | { return (r->ch < -1); } |
---|
101 | |
---|
102 | inline BOOLEAN rField_is_Zp_a(ring r, int p) |
---|
103 | { return (r->ch < -1 ) && (-(r->ch) == ABS(p)); } |
---|
104 | |
---|
105 | inline BOOLEAN rField_is_Q_a(ring r=currRing) |
---|
106 | { return (r->ch == 1); } |
---|
107 | |
---|
108 | inline BOOLEAN rField_is_long_R(ring r=currRing) |
---|
109 | { |
---|
110 | if (rField_is_numeric(r) && (r->ch_flags >(short)SHORT_REAL_LENGTH)) |
---|
111 | return (r->parameter==NULL); |
---|
112 | return FALSE; |
---|
113 | } |
---|
114 | |
---|
115 | inline BOOLEAN rField_is_long_C(ring r=currRing) |
---|
116 | { |
---|
117 | if (rField_is_numeric(r)) |
---|
118 | return (r->parameter!=NULL); |
---|
119 | return FALSE; |
---|
120 | } |
---|
121 | |
---|
122 | inline BOOLEAN rField_has_simple_inverse(ring r=currRing) |
---|
123 | /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/ |
---|
124 | { return (r->ch>1) || ((r->ch== -1) && (r->ch_flags < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/ |
---|
125 | |
---|
126 | inline BOOLEAN rField_has_simple_Alloc(ring r=currRing) |
---|
127 | { return (rField_is_Zp(r) || rField_is_GF(r) || rField_is_R(r)); } |
---|
128 | |
---|
129 | /* Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies*/ |
---|
130 | |
---|
131 | inline 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 | |
---|
134 | // this needs to be called whenever a new ring is created: new fields |
---|
135 | // in ring are created (like VarOffset), unless they already exist |
---|
136 | // with force == 1, new fields are _always_ created (overwritten), |
---|
137 | // even if they exist |
---|
138 | BOOLEAN rComplete(ring r, int force = 0); |
---|
139 | // use this to free fields created by rComplete |
---|
140 | void rUnComplete(ring r); |
---|
141 | inline int rBlocks(ring r) |
---|
142 | { |
---|
143 | int i=0; |
---|
144 | while (r->order[i]!=0) i++; |
---|
145 | return i+1; |
---|
146 | } |
---|
147 | |
---|
148 | typedef enum rRingOrder_t |
---|
149 | { |
---|
150 | ringorder_no = 0, |
---|
151 | ringorder_a, |
---|
152 | ringorder_c, |
---|
153 | ringorder_C, |
---|
154 | ringorder_M, |
---|
155 | ringorder_S, |
---|
156 | ringorder_s, |
---|
157 | ringorder_lp, |
---|
158 | ringorder_dp, |
---|
159 | ringorder_rp, |
---|
160 | ringorder_Dp, |
---|
161 | ringorder_wp, |
---|
162 | ringorder_Wp, |
---|
163 | ringorder_ls, |
---|
164 | ringorder_ds, |
---|
165 | ringorder_Ds, |
---|
166 | ringorder_ws, |
---|
167 | ringorder_Ws, |
---|
168 | ringorder_L, |
---|
169 | ringorder_unspec |
---|
170 | } rRingOrder_t; |
---|
171 | |
---|
172 | typedef enum rOrderType_t |
---|
173 | { |
---|
174 | rOrderType_General = 0, // non-simple ordering as specified by currRing |
---|
175 | rOrderType_CompExp, // simple ordering, component has priority |
---|
176 | rOrderType_ExpComp, // simple ordering, exponent vector has priority |
---|
177 | // component not compatible with exp-vector order |
---|
178 | rOrderType_Exp, // simple ordering, exponent vector has priority |
---|
179 | // component is compatible with exp-vector order |
---|
180 | rOrderType_Syz, // syzygy ordering |
---|
181 | rOrderType_Schreyer, // Schreyer ordering |
---|
182 | rOrderType_Syz2dpc, // syzcomp2dpc |
---|
183 | rOrderType_ExpNoComp // simple ordering, differences in component are |
---|
184 | // not considered |
---|
185 | } rOrderType_t; |
---|
186 | |
---|
187 | inline BOOLEAN rIsSyzIndexRing(ring r) |
---|
188 | { return r->order[0] == ringorder_s;} |
---|
189 | |
---|
190 | inline int rGetCurrSyzLimit() |
---|
191 | { return (currRing->order[0] == ringorder_s ? |
---|
192 | currRing->typ[0].data.syz.limit : 0);} |
---|
193 | |
---|
194 | // Ring Manipulations |
---|
195 | ring rCurrRingAssure_SyzComp(); |
---|
196 | void rSetSyzComp(int k); |
---|
197 | ring rCurrRingAssure_dp_S(); |
---|
198 | ring rCurrRingAssure_dp_C(); |
---|
199 | ring rCurrRingAssure_C_dp(); |
---|
200 | // makes sure that c/C ordering is last ordering |
---|
201 | ring rCurrRingAssure_CompLastBlock(); |
---|
202 | // makes sure that c/C ordering is last ordering and SyzIndex is first |
---|
203 | ring rCurrRingAssure_SyzComp_CompLastBlock(); |
---|
204 | |
---|
205 | // return the max-comonent wchich has syzIndex i |
---|
206 | // Assume: i<= syzIndex_limit |
---|
207 | int rGetMaxSyzComp(int i); |
---|
208 | |
---|
209 | BOOLEAN rHasSimpleOrder(ring r); |
---|
210 | // returns TRUE, if simple lp or ls ordering |
---|
211 | BOOLEAN rHasSimpleLexOrder(ring r); |
---|
212 | // return TRUE if p->exp[r->pOrdIndex] holds total degree of p */ |
---|
213 | BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing); |
---|
214 | rOrderType_t rGetOrderType(ring r); |
---|
215 | BOOLEAN rIsPolyVar(int i); /* returns TRUE if var(i) belongs to p-block */ |
---|
216 | |
---|
217 | #ifdef RDEBUG |
---|
218 | #define rTest(r) rDBTest(r, __FILE__, __LINE__) |
---|
219 | extern BOOLEAN rDBTest(ring r, char* fn, int l); |
---|
220 | #else |
---|
221 | #define rTest(r) |
---|
222 | #endif |
---|
223 | |
---|
224 | ring rModifyRing(ring r, BOOLEAN omit_degree, |
---|
225 | BOOLEAN omit_comp, |
---|
226 | unsigned long exp_limit); |
---|
227 | void rKillModifiedRing(ring r); |
---|
228 | |
---|
229 | void rDebugPrint(ring r); |
---|
230 | void pDebugPrint(poly p); |
---|
231 | #endif |
---|