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