[35aab3] | 1 | #ifndef KUTIL_H |
---|
| 2 | #define KUTIL_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
[660ed3] | 6 | /* $Id: kutil.h,v 1.16 2006-05-19 10:22:36 Singular Exp $ */ |
---|
[35aab3] | 7 | /* |
---|
| 8 | * ABSTRACT: kernel: utils for kStd |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | #include <string.h> |
---|
| 13 | #include <mylimits.h> |
---|
| 14 | |
---|
| 15 | #include "structs.h" |
---|
| 16 | #include "omalloc.h" |
---|
| 17 | #include "ring.h" |
---|
| 18 | #include "structs.h" |
---|
| 19 | #include "pShallowCopyDelete.h" |
---|
| 20 | |
---|
| 21 | #if 1 |
---|
| 22 | #define setmax 16 |
---|
[425d94c] | 23 | #define setmaxL ((4096-12)/sizeof(LObject)) |
---|
| 24 | #define setmaxLinc ((4096)/sizeof(LObject)) |
---|
[939847] | 25 | |
---|
| 26 | #define setmaxT 64 |
---|
| 27 | #define setmaxTinc 32 |
---|
[35aab3] | 28 | #else |
---|
| 29 | #define setmax 16 |
---|
| 30 | #define setmaxL 16 |
---|
| 31 | #define setmaxLinc 16 |
---|
| 32 | #define setmaxT 16 |
---|
| 33 | #define setmaxTinc 16 |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | // define if you want std computations as in Singular version < 2 |
---|
| 37 | // This disbales RedThrough, tailReductions against T (bba), |
---|
| 38 | // sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg |
---|
| 39 | // NOTE: the same effect can be achieved with option(oldStd) |
---|
| 40 | // #define HAVE_OLD_STD |
---|
| 41 | |
---|
| 42 | #ifdef HAVE_OLD_STD |
---|
| 43 | #define K_TEST_OPT_REDTHROUGH 0 |
---|
| 44 | #define K_TEST_OPT_OLDSTD 1 |
---|
| 45 | #else |
---|
| 46 | #define K_TEST_OPT_REDTHROUGH TEST_OPT_REDTHROUGH |
---|
| 47 | #define K_TEST_OPT_OLDSTD TEST_OPT_OLDSTD |
---|
| 48 | #endif |
---|
| 49 | |
---|
| 50 | #undef NO_KINLINE |
---|
| 51 | #if !defined(KDEBUG) && !defined(NO_INLINE) |
---|
| 52 | #define KINLINE inline |
---|
| 53 | #else |
---|
| 54 | #define KINLINE |
---|
| 55 | #define NO_KINLINE 1 |
---|
| 56 | #endif |
---|
| 57 | |
---|
| 58 | typedef int* intset; |
---|
[58ebad] | 59 | typedef int64 wlen_type; |
---|
[fe5ad5] | 60 | typedef wlen_type* wlen_set; |
---|
| 61 | |
---|
[35aab3] | 62 | typedef class sTObject TObject; |
---|
| 63 | typedef class sLObject LObject; |
---|
| 64 | typedef TObject * TSet; |
---|
| 65 | typedef LObject * LSet; |
---|
| 66 | |
---|
| 67 | class sTObject |
---|
| 68 | { |
---|
| 69 | public: |
---|
| 70 | poly p; // Lm(p) \in currRing Tail(p) \in tailRing |
---|
| 71 | poly t_p; // t_p \in tailRing: as monomials Lm(t_p) == Lm(p) |
---|
| 72 | poly max; // p_GetMaxExpP(pNext(p)) |
---|
[ad07b8] | 73 | ring tailRing; |
---|
[35aab3] | 74 | long FDeg; // pFDeg(p) |
---|
| 75 | int ecart, |
---|
| 76 | length, // as of pLDeg |
---|
| 77 | pLength, // either == 0, or == pLength(p) |
---|
| 78 | i_r; // index of TObject in R set, or -1 if not in T |
---|
| 79 | BOOLEAN is_normalized; // true, if pNorm was called on p, false otherwise |
---|
| 80 | |
---|
| 81 | // initialization |
---|
| 82 | KINLINE void Init(ring r = currRing); |
---|
| 83 | KINLINE sTObject(ring tailRing = currRing); |
---|
| 84 | KINLINE sTObject(poly p, ring tailRing = currRing); |
---|
| 85 | KINLINE sTObject(poly p, ring c_r, ring tailRing); |
---|
| 86 | KINLINE sTObject(sTObject* T, int copy); |
---|
| 87 | |
---|
| 88 | KINLINE void Set(ring r=currRing); |
---|
| 89 | KINLINE void Set(poly p_in, ring r=currRing); |
---|
| 90 | KINLINE void Set(poly p_in, ring c_r, ring t_r); |
---|
| 91 | |
---|
| 92 | // Frees the polys of T |
---|
| 93 | KINLINE void Delete(); |
---|
| 94 | // Sets polys to NULL |
---|
| 95 | KINLINE void Clear(); |
---|
| 96 | // makes a copy of the poly of T |
---|
| 97 | KINLINE void Copy(); |
---|
| 98 | |
---|
| 99 | // ring-dependent Lm access: these might result in allocation of monomials |
---|
| 100 | KINLINE poly GetLmCurrRing(); |
---|
| 101 | KINLINE poly GetLmTailRing(); |
---|
| 102 | KINLINE poly GetLm(ring r); |
---|
| 103 | // this returns Lm and ring r (preferably from tailRing), but does not |
---|
| 104 | // allocate a new poly |
---|
| 105 | KINLINE void GetLm(poly &p, ring &r) const; |
---|
[585bbcb] | 106 | |
---|
| 107 | #ifdef OLIVER_PRIVAT_LT |
---|
| 108 | // routines for calc. with rings |
---|
| 109 | KINLINE poly GetLtCurrRing(); |
---|
| 110 | KINLINE poly GetLtTailRing(); |
---|
| 111 | KINLINE poly GetLt(ring r); |
---|
| 112 | KINLINE void GetLt(poly &p, ring &r) const; |
---|
| 113 | #endif |
---|
| 114 | |
---|
[35aab3] | 115 | KINLINE BOOLEAN IsNull() const; |
---|
| 116 | |
---|
| 117 | KINLINE int GetpLength(); |
---|
| 118 | |
---|
| 119 | // makes sure that T.p exists |
---|
| 120 | KINLINE void SetLmCurrRing(); |
---|
| 121 | |
---|
| 122 | // Iterations |
---|
| 123 | // simply get the next monomial |
---|
| 124 | KINLINE poly Next(); |
---|
| 125 | KINLINE void LmDeleteAndIter(); |
---|
| 126 | |
---|
| 127 | // deg stuff |
---|
| 128 | // computes pFDeg |
---|
| 129 | KINLINE long pFDeg() const; |
---|
| 130 | // computes and sets FDeg |
---|
| 131 | KINLINE long SetpFDeg(); |
---|
| 132 | // gets stored FDeg |
---|
| 133 | KINLINE long GetpFDeg() const; |
---|
| 134 | |
---|
| 135 | // computes pLDeg |
---|
| 136 | KINLINE long pLDeg(); |
---|
| 137 | // sets length, FDeg, returns LDeg |
---|
| 138 | KINLINE long SetDegStuffReturnLDeg(); |
---|
| 139 | |
---|
| 140 | // arithmetic |
---|
| 141 | KINLINE void Mult_nn(number n); |
---|
| 142 | KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin, |
---|
| 143 | pShallowCopyDeleteProc p_shallow_copy_delete, |
---|
| 144 | BOOLEAN set_max = TRUE); |
---|
| 145 | // manipulations |
---|
| 146 | KINLINE void pNorm(); |
---|
| 147 | KINLINE void pCleardenom(); |
---|
| 148 | |
---|
| 149 | #ifdef KDEBUG |
---|
| 150 | void wrp(); |
---|
| 151 | #endif |
---|
| 152 | }; |
---|
| 153 | |
---|
[2d9e1e] | 154 | #ifndef NDEBUG |
---|
| 155 | extern int strat_nr; |
---|
| 156 | extern int strat_fac_debug; |
---|
| 157 | #endif |
---|
| 158 | |
---|
[35aab3] | 159 | class sLObject : public sTObject |
---|
| 160 | { |
---|
| 161 | |
---|
| 162 | public: |
---|
| 163 | unsigned long sev; |
---|
| 164 | poly p1,p2; /*- the pair p comes from -*/ |
---|
| 165 | |
---|
| 166 | poly lcm; /*- the lcm of p1,p2 -*/ |
---|
| 167 | poly last; // pLast(p) during reductions |
---|
| 168 | kBucket_pt bucket; |
---|
| 169 | int i_r1, i_r2; |
---|
| 170 | |
---|
| 171 | // initialization |
---|
| 172 | KINLINE void Init(ring tailRing = currRing); |
---|
| 173 | KINLINE sLObject(ring tailRing = currRing); |
---|
| 174 | KINLINE sLObject(poly p, ring tailRing = currRing); |
---|
| 175 | KINLINE sLObject(poly p, ring c_r, ring tailRing); |
---|
| 176 | |
---|
| 177 | // Frees the polys of L |
---|
| 178 | KINLINE void Delete(); |
---|
| 179 | KINLINE void Clear(); |
---|
| 180 | |
---|
| 181 | // Iterations |
---|
| 182 | KINLINE void LmDeleteAndIter(); |
---|
| 183 | KINLINE poly LmExtractAndIter(); |
---|
| 184 | |
---|
| 185 | // spoly related things |
---|
| 186 | // preparation for reduction if not spoly |
---|
| 187 | KINLINE void PrepareRed(BOOLEAN use_bucket); |
---|
| 188 | KINLINE void SetLmTail(poly lm, poly new_p, int length, |
---|
| 189 | int use_bucket, ring r, poly last); |
---|
| 190 | KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether); |
---|
| 191 | KINLINE void Tail_Mult_nn(number n); |
---|
| 192 | // deletes bucket, makes sure that p and t_p exists |
---|
| 193 | KINLINE poly GetP(omBin lmBin = NULL); |
---|
| 194 | // similar, except that only t_p exists |
---|
| 195 | KINLINE poly GetTP(); |
---|
| 196 | |
---|
| 197 | // does not delete bucket, just canonicalizes it |
---|
| 198 | // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing |
---|
| 199 | KINLINE poly CanonicalizeP(); |
---|
| 200 | |
---|
| 201 | // makes a copy of the poly of L |
---|
| 202 | KINLINE void Copy(); |
---|
| 203 | // gets the poly and makes a copy of it |
---|
| 204 | KINLINE poly CopyGetP(); |
---|
| 205 | |
---|
| 206 | KINLINE int GetpLength(); |
---|
| 207 | KINLINE long pLDeg(BOOLEAN use_last); |
---|
| 208 | KINLINE long pLDeg(); |
---|
| 209 | KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE); |
---|
| 210 | KINLINE long SetDegStuffReturnLDeg(); |
---|
| 211 | KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last); |
---|
| 212 | |
---|
| 213 | // returns minimal component of p |
---|
| 214 | KINLINE long MinComp(); |
---|
| 215 | // returns component of p |
---|
| 216 | KINLINE long Comp(); |
---|
| 217 | |
---|
| 218 | KINLINE void ShallowCopyDelete(ring new_tailRing, |
---|
| 219 | pShallowCopyDeleteProc p_shallow_copy_delete); |
---|
| 220 | |
---|
| 221 | // sets sev |
---|
| 222 | KINLINE void SetShortExpVector(); |
---|
| 223 | |
---|
| 224 | // enable assignment from TObject |
---|
| 225 | KINLINE sLObject& operator=(const sTObject&); |
---|
| 226 | |
---|
| 227 | // get T's corresponding to p1, p2: they might return NULL |
---|
| 228 | KINLINE TObject* T_1(const skStrategy* strat); |
---|
| 229 | KINLINE TObject* T_2(const skStrategy* strat); |
---|
| 230 | KINLINE void T_1_2(const skStrategy* strat, |
---|
| 231 | TObject* &T_1, TObject* &T_2); |
---|
[88f583] | 232 | |
---|
| 233 | // simplify coefficients |
---|
| 234 | KINLINE void Normalize(); |
---|
| 235 | KINLINE void HeadNormalize(); |
---|
[35aab3] | 236 | }; |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | extern int HCord; |
---|
| 240 | |
---|
| 241 | class skStrategy; |
---|
| 242 | typedef skStrategy * kStrategy; |
---|
| 243 | class skStrategy |
---|
| 244 | { |
---|
| 245 | public: |
---|
| 246 | kStrategy next; |
---|
| 247 | int (*red)(LObject * L,kStrategy strat); |
---|
| 248 | void (*initEcart)(LObject * L); |
---|
| 249 | int (*posInT)(const TSet T,const int tl,LObject &h); |
---|
| 250 | int (*posInL)(const LSet set, const int length, |
---|
| 251 | LObject* L,const kStrategy strat); |
---|
[b130fb] | 252 | void (*enterS)(LObject h, int pos,kStrategy strat, int atR/* =-1*/ ); |
---|
[35aab3] | 253 | void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG); |
---|
| 254 | int (*posInLOld)(const LSet Ls,const int Ll, |
---|
| 255 | LObject* Lo,const kStrategy strat); |
---|
| 256 | pFDegProc pOrigFDeg; |
---|
| 257 | pLDegProc pOrigLDeg; |
---|
| 258 | pFDegProc pOrigFDeg_TailRing; |
---|
| 259 | pLDegProc pOrigLDeg_TailRing; |
---|
| 260 | |
---|
| 261 | LObject P; |
---|
| 262 | ideal Shdl; |
---|
| 263 | ideal D; /*V(S) is in D(D)*/ |
---|
| 264 | ideal M; /*set of minimal generators*/ |
---|
| 265 | polyset S; |
---|
| 266 | intset ecartS; |
---|
| 267 | intset lenS; |
---|
[fe5ad5] | 268 | wlen_set lenSw; /* for tgb.ccc */ |
---|
[35aab3] | 269 | intset fromQ; |
---|
| 270 | unsigned long* sevS; |
---|
| 271 | unsigned long* sevT; |
---|
| 272 | TSet T; |
---|
| 273 | LSet L; |
---|
| 274 | LSet B; |
---|
| 275 | poly kHEdge; |
---|
| 276 | poly kNoether; |
---|
| 277 | poly t_kHEdge; // same polys in tailring |
---|
| 278 | KINLINE poly kNoetherTail(); |
---|
| 279 | poly t_kNoether; |
---|
| 280 | BOOLEAN * NotUsedAxis; |
---|
[660ed3] | 281 | BOOLEAN * pairtest;/*used for enterOnePair*/ |
---|
[35aab3] | 282 | poly tail; |
---|
| 283 | leftv kIdeal; |
---|
| 284 | intvec * kModW; |
---|
| 285 | intvec * kHomW; |
---|
| 286 | // procedure for ShalloCopy from tailRing to currRing |
---|
| 287 | pShallowCopyDeleteProc p_shallow_copy_delete; |
---|
| 288 | // pointers to Tobjects R[i] is ith Tobject which is generated |
---|
| 289 | TObject** R; |
---|
| 290 | // S_2_R[i] yields Tobject which corresponds to S[i] |
---|
| 291 | int* S_2_R; |
---|
| 292 | ring tailRing; |
---|
| 293 | omBin lmBin; |
---|
| 294 | omBin tailBin; |
---|
[2d9e1e] | 295 | #ifndef NDEBUG |
---|
| 296 | int nr; |
---|
| 297 | #endif |
---|
[35aab3] | 298 | int cp,c3; |
---|
| 299 | int sl,mu; |
---|
| 300 | int tl,tmax; |
---|
| 301 | int Ll,Lmax; |
---|
| 302 | int Bl,Bmax; |
---|
| 303 | int ak,LazyDegree,LazyPass; |
---|
| 304 | int syzComp; |
---|
| 305 | int HCord; |
---|
| 306 | int lastAxis; |
---|
| 307 | int newIdeal; |
---|
| 308 | int minim; |
---|
| 309 | BOOLEAN interpt; |
---|
| 310 | BOOLEAN homog; |
---|
| 311 | BOOLEAN kHEdgeFound; |
---|
| 312 | BOOLEAN honey,sugarCrit; |
---|
| 313 | BOOLEAN Gebauer,noTailReduction; |
---|
| 314 | BOOLEAN fromT; |
---|
| 315 | BOOLEAN noetherSet; |
---|
| 316 | BOOLEAN update; |
---|
| 317 | BOOLEAN posInLOldFlag; |
---|
| 318 | BOOLEAN use_buckets; |
---|
| 319 | BOOLEAN interred_flag; |
---|
| 320 | // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength) |
---|
| 321 | BOOLEAN LDegLast; |
---|
| 322 | // if set, then L.length == L.pLength |
---|
| 323 | BOOLEAN length_pLength; |
---|
| 324 | // if set, then posInL does not depend on L.length |
---|
| 325 | BOOLEAN posInLDependsOnLength; |
---|
| 326 | /*FALSE, if posInL == posInL10*/ |
---|
| 327 | char redTailChange; |
---|
| 328 | char news; |
---|
| 329 | char newt;/*used for messageSets*/ |
---|
[660ed3] | 330 | char noClearS; |
---|
[35aab3] | 331 | |
---|
| 332 | skStrategy(); |
---|
| 333 | ~skStrategy(); |
---|
| 334 | |
---|
| 335 | // return TObject corresponding to S[i]: assume that it exists |
---|
| 336 | // i.e. no error checking is done |
---|
| 337 | KINLINE TObject* S_2_T(int i); |
---|
| 338 | // like S_2_T, except that NULL is returned if it can not be found |
---|
| 339 | KINLINE TObject* s_2_t(int i); |
---|
| 340 | }; |
---|
| 341 | |
---|
| 342 | void deleteHC(poly *p, int *e, int *l, kStrategy strat); |
---|
| 343 | void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE); |
---|
| 344 | void deleteInS (int i,kStrategy strat); |
---|
| 345 | void cleanT (kStrategy strat); |
---|
[ad07b8] | 346 | static inline LSet initL () |
---|
| 347 | { return (LSet)omAlloc(setmaxL*sizeof(LObject)); }; |
---|
[35aab3] | 348 | void deleteInL(LSet set, int *length, int j,kStrategy strat); |
---|
| 349 | void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at); |
---|
| 350 | void enterSBba (LObject p,int atS,kStrategy strat, int atR = -1); |
---|
| 351 | void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG); |
---|
| 352 | void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG); |
---|
| 353 | int posInS (kStrategy strat,int length,poly p, int ecart_p); |
---|
| 354 | int posInT0 (const TSet set,const int length,LObject &p); |
---|
| 355 | int posInT1 (const TSet set,const int length,LObject &p); |
---|
| 356 | int posInT2 (const TSet set,const int length,LObject &p); |
---|
| 357 | int posInT11 (const TSet set,const int length,LObject &p); |
---|
| 358 | int posInT110 (const TSet set,const int length,LObject &p); |
---|
| 359 | int posInT13 (const TSet set,const int length,LObject &p); |
---|
| 360 | int posInT15 (const TSet set,const int length,LObject &p); |
---|
| 361 | int posInT17 (const TSet set,const int length,LObject &p); |
---|
| 362 | int posInT19 (const TSet set,const int length,LObject &p); |
---|
| 363 | int posInT_EcartpLength(const TSet set,const int length,LObject &p); |
---|
| 364 | |
---|
| 365 | #ifdef HAVE_MORE_POS_IN_T |
---|
| 366 | int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p); |
---|
| 367 | int posInT_FDegpLength(const TSet set,const int length,LObject &p); |
---|
| 368 | int posInT_pLength(const TSet set,const int length,LObject &p); |
---|
| 369 | #endif |
---|
| 370 | |
---|
| 371 | |
---|
| 372 | void reorderS (int* suc,kStrategy strat); |
---|
| 373 | int posInL0 (const LSet set, const int length, |
---|
| 374 | LObject* L,const kStrategy strat); |
---|
| 375 | int posInL11 (const LSet set, const int length, |
---|
| 376 | LObject* L,const kStrategy strat); |
---|
| 377 | int posInL13 (const LSet set, const int length, |
---|
| 378 | LObject* L,const kStrategy strat); |
---|
| 379 | int posInL15 (const LSet set, const int length, |
---|
| 380 | LObject* L,const kStrategy strat); |
---|
| 381 | int posInL17 (const LSet set, const int length, |
---|
| 382 | LObject* L,const kStrategy strat); |
---|
| 383 | int posInL10 (const LSet set, const int length, |
---|
| 384 | LObject* L,const kStrategy strat); |
---|
| 385 | KINLINE poly redtailBba (poly p,int pos,kStrategy strat); |
---|
| 386 | poly redtailBba (LObject *L, int pos,kStrategy strat, BOOLEAN withT = FALSE); |
---|
| 387 | poly redtailBba (TObject *T, int pos,kStrategy strat, BOOLEAN withT = FALSE); |
---|
| 388 | poly redtail (poly p,int pos,kStrategy strat); |
---|
| 389 | poly redtail (LObject *L,int pos,kStrategy strat); |
---|
| 390 | poly redNF (poly h,kStrategy strat); |
---|
| 391 | int redNF0 (LObject *P,kStrategy strat); |
---|
| 392 | poly redNFTail (poly h,const int sl,kStrategy strat); |
---|
| 393 | int redHoney (LObject* h, kStrategy strat); |
---|
[585bbcb] | 394 | #ifdef HAVE_RING2TOM |
---|
| 395 | int redRing2toM (LObject* h,kStrategy strat); |
---|
[a725dae] | 396 | long twoPow(long arg); |
---|
[f92547] | 397 | void enterExtendedSpoly(poly h,kStrategy strat); |
---|
| 398 | void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1); |
---|
[585bbcb] | 399 | #endif |
---|
[35aab3] | 400 | int redLazy (LObject* h,kStrategy strat); |
---|
| 401 | int redHomog (LObject* h,kStrategy strat); |
---|
| 402 | void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1); |
---|
| 403 | void entersets (LObject h); |
---|
| 404 | void pairs (); |
---|
| 405 | void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result); |
---|
| 406 | void messageStat (int srmax,int lrmax,int hilbcount,kStrategy strat); |
---|
| 407 | #ifdef KDEBUG |
---|
| 408 | void messageSets (kStrategy strat); |
---|
| 409 | #else |
---|
| 410 | #define messageSets(s) ((void) 0) |
---|
| 411 | #endif |
---|
| 412 | |
---|
| 413 | void initEcartNormal (LObject* h); |
---|
| 414 | void initEcartBBA (LObject* h); |
---|
| 415 | void initS (ideal F, ideal Q,kStrategy strat); |
---|
| 416 | void initSL (ideal F, ideal Q,kStrategy strat); |
---|
| 417 | void updateS(BOOLEAN toT,kStrategy strat); |
---|
| 418 | void enterT (LObject p,kStrategy strat, int atT = -1); |
---|
| 419 | void cancelunit (LObject* p); |
---|
| 420 | void HEckeTest (poly pp,kStrategy strat); |
---|
| 421 | void initBuchMoraCrit(kStrategy strat); |
---|
| 422 | void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat); |
---|
| 423 | void initBuchMoraPos(kStrategy strat); |
---|
| 424 | void initBuchMora (ideal F, ideal Q,kStrategy strat); |
---|
| 425 | void exitBuchMora (kStrategy strat); |
---|
| 426 | void updateResult(ideal r,ideal Q,kStrategy strat); |
---|
| 427 | void completeReduce (kStrategy strat); |
---|
| 428 | void kFreeStrat(kStrategy strat); |
---|
| 429 | BOOLEAN homogTest(polyset F, int Fmax); |
---|
| 430 | BOOLEAN newHEdge(polyset S, kStrategy strat); |
---|
| 431 | // returns index of p in TSet, or -1 if not found |
---|
| 432 | int kFindInT(poly p, TSet T, int tlength); |
---|
| 433 | |
---|
| 434 | // return -1 if no divisor is found |
---|
| 435 | // number of first divisor, otherwise |
---|
| 436 | int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT, |
---|
| 437 | const int tl, const LObject* L, const int start=0); |
---|
| 438 | // same with S |
---|
| 439 | int kFindDivisibleByInS(const polyset &S, const unsigned long* sev, |
---|
| 440 | const int sl, LObject* L); |
---|
| 441 | |
---|
| 442 | TObject* |
---|
| 443 | kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, |
---|
| 444 | long ecart = LONG_MAX); |
---|
| 445 | |
---|
[cea6f3] | 446 | /*Obsolete since changes to pLmDiv |
---|
[585bbcb] | 447 | #ifdef HAVE_RING2TOM |
---|
| 448 | // same for rings |
---|
| 449 | int kRingFindDivisibleByInT(const TSet &T, const unsigned long* sevT, |
---|
| 450 | const int tl, const LObject* L, const int start=0); |
---|
| 451 | int kRingFindDivisibleByInS(const polyset &S, const unsigned long* sev, |
---|
| 452 | const int sl, LObject* L); |
---|
| 453 | |
---|
| 454 | |
---|
| 455 | TObject* |
---|
| 456 | kRingFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, |
---|
| 457 | long ecart = LONG_MAX); |
---|
| 458 | #endif |
---|
[cea6f3] | 459 | */ |
---|
[35aab3] | 460 | /*************************************************************** |
---|
| 461 | * |
---|
| 462 | * stuff to be inlined |
---|
| 463 | * |
---|
| 464 | ***************************************************************/ |
---|
| 465 | |
---|
| 466 | KINLINE TSet initT (); |
---|
| 467 | KINLINE TObject** initR(); |
---|
| 468 | KINLINE unsigned long* initsevT(); |
---|
| 469 | KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin); |
---|
| 470 | KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin); |
---|
| 471 | KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin); |
---|
| 472 | KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin bin); |
---|
| 473 | |
---|
| 474 | KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing); |
---|
| 475 | KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing); |
---|
| 476 | KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing); |
---|
| 477 | KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing); |
---|
| 478 | |
---|
| 479 | // if exp bound is not violated, return TRUE and |
---|
| 480 | // get m1 = LCM(LM(p1), LM(p2))/LM(p1) |
---|
| 481 | // m2 = LCM(LM(p1), LM(p2))/LM(p2) |
---|
| 482 | // return FALSE and m1 == NULL, m2 == NULL , otherwise |
---|
| 483 | KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, |
---|
| 484 | poly &m1, poly &m2, const ring m_r); |
---|
| 485 | #ifdef KDEBUG |
---|
| 486 | // test strat |
---|
| 487 | BOOLEAN kTest(kStrategy strat); |
---|
| 488 | // test strat, and test that S is contained in T |
---|
| 489 | BOOLEAN kTest_TS(kStrategy strat); |
---|
| 490 | // test LObject |
---|
| 491 | BOOLEAN kTest_L(LObject* L, ring tailRing = NULL, |
---|
| 492 | BOOLEAN testp = FALSE, int lpos = -1, |
---|
| 493 | TSet T = NULL, int tlength = -1); |
---|
| 494 | // test TObject |
---|
| 495 | BOOLEAN kTest_T(TObject* T, ring tailRing = NULL, int tpos = -1, char TN = '?'); |
---|
| 496 | // test set strat->SevS |
---|
| 497 | BOOLEAN kTest_S(kStrategy strat); |
---|
| 498 | #else |
---|
| 499 | #define kTest(A) ((void)0) |
---|
| 500 | #define kTest_TS(A) ((void)0) |
---|
| 501 | #define kTest_T(T) ((void)0) |
---|
| 502 | #define kTest_S(T) ((void)0) |
---|
| 503 | #define kTest_L(T) ((void)0) |
---|
| 504 | #endif |
---|
| 505 | |
---|
| 506 | |
---|
| 507 | /*************************************************************** |
---|
| 508 | * |
---|
| 509 | * From kstd2.cc |
---|
| 510 | * |
---|
| 511 | ***************************************************************/ |
---|
[a6889e] | 512 | poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing); |
---|
[35aab3] | 513 | ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat); |
---|
| 514 | poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce); |
---|
| 515 | ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce); |
---|
| 516 | void initBba(ideal F,kStrategy strat); |
---|
| 517 | |
---|
| 518 | /*************************************************************** |
---|
| 519 | * |
---|
| 520 | * From kSpolys.cc |
---|
| 521 | * |
---|
| 522 | ***************************************************************/ |
---|
| 523 | // Reduces PR with PW |
---|
| 524 | // Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR) |
---|
| 525 | // Changes: PR |
---|
| 526 | // Const: PW |
---|
| 527 | // If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW) |
---|
| 528 | // If strat != NULL, tailRing is changed if reduction would violate exp bound |
---|
| 529 | // of tailRing |
---|
| 530 | // Returns: 0 everything ok, no tailRing change |
---|
| 531 | // 1 tailRing has successfully changed (strat != NULL) |
---|
| 532 | // 2 no reduction performed, tailRing needs to be changed first |
---|
| 533 | // (strat == NULL) |
---|
| 534 | // -1 tailRing change could not be performed due to exceeding exp |
---|
| 535 | // bound of currRing |
---|
| 536 | int ksReducePoly(LObject* PR, |
---|
| 537 | TObject* PW, |
---|
| 538 | poly spNoether = NULL, |
---|
| 539 | number *coef = NULL, |
---|
| 540 | kStrategy strat = NULL); |
---|
| 541 | |
---|
[585bbcb] | 542 | #ifdef HAVE_RING2TOM |
---|
| 543 | // same for rings |
---|
| 544 | int ksRingReducePoly(LObject* PR, |
---|
| 545 | TObject* PW, |
---|
| 546 | poly spNoether = NULL, |
---|
| 547 | number *coef = NULL, |
---|
| 548 | kStrategy strat = NULL); |
---|
| 549 | #endif |
---|
| 550 | |
---|
[35aab3] | 551 | // Reduces PR at Current->next with PW |
---|
| 552 | // Assumes PR != NULL, Current contained in PR |
---|
| 553 | // Current->next != NULL, LM(PW) devides LM(Current->next) |
---|
| 554 | // Changes: PR |
---|
| 555 | // Const: PW |
---|
| 556 | // Return: see ksReducePoly |
---|
| 557 | int ksReducePolyTail(LObject* PR, |
---|
| 558 | TObject* PW, |
---|
| 559 | poly Current, |
---|
| 560 | poly spNoether = NULL); |
---|
| 561 | |
---|
| 562 | KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red); |
---|
| 563 | |
---|
| 564 | // Creates S-Poly of Pair |
---|
| 565 | // Const: Pair->p1, Pair->p2 |
---|
| 566 | // Changes: Pair->p == S-Poly of p1, p2 |
---|
| 567 | // Assume: Pair->p1 != NULL && Pair->p2 |
---|
| 568 | void ksCreateSpoly(LObject* Pair, poly spNoether = NULL, |
---|
| 569 | int use_buckets=0, ring tailRing=currRing, |
---|
| 570 | poly m1 = NULL, poly m2 = NULL, TObject** R = NULL); |
---|
| 571 | |
---|
| 572 | /*2 |
---|
| 573 | * creates the leading term of the S-polynomial of p1 and p2 |
---|
| 574 | * do not destroy p1 and p2 |
---|
| 575 | * remarks: |
---|
| 576 | * 1. the coefficient is 0 (nNew) |
---|
| 577 | * 2. pNext is undefined |
---|
| 578 | */ |
---|
| 579 | poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing); |
---|
| 580 | |
---|
| 581 | |
---|
| 582 | /* |
---|
| 583 | * input - output: a, b |
---|
| 584 | * returns: |
---|
| 585 | * a := a/gcd(a,b), b := b/gcd(a,b) |
---|
| 586 | * and return value |
---|
| 587 | * 0 -> a != 1, b != 1 |
---|
| 588 | * 1 -> a == 1, b != 1 |
---|
| 589 | * 2 -> a != 1, b == 1 |
---|
| 590 | * 3 -> a == 1, b == 1 |
---|
| 591 | * this value is used to control the spolys |
---|
| 592 | */ |
---|
| 593 | int ksCheckCoeff(number *a, number *b); |
---|
| 594 | |
---|
| 595 | // old stuff |
---|
| 596 | KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL); |
---|
| 597 | KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL); |
---|
| 598 | KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing); |
---|
| 599 | KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing); |
---|
| 600 | |
---|
| 601 | /*************************************************************** |
---|
| 602 | * |
---|
| 603 | * Routines related for ring changes during std computations |
---|
| 604 | * |
---|
| 605 | ***************************************************************/ |
---|
| 606 | // return TRUE and set m1, m2 to k_GetLcmTerms, |
---|
| 607 | // if spoly creation of strat->P does not violate |
---|
| 608 | // exponent bound of strat->tailRing |
---|
| 609 | // FALSE, otherwise |
---|
| 610 | BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2); |
---|
| 611 | // change strat->tailRing and adjust all data in strat, L, and T: |
---|
| 612 | // new tailRing has larger exponent bound |
---|
| 613 | // do nothing and return FALSE if exponent bound increase would result in |
---|
| 614 | // larger exponent bound that that of currRing |
---|
| 615 | BOOLEAN kStratChangeTailRing(kStrategy strat, |
---|
| 616 | LObject* L = NULL, TObject* T = NULL, |
---|
| 617 | // take this as new_expbound: if 0 |
---|
| 618 | // new expbound is 2*expbound of tailRing |
---|
| 619 | unsigned long new_expbound = 0); |
---|
| 620 | // initiate a change of the tailRing of strat -- should be called |
---|
| 621 | // right before main loop in bba |
---|
| 622 | void kStratInitChangeTailRing(kStrategy strat); |
---|
| 623 | |
---|
| 624 | #include "kInline.cc" |
---|
| 625 | |
---|
| 626 | |
---|
| 627 | #endif |
---|