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