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