[35aab3] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
| 4 | /* |
---|
| 5 | * ABSTRACT: |
---|
| 6 | */ |
---|
| 7 | |
---|
[645a19] | 8 | // TODO: why the following is here instead of mod2.h??? |
---|
[35aab3] | 9 | |
---|
| 10 | |
---|
[645a19] | 11 | // define if buckets should be used |
---|
| 12 | #define MORA_USE_BUCKETS |
---|
| 13 | |
---|
[ef2729] | 14 | //#define ADIDEBUG 0 |
---|
| 15 | //#define ADIDEBUG_NF 0 |
---|
[5efbf9] | 16 | #define PRE_INTEGER_CHECK 0 |
---|
[c25b56c] | 17 | |
---|
[89f4843] | 18 | #include "kernel/mod2.h" |
---|
[c6e80e] | 19 | |
---|
[89f4843] | 20 | #include "omalloc/omalloc.h" |
---|
[fd1b1be] | 21 | |
---|
[89f4843] | 22 | #include "misc/options.h" |
---|
| 23 | #include "misc/intvec.h" |
---|
[c6e80e] | 24 | |
---|
[89f4843] | 25 | #include "polys/weight.h" |
---|
| 26 | #include "kernel/polys.h" |
---|
[c6e80e] | 27 | |
---|
[89f4843] | 28 | #include "kernel/GBEngine/kutil.h" |
---|
| 29 | #include "kernel/GBEngine/kstd1.h" |
---|
| 30 | #include "kernel/GBEngine/khstd.h" |
---|
| 31 | #include "kernel/combinatorics/stairc.h" |
---|
| 32 | #include "kernel/ideals.h" |
---|
[35aab3] | 33 | |
---|
| 34 | //#include "ipprint.h" |
---|
| 35 | |
---|
[32b0000] | 36 | #ifdef HAVE_PLURAL |
---|
[89f4843] | 37 | #include "polys/nc/nc.h" |
---|
| 38 | #include "polys/nc/sca.h" |
---|
| 39 | #include "kernel/GBEngine/nc.h" |
---|
[32b0000] | 40 | #endif |
---|
| 41 | |
---|
[89f4843] | 42 | #include "kernel/GBEngine/kInline.h" |
---|
[c6e80e] | 43 | |
---|
[32b0000] | 44 | |
---|
[35aab3] | 45 | /* the list of all options which give a warning by test */ |
---|
| 46 | BITSET kOptions=Sy_bit(OPT_PROT) /* 0 */ |
---|
| 47 | |Sy_bit(OPT_REDSB) /* 1 */ |
---|
| 48 | |Sy_bit(OPT_NOT_SUGAR) /* 3 */ |
---|
| 49 | |Sy_bit(OPT_INTERRUPT) /* 4 */ |
---|
| 50 | |Sy_bit(OPT_SUGARCRIT) /* 5 */ |
---|
| 51 | |Sy_bit(OPT_REDTHROUGH) |
---|
| 52 | |Sy_bit(OPT_OLDSTD) |
---|
| 53 | |Sy_bit(OPT_FASTHC) /* 10 */ |
---|
| 54 | |Sy_bit(OPT_INTSTRATEGY) /* 26 */ |
---|
| 55 | |Sy_bit(OPT_INFREDTAIL) /* 28 */ |
---|
| 56 | |Sy_bit(OPT_NOTREGULARITY) /* 30 */ |
---|
| 57 | |Sy_bit(OPT_WEIGHTM); /* 31 */ |
---|
| 58 | |
---|
| 59 | /* the list of all options which may be used by option and test */ |
---|
[fb12237] | 60 | /* defintion of ALL options: libpolys/misc/options.h */ |
---|
[35aab3] | 61 | BITSET validOpts=Sy_bit(0) |
---|
| 62 | |Sy_bit(1) |
---|
| 63 | |Sy_bit(2) // obachman 10/00: replaced by notBucket |
---|
| 64 | |Sy_bit(3) |
---|
| 65 | |Sy_bit(4) |
---|
| 66 | |Sy_bit(5) |
---|
| 67 | |Sy_bit(6) |
---|
| 68 | // |Sy_bit(7) obachman 11/00 tossed: 12/00 used for redThrough |
---|
[750e70] | 69 | |Sy_bit(7) // OPT_REDTHROUGH |
---|
| 70 | |Sy_bit(8) // obachman 11/00 tossed -> motsak 2011 experimental: OPT_NO_SYZ_MINIM |
---|
[35aab3] | 71 | |Sy_bit(9) |
---|
| 72 | |Sy_bit(10) |
---|
| 73 | |Sy_bit(11) |
---|
| 74 | |Sy_bit(12) |
---|
| 75 | |Sy_bit(13) |
---|
| 76 | |Sy_bit(14) |
---|
| 77 | |Sy_bit(15) |
---|
| 78 | |Sy_bit(16) |
---|
| 79 | |Sy_bit(17) |
---|
| 80 | |Sy_bit(18) |
---|
| 81 | |Sy_bit(19) |
---|
| 82 | // |Sy_bit(20) obachman 11/00 tossed: 12/00 used for redOldStd |
---|
[d544b1] | 83 | |Sy_bit(OPT_OLDSTD) |
---|
[35aab3] | 84 | |Sy_bit(21) |
---|
| 85 | |Sy_bit(22) |
---|
| 86 | /*|Sy_bit(23)*/ |
---|
| 87 | /*|Sy_bit(24)*/ |
---|
| 88 | |Sy_bit(OPT_REDTAIL) |
---|
| 89 | |Sy_bit(OPT_INTSTRATEGY) |
---|
| 90 | |Sy_bit(27) |
---|
| 91 | |Sy_bit(28) |
---|
| 92 | |Sy_bit(29) |
---|
| 93 | |Sy_bit(30) |
---|
| 94 | |Sy_bit(31); |
---|
| 95 | |
---|
| 96 | //static BOOLEAN posInLOldFlag; |
---|
| 97 | /*FALSE, if posInL == posInL10*/ |
---|
| 98 | // returns TRUE if mora should use buckets, false otherwise |
---|
| 99 | static BOOLEAN kMoraUseBucket(kStrategy strat); |
---|
| 100 | |
---|
| 101 | static void kOptimizeLDeg(pLDegProc ldeg, kStrategy strat) |
---|
| 102 | { |
---|
[485b5d] | 103 | // if (strat->ak == 0 && !rIsSyzIndexRing(currRing)) |
---|
[35aab3] | 104 | strat->length_pLength = TRUE; |
---|
[485b5d] | 105 | // else |
---|
| 106 | // strat->length_pLength = FALSE; |
---|
[35aab3] | 107 | |
---|
[485b5d] | 108 | if ((ldeg == pLDeg0c /*&& !rIsSyzIndexRing(currRing)*/) || |
---|
[35aab3] | 109 | (ldeg == pLDeg0 && strat->ak == 0)) |
---|
| 110 | { |
---|
| 111 | strat->LDegLast = TRUE; |
---|
| 112 | } |
---|
| 113 | else |
---|
| 114 | { |
---|
| 115 | strat->LDegLast = FALSE; |
---|
| 116 | } |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | |
---|
[2a4bc6e] | 120 | static int doRed (LObject* h, TObject* with,BOOLEAN intoT,kStrategy strat, bool redMoraNF) |
---|
[35aab3] | 121 | { |
---|
| 122 | int ret; |
---|
| 123 | #if KDEBUG > 0 |
---|
[eb55f8a] | 124 | kTest_L(h); |
---|
| 125 | kTest_T(with); |
---|
[35aab3] | 126 | #endif |
---|
| 127 | // Hmmm ... why do we do this -- polys from T should already be normalized |
---|
| 128 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 129 | with->pNorm(); |
---|
| 130 | #ifdef KDEBUG |
---|
| 131 | if (TEST_OPT_DEBUG) |
---|
| 132 | { |
---|
| 133 | PrintS("reduce ");h->wrp();PrintS(" with ");with->wrp();PrintLn(); |
---|
| 134 | } |
---|
| 135 | #endif |
---|
| 136 | if (intoT) |
---|
| 137 | { |
---|
| 138 | // need to do it exacly like this: otherwise |
---|
| 139 | // we might get errors |
---|
| 140 | LObject L= *h; |
---|
| 141 | L.Copy(); |
---|
| 142 | h->GetP(); |
---|
[100bd4] | 143 | h->length=h->pLength=pLength(h->p); |
---|
[35aab3] | 144 | ret = ksReducePoly(&L, with, strat->kNoetherTail(), NULL, strat); |
---|
| 145 | if (ret) |
---|
| 146 | { |
---|
| 147 | if (ret < 0) return ret; |
---|
| 148 | if (h->tailRing != strat->tailRing) |
---|
| 149 | h->ShallowCopyDelete(strat->tailRing, |
---|
| 150 | pGetShallowCopyDeleteProc(h->tailRing, |
---|
| 151 | strat->tailRing)); |
---|
| 152 | } |
---|
[e21795] | 153 | if(redMoraNF && (rField_is_Ring(currRing))) |
---|
[2a4bc6e] | 154 | enterT_strong(*h,strat); |
---|
| 155 | else |
---|
| 156 | enterT(*h,strat); |
---|
[35aab3] | 157 | *h = L; |
---|
| 158 | } |
---|
| 159 | else |
---|
| 160 | ret = ksReducePoly(h, with, strat->kNoetherTail(), NULL, strat); |
---|
| 161 | #ifdef KDEBUG |
---|
| 162 | if (TEST_OPT_DEBUG) |
---|
| 163 | { |
---|
| 164 | PrintS("to ");h->wrp();PrintLn(); |
---|
| 165 | } |
---|
| 166 | #endif |
---|
| 167 | return ret; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | int redEcart (LObject* h,kStrategy strat) |
---|
| 171 | { |
---|
[d5564f8] | 172 | int i,at,ei,li,ii; |
---|
[35aab3] | 173 | int j = 0; |
---|
| 174 | int pass = 0; |
---|
[d5564f8] | 175 | long d,reddeg; |
---|
[35aab3] | 176 | |
---|
| 177 | d = h->GetpFDeg()+ h->ecart; |
---|
| 178 | reddeg = strat->LazyDegree+d; |
---|
| 179 | h->SetShortExpVector(); |
---|
| 180 | loop |
---|
| 181 | { |
---|
[a576b0] | 182 | j = kFindDivisibleByInT(strat, h); |
---|
[35aab3] | 183 | if (j < 0) |
---|
| 184 | { |
---|
| 185 | if (strat->honey) h->SetLength(strat->length_pLength); |
---|
| 186 | return 1; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | ei = strat->T[j].ecart; |
---|
| 190 | ii = j; |
---|
| 191 | |
---|
| 192 | if (ei > h->ecart && ii < strat->tl) |
---|
| 193 | { |
---|
| 194 | li = strat->T[j].length; |
---|
| 195 | // the polynomial to reduce with (up to the moment) is; |
---|
| 196 | // pi with ecart ei and length li |
---|
| 197 | // look for one with smaller ecart |
---|
| 198 | i = j; |
---|
| 199 | loop |
---|
| 200 | { |
---|
| 201 | /*- takes the first possible with respect to ecart -*/ |
---|
| 202 | i++; |
---|
| 203 | #if 1 |
---|
| 204 | if (i > strat->tl) break; |
---|
| 205 | if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei && |
---|
| 206 | strat->T[i].length < li)) |
---|
| 207 | && |
---|
| 208 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing)) |
---|
| 209 | #else |
---|
[a576b0] | 210 | j = kFindDivisibleByInT(strat, h, i); |
---|
[35aab3] | 211 | if (j < 0) break; |
---|
| 212 | i = j; |
---|
| 213 | if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei && |
---|
| 214 | strat->T[i].length < li)) |
---|
| 215 | #endif |
---|
| 216 | { |
---|
| 217 | // the polynomial to reduce with is now |
---|
| 218 | ii = i; |
---|
| 219 | ei = strat->T[i].ecart; |
---|
| 220 | if (ei <= h->ecart) break; |
---|
| 221 | li = strat->T[i].length; |
---|
| 222 | } |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | // end of search: have to reduce with pi |
---|
| 227 | if (ei > h->ecart) |
---|
| 228 | { |
---|
| 229 | // It is not possible to reduce h with smaller ecart; |
---|
| 230 | // if possible h goes to the lazy-set L,i.e |
---|
| 231 | // if its position in L would be not the last one |
---|
| 232 | strat->fromT = TRUE; |
---|
[228b631] | 233 | if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/ |
---|
[35aab3] | 234 | { |
---|
| 235 | h->SetLmCurrRing(); |
---|
| 236 | if (strat->honey && strat->posInLDependsOnLength) |
---|
| 237 | h->SetLength(strat->length_pLength); |
---|
| 238 | assume(h->FDeg == h->pFDeg()); |
---|
| 239 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 240 | if (at <= strat->Ll) |
---|
| 241 | { |
---|
| 242 | /*- h will not become the next element to reduce -*/ |
---|
| 243 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 244 | #ifdef KDEBUG |
---|
| 245 | if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at); |
---|
| 246 | #endif |
---|
| 247 | h->Clear(); |
---|
| 248 | strat->fromT = FALSE; |
---|
| 249 | return -1; |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | // now we finally can reduce |
---|
[2a4bc6e] | 255 | doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE); |
---|
[35aab3] | 256 | strat->fromT=FALSE; |
---|
| 257 | |
---|
| 258 | // are we done ??? |
---|
| 259 | if (h->IsNull()) |
---|
| 260 | { |
---|
[56d884] | 261 | assume(!rField_is_Ring(currRing)); |
---|
[35aab3] | 262 | if (h->lcm!=NULL) pLmFree(h->lcm); |
---|
| 263 | h->Clear(); |
---|
| 264 | return 0; |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | // NO! |
---|
| 268 | h->SetShortExpVector(); |
---|
| 269 | h->SetpFDeg(); |
---|
| 270 | if (strat->honey) |
---|
| 271 | { |
---|
| 272 | if (ei <= h->ecart) |
---|
| 273 | h->ecart = d-h->GetpFDeg(); |
---|
| 274 | else |
---|
| 275 | h->ecart = d-h->GetpFDeg()+ei-h->ecart; |
---|
| 276 | } |
---|
| 277 | else |
---|
| 278 | // this has the side effect of setting h->length |
---|
| 279 | h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg(); |
---|
[b981502] | 280 | #if 0 |
---|
[35aab3] | 281 | if (strat->syzComp!=0) |
---|
| 282 | { |
---|
| 283 | if ((strat->syzComp>0) && (h->Comp() > strat->syzComp)) |
---|
| 284 | { |
---|
| 285 | assume(h->MinComp() > strat->syzComp); |
---|
| 286 | if (strat->honey) h->SetLength(); |
---|
| 287 | #ifdef KDEBUG |
---|
| 288 | if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
| 289 | #endif |
---|
| 290 | return -2; |
---|
| 291 | } |
---|
| 292 | } |
---|
[b981502] | 293 | #endif |
---|
[35aab3] | 294 | /*- try to reduce the s-polynomial -*/ |
---|
| 295 | pass++; |
---|
| 296 | d = h->GetpFDeg()+h->ecart; |
---|
| 297 | /* |
---|
| 298 | *test whether the polynomial should go to the lazyset L |
---|
| 299 | *-if the degree jumps |
---|
| 300 | *-if the number of pre-defined reductions jumps |
---|
| 301 | */ |
---|
[228b631] | 302 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) |
---|
[35aab3] | 303 | && ((d >= reddeg) || (pass > strat->LazyPass))) |
---|
| 304 | { |
---|
| 305 | h->SetLmCurrRing(); |
---|
| 306 | if (strat->honey && strat->posInLDependsOnLength) |
---|
| 307 | h->SetLength(strat->length_pLength); |
---|
| 308 | assume(h->FDeg == h->pFDeg()); |
---|
| 309 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 310 | if (at <= strat->Ll) |
---|
| 311 | { |
---|
[391323] | 312 | int dummy=strat->sl; |
---|
| 313 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
[35aab3] | 314 | { |
---|
| 315 | if (strat->honey && !strat->posInLDependsOnLength) |
---|
| 316 | h->SetLength(strat->length_pLength); |
---|
| 317 | return 1; |
---|
| 318 | } |
---|
| 319 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 320 | #ifdef KDEBUG |
---|
| 321 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
| 322 | #endif |
---|
| 323 | h->Clear(); |
---|
| 324 | return -1; |
---|
| 325 | } |
---|
| 326 | } |
---|
| 327 | else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
| 328 | { |
---|
[dd8a7d] | 329 | Print(".%ld",d);mflush(); |
---|
[35aab3] | 330 | reddeg = d+1; |
---|
[32ad2a] | 331 | if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask) |
---|
[d5564f8] | 332 | { |
---|
[d95cee] | 333 | strat->overflow=TRUE; |
---|
[d5564f8] | 334 | //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask); |
---|
[d95cee] | 335 | h->GetP(); |
---|
| 336 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 337 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 338 | h->Clear(); |
---|
[d5564f8] | 339 | return -1; |
---|
| 340 | } |
---|
[35aab3] | 341 | } |
---|
| 342 | } |
---|
| 343 | } |
---|
| 344 | |
---|
[42a81e] | 345 | #ifdef HAVE_RINGS |
---|
[c25b56c] | 346 | int redRiloc (LObject* h,kStrategy strat) |
---|
| 347 | { |
---|
| 348 | int i,at,ei,li,ii; |
---|
| 349 | int j = 0; |
---|
| 350 | int pass = 0; |
---|
| 351 | long d,reddeg; |
---|
[601105] | 352 | |
---|
| 353 | |
---|
[ef2729] | 354 | #ifdef ADIDEBUG_NF |
---|
[601105] | 355 | int iii; |
---|
[fc58b5b] | 356 | PrintS("\n---------------------------- NEW REDRILOC COMPUTATION ----------------------------\n"); |
---|
| 357 | PrintS(" The pair h :\n"); |
---|
| 358 | PrintS("\n p1 = "); p_Write(h->p1,strat->tailRing); |
---|
| 359 | PrintS("\n p2 = "); p_Write(h->p2,strat->tailRing); |
---|
| 360 | PrintS("\n p = "); p_Write(h->p,strat->tailRing); |
---|
| 361 | PrintS("\n The actual reducer T is: "); |
---|
[601105] | 362 | if(strat->tl<0) |
---|
[3ffb5ca] | 363 | {PrintS(" Empty.\n");} |
---|
[601105] | 364 | else |
---|
[f3db6e] | 365 | { |
---|
[3ffb5ca] | 366 | for (iii=0;iii<=strat->tl;iii++) |
---|
| 367 | { |
---|
[fc58b5b] | 368 | Print("\n T[%i] = ",iii);p_Write(strat->T[iii].p,strat->tailRing); |
---|
[3ffb5ca] | 369 | } |
---|
[f3db6e] | 370 | } |
---|
| 371 | #endif /* ADIDEBUG_NF */ |
---|
[601105] | 372 | |
---|
[c25b56c] | 373 | d = h->GetpFDeg()+ h->ecart; |
---|
| 374 | reddeg = strat->LazyDegree+d; |
---|
| 375 | h->SetShortExpVector(); |
---|
[ef2729] | 376 | #ifdef ADIDEBUG_NF |
---|
[fb12237] | 377 | Print("\n Searching for a poly in T that divides h (of ecart %i) ...\n",h->ecart); |
---|
[f3db6e] | 378 | #endif |
---|
[c25b56c] | 379 | loop |
---|
| 380 | { |
---|
[a576b0] | 381 | j = kFindDivisibleByInT(strat, h); |
---|
[ef2729] | 382 | #ifdef ADIDEBUG_NF |
---|
[f3db6e] | 383 | if(j != -1) |
---|
| 384 | { |
---|
| 385 | ei = strat->T[j].ecart; |
---|
[fb12237] | 386 | Print("\n Found one: T[%i] of ecart %i: ",j,ei); |
---|
| 387 | p_Write(strat->T[j].p,strat->tailRing); |
---|
| 388 | PrintS("\n Try to find another with smaller ecart:\n"); |
---|
[f3db6e] | 389 | } |
---|
| 390 | else |
---|
| 391 | { |
---|
[fb12237] | 392 | PrintS("\n No poly in T divides h.\n"); |
---|
[f3db6e] | 393 | } |
---|
[c1c2ccd] | 394 | //getchar(); |
---|
[f3db6e] | 395 | #endif |
---|
[c25b56c] | 396 | if (j < 0) |
---|
| 397 | { |
---|
[3ffb5ca] | 398 | // over ZZ: cleanup coefficients by complete reduction with monomials |
---|
| 399 | postReduceByMon(h, strat); |
---|
[fc58b5b] | 400 | if(h->p == NULL) |
---|
[879e4c] | 401 | { |
---|
| 402 | if (h->lcm!=NULL) pLmDelete(h->lcm); |
---|
| 403 | h->Clear(); |
---|
| 404 | return 0; |
---|
| 405 | } |
---|
[fc58b5b] | 406 | if (strat->honey) h->SetLength(strat->length_pLength); |
---|
[3ffb5ca] | 407 | if(strat->tl >= 0) |
---|
| 408 | h->i_r1 = strat->tl; |
---|
| 409 | else |
---|
| 410 | h->i_r1 = -1; |
---|
| 411 | if (h->GetLmTailRing() == NULL) |
---|
| 412 | { |
---|
| 413 | if (h->lcm!=NULL) pLmDelete(h->lcm); |
---|
| 414 | h->Clear(); |
---|
| 415 | return 0; |
---|
| 416 | } |
---|
[c25b56c] | 417 | return 1; |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | ei = strat->T[j].ecart; |
---|
| 421 | ii = j; |
---|
[ef2729] | 422 | #ifdef ADIDEBUG_NF |
---|
[601105] | 423 | iii=ii; |
---|
[f3db6e] | 424 | #endif |
---|
[c25b56c] | 425 | if (ei > h->ecart && ii < strat->tl) |
---|
| 426 | { |
---|
[601105] | 427 | li = strat->T[j].length; |
---|
[c25b56c] | 428 | // the polynomial to reduce with (up to the moment) is; |
---|
| 429 | // pi with ecart ei and length li |
---|
| 430 | // look for one with smaller ecart |
---|
| 431 | i = j; |
---|
| 432 | loop |
---|
| 433 | { |
---|
| 434 | /*- takes the first possible with respect to ecart -*/ |
---|
| 435 | i++; |
---|
| 436 | #if 1 |
---|
| 437 | if (i > strat->tl) break; |
---|
| 438 | if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei && |
---|
| 439 | strat->T[i].length < li)) |
---|
| 440 | && |
---|
[fc58b5b] | 441 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing) |
---|
| 442 | && |
---|
[06abb07] | 443 | n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf)) |
---|
[c25b56c] | 444 | #else |
---|
[a576b0] | 445 | j = kFindDivisibleByInT(strat, h, i); |
---|
[c25b56c] | 446 | if (j < 0) break; |
---|
| 447 | i = j; |
---|
| 448 | if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei && |
---|
| 449 | strat->T[i].length < li)) |
---|
| 450 | #endif |
---|
| 451 | { |
---|
| 452 | // the polynomial to reduce with is now |
---|
[ef2729] | 453 | #ifdef ADIDEBUG_NF |
---|
[212806] | 454 | printf("\n Intermidiate one, h.ecart = %i < ecart = %i < ei = %i: ",h->ecart,strat->T[i].ecart, ei); |
---|
| 455 | pWrite(strat->T[i].p); |
---|
| 456 | #endif |
---|
[c25b56c] | 457 | ii = i; |
---|
| 458 | ei = strat->T[i].ecart; |
---|
| 459 | if (ei <= h->ecart) break; |
---|
| 460 | li = strat->T[i].length; |
---|
| 461 | } |
---|
| 462 | } |
---|
[601105] | 463 | |
---|
[ef2729] | 464 | #ifdef ADIDEBUG_NF |
---|
[f3db6e] | 465 | if(iii == ii) |
---|
[601105] | 466 | { |
---|
[fb12237] | 467 | PrintS("\n None was found.\n"); |
---|
[601105] | 468 | } |
---|
[f3db6e] | 469 | else |
---|
[601105] | 470 | { |
---|
[fb12237] | 471 | Print("\n A better one (ecart = %i): T[%i] = ",ei,ii); |
---|
| 472 | p_Write(strat->T[ii].p,strat->tailRing); |
---|
[f3db6e] | 473 | PrintLn(); |
---|
[601105] | 474 | } |
---|
[f3db6e] | 475 | #endif |
---|
[c25b56c] | 476 | } |
---|
| 477 | |
---|
| 478 | // end of search: have to reduce with pi |
---|
| 479 | if (ei > h->ecart) |
---|
| 480 | { |
---|
[ef2729] | 481 | #ifdef ADIDEBUG_NF |
---|
[212806] | 482 | printf("\nHAD TO REDUCE WITH BIGGER ECART!!!\n"); |
---|
| 483 | #endif |
---|
[c25b56c] | 484 | // It is not possible to reduce h with smaller ecart; |
---|
| 485 | // if possible h goes to the lazy-set L,i.e |
---|
| 486 | // if its position in L would be not the last one |
---|
| 487 | strat->fromT = TRUE; |
---|
| 488 | if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/ |
---|
| 489 | { |
---|
| 490 | h->SetLmCurrRing(); |
---|
| 491 | if (strat->honey && strat->posInLDependsOnLength) |
---|
| 492 | h->SetLength(strat->length_pLength); |
---|
| 493 | assume(h->FDeg == h->pFDeg()); |
---|
| 494 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
[3ffb5ca] | 495 | if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef)) |
---|
[c25b56c] | 496 | { |
---|
| 497 | /*- h will not become the next element to reduce -*/ |
---|
| 498 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
[19a089f] | 499 | #ifdef KDEBUG |
---|
[c25b56c] | 500 | if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at); |
---|
[19a089f] | 501 | #endif |
---|
[c25b56c] | 502 | h->Clear(); |
---|
| 503 | strat->fromT = FALSE; |
---|
| 504 | return -1; |
---|
| 505 | } |
---|
| 506 | } |
---|
[d49439] | 507 | doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE); |
---|
[2d223b] | 508 | } |
---|
| 509 | else |
---|
| 510 | { |
---|
| 511 | // now we finally can reduce |
---|
| 512 | doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE); |
---|
[c25b56c] | 513 | } |
---|
| 514 | strat->fromT=FALSE; |
---|
| 515 | // are we done ??? |
---|
| 516 | if (h->IsNull()) |
---|
| 517 | { |
---|
[ef2729] | 518 | #ifdef ADIDEBUG_NF |
---|
[212806] | 519 | printf("\nReduced to 0. Exit\n"); |
---|
| 520 | #endif |
---|
[fb12237] | 521 | if (h->lcm!=NULL) pLmDelete(h->lcm); |
---|
[c25b56c] | 522 | h->Clear(); |
---|
| 523 | return 0; |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | // NO! |
---|
| 527 | h->SetShortExpVector(); |
---|
| 528 | h->SetpFDeg(); |
---|
| 529 | if (strat->honey) |
---|
| 530 | { |
---|
| 531 | if (ei <= h->ecart) |
---|
| 532 | h->ecart = d-h->GetpFDeg(); |
---|
| 533 | else |
---|
| 534 | h->ecart = d-h->GetpFDeg()+ei-h->ecart; |
---|
| 535 | } |
---|
| 536 | else |
---|
| 537 | // this has the side effect of setting h->length |
---|
| 538 | h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg(); |
---|
[ef2729] | 539 | #ifdef ADIDEBUG_NF |
---|
[212806] | 540 | printf("\n Partial Reduced (ecart %i) h = ",h->ecart);p_Write(h->p,strat->tailRing); |
---|
| 541 | PrintLn(); |
---|
| 542 | #endif |
---|
[c25b56c] | 543 | /*- try to reduce the s-polynomial -*/ |
---|
| 544 | pass++; |
---|
| 545 | d = h->GetpFDeg()+h->ecart; |
---|
| 546 | /* |
---|
| 547 | *test whether the polynomial should go to the lazyset L |
---|
| 548 | *-if the degree jumps |
---|
| 549 | *-if the number of pre-defined reductions jumps |
---|
| 550 | */ |
---|
| 551 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) |
---|
| 552 | && ((d >= reddeg) || (pass > strat->LazyPass))) |
---|
| 553 | { |
---|
| 554 | h->SetLmCurrRing(); |
---|
| 555 | if (strat->honey && strat->posInLDependsOnLength) |
---|
| 556 | h->SetLength(strat->length_pLength); |
---|
| 557 | assume(h->FDeg == h->pFDeg()); |
---|
| 558 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 559 | if (at <= strat->Ll) |
---|
| 560 | { |
---|
| 561 | int dummy=strat->sl; |
---|
| 562 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
| 563 | { |
---|
| 564 | if (strat->honey && !strat->posInLDependsOnLength) |
---|
| 565 | h->SetLength(strat->length_pLength); |
---|
| 566 | return 1; |
---|
| 567 | } |
---|
| 568 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 569 | #ifdef KDEBUG |
---|
| 570 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
| 571 | #endif |
---|
| 572 | h->Clear(); |
---|
| 573 | return -1; |
---|
| 574 | } |
---|
| 575 | } |
---|
| 576 | else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
| 577 | { |
---|
| 578 | Print(".%ld",d);mflush(); |
---|
| 579 | reddeg = d+1; |
---|
[32ad2a] | 580 | if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask) |
---|
[c25b56c] | 581 | { |
---|
| 582 | strat->overflow=TRUE; |
---|
| 583 | //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask); |
---|
| 584 | h->GetP(); |
---|
| 585 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 586 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 587 | h->Clear(); |
---|
| 588 | return -1; |
---|
| 589 | } |
---|
| 590 | } |
---|
| 591 | } |
---|
| 592 | } |
---|
[42a81e] | 593 | #endif |
---|
[c25b56c] | 594 | |
---|
[35aab3] | 595 | /*2 |
---|
| 596 | *reduces h with elements from T choosing the first possible |
---|
| 597 | * element in t with respect to the given pDivisibleBy |
---|
| 598 | */ |
---|
| 599 | int redFirst (LObject* h,kStrategy strat) |
---|
| 600 | { |
---|
| 601 | if (h->IsNull()) return 0; |
---|
| 602 | |
---|
[d5564f8] | 603 | int at; |
---|
| 604 | long reddeg,d; |
---|
[35aab3] | 605 | int pass = 0; |
---|
| 606 | int j = 0; |
---|
| 607 | |
---|
| 608 | if (! strat->homog) |
---|
| 609 | { |
---|
| 610 | d = h->GetpFDeg() + h->ecart; |
---|
| 611 | reddeg = strat->LazyDegree+d; |
---|
| 612 | } |
---|
| 613 | h->SetShortExpVector(); |
---|
[485b5d] | 614 | loop |
---|
[35aab3] | 615 | { |
---|
[a576b0] | 616 | j = kFindDivisibleByInT(strat, h); |
---|
[35aab3] | 617 | if (j < 0) |
---|
| 618 | { |
---|
| 619 | h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 620 | return 1; |
---|
| 621 | } |
---|
| 622 | |
---|
| 623 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 624 | strat->T[j].pNorm(); |
---|
| 625 | #ifdef KDEBUG |
---|
| 626 | if (TEST_OPT_DEBUG) |
---|
| 627 | { |
---|
| 628 | PrintS("reduce "); |
---|
| 629 | h->wrp(); |
---|
| 630 | PrintS(" with "); |
---|
| 631 | strat->T[j].wrp(); |
---|
| 632 | } |
---|
| 633 | #endif |
---|
| 634 | ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, strat); |
---|
| 635 | #ifdef KDEBUG |
---|
| 636 | if (TEST_OPT_DEBUG) |
---|
| 637 | { |
---|
| 638 | PrintS(" to "); |
---|
| 639 | wrp(h->p); |
---|
| 640 | PrintLn(); |
---|
| 641 | } |
---|
| 642 | #endif |
---|
| 643 | if (h->IsNull()) |
---|
| 644 | { |
---|
[56d884] | 645 | assume(!rField_is_Ring(currRing)); |
---|
[35aab3] | 646 | if (h->lcm!=NULL) pLmFree(h->lcm); |
---|
| 647 | h->Clear(); |
---|
| 648 | return 0; |
---|
| 649 | } |
---|
| 650 | h->SetShortExpVector(); |
---|
| 651 | |
---|
[b981502] | 652 | #if 0 |
---|
[35aab3] | 653 | if ((strat->syzComp!=0) && !strat->honey) |
---|
| 654 | { |
---|
| 655 | if ((strat->syzComp>0) && |
---|
| 656 | (h->Comp() > strat->syzComp)) |
---|
| 657 | { |
---|
| 658 | assume(h->MinComp() > strat->syzComp); |
---|
| 659 | #ifdef KDEBUG |
---|
| 660 | if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
| 661 | #endif |
---|
| 662 | if (strat->homog) |
---|
| 663 | h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 664 | return -2; |
---|
| 665 | } |
---|
| 666 | } |
---|
[16493d] | 667 | #endif |
---|
[35aab3] | 668 | if (!strat->homog) |
---|
| 669 | { |
---|
[228b631] | 670 | if (!TEST_OPT_OLDSTD && strat->honey) |
---|
[35aab3] | 671 | { |
---|
| 672 | h->SetpFDeg(); |
---|
| 673 | if (strat->T[j].ecart <= h->ecart) |
---|
| 674 | h->ecart = d - h->GetpFDeg(); |
---|
| 675 | else |
---|
| 676 | h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart; |
---|
| 677 | |
---|
| 678 | d = h->GetpFDeg() + h->ecart; |
---|
| 679 | } |
---|
| 680 | else |
---|
| 681 | d = h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 682 | /*- try to reduce the s-polynomial -*/ |
---|
| 683 | pass++; |
---|
| 684 | /* |
---|
| 685 | *test whether the polynomial should go to the lazyset L |
---|
| 686 | *-if the degree jumps |
---|
| 687 | *-if the number of pre-defined reductions jumps |
---|
| 688 | */ |
---|
[228b631] | 689 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) |
---|
[35aab3] | 690 | && ((d >= reddeg) || (pass > strat->LazyPass))) |
---|
| 691 | { |
---|
| 692 | h->SetLmCurrRing(); |
---|
| 693 | if (strat->posInLDependsOnLength) |
---|
| 694 | h->SetLength(strat->length_pLength); |
---|
| 695 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 696 | if (at <= strat->Ll) |
---|
| 697 | { |
---|
[391323] | 698 | int dummy=strat->sl; |
---|
| 699 | if (kFindDivisibleByInS(strat,&dummy, h) < 0) |
---|
[35aab3] | 700 | return 1; |
---|
| 701 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 702 | #ifdef KDEBUG |
---|
| 703 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
| 704 | #endif |
---|
| 705 | h->Clear(); |
---|
| 706 | return -1; |
---|
| 707 | } |
---|
| 708 | } |
---|
| 709 | if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
| 710 | { |
---|
| 711 | reddeg = d+1; |
---|
[dd8a7d] | 712 | Print(".%ld",d);mflush(); |
---|
[32ad2a] | 713 | if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask) |
---|
[d5564f8] | 714 | { |
---|
[d95cee] | 715 | strat->overflow=TRUE; |
---|
[d5564f8] | 716 | //Print("OVERFLOW in redFirst d=%ld, max=%ld",d,strat->tailRing->bitmask); |
---|
[d95cee] | 717 | h->GetP(); |
---|
| 718 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 719 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 720 | h->Clear(); |
---|
[d5564f8] | 721 | return -1; |
---|
| 722 | } |
---|
[35aab3] | 723 | } |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | } |
---|
| 727 | |
---|
| 728 | /*2 |
---|
| 729 | * reduces h with elements from T choosing first possible |
---|
| 730 | * element in T with respect to the given ecart |
---|
| 731 | * used for computing normal forms outside kStd |
---|
| 732 | */ |
---|
| 733 | static poly redMoraNF (poly h,kStrategy strat, int flag) |
---|
| 734 | { |
---|
| 735 | LObject H; |
---|
| 736 | H.p = h; |
---|
| 737 | int j = 0; |
---|
| 738 | int z = 10; |
---|
| 739 | int o = H.SetpFDeg(); |
---|
[aef70f7] | 740 | H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o; |
---|
[5572c1] | 741 | if ((flag & 2) == 0) cancelunit(&H,TRUE); |
---|
[35aab3] | 742 | H.sev = pGetShortExpVector(H.p); |
---|
| 743 | unsigned long not_sev = ~ H.sev; |
---|
| 744 | loop |
---|
| 745 | { |
---|
[e21795] | 746 | if (j > strat->tl) |
---|
[c1c2ccd] | 747 | { |
---|
[e21795] | 748 | return H.p; |
---|
[c1c2ccd] | 749 | } |
---|
[e21795] | 750 | if (TEST_V_DEG_STOP) |
---|
| 751 | { |
---|
| 752 | if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p); |
---|
| 753 | if (H.p==NULL) return NULL; |
---|
| 754 | } |
---|
| 755 | if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing) |
---|
| 756 | ) |
---|
| 757 | { |
---|
| 758 | /*- remember the found T-poly -*/ |
---|
| 759 | // poly pi = strat->T[j].p; |
---|
| 760 | int ei = strat->T[j].ecart; |
---|
| 761 | int li = strat->T[j].length; |
---|
| 762 | int ii = j; |
---|
| 763 | /* |
---|
| 764 | * the polynomial to reduce with (up to the moment) is; |
---|
| 765 | * pi with ecart ei and length li |
---|
| 766 | */ |
---|
| 767 | loop |
---|
| 768 | { |
---|
| 769 | /*- look for a better one with respect to ecart -*/ |
---|
| 770 | /*- stop, if the ecart is small enough (<=ecart(H)) -*/ |
---|
| 771 | j++; |
---|
| 772 | if (j > strat->tl) break; |
---|
| 773 | if (ei <= H.ecart) break; |
---|
| 774 | if (((strat->T[j].ecart < ei) |
---|
| 775 | || ((strat->T[j].ecart == ei) |
---|
| 776 | && (strat->T[j].length < li))) |
---|
| 777 | && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev) |
---|
| 778 | ) |
---|
| 779 | { |
---|
| 780 | /* |
---|
| 781 | * the polynomial to reduce with is now; |
---|
| 782 | */ |
---|
| 783 | // pi = strat->T[j].p; |
---|
| 784 | ei = strat->T[j].ecart; |
---|
| 785 | li = strat->T[j].length; |
---|
| 786 | ii = j; |
---|
| 787 | } |
---|
| 788 | } |
---|
| 789 | /* |
---|
| 790 | * end of search: have to reduce with pi |
---|
| 791 | */ |
---|
| 792 | z++; |
---|
| 793 | if (z>10) |
---|
| 794 | { |
---|
| 795 | pNormalize(H.p); |
---|
| 796 | z=0; |
---|
| 797 | } |
---|
| 798 | if ((ei > H.ecart) && (!strat->kHEdgeFound)) |
---|
| 799 | { |
---|
| 800 | /* |
---|
| 801 | * It is not possible to reduce h with smaller ecart; |
---|
| 802 | * we have to reduce with bad ecart: H has to enter in T |
---|
| 803 | */ |
---|
| 804 | doRed(&H,&(strat->T[ii]),TRUE,strat,TRUE); |
---|
| 805 | if (H.p == NULL) |
---|
| 806 | return NULL; |
---|
| 807 | } |
---|
| 808 | else |
---|
| 809 | { |
---|
| 810 | /* |
---|
| 811 | * we reduce with good ecart, h need not to be put to T |
---|
| 812 | */ |
---|
| 813 | doRed(&H,&(strat->T[ii]),FALSE,strat,TRUE); |
---|
| 814 | if (H.p == NULL) |
---|
| 815 | return NULL; |
---|
| 816 | } |
---|
| 817 | /*- try to reduce the s-polynomial -*/ |
---|
| 818 | o = H.SetpFDeg(); |
---|
| 819 | if ((flag &2 ) == 0) cancelunit(&H,TRUE); |
---|
| 820 | H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o; |
---|
| 821 | j = 0; |
---|
| 822 | H.sev = pGetShortExpVector(H.p); |
---|
| 823 | not_sev = ~ H.sev; |
---|
| 824 | } |
---|
| 825 | else |
---|
| 826 | { |
---|
| 827 | j++; |
---|
| 828 | } |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | |
---|
| 832 | #ifdef HAVE_RINGS |
---|
| 833 | static poly redMoraNFRing (poly h,kStrategy strat, int flag) |
---|
| 834 | { |
---|
| 835 | LObject H; |
---|
| 836 | H.p = h; |
---|
| 837 | int j = 0; |
---|
| 838 | int z = 10; |
---|
| 839 | int o = H.SetpFDeg(); |
---|
| 840 | H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o; |
---|
| 841 | if ((flag & 2) == 0) cancelunit(&H,TRUE); |
---|
| 842 | H.sev = pGetShortExpVector(H.p); |
---|
| 843 | unsigned long not_sev = ~ H.sev; |
---|
| 844 | loop |
---|
| 845 | { |
---|
[35aab3] | 846 | if (j > strat->tl) |
---|
| 847 | { |
---|
| 848 | return H.p; |
---|
| 849 | } |
---|
| 850 | if (TEST_V_DEG_STOP) |
---|
| 851 | { |
---|
[075c01] | 852 | if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p); |
---|
[35aab3] | 853 | if (H.p==NULL) return NULL; |
---|
| 854 | } |
---|
[ef2729] | 855 | #ifdef ADIDEBUG_NF |
---|
[109e385] | 856 | printf("\nSearching for a reducer...\n"); |
---|
| 857 | #endif |
---|
| 858 | if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing) |
---|
[06abb07] | 859 | && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf)) |
---|
[109e385] | 860 | ) |
---|
[35aab3] | 861 | { |
---|
| 862 | /*- remember the found T-poly -*/ |
---|
[cd4f24] | 863 | // poly pi = strat->T[j].p; |
---|
[35aab3] | 864 | int ei = strat->T[j].ecart; |
---|
| 865 | int li = strat->T[j].length; |
---|
| 866 | int ii = j; |
---|
[ef2729] | 867 | #ifdef ADIDEBUG_NF |
---|
[109e385] | 868 | printf("\nFound: j = %i, ecart = %i\nTrying to find a better one...\n",j,ei);pWrite(strat->T[j].p); |
---|
| 869 | #endif |
---|
[35aab3] | 870 | /* |
---|
| 871 | * the polynomial to reduce with (up to the moment) is; |
---|
| 872 | * pi with ecart ei and length li |
---|
| 873 | */ |
---|
| 874 | loop |
---|
| 875 | { |
---|
| 876 | /*- look for a better one with respect to ecart -*/ |
---|
| 877 | /*- stop, if the ecart is small enough (<=ecart(H)) -*/ |
---|
| 878 | j++; |
---|
| 879 | if (j > strat->tl) break; |
---|
| 880 | if (ei <= H.ecart) break; |
---|
| 881 | if (((strat->T[j].ecart < ei) |
---|
[109e385] | 882 | || ((strat->T[j].ecart == ei) |
---|
| 883 | && (strat->T[j].length < li))) |
---|
[fc58b5b] | 884 | && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev) |
---|
[06abb07] | 885 | && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf)) |
---|
[109e385] | 886 | ) |
---|
[35aab3] | 887 | { |
---|
| 888 | /* |
---|
| 889 | * the polynomial to reduce with is now; |
---|
| 890 | */ |
---|
[cd4f24] | 891 | // pi = strat->T[j].p; |
---|
[35aab3] | 892 | ei = strat->T[j].ecart; |
---|
| 893 | li = strat->T[j].length; |
---|
| 894 | ii = j; |
---|
[ef2729] | 895 | #ifdef ADIDEBUG_NF |
---|
[109e385] | 896 | printf("\nFound a better one: j = %i, ecart = %i\nTrying to find a better one...\n",j,ei); |
---|
| 897 | pWrite(strat->T[j].p); |
---|
| 898 | #endif |
---|
[35aab3] | 899 | } |
---|
| 900 | } |
---|
| 901 | /* |
---|
| 902 | * end of search: have to reduce with pi |
---|
| 903 | */ |
---|
| 904 | z++; |
---|
| 905 | if (z>10) |
---|
| 906 | { |
---|
| 907 | pNormalize(H.p); |
---|
| 908 | z=0; |
---|
| 909 | } |
---|
| 910 | if ((ei > H.ecart) && (!strat->kHEdgeFound)) |
---|
| 911 | { |
---|
| 912 | /* |
---|
| 913 | * It is not possible to reduce h with smaller ecart; |
---|
| 914 | * we have to reduce with bad ecart: H has to enter in T |
---|
| 915 | */ |
---|
[ef2729] | 916 | #ifdef ADIDEBUG_NF |
---|
[19a089f] | 917 | printf("\nHAVE TO REDUCE IT WITH BIGGER ECART\n"); |
---|
| 918 | #endif |
---|
[2a4bc6e] | 919 | doRed(&H,&(strat->T[ii]),TRUE,strat,TRUE); |
---|
[35aab3] | 920 | if (H.p == NULL) |
---|
| 921 | return NULL; |
---|
| 922 | } |
---|
| 923 | else |
---|
| 924 | { |
---|
| 925 | /* |
---|
| 926 | * we reduce with good ecart, h need not to be put to T |
---|
| 927 | */ |
---|
[2a4bc6e] | 928 | doRed(&H,&(strat->T[ii]),FALSE,strat,TRUE); |
---|
[35aab3] | 929 | if (H.p == NULL) |
---|
| 930 | return NULL; |
---|
| 931 | } |
---|
[ef2729] | 932 | #ifdef ADIDEBUG_NF |
---|
[109e385] | 933 | printf("\nAfter the small reduction it looks like this:\n");pWrite(H.p); |
---|
[19a089f] | 934 | getchar(); |
---|
[109e385] | 935 | #endif |
---|
[35aab3] | 936 | /*- try to reduce the s-polynomial -*/ |
---|
| 937 | o = H.SetpFDeg(); |
---|
[5572c1] | 938 | if ((flag &2 ) == 0) cancelunit(&H,TRUE); |
---|
[aef70f7] | 939 | H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o; |
---|
[35aab3] | 940 | j = 0; |
---|
| 941 | H.sev = pGetShortExpVector(H.p); |
---|
| 942 | not_sev = ~ H.sev; |
---|
| 943 | } |
---|
| 944 | else |
---|
| 945 | { |
---|
| 946 | j++; |
---|
| 947 | } |
---|
| 948 | } |
---|
| 949 | } |
---|
[e21795] | 950 | #endif |
---|
[35aab3] | 951 | |
---|
| 952 | /*2 |
---|
| 953 | *reorders L with respect to posInL |
---|
| 954 | */ |
---|
| 955 | void reorderL(kStrategy strat) |
---|
| 956 | { |
---|
| 957 | int i,j,at; |
---|
| 958 | LObject p; |
---|
| 959 | |
---|
| 960 | for (i=1; i<=strat->Ll; i++) |
---|
| 961 | { |
---|
| 962 | at = strat->posInL(strat->L,i-1,&(strat->L[i]),strat); |
---|
| 963 | if (at != i) |
---|
| 964 | { |
---|
| 965 | p = strat->L[i]; |
---|
| 966 | for (j=i-1; j>=at; j--) strat->L[j+1] = strat->L[j]; |
---|
| 967 | strat->L[at] = p; |
---|
| 968 | } |
---|
| 969 | } |
---|
| 970 | } |
---|
| 971 | |
---|
| 972 | /*2 |
---|
| 973 | *reorders T with respect to length |
---|
| 974 | */ |
---|
| 975 | void reorderT(kStrategy strat) |
---|
| 976 | { |
---|
| 977 | int i,j,at; |
---|
| 978 | TObject p; |
---|
| 979 | unsigned long sev; |
---|
| 980 | |
---|
| 981 | |
---|
| 982 | for (i=1; i<=strat->tl; i++) |
---|
| 983 | { |
---|
| 984 | if (strat->T[i-1].length > strat->T[i].length) |
---|
| 985 | { |
---|
| 986 | p = strat->T[i]; |
---|
| 987 | sev = strat->sevT[i]; |
---|
| 988 | at = i-1; |
---|
| 989 | loop |
---|
| 990 | { |
---|
| 991 | at--; |
---|
| 992 | if (at < 0) break; |
---|
| 993 | if (strat->T[i].length > strat->T[at].length) break; |
---|
| 994 | } |
---|
| 995 | for (j = i-1; j>at; j--) |
---|
| 996 | { |
---|
| 997 | strat->T[j+1]=strat->T[j]; |
---|
| 998 | strat->sevT[j+1]=strat->sevT[j]; |
---|
| 999 | strat->R[strat->T[j+1].i_r] = &(strat->T[j+1]); |
---|
| 1000 | } |
---|
| 1001 | strat->T[at+1]=p; |
---|
| 1002 | strat->sevT[at+1] = sev; |
---|
| 1003 | strat->R[p.i_r] = &(strat->T[at+1]); |
---|
| 1004 | } |
---|
| 1005 | } |
---|
| 1006 | } |
---|
| 1007 | |
---|
| 1008 | /*2 |
---|
[1f637e] | 1009 | *looks whether exactly (currRing->N)-1 axis are used |
---|
[35aab3] | 1010 | *returns last != 0 in this case |
---|
| 1011 | *last is the (first) unused axis |
---|
| 1012 | */ |
---|
| 1013 | void missingAxis (int* last,kStrategy strat) |
---|
| 1014 | { |
---|
| 1015 | int i = 0; |
---|
| 1016 | int k = 0; |
---|
| 1017 | |
---|
| 1018 | *last = 0; |
---|
[41b9d0] | 1019 | if (!rHasMixedOrdering(currRing)) |
---|
[35aab3] | 1020 | { |
---|
| 1021 | loop |
---|
| 1022 | { |
---|
| 1023 | i++; |
---|
[1f637e] | 1024 | if (i > (currRing->N)) break; |
---|
[35aab3] | 1025 | if (strat->NotUsedAxis[i]) |
---|
| 1026 | { |
---|
| 1027 | *last = i; |
---|
| 1028 | k++; |
---|
| 1029 | } |
---|
| 1030 | if (k>1) |
---|
| 1031 | { |
---|
| 1032 | *last = 0; |
---|
| 1033 | break; |
---|
| 1034 | } |
---|
| 1035 | } |
---|
| 1036 | } |
---|
| 1037 | } |
---|
| 1038 | |
---|
| 1039 | /*2 |
---|
| 1040 | *last is the only non used axis, it looks |
---|
| 1041 | *for a monomial in p being a pure power of this |
---|
| 1042 | *variable and returns TRUE in this case |
---|
| 1043 | *(*length) gives the length between the pure power and the leading term |
---|
| 1044 | *(should be minimal) |
---|
| 1045 | */ |
---|
| 1046 | BOOLEAN hasPurePower (const poly p,int last, int *length,kStrategy strat) |
---|
| 1047 | { |
---|
| 1048 | poly h; |
---|
| 1049 | int i; |
---|
| 1050 | |
---|
| 1051 | if (pNext(p) == strat->tail) |
---|
| 1052 | return FALSE; |
---|
| 1053 | pp_Test(p, currRing, strat->tailRing); |
---|
| 1054 | if (strat->ak <= 0 || p_MinComp(p, currRing, strat->tailRing) == strat->ak) |
---|
| 1055 | { |
---|
| 1056 | i = p_IsPurePower(p, currRing); |
---|
[e6f1e6] | 1057 | if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(p), currRing->cf))) i=0; |
---|
[35aab3] | 1058 | if (i == last) |
---|
| 1059 | { |
---|
| 1060 | *length = 0; |
---|
| 1061 | return TRUE; |
---|
| 1062 | } |
---|
| 1063 | *length = 1; |
---|
| 1064 | h = pNext(p); |
---|
| 1065 | while (h != NULL) |
---|
| 1066 | { |
---|
| 1067 | i = p_IsPurePower(h, strat->tailRing); |
---|
[e6f1e6] | 1068 | if (rField_is_Ring(currRing) && (!n_IsUnit(pGetCoeff(h), currRing->cf))) i=0; |
---|
[35aab3] | 1069 | if (i==last) return TRUE; |
---|
| 1070 | (*length)++; |
---|
| 1071 | pIter(h); |
---|
| 1072 | } |
---|
| 1073 | } |
---|
| 1074 | return FALSE; |
---|
| 1075 | } |
---|
| 1076 | |
---|
| 1077 | BOOLEAN hasPurePower (LObject *L,int last, int *length,kStrategy strat) |
---|
| 1078 | { |
---|
| 1079 | if (L->bucket != NULL) |
---|
| 1080 | { |
---|
| 1081 | poly p = L->CanonicalizeP(); |
---|
| 1082 | BOOLEAN ret = hasPurePower(p, last, length, strat); |
---|
| 1083 | pNext(p) = NULL; |
---|
| 1084 | return ret; |
---|
| 1085 | } |
---|
| 1086 | else |
---|
| 1087 | { |
---|
| 1088 | return hasPurePower(L->p, last, length, strat); |
---|
| 1089 | } |
---|
| 1090 | } |
---|
| 1091 | |
---|
| 1092 | /*2 |
---|
| 1093 | * looks up the position of polynomial p in L |
---|
| 1094 | * in the case of looking for the pure powers |
---|
| 1095 | */ |
---|
| 1096 | int posInL10 (const LSet set,const int length, LObject* p,const kStrategy strat) |
---|
| 1097 | { |
---|
| 1098 | int j,dp,dL; |
---|
| 1099 | |
---|
| 1100 | if (length<0) return 0; |
---|
| 1101 | if (hasPurePower(p,strat->lastAxis,&dp,strat)) |
---|
| 1102 | { |
---|
| 1103 | int op= p->GetpFDeg() +p->ecart; |
---|
| 1104 | for (j=length; j>=0; j--) |
---|
| 1105 | { |
---|
| 1106 | if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) |
---|
| 1107 | return j+1; |
---|
| 1108 | if (dp < dL) |
---|
| 1109 | return j+1; |
---|
| 1110 | if ((dp == dL) |
---|
| 1111 | && (set[j].GetpFDeg()+set[j].ecart >= op)) |
---|
| 1112 | return j+1; |
---|
| 1113 | } |
---|
| 1114 | } |
---|
| 1115 | j=length; |
---|
| 1116 | loop |
---|
| 1117 | { |
---|
| 1118 | if (j<0) break; |
---|
| 1119 | if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break; |
---|
| 1120 | j--; |
---|
| 1121 | } |
---|
| 1122 | return strat->posInLOld(set,j,p,strat); |
---|
| 1123 | } |
---|
| 1124 | |
---|
| 1125 | |
---|
| 1126 | /*2 |
---|
| 1127 | * computes the s-polynomials L[ ].p in L |
---|
| 1128 | */ |
---|
| 1129 | void updateL(kStrategy strat) |
---|
| 1130 | { |
---|
| 1131 | LObject p; |
---|
| 1132 | int dL; |
---|
| 1133 | int j=strat->Ll; |
---|
| 1134 | loop |
---|
| 1135 | { |
---|
| 1136 | if (j<0) break; |
---|
| 1137 | if (hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat)) |
---|
| 1138 | { |
---|
| 1139 | p=strat->L[strat->Ll]; |
---|
| 1140 | strat->L[strat->Ll]=strat->L[j]; |
---|
| 1141 | strat->L[j]=p; |
---|
| 1142 | break; |
---|
| 1143 | } |
---|
| 1144 | j--; |
---|
| 1145 | } |
---|
| 1146 | if (j<0) |
---|
| 1147 | { |
---|
| 1148 | j=strat->Ll; |
---|
| 1149 | loop |
---|
| 1150 | { |
---|
| 1151 | if (j<0) break; |
---|
| 1152 | if (pNext(strat->L[j].p) == strat->tail) |
---|
| 1153 | { |
---|
[a539ad] | 1154 | if (rField_is_Ring(currRing)) |
---|
| 1155 | pLmDelete(strat->L[j].p); /*deletes the short spoly and computes*/ |
---|
| 1156 | else |
---|
| 1157 | pLmFree(strat->L[j].p); /*deletes the short spoly and computes*/ |
---|
[35aab3] | 1158 | strat->L[j].p = NULL; |
---|
| 1159 | poly m1 = NULL, m2 = NULL; |
---|
| 1160 | // check that spoly creation is ok |
---|
| 1161 | while (strat->tailRing != currRing && |
---|
| 1162 | !kCheckSpolyCreation(&(strat->L[j]), strat, m1, m2)) |
---|
| 1163 | { |
---|
| 1164 | assume(m1 == NULL && m2 == NULL); |
---|
| 1165 | // if not, change to a ring where exponents are at least |
---|
| 1166 | // large enough |
---|
| 1167 | kStratChangeTailRing(strat); |
---|
| 1168 | } |
---|
| 1169 | /* create the real one */ |
---|
| 1170 | ksCreateSpoly(&(strat->L[j]), strat->kNoetherTail(), FALSE, |
---|
| 1171 | strat->tailRing, m1, m2, strat->R); |
---|
| 1172 | |
---|
| 1173 | strat->L[j].SetLmCurrRing(); |
---|
| 1174 | if (!strat->honey) |
---|
| 1175 | strat->initEcart(&strat->L[j]); |
---|
| 1176 | else |
---|
| 1177 | strat->L[j].SetLength(strat->length_pLength); |
---|
| 1178 | |
---|
| 1179 | BOOLEAN pp = hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat); |
---|
| 1180 | |
---|
| 1181 | if (strat->use_buckets) strat->L[j].PrepareRed(TRUE); |
---|
| 1182 | |
---|
| 1183 | if (pp) |
---|
| 1184 | { |
---|
| 1185 | p=strat->L[strat->Ll]; |
---|
| 1186 | strat->L[strat->Ll]=strat->L[j]; |
---|
| 1187 | strat->L[j]=p; |
---|
| 1188 | break; |
---|
| 1189 | } |
---|
| 1190 | } |
---|
| 1191 | j--; |
---|
| 1192 | } |
---|
| 1193 | } |
---|
| 1194 | } |
---|
| 1195 | |
---|
| 1196 | /*2 |
---|
| 1197 | * computes the s-polynomials L[ ].p in L and |
---|
| 1198 | * cuts elements in L above noether |
---|
| 1199 | */ |
---|
| 1200 | void updateLHC(kStrategy strat) |
---|
| 1201 | { |
---|
[c25b56c] | 1202 | |
---|
[35aab3] | 1203 | int i = 0; |
---|
[eb55f8a] | 1204 | kTest_TS(strat); |
---|
[35aab3] | 1205 | while (i <= strat->Ll) |
---|
| 1206 | { |
---|
| 1207 | if (pNext(strat->L[i].p) == strat->tail) |
---|
| 1208 | { |
---|
| 1209 | /*- deletes the int spoly and computes -*/ |
---|
| 1210 | if (pLmCmp(strat->L[i].p,strat->kNoether) == -1) |
---|
| 1211 | { |
---|
[879e4c] | 1212 | if (rField_is_Ring(currRing)) |
---|
| 1213 | pLmDelete(strat->L[i].p); |
---|
| 1214 | else |
---|
| 1215 | pLmFree(strat->L[i].p); |
---|
[35aab3] | 1216 | strat->L[i].p = NULL; |
---|
| 1217 | } |
---|
| 1218 | else |
---|
| 1219 | { |
---|
[879e4c] | 1220 | if (rField_is_Ring(currRing)) |
---|
| 1221 | pLmDelete(strat->L[i].p); |
---|
| 1222 | else |
---|
| 1223 | pLmFree(strat->L[i].p); |
---|
[35aab3] | 1224 | strat->L[i].p = NULL; |
---|
| 1225 | poly m1 = NULL, m2 = NULL; |
---|
| 1226 | // check that spoly creation is ok |
---|
| 1227 | while (strat->tailRing != currRing && |
---|
| 1228 | !kCheckSpolyCreation(&(strat->L[i]), strat, m1, m2)) |
---|
| 1229 | { |
---|
| 1230 | assume(m1 == NULL && m2 == NULL); |
---|
| 1231 | // if not, change to a ring where exponents are at least |
---|
| 1232 | // large enough |
---|
| 1233 | kStratChangeTailRing(strat); |
---|
| 1234 | } |
---|
| 1235 | /* create the real one */ |
---|
| 1236 | ksCreateSpoly(&(strat->L[i]), strat->kNoetherTail(), FALSE, |
---|
| 1237 | strat->tailRing, m1, m2, strat->R); |
---|
| 1238 | if (! strat->L[i].IsNull()) |
---|
| 1239 | { |
---|
| 1240 | strat->L[i].SetLmCurrRing(); |
---|
| 1241 | strat->L[i].SetpFDeg(); |
---|
| 1242 | strat->L[i].ecart |
---|
| 1243 | = strat->L[i].pLDeg(strat->LDegLast) - strat->L[i].GetpFDeg(); |
---|
| 1244 | if (strat->use_buckets) strat->L[i].PrepareRed(TRUE); |
---|
| 1245 | } |
---|
| 1246 | } |
---|
| 1247 | } |
---|
| 1248 | else |
---|
| 1249 | deleteHC(&(strat->L[i]), strat); |
---|
[a969ff] | 1250 | if (strat->L[i].IsNull()) |
---|
[35aab3] | 1251 | deleteInL(strat->L,&strat->Ll,i,strat); |
---|
| 1252 | else |
---|
| 1253 | { |
---|
| 1254 | #ifdef KDEBUG |
---|
[eb55f8a] | 1255 | kTest_L(&(strat->L[i]), strat->tailRing, TRUE, i, strat->T, strat->tl); |
---|
[35aab3] | 1256 | #endif |
---|
| 1257 | i++; |
---|
| 1258 | } |
---|
| 1259 | } |
---|
[eb55f8a] | 1260 | kTest_TS(strat); |
---|
[35aab3] | 1261 | } |
---|
| 1262 | |
---|
| 1263 | /*2 |
---|
| 1264 | * cuts in T above strat->kNoether and tries to cancel a unit |
---|
[a969ff] | 1265 | * changes also S as S is a subset of T |
---|
[35aab3] | 1266 | */ |
---|
| 1267 | void updateT(kStrategy strat) |
---|
| 1268 | { |
---|
| 1269 | int i = 0; |
---|
| 1270 | LObject p; |
---|
| 1271 | |
---|
| 1272 | while (i <= strat->tl) |
---|
| 1273 | { |
---|
[601105] | 1274 | p = strat->T[i]; |
---|
[35aab3] | 1275 | deleteHC(&p,strat, TRUE); |
---|
| 1276 | /*- tries to cancel a unit: -*/ |
---|
| 1277 | cancelunit(&p); |
---|
[a969ff] | 1278 | if (TEST_OPT_INTSTRATEGY) /* deleteHC and/or cancelunit may have changed p*/ |
---|
| 1279 | p.pCleardenom(); |
---|
[35aab3] | 1280 | if (p.p != strat->T[i].p) |
---|
| 1281 | { |
---|
| 1282 | strat->sevT[i] = pGetShortExpVector(p.p); |
---|
| 1283 | p.SetpFDeg(); |
---|
| 1284 | } |
---|
| 1285 | strat->T[i] = p; |
---|
| 1286 | i++; |
---|
| 1287 | } |
---|
| 1288 | } |
---|
| 1289 | |
---|
| 1290 | /*2 |
---|
| 1291 | * arranges red, pos and T if strat->kHEdgeFound (first time) |
---|
| 1292 | */ |
---|
| 1293 | void firstUpdate(kStrategy strat) |
---|
| 1294 | { |
---|
| 1295 | if (strat->update) |
---|
| 1296 | { |
---|
[eb55f8a] | 1297 | kTest_TS(strat); |
---|
[35aab3] | 1298 | strat->update = (strat->tl == -1); |
---|
[1c94e4] | 1299 | if (TEST_OPT_WEIGHTM) |
---|
| 1300 | { |
---|
| 1301 | pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
| 1302 | if (strat->tailRing != currRing) |
---|
| 1303 | { |
---|
| 1304 | strat->tailRing->pFDeg = strat->pOrigFDeg_TailRing; |
---|
| 1305 | strat->tailRing->pLDeg = strat->pOrigLDeg_TailRing; |
---|
| 1306 | } |
---|
| 1307 | int i; |
---|
| 1308 | for (i=strat->Ll; i>=0; i--) |
---|
| 1309 | { |
---|
| 1310 | strat->L[i].SetpFDeg(); |
---|
| 1311 | } |
---|
| 1312 | for (i=strat->tl; i>=0; i--) |
---|
| 1313 | { |
---|
| 1314 | strat->T[i].SetpFDeg(); |
---|
| 1315 | } |
---|
| 1316 | if (ecartWeights) |
---|
| 1317 | { |
---|
| 1318 | omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short)); |
---|
| 1319 | ecartWeights=NULL; |
---|
| 1320 | } |
---|
| 1321 | } |
---|
[35aab3] | 1322 | if (TEST_OPT_FASTHC) |
---|
| 1323 | { |
---|
| 1324 | strat->posInL = strat->posInLOld; |
---|
| 1325 | strat->lastAxis = 0; |
---|
| 1326 | } |
---|
[804591] | 1327 | if (TEST_OPT_FINDET) |
---|
[35aab3] | 1328 | return; |
---|
[601105] | 1329 | |
---|
[009bd5] | 1330 | if ( (!rField_is_Ring(currRing)) || (rHasGlobalOrdering(currRing))) |
---|
[601105] | 1331 | { |
---|
[009bd5] | 1332 | strat->red = redFirst; |
---|
[601105] | 1333 | strat->use_buckets = kMoraUseBucket(strat); |
---|
[009bd5] | 1334 | } |
---|
[35aab3] | 1335 | updateT(strat); |
---|
[601105] | 1336 | |
---|
[009bd5] | 1337 | if ( (!rField_is_Ring(currRing)) || (rHasGlobalOrdering(currRing))) |
---|
[601105] | 1338 | { |
---|
[009bd5] | 1339 | strat->posInT = posInT2; |
---|
[601105] | 1340 | reorderT(strat); |
---|
[009bd5] | 1341 | } |
---|
[35aab3] | 1342 | } |
---|
[eb55f8a] | 1343 | kTest_TS(strat); |
---|
[35aab3] | 1344 | } |
---|
| 1345 | |
---|
| 1346 | /*2 |
---|
| 1347 | *-puts p to the standardbasis s at position at |
---|
| 1348 | *-reduces the tail of p if TEST_OPT_REDTAIL |
---|
| 1349 | *-tries to cancel a unit |
---|
| 1350 | *-HEckeTest |
---|
| 1351 | * if TRUE |
---|
| 1352 | * - decides about reduction-strategies |
---|
| 1353 | * - computes noether |
---|
[804591] | 1354 | * - stops computation if TEST_OPT_FINDET |
---|
[35aab3] | 1355 | * - cuts the tails of the polynomials |
---|
| 1356 | * in s,t and the elements in L above noether |
---|
| 1357 | * and cancels units if possible |
---|
| 1358 | * - reorders s,L |
---|
| 1359 | */ |
---|
[aa353e] | 1360 | void enterSMora (LObject &p,int atS,kStrategy strat, int atR = -1) |
---|
[35aab3] | 1361 | { |
---|
| 1362 | enterSBba(p, atS, strat, atR); |
---|
[08ab82] | 1363 | #ifdef KDEBUG |
---|
[35aab3] | 1364 | if (TEST_OPT_DEBUG) |
---|
| 1365 | { |
---|
| 1366 | Print("new s%d:",atS); |
---|
[9b8b09] | 1367 | p_wrp(p.p,currRing,strat->tailRing); |
---|
[35aab3] | 1368 | PrintLn(); |
---|
| 1369 | } |
---|
[08ab82] | 1370 | #endif |
---|
[35aab3] | 1371 | if ((!strat->kHEdgeFound) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat); |
---|
| 1372 | if (strat->kHEdgeFound) |
---|
| 1373 | { |
---|
[930ea8] | 1374 | if (newHEdge(strat)) |
---|
[35aab3] | 1375 | { |
---|
| 1376 | firstUpdate(strat); |
---|
[804591] | 1377 | if (TEST_OPT_FINDET) |
---|
[35aab3] | 1378 | return; |
---|
[601105] | 1379 | |
---|
[35aab3] | 1380 | /*- cuts elements in L above noether and reorders L -*/ |
---|
| 1381 | updateLHC(strat); |
---|
| 1382 | /*- reorders L with respect to posInL -*/ |
---|
| 1383 | reorderL(strat); |
---|
| 1384 | } |
---|
| 1385 | } |
---|
| 1386 | else if (strat->kNoether!=NULL) |
---|
| 1387 | strat->kHEdgeFound = TRUE; |
---|
| 1388 | else if (TEST_OPT_FASTHC) |
---|
| 1389 | { |
---|
| 1390 | if (strat->posInLOldFlag) |
---|
| 1391 | { |
---|
| 1392 | missingAxis(&strat->lastAxis,strat); |
---|
| 1393 | if (strat->lastAxis) |
---|
| 1394 | { |
---|
| 1395 | strat->posInLOld = strat->posInL; |
---|
| 1396 | strat->posInLOldFlag = FALSE; |
---|
| 1397 | strat->posInL = posInL10; |
---|
| 1398 | strat->posInLDependsOnLength = TRUE; |
---|
| 1399 | updateL(strat); |
---|
| 1400 | reorderL(strat); |
---|
| 1401 | } |
---|
| 1402 | } |
---|
| 1403 | else if (strat->lastAxis) |
---|
| 1404 | updateL(strat); |
---|
| 1405 | } |
---|
| 1406 | } |
---|
| 1407 | |
---|
| 1408 | /*2 |
---|
| 1409 | *-puts p to the standardbasis s at position at |
---|
| 1410 | *-HEckeTest |
---|
| 1411 | * if TRUE |
---|
| 1412 | * - computes noether |
---|
| 1413 | */ |
---|
[aa353e] | 1414 | void enterSMoraNF (LObject &p, int atS,kStrategy strat, int atR = -1) |
---|
[35aab3] | 1415 | { |
---|
| 1416 | enterSBba(p, atS, strat, atR); |
---|
| 1417 | if ((!strat->kHEdgeFound) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat); |
---|
| 1418 | if (strat->kHEdgeFound) |
---|
[930ea8] | 1419 | newHEdge(strat); |
---|
[35aab3] | 1420 | else if (strat->kNoether!=NULL) |
---|
| 1421 | strat->kHEdgeFound = TRUE; |
---|
| 1422 | } |
---|
| 1423 | |
---|
[4cc32b2] | 1424 | void initBba(kStrategy strat) |
---|
[35aab3] | 1425 | { |
---|
| 1426 | /* setting global variables ------------------- */ |
---|
| 1427 | strat->enterS = enterSBba; |
---|
[bdde4f4] | 1428 | strat->red = redHoney; |
---|
[35aab3] | 1429 | if (strat->honey) |
---|
| 1430 | strat->red = redHoney; |
---|
[fe89b98] | 1431 | else if (currRing->pLexOrder && !strat->homog) |
---|
[35aab3] | 1432 | strat->red = redLazy; |
---|
| 1433 | else |
---|
[bdde4f4] | 1434 | { |
---|
| 1435 | strat->LazyPass *=4; |
---|
[35aab3] | 1436 | strat->red = redHomog; |
---|
[bdde4f4] | 1437 | } |
---|
[751a01] | 1438 | if (rField_is_Ring(currRing)) |
---|
| 1439 | { |
---|
[093f30e] | 1440 | strat->red = redRing; |
---|
[585bbcb] | 1441 | } |
---|
[fe89b98] | 1442 | if (currRing->pLexOrder && strat->honey) |
---|
[35aab3] | 1443 | strat->initEcart = initEcartNormal; |
---|
| 1444 | else |
---|
| 1445 | strat->initEcart = initEcartBBA; |
---|
| 1446 | if (strat->honey) |
---|
| 1447 | strat->initEcartPair = initEcartPairMora; |
---|
| 1448 | else |
---|
| 1449 | strat->initEcartPair = initEcartPairBba; |
---|
[0b356b] | 1450 | // if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1451 | // { |
---|
| 1452 | // //interred machen Aenderung |
---|
[eafa0ed] | 1453 | // strat->pOrigFDeg=pFDeg; |
---|
| 1454 | // strat->pOrigLDeg=pLDeg; |
---|
[0b356b] | 1455 | // //h=ggetid("ecart"); |
---|
| 1456 | // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/) |
---|
| 1457 | // //{ |
---|
| 1458 | // // ecartWeights=iv2array(IDINTVEC(h)); |
---|
| 1459 | // //} |
---|
| 1460 | // //else |
---|
| 1461 | // { |
---|
| 1462 | // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short)); |
---|
| 1463 | // /*uses automatic computation of the ecartWeights to set them*/ |
---|
| 1464 | // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights); |
---|
| 1465 | // } |
---|
| 1466 | // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart); |
---|
| 1467 | // if (TEST_OPT_PROT) |
---|
| 1468 | // { |
---|
| 1469 | // for(i=1; i<=(currRing->N); i++) |
---|
| 1470 | // Print(" %d",ecartWeights[i]); |
---|
| 1471 | // PrintLn(); |
---|
| 1472 | // mflush(); |
---|
| 1473 | // } |
---|
| 1474 | // } |
---|
[35aab3] | 1475 | } |
---|
| 1476 | |
---|
[83be980] | 1477 | void initSba(ideal F,kStrategy strat) |
---|
| 1478 | { |
---|
| 1479 | int i; |
---|
| 1480 | //idhdl h; |
---|
| 1481 | /* setting global variables ------------------- */ |
---|
| 1482 | strat->enterS = enterSSba; |
---|
| 1483 | strat->red2 = redHoney; |
---|
| 1484 | if (strat->honey) |
---|
| 1485 | strat->red2 = redHoney; |
---|
| 1486 | else if (currRing->pLexOrder && !strat->homog) |
---|
| 1487 | strat->red2 = redLazy; |
---|
| 1488 | else |
---|
| 1489 | { |
---|
| 1490 | strat->LazyPass *=4; |
---|
| 1491 | strat->red2 = redHomog; |
---|
| 1492 | } |
---|
| 1493 | if (rField_is_Ring(currRing)) |
---|
| 1494 | { |
---|
[009bd5] | 1495 | if(rHasLocalOrMixedOrdering(currRing)) |
---|
[a63783] | 1496 | {strat->red2 = redRiloc;} |
---|
[601105] | 1497 | else |
---|
| 1498 | {strat->red2 = redRing;} |
---|
[83be980] | 1499 | } |
---|
| 1500 | if (currRing->pLexOrder && strat->honey) |
---|
| 1501 | strat->initEcart = initEcartNormal; |
---|
| 1502 | else |
---|
| 1503 | strat->initEcart = initEcartBBA; |
---|
| 1504 | if (strat->honey) |
---|
| 1505 | strat->initEcartPair = initEcartPairMora; |
---|
| 1506 | else |
---|
| 1507 | strat->initEcartPair = initEcartPairBba; |
---|
| 1508 | //strat->kIdeal = NULL; |
---|
| 1509 | //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD; |
---|
| 1510 | //else strat->kIdeal->rtyp=MODUL_CMD; |
---|
| 1511 | //strat->kIdeal->data=(void *)strat->Shdl; |
---|
| 1512 | if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1513 | { |
---|
| 1514 | //interred machen Aenderung |
---|
| 1515 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 1516 | strat->pOrigLDeg = currRing->pLDeg; |
---|
| 1517 | //h=ggetid("ecart"); |
---|
| 1518 | //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/) |
---|
| 1519 | //{ |
---|
| 1520 | // ecartWeights=iv2array(IDINTVEC(h)); |
---|
| 1521 | //} |
---|
| 1522 | //else |
---|
| 1523 | { |
---|
| 1524 | ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short)); |
---|
| 1525 | /*uses automatic computation of the ecartWeights to set them*/ |
---|
| 1526 | kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights, currRing); |
---|
| 1527 | } |
---|
| 1528 | pRestoreDegProcs(currRing, totaldegreeWecart, maxdegreeWecart); |
---|
| 1529 | if (TEST_OPT_PROT) |
---|
| 1530 | { |
---|
| 1531 | for(i=1; i<=(currRing->N); i++) |
---|
| 1532 | Print(" %d",ecartWeights[i]); |
---|
| 1533 | PrintLn(); |
---|
| 1534 | mflush(); |
---|
| 1535 | } |
---|
| 1536 | } |
---|
| 1537 | // for sig-safe reductions in signature-based |
---|
| 1538 | // standard basis computations |
---|
[e40da9f] | 1539 | if(rField_is_Ring(currRing)) |
---|
| 1540 | strat->red = redSigRing; |
---|
| 1541 | else |
---|
| 1542 | strat->red = redSig; |
---|
[f7f084] | 1543 | //strat->sbaOrder = 1; |
---|
[83be980] | 1544 | strat->currIdx = 1; |
---|
| 1545 | } |
---|
| 1546 | |
---|
[35aab3] | 1547 | void initMora(ideal F,kStrategy strat) |
---|
| 1548 | { |
---|
| 1549 | int i,j; |
---|
| 1550 | |
---|
[1f637e] | 1551 | strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN)); |
---|
| 1552 | for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE; |
---|
[35aab3] | 1553 | strat->enterS = enterSMora; |
---|
| 1554 | strat->initEcartPair = initEcartPairMora; /*- ecart approximation -*/ |
---|
| 1555 | strat->posInLOld = strat->posInL; |
---|
| 1556 | strat->posInLOldFlag = TRUE; |
---|
| 1557 | strat->initEcart = initEcartNormal; |
---|
[993ae2] | 1558 | strat->kHEdgeFound = (currRing->ppNoether) != NULL; |
---|
[35aab3] | 1559 | if ( strat->kHEdgeFound ) |
---|
[993ae2] | 1560 | strat->kNoether = pCopy((currRing->ppNoether)); |
---|
[35aab3] | 1561 | else if (strat->kHEdgeFound || strat->homog) |
---|
| 1562 | strat->red = redFirst; /*take the first possible in T*/ |
---|
| 1563 | else |
---|
| 1564 | strat->red = redEcart;/*take the first possible in under ecart-restriction*/ |
---|
| 1565 | if (strat->kHEdgeFound) |
---|
| 1566 | { |
---|
[993ae2] | 1567 | strat->HCord = currRing->pFDeg((currRing->ppNoether),currRing)+1; |
---|
[35aab3] | 1568 | strat->posInT = posInT2; |
---|
| 1569 | } |
---|
| 1570 | else |
---|
| 1571 | { |
---|
| 1572 | strat->HCord = 32000;/*- very large -*/ |
---|
| 1573 | } |
---|
[601105] | 1574 | |
---|
[279976] | 1575 | if (rField_is_Ring(currRing)) |
---|
| 1576 | strat->red = redRiloc; |
---|
[c25b56c] | 1577 | |
---|
[35aab3] | 1578 | /*reads the ecartWeights used for Graebes method from the |
---|
| 1579 | *intvec ecart and set ecartWeights |
---|
| 1580 | */ |
---|
[eafa0ed] | 1581 | if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 1582 | { |
---|
| 1583 | //interred machen Aenderung |
---|
| 1584 | strat->pOrigFDeg=currRing->pFDeg; |
---|
| 1585 | strat->pOrigLDeg=currRing->pLDeg; |
---|
| 1586 | ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short)); |
---|
| 1587 | /*uses automatic computation of the ecartWeights to set them*/ |
---|
| 1588 | kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights,currRing); |
---|
| 1589 | |
---|
| 1590 | pSetDegProcs(currRing,totaldegreeWecart, maxdegreeWecart); |
---|
| 1591 | if (TEST_OPT_PROT) |
---|
| 1592 | { |
---|
| 1593 | for(i=1; i<=(currRing->N); i++) |
---|
| 1594 | Print(" %d",ecartWeights[i]); |
---|
| 1595 | PrintLn(); |
---|
| 1596 | mflush(); |
---|
| 1597 | } |
---|
| 1598 | } |
---|
[aef70f7] | 1599 | kOptimizeLDeg(currRing->pLDeg, strat); |
---|
[35aab3] | 1600 | } |
---|
| 1601 | |
---|
[3e9d1d9] | 1602 | void kDebugPrint(kStrategy strat); |
---|
| 1603 | |
---|
[35aab3] | 1604 | ideal mora (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) |
---|
| 1605 | { |
---|
[c25b56c] | 1606 | #ifdef HAVE_RINGS |
---|
[ef2729] | 1607 | #ifdef ADIDEBUG |
---|
[c25b56c] | 1608 | int loop_count; |
---|
| 1609 | loop_count = 1; |
---|
| 1610 | #endif |
---|
[35aab3] | 1611 | #endif |
---|
| 1612 | int olddeg = 0; |
---|
| 1613 | int reduc = 0; |
---|
| 1614 | int red_result = 1; |
---|
| 1615 | int hilbeledeg=1,hilbcount=0; |
---|
[d30a399] | 1616 | BITSET save1; |
---|
| 1617 | SI_SAVE_OPT1(save1); |
---|
[41b9d0] | 1618 | if (rHasMixedOrdering(currRing)) |
---|
[70f5c0] | 1619 | { |
---|
[d30a399] | 1620 | si_opt_1 &= ~Sy_bit(OPT_REDSB); |
---|
| 1621 | si_opt_1 &= ~Sy_bit(OPT_REDTAIL); |
---|
[70f5c0] | 1622 | } |
---|
[35aab3] | 1623 | |
---|
| 1624 | strat->update = TRUE; |
---|
| 1625 | /*- setting global variables ------------------- -*/ |
---|
| 1626 | initBuchMoraCrit(strat); |
---|
| 1627 | initHilbCrit(F,Q,&hilb,strat); |
---|
| 1628 | initMora(F,strat); |
---|
[5efbf9] | 1629 | if(rField_is_Ring(currRing)) |
---|
| 1630 | initBuchMoraPosRing(strat); |
---|
| 1631 | else |
---|
| 1632 | initBuchMoraPos(strat); |
---|
[35aab3] | 1633 | /*Shdl=*/initBuchMora(F,Q,strat); |
---|
| 1634 | if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat); |
---|
| 1635 | /*updateS in initBuchMora has Hecketest |
---|
| 1636 | * and could have put strat->kHEdgdeFound FALSE*/ |
---|
[993ae2] | 1637 | if ((currRing->ppNoether)!=NULL) |
---|
[35aab3] | 1638 | { |
---|
| 1639 | strat->kHEdgeFound = TRUE; |
---|
| 1640 | } |
---|
| 1641 | if (strat->kHEdgeFound && strat->update) |
---|
| 1642 | { |
---|
| 1643 | firstUpdate(strat); |
---|
| 1644 | updateLHC(strat); |
---|
| 1645 | reorderL(strat); |
---|
| 1646 | } |
---|
| 1647 | if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag) |
---|
| 1648 | { |
---|
| 1649 | strat->posInLOld = strat->posInL; |
---|
| 1650 | strat->posInLOldFlag = FALSE; |
---|
| 1651 | strat->posInL = posInL10; |
---|
| 1652 | updateL(strat); |
---|
| 1653 | reorderL(strat); |
---|
| 1654 | } |
---|
[eb55f8a] | 1655 | kTest_TS(strat); |
---|
[35aab3] | 1656 | strat->use_buckets = kMoraUseBucket(strat); |
---|
| 1657 | |
---|
| 1658 | #ifdef HAVE_TAIL_RING |
---|
[6497fd] | 1659 | if (strat->homog && strat->red == redFirst) |
---|
[add269] | 1660 | if(!idIs0(F) &&(!rField_is_Ring(currRing))) |
---|
[fc58b5b] | 1661 | kStratInitChangeTailRing(strat); |
---|
[35aab3] | 1662 | #endif |
---|
[c25b56c] | 1663 | |
---|
[3e9d1d9] | 1664 | if (BVERBOSE(23)) |
---|
| 1665 | { |
---|
| 1666 | kDebugPrint(strat); |
---|
| 1667 | } |
---|
[9005c8] | 1668 | //deleteInL(strat->L,&strat->Ll,1,strat); |
---|
| 1669 | //deleteInL(strat->L,&strat->Ll,0,strat); |
---|
[35aab3] | 1670 | |
---|
[f8fb93d] | 1671 | /*- compute-------------------------------------------*/ |
---|
[35aab3] | 1672 | while (strat->Ll >= 0) |
---|
| 1673 | { |
---|
[ef2729] | 1674 | #ifdef ADIDEBUG |
---|
[1c3860b] | 1675 | printf("\n ------------------------NEW LOOP\n"); |
---|
| 1676 | printf("\nShdl = \n"); |
---|
| 1677 | for(int iii = 0; iii<= strat->sl; iii++) |
---|
| 1678 | { |
---|
| 1679 | printf("S[%i]:",iii); |
---|
| 1680 | p_Write(strat->S[iii], strat->tailRing); |
---|
| 1681 | } |
---|
| 1682 | printf("\n list L has %i\n", strat->Ll); |
---|
| 1683 | int iii; |
---|
[ef2729] | 1684 | #ifdef ADIDEBUG |
---|
[1c3860b] | 1685 | for(iii = 0; iii<= strat->Ll; iii++) |
---|
| 1686 | { |
---|
| 1687 | printf("L[%i]:",iii); |
---|
| 1688 | pWrite(strat->L[iii].p); |
---|
| 1689 | pWrite(strat->L[iii].p1); |
---|
| 1690 | pWrite(strat->L[iii].p2); |
---|
| 1691 | } |
---|
| 1692 | #endif |
---|
[5d9204] | 1693 | getchar(); |
---|
[1c3860b] | 1694 | #endif |
---|
[08ab82] | 1695 | #ifdef KDEBUG |
---|
[35aab3] | 1696 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[08ab82] | 1697 | #endif |
---|
[35aab3] | 1698 | if (TEST_OPT_DEGBOUND |
---|
| 1699 | && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)) |
---|
| 1700 | { |
---|
| 1701 | /* |
---|
| 1702 | * stops computation if |
---|
| 1703 | * - 24 (degBound) |
---|
| 1704 | * && upper degree is bigger than Kstd1_deg |
---|
| 1705 | */ |
---|
| 1706 | while ((strat->Ll >= 0) |
---|
[939847] | 1707 | && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) |
---|
[35aab3] | 1708 | && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg) |
---|
[939847] | 1709 | ) |
---|
[35aab3] | 1710 | { |
---|
| 1711 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 1712 | //if (TEST_OPT_PROT) |
---|
| 1713 | //{ |
---|
| 1714 | // PrintS("D"); mflush(); |
---|
| 1715 | //} |
---|
| 1716 | } |
---|
| 1717 | if (strat->Ll<0) break; |
---|
[3957e37] | 1718 | else strat->noClearS=TRUE; |
---|
[35aab3] | 1719 | } |
---|
| 1720 | strat->P = strat->L[strat->Ll];/*- picks the last element from the lazyset L -*/ |
---|
| 1721 | if (strat->Ll==0) strat->interpt=TRUE; |
---|
| 1722 | strat->Ll--; |
---|
| 1723 | // create the real Spoly |
---|
| 1724 | if (pNext(strat->P.p) == strat->tail) |
---|
| 1725 | { |
---|
| 1726 | /*- deletes the short spoly and computes -*/ |
---|
[f41347f] | 1727 | if (rField_is_Ring(currRing)) |
---|
| 1728 | pLmDelete(strat->P.p); |
---|
| 1729 | else |
---|
[d249822] | 1730 | pLmFree(strat->P.p); |
---|
[35aab3] | 1731 | strat->P.p = NULL; |
---|
| 1732 | poly m1 = NULL, m2 = NULL; |
---|
| 1733 | // check that spoly creation is ok |
---|
| 1734 | while (strat->tailRing != currRing && |
---|
| 1735 | !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) |
---|
| 1736 | { |
---|
| 1737 | assume(m1 == NULL && m2 == NULL); |
---|
| 1738 | // if not, change to a ring where exponents are large enough |
---|
| 1739 | kStratChangeTailRing(strat); |
---|
| 1740 | } |
---|
| 1741 | /* create the real one */ |
---|
| 1742 | ksCreateSpoly(&(strat->P), strat->kNoetherTail(), strat->use_buckets, |
---|
| 1743 | strat->tailRing, m1, m2, strat->R); |
---|
| 1744 | if (!strat->use_buckets) |
---|
| 1745 | strat->P.SetLength(strat->length_pLength); |
---|
| 1746 | } |
---|
| 1747 | else if (strat->P.p1 == NULL) |
---|
| 1748 | { |
---|
| 1749 | // for input polys, prepare reduction (buckets !) |
---|
| 1750 | strat->P.SetLength(strat->length_pLength); |
---|
| 1751 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 1752 | } |
---|
| 1753 | |
---|
[a969ff] | 1754 | // the s-poly |
---|
[35aab3] | 1755 | if (!strat->P.IsNull()) |
---|
| 1756 | { |
---|
| 1757 | // might be NULL from noether !!! |
---|
| 1758 | if (TEST_OPT_PROT) |
---|
| 1759 | message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result); |
---|
| 1760 | // reduce |
---|
[ef2729] | 1761 | #ifdef ADIDEBUG |
---|
[535b07] | 1762 | printf("\nThis is P vor red:\n");p_Write(strat->P.p,strat->tailRing);p_Write(strat->P.p1,strat->tailRing);p_Write(strat->P.p2,strat->tailRing); |
---|
| 1763 | printf("\nBefore Ll = %i\n", strat->Ll); |
---|
| 1764 | #endif |
---|
[c6a876] | 1765 | red_result = strat->red(&strat->P,strat); |
---|
[ef2729] | 1766 | #ifdef ADIDEBUG |
---|
[535b07] | 1767 | printf("\nThis is P nach red:\n");p_Write(strat->P.p,strat->tailRing);p_Write(strat->P.p1,strat->tailRing);p_Write(strat->P.p2,strat->tailRing); |
---|
[212806] | 1768 | printf("\nAfter Ll = %i\n", strat->Ll); |
---|
[535b07] | 1769 | #endif |
---|
[35aab3] | 1770 | } |
---|
| 1771 | |
---|
[a969ff] | 1772 | // the reduced s-poly |
---|
[35aab3] | 1773 | if (! strat->P.IsNull()) |
---|
| 1774 | { |
---|
| 1775 | strat->P.GetP(); |
---|
| 1776 | // statistics |
---|
| 1777 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 1778 | // normalization |
---|
[a969ff] | 1779 | if (TEST_OPT_INTSTRATEGY) |
---|
| 1780 | strat->P.pCleardenom(); |
---|
| 1781 | else |
---|
[35aab3] | 1782 | strat->P.pNorm(); |
---|
| 1783 | // tailreduction |
---|
| 1784 | strat->P.p = redtail(&(strat->P),strat->sl,strat); |
---|
[2f3b27] | 1785 | if (strat->P.p==NULL) |
---|
| 1786 | { |
---|
| 1787 | WerrorS("expoent overflow - wrong ordering"); |
---|
[3cc89c] | 1788 | return(idInit(1,1)); |
---|
[2f3b27] | 1789 | } |
---|
[35aab3] | 1790 | // set ecart -- might have changed because of tail reductions |
---|
| 1791 | if ((!strat->noTailReduction) && (!strat->honey)) |
---|
| 1792 | strat->initEcart(&strat->P); |
---|
[5d0052] | 1793 | // cancel unit |
---|
| 1794 | cancelunit(&strat->P); |
---|
[35aab3] | 1795 | // for char 0, clear denominators |
---|
[a969ff] | 1796 | if ((strat->P.p->next==NULL) /* i.e. cancelunit did something*/ |
---|
| 1797 | && TEST_OPT_INTSTRATEGY) |
---|
[35aab3] | 1798 | strat->P.pCleardenom(); |
---|
| 1799 | |
---|
[db0c2bd] | 1800 | enterT(strat->P,strat); |
---|
[35aab3] | 1801 | // build new pairs |
---|
[f41347f] | 1802 | if (rField_is_Ring(currRing)) |
---|
[601105] | 1803 | superenterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl); |
---|
[f41347f] | 1804 | else |
---|
[d249822] | 1805 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl); |
---|
[35aab3] | 1806 | // put in S |
---|
[601105] | 1807 | |
---|
[ef2729] | 1808 | #ifdef ADIDEBUG |
---|
[f3db6e] | 1809 | Print("\n The new pair list L -- after superenterpairs in loop %d -- is:\n",loop_count); |
---|
| 1810 | for(int iii=0;iii<=strat->Ll;iii++) |
---|
| 1811 | { |
---|
[535b07] | 1812 | printf("\n L[%d]:\n",iii); |
---|
| 1813 | PrintS(" ");p_Write(strat->L[iii].p,strat->tailRing); |
---|
[f3db6e] | 1814 | PrintS(" ");p_Write(strat->L[iii].p1,strat->tailRing); |
---|
| 1815 | PrintS(" ");p_Write(strat->L[iii].p2,strat->tailRing); |
---|
| 1816 | } |
---|
[535b07] | 1817 | #endif |
---|
[35aab3] | 1818 | strat->enterS(strat->P, |
---|
| 1819 | posInS(strat,strat->sl,strat->P.p, strat->P.ecart), |
---|
| 1820 | strat, strat->tl); |
---|
[ef2729] | 1821 | #ifdef ADIDEBUG |
---|
[535b07] | 1822 | printf("\nThis pair has been added to S:\n"); |
---|
| 1823 | pWrite(strat->P.p); |
---|
| 1824 | pWrite(strat->P.p1); |
---|
| 1825 | pWrite(strat->P.p2); |
---|
| 1826 | #endif |
---|
[35aab3] | 1827 | |
---|
| 1828 | // apply hilbert criterion |
---|
[601105] | 1829 | if (hilb!=NULL) |
---|
[f3db6e] | 1830 | { |
---|
[601105] | 1831 | if (strat->homog==isHomog) |
---|
| 1832 | khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 1833 | else |
---|
| 1834 | khCheckLocInhom(Q,w,hilb,hilbcount,strat); |
---|
[f3db6e] | 1835 | } |
---|
[35aab3] | 1836 | |
---|
| 1837 | // clear strat->P |
---|
[822aa3a] | 1838 | if (strat->P.lcm!=NULL) |
---|
[a969ff] | 1839 | { |
---|
[c6a876] | 1840 | if (rField_is_Ring(currRing)) |
---|
[d249822] | 1841 | pLmDelete(strat->P.lcm); |
---|
[f8fb93d] | 1842 | else |
---|
| 1843 | pLmFree(strat->P.lcm); |
---|
[a969ff] | 1844 | strat->P.lcm=NULL; |
---|
| 1845 | } |
---|
[f8fb93d] | 1846 | |
---|
[35aab3] | 1847 | #ifdef KDEBUG |
---|
| 1848 | // make sure kTest_TS does not complain about strat->P |
---|
| 1849 | memset(&strat->P,0,sizeof(strat->P)); |
---|
| 1850 | #endif |
---|
| 1851 | } |
---|
| 1852 | if (strat->kHEdgeFound) |
---|
| 1853 | { |
---|
[804591] | 1854 | if ((TEST_OPT_FINDET) |
---|
[2d3b010] | 1855 | || ((TEST_OPT_MULTBOUND) && (scMult0Int(strat->Shdl,NULL,strat->tailRing) < Kstd1_mu))) |
---|
[35aab3] | 1856 | { |
---|
| 1857 | // obachman: is this still used ??? |
---|
| 1858 | /* |
---|
| 1859 | * stops computation if strat->kHEdgeFound and |
---|
| 1860 | * - 27 (finiteDeterminacyTest) |
---|
| 1861 | * or |
---|
| 1862 | * - 23 |
---|
| 1863 | * (multBound) |
---|
| 1864 | * && multiplicity of the ideal is smaller then a predefined number mu |
---|
| 1865 | */ |
---|
| 1866 | while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 1867 | } |
---|
| 1868 | } |
---|
[eb55f8a] | 1869 | kTest_TS(strat); |
---|
[35aab3] | 1870 | } |
---|
| 1871 | /*- complete reduction of the standard basis------------------------ -*/ |
---|
| 1872 | if (TEST_OPT_REDSB) completeReduce(strat); |
---|
[5accf0] | 1873 | else if (TEST_OPT_PROT) PrintLn(); |
---|
[35aab3] | 1874 | /*- release temp data------------------------------- -*/ |
---|
| 1875 | exitBuchMora(strat); |
---|
| 1876 | /*- polynomials used for HECKE: HC, noether -*/ |
---|
[804591] | 1877 | if (TEST_OPT_FINDET) |
---|
[35aab3] | 1878 | { |
---|
| 1879 | if (strat->kHEdge!=NULL) |
---|
[0b356b] | 1880 | Kstd1_mu=currRing->pFDeg(strat->kHEdge,currRing); |
---|
[35aab3] | 1881 | else |
---|
| 1882 | Kstd1_mu=-1; |
---|
| 1883 | } |
---|
[15d75cd] | 1884 | if (strat->kHEdge!=NULL) pLmFree(&strat->kHEdge); |
---|
[35aab3] | 1885 | strat->update = TRUE; //??? |
---|
| 1886 | strat->lastAxis = 0; //??? |
---|
[15d75cd] | 1887 | if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether); |
---|
[1f637e] | 1888 | omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN)); |
---|
[ede2ad8] | 1889 | if ((TEST_OPT_PROT)||(TEST_OPT_DEBUG)) messageStat(hilbcount,strat); |
---|
[0b356b] | 1890 | // if (TEST_OPT_WEIGHTM) |
---|
| 1891 | // { |
---|
[eafa0ed] | 1892 | // pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
[0b356b] | 1893 | // if (ecartWeights) |
---|
| 1894 | // { |
---|
| 1895 | // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
| 1896 | // ecartWeights=NULL; |
---|
| 1897 | // } |
---|
| 1898 | // } |
---|
[535b07] | 1899 | if(nCoeff_is_Ring_Z(currRing->cf)) |
---|
| 1900 | finalReduceByMon(strat); |
---|
[35aab3] | 1901 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
[d30a399] | 1902 | SI_RESTORE_OPT1(save1); |
---|
[35aab3] | 1903 | idTest(strat->Shdl); |
---|
| 1904 | return (strat->Shdl); |
---|
| 1905 | } |
---|
| 1906 | |
---|
| 1907 | poly kNF1 (ideal F,ideal Q,poly q, kStrategy strat, int lazyReduce) |
---|
| 1908 | { |
---|
[822aa3a] | 1909 | assume(q!=NULL); |
---|
| 1910 | assume(!(idIs0(F)&&(Q==NULL))); |
---|
| 1911 | |
---|
[93f4bb] | 1912 | // lazy_reduce flags: can be combined by | |
---|
| 1913 | //#define KSTD_NF_LAZY 1 |
---|
| 1914 | // do only a reduction of the leading term |
---|
| 1915 | //#define KSTD_NF_ECART 2 |
---|
| 1916 | // only local: recude even with bad ecart |
---|
[35aab3] | 1917 | poly p; |
---|
| 1918 | int i; |
---|
| 1919 | int j; |
---|
| 1920 | int o; |
---|
| 1921 | LObject h; |
---|
[d30a399] | 1922 | BITSET save1; |
---|
| 1923 | SI_SAVE_OPT1(save1); |
---|
[35aab3] | 1924 | |
---|
[822aa3a] | 1925 | //if ((idIs0(F))&&(Q==NULL)) |
---|
| 1926 | // return pCopy(q); /*F=0*/ |
---|
[1ee19dc] | 1927 | //strat->ak = si_max(idRankFreeModule(F),pMaxComp(q)); |
---|
[35aab3] | 1928 | /*- creating temp data structures------------------- -*/ |
---|
[993ae2] | 1929 | strat->kHEdgeFound = (currRing->ppNoether) != NULL; |
---|
| 1930 | strat->kNoether = pCopy((currRing->ppNoether)); |
---|
[d30a399] | 1931 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
| 1932 | si_opt_1&=~Sy_bit(OPT_INTSTRATEGY); |
---|
[35aab3] | 1933 | if (TEST_OPT_STAIRCASEBOUND |
---|
| 1934 | && (! TEST_V_DEG_STOP) |
---|
| 1935 | && (0<Kstd1_deg) |
---|
| 1936 | && ((!strat->kHEdgeFound) |
---|
| 1937 | ||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg)))) |
---|
| 1938 | { |
---|
[15d75cd] | 1939 | pLmDelete(&strat->kNoether); |
---|
[35aab3] | 1940 | strat->kNoether=pOne(); |
---|
| 1941 | pSetExp(strat->kNoether,1, Kstd1_deg+1); |
---|
| 1942 | pSetm(strat->kNoether); |
---|
| 1943 | strat->kHEdgeFound=TRUE; |
---|
| 1944 | } |
---|
| 1945 | initBuchMoraCrit(strat); |
---|
[5efbf9] | 1946 | if(rField_is_Ring(currRing)) |
---|
| 1947 | initBuchMoraPosRing(strat); |
---|
| 1948 | else |
---|
| 1949 | initBuchMoraPos(strat); |
---|
[35aab3] | 1950 | initMora(F,strat); |
---|
| 1951 | strat->enterS = enterSMoraNF; |
---|
| 1952 | /*- set T -*/ |
---|
| 1953 | strat->tl = -1; |
---|
| 1954 | strat->tmax = setmaxT; |
---|
| 1955 | strat->T = initT(); |
---|
| 1956 | strat->R = initR(); |
---|
| 1957 | strat->sevT = initsevT(); |
---|
| 1958 | /*- set S -*/ |
---|
| 1959 | strat->sl = -1; |
---|
| 1960 | /*- init local data struct.-------------------------- -*/ |
---|
| 1961 | /*Shdl=*/initS(F,Q,strat); |
---|
| 1962 | if ((strat->ak!=0) |
---|
| 1963 | && (strat->kHEdgeFound)) |
---|
| 1964 | { |
---|
| 1965 | if (strat->ak!=1) |
---|
| 1966 | { |
---|
| 1967 | pSetComp(strat->kNoether,1); |
---|
| 1968 | pSetmComp(strat->kNoether); |
---|
| 1969 | poly p=pHead(strat->kNoether); |
---|
| 1970 | pSetComp(p,strat->ak); |
---|
| 1971 | pSetmComp(p); |
---|
| 1972 | p=pAdd(strat->kNoether,p); |
---|
| 1973 | strat->kNoether=pNext(p); |
---|
[15d75cd] | 1974 | p_LmDelete(p,currRing); |
---|
[35aab3] | 1975 | } |
---|
| 1976 | } |
---|
[18ff4c] | 1977 | if ((lazyReduce & KSTD_NF_LAZY)==0) |
---|
[35aab3] | 1978 | { |
---|
| 1979 | for (i=strat->sl; i>=0; i--) |
---|
| 1980 | pNorm(strat->S[i]); |
---|
| 1981 | } |
---|
| 1982 | /*- puts the elements of S also to T -*/ |
---|
| 1983 | for (i=0; i<=strat->sl; i++) |
---|
| 1984 | { |
---|
| 1985 | h.p = strat->S[i]; |
---|
| 1986 | h.ecart = strat->ecartS[i]; |
---|
| 1987 | if (strat->sevS[i] == 0) strat->sevS[i] = pGetShortExpVector(h.p); |
---|
| 1988 | else assume(strat->sevS[i] == pGetShortExpVector(h.p)); |
---|
| 1989 | h.length = pLength(h.p); |
---|
| 1990 | h.sev = strat->sevS[i]; |
---|
| 1991 | h.SetpFDeg(); |
---|
| 1992 | enterT(h,strat); |
---|
| 1993 | } |
---|
[c25b56c] | 1994 | #ifdef KDEBUG |
---|
[601105] | 1995 | // kDebugPrint(strat); |
---|
[c25b56c] | 1996 | #endif |
---|
[35aab3] | 1997 | /*- compute------------------------------------------- -*/ |
---|
| 1998 | p = pCopy(q); |
---|
| 1999 | deleteHC(&p,&o,&j,strat); |
---|
[eb55f8a] | 2000 | kTest(strat); |
---|
[35aab3] | 2001 | if (TEST_OPT_PROT) { PrintS("r"); mflush(); } |
---|
[e9c3b2] | 2002 | if (BVERBOSE(23)) kDebugPrint(strat); |
---|
[e21795] | 2003 | if(rField_is_Ring(currRing)) |
---|
| 2004 | { |
---|
| 2005 | if (p!=NULL) p = redMoraNFRing(p,strat, lazyReduce & KSTD_NF_ECART); |
---|
| 2006 | } |
---|
| 2007 | else |
---|
[d249822] | 2008 | { |
---|
[e21795] | 2009 | if (p!=NULL) p = redMoraNF(p,strat, lazyReduce & KSTD_NF_ECART); |
---|
[d249822] | 2010 | } |
---|
[18ff4c] | 2011 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
[35aab3] | 2012 | { |
---|
| 2013 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 2014 | p = redtail(p,strat->sl,strat); |
---|
| 2015 | } |
---|
| 2016 | /*- release temp data------------------------------- -*/ |
---|
| 2017 | cleanT(strat); |
---|
[e14e025] | 2018 | assume(strat->L==NULL); /*strat->L unsed */ |
---|
| 2019 | assume(strat->B==NULL); /*strat->B unused */ |
---|
[35aab3] | 2020 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 2021 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 2022 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
[1f637e] | 2023 | omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN)); |
---|
[e14e025] | 2024 | omFree(strat->sevT); |
---|
| 2025 | omFree(strat->S_2_R); |
---|
| 2026 | omFree(strat->R); |
---|
[35aab3] | 2027 | |
---|
| 2028 | if ((Q!=NULL)&&(strat->fromQ!=NULL)) |
---|
| 2029 | { |
---|
| 2030 | i=((IDELEMS(Q)+IDELEMS(F)+15)/16)*16; |
---|
| 2031 | omFreeSize((ADDRESS)strat->fromQ,i*sizeof(int)); |
---|
| 2032 | strat->fromQ=NULL; |
---|
| 2033 | } |
---|
[15d75cd] | 2034 | if (strat->kHEdge!=NULL) pLmFree(&strat->kHEdge); |
---|
| 2035 | if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether); |
---|
[0b356b] | 2036 | // if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 2037 | // { |
---|
[eafa0ed] | 2038 | // pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
[0b356b] | 2039 | // if (ecartWeights) |
---|
| 2040 | // { |
---|
| 2041 | // omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
| 2042 | // ecartWeights=NULL; |
---|
| 2043 | // } |
---|
| 2044 | // } |
---|
[35aab3] | 2045 | idDelete(&strat->Shdl); |
---|
[d30a399] | 2046 | SI_RESTORE_OPT1(save1); |
---|
[35aab3] | 2047 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 2048 | return p; |
---|
| 2049 | } |
---|
| 2050 | |
---|
| 2051 | ideal kNF1 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce) |
---|
| 2052 | { |
---|
[822aa3a] | 2053 | assume(!idIs0(q)); |
---|
| 2054 | assume(!(idIs0(F)&&(Q==NULL))); |
---|
| 2055 | |
---|
[93f4bb] | 2056 | // lazy_reduce flags: can be combined by | |
---|
| 2057 | //#define KSTD_NF_LAZY 1 |
---|
| 2058 | // do only a reduction of the leading term |
---|
| 2059 | //#define KSTD_NF_ECART 2 |
---|
| 2060 | // only local: recude even with bad ecart |
---|
[35aab3] | 2061 | poly p; |
---|
| 2062 | int i; |
---|
| 2063 | int j; |
---|
| 2064 | int o; |
---|
| 2065 | LObject h; |
---|
| 2066 | ideal res; |
---|
[d30a399] | 2067 | BITSET save1; |
---|
| 2068 | SI_SAVE_OPT1(save1); |
---|
[35aab3] | 2069 | |
---|
[822aa3a] | 2070 | //if (idIs0(q)) return idInit(IDELEMS(q),si_max(q->rank,F->rank)); |
---|
| 2071 | //if ((idIs0(F))&&(Q==NULL)) |
---|
| 2072 | // return idCopy(q); /*F=0*/ |
---|
[1ee19dc] | 2073 | //strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(q)); |
---|
[35aab3] | 2074 | /*- creating temp data structures------------------- -*/ |
---|
[993ae2] | 2075 | strat->kHEdgeFound = (currRing->ppNoether) != NULL; |
---|
| 2076 | strat->kNoether=pCopy((currRing->ppNoether)); |
---|
[d30a399] | 2077 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
[35aab3] | 2078 | if (TEST_OPT_STAIRCASEBOUND |
---|
| 2079 | && (0<Kstd1_deg) |
---|
| 2080 | && ((!strat->kHEdgeFound) |
---|
| 2081 | ||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg)))) |
---|
| 2082 | { |
---|
[15d75cd] | 2083 | pLmDelete(&strat->kNoether); |
---|
[35aab3] | 2084 | strat->kNoether=pOne(); |
---|
| 2085 | pSetExp(strat->kNoether,1, Kstd1_deg+1); |
---|
| 2086 | pSetm(strat->kNoether); |
---|
| 2087 | strat->kHEdgeFound=TRUE; |
---|
| 2088 | } |
---|
| 2089 | initBuchMoraCrit(strat); |
---|
[5efbf9] | 2090 | if(rField_is_Ring(currRing)) |
---|
| 2091 | initBuchMoraPosRing(strat); |
---|
| 2092 | else |
---|
| 2093 | initBuchMoraPos(strat); |
---|
[35aab3] | 2094 | initMora(F,strat); |
---|
| 2095 | strat->enterS = enterSMoraNF; |
---|
| 2096 | /*- set T -*/ |
---|
| 2097 | strat->tl = -1; |
---|
| 2098 | strat->tmax = setmaxT; |
---|
| 2099 | strat->T = initT(); |
---|
| 2100 | strat->R = initR(); |
---|
| 2101 | strat->sevT = initsevT(); |
---|
| 2102 | /*- set S -*/ |
---|
| 2103 | strat->sl = -1; |
---|
| 2104 | /*- init local data struct.-------------------------- -*/ |
---|
| 2105 | /*Shdl=*/initS(F,Q,strat); |
---|
| 2106 | if ((strat->ak!=0) |
---|
| 2107 | && (strat->kHEdgeFound)) |
---|
| 2108 | { |
---|
| 2109 | if (strat->ak!=1) |
---|
| 2110 | { |
---|
| 2111 | pSetComp(strat->kNoether,1); |
---|
| 2112 | pSetmComp(strat->kNoether); |
---|
| 2113 | poly p=pHead(strat->kNoether); |
---|
| 2114 | pSetComp(p,strat->ak); |
---|
| 2115 | pSetmComp(p); |
---|
| 2116 | p=pAdd(strat->kNoether,p); |
---|
| 2117 | strat->kNoether=pNext(p); |
---|
[15d75cd] | 2118 | p_LmDelete(p,currRing); |
---|
[35aab3] | 2119 | } |
---|
| 2120 | } |
---|
[18ff4c] | 2121 | if (TEST_OPT_INTSTRATEGY && ((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
[35aab3] | 2122 | { |
---|
| 2123 | for (i=strat->sl; i>=0; i--) |
---|
| 2124 | pNorm(strat->S[i]); |
---|
| 2125 | } |
---|
| 2126 | /*- compute------------------------------------------- -*/ |
---|
[baa72c5] | 2127 | res=idInit(IDELEMS(q),strat->ak); |
---|
[35aab3] | 2128 | for (i=0; i<IDELEMS(q); i++) |
---|
| 2129 | { |
---|
| 2130 | if (q->m[i]!=NULL) |
---|
| 2131 | { |
---|
| 2132 | p = pCopy(q->m[i]); |
---|
| 2133 | deleteHC(&p,&o,&j,strat); |
---|
| 2134 | if (p!=NULL) |
---|
| 2135 | { |
---|
| 2136 | /*- puts the elements of S also to T -*/ |
---|
| 2137 | for (j=0; j<=strat->sl; j++) |
---|
| 2138 | { |
---|
| 2139 | h.p = strat->S[j]; |
---|
| 2140 | h.ecart = strat->ecartS[j]; |
---|
| 2141 | h.pLength = h.length = pLength(h.p); |
---|
| 2142 | if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p); |
---|
| 2143 | else assume(strat->sevS[j] == pGetShortExpVector(h.p)); |
---|
| 2144 | h.sev = strat->sevS[j]; |
---|
| 2145 | h.SetpFDeg(); |
---|
[19a089f] | 2146 | if(rField_is_Ring(currRing) && rHasLocalOrMixedOrdering(currRing)) |
---|
| 2147 | enterT_strong(h,strat); |
---|
| 2148 | else |
---|
[e6f1e6] | 2149 | enterT(h,strat); |
---|
[35aab3] | 2150 | } |
---|
| 2151 | if (TEST_OPT_PROT) { PrintS("r"); mflush(); } |
---|
[e21795] | 2152 | if(rField_is_Ring(currRing)) |
---|
| 2153 | { |
---|
| 2154 | p = redMoraNFRing(p,strat, lazyReduce & KSTD_NF_ECART); |
---|
| 2155 | } |
---|
| 2156 | else |
---|
| 2157 | p = redMoraNF(p,strat, lazyReduce & KSTD_NF_ECART); |
---|
[18ff4c] | 2158 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
[35aab3] | 2159 | { |
---|
| 2160 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 2161 | p = redtail(p,strat->sl,strat); |
---|
| 2162 | } |
---|
| 2163 | cleanT(strat); |
---|
| 2164 | } |
---|
| 2165 | res->m[i]=p; |
---|
| 2166 | } |
---|
| 2167 | //else |
---|
| 2168 | // res->m[i]=NULL; |
---|
| 2169 | } |
---|
| 2170 | /*- release temp data------------------------------- -*/ |
---|
[e14e025] | 2171 | assume(strat->L==NULL); /*strat->L unsed */ |
---|
| 2172 | assume(strat->B==NULL); /*strat->B unused */ |
---|
[35aab3] | 2173 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 2174 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 2175 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
[1f637e] | 2176 | omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN)); |
---|
[e14e025] | 2177 | omFree(strat->sevT); |
---|
| 2178 | omFree(strat->S_2_R); |
---|
| 2179 | omFree(strat->R); |
---|
[35aab3] | 2180 | if ((Q!=NULL)&&(strat->fromQ!=NULL)) |
---|
| 2181 | { |
---|
| 2182 | i=((IDELEMS(Q)+IDELEMS(F)+15)/16)*16; |
---|
| 2183 | omFreeSize((ADDRESS)strat->fromQ,i*sizeof(int)); |
---|
| 2184 | strat->fromQ=NULL; |
---|
| 2185 | } |
---|
[15d75cd] | 2186 | if (strat->kHEdge!=NULL) pLmFree(&strat->kHEdge); |
---|
| 2187 | if (strat->kNoether!=NULL) pLmDelete(&strat->kNoether); |
---|
[0b356b] | 2188 | // if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 2189 | // { |
---|
[eafa0ed] | 2190 | // pFDeg=strat->pOrigFDeg; |
---|
| 2191 | // pLDeg=strat->pOrigLDeg; |
---|
[0b356b] | 2192 | // if (ecartWeights) |
---|
| 2193 | // { |
---|
| 2194 | // omFreeSize((ADDRESS *)&ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
| 2195 | // ecartWeights=NULL; |
---|
| 2196 | // } |
---|
| 2197 | // } |
---|
[35aab3] | 2198 | idDelete(&strat->Shdl); |
---|
[d30a399] | 2199 | SI_RESTORE_OPT1(save1); |
---|
[35aab3] | 2200 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 2201 | return res; |
---|
| 2202 | } |
---|
| 2203 | |
---|
| 2204 | intvec * kModW, * kHomW; |
---|
| 2205 | |
---|
| 2206 | long kModDeg(poly p, ring r) |
---|
| 2207 | { |
---|
[c6e80e] | 2208 | long o=p_WDegree(p, r); |
---|
[dcddf66] | 2209 | long i=__p_GetComp(p, r); |
---|
[35aab3] | 2210 | if (i==0) return o; |
---|
[a51351c] | 2211 | //assume((i>0) && (i<=kModW->length())); |
---|
| 2212 | if (i<=kModW->length()) |
---|
| 2213 | return o+(*kModW)[i-1]; |
---|
[d95cee] | 2214 | return o; |
---|
[35aab3] | 2215 | } |
---|
| 2216 | long kHomModDeg(poly p, ring r) |
---|
| 2217 | { |
---|
| 2218 | int i; |
---|
| 2219 | long j=0; |
---|
| 2220 | |
---|
| 2221 | for (i=r->N;i>0;i--) |
---|
| 2222 | j+=p_GetExp(p,i,r)*(*kHomW)[i-1]; |
---|
| 2223 | if (kModW == NULL) return j; |
---|
[dcddf66] | 2224 | i = __p_GetComp(p,r); |
---|
[35aab3] | 2225 | if (i==0) return j; |
---|
| 2226 | return j+(*kModW)[i-1]; |
---|
| 2227 | } |
---|
| 2228 | |
---|
| 2229 | ideal kStd(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp, |
---|
[8204ed] | 2230 | int newIdeal, intvec *vw, s_poly_proc_t sp) |
---|
[35aab3] | 2231 | { |
---|
[645a19] | 2232 | if(idIs0(F)) |
---|
| 2233 | return idInit(1,F->rank); |
---|
| 2234 | |
---|
[35aab3] | 2235 | ideal r; |
---|
[fe89b98] | 2236 | BOOLEAN b=currRing->pLexOrder,toReset=FALSE; |
---|
[35aab3] | 2237 | BOOLEAN delete_w=(w==NULL); |
---|
| 2238 | kStrategy strat=new skStrategy; |
---|
| 2239 | |
---|
[8204ed] | 2240 | strat->s_poly=sp; |
---|
[35aab3] | 2241 | if(!TEST_OPT_RETURN_SB) |
---|
| 2242 | strat->syzComp = syzComp; |
---|
[fb12237] | 2243 | if (TEST_OPT_SB_1 |
---|
| 2244 | &&(!rField_is_Ring(currRing)) |
---|
| 2245 | ) |
---|
[35aab3] | 2246 | strat->newIdeal = newIdeal; |
---|
[0b356b] | 2247 | if (rField_has_simple_inverse(currRing)) |
---|
[35aab3] | 2248 | strat->LazyPass=20; |
---|
| 2249 | else |
---|
| 2250 | strat->LazyPass=2; |
---|
| 2251 | strat->LazyDegree = 1; |
---|
[0b356b] | 2252 | strat->ak = id_RankFreeModule(F,currRing); |
---|
[35aab3] | 2253 | strat->kModW=kModW=NULL; |
---|
| 2254 | strat->kHomW=kHomW=NULL; |
---|
| 2255 | if (vw != NULL) |
---|
| 2256 | { |
---|
[fe89b98] | 2257 | currRing->pLexOrder=FALSE; |
---|
[35aab3] | 2258 | strat->kHomW=kHomW=vw; |
---|
[eafa0ed] | 2259 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2260 | strat->pOrigLDeg = currRing->pLDeg; |
---|
[0b356b] | 2261 | pSetDegProcs(currRing,kHomModDeg); |
---|
[35aab3] | 2262 | toReset = TRUE; |
---|
| 2263 | } |
---|
| 2264 | if (h==testHomog) |
---|
| 2265 | { |
---|
| 2266 | if (strat->ak == 0) |
---|
| 2267 | { |
---|
| 2268 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 2269 | w=NULL; |
---|
| 2270 | } |
---|
| 2271 | else if (!TEST_OPT_DEGBOUND) |
---|
| 2272 | { |
---|
[21d5430] | 2273 | if (w!=NULL) |
---|
| 2274 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 2275 | else |
---|
| 2276 | h = (tHomog)idHomIdeal(F,Q); |
---|
[35aab3] | 2277 | } |
---|
| 2278 | } |
---|
[fe89b98] | 2279 | currRing->pLexOrder=b; |
---|
[35aab3] | 2280 | if (h==isHomog) |
---|
| 2281 | { |
---|
| 2282 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 2283 | { |
---|
| 2284 | strat->kModW = kModW = *w; |
---|
| 2285 | if (vw == NULL) |
---|
| 2286 | { |
---|
[eafa0ed] | 2287 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2288 | strat->pOrigLDeg = currRing->pLDeg; |
---|
[0b356b] | 2289 | pSetDegProcs(currRing,kModDeg); |
---|
[35aab3] | 2290 | toReset = TRUE; |
---|
| 2291 | } |
---|
| 2292 | } |
---|
[fe89b98] | 2293 | currRing->pLexOrder = TRUE; |
---|
[35aab3] | 2294 | if (hilb==NULL) strat->LazyPass*=2; |
---|
| 2295 | } |
---|
| 2296 | strat->homog=h; |
---|
| 2297 | #ifdef KDEBUG |
---|
| 2298 | idTest(F); |
---|
[9e8bfa] | 2299 | if (Q!=NULL) idTest(Q); |
---|
[35aab3] | 2300 | #endif |
---|
| 2301 | #ifdef HAVE_PLURAL |
---|
| 2302 | if (rIsPluralRing(currRing)) |
---|
| 2303 | { |
---|
[a794e7] | 2304 | const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit |
---|
| 2305 | strat->no_prod_crit = ! bIsSCA; |
---|
[35aab3] | 2306 | if (w!=NULL) |
---|
[0b356b] | 2307 | r = nc_GB(F, Q, *w, hilb, strat, currRing); |
---|
[35aab3] | 2308 | else |
---|
[0b356b] | 2309 | r = nc_GB(F, Q, NULL, hilb, strat, currRing); |
---|
[35aab3] | 2310 | } |
---|
| 2311 | else |
---|
[c31189c] | 2312 | #endif |
---|
[009bd5] | 2313 | { |
---|
[5efbf9] | 2314 | #if PRE_INTEGER_CHECK |
---|
[d3963a] | 2315 | //the preinteger check strategy is not for modules |
---|
| 2316 | if(rField_is_Ring(currRing) && nCoeff_is_Ring_Z(currRing->cf) && strat->ak <= 0) |
---|
[1c3860b] | 2317 | { |
---|
[d3963a] | 2318 | ideal FCopy = idCopy(F); |
---|
| 2319 | poly pFmon = preIntegerCheck(FCopy, Q); |
---|
| 2320 | if(pFmon != NULL) |
---|
| 2321 | { |
---|
| 2322 | idInsertPoly(FCopy, pFmon); |
---|
[ef2729] | 2323 | #ifdef ADIDEBUG |
---|
[d3963a] | 2324 | printf("\nPreintegerCheck found this constant:\n");pWrite(pFmon); |
---|
| 2325 | #endif |
---|
[bdebb8] | 2326 | |
---|
[d3963a] | 2327 | strat->kModW=kModW=NULL; |
---|
| 2328 | if (h==testHomog) |
---|
[1c3860b] | 2329 | { |
---|
[d3963a] | 2330 | if (strat->ak == 0) |
---|
[fc58b5b] | 2331 | { |
---|
[d3963a] | 2332 | h = (tHomog)idHomIdeal(FCopy,Q); |
---|
| 2333 | w=NULL; |
---|
[1c3860b] | 2334 | } |
---|
[d3963a] | 2335 | else if (!TEST_OPT_DEGBOUND) |
---|
[1c3860b] | 2336 | { |
---|
[d3963a] | 2337 | h = (tHomog)idHomModule(FCopy,Q,w); |
---|
[1c3860b] | 2338 | } |
---|
| 2339 | } |
---|
[d3963a] | 2340 | currRing->pLexOrder=b; |
---|
| 2341 | if (h==isHomog) |
---|
[1c3860b] | 2342 | { |
---|
[d3963a] | 2343 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 2344 | { |
---|
| 2345 | strat->kModW = kModW = *w; |
---|
| 2346 | if (vw == NULL) |
---|
| 2347 | { |
---|
| 2348 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2349 | strat->pOrigLDeg = currRing->pLDeg; |
---|
| 2350 | pSetDegProcs(currRing,kModDeg); |
---|
| 2351 | toReset = TRUE; |
---|
| 2352 | } |
---|
| 2353 | } |
---|
| 2354 | currRing->pLexOrder = TRUE; |
---|
| 2355 | if (hilb==NULL) strat->LazyPass*=2; |
---|
[1c3860b] | 2356 | } |
---|
[d3963a] | 2357 | strat->homog=h; |
---|
| 2358 | } |
---|
[31b6f4] | 2359 | #ifdef ADIDEBUG |
---|
[456eb62] | 2360 | else |
---|
[d3963a] | 2361 | { |
---|
| 2362 | printf("\npreIntegerCheck didn't found any new information\n"); |
---|
| 2363 | } |
---|
[31b6f4] | 2364 | #endif |
---|
[d3963a] | 2365 | omTestMemory(1); |
---|
| 2366 | if(w == NULL) |
---|
| 2367 | { |
---|
| 2368 | if(rHasLocalOrMixedOrdering(currRing)) |
---|
| 2369 | r=mora(FCopy,Q,NULL,hilb,strat); |
---|
| 2370 | else |
---|
| 2371 | r=bba(FCopy,Q,NULL,hilb,strat); |
---|
| 2372 | } |
---|
[5a9e7b] | 2373 | else |
---|
[d3963a] | 2374 | { |
---|
| 2375 | if(rHasLocalOrMixedOrdering(currRing)) |
---|
| 2376 | r=mora(FCopy,Q,*w,hilb,strat); |
---|
| 2377 | else |
---|
| 2378 | r=bba(FCopy,Q,*w,hilb,strat); |
---|
| 2379 | } |
---|
| 2380 | idDelete(&FCopy); |
---|
[5a9e7b] | 2381 | } |
---|
[35aab3] | 2382 | else |
---|
[d3963a] | 2383 | #endif |
---|
[5a9e7b] | 2384 | { |
---|
[d3963a] | 2385 | if(w==NULL) |
---|
| 2386 | { |
---|
| 2387 | if(rHasLocalOrMixedOrdering(currRing)) |
---|
| 2388 | r=mora(F,Q,NULL,hilb,strat); |
---|
| 2389 | else |
---|
| 2390 | r=bba(F,Q,NULL,hilb,strat); |
---|
| 2391 | } |
---|
[5a9e7b] | 2392 | else |
---|
[d3963a] | 2393 | { |
---|
| 2394 | if(rHasLocalOrMixedOrdering(currRing)) |
---|
| 2395 | r=mora(F,Q,*w,hilb,strat); |
---|
| 2396 | else |
---|
| 2397 | r=bba(F,Q,*w,hilb,strat); |
---|
| 2398 | } |
---|
[5a9e7b] | 2399 | } |
---|
[35aab3] | 2400 | } |
---|
| 2401 | #ifdef KDEBUG |
---|
| 2402 | idTest(r); |
---|
| 2403 | #endif |
---|
| 2404 | if (toReset) |
---|
| 2405 | { |
---|
| 2406 | kModW = NULL; |
---|
[eafa0ed] | 2407 | pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
[35aab3] | 2408 | } |
---|
[fe89b98] | 2409 | currRing->pLexOrder = b; |
---|
[1c473f] | 2410 | //Print("%d reductions canceled \n",strat->cel); |
---|
| 2411 | HCord=strat->HCord; |
---|
| 2412 | delete(strat); |
---|
| 2413 | if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w; |
---|
| 2414 | return r; |
---|
| 2415 | } |
---|
| 2416 | |
---|
[f7f084] | 2417 | ideal kSba(ideal F, ideal Q, tHomog h,intvec ** w, int sbaOrder, int arri, intvec *hilb,int syzComp, |
---|
[83be980] | 2418 | int newIdeal, intvec *vw) |
---|
| 2419 | { |
---|
[e009ef] | 2420 | if(idIs0(F)) |
---|
| 2421 | return idInit(1,F->rank); |
---|
[042a24] | 2422 | if(!rField_is_Ring(currRing)) |
---|
[83be980] | 2423 | { |
---|
[042a24] | 2424 | ideal r; |
---|
| 2425 | BOOLEAN b=currRing->pLexOrder,toReset=FALSE; |
---|
| 2426 | BOOLEAN delete_w=(w==NULL); |
---|
| 2427 | kStrategy strat=new skStrategy; |
---|
| 2428 | strat->sbaOrder = sbaOrder; |
---|
| 2429 | if (arri!=0) |
---|
[83be980] | 2430 | { |
---|
[042a24] | 2431 | strat->rewCrit1 = arriRewDummy; |
---|
| 2432 | strat->rewCrit2 = arriRewCriterion; |
---|
| 2433 | strat->rewCrit3 = arriRewCriterionPre; |
---|
[83be980] | 2434 | } |
---|
[042a24] | 2435 | else |
---|
[83be980] | 2436 | { |
---|
[042a24] | 2437 | strat->rewCrit1 = faugereRewCriterion; |
---|
| 2438 | strat->rewCrit2 = faugereRewCriterion; |
---|
| 2439 | strat->rewCrit3 = faugereRewCriterion; |
---|
[83be980] | 2440 | } |
---|
[042a24] | 2441 | |
---|
| 2442 | if(!TEST_OPT_RETURN_SB) |
---|
| 2443 | strat->syzComp = syzComp; |
---|
| 2444 | if (TEST_OPT_SB_1) |
---|
[e009ef] | 2445 | //if(!rField_is_Ring(currRing)) // always true here |
---|
[042a24] | 2446 | strat->newIdeal = newIdeal; |
---|
| 2447 | if (rField_has_simple_inverse(currRing)) |
---|
| 2448 | strat->LazyPass=20; |
---|
| 2449 | else |
---|
| 2450 | strat->LazyPass=2; |
---|
| 2451 | strat->LazyDegree = 1; |
---|
| 2452 | strat->enterOnePair=enterOnePairNormal; |
---|
| 2453 | strat->chainCrit=chainCritNormal; |
---|
| 2454 | if (TEST_OPT_SB_1) strat->chainCrit=chainCritOpt_1; |
---|
| 2455 | strat->ak = id_RankFreeModule(F,currRing); |
---|
| 2456 | strat->kModW=kModW=NULL; |
---|
| 2457 | strat->kHomW=kHomW=NULL; |
---|
| 2458 | if (vw != NULL) |
---|
| 2459 | { |
---|
| 2460 | currRing->pLexOrder=FALSE; |
---|
| 2461 | strat->kHomW=kHomW=vw; |
---|
| 2462 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2463 | strat->pOrigLDeg = currRing->pLDeg; |
---|
| 2464 | pSetDegProcs(currRing,kHomModDeg); |
---|
| 2465 | toReset = TRUE; |
---|
| 2466 | } |
---|
| 2467 | if (h==testHomog) |
---|
| 2468 | { |
---|
| 2469 | if (strat->ak == 0) |
---|
| 2470 | { |
---|
| 2471 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 2472 | w=NULL; |
---|
| 2473 | } |
---|
| 2474 | else if (!TEST_OPT_DEGBOUND) |
---|
| 2475 | { |
---|
| 2476 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 2477 | } |
---|
| 2478 | } |
---|
| 2479 | currRing->pLexOrder=b; |
---|
| 2480 | if (h==isHomog) |
---|
[83be980] | 2481 | { |
---|
[042a24] | 2482 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
[83be980] | 2483 | { |
---|
[042a24] | 2484 | strat->kModW = kModW = *w; |
---|
| 2485 | if (vw == NULL) |
---|
| 2486 | { |
---|
| 2487 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2488 | strat->pOrigLDeg = currRing->pLDeg; |
---|
| 2489 | pSetDegProcs(currRing,kModDeg); |
---|
| 2490 | toReset = TRUE; |
---|
| 2491 | } |
---|
[83be980] | 2492 | } |
---|
[042a24] | 2493 | currRing->pLexOrder = TRUE; |
---|
| 2494 | if (hilb==NULL) strat->LazyPass*=2; |
---|
[83be980] | 2495 | } |
---|
[042a24] | 2496 | strat->homog=h; |
---|
| 2497 | #ifdef KDEBUG |
---|
| 2498 | idTest(F); |
---|
| 2499 | if(Q != NULL) |
---|
| 2500 | idTest(Q); |
---|
| 2501 | #endif |
---|
| 2502 | #ifdef HAVE_PLURAL |
---|
| 2503 | if (rIsPluralRing(currRing)) |
---|
[83be980] | 2504 | { |
---|
[042a24] | 2505 | const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit |
---|
| 2506 | strat->no_prod_crit = ! bIsSCA; |
---|
[83be980] | 2507 | if (w!=NULL) |
---|
[042a24] | 2508 | r = nc_GB(F, Q, *w, hilb, strat, currRing); |
---|
[83be980] | 2509 | else |
---|
[042a24] | 2510 | r = nc_GB(F, Q, NULL, hilb, strat, currRing); |
---|
[83be980] | 2511 | } |
---|
| 2512 | else |
---|
[042a24] | 2513 | #endif |
---|
[83be980] | 2514 | { |
---|
[042a24] | 2515 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
| 2516 | { |
---|
| 2517 | if (w!=NULL) |
---|
| 2518 | r=mora(F,Q,*w,hilb,strat); |
---|
| 2519 | else |
---|
| 2520 | r=mora(F,Q,NULL,hilb,strat); |
---|
| 2521 | } |
---|
[83be980] | 2522 | else |
---|
[042a24] | 2523 | { |
---|
[e40da9f] | 2524 | strat->sigdrop = FALSE; |
---|
[042a24] | 2525 | if (w!=NULL) |
---|
| 2526 | r=sba(F,Q,*w,hilb,strat); |
---|
| 2527 | else |
---|
| 2528 | r=sba(F,Q,NULL,hilb,strat); |
---|
| 2529 | } |
---|
| 2530 | } |
---|
| 2531 | #ifdef KDEBUG |
---|
| 2532 | idTest(r); |
---|
| 2533 | #endif |
---|
| 2534 | if (toReset) |
---|
| 2535 | { |
---|
| 2536 | kModW = NULL; |
---|
| 2537 | pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
| 2538 | } |
---|
| 2539 | currRing->pLexOrder = b; |
---|
| 2540 | //Print("%d reductions canceled \n",strat->cel); |
---|
| 2541 | HCord=strat->HCord; |
---|
| 2542 | //delete(strat); |
---|
| 2543 | if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w; |
---|
| 2544 | return r; |
---|
| 2545 | } |
---|
| 2546 | else |
---|
| 2547 | { |
---|
| 2548 | //--------------------------RING CASE------------------------- |
---|
[e40da9f] | 2549 | assume(sbaOrder == 1); |
---|
| 2550 | assume(arri == 0); |
---|
[042a24] | 2551 | ideal r; |
---|
| 2552 | r = idCopy(F); |
---|
| 2553 | int sbaEnterS = -1; |
---|
| 2554 | bool sigdrop = TRUE; |
---|
[ef2729] | 2555 | #ifdef ADIDEBUG |
---|
[042a24] | 2556 | printf("\nEnter the nice kSba loop\n"); |
---|
| 2557 | #endif |
---|
| 2558 | //This is how we set the SBA algorithm; |
---|
[d249822] | 2559 | int totalsbaruns = 1,blockedreductions = 20,blockred = 0,loops = 0; |
---|
[c6a876] | 2560 | while(sigdrop && (loops < totalsbaruns || totalsbaruns == -1) |
---|
[7d2b89] | 2561 | && (blockred <= blockedreductions)) |
---|
[042a24] | 2562 | { |
---|
| 2563 | loops++; |
---|
| 2564 | if(loops == 1) |
---|
| 2565 | sigdrop = FALSE; |
---|
| 2566 | BOOLEAN b=currRing->pLexOrder,toReset=FALSE; |
---|
| 2567 | BOOLEAN delete_w=(w==NULL); |
---|
| 2568 | kStrategy strat=new skStrategy; |
---|
| 2569 | strat->sbaEnterS = sbaEnterS; |
---|
| 2570 | strat->sigdrop = sigdrop; |
---|
[7d2b89] | 2571 | #if 0 |
---|
| 2572 | strat->blockred = blockred; |
---|
| 2573 | #else |
---|
| 2574 | strat->blockred = 0; |
---|
| 2575 | #endif |
---|
| 2576 | strat->blockredmax = blockedreductions; |
---|
[459ec94] | 2577 | //printf("\nsbaEnterS beginning = %i\n",strat->sbaEnterS); |
---|
| 2578 | //printf("\nsigdrop beginning = %i\n",strat->sigdrop); |
---|
[042a24] | 2579 | strat->sbaOrder = sbaOrder; |
---|
| 2580 | if (arri!=0) |
---|
| 2581 | { |
---|
| 2582 | strat->rewCrit1 = arriRewDummy; |
---|
| 2583 | strat->rewCrit2 = arriRewCriterion; |
---|
| 2584 | strat->rewCrit3 = arriRewCriterionPre; |
---|
| 2585 | } |
---|
| 2586 | else |
---|
| 2587 | { |
---|
| 2588 | strat->rewCrit1 = faugereRewCriterion; |
---|
| 2589 | strat->rewCrit2 = faugereRewCriterion; |
---|
| 2590 | strat->rewCrit3 = faugereRewCriterion; |
---|
| 2591 | } |
---|
| 2592 | |
---|
| 2593 | if(!TEST_OPT_RETURN_SB) |
---|
| 2594 | strat->syzComp = syzComp; |
---|
| 2595 | if (TEST_OPT_SB_1) |
---|
| 2596 | if(!rField_is_Ring(currRing)) |
---|
| 2597 | strat->newIdeal = newIdeal; |
---|
| 2598 | if (rField_has_simple_inverse(currRing)) |
---|
| 2599 | strat->LazyPass=20; |
---|
| 2600 | else |
---|
| 2601 | strat->LazyPass=2; |
---|
| 2602 | strat->LazyDegree = 1; |
---|
| 2603 | strat->enterOnePair=enterOnePairNormal; |
---|
| 2604 | strat->chainCrit=chainCritNormal; |
---|
| 2605 | if (TEST_OPT_SB_1) strat->chainCrit=chainCritOpt_1; |
---|
| 2606 | strat->ak = id_RankFreeModule(F,currRing); |
---|
| 2607 | strat->kModW=kModW=NULL; |
---|
| 2608 | strat->kHomW=kHomW=NULL; |
---|
| 2609 | if (vw != NULL) |
---|
| 2610 | { |
---|
| 2611 | currRing->pLexOrder=FALSE; |
---|
| 2612 | strat->kHomW=kHomW=vw; |
---|
| 2613 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2614 | strat->pOrigLDeg = currRing->pLDeg; |
---|
| 2615 | pSetDegProcs(currRing,kHomModDeg); |
---|
| 2616 | toReset = TRUE; |
---|
| 2617 | } |
---|
| 2618 | if (h==testHomog) |
---|
| 2619 | { |
---|
| 2620 | if (strat->ak == 0) |
---|
| 2621 | { |
---|
| 2622 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 2623 | w=NULL; |
---|
| 2624 | } |
---|
| 2625 | else if (!TEST_OPT_DEGBOUND) |
---|
| 2626 | { |
---|
| 2627 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 2628 | } |
---|
| 2629 | } |
---|
| 2630 | currRing->pLexOrder=b; |
---|
| 2631 | if (h==isHomog) |
---|
| 2632 | { |
---|
| 2633 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 2634 | { |
---|
| 2635 | strat->kModW = kModW = *w; |
---|
| 2636 | if (vw == NULL) |
---|
| 2637 | { |
---|
| 2638 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2639 | strat->pOrigLDeg = currRing->pLDeg; |
---|
| 2640 | pSetDegProcs(currRing,kModDeg); |
---|
| 2641 | toReset = TRUE; |
---|
| 2642 | } |
---|
| 2643 | } |
---|
| 2644 | currRing->pLexOrder = TRUE; |
---|
| 2645 | if (hilb==NULL) strat->LazyPass*=2; |
---|
| 2646 | } |
---|
| 2647 | strat->homog=h; |
---|
| 2648 | #ifdef KDEBUG |
---|
| 2649 | idTest(F); |
---|
| 2650 | if(Q != NULL) |
---|
| 2651 | idTest(Q); |
---|
| 2652 | #endif |
---|
| 2653 | #ifdef HAVE_PLURAL |
---|
| 2654 | if (rIsPluralRing(currRing)) |
---|
| 2655 | { |
---|
| 2656 | const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit |
---|
| 2657 | strat->no_prod_crit = ! bIsSCA; |
---|
| 2658 | if (w!=NULL) |
---|
| 2659 | r = nc_GB(F, Q, *w, hilb, strat, currRing); |
---|
| 2660 | else |
---|
| 2661 | r = nc_GB(F, Q, NULL, hilb, strat, currRing); |
---|
| 2662 | } |
---|
| 2663 | else |
---|
| 2664 | #endif |
---|
| 2665 | { |
---|
| 2666 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
| 2667 | { |
---|
| 2668 | if (w!=NULL) |
---|
| 2669 | r=mora(F,Q,*w,hilb,strat); |
---|
| 2670 | else |
---|
| 2671 | r=mora(F,Q,NULL,hilb,strat); |
---|
| 2672 | } |
---|
| 2673 | else |
---|
[094031] | 2674 | { |
---|
[042a24] | 2675 | if (w!=NULL) |
---|
| 2676 | r=sba(r,Q,*w,hilb,strat); |
---|
| 2677 | else |
---|
[c6a876] | 2678 | { |
---|
[042a24] | 2679 | r=sba(r,Q,NULL,hilb,strat); |
---|
| 2680 | } |
---|
[ef2729] | 2681 | #ifdef ADIDEBUG |
---|
[042a24] | 2682 | printf("\nSBA Run %i: %i elements (syzCrit = %i,rewCrit = %i)\n",loops,IDELEMS(r),strat->nrsyzcrit,strat->nrrewcrit); |
---|
| 2683 | idPrint(r); |
---|
[d249822] | 2684 | //getchar(); |
---|
[094031] | 2685 | #endif |
---|
| 2686 | } |
---|
| 2687 | } |
---|
[042a24] | 2688 | #ifdef KDEBUG |
---|
| 2689 | idTest(r); |
---|
| 2690 | #endif |
---|
| 2691 | if (toReset) |
---|
| 2692 | { |
---|
| 2693 | kModW = NULL; |
---|
| 2694 | pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
| 2695 | } |
---|
| 2696 | currRing->pLexOrder = b; |
---|
| 2697 | //Print("%d reductions canceled \n",strat->cel); |
---|
| 2698 | HCord=strat->HCord; |
---|
| 2699 | sigdrop = strat->sigdrop; |
---|
| 2700 | sbaEnterS = strat->sbaEnterS; |
---|
[7d2b89] | 2701 | blockred = strat->blockred; |
---|
[ef2729] | 2702 | #ifdef ADIDEBUG |
---|
[042a24] | 2703 | printf("\nsbaEnterS = %i\n",sbaEnterS); |
---|
| 2704 | #endif |
---|
| 2705 | delete(strat); |
---|
| 2706 | if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w; |
---|
[83be980] | 2707 | } |
---|
[042a24] | 2708 | // Go to std |
---|
[7d2b89] | 2709 | if(sigdrop || blockred > blockedreductions) |
---|
[042a24] | 2710 | { |
---|
[ef2729] | 2711 | #ifdef ADIDEBUG |
---|
[042a24] | 2712 | printf("\nWent to std\n"); |
---|
[d249822] | 2713 | idPrint(r); |
---|
| 2714 | getchar(); |
---|
[042a24] | 2715 | #endif |
---|
| 2716 | r = kStd(r, Q, h, w, hilb, syzComp, newIdeal, vw); |
---|
| 2717 | } |
---|
| 2718 | return r; |
---|
[83be980] | 2719 | } |
---|
| 2720 | } |
---|
| 2721 | |
---|
[037df4] | 2722 | #ifdef HAVE_SHIFTBBA |
---|
[1c473f] | 2723 | ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp, |
---|
[36605f] | 2724 | int newIdeal, intvec *vw, int uptodeg, int lV) |
---|
[1c473f] | 2725 | { |
---|
| 2726 | ideal r; |
---|
[fe89b98] | 2727 | BOOLEAN b=currRing->pLexOrder,toReset=FALSE; |
---|
[1c473f] | 2728 | BOOLEAN delete_w=(w==NULL); |
---|
| 2729 | kStrategy strat=new skStrategy; |
---|
| 2730 | |
---|
| 2731 | if(!TEST_OPT_RETURN_SB) |
---|
| 2732 | strat->syzComp = syzComp; |
---|
| 2733 | if (TEST_OPT_SB_1) |
---|
[9927b9e] | 2734 | if(!rField_is_Ring(currRing)) |
---|
[e6f1e6] | 2735 | strat->newIdeal = newIdeal; |
---|
[0b356b] | 2736 | if (rField_has_simple_inverse(currRing)) |
---|
[1c473f] | 2737 | strat->LazyPass=20; |
---|
| 2738 | else |
---|
| 2739 | strat->LazyPass=2; |
---|
| 2740 | strat->LazyDegree = 1; |
---|
[0b356b] | 2741 | strat->ak = id_RankFreeModule(F,currRing); |
---|
[1c473f] | 2742 | strat->kModW=kModW=NULL; |
---|
| 2743 | strat->kHomW=kHomW=NULL; |
---|
| 2744 | if (vw != NULL) |
---|
| 2745 | { |
---|
[fe89b98] | 2746 | currRing->pLexOrder=FALSE; |
---|
[1c473f] | 2747 | strat->kHomW=kHomW=vw; |
---|
[eafa0ed] | 2748 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2749 | strat->pOrigLDeg = currRing->pLDeg; |
---|
[0b356b] | 2750 | pSetDegProcs(currRing,kHomModDeg); |
---|
[1c473f] | 2751 | toReset = TRUE; |
---|
| 2752 | } |
---|
| 2753 | if (h==testHomog) |
---|
| 2754 | { |
---|
| 2755 | if (strat->ak == 0) |
---|
| 2756 | { |
---|
| 2757 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 2758 | w=NULL; |
---|
| 2759 | } |
---|
| 2760 | else if (!TEST_OPT_DEGBOUND) |
---|
| 2761 | { |
---|
| 2762 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 2763 | } |
---|
| 2764 | } |
---|
[fe89b98] | 2765 | currRing->pLexOrder=b; |
---|
[1c473f] | 2766 | if (h==isHomog) |
---|
| 2767 | { |
---|
| 2768 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 2769 | { |
---|
| 2770 | strat->kModW = kModW = *w; |
---|
| 2771 | if (vw == NULL) |
---|
| 2772 | { |
---|
[eafa0ed] | 2773 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2774 | strat->pOrigLDeg = currRing->pLDeg; |
---|
[0b356b] | 2775 | pSetDegProcs(currRing,kModDeg); |
---|
[1c473f] | 2776 | toReset = TRUE; |
---|
| 2777 | } |
---|
| 2778 | } |
---|
[fe89b98] | 2779 | currRing->pLexOrder = TRUE; |
---|
[1c473f] | 2780 | if (hilb==NULL) strat->LazyPass*=2; |
---|
| 2781 | } |
---|
| 2782 | strat->homog=h; |
---|
| 2783 | #ifdef KDEBUG |
---|
| 2784 | idTest(F); |
---|
| 2785 | #endif |
---|
[009bd5] | 2786 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
[1c473f] | 2787 | { |
---|
| 2788 | /* error: no local ord yet with shifts */ |
---|
[f9b0bd] | 2789 | PrintS("No local ordering possible for shifts"); |
---|
[1c473f] | 2790 | return(NULL); |
---|
| 2791 | } |
---|
| 2792 | else |
---|
| 2793 | { |
---|
| 2794 | /* global ordering */ |
---|
| 2795 | if (w!=NULL) |
---|
| 2796 | r=bbaShift(F,Q,*w,hilb,strat,uptodeg,lV); |
---|
| 2797 | else |
---|
| 2798 | r=bbaShift(F,Q,NULL,hilb,strat,uptodeg,lV); |
---|
| 2799 | } |
---|
| 2800 | #ifdef KDEBUG |
---|
| 2801 | idTest(r); |
---|
| 2802 | #endif |
---|
| 2803 | if (toReset) |
---|
| 2804 | { |
---|
| 2805 | kModW = NULL; |
---|
[eafa0ed] | 2806 | pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
[1c473f] | 2807 | } |
---|
[fe89b98] | 2808 | currRing->pLexOrder = b; |
---|
[35aab3] | 2809 | //Print("%d reductions canceled \n",strat->cel); |
---|
| 2810 | HCord=strat->HCord; |
---|
| 2811 | delete(strat); |
---|
| 2812 | if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w; |
---|
| 2813 | return r; |
---|
| 2814 | } |
---|
[037df4] | 2815 | #endif |
---|
[35aab3] | 2816 | |
---|
| 2817 | //############################################################## |
---|
| 2818 | //############################################################## |
---|
| 2819 | //############################################################## |
---|
| 2820 | //############################################################## |
---|
| 2821 | //############################################################## |
---|
| 2822 | |
---|
| 2823 | ideal kMin_std(ideal F, ideal Q, tHomog h,intvec ** w, ideal &M, intvec *hilb, |
---|
| 2824 | int syzComp, int reduced) |
---|
| 2825 | { |
---|
[645a19] | 2826 | if(idIs0(F)) |
---|
[9eafde] | 2827 | { |
---|
| 2828 | M=idInit(1,F->rank); |
---|
[645a19] | 2829 | return idInit(1,F->rank); |
---|
[9eafde] | 2830 | } |
---|
[0fc231] | 2831 | if(rField_is_Ring(currRing)) |
---|
| 2832 | { |
---|
| 2833 | ideal sb; |
---|
| 2834 | sb = kStd(F, Q, h, w, hilb); |
---|
| 2835 | idSkipZeroes(sb); |
---|
| 2836 | if(IDELEMS(sb) <= IDELEMS(F)) |
---|
| 2837 | { |
---|
| 2838 | M = idCopy(sb); |
---|
| 2839 | idSkipZeroes(M); |
---|
| 2840 | return(sb); |
---|
| 2841 | } |
---|
| 2842 | else |
---|
| 2843 | { |
---|
| 2844 | M = idCopy(F); |
---|
| 2845 | idSkipZeroes(M); |
---|
| 2846 | return(sb); |
---|
| 2847 | } |
---|
| 2848 | } |
---|
[35aab3] | 2849 | ideal r=NULL; |
---|
| 2850 | int Kstd1_OldDeg = Kstd1_deg,i; |
---|
| 2851 | intvec* temp_w=NULL; |
---|
[fe89b98] | 2852 | BOOLEAN b=currRing->pLexOrder,toReset=FALSE; |
---|
[35aab3] | 2853 | BOOLEAN delete_w=(w==NULL); |
---|
| 2854 | BOOLEAN oldDegBound=TEST_OPT_DEGBOUND; |
---|
| 2855 | kStrategy strat=new skStrategy; |
---|
| 2856 | |
---|
| 2857 | if(!TEST_OPT_RETURN_SB) |
---|
| 2858 | strat->syzComp = syzComp; |
---|
[0b356b] | 2859 | if (rField_has_simple_inverse(currRing)) |
---|
[35aab3] | 2860 | strat->LazyPass=20; |
---|
| 2861 | else |
---|
| 2862 | strat->LazyPass=2; |
---|
| 2863 | strat->LazyDegree = 1; |
---|
| 2864 | strat->minim=(reduced % 2)+1; |
---|
[0b356b] | 2865 | strat->ak = id_RankFreeModule(F,currRing); |
---|
[35aab3] | 2866 | if (delete_w) |
---|
| 2867 | { |
---|
| 2868 | temp_w=new intvec((strat->ak)+1); |
---|
| 2869 | w = &temp_w; |
---|
| 2870 | } |
---|
[30664c] | 2871 | if (h==testHomog) |
---|
[35aab3] | 2872 | { |
---|
| 2873 | if (strat->ak == 0) |
---|
| 2874 | { |
---|
| 2875 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 2876 | w=NULL; |
---|
| 2877 | } |
---|
| 2878 | else |
---|
| 2879 | { |
---|
| 2880 | h = (tHomog)idHomModule(F,Q,w); |
---|
| 2881 | } |
---|
| 2882 | } |
---|
| 2883 | if (h==isHomog) |
---|
| 2884 | { |
---|
| 2885 | if (strat->ak > 0 && (w!=NULL) && (*w!=NULL)) |
---|
| 2886 | { |
---|
| 2887 | kModW = *w; |
---|
| 2888 | strat->kModW = *w; |
---|
[aef70f7] | 2889 | assume(currRing->pFDeg != NULL && currRing->pLDeg != NULL); |
---|
[eafa0ed] | 2890 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 2891 | strat->pOrigLDeg = currRing->pLDeg; |
---|
[0b356b] | 2892 | pSetDegProcs(currRing,kModDeg); |
---|
[35aab3] | 2893 | |
---|
| 2894 | toReset = TRUE; |
---|
| 2895 | if (reduced>1) |
---|
| 2896 | { |
---|
| 2897 | Kstd1_OldDeg=Kstd1_deg; |
---|
| 2898 | Kstd1_deg = -1; |
---|
| 2899 | for (i=IDELEMS(F)-1;i>=0;i--) |
---|
| 2900 | { |
---|
[0b356b] | 2901 | if ((F->m[i]!=NULL) && (currRing->pFDeg(F->m[i],currRing)>=Kstd1_deg)) |
---|
| 2902 | Kstd1_deg = currRing->pFDeg(F->m[i],currRing)+1; |
---|
[35aab3] | 2903 | } |
---|
| 2904 | } |
---|
| 2905 | } |
---|
[fe89b98] | 2906 | currRing->pLexOrder = TRUE; |
---|
[35aab3] | 2907 | strat->LazyPass*=2; |
---|
| 2908 | } |
---|
| 2909 | strat->homog=h; |
---|
[009bd5] | 2910 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
[35aab3] | 2911 | { |
---|
| 2912 | if (w!=NULL) |
---|
| 2913 | r=mora(F,Q,*w,hilb,strat); |
---|
| 2914 | else |
---|
| 2915 | r=mora(F,Q,NULL,hilb,strat); |
---|
| 2916 | } |
---|
| 2917 | else |
---|
| 2918 | { |
---|
| 2919 | if (w!=NULL) |
---|
| 2920 | r=bba(F,Q,*w,hilb,strat); |
---|
| 2921 | else |
---|
| 2922 | r=bba(F,Q,NULL,hilb,strat); |
---|
| 2923 | } |
---|
| 2924 | #ifdef KDEBUG |
---|
| 2925 | { |
---|
| 2926 | int i; |
---|
| 2927 | for (i=IDELEMS(r)-1; i>=0; i--) pTest(r->m[i]); |
---|
| 2928 | } |
---|
| 2929 | #endif |
---|
| 2930 | idSkipZeroes(r); |
---|
| 2931 | if (toReset) |
---|
| 2932 | { |
---|
[eafa0ed] | 2933 | pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
[35aab3] | 2934 | kModW = NULL; |
---|
| 2935 | } |
---|
[fe89b98] | 2936 | currRing->pLexOrder = b; |
---|
[35aab3] | 2937 | HCord=strat->HCord; |
---|
| 2938 | if ((delete_w)&&(temp_w!=NULL)) delete temp_w; |
---|
[15bfa8] | 2939 | if ((IDELEMS(r)==1) && (r->m[0]!=NULL) && pIsConstant(r->m[0]) && (strat->ak==0)) |
---|
| 2940 | { |
---|
[f52515c] | 2941 | M=idInit(1,F->rank); |
---|
[15bfa8] | 2942 | M->m[0]=pOne(); |
---|
| 2943 | //if (strat->ak!=0) { pSetComp(M->m[0],strat->ak); pSetmComp(M->m[0]); } |
---|
[716335] | 2944 | if (strat->M!=NULL) idDelete(&strat->M); |
---|
[15bfa8] | 2945 | } |
---|
[899741] | 2946 | else if (strat->M==NULL) |
---|
[35aab3] | 2947 | { |
---|
| 2948 | M=idInit(1,F->rank); |
---|
| 2949 | Warn("no minimal generating set computed"); |
---|
| 2950 | } |
---|
| 2951 | else |
---|
| 2952 | { |
---|
| 2953 | idSkipZeroes(strat->M); |
---|
| 2954 | M=strat->M; |
---|
| 2955 | } |
---|
| 2956 | delete(strat); |
---|
| 2957 | if (reduced>2) |
---|
| 2958 | { |
---|
| 2959 | Kstd1_deg=Kstd1_OldDeg; |
---|
| 2960 | if (!oldDegBound) |
---|
[d30a399] | 2961 | si_opt_1 &= ~Sy_bit(OPT_DEGBOUND); |
---|
[35aab3] | 2962 | } |
---|
[899741] | 2963 | else |
---|
| 2964 | { |
---|
[fea494] | 2965 | if (IDELEMS(M)>IDELEMS(r)) { |
---|
| 2966 | idDelete(&M); |
---|
[0fc231] | 2967 | M=idCopy(r); } |
---|
[899741] | 2968 | } |
---|
[35aab3] | 2969 | return r; |
---|
| 2970 | } |
---|
| 2971 | |
---|
| 2972 | poly kNF(ideal F, ideal Q, poly p,int syzComp, int lazyReduce) |
---|
| 2973 | { |
---|
| 2974 | if (p==NULL) |
---|
| 2975 | return NULL; |
---|
[52e2f6] | 2976 | |
---|
| 2977 | poly pp = p; |
---|
[36605f] | 2978 | |
---|
[52e2f6] | 2979 | #ifdef HAVE_PLURAL |
---|
| 2980 | if(rIsSCA(currRing)) |
---|
| 2981 | { |
---|
| 2982 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 2983 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 2984 | pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 2985 | |
---|
[ac00e2f] | 2986 | if(Q == currRing->qideal) |
---|
[52e2f6] | 2987 | Q = SCAQuotient(currRing); |
---|
| 2988 | } |
---|
| 2989 | #endif |
---|
[36605f] | 2990 | |
---|
[645a19] | 2991 | if ((idIs0(F))&&(Q==NULL)) |
---|
| 2992 | { |
---|
| 2993 | #ifdef HAVE_PLURAL |
---|
| 2994 | if(p != pp) |
---|
| 2995 | return pp; |
---|
| 2996 | #endif |
---|
| 2997 | return pCopy(p); /*F+Q=0*/ |
---|
| 2998 | } |
---|
| 2999 | |
---|
| 3000 | kStrategy strat=new skStrategy; |
---|
| 3001 | strat->syzComp = syzComp; |
---|
[0b356b] | 3002 | strat->ak = si_max(id_RankFreeModule(F,currRing),pMaxComp(p)); |
---|
[52e2f6] | 3003 | poly res; |
---|
| 3004 | |
---|
[009bd5] | 3005 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
[52e2f6] | 3006 | res=kNF1(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 3007 | else |
---|
[52e2f6] | 3008 | res=kNF2(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 3009 | delete(strat); |
---|
[52e2f6] | 3010 | |
---|
| 3011 | #ifdef HAVE_PLURAL |
---|
| 3012 | if(pp != p) |
---|
| 3013 | p_Delete(&pp, currRing); |
---|
| 3014 | #endif |
---|
| 3015 | return res; |
---|
[35aab3] | 3016 | } |
---|
| 3017 | |
---|
[c2ef83] | 3018 | poly kNFBound(ideal F, ideal Q, poly p,int bound,int syzComp, int lazyReduce) |
---|
| 3019 | { |
---|
| 3020 | if (p==NULL) |
---|
| 3021 | return NULL; |
---|
| 3022 | |
---|
| 3023 | poly pp = p; |
---|
| 3024 | |
---|
| 3025 | #ifdef HAVE_PLURAL |
---|
| 3026 | if(rIsSCA(currRing)) |
---|
| 3027 | { |
---|
| 3028 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 3029 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 3030 | pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 3031 | |
---|
| 3032 | if(Q == currRing->qideal) |
---|
| 3033 | Q = SCAQuotient(currRing); |
---|
| 3034 | } |
---|
| 3035 | #endif |
---|
| 3036 | |
---|
| 3037 | if ((idIs0(F))&&(Q==NULL)) |
---|
| 3038 | { |
---|
| 3039 | #ifdef HAVE_PLURAL |
---|
| 3040 | if(p != pp) |
---|
| 3041 | return pp; |
---|
| 3042 | #endif |
---|
| 3043 | return pCopy(p); /*F+Q=0*/ |
---|
| 3044 | } |
---|
| 3045 | |
---|
| 3046 | kStrategy strat=new skStrategy; |
---|
| 3047 | strat->syzComp = syzComp; |
---|
| 3048 | strat->ak = si_max(id_RankFreeModule(F,currRing),pMaxComp(p)); |
---|
| 3049 | poly res; |
---|
| 3050 | res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce); |
---|
| 3051 | delete(strat); |
---|
| 3052 | |
---|
| 3053 | #ifdef HAVE_PLURAL |
---|
| 3054 | if(pp != p) |
---|
| 3055 | p_Delete(&pp, currRing); |
---|
| 3056 | #endif |
---|
| 3057 | return res; |
---|
| 3058 | } |
---|
| 3059 | |
---|
[35aab3] | 3060 | ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce) |
---|
| 3061 | { |
---|
| 3062 | ideal res; |
---|
| 3063 | if (TEST_OPT_PROT) |
---|
| 3064 | { |
---|
| 3065 | Print("(S:%d)",IDELEMS(p));mflush(); |
---|
| 3066 | } |
---|
[822aa3a] | 3067 | if (idIs0(p)) |
---|
| 3068 | return idInit(IDELEMS(p),si_max(p->rank,F->rank)); |
---|
[52e2f6] | 3069 | |
---|
| 3070 | ideal pp = p; |
---|
| 3071 | #ifdef HAVE_PLURAL |
---|
| 3072 | if(rIsSCA(currRing)) |
---|
| 3073 | { |
---|
| 3074 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 3075 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
[8ba25b] | 3076 | pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false); |
---|
[52e2f6] | 3077 | |
---|
[ac00e2f] | 3078 | if(Q == currRing->qideal) |
---|
[52e2f6] | 3079 | Q = SCAQuotient(currRing); |
---|
| 3080 | } |
---|
| 3081 | #endif |
---|
| 3082 | |
---|
[645a19] | 3083 | if ((idIs0(F))&&(Q==NULL)) |
---|
| 3084 | { |
---|
| 3085 | #ifdef HAVE_PLURAL |
---|
| 3086 | if(p != pp) |
---|
| 3087 | return pp; |
---|
| 3088 | #endif |
---|
| 3089 | return idCopy(p); /*F+Q=0*/ |
---|
| 3090 | } |
---|
| 3091 | |
---|
| 3092 | kStrategy strat=new skStrategy; |
---|
| 3093 | strat->syzComp = syzComp; |
---|
[0b356b] | 3094 | strat->ak = si_max(id_RankFreeModule(F,currRing),id_RankFreeModule(p,currRing)); |
---|
[b28edc] | 3095 | if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst |
---|
| 3096 | { |
---|
| 3097 | strat->ak = si_max(strat->ak,(int)F->rank); |
---|
| 3098 | } |
---|
[645a19] | 3099 | |
---|
[009bd5] | 3100 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
[52e2f6] | 3101 | res=kNF1(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 3102 | else |
---|
[52e2f6] | 3103 | res=kNF2(F,Q,pp,strat,lazyReduce); |
---|
[35aab3] | 3104 | delete(strat); |
---|
[52e2f6] | 3105 | |
---|
| 3106 | #ifdef HAVE_PLURAL |
---|
| 3107 | if(pp != p) |
---|
| 3108 | id_Delete(&pp, currRing); |
---|
| 3109 | #endif |
---|
| 3110 | |
---|
[35aab3] | 3111 | return res; |
---|
| 3112 | } |
---|
| 3113 | |
---|
[c2ef83] | 3114 | ideal kNFBound(ideal F, ideal Q, ideal p,int bound,int syzComp,int lazyReduce) |
---|
| 3115 | { |
---|
| 3116 | ideal res; |
---|
| 3117 | if (TEST_OPT_PROT) |
---|
| 3118 | { |
---|
| 3119 | Print("(S:%d)",IDELEMS(p));mflush(); |
---|
| 3120 | } |
---|
| 3121 | if (idIs0(p)) |
---|
| 3122 | return idInit(IDELEMS(p),si_max(p->rank,F->rank)); |
---|
| 3123 | |
---|
| 3124 | ideal pp = p; |
---|
| 3125 | #ifdef HAVE_PLURAL |
---|
| 3126 | if(rIsSCA(currRing)) |
---|
| 3127 | { |
---|
| 3128 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 3129 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 3130 | pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false); |
---|
| 3131 | |
---|
| 3132 | if(Q == currRing->qideal) |
---|
| 3133 | Q = SCAQuotient(currRing); |
---|
| 3134 | } |
---|
| 3135 | #endif |
---|
| 3136 | |
---|
| 3137 | if ((idIs0(F))&&(Q==NULL)) |
---|
| 3138 | { |
---|
| 3139 | #ifdef HAVE_PLURAL |
---|
| 3140 | if(p != pp) |
---|
| 3141 | return pp; |
---|
| 3142 | #endif |
---|
| 3143 | return idCopy(p); /*F+Q=0*/ |
---|
| 3144 | } |
---|
| 3145 | |
---|
| 3146 | kStrategy strat=new skStrategy; |
---|
| 3147 | strat->syzComp = syzComp; |
---|
| 3148 | strat->ak = si_max(id_RankFreeModule(F,currRing),id_RankFreeModule(p,currRing)); |
---|
| 3149 | if (strat->ak>0) // only for module case, see Tst/Short/bug_reduce.tst |
---|
| 3150 | { |
---|
| 3151 | strat->ak = si_max(strat->ak,(int)F->rank); |
---|
| 3152 | } |
---|
| 3153 | |
---|
| 3154 | res=kNF2Bound(F,Q,pp,bound,strat,lazyReduce); |
---|
| 3155 | delete(strat); |
---|
| 3156 | |
---|
| 3157 | #ifdef HAVE_PLURAL |
---|
| 3158 | if(pp != p) |
---|
| 3159 | id_Delete(&pp, currRing); |
---|
| 3160 | #endif |
---|
| 3161 | |
---|
| 3162 | return res; |
---|
| 3163 | } |
---|
| 3164 | |
---|
[c6ded3] | 3165 | poly k_NF (ideal F, ideal Q, poly p,int syzComp, int lazyReduce, const ring _currRing) |
---|
[64f0ca] | 3166 | { |
---|
[c6ded3] | 3167 | const ring save = currRing; |
---|
| 3168 | if( currRing != _currRing ) rChangeCurrRing(_currRing); |
---|
[64f0ca] | 3169 | poly ret = kNF(F, Q, p, syzComp, lazyReduce); |
---|
| 3170 | if( currRing != save ) rChangeCurrRing(save); |
---|
| 3171 | return ret; |
---|
| 3172 | } |
---|
| 3173 | |
---|
[35aab3] | 3174 | /*2 |
---|
| 3175 | *interreduces F |
---|
| 3176 | */ |
---|
[36605f] | 3177 | // old version |
---|
| 3178 | ideal kInterRedOld (ideal F, ideal Q) |
---|
[35aab3] | 3179 | { |
---|
[36605f] | 3180 | int j; |
---|
[16493d] | 3181 | kStrategy strat = new skStrategy; |
---|
[36605f] | 3182 | |
---|
| 3183 | ideal tempF = F; |
---|
| 3184 | ideal tempQ = Q; |
---|
| 3185 | |
---|
| 3186 | #ifdef HAVE_PLURAL |
---|
| 3187 | if(rIsSCA(currRing)) |
---|
| 3188 | { |
---|
| 3189 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 3190 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 3191 | tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 3192 | |
---|
| 3193 | // this should be done on the upper level!!! : |
---|
| 3194 | // tempQ = SCAQuotient(currRing); |
---|
| 3195 | |
---|
[ac00e2f] | 3196 | if(Q == currRing->qideal) |
---|
[36605f] | 3197 | tempQ = SCAQuotient(currRing); |
---|
| 3198 | } |
---|
| 3199 | #endif |
---|
| 3200 | |
---|
| 3201 | // if (TEST_OPT_PROT) |
---|
| 3202 | // { |
---|
| 3203 | // writeTime("start InterRed:"); |
---|
| 3204 | // mflush(); |
---|
| 3205 | // } |
---|
| 3206 | //strat->syzComp = 0; |
---|
[993ae2] | 3207 | strat->kHEdgeFound = (currRing->ppNoether) != NULL; |
---|
| 3208 | strat->kNoether=pCopy((currRing->ppNoether)); |
---|
[0b356b] | 3209 | strat->ak = id_RankFreeModule(tempF,currRing); |
---|
[16493d] | 3210 | initBuchMoraCrit(strat); |
---|
[1f637e] | 3211 | strat->NotUsedAxis = (BOOLEAN *)omAlloc(((currRing->N)+1)*sizeof(BOOLEAN)); |
---|
| 3212 | for (j=(currRing->N); j>0; j--) strat->NotUsedAxis[j] = TRUE; |
---|
[16493d] | 3213 | strat->enterS = enterSBba; |
---|
| 3214 | strat->posInT = posInT17; |
---|
| 3215 | strat->initEcart = initEcartNormal; |
---|
[36605f] | 3216 | strat->sl = -1; |
---|
[16493d] | 3217 | strat->tl = -1; |
---|
| 3218 | strat->tmax = setmaxT; |
---|
| 3219 | strat->T = initT(); |
---|
| 3220 | strat->R = initR(); |
---|
| 3221 | strat->sevT = initsevT(); |
---|
[009bd5] | 3222 | if (rHasLocalOrMixedOrdering(currRing)) strat->honey = TRUE; |
---|
[36605f] | 3223 | initS(tempF, tempQ, strat); |
---|
[16493d] | 3224 | if (TEST_OPT_REDSB) |
---|
| 3225 | strat->noTailReduction=FALSE; |
---|
[36605f] | 3226 | updateS(TRUE,strat); |
---|
| 3227 | if (TEST_OPT_REDSB && TEST_OPT_INTSTRATEGY) |
---|
| 3228 | completeReduce(strat); |
---|
| 3229 | //else if (TEST_OPT_PROT) PrintLn(); |
---|
[15d75cd] | 3230 | if (strat->kHEdge!=NULL) pLmFree(&strat->kHEdge); |
---|
[36605f] | 3231 | omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject)); |
---|
| 3232 | omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 3233 | omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long)); |
---|
[1f637e] | 3234 | omFreeSize((ADDRESS)strat->NotUsedAxis,((currRing->N)+1)*sizeof(BOOLEAN)); |
---|
[36605f] | 3235 | omfree(strat->sevT); |
---|
| 3236 | omfree(strat->S_2_R); |
---|
| 3237 | omfree(strat->R); |
---|
| 3238 | |
---|
| 3239 | if (strat->fromQ) |
---|
| 3240 | { |
---|
| 3241 | for (j=IDELEMS(strat->Shdl)-1;j>=0;j--) |
---|
| 3242 | { |
---|
| 3243 | if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]); |
---|
| 3244 | } |
---|
| 3245 | omFreeSize((ADDRESS)strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
| 3246 | } |
---|
| 3247 | // if (TEST_OPT_PROT) |
---|
| 3248 | // { |
---|
| 3249 | // writeTime("end Interred:"); |
---|
| 3250 | // mflush(); |
---|
| 3251 | // } |
---|
| 3252 | ideal shdl=strat->Shdl; |
---|
| 3253 | idSkipZeroes(shdl); |
---|
| 3254 | if (strat->fromQ) |
---|
| 3255 | { |
---|
| 3256 | strat->fromQ=NULL; |
---|
| 3257 | ideal res=kInterRed(shdl,NULL); |
---|
| 3258 | idDelete(&shdl); |
---|
| 3259 | shdl=res; |
---|
| 3260 | } |
---|
| 3261 | delete(strat); |
---|
| 3262 | #ifdef HAVE_PLURAL |
---|
| 3263 | if( tempF != F ) |
---|
| 3264 | id_Delete( &tempF, currRing); |
---|
| 3265 | #endif |
---|
| 3266 | return shdl; |
---|
| 3267 | } |
---|
| 3268 | // new version |
---|
| 3269 | ideal kInterRedBba (ideal F, ideal Q, int &need_retry) |
---|
| 3270 | { |
---|
| 3271 | need_retry=0; |
---|
[930ea8] | 3272 | int red_result = 1; |
---|
[36605f] | 3273 | int olddeg,reduc; |
---|
| 3274 | BOOLEAN withT = FALSE; |
---|
[cd4f24] | 3275 | // BOOLEAN toReset=FALSE; |
---|
[36605f] | 3276 | kStrategy strat=new skStrategy; |
---|
| 3277 | tHomog h; |
---|
| 3278 | intvec * w=NULL; |
---|
| 3279 | |
---|
[0b356b] | 3280 | if (rField_has_simple_inverse(currRing)) |
---|
[36605f] | 3281 | strat->LazyPass=20; |
---|
| 3282 | else |
---|
| 3283 | strat->LazyPass=2; |
---|
| 3284 | strat->LazyDegree = 1; |
---|
[0b356b] | 3285 | strat->ak = id_RankFreeModule(F,currRing); |
---|
[36605f] | 3286 | strat->syzComp = strat->ak; |
---|
| 3287 | strat->kModW=kModW=NULL; |
---|
| 3288 | strat->kHomW=kHomW=NULL; |
---|
| 3289 | if (strat->ak == 0) |
---|
| 3290 | { |
---|
| 3291 | h = (tHomog)idHomIdeal(F,Q); |
---|
| 3292 | w=NULL; |
---|
| 3293 | } |
---|
| 3294 | else if (!TEST_OPT_DEGBOUND) |
---|
| 3295 | { |
---|
| 3296 | h = (tHomog)idHomModule(F,Q,&w); |
---|
| 3297 | } |
---|
| 3298 | if (h==isHomog) |
---|
| 3299 | { |
---|
| 3300 | if (strat->ak > 0 && (w!=NULL) && (w!=NULL)) |
---|
| 3301 | { |
---|
| 3302 | strat->kModW = kModW = w; |
---|
[eafa0ed] | 3303 | strat->pOrigFDeg = currRing->pFDeg; |
---|
| 3304 | strat->pOrigLDeg = currRing->pLDeg; |
---|
[0b356b] | 3305 | pSetDegProcs(currRing,kModDeg); |
---|
[cd4f24] | 3306 | // toReset = TRUE; |
---|
[36605f] | 3307 | } |
---|
| 3308 | strat->LazyPass*=2; |
---|
| 3309 | } |
---|
| 3310 | strat->homog=h; |
---|
| 3311 | #ifdef KDEBUG |
---|
| 3312 | idTest(F); |
---|
| 3313 | #endif |
---|
| 3314 | |
---|
| 3315 | initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ |
---|
[5efbf9] | 3316 | if(rField_is_Ring(currRing)) |
---|
| 3317 | initBuchMoraPosRing(strat); |
---|
| 3318 | else |
---|
| 3319 | initBuchMoraPos(strat); |
---|
[4cc32b2] | 3320 | initBba(strat); |
---|
[36605f] | 3321 | /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ |
---|
| 3322 | strat->posInL=posInL0; /* ord according pComp */ |
---|
| 3323 | |
---|
[780e11] | 3324 | /*Shdl=*/initBuchMora(F, Q, strat); |
---|
[930ea8] | 3325 | reduc = olddeg = 0; |
---|
[16493d] | 3326 | |
---|
| 3327 | #ifndef NO_BUCKETS |
---|
| 3328 | if (!TEST_OPT_NOT_BUCKETS) |
---|
| 3329 | strat->use_buckets = 1; |
---|
| 3330 | #endif |
---|
| 3331 | |
---|
[36605f] | 3332 | // redtailBBa against T for inhomogenous input |
---|
[228b631] | 3333 | if (!TEST_OPT_OLDSTD) |
---|
[36605f] | 3334 | withT = ! strat->homog; |
---|
| 3335 | |
---|
[16493d] | 3336 | // strat->posInT = posInT_pLength; |
---|
[eb55f8a] | 3337 | kTest_TS(strat); |
---|
[16493d] | 3338 | |
---|
[36605f] | 3339 | #ifdef HAVE_TAIL_RING |
---|
| 3340 | kStratInitChangeTailRing(strat); |
---|
| 3341 | #endif |
---|
| 3342 | |
---|
[16493d] | 3343 | /* compute------------------------------------------------------- */ |
---|
| 3344 | while (strat->Ll >= 0) |
---|
[35aab3] | 3345 | { |
---|
[08ab82] | 3346 | #ifdef KDEBUG |
---|
[36605f] | 3347 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[08ab82] | 3348 | #endif |
---|
[16493d] | 3349 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
| 3350 | /* picks the last element from the lazyset L */ |
---|
| 3351 | strat->P = strat->L[strat->Ll]; |
---|
| 3352 | strat->Ll--; |
---|
| 3353 | |
---|
[36605f] | 3354 | if (strat->P.p1 == NULL) |
---|
| 3355 | { |
---|
| 3356 | // for input polys, prepare reduction |
---|
| 3357 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 3358 | } |
---|
[16493d] | 3359 | |
---|
| 3360 | if (strat->P.p == NULL && strat->P.t_p == NULL) |
---|
[35aab3] | 3361 | { |
---|
[16493d] | 3362 | red_result = 0; |
---|
[35aab3] | 3363 | } |
---|
[16493d] | 3364 | else |
---|
| 3365 | { |
---|
| 3366 | if (TEST_OPT_PROT) |
---|
[4378bb] | 3367 | message(strat->P.pFDeg(), |
---|
[16493d] | 3368 | &olddeg,&reduc,strat, red_result); |
---|
| 3369 | |
---|
[88615db] | 3370 | /* reduction of the element chosen from L */ |
---|
[16493d] | 3371 | red_result = strat->red(&strat->P,strat); |
---|
| 3372 | } |
---|
| 3373 | |
---|
| 3374 | // reduction to non-zero new poly |
---|
| 3375 | if (red_result == 1) |
---|
| 3376 | { |
---|
| 3377 | /* statistic */ |
---|
| 3378 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 3379 | |
---|
| 3380 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 3381 | strat->P.GetP(strat->lmBin); |
---|
| 3382 | |
---|
| 3383 | int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 3384 | |
---|
| 3385 | // reduce the tail and normalize poly |
---|
[36605f] | 3386 | // in the ring case we cannot expect LC(f) = 1, |
---|
| 3387 | // therefore we call pContent instead of pNorm |
---|
| 3388 | if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing))) |
---|
[16493d] | 3389 | { |
---|
| 3390 | strat->P.pCleardenom(); |
---|
[34a9b4f] | 3391 | if (0) |
---|
[4378bb] | 3392 | //if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
[16493d] | 3393 | { |
---|
[36605f] | 3394 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
[16493d] | 3395 | strat->P.pCleardenom(); |
---|
| 3396 | } |
---|
| 3397 | } |
---|
| 3398 | else |
---|
| 3399 | { |
---|
| 3400 | strat->P.pNorm(); |
---|
[34a9b4f] | 3401 | if (0) |
---|
[4378bb] | 3402 | //if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
[36605f] | 3403 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
[16493d] | 3404 | } |
---|
| 3405 | |
---|
| 3406 | #ifdef KDEBUG |
---|
| 3407 | if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} |
---|
| 3408 | #endif |
---|
| 3409 | |
---|
| 3410 | // enter into S, L, and T |
---|
[a973339] | 3411 | if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) |
---|
| 3412 | { |
---|
[36605f] | 3413 | enterT(strat->P, strat); |
---|
[a973339] | 3414 | // posInS only depends on the leading term |
---|
| 3415 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
[36605f] | 3416 | |
---|
[a973339] | 3417 | if (pos<strat->sl) |
---|
[d95cee] | 3418 | { |
---|
[a973339] | 3419 | need_retry++; |
---|
| 3420 | // move all "larger" elements fromS to L |
---|
| 3421 | // remove them from T |
---|
| 3422 | int ii=pos+1; |
---|
| 3423 | for(;ii<=strat->sl;ii++) |
---|
[d95cee] | 3424 | { |
---|
[a973339] | 3425 | LObject h; |
---|
| 3426 | memset(&h,0,sizeof(h)); |
---|
| 3427 | h.tailRing=strat->tailRing; |
---|
| 3428 | h.p=strat->S[ii]; strat->S[ii]=NULL; |
---|
| 3429 | strat->initEcart(&h); |
---|
| 3430 | h.sev=strat->sevS[ii]; |
---|
| 3431 | int jj=strat->tl; |
---|
| 3432 | while (jj>=0) |
---|
[d95cee] | 3433 | { |
---|
[a973339] | 3434 | if (strat->T[jj].p==h.p) |
---|
[d95cee] | 3435 | { |
---|
[a973339] | 3436 | strat->T[jj].p=NULL; |
---|
| 3437 | if (jj<strat->tl) |
---|
| 3438 | { |
---|
| 3439 | memmove(&(strat->T[jj]),&(strat->T[jj+1]), |
---|
| 3440 | (strat->tl-jj)*sizeof(strat->T[jj])); |
---|
| 3441 | memmove(&(strat->sevT[jj]),&(strat->sevT[jj+1]), |
---|
| 3442 | (strat->tl-jj)*sizeof(strat->sevT[jj])); |
---|
| 3443 | } |
---|
| 3444 | strat->tl--; |
---|
| 3445 | break; |
---|
[d95cee] | 3446 | } |
---|
[a973339] | 3447 | jj--; |
---|
[d95cee] | 3448 | } |
---|
[a973339] | 3449 | int lpos=strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 3450 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,lpos); |
---|
| 3451 | #ifdef KDEBUG |
---|
| 3452 | if (TEST_OPT_DEBUG) |
---|
| 3453 | { |
---|
| 3454 | Print("move S[%d] -> L[%d]: ",ii,pos); |
---|
| 3455 | p_wrp(h.p,currRing, strat->tailRing); |
---|
| 3456 | PrintLn(); |
---|
| 3457 | } |
---|
| 3458 | #endif |
---|
[d95cee] | 3459 | } |
---|
[a973339] | 3460 | if (strat->fromQ!=NULL) |
---|
[a642361] | 3461 | { |
---|
[a973339] | 3462 | for(ii=pos+1;ii<=strat->sl;ii++) strat->fromQ[ii]=0; |
---|
[a642361] | 3463 | } |
---|
[a973339] | 3464 | strat->sl=pos; |
---|
[a642361] | 3465 | } |
---|
[d95cee] | 3466 | } |
---|
[a973339] | 3467 | else |
---|
| 3468 | { |
---|
| 3469 | // clean P |
---|
| 3470 | } |
---|
| 3471 | if (strat->P.lcm!=NULL) |
---|
| 3472 | #ifdef HAVE_RINGS |
---|
| 3473 | pLmDelete(strat->P.lcm); |
---|
| 3474 | #else |
---|
| 3475 | pLmFree(strat->P.lcm); |
---|
| 3476 | #endif |
---|
[16493d] | 3477 | } |
---|
[36605f] | 3478 | |
---|
[16493d] | 3479 | #ifdef KDEBUG |
---|
[780e11] | 3480 | if (TEST_OPT_DEBUG) |
---|
| 3481 | { |
---|
| 3482 | messageSets(strat); |
---|
| 3483 | } |
---|
[16493d] | 3484 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 3485 | #endif |
---|
[d95cee] | 3486 | //kTest_TS(strat);: i_r out of sync in kInterRedBba, but not used! |
---|
[35aab3] | 3487 | } |
---|
| 3488 | #ifdef KDEBUG |
---|
[36605f] | 3489 | //if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[35aab3] | 3490 | #endif |
---|
[16493d] | 3491 | /* complete reduction of the standard basis--------- */ |
---|
[36605f] | 3492 | |
---|
[a642361] | 3493 | if((need_retry<=0) && (TEST_OPT_REDSB)) |
---|
[35aab3] | 3494 | { |
---|
[16493d] | 3495 | completeReduce(strat); |
---|
| 3496 | if (strat->completeReduce_retry) |
---|
| 3497 | { |
---|
| 3498 | // completeReduce needed larger exponents, retry |
---|
[b68503] | 3499 | // hopefully: kStratChangeTailRing already provided a larger tailRing |
---|
| 3500 | // (otherwise: it will fail again) |
---|
[17510a] | 3501 | strat->completeReduce_retry=FALSE; |
---|
[16493d] | 3502 | completeReduce(strat); |
---|
[349e5e8] | 3503 | if (strat->completeReduce_retry) |
---|
| 3504 | { |
---|
| 3505 | #ifdef HAVE_TAIL_RING |
---|
| 3506 | if(currRing->bitmask>strat->tailRing->bitmask) |
---|
| 3507 | { |
---|
[b68503] | 3508 | // retry without T |
---|
[349e5e8] | 3509 | strat->completeReduce_retry=FALSE; |
---|
| 3510 | cleanT(strat);strat->tailRing=currRing; |
---|
| 3511 | int i; |
---|
| 3512 | for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1; |
---|
| 3513 | completeReduce(strat); |
---|
| 3514 | } |
---|
| 3515 | if (strat->completeReduce_retry) |
---|
[36605f] | 3516 | #endif |
---|
[349e5e8] | 3517 | Werror("exponent bound is %ld",currRing->bitmask); |
---|
| 3518 | } |
---|
| 3519 | } |
---|
[35aab3] | 3520 | } |
---|
[5accf0] | 3521 | else if (TEST_OPT_PROT) PrintLn(); |
---|
[16493d] | 3522 | |
---|
[349e5e8] | 3523 | |
---|
[16493d] | 3524 | /* release temp data-------------------------------- */ |
---|
[36605f] | 3525 | exitBuchMora(strat); |
---|
[0b356b] | 3526 | // if (TEST_OPT_WEIGHTM) |
---|
| 3527 | // { |
---|
[eafa0ed] | 3528 | // pRestoreDegProcs(currRing,strat->pOrigFDeg, strat->pOrigLDeg); |
---|
[0b356b] | 3529 | // if (ecartWeights) |
---|
| 3530 | // { |
---|
| 3531 | // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
| 3532 | // ecartWeights=NULL; |
---|
| 3533 | // } |
---|
| 3534 | // } |
---|
[930ea8] | 3535 | //if (TEST_OPT_PROT) messageStat(0/*hilbcount*/,strat); |
---|
[36605f] | 3536 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
| 3537 | ideal res=strat->Shdl; |
---|
| 3538 | strat->Shdl=NULL; |
---|
| 3539 | delete strat; |
---|
| 3540 | if (w!=NULL) delete w; |
---|
| 3541 | return res; |
---|
[35aab3] | 3542 | } |
---|
| 3543 | ideal kInterRed (ideal F, ideal Q) |
---|
| 3544 | { |
---|
[32b0000] | 3545 | #ifdef HAVE_PLURAL |
---|
[36605f] | 3546 | if(rIsPluralRing(currRing)) return kInterRedOld(F,Q); |
---|
[32b0000] | 3547 | #endif |
---|
[009bd5] | 3548 | if ((rHasLocalOrMixedOrdering(currRing))|| (rField_is_numeric(currRing)) |
---|
[8993b0] | 3549 | ||(rField_is_Ring(currRing)) |
---|
| 3550 | ) |
---|
[34a9b4f] | 3551 | return kInterRedOld(F,Q); |
---|
[36605f] | 3552 | |
---|
[d95cee] | 3553 | //return kInterRedOld(F,Q); |
---|
| 3554 | |
---|
[d30a399] | 3555 | BITSET save1; |
---|
| 3556 | SI_SAVE_OPT1(save1); |
---|
| 3557 | //si_opt_1|=Sy_bit(OPT_NOT_SUGAR); |
---|
| 3558 | si_opt_1|=Sy_bit(OPT_REDTHROUGH); |
---|
| 3559 | //si_opt_1&= ~Sy_bit(OPT_REDTAIL); |
---|
| 3560 | //si_opt_1&= ~Sy_bit(OPT_REDSB); |
---|
[4378bb] | 3561 | //extern char * showOption() ; |
---|
| 3562 | //Print("%s\n",showOption()); |
---|
| 3563 | |
---|
[36605f] | 3564 | int need_retry; |
---|
| 3565 | int counter=3; |
---|
[780e11] | 3566 | ideal res, res1; |
---|
| 3567 | int elems; |
---|
| 3568 | ideal null=NULL; |
---|
| 3569 | if ((Q==NULL) || (!TEST_OPT_REDSB)) |
---|
| 3570 | { |
---|
| 3571 | elems=idElem(F); |
---|
| 3572 | res=kInterRedBba(F,Q,need_retry); |
---|
| 3573 | } |
---|
| 3574 | else |
---|
| 3575 | { |
---|
| 3576 | ideal FF=idSimpleAdd(F,Q); |
---|
| 3577 | res=kInterRedBba(FF,NULL,need_retry); |
---|
| 3578 | idDelete(&FF); |
---|
| 3579 | null=idInit(1,1); |
---|
[601105] | 3580 | if (need_retry) |
---|
| 3581 | res1=kNF(null,Q,res,0,KSTD_NF_LAZY); |
---|
| 3582 | else |
---|
| 3583 | res1=kNF(null,Q,res); |
---|
[780e11] | 3584 | idDelete(&res); |
---|
| 3585 | res=res1; |
---|
[b51d2c] | 3586 | need_retry=1; |
---|
[780e11] | 3587 | } |
---|
[b51d2c] | 3588 | if (idElem(res)<=1) need_retry=0; |
---|
[36605f] | 3589 | while (need_retry && (counter>0)) |
---|
| 3590 | { |
---|
[a642361] | 3591 | #ifdef KDEBUG |
---|
| 3592 | if (TEST_OPT_DEBUG) { Print("retry counter %d\n",counter); } |
---|
| 3593 | #endif |
---|
[780e11] | 3594 | res1=kInterRedBba(res,Q,need_retry); |
---|
[36605f] | 3595 | int new_elems=idElem(res1); |
---|
| 3596 | counter -= (new_elems >= elems); |
---|
| 3597 | elems = new_elems; |
---|
| 3598 | idDelete(&res); |
---|
[b51d2c] | 3599 | if (idElem(res1)<=1) need_retry=0; |
---|
[780e11] | 3600 | if ((Q!=NULL) && (TEST_OPT_REDSB)) |
---|
| 3601 | { |
---|
[b51d2c] | 3602 | if (need_retry) |
---|
| 3603 | res=kNF(null,Q,res1,0,KSTD_NF_LAZY); |
---|
| 3604 | else |
---|
| 3605 | res=kNF(null,Q,res1); |
---|
[780e11] | 3606 | idDelete(&res1); |
---|
| 3607 | } |
---|
| 3608 | else |
---|
| 3609 | res = res1; |
---|
[b51d2c] | 3610 | if (idElem(res)<=1) need_retry=0; |
---|
[36605f] | 3611 | } |
---|
[780e11] | 3612 | if (null!=NULL) idDelete(&null); |
---|
[d30a399] | 3613 | SI_RESTORE_OPT1(save1); |
---|
[36605f] | 3614 | idSkipZeroes(res); |
---|
| 3615 | return res; |
---|
[35aab3] | 3616 | } |
---|
[36605f] | 3617 | |
---|
[35aab3] | 3618 | // returns TRUE if mora should use buckets, false otherwise |
---|
| 3619 | static BOOLEAN kMoraUseBucket(kStrategy strat) |
---|
| 3620 | { |
---|
| 3621 | #ifdef MORA_USE_BUCKETS |
---|
| 3622 | if (TEST_OPT_NOT_BUCKETS) |
---|
| 3623 | return FALSE; |
---|
| 3624 | if (strat->red == redFirst) |
---|
| 3625 | { |
---|
| 3626 | #ifdef NO_LDEG |
---|
[b981502] | 3627 | if (strat->syzComp==0) |
---|
[35aab3] | 3628 | return TRUE; |
---|
| 3629 | #else |
---|
[b981502] | 3630 | if ((strat->homog || strat->honey) && (strat->syzComp==0)) |
---|
[35aab3] | 3631 | return TRUE; |
---|
| 3632 | #endif |
---|
| 3633 | } |
---|
| 3634 | else |
---|
| 3635 | { |
---|
[d46f75] | 3636 | #ifdef HAVE_RINGS |
---|
[c25b56c] | 3637 | assume(strat->red == redEcart || strat->red == redRiloc); |
---|
[d46f75] | 3638 | #else |
---|
| 3639 | assume(strat->red == redEcart); |
---|
| 3640 | #endif |
---|
[b981502] | 3641 | if (strat->honey && (strat->syzComp==0)) |
---|
[35aab3] | 3642 | return TRUE; |
---|
| 3643 | } |
---|
| 3644 | #endif |
---|
| 3645 | return FALSE; |
---|
| 3646 | } |
---|