[35aab3] | 1 | #ifndef RING_H |
---|
| 2 | #define RING_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
| 6 | /* |
---|
| 7 | * ABSTRACT - the interpreter related ring operations |
---|
| 8 | */ |
---|
[341696] | 9 | /* $Id$ */ |
---|
[35aab3] | 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 | |
---|
[b07ba77] | 17 | #if 0 |
---|
| 18 | enum n_coeffType |
---|
| 19 | { |
---|
| 20 | n_unknown=0, |
---|
| 21 | n_Zp, |
---|
| 22 | n_Q, |
---|
| 23 | n_R, |
---|
| 24 | n_GF, |
---|
| 25 | n_long_R, |
---|
| 26 | n_Zp_a, |
---|
| 27 | n_Q_a, |
---|
| 28 | n_long_C |
---|
| 29 | }; |
---|
| 30 | #endif |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | // #ifdef HAVE_PLURAL |
---|
| 34 | #if 0 |
---|
| 35 | enum nc_type |
---|
| 36 | { |
---|
| 37 | nc_error = -1, // Something's gone wrong! |
---|
| 38 | nc_general = 0, /* yx=q xy+... */ |
---|
| 39 | nc_skew, /*1*/ /* yx=q xy */ |
---|
| 40 | nc_comm, /*2*/ /* yx= xy */ |
---|
| 41 | nc_lie, /*3*/ /* yx=xy+... */ |
---|
| 42 | nc_undef, /*4*/ /* for internal reasons */ |
---|
| 43 | |
---|
| 44 | nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0 |
---|
| 45 | }; |
---|
| 46 | #endif |
---|
| 47 | // #endif |
---|
| 48 | |
---|
[56bd6a] | 49 | enum tHomog |
---|
| 50 | { |
---|
| 51 | isNotHomog = FALSE, |
---|
| 52 | isHomog = TRUE, |
---|
| 53 | testHomog |
---|
| 54 | }; |
---|
[b07ba77] | 55 | |
---|
[835d83] | 56 | extern ring currRing; |
---|
| 57 | extern ideal currQuotient; |
---|
| 58 | extern idhdl currRingHdl; |
---|
| 59 | |
---|
[35aab3] | 60 | |
---|
| 61 | void rChangeCurrRing(ring r); |
---|
| 62 | void rSetHdl(idhdl h); |
---|
| 63 | ring rInit(sleftv* pn, sleftv* rv, sleftv* ord); |
---|
[85e68dd] | 64 | idhdl rDefault(const char *s); |
---|
[35aab3] | 65 | ring rDefault(int ch, int N, char **n); |
---|
| 66 | #define rIsRingVar(A) r_IsRingVar(A,currRing) |
---|
[8837a0] | 67 | int r_IsRingVar(const char *n, ring r); |
---|
[35aab3] | 68 | void rWrite(ring r); |
---|
| 69 | void rKill(idhdl h); |
---|
| 70 | void rKill(ring r); |
---|
| 71 | ring rCopy(ring r); |
---|
[645a19] | 72 | ring rCopy0(const ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE); |
---|
[8f42a46] | 73 | void rNameCheck(ring R); |
---|
[6b5dd2] | 74 | ring rOpposite(ring r); |
---|
| 75 | ring rEnvelope(ring r); |
---|
[35aab3] | 76 | |
---|
[645a19] | 77 | /// we must always have this test! |
---|
[24cece] | 78 | static inline bool rIsPluralRing(const ring r) |
---|
[d312f6] | 79 | { |
---|
[86016d] | 80 | #ifdef HAVE_PLURAL |
---|
[7ff04a] | 81 | nc_struct *n; |
---|
[a794e7] | 82 | return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/; |
---|
[d312f6] | 83 | #else |
---|
[86016d] | 84 | return false; |
---|
[d312f6] | 85 | #endif |
---|
[86016d] | 86 | } |
---|
[d312f6] | 87 | |
---|
[24cece] | 88 | static inline bool rIsRatGRing(const ring r) |
---|
[454cb0] | 89 | { |
---|
| 90 | #ifdef HAVE_PLURAL |
---|
[9be65c] | 91 | /* nc_struct *n; */ |
---|
[0b4ec2] | 92 | return (r != NULL) /* && ((n=r->GetNC()) != NULL) */ |
---|
[454cb0] | 93 | && (r->real_var_start>1); |
---|
| 94 | #else |
---|
| 95 | return false; |
---|
| 96 | #endif |
---|
| 97 | } |
---|
| 98 | |
---|
[35aab3] | 99 | |
---|
| 100 | |
---|
[4c7d73] | 101 | |
---|
[35aab3] | 102 | #ifdef PDEBUG |
---|
| 103 | #define rChangeSComps(c,s,l) rDBChangeSComps(c,s,l) |
---|
| 104 | #define rGetSComps(c,s,l) rDBGetSComps(c,s,l) |
---|
| 105 | void rDBChangeSComps(int* currComponents, |
---|
| 106 | long* currShiftedComponents, |
---|
| 107 | int length, |
---|
| 108 | ring r = currRing); |
---|
| 109 | void rDBGetSComps(int** currComponents, |
---|
| 110 | long** currShiftedComponents, |
---|
| 111 | int *length, |
---|
| 112 | ring r = currRing); |
---|
| 113 | #else |
---|
| 114 | #define rChangeSComps(c,s,l) rNChangeSComps(c,s) |
---|
| 115 | #define rGetSComps(c,s,l) rNGetSComps(c,s) |
---|
| 116 | #endif |
---|
| 117 | |
---|
| 118 | void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r = currRing); |
---|
| 119 | void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r = currRing); |
---|
| 120 | |
---|
| 121 | idhdl rFindHdl(ring r, idhdl n, idhdl w); |
---|
| 122 | idhdl rSimpleFindHdl(ring r, idhdl root, idhdl n); |
---|
| 123 | const char * rSimpleOrdStr(int ord); |
---|
| 124 | int rOrderName(char * ordername); |
---|
| 125 | char * rOrdStr(ring r); |
---|
| 126 | char * rVarStr(ring r); |
---|
| 127 | char * rCharStr(ring r); |
---|
| 128 | char * rString(ring r); |
---|
| 129 | int rChar(ring r=currRing); |
---|
| 130 | #define rPar(r) (r->P) |
---|
[98a77e] | 131 | #define rVar(r) (r->N) |
---|
[35aab3] | 132 | char * rParStr(ring r); |
---|
| 133 | int rIsExtension(ring r); |
---|
| 134 | int rIsExtension(); |
---|
| 135 | int rSum(ring r1, ring r2, ring &sum); |
---|
[83bde7] | 136 | int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp); |
---|
[35aab3] | 137 | |
---|
| 138 | BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1); |
---|
[f62996] | 139 | BOOLEAN rSamePolyRep(ring r1, ring r2); |
---|
[35aab3] | 140 | void rUnComplete(ring r); |
---|
| 141 | |
---|
| 142 | #define rInternalChar(r) ((r)->ch) |
---|
| 143 | |
---|
| 144 | BOOLEAN rRing_is_Homog(ring r=currRing); |
---|
| 145 | BOOLEAN rRing_has_CompLastBlock(ring r=currRing); |
---|
| 146 | |
---|
[c90b43] | 147 | #ifdef HAVE_RINGS |
---|
[24cece] | 148 | static inline BOOLEAN rField_is_Ring_2toM(ring r=currRing) |
---|
[009d80] | 149 | { return (r->ringtype == 1); } |
---|
[994445] | 150 | |
---|
[24cece] | 151 | static inline BOOLEAN rField_is_Ring_ModN(ring r=currRing) |
---|
[009d80] | 152 | { return (r->ringtype == 2); } |
---|
[585bbcb] | 153 | |
---|
[24cece] | 154 | static inline BOOLEAN rField_is_Ring_PtoM(ring r=currRing) |
---|
[1e579c6] | 155 | { return (r->ringtype == 3); } |
---|
| 156 | |
---|
[24cece] | 157 | static inline BOOLEAN rField_is_Ring_Z(ring r=currRing) |
---|
[1e579c6] | 158 | { return (r->ringtype == 4); } |
---|
| 159 | |
---|
[24cece] | 160 | static inline BOOLEAN rField_is_Ring(ring r=currRing) |
---|
[206e158] | 161 | { return (r->ringtype != 0); } |
---|
| 162 | |
---|
[24cece] | 163 | static inline BOOLEAN rField_is_Domain(ring r=currRing) |
---|
[1e579c6] | 164 | { return (r->ringtype == 4 || r->ringtype == 0); } |
---|
| 165 | |
---|
[24cece] | 166 | static inline BOOLEAN rField_has_Units(ring r=currRing) |
---|
[1e579c6] | 167 | { return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); } |
---|
[9d249b] | 168 | #else |
---|
| 169 | #define rField_is_Ring(A) (0) |
---|
[009d80] | 170 | #endif |
---|
| 171 | |
---|
| 172 | #ifdef HAVE_RINGS |
---|
[24cece] | 173 | static inline BOOLEAN rField_is_Zp(ring r=currRing) |
---|
[009d80] | 174 | { return (r->ringtype == 0) && (r->ch > 1) && (r->parameter==NULL); } |
---|
[585bbcb] | 175 | |
---|
[24cece] | 176 | static inline BOOLEAN rField_is_Zp(ring r, int p) |
---|
[009d80] | 177 | { return (r->ringtype == 0) && (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); } |
---|
[585bbcb] | 178 | |
---|
[24cece] | 179 | static inline BOOLEAN rField_is_Q(ring r=currRing) |
---|
[009d80] | 180 | { return (r->ringtype == 0) && (r->ch == 0) && (r->parameter==NULL); } |
---|
[585bbcb] | 181 | |
---|
[24cece] | 182 | static inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */ |
---|
[009d80] | 183 | { return (r->ringtype == 0) && (r->ch == -1); } |
---|
[585bbcb] | 184 | |
---|
[24cece] | 185 | static inline BOOLEAN rField_is_R(ring r=currRing) |
---|
[585bbcb] | 186 | { |
---|
| 187 | if (rField_is_numeric(r) && (r->float_len <= (short)SHORT_REAL_LENGTH)) |
---|
[009d80] | 188 | return (r->ringtype == 0) && (r->parameter==NULL); |
---|
[585bbcb] | 189 | return FALSE; |
---|
| 190 | } |
---|
| 191 | |
---|
[24cece] | 192 | static inline BOOLEAN rField_is_GF(ring r=currRing) |
---|
[009d80] | 193 | { return (r->ringtype == 0) && (r->ch > 1) && (r->parameter!=NULL); } |
---|
[585bbcb] | 194 | |
---|
[24cece] | 195 | static inline BOOLEAN rField_is_GF(ring r, int q) |
---|
[009d80] | 196 | { return (r->ringtype == 0) && (r->ch == q); } |
---|
[585bbcb] | 197 | |
---|
[24cece] | 198 | static inline BOOLEAN rField_is_Zp_a(ring r=currRing) |
---|
[009d80] | 199 | { return (r->ringtype == 0) && (r->ch < -1); } |
---|
[585bbcb] | 200 | |
---|
[24cece] | 201 | static inline BOOLEAN rField_is_Zp_a(ring r, int p) |
---|
[009d80] | 202 | { return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); } |
---|
[585bbcb] | 203 | |
---|
[24cece] | 204 | static inline BOOLEAN rField_is_Q_a(ring r=currRing) |
---|
[009d80] | 205 | { return (r->ringtype == 0) && (r->ch == 1); } |
---|
[585bbcb] | 206 | |
---|
[24cece] | 207 | static inline BOOLEAN rField_is_long_R(ring r=currRing) |
---|
[585bbcb] | 208 | { |
---|
| 209 | if (rField_is_numeric(r) && (r->float_len >(short)SHORT_REAL_LENGTH)) |
---|
[009d80] | 210 | return (r->ringtype == 0) && (r->parameter==NULL); |
---|
[585bbcb] | 211 | return FALSE; |
---|
| 212 | } |
---|
| 213 | |
---|
[24cece] | 214 | static inline BOOLEAN rField_is_long_C(ring r=currRing) |
---|
[585bbcb] | 215 | { |
---|
| 216 | if (rField_is_numeric(r)) |
---|
[009d80] | 217 | return (r->ringtype == 0) && (r->parameter!=NULL); |
---|
[585bbcb] | 218 | return FALSE; |
---|
| 219 | } |
---|
| 220 | #else |
---|
[24cece] | 221 | static inline BOOLEAN rField_is_Zp(ring r=currRing) |
---|
[35aab3] | 222 | { return (r->ch > 1) && (r->parameter==NULL); } |
---|
| 223 | |
---|
[24cece] | 224 | static inline BOOLEAN rField_is_Zp(ring r, int p) |
---|
[35aab3] | 225 | { return (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); } |
---|
| 226 | |
---|
[24cece] | 227 | static inline BOOLEAN rField_is_Q(ring r=currRing) |
---|
[35aab3] | 228 | { return (r->ch == 0) && (r->parameter==NULL); } |
---|
| 229 | |
---|
[24cece] | 230 | static inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */ |
---|
[35aab3] | 231 | { return (r->ch == -1); } |
---|
| 232 | |
---|
[24cece] | 233 | static inline BOOLEAN rField_is_R(ring r=currRing) |
---|
[35aab3] | 234 | { |
---|
| 235 | if (rField_is_numeric(r) && (r->float_len <= (short)SHORT_REAL_LENGTH)) |
---|
| 236 | return (r->parameter==NULL); |
---|
| 237 | return FALSE; |
---|
| 238 | } |
---|
| 239 | |
---|
[24cece] | 240 | static inline BOOLEAN rField_is_GF(ring r=currRing) |
---|
[35aab3] | 241 | { return (r->ch > 1) && (r->parameter!=NULL); } |
---|
| 242 | |
---|
[24cece] | 243 | static inline BOOLEAN rField_is_GF(ring r, int q) |
---|
[35aab3] | 244 | { return (r->ch == q); } |
---|
| 245 | |
---|
[24cece] | 246 | static inline BOOLEAN rField_is_Zp_a(ring r=currRing) |
---|
[35aab3] | 247 | { return (r->ch < -1); } |
---|
| 248 | |
---|
[24cece] | 249 | static inline BOOLEAN rField_is_Zp_a(ring r, int p) |
---|
[35aab3] | 250 | { return (r->ch < -1 ) && (-(r->ch) == ABS(p)); } |
---|
| 251 | |
---|
[24cece] | 252 | static inline BOOLEAN rField_is_Q_a(ring r=currRing) |
---|
[35aab3] | 253 | { return (r->ch == 1); } |
---|
| 254 | |
---|
[24cece] | 255 | static inline BOOLEAN rField_is_long_R(ring r=currRing) |
---|
[35aab3] | 256 | { |
---|
| 257 | if (rField_is_numeric(r) && (r->float_len >(short)SHORT_REAL_LENGTH)) |
---|
| 258 | return (r->parameter==NULL); |
---|
| 259 | return FALSE; |
---|
| 260 | } |
---|
| 261 | |
---|
[24cece] | 262 | static inline BOOLEAN rField_is_long_C(ring r=currRing) |
---|
[35aab3] | 263 | { |
---|
| 264 | if (rField_is_numeric(r)) |
---|
| 265 | return (r->parameter!=NULL); |
---|
| 266 | return FALSE; |
---|
| 267 | } |
---|
[585bbcb] | 268 | #endif |
---|
[35aab3] | 269 | |
---|
[24cece] | 270 | static inline BOOLEAN rField_has_simple_inverse(ring r=currRing) |
---|
[35aab3] | 271 | /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/ |
---|
[009d80] | 272 | #ifdef HAVE_RINGS |
---|
| 273 | { return (r->ringtype > 0) || (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/ |
---|
[585bbcb] | 274 | #else |
---|
[35aab3] | 275 | { return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/ |
---|
[585bbcb] | 276 | #endif |
---|
[35aab3] | 277 | |
---|
[24cece] | 278 | static inline BOOLEAN rField_has_simple_Alloc(ring r=currRing) |
---|
[009d80] | 279 | { return (rField_is_Zp(r) |
---|
| 280 | || rField_is_GF(r) |
---|
[c90b43] | 281 | #ifdef HAVE_RINGS |
---|
[009d80] | 282 | || rField_is_Ring_2toM(r) |
---|
[585bbcb] | 283 | #endif |
---|
[009d80] | 284 | || rField_is_R(r)); } |
---|
[35aab3] | 285 | |
---|
| 286 | /* Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies*/ |
---|
[24cece] | 287 | static inline BOOLEAN rField_is_Extension(ring r=currRing) |
---|
[35aab3] | 288 | { return (rField_is_Q_a(r)) || (rField_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/ |
---|
| 289 | |
---|
| 290 | n_coeffType rFieldType(ring r); |
---|
| 291 | |
---|
[645a19] | 292 | /// this needs to be called whenever a new ring is created: new fields |
---|
| 293 | /// in ring are created (like VarOffset), unless they already exist |
---|
| 294 | /// with force == 1, new fields are _always_ created (overwritten), |
---|
| 295 | /// even if they exist |
---|
[35aab3] | 296 | BOOLEAN rComplete(ring r, int force = 0); |
---|
[645a19] | 297 | // use this to free fields created by rComplete //? |
---|
[ea68ed] | 298 | |
---|
[24cece] | 299 | static inline int rBlocks(ring r) |
---|
[35aab3] | 300 | { |
---|
| 301 | int i=0; |
---|
| 302 | while (r->order[i]!=0) i++; |
---|
| 303 | return i+1; |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | // misc things |
---|
[24cece] | 307 | static inline char* rRingVar(short i) |
---|
[35aab3] | 308 | { |
---|
| 309 | return currRing->names[i]; |
---|
| 310 | } |
---|
[24cece] | 311 | static inline char* rRingVar(short i, ring r) |
---|
[35aab3] | 312 | { |
---|
| 313 | return r->names[i]; |
---|
| 314 | } |
---|
[24cece] | 315 | static inline BOOLEAN rShortOut(ring r) |
---|
[35aab3] | 316 | { |
---|
| 317 | return (r->ShortOut); |
---|
| 318 | } |
---|
| 319 | |
---|
[645a19] | 320 | /// order stuff |
---|
[35aab3] | 321 | typedef enum rRingOrder_t |
---|
| 322 | { |
---|
| 323 | ringorder_no = 0, |
---|
| 324 | ringorder_a, |
---|
[645a19] | 325 | ringorder_a64, ///< for int64 weights |
---|
[35aab3] | 326 | ringorder_c, |
---|
| 327 | ringorder_C, |
---|
| 328 | ringorder_M, |
---|
[645a19] | 329 | ringorder_S, ///< S? |
---|
| 330 | ringorder_s, ///< s? |
---|
[35aab3] | 331 | ringorder_lp, |
---|
| 332 | ringorder_dp, |
---|
| 333 | ringorder_rp, |
---|
| 334 | ringorder_Dp, |
---|
| 335 | ringorder_wp, |
---|
| 336 | ringorder_Wp, |
---|
| 337 | ringorder_ls, |
---|
| 338 | ringorder_ds, |
---|
| 339 | ringorder_Ds, |
---|
| 340 | ringorder_ws, |
---|
| 341 | ringorder_Ws, |
---|
| 342 | ringorder_L, |
---|
| 343 | // the following are only used internally |
---|
[645a19] | 344 | ringorder_aa, ///< for idElimination, like a, except pFDeg, pWeigths ignore it |
---|
| 345 | ringorder_rs, ///< ??? |
---|
| 346 | ringorder_IS, ///< Induced (Schreyer) ordering |
---|
[35aab3] | 347 | ringorder_unspec |
---|
| 348 | } rRingOrder_t; |
---|
| 349 | |
---|
| 350 | typedef enum rOrderType_t |
---|
| 351 | { |
---|
[645a19] | 352 | rOrderType_General = 0, ///< non-simple ordering as specified by currRing |
---|
| 353 | rOrderType_CompExp, ///< simple ordering, component has priority |
---|
| 354 | rOrderType_ExpComp, ///< simple ordering, exponent vector has priority |
---|
| 355 | ///< component not compatible with exp-vector order |
---|
| 356 | rOrderType_Exp, ///< simple ordering, exponent vector has priority |
---|
| 357 | ///< component is compatible with exp-vector order |
---|
| 358 | rOrderType_Syz, ///< syzygy ordering |
---|
| 359 | rOrderType_Schreyer, ///< Schreyer ordering |
---|
| 360 | rOrderType_Syz2dpc, ///< syzcomp2dpc |
---|
| 361 | rOrderType_ExpNoComp ///< simple ordering, differences in component are |
---|
| 362 | ///< not considered |
---|
[35aab3] | 363 | } rOrderType_t; |
---|
| 364 | |
---|
[24cece] | 365 | static inline BOOLEAN rIsSyzIndexRing(const ring r) |
---|
[35aab3] | 366 | { return r->order[0] == ringorder_s;} |
---|
| 367 | |
---|
[24cece] | 368 | static inline int rGetCurrSyzLimit(const ring r = currRing) |
---|
[645a19] | 369 | { return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);} |
---|
[35aab3] | 370 | |
---|
| 371 | // Ring Manipulations |
---|
[935bb1b] | 372 | ring rAssure_HasComp(ring r); |
---|
[35aab3] | 373 | ring rCurrRingAssure_SyzComp(); |
---|
| 374 | void rSetSyzComp(int k); |
---|
| 375 | ring rCurrRingAssure_dp_S(); |
---|
| 376 | ring rCurrRingAssure_dp_C(); |
---|
| 377 | ring rCurrRingAssure_C_dp(); |
---|
[645a19] | 378 | |
---|
| 379 | /// makes sure that c/C ordering is last ordering |
---|
[35aab3] | 380 | ring rCurrRingAssure_CompLastBlock(); |
---|
[645a19] | 381 | |
---|
| 382 | /// makes sure that c/C ordering is last ordering and SyzIndex is first |
---|
[35aab3] | 383 | ring rCurrRingAssure_SyzComp_CompLastBlock(); |
---|
[afd7439] | 384 | ring rAssure_TDeg(ring r, int start_var, int end_var, int &pos); |
---|
[35aab3] | 385 | |
---|
[645a19] | 386 | /// return the max-comonent wchich has syzIndex i |
---|
| 387 | /// Assume: i<= syzIndex_limit |
---|
[35aab3] | 388 | int rGetMaxSyzComp(int i); |
---|
| 389 | |
---|
[b9642b1] | 390 | BOOLEAN rHasSimpleOrder(const ring r); |
---|
[645a19] | 391 | |
---|
| 392 | /// returns TRUE, if simple lp or ls ordering |
---|
[b9642b1] | 393 | BOOLEAN rHasSimpleLexOrder(const ring r); |
---|
[645a19] | 394 | |
---|
[35aab3] | 395 | // return TRUE if p->exp[r->pOrdIndex] holds total degree of p */ |
---|
[0ec631] | 396 | //inline BOOLEAN rHasGlobalOrdering(const ring r=currRing) |
---|
| 397 | //{ return (r->OrdSgn==1); } |
---|
| 398 | #define rHasGlobalOrdering(R) ((R)->OrdSgn==1) |
---|
[f20117] | 399 | #define rHasGlobalOrdering_currRing() (pOrdSgn==1) |
---|
[0ec631] | 400 | //inline BOOLEAN rHasLocalOrMixedOrdering(const ring r=currRing) |
---|
| 401 | //{ return (r->OrdSgn==-1); } |
---|
| 402 | #define rHasLocalOrMixedOrdering(R) ((R)->OrdSgn==-1) |
---|
[753f9d2] | 403 | #define rHasLocalOrMixedOrdering_currRing() (pOrdSgn==-1) |
---|
[35aab3] | 404 | BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing); |
---|
[645a19] | 405 | |
---|
| 406 | /// return TRUE if p_SetComp requires p_Setm |
---|
[35aab3] | 407 | BOOLEAN rOrd_SetCompRequiresSetm(ring r); |
---|
| 408 | rOrderType_t rGetOrderType(ring r); |
---|
[645a19] | 409 | |
---|
| 410 | /// returns TRUE if var(i) belongs to p-block |
---|
[35aab3] | 411 | BOOLEAN rIsPolyVar(int i, ring r = currRing); |
---|
| 412 | |
---|
[24cece] | 413 | static inline BOOLEAN rOrd_is_Comp_dp(ring r) |
---|
[35aab3] | 414 | { |
---|
| 415 | return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) && |
---|
| 416 | r->order[1] == ringorder_dp && |
---|
| 417 | r->order[2] == 0); |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | #ifdef RDEBUG |
---|
| 421 | #define rTest(r) rDBTest(r, __FILE__, __LINE__) |
---|
[85e68dd] | 422 | extern BOOLEAN rDBTest(ring r, const char* fn, const int l); |
---|
[35aab3] | 423 | #else |
---|
| 424 | #define rTest(r) |
---|
| 425 | #endif |
---|
| 426 | |
---|
| 427 | ring rModifyRing(ring r, BOOLEAN omit_degree, |
---|
| 428 | BOOLEAN omit_comp, |
---|
| 429 | unsigned long exp_limit); |
---|
[645a19] | 430 | |
---|
| 431 | /// construct Wp, C ring |
---|
[35aab3] | 432 | ring rModifyRing_Wp(ring r, int* weights); |
---|
[4c7d73] | 433 | void rModify_a_to_A(ring r); |
---|
[35aab3] | 434 | |
---|
| 435 | void rKillModifiedRing(ring r); |
---|
| 436 | // also frees weights |
---|
| 437 | void rKillModified_Wp_Ring(ring r); |
---|
| 438 | |
---|
| 439 | ring rModifyRing_Simple(ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit, BOOLEAN &simple); |
---|
| 440 | void rKillModifiedRing_Simple(ring r); |
---|
| 441 | |
---|
[645a19] | 442 | #ifdef RDEBUG |
---|
[35aab3] | 443 | void rDebugPrint(ring r); |
---|
| 444 | void pDebugPrint(poly p); |
---|
[3664c9a] | 445 | void p_DebugPrint(poly p, const ring r); |
---|
[645a19] | 446 | #endif |
---|
| 447 | |
---|
[af3d2a] | 448 | #ifndef NDEBUG |
---|
[645a19] | 449 | /// debug-print at most nTerms (2 by default) terms from poly/vector p, |
---|
| 450 | /// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing. |
---|
| 451 | void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms = 2); |
---|
[af3d2a] | 452 | #endif |
---|
[35aab3] | 453 | |
---|
[4c7d73] | 454 | int64 * rGetWeightVec(ring r); |
---|
| 455 | void rSetWeightVec(ring r, int64 *wv); |
---|
[35aab3] | 456 | |
---|
[9b9c0b] | 457 | lists rDecompose(const ring r); |
---|
| 458 | ring rCompose(const lists L); |
---|
[a830d2b] | 459 | ///////////////////////////// |
---|
| 460 | // Auxillary functions |
---|
| 461 | // |
---|
| 462 | |
---|
| 463 | BOOLEAN rCheckIV(intvec *iv); |
---|
| 464 | int rTypeOfMatrixOrder(intvec * order); |
---|
| 465 | void rDelete(ring r); |
---|
| 466 | |
---|
[9c4865b] | 467 | extern struct omBin_s* sip_sring_bin; |
---|
[35aab3] | 468 | #endif |
---|