[35aab3] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
[52e2f6] | 4 | /* $Id: kstd1.cc,v 1.35 2008-06-10 10:17:31 motsak Exp $ */ |
---|
[35aab3] | 5 | /* |
---|
| 6 | * ABSTRACT: |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | // define if buckets should be used |
---|
| 10 | #define MORA_USE_BUCKETS |
---|
| 11 | |
---|
| 12 | // define if tailrings should be used |
---|
| 13 | #define HAVE_TAIL_RING |
---|
| 14 | |
---|
| 15 | #include "mod2.h" |
---|
| 16 | #include "structs.h" |
---|
| 17 | #include "omalloc.h" |
---|
| 18 | #include "kutil.h" |
---|
| 19 | #include "kInline.cc" |
---|
| 20 | #include "polys.h" |
---|
| 21 | #include "febase.h" |
---|
| 22 | #include "kstd1.h" |
---|
| 23 | #include "khstd.h" |
---|
| 24 | #include "stairc.h" |
---|
| 25 | #include "weight.h" |
---|
| 26 | //#include "cntrlc.h" |
---|
| 27 | #include "intvec.h" |
---|
| 28 | #include "ideals.h" |
---|
[e5a253] | 29 | //#include "../Singular/ipid.h" |
---|
[35aab3] | 30 | #include "timer.h" |
---|
| 31 | |
---|
| 32 | //#include "ipprint.h" |
---|
| 33 | |
---|
[32b0000] | 34 | #ifdef HAVE_PLURAL |
---|
| 35 | #include "sca.h" |
---|
| 36 | #endif |
---|
| 37 | |
---|
| 38 | |
---|
[35aab3] | 39 | /* the list of all options which give a warning by test */ |
---|
| 40 | BITSET kOptions=Sy_bit(OPT_PROT) /* 0 */ |
---|
| 41 | |Sy_bit(OPT_REDSB) /* 1 */ |
---|
| 42 | |Sy_bit(OPT_NOT_SUGAR) /* 3 */ |
---|
| 43 | |Sy_bit(OPT_INTERRUPT) /* 4 */ |
---|
| 44 | |Sy_bit(OPT_SUGARCRIT) /* 5 */ |
---|
| 45 | |Sy_bit(OPT_REDTHROUGH) |
---|
| 46 | |Sy_bit(OPT_OLDSTD) |
---|
| 47 | |Sy_bit(OPT_FASTHC) /* 10 */ |
---|
| 48 | |Sy_bit(OPT_KEEPVARS) /* 21 */ |
---|
| 49 | |Sy_bit(OPT_INTSTRATEGY) /* 26 */ |
---|
| 50 | |Sy_bit(OPT_INFREDTAIL) /* 28 */ |
---|
| 51 | |Sy_bit(OPT_NOTREGULARITY) /* 30 */ |
---|
| 52 | |Sy_bit(OPT_WEIGHTM); /* 31 */ |
---|
| 53 | |
---|
| 54 | /* the list of all options which may be used by option and test */ |
---|
| 55 | BITSET validOpts=Sy_bit(0) |
---|
| 56 | |Sy_bit(1) |
---|
| 57 | |Sy_bit(2) // obachman 10/00: replaced by notBucket |
---|
| 58 | |Sy_bit(3) |
---|
| 59 | |Sy_bit(4) |
---|
| 60 | |Sy_bit(5) |
---|
| 61 | |Sy_bit(6) |
---|
| 62 | // |Sy_bit(7) obachman 11/00 tossed: 12/00 used for redThrough |
---|
| 63 | |Sy_bit(OPT_REDTHROUGH) |
---|
| 64 | // |Sy_bit(8) obachman 11/00 tossed |
---|
| 65 | |Sy_bit(9) |
---|
| 66 | |Sy_bit(10) |
---|
| 67 | |Sy_bit(11) |
---|
| 68 | |Sy_bit(12) |
---|
| 69 | |Sy_bit(13) |
---|
| 70 | |Sy_bit(14) |
---|
| 71 | |Sy_bit(15) |
---|
| 72 | |Sy_bit(16) |
---|
| 73 | |Sy_bit(17) |
---|
| 74 | |Sy_bit(18) |
---|
| 75 | |Sy_bit(19) |
---|
| 76 | // |Sy_bit(20) obachman 11/00 tossed: 12/00 used for redOldStd |
---|
| 77 | |Sy_bit(OPT_OLDSTD) |
---|
| 78 | |Sy_bit(21) |
---|
| 79 | |Sy_bit(22) |
---|
| 80 | /*|Sy_bit(23)*/ |
---|
| 81 | /*|Sy_bit(24)*/ |
---|
| 82 | |Sy_bit(OPT_REDTAIL) |
---|
| 83 | |Sy_bit(OPT_INTSTRATEGY) |
---|
| 84 | |Sy_bit(27) |
---|
| 85 | |Sy_bit(28) |
---|
| 86 | |Sy_bit(29) |
---|
| 87 | |Sy_bit(30) |
---|
| 88 | |Sy_bit(31); |
---|
| 89 | |
---|
| 90 | //static BOOLEAN posInLOldFlag; |
---|
| 91 | /*FALSE, if posInL == posInL10*/ |
---|
| 92 | // returns TRUE if mora should use buckets, false otherwise |
---|
| 93 | static BOOLEAN kMoraUseBucket(kStrategy strat); |
---|
| 94 | |
---|
| 95 | static void kOptimizeLDeg(pLDegProc ldeg, kStrategy strat) |
---|
| 96 | { |
---|
[485b5d] | 97 | // if (strat->ak == 0 && !rIsSyzIndexRing(currRing)) |
---|
[35aab3] | 98 | strat->length_pLength = TRUE; |
---|
[485b5d] | 99 | // else |
---|
| 100 | // strat->length_pLength = FALSE; |
---|
[35aab3] | 101 | |
---|
[485b5d] | 102 | if ((ldeg == pLDeg0c /*&& !rIsSyzIndexRing(currRing)*/) || |
---|
[35aab3] | 103 | (ldeg == pLDeg0 && strat->ak == 0)) |
---|
| 104 | { |
---|
| 105 | strat->LDegLast = TRUE; |
---|
| 106 | } |
---|
| 107 | else |
---|
| 108 | { |
---|
| 109 | strat->LDegLast = FALSE; |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | static int doRed (LObject* h, TObject* with,BOOLEAN intoT,kStrategy strat) |
---|
| 115 | { |
---|
| 116 | poly hp; |
---|
| 117 | int ret; |
---|
| 118 | #if KDEBUG > 0 |
---|
| 119 | kTest_L(h); |
---|
| 120 | kTest_T(with); |
---|
| 121 | #endif |
---|
| 122 | // Hmmm ... why do we do this -- polys from T should already be normalized |
---|
| 123 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 124 | with->pNorm(); |
---|
| 125 | #ifdef KDEBUG |
---|
| 126 | if (TEST_OPT_DEBUG) |
---|
| 127 | { |
---|
| 128 | PrintS("reduce ");h->wrp();PrintS(" with ");with->wrp();PrintLn(); |
---|
| 129 | } |
---|
| 130 | #endif |
---|
| 131 | if (intoT) |
---|
| 132 | { |
---|
| 133 | // need to do it exacly like this: otherwise |
---|
| 134 | // we might get errors |
---|
| 135 | LObject L= *h; |
---|
| 136 | L.Copy(); |
---|
| 137 | h->GetP(); |
---|
| 138 | h->SetLength(strat->length_pLength); |
---|
| 139 | ret = ksReducePoly(&L, with, strat->kNoetherTail(), NULL, strat); |
---|
| 140 | if (ret) |
---|
| 141 | { |
---|
| 142 | if (ret < 0) return ret; |
---|
| 143 | if (h->tailRing != strat->tailRing) |
---|
| 144 | h->ShallowCopyDelete(strat->tailRing, |
---|
| 145 | pGetShallowCopyDeleteProc(h->tailRing, |
---|
| 146 | strat->tailRing)); |
---|
| 147 | } |
---|
| 148 | enterT(*h,strat); |
---|
| 149 | *h = L; |
---|
| 150 | } |
---|
| 151 | else |
---|
| 152 | ret = ksReducePoly(h, with, strat->kNoetherTail(), NULL, strat); |
---|
| 153 | #ifdef KDEBUG |
---|
| 154 | if (TEST_OPT_DEBUG) |
---|
| 155 | { |
---|
| 156 | PrintS("to ");h->wrp();PrintLn(); |
---|
| 157 | } |
---|
| 158 | #endif |
---|
| 159 | return ret; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | int redEcart (LObject* h,kStrategy strat) |
---|
| 163 | { |
---|
| 164 | poly pi; |
---|
| 165 | int i,at,reddeg,d,ei,li,ii; |
---|
| 166 | int j = 0; |
---|
| 167 | int pass = 0; |
---|
| 168 | |
---|
| 169 | d = h->GetpFDeg()+ h->ecart; |
---|
| 170 | reddeg = strat->LazyDegree+d; |
---|
| 171 | h->SetShortExpVector(); |
---|
| 172 | loop |
---|
| 173 | { |
---|
| 174 | j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h); |
---|
| 175 | if (j < 0) |
---|
| 176 | { |
---|
| 177 | if (strat->honey) h->SetLength(strat->length_pLength); |
---|
| 178 | return 1; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | ei = strat->T[j].ecart; |
---|
| 182 | ii = j; |
---|
| 183 | |
---|
| 184 | if (ei > h->ecart && ii < strat->tl) |
---|
| 185 | { |
---|
| 186 | li = strat->T[j].length; |
---|
| 187 | // the polynomial to reduce with (up to the moment) is; |
---|
| 188 | // pi with ecart ei and length li |
---|
| 189 | // look for one with smaller ecart |
---|
| 190 | i = j; |
---|
| 191 | loop |
---|
| 192 | { |
---|
| 193 | /*- takes the first possible with respect to ecart -*/ |
---|
| 194 | i++; |
---|
| 195 | #if 1 |
---|
| 196 | if (i > strat->tl) break; |
---|
| 197 | if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei && |
---|
| 198 | strat->T[i].length < li)) |
---|
| 199 | && |
---|
| 200 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)) |
---|
| 201 | #else |
---|
| 202 | j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h, i); |
---|
| 203 | if (j < 0) break; |
---|
| 204 | i = j; |
---|
| 205 | if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei && |
---|
| 206 | strat->T[i].length < li)) |
---|
| 207 | #endif |
---|
| 208 | { |
---|
| 209 | // the polynomial to reduce with is now |
---|
| 210 | ii = i; |
---|
| 211 | ei = strat->T[i].ecart; |
---|
| 212 | if (ei <= h->ecart) break; |
---|
| 213 | li = strat->T[i].length; |
---|
| 214 | } |
---|
| 215 | } |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | // end of search: have to reduce with pi |
---|
| 219 | if (ei > h->ecart) |
---|
| 220 | { |
---|
| 221 | // It is not possible to reduce h with smaller ecart; |
---|
| 222 | // if possible h goes to the lazy-set L,i.e |
---|
| 223 | // if its position in L would be not the last one |
---|
| 224 | strat->fromT = TRUE; |
---|
| 225 | if (!K_TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/ |
---|
| 226 | { |
---|
| 227 | h->SetLmCurrRing(); |
---|
| 228 | if (strat->honey && strat->posInLDependsOnLength) |
---|
| 229 | h->SetLength(strat->length_pLength); |
---|
| 230 | assume(h->FDeg == h->pFDeg()); |
---|
| 231 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 232 | if (at <= strat->Ll) |
---|
| 233 | { |
---|
| 234 | /*- h will not become the next element to reduce -*/ |
---|
| 235 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 236 | #ifdef KDEBUG |
---|
| 237 | if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at); |
---|
| 238 | #endif |
---|
| 239 | h->Clear(); |
---|
| 240 | strat->fromT = FALSE; |
---|
| 241 | return -1; |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | // now we finally can reduce |
---|
| 247 | doRed(h,&(strat->T[ii]),strat->fromT,strat); |
---|
| 248 | strat->fromT=FALSE; |
---|
| 249 | |
---|
| 250 | // are we done ??? |
---|
| 251 | if (h->IsNull()) |
---|
| 252 | { |
---|
| 253 | if (h->lcm!=NULL) pLmFree(h->lcm); |
---|
| 254 | h->Clear(); |
---|
| 255 | return 0; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | // NO! |
---|
| 259 | h->SetShortExpVector(); |
---|
| 260 | h->SetpFDeg(); |
---|
| 261 | if (strat->honey) |
---|
| 262 | { |
---|
| 263 | if (ei <= h->ecart) |
---|
| 264 | h->ecart = d-h->GetpFDeg(); |
---|
| 265 | else |
---|
| 266 | h->ecart = d-h->GetpFDeg()+ei-h->ecart; |
---|
| 267 | } |
---|
| 268 | else |
---|
| 269 | // this has the side effect of setting h->length |
---|
| 270 | h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg(); |
---|
[b981502] | 271 | #if 0 |
---|
[35aab3] | 272 | if (strat->syzComp!=0) |
---|
| 273 | { |
---|
| 274 | if ((strat->syzComp>0) && (h->Comp() > strat->syzComp)) |
---|
| 275 | { |
---|
| 276 | assume(h->MinComp() > strat->syzComp); |
---|
| 277 | if (strat->honey) h->SetLength(); |
---|
| 278 | #ifdef KDEBUG |
---|
| 279 | if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
| 280 | #endif |
---|
| 281 | return -2; |
---|
| 282 | } |
---|
| 283 | } |
---|
[b981502] | 284 | #endif |
---|
[35aab3] | 285 | /*- try to reduce the s-polynomial -*/ |
---|
| 286 | pass++; |
---|
| 287 | d = h->GetpFDeg()+h->ecart; |
---|
| 288 | /* |
---|
| 289 | *test whether the polynomial should go to the lazyset L |
---|
| 290 | *-if the degree jumps |
---|
| 291 | *-if the number of pre-defined reductions jumps |
---|
| 292 | */ |
---|
| 293 | if (!K_TEST_OPT_REDTHROUGH && (strat->Ll >= 0) |
---|
| 294 | && ((d >= reddeg) || (pass > strat->LazyPass))) |
---|
| 295 | { |
---|
| 296 | h->SetLmCurrRing(); |
---|
| 297 | if (strat->honey && strat->posInLDependsOnLength) |
---|
| 298 | h->SetLength(strat->length_pLength); |
---|
| 299 | assume(h->FDeg == h->pFDeg()); |
---|
| 300 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 301 | if (at <= strat->Ll) |
---|
| 302 | { |
---|
[391323] | 303 | int dummy=strat->sl; |
---|
| 304 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
[35aab3] | 305 | { |
---|
| 306 | if (strat->honey && !strat->posInLDependsOnLength) |
---|
| 307 | h->SetLength(strat->length_pLength); |
---|
| 308 | return 1; |
---|
| 309 | } |
---|
| 310 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 311 | #ifdef KDEBUG |
---|
| 312 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
| 313 | #endif |
---|
| 314 | h->Clear(); |
---|
| 315 | return -1; |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
| 319 | { |
---|
| 320 | Print(".%d",d);mflush(); |
---|
| 321 | reddeg = d+1; |
---|
| 322 | } |
---|
| 323 | } |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | /*2 |
---|
| 327 | *reduces h with elements from T choosing the first possible |
---|
| 328 | * element in t with respect to the given pDivisibleBy |
---|
| 329 | */ |
---|
| 330 | int redFirst (LObject* h,kStrategy strat) |
---|
| 331 | { |
---|
| 332 | if (h->IsNull()) return 0; |
---|
| 333 | |
---|
| 334 | int at, reddeg,d; |
---|
| 335 | int pass = 0; |
---|
| 336 | int j = 0; |
---|
| 337 | |
---|
| 338 | if (! strat->homog) |
---|
| 339 | { |
---|
| 340 | d = h->GetpFDeg() + h->ecart; |
---|
| 341 | reddeg = strat->LazyDegree+d; |
---|
| 342 | } |
---|
| 343 | h->SetShortExpVector(); |
---|
[485b5d] | 344 | loop |
---|
[35aab3] | 345 | { |
---|
| 346 | j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h); |
---|
| 347 | if (j < 0) |
---|
| 348 | { |
---|
| 349 | h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 350 | return 1; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 354 | strat->T[j].pNorm(); |
---|
| 355 | #ifdef KDEBUG |
---|
| 356 | if (TEST_OPT_DEBUG) |
---|
| 357 | { |
---|
| 358 | PrintS("reduce "); |
---|
| 359 | h->wrp(); |
---|
| 360 | PrintS(" with "); |
---|
| 361 | strat->T[j].wrp(); |
---|
| 362 | } |
---|
| 363 | #endif |
---|
| 364 | ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, strat); |
---|
| 365 | #ifdef KDEBUG |
---|
| 366 | if (TEST_OPT_DEBUG) |
---|
| 367 | { |
---|
| 368 | PrintS(" to "); |
---|
| 369 | wrp(h->p); |
---|
| 370 | PrintLn(); |
---|
| 371 | } |
---|
| 372 | #endif |
---|
| 373 | if (h->IsNull()) |
---|
| 374 | { |
---|
| 375 | if (h->lcm!=NULL) pLmFree(h->lcm); |
---|
| 376 | h->Clear(); |
---|
| 377 | return 0; |
---|
| 378 | } |
---|
| 379 | h->SetShortExpVector(); |
---|
| 380 | |
---|
[b981502] | 381 | #if 0 |
---|
[35aab3] | 382 | if ((strat->syzComp!=0) && !strat->honey) |
---|
| 383 | { |
---|
| 384 | if ((strat->syzComp>0) && |
---|
| 385 | (h->Comp() > strat->syzComp)) |
---|
| 386 | { |
---|
| 387 | assume(h->MinComp() > strat->syzComp); |
---|
| 388 | #ifdef KDEBUG |
---|
| 389 | if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
| 390 | #endif |
---|
| 391 | if (strat->homog) |
---|
| 392 | h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 393 | return -2; |
---|
| 394 | } |
---|
| 395 | } |
---|
[16493d] | 396 | #endif |
---|
[35aab3] | 397 | if (!strat->homog) |
---|
| 398 | { |
---|
| 399 | if (!K_TEST_OPT_OLDSTD && strat->honey) |
---|
| 400 | { |
---|
| 401 | h->SetpFDeg(); |
---|
| 402 | if (strat->T[j].ecart <= h->ecart) |
---|
| 403 | h->ecart = d - h->GetpFDeg(); |
---|
| 404 | else |
---|
| 405 | h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart; |
---|
| 406 | |
---|
| 407 | d = h->GetpFDeg() + h->ecart; |
---|
| 408 | } |
---|
| 409 | else |
---|
| 410 | d = h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 411 | /*- try to reduce the s-polynomial -*/ |
---|
| 412 | pass++; |
---|
| 413 | /* |
---|
| 414 | *test whether the polynomial should go to the lazyset L |
---|
| 415 | *-if the degree jumps |
---|
| 416 | *-if the number of pre-defined reductions jumps |
---|
| 417 | */ |
---|
| 418 | if (!K_TEST_OPT_REDTHROUGH && (strat->Ll >= 0) |
---|
| 419 | && ((d >= reddeg) || (pass > strat->LazyPass))) |
---|
| 420 | { |
---|
| 421 | h->SetLmCurrRing(); |
---|
| 422 | if (strat->posInLDependsOnLength) |
---|
| 423 | h->SetLength(strat->length_pLength); |
---|
| 424 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 425 | if (at <= strat->Ll) |
---|
| 426 | { |
---|
[391323] | 427 | int dummy=strat->sl; |
---|
| 428 | if (kFindDivisibleByInS(strat,&dummy, h) < 0) |
---|
[35aab3] | 429 | return 1; |
---|
| 430 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 431 | #ifdef KDEBUG |
---|
| 432 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
| 433 | #endif |
---|
| 434 | h->Clear(); |
---|
| 435 | return -1; |
---|
| 436 | } |
---|
| 437 | } |
---|
| 438 | if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
| 439 | { |
---|
| 440 | reddeg = d+1; |
---|
| 441 | Print(".%d",d);mflush(); |
---|
| 442 | } |
---|
| 443 | } |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | /*2 |
---|
| 448 | * reduces h with elements from T choosing first possible |
---|
| 449 | * element in T with respect to the given ecart |
---|
| 450 | * used for computing normal forms outside kStd |
---|
| 451 | */ |
---|
| 452 | static poly redMoraNF (poly h,kStrategy strat, int flag) |
---|
| 453 | { |
---|
| 454 | LObject H; |
---|
| 455 | H.p = h; |
---|
| 456 | int j = 0; |
---|
| 457 | int z = 10; |
---|
| 458 | int o = H.SetpFDeg(); |
---|
[b130fb] | 459 | H.ecart = pLDeg(H.p,&H.length,currRing)-o; |
---|
[5572c1] | 460 | if ((flag & 2) == 0) cancelunit(&H,TRUE); |
---|
[35aab3] | 461 | H.sev = pGetShortExpVector(H.p); |
---|
| 462 | unsigned long not_sev = ~ H.sev; |
---|
| 463 | loop |
---|
| 464 | { |
---|
| 465 | if (j > strat->tl) |
---|
| 466 | { |
---|
| 467 | return H.p; |
---|
| 468 | } |
---|
| 469 | if (TEST_V_DEG_STOP) |
---|
| 470 | { |
---|
| 471 | if (kModDeg(H.p)>Kstd1_deg) pDeleteLm(&H.p); |
---|
| 472 | if (H.p==NULL) return NULL; |
---|
| 473 | } |
---|
| 474 | if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)) |
---|
| 475 | { |
---|
| 476 | //if (strat->interpt) test_int_std(strat->kIdeal); |
---|
| 477 | /*- remember the found T-poly -*/ |
---|
| 478 | poly pi = strat->T[j].p; |
---|
| 479 | int ei = strat->T[j].ecart; |
---|
| 480 | int li = strat->T[j].length; |
---|
| 481 | int ii = j; |
---|
| 482 | /* |
---|
| 483 | * the polynomial to reduce with (up to the moment) is; |
---|
| 484 | * pi with ecart ei and length li |
---|
| 485 | */ |
---|
| 486 | loop |
---|
| 487 | { |
---|
| 488 | /*- look for a better one with respect to ecart -*/ |
---|
| 489 | /*- stop, if the ecart is small enough (<=ecart(H)) -*/ |
---|
| 490 | j++; |
---|
| 491 | if (j > strat->tl) break; |
---|
| 492 | if (ei <= H.ecart) break; |
---|
| 493 | if (((strat->T[j].ecart < ei) |
---|
| 494 | || ((strat->T[j].ecart == ei) |
---|
| 495 | && (strat->T[j].length < li))) |
---|
| 496 | && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)) |
---|
| 497 | { |
---|
| 498 | /* |
---|
| 499 | * the polynomial to reduce with is now; |
---|
| 500 | */ |
---|
| 501 | pi = strat->T[j].p; |
---|
| 502 | ei = strat->T[j].ecart; |
---|
| 503 | li = strat->T[j].length; |
---|
| 504 | ii = j; |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | /* |
---|
| 508 | * end of search: have to reduce with pi |
---|
| 509 | */ |
---|
| 510 | z++; |
---|
| 511 | if (z>10) |
---|
| 512 | { |
---|
| 513 | pNormalize(H.p); |
---|
| 514 | z=0; |
---|
| 515 | } |
---|
| 516 | if ((ei > H.ecart) && (!strat->kHEdgeFound)) |
---|
| 517 | { |
---|
| 518 | /* |
---|
| 519 | * It is not possible to reduce h with smaller ecart; |
---|
| 520 | * we have to reduce with bad ecart: H has to enter in T |
---|
| 521 | */ |
---|
| 522 | doRed(&H,&(strat->T[ii]),TRUE,strat); |
---|
| 523 | if (H.p == NULL) |
---|
| 524 | return NULL; |
---|
| 525 | } |
---|
| 526 | else |
---|
| 527 | { |
---|
| 528 | /* |
---|
| 529 | * we reduce with good ecart, h need not to be put to T |
---|
| 530 | */ |
---|
| 531 | doRed(&H,&(strat->T[ii]),FALSE,strat); |
---|
| 532 | if (H.p == NULL) |
---|
| 533 | return NULL; |
---|
| 534 | } |
---|
| 535 | /*- try to reduce the s-polynomial -*/ |
---|
| 536 | o = H.SetpFDeg(); |
---|
[5572c1] | 537 | if ((flag &2 ) == 0) cancelunit(&H,TRUE); |
---|
[b130fb] | 538 | H.ecart = pLDeg(H.p,&(H.length),currRing)-o; |
---|
[35aab3] | 539 | j = 0; |
---|
| 540 | H.sev = pGetShortExpVector(H.p); |
---|
| 541 | not_sev = ~ H.sev; |
---|
| 542 | } |
---|
| 543 | else |
---|
| 544 | { |
---|
| 545 | j++; |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | /*2 |
---|
| 551 | *reorders L with respect to posInL |
---|
| 552 | */ |
---|
| 553 | void reorderL(kStrategy strat) |
---|
| 554 | { |
---|
| 555 | int i,j,at; |
---|
| 556 | LObject p; |
---|
| 557 | |
---|
| 558 | for (i=1; i<=strat->Ll; i++) |
---|
| 559 | { |
---|
| 560 | at = strat->posInL(strat->L,i-1,&(strat->L[i]),strat); |
---|
| 561 | if (at != i) |
---|
| 562 | { |
---|
| 563 | p = strat->L[i]; |
---|
| 564 | for (j=i-1; j>=at; j--) strat->L[j+1] = strat->L[j]; |
---|
| 565 | strat->L[at] = p; |
---|
| 566 | } |
---|
| 567 | } |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | /*2 |
---|
| 571 | *reorders T with respect to length |
---|
| 572 | */ |
---|
| 573 | void reorderT(kStrategy strat) |
---|
| 574 | { |
---|
| 575 | int i,j,at; |
---|
| 576 | TObject p; |
---|
| 577 | unsigned long sev; |
---|
| 578 | |
---|
| 579 | |
---|
| 580 | for (i=1; i<=strat->tl; i++) |
---|
| 581 | { |
---|
| 582 | if (strat->T[i-1].length > strat->T[i].length) |
---|
| 583 | { |
---|
| 584 | p = strat->T[i]; |
---|
| 585 | sev = strat->sevT[i]; |
---|
| 586 | at = i-1; |
---|
| 587 | loop |
---|
| 588 | { |
---|
| 589 | at--; |
---|
| 590 | if (at < 0) break; |
---|
| 591 | if (strat->T[i].length > strat->T[at].length) break; |
---|
| 592 | } |
---|
| 593 | for (j = i-1; j>at; j--) |
---|
| 594 | { |
---|
| 595 | strat->T[j+1]=strat->T[j]; |
---|
| 596 | strat->sevT[j+1]=strat->sevT[j]; |
---|
| 597 | strat->R[strat->T[j+1].i_r] = &(strat->T[j+1]); |
---|
| 598 | } |
---|
| 599 | strat->T[at+1]=p; |
---|
| 600 | strat->sevT[at+1] = sev; |
---|
| 601 | strat->R[p.i_r] = &(strat->T[at+1]); |
---|
| 602 | } |
---|
| 603 | } |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | /*2 |
---|
| 607 | *looks whether exactly pVariables-1 axis are used |
---|
| 608 | *returns last != 0 in this case |
---|
| 609 | *last is the (first) unused axis |
---|
| 610 | */ |
---|
| 611 | void missingAxis (int* last,kStrategy strat) |
---|
| 612 | { |
---|
| 613 | int i = 0; |
---|
| 614 | int k = 0; |
---|
| 615 | |
---|
| 616 | *last = 0; |
---|
| 617 | if (!currRing->MixedOrder) |
---|
| 618 | { |
---|
| 619 | loop |
---|
| 620 | { |
---|
| 621 | i++; |
---|
| 622 | if (i > pVariables) break; |
---|
| 623 | if (strat->NotUsedAxis[i]) |
---|
| 624 | { |
---|
| 625 | *last = i; |
---|
| 626 | k++; |
---|
| 627 | } |
---|
| 628 | if (k>1) |
---|
| 629 | { |
---|
| 630 | *last = 0; |
---|
| 631 | break; |
---|
| 632 | } |
---|
| 633 | } |
---|
| 634 | } |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | /*2 |
---|
| 638 | *last is the only non used axis, it looks |
---|
| 639 | *for a monomial in p being a pure power of this |
---|
| 640 | *variable and returns TRUE in this case |
---|
| 641 | *(*length) gives the length between the pure power and the leading term |
---|
| 642 | *(should be minimal) |
---|
| 643 | */ |
---|
| 644 | BOOLEAN hasPurePower (const poly p,int last, int *length,kStrategy strat) |
---|
| 645 | { |
---|
| 646 | poly h; |
---|
| 647 | int i; |
---|
| 648 | |
---|
| 649 | if (pNext(p) == strat->tail) |
---|
| 650 | return FALSE; |
---|
| 651 | pp_Test(p, currRing, strat->tailRing); |
---|
| 652 | if (strat->ak <= 0 || p_MinComp(p, currRing, strat->tailRing) == strat->ak) |
---|
| 653 | { |
---|
| 654 | i = p_IsPurePower(p, currRing); |
---|
| 655 | if (i == last) |
---|
| 656 | { |
---|
| 657 | *length = 0; |
---|
| 658 | return TRUE; |
---|
| 659 | } |
---|
| 660 | *length = 1; |
---|
| 661 | h = pNext(p); |
---|
| 662 | while (h != NULL) |
---|
| 663 | { |
---|
| 664 | i = p_IsPurePower(h, strat->tailRing); |
---|
| 665 | if (i==last) return TRUE; |
---|
| 666 | (*length)++; |
---|
| 667 | pIter(h); |
---|
| 668 | } |
---|
| 669 | } |
---|
| 670 | return FALSE; |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | BOOLEAN hasPurePower (LObject *L,int last, int *length,kStrategy strat) |
---|
| 674 | { |
---|
| 675 | if (L->bucket != NULL) |
---|
| 676 | { |
---|
| 677 | poly p = L->CanonicalizeP(); |
---|
| 678 | BOOLEAN ret = hasPurePower(p, last, length, strat); |
---|
| 679 | pNext(p) = NULL; |
---|
| 680 | return ret; |
---|
| 681 | } |
---|
| 682 | else |
---|
| 683 | { |
---|
| 684 | return hasPurePower(L->p, last, length, strat); |
---|
| 685 | } |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | /*2 |
---|
| 689 | * looks up the position of polynomial p in L |
---|
| 690 | * in the case of looking for the pure powers |
---|
| 691 | */ |
---|
| 692 | int posInL10 (const LSet set,const int length, LObject* p,const kStrategy strat) |
---|
| 693 | { |
---|
| 694 | int j,dp,dL; |
---|
| 695 | |
---|
| 696 | if (length<0) return 0; |
---|
| 697 | if (hasPurePower(p,strat->lastAxis,&dp,strat)) |
---|
| 698 | { |
---|
| 699 | int op= p->GetpFDeg() +p->ecart; |
---|
| 700 | for (j=length; j>=0; j--) |
---|
| 701 | { |
---|
| 702 | if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) |
---|
| 703 | return j+1; |
---|
| 704 | if (dp < dL) |
---|
| 705 | return j+1; |
---|
| 706 | if ((dp == dL) |
---|
| 707 | && (set[j].GetpFDeg()+set[j].ecart >= op)) |
---|
| 708 | return j+1; |
---|
| 709 | } |
---|
| 710 | } |
---|
| 711 | j=length; |
---|
| 712 | loop |
---|
| 713 | { |
---|
| 714 | if (j<0) break; |
---|
| 715 | if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break; |
---|
| 716 | j--; |
---|
| 717 | } |
---|
| 718 | return strat->posInLOld(set,j,p,strat); |
---|
| 719 | } |
---|
| 720 | |
---|
| 721 | |
---|
| 722 | /*2 |
---|
| 723 | * computes the s-polynomials L[ ].p in L |
---|
| 724 | */ |
---|
| 725 | void updateL(kStrategy strat) |
---|
| 726 | { |
---|
| 727 | LObject p; |
---|
| 728 | int dL; |
---|
| 729 | int j=strat->Ll; |
---|
| 730 | loop |
---|
| 731 | { |
---|
| 732 | if (j<0) break; |
---|
| 733 | if (hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat)) |
---|
| 734 | { |
---|
| 735 | p=strat->L[strat->Ll]; |
---|
| 736 | strat->L[strat->Ll]=strat->L[j]; |
---|
| 737 | strat->L[j]=p; |
---|
| 738 | break; |
---|
| 739 | } |
---|
| 740 | j--; |
---|
| 741 | } |
---|
| 742 | if (j<0) |
---|
| 743 | { |
---|
| 744 | j=strat->Ll; |
---|
| 745 | loop |
---|
| 746 | { |
---|
| 747 | if (j<0) break; |
---|
| 748 | if (pNext(strat->L[j].p) == strat->tail) |
---|
| 749 | { |
---|
[a539ad] | 750 | #ifdef HAVE_RINGS |
---|
| 751 | if (rField_is_Ring(currRing)) |
---|
| 752 | pLmDelete(strat->L[j].p); /*deletes the short spoly and computes*/ |
---|
| 753 | else |
---|
| 754 | #else |
---|
| 755 | pLmFree(strat->L[j].p); /*deletes the short spoly and computes*/ |
---|
| 756 | #endif |
---|
[35aab3] | 757 | strat->L[j].p = NULL; |
---|
| 758 | poly m1 = NULL, m2 = NULL; |
---|
| 759 | // check that spoly creation is ok |
---|
| 760 | while (strat->tailRing != currRing && |
---|
| 761 | !kCheckSpolyCreation(&(strat->L[j]), strat, m1, m2)) |
---|
| 762 | { |
---|
| 763 | assume(m1 == NULL && m2 == NULL); |
---|
| 764 | // if not, change to a ring where exponents are at least |
---|
| 765 | // large enough |
---|
| 766 | kStratChangeTailRing(strat); |
---|
| 767 | } |
---|
| 768 | /* create the real one */ |
---|
| 769 | ksCreateSpoly(&(strat->L[j]), strat->kNoetherTail(), FALSE, |
---|
| 770 | strat->tailRing, m1, m2, strat->R); |
---|
| 771 | |
---|
| 772 | strat->L[j].SetLmCurrRing(); |
---|
| 773 | if (!strat->honey) |
---|
| 774 | strat->initEcart(&strat->L[j]); |
---|
| 775 | else |
---|
| 776 | strat->L[j].SetLength(strat->length_pLength); |
---|
| 777 | |
---|
| 778 | BOOLEAN pp = hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat); |
---|
| 779 | |
---|
| 780 | if (strat->use_buckets) strat->L[j].PrepareRed(TRUE); |
---|
| 781 | |
---|
| 782 | if (pp) |
---|
| 783 | { |
---|
| 784 | p=strat->L[strat->Ll]; |
---|
| 785 | strat->L[strat->Ll]=strat->L[j]; |
---|
| 786 | strat->L[j]=p; |
---|
| 787 | break; |
---|
| 788 | } |
---|
| 789 | } |
---|
| 790 | j--; |
---|
| 791 | } |
---|
| 792 | } |
---|
| 793 | } |
---|
| 794 | |
---|
| 795 | /*2 |
---|
| 796 | * computes the s-polynomials L[ ].p in L and |
---|
| 797 | * cuts elements in L above noether |
---|
| 798 | */ |
---|
| 799 | void updateLHC(kStrategy strat) |
---|
| 800 | { |
---|
| 801 | int i = 0; |
---|
| 802 | kTest_TS(strat); |
---|
| 803 | while (i <= strat->Ll) |
---|
| 804 | { |
---|
| 805 | if (pNext(strat->L[i].p) == strat->tail) |
---|
| 806 | { |
---|
| 807 | /*- deletes the int spoly and computes -*/ |
---|
| 808 | if (pLmCmp(strat->L[i].p,strat->kNoether) == -1) |
---|
| 809 | { |
---|
| 810 | pLmFree(strat->L[i].p); |
---|
| 811 | strat->L[i].p = NULL; |
---|
| 812 | } |
---|
| 813 | else |
---|
| 814 | { |
---|
| 815 | pLmFree(strat->L[i].p); |
---|
| 816 | strat->L[i].p = NULL; |
---|
| 817 | poly m1 = NULL, m2 = NULL; |
---|
| 818 | // check that spoly creation is ok |
---|
| 819 | while (strat->tailRing != currRing && |
---|
| 820 | !kCheckSpolyCreation(&(strat->L[i]), strat, m1, m2)) |
---|
| 821 | { |
---|
| 822 | assume(m1 == NULL && m2 == NULL); |
---|
| 823 | // if not, change to a ring where exponents are at least |
---|
| 824 | // large enough |
---|
| 825 | kStratChangeTailRing(strat); |
---|
| 826 | } |
---|
| 827 | /* create the real one */ |
---|
| 828 | ksCreateSpoly(&(strat->L[i]), strat->kNoetherTail(), FALSE, |
---|
| 829 | strat->tailRing, m1, m2, strat->R); |
---|
| 830 | if (! strat->L[i].IsNull()) |
---|
| 831 | { |
---|
| 832 | strat->L[i].SetLmCurrRing(); |
---|
| 833 | strat->L[i].SetpFDeg(); |
---|
| 834 | strat->L[i].ecart |
---|
| 835 | = strat->L[i].pLDeg(strat->LDegLast) - strat->L[i].GetpFDeg(); |
---|
| 836 | if (strat->use_buckets) strat->L[i].PrepareRed(TRUE); |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | } |
---|
| 840 | else |
---|
| 841 | deleteHC(&(strat->L[i]), strat); |
---|
| 842 | if (strat->L[i].IsNull()) |
---|
| 843 | deleteInL(strat->L,&strat->Ll,i,strat); |
---|
| 844 | else |
---|
| 845 | { |
---|
| 846 | #ifdef KDEBUG |
---|
| 847 | kTest_L(&(strat->L[i]), strat->tailRing, TRUE, i, strat->T, strat->tl); |
---|
| 848 | #endif |
---|
| 849 | i++; |
---|
| 850 | } |
---|
| 851 | } |
---|
| 852 | kTest_TS(strat); |
---|
| 853 | } |
---|
| 854 | |
---|
| 855 | /*2 |
---|
| 856 | * cuts in T above strat->kNoether and tries to cancel a unit |
---|
| 857 | */ |
---|
| 858 | void updateT(kStrategy strat) |
---|
| 859 | { |
---|
| 860 | int i = 0; |
---|
| 861 | LObject p; |
---|
| 862 | |
---|
| 863 | while (i <= strat->tl) |
---|
| 864 | { |
---|
| 865 | p = strat->T[i]; |
---|
| 866 | deleteHC(&p,strat, TRUE); |
---|
| 867 | /*- tries to cancel a unit: -*/ |
---|
| 868 | cancelunit(&p); |
---|
| 869 | if (p.p != strat->T[i].p) |
---|
| 870 | { |
---|
| 871 | strat->sevT[i] = pGetShortExpVector(p.p); |
---|
| 872 | p.SetpFDeg(); |
---|
| 873 | } |
---|
| 874 | strat->T[i] = p; |
---|
| 875 | i++; |
---|
| 876 | } |
---|
| 877 | } |
---|
| 878 | |
---|
| 879 | /*2 |
---|
| 880 | * arranges red, pos and T if strat->kHEdgeFound (first time) |
---|
| 881 | */ |
---|
| 882 | void firstUpdate(kStrategy strat) |
---|
| 883 | { |
---|
| 884 | if (strat->update) |
---|
| 885 | { |
---|
| 886 | kTest_TS(strat); |
---|
| 887 | strat->update = (strat->tl == -1); |
---|
| 888 | if (TEST_OPT_WEIGHTM) |
---|
| 889 | { |
---|
| 890 | pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 891 | if (strat->tailRing != currRing) |
---|
| 892 | { |
---|
| 893 | strat->tailRing->pFDeg = strat->pOrigFDeg_TailRing; |
---|
| 894 | strat->tailRing->pLDeg = strat->pOrigLDeg_TailRing; |
---|
| 895 | } |
---|
| 896 | int i; |
---|
| 897 | for (i=strat->Ll; i>=0; i--) |
---|
| 898 | { |
---|
| 899 | strat->L[i].SetpFDeg(); |
---|
| 900 | } |
---|
| 901 | for (i=strat->tl; i>=0; i--) |
---|
| 902 | { |
---|
| 903 | strat->T[i].SetpFDeg(); |
---|
| 904 | } |
---|
| 905 | if (ecartWeights) |
---|
| 906 | { |
---|
| 907 | omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short)); |
---|
| 908 | ecartWeights=NULL; |
---|
| 909 | } |
---|
| 910 | } |
---|
| 911 | if (TEST_OPT_FASTHC) |
---|
| 912 | { |
---|
| 913 | strat->posInL = strat->posInLOld; |
---|
| 914 | strat->lastAxis = 0; |
---|
| 915 | } |
---|
| 916 | if (BTEST1(27)) |
---|
| 917 | return; |
---|
| 918 | strat->red = redFirst; |
---|
| 919 | strat->use_buckets = kMoraUseBucket(strat); |
---|
| 920 | updateT(strat); |
---|
| 921 | strat->posInT = posInT2; |
---|
| 922 | reorderT(strat); |
---|
| 923 | } |
---|
| 924 | kTest_TS(strat); |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | /*2 |
---|
| 928 | *-puts p to the standardbasis s at position at |
---|
| 929 | *-reduces the tail of p if TEST_OPT_REDTAIL |
---|
| 930 | *-tries to cancel a unit |
---|
| 931 | *-HEckeTest |
---|
| 932 | * if TRUE |
---|
| 933 | * - decides about reduction-strategies |
---|
| 934 | * - computes noether |
---|
| 935 | * - stops computation if BTEST1(27) |
---|
| 936 | * - cuts the tails of the polynomials |
---|
| 937 | * in s,t and the elements in L above noether |
---|
| 938 | * and cancels units if possible |
---|
| 939 | * - reorders s,L |
---|
| 940 | */ |
---|
| 941 | void enterSMora (LObject p,int atS,kStrategy strat, int atR = -1) |
---|
| 942 | { |
---|
| 943 | int i; |
---|
| 944 | enterSBba(p, atS, strat, atR); |
---|
[08ab82] | 945 | #ifdef KDEBUG |
---|
[35aab3] | 946 | if (TEST_OPT_DEBUG) |
---|
| 947 | { |
---|
| 948 | Print("new s%d:",atS); |
---|
| 949 | wrp(p.p); |
---|
| 950 | PrintLn(); |
---|
| 951 | } |
---|
[08ab82] | 952 | #endif |
---|
[35aab3] | 953 | if ((!strat->kHEdgeFound) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat); |
---|
| 954 | if (strat->kHEdgeFound) |
---|
| 955 | { |
---|
| 956 | if (newHEdge(strat->S,strat)) |
---|
| 957 | { |
---|
| 958 | firstUpdate(strat); |
---|
| 959 | if (BTEST1(27)) |
---|
| 960 | return; |
---|
| 961 | /*- cuts elements in L above noether and reorders L -*/ |
---|
| 962 | updateLHC(strat); |
---|
| 963 | /*- reorders L with respect to posInL -*/ |
---|
| 964 | reorderL(strat); |
---|
| 965 | } |
---|
| 966 | } |
---|
| 967 | else if (strat->kNoether!=NULL) |
---|
| 968 | strat->kHEdgeFound = TRUE; |
---|
| 969 | else if (TEST_OPT_FASTHC) |
---|
| 970 | { |
---|
| 971 | if (strat->posInLOldFlag) |
---|
| 972 | { |
---|
| 973 | missingAxis(&strat->lastAxis,strat); |
---|
| 974 | if (strat->lastAxis) |
---|
| 975 | { |
---|
| 976 | strat->posInLOld = strat->posInL; |
---|
| 977 | strat->posInLOldFlag = FALSE; |
---|
| 978 | strat->posInL = posInL10; |
---|
| 979 | strat->posInLDependsOnLength = TRUE; |
---|
| 980 | updateL(strat); |
---|
| 981 | reorderL(strat); |
---|
| 982 | } |
---|
| 983 | } |
---|
| 984 | else if (strat->lastAxis) |
---|
| 985 | updateL(strat); |
---|
| 986 | } |
---|
| 987 | } |
---|
| 988 | |
---|
| 989 | /*2 |
---|
| 990 | *-puts p to the standardbasis s at position at |
---|
| 991 | *-HEckeTest |
---|
| 992 | * if TRUE |
---|
| 993 | * - computes noether |
---|
| 994 | */ |
---|
| 995 | void enterSMoraNF (LObject p, int atS,kStrategy strat, int atR = -1) |
---|
| 996 | { |
---|
| 997 | int i; |
---|
| 998 | |
---|
| 999 | enterSBba(p, atS, strat, atR); |
---|
| 1000 | if ((!strat->kHEdgeFound) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat); |
---|
| 1001 | if (strat->kHEdgeFound) |
---|
| 1002 | newHEdge(strat->S,strat); |
---|
| 1003 | else if (strat->kNoether!=NULL) |
---|
| 1004 | strat->kHEdgeFound = TRUE; |
---|
| 1005 | } |
---|
| 1006 | |
---|
| 1007 | void initBba(ideal F,kStrategy strat) |
---|
| 1008 | { |
---|
| 1009 | int i; |
---|
| 1010 | idhdl h; |
---|
| 1011 | /* setting global variables ------------------- */ |
---|
| 1012 | strat->enterS = enterSBba; |
---|
[bdde4f4] | 1013 | strat->red = redHoney; |
---|
[35aab3] | 1014 | if (strat->honey) |
---|
| 1015 | strat->red = redHoney; |
---|
| 1016 | else if (pLexOrder && !strat->homog) |
---|
| 1017 | strat->red = redLazy; |
---|
| 1018 | else |
---|
[bdde4f4] | 1019 | { |
---|
| 1020 | strat->LazyPass *=4; |
---|
[35aab3] | 1021 | strat->red = redHomog; |
---|
[bdde4f4] | 1022 | } |
---|
[206e158] | 1023 | #ifdef HAVE_RINGS //TODO Oliver |
---|
[751a01] | 1024 | if (rField_is_Ring(currRing)) |
---|
| 1025 | { |
---|
[093f30e] | 1026 | strat->red = redRing; |
---|
[585bbcb] | 1027 | } |
---|
| 1028 | #endif |
---|
[35aab3] | 1029 | if (pLexOrder && strat->honey) |
---|
| 1030 | strat->initEcart = initEcartNormal; |
---|
| 1031 | else |
---|
| 1032 | strat->initEcart = initEcartBBA; |
---|
| 1033 | if (strat->honey) |
---|
| 1034 | strat->initEcartPair = initEcartPairMora; |
---|
| 1035 | else |
---|
| 1036 | strat->initEcartPair = initEcartPairBba; |
---|
| 1037 | strat->kIdeal = NULL; |
---|
| 1038 | //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD; |
---|
| 1039 | //else strat->kIdeal->rtyp=MODUL_CMD; |
---|
| 1040 | //strat->kIdeal->data=(void *)strat->Shdl; |
---|
| 1041 | if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1042 | { |
---|
| 1043 | //interred machen Aenderung |
---|
| 1044 | pFDegOld=pFDeg; |
---|
| 1045 | pLDegOld=pLDeg; |
---|
[e5a253] | 1046 | //h=ggetid("ecart"); |
---|
| 1047 | //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/) |
---|
| 1048 | //{ |
---|
| 1049 | // ecartWeights=iv2array(IDINTVEC(h)); |
---|
| 1050 | //} |
---|
| 1051 | //else |
---|
[35aab3] | 1052 | { |
---|
| 1053 | ecartWeights=(short *)omAlloc((pVariables+1)*sizeof(short)); |
---|
| 1054 | /*uses automatic computation of the ecartWeights to set them*/ |
---|
| 1055 | kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights); |
---|
| 1056 | } |
---|
| 1057 | pRestoreDegProcs(totaldegreeWecart, maxdegreeWecart); |
---|
| 1058 | if (TEST_OPT_PROT) |
---|
| 1059 | { |
---|
| 1060 | for(i=1; i<=pVariables; i++) |
---|
| 1061 | Print(" %d",ecartWeights[i]); |
---|
| 1062 | PrintLn(); |
---|
| 1063 | mflush(); |
---|
| 1064 | } |
---|
| 1065 | } |
---|
| 1066 | } |
---|
| 1067 | |
---|
| 1068 | void initMora(ideal F,kStrategy strat) |
---|
| 1069 | { |
---|
| 1070 | int i,j; |
---|
| 1071 | idhdl h; |
---|
| 1072 | |
---|
| 1073 | strat->NotUsedAxis = (BOOLEAN *)omAlloc((pVariables+1)*sizeof(BOOLEAN)); |
---|
| 1074 | for (j=pVariables; j>0; j--) strat->NotUsedAxis[j] = TRUE; |
---|
| 1075 | strat->enterS = enterSMora; |
---|
| 1076 | strat->initEcartPair = initEcartPairMora; /*- ecart approximation -*/ |
---|
| 1077 | strat->posInLOld = strat->posInL; |
---|
| 1078 | strat->posInLOldFlag = TRUE; |
---|
| 1079 | strat->initEcart = initEcartNormal; |
---|
| 1080 | strat->kHEdgeFound = ppNoether != NULL; |
---|
| 1081 | if ( strat->kHEdgeFound ) |
---|
| 1082 | strat->kNoether = pCopy(ppNoether); |
---|
| 1083 | else if (strat->kHEdgeFound || strat->homog) |
---|
| 1084 | strat->red = redFirst; /*take the first possible in T*/ |
---|
[04d04e0] | 1085 | #ifdef HAVE_RINGS //TODO Oliver |
---|
| 1086 | else if (rField_is_Ring(currRing)) |
---|
[093f30e] | 1087 | strat->red = redRing; |
---|
[04d04e0] | 1088 | #endif |
---|
[35aab3] | 1089 | else |
---|
| 1090 | strat->red = redEcart;/*take the first possible in under ecart-restriction*/ |
---|
| 1091 | if (strat->kHEdgeFound) |
---|
| 1092 | { |
---|
[b130fb] | 1093 | strat->HCord = pFDeg(ppNoether,currRing)+1; |
---|
[35aab3] | 1094 | strat->posInT = posInT2; |
---|
| 1095 | } |
---|
| 1096 | else |
---|
| 1097 | { |
---|
| 1098 | strat->HCord = 32000;/*- very large -*/ |
---|
| 1099 | } |
---|
| 1100 | /*reads the ecartWeights used for Graebes method from the |
---|
| 1101 | *intvec ecart and set ecartWeights |
---|
| 1102 | */ |
---|
| 1103 | if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1104 | { |
---|
| 1105 | //interred machen Aenderung |
---|
| 1106 | pFDegOld=pFDeg; |
---|
| 1107 | pLDegOld=pLDeg; |
---|
[e5a253] | 1108 | //h=ggetid("ecart"); |
---|
| 1109 | //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/) |
---|
| 1110 | //{ |
---|
| 1111 | // ecartWeights=iv2array(IDINTVEC(h)); |
---|
| 1112 | //} |
---|
| 1113 | //else |
---|
[35aab3] | 1114 | { |
---|
| 1115 | ecartWeights=(short *)omAlloc((pVariables+1)*sizeof(short)); |
---|
| 1116 | /*uses automatic computation of the ecartWeights to set them*/ |
---|
| 1117 | kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights); |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | pSetDegProcs(totaldegreeWecart, maxdegreeWecart); |
---|
| 1121 | if (TEST_OPT_PROT) |
---|
| 1122 | { |
---|
| 1123 | for(i=1; i<=pVariables; i++) |
---|
| 1124 | Print(" %d",ecartWeights[i]); |
---|
| 1125 | PrintLn(); |
---|
| 1126 | mflush(); |
---|
| 1127 | } |
---|
| 1128 | } |
---|
| 1129 | kOptimizeLDeg(pLDeg, strat); |
---|
| 1130 | } |
---|
| 1131 | |
---|
| 1132 | #ifdef HAVE_ASSUME |
---|
| 1133 | static int mora_count = 0; |
---|
| 1134 | static int mora_loop_count; |
---|
| 1135 | #endif |
---|
| 1136 | |
---|
| 1137 | ideal mora (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) |
---|
| 1138 | { |
---|
| 1139 | #ifdef HAVE_ASSUME |
---|
| 1140 | mora_count++; |
---|
| 1141 | mora_loop_count = 0; |
---|
| 1142 | #endif |
---|
| 1143 | #ifdef KDEBUG |
---|
| 1144 | om_Opts.MinTrack = 5; |
---|
| 1145 | #endif |
---|
| 1146 | int srmax; |
---|
| 1147 | int lrmax = 0; |
---|
| 1148 | int olddeg = 0; |
---|
| 1149 | int reduc = 0; |
---|
| 1150 | int red_result = 1; |
---|
| 1151 | int hilbeledeg=1,hilbcount=0; |
---|
| 1152 | |
---|
| 1153 | strat->update = TRUE; |
---|
| 1154 | /*- setting global variables ------------------- -*/ |
---|
| 1155 | initBuchMoraCrit(strat); |
---|
| 1156 | initHilbCrit(F,Q,&hilb,strat); |
---|
| 1157 | initMora(F,strat); |
---|
| 1158 | initBuchMoraPos(strat); |
---|
| 1159 | /*Shdl=*/initBuchMora(F,Q,strat); |
---|
| 1160 | if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat); |
---|
| 1161 | /*updateS in initBuchMora has Hecketest |
---|
| 1162 | * and could have put strat->kHEdgdeFound FALSE*/ |
---|
| 1163 | if (ppNoether!=NULL) |
---|
| 1164 | { |
---|
| 1165 | strat->kHEdgeFound = TRUE; |
---|
| 1166 | } |
---|
| 1167 | if (strat->kHEdgeFound && strat->update) |
---|
| 1168 | { |
---|
| 1169 | firstUpdate(strat); |
---|
| 1170 | updateLHC(strat); |
---|
| 1171 | reorderL(strat); |
---|
| 1172 | } |
---|
| 1173 | if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag) |
---|
| 1174 | { |
---|
| 1175 | strat->posInLOld = strat->posInL; |
---|
| 1176 | strat->posInLOldFlag = FALSE; |
---|
| 1177 | strat->posInL = posInL10; |
---|
| 1178 | updateL(strat); |
---|
| 1179 | reorderL(strat); |
---|
| 1180 | } |
---|
| 1181 | srmax = strat->sl; |
---|
| 1182 | kTest_TS(strat); |
---|
| 1183 | strat->use_buckets = kMoraUseBucket(strat); |
---|
| 1184 | /*- compute-------------------------------------------*/ |
---|
| 1185 | |
---|
| 1186 | #ifdef HAVE_TAIL_RING |
---|
| 1187 | // if (strat->homog && strat->red == redFirst) |
---|
| 1188 | kStratInitChangeTailRing(strat); |
---|
| 1189 | #endif |
---|
| 1190 | |
---|
| 1191 | while (strat->Ll >= 0) |
---|
| 1192 | { |
---|
| 1193 | #ifdef HAVE_ASSUME |
---|
| 1194 | mora_loop_count++; |
---|
| 1195 | #endif |
---|
| 1196 | if (lrmax< strat->Ll) lrmax=strat->Ll; /*stat*/ |
---|
| 1197 | //test_int_std(strat->kIdeal); |
---|
[08ab82] | 1198 | #ifdef KDEBUG |
---|
[35aab3] | 1199 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[08ab82] | 1200 | #endif |
---|
[35aab3] | 1201 | if (TEST_OPT_DEGBOUND |
---|
| 1202 | && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)) |
---|
| 1203 | { |
---|
| 1204 | /* |
---|
| 1205 | * stops computation if |
---|
| 1206 | * - 24 (degBound) |
---|
| 1207 | * && upper degree is bigger than Kstd1_deg |
---|
| 1208 | */ |
---|
| 1209 | while ((strat->Ll >= 0) |
---|
[939847] | 1210 | && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) |
---|
[35aab3] | 1211 | && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg) |
---|
[939847] | 1212 | ) |
---|
[35aab3] | 1213 | { |
---|
| 1214 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 1215 | //if (TEST_OPT_PROT) |
---|
| 1216 | //{ |
---|
| 1217 | // PrintS("D"); mflush(); |
---|
| 1218 | //} |
---|
| 1219 | } |
---|
| 1220 | if (strat->Ll<0) break; |
---|
[3957e37] | 1221 | else strat->noClearS=TRUE; |
---|
[35aab3] | 1222 | } |
---|
| 1223 | strat->P = strat->L[strat->Ll];/*- picks the last element from the lazyset L -*/ |
---|
| 1224 | if (strat->Ll==0) strat->interpt=TRUE; |
---|
| 1225 | strat->Ll--; |
---|
| 1226 | |
---|
| 1227 | // create the real Spoly |
---|
| 1228 | if (pNext(strat->P.p) == strat->tail) |
---|
| 1229 | { |
---|
| 1230 | /*- deletes the short spoly and computes -*/ |
---|
| 1231 | pLmFree(strat->P.p); |
---|
| 1232 | strat->P.p = NULL; |
---|
| 1233 | poly m1 = NULL, m2 = NULL; |
---|
| 1234 | // check that spoly creation is ok |
---|
| 1235 | while (strat->tailRing != currRing && |
---|
| 1236 | !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) |
---|
| 1237 | { |
---|
| 1238 | assume(m1 == NULL && m2 == NULL); |
---|
| 1239 | // if not, change to a ring where exponents are large enough |
---|
| 1240 | kStratChangeTailRing(strat); |
---|
| 1241 | } |
---|
| 1242 | /* create the real one */ |
---|
| 1243 | ksCreateSpoly(&(strat->P), strat->kNoetherTail(), strat->use_buckets, |
---|
| 1244 | strat->tailRing, m1, m2, strat->R); |
---|
| 1245 | if (!strat->use_buckets) |
---|
| 1246 | strat->P.SetLength(strat->length_pLength); |
---|
| 1247 | } |
---|
| 1248 | else if (strat->P.p1 == NULL) |
---|
| 1249 | { |
---|
| 1250 | // for input polys, prepare reduction (buckets !) |
---|
| 1251 | strat->P.SetLength(strat->length_pLength); |
---|
| 1252 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 1253 | } |
---|
| 1254 | |
---|
| 1255 | if (!strat->P.IsNull()) |
---|
| 1256 | { |
---|
| 1257 | // might be NULL from noether !!! |
---|
| 1258 | if (TEST_OPT_PROT) |
---|
| 1259 | message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result); |
---|
| 1260 | // reduce |
---|
| 1261 | red_result = strat->red(&strat->P,strat); |
---|
| 1262 | } |
---|
| 1263 | |
---|
| 1264 | if (! strat->P.IsNull()) |
---|
| 1265 | { |
---|
| 1266 | strat->P.GetP(); |
---|
| 1267 | // statistics |
---|
| 1268 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 1269 | // normalization |
---|
| 1270 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 1271 | strat->P.pNorm(); |
---|
| 1272 | // tailreduction |
---|
| 1273 | strat->P.p = redtail(&(strat->P),strat->sl,strat); |
---|
| 1274 | // set ecart -- might have changed because of tail reductions |
---|
| 1275 | if ((!strat->noTailReduction) && (!strat->honey)) |
---|
| 1276 | strat->initEcart(&strat->P); |
---|
[5d0052] | 1277 | // cancel unit |
---|
| 1278 | cancelunit(&strat->P); |
---|
[35aab3] | 1279 | // for char 0, clear denominators |
---|
| 1280 | if (TEST_OPT_INTSTRATEGY) |
---|
| 1281 | strat->P.pCleardenom(); |
---|
| 1282 | |
---|
| 1283 | // put in T |
---|
| 1284 | enterT(strat->P,strat); |
---|
| 1285 | // build new pairs |
---|
| 1286 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl); |
---|
| 1287 | // put in S |
---|
| 1288 | strat->enterS(strat->P, |
---|
| 1289 | posInS(strat,strat->sl,strat->P.p, strat->P.ecart), |
---|
| 1290 | strat, strat->tl); |
---|
| 1291 | |
---|
| 1292 | // apply hilbert criterion |
---|
| 1293 | if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 1294 | |
---|
| 1295 | // clear strat->P |
---|
| 1296 | if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); |
---|
| 1297 | strat->P.lcm=NULL; |
---|
| 1298 | #ifdef KDEBUG |
---|
| 1299 | // make sure kTest_TS does not complain about strat->P |
---|
| 1300 | memset(&strat->P,0,sizeof(strat->P)); |
---|
| 1301 | #endif |
---|
| 1302 | if (strat->sl>srmax) srmax = strat->sl; /*stat.*/ |
---|
| 1303 | if (strat->Ll>lrmax) lrmax = strat->Ll; |
---|
| 1304 | } |
---|
| 1305 | if (strat->kHEdgeFound) |
---|
| 1306 | { |
---|
| 1307 | if ((BTEST1(27)) |
---|
| 1308 | || ((TEST_OPT_MULTBOUND) && (scMult0Int((strat->Shdl)) < mu))) |
---|
| 1309 | { |
---|
| 1310 | // obachman: is this still used ??? |
---|
| 1311 | /* |
---|
| 1312 | * stops computation if strat->kHEdgeFound and |
---|
| 1313 | * - 27 (finiteDeterminacyTest) |
---|
| 1314 | * or |
---|
| 1315 | * - 23 |
---|
| 1316 | * (multBound) |
---|
| 1317 | * && multiplicity of the ideal is smaller then a predefined number mu |
---|
| 1318 | */ |
---|
| 1319 | while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 1320 | } |
---|
| 1321 | } |
---|
| 1322 | kTest_TS(strat); |
---|
| 1323 | } |
---|
| 1324 | /*- complete reduction of the standard basis------------------------ -*/ |
---|
| 1325 | if (TEST_OPT_REDSB) completeReduce(strat); |
---|
[5accf0] | 1326 | else if (TEST_OPT_PROT) PrintLn(); |
---|
[35aab3] | 1327 | /*- release temp data------------------------------- -*/ |
---|
| 1328 | exitBuchMora(strat); |
---|
| 1329 | /*- polynomials used for HECKE: HC, noether -*/ |
---|
| 1330 | if (BTEST1(27)) |
---|
| 1331 | { |
---|
| 1332 | if (strat->kHEdge!=NULL) |
---|
[b130fb] | 1333 | Kstd1_mu=pFDeg(strat->kHEdge,currRing); |
---|
[35aab3] | 1334 | else |
---|
| 1335 | Kstd1_mu=-1; |
---|
| 1336 | } |
---|
| 1337 | pDelete(&strat->kHEdge); |
---|
| 1338 | strat->update = TRUE; //??? |
---|
| 1339 | strat->lastAxis = 0; //??? |
---|
| 1340 | pDelete(&strat->kNoether); |
---|
| 1341 | omFreeSize((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN)); |
---|
| 1342 | if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat); |
---|
| 1343 | if (TEST_OPT_WEIGHTM) |
---|
| 1344 | { |
---|
| 1345 | pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 1346 | if (ecartWeights) |
---|
| 1347 | { |
---|
| 1348 | omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short)); |
---|
| 1349 | ecartWeights=NULL; |
---|
| 1350 | } |
---|
| 1351 | } |
---|
| 1352 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
| 1353 | idTest(strat->Shdl); |
---|
| 1354 | return (strat->Shdl); |
---|
| 1355 | } |
---|
| 1356 | |
---|
| 1357 | poly kNF1 (ideal F,ideal Q,poly q, kStrategy strat, int lazyReduce) |
---|
| 1358 | { |
---|
| 1359 | poly p; |
---|
| 1360 | int i; |
---|
| 1361 | int j; |
---|
| 1362 | int o; |
---|
| 1363 | LObject h; |
---|
| 1364 | BITSET save_test=test; |
---|
| 1365 | |
---|
| 1366 | if ((idIs0(F))&&(Q==NULL)) |
---|
| 1367 | return pCopy(q); /*F=0*/ |
---|
| 1368 | strat->ak = si_max(idRankFreeModule(F),pMaxComp(q)); |
---|
| 1369 | /*- creating temp data structures------------------- -*/ |
---|
| 1370 | strat->kHEdgeFound = ppNoether != NULL; |
---|
| 1371 | strat->kNoether = pCopy(ppNoether); |
---|
| 1372 | test|=Sy_bit(OPT_REDTAIL); |
---|
| 1373 | test&=~Sy_bit(OPT_INTSTRATEGY); |
---|
| 1374 | if (TEST_OPT_STAIRCASEBOUND |
---|
| 1375 | && (! TEST_V_DEG_STOP) |
---|
| 1376 | && (0<Kstd1_deg) |
---|
| 1377 | && ((!strat->kHEdgeFound) |
---|
| 1378 | ||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg)))) |
---|
| 1379 | { |
---|
| 1380 | pDelete(&strat->kNoether); |
---|
| 1381 | strat->kNoether=pOne(); |
---|
| 1382 | pSetExp(strat->kNoether,1, Kstd1_deg+1); |
---|
| 1383 | pSetm(strat->kNoether); |
---|
| 1384 | strat->kHEdgeFound=TRUE; |
---|
| 1385 | } |
---|
| 1386 | initBuchMoraCrit(strat); |
---|
| 1387 | initBuchMoraPos(strat); |
---|
| 1388 | initMora(F,strat); |
---|
| 1389 | strat->enterS = enterSMoraNF; |
---|
| 1390 | /*- set T -*/ |
---|
| 1391 | strat->tl = -1; |
---|
| 1392 | strat->tmax = setmaxT; |
---|
| 1393 | strat->T = initT(); |
---|
| 1394 | strat->R = initR(); |
---|
| 1395 | strat->sevT = initsevT(); |
---|
| 1396 | /*- set S -*/ |
---|
| 1397 | strat->sl = -1; |
---|
| 1398 | /*- init local data struct.-------------------------- -*/ |
---|
| 1399 | /*Shdl=*/initS(F,Q,strat); |
---|
| 1400 | if ((strat->ak!=0) |
---|
| 1401 | && (strat->kHEdgeFound)) |
---|
| 1402 | { |
---|
| 1403 | if (strat->ak!=1) |
---|
| 1404 | { |
---|
| 1405 | pSetComp(strat->kNoether,1); |
---|
| 1406 | pSetmComp(strat->kNoether); |
---|
| 1407 | poly p=pHead(strat->kNoether); |
---|
| 1408 | pSetComp(p,strat->ak); |
---|
| 1409 | pSetmComp(p); |
---|
| 1410 | p=pAdd(strat->kNoether,p); |
---|
| 1411 | strat->kNoether=pNext(p); |
---|
| 1412 | p_LmFree(p,currRing); |
---|
| 1413 | } |
---|
| 1414 | } |
---|
[18ff4c] | 1415 | if ((lazyReduce & KSTD_NF_LAZY)==0) |
---|
[35aab3] | 1416 | { |
---|
| 1417 | for (i=strat->sl; i>=0; i--) |
---|
| 1418 | pNorm(strat->S[i]); |
---|
| 1419 | } |
---|
| 1420 | /*- puts the elements of S also to T -*/ |
---|
| 1421 | for (i=0; i<=strat->sl; i++) |
---|
| 1422 | { |
---|
| 1423 | h.p = strat->S[i]; |
---|
| 1424 | h.ecart = strat->ecartS[i]; |
---|
| 1425 | if (strat->sevS[i] == 0) strat->sevS[i] = pGetShortExpVector(h.p); |
---|
| 1426 | else assume(strat->sevS[i] == pGetShortExpVector(h.p)); |
---|
| 1427 | h.length = pLength(h.p); |
---|
| 1428 | h.sev = strat->sevS[i]; |
---|
| 1429 | h.SetpFDeg(); |
---|
| 1430 | enterT(h,strat); |
---|
| 1431 | } |
---|
| 1432 | /*- compute------------------------------------------- -*/ |
---|
| 1433 | p = pCopy(q); |
---|
| 1434 | deleteHC(&p,&o,&j,strat); |
---|
| 1435 | if (TEST_OPT_PROT) { PrintS("r"); mflush(); } |
---|
[18ff4c] | 1436 | if (p!=NULL) p = redMoraNF(p,strat, lazyReduce & KSTD_NF_ECART); |
---|
| 1437 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
[35aab3] | 1438 | { |
---|
| 1439 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 1440 | p = redtail(p,strat->sl,strat); |
---|
| 1441 | } |
---|
| 1442 | /*- release temp data------------------------------- -*/ |
---|
| 1443 | cleanT(strat); |
---|
| 1444 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 1445 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 1446 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
| 1447 | omFreeSize((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN)); |
---|
| 1448 | omfree(strat->sevT); |
---|
| 1449 | omfree(strat->S_2_R); |
---|
| 1450 | omfree(strat->R); |
---|
| 1451 | |
---|
| 1452 | if ((Q!=NULL)&&(strat->fromQ!=NULL)) |
---|
| 1453 | { |
---|
| 1454 | i=((IDELEMS(Q)+IDELEMS(F)+15)/16)*16; |
---|
| 1455 | omFreeSize((ADDRESS)strat->fromQ,i*sizeof(int)); |
---|
| 1456 | strat->fromQ=NULL; |
---|
| 1457 | } |
---|
| 1458 | pDelete(&strat->kHEdge); |
---|
| 1459 | pDelete(&strat->kNoether); |
---|
| 1460 | if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1461 | { |
---|
| 1462 | pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 1463 | if (ecartWeights) |
---|
| 1464 | { |
---|
| 1465 | omFreeSize((ADDRESS *)&ecartWeights,(pVariables+1)*sizeof(short)); |
---|
| 1466 | ecartWeights=NULL; |
---|
| 1467 | } |
---|
| 1468 | } |
---|
| 1469 | idDelete(&strat->Shdl); |
---|
| 1470 | test=save_test; |
---|
| 1471 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 1472 | return p; |
---|
| 1473 | } |
---|
| 1474 | |
---|
| 1475 | ideal kNF1 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce) |
---|
| 1476 | { |
---|
| 1477 | poly p; |
---|
| 1478 | int i; |
---|
| 1479 | int j; |
---|
| 1480 | int o; |
---|
| 1481 | LObject h; |
---|
| 1482 | ideal res; |
---|
| 1483 | BITSET save_test=test; |
---|
| 1484 | |
---|
| 1485 | if (idIs0(q)) return idInit(IDELEMS(q),q->rank); |
---|
| 1486 | if ((idIs0(F))&&(Q==NULL)) |
---|
| 1487 | return idCopy(q); /*F=0*/ |
---|
| 1488 | strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(q)); |
---|
| 1489 | /*- creating temp data structures------------------- -*/ |
---|
| 1490 | strat->kHEdgeFound = ppNoether != NULL; |
---|
| 1491 | strat->kNoether=pCopy(ppNoether); |
---|
| 1492 | test|=Sy_bit(OPT_REDTAIL); |
---|
| 1493 | if (TEST_OPT_STAIRCASEBOUND |
---|
| 1494 | && (0<Kstd1_deg) |
---|
| 1495 | && ((!strat->kHEdgeFound) |
---|
| 1496 | ||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg)))) |
---|
| 1497 | { |
---|
| 1498 | pDelete(&strat->kNoether); |
---|
| 1499 | strat->kNoether=pOne(); |
---|
| 1500 | pSetExp(strat->kNoether,1, Kstd1_deg+1); |
---|
| 1501 | pSetm(strat->kNoether); |
---|
| 1502 | strat->kHEdgeFound=TRUE; |
---|
| 1503 | } |
---|
| 1504 | initBuchMoraCrit(strat); |
---|
| 1505 | initBuchMoraPos(strat); |
---|
| 1506 | initMora(F,strat); |
---|
| 1507 | strat->enterS = enterSMoraNF; |
---|
| 1508 | /*- set T -*/ |
---|
| 1509 | strat->tl = -1; |
---|
| 1510 | strat->tmax = setmaxT; |
---|
| 1511 | strat->T = initT(); |
---|
| 1512 | strat->R = initR(); |
---|
| 1513 | strat->sevT = initsevT(); |
---|
| 1514 | /*- set S -*/ |
---|
| 1515 | strat->sl = -1; |
---|
| 1516 | /*- init local data struct.-------------------------- -*/ |
---|
| 1517 | /*Shdl=*/initS(F,Q,strat); |
---|
| 1518 | if ((strat->ak!=0) |
---|
| 1519 | && (strat->kHEdgeFound)) |
---|
| 1520 | { |
---|
| 1521 | if (strat->ak!=1) |
---|
| 1522 | { |
---|
| 1523 | pSetComp(strat->kNoether,1); |
---|
| 1524 | pSetmComp(strat->kNoether); |
---|
| 1525 | poly p=pHead(strat->kNoether); |
---|
| 1526 | pSetComp(p,strat->ak); |
---|
| 1527 | pSetmComp(p); |
---|
| 1528 | p=pAdd(strat->kNoether,p); |
---|
| 1529 | strat->kNoether=pNext(p); |
---|
| 1530 | p_LmFree(p,currRing); |
---|
| 1531 | } |
---|
| 1532 | } |
---|
[18ff4c] | 1533 | if (TEST_OPT_INTSTRATEGY && ((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
[35aab3] | 1534 | { |
---|
| 1535 | for (i=strat->sl; i>=0; i--) |
---|
| 1536 | pNorm(strat->S[i]); |
---|
| 1537 | } |
---|
| 1538 | /*- compute------------------------------------------- -*/ |
---|
| 1539 | res=idInit(IDELEMS(q),q->rank); |
---|
| 1540 | for (i=0; i<IDELEMS(q); i++) |
---|
| 1541 | { |
---|
| 1542 | if (q->m[i]!=NULL) |
---|
| 1543 | { |
---|
| 1544 | p = pCopy(q->m[i]); |
---|
| 1545 | deleteHC(&p,&o,&j,strat); |
---|
| 1546 | if (p!=NULL) |
---|
| 1547 | { |
---|
| 1548 | /*- puts the elements of S also to T -*/ |
---|
| 1549 | for (j=0; j<=strat->sl; j++) |
---|
| 1550 | { |
---|
| 1551 | h.p = strat->S[j]; |
---|
| 1552 | h.ecart = strat->ecartS[j]; |
---|
| 1553 | h.pLength = h.length = pLength(h.p); |
---|
| 1554 | if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p); |
---|
| 1555 | else assume(strat->sevS[j] == pGetShortExpVector(h.p)); |
---|
| 1556 | h.sev = strat->sevS[j]; |
---|
| 1557 | h.SetpFDeg(); |
---|
| 1558 | enterT(h,strat); |
---|
| 1559 | } |
---|
| 1560 | if (TEST_OPT_PROT) { PrintS("r"); mflush(); } |
---|
[18ff4c] | 1561 | p = redMoraNF(p,strat, lazyReduce & KSTD_NF_ECART); |
---|
| 1562 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
[35aab3] | 1563 | { |
---|
| 1564 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 1565 | p = redtail(p,strat->sl,strat); |
---|
| 1566 | } |
---|
| 1567 | cleanT(strat); |
---|
| 1568 | } |
---|
| 1569 | res->m[i]=p; |
---|
| 1570 | } |
---|
| 1571 | //else |
---|
| 1572 | // res->m[i]=NULL; |
---|
| 1573 | } |
---|
| 1574 | /*- release temp data------------------------------- -*/ |
---|
| 1575 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 1576 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 1577 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
| 1578 | omFreeSize((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN)); |
---|
| 1579 | omfree(strat->sevT); |
---|
| 1580 | omfree(strat->S_2_R); |
---|
| 1581 | omfree(strat->R); |
---|
| 1582 | if ((Q!=NULL)&&(strat->fromQ!=NULL)) |
---|
| 1583 | { |
---|
| 1584 | i=((IDELEMS(Q)+IDELEMS(F)+15)/16)*16; |
---|
| 1585 | omFreeSize((ADDRESS)strat->fromQ,i*sizeof(int)); |
---|
| 1586 | strat->fromQ=NULL; |
---|
| 1587 | } |
---|
| 1588 | pDelete(&strat->kHEdge); |
---|
| 1589 | pDelete(&strat->kNoether); |
---|
| 1590 | if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1591 | { |
---|
| 1592 | pFDeg=pFDegOld; |
---|
| 1593 | pLDeg=pLDegOld; |
---|
| 1594 | if (ecartWeights) |
---|
| 1595 | { |
---|
| 1596 | omFreeSize((ADDRESS *)&ecartWeights,(pVariables+1)*sizeof(short)); |
---|
| 1597 | ecartWeights=NULL; |
---|
| 1598 | } |
---|
| 1599 | } |
---|
| 1600 | idDelete(&strat->Shdl); |
---|
| 1601 | test=save_test; |
---|
| 1602 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 1603 | return res; |
---|
| 1604 | } |
---|
| 1605 | |
---|
| 1606 | pFDegProc pFDegOld; |
---|
| 1607 | pLDegProc pLDegOld; |
---|
| 1608 | intvec * kModW, * kHomW; |
---|
| 1609 | |
---|
| 1610 | long kModDeg(poly p, ring r) |
---|
| 1611 | { |
---|
| 1612 | long o=pWDegree(p, r); |
---|
| 1613 | long i=p_GetComp(p, r); |
---|
| 1614 | if (i==0) return o; |
---|
| 1615 | assume((i>0) && (i<=kModW->length())); |
---|
| 1616 | return o+(*kModW)[i-1]; |
---|
| 1617 | } |
---|
| 1618 | long kHomModDeg(poly p, ring r) |
---|
| 1619 | { |
---|
| 1620 | int i; |
---|
| 1621 | long j=0; |
---|
| 1622 | |
---|
| 1623 | for (i=r->N;i>0;i--) |
---|
| 1624 | j+=p_GetExp(p,i,r)*(*kHomW)[i-1]; |
---|
| 1625 | if (kModW == NULL) return j; |
---|
| 1626 | i = p_GetComp(p,r); |
---|
| 1627 | if (i==0) return j; |
---|
| 1628 | return j+(*kModW)[i-1]; |
---|
| 1629 | } |
---|
| 1630 | |
---|
| 1631 | ideal kStd(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp, |
---|
| 1632 | int newIdeal, intvec *vw) |
---|
| 1633 | { |
---|
| 1634 | ideal r; |
---|
| 1635 | BOOLEAN b=pLexOrder,toReset=FALSE; |
---|
| 1636 | BOOLEAN delete_w=(w==NULL); |
---|
| 1637 | kStrategy strat=new skStrategy; |
---|
| 1638 | |
---|
| 1639 | if(!TEST_OPT_RETURN_SB) |
---|
| 1640 | strat->syzComp = syzComp; |
---|
| 1641 | if (TEST_OPT_SB_1) |
---|
| 1642 | strat->newIdeal = newIdeal; |
---|
| 1643 | if (rField_has_simple_inverse()) |
---|
| 1644 | strat->LazyPass=20; |
---|
| 1645 | else |
---|
| 1646 | strat->LazyPass=2; |
---|
| 1647 | strat->LazyDegree = 1; |
---|
| 1648 | strat->ak = idRankFreeModule(F); |
---|
| 1649 | strat->kModW=kModW=NULL; |
---|
| 1650 | strat->kHomW=kHomW=NULL; |
---|
| 1651 | if (vw != NULL) |
---|
| 1652 | { |
---|
| 1653 | pLexOrder=FALSE; |
---|
| 1654 | strat->kHomW=kHomW=vw; |
---|
| 1655 | pFDegOld = pFDeg; |
---|
| 1656 | pLDegOld = pLDeg; |
---|
| 1657 | pSetDegProcs(kHomModDeg); |
---|
| 1658 | toReset = TRUE; |
---|
| 1659 | } |
---|
| 1660 | if (h==testHomog) |
---|
| 1661 | { |
---|
| 1662 | if (strat->ak == 0) |
---|
| 1663 | { |
---|
| 1664 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 1665 | w=NULL; |
---|
| 1666 | } |
---|
| 1667 | else if (!TEST_OPT_DEGBOUND) |
---|
| 1668 | { |
---|
| 1669 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 1670 | } |
---|
| 1671 | } |
---|
| 1672 | pLexOrder=b; |
---|
| 1673 | if (h==isHomog) |
---|
| 1674 | { |
---|
| 1675 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 1676 | { |
---|
| 1677 | strat->kModW = kModW = *w; |
---|
| 1678 | if (vw == NULL) |
---|
| 1679 | { |
---|
| 1680 | pFDegOld = pFDeg; |
---|
| 1681 | pLDegOld = pLDeg; |
---|
| 1682 | pSetDegProcs(kModDeg); |
---|
| 1683 | toReset = TRUE; |
---|
| 1684 | } |
---|
| 1685 | } |
---|
| 1686 | pLexOrder = TRUE; |
---|
| 1687 | if (hilb==NULL) strat->LazyPass*=2; |
---|
| 1688 | } |
---|
| 1689 | strat->homog=h; |
---|
| 1690 | #ifdef KDEBUG |
---|
| 1691 | idTest(F); |
---|
| 1692 | #endif |
---|
| 1693 | #ifdef HAVE_PLURAL |
---|
| 1694 | if (rIsPluralRing(currRing)) |
---|
| 1695 | { |
---|
| 1696 | if (w!=NULL) |
---|
[5a9e7b] | 1697 | r = nc_GB(F, Q, *w, hilb, strat); |
---|
[35aab3] | 1698 | else |
---|
[5a9e7b] | 1699 | r = nc_GB(F, Q, NULL, hilb, strat); |
---|
[35aab3] | 1700 | } |
---|
| 1701 | else |
---|
[5a9e7b] | 1702 | #endif |
---|
[35aab3] | 1703 | { |
---|
[5a9e7b] | 1704 | if (pOrdSgn==-1) |
---|
| 1705 | { |
---|
| 1706 | if (w!=NULL) |
---|
| 1707 | r=mora(F,Q,*w,hilb,strat); |
---|
| 1708 | else |
---|
| 1709 | r=mora(F,Q,NULL,hilb,strat); |
---|
| 1710 | } |
---|
[35aab3] | 1711 | else |
---|
[5a9e7b] | 1712 | { |
---|
| 1713 | if (w!=NULL) |
---|
| 1714 | r=bba(F,Q,*w,hilb,strat); |
---|
| 1715 | else |
---|
| 1716 | r=bba(F,Q,NULL,hilb,strat); |
---|
| 1717 | } |
---|
[35aab3] | 1718 | } |
---|
| 1719 | #ifdef KDEBUG |
---|
| 1720 | idTest(r); |
---|
| 1721 | #endif |
---|
| 1722 | if (toReset) |
---|
| 1723 | { |
---|
| 1724 | kModW = NULL; |
---|
| 1725 | pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 1726 | } |
---|
| 1727 | pLexOrder = b; |
---|
[1c473f] | 1728 | //Print("%d reductions canceled \n",strat->cel); |
---|
| 1729 | HCord=strat->HCord; |
---|
| 1730 | delete(strat); |
---|
| 1731 | if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w; |
---|
| 1732 | return r; |
---|
| 1733 | } |
---|
| 1734 | |
---|
| 1735 | ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp, |
---|
| 1736 | int newIdeal, intvec *vw, int uptodeg, int lV) |
---|
| 1737 | { |
---|
| 1738 | ideal r; |
---|
| 1739 | BOOLEAN b=pLexOrder,toReset=FALSE; |
---|
| 1740 | BOOLEAN delete_w=(w==NULL); |
---|
| 1741 | kStrategy strat=new skStrategy; |
---|
| 1742 | |
---|
| 1743 | if(!TEST_OPT_RETURN_SB) |
---|
| 1744 | strat->syzComp = syzComp; |
---|
| 1745 | if (TEST_OPT_SB_1) |
---|
| 1746 | strat->newIdeal = newIdeal; |
---|
| 1747 | if (rField_has_simple_inverse()) |
---|
| 1748 | strat->LazyPass=20; |
---|
| 1749 | else |
---|
| 1750 | strat->LazyPass=2; |
---|
| 1751 | strat->LazyDegree = 1; |
---|
| 1752 | strat->ak = idRankFreeModule(F); |
---|
| 1753 | strat->kModW=kModW=NULL; |
---|
| 1754 | strat->kHomW=kHomW=NULL; |
---|
| 1755 | if (vw != NULL) |
---|
| 1756 | { |
---|
| 1757 | pLexOrder=FALSE; |
---|
| 1758 | strat->kHomW=kHomW=vw; |
---|
| 1759 | pFDegOld = pFDeg; |
---|
| 1760 | pLDegOld = pLDeg; |
---|
| 1761 | pSetDegProcs(kHomModDeg); |
---|
| 1762 | toReset = TRUE; |
---|
| 1763 | } |
---|
| 1764 | if (h==testHomog) |
---|
| 1765 | { |
---|
| 1766 | if (strat->ak == 0) |
---|
| 1767 | { |
---|
| 1768 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 1769 | w=NULL; |
---|
| 1770 | } |
---|
| 1771 | else if (!TEST_OPT_DEGBOUND) |
---|
| 1772 | { |
---|
| 1773 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 1774 | } |
---|
| 1775 | } |
---|
| 1776 | pLexOrder=b; |
---|
| 1777 | if (h==isHomog) |
---|
| 1778 | { |
---|
| 1779 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 1780 | { |
---|
| 1781 | strat->kModW = kModW = *w; |
---|
| 1782 | if (vw == NULL) |
---|
| 1783 | { |
---|
| 1784 | pFDegOld = pFDeg; |
---|
| 1785 | pLDegOld = pLDeg; |
---|
| 1786 | pSetDegProcs(kModDeg); |
---|
| 1787 | toReset = TRUE; |
---|
| 1788 | } |
---|
| 1789 | } |
---|
| 1790 | pLexOrder = TRUE; |
---|
| 1791 | if (hilb==NULL) strat->LazyPass*=2; |
---|
| 1792 | } |
---|
| 1793 | strat->homog=h; |
---|
| 1794 | #ifdef KDEBUG |
---|
| 1795 | idTest(F); |
---|
| 1796 | #endif |
---|
| 1797 | if (pOrdSgn==-1) |
---|
| 1798 | { |
---|
| 1799 | /* error: no local ord yet with shifts */ |
---|
| 1800 | Print("No local ordering possible for shifts"); |
---|
| 1801 | return(NULL); |
---|
| 1802 | } |
---|
| 1803 | else |
---|
| 1804 | { |
---|
| 1805 | /* global ordering */ |
---|
| 1806 | if (w!=NULL) |
---|
| 1807 | r=bbaShift(F,Q,*w,hilb,strat,uptodeg,lV); |
---|
| 1808 | else |
---|
| 1809 | r=bbaShift(F,Q,NULL,hilb,strat,uptodeg,lV); |
---|
| 1810 | } |
---|
| 1811 | #ifdef KDEBUG |
---|
| 1812 | idTest(r); |
---|
| 1813 | #endif |
---|
| 1814 | if (toReset) |
---|
| 1815 | { |
---|
| 1816 | kModW = NULL; |
---|
| 1817 | pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 1818 | } |
---|
| 1819 | pLexOrder = b; |
---|
[35aab3] | 1820 | //Print("%d reductions canceled \n",strat->cel); |
---|
| 1821 | HCord=strat->HCord; |
---|
| 1822 | delete(strat); |
---|
| 1823 | if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w; |
---|
| 1824 | return r; |
---|
| 1825 | } |
---|
| 1826 | |
---|
| 1827 | //############################################################## |
---|
| 1828 | //############################################################## |
---|
| 1829 | //############################################################## |
---|
| 1830 | //############################################################## |
---|
| 1831 | //############################################################## |
---|
| 1832 | |
---|
| 1833 | ideal kMin_std(ideal F, ideal Q, tHomog h,intvec ** w, ideal &M, intvec *hilb, |
---|
| 1834 | int syzComp, int reduced) |
---|
| 1835 | { |
---|
| 1836 | ideal r=NULL; |
---|
| 1837 | int Kstd1_OldDeg = Kstd1_deg,i; |
---|
| 1838 | intvec* temp_w=NULL; |
---|
| 1839 | BOOLEAN b=pLexOrder,toReset=FALSE; |
---|
| 1840 | BOOLEAN delete_w=(w==NULL); |
---|
| 1841 | BOOLEAN oldDegBound=TEST_OPT_DEGBOUND; |
---|
| 1842 | kStrategy strat=new skStrategy; |
---|
| 1843 | |
---|
| 1844 | if(!TEST_OPT_RETURN_SB) |
---|
| 1845 | strat->syzComp = syzComp; |
---|
| 1846 | if (rField_has_simple_inverse()) |
---|
| 1847 | strat->LazyPass=20; |
---|
| 1848 | else |
---|
| 1849 | strat->LazyPass=2; |
---|
| 1850 | strat->LazyDegree = 1; |
---|
| 1851 | strat->minim=(reduced % 2)+1; |
---|
| 1852 | strat->ak = idRankFreeModule(F); |
---|
| 1853 | if (delete_w) |
---|
| 1854 | { |
---|
| 1855 | temp_w=new intvec((strat->ak)+1); |
---|
| 1856 | w = &temp_w; |
---|
| 1857 | } |
---|
| 1858 | if ((h==testHomog) |
---|
| 1859 | ) |
---|
| 1860 | { |
---|
| 1861 | if (strat->ak == 0) |
---|
| 1862 | { |
---|
| 1863 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 1864 | w=NULL; |
---|
| 1865 | } |
---|
| 1866 | else |
---|
| 1867 | { |
---|
| 1868 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 1869 | } |
---|
| 1870 | } |
---|
| 1871 | if (h==isHomog) |
---|
| 1872 | { |
---|
| 1873 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 1874 | { |
---|
| 1875 | kModW = *w; |
---|
| 1876 | strat->kModW = *w; |
---|
| 1877 | assume(pFDeg != NULL && pLDeg != NULL); |
---|
| 1878 | pFDegOld = pFDeg; |
---|
| 1879 | pLDegOld = pLDeg; |
---|
| 1880 | pSetDegProcs(kModDeg); |
---|
| 1881 | |
---|
| 1882 | toReset = TRUE; |
---|
| 1883 | if (reduced>1) |
---|
| 1884 | { |
---|
| 1885 | Kstd1_OldDeg=Kstd1_deg; |
---|
| 1886 | Kstd1_deg = -1; |
---|
| 1887 | for (i=IDELEMS(F)-1;i>=0;i--) |
---|
| 1888 | { |
---|
[b130fb] | 1889 | if ((F->m[i]!=NULL) && (pFDeg(F->m[i],currRing)>=Kstd1_deg)) |
---|
| 1890 | Kstd1_deg = pFDeg(F->m[i],currRing)+1; |
---|
[35aab3] | 1891 | } |
---|
| 1892 | } |
---|
| 1893 | } |
---|
| 1894 | pLexOrder = TRUE; |
---|
| 1895 | strat->LazyPass*=2; |
---|
| 1896 | } |
---|
| 1897 | strat->homog=h; |
---|
| 1898 | if (pOrdSgn==-1) |
---|
| 1899 | { |
---|
| 1900 | if (w!=NULL) |
---|
| 1901 | r=mora(F,Q,*w,hilb,strat); |
---|
| 1902 | else |
---|
| 1903 | r=mora(F,Q,NULL,hilb,strat); |
---|
| 1904 | } |
---|
| 1905 | else |
---|
| 1906 | { |
---|
| 1907 | if (w!=NULL) |
---|
| 1908 | r=bba(F,Q,*w,hilb,strat); |
---|
| 1909 | else |
---|
| 1910 | r=bba(F,Q,NULL,hilb,strat); |
---|
| 1911 | } |
---|
| 1912 | #ifdef KDEBUG |
---|
| 1913 | { |
---|
| 1914 | int i; |
---|
| 1915 | for (i=IDELEMS(r)-1; i>=0; i--) pTest(r->m[i]); |
---|
| 1916 | } |
---|
| 1917 | #endif |
---|
| 1918 | idSkipZeroes(r); |
---|
| 1919 | if (toReset) |
---|
| 1920 | { |
---|
| 1921 | pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 1922 | kModW = NULL; |
---|
| 1923 | } |
---|
| 1924 | pLexOrder = b; |
---|
| 1925 | HCord=strat->HCord; |
---|
| 1926 | if ((delete_w)&&(temp_w!=NULL)) delete temp_w; |
---|
[15bfa8] | 1927 | if ((IDELEMS(r)==1) && (r->m[0]!=NULL) && pIsConstant(r->m[0]) && (strat->ak==0)) |
---|
| 1928 | { |
---|
[f52515c] | 1929 | M=idInit(1,F->rank); |
---|
[15bfa8] | 1930 | M->m[0]=pOne(); |
---|
| 1931 | //if (strat->ak!=0) { pSetComp(M->m[0],strat->ak); pSetmComp(M->m[0]); } |
---|
[716335] | 1932 | if (strat->M!=NULL) idDelete(&strat->M); |
---|
[15bfa8] | 1933 | } |
---|
| 1934 | else |
---|
[35aab3] | 1935 | if (strat->M==NULL) |
---|
| 1936 | { |
---|
| 1937 | M=idInit(1,F->rank); |
---|
| 1938 | Warn("no minimal generating set computed"); |
---|
| 1939 | } |
---|
| 1940 | else |
---|
| 1941 | { |
---|
| 1942 | idSkipZeroes(strat->M); |
---|
| 1943 | M=strat->M; |
---|
| 1944 | } |
---|
| 1945 | delete(strat); |
---|
| 1946 | if (reduced>2) |
---|
| 1947 | { |
---|
| 1948 | Kstd1_deg=Kstd1_OldDeg; |
---|
| 1949 | if (!oldDegBound) |
---|
| 1950 | test &= ~Sy_bit(OPT_DEGBOUND); |
---|
| 1951 | } |
---|
| 1952 | return r; |
---|
| 1953 | } |
---|
| 1954 | |
---|
| 1955 | poly kNF(ideal F, ideal Q, poly p,int syzComp, int lazyReduce) |
---|
| 1956 | { |
---|
| 1957 | if (p==NULL) |
---|
| 1958 | return NULL; |
---|
| 1959 | kStrategy strat=new skStrategy; |
---|
| 1960 | strat->syzComp = syzComp; |
---|
[52e2f6] | 1961 | |
---|
| 1962 | poly pp = p; |
---|
| 1963 | |
---|
| 1964 | #ifdef HAVE_PLURAL |
---|
| 1965 | if(rIsSCA(currRing)) |
---|
| 1966 | { |
---|
| 1967 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 1968 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 1969 | pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 1970 | |
---|
| 1971 | if(Q == currQuotient) |
---|
| 1972 | Q = SCAQuotient(currRing); |
---|
| 1973 | } |
---|
| 1974 | #endif |
---|
| 1975 | |
---|
| 1976 | poly res; |
---|
| 1977 | |
---|
[35aab3] | 1978 | if (pOrdSgn==-1) |
---|
[52e2f6] | 1979 | res=kNF1(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 1980 | else |
---|
[52e2f6] | 1981 | res=kNF2(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 1982 | delete(strat); |
---|
[52e2f6] | 1983 | |
---|
| 1984 | #ifdef HAVE_PLURAL |
---|
| 1985 | if(pp != p) |
---|
| 1986 | p_Delete(&pp, currRing); |
---|
| 1987 | #endif |
---|
| 1988 | |
---|
| 1989 | return res; |
---|
[35aab3] | 1990 | } |
---|
| 1991 | |
---|
| 1992 | ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce) |
---|
| 1993 | { |
---|
| 1994 | ideal res; |
---|
| 1995 | if (TEST_OPT_PROT) |
---|
| 1996 | { |
---|
| 1997 | Print("(S:%d)",IDELEMS(p));mflush(); |
---|
| 1998 | } |
---|
| 1999 | kStrategy strat=new skStrategy; |
---|
| 2000 | strat->syzComp = syzComp; |
---|
[52e2f6] | 2001 | |
---|
| 2002 | ideal pp = p; |
---|
| 2003 | #ifdef HAVE_PLURAL |
---|
| 2004 | if(rIsSCA(currRing)) |
---|
| 2005 | { |
---|
| 2006 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 2007 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 2008 | pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 2009 | |
---|
| 2010 | if(Q == currQuotient) |
---|
| 2011 | Q = SCAQuotient(currRing); |
---|
| 2012 | } |
---|
| 2013 | #endif |
---|
| 2014 | |
---|
[35aab3] | 2015 | if (pOrdSgn==-1) |
---|
[52e2f6] | 2016 | res=kNF1(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 2017 | else |
---|
[52e2f6] | 2018 | res=kNF2(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 2019 | delete(strat); |
---|
[52e2f6] | 2020 | |
---|
| 2021 | #ifdef HAVE_PLURAL |
---|
| 2022 | if(pp != p) |
---|
| 2023 | id_Delete(&pp, currRing); |
---|
| 2024 | #endif |
---|
| 2025 | |
---|
| 2026 | |
---|
[35aab3] | 2027 | return res; |
---|
| 2028 | } |
---|
| 2029 | |
---|
| 2030 | /*2 |
---|
| 2031 | *interreduces F |
---|
| 2032 | */ |
---|
| 2033 | #if 0 |
---|
| 2034 | // new version |
---|
[16493d] | 2035 | ideal kInterRed (ideal F, ideal Q) |
---|
[35aab3] | 2036 | { |
---|
[16493d] | 2037 | int srmax,lrmax, red_result = 1; |
---|
| 2038 | int olddeg,reduc,j; |
---|
| 2039 | BOOLEAN need_update=FALSE; |
---|
[35aab3] | 2040 | |
---|
[16493d] | 2041 | kStrategy strat = new skStrategy; |
---|
| 2042 | strat->kHEdgeFound = ppNoether != NULL; |
---|
| 2043 | strat->kNoether=pCopy(ppNoether); |
---|
[35aab3] | 2044 | strat->ak = idRankFreeModule(F); |
---|
[16493d] | 2045 | initBuchMoraCrit(strat); |
---|
| 2046 | initBuchMoraPos(strat); |
---|
| 2047 | strat->NotUsedAxis = (BOOLEAN *)omAlloc((pVariables+1)*sizeof(BOOLEAN)); |
---|
| 2048 | for (j=pVariables; j>0; j--) strat->NotUsedAxis[j] = TRUE; |
---|
| 2049 | strat->enterS = enterSBba; |
---|
| 2050 | strat->posInT = posInT17; |
---|
| 2051 | strat->initEcart = initEcartNormal; |
---|
| 2052 | strat->sl = -1; |
---|
| 2053 | strat->tl = -1; |
---|
| 2054 | strat->Ll = -1; |
---|
| 2055 | strat->tmax = setmaxT; |
---|
| 2056 | strat->Lmax = setmaxL; |
---|
| 2057 | strat->T = initT(); |
---|
| 2058 | strat->R = initR(); |
---|
| 2059 | strat->L = initL(); |
---|
| 2060 | strat->sevT = initsevT(); |
---|
| 2061 | strat->red = redLazy; |
---|
[04d04e0] | 2062 | #ifdef HAVE_RINGS //TODO Oliver |
---|
| 2063 | if (rField_is_Ring(currRing)) { |
---|
[093f30e] | 2064 | strat->red = redRing; |
---|
[04d04e0] | 2065 | } |
---|
| 2066 | #endif |
---|
[16493d] | 2067 | strat->tailRing = currRing; |
---|
| 2068 | if (pOrdSgn == -1) |
---|
| 2069 | strat->honey = TRUE; |
---|
| 2070 | initSL(F,Q,strat); |
---|
| 2071 | for(j=strat->Ll; j>=0; j--) |
---|
| 2072 | strat->L[j].tailRing=currRing; |
---|
| 2073 | if (TEST_OPT_REDSB) |
---|
| 2074 | strat->noTailReduction=FALSE; |
---|
| 2075 | |
---|
| 2076 | srmax = strat->sl; |
---|
| 2077 | reduc = olddeg = lrmax = 0; |
---|
| 2078 | |
---|
| 2079 | #ifndef NO_BUCKETS |
---|
| 2080 | if (!TEST_OPT_NOT_BUCKETS) |
---|
| 2081 | strat->use_buckets = 1; |
---|
| 2082 | #endif |
---|
| 2083 | |
---|
| 2084 | // strat->posInT = posInT_pLength; |
---|
| 2085 | kTest_TS(strat); |
---|
| 2086 | |
---|
| 2087 | /* compute------------------------------------------------------- */ |
---|
| 2088 | while (strat->Ll >= 0) |
---|
[35aab3] | 2089 | { |
---|
[16493d] | 2090 | if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/ |
---|
[08ab82] | 2091 | #ifdef KDEBUG |
---|
[16493d] | 2092 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[08ab82] | 2093 | #endif |
---|
[16493d] | 2094 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
| 2095 | /* picks the last element from the lazyset L */ |
---|
| 2096 | strat->P = strat->L[strat->Ll]; |
---|
| 2097 | strat->Ll--; |
---|
| 2098 | |
---|
| 2099 | // for input polys, prepare reduction |
---|
| 2100 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 2101 | |
---|
| 2102 | if (strat->P.p == NULL && strat->P.t_p == NULL) |
---|
[35aab3] | 2103 | { |
---|
[16493d] | 2104 | red_result = 0; |
---|
[35aab3] | 2105 | } |
---|
[16493d] | 2106 | else |
---|
| 2107 | { |
---|
| 2108 | if (TEST_OPT_PROT) |
---|
| 2109 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
| 2110 | &olddeg,&reduc,strat, red_result); |
---|
| 2111 | |
---|
| 2112 | /* reduction of the element choosen from L */ |
---|
| 2113 | red_result = strat->red(&strat->P,strat); |
---|
| 2114 | } |
---|
| 2115 | |
---|
| 2116 | // reduction to non-zero new poly |
---|
| 2117 | if (red_result == 1) |
---|
| 2118 | { |
---|
| 2119 | /* statistic */ |
---|
| 2120 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 2121 | |
---|
| 2122 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 2123 | strat->P.GetP(strat->lmBin); |
---|
| 2124 | |
---|
| 2125 | int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 2126 | |
---|
| 2127 | // reduce the tail and normalize poly |
---|
| 2128 | if (TEST_OPT_INTSTRATEGY) |
---|
| 2129 | { |
---|
| 2130 | strat->P.pCleardenom(); |
---|
| 2131 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 2132 | { |
---|
| 2133 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, FALSE); |
---|
| 2134 | strat->P.pCleardenom(); |
---|
| 2135 | } |
---|
| 2136 | } |
---|
| 2137 | else |
---|
| 2138 | { |
---|
| 2139 | strat->P.pNorm(); |
---|
| 2140 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 2141 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, FALSE); |
---|
| 2142 | } |
---|
| 2143 | |
---|
| 2144 | #ifdef KDEBUG |
---|
| 2145 | if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} |
---|
| 2146 | #endif |
---|
| 2147 | |
---|
| 2148 | // enter into S, L, and T |
---|
| 2149 | enterT(strat->P, strat); |
---|
| 2150 | // posInS only depends on the leading term |
---|
| 2151 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
| 2152 | if (pos<strat->sl) |
---|
| 2153 | { |
---|
| 2154 | need_update=TRUE; |
---|
| 2155 | #if 0 |
---|
| 2156 | LObject h; |
---|
| 2157 | for(j=strat->sl;j>pos;j--) |
---|
| 2158 | { |
---|
| 2159 | if (TEST_OPT_PROT) { PrintS("+"); mflush(); } |
---|
| 2160 | memset(&h, 0, sizeof(h)); |
---|
| 2161 | h.p=strat->S[j]; |
---|
| 2162 | int i; |
---|
| 2163 | for(i=strat->tl;i>=0;i--) |
---|
| 2164 | { |
---|
| 2165 | if (pLmCmp(h.p,strat->T[i].p)==0) |
---|
| 2166 | { |
---|
| 2167 | if (i < strat->tl) |
---|
| 2168 | { |
---|
| 2169 | #ifdef ENTER_USE_MEMMOVE |
---|
| 2170 | memmove(&(strat->T[i]), &(strat->T[i+1]), |
---|
| 2171 | (strat->tl-i)*sizeof(TObject)); |
---|
| 2172 | memmove(&(strat->sevT[i]), &(strat->sevT[i+1]), |
---|
| 2173 | (strat->tl-i)*sizeof(unsigned long)); |
---|
| 2174 | #endif |
---|
| 2175 | for (int l=i; l<strat->tl; l++) |
---|
| 2176 | { |
---|
| 2177 | #ifndef ENTER_USE_MEMMOVE |
---|
| 2178 | strat->T[l] = strat->T[l+1]; |
---|
| 2179 | strat->sevT[l] = strat->sevT[l+1]; |
---|
| 2180 | #endif |
---|
| 2181 | strat->R[strat->T[l].i_r] = &(strat->T[l]); |
---|
| 2182 | } |
---|
| 2183 | } |
---|
| 2184 | strat->tl--; |
---|
| 2185 | break; |
---|
| 2186 | } |
---|
| 2187 | } |
---|
| 2188 | strat->S[j]=NULL; |
---|
| 2189 | strat->sl--; |
---|
| 2190 | if (TEST_OPT_INTSTRATEGY) |
---|
| 2191 | { |
---|
| 2192 | //pContent(h.p); |
---|
| 2193 | h.pCleardenom(); // also does a pContent |
---|
| 2194 | } |
---|
| 2195 | else |
---|
| 2196 | { |
---|
| 2197 | h.pNorm(); |
---|
| 2198 | } |
---|
| 2199 | strat->initEcart(&h); |
---|
| 2200 | if (strat->Ll==-1) |
---|
| 2201 | pos =0; |
---|
| 2202 | else |
---|
| 2203 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 2204 | h.sev = pGetShortExpVector(h.p); |
---|
| 2205 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 2206 | } |
---|
| 2207 | #endif |
---|
| 2208 | } |
---|
| 2209 | if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); |
---|
| 2210 | if (strat->sl>srmax) srmax = strat->sl; |
---|
| 2211 | } |
---|
| 2212 | #ifdef KDEBUG |
---|
| 2213 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 2214 | #endif |
---|
| 2215 | kTest_TS(strat); |
---|
[35aab3] | 2216 | } |
---|
| 2217 | #ifdef KDEBUG |
---|
[16493d] | 2218 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[35aab3] | 2219 | #endif |
---|
[16493d] | 2220 | /* complete reduction of the standard basis--------- */ |
---|
| 2221 | if (TEST_OPT_REDSB) |
---|
[35aab3] | 2222 | { |
---|
[16493d] | 2223 | completeReduce(strat); |
---|
| 2224 | if (strat->completeReduce_retry) |
---|
| 2225 | { |
---|
| 2226 | // completeReduce needed larger exponents, retry |
---|
| 2227 | // to reduce with S (instead of T) |
---|
| 2228 | // and in currRing (instead of strat->tailRing) |
---|
| 2229 | cleanT(strat);strat->tailRing=currRing; |
---|
| 2230 | int i; |
---|
| 2231 | for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1; |
---|
| 2232 | completeReduce(strat); |
---|
| 2233 | } |
---|
[35aab3] | 2234 | } |
---|
[5accf0] | 2235 | else if (TEST_OPT_PROT) PrintLn(); |
---|
[16493d] | 2236 | |
---|
| 2237 | /* release temp data-------------------------------- */ |
---|
| 2238 | if (TEST_OPT_PROT) messageStat(srmax,lrmax,0,strat); |
---|
| 2239 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
| 2240 | ideal shdl=strat->Shdl; |
---|
| 2241 | idSkipZeroes(shdl); |
---|
| 2242 | pDelete(&strat->kHEdge); |
---|
| 2243 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 2244 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 2245 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
| 2246 | omFreeSize((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN)); |
---|
| 2247 | omFreeSize((ADDRESS)strat->L,(strat->Lmax)*sizeof(LObject)); |
---|
| 2248 | omfree(strat->sevT); |
---|
| 2249 | omfree(strat->S_2_R); |
---|
| 2250 | omfree(strat->R); |
---|
| 2251 | |
---|
| 2252 | if (strat->fromQ) |
---|
[35aab3] | 2253 | { |
---|
[16493d] | 2254 | for (j=IDELEMS(strat->Shdl)-1;j>=0;j--) |
---|
| 2255 | { |
---|
| 2256 | if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]); |
---|
| 2257 | } |
---|
| 2258 | omFreeSize((ADDRESS)strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 2259 | strat->fromQ=NULL; |
---|
[35aab3] | 2260 | } |
---|
[16493d] | 2261 | delete(strat); |
---|
| 2262 | #if 0 |
---|
| 2263 | if (need_update) |
---|
[35aab3] | 2264 | { |
---|
[16493d] | 2265 | ideal res=kInterRed(shdl,Q); |
---|
| 2266 | idDelete(&shdl); |
---|
| 2267 | shdl=res; |
---|
[35aab3] | 2268 | } |
---|
[16493d] | 2269 | #endif |
---|
| 2270 | return shdl; |
---|
[35aab3] | 2271 | } |
---|
| 2272 | #else |
---|
| 2273 | // old version |
---|
| 2274 | ideal kInterRed (ideal F, ideal Q) |
---|
| 2275 | { |
---|
| 2276 | int j; |
---|
| 2277 | kStrategy strat = new skStrategy; |
---|
| 2278 | |
---|
[32b0000] | 2279 | ideal tempF = F; |
---|
| 2280 | ideal tempQ = Q; |
---|
| 2281 | |
---|
| 2282 | #ifdef HAVE_PLURAL |
---|
| 2283 | if(rIsSCA(currRing)) |
---|
| 2284 | { |
---|
| 2285 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 2286 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 2287 | tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 2288 | |
---|
| 2289 | // this should be done on the upper level!!! : |
---|
[52e2f6] | 2290 | // tempQ = SCAQuotient(currRing); |
---|
[32b0000] | 2291 | |
---|
| 2292 | if(Q == currQuotient) |
---|
[52e2f6] | 2293 | tempQ = SCAQuotient(currRing); |
---|
[32b0000] | 2294 | } |
---|
| 2295 | #endif |
---|
[18ff4c] | 2296 | |
---|
[35aab3] | 2297 | // if (TEST_OPT_PROT) |
---|
| 2298 | // { |
---|
| 2299 | // writeTime("start InterRed:"); |
---|
| 2300 | // mflush(); |
---|
| 2301 | // } |
---|
| 2302 | //strat->syzComp = 0; |
---|
| 2303 | strat->kHEdgeFound = ppNoether != NULL; |
---|
| 2304 | strat->kNoether=pCopy(ppNoether); |
---|
[32b0000] | 2305 | strat->ak = idRankFreeModule(tempF); |
---|
[35aab3] | 2306 | initBuchMoraCrit(strat); |
---|
| 2307 | strat->NotUsedAxis = (BOOLEAN *)omAlloc((pVariables+1)*sizeof(BOOLEAN)); |
---|
| 2308 | for (j=pVariables; j>0; j--) strat->NotUsedAxis[j] = TRUE; |
---|
| 2309 | strat->enterS = enterSBba; |
---|
| 2310 | strat->posInT = posInT17; |
---|
| 2311 | strat->initEcart = initEcartNormal; |
---|
| 2312 | strat->sl = -1; |
---|
| 2313 | strat->tl = -1; |
---|
| 2314 | strat->tmax = setmaxT; |
---|
| 2315 | strat->T = initT(); |
---|
| 2316 | strat->R = initR(); |
---|
| 2317 | strat->sevT = initsevT(); |
---|
| 2318 | if (pOrdSgn == -1) strat->honey = TRUE; |
---|
[32b0000] | 2319 | initS(tempF, tempQ, strat); |
---|
[35aab3] | 2320 | if (TEST_OPT_REDSB) |
---|
| 2321 | strat->noTailReduction=FALSE; |
---|
| 2322 | updateS(TRUE,strat); |
---|
| 2323 | if (TEST_OPT_REDSB && TEST_OPT_INTSTRATEGY) |
---|
| 2324 | completeReduce(strat); |
---|
[5accf0] | 2325 | //else if (TEST_OPT_PROT) PrintLn(); |
---|
[35aab3] | 2326 | pDelete(&strat->kHEdge); |
---|
| 2327 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 2328 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 2329 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
| 2330 | omFreeSize((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN)); |
---|
| 2331 | omfree(strat->sevT); |
---|
| 2332 | omfree(strat->S_2_R); |
---|
| 2333 | omfree(strat->R); |
---|
| 2334 | |
---|
| 2335 | if (strat->fromQ) |
---|
| 2336 | { |
---|
| 2337 | for (j=IDELEMS(strat->Shdl)-1;j>=0;j--) |
---|
| 2338 | { |
---|
| 2339 | if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]); |
---|
| 2340 | } |
---|
| 2341 | omFreeSize((ADDRESS)strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 2342 | } |
---|
| 2343 | // if (TEST_OPT_PROT) |
---|
| 2344 | // { |
---|
| 2345 | // writeTime("end Interred:"); |
---|
| 2346 | // mflush(); |
---|
| 2347 | // } |
---|
| 2348 | ideal shdl=strat->Shdl; |
---|
| 2349 | idSkipZeroes(shdl); |
---|
[5accf0] | 2350 | if (strat->fromQ) |
---|
| 2351 | { |
---|
| 2352 | strat->fromQ=NULL; |
---|
| 2353 | ideal res=kInterRed(shdl,NULL); |
---|
| 2354 | idDelete(&shdl); |
---|
| 2355 | shdl=res; |
---|
| 2356 | } |
---|
[35aab3] | 2357 | delete(strat); |
---|
[32b0000] | 2358 | |
---|
| 2359 | #ifdef HAVE_PLURAL |
---|
| 2360 | if( tempF != F ) |
---|
| 2361 | id_Delete( &tempF, currRing); |
---|
| 2362 | #endif |
---|
[18ff4c] | 2363 | |
---|
[35aab3] | 2364 | return shdl; |
---|
| 2365 | } |
---|
| 2366 | #endif |
---|
| 2367 | |
---|
| 2368 | // returns TRUE if mora should use buckets, false otherwise |
---|
| 2369 | static BOOLEAN kMoraUseBucket(kStrategy strat) |
---|
| 2370 | { |
---|
| 2371 | #ifdef MORA_USE_BUCKETS |
---|
| 2372 | if (TEST_OPT_NOT_BUCKETS) |
---|
| 2373 | return FALSE; |
---|
| 2374 | if (strat->red == redFirst) |
---|
| 2375 | { |
---|
| 2376 | #ifdef NO_LDEG |
---|
[b981502] | 2377 | if (strat->syzComp==0) |
---|
[35aab3] | 2378 | return TRUE; |
---|
| 2379 | #else |
---|
[b981502] | 2380 | if ((strat->homog || strat->honey) && (strat->syzComp==0)) |
---|
[35aab3] | 2381 | return TRUE; |
---|
| 2382 | #endif |
---|
| 2383 | } |
---|
| 2384 | else |
---|
| 2385 | { |
---|
| 2386 | assume(strat->red == redEcart); |
---|
[b981502] | 2387 | if (strat->honey && (strat->syzComp==0)) |
---|
[35aab3] | 2388 | return TRUE; |
---|
| 2389 | } |
---|
| 2390 | #endif |
---|
| 2391 | return FALSE; |
---|
| 2392 | } |
---|