18#define PLURAL_INTERNAL_DECLARATIONS 1
21#define STDZ_EXHANGE_DURING_REDUCTION 0
39#define SBA_INTERRED_START 0
41#define SBA_PRODUCT_CRITERION 0
42#define SBA_PRINT_ZERO_REDUCTIONS 0
43#define SBA_PRINT_REDUCTION_STEPS 0
44#define SBA_PRINT_OPERATIONS 0
45#define SBA_PRINT_SIZE_G 0
46#define SBA_PRINT_SIZE_SYZ 0
47#define SBA_PRINT_PRODUCT_CRITERION 0
50#if SBA_PRINT_REDUCTION_STEPS
51VAR long sba_reduction_steps;
52VAR long sba_interreduction_steps;
54#if SBA_PRINT_OPERATIONS
55VAR long sba_operations;
56VAR long sba_interreduction_operations;
88 unsigned long not_sev = ~L->sev;
93 const unsigned long* sevT=strat->
sevT;
105 if (
j > strat->
tl)
return o;
126 if (
j > strat->
tl)
return o;
147 unsigned long not_sev = ~L->sev;
148 const unsigned long sevT0 = strat->
sevT[0];
149 number rest, orest,
mult;
152 const poly T0p = strat->
T[0].p;
159#if defined(PDEBUG) || defined(PDIV_DEBUG)
181 const poly T0p = strat->
T[0].t_p;
183 const poly
p = L->t_p;
185#if defined(PDEBUG) || defined(PDIV_DEBUG)
211 unsigned long not_sev = ~L->sev;
216 const unsigned long* sevT=strat->
sevT;
217 number rest, orest,
mult;
228 if (
j > strat->
tl)
return o;
229#if defined(PDEBUG) || defined(PDIV_DEBUG)
260 if (
j > strat->
tl)
return o;
261#if defined(PDEBUG) || defined(PDIV_DEBUG)
292 unsigned long not_sev = ~L->sev;
296 const unsigned long* sevT=strat->
sevT;
309 if (
j > strat->
tl)
return -1;
310#if defined(PDEBUG) || defined(PDIV_DEBUG)
318 if (!(sevT[
j] & not_sev)
333 if (
j > strat->
tl)
return -1;
334#if defined(PDEBUG) || defined(PDIV_DEBUG)
341 if (!(sevT[
j] & not_sev)
360 if (
j > strat->
tl)
return -1;
361#if defined(PDEBUG) || defined(PDIV_DEBUG)
369 if (!(sevT[
j] & not_sev) &&
383 if (
j > strat->
tl)
return -1;
384#if defined(PDEBUG) || defined(PDIV_DEBUG)
391 if (!(sevT[
j] & not_sev) &&
406 unsigned long not_sev = ~L->sev;
407 poly
p = L->GetLmCurrRing();
421 ende=
posInS(strat,*max_ind,
p,0)+1;
422 if (ende>(*max_ind)) ende=(*max_ind);
431 if (
j > ende)
return -1;
432#if defined(PDEBUG) || defined(PDIV_DEBUG)
440 if ( !(strat->
sevS[
j] & not_sev) &&
454 if (
j > ende)
return -1;
455#if defined(PDEBUG) || defined(PDIV_DEBUG)
462 if ( !(strat->
sevS[
j] & not_sev) &&
475 unsigned long not_sev = ~L->sev;
476 poly
p = L->GetLmCurrRing();
489 if (
j > ende)
return -1;
490#if defined(PDEBUG) || defined(PDIV_DEBUG)
498 if ( !(strat->
sevS[
j] & not_sev) &&
512 if (
j > ende)
return -1;
513#if defined(PDEBUG) || defined(PDIV_DEBUG)
520 if ( !(strat->
sevS[
j] & not_sev) &&
534 if (arg <= 0)
return 0;
546 if (arg <= 0)
return 0;
548 if (arg%2 == 1) { arg--; }
566 poly zeroPoly =
NULL;
567 unsigned long a = (
unsigned long)
pGetCoeff(
p);
570 int a_ind2 =
ind2(a);
574 for (
int i = 1;
i <= leadRing->N;
i++)
583 poly lead_mult =
p_ISet(1, tailRing);
584 if (
n_GetChar(leadRing->cf) <= k_ind2 + a_ind2)
586 int too_much = k_ind2 + a_ind2 -
n_GetChar(leadRing->cf);
588 zeroPoly =
p_ISet(a, tailRing);
589 for (
int i = 1;
i <= leadRing->N;
i++)
596 while ( (0 <
ind2(s_exp)) && (
ind2(s_exp) <= too_much) )
598 too_much = too_much -
ind2(s_exp);
602 for (
int j = 1;
j <= s_exp;
j++)
619 p_Setm(lead_mult, tailRing);
620 zeroPoly =
p_Mult_mm(zeroPoly, lead_mult, tailRing);
622 for (
int i = 1;
i <= leadRing->N;
i++)
675 if (
h->IsNull())
return 0;
676 if (strat->
tl<0)
return 1;
686 long reddeg =
h->GetpFDeg();
688 h->SetShortExpVector();
695#if STDZ_EXCHANGE_DURING_REDUCTION
723 if (
h->GetLmTailRing() ==
NULL)
752#if STDZ_EXCHANGE_DURING_REDUCTION
777 if (
h->GetLmTailRing() ==
NULL)
786 h->SetShortExpVector();
791 (strat->
Ll >= 0) && ((d > reddeg) || (pass > strat->
LazyPass)))
796 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
811 if (
h->pTotalDeg() >= (
long)strat->
tailRing->bitmask)
816 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
833 if (strat->
tl<0)
return 1;
834 if (
h->IsNull())
return 0;
845 long reddeg =
h->GetpFDeg();
847 h->SetShortExpVector();
869 if (
h->GetLmTailRing() ==
NULL)
882 if (
h->GetLmTailRing() ==
NULL)
888 h->SetShortExpVector();
893 (strat->
Ll >= 0) && ((d > reddeg) || (pass > strat->
LazyPass)))
898 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
913 if (
h->pTotalDeg() >= (
long)strat->
tailRing->bitmask)
918 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
940 if (strat->
tl<0)
return 1;
945 int i,
j,at,pass,cnt,ii;
953 h->SetShortExpVector();
954 h_p =
h->GetLmTailRing();
961 li = strat->
T[
j].pLength;
971 if (li<=0) li=strat->
T[
j].GetpLength();
974 unsigned long not_sev = ~ h->sev;
981 if ((strat->
T[
i].pLength < li)
989 li = strat->
T[
i].pLength;
990 if (li<=0) li=strat->
T[
i].GetpLength();
1014#if SBA_PRINT_REDUCTION_STEPS
1015 sba_interreduction_steps++;
1017#if SBA_PRINT_OPERATIONS
1018 sba_interreduction_operations +=
pLength(strat->
T[ii].p);
1030 h_p =
h->GetLmTailRing();
1047 else if (
h->t_p!=
NULL)
1067 else if (
h->t_p!=
NULL)
1076 h->SetShortExpVector();
1088 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
1089 if (at <= strat->Ll)
1100 int dummy=strat->
sl;
1107 Print(
" lazy: -> L%d\n",at);
1126 assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1128 Red->HeadNormalize();
1162 if (strat->
tl<0)
return 1;
1168 PrintS(
"------- IN REDSIG -------\n");
1175 PrintS(
"---------------------------\n");
1178 int i,
j,at,pass, ii;
1181 unsigned long not_sev;
1188 h->SetShortExpVector();
1189 h_p =
h->GetLmTailRing();
1199 li = strat->
T[
j].pLength;
1200 if (li<=0) li=strat->
T[
j].GetpLength();
1208 if (test_opt_length)
1217 if ((strat->
T[
i].pLength < li)
1225 li = strat->
T[
i].pLength;
1226 if (li<=0) li=strat->
T[
i].GetpLength();
1248 Print(
"BEFORE REDUCTION WITH %d:\n",ii);
1249 PrintS(
"--------------------------------\n");
1256 PrintS(
"--------------------------------\n");
1257 printf(
"INDEX OF REDUCER T: %d\n",ii);
1260#if SBA_PRINT_REDUCTION_STEPS
1262 sba_reduction_steps++;
1264#if SBA_PRINT_OPERATIONS
1266 sba_operations +=
pLength(strat->
T[ii].p);
1273 Print(
"SigSAFE: %d\n",sigSafe);
1288 h_p =
h->GetLmTailRing();
1294 h->SetShortExpVector();
1306 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
1307 if (at <= strat->Ll)
1309 int dummy=strat->
sl;
1317 Print(
" lazy: -> L%d\n",at);
1341 beforeredsig =
pCopy(
h->sig);
1343 if (strat->
tl<0)
return 1;
1349 Print(
"------- IN REDSIG -------\n");
1356 Print(
"---------------------------\n");
1359 int i,
j,at,pass, ii;
1362 unsigned long not_sev;
1369 h->SetShortExpVector();
1370 h_p =
h->GetLmTailRing();
1392 h->i_r1 = strat->
tl;
1395 if (
h->GetLmTailRing() ==
NULL)
1402 if(
pLtCmp(beforeredsig,
h->sig) == 1)
1425 li = strat->
T[
j].pLength;
1426 if (li<=0) li=strat->
T[
j].GetpLength();
1433 if (test_opt_length)
1442 if ((strat->
T[
i].pLength < li)
1450 li = strat->
T[
i].pLength;
1451 if (li<=0) li=strat->
T[
i].GetpLength();
1473 Print(
"BEFORE REDUCTION WITH %d:\n",ii);
1474 Print(
"--------------------------------\n");
1481 Print(
"--------------------------------\n");
1482 printf(
"INDEX OF REDUCER T: %d\n",ii);
1510#if SBA_PRINT_REDUCTION_STEPS
1512 sba_reduction_steps++;
1514#if SBA_PRINT_OPERATIONS
1516 sba_operations +=
pLength(strat->
T[ii].p);
1523 Print(
"SigSAFE: %d\n",sigSafe);
1538 h_p =
h->GetLmTailRing();
1544 h->SetShortExpVector();
1556 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
1557 if (at <= strat->Ll)
1559 int dummy=strat->
sl;
1567 Print(
" lazy: -> L%d\n",at);
1583 p =
h = L->GetLmTailRing();
1585 return L->GetLmCurrRing();
1593 Ln.sevSig = L->sevSig;
1594 Ln.pLength = L->GetpLength() - 1;
1609 Ln.SetShortExpVector();
1615 With = &(strat->
T[
j]);
1620 if (With ==
NULL)
break;
1644#if SBA_PRINT_REDUCTION_STEPS
1646 sba_reduction_steps++;
1648#if SBA_PRINT_OPERATIONS
1650 sba_operations +=
pLength(With->p);
1660 pNext(
h) = Ln.LmExtractAndIter();
1663 }
while (!Ln.IsNull());
1666 if (Ln.IsNull())
goto all_done;
1667 if (! withT) With_s.Init(
currRing);
1674 pNext(
h) = Ln.LmExtractAndIter();
1691 return L->GetLmCurrRing();
1700 if (strat->
tl<0)
return 1;
1706 long reddeg =
h->GetpFDeg();
1710 h->SetShortExpVector();
1711 poly h_p =
h->GetLmTailRing();
1716 if (
j < 0)
return 1;
1718 li = strat->
T[
j].pLength;
1727 if (test_opt_length)
1729 if (li<=0) li=strat->
T[
j].GetpLength();
1732 unsigned long not_sev = ~ h->sev;
1739 if ((strat->
T[
i].pLength < li)
1747 li = strat->
T[
i].pLength;
1748 if (li<=0) li=strat->
T[
i].GetpLength();
1773#if SBA_PRINT_REDUCTION_STEPS
1774 sba_interreduction_steps++;
1776#if SBA_PRINT_OPERATIONS
1777 sba_interreduction_operations +=
pLength(strat->
T[ii].p);
1789 h_p=
h->GetLmTailRing();
1807 else if (
h->t_p!=
NULL)
1827 else if (
h->t_p!=
NULL)
1836 h->SetShortExpVector();
1842 (strat->
Ll >= 0) && ((d > reddeg) || (pass > strat->
LazyPass)))
1845 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
1846 if (at <= strat->Ll)
1858 int dummy=strat->
sl;
1871 else if (d != reddeg)
1875 if (
h->pTotalDeg() >= (
long)strat->
tailRing->bitmask)
1880 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
1907 if (strat->
tl<0)
return 1;
1911 int i,
j,at,pass,ei, ii, h_d;
1917 d = reddeg =
h->GetpFDeg() +
h->ecart;
1918 h->SetShortExpVector();
1919 h_p =
h->GetLmTailRing();
1925 if (
j < 0)
return 1;
1927 ei = strat->
T[
j].ecart;
1928 li = strat->
T[
j].pLength;
1935 if (test_opt_length)
1937 if (li<=0) li=strat->
T[
j].GetpLength();
1940 unsigned long not_sev = ~ h->sev;
1945 if (
i > strat->
tl)
break;
1946 if (ei <= h->ecart)
break;
1950 strat->
T[
i].GetpLength();
1951 if (((strat->
T[
i].ecart < ei) && (ei>
h->ecart))
1952 || ((strat->
T[
i].ecart <=
h->ecart) && (strat->
T[
i].pLength < li)))
1957 ei = strat->
T[
i].ecart;
1958 li = strat->
T[
i].pLength;
1961 if (ei<=h->ecart)
break;
1982 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
2000 Print(
"\nwith T[%d]:",ii);
2007#if SBA_PRINT_REDUCTION_STEPS
2008 sba_interreduction_steps++;
2010#if SBA_PRINT_OPERATIONS
2011 sba_interreduction_operations += strat->
T[ii].pLength;
2038 else if (
h->t_p!=
NULL)
2058 else if (
h->t_p!=
NULL)
2066 h->SetShortExpVector();
2067 h_d =
h->SetpFDeg();
2072 h->ecart = d-h_d+ei-
h->ecart;
2084 && ((d > reddeg) || (pass > strat->
LazyPass))))
2088 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
2089 if (at <= strat->Ll)
2100 int dummy=strat->
sl;
2107 Print(
" degree jumped: -> L%d\n",at);
2113 else if (d > reddeg)
2117 if (
h->pTotalDeg()+
h->ecart >= (
long)strat->
tailRing->bitmask)
2122 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
2154 P.SetShortExpVector();
2247 P.SetShortExpVector();
2283 P.SetShortExpVector();
2353 P.SetShortExpVector();
2368 P.SetShortExpVector();
2394 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2417 withT = ! strat->
homog;
2422#ifdef HAVE_TAIL_RING
2438 while (strat->
Ll >= 0)
2445 while (strat->
Ll >= 0)
2458 while ((strat->
Ll >= 0)
2459 && (strat->
L[strat->
Ll].p1!=
NULL) && (strat->
L[strat->
Ll].p2!=
NULL)
2464 if (strat->
Ll<0)
break;
2469 strat->
P = strat->
L[strat->
Ll];
2499 else if (strat->
P.p1 ==
NULL)
2501 if (strat->
minim > 0)
2507 if ((strat->
P.p ==
NULL) && (strat->
P.t_p ==
NULL))
2515 &olddeg,&reduc,strat, red_result);
2518 red_result = strat->
red(&strat->
P,strat);
2528 if (red_result == 1)
2531 strat->
P.GetP(strat->
lmBin);
2540 int pos=
posInS(strat,strat->
sl,strat->
P.p,strat->
P.ecart);
2555 strat->
P.pCleardenom();
2559 strat->
P.pCleardenom();
2568 strat->
P.p =
redtailBba(&(strat->
P),pos-1,strat, withT);
2580 if (strat->
minim==1)
2587 strat->
M->m[minimcnt]=strat->
P.p2;
2591 pNext(strat->
M->m[minimcnt])
2602 strat->
P.SetShortExpVector();
2609 strat->
enterS(strat->
P, pos, strat, strat->
tl);
2624 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
2632 if (strat->
s_poly(strat))
2637 int pos=
posInS(strat,strat->
sl,strat->
P.p,strat->
P.ecart);
2643 strat->
enterS(strat->
P, pos, strat, strat->
tl);
2647 else if (strat->
P.p1 ==
NULL && strat->
minim > 0)
2653 memset(&(strat->
P), 0,
sizeof(strat->
P));
2689#ifdef HAVE_TAIL_RING
2711 for(
int i = 0;
i<=strat->
sl;
i++)
2746 return (strat->
Shdl);
2758#if SBA_PRINT_ZERO_REDUCTIONS
2759 long zeroreductions = 0;
2761#if SBA_PRINT_PRODUCT_CRITERION
2762 long product_criterion = 0;
2766 int size_g_non_red = 0;
2768#if SBA_PRINT_SIZE_SYZ
2772#if SBA_PRINT_REDUCTION_STEPS
2773 sba_reduction_steps = 0;
2774 sba_interreduction_steps = 0;
2776#if SBA_PRINT_OPERATIONS
2778 sba_interreduction_operations = 0;
2782 ring sRing, currRingOld;
2787 if (sRing!=currRingOld)
2806 dummy =
pCopy(F->m[0]);
2808 F->m[
i] = F->m[
i+1];
2829 dummy =
pCopy(F->m[0]);
2831 F->m[
i] = F->m[
i+1];
2849 for (
int i=0;
i<
sort->length();++
i)
2850 F->m[
i] = F1->m[(*
sort)[
i]-1];
2864 F->m[
j] = F->m[
j-1];
2878#if SBA_INTERRED_START
2882 printf(
"SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
2884 printf(
"ordSgn = %d\n",
currRing->OrdSgn);
2887 int srmax,lrmax, red_result = 1;
2889 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2903 reduc = olddeg = lrmax = 0;
2916#ifdef HAVE_TAIL_RING
2934 strat->
enterS(strat->
L[strat->
Ll-(
i)], strat->
sl+1, strat, strat->
tl);
2944 while (strat->
Ll >= 0)
2946 if (strat->
Ll > lrmax) lrmax =strat->
Ll;
2976 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
2977 lrmax, reduc,
Q,
w, hilb );
2987 strat->
P = strat->
L[strat->
Ll];
2993 if (!strat->
rewCrit2(strat->
P.sig, ~strat->
P.sevSig, strat->
P.GetLmCurrRing(), strat, strat->
P.checked+1))
2997 PrintS(
"SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
2998 PrintS(
"-------------------------------------------------\n");
3003 PrintS(
"-------------------------------------------------\n");
3038 else if (strat->
P.p1 ==
NULL)
3040 if (strat->
minim > 0)
3046 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
3054 PrintS(
"Poly before red: ");
3058#if SBA_PRODUCT_CRITERION
3059 if (strat->
P.prod_crit)
3061#if SBA_PRINT_PRODUCT_CRITERION
3062 product_criterion++;
3064 int pos =
posInSyz(strat, strat->
P.sig);
3071 red_result = strat->
red(&strat->
P,strat);
3074 red_result = strat->
red(&strat->
P,strat);
3090 strat->
P.p =
pNeg(strat->
P.p);
3091 strat->
P.sig =
pNeg(strat->
P.sig);
3094 if(strat->
P.sig !=
NULL)
3096 if(strat->
P.p !=
NULL)
3103 red_result =
redRing(&strat->
P,strat);
3108 strat->
P.sig =
NULL;
3112 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3128 if (red_result != 0)
3130 PrintS(
"Poly after red: ");
3132 pWrite(strat->
P.GetLmCurrRing());
3134 printf(
"%d\n",red_result);
3139 if(strat->
P.p !=
NULL)
3141 &olddeg,&reduc,strat, red_result);
3144 &olddeg,&reduc,strat, red_result);
3152 if (red_result == 1)
3155 strat->
P.GetP(strat->
lmBin);
3159 (strat->
P).FDeg = (strat->
P).pFDeg();
3171 int pos = strat->
sl+1;
3178 beforetailred =
pCopy(strat->
P.sig);
3184 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3192 strat->
P.pCleardenom();
3195 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3196 strat->
P.pCleardenom();
3203 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3212 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3218 if(strat->
P.sig ==
NULL ||
pLtCmp(beforetailred,strat->
P.sig) == 1)
3222 red_result =
redRing(&strat->
P,strat);
3231 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3237 if(strat->
P.p ==
NULL)
3238 goto case_when_red_result_changed;
3244 for (
int jj = 0; jj<strat->
tl+1; jj++)
3248 strat->
T[jj].is_sigsafe =
FALSE;
3254 for (
int jj = 0; jj<strat->
tl+1; jj++)
3256 strat->
T[jj].is_sigsafe =
FALSE;
3266 if (strat->
minim==1)
3273 strat->
M->m[minimcnt]=strat->
P.p2;
3277 pNext(strat->
M->m[minimcnt])
3287 strat->
T[strat->
tl].is_sigsafe =
FALSE;
3301 strat->
enterS(strat->
P, pos, strat, strat->
tl);
3305 for (
int tk=0; tk<strat->
sl+1; tk++)
3326 for(
int ps=0;ps<strat->
sl+1;ps++)
3334 (strat->
syzmax)*
sizeof(
unsigned long),
3336 *
sizeof(
unsigned long));
3368 unsigned max_cmp =
IDELEMS(F);
3378 for (
int i=0;
i<strat->
sl; ++
i)
3395 for (
unsigned i=cmp+1;
i<=max_cmp; ++
i)
3398 for (
int j=0;
j<strat->
sl; ++
j)
3436 printf(
"---------------------------\n");
3437 Print(
" %d. ELEMENT ADDED TO GCURR:\n",strat->
sl+1);
3460 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
3463 if (strat->
sl>srmax) srmax = strat->
sl;
3467 case_when_red_result_changed:
3475#if SBA_PRINT_ZERO_REDUCTIONS
3484 int pos =
posInSyz(strat, strat->
P.sig);
3488 Print(
"ADDING STUFF TO SYZ : ");
3501 memset(&(strat->
P), 0,
sizeof(strat->
P));
3507 printf(
"\nSigDrop!\n");
3509 printf(
"\nEnded with no SigDrop\n");
3515 if(strat->
P.sig !=
NULL)
3519 memset(&(strat->
P), 0,
sizeof(strat->
P));
3554#ifdef HAVE_TAIL_RING
3570#if SBA_PRINT_SIZE_SYZ
3572 size_syz = strat->
syzl;
3600 for(;
k>=0 && (strat->
L[
k].p1 !=
NULL || strat->
L[
k].p2 !=
NULL);
k--)
3610 for(;
k>=0 && strat->
L[
k].p1 ==
NULL && strat->
L[
k].p2 ==
NULL;
k--)
3613 strat->
enterS(strat->
L[
k], strat->
sl+1, strat, strat->
tl);
3621 for(
k=strat->
sl;
k>=0;
k--)
3658 printf(
"SIZE OF SHDL: %d\n",
IDELEMS(strat->
Shdl));
3662 printf(
" %d. ",oo+1);
3667#if SBA_PRINT_ZERO_REDUCTIONS
3668 printf(
"----------------------------------------------------------\n");
3669 printf(
"ZERO REDUCTIONS: %ld\n",zeroreductions);
3672#if SBA_PRINT_REDUCTION_STEPS
3673 printf(
"----------------------------------------------------------\n");
3674 printf(
"S-REDUCTIONS: %ld\n",sba_reduction_steps);
3676#if SBA_PRINT_OPERATIONS
3677 printf(
"OPERATIONS: %ld\n",sba_operations);
3679#if SBA_PRINT_REDUCTION_STEPS
3680 printf(
"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3681 printf(
"INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3683#if SBA_PRINT_OPERATIONS
3684 printf(
"INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3686#if SBA_PRINT_REDUCTION_STEPS
3687 printf(
"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3688 printf(
"ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3689 sba_interreduction_steps = 0;
3690 sba_reduction_steps = 0;
3692#if SBA_PRINT_OPERATIONS
3693 printf(
"ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3694 sba_interreduction_operations = 0;
3698 printf(
"----------------------------------------------------------\n");
3699 printf(
"SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3703#if SBA_PRINT_SIZE_SYZ
3704 printf(
"SIZE OF SYZ: %ld\n",size_syz);
3705 printf(
"----------------------------------------------------------\n");
3708#if SBA_PRINT_PRODUCT_CRITERION
3709 printf(
"PRODUCT CRITERIA: %ld\n",product_criterion);
3710 product_criterion = 0;
3712 return (strat->
Shdl);
4047 int& hilbcount,
int& srmax,
int& lrmax,
int& reduc, ideal
Q,
4050 int Ll_old, red_result = 1;
4056 reduc = olddeg = lrmax = 0;
4061 while (strat->
tl >= 0)
4063 if(!strat->
T[strat->
tl].is_redundant)
4066 h.p = strat->
T[strat->
tl].p;
4067 h.tailRing = strat->
T[strat->
tl].tailRing;
4068 h.t_p = strat->
T[strat->
tl].t_p;
4107 while (strat->
Ll>Ll_old)
4109 strat->
P = strat->
L[strat->
Ll];
4113 PrintS(
"NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
4114 PrintS(
"-------------------------------------------------\n");
4118 printf(
"%d\n",strat->
tl);
4119 PrintS(
"-------------------------------------------------\n");
4152 else if (strat->
P.p1 ==
NULL)
4154 if (strat->
minim > 0)
4161 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
4169 &olddeg,&reduc,strat, red_result);
4172 PrintS(
"Poly before red: ");
4176 red_result = strat->
red2(&strat->
P,strat);
4186 if (red_result == 1)
4189 strat->
P.GetP(strat->
lmBin);
4200 pos =
posInS(strat,strat->
sl,strat->
P.p,strat->
P.ecart);
4204 pos =
posInS(strat,strat->
sl,strat->
P.p,strat->
P.ecart);
4212 strat->
P.pCleardenom();
4215 strat->
P.p =
redtailBba(&(strat->
P),pos-1,strat, withT);
4216 strat->
P.pCleardenom();
4223 strat->
P.p =
redtailBba(&(strat->
P),pos-1,strat, withT);
4233 if (strat->
minim==1)
4240 strat->
M->m[minimcnt]=strat->
P.p2;
4244 pNext(strat->
M->m[minimcnt])
4257 strat->
enterS(strat->
P, pos, strat, strat->
tl);
4260 PrintS(
"ELEMENT ADDED TO GCURR DURING INTERRED: ");
4264 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
4268 if (strat->
sl>srmax) srmax = strat->
sl;
4284 memset(&(strat->
P), 0,
sizeof(strat->
P));
4288 while (cc<strat->tl+1)
4290 strat->
T[cc].sig =
pOne();
4293 strat->
sig[cc] = strat->
T[cc].sig;
4294 strat->
sevSig[cc] = strat->
T[cc].sevSig;
4295 strat->
T[cc].is_sigsafe =
TRUE;
4303 for (
int cd=strat->
Ll;
cd>=0;
cd--)
4311 printf(
"\nAfter f5c sorting\n");
4312 for(
int i=0;
i<=strat->
sl;
i++)
4318 PrintS(
"------------------- STRAT S ---------------------\n");
4320 while (cc<strat->tl+1)
4324 printf(
"- - - - - -\n");
4327 PrintS(
"-------------------------------------------------\n");
4328 PrintS(
"------------------- STRAT T ---------------------\n");
4330 while (cc<strat->tl+1)
4334 printf(
"- - - - - -\n");
4337 PrintS(
"-------------------------------------------------\n");
4338 PrintS(
"------------------- STRAT L ---------------------\n");
4340 while (cc<strat->Ll+1)
4346 printf(
"- - - - - -\n");
4349 PrintS(
"-------------------------------------------------\n");
4350 printf(
"F5C DONE\nSTRAT SL: %d -- %d\n",strat->
sl, strat->
currIdx);
4362 int hilbeledeg=1,hilbcount=0,minimcnt=0;
4390#ifdef HAVE_TAIL_RING
4406 while (strat->
Ll >= 0)
4413 while (strat->
Ll >= 0)
4426 while ((strat->
Ll >= 0)
4427 && (strat->
L[strat->
Ll].p1!=
NULL) && (strat->
L[strat->
Ll].p2!=
NULL)
4432 if (strat->
Ll<0)
break;
4437 strat->
P = strat->
L[strat->
Ll];
4467 else if (strat->
P.p1 ==
NULL)
4469 if (strat->
minim > 0)
4475 if ((strat->
P.p ==
NULL) && (strat->
P.t_p ==
NULL))
4483 &olddeg,&reduc,strat, red_result);
4486 red_result = strat->
red(&strat->
P,strat);
4496 if (red_result == 1)
4499 strat->
P.GetP(strat->
lmBin);
4508 int pos=
posInS(strat,strat->
sl,strat->
P.p,strat->
P.ecart);
4523 strat->
P.pCleardenom();
4527 strat->
P.pCleardenom();
4540 strat->
P.p =
redtailBba(&(strat->
P),pos-1,strat, withT);
4556 if (strat->
minim==1)
4563 strat->
M->m[minimcnt]=strat->
P.p2;
4567 pNext(strat->
M->m[minimcnt])
4581 strat->
enterS(strat->
P, pos, strat, strat->
tl);
4586 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
4594 if (strat->
s_poly(strat))
4599 int pos=
posInS(strat,strat->
sl,strat->
P.p,strat->
P.ecart);
4602 strat->
enterS(strat->
P, pos, strat, strat->
tl);
4608 else if (strat->
P.p1 ==
NULL && strat->
minim > 0)
4613 memset(&(strat->
P), 0,
sizeof(strat->
P));
4625 for (
int k = 0;
k <= strat->
sl; ++
k)
4628 for (
int j = 0;
j<=strat->
tl; ++
j)
4658#ifdef HAVE_TAIL_RING
4665 WarnS(
"reduction with S is not yet supported by Letterplace");
4682 for(
int i = 0;
i<=strat->
sl;
i++)
4717 return (strat->
Shdl);
4740 if (
h->IsNull())
return 0;
4748 d =
h->GetpFDeg() +
h->ecart;
4751 h->SetShortExpVector();
4757 h->SetDegStuffReturnLDeg(strat->
LDegLast);
4762 strat->
T[
j].pNorm();
4788 h->SetShortExpVector();
4801 h->SetDegStuffReturnLDeg(strat->
LDegLast);
4811 if (strat->
T[
j].ecart <=
h->ecart)
4812 h->ecart = d -
h->GetpFDeg();
4814 h->ecart = d -
h->GetpFDeg() + strat->
T[
j].ecart -
h->ecart;
4816 d =
h->GetpFDeg() +
h->ecart;
4819 d =
h->SetDegStuffReturnLDeg(strat->
LDegLast);
4828 && ((d >= reddeg) || (pass > strat->
LazyPass)))
4833 at = strat->
posInL(strat->
L,strat->
Ll,
h,strat);
4834 if (at <= strat->Ll)
static int si_max(const int a, const int b)
CanonicalForm cd(bCommonDen(FF))
static CanonicalForm bound(const CFMatrix &M)
KINLINE poly kNoetherTail()
int(* red2)(LObject *L, kStrategy strat)
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
pShallowCopyDeleteProc p_shallow_copy_delete
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
char completeReduce_retry
void(* initEcart)(TObject *L)
int(* posInT)(const TSet T, const int tl, LObject &h)
int(* red)(LObject *L, kStrategy strat)
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
char posInLDependsOnLength
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
static FORCE_INLINE number n_EucNorm(number a, const coeffs r)
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
void sort(CFArray &A, int l=0)
quick sort A
void WerrorS(const char *s)
#define idDelete(H)
delete an ideal
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
static BOOLEAN length(leftv result, leftv arg)
KINLINE poly redtailBba_Ring(poly p, int pos, kStrategy strat)
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
KINLINE poly redtailBbaBound(poly p, int pos, kStrategy strat, int bound, BOOLEAN normalize)
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
void kBucketDestroy(kBucket_pt *bucket_pt)
void kBucketInit(kBucket_pt bucket, poly lm, int length)
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
const poly kBucketGetLm(kBucket_pt bucket)
int kBucketCanonicalize(kBucket_pt bucket)
Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in one bucket: Returns number of bu...
void khCheck(ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count, kStrategy strat)
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat)
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
int ksReducePolyZ(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
int ksReducePolyGCD(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
ideal kStdShift(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, BOOLEAN rightGB)
ideal kInterRed(ideal F, ideal Q)
void initBba(kStrategy strat)
void initSba(ideal F, kStrategy strat)
int redRing_Z(LObject *h, kStrategy strat)
poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing)
int redFirstShift(LObject *h, kStrategy strat)
int kFindSameLMInT_Z(const kStrategy strat, const LObject *L, const int start)
int kFindDivisibleByInT_Z(const kStrategy strat, const LObject *L, const int start)
int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject *L)
return -1 if no divisor is found number of first divisor in S, otherwise
int kTestDivisibleByT0_Z(const kStrategy strat, const LObject *L)
tests if T[0] divides the leading monomial of L, returns -1 if not
poly redNFBound(poly h, int &max_ind, int nonorm, kStrategy strat, int bound)
poly kNF2(ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce)
VAR int(* test_PosInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
int redHoney(LObject *h, kStrategy strat)
int kFindNextDivisibleByInS(const kStrategy strat, int start, int max_ind, LObject *L)
static long ind_fact_2(long arg)
int redHomog(LObject *h, kStrategy strat)
ideal sba(ideal F0, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
ideal bba(ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
int redLazy(LObject *h, kStrategy strat)
int redSigRing(LObject *h, kStrategy strat)
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
KINLINE int ksReducePolyTailSig(LObject *PR, TObject *PW, LObject *Red, kStrategy strat)
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
int redSig(LObject *h, kStrategy strat)
static long ind2(long arg)
void kDebugPrint(kStrategy strat)
void f5c(kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, intvec *hilb)
VAR int(* test_PosInT)(const TSet T, const int tl, LObject &h)
poly kNF2Bound(ideal F, ideal Q, poly q, int bound, kStrategy strat, int lazyReduce)
int redRing(LObject *h, kStrategy strat)
int kFindDivisibleByInT(const kStrategy strat, const LObject *L, const int start)
return -1 if no divisor is found number of first divisor in T, otherwise
ideal bbaShift(ideal F, ideal Q, intvec *w, intvec *hilb, kStrategy strat)
ideal rightgb(ideal F, ideal Q)
void initSbaPos(kStrategy strat)
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
void initBuchMora(ideal F, ideal Q, kStrategy strat)
void enterSyz(LObject &p, kStrategy strat, int atT)
void enterT(LObject &p, kStrategy strat, int atT)
void enterTShift(LObject p, kStrategy strat, int atT)
BOOLEAN kTest(kStrategy strat)
TObject * kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject *L, TObject *T, long ecart)
BOOLEAN kTest_TS(kStrategy strat)
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
void redtailBbaAlsoLC_Z(LObject *L, int end_pos, kStrategy strat)
void initHilbCrit(ideal, ideal, intvec **hilb, kStrategy strat)
int posInSMonFirst(const kStrategy strat, const int length, const poly p)
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
void initBuchMoraPos(kStrategy strat)
void initS(ideal F, ideal Q, kStrategy strat)
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
void postReduceByMon(LObject *h, kStrategy strat)
used for GB over ZZ: intermediate reduction by monomial elements background: any known constant eleme...
void enterpairsShift(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
BOOLEAN kTest_L(LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
void exitBuchMora(kStrategy strat)
void messageStatSBA(int hilbcount, kStrategy strat)
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
void initSyzRules(kStrategy strat)
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
void cleanT(kStrategy strat)
int posInSyz(const kStrategy strat, poly sig)
void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat)
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
void updateResult(ideal r, ideal Q, kStrategy strat)
void superenterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
void exitSba(kStrategy strat)
void deleteInL(LSet set, int *length, int j, kStrategy strat)
void kStratInitChangeTailRing(kStrategy strat)
void initBuchMoraCrit(kStrategy strat)
void completeReduce(kStrategy strat, BOOLEAN withT)
void initBuchMoraPosRing(kStrategy strat)
void postReduceByMonSig(LObject *h, kStrategy strat)
void messageSets(kStrategy strat)
void deleteInS(int i, kStrategy strat)
BOOLEAN sbaCheckGcdPair(LObject *h, kStrategy strat)
int posInLF5CRing(const LSet set, int start, const int length, LObject *p, const kStrategy)
void initEcartBBA(TObject *h)
void enterSBbaShift(LObject &p, int atS, kStrategy strat, int atR)
void messageStat(int hilbcount, kStrategy strat)
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
void finalReduceByMon(kStrategy strat)
used for GB over ZZ: final reduction by constant elements background: any known constant element of i...
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
void initSbaCrit(kStrategy strat)
void cancelunit(LObject *L, BOOLEAN inNF)
#define REDNF_CANONICALIZE
static void kDeleteLcm(LObject *P)
#define REDTAIL_CANONICALIZE
static void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c)
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
#define __p_GetComp(p, r)
#define omRealloc0Size(addr, o_size, size)
#define TEST_OPT_INTSTRATEGY
#define SI_RESTORE_OPT1(A)
#define TEST_OPT_DEGBOUND
#define TEST_OPT_REDTHROUGH
#define TEST_OPT_REDTAIL_SYZ
#define TEST_OPT_CONTENTSB
#define TEST_OPT_NOT_BUCKETS
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
unsigned long p_GetShortExpVector(const poly p, const ring r)
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
void pEnlargeSet(poly **p, int l, int increment)
long p_Deg(poly a, const ring r)
static poly p_Add_q(poly p, poly q, const ring r)
static poly p_Mult_q(poly p, poly q, const ring r)
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
#define p_LmEqual(p1, p2, r)
static void p_SetExpV(poly p, int *ev, const ring r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static void p_Setm(poly p, const ring r)
static int p_LmCmp(poly p, poly q, const ring r)
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
static void p_Delete(poly *p, const ring r)
static unsigned pLength(poly a)
static void p_GetExpV(poly p, int *ev, const ring r)
static poly p_Mult_mm(poly p, poly m, const ring r)
static poly p_LmDeleteAndNext(poly p, const ring r)
static poly p_Copy(poly p, const ring r)
returns a copy of p
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatiblity layer for legacy polynomial operations (over currRing)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
#define pGetComp(p)
Component.
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
#define pCopy(p)
return a copy of the poly
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
void PrintS(const char *s)
void Werror(const char *fmt,...)
void rWrite(ring r, BOOLEAN details)
void rDelete(ring r)
unconditionally deletes fields in r
static BOOLEAN rField_is_Z(const ring r)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static BOOLEAN rField_is_Zn(const ring r)
static BOOLEAN rIsLPRing(const ring r)
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
#define rField_is_Ring(R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)