[35aab3] | 1 | #ifndef KUTIL_H |
---|
| 2 | #define KUTIL_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
| 6 | /* |
---|
| 7 | * ABSTRACT: kernel: utils for kStd |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | #include <string.h> |
---|
| 12 | |
---|
[89f4843] | 13 | #include "omalloc/omalloc.h" |
---|
[db143c] | 14 | #ifdef HAVE_OMALLOC |
---|
[89f4843] | 15 | #include "omalloc/omallocClass.h" |
---|
[474f55c] | 16 | #endif |
---|
[c6e80e] | 17 | |
---|
[e6cdad] | 18 | #include "misc/mylimits.h" |
---|
[c6e80e] | 19 | |
---|
[89f4843] | 20 | #include "kernel/polys.h" |
---|
| 21 | #include "polys/operations/pShallowCopyDelete.h" |
---|
[35aab3] | 22 | |
---|
[89f4843] | 23 | #include "kernel/structs.h" |
---|
| 24 | #include "kernel/GBEngine/kstd1.h" /* for s_poly_proc_t */ |
---|
[c6e80e] | 25 | |
---|
[351415] | 26 | // define if tailrings should be used |
---|
| 27 | #define HAVE_TAIL_RING |
---|
| 28 | |
---|
[f4d581] | 29 | #define setmax 128 |
---|
[425d94c] | 30 | #define setmaxL ((4096-12)/sizeof(LObject)) |
---|
| 31 | #define setmaxLinc ((4096)/sizeof(LObject)) |
---|
[939847] | 32 | |
---|
[61145cc] | 33 | #define setmaxT ((4096-12)/sizeof(TObject)) |
---|
| 34 | #define setmaxTinc ((4096)/sizeof(TObject)) |
---|
[35aab3] | 35 | |
---|
[cee170] | 36 | #define RED_CANONICALIZE 200 |
---|
[45cfb82] | 37 | #define REDNF_CANONICALIZE 60 |
---|
| 38 | #define REDTAIL_CANONICALIZE 100 |
---|
| 39 | |
---|
[228b631] | 40 | // if you want std computations as in Singular version < 2: |
---|
| 41 | // This disables RedThrough, tailReductions against T (bba), |
---|
[35aab3] | 42 | // sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg |
---|
[228b631] | 43 | // NOTE: can be achieved with option(oldStd) |
---|
[35aab3] | 44 | |
---|
| 45 | #undef NO_KINLINE |
---|
| 46 | #if !defined(KDEBUG) && !defined(NO_INLINE) |
---|
| 47 | #define KINLINE inline |
---|
| 48 | #else |
---|
| 49 | #define KINLINE |
---|
| 50 | #define NO_KINLINE 1 |
---|
| 51 | #endif |
---|
| 52 | |
---|
| 53 | typedef int* intset; |
---|
[58ebad] | 54 | typedef int64 wlen_type; |
---|
[fe5ad5] | 55 | typedef wlen_type* wlen_set; |
---|
| 56 | |
---|
[35aab3] | 57 | typedef class sTObject TObject; |
---|
| 58 | typedef class sLObject LObject; |
---|
| 59 | typedef TObject * TSet; |
---|
| 60 | typedef LObject * LSet; |
---|
| 61 | |
---|
[526e40d] | 62 | typedef struct denominator_list_s denominator_list_s; |
---|
| 63 | typedef denominator_list_s *denominator_list; |
---|
| 64 | |
---|
| 65 | struct denominator_list_s{number n; denominator_list next;}; |
---|
[a3f0fea] | 66 | EXTERN_VAR denominator_list DENOMINATOR_LIST; |
---|
[526e40d] | 67 | |
---|
[35aab3] | 68 | class sTObject |
---|
| 69 | { |
---|
| 70 | public: |
---|
[83be980] | 71 | unsigned long sevSig; |
---|
| 72 | poly sig; // the signature of the element |
---|
[35aab3] | 73 | poly p; // Lm(p) \in currRing Tail(p) \in tailRing |
---|
| 74 | poly t_p; // t_p \in tailRing: as monomials Lm(t_p) == Lm(p) |
---|
[4763e2] | 75 | poly max_exp; // p_GetMaxExpP(pNext(p)) |
---|
[ad07b8] | 76 | ring tailRing; |
---|
[35aab3] | 77 | long FDeg; // pFDeg(p) |
---|
| 78 | int ecart, |
---|
[0d1a36] | 79 | length, // as of pLDeg |
---|
[b5a454] | 80 | pLength, // either == 0, or == pLength(p) |
---|
| 81 | i_r; // index of TObject in R set, or -1 if not in T |
---|
[73b084] | 82 | |
---|
| 83 | #ifdef HAVE_SHIFTBBA |
---|
| 84 | int shift; |
---|
| 85 | #endif |
---|
| 86 | |
---|
[721195] | 87 | /*BOOLEAN*/ char is_normalized; // true, if pNorm was called on p, false otherwise |
---|
[83be980] | 88 | // used in incremental sba() with F5C: |
---|
[a9c298] | 89 | // we know some of the redundant elements in |
---|
[83be980] | 90 | // strat->T beforehand, so we can just discard |
---|
| 91 | // them and do not need to consider them in the |
---|
| 92 | // interreduction process |
---|
[721195] | 93 | /*BOOLEAN*/ char is_redundant; |
---|
[83be980] | 94 | // used in sba's sig-safe reduction: |
---|
| 95 | // sometimes we already know that a reducer |
---|
| 96 | // is sig-safe, so no need for a real |
---|
| 97 | // sig-safeness check |
---|
[721195] | 98 | /*BOOLEAN*/ char is_sigsafe; |
---|
[83be980] | 99 | |
---|
[35aab3] | 100 | |
---|
[a9c298] | 101 | #ifdef HAVE_PLURAL |
---|
[721195] | 102 | /*BOOLEAN*/ char is_special; // true, it is a new special S-poly (e.g. for SCA) |
---|
[c656700] | 103 | #endif |
---|
[a9c298] | 104 | |
---|
[35aab3] | 105 | // initialization |
---|
| 106 | KINLINE void Init(ring r = currRing); |
---|
| 107 | KINLINE sTObject(ring tailRing = currRing); |
---|
| 108 | KINLINE sTObject(poly p, ring tailRing = currRing); |
---|
| 109 | KINLINE sTObject(poly p, ring c_r, ring tailRing); |
---|
| 110 | KINLINE sTObject(sTObject* T, int copy); |
---|
| 111 | |
---|
| 112 | KINLINE void Set(ring r=currRing); |
---|
| 113 | KINLINE void Set(poly p_in, ring r=currRing); |
---|
| 114 | KINLINE void Set(poly p_in, ring c_r, ring t_r); |
---|
| 115 | |
---|
| 116 | // Frees the polys of T |
---|
| 117 | KINLINE void Delete(); |
---|
| 118 | // Sets polys to NULL |
---|
| 119 | KINLINE void Clear(); |
---|
| 120 | // makes a copy of the poly of T |
---|
| 121 | KINLINE void Copy(); |
---|
| 122 | |
---|
| 123 | // ring-dependent Lm access: these might result in allocation of monomials |
---|
| 124 | KINLINE poly GetLmCurrRing(); |
---|
| 125 | KINLINE poly GetLmTailRing(); |
---|
| 126 | KINLINE poly GetLm(ring r); |
---|
| 127 | // this returns Lm and ring r (preferably from tailRing), but does not |
---|
| 128 | // allocate a new poly |
---|
| 129 | KINLINE void GetLm(poly &p, ring &r) const; |
---|
[585bbcb] | 130 | |
---|
| 131 | #ifdef OLIVER_PRIVAT_LT |
---|
| 132 | // routines for calc. with rings |
---|
| 133 | KINLINE poly GetLtCurrRing(); |
---|
| 134 | KINLINE poly GetLtTailRing(); |
---|
| 135 | KINLINE poly GetLt(ring r); |
---|
| 136 | KINLINE void GetLt(poly &p, ring &r) const; |
---|
| 137 | #endif |
---|
| 138 | |
---|
[35aab3] | 139 | KINLINE BOOLEAN IsNull() const; |
---|
| 140 | |
---|
| 141 | KINLINE int GetpLength(); |
---|
| 142 | |
---|
| 143 | // makes sure that T.p exists |
---|
| 144 | KINLINE void SetLmCurrRing(); |
---|
| 145 | |
---|
| 146 | // Iterations |
---|
| 147 | // simply get the next monomial |
---|
| 148 | KINLINE poly Next(); |
---|
| 149 | KINLINE void LmDeleteAndIter(); |
---|
| 150 | |
---|
| 151 | // deg stuff |
---|
[d5564f8] | 152 | // compute pTotalDegree |
---|
| 153 | KINLINE long pTotalDeg() const; |
---|
[35aab3] | 154 | // computes pFDeg |
---|
| 155 | KINLINE long pFDeg() const; |
---|
| 156 | // computes and sets FDeg |
---|
| 157 | KINLINE long SetpFDeg(); |
---|
| 158 | // gets stored FDeg |
---|
| 159 | KINLINE long GetpFDeg() const; |
---|
| 160 | |
---|
| 161 | // computes pLDeg |
---|
| 162 | KINLINE long pLDeg(); |
---|
| 163 | // sets length, FDeg, returns LDeg |
---|
| 164 | KINLINE long SetDegStuffReturnLDeg(); |
---|
| 165 | |
---|
| 166 | // arithmetic |
---|
| 167 | KINLINE void Mult_nn(number n); |
---|
| 168 | KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin, |
---|
| 169 | pShallowCopyDeleteProc p_shallow_copy_delete, |
---|
| 170 | BOOLEAN set_max = TRUE); |
---|
| 171 | // manipulations |
---|
| 172 | KINLINE void pNorm(); |
---|
| 173 | KINLINE void pCleardenom(); |
---|
[897be4] | 174 | KINLINE void pContent(); |
---|
[35aab3] | 175 | |
---|
| 176 | #ifdef KDEBUG |
---|
| 177 | void wrp(); |
---|
| 178 | #endif |
---|
| 179 | }; |
---|
| 180 | |
---|
[a3f0fea] | 181 | EXTERN_VAR int strat_nr; |
---|
[2d9e1e] | 182 | |
---|
[35aab3] | 183 | class sLObject : public sTObject |
---|
| 184 | { |
---|
| 185 | |
---|
| 186 | public: |
---|
| 187 | unsigned long sev; |
---|
[f7f346] | 188 | poly p1,p2; /*- the pair p comes from, |
---|
| 189 | lm(pi) in currRing, tail(pi) in tailring -*/ |
---|
| 190 | |
---|
| 191 | poly lcm; /*- the lcm of p1,p2 -*/ |
---|
| 192 | kBucket_pt bucket; |
---|
[b5a454] | 193 | int i_r1, i_r2; |
---|
[f7f346] | 194 | unsigned checked; // this is the index of S up to which |
---|
[83be980] | 195 | // the corresponding LObject was already checked in |
---|
| 196 | // critical pair creation => when entering the |
---|
| 197 | // reduction process it is enough to start a second |
---|
| 198 | // rewritten criterion check from checked+1 onwards |
---|
[a7b37d] | 199 | BOOLEAN prod_crit; |
---|
| 200 | // NOTE: If prod_crit = TRUE then the corresponding pair is |
---|
[5313c0] | 201 | // detected by Buchberger's Product Criterion and can be |
---|
| 202 | // deleted |
---|
[35aab3] | 203 | |
---|
| 204 | // initialization |
---|
| 205 | KINLINE void Init(ring tailRing = currRing); |
---|
| 206 | KINLINE sLObject(ring tailRing = currRing); |
---|
| 207 | KINLINE sLObject(poly p, ring tailRing = currRing); |
---|
| 208 | KINLINE sLObject(poly p, ring c_r, ring tailRing); |
---|
| 209 | |
---|
| 210 | // Frees the polys of L |
---|
| 211 | KINLINE void Delete(); |
---|
| 212 | KINLINE void Clear(); |
---|
| 213 | |
---|
| 214 | // Iterations |
---|
| 215 | KINLINE void LmDeleteAndIter(); |
---|
| 216 | KINLINE poly LmExtractAndIter(); |
---|
| 217 | |
---|
| 218 | // spoly related things |
---|
| 219 | // preparation for reduction if not spoly |
---|
| 220 | KINLINE void PrepareRed(BOOLEAN use_bucket); |
---|
| 221 | KINLINE void SetLmTail(poly lm, poly new_p, int length, |
---|
[f224d85] | 222 | int use_bucket, ring r); |
---|
[0d1a36] | 223 | KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether); |
---|
[35aab3] | 224 | KINLINE void Tail_Mult_nn(number n); |
---|
| 225 | // deletes bucket, makes sure that p and t_p exists |
---|
[39932b] | 226 | KINLINE poly GetP(omBin lmBin = (omBin)NULL); |
---|
[35aab3] | 227 | // similar, except that only t_p exists |
---|
| 228 | KINLINE poly GetTP(); |
---|
| 229 | |
---|
| 230 | // does not delete bucket, just canonicalizes it |
---|
| 231 | // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing |
---|
[7ddfab] | 232 | KINLINE void CanonicalizeP(); |
---|
[35aab3] | 233 | |
---|
| 234 | // makes a copy of the poly of L |
---|
| 235 | KINLINE void Copy(); |
---|
| 236 | |
---|
| 237 | KINLINE int GetpLength(); |
---|
| 238 | KINLINE long pLDeg(BOOLEAN use_last); |
---|
| 239 | KINLINE long pLDeg(); |
---|
| 240 | KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE); |
---|
| 241 | KINLINE long SetDegStuffReturnLDeg(); |
---|
| 242 | KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last); |
---|
| 243 | |
---|
| 244 | // returns minimal component of p |
---|
| 245 | KINLINE long MinComp(); |
---|
| 246 | // returns component of p |
---|
| 247 | KINLINE long Comp(); |
---|
| 248 | |
---|
| 249 | KINLINE void ShallowCopyDelete(ring new_tailRing, |
---|
| 250 | pShallowCopyDeleteProc p_shallow_copy_delete); |
---|
| 251 | |
---|
| 252 | // sets sev |
---|
| 253 | KINLINE void SetShortExpVector(); |
---|
| 254 | |
---|
| 255 | // enable assignment from TObject |
---|
| 256 | KINLINE sLObject& operator=(const sTObject&); |
---|
| 257 | |
---|
| 258 | // get T's corresponding to p1, p2: they might return NULL |
---|
| 259 | KINLINE TObject* T_1(const skStrategy* strat); |
---|
| 260 | KINLINE TObject* T_2(const skStrategy* strat); |
---|
| 261 | KINLINE void T_1_2(const skStrategy* strat, |
---|
| 262 | TObject* &T_1, TObject* &T_2); |
---|
[88f583] | 263 | |
---|
| 264 | // simplify coefficients |
---|
| 265 | KINLINE void Normalize(); |
---|
| 266 | KINLINE void HeadNormalize(); |
---|
[35aab3] | 267 | }; |
---|
| 268 | |
---|
[a3f0fea] | 269 | EXTERN_VAR int HCord; |
---|
[35aab3] | 270 | |
---|
[474f55c] | 271 | class skStrategy |
---|
[6408aa] | 272 | #ifdef HAVE_OMALLOC |
---|
[474f55c] | 273 | : public omallocClass |
---|
| 274 | #endif |
---|
[35aab3] | 275 | { |
---|
| 276 | public: |
---|
| 277 | kStrategy next; |
---|
| 278 | int (*red)(LObject * L,kStrategy strat); |
---|
[83be980] | 279 | int (*red2)(LObject * L,kStrategy strat); |
---|
[f6c77e9] | 280 | void (*initEcart)(TObject * L); |
---|
[35aab3] | 281 | int (*posInT)(const TSet T,const int tl,LObject &h); |
---|
[83be980] | 282 | int (*posInLSba)(const LSet set, const int length, |
---|
| 283 | LObject* L,const kStrategy strat); |
---|
[35aab3] | 284 | int (*posInL)(const LSet set, const int length, |
---|
| 285 | LObject* L,const kStrategy strat); |
---|
[b5a454] | 286 | void (*enterS)(LObject &h, int pos,kStrategy strat, int atR/* =-1*/ ); |
---|
[35aab3] | 287 | void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG); |
---|
| 288 | int (*posInLOld)(const LSet Ls,const int Ll, |
---|
| 289 | LObject* Lo,const kStrategy strat); |
---|
[b5a454] | 290 | void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/); |
---|
[6c55ae] | 291 | void (*chainCrit) (poly p,int ecart,kStrategy strat); |
---|
[83be980] | 292 | BOOLEAN (*syzCrit) (poly sig, unsigned long not_sevSig, kStrategy strat); |
---|
[32f7e5] | 293 | BOOLEAN (*rewCrit1) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/); |
---|
| 294 | BOOLEAN (*rewCrit2) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/); |
---|
| 295 | BOOLEAN (*rewCrit3) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/); |
---|
[35aab3] | 296 | pFDegProc pOrigFDeg; |
---|
| 297 | pLDegProc pOrigLDeg; |
---|
| 298 | pFDegProc pOrigFDeg_TailRing; |
---|
| 299 | pLDegProc pOrigLDeg_TailRing; |
---|
[8204ed] | 300 | s_poly_proc_t s_poly; |
---|
[35aab3] | 301 | |
---|
| 302 | LObject P; |
---|
| 303 | ideal Shdl; |
---|
| 304 | ideal D; /*V(S) is in D(D)*/ |
---|
| 305 | ideal M; /*set of minimal generators*/ |
---|
| 306 | polyset S; |
---|
[83be980] | 307 | polyset syz; |
---|
| 308 | polyset sig; |
---|
[35aab3] | 309 | intset ecartS; |
---|
[83be980] | 310 | intset fromS; // from which S[i] S[j] comes from |
---|
| 311 | // this is important for signature-based |
---|
| 312 | // algorithms |
---|
| 313 | intset syzIdx;// index in the syz array at which the first |
---|
| 314 | // syzygy of component i comes up |
---|
| 315 | // important for signature-based algorithms |
---|
[f7f084] | 316 | unsigned sbaOrder; |
---|
[32ad2a] | 317 | int currIdx; |
---|
[83be980] | 318 | int max_lower_index; |
---|
[35aab3] | 319 | intset lenS; |
---|
[fe5ad5] | 320 | wlen_set lenSw; /* for tgb.ccc */ |
---|
[35aab3] | 321 | intset fromQ; |
---|
| 322 | unsigned long* sevS; |
---|
[83be980] | 323 | unsigned long* sevSyz; |
---|
| 324 | unsigned long* sevSig; |
---|
[35aab3] | 325 | unsigned long* sevT; |
---|
| 326 | TSet T; |
---|
| 327 | LSet L; |
---|
| 328 | LSet B; |
---|
| 329 | poly kNoether; |
---|
[572022] | 330 | poly t_kNoether; // same polys in tailring |
---|
[35aab3] | 331 | KINLINE poly kNoetherTail(); |
---|
| 332 | BOOLEAN * NotUsedAxis; |
---|
[660ed3] | 333 | BOOLEAN * pairtest;/*used for enterOnePair*/ |
---|
[35aab3] | 334 | poly tail; |
---|
| 335 | intvec * kModW; |
---|
| 336 | intvec * kHomW; |
---|
| 337 | // procedure for ShalloCopy from tailRing to currRing |
---|
| 338 | pShallowCopyDeleteProc p_shallow_copy_delete; |
---|
[b5a454] | 339 | // pointers to Tobjects R[i] is ith Tobject which is generated |
---|
| 340 | TObject** R; |
---|
| 341 | // S_2_R[i] yields Tobject which corresponds to S[i] |
---|
| 342 | int* S_2_R; |
---|
[35aab3] | 343 | ring tailRing; |
---|
| 344 | omBin lmBin; |
---|
| 345 | omBin tailBin; |
---|
[2d9e1e] | 346 | int nr; |
---|
[35aab3] | 347 | int cp,c3; |
---|
| 348 | int sl,mu; |
---|
[83be980] | 349 | int syzl,syzmax,syzidxmax; |
---|
[35aab3] | 350 | int tl,tmax; |
---|
| 351 | int Ll,Lmax; |
---|
| 352 | int Bl,Bmax; |
---|
| 353 | int ak,LazyDegree,LazyPass; |
---|
| 354 | int syzComp; |
---|
| 355 | int lastAxis; |
---|
| 356 | int newIdeal; |
---|
| 357 | int minim; |
---|
[094031] | 358 | #ifdef HAVE_RINGS |
---|
| 359 | bool sigdrop; //This is used to check sigdrop in sba over Z |
---|
| 360 | int nrsyzcrit; // counts how many pairs are deleted by SyzCrit |
---|
[11416e] | 361 | int nrrewcrit; // counts how many pairs are deleted by FaugereRewCrit |
---|
[780c1b] | 362 | int sbaEnterS; // sba over Z strategy: if sigdrop element has _*gen(sbaEnterS+1), then |
---|
[094031] | 363 | // add directly sbaEnterS elements into S |
---|
[7d2b89] | 364 | int blockred; // counter for blocked reductions in redSig |
---|
| 365 | int blockredmax; |
---|
[094031] | 366 | #endif |
---|
[63b728c] | 367 | #ifdef HAVE_SHIFTBBA |
---|
[ca0d3b5] | 368 | int cv; // in shift bases: counting V criterion |
---|
[b95a5f] | 369 | /*BOOLEAN*/ char rightGB; |
---|
[63b728c] | 370 | #endif |
---|
[721195] | 371 | /*BOOLEAN*/ char interpt; |
---|
| 372 | /*BOOLEAN*/ char homog; |
---|
[aef1b86] | 373 | #ifdef HAVE_PLURAL |
---|
[721195] | 374 | /*BOOLEAN*/ char z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases! |
---|
[aef1b86] | 375 | #endif |
---|
[a33602] | 376 | /*BOOLEAN*/ char kAllAxis; // all axis are used -> (re)compute noether |
---|
[721195] | 377 | /*BOOLEAN*/ char honey,sugarCrit; |
---|
| 378 | /*BOOLEAN*/ char Gebauer,noTailReduction; |
---|
| 379 | /*BOOLEAN*/ char fromT; |
---|
| 380 | /*BOOLEAN*/ char noetherSet; |
---|
| 381 | /*BOOLEAN*/ char update; |
---|
| 382 | /*BOOLEAN*/ char posInLOldFlag; |
---|
| 383 | /*BOOLEAN*/ char use_buckets; |
---|
[35aab3] | 384 | // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength) |
---|
[721195] | 385 | /*BOOLEAN*/ char LDegLast; |
---|
[35aab3] | 386 | // if set, then L.length == L.pLength |
---|
[721195] | 387 | /*BOOLEAN*/ char length_pLength; |
---|
[35aab3] | 388 | // if set, then posInL does not depend on L.length |
---|
[721195] | 389 | /*BOOLEAN*/ char posInLDependsOnLength; |
---|
[35aab3] | 390 | /*FALSE, if posInL == posInL10*/ |
---|
[a794e7] | 391 | #ifdef HAVE_PLURAL |
---|
[cce4a2f] | 392 | // set this flag to 1 to stop the product criteria |
---|
| 393 | // use ALLOW_PROD_CRIT(strat) to test |
---|
[721195] | 394 | /*BOOLEAN*/ char no_prod_crit; |
---|
[cce4a2f] | 395 | #define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit) |
---|
[a794e7] | 396 | #else |
---|
[cce4a2f] | 397 | #define ALLOW_PROD_CRIT(A) (1) |
---|
[a794e7] | 398 | #endif |
---|
[35aab3] | 399 | char redTailChange; |
---|
| 400 | char news; |
---|
| 401 | char newt;/*used for messageSets*/ |
---|
[660ed3] | 402 | char noClearS; |
---|
[b57694] | 403 | char completeReduce_retry; |
---|
[d5564f8] | 404 | char overflow; |
---|
[35aab3] | 405 | |
---|
| 406 | skStrategy(); |
---|
| 407 | ~skStrategy(); |
---|
| 408 | |
---|
| 409 | // return TObject corresponding to S[i]: assume that it exists |
---|
| 410 | // i.e. no error checking is done |
---|
| 411 | KINLINE TObject* S_2_T(int i); |
---|
| 412 | // like S_2_T, except that NULL is returned if it can not be found |
---|
| 413 | KINLINE TObject* s_2_t(int i); |
---|
| 414 | }; |
---|
| 415 | |
---|
| 416 | void deleteHC(poly *p, int *e, int *l, kStrategy strat); |
---|
| 417 | void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE); |
---|
| 418 | void deleteInS (int i,kStrategy strat); |
---|
[83be980] | 419 | void deleteInSSba (int i,kStrategy strat); |
---|
[35aab3] | 420 | void cleanT (kStrategy strat); |
---|
[e259fe] | 421 | static inline LSet initL (int nr=setmaxL) |
---|
[27fc50] | 422 | { return (LSet)omAlloc(nr*sizeof(LObject)); } |
---|
[35aab3] | 423 | void deleteInL(LSet set, int *length, int j,kStrategy strat); |
---|
| 424 | void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at); |
---|
[b5a454] | 425 | void enterSBba (LObject &p,int atS,kStrategy strat, int atR = -1); |
---|
| 426 | void enterSBbaShift (LObject &p,int atS,kStrategy strat, int atR = -1); |
---|
| 427 | void enterSSba (LObject &p,int atS,kStrategy strat, int atR = -1); |
---|
[35aab3] | 428 | void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG); |
---|
| 429 | void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG); |
---|
[a9c298] | 430 | int posInS (const kStrategy strat, const int length, const poly p, |
---|
[391323] | 431 | const int ecart_p); |
---|
[9d19c1] | 432 | int posInSMonFirst (const kStrategy strat, const int length, const poly p); |
---|
[e07fa9] | 433 | int posInIdealMonFirst (const ideal F, const poly p,int start = 0,int end = -1); |
---|
[35aab3] | 434 | int posInT0 (const TSet set,const int length,LObject &p); |
---|
| 435 | int posInT1 (const TSet set,const int length,LObject &p); |
---|
| 436 | int posInT2 (const TSet set,const int length,LObject &p); |
---|
| 437 | int posInT11 (const TSet set,const int length,LObject &p); |
---|
[83be980] | 438 | int posInTSig (const TSet set,const int length,LObject &p); |
---|
[35aab3] | 439 | int posInT110 (const TSet set,const int length,LObject &p); |
---|
| 440 | int posInT13 (const TSet set,const int length,LObject &p); |
---|
| 441 | int posInT15 (const TSet set,const int length,LObject &p); |
---|
| 442 | int posInT17 (const TSet set,const int length,LObject &p); |
---|
[a35d3d7] | 443 | int posInT17_c (const TSet set,const int length,LObject &p); |
---|
[35aab3] | 444 | int posInT19 (const TSet set,const int length,LObject &p); |
---|
| 445 | int posInT_EcartpLength(const TSet set,const int length,LObject &p); |
---|
[a35d3d7] | 446 | int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p); |
---|
| 447 | int posInT_FDegpLength(const TSet set,const int length,LObject &p); |
---|
| 448 | int posInT_pLength(const TSet set,const int length,LObject &p); |
---|
[35aab3] | 449 | |
---|
| 450 | #ifdef HAVE_MORE_POS_IN_T |
---|
| 451 | int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p); |
---|
| 452 | int posInT_FDegpLength(const TSet set,const int length,LObject &p); |
---|
| 453 | int posInT_pLength(const TSet set,const int length,LObject &p); |
---|
| 454 | #endif |
---|
| 455 | |
---|
| 456 | |
---|
| 457 | void reorderS (int* suc,kStrategy strat); |
---|
[83be980] | 458 | int posInLF5C (const LSet set, const int length, |
---|
| 459 | LObject* L,const kStrategy strat); |
---|
| 460 | int posInLSig (const LSet set, const int length, |
---|
| 461 | LObject* L,const kStrategy strat); |
---|
[11416e] | 462 | int posInLSigRing (const LSet set, const int length, |
---|
| 463 | LObject* L,const kStrategy strat); |
---|
[a469814] | 464 | int posInLRing (const LSet set, const int length, |
---|
| 465 | LObject* L,const kStrategy strat); |
---|
[32f7e5] | 466 | int posInSyz (const kStrategy strat, const poly sig); |
---|
[35aab3] | 467 | int posInL0 (const LSet set, const int length, |
---|
| 468 | LObject* L,const kStrategy strat); |
---|
| 469 | int posInL11 (const LSet set, const int length, |
---|
| 470 | LObject* L,const kStrategy strat); |
---|
[a469814] | 471 | int posInL11Ring (const LSet set, const int length, |
---|
| 472 | LObject* L,const kStrategy strat); |
---|
[a63783] | 473 | int posInLF5CRing (const LSet set, int start , const int length, |
---|
| 474 | LObject* L,const kStrategy strat); |
---|
[d5a149] | 475 | int posInL11Ringls (const LSet set, const int length, |
---|
| 476 | LObject* L,const kStrategy strat); |
---|
[35aab3] | 477 | int posInL13 (const LSet set, const int length, |
---|
| 478 | LObject* L,const kStrategy strat); |
---|
| 479 | int posInL15 (const LSet set, const int length, |
---|
| 480 | LObject* L,const kStrategy strat); |
---|
[5efbf9] | 481 | int posInL15Ring (const LSet set, const int length, |
---|
| 482 | LObject* L,const kStrategy strat); |
---|
[35aab3] | 483 | int posInL17 (const LSet set, const int length, |
---|
| 484 | LObject* L,const kStrategy strat); |
---|
| 485 | int posInL10 (const LSet set, const int length, |
---|
| 486 | LObject* L,const kStrategy strat); |
---|
[5efbf9] | 487 | int posInL10Ring (const LSet set, const int length, |
---|
| 488 | LObject* L,const kStrategy strat); |
---|
[830ef8] | 489 | int posInL110 (const LSet set, const int length, |
---|
| 490 | LObject* L,const kStrategy strat); |
---|
[eeb59b7] | 491 | KINLINE poly redtailBba (poly p,int end_pos,kStrategy strat,BOOLEAN normalize=FALSE); |
---|
| 492 | KINLINE poly redtailBbaBound (poly p,int end_pos,kStrategy strat,int bound,BOOLEAN normalize=FALSE); |
---|
[5eb865] | 493 | #ifdef HAVE_RINGS |
---|
[4c0fd3] | 494 | KINLINE poly redtailBba_Ring (poly p,int end_pos,kStrategy strat); |
---|
[eeb59b7] | 495 | KINLINE poly redtailBba_Z (poly p,int end_pos,kStrategy strat); |
---|
[4c0fd3] | 496 | poly redtailBba_Ring (LObject* L, int end_pos, kStrategy strat ); |
---|
[eeb59b7] | 497 | poly redtailBba_Z (LObject* L, int end_pos, kStrategy strat ); |
---|
[3b1ebb] | 498 | void redtailBbaAlsoLC_Z (LObject* L, int end_pos, kStrategy strat ); |
---|
[5eb865] | 499 | #endif |
---|
[eeb59b7] | 500 | poly redtailBba (LObject *L, int end_pos,kStrategy strat, |
---|
[015bba] | 501 | BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE); |
---|
[eeb59b7] | 502 | poly redtailBbaBound (LObject *L, int end_pos,kStrategy strat,int bound, |
---|
[c2ef83] | 503 | BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE); |
---|
[eeb59b7] | 504 | poly redtailSba (LObject *L, int end_pos,kStrategy strat, |
---|
[b085fba] | 505 | BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE); |
---|
[eeb59b7] | 506 | poly redtailBba (TObject *T, int end_pos,kStrategy strat); |
---|
| 507 | poly redtail (poly p,int end_pos,kStrategy strat); |
---|
| 508 | poly redtail (LObject *L,int end_pos,kStrategy strat); |
---|
[ab1c36] | 509 | poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat); |
---|
[35aab3] | 510 | int redNF0 (LObject *P,kStrategy strat); |
---|
| 511 | poly redNFTail (poly h,const int sl,kStrategy strat); |
---|
| 512 | int redHoney (LObject* h, kStrategy strat); |
---|
[e12a8a] | 513 | int redHoneyM (LObject* h, kStrategy strat); |
---|
[9f5bec] | 514 | int redLiftstd (LObject* h, kStrategy strat); |
---|
[206e158] | 515 | #ifdef HAVE_RINGS |
---|
[093f30e] | 516 | int redRing (LObject* h,kStrategy strat); |
---|
[ff4c0c1] | 517 | int redRing_Z (LObject* h,kStrategy strat); |
---|
[c25b56c] | 518 | int redRiloc (LObject* h,kStrategy strat); |
---|
[f92547] | 519 | void enterExtendedSpoly(poly h,kStrategy strat); |
---|
[1798a0] | 520 | void enterExtendedSpolySig(poly h,poly hSig,kStrategy strat); |
---|
[b5a454] | 521 | void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1); |
---|
| 522 | void superenterpairsSig (poly h,poly hSig,int hFrom,int k,int ecart,int pos,kStrategy strat, int atR = -1); |
---|
[585bbcb] | 523 | #endif |
---|
[35aab3] | 524 | int redLazy (LObject* h,kStrategy strat); |
---|
| 525 | int redHomog (LObject* h,kStrategy strat); |
---|
[83be980] | 526 | int redSig (LObject* h,kStrategy strat); |
---|
[e40da9f] | 527 | int redSigRing (LObject* h,kStrategy strat); |
---|
[83be980] | 528 | //adds hSig to be able to check with F5's criteria when entering pairs! |
---|
[b5a454] | 529 | void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos,kStrategy strat, int atR = -1); |
---|
| 530 | void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1); |
---|
[35aab3] | 531 | void entersets (LObject h); |
---|
| 532 | void pairs (); |
---|
[459ec94] | 533 | BOOLEAN sbaCheckGcdPair (LObject* h,kStrategy strat); |
---|
[35aab3] | 534 | void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result); |
---|
[930ea8] | 535 | void messageStat (int hilbcount,kStrategy strat); |
---|
[11416e] | 536 | void messageStatSBA (int hilbcount,kStrategy strat); |
---|
[35aab3] | 537 | #ifdef KDEBUG |
---|
| 538 | void messageSets (kStrategy strat); |
---|
| 539 | #else |
---|
[d101b1] | 540 | #define messageSets(s) do {} while (0) |
---|
[35aab3] | 541 | #endif |
---|
| 542 | |
---|
[f6c77e9] | 543 | void initEcartNormal (TObject* h); |
---|
| 544 | void initEcartBBA (TObject* h); |
---|
[35aab3] | 545 | void initS (ideal F, ideal Q,kStrategy strat); |
---|
| 546 | void initSL (ideal F, ideal Q,kStrategy strat); |
---|
[83be980] | 547 | void initSLSba (ideal F, ideal Q,kStrategy strat); |
---|
| 548 | /************************************************* |
---|
[a9c298] | 549 | * when initializing a new bunch of principal |
---|
[83be980] | 550 | * syzygies at the beginning of a new iteration |
---|
[a9c298] | 551 | * step in a signature-based algorithm we |
---|
[83be980] | 552 | * compute ONLY the leading elements of those |
---|
| 553 | * syzygies, NOT the whole syzygy |
---|
| 554 | * NOTE: this needs to be adjusted for a more |
---|
| 555 | * general approach on signature-based algorithms |
---|
| 556 | ***********************************************/ |
---|
| 557 | void initSyzRules (kStrategy strat); |
---|
[35aab3] | 558 | void updateS(BOOLEAN toT,kStrategy strat); |
---|
[aa353e] | 559 | void enterSyz (LObject &p,kStrategy strat, int atT); |
---|
| 560 | void enterT (LObject &p,kStrategy strat, int atT = -1); |
---|
[ab6ae3] | 561 | void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat); |
---|
[e21795] | 562 | #ifdef HAVE_RINGS |
---|
[8a14df] | 563 | void enterT_strong (LObject &p,kStrategy strat, int atT = -1); |
---|
[e21795] | 564 | #endif |
---|
[5572c1] | 565 | void cancelunit (LObject* p,BOOLEAN inNF=FALSE); |
---|
[35aab3] | 566 | void HEckeTest (poly pp,kStrategy strat); |
---|
| 567 | void initBuchMoraCrit(kStrategy strat); |
---|
[83be980] | 568 | void initSbaCrit(kStrategy strat); |
---|
[35aab3] | 569 | void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat); |
---|
| 570 | void initBuchMoraPos(kStrategy strat); |
---|
[5efbf9] | 571 | void initBuchMoraPosRing(kStrategy strat); |
---|
[83be980] | 572 | void initSbaPos(kStrategy strat); |
---|
[35aab3] | 573 | void initBuchMora (ideal F, ideal Q,kStrategy strat); |
---|
[83be980] | 574 | void initSbaBuchMora (ideal F, ideal Q,kStrategy strat); |
---|
[35aab3] | 575 | void exitBuchMora (kStrategy strat); |
---|
[83be980] | 576 | void exitSba (kStrategy strat); |
---|
[35aab3] | 577 | void updateResult(ideal r,ideal Q,kStrategy strat); |
---|
[4d43ff] | 578 | void completeReduce (kStrategy strat, BOOLEAN withT=FALSE); |
---|
[35aab3] | 579 | void kFreeStrat(kStrategy strat); |
---|
[b5a454] | 580 | void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR); |
---|
[6c55ae] | 581 | void chainCritNormal (poly p,int ecart,kStrategy strat); |
---|
[ede2ad8] | 582 | void chainCritOpt_1 (poly,int,kStrategy strat); |
---|
[83be980] | 583 | void chainCritSig (poly p,int ecart,kStrategy strat); |
---|
[35aab3] | 584 | BOOLEAN homogTest(polyset F, int Fmax); |
---|
[930ea8] | 585 | BOOLEAN newHEdge(kStrategy strat); |
---|
[83be980] | 586 | BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat); |
---|
| 587 | BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat); |
---|
[32f7e5] | 588 | KINLINE BOOLEAN arriRewDummy(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start); |
---|
| 589 | BOOLEAN arriRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start); |
---|
| 590 | BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start); |
---|
| 591 | BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start); |
---|
[83be980] | 592 | BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start); |
---|
[152e71c] | 593 | |
---|
| 594 | /// returns index of p in TSet, or -1 if not found |
---|
[35aab3] | 595 | int kFindInT(poly p, TSet T, int tlength); |
---|
[94b41d] | 596 | #ifdef HAVE_SHIFTBBA |
---|
| 597 | int kFindInTShift(poly p, TSet T, int tlength); |
---|
| 598 | #endif |
---|
[35aab3] | 599 | |
---|
[152e71c] | 600 | /// return -1 if no divisor is found |
---|
| 601 | /// number of first divisor in T, otherwise |
---|
[a576b0] | 602 | int kFindDivisibleByInT(const kStrategy strat, const LObject* L, const int start=0); |
---|
[2c1877] | 603 | int kFindDivisibleByInT_Z(const kStrategy strat, const LObject* L, const int start=0); |
---|
[3b1ebb] | 604 | int kFindSameLMInT_Z(const kStrategy strat, const LObject* L, const int start=0); |
---|
[152e71c] | 605 | |
---|
[beac9c6] | 606 | /// tests if T[0] divides the leading monomial of L, returns -1 if not |
---|
| 607 | int kTestDivisibleByT0_Z(const kStrategy strat, const LObject* L); |
---|
[152e71c] | 608 | /// return -1 if no divisor is found |
---|
| 609 | /// number of first divisor in S, otherwise |
---|
[391323] | 610 | int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L); |
---|
[35aab3] | 611 | |
---|
[7ba059] | 612 | int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L); |
---|
[ad53a8] | 613 | TObject* kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject* L, TObject *T, long ecart = LONG_MAX); |
---|
[35aab3] | 614 | |
---|
| 615 | /*************************************************************** |
---|
| 616 | * |
---|
| 617 | * stuff to be inlined |
---|
| 618 | * |
---|
| 619 | ***************************************************************/ |
---|
| 620 | |
---|
| 621 | KINLINE TSet initT (); |
---|
| 622 | KINLINE TObject** initR(); |
---|
| 623 | KINLINE unsigned long* initsevT(); |
---|
| 624 | KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin); |
---|
| 625 | KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin); |
---|
| 626 | KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin); |
---|
| 627 | KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin bin); |
---|
| 628 | |
---|
| 629 | KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing); |
---|
| 630 | KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing); |
---|
| 631 | KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing); |
---|
| 632 | KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing); |
---|
| 633 | |
---|
| 634 | // if exp bound is not violated, return TRUE and |
---|
| 635 | // get m1 = LCM(LM(p1), LM(p2))/LM(p1) |
---|
| 636 | // m2 = LCM(LM(p1), LM(p2))/LM(p2) |
---|
| 637 | // return FALSE and m1 == NULL, m2 == NULL , otherwise |
---|
| 638 | KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, |
---|
| 639 | poly &m1, poly &m2, const ring m_r); |
---|
[d681e8] | 640 | #ifdef HAVE_RINGS |
---|
[ca371d] | 641 | KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, |
---|
[d681e8] | 642 | poly &m1, poly &m2, poly &lcm, const ring taiRing); |
---|
| 643 | #endif |
---|
[35aab3] | 644 | #ifdef KDEBUG |
---|
| 645 | // test strat |
---|
| 646 | BOOLEAN kTest(kStrategy strat); |
---|
| 647 | // test strat, and test that S is contained in T |
---|
| 648 | BOOLEAN kTest_TS(kStrategy strat); |
---|
| 649 | // test LObject |
---|
[2e41b6d] | 650 | BOOLEAN kTest_L(LObject* L, kStrategy strat, |
---|
[35aab3] | 651 | BOOLEAN testp = FALSE, int lpos = -1, |
---|
| 652 | TSet T = NULL, int tlength = -1); |
---|
| 653 | // test TObject |
---|
[2e41b6d] | 654 | BOOLEAN kTest_T(TObject* T, kStrategy strat, int tpos = -1, char TN = '?'); |
---|
[35aab3] | 655 | // test set strat->SevS |
---|
| 656 | BOOLEAN kTest_S(kStrategy strat); |
---|
| 657 | #else |
---|
[d101b1] | 658 | #define kTest(A) (TRUE) |
---|
| 659 | #define kTest_TS(A) (TRUE) |
---|
[2e41b6d] | 660 | #define kTest_T(T,S) (TRUE) |
---|
[d101b1] | 661 | #define kTest_S(T) (TRUE) |
---|
[1eabfc] | 662 | #define kTest_L(T,R) (TRUE) |
---|
[35aab3] | 663 | #endif |
---|
| 664 | |
---|
| 665 | |
---|
| 666 | /*************************************************************** |
---|
| 667 | * |
---|
| 668 | * From kstd2.cc |
---|
| 669 | * |
---|
| 670 | ***************************************************************/ |
---|
[a6889e] | 671 | poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing); |
---|
[35aab3] | 672 | ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat); |
---|
[83be980] | 673 | ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat); |
---|
[35aab3] | 674 | poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce); |
---|
| 675 | ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce); |
---|
[c2ef83] | 676 | poly kNF2Bound (ideal F, ideal Q, poly q,int bound, kStrategy strat, int lazyReduce); |
---|
| 677 | ideal kNF2Bound (ideal F,ideal Q,ideal q,int bound, kStrategy strat, int lazyReduce); |
---|
[4cc32b2] | 678 | void initBba(kStrategy strat); |
---|
[83be980] | 679 | void initSba(ideal F,kStrategy strat); |
---|
[a9c298] | 680 | void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg, |
---|
[83be980] | 681 | int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q, |
---|
| 682 | intvec *w,intvec *hilb ); |
---|
[35aab3] | 683 | |
---|
| 684 | /*************************************************************** |
---|
| 685 | * |
---|
[c25b56c] | 686 | * From kspoly.cc |
---|
[35aab3] | 687 | * |
---|
| 688 | ***************************************************************/ |
---|
| 689 | // Reduces PR with PW |
---|
| 690 | // Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR) |
---|
| 691 | // Changes: PR |
---|
| 692 | // Const: PW |
---|
| 693 | // If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW) |
---|
| 694 | // If strat != NULL, tailRing is changed if reduction would violate exp bound |
---|
| 695 | // of tailRing |
---|
| 696 | // Returns: 0 everything ok, no tailRing change |
---|
| 697 | // 1 tailRing has successfully changed (strat != NULL) |
---|
| 698 | // 2 no reduction performed, tailRing needs to be changed first |
---|
| 699 | // (strat == NULL) |
---|
| 700 | // -1 tailRing change could not be performed due to exceeding exp |
---|
| 701 | // bound of currRing |
---|
[ac5926] | 702 | // reduce should be set inside "kNF" (only relevant for rings) |
---|
[35aab3] | 703 | int ksReducePoly(LObject* PR, |
---|
| 704 | TObject* PW, |
---|
| 705 | poly spNoether = NULL, |
---|
| 706 | number *coef = NULL, |
---|
[897be4] | 707 | poly *mon =NULL, |
---|
[ac5926] | 708 | kStrategy strat = NULL, |
---|
| 709 | BOOLEAN redtail = FALSE); |
---|
[953f6b] | 710 | |
---|
[755d41] | 711 | /* like ksReducePoly, but if the reducer has only 1 term we still |
---|
| 712 | * compute a possible coefficient multiplier for PR. this comes from |
---|
| 713 | * a special situation in redRing_Z and it is used only there. */ |
---|
| 714 | int ksReducePolyZ(LObject* PR, |
---|
| 715 | TObject* PW, |
---|
| 716 | poly spNoether = NULL, |
---|
| 717 | number *coef = NULL, |
---|
| 718 | kStrategy strat = NULL); |
---|
| 719 | |
---|
[953f6b] | 720 | int ksReducePolyLC(LObject* PR, |
---|
| 721 | TObject* PW, |
---|
| 722 | poly spNoether = NULL, |
---|
| 723 | number *coef = NULL, |
---|
[3b1ebb] | 724 | kStrategy strat = NULL); |
---|
| 725 | |
---|
| 726 | |
---|
| 727 | int ksReducePolyGCD(LObject* PR, |
---|
| 728 | TObject* PW, |
---|
| 729 | poly spNoether = NULL, |
---|
| 730 | number *coef = NULL, |
---|
[35aab3] | 731 | kStrategy strat = NULL); |
---|
[7bb1ac] | 732 | |
---|
[c2ef83] | 733 | int ksReducePolyBound(LObject* PR, |
---|
| 734 | TObject* PW, |
---|
| 735 | int bound, |
---|
| 736 | poly spNoether = NULL, |
---|
| 737 | number *coef = NULL, |
---|
| 738 | kStrategy strat = NULL); |
---|
[35aab3] | 739 | |
---|
[83be980] | 740 | // Reduces PR with PW |
---|
| 741 | // Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR) |
---|
| 742 | // Changes: PR |
---|
| 743 | // Const: PW |
---|
| 744 | // If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW) |
---|
| 745 | // If strat != NULL, tailRing is changed if reduction would violate exp bound |
---|
| 746 | // of tailRing |
---|
| 747 | // Returns: 0 everything ok, no tailRing change |
---|
| 748 | // 1 tailRing has successfully changed (strat != NULL) |
---|
| 749 | // 2 no reduction performed, tailRing needs to be changed first |
---|
| 750 | // (strat == NULL) |
---|
| 751 | // 3 no reduction performed, not sig-safe!!! |
---|
| 752 | // -1 tailRing change could not be performed due to exceeding exp |
---|
| 753 | // bound of currRing |
---|
| 754 | int ksReducePolySig(LObject* PR, |
---|
| 755 | TObject* PW, |
---|
| 756 | long idx, |
---|
| 757 | poly spNoether = NULL, |
---|
| 758 | number *coef = NULL, |
---|
| 759 | kStrategy strat = NULL); |
---|
[780c1b] | 760 | |
---|
[e40da9f] | 761 | int ksReducePolySigRing(LObject* PR, |
---|
| 762 | TObject* PW, |
---|
| 763 | long idx, |
---|
| 764 | poly spNoether = NULL, |
---|
| 765 | number *coef = NULL, |
---|
| 766 | kStrategy strat = NULL); |
---|
[83be980] | 767 | |
---|
[35aab3] | 768 | // Reduces PR at Current->next with PW |
---|
| 769 | // Assumes PR != NULL, Current contained in PR |
---|
[c858487] | 770 | // Current->next != NULL, LM(PW) divides LM(Current->next) |
---|
[35aab3] | 771 | // Changes: PR |
---|
| 772 | // Const: PW |
---|
| 773 | // Return: see ksReducePoly |
---|
| 774 | int ksReducePolyTail(LObject* PR, |
---|
| 775 | TObject* PW, |
---|
| 776 | poly Current, |
---|
| 777 | poly spNoether = NULL); |
---|
| 778 | |
---|
| 779 | KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red); |
---|
| 780 | |
---|
| 781 | // Creates S-Poly of Pair |
---|
| 782 | // Const: Pair->p1, Pair->p2 |
---|
| 783 | // Changes: Pair->p == S-Poly of p1, p2 |
---|
| 784 | // Assume: Pair->p1 != NULL && Pair->p2 |
---|
| 785 | void ksCreateSpoly(LObject* Pair, poly spNoether = NULL, |
---|
| 786 | int use_buckets=0, ring tailRing=currRing, |
---|
[b5a454] | 787 | poly m1 = NULL, poly m2 = NULL, TObject** R = NULL); |
---|
[35aab3] | 788 | |
---|
| 789 | /*2 |
---|
| 790 | * creates the leading term of the S-polynomial of p1 and p2 |
---|
| 791 | * do not destroy p1 and p2 |
---|
| 792 | * remarks: |
---|
| 793 | * 1. the coefficient is 0 (nNew) |
---|
| 794 | * 2. pNext is undefined |
---|
| 795 | */ |
---|
| 796 | poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing); |
---|
| 797 | |
---|
| 798 | |
---|
| 799 | // old stuff |
---|
| 800 | KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL); |
---|
| 801 | KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL); |
---|
| 802 | KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing); |
---|
| 803 | KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing); |
---|
| 804 | |
---|
| 805 | /*************************************************************** |
---|
| 806 | * |
---|
| 807 | * Routines related for ring changes during std computations |
---|
| 808 | * |
---|
| 809 | ***************************************************************/ |
---|
| 810 | // return TRUE and set m1, m2 to k_GetLcmTerms, |
---|
| 811 | // if spoly creation of strat->P does not violate |
---|
| 812 | // exponent bound of strat->tailRing |
---|
| 813 | // FALSE, otherwise |
---|
| 814 | BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2); |
---|
[7245240] | 815 | #ifdef HAVE_RINGS |
---|
[b5a454] | 816 | // return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate |
---|
| 817 | // exponent bound of strat->tailRing |
---|
| 818 | // FALSE, otherwise |
---|
| 819 | BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat); |
---|
[a469814] | 820 | poly preIntegerCheck(ideal F, ideal Q); |
---|
| 821 | void postReduceByMon(LObject* h, kStrategy strat); |
---|
[978a8c] | 822 | void postReduceByMonSig(LObject* h, kStrategy strat); |
---|
[d762df9] | 823 | void finalReduceByMon(kStrategy strat); |
---|
[7245240] | 824 | #endif |
---|
[35aab3] | 825 | // change strat->tailRing and adjust all data in strat, L, and T: |
---|
| 826 | // new tailRing has larger exponent bound |
---|
| 827 | // do nothing and return FALSE if exponent bound increase would result in |
---|
| 828 | // larger exponent bound that that of currRing |
---|
| 829 | BOOLEAN kStratChangeTailRing(kStrategy strat, |
---|
| 830 | LObject* L = NULL, TObject* T = NULL, |
---|
| 831 | // take this as new_expbound: if 0 |
---|
| 832 | // new expbound is 2*expbound of tailRing |
---|
| 833 | unsigned long new_expbound = 0); |
---|
| 834 | // initiate a change of the tailRing of strat -- should be called |
---|
| 835 | // right before main loop in bba |
---|
| 836 | void kStratInitChangeTailRing(kStrategy strat); |
---|
| 837 | |
---|
[4f7d76] | 838 | /// Output some debug info about a given strategy |
---|
| 839 | void kDebugPrint(kStrategy strat); |
---|
| 840 | |
---|
[83be980] | 841 | // getting sb order for sba computations |
---|
| 842 | ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1); |
---|
[4f7d76] | 843 | |
---|
[ec69aa] | 844 | KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k, |
---|
| 845 | kStrategy strat); |
---|
[1f637e] | 846 | |
---|
[89f4843] | 847 | #include "kernel/GBEngine/kInline.h" |
---|
[35aab3] | 848 | |
---|
[cb0fbe] | 849 | /* shiftgb stuff */ |
---|
[89f4843] | 850 | #include "kernel/GBEngine/shiftgb.h" |
---|
[35aab3] | 851 | |
---|
[95b713] | 852 | #ifdef HAVE_SHIFTBBA |
---|
| 853 | static inline int kFindInL1(const poly p, const kStrategy strat) |
---|
| 854 | { |
---|
| 855 | for(int i=strat->Ll;i>=0;i--) |
---|
| 856 | { |
---|
| 857 | if (p==strat->L[i].p1) return i; |
---|
| 858 | } |
---|
| 859 | return -1; |
---|
| 860 | } |
---|
| 861 | |
---|
[4d2ab5c] | 862 | poly pMove2CurrTail(poly p, kStrategy strat); |
---|
| 863 | |
---|
| 864 | poly pMoveCurrTail2poly(poly p, kStrategy strat); |
---|
| 865 | |
---|
| 866 | poly pCopyL2p(LObject h, kStrategy strat); |
---|
| 867 | |
---|
[216e12] | 868 | void enterTShift(LObject p, kStrategy strat, int atT = -1); |
---|
[cb0fbe] | 869 | |
---|
[a795108] | 870 | BOOLEAN enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS); |
---|
[37a4c3] | 871 | |
---|
[b5a454] | 872 | void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR); |
---|
[37a4c3] | 873 | |
---|
[b5a454] | 874 | void superenterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR); |
---|
[cb0fbe] | 875 | |
---|
[37a4c3] | 876 | poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize); |
---|
| 877 | |
---|
| 878 | int redFirstShift (LObject* h,kStrategy strat); // ok |
---|
[cb0fbe] | 879 | |
---|
[b00f8a] | 880 | ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat); |
---|
[95b713] | 881 | #endif |
---|
| 882 | |
---|
[57fad3a] | 883 | // test syz strategy: // will be removed soon |
---|
[a3f0fea] | 884 | EXTERN_VAR int (*test_PosInT)(const TSet T,const int tl,LObject &h); |
---|
| 885 | EXTERN_VAR int (*test_PosInL)(const LSet set, const int length, |
---|
[57fad3a] | 886 | LObject* L,const kStrategy strat); |
---|
[3e5610] | 887 | |
---|
| 888 | static inline void kDeleteLcm(LObject *P) |
---|
| 889 | { |
---|
| 890 | if (P->lcm!=NULL) |
---|
| 891 | { |
---|
| 892 | #ifdef HAVE_RINGS |
---|
| 893 | if (rField_is_Ring(currRing)) |
---|
| 894 | pLmDelete(P->lcm); |
---|
| 895 | else |
---|
| 896 | #endif |
---|
| 897 | pLmFree(P->lcm); |
---|
| 898 | P->lcm=NULL; |
---|
| 899 | } |
---|
| 900 | } |
---|
[a647f6c] | 901 | |
---|
[b5a454] | 902 | void initenterpairs (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1); |
---|
[35aab3] | 903 | #endif |
---|