[64f0ca] | 1 | #define PLURAL_INTERNAL_DECLARATIONS |
---|
| 2 | |
---|
[16f511] | 3 | #ifdef HAVE_CONFIG_H |
---|
[ba5e9e] | 4 | #include "singularconfig.h" |
---|
[16f511] | 5 | #endif /* HAVE_CONFIG_H */ |
---|
[c7aad0] | 6 | #include "mod2.h" |
---|
| 7 | #include <misc/auxiliary.h> |
---|
| 8 | |
---|
| 9 | #include <misc/options.h> |
---|
| 10 | |
---|
| 11 | #include <polys/simpleideals.h> |
---|
| 12 | #include <polys/prCopy.h> |
---|
| 13 | |
---|
[64f0ca] | 14 | #include <polys/nc/sca.h> |
---|
| 15 | #include <polys/nc/gb_hack.h> |
---|
| 16 | |
---|
| 17 | #include "polys.h" |
---|
[c7aad0] | 18 | #include "ideals.h" |
---|
| 19 | #include "kstd1.h" |
---|
[64f0ca] | 20 | #include "kutil.h" |
---|
[c7aad0] | 21 | |
---|
| 22 | #include "nc.h" |
---|
| 23 | |
---|
[64f0ca] | 24 | /// nc_gr_initBba is needed for sca_gr_bba and gr_bba. |
---|
| 25 | void nc_gr_initBba(ideal F, kStrategy strat); // from gr_kstd2.cc! |
---|
| 26 | |
---|
[c7aad0] | 27 | void addLObject(LObject& h, kStrategy& strat) |
---|
| 28 | { |
---|
| 29 | if(h.IsNull()) return; |
---|
| 30 | |
---|
| 31 | strat->initEcart(&h); |
---|
| 32 | h.sev=0; // pGetShortExpVector(h.p); |
---|
| 33 | |
---|
| 34 | // add h into S and L |
---|
| 35 | int pos=posInS(strat, strat->sl, h.p, h.ecart); |
---|
| 36 | |
---|
[64f0ca] | 37 | if ( (pos <= strat->sl) && (p_ComparePolys(h.p, strat->S[pos], currRing)) ) |
---|
[c7aad0] | 38 | { |
---|
| 39 | if (TEST_OPT_PROT) |
---|
| 40 | PrintS("d\n"); |
---|
| 41 | } |
---|
| 42 | else |
---|
| 43 | { |
---|
| 44 | if (TEST_OPT_INTSTRATEGY) |
---|
| 45 | { |
---|
| 46 | p_Cleardenom(h.p, currRing); |
---|
| 47 | } |
---|
| 48 | else |
---|
| 49 | { |
---|
| 50 | pNorm(h.p); |
---|
| 51 | p_Content(h.p,currRing); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | if ((strat->syzComp==0)||(!strat->homog)) |
---|
| 55 | { |
---|
| 56 | h.p = redtailBba(h.p,pos-1,strat); |
---|
| 57 | |
---|
| 58 | if (TEST_OPT_INTSTRATEGY) |
---|
| 59 | { |
---|
| 60 | // pCleardenom(h.p); |
---|
| 61 | p_Content(h.p,currRing); |
---|
| 62 | } |
---|
| 63 | else |
---|
| 64 | { |
---|
| 65 | pNorm(h.p); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | if(h.IsNull()) return; |
---|
| 70 | |
---|
| 71 | // statistic |
---|
| 72 | if (TEST_OPT_PROT) |
---|
| 73 | { |
---|
| 74 | PrintS("s\n"); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | #ifdef KDEBUG |
---|
| 78 | if (TEST_OPT_DEBUG) |
---|
| 79 | { |
---|
| 80 | PrintS("new s:"); |
---|
| 81 | wrp(h.p); |
---|
| 82 | PrintLn(); |
---|
| 83 | } |
---|
| 84 | #endif |
---|
| 85 | |
---|
| 86 | enterpairs(h.p, strat->sl, h.ecart, 0, strat); |
---|
| 87 | |
---|
| 88 | pos=0; |
---|
| 89 | |
---|
| 90 | if (strat->sl!=-1) pos = posInS(strat, strat->sl, h.p, h.ecart); |
---|
| 91 | strat->enterS(h, pos, strat, -1); |
---|
| 92 | // enterT(h, strat); // ?! |
---|
| 93 | |
---|
| 94 | if (h.lcm!=NULL) pLmFree(h.lcm); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | ideal sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing) |
---|
| 102 | { |
---|
[64f0ca] | 103 | const ring save = currRing; |
---|
| 104 | if( currRing != _currRing ) rChangeCurrRing(_currRing); |
---|
| 105 | assume( currRing == _currRing ); |
---|
| 106 | |
---|
[a9c298] | 107 | |
---|
[c7aad0] | 108 | #if MYTEST |
---|
| 109 | PrintS("<sca_gr_bba>\n"); |
---|
| 110 | #endif |
---|
| 111 | |
---|
| 112 | assume(rIsSCA(currRing)); |
---|
| 113 | |
---|
| 114 | #ifndef NDEBUG |
---|
| 115 | idTest(F); |
---|
| 116 | idTest(Q); |
---|
| 117 | #endif |
---|
| 118 | |
---|
| 119 | #ifdef HAVE_PLURAL |
---|
| 120 | #if MYTEST |
---|
| 121 | PrintS("currRing: \n"); |
---|
| 122 | rWrite(currRing); |
---|
| 123 | #ifdef RDEBUG |
---|
| 124 | rDebugPrint(currRing); |
---|
| 125 | #endif |
---|
| 126 | |
---|
| 127 | PrintS("F: \n"); |
---|
| 128 | idPrint(F); |
---|
| 129 | PrintS("Q: \n"); |
---|
| 130 | idPrint(Q); |
---|
| 131 | #endif |
---|
| 132 | #endif |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 136 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 137 | |
---|
| 138 | ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 139 | ideal tempQ = Q; |
---|
| 140 | |
---|
| 141 | if(Q == currQuotient) |
---|
| 142 | tempQ = SCAQuotient(currRing); |
---|
| 143 | |
---|
| 144 | strat->z2homog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL! |
---|
| 145 | // redo: no_prod_crit |
---|
| 146 | const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit |
---|
| 147 | strat->no_prod_crit = ! bIsSCA; |
---|
| 148 | |
---|
| 149 | // strat->homog = strat->homog && strat->z2homog; // ? |
---|
| 150 | |
---|
| 151 | #if MYTEST |
---|
| 152 | { |
---|
| 153 | PrintS("ideal tempF: \n"); |
---|
| 154 | idPrint(tempF); |
---|
| 155 | PrintS("ideal tempQ: \n"); |
---|
| 156 | idPrint(tempQ); |
---|
| 157 | } |
---|
| 158 | #endif |
---|
| 159 | |
---|
| 160 | int olddeg, reduc; |
---|
| 161 | int red_result = 1; |
---|
| 162 | // int hilbeledeg = 1, minimcnt = 0; |
---|
| 163 | int hilbcount = 0; |
---|
| 164 | |
---|
| 165 | initBuchMoraCrit(strat); // set Gebauer, honey, sugarCrit |
---|
| 166 | |
---|
| 167 | nc_gr_initBba(tempF,strat); // set enterS, red, initEcart, initEcartPair |
---|
| 168 | |
---|
| 169 | initBuchMoraPos(strat); |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | // ?? set spSpolyShort, reduce ??? |
---|
| 173 | |
---|
| 174 | initBuchMora(tempF, tempQ, strat); // SCAQuotient(currRing) instead of Q == squares!!!!!!! |
---|
| 175 | |
---|
| 176 | strat->posInT=posInT110; // !!! |
---|
| 177 | |
---|
[930ea8] | 178 | reduc = olddeg = 0; |
---|
[c7aad0] | 179 | |
---|
| 180 | |
---|
| 181 | // compute------------------------------------------------------- |
---|
| 182 | for(; strat->Ll >= 0; |
---|
| 183 | #ifdef KDEBUG |
---|
| 184 | strat->P.lcm = NULL, |
---|
| 185 | #endif |
---|
| 186 | kTest(strat) |
---|
| 187 | ) |
---|
| 188 | { |
---|
| 189 | #ifdef KDEBUG |
---|
| 190 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 191 | #endif |
---|
| 192 | |
---|
| 193 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
| 194 | |
---|
| 195 | if (TEST_OPT_DEGBOUND |
---|
| 196 | && ((strat->honey |
---|
[64f0ca] | 197 | && (strat->L[strat->Ll].ecart+ currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 198 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
[c7aad0] | 199 | { |
---|
| 200 | // stops computation if |
---|
| 201 | // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
| 202 | // a predefined number Kstd1_deg |
---|
| 203 | while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 204 | break; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | // picks the last element from the lazyset L |
---|
| 208 | strat->P = strat->L[strat->Ll]; |
---|
| 209 | strat->Ll--; |
---|
| 210 | |
---|
| 211 | //kTest(strat); |
---|
| 212 | |
---|
| 213 | // assume(pNext(strat->P.p) != strat->tail); // !??? |
---|
| 214 | if(strat->P.IsNull()) continue; |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | if( pNext(strat->P.p) == strat->tail ) |
---|
| 218 | { |
---|
| 219 | // deletes the int spoly and computes SPoly |
---|
| 220 | pLmFree(strat->P.p); // ??? |
---|
| 221 | strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | if(strat->P.IsNull()) continue; |
---|
| 225 | |
---|
| 226 | // poly save = NULL; |
---|
| 227 | // |
---|
| 228 | // if(pNext(strat->P.p) != NULL) |
---|
| 229 | // save = p_Copy(strat->P.p, currRing); |
---|
| 230 | |
---|
| 231 | strat->initEcart(&strat->P); // remove it? |
---|
| 232 | |
---|
| 233 | if (TEST_OPT_PROT) |
---|
| 234 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), &olddeg,&reduc,strat, red_result); |
---|
| 235 | |
---|
| 236 | // reduction of the element chosen from L wrt S |
---|
| 237 | strat->red(&strat->P,strat); |
---|
| 238 | |
---|
| 239 | if(strat->P.IsNull()) continue; |
---|
| 240 | |
---|
| 241 | addLObject(strat->P, strat); |
---|
| 242 | |
---|
| 243 | const poly save = strat->P.p; |
---|
| 244 | |
---|
| 245 | #ifdef PDEBUG |
---|
| 246 | p_Test(save, currRing); |
---|
| 247 | #endif |
---|
| 248 | assume( save != NULL ); |
---|
| 249 | |
---|
| 250 | // SCA Specials: |
---|
| 251 | |
---|
| 252 | { |
---|
| 253 | const poly p_next = pNext(save); |
---|
| 254 | |
---|
| 255 | if( p_next != NULL ) |
---|
| 256 | for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) |
---|
| 257 | if( p_GetExp(save, i, currRing) != 0 ) |
---|
| 258 | { |
---|
| 259 | assume(p_GetExp(save, i, currRing) == 1); |
---|
| 260 | |
---|
| 261 | const poly tt = sca_pp_Mult_xi_pp(i, p_next, currRing); |
---|
| 262 | |
---|
| 263 | #ifdef PDEBUG |
---|
| 264 | p_Test(tt, currRing); |
---|
| 265 | #endif |
---|
| 266 | |
---|
| 267 | if( tt == NULL) continue; |
---|
| 268 | |
---|
| 269 | LObject h(tt); // h = x_i * P |
---|
| 270 | |
---|
| 271 | if (TEST_OPT_INTSTRATEGY) |
---|
| 272 | { |
---|
| 273 | // h.pCleardenom(); // also does a p_Content |
---|
| 274 | p_Content(h.p,currRing); |
---|
| 275 | } |
---|
| 276 | else |
---|
| 277 | { |
---|
| 278 | h.pNorm(); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | strat->initEcart(&h); |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | // if (pOrdSgn==-1) |
---|
| 285 | // { |
---|
| 286 | // cancelunit(&h); // tries to cancel a unit |
---|
| 287 | // deleteHC(&h, strat); |
---|
| 288 | // } |
---|
| 289 | |
---|
| 290 | // if(h.IsNull()) continue; |
---|
| 291 | |
---|
| 292 | // if (TEST_OPT_PROT) |
---|
| 293 | // message((strat->honey ? h.ecart : 0) + h.pFDeg(), &olddeg, &reduc, strat, red_result); |
---|
| 294 | |
---|
| 295 | // strat->red(&h, strat); // wrt S |
---|
| 296 | // if(h.IsNull()) continue; |
---|
| 297 | |
---|
| 298 | // poly save = p_Copy(h.p, currRing); |
---|
| 299 | |
---|
| 300 | int pos; |
---|
| 301 | |
---|
| 302 | if (strat->Ll==-1) |
---|
| 303 | pos =0; |
---|
| 304 | else |
---|
| 305 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 306 | |
---|
| 307 | h.sev = pGetShortExpVector(h.p); |
---|
| 308 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 309 | |
---|
| 310 | // h.p = save; |
---|
| 311 | // addLObject(h, strat); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | // p_Delete( &save, currRing ); |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | } // for(;;) |
---|
| 319 | |
---|
| 320 | |
---|
| 321 | #ifdef KDEBUG |
---|
| 322 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 323 | #endif |
---|
| 324 | |
---|
| 325 | if (TEST_OPT_REDSB){ |
---|
| 326 | completeReduce(strat); // ??? |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | // release temp data-------------------------------- |
---|
| 330 | exitBuchMora(strat); |
---|
| 331 | |
---|
[64f0ca] | 332 | // if (TEST_OPT_WEIGHTM) |
---|
| 333 | // { |
---|
| 334 | // pRestoreDegProcs(currRing,pFDegOld, pLDegOld); |
---|
| 335 | // if (ecartWeights) |
---|
| 336 | // { |
---|
| 337 | // omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(int)); |
---|
| 338 | // ecartWeights=NULL; |
---|
| 339 | // } |
---|
| 340 | // } |
---|
[c7aad0] | 341 | |
---|
[930ea8] | 342 | if (TEST_OPT_PROT) messageStat(hilbcount,strat); |
---|
[c7aad0] | 343 | |
---|
| 344 | if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); |
---|
| 345 | |
---|
| 346 | id_Delete(&tempF, currRing); |
---|
| 347 | |
---|
| 348 | |
---|
| 349 | // complete reduction of the standard basis--------- |
---|
| 350 | if (TEST_OPT_REDSB){ |
---|
| 351 | ideal I = strat->Shdl; |
---|
| 352 | ideal erg = kInterRedOld(I,tempQ); |
---|
| 353 | assume(I!=erg); |
---|
| 354 | id_Delete(&I, currRing); |
---|
| 355 | strat->Shdl = erg; |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | |
---|
| 359 | #if MYTEST |
---|
| 360 | // PrintS("</sca_gr_bba>\n"); |
---|
| 361 | #endif |
---|
| 362 | |
---|
[64f0ca] | 363 | if( currRing != save ) rChangeCurrRing(save); |
---|
[a9c298] | 364 | |
---|
[c7aad0] | 365 | return (strat->Shdl); |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | |
---|
| 369 | |
---|
| 370 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 371 | //************* SCA BBA *************************************************************// |
---|
| 372 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 373 | |
---|
| 374 | // Under development!!! |
---|
[2e4ec14] | 375 | ideal sca_bba (const ideal F, const ideal Q, const intvec */*w*/, const intvec * /*hilb*/, kStrategy strat, const ring _currRing) |
---|
[c7aad0] | 376 | { |
---|
[64f0ca] | 377 | const ring save = currRing; |
---|
| 378 | if( currRing != _currRing ) rChangeCurrRing(_currRing); |
---|
| 379 | assume( currRing == _currRing ); |
---|
| 380 | |
---|
[c7aad0] | 381 | #if MYTEST |
---|
| 382 | PrintS("\n\n<sca_bba>\n\n"); |
---|
| 383 | #endif |
---|
| 384 | |
---|
| 385 | assume(rIsSCA(currRing)); |
---|
| 386 | |
---|
| 387 | #ifndef NDEBUG |
---|
| 388 | idTest(F); |
---|
| 389 | idTest(Q); |
---|
| 390 | #endif |
---|
| 391 | |
---|
| 392 | #if MYTEST |
---|
| 393 | PrintS("\ncurrRing: \n"); |
---|
| 394 | rWrite(currRing); |
---|
| 395 | #ifdef RDEBUG |
---|
| 396 | // rDebugPrint(currRing); |
---|
| 397 | #endif |
---|
| 398 | |
---|
| 399 | PrintS("\n\nF: \n"); |
---|
| 400 | idPrint(F); |
---|
| 401 | PrintS("\n\nQ: \n"); |
---|
| 402 | idPrint(Q); |
---|
| 403 | |
---|
| 404 | PrintLn(); |
---|
| 405 | #endif |
---|
| 406 | |
---|
| 407 | |
---|
| 408 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 409 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 410 | |
---|
| 411 | ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 412 | |
---|
| 413 | ideal tempQ = Q; |
---|
| 414 | |
---|
| 415 | if(Q == currQuotient) |
---|
| 416 | tempQ = SCAQuotient(currRing); |
---|
| 417 | |
---|
| 418 | // Q or tempQ will not be used below :((( |
---|
| 419 | |
---|
| 420 | |
---|
| 421 | #if MYTEST |
---|
| 422 | |
---|
| 423 | PrintS("tempF: \n"); |
---|
| 424 | idPrint(tempF); |
---|
| 425 | PrintS("tempQ: \n"); |
---|
| 426 | idPrint(tempQ); |
---|
| 427 | #endif |
---|
| 428 | |
---|
| 429 | strat->z2homog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL! |
---|
| 430 | // redo no_prod_crit: |
---|
| 431 | const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit |
---|
| 432 | strat->no_prod_crit = ! bIsSCA; |
---|
| 433 | |
---|
| 434 | // strat->homog = strat->homog && strat->z2homog; // ? |
---|
| 435 | |
---|
[930ea8] | 436 | int red_result = 1; |
---|
[c7aad0] | 437 | int olddeg, reduc; |
---|
| 438 | |
---|
| 439 | // int hilbeledeg = 1, minimcnt = 0; |
---|
| 440 | int hilbcount = 0; |
---|
| 441 | |
---|
| 442 | BOOLEAN withT = FALSE; |
---|
| 443 | |
---|
| 444 | initBuchMoraCrit(strat); // sets Gebauer, honey, sugarCrit // sca - ok??? |
---|
| 445 | initBuchMoraPos(strat); // sets strat->posInL, strat->posInT // check!! (Plural's: ) |
---|
| 446 | |
---|
| 447 | // initHilbCrit(F, Q, &hilb, strat); |
---|
| 448 | |
---|
| 449 | // nc_gr_initBba(F,strat); |
---|
| 450 | initBba(tempF, strat); // set enterS, red, initEcart, initEcartPair |
---|
| 451 | |
---|
| 452 | // set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair |
---|
| 453 | // ?? set spSpolyShort, reduce ??? |
---|
| 454 | initBuchMora(tempF, tempQ, strat); // tempQ = Q without squares!!! |
---|
| 455 | |
---|
| 456 | // if (strat->minim>0) strat->M = idInit(IDELEMS(F),F->rank); |
---|
| 457 | |
---|
[930ea8] | 458 | reduc = olddeg = 0; |
---|
[c7aad0] | 459 | |
---|
| 460 | #define NO_BUCKETS |
---|
| 461 | |
---|
| 462 | #ifndef NO_BUCKETS |
---|
| 463 | if (!TEST_OPT_NOT_BUCKETS) |
---|
| 464 | strat->use_buckets = 1; |
---|
| 465 | #endif |
---|
| 466 | |
---|
| 467 | // redtailBBa against T for inhomogenous input |
---|
| 468 | if (!TEST_OPT_OLDSTD) |
---|
| 469 | withT = ! strat->homog; |
---|
| 470 | |
---|
| 471 | // strat->posInT = posInT_pLength; |
---|
[d101b1] | 472 | assume(kTest_TS(strat)); |
---|
[c7aad0] | 473 | |
---|
| 474 | #undef HAVE_TAIL_RING |
---|
| 475 | |
---|
| 476 | #ifdef HAVE_TAIL_RING |
---|
| 477 | if(!idIs0(F) &&(!rField_is_Ring())) // create strong gcd poly computes with tailring and S[i] ->to be fixed |
---|
| 478 | kStratInitChangeTailRing(strat); |
---|
| 479 | #endif |
---|
| 480 | if (BVERBOSE(23)) |
---|
| 481 | { |
---|
| 482 | if (test_PosInT!=NULL) strat->posInT=test_PosInT; |
---|
| 483 | if (test_PosInL!=NULL) strat->posInL=test_PosInL; |
---|
| 484 | kDebugPrint(strat); |
---|
| 485 | } |
---|
[a9c298] | 486 | |
---|
[c7aad0] | 487 | |
---|
| 488 | /////////////////////////////////////////////////////////////// |
---|
| 489 | // SCA: |
---|
| 490 | |
---|
| 491 | // due to std( SB, p). |
---|
| 492 | // Note that after initBuchMora :: initSSpecial all these additional |
---|
| 493 | // elements are in S and T (and some pairs are in L, which also has no initiall |
---|
| 494 | // elements!!!) |
---|
| 495 | if(TEST_OPT_SB_1) |
---|
| 496 | { |
---|
| 497 | // For all additional elements... |
---|
| 498 | for (int iNewElement = strat->newIdeal; iNewElement < IDELEMS(tempF); iNewElement++) |
---|
| 499 | { |
---|
| 500 | const poly pSave = tempF->m[iNewElement]; |
---|
| 501 | |
---|
| 502 | if( pSave != NULL ) |
---|
| 503 | { |
---|
| 504 | // tempF->m[iNewElement] = NULL; |
---|
| 505 | |
---|
| 506 | const poly p_next = pNext(pSave); |
---|
| 507 | |
---|
| 508 | if(p_next != NULL) |
---|
| 509 | for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) |
---|
| 510 | if( p_GetExp(pSave, i, currRing) != 0 ) |
---|
| 511 | { |
---|
| 512 | assume(p_GetExp(pSave, i, currRing) == 1); |
---|
| 513 | |
---|
| 514 | const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing); |
---|
| 515 | |
---|
| 516 | #ifdef PDEBUG |
---|
| 517 | p_Test(p_new, currRing); |
---|
| 518 | #endif |
---|
| 519 | |
---|
| 520 | if( p_new == NULL) continue; |
---|
| 521 | |
---|
| 522 | LObject h(p_new); // h = x_i * strat->P |
---|
| 523 | h.is_special = TRUE; |
---|
| 524 | |
---|
| 525 | if (TEST_OPT_INTSTRATEGY) |
---|
| 526 | h.pCleardenom(); // also does a p_Content |
---|
| 527 | else |
---|
| 528 | h.pNorm(); |
---|
| 529 | |
---|
| 530 | strat->initEcart(&h); |
---|
| 531 | h.sev = pGetShortExpVector(h.p); |
---|
| 532 | |
---|
| 533 | int pos = 0; |
---|
| 534 | |
---|
| 535 | if (strat->Ll != -1) |
---|
| 536 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 537 | |
---|
| 538 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | } |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | // compute------------------------------------------------------- |
---|
| 545 | while (strat->Ll >= 0) |
---|
| 546 | { |
---|
| 547 | #ifdef KDEBUG |
---|
| 548 | // loop_count++; |
---|
| 549 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 550 | #endif |
---|
| 551 | |
---|
| 552 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
| 553 | |
---|
| 554 | if (TEST_OPT_DEGBOUND |
---|
[64f0ca] | 555 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 556 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
[c7aad0] | 557 | { |
---|
| 558 | |
---|
| 559 | #ifdef KDEBUG |
---|
| 560 | // if (TEST_OPT_DEBUG){PrintS("^^^^?");} |
---|
| 561 | #endif |
---|
| 562 | |
---|
| 563 | // *stops computation if |
---|
| 564 | // * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
| 565 | // *a predefined number Kstd1_deg |
---|
| 566 | while ((strat->Ll >= 0) |
---|
| 567 | && ( (strat->homog==isHomog) || strat->L[strat->Ll].is_special || ((strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)) ) |
---|
[64f0ca] | 568 | && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
| 569 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))) |
---|
[c7aad0] | 570 | ) |
---|
| 571 | { |
---|
| 572 | #ifdef KDEBUG |
---|
| 573 | // if (TEST_OPT_DEBUG){PrintS("^^^^^^^^^^^^!!!!");} |
---|
| 574 | #endif |
---|
| 575 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 576 | // if (TEST_OPT_PROT) PrintS("^!"); |
---|
| 577 | } |
---|
| 578 | if (strat->Ll<0) break; |
---|
| 579 | else strat->noClearS=TRUE; |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | // picks the last element from the lazyset L |
---|
| 583 | strat->P = strat->L[strat->Ll]; |
---|
| 584 | strat->Ll--; |
---|
| 585 | |
---|
| 586 | |
---|
| 587 | // assume(pNext(strat->P.p) != strat->tail); |
---|
| 588 | |
---|
| 589 | if(strat->P.IsNull()) continue; |
---|
| 590 | |
---|
| 591 | if (pNext(strat->P.p) == strat->tail) |
---|
| 592 | { |
---|
| 593 | // deletes the short spoly |
---|
| 594 | pLmFree(strat->P.p); |
---|
| 595 | |
---|
| 596 | strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing); |
---|
| 597 | if (strat->P.p!=NULL) strat->initEcart(&strat->P); |
---|
| 598 | }// else |
---|
| 599 | |
---|
| 600 | |
---|
| 601 | if(strat->P.IsNull()) continue; |
---|
| 602 | |
---|
| 603 | if (strat->P.p1 == NULL) |
---|
| 604 | { |
---|
| 605 | // if (strat->minim > 0) |
---|
| 606 | // strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); |
---|
| 607 | |
---|
| 608 | |
---|
| 609 | // for input polys, prepare reduction |
---|
| 610 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 611 | } |
---|
| 612 | |
---|
| 613 | if (TEST_OPT_PROT) |
---|
| 614 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
| 615 | &olddeg,&reduc,strat, red_result); |
---|
| 616 | |
---|
| 617 | // reduction of the element choosen from L |
---|
| 618 | red_result = strat->red(&strat->P,strat); |
---|
| 619 | |
---|
| 620 | |
---|
| 621 | // reduction to non-zero new poly |
---|
| 622 | if (red_result == 1) |
---|
| 623 | { |
---|
| 624 | // statistic |
---|
| 625 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 626 | |
---|
| 627 | // get the polynomial (canonicalize bucket, make sure P.p is set) |
---|
| 628 | strat->P.GetP(strat->lmBin); |
---|
| 629 | |
---|
| 630 | int pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
| 631 | |
---|
| 632 | // reduce the tail and normalize poly |
---|
| 633 | if (TEST_OPT_INTSTRATEGY) |
---|
| 634 | { |
---|
| 635 | strat->P.pCleardenom(); |
---|
| 636 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 637 | { |
---|
| 638 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); // !!! |
---|
| 639 | strat->P.pCleardenom(); |
---|
| 640 | } |
---|
| 641 | } |
---|
| 642 | else |
---|
| 643 | { |
---|
| 644 | strat->P.pNorm(); |
---|
| 645 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 646 | strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); |
---|
| 647 | } |
---|
| 648 | strat->P.is_normalized=nIsOne(pGetCoeff(strat->P.p)); |
---|
| 649 | |
---|
| 650 | #ifdef KDEBUG |
---|
| 651 | if (TEST_OPT_DEBUG){PrintS(" ns:");p_wrp(strat->P.p,currRing);PrintLn();} |
---|
| 652 | #endif |
---|
| 653 | |
---|
| 654 | // // min_std stuff |
---|
| 655 | // if ((strat->P.p1==NULL) && (strat->minim>0)) |
---|
| 656 | // { |
---|
| 657 | // if (strat->minim==1) |
---|
| 658 | // { |
---|
| 659 | // strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); |
---|
| 660 | // p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 661 | // } |
---|
| 662 | // else |
---|
| 663 | // { |
---|
| 664 | // strat->M->m[minimcnt]=strat->P.p2; |
---|
| 665 | // strat->P.p2=NULL; |
---|
| 666 | // } |
---|
| 667 | // if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) |
---|
| 668 | // pNext(strat->M->m[minimcnt]) |
---|
| 669 | // = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), |
---|
| 670 | // strat->tailRing, currRing, |
---|
| 671 | // currRing->PolyBin); |
---|
| 672 | // minimcnt++; |
---|
| 673 | // } |
---|
| 674 | |
---|
| 675 | // enter into S, L, and T |
---|
| 676 | //if(withT) |
---|
| 677 | enterT(strat->P, strat); |
---|
| 678 | |
---|
| 679 | // L |
---|
| 680 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); |
---|
| 681 | |
---|
| 682 | // posInS only depends on the leading term |
---|
| 683 | strat->enterS(strat->P, pos, strat, strat->tl); |
---|
| 684 | |
---|
| 685 | // if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
| 686 | |
---|
| 687 | // Print("[%d]",hilbeledeg); |
---|
| 688 | if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); |
---|
| 689 | |
---|
| 690 | // ////////////////////////////////////////////////////////// |
---|
| 691 | // SCA: |
---|
| 692 | const poly pSave = strat->P.p; |
---|
| 693 | const poly p_next = pNext(pSave); |
---|
| 694 | |
---|
| 695 | // if(0) |
---|
| 696 | if( p_next != NULL ) |
---|
| 697 | for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) |
---|
| 698 | if( p_GetExp(pSave, i, currRing) != 0 ) |
---|
| 699 | { |
---|
| 700 | assume(p_GetExp(pSave, i, currRing) == 1); |
---|
| 701 | const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing); |
---|
| 702 | |
---|
| 703 | #ifdef PDEBUG |
---|
| 704 | p_Test(p_new, currRing); |
---|
| 705 | #endif |
---|
| 706 | |
---|
| 707 | if( p_new == NULL) continue; |
---|
| 708 | |
---|
| 709 | LObject h(p_new); // h = x_i * strat->P |
---|
| 710 | |
---|
| 711 | h.is_special = TRUE; |
---|
| 712 | |
---|
| 713 | if (TEST_OPT_INTSTRATEGY) |
---|
| 714 | { |
---|
| 715 | // p_Content(h.p); |
---|
| 716 | h.pCleardenom(); // also does a p_Content |
---|
| 717 | } |
---|
| 718 | else |
---|
| 719 | { |
---|
| 720 | h.pNorm(); |
---|
| 721 | } |
---|
| 722 | |
---|
| 723 | strat->initEcart(&h); |
---|
| 724 | h.sev = pGetShortExpVector(h.p); |
---|
| 725 | |
---|
| 726 | int pos = 0; |
---|
| 727 | |
---|
| 728 | if (strat->Ll != -1) |
---|
| 729 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 730 | |
---|
| 731 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 732 | |
---|
[a9c298] | 733 | |
---|
| 734 | |
---|
| 735 | |
---|
| 736 | #if 0 |
---|
[c7aad0] | 737 | h.sev = pGetShortExpVector(h.p); |
---|
| 738 | strat->initEcart(&h); |
---|
| 739 | |
---|
| 740 | h.PrepareRed(strat->use_buckets); |
---|
| 741 | |
---|
| 742 | // reduction of the element choosen from L(?) |
---|
| 743 | red_result = strat->red(&h,strat); |
---|
| 744 | |
---|
| 745 | // reduction to non-zero new poly |
---|
| 746 | if (red_result != 1) continue; |
---|
| 747 | |
---|
| 748 | |
---|
| 749 | int pos = posInS(strat,strat->sl,h.p,h.ecart); |
---|
| 750 | |
---|
| 751 | // reduce the tail and normalize poly |
---|
| 752 | if (TEST_OPT_INTSTRATEGY) |
---|
| 753 | { |
---|
| 754 | h.pCleardenom(); |
---|
| 755 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 756 | { |
---|
| 757 | h.p = redtailBba(&(h),pos-1,strat, withT); // !!! |
---|
| 758 | h.pCleardenom(); |
---|
| 759 | } |
---|
| 760 | } |
---|
| 761 | else |
---|
| 762 | { |
---|
| 763 | h.pNorm(); |
---|
| 764 | if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) |
---|
| 765 | h.p = redtailBba(&(h),pos-1,strat, withT); |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | #ifdef KDEBUG |
---|
| 769 | if (TEST_OPT_DEBUG){PrintS(" N:");h.wrp();PrintLn();} |
---|
| 770 | #endif |
---|
| 771 | |
---|
| 772 | // h.PrepareRed(strat->use_buckets); // ??? |
---|
| 773 | |
---|
| 774 | h.sev = pGetShortExpVector(h.p); |
---|
| 775 | strat->initEcart(&h); |
---|
| 776 | |
---|
| 777 | if (strat->Ll==-1) |
---|
| 778 | pos = 0; |
---|
| 779 | else |
---|
| 780 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 781 | |
---|
| 782 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
[a9c298] | 783 | // the end of "#if 0" (comment) |
---|
| 784 | #endif |
---|
[c7aad0] | 785 | |
---|
| 786 | } // for all x_i \in Ann(lm(P)) |
---|
| 787 | } // if red(P) != NULL |
---|
| 788 | |
---|
| 789 | // else if (strat->P.p1 == NULL && strat->minim > 0) |
---|
| 790 | // { |
---|
| 791 | // p_Delete(&strat->P.p2, currRing, strat->tailRing); |
---|
| 792 | // } |
---|
| 793 | |
---|
| 794 | #ifdef KDEBUG |
---|
| 795 | // memset(&(strat->P), 0, sizeof(strat->P)); |
---|
| 796 | #endif |
---|
| 797 | |
---|
[d101b1] | 798 | assume(kTest_TS(strat)); // even of T is not used! |
---|
[c7aad0] | 799 | |
---|
| 800 | // Print("\n$\n"); |
---|
| 801 | |
---|
| 802 | } |
---|
| 803 | |
---|
| 804 | #ifdef KDEBUG |
---|
| 805 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 806 | #endif |
---|
| 807 | |
---|
| 808 | // complete reduction of the standard basis--------- |
---|
| 809 | |
---|
| 810 | if (TEST_OPT_REDSB) |
---|
| 811 | { |
---|
| 812 | completeReduce(strat); |
---|
| 813 | } |
---|
| 814 | |
---|
| 815 | //release temp data-------------------------------- |
---|
| 816 | |
---|
| 817 | exitBuchMora(strat); // cleanT! |
---|
| 818 | |
---|
| 819 | id_Delete(&tempF, currRing); |
---|
| 820 | |
---|
[64f0ca] | 821 | // if (TEST_OPT_WEIGHTM) |
---|
| 822 | // { |
---|
| 823 | // pRestoreDegProcs(currRing, pFDegOld, pLDegOld); |
---|
| 824 | // if (ecartWeights) |
---|
| 825 | // { |
---|
| 826 | // omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short)); |
---|
| 827 | // ecartWeights=NULL; |
---|
| 828 | // } |
---|
| 829 | // } |
---|
[c7aad0] | 830 | |
---|
[930ea8] | 831 | if (TEST_OPT_PROT) messageStat(hilbcount,strat); |
---|
[c7aad0] | 832 | |
---|
| 833 | |
---|
| 834 | |
---|
| 835 | if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); |
---|
| 836 | |
---|
| 837 | |
---|
| 838 | if (TEST_OPT_REDSB) // ??? |
---|
| 839 | { |
---|
| 840 | // must be at the very end (after exitBuchMora) as it changes the S set!!! |
---|
| 841 | ideal I = strat->Shdl; |
---|
| 842 | ideal erg = kInterRedOld(I,tempQ); |
---|
| 843 | assume(I!=erg); |
---|
| 844 | id_Delete(&I, currRing); |
---|
| 845 | strat->Shdl = erg; |
---|
| 846 | } |
---|
| 847 | |
---|
| 848 | #if MYTEST |
---|
| 849 | PrintS("\n\n</sca_bba>\n\n"); |
---|
| 850 | #endif |
---|
| 851 | |
---|
[64f0ca] | 852 | if( currRing != save ) rChangeCurrRing(save); |
---|
[a9c298] | 853 | |
---|
[c7aad0] | 854 | return (strat->Shdl); |
---|
| 855 | } |
---|
| 856 | |
---|
| 857 | // ////////////////////////////////////////////////////////////////////////////// |
---|
| 858 | // sca mora... |
---|
| 859 | |
---|
| 860 | // returns TRUE if mora should use buckets, false otherwise |
---|
[2e4ec14] | 861 | #ifdef MORA_USE_BUCKETS |
---|
[c7aad0] | 862 | static BOOLEAN kMoraUseBucket(kStrategy strat) |
---|
[2e4ec14] | 863 | #else |
---|
| 864 | static BOOLEAN kMoraUseBucket(kStrategy) |
---|
| 865 | #endif |
---|
[c7aad0] | 866 | { |
---|
| 867 | #ifdef MORA_USE_BUCKETS |
---|
| 868 | if (TEST_OPT_NOT_BUCKETS) |
---|
| 869 | return FALSE; |
---|
| 870 | if (strat->red == redFirst) |
---|
| 871 | { |
---|
| 872 | #ifdef NO_LDEG |
---|
| 873 | if (!strat->syzComp) |
---|
| 874 | return TRUE; |
---|
| 875 | #else |
---|
| 876 | if ((strat->homog || strat->honey) && !strat->syzComp) |
---|
| 877 | return TRUE; |
---|
| 878 | #endif |
---|
| 879 | } |
---|
| 880 | else |
---|
| 881 | { |
---|
| 882 | assume(strat->red == redEcart); |
---|
| 883 | if (strat->honey && !strat->syzComp) |
---|
| 884 | return TRUE; |
---|
| 885 | } |
---|
| 886 | #endif |
---|
| 887 | return FALSE; |
---|
| 888 | } |
---|
| 889 | |
---|
| 890 | #ifdef HAVE_ASSUME |
---|
| 891 | static int sca_mora_count = 0; |
---|
| 892 | static int sca_mora_loop_count; |
---|
| 893 | #endif |
---|
| 894 | |
---|
| 895 | // ideal sca_mora (ideal F, ideal Q, intvec *w, intvec *, kStrategy strat) |
---|
[2e4ec14] | 896 | ideal sca_mora(const ideal F, const ideal Q, const intvec */*w*/, const intvec *, kStrategy strat, const ring _currRing) |
---|
[c7aad0] | 897 | { |
---|
[64f0ca] | 898 | const ring save = currRing; |
---|
| 899 | if( currRing != _currRing ) rChangeCurrRing(_currRing); |
---|
| 900 | assume( currRing == _currRing ); |
---|
| 901 | |
---|
[c7aad0] | 902 | assume(rIsSCA(currRing)); |
---|
| 903 | |
---|
| 904 | const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); |
---|
| 905 | const unsigned int m_iLastAltVar = scaLastAltVar(currRing); |
---|
| 906 | |
---|
| 907 | ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); |
---|
| 908 | |
---|
| 909 | ideal tempQ = Q; |
---|
| 910 | |
---|
| 911 | if(Q == currQuotient) |
---|
| 912 | tempQ = SCAQuotient(currRing); |
---|
| 913 | |
---|
| 914 | bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL! |
---|
| 915 | |
---|
| 916 | assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog |
---|
| 917 | |
---|
| 918 | strat->homog = strat->homog && bIdHomog; |
---|
| 919 | |
---|
| 920 | #ifdef PDEBUG |
---|
| 921 | assume( strat->homog == bIdHomog ); |
---|
[a9c298] | 922 | #endif |
---|
[c7aad0] | 923 | |
---|
| 924 | #ifdef HAVE_ASSUME |
---|
| 925 | sca_mora_count++; |
---|
| 926 | sca_mora_loop_count = 0; |
---|
| 927 | #endif |
---|
| 928 | |
---|
| 929 | strat->update = TRUE; |
---|
| 930 | //- setting global variables ------------------- - |
---|
| 931 | initBuchMoraCrit(strat); |
---|
| 932 | // initHilbCrit(F,NULL,&hilb,strat); // no Q! |
---|
| 933 | initMora(tempF, strat); |
---|
| 934 | initBuchMoraPos(strat); |
---|
| 935 | //Shdl= |
---|
| 936 | initBuchMora(tempF, tempQ, strat); // temp Q, F! |
---|
| 937 | // if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat); |
---|
| 938 | // updateS in initBuchMora has Hecketest |
---|
| 939 | // * and could have put strat->kHEdgdeFound FALSE |
---|
| 940 | #if 0 |
---|
| 941 | if (ppNoether!=NULL) |
---|
| 942 | { |
---|
| 943 | strat->kHEdgeFound = TRUE; |
---|
| 944 | } |
---|
| 945 | if (strat->kHEdgeFound && strat->update) |
---|
| 946 | { |
---|
| 947 | firstUpdate(strat); |
---|
| 948 | updateLHC(strat); |
---|
| 949 | reorderL(strat); |
---|
| 950 | } |
---|
| 951 | if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag) |
---|
| 952 | { |
---|
| 953 | strat->posInLOld = strat->posInL; |
---|
| 954 | strat->posInLOldFlag = FALSE; |
---|
| 955 | strat->posInL = posInL10; |
---|
| 956 | updateL(strat); |
---|
| 957 | reorderL(strat); |
---|
| 958 | } |
---|
| 959 | #endif |
---|
| 960 | strat->use_buckets = kMoraUseBucket(strat); |
---|
| 961 | |
---|
[d101b1] | 962 | assume(kTest_TS(strat)); |
---|
[c7aad0] | 963 | |
---|
| 964 | |
---|
| 965 | int olddeg = 0; |
---|
| 966 | int reduc = 0; |
---|
| 967 | int red_result = 1; |
---|
| 968 | // int hilbeledeg=1; |
---|
| 969 | int hilbcount=0; |
---|
| 970 | |
---|
| 971 | |
---|
| 972 | //- compute------------------------------------------- |
---|
| 973 | |
---|
| 974 | #undef HAVE_TAIL_RING |
---|
| 975 | |
---|
| 976 | #ifdef HAVE_TAIL_RING |
---|
| 977 | // if (strat->homog && strat->red == redFirst) |
---|
| 978 | // kStratInitChangeTailRing(strat); |
---|
| 979 | #endif |
---|
| 980 | |
---|
| 981 | |
---|
| 982 | |
---|
| 983 | |
---|
| 984 | |
---|
| 985 | // due to std( SB, p) |
---|
| 986 | if(TEST_OPT_SB_1) |
---|
| 987 | { |
---|
| 988 | for (int iNewElement = strat->newIdeal; iNewElement < IDELEMS(tempF); iNewElement++) |
---|
| 989 | { |
---|
| 990 | |
---|
| 991 | const poly pSave = tempF->m[iNewElement]; |
---|
| 992 | |
---|
| 993 | if( pSave != NULL ) |
---|
| 994 | { |
---|
| 995 | // tempF->m[iNewElement] = NULL; |
---|
| 996 | |
---|
| 997 | const poly p_next = pNext(pSave); |
---|
| 998 | |
---|
| 999 | if(p_next != NULL) |
---|
| 1000 | for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) |
---|
| 1001 | if( p_GetExp(pSave, i, currRing) != 0 ) |
---|
| 1002 | { |
---|
| 1003 | |
---|
| 1004 | assume(p_GetExp(pSave, i, currRing) == 1); |
---|
| 1005 | |
---|
| 1006 | const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing); |
---|
| 1007 | |
---|
| 1008 | #ifdef PDEBUG |
---|
| 1009 | p_Test(p_new, currRing); |
---|
| 1010 | #endif |
---|
| 1011 | |
---|
| 1012 | if( p_new == NULL) continue; |
---|
| 1013 | |
---|
| 1014 | LObject h(p_new); // h = x_i * strat->P |
---|
| 1015 | |
---|
| 1016 | if (TEST_OPT_INTSTRATEGY) |
---|
| 1017 | h.pCleardenom(); // also does a p_Content |
---|
| 1018 | else |
---|
| 1019 | h.pNorm(); |
---|
| 1020 | |
---|
| 1021 | strat->initEcart(&h); |
---|
| 1022 | h.sev = pGetShortExpVector(h.p); |
---|
| 1023 | |
---|
| 1024 | int pos = 0; |
---|
| 1025 | |
---|
| 1026 | if (strat->Ll != -1) |
---|
| 1027 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 1028 | |
---|
| 1029 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 1030 | } |
---|
| 1031 | } |
---|
| 1032 | |
---|
| 1033 | } |
---|
| 1034 | } |
---|
| 1035 | |
---|
| 1036 | |
---|
| 1037 | |
---|
| 1038 | |
---|
| 1039 | while (strat->Ll >= 0) |
---|
| 1040 | { |
---|
| 1041 | #ifdef HAVE_ASSUME |
---|
| 1042 | sca_mora_loop_count++; |
---|
| 1043 | #endif |
---|
| 1044 | //test_int_std(strat->kIdeal); |
---|
| 1045 | #ifdef KDEBUG |
---|
| 1046 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
| 1047 | #endif |
---|
| 1048 | if (TEST_OPT_DEGBOUND |
---|
| 1049 | && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)) |
---|
| 1050 | { |
---|
| 1051 | // * stops computation if |
---|
| 1052 | // * - 24 (degBound) |
---|
| 1053 | // * && upper degree is bigger than Kstd1_deg |
---|
| 1054 | while ((strat->Ll >= 0) |
---|
| 1055 | && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) |
---|
| 1056 | && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg) |
---|
| 1057 | ) |
---|
| 1058 | { |
---|
| 1059 | deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 1060 | //if (TEST_OPT_PROT) |
---|
| 1061 | //{ |
---|
| 1062 | // PrintS("D"); mflush(); |
---|
| 1063 | //} |
---|
| 1064 | } |
---|
| 1065 | if (strat->Ll<0) break; |
---|
| 1066 | else strat->noClearS=TRUE; |
---|
| 1067 | } |
---|
| 1068 | strat->P = strat->L[strat->Ll];// - picks the last element from the lazyset L - |
---|
| 1069 | if (strat->Ll==0) strat->interpt=TRUE; |
---|
| 1070 | strat->Ll--; |
---|
| 1071 | |
---|
| 1072 | // create the real Spoly |
---|
| 1073 | // assume(pNext(strat->P.p) != strat->tail); |
---|
| 1074 | |
---|
| 1075 | if(strat->P.IsNull()) continue; |
---|
| 1076 | |
---|
| 1077 | |
---|
| 1078 | if( pNext(strat->P.p) == strat->tail ) |
---|
| 1079 | { |
---|
| 1080 | // deletes the int spoly and computes SPoly |
---|
| 1081 | pLmFree(strat->P.p); // ??? |
---|
| 1082 | strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing); |
---|
| 1083 | } |
---|
| 1084 | |
---|
| 1085 | |
---|
| 1086 | |
---|
| 1087 | if (strat->P.p1 == NULL) |
---|
| 1088 | { |
---|
| 1089 | // for input polys, prepare reduction (buckets !) |
---|
| 1090 | strat->P.SetLength(strat->length_pLength); |
---|
| 1091 | strat->P.PrepareRed(strat->use_buckets); |
---|
| 1092 | } |
---|
| 1093 | |
---|
| 1094 | if (!strat->P.IsNull()) |
---|
| 1095 | { |
---|
| 1096 | // might be NULL from noether !!! |
---|
| 1097 | if (TEST_OPT_PROT) |
---|
| 1098 | message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result); |
---|
| 1099 | // reduce |
---|
| 1100 | red_result = strat->red(&strat->P,strat); |
---|
| 1101 | } |
---|
| 1102 | |
---|
| 1103 | if (! strat->P.IsNull()) |
---|
| 1104 | { |
---|
| 1105 | strat->P.GetP(); |
---|
| 1106 | // statistics |
---|
| 1107 | if (TEST_OPT_PROT) PrintS("s"); |
---|
| 1108 | // normalization |
---|
| 1109 | if (!TEST_OPT_INTSTRATEGY) |
---|
| 1110 | strat->P.pNorm(); |
---|
| 1111 | // tailreduction |
---|
| 1112 | strat->P.p = redtail(&(strat->P),strat->sl,strat); |
---|
| 1113 | // set ecart -- might have changed because of tail reductions |
---|
| 1114 | if ((!strat->noTailReduction) && (!strat->honey)) |
---|
| 1115 | strat->initEcart(&strat->P); |
---|
| 1116 | // cancel unit |
---|
| 1117 | cancelunit(&strat->P); |
---|
| 1118 | // for char 0, clear denominators |
---|
| 1119 | if (TEST_OPT_INTSTRATEGY) |
---|
| 1120 | strat->P.pCleardenom(); |
---|
| 1121 | |
---|
| 1122 | // put in T |
---|
| 1123 | enterT(strat->P,strat); |
---|
| 1124 | // build new pairs |
---|
| 1125 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl); |
---|
| 1126 | // put in S |
---|
| 1127 | strat->enterS(strat->P, |
---|
| 1128 | posInS(strat,strat->sl,strat->P.p, strat->P.ecart), |
---|
| 1129 | strat, strat->tl); |
---|
| 1130 | |
---|
| 1131 | |
---|
| 1132 | // clear strat->P |
---|
| 1133 | if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); |
---|
| 1134 | strat->P.lcm=NULL; |
---|
| 1135 | |
---|
| 1136 | // ////////////////////////////////////////////////////////// |
---|
| 1137 | // SCA: |
---|
| 1138 | const poly pSave = strat->P.p; |
---|
| 1139 | const poly p_next = pNext(pSave); |
---|
| 1140 | |
---|
| 1141 | if(p_next != NULL) |
---|
| 1142 | for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) |
---|
| 1143 | if( p_GetExp(pSave, i, currRing) != 0 ) |
---|
| 1144 | { |
---|
| 1145 | |
---|
| 1146 | assume(p_GetExp(pSave, i, currRing) == 1); |
---|
| 1147 | |
---|
| 1148 | const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing); |
---|
| 1149 | |
---|
| 1150 | #ifdef PDEBUG |
---|
| 1151 | p_Test(p_new, currRing); |
---|
| 1152 | #endif |
---|
| 1153 | |
---|
| 1154 | if( p_new == NULL) continue; |
---|
| 1155 | |
---|
| 1156 | LObject h(p_new); // h = x_i * strat->P |
---|
| 1157 | |
---|
| 1158 | if (TEST_OPT_INTSTRATEGY) |
---|
| 1159 | h.pCleardenom(); // also does a p_Content |
---|
| 1160 | else |
---|
| 1161 | h.pNorm(); |
---|
| 1162 | |
---|
| 1163 | strat->initEcart(&h); |
---|
| 1164 | h.sev = pGetShortExpVector(h.p); |
---|
| 1165 | |
---|
| 1166 | int pos = 0; |
---|
| 1167 | |
---|
| 1168 | if (strat->Ll != -1) |
---|
| 1169 | pos = strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
| 1170 | |
---|
| 1171 | enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
| 1172 | } |
---|
| 1173 | |
---|
| 1174 | #ifdef KDEBUG |
---|
| 1175 | // make sure kTest_TS does not complain about strat->P |
---|
| 1176 | memset(&strat->P,0,sizeof(strat->P)); |
---|
| 1177 | #endif |
---|
| 1178 | } |
---|
| 1179 | #if 0 |
---|
| 1180 | if (strat->kHEdgeFound) |
---|
| 1181 | { |
---|
| 1182 | if ((TEST_OPT_FINDET) |
---|
| 1183 | || ((TEST_OPT_MULTBOUND) && (scMult0Int((strat->Shdl)) < mu))) |
---|
| 1184 | { |
---|
| 1185 | // obachman: is this still used ??? |
---|
| 1186 | // * stops computation if strat->kHEdgeFound and |
---|
| 1187 | // * - 27 (finiteDeterminacyTest) |
---|
| 1188 | // * or |
---|
| 1189 | // * - 23 |
---|
| 1190 | // * (multBound) |
---|
| 1191 | // * && multiplicity of the ideal is smaller then a predefined number mu |
---|
| 1192 | while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
| 1193 | } |
---|
| 1194 | } |
---|
| 1195 | #endif |
---|
[d101b1] | 1196 | assume(kTest_TS(strat)); |
---|
[c7aad0] | 1197 | } |
---|
| 1198 | // - complete reduction of the standard basis------------------------ - |
---|
| 1199 | if (TEST_OPT_REDSB) completeReduce(strat); |
---|
| 1200 | // - release temp data------------------------------- - |
---|
| 1201 | exitBuchMora(strat); |
---|
| 1202 | // - polynomials used for HECKE: HC, noether - |
---|
| 1203 | if (TEST_OPT_FINDET) |
---|
| 1204 | { |
---|
| 1205 | if (strat->kHEdge!=NULL) |
---|
[64f0ca] | 1206 | Kstd1_mu=currRing->pFDeg(strat->kHEdge,currRing); |
---|
[c7aad0] | 1207 | else |
---|
| 1208 | Kstd1_mu=-1; |
---|
| 1209 | } |
---|
| 1210 | pDelete(&strat->kHEdge); |
---|
| 1211 | strat->update = TRUE; //??? |
---|
| 1212 | strat->lastAxis = 0; //??? |
---|
| 1213 | pDelete(&strat->kNoether); |
---|
[64f0ca] | 1214 | omFreeSize((ADDRESS)strat->NotUsedAxis,(rVar(currRing)+1)*sizeof(BOOLEAN)); |
---|
[930ea8] | 1215 | if (TEST_OPT_PROT) messageStat(hilbcount,strat); |
---|
[64f0ca] | 1216 | // if (TEST_OPT_WEIGHTM) |
---|
| 1217 | // { |
---|
| 1218 | // pRestoreDegProcs(currRing, pFDegOld, pLDegOld); |
---|
| 1219 | // if (ecartWeights) |
---|
| 1220 | // { |
---|
| 1221 | // omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short)); |
---|
| 1222 | // ecartWeights=NULL; |
---|
| 1223 | // } |
---|
| 1224 | // } |
---|
[c7aad0] | 1225 | if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); |
---|
| 1226 | idTest(strat->Shdl); |
---|
| 1227 | |
---|
| 1228 | id_Delete( &tempF, currRing); |
---|
| 1229 | |
---|
[64f0ca] | 1230 | if( currRing != save ) rChangeCurrRing(save); |
---|
[a9c298] | 1231 | |
---|
[c7aad0] | 1232 | return (strat->Shdl); |
---|
| 1233 | } |
---|
| 1234 | |
---|