[35aab3] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
| 4 | /* |
---|
| 5 | * ABSTRACT - Kernel: alg. of Buchberger |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | // #define PDEBUG 2 |
---|
[645a19] | 9 | |
---|
[89f4843] | 10 | #include "kernel/mod2.h" |
---|
[645a19] | 11 | |
---|
[459ec94] | 12 | #define GCD_SBA 1 |
---|
[19a089f] | 13 | |
---|
[35aab3] | 14 | // define if no buckets should be used |
---|
| 15 | // #define NO_BUCKETS |
---|
| 16 | |
---|
[cbc616] | 17 | #ifdef HAVE_PLURAL |
---|
| 18 | #define PLURAL_INTERNAL_DECLARATIONS 1 |
---|
| 19 | #endif |
---|
[83be980] | 20 | |
---|
[b3e94aa] | 21 | /*********************************************** |
---|
| 22 | * SBA stuff -- start |
---|
| 23 | ***********************************************/ |
---|
[83be980] | 24 | #define DEBUGF50 0 |
---|
| 25 | #define DEBUGF51 0 |
---|
| 26 | |
---|
| 27 | #ifdef DEBUGF5 |
---|
| 28 | #undef DEBUGF5 |
---|
| 29 | //#define DEBUGF5 1 |
---|
| 30 | #endif |
---|
| 31 | |
---|
[15b211] | 32 | #define F5C 1 |
---|
[83be980] | 33 | #if F5C |
---|
[f9d20d7] | 34 | #define F5CTAILRED 1 |
---|
[83be980] | 35 | #endif |
---|
| 36 | |
---|
[cc6544] | 37 | #define SBA_INTERRED_START 0 |
---|
[f1cef21] | 38 | #define SBA_TAIL_RED 1 |
---|
[f59aaa] | 39 | #define SBA_PRODUCT_CRITERION 0 |
---|
[d5856f] | 40 | #define SBA_PRINT_ZERO_REDUCTIONS 0 |
---|
| 41 | #define SBA_PRINT_REDUCTION_STEPS 0 |
---|
| 42 | #define SBA_PRINT_OPERATIONS 0 |
---|
| 43 | #define SBA_PRINT_SIZE_G 0 |
---|
| 44 | #define SBA_PRINT_SIZE_SYZ 0 |
---|
[f59aaa] | 45 | #define SBA_PRINT_PRODUCT_CRITERION 0 |
---|
[f9d20d7] | 46 | |
---|
[f59aaa] | 47 | // counts sba's reduction steps |
---|
[f7f084] | 48 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[a3f0fea] | 49 | VAR long sba_reduction_steps; |
---|
| 50 | VAR long sba_interreduction_steps; |
---|
[6d77472] | 51 | #endif |
---|
| 52 | #if SBA_PRINT_OPERATIONS |
---|
[a3f0fea] | 53 | VAR long sba_operations; |
---|
| 54 | VAR long sba_interreduction_operations; |
---|
[6d77472] | 55 | #endif |
---|
| 56 | |
---|
[b3e94aa] | 57 | /*********************************************** |
---|
| 58 | * SBA stuff -- done |
---|
| 59 | ***********************************************/ |
---|
| 60 | |
---|
[89f4843] | 61 | #include "kernel/GBEngine/kutil.h" |
---|
| 62 | #include "misc/options.h" |
---|
| 63 | #include "kernel/polys.h" |
---|
| 64 | #include "kernel/ideals.h" |
---|
| 65 | #include "kernel/GBEngine/kstd1.h" |
---|
| 66 | #include "kernel/GBEngine/khstd.h" |
---|
| 67 | #include "polys/kbuckets.h" |
---|
| 68 | #include "polys/prCopy.h" |
---|
| 69 | #include "polys/weight.h" |
---|
| 70 | #include "misc/intvec.h" |
---|
[35aab3] | 71 | #ifdef HAVE_PLURAL |
---|
[89f4843] | 72 | #include "polys/nc/nc.h" |
---|
[35aab3] | 73 | #endif |
---|
| 74 | // #include "timer.h" |
---|
| 75 | |
---|
[4ab28ee] | 76 | #ifdef HAVE_SHIFTBBA |
---|
| 77 | #include "polys/shiftop.h" |
---|
| 78 | #endif |
---|
[cb0fbe] | 79 | |
---|
[a3f0fea] | 80 | VAR int (*test_PosInT)(const TSet T,const int tl,LObject &h); |
---|
| 81 | VAR int (*test_PosInL)(const LSet set, const int length, |
---|
[57fad3a] | 82 | LObject* L,const kStrategy strat); |
---|
| 83 | |
---|
[28ac7f] | 84 | int kFindSameLMInT_Z(const kStrategy strat, const LObject* L, const int start) |
---|
| 85 | { |
---|
| 86 | unsigned long not_sev = ~L->sev; |
---|
| 87 | int j = start; |
---|
| 88 | int o = -1; |
---|
| 89 | |
---|
| 90 | const TSet T=strat->T; |
---|
| 91 | const unsigned long* sevT=strat->sevT; |
---|
[acb37e6] | 92 | number gcd, ogcd; |
---|
[28ac7f] | 93 | if (L->p!=NULL) |
---|
| 94 | { |
---|
| 95 | const ring r=currRing; |
---|
| 96 | const poly p=L->p; |
---|
[acb37e6] | 97 | ogcd = pGetCoeff(p); |
---|
[28ac7f] | 98 | |
---|
| 99 | pAssume(~not_sev == p_GetShortExpVector(p, r)); |
---|
| 100 | |
---|
| 101 | loop |
---|
| 102 | { |
---|
| 103 | if (j > strat->tl) return o; |
---|
| 104 | if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r) && p_LmEqual(T[j].p, p, r)) |
---|
| 105 | { |
---|
[acb37e6] | 106 | gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf); |
---|
| 107 | if (o == -1 || |
---|
| 108 | n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf) == TRUE) { |
---|
| 109 | ogcd = gcd; |
---|
| 110 | o = j; |
---|
[28ac7f] | 111 | } |
---|
| 112 | } |
---|
| 113 | j++; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | const ring r=strat->tailRing; |
---|
[acb37e6] | 119 | const poly p=L->t_p; |
---|
| 120 | ogcd = pGetCoeff(p); |
---|
[28ac7f] | 121 | loop |
---|
| 122 | { |
---|
| 123 | if (j > strat->tl) return o; |
---|
| 124 | if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r) && p_LmEqual(T[j].p, p, r)) |
---|
| 125 | { |
---|
[acb37e6] | 126 | gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf); |
---|
| 127 | if (o == -1 || |
---|
| 128 | n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf) == TRUE) { |
---|
| 129 | ogcd = gcd; |
---|
| 130 | o = j; |
---|
[28ac7f] | 131 | } |
---|
| 132 | } |
---|
| 133 | j++; |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | } |
---|
[486d31] | 137 | // return -1 if no divisor is found |
---|
| 138 | // number of first divisor, otherwise |
---|
[2c1877] | 139 | int kFindDivisibleByInT_Z(const kStrategy strat, const LObject* L, const int start) |
---|
[953f6b] | 140 | { |
---|
| 141 | unsigned long not_sev = ~L->sev; |
---|
| 142 | int j = start; |
---|
[acb37e6] | 143 | int o = -1; |
---|
[953f6b] | 144 | |
---|
| 145 | const TSet T=strat->T; |
---|
| 146 | const unsigned long* sevT=strat->sevT; |
---|
[acb37e6] | 147 | number rest, orest, mult; |
---|
[953f6b] | 148 | if (L->p!=NULL) |
---|
| 149 | { |
---|
| 150 | const ring r=currRing; |
---|
| 151 | const poly p=L->p; |
---|
[acb37e6] | 152 | orest = pGetCoeff(p); |
---|
[953f6b] | 153 | |
---|
| 154 | pAssume(~not_sev == p_GetShortExpVector(p, r)); |
---|
| 155 | |
---|
| 156 | loop |
---|
| 157 | { |
---|
[acb37e6] | 158 | if (j > strat->tl) return o; |
---|
[953f6b] | 159 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 160 | if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r)) |
---|
| 161 | { |
---|
[98f4749] | 162 | mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf); |
---|
[acb37e6] | 163 | if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { |
---|
| 164 | o = j; |
---|
| 165 | orest = rest; |
---|
[1308eb] | 166 | } |
---|
[953f6b] | 167 | } |
---|
| 168 | #else |
---|
[98f4749] | 169 | if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].p, p, r)) |
---|
[953f6b] | 170 | { |
---|
[98f4749] | 171 | mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf); |
---|
[acb37e6] | 172 | if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { |
---|
| 173 | o = j; |
---|
| 174 | orest = rest; |
---|
[1308eb] | 175 | } |
---|
[953f6b] | 176 | } |
---|
| 177 | #endif |
---|
| 178 | j++; |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | else |
---|
| 182 | { |
---|
| 183 | const ring r=strat->tailRing; |
---|
[acb37e6] | 184 | const poly p=L->t_p; |
---|
| 185 | orest = pGetCoeff(p); |
---|
[953f6b] | 186 | loop |
---|
| 187 | { |
---|
[acb37e6] | 188 | if (j > strat->tl) return o; |
---|
[953f6b] | 189 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 190 | if (p_LmShortDivisibleBy(T[j].t_p, sevT[j], |
---|
| 191 | p, not_sev, r)) |
---|
| 192 | { |
---|
[98f4749] | 193 | mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf); |
---|
[acb37e6] | 194 | if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { |
---|
| 195 | o = j; |
---|
| 196 | orest = rest; |
---|
[1308eb] | 197 | } |
---|
[953f6b] | 198 | } |
---|
| 199 | #else |
---|
[98f4749] | 200 | if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].t_p, p, r)) |
---|
[953f6b] | 201 | { |
---|
[98f4749] | 202 | mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf); |
---|
[acb37e6] | 203 | if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { |
---|
| 204 | o = j; |
---|
| 205 | orest = rest; |
---|
[1308eb] | 206 | } |
---|
[953f6b] | 207 | } |
---|
| 208 | #endif |
---|
| 209 | j++; |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | } |
---|
| 213 | |
---|
[35aab3] | 214 | // return -1 if no divisor is found |
---|
| 215 | // number of first divisor, otherwise |
---|
[a576b0] | 216 | int kFindDivisibleByInT(const kStrategy strat, const LObject* L, const int start) |
---|
[35aab3] | 217 | { |
---|
| 218 | unsigned long not_sev = ~L->sev; |
---|
| 219 | int j = start; |
---|
| 220 | |
---|
[a576b0] | 221 | const TSet T=strat->T; |
---|
| 222 | const unsigned long* sevT=strat->sevT; |
---|
[59b9fdb] | 223 | const ring r=currRing; |
---|
| 224 | const BOOLEAN is_Ring=rField_is_Ring(r); |
---|
[a576b0] | 225 | if (L->p!=NULL) |
---|
[35aab3] | 226 | { |
---|
[a576b0] | 227 | const poly p=L->p; |
---|
[e9478b] | 228 | |
---|
[9a871d] | 229 | pAssume(~not_sev == p_GetShortExpVector(p, r)); |
---|
| 230 | |
---|
[59b9fdb] | 231 | if(is_Ring) |
---|
[35aab3] | 232 | { |
---|
[e21795] | 233 | loop |
---|
[e6f1e6] | 234 | { |
---|
[e21795] | 235 | if (j > strat->tl) return -1; |
---|
| 236 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 237 | if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r)) |
---|
[4d5a3e] | 238 | { |
---|
[06abb07] | 239 | if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf)) |
---|
[4d5a3e] | 240 | return j; |
---|
| 241 | } |
---|
[35aab3] | 242 | #else |
---|
[e21795] | 243 | if (!(sevT[j] & not_sev) && |
---|
[35aab3] | 244 | p_LmDivisibleBy(T[j].p, p, r)) |
---|
[4d5a3e] | 245 | { |
---|
[06abb07] | 246 | if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].p), r->cf)) |
---|
[4d5a3e] | 247 | return j; |
---|
| 248 | } |
---|
[35aab3] | 249 | #endif |
---|
[e21795] | 250 | j++; |
---|
[bdebb8] | 251 | } |
---|
[e21795] | 252 | } |
---|
| 253 | else |
---|
| 254 | { |
---|
| 255 | loop |
---|
| 256 | { |
---|
| 257 | if (j > strat->tl) return -1; |
---|
| 258 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 259 | if (p_LmShortDivisibleBy(T[j].p, sevT[j],p, not_sev, r)) |
---|
| 260 | { |
---|
| 261 | return j; |
---|
| 262 | } |
---|
[35aab3] | 263 | #else |
---|
[e21795] | 264 | if (!(sevT[j] & not_sev) && |
---|
[35aab3] | 265 | p_LmDivisibleBy(T[j].p, p, r)) |
---|
[e21795] | 266 | { |
---|
| 267 | return j; |
---|
[4d5a3e] | 268 | } |
---|
[35aab3] | 269 | #endif |
---|
[e21795] | 270 | j++; |
---|
| 271 | } |
---|
[35aab3] | 272 | } |
---|
| 273 | } |
---|
| 274 | else |
---|
| 275 | { |
---|
[a576b0] | 276 | const poly p=L->t_p; |
---|
| 277 | const ring r=strat->tailRing; |
---|
[59b9fdb] | 278 | if(is_Ring) |
---|
[35aab3] | 279 | { |
---|
[e21795] | 280 | loop |
---|
| 281 | { |
---|
| 282 | if (j > strat->tl) return -1; |
---|
[35aab3] | 283 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
[e21795] | 284 | if (p_LmShortDivisibleBy(T[j].t_p, sevT[j], |
---|
[35aab3] | 285 | p, not_sev, r)) |
---|
[4d5a3e] | 286 | { |
---|
[06abb07] | 287 | if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf)) |
---|
[4d5a3e] | 288 | return j; |
---|
| 289 | } |
---|
[35aab3] | 290 | #else |
---|
[e21795] | 291 | if (!(sevT[j] & not_sev) && |
---|
[35aab3] | 292 | p_LmDivisibleBy(T[j].t_p, p, r)) |
---|
[4d5a3e] | 293 | { |
---|
[06abb07] | 294 | if(n_DivBy(pGetCoeff(p), pGetCoeff(T[j].t_p), r->cf)) |
---|
[4d5a3e] | 295 | return j; |
---|
| 296 | } |
---|
[35aab3] | 297 | #endif |
---|
[e21795] | 298 | j++; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | else |
---|
| 302 | { |
---|
| 303 | loop |
---|
| 304 | { |
---|
| 305 | if (j > strat->tl) return -1; |
---|
| 306 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 307 | if (p_LmShortDivisibleBy(T[j].t_p, sevT[j], |
---|
| 308 | p, not_sev, r)) |
---|
| 309 | { |
---|
| 310 | return j; |
---|
| 311 | } |
---|
| 312 | #else |
---|
| 313 | if (!(sevT[j] & not_sev) && |
---|
| 314 | p_LmDivisibleBy(T[j].t_p, p, r)) |
---|
[bdebb8] | 315 | { |
---|
| 316 | return j; |
---|
| 317 | } |
---|
[35aab3] | 318 | #endif |
---|
[e21795] | 319 | j++; |
---|
| 320 | } |
---|
[35aab3] | 321 | } |
---|
| 322 | } |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | // same as above, only with set S |
---|
[391323] | 326 | int kFindDivisibleByInS(const kStrategy strat, int* max_ind, LObject* L) |
---|
[35aab3] | 327 | { |
---|
| 328 | unsigned long not_sev = ~L->sev; |
---|
| 329 | poly p = L->GetLmCurrRing(); |
---|
| 330 | int j = 0; |
---|
| 331 | |
---|
| 332 | pAssume(~not_sev == p_GetShortExpVector(p, currRing)); |
---|
[59b9fdb] | 333 | |
---|
| 334 | BOOLEAN is_Ring=rField_is_Ring(currRing); |
---|
[dd60f3c] | 335 | #if 1 |
---|
| 336 | int ende; |
---|
[59b9fdb] | 337 | if (is_Ring |
---|
| 338 | || (strat->ak>0) |
---|
| 339 | || currRing->pLexOrder) |
---|
| 340 | ende=strat->sl; |
---|
| 341 | else |
---|
| 342 | { |
---|
| 343 | ende=posInS(strat,*max_ind,p,0)+1; |
---|
| 344 | if (ende>(*max_ind)) ende=(*max_ind); |
---|
| 345 | } |
---|
[f41bd9] | 346 | #else |
---|
[e690a91] | 347 | int ende=strat->sl; |
---|
[b2c236] | 348 | #endif |
---|
[59b9fdb] | 349 | if(is_Ring) |
---|
[35aab3] | 350 | { |
---|
[e21795] | 351 | loop |
---|
| 352 | { |
---|
| 353 | if (j > ende) return -1; |
---|
[35aab3] | 354 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
[e21795] | 355 | if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j], |
---|
[35aab3] | 356 | p, not_sev, currRing)) |
---|
[bdebb8] | 357 | { |
---|
[06abb07] | 358 | if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf)) |
---|
[bdebb8] | 359 | return j; |
---|
| 360 | } |
---|
[35aab3] | 361 | #else |
---|
[e21795] | 362 | if ( !(strat->sevS[j] & not_sev) && |
---|
[efb860] | 363 | p_LmDivisibleBy(strat->S[j], p, currRing)) |
---|
[bdebb8] | 364 | { |
---|
[06abb07] | 365 | if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf)) |
---|
[bdebb8] | 366 | return j; |
---|
| 367 | } |
---|
[e21795] | 368 | #endif |
---|
| 369 | j++; |
---|
[bdebb8] | 370 | } |
---|
[e21795] | 371 | } |
---|
| 372 | else |
---|
| 373 | { |
---|
| 374 | loop |
---|
| 375 | { |
---|
| 376 | if (j > ende) return -1; |
---|
| 377 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 378 | if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j], |
---|
| 379 | p, not_sev, currRing)) |
---|
| 380 | { |
---|
| 381 | return j; |
---|
| 382 | } |
---|
| 383 | #else |
---|
| 384 | if ( !(strat->sevS[j] & not_sev) && |
---|
| 385 | p_LmDivisibleBy(strat->S[j], p, currRing)) |
---|
| 386 | { |
---|
| 387 | return j; |
---|
| 388 | } |
---|
[35aab3] | 389 | #endif |
---|
[e21795] | 390 | j++; |
---|
| 391 | } |
---|
[35aab3] | 392 | } |
---|
| 393 | } |
---|
| 394 | |
---|
[7ba059] | 395 | int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L) |
---|
| 396 | { |
---|
| 397 | unsigned long not_sev = ~L->sev; |
---|
| 398 | poly p = L->GetLmCurrRing(); |
---|
| 399 | int j = start; |
---|
| 400 | |
---|
| 401 | pAssume(~not_sev == p_GetShortExpVector(p, currRing)); |
---|
| 402 | #if 1 |
---|
| 403 | int ende=max_ind; |
---|
| 404 | #else |
---|
| 405 | int ende=strat->sl; |
---|
| 406 | #endif |
---|
[e21795] | 407 | if(rField_is_Ring(currRing)) |
---|
[7ba059] | 408 | { |
---|
[e21795] | 409 | loop |
---|
| 410 | { |
---|
| 411 | if (j > ende) return -1; |
---|
[7ba059] | 412 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
[e21795] | 413 | if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j], |
---|
[7ba059] | 414 | p, not_sev, currRing)) |
---|
[bdebb8] | 415 | { |
---|
[06abb07] | 416 | if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf)) |
---|
[bdebb8] | 417 | return j; |
---|
| 418 | } |
---|
[7ba059] | 419 | #else |
---|
[e21795] | 420 | if ( !(strat->sevS[j] & not_sev) && |
---|
[7ba059] | 421 | p_LmDivisibleBy(strat->S[j], p, currRing)) |
---|
[e21795] | 422 | { |
---|
[06abb07] | 423 | if(n_DivBy(pGetCoeff(p), pGetCoeff(strat->S[j]), currRing->cf)) |
---|
[e21795] | 424 | return j; |
---|
| 425 | } |
---|
[7ba059] | 426 | #endif |
---|
[e21795] | 427 | j++; |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | else |
---|
| 431 | { |
---|
| 432 | loop |
---|
| 433 | { |
---|
| 434 | if (j > ende) return -1; |
---|
| 435 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
| 436 | if (p_LmShortDivisibleBy(strat->S[j], strat->sevS[j], |
---|
| 437 | p, not_sev, currRing)) |
---|
| 438 | { |
---|
[bdebb8] | 439 | return j; |
---|
[e21795] | 440 | } |
---|
[7ba059] | 441 | #else |
---|
[e21795] | 442 | if ( !(strat->sevS[j] & not_sev) && |
---|
[7ba059] | 443 | p_LmDivisibleBy(strat->S[j], p, currRing)) |
---|
[e21795] | 444 | { |
---|
| 445 | return j; |
---|
| 446 | } |
---|
[7ba059] | 447 | #endif |
---|
[e21795] | 448 | j++; |
---|
| 449 | } |
---|
[7ba059] | 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
[c90b43] | 453 | #ifdef HAVE_RINGS |
---|
[a09a42] | 454 | poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing) |
---|
| 455 | { |
---|
[cea6f3] | 456 | // m = currRing->ch |
---|
| 457 | |
---|
[a6889e] | 458 | if (input_p == NULL) return NULL; |
---|
| 459 | |
---|
| 460 | poly p = input_p; |
---|
[cea6f3] | 461 | poly zeroPoly = NULL; |
---|
[6a70f3] | 462 | unsigned long a = (unsigned long) pGetCoeff(p); |
---|
[cea6f3] | 463 | |
---|
[fe7f527] | 464 | int k_ind2 = 0; |
---|
| 465 | int a_ind2 = ind2(a); |
---|
[cea6f3] | 466 | |
---|
[6a70f3] | 467 | // unsigned long k = 1; |
---|
[6d09f28] | 468 | // of interest is only k_ind2, special routine for improvement ... TODO OLIVER |
---|
[fe7f527] | 469 | for (int i = 1; i <= leadRing->N; i++) |
---|
[a09a42] | 470 | { |
---|
[fe7f527] | 471 | k_ind2 = k_ind2 + ind_fact_2(p_GetExp(p, i, leadRing)); |
---|
[cea6f3] | 472 | } |
---|
[fe7f527] | 473 | |
---|
[6a70f3] | 474 | a = (unsigned long) pGetCoeff(p); |
---|
[cea6f3] | 475 | |
---|
| 476 | number tmp1; |
---|
| 477 | poly tmp2, tmp3; |
---|
[fe7f527] | 478 | poly lead_mult = p_ISet(1, tailRing); |
---|
[e533660] | 479 | if (n_GetChar(leadRing->cf) <= k_ind2 + a_ind2) |
---|
[a09a42] | 480 | { |
---|
[e533660] | 481 | int too_much = k_ind2 + a_ind2 - n_GetChar(leadRing->cf); |
---|
[fe7f527] | 482 | int s_exp; |
---|
[a6889e] | 483 | zeroPoly = p_ISet(a, tailRing); |
---|
[a09a42] | 484 | for (int i = 1; i <= leadRing->N; i++) |
---|
| 485 | { |
---|
[fe7f527] | 486 | s_exp = p_GetExp(p, i,leadRing); |
---|
[388f91e] | 487 | if (s_exp % 2 != 0) |
---|
[fe7f527] | 488 | { |
---|
| 489 | s_exp = s_exp - 1; |
---|
| 490 | } |
---|
| 491 | while ( (0 < ind2(s_exp)) && (ind2(s_exp) <= too_much) ) |
---|
| 492 | { |
---|
| 493 | too_much = too_much - ind2(s_exp); |
---|
| 494 | s_exp = s_exp - 2; |
---|
| 495 | } |
---|
[388f91e] | 496 | p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing); |
---|
[32ad2a] | 497 | for (int j = 1; j <= s_exp; j++) |
---|
[a09a42] | 498 | { |
---|
[cea6f3] | 499 | tmp1 = nInit(j); |
---|
[a6889e] | 500 | tmp2 = p_ISet(1, tailRing); |
---|
| 501 | p_SetExp(tmp2, i, 1, tailRing); |
---|
| 502 | p_Setm(tmp2, tailRing); |
---|
[a09a42] | 503 | if (nIsZero(tmp1)) |
---|
[fe7f527] | 504 | { // should nowbe obsolet, test ! TODO OLIVER |
---|
[a6889e] | 505 | zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing); |
---|
[cea6f3] | 506 | } |
---|
[a09a42] | 507 | else |
---|
| 508 | { |
---|
[f92547] | 509 | tmp3 = p_NSet(nCopy(tmp1), tailRing); |
---|
[fe7f527] | 510 | zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing); |
---|
[cea6f3] | 511 | } |
---|
| 512 | } |
---|
| 513 | } |
---|
[fe7f527] | 514 | p_Setm(lead_mult, tailRing); |
---|
[388f91e] | 515 | zeroPoly = p_Mult_mm(zeroPoly, lead_mult, tailRing); |
---|
[f92547] | 516 | tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing); |
---|
[977f94] | 517 | for (int i = 1; i <= leadRing->N; i++) |
---|
| 518 | { |
---|
[a725dae] | 519 | pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing)); |
---|
[cea6f3] | 520 | } |
---|
[7f06cca] | 521 | p_Setm(tmp2, leadRing); |
---|
| 522 | zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing); |
---|
[cea6f3] | 523 | pNext(tmp2) = zeroPoly; |
---|
| 524 | return tmp2; |
---|
| 525 | } |
---|
[6a70f3] | 526 | /* unsigned long alpha_k = twoPow(leadRing->ch - k_ind2); |
---|
[977f94] | 527 | if (1 == 0 && alpha_k <= a) |
---|
| 528 | { // Temporarly disabled, reducing coefficients not compatible with std TODO Oliver |
---|
[7f06cca] | 529 | zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing); |
---|
[977f94] | 530 | for (int i = 1; i <= leadRing->N; i++) |
---|
| 531 | { |
---|
[6a70f3] | 532 | for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++) |
---|
[977f94] | 533 | { |
---|
[7f06cca] | 534 | tmp1 = nInit(j); |
---|
| 535 | tmp2 = p_ISet(1, tailRing); |
---|
| 536 | p_SetExp(tmp2, i, 1, tailRing); |
---|
| 537 | p_Setm(tmp2, tailRing); |
---|
[977f94] | 538 | if (nIsZero(tmp1)) |
---|
| 539 | { |
---|
[7f06cca] | 540 | zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing); |
---|
| 541 | } |
---|
[977f94] | 542 | else |
---|
| 543 | { |
---|
[6a70f3] | 544 | tmp3 = p_ISet((unsigned long) tmp1, tailRing); |
---|
[7f06cca] | 545 | zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing); |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | } |
---|
[6a70f3] | 549 | tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing); |
---|
[977f94] | 550 | for (int i = 1; i <= leadRing->N; i++) |
---|
| 551 | { |
---|
[a725dae] | 552 | pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing)); |
---|
[7f06cca] | 553 | } |
---|
| 554 | p_Setm(tmp2, leadRing); |
---|
| 555 | zeroPoly = p_LmDeleteAndNext(zeroPoly, tailRing); |
---|
| 556 | pNext(tmp2) = zeroPoly; |
---|
| 557 | return tmp2; |
---|
[6d09f28] | 558 | } */ |
---|
[cea6f3] | 559 | return NULL; |
---|
| 560 | } |
---|
[206e158] | 561 | #endif |
---|
[a6889e] | 562 | |
---|
[206e158] | 563 | |
---|
| 564 | #ifdef HAVE_RINGS |
---|
[585bbcb] | 565 | /*2 |
---|
| 566 | * reduction procedure for the ring Z/2^m |
---|
| 567 | */ |
---|
[ff4c0c1] | 568 | int redRing_Z (LObject* h,kStrategy strat) |
---|
[953f6b] | 569 | { |
---|
| 570 | if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors) |
---|
| 571 | if (strat->tl<0) return 1; |
---|
| 572 | |
---|
| 573 | int at/*,i*/; |
---|
| 574 | long d; |
---|
| 575 | int j = 0; |
---|
| 576 | int pass = 0; |
---|
| 577 | // poly zeroPoly = NULL; |
---|
| 578 | |
---|
| 579 | // TODO warum SetpFDeg notwendig? |
---|
| 580 | h->SetpFDeg(); |
---|
| 581 | assume(h->pFDeg() == h->FDeg); |
---|
| 582 | long reddeg = h->GetpFDeg(); |
---|
| 583 | |
---|
| 584 | h->SetShortExpVector(); |
---|
| 585 | loop |
---|
| 586 | { |
---|
[a75fc3] | 587 | /* check if a reducer of the lead term exists */ |
---|
[953f6b] | 588 | j = kFindDivisibleByInT(strat, h); |
---|
[bf25df] | 589 | if (j < 0) { |
---|
[a75fc3] | 590 | /* check if a reducer with the same lead monomial exists */ |
---|
| 591 | j = kFindSameLMInT_Z(strat, h); |
---|
| 592 | if (j < 0) { |
---|
| 593 | /* check if a reducer of the lead monomial exists, by the above |
---|
| 594 | * check this is a real divisor of the lead monomial */ |
---|
| 595 | j = kFindDivisibleByInT_Z(strat, h); |
---|
| 596 | if (j < 0) |
---|
[953f6b] | 597 | { |
---|
[a75fc3] | 598 | // over ZZ: cleanup coefficients by complete reduction with monomials |
---|
[b2bceb6] | 599 | if (rHasLocalOrMixedOrdering(currRing)) |
---|
| 600 | postReduceByMon(h, strat); |
---|
[a75fc3] | 601 | if(h->p == NULL) |
---|
[bf25df] | 602 | { |
---|
| 603 | if (h->lcm!=NULL) pLmDelete(h->lcm); |
---|
| 604 | h->Clear(); |
---|
| 605 | return 0; |
---|
| 606 | } |
---|
[a75fc3] | 607 | if(nIsZero(pGetCoeff(h->p))) return 2; |
---|
| 608 | j = kFindDivisibleByInT(strat, h); |
---|
| 609 | if(j < 0) |
---|
| 610 | { |
---|
| 611 | if(strat->tl >= 0) |
---|
| 612 | h->i_r1 = strat->tl; |
---|
| 613 | else |
---|
| 614 | h->i_r1 = -1; |
---|
| 615 | if (h->GetLmTailRing() == NULL) |
---|
| 616 | { |
---|
| 617 | if (h->lcm!=NULL) pLmDelete(h->lcm); |
---|
| 618 | h->Clear(); |
---|
| 619 | return 0; |
---|
| 620 | } |
---|
| 621 | return 1; |
---|
| 622 | } |
---|
| 623 | } else { |
---|
| 624 | /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer)) |
---|
| 625 | * => we try to cut down the lead coefficient at least */ |
---|
| 626 | /* first copy T[j] in order to multiply it with a coefficient later on */ |
---|
| 627 | number mult, rest; |
---|
| 628 | TObject tj = strat->T[j]; |
---|
| 629 | tj.Copy(); |
---|
| 630 | /* tj.max_exp = strat->T[j].max_exp; */ |
---|
| 631 | /* compute division with remainder of lc(h) and lc(T[j]) */ |
---|
[acb37e6] | 632 | mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p), |
---|
| 633 | &rest, currRing->cf); |
---|
[a75fc3] | 634 | /* set corresponding new lead coefficient already. we do not |
---|
| 635 | * remove the lead term in ksReducePolyLC, but only apply |
---|
| 636 | * a lead coefficient reduction */ |
---|
[acb37e6] | 637 | tj.Mult_nn(mult); |
---|
| 638 | ksReducePolyLC(h, &tj, NULL, &rest, strat); |
---|
[a75fc3] | 639 | tj.Delete(); |
---|
| 640 | tj.Clear(); |
---|
[bf25df] | 641 | } |
---|
| 642 | } else { |
---|
[a75fc3] | 643 | /* same lead monomial but lead coefficients do not divide each other: |
---|
| 644 | * change the polys to h <- spoly(h,tj) and h2 <- gpoly(h,tj). */ |
---|
| 645 | LObject h2 = *h; |
---|
| 646 | h2.Copy(); |
---|
| 647 | |
---|
[b2bceb6] | 648 | ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat); |
---|
[a75fc3] | 649 | ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat); |
---|
[b2bceb6] | 650 | if (!rHasLocalOrMixedOrdering(currRing)) { |
---|
[194f799] | 651 | redtailBbaAlsoLC_Z(&h2, j, strat); |
---|
[b2bceb6] | 652 | h2.pCleardenom(); |
---|
| 653 | } |
---|
[a75fc3] | 654 | /* replace h2 for tj in L (already generated pairs with tj), S and T */ |
---|
[ab6ae3] | 655 | replaceInLAndSAndT(h2, j, strat); |
---|
[953f6b] | 656 | } |
---|
| 657 | } else { |
---|
[bf25df] | 658 | ksReducePoly(h, &(strat->T[j]), NULL, NULL, strat); |
---|
[953f6b] | 659 | } |
---|
| 660 | /* printf("\nAfter small red: ");pWrite(h->p); */ |
---|
| 661 | if (h->GetLmTailRing() == NULL) |
---|
| 662 | { |
---|
| 663 | if (h->lcm!=NULL) pLmDelete(h->lcm); |
---|
| 664 | #ifdef KDEBUG |
---|
| 665 | h->lcm=NULL; |
---|
| 666 | #endif |
---|
| 667 | h->Clear(); |
---|
| 668 | return 0; |
---|
| 669 | } |
---|
| 670 | h->SetShortExpVector(); |
---|
| 671 | d = h->SetpFDeg(); |
---|
| 672 | /*- try to reduce the s-polynomial -*/ |
---|
| 673 | pass++; |
---|
| 674 | if (!TEST_OPT_REDTHROUGH && |
---|
| 675 | (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
| 676 | { |
---|
| 677 | h->SetLmCurrRing(); |
---|
| 678 | if (strat->posInLDependsOnLength) |
---|
| 679 | h->SetLength(strat->length_pLength); |
---|
| 680 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 681 | if (at <= strat->Ll) |
---|
| 682 | { |
---|
| 683 | #ifdef KDEBUG |
---|
| 684 | if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at); |
---|
| 685 | #endif |
---|
| 686 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER |
---|
| 687 | h->Clear(); |
---|
| 688 | return -1; |
---|
| 689 | } |
---|
| 690 | } |
---|
| 691 | if (d != reddeg) |
---|
| 692 | { |
---|
| 693 | if (d >= (long)strat->tailRing->bitmask) |
---|
| 694 | { |
---|
| 695 | if (h->pTotalDeg() >= (long)strat->tailRing->bitmask) |
---|
| 696 | { |
---|
| 697 | strat->overflow=TRUE; |
---|
| 698 | //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask); |
---|
| 699 | h->GetP(); |
---|
| 700 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 701 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 702 | h->Clear(); |
---|
| 703 | return -1; |
---|
| 704 | } |
---|
| 705 | } |
---|
| 706 | else if ((TEST_OPT_PROT) && (strat->Ll < 0)) |
---|
| 707 | { |
---|
| 708 | Print(".%ld",d);mflush(); |
---|
| 709 | reddeg = d; |
---|
| 710 | } |
---|
| 711 | } |
---|
| 712 | } |
---|
| 713 | } |
---|
| 714 | |
---|
[093f30e] | 715 | int redRing (LObject* h,kStrategy strat) |
---|
[585bbcb] | 716 | { |
---|
[8d679fd] | 717 | if (h->IsNull()) return 0; // spoly is zero (can only occure with zero divisors) |
---|
| 718 | if (strat->tl<0) return 1; |
---|
[cea6f3] | 719 | |
---|
[6909cfb] | 720 | int at/*,i*/; |
---|
[d5564f8] | 721 | long d; |
---|
[585bbcb] | 722 | int j = 0; |
---|
| 723 | int pass = 0; |
---|
[6909cfb] | 724 | // poly zeroPoly = NULL; |
---|
[cea6f3] | 725 | |
---|
[388f91e] | 726 | // TODO warum SetpFDeg notwendig? |
---|
[cea6f3] | 727 | h->SetpFDeg(); |
---|
| 728 | assume(h->pFDeg() == h->FDeg); |
---|
[388f91e] | 729 | long reddeg = h->GetpFDeg(); |
---|
[585bbcb] | 730 | |
---|
[fe7f527] | 731 | h->SetShortExpVector(); |
---|
[585bbcb] | 732 | loop |
---|
| 733 | { |
---|
[a576b0] | 734 | j = kFindDivisibleByInT(strat, h); |
---|
[fc58b5b] | 735 | if (j < 0) |
---|
[22d119e] | 736 | { |
---|
[fc58b5b] | 737 | // over ZZ: cleanup coefficients by complete reduction with monomials |
---|
| 738 | postReduceByMon(h, strat); |
---|
[0091f5] | 739 | if(h->p == NULL) |
---|
| 740 | { |
---|
[3e5610] | 741 | kDeleteLcm(h); |
---|
[0091f5] | 742 | h->Clear(); |
---|
| 743 | return 0; |
---|
| 744 | } |
---|
[fc58b5b] | 745 | if(nIsZero(pGetCoeff(h->p))) return 2; |
---|
| 746 | j = kFindDivisibleByInT(strat, h); |
---|
| 747 | if(j < 0) |
---|
| 748 | { |
---|
| 749 | if(strat->tl >= 0) |
---|
| 750 | h->i_r1 = strat->tl; |
---|
| 751 | else |
---|
| 752 | h->i_r1 = -1; |
---|
| 753 | if (h->GetLmTailRing() == NULL) |
---|
[22d119e] | 754 | { |
---|
[3e5610] | 755 | kDeleteLcm(h); |
---|
[fc58b5b] | 756 | h->Clear(); |
---|
| 757 | return 0; |
---|
[22d119e] | 758 | } |
---|
[fc58b5b] | 759 | return 1; |
---|
| 760 | } |
---|
[22d119e] | 761 | } |
---|
[459ec94] | 762 | //printf("\nFound one: ");pWrite(strat->T[j].p); |
---|
[7a38e1] | 763 | //enterT(*h, strat); |
---|
[94ebce] | 764 | ksReducePoly(h, &(strat->T[j]), NULL, NULL, strat); // with debug output |
---|
[459ec94] | 765 | //printf("\nAfter small red: ");pWrite(h->p); |
---|
[585bbcb] | 766 | if (h->GetLmTailRing() == NULL) |
---|
| 767 | { |
---|
[3e5610] | 768 | kDeleteLcm(h); |
---|
[8d679fd] | 769 | h->Clear(); |
---|
[585bbcb] | 770 | return 0; |
---|
| 771 | } |
---|
| 772 | h->SetShortExpVector(); |
---|
| 773 | d = h->SetpFDeg(); |
---|
| 774 | /*- try to reduce the s-polynomial -*/ |
---|
| 775 | pass++; |
---|
[228b631] | 776 | if (!TEST_OPT_REDTHROUGH && |
---|
[585bbcb] | 777 | (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
| 778 | { |
---|
| 779 | h->SetLmCurrRing(); |
---|
[8d679fd] | 780 | if (strat->posInLDependsOnLength) |
---|
| 781 | h->SetLength(strat->length_pLength); |
---|
[585bbcb] | 782 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 783 | if (at <= strat->Ll) |
---|
| 784 | { |
---|
| 785 | #ifdef KDEBUG |
---|
| 786 | if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at); |
---|
| 787 | #endif |
---|
[cea6f3] | 788 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); // NOT RING CHECKED OLIVER |
---|
[585bbcb] | 789 | h->Clear(); |
---|
| 790 | return -1; |
---|
| 791 | } |
---|
| 792 | } |
---|
[8d679fd] | 793 | if (d != reddeg) |
---|
[585bbcb] | 794 | { |
---|
[32ad2a] | 795 | if (d >= (long)strat->tailRing->bitmask) |
---|
[f7feb7] | 796 | { |
---|
[32ad2a] | 797 | if (h->pTotalDeg() >= (long)strat->tailRing->bitmask) |
---|
[8d679fd] | 798 | { |
---|
| 799 | strat->overflow=TRUE; |
---|
[d5564f8] | 800 | //Print("OVERFLOW in redRing d=%ld, max=%ld\n",d,strat->tailRing->bitmask); |
---|
[8d679fd] | 801 | h->GetP(); |
---|
| 802 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 803 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 804 | h->Clear(); |
---|
[d5564f8] | 805 | return -1; |
---|
| 806 | } |
---|
[f7feb7] | 807 | } |
---|
| 808 | else if ((TEST_OPT_PROT) && (strat->Ll < 0)) |
---|
| 809 | { |
---|
[dd8a7d] | 810 | Print(".%ld",d);mflush(); |
---|
[f7feb7] | 811 | reddeg = d; |
---|
| 812 | } |
---|
[585bbcb] | 813 | } |
---|
| 814 | } |
---|
| 815 | } |
---|
| 816 | #endif |
---|
| 817 | |
---|
[35aab3] | 818 | /*2 |
---|
| 819 | * reduction procedure for the homogeneous case |
---|
| 820 | * and the case of a degree-ordering |
---|
| 821 | */ |
---|
| 822 | int redHomog (LObject* h,kStrategy strat) |
---|
| 823 | { |
---|
[bdde4f4] | 824 | if (strat->tl<0) return 1; |
---|
| 825 | //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED! |
---|
| 826 | assume(h->FDeg == h->pFDeg()); |
---|
| 827 | |
---|
| 828 | poly h_p; |
---|
[225d94] | 829 | int i,j,at,pass, ii; |
---|
[bdde4f4] | 830 | unsigned long not_sev; |
---|
[cd4f24] | 831 | // long reddeg,d; |
---|
[bdde4f4] | 832 | |
---|
| 833 | pass = j = 0; |
---|
[cd4f24] | 834 | // d = reddeg = h->GetpFDeg(); |
---|
[bdde4f4] | 835 | h->SetShortExpVector(); |
---|
| 836 | int li; |
---|
| 837 | h_p = h->GetLmTailRing(); |
---|
| 838 | not_sev = ~ h->sev; |
---|
[35aab3] | 839 | loop |
---|
| 840 | { |
---|
[a576b0] | 841 | j = kFindDivisibleByInT(strat, h); |
---|
[bdde4f4] | 842 | if (j < 0) return 1; |
---|
| 843 | |
---|
| 844 | li = strat->T[j].pLength; |
---|
[eafad1b] | 845 | if (li<=0) li=strat->T[j].GetpLength(); |
---|
[bdde4f4] | 846 | ii = j; |
---|
| 847 | /* |
---|
| 848 | * the polynomial to reduce with (up to the moment) is; |
---|
| 849 | * pi with length li |
---|
| 850 | */ |
---|
| 851 | i = j; |
---|
| 852 | #if 1 |
---|
[8c36a9] | 853 | if (TEST_OPT_LENGTH) |
---|
[bdde4f4] | 854 | loop |
---|
[35aab3] | 855 | { |
---|
[bdde4f4] | 856 | /*- search the shortest possible with respect to length -*/ |
---|
| 857 | i++; |
---|
| 858 | if (i > strat->tl) |
---|
| 859 | break; |
---|
[eafad1b] | 860 | if (li==1) |
---|
[bdde4f4] | 861 | break; |
---|
| 862 | if ((strat->T[i].pLength < li) |
---|
| 863 | && |
---|
| 864 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], |
---|
| 865 | h_p, not_sev, strat->tailRing)) |
---|
| 866 | { |
---|
| 867 | /* |
---|
| 868 | * the polynomial to reduce with is now; |
---|
| 869 | */ |
---|
| 870 | li = strat->T[i].pLength; |
---|
[eafad1b] | 871 | if (li<=0) li=strat->T[i].GetpLength(); |
---|
[bdde4f4] | 872 | ii = i; |
---|
| 873 | } |
---|
[35aab3] | 874 | } |
---|
[bdde4f4] | 875 | #endif |
---|
[35aab3] | 876 | |
---|
[bdde4f4] | 877 | /* |
---|
| 878 | * end of search: have to reduce with pi |
---|
| 879 | */ |
---|
| 880 | #ifdef KDEBUG |
---|
| 881 | if (TEST_OPT_DEBUG) |
---|
| 882 | { |
---|
| 883 | PrintS("red:"); |
---|
| 884 | h->wrp(); |
---|
| 885 | PrintS(" with "); |
---|
| 886 | strat->T[ii].wrp(); |
---|
| 887 | } |
---|
| 888 | #endif |
---|
| 889 | assume(strat->fromT == FALSE); |
---|
| 890 | |
---|
| 891 | ksReducePoly(h, &(strat->T[ii]), NULL, NULL, strat); |
---|
[6d77472] | 892 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 893 | sba_interreduction_steps++; |
---|
| 894 | #endif |
---|
[8fcfae] | 895 | #if SBA_PRINT_OPERATIONS |
---|
[f59aaa] | 896 | sba_interreduction_operations += pLength(strat->T[ii].p); |
---|
| 897 | #endif |
---|
[35aab3] | 898 | |
---|
| 899 | #ifdef KDEBUG |
---|
| 900 | if (TEST_OPT_DEBUG) |
---|
| 901 | { |
---|
[bdde4f4] | 902 | PrintS("\nto "); |
---|
[35aab3] | 903 | h->wrp(); |
---|
| 904 | PrintLn(); |
---|
| 905 | } |
---|
| 906 | #endif |
---|
[bdde4f4] | 907 | |
---|
| 908 | h_p = h->GetLmTailRing(); |
---|
| 909 | if (h_p == NULL) |
---|
[35aab3] | 910 | { |
---|
[3e5610] | 911 | kDeleteLcm(h); |
---|
[35aab3] | 912 | return 0; |
---|
| 913 | } |
---|
[bdde4f4] | 914 | h->SetShortExpVector(); |
---|
| 915 | not_sev = ~ h->sev; |
---|
| 916 | /* |
---|
| 917 | * try to reduce the s-polynomial h |
---|
| 918 | *test first whether h should go to the lazyset L |
---|
| 919 | *-if the degree jumps |
---|
| 920 | *-if the number of pre-defined reductions jumps |
---|
| 921 | */ |
---|
| 922 | pass++; |
---|
[228b631] | 923 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass)) |
---|
[0188fa] | 924 | { |
---|
| 925 | h->SetLmCurrRing(); |
---|
[bdde4f4] | 926 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
[0188fa] | 927 | if (at <= strat->Ll) |
---|
| 928 | { |
---|
[bdde4f4] | 929 | int dummy=strat->sl; |
---|
| 930 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
| 931 | return 1; |
---|
| 932 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
[0188fa] | 933 | #ifdef KDEBUG |
---|
[bdde4f4] | 934 | if (TEST_OPT_DEBUG) |
---|
| 935 | Print(" lazy: -> L%d\n",at); |
---|
[0188fa] | 936 | #endif |
---|
| 937 | h->Clear(); |
---|
| 938 | return -1; |
---|
| 939 | } |
---|
| 940 | } |
---|
[35aab3] | 941 | } |
---|
| 942 | } |
---|
| 943 | |
---|
[094031] | 944 | KINLINE int ksReducePolyTailSig(LObject* PR, TObject* PW, LObject* Red, kStrategy strat) |
---|
[fbc7cb] | 945 | { |
---|
| 946 | BOOLEAN ret; |
---|
| 947 | number coef; |
---|
| 948 | assume(PR->GetLmCurrRing() != PW->GetLmCurrRing()); |
---|
[459ec94] | 949 | if(!rField_is_Ring(currRing)) |
---|
| 950 | Red->HeadNormalize(); |
---|
[fbc7cb] | 951 | /* |
---|
| 952 | printf("------------------------\n"); |
---|
| 953 | pWrite(Red->GetLmCurrRing()); |
---|
| 954 | */ |
---|
[e40da9f] | 955 | if(rField_is_Ring(currRing)) |
---|
| 956 | ret = ksReducePolySigRing(Red, PW, 1, NULL, &coef, strat); |
---|
| 957 | else |
---|
| 958 | ret = ksReducePolySig(Red, PW, 1, NULL, &coef, strat); |
---|
[fbc7cb] | 959 | if (!ret) |
---|
| 960 | { |
---|
[459ec94] | 961 | if (! n_IsOne(coef, currRing->cf) && !rField_is_Ring(currRing)) |
---|
[fbc7cb] | 962 | { |
---|
| 963 | PR->Mult_nn(coef); |
---|
| 964 | // HANNES: mark for Normalize |
---|
| 965 | } |
---|
| 966 | n_Delete(&coef, currRing->cf); |
---|
| 967 | } |
---|
| 968 | return ret; |
---|
| 969 | } |
---|
| 970 | |
---|
[83be980] | 971 | /*2 |
---|
| 972 | * reduction procedure for signature-based standard |
---|
| 973 | * basis algorithms: |
---|
| 974 | * all reductions have to be sig-safe! |
---|
| 975 | * |
---|
| 976 | * 2 is returned if and only if the pair is rejected by the rewritten criterion |
---|
| 977 | * at exactly this point of the computations. This is the last possible point |
---|
| 978 | * such a check can be done => checks with the biggest set of available |
---|
| 979 | * signatures |
---|
| 980 | */ |
---|
[e40da9f] | 981 | |
---|
[83be980] | 982 | int redSig (LObject* h,kStrategy strat) |
---|
[e40da9f] | 983 | { |
---|
| 984 | if (strat->tl<0) return 1; |
---|
| 985 | //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED! |
---|
| 986 | //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg()); |
---|
| 987 | assume(h->FDeg == h->pFDeg()); |
---|
| 988 | //#if 1 |
---|
| 989 | #ifdef DEBUGF5 |
---|
[f9b0bd] | 990 | PrintS("------- IN REDSIG -------\n"); |
---|
[e40da9f] | 991 | Print("p: "); |
---|
| 992 | pWrite(pHead(h->p)); |
---|
[f9b0bd] | 993 | PrintS("p1: "); |
---|
[e40da9f] | 994 | pWrite(pHead(h->p1)); |
---|
[f9b0bd] | 995 | PrintS("p2: "); |
---|
[e40da9f] | 996 | pWrite(pHead(h->p2)); |
---|
[f9b0bd] | 997 | PrintS("---------------------------\n"); |
---|
[e40da9f] | 998 | #endif |
---|
| 999 | poly h_p; |
---|
| 1000 | int i,j,at,pass, ii; |
---|
| 1001 | int start=0; |
---|
| 1002 | int sigSafe; |
---|
| 1003 | unsigned long not_sev; |
---|
| 1004 | // long reddeg,d; |
---|
| 1005 | |
---|
| 1006 | pass = j = 0; |
---|
| 1007 | // d = reddeg = h->GetpFDeg(); |
---|
| 1008 | h->SetShortExpVector(); |
---|
| 1009 | int li; |
---|
| 1010 | h_p = h->GetLmTailRing(); |
---|
| 1011 | not_sev = ~ h->sev; |
---|
| 1012 | loop |
---|
| 1013 | { |
---|
| 1014 | j = kFindDivisibleByInT(strat, h, start); |
---|
| 1015 | if (j < 0) |
---|
| 1016 | { |
---|
| 1017 | return 1; |
---|
| 1018 | } |
---|
| 1019 | |
---|
| 1020 | li = strat->T[j].pLength; |
---|
[eafad1b] | 1021 | if (li<=0) li=strat->T[j].GetpLength(); |
---|
[e40da9f] | 1022 | ii = j; |
---|
| 1023 | /* |
---|
| 1024 | * the polynomial to reduce with (up to the moment) is; |
---|
| 1025 | * pi with length li |
---|
| 1026 | */ |
---|
| 1027 | i = j; |
---|
| 1028 | #if 1 |
---|
| 1029 | if (TEST_OPT_LENGTH) |
---|
| 1030 | loop |
---|
| 1031 | { |
---|
| 1032 | /*- search the shortest possible with respect to length -*/ |
---|
| 1033 | i++; |
---|
| 1034 | if (i > strat->tl) |
---|
| 1035 | break; |
---|
[eafad1b] | 1036 | if (li==1) |
---|
[e40da9f] | 1037 | break; |
---|
| 1038 | if ((strat->T[i].pLength < li) |
---|
| 1039 | && |
---|
| 1040 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], |
---|
| 1041 | h_p, not_sev, strat->tailRing)) |
---|
| 1042 | { |
---|
| 1043 | /* |
---|
| 1044 | * the polynomial to reduce with is now; |
---|
| 1045 | */ |
---|
| 1046 | li = strat->T[i].pLength; |
---|
[eafad1b] | 1047 | if (li<=0) li=strat->T[i].GetpLength(); |
---|
[e40da9f] | 1048 | ii = i; |
---|
| 1049 | } |
---|
| 1050 | } |
---|
| 1051 | start = ii+1; |
---|
| 1052 | #endif |
---|
| 1053 | |
---|
| 1054 | /* |
---|
| 1055 | * end of search: have to reduce with pi |
---|
| 1056 | */ |
---|
| 1057 | #ifdef KDEBUG |
---|
| 1058 | if (TEST_OPT_DEBUG) |
---|
| 1059 | { |
---|
| 1060 | PrintS("red:"); |
---|
| 1061 | h->wrp(); |
---|
| 1062 | PrintS(" with "); |
---|
| 1063 | strat->T[ii].wrp(); |
---|
| 1064 | } |
---|
| 1065 | #endif |
---|
| 1066 | assume(strat->fromT == FALSE); |
---|
| 1067 | //#if 1 |
---|
| 1068 | #ifdef DEBUGF5 |
---|
| 1069 | Print("BEFORE REDUCTION WITH %d:\n",ii); |
---|
[f9b0bd] | 1070 | PrintS("--------------------------------\n"); |
---|
[e40da9f] | 1071 | pWrite(h->sig); |
---|
| 1072 | pWrite(strat->T[ii].sig); |
---|
| 1073 | pWrite(h->GetLmCurrRing()); |
---|
| 1074 | pWrite(pHead(h->p1)); |
---|
| 1075 | pWrite(pHead(h->p2)); |
---|
| 1076 | pWrite(pHead(strat->T[ii].p)); |
---|
[f9b0bd] | 1077 | PrintS("--------------------------------\n"); |
---|
[e40da9f] | 1078 | printf("INDEX OF REDUCER T: %d\n",ii); |
---|
| 1079 | #endif |
---|
| 1080 | sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat); |
---|
| 1081 | #if SBA_PRINT_REDUCTION_STEPS |
---|
| 1082 | if (sigSafe != 3) |
---|
| 1083 | sba_reduction_steps++; |
---|
| 1084 | #endif |
---|
| 1085 | #if SBA_PRINT_OPERATIONS |
---|
| 1086 | if (sigSafe != 3) |
---|
| 1087 | sba_operations += pLength(strat->T[ii].p); |
---|
| 1088 | #endif |
---|
| 1089 | // if reduction has taken place, i.e. the reduction was sig-safe |
---|
| 1090 | // otherwise start is already at the next position and the loop |
---|
| 1091 | // searching reducers in T goes on from index start |
---|
| 1092 | //#if 1 |
---|
| 1093 | #ifdef DEBUGF5 |
---|
| 1094 | Print("SigSAFE: %d\n",sigSafe); |
---|
| 1095 | #endif |
---|
| 1096 | if (sigSafe != 3) |
---|
| 1097 | { |
---|
| 1098 | // start the next search for reducers in T from the beginning |
---|
| 1099 | start = 0; |
---|
| 1100 | #ifdef KDEBUG |
---|
| 1101 | if (TEST_OPT_DEBUG) |
---|
| 1102 | { |
---|
| 1103 | PrintS("\nto "); |
---|
| 1104 | h->wrp(); |
---|
| 1105 | PrintLn(); |
---|
| 1106 | } |
---|
| 1107 | #endif |
---|
| 1108 | |
---|
| 1109 | h_p = h->GetLmTailRing(); |
---|
| 1110 | if (h_p == NULL) |
---|
| 1111 | { |
---|
[3e5610] | 1112 | kDeleteLcm(h); |
---|
[e40da9f] | 1113 | return 0; |
---|
| 1114 | } |
---|
| 1115 | h->SetShortExpVector(); |
---|
| 1116 | not_sev = ~ h->sev; |
---|
| 1117 | /* |
---|
| 1118 | * try to reduce the s-polynomial h |
---|
| 1119 | *test first whether h should go to the lazyset L |
---|
| 1120 | *-if the degree jumps |
---|
| 1121 | *-if the number of pre-defined reductions jumps |
---|
| 1122 | */ |
---|
| 1123 | pass++; |
---|
| 1124 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass)) |
---|
| 1125 | { |
---|
| 1126 | h->SetLmCurrRing(); |
---|
| 1127 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 1128 | if (at <= strat->Ll) |
---|
| 1129 | { |
---|
| 1130 | int dummy=strat->sl; |
---|
| 1131 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
| 1132 | { |
---|
| 1133 | return 1; |
---|
| 1134 | } |
---|
| 1135 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1136 | #ifdef KDEBUG |
---|
| 1137 | if (TEST_OPT_DEBUG) |
---|
| 1138 | Print(" lazy: -> L%d\n",at); |
---|
| 1139 | #endif |
---|
| 1140 | h->Clear(); |
---|
| 1141 | return -1; |
---|
| 1142 | } |
---|
| 1143 | } |
---|
| 1144 | } |
---|
| 1145 | } |
---|
| 1146 | } |
---|
| 1147 | |
---|
| 1148 | |
---|
| 1149 | int redSigRing (LObject* h,kStrategy strat) |
---|
[83be980] | 1150 | { |
---|
[459ec94] | 1151 | //Since reduce is really bad for SBA we use the following idea: |
---|
| 1152 | // We first check if we can build a gcd pair between h and S |
---|
| 1153 | //where the sig remains the same and replace h by this gcd poly |
---|
[e40da9f] | 1154 | assume(rField_is_Ring(currRing)); |
---|
[459ec94] | 1155 | #if GCD_SBA |
---|
[780c1b] | 1156 | while(sbaCheckGcdPair(h,strat)) |
---|
[459ec94] | 1157 | { |
---|
| 1158 | h->sev = pGetShortExpVector(h->p); |
---|
| 1159 | } |
---|
| 1160 | #endif |
---|
[094031] | 1161 | poly beforeredsig; |
---|
[e40da9f] | 1162 | beforeredsig = pCopy(h->sig); |
---|
[780c1b] | 1163 | |
---|
[83be980] | 1164 | if (strat->tl<0) return 1; |
---|
| 1165 | //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED! |
---|
| 1166 | //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg()); |
---|
| 1167 | assume(h->FDeg == h->pFDeg()); |
---|
| 1168 | //#if 1 |
---|
| 1169 | #ifdef DEBUGF5 |
---|
| 1170 | Print("------- IN REDSIG -------\n"); |
---|
| 1171 | Print("p: "); |
---|
| 1172 | pWrite(pHead(h->p)); |
---|
| 1173 | Print("p1: "); |
---|
| 1174 | pWrite(pHead(h->p1)); |
---|
| 1175 | Print("p2: "); |
---|
| 1176 | pWrite(pHead(h->p2)); |
---|
| 1177 | Print("---------------------------\n"); |
---|
| 1178 | #endif |
---|
| 1179 | poly h_p; |
---|
| 1180 | int i,j,at,pass, ii; |
---|
| 1181 | int start=0; |
---|
| 1182 | int sigSafe; |
---|
| 1183 | unsigned long not_sev; |
---|
[cd4f24] | 1184 | // long reddeg,d; |
---|
[83be980] | 1185 | |
---|
| 1186 | pass = j = 0; |
---|
[cd4f24] | 1187 | // d = reddeg = h->GetpFDeg(); |
---|
[83be980] | 1188 | h->SetShortExpVector(); |
---|
| 1189 | int li; |
---|
| 1190 | h_p = h->GetLmTailRing(); |
---|
| 1191 | not_sev = ~ h->sev; |
---|
| 1192 | loop |
---|
| 1193 | { |
---|
[a576b0] | 1194 | j = kFindDivisibleByInT(strat, h, start); |
---|
[83be980] | 1195 | if (j < 0) |
---|
| 1196 | { |
---|
[459ec94] | 1197 | #if GCD_SBA |
---|
[780c1b] | 1198 | while(sbaCheckGcdPair(h,strat)) |
---|
[459ec94] | 1199 | { |
---|
| 1200 | h->sev = pGetShortExpVector(h->p); |
---|
| 1201 | h->is_redundant = FALSE; |
---|
| 1202 | start = 0; |
---|
| 1203 | } |
---|
| 1204 | #endif |
---|
[978a8c] | 1205 | // over ZZ: cleanup coefficients by complete reduction with monomials |
---|
| 1206 | postReduceByMonSig(h, strat); |
---|
[2268ed] | 1207 | if(h->p == NULL || nIsZero(pGetCoeff(h->p))) return 2; |
---|
[978a8c] | 1208 | j = kFindDivisibleByInT(strat, h,start); |
---|
| 1209 | if(j < 0) |
---|
[094031] | 1210 | { |
---|
[978a8c] | 1211 | if(strat->tl >= 0) |
---|
| 1212 | h->i_r1 = strat->tl; |
---|
| 1213 | else |
---|
| 1214 | h->i_r1 = -1; |
---|
| 1215 | if (h->GetLmTailRing() == NULL) |
---|
[094031] | 1216 | { |
---|
[3e5610] | 1217 | kDeleteLcm(h); |
---|
[978a8c] | 1218 | h->Clear(); |
---|
| 1219 | return 0; |
---|
| 1220 | } |
---|
[e40da9f] | 1221 | //Check for sigdrop after reduction |
---|
| 1222 | if(pLtCmp(beforeredsig,h->sig) == 1) |
---|
[978a8c] | 1223 | { |
---|
[e40da9f] | 1224 | strat->sigdrop = TRUE; |
---|
| 1225 | //Reduce it as much as you can |
---|
| 1226 | int red_result = redRing(h,strat); |
---|
| 1227 | if(red_result == 0) |
---|
[094031] | 1228 | { |
---|
[e40da9f] | 1229 | //It reduced to 0, cancel the sigdrop |
---|
| 1230 | strat->sigdrop = FALSE; |
---|
| 1231 | p_Delete(&h->sig,currRing);h->sig = NULL; |
---|
| 1232 | return 0; |
---|
| 1233 | } |
---|
| 1234 | else |
---|
| 1235 | { |
---|
| 1236 | //strat->enterS(*h, strat->sl+1, strat, strat->tl); |
---|
| 1237 | return 0; |
---|
[094031] | 1238 | } |
---|
| 1239 | } |
---|
[e40da9f] | 1240 | p_Delete(&beforeredsig,currRing); |
---|
[978a8c] | 1241 | return 1; |
---|
[094031] | 1242 | } |
---|
[83be980] | 1243 | } |
---|
| 1244 | |
---|
| 1245 | li = strat->T[j].pLength; |
---|
[eafad1b] | 1246 | if (li<=0) li=strat->T[j].GetpLength(); |
---|
[83be980] | 1247 | ii = j; |
---|
| 1248 | /* |
---|
| 1249 | * the polynomial to reduce with (up to the moment) is; |
---|
| 1250 | * pi with length li |
---|
| 1251 | */ |
---|
| 1252 | i = j; |
---|
| 1253 | if (TEST_OPT_LENGTH) |
---|
[e40da9f] | 1254 | loop |
---|
[459ec94] | 1255 | { |
---|
[e40da9f] | 1256 | /*- search the shortest possible with respect to length -*/ |
---|
| 1257 | i++; |
---|
| 1258 | if (i > strat->tl) |
---|
| 1259 | break; |
---|
[eafad1b] | 1260 | if (li==1) |
---|
[e40da9f] | 1261 | break; |
---|
| 1262 | if ((strat->T[i].pLength < li) |
---|
| 1263 | && n_DivBy(pGetCoeff(h_p),pGetCoeff(strat->T[i].p),currRing->cf) |
---|
| 1264 | && p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], |
---|
| 1265 | h_p, not_sev, strat->tailRing)) |
---|
[459ec94] | 1266 | { |
---|
[e40da9f] | 1267 | /* |
---|
| 1268 | * the polynomial to reduce with is now; |
---|
| 1269 | */ |
---|
| 1270 | li = strat->T[i].pLength; |
---|
[eafad1b] | 1271 | if (li<=0) li=strat->T[i].GetpLength(); |
---|
[e40da9f] | 1272 | ii = i; |
---|
[83be980] | 1273 | } |
---|
| 1274 | } |
---|
[780c1b] | 1275 | |
---|
[83be980] | 1276 | start = ii+1; |
---|
| 1277 | |
---|
| 1278 | /* |
---|
| 1279 | * end of search: have to reduce with pi |
---|
| 1280 | */ |
---|
| 1281 | #ifdef KDEBUG |
---|
| 1282 | if (TEST_OPT_DEBUG) |
---|
| 1283 | { |
---|
| 1284 | PrintS("red:"); |
---|
| 1285 | h->wrp(); |
---|
| 1286 | PrintS(" with "); |
---|
| 1287 | strat->T[ii].wrp(); |
---|
| 1288 | } |
---|
| 1289 | #endif |
---|
| 1290 | assume(strat->fromT == FALSE); |
---|
| 1291 | //#if 1 |
---|
| 1292 | #ifdef DEBUGF5 |
---|
| 1293 | Print("BEFORE REDUCTION WITH %d:\n",ii); |
---|
| 1294 | Print("--------------------------------\n"); |
---|
| 1295 | pWrite(h->sig); |
---|
| 1296 | pWrite(strat->T[ii].sig); |
---|
| 1297 | pWrite(h->GetLmCurrRing()); |
---|
| 1298 | pWrite(pHead(h->p1)); |
---|
| 1299 | pWrite(pHead(h->p2)); |
---|
| 1300 | pWrite(pHead(strat->T[ii].p)); |
---|
| 1301 | Print("--------------------------------\n"); |
---|
| 1302 | printf("INDEX OF REDUCER T: %d\n",ii); |
---|
| 1303 | #endif |
---|
[e40da9f] | 1304 | sigSafe = ksReducePolySigRing(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat); |
---|
| 1305 | if(h->p == NULL && h->sig == NULL) |
---|
[094031] | 1306 | { |
---|
| 1307 | //Trivial case catch |
---|
| 1308 | strat->sigdrop = FALSE; |
---|
| 1309 | } |
---|
[7d2b89] | 1310 | #if 0 |
---|
[459ec94] | 1311 | //If the reducer has the same lt (+ or -) as the other one, reduce it via redRing |
---|
[7d2b89] | 1312 | //In some cases this proves to be very bad |
---|
[459ec94] | 1313 | if(rField_is_Ring(currRing) && h->p != NULL && pLmCmp(h->p,strat->T[ii].p)==0) |
---|
[094031] | 1314 | { |
---|
[459ec94] | 1315 | int red_result = redRing(h,strat); |
---|
| 1316 | if(red_result == 0) |
---|
| 1317 | { |
---|
| 1318 | pDelete(&h->sig);h->sig = NULL; |
---|
| 1319 | return 0; |
---|
| 1320 | } |
---|
| 1321 | else |
---|
| 1322 | { |
---|
| 1323 | strat->sigdrop = TRUE; |
---|
| 1324 | return 1; |
---|
| 1325 | } |
---|
[094031] | 1326 | } |
---|
[7d2b89] | 1327 | #endif |
---|
| 1328 | if(strat->sigdrop) |
---|
| 1329 | return 1; |
---|
[f9d20d7] | 1330 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[15b211] | 1331 | if (sigSafe != 3) |
---|
| 1332 | sba_reduction_steps++; |
---|
| 1333 | #endif |
---|
| 1334 | #if SBA_PRINT_OPERATIONS |
---|
| 1335 | if (sigSafe != 3) |
---|
| 1336 | sba_operations += pLength(strat->T[ii].p); |
---|
[f9d20d7] | 1337 | #endif |
---|
[83be980] | 1338 | // if reduction has taken place, i.e. the reduction was sig-safe |
---|
| 1339 | // otherwise start is already at the next position and the loop |
---|
| 1340 | // searching reducers in T goes on from index start |
---|
| 1341 | //#if 1 |
---|
| 1342 | #ifdef DEBUGF5 |
---|
| 1343 | Print("SigSAFE: %d\n",sigSafe); |
---|
| 1344 | #endif |
---|
| 1345 | if (sigSafe != 3) |
---|
| 1346 | { |
---|
| 1347 | // start the next search for reducers in T from the beginning |
---|
| 1348 | start = 0; |
---|
| 1349 | #ifdef KDEBUG |
---|
| 1350 | if (TEST_OPT_DEBUG) |
---|
| 1351 | { |
---|
| 1352 | PrintS("\nto "); |
---|
| 1353 | h->wrp(); |
---|
| 1354 | PrintLn(); |
---|
| 1355 | } |
---|
| 1356 | #endif |
---|
| 1357 | |
---|
| 1358 | h_p = h->GetLmTailRing(); |
---|
| 1359 | if (h_p == NULL) |
---|
| 1360 | { |
---|
[3e5610] | 1361 | kDeleteLcm(h); |
---|
[83be980] | 1362 | return 0; |
---|
| 1363 | } |
---|
| 1364 | h->SetShortExpVector(); |
---|
| 1365 | not_sev = ~ h->sev; |
---|
| 1366 | /* |
---|
| 1367 | * try to reduce the s-polynomial h |
---|
| 1368 | *test first whether h should go to the lazyset L |
---|
| 1369 | *-if the degree jumps |
---|
| 1370 | *-if the number of pre-defined reductions jumps |
---|
| 1371 | */ |
---|
| 1372 | pass++; |
---|
| 1373 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass)) |
---|
| 1374 | { |
---|
| 1375 | h->SetLmCurrRing(); |
---|
| 1376 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 1377 | if (at <= strat->Ll) |
---|
| 1378 | { |
---|
| 1379 | int dummy=strat->sl; |
---|
| 1380 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
| 1381 | { |
---|
| 1382 | return 1; |
---|
| 1383 | } |
---|
| 1384 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1385 | #ifdef KDEBUG |
---|
| 1386 | if (TEST_OPT_DEBUG) |
---|
| 1387 | Print(" lazy: -> L%d\n",at); |
---|
| 1388 | #endif |
---|
| 1389 | h->Clear(); |
---|
| 1390 | return -1; |
---|
| 1391 | } |
---|
| 1392 | } |
---|
| 1393 | } |
---|
| 1394 | } |
---|
| 1395 | } |
---|
| 1396 | |
---|
[fbc7cb] | 1397 | // tail reduction for SBA |
---|
| 1398 | poly redtailSba (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize) |
---|
| 1399 | { |
---|
| 1400 | #define REDTAIL_CANONICALIZE 100 |
---|
| 1401 | strat->redTailChange=FALSE; |
---|
| 1402 | if (strat->noTailReduction) return L->GetLmCurrRing(); |
---|
| 1403 | poly h, p; |
---|
| 1404 | p = h = L->GetLmTailRing(); |
---|
| 1405 | if ((h==NULL) || (pNext(h)==NULL)) |
---|
| 1406 | return L->GetLmCurrRing(); |
---|
| 1407 | |
---|
| 1408 | TObject* With; |
---|
| 1409 | // placeholder in case strat->tl < 0 |
---|
| 1410 | TObject With_s(strat->tailRing); |
---|
| 1411 | |
---|
| 1412 | LObject Ln(pNext(h), strat->tailRing); |
---|
| 1413 | Ln.sig = L->sig; |
---|
| 1414 | Ln.sevSig = L->sevSig; |
---|
| 1415 | Ln.pLength = L->GetpLength() - 1; |
---|
| 1416 | |
---|
| 1417 | pNext(h) = NULL; |
---|
| 1418 | if (L->p != NULL) pNext(L->p) = NULL; |
---|
| 1419 | L->pLength = 1; |
---|
| 1420 | |
---|
| 1421 | Ln.PrepareRed(strat->use_buckets); |
---|
| 1422 | |
---|
| 1423 | int cnt=REDTAIL_CANONICALIZE; |
---|
| 1424 | while(!Ln.IsNull()) |
---|
| 1425 | { |
---|
| 1426 | loop |
---|
| 1427 | { |
---|
[094031] | 1428 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
| 1429 | break; |
---|
[fbc7cb] | 1430 | Ln.SetShortExpVector(); |
---|
| 1431 | if (withT) |
---|
| 1432 | { |
---|
| 1433 | int j; |
---|
[a576b0] | 1434 | j = kFindDivisibleByInT(strat, &Ln); |
---|
[fbc7cb] | 1435 | if (j < 0) break; |
---|
| 1436 | With = &(strat->T[j]); |
---|
| 1437 | } |
---|
| 1438 | else |
---|
| 1439 | { |
---|
[ad53a8] | 1440 | With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s); |
---|
[fbc7cb] | 1441 | if (With == NULL) break; |
---|
| 1442 | } |
---|
| 1443 | cnt--; |
---|
| 1444 | if (cnt==0) |
---|
| 1445 | { |
---|
| 1446 | cnt=REDTAIL_CANONICALIZE; |
---|
| 1447 | /*poly tmp=*/Ln.CanonicalizeP(); |
---|
[459ec94] | 1448 | if (normalize && !rField_is_Ring(currRing)) |
---|
[fbc7cb] | 1449 | { |
---|
| 1450 | Ln.Normalize(); |
---|
| 1451 | //pNormalize(tmp); |
---|
| 1452 | //if (TEST_OPT_PROT) { PrintS("n"); mflush(); } |
---|
| 1453 | } |
---|
| 1454 | } |
---|
[459ec94] | 1455 | if (normalize && (!TEST_OPT_INTSTRATEGY) && !rField_is_Ring(currRing) && (!nIsOne(pGetCoeff(With->p)))) |
---|
[fbc7cb] | 1456 | { |
---|
| 1457 | With->pNorm(); |
---|
| 1458 | } |
---|
| 1459 | strat->redTailChange=TRUE; |
---|
[094031] | 1460 | int ret = ksReducePolyTailSig(L, With, &Ln, strat); |
---|
| 1461 | if(rField_is_Ring(currRing)) |
---|
| 1462 | L->sig = Ln.sig; |
---|
| 1463 | //Because Ln.sig is set to L->sig, but in ksReducePolyTailSig -> ksReducePolySig |
---|
| 1464 | // I delete it an then set Ln.sig. Hence L->sig is lost |
---|
[fbc7cb] | 1465 | #if SBA_PRINT_REDUCTION_STEPS |
---|
| 1466 | if (ret != 3) |
---|
| 1467 | sba_reduction_steps++; |
---|
| 1468 | #endif |
---|
| 1469 | #if SBA_PRINT_OPERATIONS |
---|
| 1470 | if (ret != 3) |
---|
| 1471 | sba_operations += pLength(With->p); |
---|
| 1472 | #endif |
---|
| 1473 | if (ret) |
---|
| 1474 | { |
---|
| 1475 | // reducing the tail would violate the exp bound |
---|
| 1476 | // set a flag and hope for a retry (in bba) |
---|
| 1477 | strat->completeReduce_retry=TRUE; |
---|
| 1478 | if ((Ln.p != NULL) && (Ln.t_p != NULL)) Ln.p=NULL; |
---|
| 1479 | do |
---|
| 1480 | { |
---|
| 1481 | pNext(h) = Ln.LmExtractAndIter(); |
---|
| 1482 | pIter(h); |
---|
| 1483 | L->pLength++; |
---|
| 1484 | } while (!Ln.IsNull()); |
---|
| 1485 | goto all_done; |
---|
| 1486 | } |
---|
| 1487 | if (Ln.IsNull()) goto all_done; |
---|
| 1488 | if (! withT) With_s.Init(currRing); |
---|
[459ec94] | 1489 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
| 1490 | { |
---|
| 1491 | //Cannot break the loop here so easily |
---|
| 1492 | break; |
---|
| 1493 | } |
---|
[fbc7cb] | 1494 | } |
---|
| 1495 | pNext(h) = Ln.LmExtractAndIter(); |
---|
| 1496 | pIter(h); |
---|
[459ec94] | 1497 | if(!rField_is_Ring(currRing)) |
---|
| 1498 | pNormalize(h); |
---|
[fbc7cb] | 1499 | L->pLength++; |
---|
| 1500 | } |
---|
| 1501 | all_done: |
---|
| 1502 | Ln.Delete(); |
---|
| 1503 | if (L->p != NULL) pNext(L->p) = pNext(p); |
---|
| 1504 | |
---|
| 1505 | if (strat->redTailChange) |
---|
| 1506 | { |
---|
| 1507 | L->length = 0; |
---|
| 1508 | } |
---|
| 1509 | //if (TEST_OPT_PROT) { PrintS("N"); mflush(); } |
---|
| 1510 | //L->Normalize(); // HANNES: should have a test |
---|
[1eabfc] | 1511 | kTest_L(L,strat->tailRing); |
---|
[fbc7cb] | 1512 | return L->GetLmCurrRing(); |
---|
| 1513 | } |
---|
| 1514 | |
---|
[35aab3] | 1515 | /*2 |
---|
| 1516 | * reduction procedure for the inhomogeneous case |
---|
| 1517 | * and not a degree-ordering |
---|
| 1518 | */ |
---|
| 1519 | int redLazy (LObject* h,kStrategy strat) |
---|
| 1520 | { |
---|
| 1521 | if (strat->tl<0) return 1; |
---|
[d5564f8] | 1522 | int at,i,ii,li; |
---|
[35aab3] | 1523 | int j = 0; |
---|
| 1524 | int pass = 0; |
---|
| 1525 | assume(h->pFDeg() == h->FDeg); |
---|
| 1526 | long reddeg = h->GetpFDeg(); |
---|
[d5564f8] | 1527 | long d; |
---|
[225d94] | 1528 | unsigned long not_sev; |
---|
[35aab3] | 1529 | |
---|
| 1530 | h->SetShortExpVector(); |
---|
[225d94] | 1531 | poly h_p = h->GetLmTailRing(); |
---|
| 1532 | not_sev = ~ h->sev; |
---|
[35aab3] | 1533 | loop |
---|
| 1534 | { |
---|
[a576b0] | 1535 | j = kFindDivisibleByInT(strat, h); |
---|
[35aab3] | 1536 | if (j < 0) return 1; |
---|
[533634] | 1537 | |
---|
[225d94] | 1538 | li = strat->T[j].pLength; |
---|
[eafad1b] | 1539 | if (li<=0) li=strat->T[j].GetpLength(); |
---|
[225d94] | 1540 | ii = j; |
---|
| 1541 | /* |
---|
| 1542 | * the polynomial to reduce with (up to the moment) is; |
---|
| 1543 | * pi with length li |
---|
| 1544 | */ |
---|
| 1545 | |
---|
| 1546 | i = j; |
---|
| 1547 | #if 1 |
---|
[8c36a9] | 1548 | if (TEST_OPT_LENGTH) |
---|
[225d94] | 1549 | loop |
---|
| 1550 | { |
---|
| 1551 | /*- search the shortest possible with respect to length -*/ |
---|
| 1552 | i++; |
---|
| 1553 | if (i > strat->tl) |
---|
| 1554 | break; |
---|
[eafad1b] | 1555 | if (li==1) |
---|
[225d94] | 1556 | break; |
---|
| 1557 | if ((strat->T[i].pLength < li) |
---|
| 1558 | && |
---|
| 1559 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], |
---|
| 1560 | h_p, not_sev, strat->tailRing)) |
---|
| 1561 | { |
---|
| 1562 | /* |
---|
| 1563 | * the polynomial to reduce with is now; |
---|
| 1564 | */ |
---|
| 1565 | li = strat->T[i].pLength; |
---|
[eafad1b] | 1566 | if (li<=0) li=strat->T[i].GetpLength(); |
---|
[225d94] | 1567 | ii = i; |
---|
| 1568 | } |
---|
| 1569 | } |
---|
| 1570 | #endif |
---|
| 1571 | |
---|
| 1572 | /* |
---|
| 1573 | * end of search: have to reduce with pi |
---|
| 1574 | */ |
---|
| 1575 | |
---|
[35aab3] | 1576 | |
---|
| 1577 | #ifdef KDEBUG |
---|
| 1578 | if (TEST_OPT_DEBUG) |
---|
| 1579 | { |
---|
| 1580 | PrintS("red:"); |
---|
| 1581 | h->wrp(); |
---|
| 1582 | PrintS(" with "); |
---|
[225d94] | 1583 | strat->T[ii].wrp(); |
---|
[35aab3] | 1584 | } |
---|
| 1585 | #endif |
---|
| 1586 | |
---|
[225d94] | 1587 | ksReducePoly(h, &(strat->T[ii]), NULL, NULL, strat); |
---|
[6d77472] | 1588 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 1589 | sba_interreduction_steps++; |
---|
| 1590 | #endif |
---|
[7464b7c] | 1591 | #if SBA_PRINT_OPERATIONS |
---|
[f59aaa] | 1592 | sba_interreduction_operations += pLength(strat->T[ii].p); |
---|
| 1593 | #endif |
---|
[35aab3] | 1594 | |
---|
| 1595 | #ifdef KDEBUG |
---|
| 1596 | if (TEST_OPT_DEBUG) |
---|
| 1597 | { |
---|
| 1598 | PrintS("\nto "); |
---|
| 1599 | h->wrp(); |
---|
| 1600 | PrintLn(); |
---|
| 1601 | } |
---|
| 1602 | #endif |
---|
| 1603 | |
---|
[225d94] | 1604 | h_p=h->GetLmTailRing(); |
---|
| 1605 | |
---|
| 1606 | if (h_p == NULL) |
---|
[35aab3] | 1607 | { |
---|
[3e5610] | 1608 | kDeleteLcm(h); |
---|
[35aab3] | 1609 | return 0; |
---|
| 1610 | } |
---|
| 1611 | h->SetShortExpVector(); |
---|
[225d94] | 1612 | not_sev = ~ h->sev; |
---|
[35aab3] | 1613 | d = h->SetpFDeg(); |
---|
| 1614 | /*- try to reduce the s-polynomial -*/ |
---|
| 1615 | pass++; |
---|
[228b631] | 1616 | if (//!TEST_OPT_REDTHROUGH && |
---|
[35aab3] | 1617 | (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
| 1618 | { |
---|
| 1619 | h->SetLmCurrRing(); |
---|
[0188fa] | 1620 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
[35aab3] | 1621 | if (at <= strat->Ll) |
---|
| 1622 | { |
---|
[e690a91] | 1623 | #if 1 |
---|
| 1624 | int dummy=strat->sl; |
---|
| 1625 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
[35aab3] | 1626 | return 1; |
---|
[0188fa] | 1627 | #endif |
---|
[35aab3] | 1628 | #ifdef KDEBUG |
---|
| 1629 | if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at); |
---|
| 1630 | #endif |
---|
| 1631 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1632 | h->Clear(); |
---|
| 1633 | return -1; |
---|
| 1634 | } |
---|
| 1635 | } |
---|
[f7feb7] | 1636 | else if (d != reddeg) |
---|
[35aab3] | 1637 | { |
---|
[32ad2a] | 1638 | if (d>=(long)strat->tailRing->bitmask) |
---|
[f7feb7] | 1639 | { |
---|
[32ad2a] | 1640 | if (h->pTotalDeg() >= (long)strat->tailRing->bitmask) |
---|
[8d679fd] | 1641 | { |
---|
| 1642 | strat->overflow=TRUE; |
---|
[d5564f8] | 1643 | //Print("OVERFLOW in redLazy d=%ld, max=%ld\n",d,strat->tailRing->bitmask); |
---|
[8d679fd] | 1644 | h->GetP(); |
---|
| 1645 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 1646 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1647 | h->Clear(); |
---|
[d5564f8] | 1648 | return -1; |
---|
| 1649 | } |
---|
[f7feb7] | 1650 | } |
---|
| 1651 | else if ((TEST_OPT_PROT) && (strat->Ll < 0)) |
---|
| 1652 | { |
---|
[dd8a7d] | 1653 | Print(".%ld",d);mflush(); |
---|
[f7feb7] | 1654 | reddeg = d; |
---|
| 1655 | } |
---|
[35aab3] | 1656 | } |
---|
| 1657 | } |
---|
| 1658 | } |
---|
| 1659 | /*2 |
---|
| 1660 | * reduction procedure for the sugar-strategy (honey) |
---|
| 1661 | * reduces h with elements from T choosing first possible |
---|
| 1662 | * element in T with respect to the given ecart |
---|
| 1663 | */ |
---|
| 1664 | int redHoney (LObject* h, kStrategy strat) |
---|
| 1665 | { |
---|
| 1666 | if (strat->tl<0) return 1; |
---|
[c5f67b5] | 1667 | //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED! |
---|
[35aab3] | 1668 | assume(h->FDeg == h->pFDeg()); |
---|
| 1669 | poly h_p; |
---|
| 1670 | int i,j,at,pass,ei, ii, h_d; |
---|
| 1671 | unsigned long not_sev; |
---|
| 1672 | long reddeg,d; |
---|
| 1673 | |
---|
| 1674 | pass = j = 0; |
---|
| 1675 | d = reddeg = h->GetpFDeg() + h->ecart; |
---|
| 1676 | h->SetShortExpVector(); |
---|
[b2c236] | 1677 | int li; |
---|
[35aab3] | 1678 | h_p = h->GetLmTailRing(); |
---|
| 1679 | not_sev = ~ h->sev; |
---|
[f53fdf] | 1680 | |
---|
| 1681 | h->PrepareRed(strat->use_buckets); |
---|
[35aab3] | 1682 | loop |
---|
| 1683 | { |
---|
[a576b0] | 1684 | j=kFindDivisibleByInT(strat, h); |
---|
[35aab3] | 1685 | if (j < 0) return 1; |
---|
| 1686 | |
---|
| 1687 | ei = strat->T[j].ecart; |
---|
[b2c236] | 1688 | li = strat->T[j].pLength; |
---|
[eafad1b] | 1689 | if (li<=0) li=strat->T[j].GetpLength(); |
---|
[35aab3] | 1690 | ii = j; |
---|
| 1691 | /* |
---|
| 1692 | * the polynomial to reduce with (up to the moment) is; |
---|
[0ee0b4] | 1693 | * pi with ecart ei (T[ii]) |
---|
[35aab3] | 1694 | */ |
---|
| 1695 | i = j; |
---|
[8c36a9] | 1696 | if (TEST_OPT_LENGTH) |
---|
[35aab3] | 1697 | loop |
---|
| 1698 | { |
---|
| 1699 | /*- takes the first possible with respect to ecart -*/ |
---|
| 1700 | i++; |
---|
| 1701 | if (i > strat->tl) |
---|
| 1702 | break; |
---|
[f0b6c9] | 1703 | //if (ei < h->ecart) |
---|
| 1704 | // break; |
---|
[eafad1b] | 1705 | if (li==1) |
---|
[35aab3] | 1706 | break; |
---|
[f0b6c9] | 1707 | if ((((strat->T[i].ecart < ei) && (ei> h->ecart)) |
---|
[b2c236] | 1708 | || ((strat->T[i].ecart <= h->ecart) && (strat->T[i].pLength < li))) |
---|
| 1709 | && |
---|
[35aab3] | 1710 | p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], |
---|
| 1711 | h_p, not_sev, strat->tailRing)) |
---|
| 1712 | { |
---|
| 1713 | /* |
---|
| 1714 | * the polynomial to reduce with is now; |
---|
| 1715 | */ |
---|
| 1716 | ei = strat->T[i].ecart; |
---|
[b2c236] | 1717 | li = strat->T[i].pLength; |
---|
[eafad1b] | 1718 | if (li<=0) li=strat->T[i].GetpLength(); |
---|
[35aab3] | 1719 | ii = i; |
---|
| 1720 | } |
---|
| 1721 | } |
---|
| 1722 | |
---|
| 1723 | /* |
---|
| 1724 | * end of search: have to reduce with pi |
---|
| 1725 | */ |
---|
[228b631] | 1726 | if (!TEST_OPT_REDTHROUGH && (pass!=0) && (ei > h->ecart)) |
---|
[35aab3] | 1727 | { |
---|
[f53fdf] | 1728 | h->GetTP(); // clears bucket |
---|
[35aab3] | 1729 | h->SetLmCurrRing(); |
---|
| 1730 | /* |
---|
| 1731 | * It is not possible to reduce h with smaller ecart; |
---|
| 1732 | * if possible h goes to the lazy-set L,i.e |
---|
| 1733 | * if its position in L would be not the last one |
---|
| 1734 | */ |
---|
| 1735 | if (strat->Ll >= 0) /* L is not empty */ |
---|
| 1736 | { |
---|
| 1737 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 1738 | if(at <= strat->Ll) |
---|
| 1739 | /*- h will not become the next element to reduce -*/ |
---|
| 1740 | { |
---|
| 1741 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1742 | #ifdef KDEBUG |
---|
| 1743 | if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at); |
---|
| 1744 | #endif |
---|
| 1745 | h->Clear(); |
---|
| 1746 | return -1; |
---|
| 1747 | } |
---|
| 1748 | } |
---|
| 1749 | } |
---|
| 1750 | #ifdef KDEBUG |
---|
| 1751 | if (TEST_OPT_DEBUG) |
---|
| 1752 | { |
---|
| 1753 | PrintS("red:"); |
---|
| 1754 | h->wrp(); |
---|
[0ee0b4] | 1755 | Print("\nwith T[%d]:",ii); |
---|
[35aab3] | 1756 | strat->T[ii].wrp(); |
---|
| 1757 | } |
---|
| 1758 | #endif |
---|
| 1759 | assume(strat->fromT == FALSE); |
---|
| 1760 | |
---|
[2cbd15] | 1761 | ksReducePoly(h,&(strat->T[ii]),strat->kNoetherTail(),NULL,strat); |
---|
[6d77472] | 1762 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 1763 | sba_interreduction_steps++; |
---|
| 1764 | #endif |
---|
[7464b7c] | 1765 | #if SBA_PRINT_OPERATIONS |
---|
[f59aaa] | 1766 | sba_interreduction_operations += pLength(strat->T[ii].p); |
---|
| 1767 | #endif |
---|
[35aab3] | 1768 | #ifdef KDEBUG |
---|
| 1769 | if (TEST_OPT_DEBUG) |
---|
| 1770 | { |
---|
[f53fdf] | 1771 | PrintS("\nto:"); |
---|
[35aab3] | 1772 | h->wrp(); |
---|
| 1773 | PrintLn(); |
---|
| 1774 | } |
---|
| 1775 | #endif |
---|
[f53fdf] | 1776 | if(h->IsNull()) |
---|
[35aab3] | 1777 | { |
---|
[3e5610] | 1778 | kDeleteLcm(h); |
---|
[f53fdf] | 1779 | h->Clear(); |
---|
[35aab3] | 1780 | return 0; |
---|
| 1781 | } |
---|
[80c072] | 1782 | if (TEST_OPT_IDLIFT) |
---|
| 1783 | { |
---|
| 1784 | if (h->p!=NULL) |
---|
| 1785 | { |
---|
| 1786 | if(p_GetComp(h->p,currRing)>strat->syzComp) |
---|
[fc58b5b] | 1787 | { |
---|
| 1788 | h->Delete(); |
---|
| 1789 | return 0; |
---|
| 1790 | } |
---|
[80c072] | 1791 | } |
---|
| 1792 | else if (h->t_p!=NULL) |
---|
| 1793 | { |
---|
| 1794 | if(p_GetComp(h->t_p,strat->tailRing)>strat->syzComp) |
---|
[fc58b5b] | 1795 | { |
---|
| 1796 | h->Delete(); |
---|
| 1797 | return 0; |
---|
| 1798 | } |
---|
[80c072] | 1799 | } |
---|
| 1800 | } |
---|
[35aab3] | 1801 | h->SetShortExpVector(); |
---|
| 1802 | not_sev = ~ h->sev; |
---|
| 1803 | h_d = h->SetpFDeg(); |
---|
| 1804 | /* compute the ecart */ |
---|
| 1805 | if (ei <= h->ecart) |
---|
| 1806 | h->ecart = d-h_d; |
---|
[822aa3a] | 1807 | else |
---|
[35aab3] | 1808 | h->ecart = d-h_d+ei-h->ecart; |
---|
[f53fdf] | 1809 | |
---|
[35aab3] | 1810 | /* |
---|
| 1811 | * try to reduce the s-polynomial h |
---|
| 1812 | *test first whether h should go to the lazyset L |
---|
| 1813 | *-if the degree jumps |
---|
| 1814 | *-if the number of pre-defined reductions jumps |
---|
| 1815 | */ |
---|
| 1816 | pass++; |
---|
| 1817 | d = h_d + h->ecart; |
---|
[228b631] | 1818 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
[35aab3] | 1819 | { |
---|
[f53fdf] | 1820 | h->GetTP(); // clear bucket |
---|
[35aab3] | 1821 | h->SetLmCurrRing(); |
---|
| 1822 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 1823 | if (at <= strat->Ll) |
---|
| 1824 | { |
---|
[391323] | 1825 | int dummy=strat->sl; |
---|
| 1826 | if (kFindDivisibleByInS(strat, &dummy, h) < 0) |
---|
[35aab3] | 1827 | return 1; |
---|
| 1828 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1829 | #ifdef KDEBUG |
---|
| 1830 | if (TEST_OPT_DEBUG) |
---|
| 1831 | Print(" degree jumped: -> L%d\n",at); |
---|
| 1832 | #endif |
---|
| 1833 | h->Clear(); |
---|
| 1834 | return -1; |
---|
| 1835 | } |
---|
| 1836 | } |
---|
[f7feb7] | 1837 | else if (d > reddeg) |
---|
[35aab3] | 1838 | { |
---|
[32ad2a] | 1839 | if (d>=(long)strat->tailRing->bitmask) |
---|
[f7feb7] | 1840 | { |
---|
[32ad2a] | 1841 | if (h->pTotalDeg()+h->ecart >= (long)strat->tailRing->bitmask) |
---|
[8d679fd] | 1842 | { |
---|
| 1843 | strat->overflow=TRUE; |
---|
[d5564f8] | 1844 | //Print("OVERFLOW in redHoney d=%ld, max=%ld\n",d,strat->tailRing->bitmask); |
---|
[8d679fd] | 1845 | h->GetP(); |
---|
| 1846 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 1847 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 1848 | h->Clear(); |
---|
[d5564f8] | 1849 | return -1; |
---|
| 1850 | } |
---|
[f7feb7] | 1851 | } |
---|
| 1852 | else if (TEST_OPT_PROT && (strat->Ll < 0) ) |
---|
| 1853 | { |
---|
| 1854 | //h->wrp(); Print("<%d>\n",h->GetpLength()); |
---|
| 1855 | reddeg = d; |
---|
| 1856 | Print(".%ld",d); mflush(); |
---|
| 1857 | } |
---|
[35aab3] | 1858 | } |
---|
| 1859 | } |
---|
| 1860 | } |
---|
[22579cf] | 1861 | |
---|
[35aab3] | 1862 | /*2 |
---|
| 1863 | * reduction procedure for the normal form |
---|
| 1864 | */ |
---|
| 1865 | |
---|
[ab1c36] | 1866 | poly redNF (poly h,int &max_ind,int nonorm,kStrategy strat) |
---|
[35aab3] | 1867 | { |
---|
[a330f25] | 1868 | #define REDNF_CANONICALIZE 60 |
---|
[35aab3] | 1869 | if (h==NULL) return NULL; |
---|
| 1870 | int j; |
---|
[2c951e5] | 1871 | int cnt=REDNF_CANONICALIZE; |
---|
[391323] | 1872 | max_ind=strat->sl; |
---|
[35aab3] | 1873 | |
---|
| 1874 | if (0 > strat->sl) |
---|
| 1875 | { |
---|
| 1876 | return h; |
---|
| 1877 | } |
---|
| 1878 | LObject P(h); |
---|
| 1879 | P.SetShortExpVector(); |
---|
| 1880 | P.bucket = kBucketCreate(currRing); |
---|
| 1881 | kBucketInit(P.bucket,P.p,pLength(P.p)); |
---|
[c5f67b5] | 1882 | kbTest(P.bucket); |
---|
[40d3462] | 1883 | #ifdef HAVE_RINGS |
---|
| 1884 | BOOLEAN is_ring = rField_is_Ring(currRing); |
---|
| 1885 | #endif |
---|
[9e8da7] | 1886 | #ifdef KDEBUG |
---|
[ede2ad8] | 1887 | // if (TEST_OPT_DEBUG) |
---|
| 1888 | // { |
---|
| 1889 | // PrintS("redNF: starting S:\n"); |
---|
| 1890 | // for( j = 0; j <= max_ind; j++ ) |
---|
| 1891 | // { |
---|
| 1892 | // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j])); |
---|
| 1893 | // pWrite(strat->S[j]); |
---|
| 1894 | // } |
---|
| 1895 | // }; |
---|
[9e8da7] | 1896 | #endif |
---|
| 1897 | |
---|
[35aab3] | 1898 | loop |
---|
| 1899 | { |
---|
[d772c3] | 1900 | j=kFindDivisibleByInS(strat,&max_ind,&P); |
---|
[35aab3] | 1901 | if (j>=0) |
---|
| 1902 | { |
---|
[40d3462] | 1903 | #ifdef HAVE_RINGS |
---|
| 1904 | if (!is_ring) |
---|
| 1905 | { |
---|
| 1906 | #endif |
---|
[ab1c36] | 1907 | int sl=pSize(strat->S[j]); |
---|
| 1908 | int jj=j; |
---|
| 1909 | loop |
---|
[7ba059] | 1910 | { |
---|
[ab1c36] | 1911 | int sll; |
---|
| 1912 | jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P); |
---|
| 1913 | if (jj<0) break; |
---|
| 1914 | sll=pSize(strat->S[jj]); |
---|
[08ab82] | 1915 | if (sll<sl) |
---|
| 1916 | { |
---|
| 1917 | #ifdef KDEBUG |
---|
| 1918 | if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll); |
---|
| 1919 | #endif |
---|
[a589e6] | 1920 | //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); } |
---|
[19408c] | 1921 | j=jj; |
---|
| 1922 | sl=sll; |
---|
[08ab82] | 1923 | } |
---|
[7ba059] | 1924 | } |
---|
[1863d8] | 1925 | if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j])))) |
---|
[ab1c36] | 1926 | { |
---|
| 1927 | pNorm(strat->S[j]); |
---|
| 1928 | //if (TEST_OPT_PROT) { PrintS("n"); mflush(); } |
---|
| 1929 | } |
---|
[40d3462] | 1930 | #ifdef HAVE_RINGS |
---|
| 1931 | } |
---|
| 1932 | #endif |
---|
[35aab3] | 1933 | nNormalize(pGetCoeff(P.p)); |
---|
| 1934 | #ifdef KDEBUG |
---|
| 1935 | if (TEST_OPT_DEBUG) |
---|
| 1936 | { |
---|
| 1937 | PrintS("red:"); |
---|
| 1938 | wrp(h); |
---|
| 1939 | PrintS(" with "); |
---|
| 1940 | wrp(strat->S[j]); |
---|
| 1941 | } |
---|
| 1942 | #endif |
---|
| 1943 | #ifdef HAVE_PLURAL |
---|
| 1944 | if (rIsPluralRing(currRing)) |
---|
| 1945 | { |
---|
[c5f67b5] | 1946 | number coef; |
---|
[70a107] | 1947 | nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef); |
---|
[c5f67b5] | 1948 | nDelete(&coef); |
---|
[35aab3] | 1949 | } |
---|
| 1950 | else |
---|
| 1951 | #endif |
---|
| 1952 | { |
---|
| 1953 | number coef; |
---|
| 1954 | coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether); |
---|
| 1955 | nDelete(&coef); |
---|
| 1956 | } |
---|
[2c951e5] | 1957 | cnt--; |
---|
| 1958 | if (cnt==0) |
---|
| 1959 | { |
---|
[aacc4a] | 1960 | kBucketCanonicalize(P.bucket); |
---|
[2c951e5] | 1961 | cnt=REDNF_CANONICALIZE; |
---|
| 1962 | } |
---|
[cea6f3] | 1963 | h = kBucketGetLm(P.bucket); // FRAGE OLIVER |
---|
[35aab3] | 1964 | if (h==NULL) |
---|
| 1965 | { |
---|
| 1966 | kBucketDestroy(&P.bucket); |
---|
[9e8da7] | 1967 | |
---|
| 1968 | #ifdef KDEBUG |
---|
[ede2ad8] | 1969 | // if (TEST_OPT_DEBUG) |
---|
| 1970 | // { |
---|
| 1971 | // PrintS("redNF: starting S:\n"); |
---|
| 1972 | // for( j = 0; j <= max_ind; j++ ) |
---|
| 1973 | // { |
---|
| 1974 | // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j])); |
---|
| 1975 | // pWrite(strat->S[j]); |
---|
| 1976 | // } |
---|
| 1977 | // }; |
---|
[9e8da7] | 1978 | #endif |
---|
[e91ba4] | 1979 | |
---|
[35aab3] | 1980 | return NULL; |
---|
| 1981 | } |
---|
[c5f67b5] | 1982 | kbTest(P.bucket); |
---|
[35aab3] | 1983 | P.p=h; |
---|
| 1984 | P.t_p=NULL; |
---|
| 1985 | P.SetShortExpVector(); |
---|
| 1986 | #ifdef KDEBUG |
---|
| 1987 | if (TEST_OPT_DEBUG) |
---|
| 1988 | { |
---|
| 1989 | PrintS("\nto:"); |
---|
| 1990 | wrp(h); |
---|
| 1991 | PrintLn(); |
---|
| 1992 | } |
---|
| 1993 | #endif |
---|
| 1994 | } |
---|
| 1995 | else |
---|
| 1996 | { |
---|
| 1997 | P.p=kBucketClear(P.bucket); |
---|
| 1998 | kBucketDestroy(&P.bucket); |
---|
| 1999 | pNormalize(P.p); |
---|
[9e8da7] | 2000 | |
---|
| 2001 | #ifdef KDEBUG |
---|
[ede2ad8] | 2002 | // if (TEST_OPT_DEBUG) |
---|
| 2003 | // { |
---|
| 2004 | // PrintS("redNF: starting S:\n"); |
---|
| 2005 | // for( j = 0; j <= max_ind; j++ ) |
---|
| 2006 | // { |
---|
| 2007 | // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j])); |
---|
| 2008 | // pWrite(strat->S[j]); |
---|
| 2009 | // } |
---|
| 2010 | // }; |
---|
[9e8da7] | 2011 | #endif |
---|
| 2012 | |
---|
[35aab3] | 2013 | return P.p; |
---|
| 2014 | } |
---|
| 2015 | } |
---|
| 2016 | } |
---|
| 2017 | |
---|
[c2ef83] | 2018 | /*2 |
---|
| 2019 | * reduction procedure from global case but with jet bound |
---|
| 2020 | */ |
---|
| 2021 | |
---|
| 2022 | poly redNFBound (poly h,int &max_ind,int nonorm,kStrategy strat,int bound) |
---|
| 2023 | { |
---|
| 2024 | h = pJet(h,bound); |
---|
[674e1f] | 2025 | if (h==NULL) return NULL; |
---|
[c2ef83] | 2026 | int j; |
---|
| 2027 | max_ind=strat->sl; |
---|
| 2028 | |
---|
| 2029 | if (0 > strat->sl) |
---|
| 2030 | { |
---|
| 2031 | return h; |
---|
| 2032 | } |
---|
| 2033 | LObject P(h); |
---|
| 2034 | P.SetShortExpVector(); |
---|
| 2035 | P.bucket = kBucketCreate(currRing); |
---|
| 2036 | kBucketInit(P.bucket,P.p,pLength(P.p)); |
---|
| 2037 | kbTest(P.bucket); |
---|
| 2038 | #ifdef HAVE_RINGS |
---|
| 2039 | BOOLEAN is_ring = rField_is_Ring(currRing); |
---|
| 2040 | #endif |
---|
| 2041 | #ifdef KDEBUG |
---|
| 2042 | // if (TEST_OPT_DEBUG) |
---|
| 2043 | // { |
---|
| 2044 | // PrintS("redNF: starting S:\n"); |
---|
| 2045 | // for( j = 0; j <= max_ind; j++ ) |
---|
| 2046 | // { |
---|
| 2047 | // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j])); |
---|
| 2048 | // pWrite(strat->S[j]); |
---|
| 2049 | // } |
---|
| 2050 | // }; |
---|
| 2051 | #endif |
---|
| 2052 | |
---|
| 2053 | loop |
---|
| 2054 | { |
---|
| 2055 | j=kFindDivisibleByInS(strat,&max_ind,&P); |
---|
| 2056 | if (j>=0) |
---|
| 2057 | { |
---|
| 2058 | #ifdef HAVE_RINGS |
---|
| 2059 | if (!is_ring) |
---|
| 2060 | { |
---|
| 2061 | #endif |
---|
| 2062 | int sl=pSize(strat->S[j]); |
---|
| 2063 | int jj=j; |
---|
| 2064 | loop |
---|
| 2065 | { |
---|
| 2066 | int sll; |
---|
| 2067 | jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P); |
---|
| 2068 | if (jj<0) break; |
---|
| 2069 | sll=pSize(strat->S[jj]); |
---|
| 2070 | if (sll<sl) |
---|
| 2071 | { |
---|
| 2072 | #ifdef KDEBUG |
---|
| 2073 | if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll); |
---|
| 2074 | #endif |
---|
| 2075 | //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); } |
---|
| 2076 | j=jj; |
---|
| 2077 | sl=sll; |
---|
| 2078 | } |
---|
| 2079 | } |
---|
| 2080 | if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j])))) |
---|
| 2081 | { |
---|
| 2082 | pNorm(strat->S[j]); |
---|
| 2083 | //if (TEST_OPT_PROT) { PrintS("n"); mflush(); } |
---|
| 2084 | } |
---|
| 2085 | #ifdef HAVE_RINGS |
---|
| 2086 | } |
---|
| 2087 | #endif |
---|
| 2088 | nNormalize(pGetCoeff(P.p)); |
---|
| 2089 | #ifdef KDEBUG |
---|
| 2090 | if (TEST_OPT_DEBUG) |
---|
| 2091 | { |
---|
| 2092 | PrintS("red:"); |
---|
| 2093 | wrp(h); |
---|
| 2094 | PrintS(" with "); |
---|
| 2095 | wrp(strat->S[j]); |
---|
| 2096 | } |
---|
| 2097 | #endif |
---|
| 2098 | #ifdef HAVE_PLURAL |
---|
| 2099 | if (rIsPluralRing(currRing)) |
---|
| 2100 | { |
---|
| 2101 | number coef; |
---|
[70a107] | 2102 | nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef); |
---|
[c2ef83] | 2103 | nDelete(&coef); |
---|
| 2104 | } |
---|
| 2105 | else |
---|
| 2106 | #endif |
---|
| 2107 | { |
---|
| 2108 | number coef; |
---|
| 2109 | coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether); |
---|
| 2110 | P.p = kBucketClear(P.bucket); |
---|
| 2111 | P.p = pJet(P.p,bound); |
---|
[70e6d91] | 2112 | if(!P.IsNull()) |
---|
| 2113 | { |
---|
| 2114 | kBucketDestroy(&P.bucket); |
---|
| 2115 | P.SetShortExpVector(); |
---|
| 2116 | P.bucket = kBucketCreate(currRing); |
---|
| 2117 | kBucketInit(P.bucket,P.p,pLength(P.p)); |
---|
| 2118 | } |
---|
[c2ef83] | 2119 | nDelete(&coef); |
---|
| 2120 | } |
---|
| 2121 | h = kBucketGetLm(P.bucket); // FRAGE OLIVER |
---|
| 2122 | if (h==NULL) |
---|
| 2123 | { |
---|
| 2124 | kBucketDestroy(&P.bucket); |
---|
| 2125 | |
---|
| 2126 | #ifdef KDEBUG |
---|
| 2127 | // if (TEST_OPT_DEBUG) |
---|
| 2128 | // { |
---|
| 2129 | // PrintS("redNF: starting S:\n"); |
---|
| 2130 | // for( j = 0; j <= max_ind; j++ ) |
---|
| 2131 | // { |
---|
| 2132 | // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j])); |
---|
| 2133 | // pWrite(strat->S[j]); |
---|
| 2134 | // } |
---|
| 2135 | // }; |
---|
| 2136 | #endif |
---|
| 2137 | |
---|
| 2138 | return NULL; |
---|
| 2139 | } |
---|
| 2140 | kbTest(P.bucket); |
---|
| 2141 | P.p=h; |
---|
| 2142 | P.t_p=NULL; |
---|
| 2143 | P.SetShortExpVector(); |
---|
| 2144 | #ifdef KDEBUG |
---|
| 2145 | if (TEST_OPT_DEBUG) |
---|
| 2146 | { |
---|
| 2147 | PrintS("\nto:"); |
---|
| 2148 | wrp(h); |
---|
| 2149 | PrintLn(); |
---|
| 2150 | } |
---|
| 2151 | #endif |
---|
| 2152 | } |
---|
| 2153 | else |
---|
| 2154 | { |
---|
| 2155 | P.p=kBucketClear(P.bucket); |
---|
| 2156 | kBucketDestroy(&P.bucket); |
---|
| 2157 | pNormalize(P.p); |
---|
| 2158 | |
---|
| 2159 | #ifdef KDEBUG |
---|
| 2160 | // if (TEST_OPT_DEBUG) |
---|
| 2161 | // { |
---|
| 2162 | // PrintS("redNF: starting S:\n"); |
---|
| 2163 | // for( j = 0; j <= max_ind; j++ ) |
---|
| 2164 | // { |
---|
| 2165 | // Print("S[%d] (of size: %d): ", j, pSize(strat->S[j])); |
---|
| 2166 | // pWrite(strat->S[j]); |
---|
| 2167 | // } |
---|
| 2168 | // }; |
---|
| 2169 | #endif |
---|
| 2170 | |
---|
| 2171 | return P.p; |
---|
| 2172 | } |
---|
| 2173 | } |
---|
| 2174 | } |
---|
| 2175 | |
---|
[79d3879] | 2176 | void kDebugPrint(kStrategy strat); |
---|
[35aab3] | 2177 | |
---|
| 2178 | ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) |
---|
| 2179 | { |
---|
[930ea8] | 2180 | int red_result = 1; |
---|
[35aab3] | 2181 | int olddeg,reduc; |
---|
| 2182 | int hilbeledeg=1,hilbcount=0,minimcnt=0; |
---|
| 2183 | BOOLEAN withT = FALSE; |
---|
[3772383] | 2184 | BITSET save; |
---|
| 2185 | SI_SAVE_OPT1(save); |
---|
[35aab3] | 2186 | |
---|
| 2187 | initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ |
---|
[e21795] | 2188 | if(rField_is_Ring(currRing)) |
---|
[5efbf9] | 2189 | initBuchMoraPosRing(strat); |
---|
| 2190 | else |
---|
| 2191 | initBuchMoraPos(strat); |
---|
[35aab3] | 2192 | initHilbCrit(F,Q,&hilb,strat); |
---|
[4cc32b2] | 2193 | initBba(strat); |
---|
[35aab3] | 2194 | /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ |
---|
| 2195 | /*Shdl=*/initBuchMora(F, Q,strat); |
---|
| 2196 | if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank); |
---|
[930ea8] | 2197 | reduc = olddeg = 0; |
---|
[35aab3] | 2198 | |
---|
| 2199 | #ifndef NO_BUCKETS |
---|
| 2200 | if (!TEST_OPT_NOT_BUCKETS) |
---|
| 2201 | strat->use_buckets = 1; |
---|
| 2202 | #endif |
---|
| 2203 | // redtailBBa against T for inhomogenous input |
---|
[228b631] | 2204 | if (!TEST_OPT_OLDSTD) |
---|
[35aab3] | 2205 | withT = ! strat->homog; |
---|
| 2206 | |
---|
| 2207 | // strat->posInT = posInT_pLength; |
---|
[eb55f8a] | 2208 | kTest_TS(strat); |
---|
[35aab3] | 2209 | |
---|
| 2210 | #ifdef HAVE_TAIL_RING |
---|
[e533660] | 2211 | if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed |
---|
[645a19] | 2212 | kStratInitChangeTailRing(strat); |
---|
[35aab3] | 2213 | #endif |
---|
[d5564f8] | 2214 | if (BVERBOSE(23)) |
---|
[57fad3a] | 2215 | { |
---|
| 2216 | if (test_PosInT!=NULL) strat->posInT=test_PosInT; |
---|
| 2217 | if (test_PosInL!=NULL) strat->posInL=test_PosInL; |
---|
| 2218 | kDebugPrint(strat); |
---|
| 2219 | } |
---|
| 2220 | |
---|
[35aab3] | 2221 | |
---|
[8d679fd] | 2222 | #ifdef KDEBUG |
---|
| 2223 | //kDebugPrint(strat); |
---|
| 2224 | #endif |
---|
[35aab3] | 2225 | /* compute------------------------------------------------------- */ |
---|
| 2226 | while (strat->Ll >= 0) |
---|
| 2227 | { |
---|
[08ab82] | 2228 | #ifdef KDEBUG |
---|
| 2229 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 2230 | #endif |
---|
[9a14a5] | 2231 | if (siCntrlc) |
---|
| 2232 | { |
---|
| 2233 | while (strat->Ll >= 0) |
---|
| 2234 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 2235 | strat->noClearS=TRUE; |
---|
| 2236 | } |
---|
| 2237 | if (TEST_OPT_DEGBOUND |
---|
[e533660] | 2238 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
[9a14a5] | 2239 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
[35aab3] | 2240 | { |
---|
| 2241 | /* |
---|
| 2242 | *stops computation if |
---|
| 2243 | * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
| 2244 | *a predefined number Kstd1_deg |
---|
| 2245 | */ |
---|
[939847] | 2246 | while ((strat->Ll >= 0) |
---|
[9a14a5] | 2247 | && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) |
---|
| 2248 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
[e533660] | 2249 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))) |
---|
[9a14a5] | 2250 | ) |
---|
[019649] | 2251 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 2252 | if (strat->Ll<0) break; |
---|
[3957e37] | 2253 | else strat->noClearS=TRUE; |
---|
[35aab3] | 2254 | } |
---|
[9a14a5] | 2255 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
[35aab3] | 2256 | /* picks the last element from the lazyset L */ |
---|
| 2257 | strat->P = strat->L[strat->Ll]; |
---|
| 2258 | strat->Ll--; |
---|
| 2259 | |
---|
| 2260 | if (pNext(strat->P.p) == strat->tail) |
---|
| 2261 | { |
---|
| 2262 | // deletes the short spoly |
---|
[a539ad] | 2263 | if (rField_is_Ring(currRing)) |
---|
| 2264 | pLmDelete(strat->P.p); |
---|
| 2265 | else |
---|
| 2266 | pLmFree(strat->P.p); |
---|
[35aab3] | 2267 | strat->P.p = NULL; |
---|
| 2268 | poly m1 = NULL, m2 = NULL; |
---|
| 2269 | |
---|
| 2270 | // check that spoly creation is ok |
---|
| 2271 | while (strat->tailRing != currRing && |
---|
| 2272 | !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) |
---|
| 2273 | { |
---|
| 2274 | assume(m1 == NULL && m2 == NULL); |
---|
| 2275 | // if not, change to a ring where exponents are at least |
---|
| 2276 | // large enough |
---|
[7ae94b] | 2277 | if (!kStratChangeTailRing(strat)) |
---|
| 2278 | { |
---|
[8d679fd] | 2279 | WerrorS("OVERFLOW..."); |
---|
[7ae94b] | 2280 | break; |
---|
| 2281 | } |
---|
[35aab3] | 2282 | } |
---|
| 2283 | // create the real one |
---|
| 2284 | ksCreateSpoly(&(strat->P), NULL, strat->use_buckets, |
---|
| 2285 | strat->tailRing, m1, m2, strat->R); |
---|
| 2286 | } |
---|
| 2287 | else if (strat->P.p1 == NULL) |
---|
| 2288 | { |
---|
| 2289 | if (strat->minim > 0) |
---|
| 2290 | strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); |
---|
| 2291 | // for input polys, prepare reduction |
---|
| 2292 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 2293 | } |
---|
| 2294 | |
---|
[eb1f43] | 2295 | if ((strat->P.p == NULL) && (strat->P.t_p == NULL)) |
---|
[977f94] | 2296 | { |
---|
[cea6f3] | 2297 | red_result = 0; |
---|
| 2298 | } |
---|
| 2299 | else |
---|
| 2300 | { |
---|
| 2301 | if (TEST_OPT_PROT) |
---|
| 2302 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
| 2303 | &olddeg,&reduc,strat, red_result); |
---|
[35aab3] | 2304 | |
---|
[88615db] | 2305 | /* reduction of the element chosen from L */ |
---|
[cea6f3] | 2306 | red_result = strat->red(&strat->P,strat); |
---|
[d5564f8] | 2307 | if (errorreported) break; |
---|
| 2308 | } |
---|
| 2309 | |
---|
| 2310 | if (strat->overflow) |
---|
| 2311 | { |
---|
[7b9b8e5] | 2312 | if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;} |
---|
[cea6f3] | 2313 | } |
---|
[35aab3] | 2314 | |
---|
| 2315 | // reduction to non-zero new poly |
---|
| 2316 | if (red_result == 1) |
---|
| 2317 | { |
---|
| 2318 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 2319 | strat->P.GetP(strat->lmBin); |
---|
[3dc79f5] | 2320 | // in the homogeneous case FDeg >= pFDeg (sugar/honey) |
---|
| 2321 | // but now, for entering S, T, we reset it |
---|
| 2322 | // in the inhomogeneous case: FDeg == pFDeg |
---|
| 2323 | if (strat->homog) strat->initEcart(&(strat->P)); |
---|
[35aab3] | 2324 | |
---|
[d5564f8] | 2325 | /* statistic */ |
---|
| 2326 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 2327 | |
---|
[35aab3] | 2328 | int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 2329 | |
---|
| 2330 | // reduce the tail and normalize poly |
---|
[521349] | 2331 | // in the ring case we cannot expect LC(f) = 1, |
---|
[24bc73] | 2332 | // therefore we call pCleardenom instead of pNorm |
---|
[89f4843] | 2333 | strat->redTailChange=FALSE; |
---|
[e34d7f] | 2334 | |
---|
| 2335 | /* if we are computing over Z we always want to try and cut down |
---|
| 2336 | * the coefficients in the tail terms */ |
---|
[b2bceb6] | 2337 | if (rField_is_Z(currRing) && !rHasLocalOrMixedOrdering(currRing)) { |
---|
[e34d7f] | 2338 | redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat); |
---|
[b2bceb6] | 2339 | strat->P.pCleardenom(); |
---|
| 2340 | } |
---|
| 2341 | |
---|
[521349] | 2342 | if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing))) |
---|
[35aab3] | 2343 | { |
---|
| 2344 | strat->P.pCleardenom(); |
---|
| 2345 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 2346 | { |
---|
[0ee0b4] | 2347 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB); |
---|
[35aab3] | 2348 | strat->P.pCleardenom(); |
---|
[89f4843] | 2349 | if (strat->redTailChange) { strat->P.t_p=NULL; } |
---|
[35aab3] | 2350 | } |
---|
| 2351 | } |
---|
| 2352 | else |
---|
| 2353 | { |
---|
| 2354 | strat->P.pNorm(); |
---|
| 2355 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
[89f4843] | 2356 | { |
---|
[35aab3] | 2357 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
[89f4843] | 2358 | if (strat->redTailChange) { strat->P.t_p=NULL; } |
---|
| 2359 | } |
---|
[35aab3] | 2360 | } |
---|
| 2361 | |
---|
| 2362 | #ifdef KDEBUG |
---|
| 2363 | if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} |
---|
[645a19] | 2364 | #endif /* KDEBUG */ |
---|
[35aab3] | 2365 | |
---|
| 2366 | // min_std stuff |
---|
| 2367 | if ((strat->P.p1==NULL) && (strat->minim>0)) |
---|
| 2368 | { |
---|
| 2369 | if (strat->minim==1) |
---|
| 2370 | { |
---|
| 2371 | strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); |
---|
| 2372 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 2373 | } |
---|
| 2374 | else |
---|
| 2375 | { |
---|
| 2376 | strat->M->m[minimcnt]=strat->P.p2; |
---|
| 2377 | strat->P.p2=NULL; |
---|
| 2378 | } |
---|
| 2379 | if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) |
---|
| 2380 | pNext(strat->M->m[minimcnt]) |
---|
| 2381 | = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), |
---|
| 2382 | strat->tailRing, currRing, |
---|
| 2383 | currRing->PolyBin); |
---|
| 2384 | minimcnt++; |
---|
| 2385 | } |
---|
| 2386 | |
---|
| 2387 | // enter into S, L, and T |
---|
[a973339] | 2388 | if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) |
---|
| 2389 | { |
---|
[f0b6c9] | 2390 | enterT(strat->P, strat); |
---|
[a973339] | 2391 | if (rField_is_Ring(currRing)) |
---|
| 2392 | superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
| 2393 | else |
---|
| 2394 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
| 2395 | // posInS only depends on the leading term |
---|
| 2396 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
[f0b6c9] | 2397 | #if 0 |
---|
[a973339] | 2398 | int pl=pLength(strat->P.p); |
---|
| 2399 | if (pl==1) |
---|
| 2400 | { |
---|
| 2401 | //if (TEST_OPT_PROT) |
---|
| 2402 | //PrintS("<1>"); |
---|
| 2403 | } |
---|
| 2404 | else if (pl==2) |
---|
| 2405 | { |
---|
| 2406 | //if (TEST_OPT_PROT) |
---|
| 2407 | //PrintS("<2>"); |
---|
| 2408 | } |
---|
[f0b6c9] | 2409 | #endif |
---|
[a973339] | 2410 | } |
---|
[6f203b] | 2411 | if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 2412 | // Print("[%d]",hilbeledeg); |
---|
[3e5610] | 2413 | kDeleteLcm(&strat->P); |
---|
[8204ed] | 2414 | if (strat->s_poly!=NULL) |
---|
| 2415 | { |
---|
[6f203b] | 2416 | // the only valid entries are: strat->P.p, |
---|
| 2417 | // strat->tailRing (read-only, keep it) |
---|
| 2418 | // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed) |
---|
[5cc43c5] | 2419 | if (strat->s_poly(strat)) |
---|
| 2420 | { |
---|
| 2421 | // we are called AFTER enterS, i.e. if we change P |
---|
[6f203b] | 2422 | // we have to add it also to S/T |
---|
[5cc43c5] | 2423 | // and add pairs |
---|
[29fde9] | 2424 | int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
[5cc43c5] | 2425 | enterT(strat->P, strat); |
---|
| 2426 | if (rField_is_Ring(currRing)) |
---|
| 2427 | superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
| 2428 | else |
---|
| 2429 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
| 2430 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
| 2431 | } |
---|
[8204ed] | 2432 | } |
---|
[35aab3] | 2433 | } |
---|
| 2434 | else if (strat->P.p1 == NULL && strat->minim > 0) |
---|
| 2435 | { |
---|
| 2436 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 2437 | } |
---|
[a539ad] | 2438 | |
---|
[35aab3] | 2439 | #ifdef KDEBUG |
---|
| 2440 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
[645a19] | 2441 | #endif /* KDEBUG */ |
---|
[eb55f8a] | 2442 | kTest_TS(strat); |
---|
[35aab3] | 2443 | } |
---|
| 2444 | #ifdef KDEBUG |
---|
| 2445 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
[645a19] | 2446 | #endif /* KDEBUG */ |
---|
| 2447 | |
---|
[07b1cf] | 2448 | if (TEST_OPT_SB_1) |
---|
| 2449 | { |
---|
[9927b9e] | 2450 | if(!rField_is_Ring(currRing)) |
---|
[07b1cf] | 2451 | { |
---|
[c6ded3] | 2452 | int k=1; |
---|
| 2453 | int j; |
---|
| 2454 | while(k<=strat->sl) |
---|
| 2455 | { |
---|
| 2456 | j=0; |
---|
| 2457 | loop |
---|
[c96539c] | 2458 | { |
---|
[c6ded3] | 2459 | if (j>=k) break; |
---|
| 2460 | clearS(strat->S[j],strat->sevS[j],&k,&j,strat); |
---|
| 2461 | j++; |
---|
[c96539c] | 2462 | } |
---|
[c6ded3] | 2463 | k++; |
---|
| 2464 | } |
---|
[07b1cf] | 2465 | } |
---|
| 2466 | } |
---|
[93f4bb] | 2467 | /* complete reduction of the standard basis--------- */ |
---|
[533634] | 2468 | if (TEST_OPT_REDSB) |
---|
[b57694] | 2469 | { |
---|
[533634] | 2470 | completeReduce(strat); |
---|
[b57694] | 2471 | if (strat->completeReduce_retry) |
---|
| 2472 | { |
---|
[533634] | 2473 | // completeReduce needed larger exponents, retry |
---|
| 2474 | // to reduce with S (instead of T) |
---|
| 2475 | // and in currRing (instead of strat->tailRing) |
---|
[f26b42] | 2476 | #ifdef HAVE_TAIL_RING |
---|
| 2477 | if(currRing->bitmask>strat->tailRing->bitmask) |
---|
| 2478 | { |
---|
| 2479 | strat->completeReduce_retry=FALSE; |
---|
| 2480 | cleanT(strat);strat->tailRing=currRing; |
---|
| 2481 | int i; |
---|
| 2482 | for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1; |
---|
| 2483 | completeReduce(strat); |
---|
| 2484 | } |
---|
| 2485 | if (strat->completeReduce_retry) |
---|
[cbc616] | 2486 | #endif |
---|
[f26b42] | 2487 | Werror("exponent bound is %ld",currRing->bitmask); |
---|
| 2488 | } |
---|
[b57694] | 2489 | } |
---|
[5accf0] | 2490 | else if (TEST_OPT_PROT) PrintLn(); |
---|
[d34308] | 2491 | /* release temp data-------------------------------- */ |
---|
| 2492 | exitBuchMora(strat); |
---|
| 2493 | /* postprocessing for GB over ZZ --------------------*/ |
---|
[f26b42] | 2494 | if (!errorreported) |
---|
[f6db0d] | 2495 | { |
---|
[353a42] | 2496 | if(rField_is_Z(currRing)) |
---|
[f6db0d] | 2497 | { |
---|
[f26b42] | 2498 | for(int i = 0;i<=strat->sl;i++) |
---|
[f6db0d] | 2499 | { |
---|
[f26b42] | 2500 | if(!nGreaterZero(pGetCoeff(strat->S[i]))) |
---|
| 2501 | { |
---|
| 2502 | strat->S[i] = pNeg(strat->S[i]); |
---|
| 2503 | } |
---|
[f6db0d] | 2504 | } |
---|
[0091f5] | 2505 | finalReduceByMon(strat); |
---|
[d16f9c] | 2506 | for(int i = 0;i<IDELEMS(strat->Shdl);i++) |
---|
[0091f5] | 2507 | { |
---|
[d16f9c] | 2508 | if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i]))) |
---|
[0091f5] | 2509 | { |
---|
[d16f9c] | 2510 | strat->S[i] = pNeg(strat->Shdl->m[i]); |
---|
[0091f5] | 2511 | } |
---|
| 2512 | } |
---|
[f6db0d] | 2513 | } |
---|
[d16f9c] | 2514 | //else if (rField_is_Ring(currRing)) |
---|
| 2515 | // finalReduceByMon(strat); |
---|
[f6db0d] | 2516 | } |
---|
[e533660] | 2517 | // if (TEST_OPT_WEIGHTM) |
---|
| 2518 | // { |
---|
| 2519 | // pRestoreDegProcs(currRing,pFDegOld, pLDegOld); |
---|
| 2520 | // if (ecartWeights) |
---|
| 2521 | // { |
---|
| 2522 | // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
| 2523 | // ecartWeights=NULL; |
---|
| 2524 | // } |
---|
| 2525 | // } |
---|
[ede2ad8] | 2526 | if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat); |
---|
[3772383] | 2527 | SI_RESTORE_OPT1(save); |
---|
[d34308] | 2528 | /* postprocessing for GB over Q-rings ------------------*/ |
---|
[f26b42] | 2529 | if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat); |
---|
[645a19] | 2530 | |
---|
| 2531 | idTest(strat->Shdl); |
---|
| 2532 | |
---|
[35aab3] | 2533 | return (strat->Shdl); |
---|
| 2534 | } |
---|
[db0c2bd] | 2535 | |
---|
[83be980] | 2536 | ideal sba (ideal F0, ideal Q,intvec *w,intvec *hilb,kStrategy strat) |
---|
| 2537 | { |
---|
| 2538 | // ring order stuff: |
---|
| 2539 | // in sba we have (until now) two possibilities: |
---|
| 2540 | // 1. an incremental computation w.r.t. (C,monomial order) |
---|
[601105] | 2541 | // 2. a (possibly non-incremental) computation w.r.t. the |
---|
[83be980] | 2542 | // induced Schreyer order. |
---|
| 2543 | // The corresponding orders are computed in sbaRing(), depending |
---|
[f7f084] | 2544 | // on the flag strat->sbaOrder |
---|
[6d77472] | 2545 | #if SBA_PRINT_ZERO_REDUCTIONS |
---|
[f59aaa] | 2546 | long zeroreductions = 0; |
---|
[6d77472] | 2547 | #endif |
---|
| 2548 | #if SBA_PRINT_PRODUCT_CRITERION |
---|
[f59aaa] | 2549 | long product_criterion = 0; |
---|
[6d77472] | 2550 | #endif |
---|
| 2551 | #if SBA_PRINT_SIZE_G |
---|
[2ce53d] | 2552 | int size_g = 0; |
---|
| 2553 | int size_g_non_red = 0; |
---|
[6d77472] | 2554 | #endif |
---|
| 2555 | #if SBA_PRINT_SIZE_SYZ |
---|
[f59aaa] | 2556 | long size_syz = 0; |
---|
[6d77472] | 2557 | #endif |
---|
[f9d20d7] | 2558 | // global variable |
---|
[6d77472] | 2559 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 2560 | sba_reduction_steps = 0; |
---|
| 2561 | sba_interreduction_steps = 0; |
---|
[6d77472] | 2562 | #endif |
---|
[e40da9f] | 2563 | #if SBA_PRINT_OPERATIONS |
---|
| 2564 | sba_operations = 0; |
---|
| 2565 | sba_interreduction_operations = 0; |
---|
| 2566 | #endif |
---|
[780c1b] | 2567 | |
---|
[e40da9f] | 2568 | ideal F1 = F0; |
---|
| 2569 | ring sRing, currRingOld; |
---|
| 2570 | currRingOld = currRing; |
---|
| 2571 | if (strat->sbaOrder == 1 || strat->sbaOrder == 3) |
---|
| 2572 | { |
---|
| 2573 | sRing = sbaRing(strat); |
---|
| 2574 | if (sRing!=currRingOld) |
---|
| 2575 | { |
---|
| 2576 | rChangeCurrRing (sRing); |
---|
| 2577 | F1 = idrMoveR (F0, currRingOld, currRing); |
---|
| 2578 | } |
---|
| 2579 | } |
---|
| 2580 | ideal F; |
---|
| 2581 | // sort ideal F |
---|
| 2582 | //Put the SigDrop element on the correct position (think of sbaEnterS) |
---|
| 2583 | //We also sort them |
---|
| 2584 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
| 2585 | { |
---|
| 2586 | #if 1 |
---|
| 2587 | F = idInit(IDELEMS(F1),F1->rank); |
---|
| 2588 | for (int i=0; i<IDELEMS(F1);++i) |
---|
| 2589 | F->m[i] = F1->m[i]; |
---|
| 2590 | if(strat->sbaEnterS >= 0) |
---|
| 2591 | { |
---|
| 2592 | poly dummy; |
---|
| 2593 | dummy = pCopy(F->m[0]); //the sigdrop element |
---|
| 2594 | for(int i = 0;i<strat->sbaEnterS;i++) |
---|
| 2595 | F->m[i] = F->m[i+1]; |
---|
| 2596 | F->m[strat->sbaEnterS] = dummy; |
---|
| 2597 | } |
---|
| 2598 | #else |
---|
| 2599 | F = idInit(1,F1->rank); |
---|
| 2600 | //printf("\nBefore the initial block sorting:\n");idPrint(F1); |
---|
| 2601 | F->m[0] = F1->m[0]; |
---|
| 2602 | int pos; |
---|
| 2603 | if(strat->sbaEnterS >= 0) |
---|
| 2604 | { |
---|
| 2605 | for(int i=1;i<=strat->sbaEnterS;i++) |
---|
| 2606 | { |
---|
| 2607 | pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS); |
---|
| 2608 | idInsertPolyOnPos(F,F1->m[i],pos); |
---|
| 2609 | } |
---|
| 2610 | for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++) |
---|
| 2611 | { |
---|
| 2612 | pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F)); |
---|
| 2613 | idInsertPolyOnPos(F,F1->m[i],pos); |
---|
| 2614 | } |
---|
| 2615 | poly dummy; |
---|
| 2616 | dummy = pCopy(F->m[0]); //the sigdrop element |
---|
| 2617 | for(int i = 0;i<strat->sbaEnterS;i++) |
---|
| 2618 | F->m[i] = F->m[i+1]; |
---|
| 2619 | F->m[strat->sbaEnterS] = dummy; |
---|
| 2620 | } |
---|
| 2621 | else |
---|
[4c7632] | 2622 | { |
---|
| 2623 | for(int i=1;i<IDELEMS(F1);i++) |
---|
| 2624 | { |
---|
| 2625 | pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F)); |
---|
| 2626 | idInsertPolyOnPos(F,F1->m[i],pos); |
---|
| 2627 | } |
---|
| 2628 | } |
---|
[094031] | 2629 | #endif |
---|
[4c7632] | 2630 | //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar(); |
---|
[094031] | 2631 | } |
---|
| 2632 | else |
---|
| 2633 | { |
---|
[4c7632] | 2634 | F = idInit(IDELEMS(F1),F1->rank); |
---|
[094031] | 2635 | intvec *sort = idSort(F1); |
---|
| 2636 | for (int i=0; i<sort->length();++i) |
---|
| 2637 | F->m[i] = F1->m[(*sort)[i]-1]; |
---|
[e40da9f] | 2638 | if(rField_is_Ring(currRing)) |
---|
[4c7632] | 2639 | { |
---|
[e40da9f] | 2640 | // put the monomials after the sbaEnterS polynomials |
---|
| 2641 | //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F); |
---|
| 2642 | int nrmon = 0; |
---|
| 2643 | for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--) |
---|
[4c7632] | 2644 | { |
---|
[e40da9f] | 2645 | //pWrite(F->m[i]); |
---|
| 2646 | if(F->m[i] != NULL && pNext(F->m[i]) == NULL) |
---|
| 2647 | { |
---|
| 2648 | poly mon = F->m[i]; |
---|
| 2649 | for(j = i;j>strat->sbaEnterS+nrmon+1;j--) |
---|
| 2650 | { |
---|
| 2651 | F->m[j] = F->m[j-1]; |
---|
| 2652 | } |
---|
| 2653 | F->m[j] = mon; |
---|
| 2654 | nrmon++; |
---|
| 2655 | } |
---|
| 2656 | //idPrint(F); |
---|
[4c7632] | 2657 | } |
---|
| 2658 | } |
---|
[094031] | 2659 | } |
---|
[4c7632] | 2660 | //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar(); |
---|
[094031] | 2661 | if(rField_is_Ring(currRing)) |
---|
| 2662 | strat->sigdrop = FALSE; |
---|
| 2663 | strat->nrsyzcrit = 0; |
---|
[11416e] | 2664 | strat->nrrewcrit = 0; |
---|
[cc6544] | 2665 | #if SBA_INTERRED_START |
---|
| 2666 | F = kInterRed(F,NULL); |
---|
| 2667 | #endif |
---|
[d5856f] | 2668 | #if F5DEBUG |
---|
[83be980] | 2669 | printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n"); |
---|
| 2670 | rWrite (currRing); |
---|
[cda0b0] | 2671 | printf("ordSgn = %d\n",currRing->OrdSgn); |
---|
[83be980] | 2672 | printf("\n"); |
---|
| 2673 | #endif |
---|
| 2674 | int srmax,lrmax, red_result = 1; |
---|
| 2675 | int olddeg,reduc; |
---|
| 2676 | int hilbeledeg=1,hilbcount=0,minimcnt=0; |
---|
| 2677 | LObject L; |
---|
[576f5b] | 2678 | BOOLEAN withT = TRUE; |
---|
[83be980] | 2679 | strat->max_lower_index = 0; |
---|
| 2680 | //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ |
---|
| 2681 | initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/ |
---|
| 2682 | initSbaPos(strat); |
---|
| 2683 | initHilbCrit(F,Q,&hilb,strat); |
---|
| 2684 | initSba(F,strat); |
---|
| 2685 | /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ |
---|
| 2686 | /*Shdl=*/initSbaBuchMora(F, Q,strat); |
---|
[e40da9f] | 2687 | idTest(strat->Shdl); |
---|
[83be980] | 2688 | if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank); |
---|
| 2689 | srmax = strat->sl; |
---|
| 2690 | reduc = olddeg = lrmax = 0; |
---|
| 2691 | #ifndef NO_BUCKETS |
---|
| 2692 | if (!TEST_OPT_NOT_BUCKETS) |
---|
| 2693 | strat->use_buckets = 1; |
---|
| 2694 | #endif |
---|
| 2695 | |
---|
| 2696 | // redtailBBa against T for inhomogenous input |
---|
[cd4f24] | 2697 | // if (!TEST_OPT_OLDSTD) |
---|
| 2698 | // withT = ! strat->homog; |
---|
[83be980] | 2699 | |
---|
| 2700 | // strat->posInT = posInT_pLength; |
---|
[eb55f8a] | 2701 | kTest_TS(strat); |
---|
[83be980] | 2702 | |
---|
| 2703 | #ifdef HAVE_TAIL_RING |
---|
[fee33e] | 2704 | if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed |
---|
[83be980] | 2705 | kStratInitChangeTailRing(strat); |
---|
| 2706 | #endif |
---|
| 2707 | if (BVERBOSE(23)) |
---|
| 2708 | { |
---|
| 2709 | if (test_PosInT!=NULL) strat->posInT=test_PosInT; |
---|
| 2710 | if (test_PosInL!=NULL) strat->posInL=test_PosInL; |
---|
| 2711 | kDebugPrint(strat); |
---|
| 2712 | } |
---|
[f7bea2] | 2713 | // We add the elements directly in S from the previous loop |
---|
[094031] | 2714 | if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0) |
---|
| 2715 | { |
---|
| 2716 | for(int i = 0;i<strat->sbaEnterS;i++) |
---|
| 2717 | { |
---|
| 2718 | //Update: now the element is at the corect place |
---|
| 2719 | //i+1 because on the 0 position is the sigdrop element |
---|
| 2720 | enterT(strat->L[strat->Ll-(i)],strat); |
---|
| 2721 | strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl); |
---|
| 2722 | } |
---|
[780c1b] | 2723 | strat->Ll = strat->Ll - strat->sbaEnterS; |
---|
[094031] | 2724 | strat->sbaEnterS = -1; |
---|
| 2725 | } |
---|
| 2726 | kTest_TS(strat); |
---|
[83be980] | 2727 | #ifdef KDEBUG |
---|
| 2728 | //kDebugPrint(strat); |
---|
| 2729 | #endif |
---|
| 2730 | /* compute------------------------------------------------------- */ |
---|
| 2731 | while (strat->Ll >= 0) |
---|
| 2732 | { |
---|
| 2733 | if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/ |
---|
| 2734 | #ifdef KDEBUG |
---|
| 2735 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 2736 | #endif |
---|
| 2737 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
[e702ac2] | 2738 | /* |
---|
[83be980] | 2739 | if (TEST_OPT_DEGBOUND |
---|
[fee33e] | 2740 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 2741 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
[83be980] | 2742 | { |
---|
[fea494] | 2743 | |
---|
[e702ac2] | 2744 | //stops computation if |
---|
| 2745 | // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
| 2746 | //a predefined number Kstd1_deg |
---|
[83be980] | 2747 | while ((strat->Ll >= 0) |
---|
| 2748 | && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) |
---|
[fee33e] | 2749 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 2750 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))) |
---|
[83be980] | 2751 | ) |
---|
| 2752 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 2753 | if (strat->Ll<0) break; |
---|
| 2754 | else strat->noClearS=TRUE; |
---|
| 2755 | } |
---|
[e702ac2] | 2756 | */ |
---|
[f7f084] | 2757 | if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx) |
---|
[83be980] | 2758 | { |
---|
| 2759 | strat->currIdx = pGetComp(strat->L[strat->Ll].sig); |
---|
| 2760 | #if F5C |
---|
| 2761 | // 1. interreduction of the current standard basis |
---|
| 2762 | // 2. generation of new principal syzygy rules for syzCriterion |
---|
[601105] | 2763 | f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax, |
---|
[8fcfae] | 2764 | lrmax, reduc, Q, w, hilb ); |
---|
[83be980] | 2765 | #endif |
---|
[601105] | 2766 | // initialize new syzygy rules for the next iteration step |
---|
[83be980] | 2767 | initSyzRules(strat); |
---|
| 2768 | } |
---|
| 2769 | /********************************************************************* |
---|
[8fcfae] | 2770 | * interrreduction step is done, we can go on with the next iteration |
---|
| 2771 | * step of the signature-based algorithm |
---|
| 2772 | ********************************************************************/ |
---|
[83be980] | 2773 | /* picks the last element from the lazyset L */ |
---|
| 2774 | strat->P = strat->L[strat->Ll]; |
---|
| 2775 | strat->Ll--; |
---|
[780c1b] | 2776 | |
---|
[094031] | 2777 | if(rField_is_Ring(currRing)) |
---|
| 2778 | strat->sbaEnterS = pGetComp(strat->P.sig) - 1; |
---|
[88615db] | 2779 | /* reduction of the element chosen from L */ |
---|
[dcddf66] | 2780 | if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1)) |
---|
| 2781 | { |
---|
[8fcfae] | 2782 | //#if 1 |
---|
[83be980] | 2783 | #ifdef DEBUGF5 |
---|
[f9b0bd] | 2784 | PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n"); |
---|
| 2785 | PrintS("-------------------------------------------------\n"); |
---|
[8fcfae] | 2786 | pWrite(strat->P.sig); |
---|
| 2787 | pWrite(pHead(strat->P.p)); |
---|
| 2788 | pWrite(pHead(strat->P.p1)); |
---|
| 2789 | pWrite(pHead(strat->P.p2)); |
---|
[f9b0bd] | 2790 | PrintS("-------------------------------------------------\n"); |
---|
[83be980] | 2791 | #endif |
---|
[8fcfae] | 2792 | if (pNext(strat->P.p) == strat->tail) |
---|
| 2793 | { |
---|
| 2794 | // deletes the short spoly |
---|
[e702ac2] | 2795 | /* |
---|
[8fcfae] | 2796 | if (rField_is_Ring(currRing)) |
---|
| 2797 | pLmDelete(strat->P.p); |
---|
| 2798 | else |
---|
| 2799 | pLmFree(strat->P.p); |
---|
[e702ac2] | 2800 | */ |
---|
| 2801 | // TODO: needs some masking |
---|
| 2802 | // TODO: masking needs to vanish once the signature |
---|
| 2803 | // sutff is completely implemented |
---|
| 2804 | strat->P.p = NULL; |
---|
[8fcfae] | 2805 | poly m1 = NULL, m2 = NULL; |
---|
[83be980] | 2806 | |
---|
[8fcfae] | 2807 | // check that spoly creation is ok |
---|
| 2808 | while (strat->tailRing != currRing && |
---|
| 2809 | !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) |
---|
[83be980] | 2810 | { |
---|
[8fcfae] | 2811 | assume(m1 == NULL && m2 == NULL); |
---|
| 2812 | // if not, change to a ring where exponents are at least |
---|
| 2813 | // large enough |
---|
| 2814 | if (!kStratChangeTailRing(strat)) |
---|
| 2815 | { |
---|
| 2816 | WerrorS("OVERFLOW..."); |
---|
| 2817 | break; |
---|
| 2818 | } |
---|
[83be980] | 2819 | } |
---|
[8fcfae] | 2820 | // create the real one |
---|
| 2821 | ksCreateSpoly(&(strat->P), NULL, strat->use_buckets, |
---|
| 2822 | strat->tailRing, m1, m2, strat->R); |
---|
[83be980] | 2823 | |
---|
[8fcfae] | 2824 | } |
---|
| 2825 | else if (strat->P.p1 == NULL) |
---|
| 2826 | { |
---|
| 2827 | if (strat->minim > 0) |
---|
| 2828 | strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); |
---|
| 2829 | // for input polys, prepare reduction |
---|
[459ec94] | 2830 | if(!rField_is_Ring(currRing)) |
---|
| 2831 | strat->P.PrepareRed(strat->use_buckets); |
---|
[8fcfae] | 2832 | } |
---|
| 2833 | if (strat->P.p == NULL && strat->P.t_p == NULL) |
---|
| 2834 | { |
---|
| 2835 | red_result = 0; |
---|
| 2836 | } |
---|
| 2837 | else |
---|
| 2838 | { |
---|
| 2839 | //#if 1 |
---|
[83be980] | 2840 | #ifdef DEBUGF5 |
---|
[f9b0bd] | 2841 | PrintS("Poly before red: "); |
---|
[8fcfae] | 2842 | pWrite(pHead(strat->P.p)); |
---|
| 2843 | pWrite(strat->P.sig); |
---|
[83be980] | 2844 | #endif |
---|
[b3e94aa] | 2845 | #if SBA_PRODUCT_CRITERION |
---|
[dcddf66] | 2846 | if (strat->P.prod_crit) |
---|
| 2847 | { |
---|
[9408d9] | 2848 | #if SBA_PRINT_PRODUCT_CRITERION |
---|
[b3e94aa] | 2849 | product_criterion++; |
---|
[9408d9] | 2850 | #endif |
---|
[32f7e5] | 2851 | int pos = posInSyz(strat, strat->P.sig); |
---|
| 2852 | enterSyz(strat->P, strat, pos); |
---|
[3e5610] | 2853 | kDeleteLcm(&strat->P); |
---|
[b3e94aa] | 2854 | red_result = 2; |
---|
[dcddf66] | 2855 | } |
---|
| 2856 | else |
---|
| 2857 | { |
---|
[b3e94aa] | 2858 | red_result = strat->red(&strat->P,strat); |
---|
| 2859 | } |
---|
| 2860 | #else |
---|
[8fcfae] | 2861 | red_result = strat->red(&strat->P,strat); |
---|
[b3e94aa] | 2862 | #endif |
---|
[83be980] | 2863 | } |
---|
[dcddf66] | 2864 | } |
---|
| 2865 | else |
---|
| 2866 | { |
---|
[e702ac2] | 2867 | /* |
---|
| 2868 | if (strat->P.lcm != NULL) |
---|
| 2869 | pLmFree(strat->P.lcm); |
---|
| 2870 | */ |
---|
| 2871 | red_result = 2; |
---|
[83be980] | 2872 | } |
---|
[094031] | 2873 | if(rField_is_Ring(currRing)) |
---|
| 2874 | { |
---|
[459ec94] | 2875 | if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig))) |
---|
| 2876 | { |
---|
| 2877 | strat->P.p = pNeg(strat->P.p); |
---|
| 2878 | strat->P.sig = pNeg(strat->P.sig); |
---|
| 2879 | } |
---|
[094031] | 2880 | strat->P.pLength = pLength(strat->P.p); |
---|
| 2881 | if(strat->P.sig != NULL) |
---|
| 2882 | strat->P.sevSig = pGetShortExpVector(strat->P.sig); |
---|
| 2883 | if(strat->P.p != NULL) |
---|
| 2884 | strat->P.sev = pGetShortExpVector(strat->P.p); |
---|
| 2885 | } |
---|
| 2886 | //sigdrop case |
---|
| 2887 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
| 2888 | { |
---|
| 2889 | //First reduce it as much as one can |
---|
| 2890 | red_result = redRing(&strat->P,strat); |
---|
| 2891 | if(red_result == 0) |
---|
| 2892 | { |
---|
| 2893 | strat->sigdrop = FALSE; |
---|
[459ec94] | 2894 | pDelete(&strat->P.sig); |
---|
| 2895 | strat->P.sig = NULL; |
---|
[094031] | 2896 | } |
---|
| 2897 | else |
---|
| 2898 | { |
---|
| 2899 | strat->enterS(strat->P, 0, strat, strat->tl); |
---|
[11416e] | 2900 | if (TEST_OPT_PROT) |
---|
| 2901 | PrintS("-"); |
---|
[094031] | 2902 | break; |
---|
| 2903 | } |
---|
| 2904 | } |
---|
[e40da9f] | 2905 | if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax) |
---|
[7d2b89] | 2906 | { |
---|
| 2907 | strat->sigdrop = TRUE; |
---|
| 2908 | break; |
---|
| 2909 | } |
---|
[780c1b] | 2910 | |
---|
[e702ac2] | 2911 | if (errorreported) break; |
---|
| 2912 | |
---|
| 2913 | //#if 1 |
---|
| 2914 | #ifdef DEBUGF5 |
---|
[dcddf66] | 2915 | if (red_result != 0) |
---|
| 2916 | { |
---|
[f9b0bd] | 2917 | PrintS("Poly after red: "); |
---|
[e702ac2] | 2918 | pWrite(pHead(strat->P.p)); |
---|
| 2919 | pWrite(strat->P.GetLmCurrRing()); |
---|
| 2920 | pWrite(strat->P.sig); |
---|
| 2921 | printf("%d\n",red_result); |
---|
| 2922 | } |
---|
| 2923 | #endif |
---|
[11416e] | 2924 | if (TEST_OPT_PROT) |
---|
| 2925 | { |
---|
| 2926 | if(strat->P.p != NULL) |
---|
| 2927 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
| 2928 | &olddeg,&reduc,strat, red_result); |
---|
| 2929 | else |
---|
| 2930 | message((strat->honey ? strat->P.ecart : 0), |
---|
| 2931 | &olddeg,&reduc,strat, red_result); |
---|
| 2932 | } |
---|
[83be980] | 2933 | |
---|
| 2934 | if (strat->overflow) |
---|
| 2935 | { |
---|
[7b9b8e5] | 2936 | if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;} |
---|
[83be980] | 2937 | } |
---|
| 2938 | // reduction to non-zero new poly |
---|
| 2939 | if (red_result == 1) |
---|
| 2940 | { |
---|
| 2941 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 2942 | strat->P.GetP(strat->lmBin); |
---|
[601105] | 2943 | |
---|
| 2944 | // sig-safe computations may lead to wrong FDeg computation, thus we need |
---|
[83be980] | 2945 | // to recompute it to make sure everything is alright |
---|
| 2946 | (strat->P).FDeg = (strat->P).pFDeg(); |
---|
| 2947 | // in the homogeneous case FDeg >= pFDeg (sugar/honey) |
---|
| 2948 | // but now, for entering S, T, we reset it |
---|
| 2949 | // in the inhomogeneous case: FDeg == pFDeg |
---|
| 2950 | if (strat->homog) strat->initEcart(&(strat->P)); |
---|
| 2951 | |
---|
| 2952 | /* statistic */ |
---|
| 2953 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 2954 | |
---|
| 2955 | //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 2956 | // in F5E we know that the last reduced element is already the |
---|
| 2957 | // the one with highest signature |
---|
| 2958 | int pos = strat->sl+1; |
---|
| 2959 | |
---|
| 2960 | // reduce the tail and normalize poly |
---|
| 2961 | // in the ring case we cannot expect LC(f) = 1, |
---|
[24bc73] | 2962 | // therefore we call pCleardenom instead of pNorm |
---|
[094031] | 2963 | #ifdef HAVE_RINGS |
---|
| 2964 | poly beforetailred; |
---|
| 2965 | if(rField_is_Ring(currRing)) |
---|
| 2966 | beforetailred = pCopy(strat->P.sig); |
---|
| 2967 | #endif |
---|
[b085fba] | 2968 | #if SBA_TAIL_RED |
---|
[094031] | 2969 | if(rField_is_Ring(currRing)) |
---|
[780c1b] | 2970 | { |
---|
[094031] | 2971 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 2972 | strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); |
---|
| 2973 | } |
---|
| 2974 | else |
---|
| 2975 | { |
---|
[dcddf66] | 2976 | if (strat->sbaOrder != 2) |
---|
| 2977 | { |
---|
[094031] | 2978 | if (TEST_OPT_INTSTRATEGY) |
---|
[e702ac2] | 2979 | { |
---|
| 2980 | strat->P.pCleardenom(); |
---|
[094031] | 2981 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 2982 | { |
---|
| 2983 | strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); |
---|
| 2984 | strat->P.pCleardenom(); |
---|
| 2985 | } |
---|
| 2986 | } |
---|
| 2987 | else |
---|
| 2988 | { |
---|
| 2989 | strat->P.pNorm(); |
---|
| 2990 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 2991 | strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); |
---|
[e702ac2] | 2992 | } |
---|
| 2993 | } |
---|
[094031] | 2994 | } |
---|
| 2995 | // It may happen that we have lost the sig in redtailsba |
---|
[780c1b] | 2996 | // It cannot reduce to 0 since here we are doing just tail reduction. |
---|
[094031] | 2997 | // Best case scenerio: remains the leading term |
---|
[780c1b] | 2998 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
[094031] | 2999 | { |
---|
| 3000 | strat->enterS(strat->P, 0, strat, strat->tl); |
---|
| 3001 | break; |
---|
| 3002 | } |
---|
| 3003 | #endif |
---|
| 3004 | if(rField_is_Ring(currRing)) |
---|
| 3005 | { |
---|
| 3006 | if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1) |
---|
| 3007 | { |
---|
| 3008 | strat->sigdrop = TRUE; |
---|
| 3009 | //Reduce it as much as you can |
---|
| 3010 | red_result = redRing(&strat->P,strat); |
---|
| 3011 | if(red_result == 0) |
---|
| 3012 | { |
---|
| 3013 | //It reduced to 0, cancel the sigdrop |
---|
| 3014 | strat->sigdrop = FALSE; |
---|
| 3015 | p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL; |
---|
| 3016 | } |
---|
[e702ac2] | 3017 | else |
---|
| 3018 | { |
---|
[094031] | 3019 | strat->enterS(strat->P, 0, strat, strat->tl); |
---|
| 3020 | break; |
---|
[83be980] | 3021 | } |
---|
| 3022 | } |
---|
[094031] | 3023 | p_Delete(&beforetailred,currRing); |
---|
[530cc55] | 3024 | // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing |
---|
| 3025 | if(strat->P.p == NULL) |
---|
| 3026 | goto case_when_red_result_changed; |
---|
[094031] | 3027 | } |
---|
[576f5b] | 3028 | // remove sigsafe label since it is no longer valid for the next element to |
---|
| 3029 | // be reduced |
---|
[f7f084] | 3030 | if (strat->sbaOrder == 1) |
---|
[576f5b] | 3031 | { |
---|
| 3032 | for (int jj = 0; jj<strat->tl+1; jj++) |
---|
[83be980] | 3033 | { |
---|
[576f5b] | 3034 | if (pGetComp(strat->T[jj].sig) == strat->currIdx) |
---|
| 3035 | { |
---|
| 3036 | strat->T[jj].is_sigsafe = FALSE; |
---|
| 3037 | } |
---|
[83be980] | 3038 | } |
---|
[576f5b] | 3039 | } |
---|
| 3040 | else |
---|
| 3041 | { |
---|
| 3042 | for (int jj = 0; jj<strat->tl+1; jj++) |
---|
| 3043 | { |
---|
| 3044 | strat->T[jj].is_sigsafe = FALSE; |
---|
| 3045 | } |
---|
| 3046 | } |
---|
[83be980] | 3047 | #ifdef KDEBUG |
---|
| 3048 | if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} |
---|
| 3049 | #endif /* KDEBUG */ |
---|
| 3050 | |
---|
| 3051 | // min_std stuff |
---|
| 3052 | if ((strat->P.p1==NULL) && (strat->minim>0)) |
---|
| 3053 | { |
---|
| 3054 | if (strat->minim==1) |
---|
| 3055 | { |
---|
| 3056 | strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); |
---|
| 3057 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 3058 | } |
---|
| 3059 | else |
---|
| 3060 | { |
---|
| 3061 | strat->M->m[minimcnt]=strat->P.p2; |
---|
| 3062 | strat->P.p2=NULL; |
---|
| 3063 | } |
---|
| 3064 | if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) |
---|
| 3065 | pNext(strat->M->m[minimcnt]) |
---|
| 3066 | = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), |
---|
| 3067 | strat->tailRing, currRing, |
---|
| 3068 | currRing->PolyBin); |
---|
| 3069 | minimcnt++; |
---|
| 3070 | } |
---|
| 3071 | |
---|
| 3072 | // enter into S, L, and T |
---|
| 3073 | //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) |
---|
[2b691c] | 3074 | enterT(strat->P, strat); |
---|
| 3075 | strat->T[strat->tl].is_sigsafe = FALSE; |
---|
[e702ac2] | 3076 | /* |
---|
| 3077 | printf("hier\n"); |
---|
| 3078 | pWrite(strat->P.GetLmCurrRing()); |
---|
| 3079 | pWrite(strat->P.sig); |
---|
| 3080 | */ |
---|
[2b691c] | 3081 | if (rField_is_Ring(currRing)) |
---|
[094031] | 3082 | superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
[2b691c] | 3083 | else |
---|
| 3084 | enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
[094031] | 3085 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
| 3086 | break; |
---|
[e40da9f] | 3087 | if(rField_is_Ring(currRing)) |
---|
| 3088 | strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing); |
---|
[2b691c] | 3089 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
| 3090 | if(strat->sbaOrder != 1) |
---|
[83be980] | 3091 | { |
---|
[d5856f] | 3092 | BOOLEAN overwrite = FALSE; |
---|
[83be980] | 3093 | for (int tk=0; tk<strat->sl+1; tk++) |
---|
| 3094 | { |
---|
| 3095 | if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig)) |
---|
| 3096 | { |
---|
| 3097 | //printf("TK %d / %d\n",tk,strat->sl); |
---|
| 3098 | overwrite = FALSE; |
---|
| 3099 | break; |
---|
| 3100 | } |
---|
| 3101 | } |
---|
| 3102 | //printf("OVERWRITE %d\n",overwrite); |
---|
| 3103 | if (overwrite) |
---|
| 3104 | { |
---|
| 3105 | int cmp = pGetComp(strat->P.sig); |
---|
| 3106 | int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int)); |
---|
[ea0d5e] | 3107 | p_GetExpV (strat->P.p,vv,currRing); |
---|
| 3108 | p_SetExpV (strat->P.sig, vv,currRing); |
---|
| 3109 | p_SetComp (strat->P.sig,cmp,currRing); |
---|
[83be980] | 3110 | |
---|
| 3111 | strat->P.sevSig = pGetShortExpVector (strat->P.sig); |
---|
[cda0b0] | 3112 | int i; |
---|
[d5856f] | 3113 | LObject Q; |
---|
[83be980] | 3114 | for(int ps=0;ps<strat->sl+1;ps++) |
---|
| 3115 | { |
---|
| 3116 | |
---|
| 3117 | strat->newt = TRUE; |
---|
| 3118 | if (strat->syzl == strat->syzmax) |
---|
| 3119 | { |
---|
| 3120 | pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc); |
---|
| 3121 | strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz, |
---|
| 3122 | (strat->syzmax)*sizeof(unsigned long), |
---|
| 3123 | ((strat->syzmax)+setmaxTinc) |
---|
| 3124 | *sizeof(unsigned long)); |
---|
| 3125 | strat->syzmax += setmaxTinc; |
---|
| 3126 | } |
---|
[cda0b0] | 3127 | Q.sig = pCopy(strat->P.sig); |
---|
[83be980] | 3128 | // add LM(F->m[i]) to the signature to get a Schreyer order |
---|
| 3129 | // without changing the underlying polynomial ring at all |
---|
[cda0b0] | 3130 | if (strat->sbaOrder == 0) |
---|
| 3131 | p_ExpVectorAdd (Q.sig,strat->S[ps],currRing); |
---|
[83be980] | 3132 | // since p_Add_q() destroys all input |
---|
[601105] | 3133 | // data we need to recreate help |
---|
[83be980] | 3134 | // each time |
---|
| 3135 | // ---------------------------------------------------------- |
---|
[601105] | 3136 | // in the Schreyer order we always know that the multiplied |
---|
[83be980] | 3137 | // module monomial strat->P.sig gives the leading monomial of |
---|
| 3138 | // the corresponding principal syzygy |
---|
| 3139 | // => we do not need to compute the "real" syzygy completely |
---|
[cc6544] | 3140 | poly help = p_Copy(strat->sig[ps],currRing); |
---|
[601105] | 3141 | p_ExpVectorAdd (help,strat->P.p,currRing); |
---|
[cda0b0] | 3142 | Q.sig = p_Add_q(Q.sig,help,currRing); |
---|
[83be980] | 3143 | //printf("%d. SYZ ",i+1); |
---|
| 3144 | //pWrite(strat->syz[i]); |
---|
[cda0b0] | 3145 | Q.sevSig = p_GetShortExpVector(Q.sig,currRing); |
---|
| 3146 | i = posInSyz(strat, Q.sig); |
---|
| 3147 | enterSyz(Q, strat, i); |
---|
[83be980] | 3148 | } |
---|
| 3149 | } |
---|
| 3150 | } |
---|
[cda0b0] | 3151 | // deg - idx - lp/rp |
---|
| 3152 | // => we need to add syzygies with indices > pGetComp(strat->P.sig) |
---|
[cc6544] | 3153 | if(strat->sbaOrder == 0 || strat->sbaOrder == 3) |
---|
[cda0b0] | 3154 | { |
---|
[d5856f] | 3155 | int cmp = pGetComp(strat->P.sig); |
---|
[eb1f43] | 3156 | unsigned max_cmp = IDELEMS(F); |
---|
[d5856f] | 3157 | int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int)); |
---|
[ea0d5e] | 3158 | p_GetExpV (strat->P.p,vv,currRing); |
---|
[d5856f] | 3159 | LObject Q; |
---|
| 3160 | int pos; |
---|
[dcddf66] | 3161 | int idx = __p_GetComp(strat->P.sig,currRing); |
---|
[cc6544] | 3162 | //printf("++ -- adding syzygies -- ++\n"); |
---|
| 3163 | // if new element is the first one in this index |
---|
[dcddf66] | 3164 | if (strat->currIdx < idx) |
---|
| 3165 | { |
---|
| 3166 | for (int i=0; i<strat->sl; ++i) |
---|
| 3167 | { |
---|
[cc6544] | 3168 | Q.sig = p_Copy(strat->P.sig,currRing); |
---|
| 3169 | p_ExpVectorAdd(Q.sig,strat->S[i],currRing); |
---|
| 3170 | poly help = p_Copy(strat->sig[i],currRing); |
---|
| 3171 | p_ExpVectorAdd(help,strat->P.p,currRing); |
---|
| 3172 | Q.sig = p_Add_q(Q.sig,help,currRing); |
---|
| 3173 | //pWrite(Q.sig); |
---|
| 3174 | pos = posInSyz(strat, Q.sig); |
---|
| 3175 | enterSyz(Q, strat, pos); |
---|
| 3176 | } |
---|
| 3177 | strat->currIdx = idx; |
---|
[dcddf66] | 3178 | } |
---|
| 3179 | else |
---|
| 3180 | { |
---|
[cc6544] | 3181 | // if the element is not the first one in the given index we build all |
---|
| 3182 | // possible syzygies with elements of higher index |
---|
[eb1f43] | 3183 | for (unsigned i=cmp+1; i<=max_cmp; ++i) |
---|
[dcddf66] | 3184 | { |
---|
[cc6544] | 3185 | pos = -1; |
---|
[dcddf66] | 3186 | for (int j=0; j<strat->sl; ++j) |
---|
| 3187 | { |
---|
| 3188 | if (__p_GetComp(strat->sig[j],currRing) == i) |
---|
| 3189 | { |
---|
[cc6544] | 3190 | pos = j; |
---|
| 3191 | break; |
---|
| 3192 | } |
---|
| 3193 | } |
---|
[dcddf66] | 3194 | if (pos != -1) |
---|
| 3195 | { |
---|
[cc6544] | 3196 | Q.sig = p_One(currRing); |
---|
| 3197 | p_SetExpV(Q.sig, vv, currRing); |
---|
| 3198 | // F->m[i-1] corresponds to index i |
---|
| 3199 | p_ExpVectorAdd(Q.sig,F->m[i-1],currRing); |
---|
| 3200 | p_SetComp(Q.sig, i, currRing); |
---|
| 3201 | poly help = p_Copy(strat->P.sig,currRing); |
---|
| 3202 | p_ExpVectorAdd(help,strat->S[pos],currRing); |
---|
| 3203 | Q.sig = p_Add_q(Q.sig,help,currRing); |
---|
[dcddf66] | 3204 | if (strat->sbaOrder == 0) |
---|
| 3205 | { |
---|
| 3206 | if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn) |
---|
| 3207 | { |
---|
[c4279b] | 3208 | pos = posInSyz(strat, Q.sig); |
---|
| 3209 | enterSyz(Q, strat, pos); |
---|
| 3210 | } |
---|
[dcddf66] | 3211 | } |
---|
| 3212 | else |
---|
| 3213 | { |
---|
[cc6544] | 3214 | pos = posInSyz(strat, Q.sig); |
---|
| 3215 | enterSyz(Q, strat, pos); |
---|
| 3216 | } |
---|
| 3217 | } |
---|
| 3218 | } |
---|
| 3219 | //printf("++ -- done adding syzygies -- ++\n"); |
---|
[83be980] | 3220 | } |
---|
| 3221 | } |
---|
| 3222 | //#if 1 |
---|
| 3223 | #if DEBUGF50 |
---|
| 3224 | printf("---------------------------\n"); |
---|
| 3225 | Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1); |
---|
[f9b0bd] | 3226 | PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl])); |
---|
| 3227 | PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]); |
---|
[83be980] | 3228 | #endif |
---|
| 3229 | /* |
---|
| 3230 | if (newrules) |
---|
| 3231 | { |
---|
| 3232 | newrules = FALSE; |
---|
| 3233 | } |
---|
| 3234 | */ |
---|
| 3235 | #if 0 |
---|
| 3236 | int pl=pLength(strat->P.p); |
---|
| 3237 | if (pl==1) |
---|
| 3238 | { |
---|
| 3239 | //if (TEST_OPT_PROT) |
---|
| 3240 | //PrintS("<1>"); |
---|
| 3241 | } |
---|
| 3242 | else if (pl==2) |
---|
| 3243 | { |
---|
| 3244 | //if (TEST_OPT_PROT) |
---|
| 3245 | //PrintS("<2>"); |
---|
| 3246 | } |
---|
| 3247 | #endif |
---|
| 3248 | if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 3249 | // Print("[%d]",hilbeledeg); |
---|
[3e5610] | 3250 | kDeleteLcm(&strat->P); |
---|
[83be980] | 3251 | if (strat->sl>srmax) srmax = strat->sl; |
---|
| 3252 | } |
---|
| 3253 | else |
---|
| 3254 | { |
---|
[530cc55] | 3255 | case_when_red_result_changed: |
---|
[83be980] | 3256 | // adds signature of the zero reduction to |
---|
| 3257 | // strat->syz. This is the leading term of |
---|
| 3258 | // syzygy and can be used in syzCriterion() |
---|
| 3259 | // the signature is added if and only if the |
---|
| 3260 | // pair was not detected by the rewritten criterion in strat->red = redSig |
---|
[dcddf66] | 3261 | if (red_result!=2) |
---|
| 3262 | { |
---|
[6d77472] | 3263 | #if SBA_PRINT_ZERO_REDUCTIONS |
---|
[83be980] | 3264 | zeroreductions++; |
---|
[6d77472] | 3265 | #endif |
---|
[094031] | 3266 | if(rField_is_Ring(currRing) && strat->P.p == NULL && strat->P.sig == NULL) |
---|
| 3267 | { |
---|
| 3268 | //Catch the case when p = 0, sig = 0 |
---|
| 3269 | } |
---|
| 3270 | else |
---|
| 3271 | { |
---|
| 3272 | int pos = posInSyz(strat, strat->P.sig); |
---|
| 3273 | enterSyz(strat->P, strat, pos); |
---|
| 3274 | //#if 1 |
---|
| 3275 | #ifdef DEBUGF5 |
---|
| 3276 | Print("ADDING STUFF TO SYZ : "); |
---|
| 3277 | //pWrite(strat->P.p); |
---|
| 3278 | pWrite(strat->P.sig); |
---|
| 3279 | #endif |
---|
| 3280 | } |
---|
[83be980] | 3281 | } |
---|
| 3282 | if (strat->P.p1 == NULL && strat->minim > 0) |
---|
| 3283 | { |
---|
| 3284 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 3285 | } |
---|
| 3286 | } |
---|
| 3287 | |
---|
| 3288 | #ifdef KDEBUG |
---|
| 3289 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 3290 | #endif /* KDEBUG */ |
---|
[eb55f8a] | 3291 | kTest_TS(strat); |
---|
[83be980] | 3292 | } |
---|
[094031] | 3293 | #if 0 |
---|
| 3294 | if(strat->sigdrop) |
---|
| 3295 | printf("\nSigDrop!\n"); |
---|
| 3296 | else |
---|
| 3297 | printf("\nEnded with no SigDrop\n"); |
---|
| 3298 | #endif |
---|
| 3299 | // Clean strat->P for the next sba call |
---|
| 3300 | if(rField_is_Ring(currRing) && strat->sigdrop) |
---|
| 3301 | { |
---|
| 3302 | //This is used to know how many elements can we directly add to S in the next run |
---|
| 3303 | if(strat->P.sig != NULL) |
---|
| 3304 | strat->sbaEnterS = pGetComp(strat->P.sig)-1; |
---|
| 3305 | //else we already set it at the beggining of the loop |
---|
| 3306 | #ifdef KDEBUG |
---|
| 3307 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 3308 | #endif /* KDEBUG */ |
---|
| 3309 | } |
---|
[83be980] | 3310 | #ifdef KDEBUG |
---|
| 3311 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 3312 | #endif /* KDEBUG */ |
---|
| 3313 | |
---|
| 3314 | if (TEST_OPT_SB_1) |
---|
| 3315 | { |
---|
[9927b9e] | 3316 | if(!rField_is_Ring(currRing)) |
---|
[83be980] | 3317 | { |
---|
[e6f1e6] | 3318 | int k=1; |
---|
| 3319 | int j; |
---|
| 3320 | while(k<=strat->sl) |
---|
| 3321 | { |
---|
| 3322 | j=0; |
---|
| 3323 | loop |
---|
[c96539c] | 3324 | { |
---|
[e6f1e6] | 3325 | if (j>=k) break; |
---|
| 3326 | clearS(strat->S[j],strat->sevS[j],&k,&j,strat); |
---|
| 3327 | j++; |
---|
[c96539c] | 3328 | } |
---|
[e6f1e6] | 3329 | k++; |
---|
| 3330 | } |
---|
[83be980] | 3331 | } |
---|
| 3332 | } |
---|
| 3333 | /* complete reduction of the standard basis--------- */ |
---|
| 3334 | if (TEST_OPT_REDSB) |
---|
| 3335 | { |
---|
| 3336 | completeReduce(strat); |
---|
| 3337 | if (strat->completeReduce_retry) |
---|
| 3338 | { |
---|
| 3339 | // completeReduce needed larger exponents, retry |
---|
| 3340 | // to reduce with S (instead of T) |
---|
| 3341 | // and in currRing (instead of strat->tailRing) |
---|
[349e5e8] | 3342 | #ifdef HAVE_TAIL_RING |
---|
| 3343 | if(currRing->bitmask>strat->tailRing->bitmask) |
---|
| 3344 | { |
---|
| 3345 | strat->completeReduce_retry=FALSE; |
---|
| 3346 | cleanT(strat);strat->tailRing=currRing; |
---|
| 3347 | int i; |
---|
| 3348 | for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1; |
---|
| 3349 | completeReduce(strat); |
---|
| 3350 | } |
---|
| 3351 | if (strat->completeReduce_retry) |
---|
[83be980] | 3352 | #endif |
---|
[349e5e8] | 3353 | Werror("exponent bound is %ld",currRing->bitmask); |
---|
| 3354 | } |
---|
[83be980] | 3355 | } |
---|
| 3356 | else if (TEST_OPT_PROT) PrintLn(); |
---|
| 3357 | |
---|
[b3e94aa] | 3358 | #if SBA_PRINT_SIZE_SYZ |
---|
[32f7e5] | 3359 | // that is correct, syzl is counting one too far |
---|
| 3360 | size_syz = strat->syzl; |
---|
[b3e94aa] | 3361 | #endif |
---|
[fee33e] | 3362 | // if (TEST_OPT_WEIGHTM) |
---|
| 3363 | // { |
---|
| 3364 | // pRestoreDegProcs(pFDegOld, pLDegOld); |
---|
| 3365 | // if (ecartWeights) |
---|
| 3366 | // { |
---|
| 3367 | // omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short)); |
---|
| 3368 | // ecartWeights=NULL; |
---|
| 3369 | // } |
---|
| 3370 | // } |
---|
[11416e] | 3371 | if (TEST_OPT_PROT) messageStatSBA(hilbcount,strat); |
---|
[83be980] | 3372 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
[2ce53d] | 3373 | #if SBA_PRINT_SIZE_G |
---|
| 3374 | size_g_non_red = IDELEMS(strat->Shdl); |
---|
[83be980] | 3375 | #endif |
---|
[7d1e80] | 3376 | if(!rField_is_Ring(currRing)) |
---|
| 3377 | exitSba(strat); |
---|
[094031] | 3378 | // I have to add the initial input polynomials which where not used (p1 and p2 = NULL) |
---|
| 3379 | #ifdef HAVE_RINGS |
---|
| 3380 | int k; |
---|
| 3381 | if(rField_is_Ring(currRing)) |
---|
| 3382 | { |
---|
| 3383 | //for(k = strat->sl;k>=0;k--) |
---|
| 3384 | // {printf("\nS[%i] = %p\n",k,strat->Shdl->m[k]);pWrite(strat->Shdl->m[k]);} |
---|
| 3385 | k = strat->Ll; |
---|
| 3386 | #if 1 |
---|
| 3387 | // 1 - adds just the unused ones, 0 - adds everthing |
---|
| 3388 | for(;k>=0 && (strat->L[k].p1 != NULL || strat->L[k].p2 != NULL);k--) |
---|
| 3389 | { |
---|
| 3390 | //printf("\nDeleted k = %i, %p\n",k,strat->L[k].p);pWrite(strat->L[k].p);pWrite(strat->L[k].p1);pWrite(strat->L[k].p2); |
---|
| 3391 | deleteInL(strat->L,&strat->Ll,k,strat); |
---|
| 3392 | } |
---|
| 3393 | #endif |
---|
| 3394 | //for(int kk = strat->sl;kk>=0;kk--) |
---|
| 3395 | // {printf("\nS[%i] = %p\n",kk,strat->Shdl->m[kk]);pWrite(strat->Shdl->m[kk]);} |
---|
| 3396 | //idPrint(strat->Shdl); |
---|
| 3397 | //printf("\nk = %i\n",k); |
---|
| 3398 | for(;k>=0 && strat->L[k].p1 == NULL && strat->L[k].p2 == NULL;k--) |
---|
| 3399 | { |
---|
| 3400 | //printf("\nAdded k = %i\n",k); |
---|
| 3401 | strat->enterS(strat->L[k], strat->sl+1, strat, strat->tl); |
---|
| 3402 | //printf("\nThis elements was added from L on pos %i\n",strat->sl);pWrite(strat->S[strat->sl]);pWrite(strat->sig[strat->sl]); |
---|
| 3403 | } |
---|
| 3404 | } |
---|
| 3405 | // Find the "sigdrop element" and put the same signature as the previous one - do we really need this?? - now i put it on the 0 position - no more comparing needed |
---|
| 3406 | #if 0 |
---|
| 3407 | if(strat->sigdrop && rField_is_Ring(currRing)) |
---|
| 3408 | { |
---|
| 3409 | for(k=strat->sl;k>=0;k--) |
---|
| 3410 | { |
---|
| 3411 | printf("\nsig[%i] = ",i);pWrite(strat->sig[k]); |
---|
| 3412 | if(strat->sig[k] == NULL) |
---|
| 3413 | strat->sig[k] = pCopy(strat->sig[k-1]); |
---|
| 3414 | } |
---|
| 3415 | } |
---|
| 3416 | #endif |
---|
| 3417 | #endif |
---|
| 3418 | //Never do this - you will damage S |
---|
| 3419 | //idSkipZeroes(strat->Shdl); |
---|
| 3420 | //idPrint(strat->Shdl); |
---|
[780c1b] | 3421 | |
---|
[d11734] | 3422 | if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld) |
---|
[83be980] | 3423 | { |
---|
| 3424 | rChangeCurrRing (currRingOld); |
---|
[493cf3d] | 3425 | F0 = idrMoveR (F1, sRing, currRing); |
---|
[fee33e] | 3426 | strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing); |
---|
[094031] | 3427 | rChangeCurrRing (sRing); |
---|
[7d1e80] | 3428 | if(rField_is_Ring(currRing)) |
---|
| 3429 | exitSba(strat); |
---|
[094031] | 3430 | rChangeCurrRing (currRingOld); |
---|
[042a24] | 3431 | if(strat->tailRing == sRing) |
---|
| 3432 | strat->tailRing = currRing; |
---|
[83be980] | 3433 | rDelete (sRing); |
---|
| 3434 | } |
---|
[094031] | 3435 | if(rField_is_Ring(currRing) && !strat->sigdrop) |
---|
| 3436 | id_DelDiv(strat->Shdl, currRing); |
---|
[7d1e80] | 3437 | if(!rField_is_Ring(currRing)) |
---|
| 3438 | id_DelDiv(strat->Shdl, currRing); |
---|
[2ce53d] | 3439 | idSkipZeroes(strat->Shdl); |
---|
[83be980] | 3440 | idTest(strat->Shdl); |
---|
| 3441 | |
---|
[2ce53d] | 3442 | #if SBA_PRINT_SIZE_G |
---|
| 3443 | size_g = IDELEMS(strat->Shdl); |
---|
| 3444 | #endif |
---|
[83be980] | 3445 | #ifdef DEBUGF5 |
---|
| 3446 | printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl)); |
---|
| 3447 | int oo = 0; |
---|
| 3448 | while (oo<IDELEMS(strat->Shdl)) |
---|
| 3449 | { |
---|
| 3450 | printf(" %d. ",oo+1); |
---|
| 3451 | pWrite(pHead(strat->Shdl->m[oo])); |
---|
| 3452 | oo++; |
---|
| 3453 | } |
---|
| 3454 | #endif |
---|
[b3e94aa] | 3455 | #if SBA_PRINT_ZERO_REDUCTIONS |
---|
[f59aaa] | 3456 | printf("----------------------------------------------------------\n"); |
---|
| 3457 | printf("ZERO REDUCTIONS: %ld\n",zeroreductions); |
---|
[6d77472] | 3458 | zeroreductions = 0; |
---|
[b3e94aa] | 3459 | #endif |
---|
[f9d20d7] | 3460 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 3461 | printf("----------------------------------------------------------\n"); |
---|
[6d77472] | 3462 | printf("S-REDUCTIONS: %ld\n",sba_reduction_steps); |
---|
[f59aaa] | 3463 | #endif |
---|
| 3464 | #if SBA_PRINT_OPERATIONS |
---|
| 3465 | printf("OPERATIONS: %ld\n",sba_operations); |
---|
| 3466 | #endif |
---|
[6d77472] | 3467 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 3468 | printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n"); |
---|
| 3469 | printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps); |
---|
| 3470 | #endif |
---|
[2b691c] | 3471 | #if SBA_PRINT_OPERATIONS |
---|
[f59aaa] | 3472 | printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations); |
---|
| 3473 | #endif |
---|
[6d77472] | 3474 | #if SBA_PRINT_REDUCTION_STEPS |
---|
[f59aaa] | 3475 | printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n"); |
---|
| 3476 | printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps); |
---|
[6d77472] | 3477 | sba_interreduction_steps = 0; |
---|
| 3478 | sba_reduction_steps = 0; |
---|
[f9d20d7] | 3479 | #endif |
---|
[6d77472] | 3480 | #if SBA_PRINT_OPERATIONS |
---|
[f59aaa] | 3481 | printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations); |
---|
[6d77472] | 3482 | sba_interreduction_operations = 0; |
---|
| 3483 | sba_operations = 0; |
---|
[f9d20d7] | 3484 | #endif |
---|
[b3e94aa] | 3485 | #if SBA_PRINT_SIZE_G |
---|
[f59aaa] | 3486 | printf("----------------------------------------------------------\n"); |
---|
[2ce53d] | 3487 | printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red); |
---|
| 3488 | size_g = 0; |
---|
| 3489 | size_g_non_red = 0; |
---|
[b3e94aa] | 3490 | #endif |
---|
| 3491 | #if SBA_PRINT_SIZE_SYZ |
---|
[f59aaa] | 3492 | printf("SIZE OF SYZ: %ld\n",size_syz); |
---|
| 3493 | printf("----------------------------------------------------------\n"); |
---|
[6d77472] | 3494 | size_syz = 0; |
---|
[b3e94aa] | 3495 | #endif |
---|
| 3496 | #if SBA_PRINT_PRODUCT_CRITERION |
---|
[f59aaa] | 3497 | printf("PRODUCT CRITERIA: %ld\n",product_criterion); |
---|
[6d77472] | 3498 | product_criterion = 0; |
---|
[b3e94aa] | 3499 | #endif |
---|
[83be980] | 3500 | return (strat->Shdl); |
---|
| 3501 | } |
---|
| 3502 | |
---|
| 3503 | poly kNF2 (ideal F,ideal Q,poly q,kStrategy strat, int lazyReduce) |
---|
| 3504 | { |
---|
| 3505 | assume(q!=NULL); |
---|
| 3506 | assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring? |
---|
| 3507 | |
---|
| 3508 | // lazy_reduce flags: can be combined by | |
---|
| 3509 | //#define KSTD_NF_LAZY 1 |
---|
| 3510 | // do only a reduction of the leading term |
---|
| 3511 | //#define KSTD_NF_NONORM 4 |
---|
| 3512 | // only global: avoid normalization, return a multiply of NF |
---|
| 3513 | poly p; |
---|
| 3514 | |
---|
| 3515 | //if ((idIs0(F))&&(Q==NULL)) |
---|
| 3516 | // return pCopy(q); /*F=0*/ |
---|
| 3517 | //strat->ak = idRankFreeModule(F); |
---|
| 3518 | /*- creating temp data structures------------------- -*/ |
---|
[d30a399] | 3519 | BITSET save1; |
---|
| 3520 | SI_SAVE_OPT1(save1); |
---|
| 3521 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
[83be980] | 3522 | initBuchMoraCrit(strat); |
---|
| 3523 | strat->initEcart = initEcartBBA; |
---|
[52bcb9] | 3524 | #ifdef HAVE_SHIFTBBA |
---|
[a1ffca6] | 3525 | if (rIsLPRing(currRing)) |
---|
[52bcb9] | 3526 | { |
---|
| 3527 | strat->enterS = enterSBbaShift; |
---|
| 3528 | } |
---|
| 3529 | else |
---|
| 3530 | #endif |
---|
| 3531 | { |
---|
| 3532 | strat->enterS = enterSBba; |
---|
| 3533 | } |
---|
[83be980] | 3534 | #ifndef NO_BUCKETS |
---|
| 3535 | strat->use_buckets = (!TEST_OPT_NOT_BUCKETS) && (!rIsPluralRing(currRing)); |
---|
| 3536 | #endif |
---|
| 3537 | /*- set S -*/ |
---|
| 3538 | strat->sl = -1; |
---|
| 3539 | /*- init local data struct.---------------------------------------- -*/ |
---|
| 3540 | /*Shdl=*/initS(F,Q,strat); |
---|
| 3541 | /*- compute------------------------------------------------------- -*/ |
---|
| 3542 | //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0)) |
---|
| 3543 | //{ |
---|
| 3544 | // for (i=strat->sl;i>=0;i--) |
---|
| 3545 | // pNorm(strat->S[i]); |
---|
| 3546 | //} |
---|
[eb55f8a] | 3547 | kTest(strat); |
---|
[83be980] | 3548 | if (TEST_OPT_PROT) { PrintS("r"); mflush(); } |
---|
| 3549 | if (BVERBOSE(23)) kDebugPrint(strat); |
---|
| 3550 | int max_ind; |
---|
| 3551 | p = redNF(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat); |
---|
| 3552 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
| 3553 | { |
---|
| 3554 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 3555 | if (rField_is_Ring(currRing)) |
---|
| 3556 | { |
---|
| 3557 | p = redtailBba_Z(p,max_ind,strat); |
---|
| 3558 | } |
---|
| 3559 | else |
---|
| 3560 | { |
---|
[d30a399] | 3561 | si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY); |
---|
[83be980] | 3562 | p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0); |
---|
| 3563 | } |
---|
| 3564 | } |
---|
| 3565 | /*- release temp data------------------------------- -*/ |
---|
[e14e025] | 3566 | assume(strat->L==NULL); /* strat->L unused */ |
---|
| 3567 | assume(strat->B==NULL); /* strat->B unused */ |
---|
| 3568 | omFree(strat->sevS); |
---|
| 3569 | omFree(strat->ecartS); |
---|
| 3570 | assume(strat->T==NULL);//omfree(strat->T); |
---|
| 3571 | assume(strat->sevT==NULL);//omfree(strat->sevT); |
---|
| 3572 | assume(strat->R==NULL);//omfree(strat->R); |
---|
[83be980] | 3573 | omfree(strat->S_2_R); |
---|
| 3574 | omfree(strat->fromQ); |
---|
[52bcb9] | 3575 | #ifdef HAVE_SHIFTBBA |
---|
| 3576 | // only LM of elements in S is shifted |
---|
| 3577 | // necessary to prevent deleting the tail multiple times |
---|
[48ef591] | 3578 | if (rIsLPRing(currRing)) |
---|
[52bcb9] | 3579 | { |
---|
[a1ffca6] | 3580 | for (int j = 0; j < IDELEMS(strat->Shdl); j++) |
---|
[52bcb9] | 3581 | { |
---|
| 3582 | if (strat->Shdl->m[j]!=NULL && pmFirstVblock(strat->Shdl->m[j]) > 1) |
---|
| 3583 | { |
---|
| 3584 | // otherwise the tail would be freed multiple times |
---|
| 3585 | pNext(strat->Shdl->m[j]) = NULL; |
---|
| 3586 | } |
---|
| 3587 | } |
---|
| 3588 | } |
---|
| 3589 | #endif |
---|
[83be980] | 3590 | idDelete(&strat->Shdl); |
---|
[d30a399] | 3591 | SI_RESTORE_OPT1(save1); |
---|
[83be980] | 3592 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 3593 | return p; |
---|
| 3594 | } |
---|
| 3595 | |
---|
[c2ef83] | 3596 | poly kNF2Bound (ideal F,ideal Q,poly q,int bound,kStrategy strat, int lazyReduce) |
---|
| 3597 | { |
---|
| 3598 | assume(q!=NULL); |
---|
| 3599 | assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring? |
---|
| 3600 | |
---|
| 3601 | // lazy_reduce flags: can be combined by | |
---|
| 3602 | //#define KSTD_NF_LAZY 1 |
---|
| 3603 | // do only a reduction of the leading term |
---|
| 3604 | //#define KSTD_NF_NONORM 4 |
---|
| 3605 | // only global: avoid normalization, return a multiply of NF |
---|
| 3606 | poly p; |
---|
| 3607 | |
---|
| 3608 | //if ((idIs0(F))&&(Q==NULL)) |
---|
| 3609 | // return pCopy(q); /*F=0*/ |
---|
| 3610 | //strat->ak = idRankFreeModule(F); |
---|
| 3611 | /*- creating temp data structures------------------- -*/ |
---|
| 3612 | BITSET save1; |
---|
| 3613 | SI_SAVE_OPT1(save1); |
---|
| 3614 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
| 3615 | initBuchMoraCrit(strat); |
---|
| 3616 | strat->initEcart = initEcartBBA; |
---|
| 3617 | strat->enterS = enterSBba; |
---|
| 3618 | #ifndef NO_BUCKETS |
---|
| 3619 | strat->use_buckets = (!TEST_OPT_NOT_BUCKETS) && (!rIsPluralRing(currRing)); |
---|
| 3620 | #endif |
---|
| 3621 | /*- set S -*/ |
---|
| 3622 | strat->sl = -1; |
---|
| 3623 | /*- init local data struct.---------------------------------------- -*/ |
---|
| 3624 | /*Shdl=*/initS(F,Q,strat); |
---|
| 3625 | /*- compute------------------------------------------------------- -*/ |
---|
| 3626 | //if ((TEST_OPT_INTSTRATEGY)&&(lazyReduce==0)) |
---|
| 3627 | //{ |
---|
| 3628 | // for (i=strat->sl;i>=0;i--) |
---|
| 3629 | // pNorm(strat->S[i]); |
---|
| 3630 | //} |
---|
| 3631 | kTest(strat); |
---|
| 3632 | if (TEST_OPT_PROT) { PrintS("r"); mflush(); } |
---|
| 3633 | if (BVERBOSE(23)) kDebugPrint(strat); |
---|
| 3634 | int max_ind; |
---|
| 3635 | p = redNFBound(pCopy(q),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound); |
---|
| 3636 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
| 3637 | { |
---|
| 3638 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 3639 | if (rField_is_Ring(currRing)) |
---|
| 3640 | { |
---|
| 3641 | p = redtailBba_Z(p,max_ind,strat); |
---|
| 3642 | } |
---|
| 3643 | else |
---|
| 3644 | { |
---|
| 3645 | si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY); |
---|
| 3646 | p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0); |
---|
| 3647 | //p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0); |
---|
| 3648 | } |
---|
| 3649 | } |
---|
| 3650 | /*- release temp data------------------------------- -*/ |
---|
| 3651 | assume(strat->L==NULL); /* strat->L unused */ |
---|
| 3652 | assume(strat->B==NULL); /* strat->B unused */ |
---|
| 3653 | omFree(strat->sevS); |
---|
| 3654 | omFree(strat->ecartS); |
---|
| 3655 | assume(strat->T==NULL);//omfree(strat->T); |
---|
| 3656 | assume(strat->sevT==NULL);//omfree(strat->sevT); |
---|
| 3657 | assume(strat->R==NULL);//omfree(strat->R); |
---|
| 3658 | omfree(strat->S_2_R); |
---|
| 3659 | omfree(strat->fromQ); |
---|
| 3660 | idDelete(&strat->Shdl); |
---|
| 3661 | SI_RESTORE_OPT1(save1); |
---|
| 3662 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 3663 | return p; |
---|
| 3664 | } |
---|
| 3665 | |
---|
[83be980] | 3666 | ideal kNF2 (ideal F,ideal Q,ideal q,kStrategy strat, int lazyReduce) |
---|
| 3667 | { |
---|
| 3668 | assume(!idIs0(q)); |
---|
| 3669 | assume(!(idIs0(F)&&(Q==NULL))); |
---|
| 3670 | // lazy_reduce flags: can be combined by | |
---|
| 3671 | //#define KSTD_NF_LAZY 1 |
---|
| 3672 | // do only a reduction of the leading term |
---|
| 3673 | //#define KSTD_NF_NONORM 4 |
---|
| 3674 | // only global: avoid normalization, return a multiply of NF |
---|
| 3675 | poly p; |
---|
| 3676 | int i; |
---|
| 3677 | ideal res; |
---|
| 3678 | int max_ind; |
---|
| 3679 | |
---|
| 3680 | //if (idIs0(q)) |
---|
| 3681 | // return idInit(IDELEMS(q),si_max(q->rank,F->rank)); |
---|
| 3682 | //if ((idIs0(F))&&(Q==NULL)) |
---|
| 3683 | // return idCopy(q); /*F=0*/ |
---|
| 3684 | //strat->ak = idRankFreeModule(F); |
---|
| 3685 | /*- creating temp data structures------------------- -*/ |
---|
[d30a399] | 3686 | BITSET save1; |
---|
| 3687 | SI_SAVE_OPT1(save1); |
---|
| 3688 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
[83be980] | 3689 | initBuchMoraCrit(strat); |
---|
| 3690 | strat->initEcart = initEcartBBA; |
---|
[52bcb9] | 3691 | #ifdef HAVE_SHIFTBBA |
---|
[a1ffca6] | 3692 | if (rIsLPRing(currRing)) |
---|
[52bcb9] | 3693 | { |
---|
| 3694 | strat->enterS = enterSBbaShift; |
---|
| 3695 | } |
---|
| 3696 | else |
---|
| 3697 | #endif |
---|
| 3698 | { |
---|
| 3699 | strat->enterS = enterSBba; |
---|
| 3700 | } |
---|
[83be980] | 3701 | /*- set S -*/ |
---|
| 3702 | strat->sl = -1; |
---|
| 3703 | #ifndef NO_BUCKETS |
---|
| 3704 | strat->use_buckets = (!TEST_OPT_NOT_BUCKETS) && (!rIsPluralRing(currRing)); |
---|
| 3705 | #endif |
---|
| 3706 | /*- init local data struct.---------------------------------------- -*/ |
---|
| 3707 | /*Shdl=*/initS(F,Q,strat); |
---|
| 3708 | /*- compute------------------------------------------------------- -*/ |
---|
| 3709 | res=idInit(IDELEMS(q),si_max(q->rank,F->rank)); |
---|
[d30a399] | 3710 | si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY); |
---|
[83be980] | 3711 | for (i=IDELEMS(q)-1; i>=0; i--) |
---|
| 3712 | { |
---|
| 3713 | if (q->m[i]!=NULL) |
---|
| 3714 | { |
---|
| 3715 | if (TEST_OPT_PROT) { PrintS("r");mflush(); } |
---|
| 3716 | p = redNF(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat); |
---|
| 3717 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
| 3718 | { |
---|
| 3719 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 3720 | if (rField_is_Ring(currRing)) |
---|
| 3721 | { |
---|
| 3722 | p = redtailBba_Z(p,max_ind,strat); |
---|
| 3723 | } |
---|
| 3724 | else |
---|
| 3725 | { |
---|
| 3726 | p = redtailBba(p,max_ind,strat,(lazyReduce & KSTD_NF_NONORM)==0); |
---|
| 3727 | } |
---|
| 3728 | } |
---|
| 3729 | res->m[i]=p; |
---|
[c2ef83] | 3730 | } |
---|
| 3731 | //else |
---|
| 3732 | // res->m[i]=NULL; |
---|
| 3733 | } |
---|
| 3734 | /*- release temp data------------------------------- -*/ |
---|
| 3735 | assume(strat->L==NULL); /* strat->L unused */ |
---|
| 3736 | assume(strat->B==NULL); /* strat->B unused */ |
---|
| 3737 | omFree(strat->sevS); |
---|
| 3738 | omFree(strat->ecartS); |
---|
| 3739 | assume(strat->T==NULL);//omfree(strat->T); |
---|
| 3740 | assume(strat->sevT==NULL);//omfree(strat->sevT); |
---|
| 3741 | assume(strat->R==NULL);//omfree(strat->R); |
---|
| 3742 | omfree(strat->S_2_R); |
---|
| 3743 | omfree(strat->fromQ); |
---|
[52bcb9] | 3744 | #ifdef HAVE_SHIFTBBA |
---|
| 3745 | // only LM of elements in S is shifted |
---|
| 3746 | // necessary to prevent deleting the tail multiple times |
---|
[48ef591] | 3747 | if (rIsLPRing(currRing)) |
---|
[52bcb9] | 3748 | { |
---|
[a1ffca6] | 3749 | for (int j = 0; j < IDELEMS(strat->Shdl); j++) |
---|
[52bcb9] | 3750 | { |
---|
| 3751 | if (strat->Shdl->m[j]!=NULL && pmFirstVblock(strat->Shdl->m[j]) > 1) |
---|
| 3752 | { |
---|
| 3753 | // otherwise the tail would be freed multiple times |
---|
| 3754 | pNext(strat->Shdl->m[j]) = NULL; |
---|
| 3755 | } |
---|
| 3756 | } |
---|
| 3757 | } |
---|
| 3758 | #endif |
---|
[c2ef83] | 3759 | idDelete(&strat->Shdl); |
---|
| 3760 | SI_RESTORE_OPT1(save1); |
---|
| 3761 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 3762 | return res; |
---|
| 3763 | } |
---|
| 3764 | |
---|
| 3765 | ideal kNF2Bound (ideal F,ideal Q,ideal q,int bound,kStrategy strat, int lazyReduce) |
---|
| 3766 | { |
---|
| 3767 | assume(!idIs0(q)); |
---|
| 3768 | assume(!(idIs0(F)&&(Q==NULL))); |
---|
| 3769 | // lazy_reduce flags: can be combined by | |
---|
| 3770 | //#define KSTD_NF_LAZY 1 |
---|
| 3771 | // do only a reduction of the leading term |
---|
| 3772 | //#define KSTD_NF_NONORM 4 |
---|
| 3773 | // only global: avoid normalization, return a multiply of NF |
---|
| 3774 | poly p; |
---|
| 3775 | int i; |
---|
| 3776 | ideal res; |
---|
| 3777 | int max_ind; |
---|
| 3778 | |
---|
| 3779 | //if (idIs0(q)) |
---|
| 3780 | // return idInit(IDELEMS(q),si_max(q->rank,F->rank)); |
---|
| 3781 | //if ((idIs0(F))&&(Q==NULL)) |
---|
| 3782 | // return idCopy(q); /*F=0*/ |
---|
| 3783 | //strat->ak = idRankFreeModule(F); |
---|
| 3784 | /*- creating temp data structures------------------- -*/ |
---|
| 3785 | BITSET save1; |
---|
| 3786 | SI_SAVE_OPT1(save1); |
---|
| 3787 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
| 3788 | initBuchMoraCrit(strat); |
---|
| 3789 | strat->initEcart = initEcartBBA; |
---|
| 3790 | strat->enterS = enterSBba; |
---|
| 3791 | /*- set S -*/ |
---|
| 3792 | strat->sl = -1; |
---|
| 3793 | #ifndef NO_BUCKETS |
---|
| 3794 | strat->use_buckets = (!TEST_OPT_NOT_BUCKETS) && (!rIsPluralRing(currRing)); |
---|
| 3795 | #endif |
---|
| 3796 | /*- init local data struct.---------------------------------------- -*/ |
---|
| 3797 | /*Shdl=*/initS(F,Q,strat); |
---|
| 3798 | /*- compute------------------------------------------------------- -*/ |
---|
| 3799 | res=idInit(IDELEMS(q),si_max(q->rank,F->rank)); |
---|
| 3800 | si_opt_1 &= ~Sy_bit(OPT_INTSTRATEGY); |
---|
| 3801 | for (i=IDELEMS(q)-1; i>=0; i--) |
---|
| 3802 | { |
---|
| 3803 | if (q->m[i]!=NULL) |
---|
| 3804 | { |
---|
| 3805 | if (TEST_OPT_PROT) { PrintS("r");mflush(); } |
---|
| 3806 | p = redNFBound(pCopy(q->m[i]),max_ind,lazyReduce & KSTD_NF_NONORM,strat,bound); |
---|
| 3807 | if ((p!=NULL)&&((lazyReduce & KSTD_NF_LAZY)==0)) |
---|
| 3808 | { |
---|
| 3809 | if (TEST_OPT_PROT) { PrintS("t"); mflush(); } |
---|
| 3810 | if (rField_is_Ring(currRing)) |
---|
| 3811 | { |
---|
| 3812 | p = redtailBba_Z(p,max_ind,strat); |
---|
| 3813 | } |
---|
| 3814 | else |
---|
| 3815 | { |
---|
[6c086a4] | 3816 | p = redtailBbaBound(p,max_ind,strat,bound,(lazyReduce & KSTD_NF_NONORM)==0); |
---|
[c2ef83] | 3817 | } |
---|
| 3818 | } |
---|
| 3819 | res->m[i]=p; |
---|
[83be980] | 3820 | } |
---|
| 3821 | //else |
---|
| 3822 | // res->m[i]=NULL; |
---|
| 3823 | } |
---|
| 3824 | /*- release temp data------------------------------- -*/ |
---|
[e14e025] | 3825 | assume(strat->L==NULL); /* strat->L unused */ |
---|
| 3826 | assume(strat->B==NULL); /* strat->B unused */ |
---|
| 3827 | omFree(strat->sevS); |
---|
| 3828 | omFree(strat->ecartS); |
---|
| 3829 | assume(strat->T==NULL);//omfree(strat->T); |
---|
| 3830 | assume(strat->sevT==NULL);//omfree(strat->sevT); |
---|
| 3831 | assume(strat->R==NULL);//omfree(strat->R); |
---|
[83be980] | 3832 | omfree(strat->S_2_R); |
---|
[35aab3] | 3833 | omfree(strat->fromQ); |
---|
| 3834 | idDelete(&strat->Shdl); |
---|
[d30a399] | 3835 | SI_RESTORE_OPT1(save1); |
---|
[35aab3] | 3836 | if (TEST_OPT_PROT) PrintLn(); |
---|
| 3837 | return res; |
---|
| 3838 | } |
---|
[dd2855] | 3839 | |
---|
[83be980] | 3840 | #if F5C |
---|
| 3841 | /********************************************************************* |
---|
| 3842 | * interrreduction step of the signature-based algorithm: |
---|
| 3843 | * 1. all strat->S are interpreted as new critical pairs |
---|
| 3844 | * 2. those pairs need to be completely reduced by the usual (non sig- |
---|
| 3845 | * safe) reduction process (including tail reductions) |
---|
| 3846 | * 3. strat->S and strat->T are completely new computed in these steps |
---|
| 3847 | ********************************************************************/ |
---|
[601105] | 3848 | void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg, |
---|
[83be980] | 3849 | int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q, |
---|
| 3850 | intvec *w,intvec *hilb ) |
---|
| 3851 | { |
---|
| 3852 | int Ll_old, red_result = 1; |
---|
| 3853 | int pos = 0; |
---|
| 3854 | hilbeledeg=1; |
---|
| 3855 | hilbcount=0; |
---|
| 3856 | minimcnt=0; |
---|
| 3857 | srmax = 0; // strat->sl is 0 at this point |
---|
| 3858 | reduc = olddeg = lrmax = 0; |
---|
| 3859 | // we cannot use strat->T anymore |
---|
| 3860 | //cleanT(strat); |
---|
| 3861 | //strat->tl = -1; |
---|
| 3862 | Ll_old = strat->Ll; |
---|
| 3863 | while (strat->tl >= 0) |
---|
| 3864 | { |
---|
| 3865 | if(!strat->T[strat->tl].is_redundant) |
---|
| 3866 | { |
---|
| 3867 | LObject h; |
---|
| 3868 | h.p = strat->T[strat->tl].p; |
---|
| 3869 | h.tailRing = strat->T[strat->tl].tailRing; |
---|
| 3870 | h.t_p = strat->T[strat->tl].t_p; |
---|
| 3871 | if (h.p!=NULL) |
---|
| 3872 | { |
---|
[fee33e] | 3873 | if (currRing->OrdSgn==-1) |
---|
[83be980] | 3874 | { |
---|
[601105] | 3875 | cancelunit(&h); |
---|
[83be980] | 3876 | deleteHC(&h, strat); |
---|
| 3877 | } |
---|
| 3878 | if (h.p!=NULL) |
---|
| 3879 | { |
---|
| 3880 | if (TEST_OPT_INTSTRATEGY) |
---|
| 3881 | { |
---|
[24bc73] | 3882 | h.pCleardenom(); // also does remove Content |
---|
[83be980] | 3883 | } |
---|
| 3884 | else |
---|
| 3885 | { |
---|
| 3886 | h.pNorm(); |
---|
| 3887 | } |
---|
| 3888 | strat->initEcart(&h); |
---|
[a63783] | 3889 | if(rField_is_Ring(currRing)) |
---|
| 3890 | pos = posInLF5CRing(strat->L, Ll_old+1,strat->Ll,&h,strat); |
---|
| 3891 | else |
---|
| 3892 | pos = strat->Ll+1; |
---|
[83be980] | 3893 | h.sev = pGetShortExpVector(h.p); |
---|
| 3894 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 3895 | } |
---|
| 3896 | } |
---|
| 3897 | } |
---|
| 3898 | strat->tl--; |
---|
| 3899 | } |
---|
| 3900 | strat->sl = -1; |
---|
| 3901 | #if 0 |
---|
| 3902 | //#ifdef HAVE_TAIL_RING |
---|
| 3903 | if(!rField_is_Ring()) // create strong gcd poly computes with tailring and S[i] ->to be fixed |
---|
| 3904 | kStratInitChangeTailRing(strat); |
---|
| 3905 | #endif |
---|
| 3906 | //enterpairs(pOne(),0,0,-1,strat,strat->tl); |
---|
| 3907 | //strat->sl = -1; |
---|
| 3908 | /* picks the last element from the lazyset L */ |
---|
| 3909 | while (strat->Ll>Ll_old) |
---|
| 3910 | { |
---|
| 3911 | strat->P = strat->L[strat->Ll]; |
---|
| 3912 | strat->Ll--; |
---|
| 3913 | //#if 1 |
---|
| 3914 | #ifdef DEBUGF5 |
---|
[f9b0bd] | 3915 | PrintS("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n"); |
---|
| 3916 | PrintS("-------------------------------------------------\n"); |
---|
[83be980] | 3917 | pWrite(pHead(strat->P.p)); |
---|
| 3918 | pWrite(pHead(strat->P.p1)); |
---|
| 3919 | pWrite(pHead(strat->P.p2)); |
---|
| 3920 | printf("%d\n",strat->tl); |
---|
[f9b0bd] | 3921 | PrintS("-------------------------------------------------\n"); |
---|
[83be980] | 3922 | #endif |
---|
| 3923 | if (pNext(strat->P.p) == strat->tail) |
---|
| 3924 | { |
---|
| 3925 | // deletes the short spoly |
---|
| 3926 | if (rField_is_Ring(currRing)) |
---|
| 3927 | pLmDelete(strat->P.p); |
---|
| 3928 | else |
---|
| 3929 | pLmFree(strat->P.p); |
---|
| 3930 | |
---|
| 3931 | // TODO: needs some masking |
---|
| 3932 | // TODO: masking needs to vanish once the signature |
---|
| 3933 | // sutff is completely implemented |
---|
| 3934 | strat->P.p = NULL; |
---|
| 3935 | poly m1 = NULL, m2 = NULL; |
---|
| 3936 | |
---|
| 3937 | // check that spoly creation is ok |
---|
| 3938 | while (strat->tailRing != currRing && |
---|
| 3939 | !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) |
---|
| 3940 | { |
---|
| 3941 | assume(m1 == NULL && m2 == NULL); |
---|
| 3942 | // if not, change to a ring where exponents are at least |
---|
| 3943 | // large enough |
---|
| 3944 | if (!kStratChangeTailRing(strat)) |
---|
| 3945 | { |
---|
| 3946 | WerrorS("OVERFLOW..."); |
---|
| 3947 | break; |
---|
| 3948 | } |
---|
| 3949 | } |
---|
| 3950 | // create the real one |
---|
| 3951 | ksCreateSpoly(&(strat->P), NULL, strat->use_buckets, |
---|
| 3952 | strat->tailRing, m1, m2, strat->R); |
---|
| 3953 | } |
---|
| 3954 | else if (strat->P.p1 == NULL) |
---|
| 3955 | { |
---|
| 3956 | if (strat->minim > 0) |
---|
| 3957 | strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); |
---|
| 3958 | // for input polys, prepare reduction |
---|
[459ec94] | 3959 | if(!rField_is_Ring(currRing)) |
---|
| 3960 | strat->P.PrepareRed(strat->use_buckets); |
---|
[83be980] | 3961 | } |
---|
| 3962 | |
---|
| 3963 | if (strat->P.p == NULL && strat->P.t_p == NULL) |
---|
| 3964 | { |
---|
| 3965 | red_result = 0; |
---|
| 3966 | } |
---|
| 3967 | else |
---|
| 3968 | { |
---|
| 3969 | if (TEST_OPT_PROT) |
---|
| 3970 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
| 3971 | &olddeg,&reduc,strat, red_result); |
---|
| 3972 | |
---|
| 3973 | #ifdef DEBUGF5 |
---|
[f9b0bd] | 3974 | PrintS("Poly before red: "); |
---|
[83be980] | 3975 | pWrite(strat->P.p); |
---|
| 3976 | #endif |
---|
[88615db] | 3977 | /* complete reduction of the element chosen from L */ |
---|
[83be980] | 3978 | red_result = strat->red2(&strat->P,strat); |
---|
| 3979 | if (errorreported) break; |
---|
| 3980 | } |
---|
| 3981 | |
---|
| 3982 | if (strat->overflow) |
---|
| 3983 | { |
---|
[7b9b8e5] | 3984 | if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;} |
---|
[83be980] | 3985 | } |
---|
| 3986 | |
---|
| 3987 | // reduction to non-zero new poly |
---|
| 3988 | if (red_result == 1) |
---|
| 3989 | { |
---|
| 3990 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 3991 | strat->P.GetP(strat->lmBin); |
---|
| 3992 | // in the homogeneous case FDeg >= pFDeg (sugar/honey) |
---|
| 3993 | // but now, for entering S, T, we reset it |
---|
| 3994 | // in the inhomogeneous case: FDeg == pFDeg |
---|
| 3995 | if (strat->homog) strat->initEcart(&(strat->P)); |
---|
| 3996 | |
---|
| 3997 | /* statistic */ |
---|
| 3998 | if (TEST_OPT_PROT) PrintS("s"); |
---|
[4c7632] | 3999 | int pos; |
---|
[7d2b89] | 4000 | #if 1 |
---|
[4c7632] | 4001 | if(!rField_is_Ring(currRing)) |
---|
| 4002 | pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 4003 | else |
---|
[9d19c1] | 4004 | pos = posInSMonFirst(strat,strat->sl,strat->P.p); |
---|
[4c7632] | 4005 | #else |
---|
| 4006 | pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 4007 | #endif |
---|
[83be980] | 4008 | // reduce the tail and normalize poly |
---|
| 4009 | // in the ring case we cannot expect LC(f) = 1, |
---|
[24bc73] | 4010 | // therefore we call pCleardenom instead of pNorm |
---|
[83be980] | 4011 | #if F5CTAILRED |
---|
[15b211] | 4012 | BOOLEAN withT = TRUE; |
---|
[83be980] | 4013 | if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing))) |
---|
| 4014 | { |
---|
| 4015 | strat->P.pCleardenom(); |
---|
| 4016 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 4017 | { |
---|
| 4018 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
| 4019 | strat->P.pCleardenom(); |
---|
| 4020 | } |
---|
| 4021 | } |
---|
| 4022 | else |
---|
| 4023 | { |
---|
| 4024 | strat->P.pNorm(); |
---|
| 4025 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 4026 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
| 4027 | } |
---|
| 4028 | #endif |
---|
| 4029 | #ifdef KDEBUG |
---|
| 4030 | if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} |
---|
| 4031 | #endif /* KDEBUG */ |
---|
| 4032 | |
---|
| 4033 | // min_std stuff |
---|
| 4034 | if ((strat->P.p1==NULL) && (strat->minim>0)) |
---|
| 4035 | { |
---|
| 4036 | if (strat->minim==1) |
---|
| 4037 | { |
---|
| 4038 | strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); |
---|
| 4039 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 4040 | } |
---|
| 4041 | else |
---|
| 4042 | { |
---|
| 4043 | strat->M->m[minimcnt]=strat->P.p2; |
---|
| 4044 | strat->P.p2=NULL; |
---|
| 4045 | } |
---|
| 4046 | if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) |
---|
| 4047 | pNext(strat->M->m[minimcnt]) |
---|
| 4048 | = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), |
---|
| 4049 | strat->tailRing, currRing, |
---|
| 4050 | currRing->PolyBin); |
---|
| 4051 | minimcnt++; |
---|
| 4052 | } |
---|
| 4053 | |
---|
| 4054 | // enter into S, L, and T |
---|
| 4055 | // here we need to recompute new signatures, but those are trivial ones |
---|
[a973339] | 4056 | if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) |
---|
| 4057 | { |
---|
| 4058 | enterT(strat->P, strat); |
---|
| 4059 | // posInS only depends on the leading term |
---|
| 4060 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
[83be980] | 4061 | //#if 1 |
---|
| 4062 | #ifdef DEBUGF5 |
---|
[f9b0bd] | 4063 | PrintS("ELEMENT ADDED TO GCURR DURING INTERRED: "); |
---|
[a973339] | 4064 | pWrite(pHead(strat->S[strat->sl])); |
---|
| 4065 | pWrite(strat->sig[strat->sl]); |
---|
[83be980] | 4066 | #endif |
---|
[a973339] | 4067 | if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 4068 | } |
---|
[83be980] | 4069 | // Print("[%d]",hilbeledeg); |
---|
[3e5610] | 4070 | kDeleteLcm(&strat->P); |
---|
[83be980] | 4071 | if (strat->sl>srmax) srmax = strat->sl; |
---|
| 4072 | } |
---|
| 4073 | else |
---|
| 4074 | { |
---|
| 4075 | // adds signature of the zero reduction to |
---|
| 4076 | // strat->syz. This is the leading term of |
---|
| 4077 | // syzygy and can be used in syzCriterion() |
---|
| 4078 | // the signature is added if and only if the |
---|
| 4079 | // pair was not detected by the rewritten criterion in strat->red = redSig |
---|
| 4080 | if (strat->P.p1 == NULL && strat->minim > 0) |
---|
| 4081 | { |
---|
| 4082 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 4083 | } |
---|
| 4084 | } |
---|
| 4085 | |
---|
| 4086 | #ifdef KDEBUG |
---|
| 4087 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 4088 | #endif /* KDEBUG */ |
---|
| 4089 | } |
---|
| 4090 | int cc = 0; |
---|
| 4091 | while (cc<strat->tl+1) |
---|
| 4092 | { |
---|
| 4093 | strat->T[cc].sig = pOne(); |
---|
| 4094 | p_SetComp(strat->T[cc].sig,cc+1,currRing); |
---|
| 4095 | strat->T[cc].sevSig = pGetShortExpVector(strat->T[cc].sig); |
---|
| 4096 | strat->sig[cc] = strat->T[cc].sig; |
---|
| 4097 | strat->sevSig[cc] = strat->T[cc].sevSig; |
---|
[601105] | 4098 | strat->T[cc].is_sigsafe = TRUE; |
---|
[83be980] | 4099 | cc++; |
---|
| 4100 | } |
---|
| 4101 | strat->max_lower_index = strat->tl; |
---|
| 4102 | // set current signature index of upcoming iteration step |
---|
| 4103 | // NOTE: this needs to be set here, as otherwise initSyzRules cannot compute |
---|
| 4104 | // the corresponding syzygy rules correctly |
---|
| 4105 | strat->currIdx = cc+1; |
---|
| 4106 | for (int cd=strat->Ll; cd>=0; cd--) |
---|
| 4107 | { |
---|
| 4108 | p_SetComp(strat->L[cd].sig,cc+1,currRing); |
---|
| 4109 | cc++; |
---|
| 4110 | } |
---|
[deb5f3] | 4111 | for (cc=strat->sl+1; cc<IDELEMS(strat->Shdl); ++cc) |
---|
| 4112 | strat->Shdl->m[cc] = NULL; |
---|
[f7bea2] | 4113 | #if 0 |
---|
| 4114 | printf("\nAfter f5c sorting\n"); |
---|
| 4115 | for(int i=0;i<=strat->sl;i++) |
---|
| 4116 | pWrite(pHead(strat->S[i])); |
---|
| 4117 | getchar(); |
---|
| 4118 | #endif |
---|
[83be980] | 4119 | //#if 1 |
---|
| 4120 | #if DEBUGF5 |
---|
[f9b0bd] | 4121 | PrintS("------------------- STRAT S ---------------------\n"); |
---|
[83be980] | 4122 | cc = 0; |
---|
| 4123 | while (cc<strat->tl+1) |
---|
| 4124 | { |
---|
| 4125 | pWrite(pHead(strat->S[cc])); |
---|
| 4126 | pWrite(strat->sig[cc]); |
---|
| 4127 | printf("- - - - - -\n"); |
---|
| 4128 | cc++; |
---|
| 4129 | } |
---|
[f9b0bd] | 4130 | PrintS("-------------------------------------------------\n"); |
---|
| 4131 | PrintS("------------------- STRAT T ---------------------\n"); |
---|
[83be980] | 4132 | cc = 0; |
---|
| 4133 | while (cc<strat->tl+1) |
---|
| 4134 | { |
---|
| 4135 | pWrite(pHead(strat->T[cc].p)); |
---|
| 4136 | pWrite(strat->T[cc].sig); |
---|
| 4137 | printf("- - - - - -\n"); |
---|
| 4138 | cc++; |
---|
| 4139 | } |
---|
[f9b0bd] | 4140 | PrintS("-------------------------------------------------\n"); |
---|
| 4141 | PrintS("------------------- STRAT L ---------------------\n"); |
---|
[83be980] | 4142 | cc = 0; |
---|
| 4143 | while (cc<strat->Ll+1) |
---|
| 4144 | { |
---|
| 4145 | pWrite(pHead(strat->L[cc].p)); |
---|
| 4146 | pWrite(pHead(strat->L[cc].p1)); |
---|
| 4147 | pWrite(pHead(strat->L[cc].p2)); |
---|
| 4148 | pWrite(strat->L[cc].sig); |
---|
| 4149 | printf("- - - - - -\n"); |
---|
| 4150 | cc++; |
---|
| 4151 | } |
---|
[f9b0bd] | 4152 | PrintS("-------------------------------------------------\n"); |
---|
[83be980] | 4153 | printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx); |
---|
| 4154 | #endif |
---|
| 4155 | |
---|
| 4156 | } |
---|
| 4157 | #endif |
---|
| 4158 | |
---|
[cb0fbe] | 4159 | /* shiftgb stuff */ |
---|
[037df4] | 4160 | #ifdef HAVE_SHIFTBBA |
---|
[37a4c3] | 4161 | |
---|
[07625cb] | 4162 | |
---|
[b00f8a] | 4163 | ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) |
---|
[cb0fbe] | 4164 | { |
---|
[930ea8] | 4165 | int red_result = 1; |
---|
[cb0fbe] | 4166 | int olddeg,reduc; |
---|
| 4167 | int hilbeledeg=1,hilbcount=0,minimcnt=0; |
---|
[8fdfee7] | 4168 | BOOLEAN withT = TRUE; // currently only T contains the shifts |
---|
| 4169 | BITSET save; |
---|
| 4170 | SI_SAVE_OPT1(save); |
---|
[cb0fbe] | 4171 | |
---|
[37a4c3] | 4172 | initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit, NO CHANGES */ |
---|
[5efbf9] | 4173 | if(rField_is_Ring(currRing)) |
---|
| 4174 | initBuchMoraPosRing(strat); |
---|
| 4175 | else |
---|
| 4176 | initBuchMoraPos(strat); /*NO CHANGES YET: perhaps later*/ |
---|
[37a4c3] | 4177 | initHilbCrit(F,Q,&hilb,strat); /*NO CHANGES*/ |
---|
[4cc32b2] | 4178 | initBbaShift(strat); /* DONE */ |
---|
[cb0fbe] | 4179 | /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ |
---|
[5c51ab] | 4180 | /*Shdl=*/initBuchMora(F, Q,strat); |
---|
[cb0fbe] | 4181 | if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank); |
---|
[930ea8] | 4182 | reduc = olddeg = 0; |
---|
[cb0fbe] | 4183 | |
---|
| 4184 | #ifndef NO_BUCKETS |
---|
| 4185 | if (!TEST_OPT_NOT_BUCKETS) |
---|
| 4186 | strat->use_buckets = 1; |
---|
| 4187 | #endif |
---|
| 4188 | // redtailBBa against T for inhomogenous input |
---|
[228b631] | 4189 | // if (!TEST_OPT_OLDSTD) |
---|
[37a4c3] | 4190 | // withT = ! strat->homog; |
---|
[cb0fbe] | 4191 | |
---|
| 4192 | // strat->posInT = posInT_pLength; |
---|
[eb55f8a] | 4193 | kTest_TS(strat); |
---|
[cb0fbe] | 4194 | |
---|
[cae182] | 4195 | #ifdef HAVE_TAIL_RING |
---|
[411e158] | 4196 | // kStratInitChangeTailRing(strat); |
---|
| 4197 | strat->tailRing=currRing; |
---|
[cae182] | 4198 | #endif |
---|
| 4199 | |
---|
[8fdfee7] | 4200 | |
---|
| 4201 | #ifdef KDEBUG |
---|
| 4202 | //kDebugPrint(strat); |
---|
| 4203 | #endif |
---|
[cb0fbe] | 4204 | /* compute------------------------------------------------------- */ |
---|
| 4205 | while (strat->Ll >= 0) |
---|
| 4206 | { |
---|
| 4207 | #ifdef KDEBUG |
---|
| 4208 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 4209 | #endif |
---|
| 4210 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
| 4211 | if (TEST_OPT_DEGBOUND |
---|
[e533660] | 4212 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 4213 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
[cb0fbe] | 4214 | { |
---|
| 4215 | /* |
---|
| 4216 | *stops computation if |
---|
| 4217 | * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
| 4218 | *a predefined number Kstd1_deg |
---|
| 4219 | */ |
---|
| 4220 | while ((strat->Ll >= 0) |
---|
| 4221 | && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) |
---|
[e533660] | 4222 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 4223 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))) |
---|
[cb0fbe] | 4224 | ) |
---|
| 4225 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 4226 | if (strat->Ll<0) break; |
---|
| 4227 | else strat->noClearS=TRUE; |
---|
| 4228 | } |
---|
| 4229 | /* picks the last element from the lazyset L */ |
---|
| 4230 | strat->P = strat->L[strat->Ll]; |
---|
| 4231 | strat->Ll--; |
---|
| 4232 | |
---|
| 4233 | if (pNext(strat->P.p) == strat->tail) |
---|
| 4234 | { |
---|
| 4235 | // deletes the short spoly |
---|
| 4236 | pLmFree(strat->P.p); |
---|
| 4237 | strat->P.p = NULL; |
---|
| 4238 | poly m1 = NULL, m2 = NULL; |
---|
| 4239 | |
---|
[cae182] | 4240 | // check that spoly creation is ok |
---|
| 4241 | while (strat->tailRing != currRing && |
---|
| 4242 | !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) |
---|
| 4243 | { |
---|
| 4244 | assume(m1 == NULL && m2 == NULL); |
---|
| 4245 | // if not, change to a ring where exponents are at least |
---|
| 4246 | // large enough |
---|
| 4247 | kStratChangeTailRing(strat); |
---|
| 4248 | } |
---|
[cb0fbe] | 4249 | // create the real one |
---|
| 4250 | ksCreateSpoly(&(strat->P), NULL, strat->use_buckets, |
---|
| 4251 | strat->tailRing, m1, m2, strat->R); |
---|
| 4252 | } |
---|
| 4253 | else if (strat->P.p1 == NULL) |
---|
| 4254 | { |
---|
| 4255 | if (strat->minim > 0) |
---|
| 4256 | strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); |
---|
| 4257 | // for input polys, prepare reduction |
---|
| 4258 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 4259 | } |
---|
| 4260 | |
---|
| 4261 | if (strat->P.p == NULL && strat->P.t_p == NULL) |
---|
| 4262 | { |
---|
| 4263 | red_result = 0; |
---|
| 4264 | } |
---|
| 4265 | else |
---|
| 4266 | { |
---|
| 4267 | if (TEST_OPT_PROT) |
---|
| 4268 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
| 4269 | &olddeg,&reduc,strat, red_result); |
---|
| 4270 | |
---|
[88615db] | 4271 | /* reduction of the element chosen from L */ |
---|
[cb0fbe] | 4272 | red_result = strat->red(&strat->P,strat); |
---|
[f42e9e] | 4273 | if (errorreported) break; |
---|
[cb0fbe] | 4274 | } |
---|
| 4275 | |
---|
| 4276 | // reduction to non-zero new poly |
---|
| 4277 | if (red_result == 1) |
---|
| 4278 | { |
---|
| 4279 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 4280 | strat->P.GetP(strat->lmBin); |
---|
[8fdfee7] | 4281 | // in the homogeneous case FDeg >= pFDeg (sugar/honey) |
---|
| 4282 | // but now, for entering S, T, we reset it |
---|
| 4283 | // in the inhomogeneous case: FDeg == pFDeg |
---|
| 4284 | if (strat->homog) strat->initEcart(&(strat->P)); |
---|
| 4285 | |
---|
| 4286 | /* statistic */ |
---|
| 4287 | if (TEST_OPT_PROT) PrintS("s"); |
---|
[cb0fbe] | 4288 | |
---|
| 4289 | int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 4290 | |
---|
| 4291 | // reduce the tail and normalize poly |
---|
[8fdfee7] | 4292 | // in the ring case we cannot expect LC(f) = 1, |
---|
| 4293 | // therefore we call pCleardenom instead of pNorm |
---|
[b00f8a] | 4294 | strat->redTailChange=FALSE; |
---|
[cb0fbe] | 4295 | if (TEST_OPT_INTSTRATEGY) |
---|
| 4296 | { |
---|
| 4297 | strat->P.pCleardenom(); |
---|
| 4298 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 4299 | { |
---|
| 4300 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
| 4301 | strat->P.pCleardenom(); |
---|
[cee69a] | 4302 | if (strat->redTailChange) { |
---|
[b00f8a] | 4303 | strat->P.t_p=NULL; |
---|
[abfdab] | 4304 | strat->initEcart(&(strat->P)); |
---|
[b00f8a] | 4305 | } |
---|
[cb0fbe] | 4306 | } |
---|
| 4307 | } |
---|
| 4308 | else |
---|
| 4309 | { |
---|
| 4310 | strat->P.pNorm(); |
---|
[b00f8a] | 4311 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) { |
---|
[cb0fbe] | 4312 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
[b00f8a] | 4313 | if (strat->redTailChange) { |
---|
| 4314 | strat->P.t_p=NULL; |
---|
[abfdab] | 4315 | strat->initEcart(&(strat->P)); |
---|
[b00f8a] | 4316 | } |
---|
| 4317 | } |
---|
[cb0fbe] | 4318 | } |
---|
| 4319 | |
---|
| 4320 | #ifdef KDEBUG |
---|
| 4321 | if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} |
---|
| 4322 | #endif |
---|
| 4323 | |
---|
| 4324 | // min_std stuff |
---|
| 4325 | if ((strat->P.p1==NULL) && (strat->minim>0)) |
---|
| 4326 | { |
---|
| 4327 | if (strat->minim==1) |
---|
| 4328 | { |
---|
| 4329 | strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); |
---|
| 4330 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 4331 | } |
---|
| 4332 | else |
---|
| 4333 | { |
---|
| 4334 | strat->M->m[minimcnt]=strat->P.p2; |
---|
| 4335 | strat->P.p2=NULL; |
---|
| 4336 | } |
---|
| 4337 | if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) |
---|
| 4338 | pNext(strat->M->m[minimcnt]) |
---|
| 4339 | = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), |
---|
| 4340 | strat->tailRing, currRing, |
---|
| 4341 | currRing->PolyBin); |
---|
| 4342 | minimcnt++; |
---|
| 4343 | } |
---|
| 4344 | |
---|
[eed827] | 4345 | |
---|
[cb0fbe] | 4346 | // enter into S, L, and T |
---|
[8fdfee7] | 4347 | if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) |
---|
[ad1c3b] | 4348 | { |
---|
[216e12] | 4349 | enterT(strat->P, strat); |
---|
| 4350 | enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
[8fdfee7] | 4351 | // posInS only depends on the leading term |
---|
[216e12] | 4352 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
[308e89] | 4353 | if (!strat->rightGB) |
---|
| 4354 | enterTShift(strat->P, strat); |
---|
[0dcc85c] | 4355 | } |
---|
[ad1c3b] | 4356 | |
---|
[cb0fbe] | 4357 | if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 4358 | // Print("[%d]",hilbeledeg); |
---|
[3e5610] | 4359 | kDeleteLcm(&strat->P); |
---|
[8fdfee7] | 4360 | if (strat->s_poly!=NULL) |
---|
[ad1c3b] | 4361 | { |
---|
[8fdfee7] | 4362 | // the only valid entries are: strat->P.p, |
---|
| 4363 | // strat->tailRing (read-only, keep it) |
---|
| 4364 | // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed) |
---|
| 4365 | if (strat->s_poly(strat)) |
---|
| 4366 | { |
---|
| 4367 | // we are called AFTER enterS, i.e. if we change P |
---|
| 4368 | // we have to add it also to S/T |
---|
| 4369 | // and add pairs |
---|
| 4370 | int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
[6b0b413] | 4371 | enterT(strat->P, strat); |
---|
| 4372 | enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
| 4373 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
[308e89] | 4374 | if (!strat->rightGB) |
---|
| 4375 | enterTShift(strat->P,strat); |
---|
[8fdfee7] | 4376 | } |
---|
[ad1c3b] | 4377 | } |
---|
[cb0fbe] | 4378 | } |
---|
[b00f8a] | 4379 | else if (strat->P.p1 == NULL && strat->minim > 0) |
---|
[cb0fbe] | 4380 | { |
---|
[b00f8a] | 4381 | p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
[cb0fbe] | 4382 | } |
---|
| 4383 | #ifdef KDEBUG |
---|
| 4384 | memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 4385 | #endif |
---|
[eb55f8a] | 4386 | kTest_TS(strat); |
---|
[cb0fbe] | 4387 | } |
---|
| 4388 | #ifdef KDEBUG |
---|
| 4389 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 4390 | #endif |
---|
[d5564f8] | 4391 | /* shift case: look for elt's in S such that they are divisible by elt in T */ |
---|
[8fdfee7] | 4392 | if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set? |
---|
[cb0fbe] | 4393 | { |
---|
[8fdfee7] | 4394 | for (int k = 0; k <= strat->sl; ++k) |
---|
[cb0fbe] | 4395 | { |
---|
[308e89] | 4396 | if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k |
---|
[8fdfee7] | 4397 | for (int j = 0; j<=strat->tl; ++j) |
---|
[cb0fbe] | 4398 | { |
---|
[8fdfee7] | 4399 | // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too |
---|
| 4400 | assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p)); |
---|
| 4401 | assume(strat->sevS[k] == pGetShortExpVector(strat->S[k])); |
---|
| 4402 | if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k])) |
---|
[4c4979] | 4403 | { |
---|
[8fdfee7] | 4404 | if (pLmCmp(strat->T[j].p, strat->S[k]) != 0) { // check whether LM is different |
---|
| 4405 | deleteInS(k, strat); |
---|
| 4406 | --k; |
---|
| 4407 | break; |
---|
[4c4979] | 4408 | } |
---|
| 4409 | } |
---|
[cb0fbe] | 4410 | } |
---|
| 4411 | } |
---|
| 4412 | } |
---|
[8fdfee7] | 4413 | /* complete reduction of the standard basis--------- */ |
---|
[cb0fbe] | 4414 | if (TEST_OPT_REDSB) |
---|
[8fdfee7] | 4415 | { |
---|
| 4416 | completeReduce(strat, TRUE); //shift: withT = TRUE |
---|
[cb0fbe] | 4417 | if (strat->completeReduce_retry) |
---|
| 4418 | { |
---|
| 4419 | // completeReduce needed larger exponents, retry |
---|
| 4420 | // to reduce with S (instead of T) |
---|
| 4421 | // and in currRing (instead of strat->tailRing) |
---|
[349e5e8] | 4422 | #ifdef HAVE_TAIL_RING |
---|
| 4423 | if(currRing->bitmask>strat->tailRing->bitmask) |
---|
| 4424 | { |
---|
| 4425 | strat->completeReduce_retry=FALSE; |
---|
| 4426 | cleanT(strat);strat->tailRing=currRing; |
---|
| 4427 | int i; |
---|
| 4428 | for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1; |
---|
[8fdfee7] | 4429 | WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know |
---|
[349e5e8] | 4430 | completeReduce(strat); |
---|
| 4431 | } |
---|
| 4432 | if (strat->completeReduce_retry) |
---|
| 4433 | #endif |
---|
| 4434 | Werror("exponent bound is %ld",currRing->bitmask); |
---|
[cb0fbe] | 4435 | } |
---|
| 4436 | } |
---|
[5accf0] | 4437 | else if (TEST_OPT_PROT) PrintLn(); |
---|
[cb0fbe] | 4438 | |
---|
| 4439 | /* release temp data-------------------------------- */ |
---|
| 4440 | exitBuchMora(strat); |
---|
[e533660] | 4441 | // if (TEST_OPT_WEIGHTM) |
---|
| 4442 | // { |
---|
| 4443 | // pRestoreDegProcs(currRing,pFDegOld, pLDegOld); |
---|
| 4444 | // if (ecartWeights) |
---|
| 4445 | // { |
---|
| 4446 | // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
| 4447 | // ecartWeights=NULL; |
---|
| 4448 | // } |
---|
| 4449 | // } |
---|
[8fdfee7] | 4450 | if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat); |
---|
| 4451 | SI_RESTORE_OPT1(save); |
---|
| 4452 | /* postprocessing for GB over Q-rings ------------------*/ |
---|
[cb0fbe] | 4453 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
[8fdfee7] | 4454 | |
---|
| 4455 | idTest(strat->Shdl); |
---|
| 4456 | |
---|
[cb0fbe] | 4457 | return (strat->Shdl); |
---|
| 4458 | } |
---|
| 4459 | |
---|
[1c473f] | 4460 | |
---|
[b95a5f] | 4461 | ideal freegb(ideal F) |
---|
[cb0fbe] | 4462 | { |
---|
[6a0ad75] | 4463 | assume(rIsLPRing(currRing)); |
---|
[b95a5f] | 4464 | assume(idIsInV(F)); |
---|
| 4465 | ideal RS = kStdShift(F, NULL, testHomog, NULL); |
---|
| 4466 | idSkipZeroes(RS); // is this even necessary? |
---|
| 4467 | assume(idIsInV(RS)); |
---|
| 4468 | return(RS); |
---|
| 4469 | } |
---|
| 4470 | |
---|
| 4471 | ideal rightgb(ideal F, ideal Q) |
---|
| 4472 | { |
---|
| 4473 | assume(rIsLPRing(currRing)); |
---|
| 4474 | assume(idIsInV(F)); |
---|
| 4475 | ideal RS = kStdShift(F, Q, testHomog, NULL, NULL, 0, 0, NULL, TRUE); |
---|
[b00f8a] | 4476 | idSkipZeroes(RS); // is this even necessary? |
---|
[4ab28ee] | 4477 | assume(idIsInV(RS)); |
---|
[cb0fbe] | 4478 | return(RS); |
---|
| 4479 | } |
---|
[37a4c3] | 4480 | |
---|
| 4481 | /*2 |
---|
| 4482 | *reduces h with elements from T choosing the first possible |
---|
| 4483 | * element in t with respect to the given pDivisibleBy |
---|
| 4484 | */ |
---|
| 4485 | int redFirstShift (LObject* h,kStrategy strat) |
---|
| 4486 | { |
---|
| 4487 | if (h->IsNull()) return 0; |
---|
| 4488 | |
---|
| 4489 | int at, reddeg,d; |
---|
| 4490 | int pass = 0; |
---|
| 4491 | int j = 0; |
---|
| 4492 | |
---|
| 4493 | if (! strat->homog) |
---|
| 4494 | { |
---|
| 4495 | d = h->GetpFDeg() + h->ecart; |
---|
| 4496 | reddeg = strat->LazyDegree+d; |
---|
| 4497 | } |
---|
| 4498 | h->SetShortExpVector(); |
---|
| 4499 | loop |
---|
| 4500 | { |
---|
[a576b0] | 4501 | j = kFindDivisibleByInT(strat, h); |
---|
[37a4c3] | 4502 | if (j < 0) |
---|
| 4503 | { |
---|
| 4504 | h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 4505 | return 1; |
---|
| 4506 | } |
---|
| 4507 | |
---|
| 4508 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 4509 | strat->T[j].pNorm(); |
---|
| 4510 | #ifdef KDEBUG |
---|
| 4511 | if (TEST_OPT_DEBUG) |
---|
| 4512 | { |
---|
| 4513 | PrintS("reduce "); |
---|
| 4514 | h->wrp(); |
---|
| 4515 | PrintS(" with "); |
---|
| 4516 | strat->T[j].wrp(); |
---|
| 4517 | } |
---|
| 4518 | #endif |
---|
| 4519 | ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, strat); |
---|
[d5564f8] | 4520 | |
---|
[37a4c3] | 4521 | #ifdef KDEBUG |
---|
| 4522 | if (TEST_OPT_DEBUG) |
---|
| 4523 | { |
---|
[0ee0b4] | 4524 | PrintS("\nto "); |
---|
[37a4c3] | 4525 | wrp(h->p); |
---|
| 4526 | PrintLn(); |
---|
| 4527 | } |
---|
| 4528 | #endif |
---|
| 4529 | if (h->IsNull()) |
---|
| 4530 | { |
---|
[3e5610] | 4531 | kDeleteLcm(h); |
---|
[37a4c3] | 4532 | h->Clear(); |
---|
| 4533 | return 0; |
---|
| 4534 | } |
---|
| 4535 | h->SetShortExpVector(); |
---|
| 4536 | |
---|
| 4537 | #if 0 |
---|
| 4538 | if ((strat->syzComp!=0) && !strat->honey) |
---|
| 4539 | { |
---|
| 4540 | if ((strat->syzComp>0) && |
---|
| 4541 | (h->Comp() > strat->syzComp)) |
---|
| 4542 | { |
---|
| 4543 | assume(h->MinComp() > strat->syzComp); |
---|
| 4544 | #ifdef KDEBUG |
---|
| 4545 | if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
| 4546 | #endif |
---|
| 4547 | if (strat->homog) |
---|
| 4548 | h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 4549 | return -2; |
---|
| 4550 | } |
---|
| 4551 | } |
---|
| 4552 | #endif |
---|
| 4553 | if (!strat->homog) |
---|
| 4554 | { |
---|
[228b631] | 4555 | if (!TEST_OPT_OLDSTD && strat->honey) |
---|
[37a4c3] | 4556 | { |
---|
| 4557 | h->SetpFDeg(); |
---|
| 4558 | if (strat->T[j].ecart <= h->ecart) |
---|
| 4559 | h->ecart = d - h->GetpFDeg(); |
---|
| 4560 | else |
---|
| 4561 | h->ecart = d - h->GetpFDeg() + strat->T[j].ecart - h->ecart; |
---|
| 4562 | |
---|
| 4563 | d = h->GetpFDeg() + h->ecart; |
---|
| 4564 | } |
---|
| 4565 | else |
---|
| 4566 | d = h->SetDegStuffReturnLDeg(strat->LDegLast); |
---|
| 4567 | /*- try to reduce the s-polynomial -*/ |
---|
| 4568 | pass++; |
---|
| 4569 | /* |
---|
| 4570 | *test whether the polynomial should go to the lazyset L |
---|
| 4571 | *-if the degree jumps |
---|
| 4572 | *-if the number of pre-defined reductions jumps |
---|
| 4573 | */ |
---|
[228b631] | 4574 | if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) |
---|
[37a4c3] | 4575 | && ((d >= reddeg) || (pass > strat->LazyPass))) |
---|
| 4576 | { |
---|
| 4577 | h->SetLmCurrRing(); |
---|
| 4578 | if (strat->posInLDependsOnLength) |
---|
| 4579 | h->SetLength(strat->length_pLength); |
---|
| 4580 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
| 4581 | if (at <= strat->Ll) |
---|
| 4582 | { |
---|
[a576b0] | 4583 | //int dummy=strat->sl; |
---|
[eed827] | 4584 | /* if (kFindDivisibleByInS(strat,&dummy, h) < 0) */ |
---|
[a576b0] | 4585 | //if (kFindDivisibleByInT(strat->T,strat->sevT, dummy, h) < 0) |
---|
| 4586 | if (kFindDivisibleByInT(strat, h) < 0) |
---|
[37a4c3] | 4587 | return 1; |
---|
| 4588 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
| 4589 | #ifdef KDEBUG |
---|
| 4590 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
[07625cb] | 4591 | #endif |
---|
[37a4c3] | 4592 | h->Clear(); |
---|
| 4593 | return -1; |
---|
| 4594 | } |
---|
| 4595 | } |
---|
| 4596 | if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
| 4597 | { |
---|
| 4598 | reddeg = d+1; |
---|
| 4599 | Print(".%d",d);mflush(); |
---|
| 4600 | } |
---|
| 4601 | } |
---|
| 4602 | } |
---|
| 4603 | } |
---|
| 4604 | |
---|
[4cc32b2] | 4605 | void initBbaShift(kStrategy strat) |
---|
[37a4c3] | 4606 | { |
---|
| 4607 | /* setting global variables ------------------- */ |
---|
| 4608 | strat->enterS = enterSBba; /* remains as is, we change enterT! */ |
---|
| 4609 | |
---|
| 4610 | strat->red = redFirstShift; /* no redHomog ! */ |
---|
| 4611 | |
---|
[fe89b98] | 4612 | if (currRing->pLexOrder && strat->honey) |
---|
[37a4c3] | 4613 | strat->initEcart = initEcartNormal; |
---|
| 4614 | else |
---|
| 4615 | strat->initEcart = initEcartBBA; |
---|
| 4616 | if (strat->honey) |
---|
| 4617 | strat->initEcartPair = initEcartPairMora; |
---|
| 4618 | else |
---|
| 4619 | strat->initEcartPair = initEcartPairBba; |
---|
[e533660] | 4620 | // if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
| 4621 | // { |
---|
| 4622 | // //interred machen Aenderung |
---|
| 4623 | // pFDegOld=currRing->pFDeg; |
---|
| 4624 | // pLDegOld=pLDeg; |
---|
| 4625 | // //h=ggetid("ecart"); |
---|
| 4626 | // //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/) |
---|
| 4627 | // //{ |
---|
| 4628 | // // ecartWeights=iv2array(IDINTVEC(h)); |
---|
| 4629 | // //} |
---|
| 4630 | // //else |
---|
| 4631 | // { |
---|
| 4632 | // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short)); |
---|
| 4633 | // /*uses automatic computation of the ecartWeights to set them*/ |
---|
| 4634 | // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights,currRing); |
---|
| 4635 | // } |
---|
| 4636 | // pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart); |
---|
| 4637 | // if (TEST_OPT_PROT) |
---|
| 4638 | // { |
---|
[d30a399] | 4639 | // for(int i=1; i<=rVar(currRing); i++) |
---|
[e533660] | 4640 | // Print(" %d",ecartWeights[i]); |
---|
| 4641 | // PrintLn(); |
---|
| 4642 | // mflush(); |
---|
| 4643 | // } |
---|
| 4644 | // } |
---|
[37a4c3] | 4645 | } |
---|
[037df4] | 4646 | #endif |
---|