Changeset 7d1e80 in git for kernel/GBEngine/kstd2.cc
- Timestamp:
- Aug 11, 2016, 4:31:28 PM (8 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 9005c821174cb97b8111112064f52487e4ca2220
- Parents:
- d5d857d04cf9046b2cdd0a2ce1fae1415473c269
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/GBEngine/kstd2.cc
rd5d857 r7d1e80 10 10 #include <kernel/mod2.h> 11 11 12 #define ADIDEBUG 112 //#define ADIDEBUG 1 13 13 #define GCD_SBA 1 14 14 … … 2195 2195 sba_interreduction_operations = 0; 2196 2196 #endif 2197 2197 2198 2198 ideal F1 = F0; 2199 2199 ring sRing, currRingOld; … … 2208 2208 } 2209 2209 } 2210 ideal F; 2210 2211 // sort ideal F 2211 ideal F = idInit(IDELEMS(F1),F1->rank); 2212 intvec *sort = idSort(F1); 2213 for (int i=0; i<sort->length();++i) 2214 F->m[i] = F1->m[(*sort)[i]-1]; 2212 //Put the SigDrop element on the correct position (think of sbaEnterS) 2213 //We also sort them 2214 if(rField_is_Ring(currRing) && strat->sigdrop) 2215 { 2216 #if 1 2217 F = idInit(IDELEMS(F1),F1->rank); 2218 for (int i=0; i<IDELEMS(F1);++i) 2219 F->m[i] = F1->m[i]; 2220 if(strat->sbaEnterS >= 0) 2221 { 2222 poly dummy; 2223 dummy = pCopy(F->m[0]); //the sigdrop element 2224 for(int i = 0;i<strat->sbaEnterS;i++) 2225 F->m[i] = F->m[i+1]; 2226 F->m[strat->sbaEnterS] = dummy; 2227 } 2228 #else 2229 F = idInit(1,F1->rank); 2230 //printf("\nBefore the initial block sorting:\n");idPrint(F1); 2231 F->m[0] = F1->m[0]; 2232 int pos; 2233 if(strat->sbaEnterS >= 0) 2234 { 2235 for(int i=1;i<=strat->sbaEnterS;i++) 2236 { 2237 pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS); 2238 idInsertPolyOnPos(F,F1->m[i],pos); 2239 } 2240 for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++) 2241 { 2242 pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F)); 2243 idInsertPolyOnPos(F,F1->m[i],pos); 2244 } 2245 poly dummy; 2246 dummy = pCopy(F->m[0]); //the sigdrop element 2247 for(int i = 0;i<strat->sbaEnterS;i++) 2248 F->m[i] = F->m[i+1]; 2249 F->m[strat->sbaEnterS] = dummy; 2250 } 2251 else 2252 { 2253 for(int i=1;i<IDELEMS(F1);i++) 2254 { 2255 pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F)); 2256 idInsertPolyOnPos(F,F1->m[i],pos); 2257 } 2258 } 2259 #endif 2260 //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar(); 2261 } 2262 else 2263 { 2264 F = idInit(IDELEMS(F1),F1->rank); 2265 intvec *sort = idSort(F1); 2266 for (int i=0; i<sort->length();++i) 2267 F->m[i] = F1->m[(*sort)[i]-1]; 2268 if(rField_is_Ring(currRing)) 2269 { 2270 // put the monomials after the sbaEnterS polynomials 2271 //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F); 2272 int nrmon = 0; 2273 for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--) 2274 { 2275 //pWrite(F->m[i]); 2276 if(F->m[i] != NULL && pNext(F->m[i]) == NULL) 2277 { 2278 poly mon = F->m[i]; 2279 for(j = i;j>strat->sbaEnterS+nrmon+1;j--) 2280 { 2281 F->m[j] = F->m[j-1]; 2282 } 2283 F->m[j] = mon; 2284 nrmon++; 2285 } 2286 //idPrint(F); 2287 } 2288 } 2289 } 2290 //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar(); 2291 if(rField_is_Ring(currRing)) 2292 strat->sigdrop = FALSE; 2293 strat->nrsyzcrit = 0; 2294 strat->nrrewcrit = 0; 2215 2295 #if SBA_INTERRED_START 2216 2296 F = kInterRed(F,NULL); … … 2222 2302 printf("\n"); 2223 2303 #endif 2224 #ifdef KDEBUG2225 bba_count++;2226 int loop_count = 0;2227 #endif /* KDEBUG */2228 2304 int srmax,lrmax, red_result = 1; 2229 2305 int olddeg,reduc; … … 2232 2308 BOOLEAN withT = TRUE; 2233 2309 strat->max_lower_index = 0; 2234 2235 2310 //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ 2236 2311 initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/ 2237 2312 initSbaPos(strat); 2238 //initBuchMoraPos(strat);2239 2313 initHilbCrit(F,Q,&hilb,strat); 2240 2314 initSba(F,strat); 2241 2315 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ 2242 2316 /*Shdl=*/initSbaBuchMora(F, Q,strat); 2317 idTest(strat->Shdl); 2243 2318 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank); 2244 2319 srmax = strat->sl; 2245 2320 reduc = olddeg = lrmax = 0; 2246 2247 2321 #ifndef NO_BUCKETS 2248 2322 if (!TEST_OPT_NOT_BUCKETS) … … 2257 2331 kTest_TS(strat); 2258 2332 2259 #ifdef KDEBUG2260 #if MYTEST2261 if (TEST_OPT_DEBUG)2262 {2263 PrintS("bba start GB: currRing: ");2264 // rWrite(currRing);PrintLn();2265 rDebugPrint(currRing);2266 PrintLn();2267 }2268 #endif /* MYTEST */2269 #endif /* KDEBUG */2270 2271 2333 #ifdef HAVE_TAIL_RING 2272 2334 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed … … 2279 2341 kDebugPrint(strat); 2280 2342 } 2281 2282 2343 // We add the elements directly in S from the previous loop 2344 if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0) 2345 { 2346 for(int i = 0;i<strat->sbaEnterS;i++) 2347 { 2348 //Update: now the element is at the corect place 2349 //i+1 because on the 0 position is the sigdrop element 2350 enterT(strat->L[strat->Ll-(i)],strat); 2351 strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl); 2352 } 2353 strat->Ll = strat->Ll - strat->sbaEnterS; 2354 strat->sbaEnterS = -1; 2355 } 2356 kTest_TS(strat); 2283 2357 #ifdef KDEBUG 2284 2358 //kDebugPrint(strat); … … 2287 2361 while (strat->Ll >= 0) 2288 2362 { 2289 #ifdef ADIDEBUG2363 #ifdef ADIDEBUG 2290 2364 printf("\n ------------------------NEW LOOP\n"); 2291 2365 printf("\nShdl = \n"); … … 2315 2389 printf("\n list L\n"); 2316 2390 int iii; 2317 #if 12391 #if 0 2318 2392 for(iii = 0; iii<= strat->Ll; iii++) 2319 2393 { 2320 2394 printf("\nL[%i]:\n",iii); 2321 p_Write(strat->L[iii].p, strat->tailRing);2322 p_Write(strat->L[iii].p1, strat->tailRing);2323 p_Write(strat->L[iii].p2, strat->tailRing);2395 p_Write(strat->L[iii].p, currRing); 2396 p_Write(strat->L[iii].p1, currRing); 2397 p_Write(strat->L[iii].p2, currRing); 2324 2398 p_Write(strat->L[iii].sig, currRing); 2325 2399 } … … 2333 2407 } 2334 2408 #endif 2335 getchar();2409 //getchar(); 2336 2410 #endif 2337 2411 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/ 2338 2412 #ifdef KDEBUG 2339 loop_count++;2340 2413 if (TEST_OPT_DEBUG) messageSets(strat); 2341 2414 #endif … … 2346 2419 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) 2347 2420 { 2421 2348 2422 //stops computation if 2349 2423 // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then … … 2370 2444 // initialize new syzygy rules for the next iteration step 2371 2445 initSyzRules(strat); 2372 2373 2446 } 2374 2447 /********************************************************************* … … 2379 2452 strat->P = strat->L[strat->Ll]; 2380 2453 strat->Ll--; 2381 /* reduction of the element choosen from L */ 2382 2454 2455 if(rField_is_Ring(currRing)) 2456 strat->sbaEnterS = pGetComp(strat->P.sig) - 1; 2457 2458 #ifdef ADIDEBUG 2459 printf("\n-------------------------\nThis is the current element P\n"); 2460 p_Write(strat->P.p,strat->tailRing); 2461 p_Write(strat->P.p1,strat->tailRing); 2462 p_Write(strat->P.p2,strat->tailRing); 2463 p_Write(strat->P.sig,currRing); 2464 #endif 2465 /* reduction of the element chosen from L */ 2383 2466 if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1)) { 2384 2467 //#if 1 2385 2468 #ifdef DEBUGF5 2386 Print ("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");2387 Print ("-------------------------------------------------\n");2469 PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n"); 2470 PrintS("-------------------------------------------------\n"); 2388 2471 pWrite(strat->P.sig); 2389 2472 pWrite(pHead(strat->P.p)); 2390 2473 pWrite(pHead(strat->P.p1)); 2391 2474 pWrite(pHead(strat->P.p2)); 2392 Print ("-------------------------------------------------\n");2475 PrintS("-------------------------------------------------\n"); 2393 2476 #endif 2394 2477 if (pNext(strat->P.p) == strat->tail) … … 2396 2479 // deletes the short spoly 2397 2480 /* 2398 #ifdef HAVE_RINGS2399 2481 if (rField_is_Ring(currRing)) 2400 2482 pLmDelete(strat->P.p); 2401 2483 else 2402 #endif2403 2484 pLmFree(strat->P.p); 2404 2485 */ … … 2432 2513 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); 2433 2514 // for input polys, prepare reduction 2434 strat->P.PrepareRed(strat->use_buckets); 2515 if(!rField_is_Ring(currRing)) 2516 strat->P.PrepareRed(strat->use_buckets); 2435 2517 } 2436 2518 if (strat->P.p == NULL && strat->P.t_p == NULL) … … 2442 2524 //#if 1 2443 2525 #ifdef DEBUGF5 2444 Print ("Poly before red: ");2526 PrintS("Poly before red: "); 2445 2527 pWrite(pHead(strat->P.p)); 2446 2528 pWrite(strat->P.sig); … … 2470 2552 red_result = 2; 2471 2553 } 2554 if(rField_is_Ring(currRing)) 2555 { 2556 if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig))) 2557 { 2558 strat->P.p = pNeg(strat->P.p); 2559 strat->P.sig = pNeg(strat->P.sig); 2560 } 2561 strat->P.pLength = pLength(strat->P.p); 2562 if(strat->P.sig != NULL) 2563 strat->P.sevSig = pGetShortExpVector(strat->P.sig); 2564 if(strat->P.p != NULL) 2565 strat->P.sev = pGetShortExpVector(strat->P.p); 2566 } 2567 #ifdef ADIDEBUG 2568 printf("\nAfter reduce (redresult=%i): \n",red_result);pWrite(strat->P.p);pWrite(strat->P.sig); 2569 #endif 2570 //sigdrop case 2571 if(rField_is_Ring(currRing) && strat->sigdrop) 2572 { 2573 //First reduce it as much as one can 2574 #ifdef ADIDEBUG 2575 printf("\nSigdrop in the reduce. Trying redring\n"); 2576 #endif 2577 red_result = redRing(&strat->P,strat); 2578 if(red_result == 0) 2579 { 2580 #ifdef ADIDEBUG 2581 printf("\nSigdrop cancelled since redRing reduced to 0\n"); 2582 #endif 2583 strat->sigdrop = FALSE; 2584 pDelete(&strat->P.sig); 2585 strat->P.sig = NULL; 2586 } 2587 else 2588 { 2589 #ifdef ADIDEBUG 2590 printf("\nStill Sigdrop - redRing reduced to:\n");pWrite(strat->P.p); 2591 #endif 2592 strat->enterS(strat->P, 0, strat, strat->tl); 2593 if (TEST_OPT_PROT) 2594 PrintS("-"); 2595 break; 2596 } 2597 } 2598 if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax) 2599 { 2600 #ifdef ADIDEBUG 2601 printf("\nToo many blocked reductions\n"); 2602 #endif 2603 strat->sigdrop = TRUE; 2604 break; 2605 } 2606 2472 2607 if (errorreported) break; 2473 2608 … … 2475 2610 #ifdef DEBUGF5 2476 2611 if (red_result != 0) { 2477 Print ("Poly after red: ");2612 PrintS("Poly after red: "); 2478 2613 pWrite(pHead(strat->P.p)); 2479 2614 pWrite(strat->P.GetLmCurrRing()); … … 2482 2617 } 2483 2618 #endif 2619 if (TEST_OPT_PROT) 2620 { 2621 if(strat->P.p != NULL) 2622 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), 2623 &olddeg,&reduc,strat, red_result); 2624 else 2625 message((strat->honey ? strat->P.ecart : 0), 2626 &olddeg,&reduc,strat, red_result); 2627 } 2484 2628 2485 2629 if (strat->overflow) 2486 2630 { 2487 if (!kStratChangeTailRing(strat)) { Werror("OVERFLOW.."); break;} 2488 } 2489 2631 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;} 2632 } 2490 2633 // reduction to non-zero new poly 2491 2634 if (red_result == 1) … … 2510 2653 int pos = strat->sl+1; 2511 2654 2512 #ifdef KDEBUG2513 #if MYTEST2514 PrintS("New S: "); pDebugPrint(strat->P.p); PrintLn();2515 #endif /* MYTEST */2516 #endif /* KDEBUG */2517 2518 2655 // reduce the tail and normalize poly 2519 2656 // in the ring case we cannot expect LC(f) = 1, 2520 2657 // therefore we call pContent instead of pNorm 2658 #ifdef HAVE_RINGS 2659 poly beforetailred; 2660 if(rField_is_Ring(currRing)) 2661 beforetailred = pCopy(strat->P.sig); 2662 #endif 2521 2663 #if SBA_TAIL_RED 2522 if (strat->sbaOrder != 2) { 2523 if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing))) 2524 { 2525 strat->P.pCleardenom(); 2526 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 2664 if(rField_is_Ring(currRing)) 2665 { 2666 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 2667 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); 2668 } 2669 else 2670 { 2671 if (strat->sbaOrder != 2) { 2672 if (TEST_OPT_INTSTRATEGY) 2527 2673 { 2528 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);2529 2674 strat->P.pCleardenom(); 2675 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 2676 { 2677 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); 2678 strat->P.pCleardenom(); 2679 } 2530 2680 } 2681 else 2682 { 2683 strat->P.pNorm(); 2684 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 2685 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); 2686 } 2687 } 2688 } 2689 // It may happen that we have lost the sig in redtailsba 2690 // It cannot reduce to 0 since here we are doing just tail reduction. 2691 // Best case scenerio: remains the leading term 2692 if(rField_is_Ring(currRing) && strat->sigdrop) 2693 { 2694 #ifdef ADIDEBUG 2695 printf("\n Still sigdrop after redtailSba - it reduced to \n");pWrite(strat->P.p); 2696 #endif 2697 strat->enterS(strat->P, 0, strat, strat->tl); 2698 break; 2699 } 2700 #endif 2701 if(rField_is_Ring(currRing)) 2702 { 2703 if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1) 2704 { 2705 #ifdef ADIDEBUG 2706 printf("\nSigDrop after TAILred\n");pWrite(beforetailred);pWrite(strat->P.sig); 2707 #endif 2708 strat->sigdrop = TRUE; 2709 //Reduce it as much as you can 2710 red_result = redRing(&strat->P,strat); 2711 if(red_result == 0) 2712 { 2713 //It reduced to 0, cancel the sigdrop 2714 #ifdef ADIDEBUG 2715 printf("\nReduced to 0 via redRing. Cancel sigdrop\n"); 2716 #endif 2717 strat->sigdrop = FALSE; 2718 p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL; 2531 2719 } 2532 2720 else 2533 2721 { 2534 strat->P.pNorm(); 2535 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 2536 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT); 2537 } 2538 } 2539 #endif 2540 2722 #ifdef ADIDEBUG 2723 printf("\nReduced to this via redRing.SIGDROP\n");pWrite(strat->P.p); 2724 #endif 2725 strat->enterS(strat->P, 0, strat, strat->tl); 2726 break; 2727 } 2728 } 2729 p_Delete(&beforetailred,currRing); 2730 // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing 2731 if(strat->P.p == NULL) 2732 goto case_when_red_result_changed; 2733 } 2734 #ifdef ADIDEBUG 2735 printf("\nNach redTailSba: \n"); 2736 p_Write(strat->P.p,strat->tailRing);p_Write(strat->P.sig,currRing); 2737 #endif 2541 2738 // remove sigsafe label since it is no longer valid for the next element to 2542 2739 // be reduced … … 2560 2757 #ifdef KDEBUG 2561 2758 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} 2562 #if MYTEST2563 //#if 12564 PrintS("New (reduced) S: "); pDebugPrint(strat->P.p); PrintLn();2565 #endif /* MYTEST */2566 2759 #endif /* KDEBUG */ 2567 2760 … … 2596 2789 pWrite(strat->P.sig); 2597 2790 */ 2598 #ifdef HAVE_RINGS2599 2791 if (rField_is_Ring(currRing)) 2600 superenterpairs (strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);2792 superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl); 2601 2793 else 2602 #endif2603 2794 enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl); 2604 // posInS only depends on the leading term 2795 #ifdef ADIDEBUG 2796 printf("\nThis element is added to S\n"); 2797 p_Write(strat->P.p, strat->tailRing);p_Write(strat->P.p1, strat->tailRing);p_Write(strat->P.p2, strat->tailRing);pWrite(strat->P.sig); 2798 //getchar(); 2799 #endif 2800 if(rField_is_Ring(currRing) && strat->sigdrop) 2801 break; 2802 if(rField_is_Ring(currRing)) 2803 strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing); 2605 2804 strat->enterS(strat->P, pos, strat, strat->tl); 2606 2805 if(strat->sbaOrder != 1) … … 2728 2927 printf("---------------------------\n"); 2729 2928 Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1); 2730 Print("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl]));2731 Print("SIGNATURE: "); pWrite(strat->sig[strat->sl]);2732 #endif2733 /*2734 if (newrules)2735 {2736 newrules = FALSE;2737 }2738 */2739 #if 02740 int pl=pLength(strat->P.p);2741 if (pl==1)2742 {2743 //if (TEST_OPT_PROT)2744 //PrintS("<1>");2745 }2746 else if (pl==2)2747 {2748 //if (TEST_OPT_PROT)2749 //PrintS("<2>");2750 }2751 #endif2752 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);2753 // Print("[%d]",hilbeledeg);2754 if (strat->P.lcm!=NULL)2755 #ifdef HAVE_RINGS2756 pLmDelete(strat->P.lcm);2757 #else2758 pLmFree(strat->P.lcm);2759 #endif2760 if (strat->sl>srmax) srmax = strat->sl;2761 }2762 else2763 {2764 // adds signature of the zero reduction to2765 // strat->syz. This is the leading term of2766 // syzygy and can be used in syzCriterion()2767 // the signature is added if and only if the2768 // pair was not detected by the rewritten criterion in strat->red = redSig2769 if (red_result!=2) {2770 #if SBA_PRINT_ZERO_REDUCTIONS2771 zeroreductions++;2772 #endif2773 int pos = posInSyz(strat, strat->P.sig);2774 enterSyz(strat->P, strat, pos);2775 //#if 12776 #ifdef DEBUGF52777 Print("ADDING STUFF TO SYZ : ");2778 //pWrite(strat->P.p);2779 pWrite(strat->P.sig);2780 #endif2781 }2782 if (strat->P.p1 == NULL && strat->minim > 0)2783 {2784 p_Delete(&strat->P.p2, currRing, strat->tailRing);2785 }2786 }2787 2788 #ifdef KDEBUG2789 memset(&(strat->P), 0, sizeof(strat->P));2790 #endif /* KDEBUG */2791 kTest_TS(strat);2792 }2793 #ifdef KDEBUG2794 #if MYTEST2795 PrintS("bba finish GB: currRing: "); rWrite(currRing);2796 #endif /* MYTEST */2797 if (TEST_OPT_DEBUG) messageSets(strat);2798 #endif /* KDEBUG */2799 2800 if (TEST_OPT_SB_1)2801 {2802 #ifdef HAVE_RINGS2803 if(!rField_is_Ring(currRing))2804 #endif2805 {2806 int k=1;2807 int j;2808 while(k<=strat->sl)2809 {2810 j=0;2811 loop2812 {2813 if (j>=k) break;2814 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);2815 j++;2816 }2817 k++;2818 }2819 }2820 }2821 2822 /* complete reduction of the standard basis--------- */2823 if (TEST_OPT_REDSB)2824 {2825 completeReduce(strat);2826 #ifdef HAVE_TAIL_RING2827 if (strat->completeReduce_retry)2828 {2829 // completeReduce needed larger exponents, retry2830 // to reduce with S (instead of T)2831 // and in currRing (instead of strat->tailRing)2832 cleanT(strat);strat->tailRing=currRing;2833 int i;2834 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;2835 completeReduce(strat);2836 }2837 #endif2838 }2839 else if (TEST_OPT_PROT) PrintLn();2840 2841 #if SBA_PRINT_SIZE_SYZ2842 // that is correct, syzl is counting one too far2843 size_syz = strat->syzl;2844 #endif2845 exitSba(strat);2846 // if (TEST_OPT_WEIGHTM)2847 // {2848 // pRestoreDegProcs(pFDegOld, pLDegOld);2849 // if (ecartWeights)2850 // {2851 // omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));2852 // ecartWeights=NULL;2853 // }2854 // }2855 if (TEST_OPT_PROT) messageStat(hilbcount,strat);2856 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);2857 2858 #ifdef KDEBUG2859 #if MYTEST2860 PrintS("bba_end: currRing: "); rWrite(currRing);2861 #endif /* MYTEST */2862 #endif /* KDEBUG */2863 #if SBA_PRINT_SIZE_G2864 size_g_non_red = IDELEMS(strat->Shdl);2865 #endif2866 if ((strat->sbaOrder == 1 || strat->sbaOrder == 3) && sRing!=currRingOld)2867 {2868 rChangeCurrRing (currRingOld);2869 F0 = idrMoveR (F1, sRing, currRing);2870 strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing);2871 rDelete (sRing);2872 }2873 id_DelDiv(strat->Shdl, currRing);2874 idSkipZeroes(strat->Shdl);2875 idTest(strat->Shdl);2876 2877 #if SBA_PRINT_SIZE_G2878 size_g = IDELEMS(strat->Shdl);2879 #endif2880 #ifdef DEBUGF52881 printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));2882 int oo = 0;2883 while (oo<IDELEMS(strat->Shdl))2884 {2885 printf(" %d. ",oo+1);2886 pWrite(pHead(strat->Shdl->m[oo]));2887 oo++;2888 }2889 #endif2890 #if SBA_PRINT_ZERO_REDUCTIONS2891 printf("----------------------------------------------------------\n");2892 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);2893 zeroreductions = 0;2894 #endif2895 #if SBA_PRINT_REDUCTION_STEPS2896 printf("----------------------------------------------------------\n");2897 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);2898 #endif2899 #if SBA_PRINT_OPERATIONS2900 printf("OPERATIONS: %ld\n",sba_operations);2901 #endif2902 #if SBA_PRINT_REDUCTION_STEPS2903 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");2904 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);2905 #endif2906 #if SBA_PRINT_OPERATIONS2907 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);2908 #endif2909 #if SBA_PRINT_REDUCTION_STEPS2910 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");2911 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);2912 sba_interreduction_steps = 0;2913 sba_reduction_steps = 0;2914 #endif2915 #if SBA_PRINT_OPERATIONS2916 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);2917 sba_interreduction_operations = 0;2918 sba_operations = 0;2919 #endif2920 #if SBA_PRINT_SIZE_G2921 printf("----------------------------------------------------------\n");2922 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);2923 size_g = 0;2924 size_g_non_red = 0;2925 #endif2926 #if SBA_PRINT_SIZE_SYZ2927 printf("SIZE OF SYZ: %ld\n",size_syz);2928 printf("----------------------------------------------------------\n");2929 size_syz = 0;2930 #endif2931 #if SBA_PRINT_PRODUCT_CRITERION2932 printf("PRODUCT CRITERIA: %ld\n",product_criterion);2933 product_criterion = 0;2934 #endif2935 return (strat->Shdl);2936 }2937 2938 ideal sbaZ (ideal F0, ideal Q,intvec *w,intvec *hilb,kStrategy strat)2939 {2940 // ring order stuff:2941 // in sba we have (until now) two possibilities:2942 // 1. an incremental computation w.r.t. (C,monomial order)2943 // 2. a (possibly non-incremental) computation w.r.t. the2944 // induced Schreyer order.2945 // The corresponding orders are computed in sbaRing(), depending2946 // on the flag strat->sbaOrder2947 #if SBA_PRINT_ZERO_REDUCTIONS2948 long zeroreductions = 0;2949 #endif2950 #if SBA_PRINT_PRODUCT_CRITERION2951 long product_criterion = 0;2952 #endif2953 #if SBA_PRINT_SIZE_G2954 int size_g = 0;2955 int size_g_non_red = 0;2956 #endif2957 #if SBA_PRINT_SIZE_SYZ2958 long size_syz = 0;2959 #endif2960 // global variable2961 #if SBA_PRINT_REDUCTION_STEPS2962 sba_reduction_steps = 0;2963 sba_interreduction_steps = 0;2964 #endif2965 #if SBA_PRINT_OPERATIONS2966 sba_operations = 0;2967 sba_interreduction_operations = 0;2968 #endif2969 2970 ideal F1 = F0;2971 ring sRing, currRingOld;2972 currRingOld = currRing;2973 if (strat->sbaOrder == 1 || strat->sbaOrder == 3)2974 {2975 sRing = sbaRing(strat);2976 if (sRing!=currRingOld)2977 {2978 rChangeCurrRing (sRing);2979 F1 = idrMoveR (F0, currRingOld, currRing);2980 }2981 }2982 ideal F;2983 // sort ideal F2984 //Put the SigDrop element on the correct position (think of sbaEnterS)2985 //We also sort them2986 if(rField_is_Ring(currRing) && strat->sigdrop)2987 {2988 #if 12989 F = idInit(IDELEMS(F1),F1->rank);2990 for (int i=0; i<IDELEMS(F1);++i)2991 F->m[i] = F1->m[i];2992 if(strat->sbaEnterS >= 0)2993 {2994 poly dummy;2995 dummy = pCopy(F->m[0]); //the sigdrop element2996 for(int i = 0;i<strat->sbaEnterS;i++)2997 F->m[i] = F->m[i+1];2998 F->m[strat->sbaEnterS] = dummy;2999 }3000 #else3001 F = idInit(1,F1->rank);3002 //printf("\nBefore the initial block sorting:\n");idPrint(F1);3003 F->m[0] = F1->m[0];3004 int pos;3005 if(strat->sbaEnterS >= 0)3006 {3007 for(int i=1;i<=strat->sbaEnterS;i++)3008 {3009 pos = posInIdealMonFirst(F,F1->m[i],1,strat->sbaEnterS);3010 idInsertPolyOnPos(F,F1->m[i],pos);3011 }3012 for(int i=strat->sbaEnterS+1;i<IDELEMS(F1);i++)3013 {3014 pos = posInIdealMonFirst(F,F1->m[i],strat->sbaEnterS+1,IDELEMS(F));3015 idInsertPolyOnPos(F,F1->m[i],pos);3016 }3017 poly dummy;3018 dummy = pCopy(F->m[0]); //the sigdrop element3019 for(int i = 0;i<strat->sbaEnterS;i++)3020 F->m[i] = F->m[i+1];3021 F->m[strat->sbaEnterS] = dummy;3022 }3023 else3024 {3025 for(int i=1;i<IDELEMS(F1);i++)3026 {3027 pos = posInIdealMonFirst(F,F1->m[i],1,IDELEMS(F));3028 idInsertPolyOnPos(F,F1->m[i],pos);3029 }3030 }3031 #endif3032 //printf("\nAfter the initial block sorting:\n");idPrint(F);getchar();3033 }3034 else3035 {3036 F = idInit(IDELEMS(F1),F1->rank);3037 intvec *sort = idSort(F1);3038 for (int i=0; i<sort->length();++i)3039 F->m[i] = F1->m[(*sort)[i]-1];3040 if(rField_is_Ring(currRing))3041 {3042 // put the monomials after the sbaEnterS polynomials3043 //printf("\nThis is the ideal before sorting (sbaEnterS = %i)\n",strat->sbaEnterS);idPrint(F);3044 int nrmon = 0;3045 for(int i = IDELEMS(F)-1,j;i>strat->sbaEnterS+nrmon+1 ;i--)3046 {3047 //pWrite(F->m[i]);3048 if(F->m[i] != NULL && pNext(F->m[i]) == NULL)3049 {3050 poly mon = F->m[i];3051 for(j = i;j>strat->sbaEnterS+nrmon+1;j--)3052 {3053 F->m[j] = F->m[j-1];3054 }3055 F->m[j] = mon;3056 nrmon++;3057 }3058 //idPrint(F);3059 }3060 }3061 }3062 //printf("\nThis is the ideal after sorting\n");idPrint(F);getchar();3063 if(rField_is_Ring(currRing))3064 strat->sigdrop = FALSE;3065 strat->nrsyzcrit = 0;3066 strat->nrrewcrit = 0;3067 #if SBA_INTERRED_START3068 F = kInterRed(F,NULL);3069 #endif3070 #if F5DEBUG3071 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");3072 rWrite (currRing);3073 printf("ordSgn = %d\n",currRing->OrdSgn);3074 printf("\n");3075 #endif3076 int srmax,lrmax, red_result = 1;3077 int olddeg,reduc;3078 int hilbeledeg=1,hilbcount=0,minimcnt=0;3079 LObject L;3080 BOOLEAN withT = TRUE;3081 strat->max_lower_index = 0;3082 //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/3083 initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/3084 initSbaPos(strat);3085 initHilbCrit(F,Q,&hilb,strat);3086 initSba(F,strat);3087 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/3088 /*Shdl=*/initSbaBuchMora(F, Q,strat);3089 idTest(strat->Shdl);3090 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);3091 srmax = strat->sl;3092 reduc = olddeg = lrmax = 0;3093 #ifndef NO_BUCKETS3094 if (!TEST_OPT_NOT_BUCKETS)3095 strat->use_buckets = 1;3096 #endif3097 3098 // redtailBBa against T for inhomogenous input3099 // if (!TEST_OPT_OLDSTD)3100 // withT = ! strat->homog;3101 3102 // strat->posInT = posInT_pLength;3103 kTest_TS(strat);3104 3105 #ifdef HAVE_TAIL_RING3106 if(!idIs0(F) &&(!rField_is_Ring(currRing))) // create strong gcd poly computes with tailring and S[i] ->to be fixed3107 kStratInitChangeTailRing(strat);3108 #endif3109 if (BVERBOSE(23))3110 {3111 if (test_PosInT!=NULL) strat->posInT=test_PosInT;3112 if (test_PosInL!=NULL) strat->posInL=test_PosInL;3113 kDebugPrint(strat);3114 }3115 // We add the elements directly in S from the previous loop3116 if(rField_is_Ring(currRing) && strat->sbaEnterS >= 0)3117 {3118 for(int i = 0;i<strat->sbaEnterS;i++)3119 {3120 //Update: now the element is at the corect place3121 //i+1 because on the 0 position is the sigdrop element3122 enterT(strat->L[strat->Ll-(i)],strat);3123 strat->enterS(strat->L[strat->Ll-(i)], strat->sl+1, strat, strat->tl);3124 }3125 strat->Ll = strat->Ll - strat->sbaEnterS;3126 strat->sbaEnterS = -1;3127 }3128 kTest_TS(strat);3129 #ifdef KDEBUG3130 //kDebugPrint(strat);3131 #endif3132 /* compute------------------------------------------------------- */3133 while (strat->Ll >= 0)3134 {3135 #ifdef ADIDEBUG3136 printf("\n ------------------------NEW LOOP\n");3137 printf("\nShdl = \n");3138 #if 03139 idPrint(strat->Shdl);3140 #else3141 for(int ii = 0; ii<=strat->sl;ii++)3142 {3143 printf("\nS[%i]: ",ii);p_Write(strat->S[ii],strat->tailRing);3144 printf("sig: ");pWrite(strat->sig[ii]);3145 }3146 #endif3147 #if 03148 for(int iii = 0; iii< strat->syzl; iii++)3149 {3150 printf("\nsyz[%i]:\n",iii);3151 p_Write(strat->syz[iii], currRing);3152 }3153 #endif3154 #if 03155 for(int iii = 0; iii<= strat->tl; iii++)3156 {3157 printf("\nT[%i]:\n",iii);3158 p_Write(strat->T[iii].p, currRing);3159 }3160 #endif3161 printf("\n list L\n");3162 int iii;3163 #if 03164 for(iii = 0; iii<= strat->Ll; iii++)3165 {3166 printf("\nL[%i]:\n",iii);3167 p_Write(strat->L[iii].p, currRing);3168 p_Write(strat->L[iii].p1, currRing);3169 p_Write(strat->L[iii].p2, currRing);3170 p_Write(strat->L[iii].sig, currRing);3171 }3172 #else3173 {3174 printf("L[%i]:",strat->Ll);3175 p_Write(strat->L[strat->Ll].p, strat->tailRing);3176 p_Write(strat->L[strat->Ll].p1, strat->tailRing);3177 p_Write(strat->L[strat->Ll].p2, strat->tailRing);3178 p_Write(strat->L[strat->Ll].sig, currRing);3179 }3180 #endif3181 //getchar();3182 #endif3183 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/3184 #ifdef KDEBUG3185 if (TEST_OPT_DEBUG) messageSets(strat);3186 #endif3187 if (strat->Ll== 0) strat->interpt=TRUE;3188 /*3189 if (TEST_OPT_DEGBOUND3190 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))3191 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))3192 {3193 3194 //stops computation if3195 // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then3196 //a predefined number Kstd1_deg3197 while ((strat->Ll >= 0)3198 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)3199 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))3200 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))3201 )3202 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);3203 if (strat->Ll<0) break;3204 else strat->noClearS=TRUE;3205 }3206 */3207 if (strat->sbaOrder == 1 && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)3208 {3209 strat->currIdx = pGetComp(strat->L[strat->Ll].sig);3210 #if F5C3211 // 1. interreduction of the current standard basis3212 // 2. generation of new principal syzygy rules for syzCriterion3213 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,3214 lrmax, reduc, Q, w, hilb );3215 #endif3216 // initialize new syzygy rules for the next iteration step3217 initSyzRules(strat);3218 }3219 /*********************************************************************3220 * interrreduction step is done, we can go on with the next iteration3221 * step of the signature-based algorithm3222 ********************************************************************/3223 /* picks the last element from the lazyset L */3224 strat->P = strat->L[strat->Ll];3225 strat->Ll--;3226 3227 if(rField_is_Ring(currRing))3228 strat->sbaEnterS = pGetComp(strat->P.sig) - 1;3229 3230 #ifdef ADIDEBUG3231 printf("\n-------------------------\nThis is the current element P\n");3232 p_Write(strat->P.p,strat->tailRing);3233 p_Write(strat->P.p1,strat->tailRing);3234 p_Write(strat->P.p2,strat->tailRing);3235 p_Write(strat->P.sig,currRing);3236 #endif3237 /* reduction of the element chosen from L */3238 // We do not delete via RewCrit strong pairs or extended spolys over rings3239 // these should have .lcm = NULL3240 if (strat->P.lcm == NULL || !strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat->P.GetLmCurrRing(), strat, strat->P.checked+1)) {3241 //#if 13242 #ifdef DEBUGF53243 PrintS("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");3244 PrintS("-------------------------------------------------\n");3245 pWrite(strat->P.sig);3246 pWrite(pHead(strat->P.p));3247 pWrite(pHead(strat->P.p1));3248 pWrite(pHead(strat->P.p2));3249 PrintS("-------------------------------------------------\n");3250 #endif3251 if (pNext(strat->P.p) == strat->tail)3252 {3253 // deletes the short spoly3254 /*3255 if (rField_is_Ring(currRing))3256 pLmDelete(strat->P.p);3257 else3258 pLmFree(strat->P.p);3259 */3260 // TODO: needs some masking3261 // TODO: masking needs to vanish once the signature3262 // sutff is completely implemented3263 strat->P.p = NULL;3264 poly m1 = NULL, m2 = NULL;3265 3266 // check that spoly creation is ok3267 while (strat->tailRing != currRing &&3268 !kCheckSpolyCreation(&(strat->P), strat, m1, m2))3269 {3270 assume(m1 == NULL && m2 == NULL);3271 // if not, change to a ring where exponents are at least3272 // large enough3273 if (!kStratChangeTailRing(strat))3274 {3275 WerrorS("OVERFLOW...");3276 break;3277 }3278 }3279 // create the real one3280 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,3281 strat->tailRing, m1, m2, strat->R);3282 3283 }3284 else if (strat->P.p1 == NULL)3285 {3286 if (strat->minim > 0)3287 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);3288 // for input polys, prepare reduction3289 if(!rField_is_Ring(currRing))3290 strat->P.PrepareRed(strat->use_buckets);3291 }3292 if (strat->P.p == NULL && strat->P.t_p == NULL)3293 {3294 red_result = 0;3295 }3296 else3297 {3298 //#if 13299 #ifdef DEBUGF53300 PrintS("Poly before red: ");3301 pWrite(pHead(strat->P.p));3302 pWrite(strat->P.sig);3303 #endif3304 #if SBA_PRODUCT_CRITERION3305 if (strat->P.prod_crit) {3306 #if SBA_PRINT_PRODUCT_CRITERION3307 product_criterion++;3308 #endif3309 int pos = posInSyz(strat, strat->P.sig);3310 enterSyz(strat->P, strat, pos);3311 if (strat->P.lcm!=NULL)3312 pLmFree(strat->P.lcm);3313 red_result = 2;3314 } else {3315 red_result = strat->red(&strat->P,strat);3316 }3317 #else3318 red_result = strat->red(&strat->P,strat);3319 #endif3320 }3321 } else {3322 /*3323 if (strat->P.lcm != NULL)3324 pLmFree(strat->P.lcm);3325 */3326 red_result = 2;3327 }3328 if(rField_is_Ring(currRing))3329 {3330 if(strat->P.sig!= NULL && !nGreaterZero(pGetCoeff(strat->P.sig)))3331 {3332 strat->P.p = pNeg(strat->P.p);3333 strat->P.sig = pNeg(strat->P.sig);3334 }3335 strat->P.pLength = pLength(strat->P.p);3336 if(strat->P.sig != NULL)3337 strat->P.sevSig = pGetShortExpVector(strat->P.sig);3338 if(strat->P.p != NULL)3339 strat->P.sev = pGetShortExpVector(strat->P.p);3340 }3341 #ifdef ADIDEBUG3342 printf("\nAfter reduce (redresult=%i): \n",red_result);pWrite(strat->P.p);pWrite(strat->P.sig);3343 #endif3344 //sigdrop case3345 if(rField_is_Ring(currRing) && strat->sigdrop)3346 {3347 //First reduce it as much as one can3348 #ifdef ADIDEBUG3349 printf("\nSigdrop in the reduce. Trying redring\n");3350 #endif3351 red_result = redRing(&strat->P,strat);3352 if(red_result == 0)3353 {3354 #ifdef ADIDEBUG3355 printf("\nSigdrop cancelled since redRing reduced to 0\n");3356 #endif3357 strat->sigdrop = FALSE;3358 pDelete(&strat->P.sig);3359 strat->P.sig = NULL;3360 }3361 else3362 {3363 #ifdef ADIDEBUG3364 printf("\nStill Sigdrop - redRing reduced to:\n");pWrite(strat->P.p);3365 #endif3366 strat->enterS(strat->P, 0, strat, strat->tl);3367 if (TEST_OPT_PROT)3368 PrintS("-");3369 break;3370 }3371 }3372 if(rField_is_Ring(currRing) && strat->blockred > strat->blockredmax)3373 {3374 #ifdef ADIDEBUG3375 printf("\nToo many blocked reductions\n");3376 #endif3377 strat->sigdrop = TRUE;3378 break;3379 }3380 3381 if (errorreported) break;3382 3383 //#if 13384 #ifdef DEBUGF53385 if (red_result != 0) {3386 PrintS("Poly after red: ");3387 pWrite(pHead(strat->P.p));3388 pWrite(strat->P.GetLmCurrRing());3389 pWrite(strat->P.sig);3390 printf("%d\n",red_result);3391 }3392 #endif3393 if (TEST_OPT_PROT)3394 {3395 if(strat->P.p != NULL)3396 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),3397 &olddeg,&reduc,strat, red_result);3398 else3399 message((strat->honey ? strat->P.ecart : 0),3400 &olddeg,&reduc,strat, red_result);3401 }3402 3403 if (strat->overflow)3404 {3405 if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}3406 }3407 // reduction to non-zero new poly3408 if (red_result == 1)3409 {3410 // get the polynomial (canonicalize bucket, make sure P.p is set)3411 strat->P.GetP(strat->lmBin);3412 3413 // sig-safe computations may lead to wrong FDeg computation, thus we need3414 // to recompute it to make sure everything is alright3415 (strat->P).FDeg = (strat->P).pFDeg();3416 // in the homogeneous case FDeg >= pFDeg (sugar/honey)3417 // but now, for entering S, T, we reset it3418 // in the inhomogeneous case: FDeg == pFDeg3419 if (strat->homog) strat->initEcart(&(strat->P));3420 3421 /* statistic */3422 if (TEST_OPT_PROT) PrintS("s");3423 3424 //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);3425 // in F5E we know that the last reduced element is already the3426 // the one with highest signature3427 int pos = strat->sl+1;3428 3429 // reduce the tail and normalize poly3430 // in the ring case we cannot expect LC(f) = 1,3431 // therefore we call pContent instead of pNorm3432 #ifdef HAVE_RINGS3433 poly beforetailred;3434 if(rField_is_Ring(currRing))3435 beforetailred = pCopy(strat->P.sig);3436 #endif3437 #if SBA_TAIL_RED3438 if(rField_is_Ring(currRing))3439 {3440 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))3441 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);3442 }3443 else3444 {3445 if (strat->sbaOrder != 2) {3446 if (TEST_OPT_INTSTRATEGY)3447 {3448 strat->P.pCleardenom();3449 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))3450 {3451 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);3452 strat->P.pCleardenom();3453 }3454 }3455 else3456 {3457 strat->P.pNorm();3458 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))3459 strat->P.p = redtailSba(&(strat->P),pos-1,strat, withT);3460 }3461 }3462 }3463 // It may happen that we have lost the sig in redtailsba3464 // It cannot reduce to 0 since here we are doing just tail reduction.3465 // Best case scenerio: remains the leading term3466 if(rField_is_Ring(currRing) && strat->sigdrop)3467 {3468 #ifdef ADIDEBUG3469 printf("\n Still sigdrop after redtailSba - it reduced to \n");pWrite(strat->P.p);3470 #endif3471 strat->enterS(strat->P, 0, strat, strat->tl);3472 break;3473 }3474 #endif3475 if(rField_is_Ring(currRing))3476 {3477 if(strat->P.sig == NULL || pLtCmp(beforetailred,strat->P.sig) == 1)3478 {3479 #ifdef ADIDEBUG3480 printf("\nSigDrop after TAILred\n");pWrite(beforetailred);pWrite(strat->P.sig);3481 #endif3482 strat->sigdrop = TRUE;3483 //Reduce it as much as you can3484 red_result = redRing(&strat->P,strat);3485 if(red_result == 0)3486 {3487 //It reduced to 0, cancel the sigdrop3488 #ifdef ADIDEBUG3489 printf("\nReduced to 0 via redRing. Cancel sigdrop\n");3490 #endif3491 strat->sigdrop = FALSE;3492 p_Delete(&strat->P.sig,currRing);strat->P.sig = NULL;3493 }3494 else3495 {3496 #ifdef ADIDEBUG3497 printf("\nReduced to this via redRing.SIGDROP\n");pWrite(strat->P.p);3498 #endif3499 strat->enterS(strat->P, 0, strat, strat->tl);3500 break;3501 }3502 }3503 p_Delete(&beforetailred,currRing);3504 // strat->P.p = NULL may appear if we had a sigdrop above and reduced to 0 via redRing3505 if(strat->P.p == NULL)3506 goto case_when_red_result_changed;3507 }3508 #ifdef ADIDEBUG3509 printf("\nNach redTailSba: \n");3510 p_Write(strat->P.p,strat->tailRing);p_Write(strat->P.sig,currRing);3511 #endif3512 // remove sigsafe label since it is no longer valid for the next element to3513 // be reduced3514 if (strat->sbaOrder == 1)3515 {3516 for (int jj = 0; jj<strat->tl+1; jj++)3517 {3518 if (pGetComp(strat->T[jj].sig) == strat->currIdx)3519 {3520 strat->T[jj].is_sigsafe = FALSE;3521 }3522 }3523 }3524 else3525 {3526 for (int jj = 0; jj<strat->tl+1; jj++)3527 {3528 strat->T[jj].is_sigsafe = FALSE;3529 }3530 }3531 #ifdef KDEBUG3532 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}3533 #endif /* KDEBUG */3534 3535 // min_std stuff3536 if ((strat->P.p1==NULL) && (strat->minim>0))3537 {3538 if (strat->minim==1)3539 {3540 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);3541 p_Delete(&strat->P.p2, currRing, strat->tailRing);3542 }3543 else3544 {3545 strat->M->m[minimcnt]=strat->P.p2;3546 strat->P.p2=NULL;3547 }3548 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)3549 pNext(strat->M->m[minimcnt])3550 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),3551 strat->tailRing, currRing,3552 currRing->PolyBin);3553 minimcnt++;3554 }3555 3556 // enter into S, L, and T3557 //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))3558 enterT(strat->P, strat);3559 strat->T[strat->tl].is_sigsafe = FALSE;3560 /*3561 printf("hier\n");3562 pWrite(strat->P.GetLmCurrRing());3563 pWrite(strat->P.sig);3564 */3565 if (rField_is_Ring(currRing))3566 superenterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);3567 else3568 enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);3569 #ifdef ADIDEBUG3570 printf("\nThis element is added to S\n");3571 p_Write(strat->P.p, strat->tailRing);p_Write(strat->P.p1, strat->tailRing);p_Write(strat->P.p2, strat->tailRing);pWrite(strat->P.sig);3572 //getchar();3573 #endif3574 if(rField_is_Ring(currRing) && strat->sigdrop)3575 break;3576 if(rField_is_Ring(currRing))3577 strat->P.sevSig = p_GetShortExpVector(strat->P.sig,currRing);3578 strat->enterS(strat->P, pos, strat, strat->tl);3579 if(strat->sbaOrder != 1)3580 {3581 BOOLEAN overwrite = FALSE;3582 for (int tk=0; tk<strat->sl+1; tk++)3583 {3584 if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))3585 {3586 //printf("TK %d / %d\n",tk,strat->sl);3587 overwrite = FALSE;3588 break;3589 }3590 }3591 //printf("OVERWRITE %d\n",overwrite);3592 if (overwrite)3593 {3594 int cmp = pGetComp(strat->P.sig);3595 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));3596 pGetExpV (strat->P.p,vv);3597 pSetExpV (strat->P.sig, vv);3598 pSetComp (strat->P.sig,cmp);3599 3600 strat->P.sevSig = pGetShortExpVector (strat->P.sig);3601 int i;3602 LObject Q;3603 for(int ps=0;ps<strat->sl+1;ps++)3604 {3605 3606 strat->newt = TRUE;3607 if (strat->syzl == strat->syzmax)3608 {3609 pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);3610 strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,3611 (strat->syzmax)*sizeof(unsigned long),3612 ((strat->syzmax)+setmaxTinc)3613 *sizeof(unsigned long));3614 strat->syzmax += setmaxTinc;3615 }3616 Q.sig = pCopy(strat->P.sig);3617 // add LM(F->m[i]) to the signature to get a Schreyer order3618 // without changing the underlying polynomial ring at all3619 if (strat->sbaOrder == 0)3620 p_ExpVectorAdd (Q.sig,strat->S[ps],currRing);3621 // since p_Add_q() destroys all input3622 // data we need to recreate help3623 // each time3624 // ----------------------------------------------------------3625 // in the Schreyer order we always know that the multiplied3626 // module monomial strat->P.sig gives the leading monomial of3627 // the corresponding principal syzygy3628 // => we do not need to compute the "real" syzygy completely3629 poly help = p_Copy(strat->sig[ps],currRing);3630 p_ExpVectorAdd (help,strat->P.p,currRing);3631 Q.sig = p_Add_q(Q.sig,help,currRing);3632 //printf("%d. SYZ ",i+1);3633 //pWrite(strat->syz[i]);3634 Q.sevSig = p_GetShortExpVector(Q.sig,currRing);3635 i = posInSyz(strat, Q.sig);3636 enterSyz(Q, strat, i);3637 }3638 }3639 }3640 // deg - idx - lp/rp3641 // => we need to add syzygies with indices > pGetComp(strat->P.sig)3642 if(strat->sbaOrder == 0 || strat->sbaOrder == 3)3643 {3644 int cmp = pGetComp(strat->P.sig);3645 int max_cmp = IDELEMS(F);3646 int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));3647 pGetExpV (strat->P.p,vv);3648 LObject Q;3649 int pos;3650 int idx = p_GetComp(strat->P.sig,currRing);3651 //printf("++ -- adding syzygies -- ++\n");3652 // if new element is the first one in this index3653 if (strat->currIdx < idx) {3654 for (int i=0; i<strat->sl; ++i) {3655 Q.sig = p_Copy(strat->P.sig,currRing);3656 p_ExpVectorAdd(Q.sig,strat->S[i],currRing);3657 poly help = p_Copy(strat->sig[i],currRing);3658 p_ExpVectorAdd(help,strat->P.p,currRing);3659 Q.sig = p_Add_q(Q.sig,help,currRing);3660 //pWrite(Q.sig);3661 pos = posInSyz(strat, Q.sig);3662 enterSyz(Q, strat, pos);3663 }3664 strat->currIdx = idx;3665 } else {3666 // if the element is not the first one in the given index we build all3667 // possible syzygies with elements of higher index3668 for (int i=cmp+1; i<=max_cmp; ++i) {3669 pos = -1;3670 for (int j=0; j<strat->sl; ++j) {3671 if (p_GetComp(strat->sig[j],currRing) == i) {3672 pos = j;3673 break;3674 }3675 }3676 if (pos != -1) {3677 Q.sig = p_One(currRing);3678 p_SetExpV(Q.sig, vv, currRing);3679 // F->m[i-1] corresponds to index i3680 p_ExpVectorAdd(Q.sig,F->m[i-1],currRing);3681 p_SetComp(Q.sig, i, currRing);3682 poly help = p_Copy(strat->P.sig,currRing);3683 p_ExpVectorAdd(help,strat->S[pos],currRing);3684 Q.sig = p_Add_q(Q.sig,help,currRing);3685 if (strat->sbaOrder == 0) {3686 if (p_LmCmp(Q.sig,strat->syz[strat->syzl-1],currRing) == -currRing->OrdSgn) {3687 pos = posInSyz(strat, Q.sig);3688 enterSyz(Q, strat, pos);3689 }3690 } else {3691 pos = posInSyz(strat, Q.sig);3692 enterSyz(Q, strat, pos);3693 }3694 }3695 }3696 //printf("++ -- done adding syzygies -- ++\n");3697 }3698 }3699 //#if 13700 #if DEBUGF503701 printf("---------------------------\n");3702 Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);3703 2929 PrintS("LEAD POLY: "); pWrite(pHead(strat->S[strat->sl])); 3704 2930 PrintS("SIGNATURE: "); pWrite(strat->sig[strat->sl]); … … 3849 3075 size_g_non_red = IDELEMS(strat->Shdl); 3850 3076 #endif 3851 3077 if(!rField_is_Ring(currRing)) 3078 exitSba(strat); 3852 3079 // I have to add the initial input polynomials which where not used (p1 and p2 = NULL) 3853 3080 #ifdef HAVE_RINGS … … 3900 3127 strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing, currRing); 3901 3128 rChangeCurrRing (sRing); 3902 exitSba(strat); 3129 if(rField_is_Ring(currRing)) 3130 exitSba(strat); 3903 3131 rChangeCurrRing (currRingOld); 3904 3132 if(strat->tailRing == sRing) … … 3907 3135 } 3908 3136 if(rField_is_Ring(currRing) && !strat->sigdrop) 3137 id_DelDiv(strat->Shdl, currRing); 3138 if(!rField_is_Ring(currRing)) 3909 3139 id_DelDiv(strat->Shdl, currRing); 3910 3140 idSkipZeroes(strat->Shdl);
Note: See TracChangeset
for help on using the changeset viewer.