12 #define BUCHBERGER_ALG //we use the improved Buchberger alg.
24 #define INVEPS_SMALL_IN_FRACTAL //to choose the small invers of epsilon
25 #define INVEPS_SMALL_IN_MPERTVECTOR //to choose the small invers of epsilon
26 #define INVEPS_SMALL_IN_TRAN //to choose the small invers of epsilon
28 #define FIRST_STEP_FRACTAL // to define the first step of the fractal
86 #include <sys/types.h>
111 return (
unsigned long*)
omAlloc0(maxnr*
sizeof(
unsigned long));
115 return (
int*)
omAlloc0(maxnr*
sizeof(
int));
135 strat->
S=strat->
Shdl->m;
141 memset(strat->
fromQ,0,i*
sizeof(
int));
147 h.p =
pCopy(Q->m[i]);
168 pos =
posInS(strat,strat->
sl,h.p,h.ecart);
172 strat->
enterS(h,pos,strat, strat->
tl+1);
185 h.p =
pCopy(F->m[i]);
201 pos =
posInS(strat,strat->
sl,h.p,h.ecart);
203 strat->
enterS(h,pos,strat, strat->
tl+1);
253 pos =
posInS(strat->
S,strat->
sl,h.p,h.ecart);
255 strat->
enterS(h,pos,strat, strat->
tl+1);
263 strat->
enterS(h,0,strat, strat->
tl+1);
362 static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
363 clock_t tlf,clock_t tred, clock_t tnw,
int step)
365 double totm = ((double) (clock() - tinput))/1000000;
366 double ostd,mostd, mif, mstd, mlf, mred, mnw, mxif,mxstd,mxlf,mxred,mxnw,tot;
368 Print(
"\n// total time = %.2f sec", totm);
369 Print(
"\n// tostd = %.2f sec = %.2f", ostd=((
double) tostd)/1000000,
370 mostd=((((
double) tostd)/1000000)/totm)*100);
371 Print(
"\n// tif = %.2f sec = %.2f", ((
double) tif)/1000000,
372 mif=((((
double) tif)/1000000)/totm)*100);
373 Print(
"\n// std = %.2f sec = %.2f", ((
double) tstd)/1000000,
374 mstd=((((
double) tstd)/1000000)/totm)*100);
375 Print(
"\n// lift = %.2f sec = %.2f", ((
double) tlf)/1000000,
376 mlf=((((
double) tlf)/1000000)/totm)*100);
377 Print(
"\n// ired = %.2f sec = %.2f", ((
double) tred)/1000000,
378 mred=((((
double) tred)/1000000)/totm)*100);
379 Print(
"\n// nextw = %.2f sec = %.2f", ((
double) tnw)/1000000,
380 mnw=((((
double) tnw)/1000000)/totm)*100);
381 PrintS(
"\n Time for the last step:");
382 Print(
"\n// xinfo = %.2f sec = %.2f", ((
double)
xtif)/1000000,
383 mxif=((((
double) xtif)/1000000)/totm)*100);
384 Print(
"\n// xstd = %.2f sec = %.2f", ((
double)
xtstd)/1000000,
385 mxstd=((((
double) xtstd)/1000000)/totm)*100);
386 Print(
"\n// xlift = %.2f sec = %.2f", ((
double)
xtlift)/1000000,
387 mxlf=((((
double) xtlift)/1000000)/totm)*100);
388 Print(
"\n// xired = %.2f sec = %.2f", ((
double)
xtred)/1000000,
389 mxred=((((
double) xtred)/1000000)/totm)*100);
390 Print(
"\n// xnextw= %.2f sec = %.2f", ((
double)
xtnw)/1000000,
391 mxnw=((((
double) xtnw)/1000000)/totm)*100);
393 tot=mostd+mif+mstd+mlf+mred+mnw+mxif+mxstd+mxlf+mxred+mxnw;
394 double res = (double) 100 - tot;
395 Print(
"\n// &%d&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f(%.2f)\\ \\",
396 step, ostd, totm, mostd,mif,mstd,mlf,mred,mnw,mxif,mxstd,mxlf,mxred,mxnw,tot,res,
397 ((((
double)
xtextra)/1000000)/totm)*100);
403 static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
404 clock_t textra, clock_t tlf,clock_t tred, clock_t tnw)
407 double totm = ((double) (clock() - tinput))/1000000;
408 double ostd, mostd, mif, mstd, mextra, mlf, mred, mnw, tot,
res;
409 Print(
"\n// total time = %.2f sec", totm);
410 Print(
"\n// tostd = %.2f sec = %.2f", ostd=((
double) tostd)/1000000,
411 mostd=((((
double) tostd)/1000000)/totm)*100);
412 Print(
"\n// tif = %.2f sec = %.2f", ((
double) tif)/1000000,
413 mif=((((
double) tif)/1000000)/totm)*100);
414 Print(
"\n// std = %.2f sec = %.2f", ((
double) tstd)/1000000,
415 mstd=((((
double) tstd)/1000000)/totm)*100);
416 Print(
"\n// xstd = %.2f sec = %.2f", ((
double) textra)/1000000,
417 mextra=((((
double) textra)/1000000)/totm)*100);
418 Print(
"\n// lift = %.2f sec = %.2f", ((
double) tlf)/1000000,
419 mlf=((((
double) tlf)/1000000)/totm)*100);
420 Print(
"\n// ired = %.2f sec = %.2f", ((
double) tred)/1000000,
421 mred=((((
double) tred)/1000000)/totm)*100);
422 Print(
"\n// nextw = %.2f sec = %.2f", ((
double) tnw)/1000000,
423 mnw=((((
double) tnw)/1000000)/totm)*100);
424 tot = mostd+mif+mstd+mextra+mlf+mred+mnw;
425 res = (double) 100.00-tot;
426 Print(
"\n// &%.2f &%.2f&%.2f &%.2f &%.2f &%.2f &%.2f &%.2f &%.2f&%.2f&%.2f\\ \\ ",
427 ostd,totm,mostd,mif,mstd,mextra,mlf,mred,mnw,tot,res);
431 #ifdef CHECK_IDEAL_MWALK
432 static void idString(
ideal L,
const char* st)
436 Print(
"\n// ideal %s = ", st);
437 for(i=0; i<nL-1; i++)
445 #if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS)
446 static void headidString(
ideal L,
char* st)
450 Print(
"\n// ideal %s = ", st);
451 for(i=0; i<nL-1; i++)
459 #if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS)
460 static void idElements(
ideal L,
char* st)
463 int *K=(
int *)
omAlloc(nL*
sizeof(
int));
465 Print(
"\n// #monoms of %s = ", st);
477 for(j=i+1; j<nL; j++)
491 Print(
"%d[%d], ", K[i], nsame);
503 Print(
"\n// intvec %s = ", ch);
505 for(
int i=0; i<nV; i++)
507 Print(
"%d, ", (*iv)[i]);
509 Print(
"%d;", (*iv)[nV]);
521 Print(
"%d, ", (*iva)[i]);
523 Print(
"%d) ==> (", (*iva)[nV]);
526 Print(
"%d, ", (*ivb)[i]);
528 Print(
"%d) := (", (*ivb)[nV]);
532 Print(
"%d, ", (*ivc)[i]);
534 Print(
"%d)", (*ivc)[nV]);
541 static inline long gcd(
const long a,
const long b)
543 long r, p0 =
a, p1 =
b;
565 static void cancel(mpz_t zaehler, mpz_t nenner)
570 mpz_gcd(g, zaehler, nenner);
572 mpz_div(zaehler , zaehler, g);
573 mpz_div(nenner , nenner, g);
580 static int isVectorNeg(
intvec* omega)
584 for(i=omega->
length(); i>=0; i--)
602 mpz_init_set_ui(sing_int, 2147483647);
615 mpz_set_si(zvec, (*weight)[i-1]);
616 mpz_mul_ui(zmul, zvec,
pGetExp(p, i));
617 mpz_add(zsum, zsum, zmul);
620 wgrad = mpz_get_ui(zsum);
622 if(mpz_cmp(zsum, sing_int)>0)
627 PrintS(
"\n// ** OVERFLOW in \"MwalkInitialForm\": ");
628 mpz_out_str( stdout, 10, zsum);
629 PrintS(
" is greater than 2147483647 (max. integer representation)");
648 int max = 0, maxtemp;
671 mpz_init_set_ui(sing_int, 2147483647);
684 mpz_set_si(zvec, (*weight)[i-1]);
685 mpz_mul_ui(zmul, zvec,
pGetExp(p, i));
686 mpz_add(ztmp, ztmp, zmul);
688 mpz_init_set(result, ztmp);
705 mpz_t
max; mpz_init(max);
706 mpz_t maxtmp; mpz_init(maxtmp);
716 if(mpz_cmp(maxtmp, max)>0)
718 mpz_init_set(max, maxtmp);
724 if(mpz_cmp(maxtmp, max)==0)
744 for(i=nG-1; i>=0; i--)
764 PrintS(
"//** the result may be WRONG, i.e. 0!!\n");
774 for(i=nG-1; i>=0; i--)
810 static inline long Mlcm(
long &i1,
long &i2)
812 long temp =
gcd(i1, i2);
813 return ((i1 / temp)* i2);
826 for(i=n-1; i>=0; i--)
828 result += (*a)[
i] * (*b)[
i];
842 for(i=n-1; i>=0; i--)
844 (*result)[
i] = (*a)[
i] - (*b)[
i];
857 for(i=nR-1; i>=0; i--)
874 for (i=0; i<niv; i++)
876 if ((*u)[i] != (*v)[i])
946 (*ivm)[
i] = (*iv)[
i];
950 (*ivm)[i*nR+i-1] = 1;
967 (*ivm)[
i] = (*iv)[
i];
968 (*ivm)[i+nR] = (*iw)[
i];
972 (*ivm)[i*nR+i-2] = 1;
985 for(i=nR-1; i>=0; i--)
1008 static void checkComplexity(
ideal G,
char* cG)
1013 int i, tmpdeg, maxdeg=0;
1014 number tmpcoeff , maxcoeff=
currRing->cf->nNULL;
1016 for(i=nG-1; i>=0; i--)
1019 if(tmpdeg > maxdeg )
1025 for(i=nG-1; i>=0; i--)
1034 maxcoeff =
nCopy(tmpcoeff);
1040 p =
pNSet(maxcoeff);
1043 Print(
"// max total degree of %s = %d\n",cG, maxdeg);
1044 Print(
"// max coefficient of %s = %s", cG, pStr);
1045 Print(
" which consists of %d digits", (
int)strlen(pStr));
1072 if(pdeg > nV || pdeg <= 0)
1074 WerrorS(
"//** The perturbed degree is wrong!!");
1083 mpz_t *pert_vector = (mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
1088 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
1093 int ntemp, maxAi, maxA=0;
1094 for(i=1; i<pdeg; i++)
1096 maxAi = (*ivtarget)[i*nV];
1101 for(j=i*nV+1; j<(i+1)*nV; j++)
1103 ntemp = (*ivtarget)[
j];
1120 mpz_t tot_deg; mpz_init(tot_deg);
1121 mpz_t maxdeg; mpz_init(maxdeg);
1122 mpz_t inveps; mpz_init(inveps);
1125 for(i=nG-1; i>=0; i--)
1128 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1130 mpz_set(tot_deg, maxdeg);
1135 mpz_mul_ui(inveps, tot_deg, maxA);
1136 mpz_add_ui(inveps, inveps, 1);
1140 #ifdef INVEPS_SMALL_IN_MPERTVECTOR
1141 if(mpz_cmp_ui(inveps, pdeg)>0 && pdeg > 3)
1144 mpz_fdiv_q_ui(inveps, inveps, pdeg);
1149 mpz_out_str(stdout, 10, inveps);
1154 for( i=1; i < pdeg; i++ )
1158 mpz_mul(pert_vector[j], pert_vector[j], inveps);
1159 if((*ivtarget)[i*nV+j]<0)
1161 mpz_sub_ui(pert_vector[j], pert_vector[j],-(*ivtarget)[i*nV+j]);
1165 mpz_add_ui(pert_vector[j], pert_vector[j],(*ivtarget)[i*nV+j]);
1171 mpz_set(ztemp, pert_vector[0]);
1174 mpz_gcd(ztemp, ztemp, pert_vector[i]);
1175 if(mpz_cmp_si(ztemp, 1) == 0)
1180 if(mpz_cmp_si(ztemp, 1) != 0)
1184 mpz_divexact(pert_vector[i], pert_vector[i], ztemp);
1192 (* pert_vector1)[
i] = mpz_get_si(pert_vector[i]);
1193 (* pert_vector1)[
i] = 0.1*(* pert_vector1)[
i];
1194 (* pert_vector1)[
i] = floor((* pert_vector1)[i] + 0.5);
1195 if((* pert_vector1)[i] == 0)
1203 delete pert_vector1;
1204 goto CHECK_OVERFLOW;
1213 mpz_set_si(pert_vector[i], (*pert_vector1)[i]);
1220 delete pert_vector1;
1227 mpz_init_set_ui(sing_int, 2147483647);
1232 (*result)[
i] = mpz_get_si(pert_vector[i]);
1233 if(mpz_cmp(pert_vector[i], sing_int)>=0)
1239 PrintS(
"\n// ** OVERFLOW in \"MPertvectors\": ");
1240 mpz_out_str( stdout, 10, pert_vector[i]);
1241 PrintS(
" is greater than 2147483647 (max. integer representation)");
1242 Print(
"\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
1250 Print(
"\n// %d element(s) of it is overflow!!", ntrue);
1254 mpz_clear(sing_int);
1289 if(pdeg > nV || pdeg <= 0)
1291 WerrorS(
"//** The perturbed degree is wrong!!");
1296 (*pert_vector)[
i]=(*ivtarget)[
i];
1304 int ntemp, maxAi, maxA=0;
1305 for(i=1; i<pdeg; i++)
1307 maxAi = (*ivtarget)[i*nV];
1308 for(j=i*nV+1; j<(i+1)*nV; j++)
1310 ntemp = (*ivtarget)[
j];
1320 int inveps, tot_deg = 0, maxdeg;
1323 for(i=nG-1; i>=0; i--)
1327 if (maxdeg > tot_deg )
1334 inveps = (tot_deg * maxA) + 1;
1336 #ifdef INVEPS_SMALL_IN_FRACTAL
1338 if(inveps > pdeg && pdeg > 3)
1340 inveps = inveps / pdeg;
1344 PrintS(
"\n// the \"big\" inverse epsilon %d", inveps);
1348 for ( i=1; i < pdeg; i++ )
1352 (*pert_vector)[
j] = inveps*((*pert_vector)[
j]) + (*ivtarget)[i*nV+
j];
1356 int temp = (*pert_vector)[0];
1359 temp =
gcd(temp, (*pert_vector)[i]);
1369 (*pert_vector)[
i] = (*pert_vector)[
i] / temp;
1388 (*ivM)[i*nV +
i] = 1;
1408 (*ivM)[(i+1)*nV - i] = -1;
1419 int nV = ivstart->
length();
1424 (*ivM)[
i] = (*ivstart)[
i];
1428 (*ivM)[i*nV + i-1] = 1;
1439 int nV = ivstart->
length();
1444 (*ivM)[
i] = (*ivstart)[
i];
1452 (*ivM)[(i+1)*nV - i] = -1;
1459 static intvec* MatrixOrderdp(
int nV)
1470 (*ivM)[(i+1)*nV - i] = -1;
1480 for(i=nV-1; i>=0; i--)
1501 int ntemp, maxAi, maxA=0;
1504 maxAi = (*ivtarget)[i*nV];
1509 for(j=i*nV+1; j<(i+1)*nV; j++)
1511 ntemp = (*ivtarget)[
j];
1521 maxA = maxA + maxAi;
1526 mpz_t tot_deg; mpz_init(tot_deg);
1527 mpz_t maxdeg; mpz_init(maxdeg);
1528 mpz_t inveps; mpz_init(inveps);
1531 for(i=nG-1; i>=0; i--)
1534 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1536 mpz_set(tot_deg, maxdeg);
1542 mpz_mul_ui(inveps, tot_deg, maxA);
1543 mpz_add_ui(inveps, inveps, 1);
1546 #ifdef INVEPS_SMALL_IN_FRACTAL
1547 if(mpz_cmp_ui(inveps, nV)>0 && nV > 3)
1549 mpz_cdiv_q_ui(inveps, inveps, nV);
1557 mpz_t *ivtemp=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
1558 mpz_t *pert_vector=(mpz_t *)
omAlloc(niv*
sizeof(mpz_t));
1560 for(i=0; i < nV; i++)
1562 mpz_init_set_si(ivtemp[i], (*ivtarget)[i]);
1563 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
1566 mpz_t ztmp; mpz_init(ztmp);
1573 mpz_mul(ztmp, inveps, ivtemp[j]);
1574 if((*ivtarget)[i*nV+j]<0)
1576 mpz_sub_ui(ivtemp[j], ztmp, -(*ivtarget)[i*nV+j]);
1580 mpz_add_ui(ivtemp[j], ztmp,(*ivtarget)[i*nV+j]);
1586 mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);
1592 mpz_init_set_ui(sing_int, 2147483647);
1599 mpz_set(ztmp, pert_vector[0]);
1600 for(i=0; i<niv; i++)
1602 mpz_gcd(ztmp, ztmp, pert_vector[i]);
1603 if(mpz_cmp_si(ztmp, 1)==0)
1609 for(i=0; i<niv; i++)
1611 mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
1612 (* result)[
i] = mpz_get_si(pert_vector[i]);
1618 (* result1)[
i] = mpz_get_si(pert_vector[i]);
1619 (* result1)[
i] = 0.1*(* result1)[
i];
1620 (* result1)[
i] = floor((* result1)[i] + 0.5);
1621 if((* result1)[i] == 0)
1630 goto CHECK_OVERFLOW;
1641 mpz_set_si(pert_vector[i], (*result1)[i]);
1652 for(i=0; i<niv; i++)
1654 if(mpz_cmp(pert_vector[i], sing_int)>0)
1661 Print(
"\n// Xlev = %d and the %d-th element is", Xnlev, i+1);
1662 PrintS(
"\n// ** OVERFLOW in \"Mfpertvector\": ");
1663 mpz_out_str( stdout, 10, pert_vector[i]);
1664 PrintS(
" is greater than 2147483647 (max. integer representation)");
1665 Print(
"\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
1679 mpz_clear(sing_int);
1717 if (result->m[k]!=
NULL)
1758 for(j=
IDELEMS(idLG)-1; j>=0; j--)
1760 F->m[
i] =
pAdd(F->m[i], idLG->m[j]);
1771 static void checkidealCC(
ideal G,
char* Ch)
1776 Print(
"\n//** Ideal %s besteht aus %d Polynomen mit ", Ch, nG);
1785 Print(
"%d, ", ntmp);
1789 Print(
" bzw. %d ", ntmp);
1793 Print(
"//** %s besitzt %d Monome.", Ch, nmon);
1800 static void HeadidString(
ideal L,
char* st)
1804 Print(
"// The head terms of the ideal %s = ", st);
1817 for(i=iva->
length()-1; i>=0; i--)
1819 if((*iva)[
i] - (*ivb)[
i] != 0)
1841 for(i=1; i < (vec->
length()); i++)
1872 target_weight !=
NULL && G !=
NULL);
1875 int checkRed,
j, kkk, nG =
IDELEMS(G);
1878 mpz_t t_zaehler, t_nenner;
1879 mpz_init(t_zaehler);
1882 mpz_t s_zaehler, s_nenner, temp, MwWd;
1883 mpz_init(s_zaehler);
1890 mpz_set_si(sing_int, 2147483647);
1892 mpz_t sing_int_half;
1893 mpz_init(sing_int_half);
1894 mpz_set_si(sing_int_half, 3*(1073741824/2));
1896 mpz_t deg_w0_p1, deg_d0_p1;
1897 mpz_init(deg_w0_p1);
1898 mpz_init(deg_d0_p1);
1915 intvec* diff_weight =
MivSub(target_weight, curr_weight);
1917 intvec* diff_weight1 =
MivSub(target_weight, curr_weight);
1920 for (j=0; j<nG; j++)
1935 mpz_sub(s_zaehler, deg_w0_p1, MwWd);
1937 if(mpz_cmp(s_zaehler, t_null) != 0)
1940 mpz_sub(s_nenner, MwWd, deg_d0_p1);
1943 if( (mpz_cmp(s_zaehler,t_null) > 0 &&
1944 mpz_cmp(s_nenner, s_zaehler)>=0) ||
1945 (mpz_cmp(s_zaehler, t_null) < 0 &&
1946 mpz_cmp(s_nenner, s_zaehler)<=0))
1949 if (mpz_cmp(s_zaehler, t_null) < 0)
1951 mpz_neg(s_zaehler, s_zaehler);
1952 mpz_neg(s_nenner, s_nenner);
1956 cancel(s_zaehler, s_nenner);
1958 if(mpz_cmp(t_nenner, t_null) != 0)
1960 mpz_mul(sztn, s_zaehler, t_nenner);
1961 mpz_mul(sntz, s_nenner, t_zaehler);
1963 if(mpz_cmp(sztn,sntz) < 0)
1965 mpz_add(t_nenner, t_null, s_nenner);
1966 mpz_add(t_zaehler,t_null, s_zaehler);
1971 mpz_add(t_nenner, t_null, s_nenner);
1972 mpz_add(t_zaehler,t_null, s_zaehler);
1982 mpz_t *
vec=(mpz_t*)
omAlloc(nRing*
sizeof(mpz_t));
1986 if(mpz_cmp(t_nenner, t_null) == 0)
1989 Print(
"\n//MwalkNextWeightCC: t_nenner ist Null!");
1992 diff_weight =
ivCopy(curr_weight);
1997 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
2000 diff_weight =
ivCopy(target_weight);
2009 gcd_tmp = (*curr_weight)[0];
2011 for (j=1; j<nRing; j++)
2013 gcd_tmp =
gcd(gcd_tmp, (*curr_weight)[j]);
2021 for (j=0; j<nRing; j++)
2023 gcd_tmp =
gcd(gcd_tmp, (*diff_weight)[j]);
2032 for (j=0; j<nRing; j++)
2034 (*curr_weight)[
j] = (*curr_weight)[
j]/gcd_tmp;
2035 (*diff_weight)[
j] = (*diff_weight)[
j]/gcd_tmp;
2040 for (j=0; j<nRing; j++)
2042 mpz_set_si(vec[j], (*diff_weight)[j]);
2047 #ifdef NEXT_VECTORS_CC
2048 Print(
"\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
2052 PrintS(
"\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler);
2053 PrintS(
", t_nenner: "); mpz_out_str( stdout, 10, t_nenner);
2059 for (j=0; j<nRing; j++)
2061 mpz_set_si(dcw, (*curr_weight)[j]);
2062 mpz_mul(s_nenner, t_nenner, dcw);
2064 if( (*diff_weight)[j]>0)
2066 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
2070 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
2071 mpz_neg(s_zaehler, s_zaehler);
2073 mpz_add(sntz, s_nenner, s_zaehler);
2074 mpz_init_set(vec[j], sntz);
2076 #ifdef NEXT_VECTORS_CC
2077 Print(
"\n// j = %d ==> ", j);
2079 mpz_out_str( stdout, 10, t_nenner);
2080 Print(
" * %d)", (*curr_weight)[j]);
2081 Print(
" + ("); mpz_out_str( stdout, 10, t_zaehler);
2082 Print(
" * %d) = ", (*diff_weight)[j]);
2083 mpz_out_str( stdout, 10, s_nenner);
2085 mpz_out_str( stdout, 10, s_zaehler);
2086 PrintS(
" = "); mpz_out_str( stdout, 10, sntz);
2087 Print(
" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
2096 if(mpz_cmp_si(ggt,1) != 0)
2098 mpz_gcd(ggt, ggt, sntz);
2103 #ifdef NEXT_VECTORS_CC
2104 PrintS(
"\n// gcd of elements of the vector: ");
2105 mpz_out_str( stdout, 10, ggt);
2116 for(j=0; j<nRing; j++)
2118 if(mpz_cmp(vec[j], sing_int_half) >= 0)
2124 for (j=0; j<nRing; j++)
2126 (*diff_weight)[
j] = mpz_get_si(vec[j]);
2131 for (j=0; j<nRing; j++)
2133 (*diff_weight)[
j] = mpz_get_si(vec[j]);
2137 for (j=0; j<nRing; j++)
2139 if(mpz_cmp_si(ggt,1)==0)
2141 (*diff_weight1)[
j] = floor(0.1*(*diff_weight)[j] + 0.5);
2146 mpz_divexact(vec[j], vec[j], ggt);
2147 (*diff_weight1)[
j] = floor(0.1*(*diff_weight)[j] + 0.5);
2170 Print(
"\n// MwalkNextWeightCC: geaenderter vector liegt in Groebnerkegel! \n");
2171 for (j=0; j<nRing; j++)
2173 (*diff_weight)[
j] = (*diff_weight1)[
j];
2190 for (j=0; j<nRing; j++)
2192 if(mpz_cmp(vec[j], sing_int)>=0)
2197 PrintS(
"\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
2198 mpz_out_str( stdout, 10, vec[j]);
2199 PrintS(
" is greater than 2147483647 (max. integer representation)\n");
2206 delete diff_weight1;
2207 mpz_clear(t_zaehler);
2208 mpz_clear(t_nenner);
2209 mpz_clear(s_zaehler);
2210 mpz_clear(s_nenner);
2215 mpz_clear(deg_w0_p1);
2216 mpz_clear(deg_d0_p1);
2219 mpz_clear(sing_int_half);
2220 mpz_clear(sing_int);
2231 for(kkk=0; kkk<
IDELEMS(G);kkk++)
2308 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2309 r->wvhdl[1] = (
int*)
omAlloc((nv-1)*
sizeof(
int));
2311 for(i=0; i<nv-1; i++)
2313 r->wvhdl[1][
i] = (*vb)[
i];
2314 r->wvhdl[0][
i] = (*va)[
i];
2316 r->wvhdl[0][nv] = (*va)[nv];
2319 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2320 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2321 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2390 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2392 r->wvhdl[0][i] = (*va)[
i];
2395 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2396 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2397 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2460 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2462 r->wvhdl[0][i] = (*va)[
i];
2465 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2466 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2467 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2535 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2536 r->wvhdl[1] = (
int*)
omAlloc(nv*
sizeof(
int));
2540 r->wvhdl[0][
i] = (*va)[
i];
2541 r->wvhdl[1][
i] = (*vb)[
i];
2547 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2548 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2549 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2618 r->wvhdl[0] = (
int*)
omAlloc(nv*nv*
sizeof(
int));
2622 for(i=0; i<nv*nv; i++)
2623 r->wvhdl[0][i] = (*va)[
i];
2626 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2627 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2628 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2696 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2697 r->wvhdl[1] = (
int*)
omAlloc(nvs*
sizeof(
int));
2700 for(i=0; i<nvs; i++)
2702 r->wvhdl[1][
i] = (*va)[
i];
2706 r->wvhdl[0][
i] = (*vb)[
i];
2709 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2710 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2711 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2781 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2782 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2783 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2818 res->VarOffset =
NULL;
2826 res->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2828 res->wvhdl[0][i] = (*va)[
i];
2832 res->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2833 res->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2834 res->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2839 res->block1[0] = nv;
2844 res->block1[1] = nv;
2860 for (i=nv-1; i>=0; i--)
2887 r->VarOffset =
NULL;
2900 for(i=nv-1; i>=0; i--)
2911 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2912 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2913 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2964 for(i=hilb->
length()-1; i>=0; i--)
2990 int nwalk=0, endwalks=0, nnwinC=1;
2992 ideal Gomega,
M, F, Gomega1, Gomega2, M1,F1,
result,ssG;
2993 ring newRing, oldRing, TargetRing;
2997 intvec* pert_target_vector;
3002 #ifndef BUCHBERGER_ALG
3008 for(i=nV-1; i>0; i--)
3010 (*last_omega)[
i] = 1;
3012 (*last_omega)[0] = 10000;
3017 if(tp_deg > 1 && tp_deg <= nV)
3034 pert_target_vector = target_weight;
3041 target_weight =
Mivlp(nV);
3052 xtnw=xtnw+clock()-
to;
3054 #ifdef PRINT_VECTORS
3055 MivString(curr_weight, target_weight, next_weight);
3074 if(
MivComp(next_weight, ivNull) == 1)
3082 if(
MivComp(next_weight, target_weight) == 1)
3085 for(i=nV-1; i>=0; i--)
3087 (*extra_curr_weight)[
i] = (*curr_weight)[
i];
3090 for(i=nV-1; i>=0; i--)
3092 (*curr_weight)[
i] = (*next_weight)[
i];
3098 xtif=xtif+clock()-
to;
3104 idElements(Gomega,
"Gw");
3105 headidString(Gomega,
"Gw");
3109 #ifndef BUCHBERGER_ALG
3118 #endif // BUCHBERGER_ALG
3135 #ifdef BUCHBERGER_ALG
3140 #endif // BUCHBERGER_ALG
3141 xtstd=xtstd+clock()-
to;
3150 xtlift=xtlift+clock()-
to;
3162 xtred=xtred+clock()-
to;
3194 Print(
"\n// takes %d steps and calls the recursion of level %d:",
3197 F1 =
LastGB(G,curr_weight, tp_deg-1);
3243 delete target_weight;
3260 for(i=
IDELEMS(G)-1; i>=0; i--)
3269 && (G->m[i]->next!=
NULL)
3270 && (G->m[i]->next->next!=
NULL)
3271 && (G->m[i]->next->next->next!=
NULL)
3288 for(i=
IDELEMS(G)-1; i>=0; i--)
3291 && (G->m[i]->next!=
NULL)
3292 && (G->m[i]->next->next!=
NULL))
3327 for (i=nH-1;i>=0; i--)
3348 for(i=nG-1; i>=0; i--)
3373 static int Trandegreebound(
ideal G)
3381 for(i=nG-1; i>=0; i--)
3417 int mtmp,
m=(*iva)[0];
3419 for(i=ivMat->
length(); i>=0; i--)
3438 mpz_set_si(ndeg, Trandegreebound(G)+1);
3444 mpz_init_set_si(maxdeg, Trandegreebound(G));
3447 mpz_pow_ui(ztmp, maxdeg, 2);
3448 mpz_mul_ui(ztmp, ztmp, 2);
3449 mpz_mul_ui(maxdeg, maxdeg, nV+1);
3450 mpz_add(ndeg, ztmp, maxdeg);
3451 mpz_mul_ui(ndeg, ndeg, m);
3457 #endif //UPPER_BOUND
3459 #ifdef INVEPS_SMALL_IN_TRAN
3460 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
3462 mpz_cdiv_q_ui(ndeg, ndeg, nV);
3468 mpz_init_set(deg_tmp, ndeg);
3470 mpz_t *ivres=( mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3471 mpz_init_set_si(ivres[nV-1],1);
3473 for(i=nV-2; i>=0; i--)
3475 mpz_init_set(ivres[i], deg_tmp);
3476 mpz_mul(deg_tmp, deg_tmp, ndeg);
3479 mpz_t *ivtmp=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3485 mpz_init_set_ui(sing_int, 2147483647);
3494 if( (*ivMat)[i*nV+j] >= 0 )
3496 mpz_mul_ui(ivres[i], ivres[i], (*ivMat)[i*nV+j]);
3500 mpz_mul_ui(ivres[i], ivres[i], -(*ivMat)[i*nV+j]);
3501 mpz_neg(ivres[i], ivres[i]);
3503 mpz_add(ivtmp[j], ivtmp[j], ivres[i]);
3511 (*repr_vector)[
i] = mpz_get_si(ivtmp[i]);
3512 if(mpz_cmp(ivtmp[i], sing_int)>=0)
3519 PrintS(
"\n// ** OVERFLOW in \"Repr.Vector\": ");
3520 mpz_out_str( stdout, 10, ivtmp[i]);
3521 PrintS(
" is greater than 2147483647 (max. integer representation)");
3522 Print(
"\n// So vector[%d] := %d is wrong!!\n",i+1,(*repr_vector)[i]);
3528 ivString(repr_vector,
"repvector");
3529 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3538 mpz_clear(sing_int);
3562 mpz_set_si(ndeg, Trandegreebound(G)+1);
3568 mpz_init_set_si(maxdeg, Trandegreebound(G));
3571 mpz_pow_ui(ztmp, maxdeg, 2);
3572 mpz_mul_ui(ztmp, ztmp, 2);
3573 mpz_mul_ui(maxdeg, maxdeg, nV+1);
3574 mpz_add(ndeg, ztmp, maxdeg);
3583 #ifdef INVEPS_SMALL_IN_TRAN
3584 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
3585 mpz_cdiv_q_ui(ndeg, ndeg, nV);
3592 mpz_init_set(deg_tmp, ndeg);
3594 mpz_t *ivres=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3595 mpz_init_set_si(ivres[nV-1], 1);
3597 for(i=nV-2; i>=0; i--)
3599 mpz_init_set(ivres[i], deg_tmp);
3600 mpz_mul(deg_tmp, deg_tmp, ndeg);
3604 mpz_init_set_ui(sing_int, 2147483647);
3610 (*repr_vector)[
i] = mpz_get_si(ivres[i]);
3612 if(mpz_cmp(ivres[i], sing_int)>=0)
3618 PrintS(
"\n// ** OVERFLOW in \"Repr.Vector\": ");
3619 mpz_out_str( stdout, 10, ivres[i]);
3620 PrintS(
" is greater than 2147483647 (max. integer representation)");
3621 Print(
"\n// So vector[%d] := %d is wrong!!\n",i+1,(*repr_vector)[i]);
3627 ivString(repr_vector,
"repvector");
3628 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3636 mpz_clear(sing_int);
3653 int degtmp, maxdeg = 0;
3655 for(i=
IDELEMS(G)-1; i>=0; i--)
3664 mpz_init_set_si(ztmp, maxdeg);
3665 mpz_t *ivres=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3666 mpz_init_set_si(ivres[nV-1], 1);
3668 for(i=nV-2; i>=0; i--)
3670 mpz_init_set(ivres[i], ztmp);
3671 mpz_mul_ui(ztmp, ztmp, maxdeg);
3674 mpz_t *ivtmp=(mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
3682 if((*M)[i*nV+
j] < 0)
3684 mpz_mul_ui(ztmp, ivres[i], -(*M)[i*nV+j]);
3685 mpz_neg(ztmp, ztmp);
3688 mpz_mul_ui(ztmp, ivres[i], (*M)[i*nV+j]);
3690 mpz_add(ivtmp[j], ivtmp[j], ztmp);
3694 mpz_init_set_ui(sing_int, 2147483647);
3700 (*repvector)[
i] = mpz_get_si(ivtmp[i]);
3701 if(mpz_cmp(ivtmp[i], sing_int)>0)
3707 PrintS(
"\n// ** OVERFLOW in \"Repr.Matrix\": ");
3708 mpz_out_str( stdout, 10, ivtmp[i]);
3709 PrintS(
" is greater than 2147483647 (max. integer representation)");
3710 Print(
"\n// So vector[%d] := %d is wrong!!\n",i+1,(*repvector)[i]);
3717 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3723 mpz_clear(sing_int);
3743 static int testnegintvec(
intvec*
v)
3760 intvec* orig_target_weight,
int tp_deg,
int npwinc)
3767 clock_t tinput = clock();
3770 int nwalk=0, endwalks=0, nnwinC=1;
3772 ideal Gomega,
M, F, Gomega1, Gomega2, M1,F1,
result,ssG;
3773 ring newRing, oldRing, TargetRing;
3780 #ifndef BUCHBERGER_ALG
3786 for(i=nV-1; i>0; i--)
3787 (*last_omega)[
i] = 1;
3788 (*last_omega)[0] = 10000;
3793 if(tp_deg > 1 && tp_deg <= nV)
3862 xtif=xtif+clock()-
to;
3864 #ifndef BUCHBERGER_ALG
3873 #endif // BUCHBERGER_ALG
3890 #ifdef BUCHBERGER_ALG
3895 #endif // BUCHBERGER_ALG
3896 xtstd=xtstd+clock()-
to;
3905 xtlift=xtlift+clock()-
to;
3917 xtred=xtred+clock()-
to;
3929 xtnw=xtnw+clock()-
to;
3930 #ifdef PRINT_VECTORS
3931 MivString(curr_weight, target_weight, next_weight);
3937 #ifdef TEST_OVERFLOW
3950 if(
MivComp(next_weight, ivNull) == 1)
3957 if(
MivComp(next_weight, target_weight) == 1)
3967 tproc=tproc+clock()-tinput;
3972 G =
Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
3979 for(i=nV-1; i>=0; i--)
3981 (*curr_weight)[
i] = (*next_weight)[
i];
4006 tproc=tproc+clock()-tinput;
4007 F1 =
Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4009 delete target_weight;
4082 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
xtextra=0;
4084 clock_t tostd, tproc;
4088 int nwalk=0, endwalks=0;
4090 ideal Gomega,
M, F, Gomega1, Gomega2, M1, F1,
G;
4093 ring newRing, oldRing;
4126 xtif=xtif+clock()-
to;
4130 for(i=nV-1; i>=0; i--)
4131 (*curr_weight)[
i] = (*extra_curr_weight)[
i];
4132 delete extra_curr_weight;
4152 xtstd=xtstd+clock()-
to;
4162 xtlift=xtlift+clock()-
to;
4174 xtred=xtred+clock()-
to;
4184 xtnw=xtnw+clock()-
to;
4185 #ifdef PRINT_VECTORS
4186 MivString(curr_weight, target_weight, next_weight);
4195 #ifdef TEST_OVERFLOW
4196 goto TEST_OVERFLOW_OI;
4215 if(
MivComp(next_weight, ivNull) == 1)
4222 if(
MivComp(next_weight, target_weight) == 1)
4224 if(
MivSame(target_weight, exivlp)==1)
4231 G =
Rec_LastGB(G, curr_weight, target_weight, 2,1);
4239 for(i=nV-1; i>=0; i--)
4242 (*curr_weight)[
i] = (*next_weight)[
i];
4246 #ifdef TEST_OVERFLOW
4257 TimeStringFractal(
xftinput, tostd, xtif, xtstd,
xtextra,xtlift, xtred,xtnw);
4298 if(
MivComp(next_weight, target_weight) == 1)
4300 return(next_weight);
4312 while(weight_norm == 0)
4317 (*next_weight22)[
i] = rand() % 60000 - 30000;
4318 weight_norm = weight_norm + (*next_weight22)[
i]*(*next_weight22)[
i];
4320 weight_norm = 1 + floor(
sqrt(weight_norm));
4323 for(i=nV-1; i>=0; i--)
4325 if((*next_weight22)[i] < 0)
4327 (*next_weight22)[
i] = 1 + (*curr_weight)[
i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
4331 (*next_weight22)[
i] = (*curr_weight)[
i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
4340 delete next_weight22;
4356 (*result)[
i] = (*next_weight2)[
i];
4363 (*result)[
i] = (*next_weight1)[
i];
4373 (*result)[
i] = (*next_weight2)[
i];
4380 (*result)[
i] = (*next_weight)[
i];
4385 delete next_weight1;
4391 delete next_weight2;
4397 return next_weight2;
4422 while(weight_norm == 0)
4426 (*next_weight22)[
i] = rand() % 60000 - 30000;
4427 weight_norm = weight_norm + (*next_weight22)[
i]*(*next_weight22)[
i];
4429 weight_norm = 1 + floor(
sqrt(weight_norm));
4433 if((*next_weight22)[i] < 0)
4435 (*next_weight22)[
i] = 1 + (*curr_weight)[
i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
4439 (*next_weight22)[
i] = (*curr_weight)[
i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
4445 delete next_weight22;
4465 (*result)[
i] = (*next_weight2)[
i];
4473 (*result)[
i] = (*next_weight1)[
i];
4483 (*result)[
i] = (*next_weight2)[
i];
4491 (*result)[
i] = (*next_weight)[
i];
4504 (*result)[
i] = (*next_weight2)[
i];
4511 (*result)[
i] = (*next_weight)[
i];
4519 delete next_weight2;
4521 delete next_weight1;
4527 delete next_weight2;
4528 delete next_weight1;
4540 int tp_deg,
int npwinc)
4546 int nwalk=0, endwalks=0, nnwinC=1, nlast = 0;
4547 ideal Gomega,
M, F, Gomega1, Gomega2, M1,F1,
result,ssG;
4548 ring newRing, oldRing, TargetRing;
4551 #ifndef BUCHBERGER_ALG
4555 for(i=nV-1; i>0; i--)
4557 (*last_omega)[
i] = 1;
4559 (*last_omega)[0] = 10000;
4566 if(tp_deg > 1 && tp_deg <= nV)
4624 xtif = xtif + clock()-
to;
4626 #ifndef BUCHBERGER_ALG
4653 #ifdef BUCHBERGER_ALG
4659 xtstd = xtstd + clock() -
to;
4669 xtlift = xtlift + clock() -
to;
4683 xtred = xtred + clock() -
to;
4697 xtnw = xtnw + clock() -
to;
4699 #ifdef PRINT_VECTORS
4700 MivString(curr_weight, target_weight, next_weight);
4714 if(
MivComp(next_weight, ivNull) == 1)
4721 if(
MivComp(next_weight, target_weight) == 1)
4729 G =
REC_GB_Mwalk(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4736 for(i=nV-1; i>=0; i--)
4738 (*curr_weight)[
i] = (*next_weight)[
i];
4761 F1 =
REC_GB_Mwalk(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4767 F1 =
REC_GB_Mwalk(F1,curr_weight, orig_target_weight,tp_deg+1,nnwinC);
4770 delete target_weight;
4814 #ifndef BUCHBERGER_ALG
4829 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
4830 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
4839 ideal Gomega,
M, F, Gomega1, Gomega2, M1, F1,
G;
4842 ring newRing, oldRing;
4845 #ifndef BUCHBERGER_ALG
4849 for(i=nV-1; i>=0; i--)
4850 (*tmp_weight)[
i] = (*curr_weight)[
i];
4854 for(i=nV-1; i>0; i--)
4855 (*last_omega)[
i] = 1;
4856 (*last_omega)[0] = 10000;
4875 tif = tif + clock()-
to;
4889 if(
MivSame(exivlp, target_weight)==1)
4898 #ifdef CHECK_IDEAL_MWALK
4899 idElements(Gomega,
"G_omega");
4900 headidString(Gomega,
"Gw");
4906 xtlift = xtlift + clock() -
to;
4929 #ifndef BUCHBERGER_ALG
4938 #endif // BUCHBERGER_ALG
4954 #ifdef BUCHBERGER_ALG
4959 #endif // BUCHBERGER_ALG
4960 tstd = tstd + clock() -
to;
4970 tlift = tlift + clock() -
to;
4986 tred = tred + clock() -
to;
4990 xtred = xtred + clock() -
to;
5001 tnw = tnw + clock() -
to;
5002 #ifdef PRINT_VECTORS
5003 MivString(curr_weight, target_weight, next_weight);
5010 PrintS(
"\n// ** The computed vector does NOT stay in Cone!!\n");
5028 if(
MivComp(next_weight, ivNull) == 1)
5034 if(
MivComp(next_weight, target_weight) == 1)
5038 for(i=nV-1; i>=0; i--)
5040 (*tmp_weight)[
i] = (*curr_weight)[
i];
5041 (*curr_weight)[
i] = (*next_weight)[
i];
5053 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5074 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5075 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5080 int i,nwalk,endwalks = 0;
5081 int nV = baseRing->N;
5083 ideal Gomega,
M, F, Gomega1, Gomega2, M1;
5085 ring XXRing = baseRing;
5093 (*tmp_weight)[
i] = (*target_M)[
i];
5097 (*curr_weight)[
i] = (*orig_M)[
i];
5098 (*target_weight)[
i] = (*target_M)[
i];
5100 #ifndef BUCHBERGER_ALG
5104 for(i=nV-1; i>0; i--)
5106 (*last_omega)[
i] = 1;
5108 (*last_omega)[0] = 10000;
5111 #ifdef CHECK_IDEAL_MWALK
5117 if(orig_M->
length() == nV)
5140 #ifdef CHECK_IDEAL_MWALK
5145 tif = tif + clock()-
to;
5147 #ifdef CHECK_IDEAL_MWALK
5148 idString(Gomega,
"Gomega");
5150 #ifndef BUCHBERGER_ALG
5162 if(orig_M->
length() == nV)
5173 if(target_M->
length() == nV)
5175 newRing =
VMrRefine(curr_weight,target_weight);
5189 #ifndef BUCHBERGER_ALG
5196 tstd = tstd + clock() -
to;
5199 #ifdef CHECK_IDEAL_MWALK
5200 PrintS(
"\n//** Mwalk: computed M.\n");
5215 tlift = tlift + clock() -
to;
5217 #ifdef CHECK_IDEAL_MWALK
5231 tstd = tstd + clock() -
to;
5234 #ifdef CHECK_IDEAL_MWALK
5242 tnw = tnw + clock() -
to;
5244 #ifdef PRINT_VECTORS
5245 MivString(curr_weight, target_weight, next_weight);
5247 if(
MivComp(next_weight, ivNull) == 1 ||
MivComp(target_weight,curr_weight) == 1)
5249 #ifdef CHECK_IDEAL_MWALK
5250 PrintS(
"\n//** Mwalk: entering last cone.\n");
5253 if(target_M->
length() == nV)
5264 #ifdef CHECK_IDEAL_MWALK
5265 idString(Gomega1,
"Gomega");
5268 #ifdef CHECK_IDEAL_MWALK
5277 #ifdef CHECK_IDEAL_MWALK
5296 tred = tred + clock() -
to;
5301 #ifdef CHECK_IDEAL_MWALK
5302 PrintS(
"\n//** Mwalk: last cone.\n");
5305 #ifdef CHECK_IDEAL_MWALK
5306 PrintS(
"\n//** Mwalk: update weight vectors.\n");
5308 for(i=nV-1; i>=0; i--)
5310 (*tmp_weight)[
i] = (*curr_weight)[
i];
5311 (*curr_weight)[
i] = (*next_weight)[
i];
5324 #ifndef BUCHBERGER_ALG
5328 Print(
"\n//** Mwalk: Groebner Walk took %d steps.\n",
nstep);
5329 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5330 Print(
"\n//** Mwalk: Ergebnis.\n");
5348 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5349 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5354 int i,nwalk,endwalks = 0;
5355 int nV = baseRing->N;
5357 ideal Gomega,
M, F, Gomega1, Gomega2, M1;
5359 ring XXRing = baseRing;
5367 (*tmp_weight)[
i] = (*target_M)[
i];
5371 (*curr_weight)[
i] = (*orig_M)[
i];
5372 (*target_weight)[
i] = (*target_M)[
i];
5374 #ifndef BUCHBERGER_ALG
5378 for(i=nV-1; i>0; i--)
5380 (*last_omega)[
i] = 1;
5382 (*last_omega)[0] = 10000;
5385 #ifdef CHECK_IDEAL_MWALK
5391 if(orig_M->
length() == nV)
5414 #ifdef CHECK_IDEAL_MWALK
5419 tif = tif + clock()-
to;
5421 #ifdef CHECK_IDEAL_MWALK
5422 idString(Gomega,
"Gomega");
5424 #ifndef BUCHBERGER_ALG
5436 if(orig_M->
length() == nV)
5447 if(target_M->
length() == nV)
5449 newRing =
VMrRefine(curr_weight,target_weight);
5463 #ifndef BUCHBERGER_ALG
5470 tstd = tstd + clock() -
to;
5473 #ifdef CHECK_IDEAL_MWALK
5474 PrintS(
"\n//** Mwalk: computed M.\n");
5489 tlift = tlift + clock() -
to;
5491 #ifdef CHECK_IDEAL_MWALK
5505 tstd = tstd + clock() -
to;
5508 #ifdef CHECK_IDEAL_MWALK
5516 tnw = tnw + clock() -
to;
5518 #ifdef PRINT_VECTORS
5519 MivString(curr_weight, target_weight, next_weight);
5521 if(
MivComp(next_weight, ivNull) == 1 ||
MivComp(target_weight,curr_weight) == 1)
5523 #ifdef CHECK_IDEAL_MWALK
5524 PrintS(
"\n//** Mwalk: entering last cone.\n");
5527 if(target_M->
length() == nV)
5538 #ifdef CHECK_IDEAL_MWALK
5539 idString(Gomega1,
"Gomega");
5542 #ifdef CHECK_IDEAL_MWALK
5551 #ifdef CHECK_IDEAL_MWALK
5570 tred = tred + clock() -
to;
5575 #ifdef CHECK_IDEAL_MWALK
5576 PrintS(
"\n//** Mwalk: last cone.\n");
5579 #ifdef CHECK_IDEAL_MWALK
5580 PrintS(
"\n//** Mwalk: update weight vectors.\n");
5582 for(i=nV-1; i>=0; i--)
5584 (*tmp_weight)[
i] = (*curr_weight)[
i];
5585 (*curr_weight)[
i] = (*next_weight)[
i];
5598 #ifndef BUCHBERGER_ALG
5602 Print(
"\n//** Mwalk: Groebner Walk took %d steps.\n",
nstep);
5603 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5604 Print(
"\n//** Mwalk: Ergebnis.\n");
5618 int nwalk=0, endwalks=0;
5620 ideal Gomega,
M, F, Gomega1, Gomega2, M1, F1,
G;
5622 ring newRing, oldRing;
5627 for(i=nV-1; i>=0; i--)
5629 (*tmp_weight)[
i] = (*curr_weight)[
i];
5633 #ifndef BUCHBERGER_ALG
5638 for(i=nV-1; i>0; i--)
5639 (*last_omega)[
i] = 1;
5640 (*last_omega)[0] = 10000;
5651 idString(Gomega,
"Gw");
5653 #ifndef BUCHBERGER_ALG
5658 #endif // BUCHBERGER_ALG
5670 #ifdef BUCHBERGER_ALG
5675 #endif // BUCHBERGER_ALG
5707 #ifdef PRINT_VECTORS
5708 MivString(curr_weight, target_weight, next_weight);
5711 if(
MivComp(next_weight, ivNull) == 1)
5716 if(
MivComp(next_weight, target_weight) == 1)
5719 for(i=nV-1; i>=0; i--)
5720 (*tmp_weight)[
i] = (*curr_weight)[
i];
5723 for(i=nV-1; i>=0; i--)
5724 (*curr_weight)[
i] = (*next_weight)[
i];
5751 intvec* target_weight,
int nP)
5757 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5759 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5765 int i, ntwC=1, ntestw=1, nV =
currRing->N;
5768 ideal Gomega,
M, F,
G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
5769 ring newRing, oldRing, TargetRing;
5773 intvec* orig_target = target_weight;
5774 intvec* pert_target_vector = target_weight;
5777 #ifndef BUCHBERGER_ALG
5784 for(i=nV-1; i>0; i--)
5785 (*last_omega)[
i] = 1;
5786 (*last_omega)[0] = 10000;
5793 if(
MivComp(curr_weight, iv_dp) == 1)
5820 if(op_deg != 1)
delete iv_M_dp;
5825 if(tp_deg > 1 && tp_deg <= nV)
5834 if(
MivSame(target_weight, exivlp) == 1)
5848 pert_target_vector = target_weight;
5871 headidString(G,
"G");
5876 tif = tif + clock()-
to;
5878 #ifndef BUCHBERGER_ALG
5883 #endif // BUCHBERGER_ALG
5900 idElements(Gomega1,
"Gw");
5901 headidString(Gomega1,
"headGw");
5902 PrintS(
"\n// compute a rGB of Gw:\n");
5904 #ifndef BUCHBERGER_ALG
5913 #ifdef BUCHBERGER_ALG
5918 #endif // BUCHBERGER_ALG
5921 xtstd = xtstd+clock()-
to;
5923 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
5924 ((
double) clock())/1000000 -((
double)tim) /1000000);
5928 tstd=tstd+clock()-
to;
5943 tlift = tlift+clock()-
to;
5961 tred = tred+clock()-
to;
5974 #ifdef PRINT_VECTORS
5975 MivString(curr_weight, target_weight, next_weight);
5987 if(
MivComp(next_weight, ivNull) == 1){
5993 if(
MivComp(next_weight, target_weight) == 1)
5996 for(i=nV-1; i>=0; i--)
5997 (*curr_weight)[
i] = (*next_weight)[
i];
6005 if(
MivSame(orig_target, exivlp) == 1)
6019 headidString(G,
"G");
6028 if( ntestw != 1 || ntwC == 0)
6041 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1){
6050 eF1 =
LastGB(F2, curr_weight, tp_deg-1);
6070 delete target_weight;
6079 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6098 (*ivM)[i*nV +
j] = 1;
6116 ring new_ring, testring;
6118 ideal Gomega, Gomega1, Gomega2, F, F1, Gresult, Gresult1, G1, Gt;
6121 #ifndef BUCHBERGER_ALG
6133 for(i=nV-1; i>0; i--)
6134 (*last_omega)[
i] = 1;
6135 (*last_omega)[0] = 10000;
6138 for(i=0; i<nV; i++) {
6139 if(Xsigma->
length() == nV)
6140 (*omega)[
i] = (*Xsigma)[
i];
6142 (*omega)[
i] = (*Xsigma)[(nV*(nlev-1))+
i];
6144 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+i];
6147 if(nlev == 1) Xcall = 1;
6154 #ifdef FIRST_STEP_FRACTAL
6157 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
6167 NEXT_VECTOR_FRACTAL:
6171 xtnw=xtnw+clock()-
to;
6172 #ifdef PRINT_VECTORS
6178 if(Xngleich == 0 && nlev == 1)
6179 if (
MivComp(next_vect, omega2) == 1)
6209 for(i=nV-1; i>=0; i--) {
6210 (*omega2)[
i] = (*Xtau)[nV+
i];
6211 (*omega)[
i] = (*Xsigma)[nV+
i];
6221 xtnw=xtnw+clock()-
to;
6223 #ifdef PRINT_VECTORS
6244 #ifdef TEST_OVERFLOW
6246 Gt =
NULL;
return(Gt);
6275 if (
MivComp(next_vect, XivNull) == 1)
6299 #ifndef MSTDCC_FRACTAL
6303 #ifdef TEST_OVERFLOW
6305 Gt =
NULL;
return(Gt);
6308 if(
MivSame(Xtau, Xtautmp) == 1)
6312 goto FRACTAL_MSTDCC;
6319 for(i=nV-1; i>=0; i--)
6320 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+i];
6326 goto NEXT_VECTOR_FRACTAL;
6338 if(
MivSame(Xivinput, Xivlp) == 1)
6373 for(i=nV-1; i>=0; i--) {
6374 (*altomega)[
i] = (*omega)[
i];
6375 (*omega)[
i] = (*next_vect)[
i];
6382 xtif=xtif+clock()-
to;
6384 #ifndef BUCHBERGER_ALG
6389 #endif // BUCHBERGER_ALG
6402 if(nlev == Xnlev ||
lengthpoly(Gomega1) == 0)
6413 #ifdef BUCHBERGER_ALG
6418 #endif // BUCHBERGER_ALG
6419 xtstd=xtstd+clock()-
to;
6437 xtlift=xtlift+clock()-
to;
6448 xtred=xtred+clock()-
to;
6462 ring new_ring, testring;
6464 ideal Gomega, Gomega1, Gomega2, F, F1, Gresult, Gresult1, G1, Gt;
6467 #ifndef BUCHBERGER_ALG
6479 for(i=nV-1; i>0; i--)
6480 (*last_omega)[
i] = 1;
6481 (*last_omega)[0] = 10000;
6484 for(i=0; i<nV; i++) {
6485 if(Xsigma->
length() == nV)
6486 (*omega)[
i] = (*Xsigma)[
i];
6488 (*omega)[
i] = (*Xsigma)[(nV*(nlev-1))+
i];
6490 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+i];
6493 if(nlev == 1) Xcall = 1;
6500 #ifdef FIRST_STEP_FRACTAL
6503 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
6513 NEXT_VECTOR_FRACTAL:
6518 xtnw=xtnw+clock()-
to;
6519 #ifdef PRINT_VECTORS
6525 if(Xngleich == 0 && nlev == 1)
6526 if (
MivComp(next_vect, omega2) == 1)
6556 for(i=nV-1; i>=0; i--) {
6557 (*omega2)[
i] = (*Xtau)[nV+
i];
6558 (*omega)[
i] = (*Xsigma)[nV+
i];
6568 xtnw=xtnw+clock()-
to;
6570 #ifdef PRINT_VECTORS
6591 #ifdef TEST_OVERFLOW
6593 Gt =
NULL;
return(Gt);
6622 if (
MivComp(next_vect, XivNull) == 1)
6646 #ifndef MSTDCC_FRACTAL
6650 #ifdef TEST_OVERFLOW
6652 Gt =
NULL;
return(Gt);
6655 if(
MivSame(Xtau, Xtautmp) == 1)
6659 goto FRACTAL_MSTDCC;
6666 for(i=nV-1; i>=0; i--)
6667 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+i];
6673 goto NEXT_VECTOR_FRACTAL;
6685 if(
MivSame(Xivinput, Xivlp) == 1)
6720 for(i=nV-1; i>=0; i--) {
6721 (*altomega)[
i] = (*omega)[
i];
6722 (*omega)[
i] = (*next_vect)[
i];
6729 xtif=xtif+clock()-
to;
6731 #ifndef BUCHBERGER_ALG
6736 #endif // BUCHBERGER_ALG
6749 if(nlev == Xnlev ||
lengthpoly(Gomega1) == 0)
6760 #ifdef BUCHBERGER_ALG
6765 #endif // BUCHBERGER_ALG
6766 xtstd=xtstd+clock()-
to;
6784 xtlift=xtlift+clock()-
to;
6795 xtred=xtred+clock()-
to;
6822 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
xtextra=0;
6827 XivNull =
new intvec(nV);
6828 Xivinput = ivtarget;
6838 #ifdef FIRST_STEP_FRACTAL
6840 for(i=
IDELEMS(Gw)-1; i>=0; i--)
6843 && (Gw->m[i]->next!=
NULL)
6844 && (Gw->m[i]->next->next!=
NULL))
6849 if(
MivSame(ivstart, iv_dp) != 1)
6869 if(
MivComp(ivtarget, Xivlp) != 1)
6927 xtlift, xtred, xtnw);
6932 Print(
"\n// the numbers of Overflow_Error (%d)", nnflow);
6948 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
xtextra=0;
6953 XivNull =
new intvec(nV);
6954 Xivinput = ivtarget;
6964 #ifdef FIRST_STEP_FRACTAL
6966 for(i=
IDELEMS(Gw)-1; i>=0; i--)
6969 && (Gw->m[i]->next!=
NULL)
6970 && (Gw->m[i]->next->next!=
NULL))
6975 if(
MivSame(ivstart, iv_dp) != 1)
6995 if(
MivComp(ivtarget, Xivlp) != 1)
7053 xtlift, xtred, xtnw);
7058 Print(
"\n// the numbers of Overflow_Error (%d)", nnflow);
7072 clock_t mtim = clock();
7079 clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
7081 clock_t tinput = clock();
7083 int nsteppert=0,
i, nV =
currRing->N, nwalk=0, npert_tmp=0;
7084 int *npert=(
int*)
omAlloc(2*nV*
sizeof(
int));
7085 ideal Gomega,
M,F, G1, Gomega1, Gomega2, M1, F1;
7087 ring newRing, oldRing, lpRing;
7095 int nGB, endwalks = 0, nwalkpert=0, npertstep=0;
7098 #ifndef BUCHBERGER_ALG
7103 for(i=nV-1; i>0; i--)
7104 (*last_omega)[
i] = 1;
7105 (*last_omega)[0] = 10000;
7109 for(i=nV-1; i>=0; i--)
7110 (*target_weight)[
i] = (*target_tmp)[
i];
7117 if(
MivComp(curr_weight, iv_dp) == 1)
7131 #ifdef REPRESENTATION_OF_SIGMA
7137 if(
MivComp(curr_weight, iv_dp) == 1)
7138 MDp = MatrixOrderdp(nV);
7142 curr_weight = RepresentationMatrix_Dp(G, MDp);
7156 tostd=tostd+clock()-
to;
7158 goto COMPUTE_NEW_VECTOR;
7173 #ifndef BUCHBERGER_ALG
7178 #endif // BUCHBERGER_ALG
7193 #ifdef BUCHBERGER_ALG
7198 #endif // BUCHBERGER_ALG
7199 tstd=tstd+clock()-
to;
7211 tlift=tlift+clock()-
to;
7224 tred=tred+clock()-
to;
7236 #ifdef PRINT_VECTORS
7237 MivString(curr_weight, target_weight, next_weight);
7250 OMEGA_OVERFLOW_TRAN_NEW:
7253 #ifdef TEST_OVERFLOW
7257 #ifdef CHECK_IDEAL_MWALK
7262 if(
MivSame(target_tmp, iv_lp) == 1)
7278 if(nP == 0 ||
MivSame(target_tmp, iv_lp) == 0){
7287 G =
LastGB(G1, curr_weight, nV-1);
7293 npert[endwalks]=nwalk-npert_tmp;
7302 if(
MivComp(next_weight, target_weight) == 1 ||
7303 MivComp(next_weight, curr_weight) == 1 )
7309 npert[endwalks]=nwalk-npert_tmp;
7315 if(endwalks == 1 &&
MivComp(next_weight, curr_weight) == 1){
7322 if(
MivSame(target_tmp, iv_lp) == 1)
7340 for(i=
IDELEMS(Glp)-1; i>=0; i--)
7366 for(i=
IDELEMS(Glp)-1; i>=0; i--)
7369 if(p->next !=
NULL &&
7370 p->next->next !=
NULL &&
7371 p->next->next->next !=
NULL)
7376 (*vector_tmp)[
i] = (*target_weight)[
i];
7378 delete target_weight;
7381 if(
MivComp(vector_tmp, target_weight)==1)
7386 goto OMEGA_OVERFLOW_TRAN_NEW;
7393 goto OMEGA_OVERFLOW_TRAN_NEW;
7403 if(plength3 ==
FALSE)
7429 goto COMPUTE_NEW_VECTOR;
7433 for(i=nV-1; i>=0; i--)
7434 (*curr_weight)[
i] = (*next_weight)[
i];
7438 #ifdef TEST_OVERFLOW
7451 Print(
"\n// Computation took %d steps and %.2f sec",
7452 nwalk, ((
double) (clock()-mtim)/1000000));
7454 TimeStringFractal(tinput, tostd, tif, tstd, textra, tlift, tred, tnw);
7469 ideal TranMrImprovwalk(
ideal G,
intvec* curr_weight,
intvec* target_tmp,
int nP,
int weight_rad,
int pert_deg)
7472 clock_t mtim = clock();
7479 clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
7481 clock_t tinput = clock();
7483 int nsteppert=0,
i, nV =
currRing->N, nwalk=0, npert_tmp=0;
7484 int *npert=(
int*)
omAlloc(2*nV*
sizeof(
int));
7485 ideal Gomega,
M,F, G1, Gomega1, Gomega2, M1, F1;
7487 ring newRing, oldRing, lpRing;
7495 int weight_norm, nGB, endwalks = 0, nwalkpert=0, npertstep=0;
7498 #ifndef BUCHBERGER_ALG
7503 for(i=nV-1; i>0; i--)
7505 (*last_omega)[
i] = 1;
7507 (*last_omega)[0] = 10000;
7511 for(i=nV-1; i>=0; i--)
7513 (*target_weight)[
i] = (*target_tmp)[
i];
7520 if(
MivComp(curr_weight, iv_dp) == 1)
7541 #ifdef REPRESENTATION_OF_SIGMA
7547 if(
MivComp(curr_weight, iv_dp) == 1)
7549 MDp = MatrixOrderdp(nV);
7555 curr_weight = RepresentationMatrix_Dp(G, MDp);
7573 tostd=tostd+clock()-
to;
7575 goto COMPUTE_NEW_VECTOR;
7590 #ifndef BUCHBERGER_ALG
7599 #endif // BUCHBERGER_ALG
7617 #ifdef BUCHBERGER_ALG
7623 tstd=tstd+clock()-
to;
7634 tlift=tlift+clock()-
to;
7647 tred=tred+clock()-
to;
7735 #ifdef PRINT_VECTORS
7736 MivString(curr_weight, target_weight, next_weight);
7748 OMEGA_OVERFLOW_TRAN_NEW:
7751 #ifdef TEST_OVERFLOW
7755 #ifdef CHECK_IDEAL_MWALK
7760 if(
MivSame(target_tmp, iv_lp) == 1)
7787 if(nP == 0 ||
MivSame(target_tmp, iv_lp) == 0)
7798 G =
LastGB(G1, curr_weight, nV-1);
7804 npert[endwalks]=nwalk-npert_tmp;
7813 if(
MivComp(next_weight, target_weight) == 1 ||
MivComp(next_weight, curr_weight) == 1 )
7819 npert[endwalks]=nwalk-npert_tmp;
7825 if(endwalks == 1 &&
MivComp(next_weight, curr_weight) == 1)
7833 if(
MivSame(target_tmp, iv_lp) == 1)
7861 for(i=
IDELEMS(Glp)-1; i>=0; i--)
7886 for(i=
IDELEMS(Glp)-1; i>=0; i--)
7889 if(p->next !=
NULL &&
7890 p->next->next !=
NULL &&
7891 p->next->next->next !=
NULL)
7897 (*vector_tmp)[
i] = (*target_weight)[
i];
7899 delete target_weight;
7902 if(
MivComp(vector_tmp, target_weight)==1)
7907 goto OMEGA_OVERFLOW_TRAN_NEW;
7914 goto OMEGA_OVERFLOW_TRAN_NEW;
7924 if(plength3 ==
FALSE)
7950 goto COMPUTE_NEW_VECTOR;
7954 for(i=nV-1; i>=0; i--)
7956 (*curr_weight)[
i] = (*next_weight)[
i];
7960 #ifdef TEST_OVERFLOW
7973 Print(
"\n// Computation took %d steps and %.2f sec", nwalk, ((
double) (clock()-mtim)/1000000));
7975 TimeStringFractal(tinput, tostd, tif, tstd, textra, tlift, tred, tnw);
7993 clock_t tinput=clock();
7995 int nwalk=0, endwalks=0, ntestwinC=1;
7996 int tp_deg_tmp = tp_deg;
7997 ideal Gomega,
M, F,
G, M1, F1, Gomega1, Gomega2, G1;
7998 ring newRing, oldRing, TargetRing;
8031 target_weight =
Mivlp(nV);
8041 if(tp_deg != tp_deg_tmp)
8051 #ifndef BUCHBERGER_ALG
8056 for(i=nV-1; i>0; i--)
8058 (*last_omega)[
i] = 1;
8060 (*last_omega)[0] = 10000;
8077 xtif=xtif+clock()-
to;
8079 #ifndef BUCHBERGER_ALG
8103 Print(
"\n// it is %d-th step!!", nwalk);
8104 idElements(Gomega1,
"Gw");
8105 PrintS(
"\n// compute a rGB of Gw:");
8111 #ifdef BUCHBERGER_ALG
8116 #endif // BUCHBERGER_ALG
8117 xtstd=xtstd+clock()-
to;
8129 xtlift=xtlift+clock()-
to;
8142 xtred=xtred+clock()-
to;
8153 xtnw=xtnw+clock()-
to;
8154 #ifdef PRINT_VECTORS
8155 MivString(curr_weight, target_weight, next_weight);
8163 tproc = tproc+clock()-tinput;
8175 if(
MivComp(next_weight, ivNull) == 1)
8181 if(
MivComp(next_weight, target_weight) == 1)
8185 for(i=nV-1; i>=0; i--)
8188 (*curr_weight)[
i] = (*next_weight)[
i];
8208 PrintS(
"\n// The perturbed target vector doesn't STAY in the correct cone!!");
8222 tproc = tproc+clock()-tinput;
8234 delete target_weight;
8251 clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
8252 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
8256 int i,nwalk,nV = baseRing->N;
8258 ideal G, Gomega,
M, F, Gomega1, Gomega2, M1;
8260 ring XXRing = baseRing;
8262 intvec* orig_target = target_weight;
8263 intvec* pert_target_vector = target_weight;
8266 #ifdef CHECK_IDEAL_MWALK
8271 (*tmp_weight)[
i] = (*curr_weight)[
i];
8273 #ifndef BUCHBERGER_ALG
8279 (*last_omega)[
i] = 1;
8281 (*last_omega)[0] = 10000;
8293 tostd = tostd + to - clock();
8295 #ifdef CHECK_IDEAL_MWALK
8310 if(tp_deg > 1 && tp_deg <= nV)
8312 pert_target_vector = target_weight;
8314 #ifdef CHECK_IDEAL_MWALK
8315 ivString(curr_weight,
"new curr_weight");
8316 ivString(target_weight,
"new target_weight");
8327 tif = tif + clock()-
to;
8329 #ifdef CHECK_IDEAL_MWALK
8330 idString(Gomega,
"Gomega");
8332 #ifndef BUCHBERGER_ALG
8348 newRing =
VMrRefine(curr_weight,target_weight);
8357 #ifndef BUCHBERGER_ALG
8365 tstd = tstd + clock() -
to;
8367 #ifdef CHECK_IDEAL_MWALK
8381 tlift = tlift + clock() -
to;
8383 #ifdef CHECK_IDEAL_MWALK
8390 #ifdef CHECK_IDEAL_MWALK
8398 tnw = tnw + clock() -
to;
8400 #ifdef PRINT_VECTORS
8401 MivString(curr_weight, target_weight, next_weight);
8405 PrintS(
"\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");
8416 for(i=nV-1; i>=0; i--)
8418 (*tmp_weight)[
i] = (*curr_weight)[
i];
8419 (*curr_weight)[
i] = (*next_weight)[
i];
8432 #ifndef BUCHBERGER_ALG
8436 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
8454 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
xtextra=0;
8456 clock_t tostd, tproc;
8460 int nwalk=0, endwalks=0;
8461 int op_tmp = op_deg;
8462 ideal Gomega,
M, F,
G, Gomega1, Gomega2, M1, F1;
8463 ring newRing, oldRing;
8470 #ifndef BUCHBERGER_ALG
8473 intvec* cw_tmp = curr_weight;
8477 for(i=nV-1; i>0; i--)
8479 (*last_omega)[
i] = 1;
8481 (*last_omega)[0] = 10000;
8493 if(
MivComp(curr_weight, iv_dp) == 1)
8496 if(op_tmp == op_deg)
8508 if(op_tmp == op_deg)
8532 curr_weight = cw_tmp;
8559 xtif=xtif+clock()-
to;
8563 for(i=nV-1; i>=0; i--)
8564 (*curr_weight)[
i] = (*extra_curr_weight)[
i];
8565 delete extra_curr_weight;
8571 #ifndef BUCHBERGER_ALG
8580 #endif // BUCHBERGER_ALG
8598 #ifdef BUCHBERGER_ALG
8603 #endif // BUCHBERGER_ALG
8604 xtstd=xtstd+clock()-
to;
8614 xtlift=xtlift+clock()-
to;
8627 xtred=xtred+clock()-
to;
8638 xtnw=xtnw+clock()-
to;
8639 #ifdef PRINT_VECTORS
8640 MivString(curr_weight, target_weight, next_weight);
8664 if(
MivComp(next_weight, ivNull) == 1)
8671 if(
MivComp(next_weight, target_weight) == 1)
8673 if(tp_deg == 1 ||
MivSame(target_weight, exivlp) == 0)
8693 for(i=nV-1; i>=0; i--)
8696 (*curr_weight)[
i] = (*next_weight)[
i];
8713 Print(
"\n// \"Main procedure\" took %d steps, %.2f sec. and Overflow_Error(%d)",
8714 nwalk, ((
double) tproc)/1000000, nOverflow_Error);
8716 TimeStringFractal(
xftinput, tostd, xtif, xtstd,
xtextra, xtlift, xtred, xtnw);
8720 Print(
"\n// Awalk1 took %d steps.\n",
nstep);
static ideal MLifttwoIdeal(ideal Gw, ideal M, ideal G)
ideal Mfwalk(ideal G, intvec *ivstart, intvec *ivtarget)
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
KINLINE TObject ** initR()
intvec * MivMatrixOrder(intvec *iv)
static int test_w_in_ConeCC(ideal G, intvec *iv)
static unsigned long * initsevS(int maxnr)
intvec * Mfpertvector(ideal G, intvec *ivtarget)
KINLINE unsigned long * initsevT()
static ideal REC_GB_Mwalk(ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
static long Mlcm(long &i1, long &i2)
static int MivComp(intvec *iva, intvec *ivb)
static ring VMrDefault1(intvec *va)
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw)
static int test_G_GB_walk(ideal H0, ideal H1)
intvec * MMatrixone(int nV)
Compatiblity layer for legacy polynomial operations (over currRing)
static int MivAbsMax(intvec *vec)
intvec * MivWeightOrderlp(intvec *ivstart)
static ring VMatrDefault(intvec *va)
void enterT(LObject p, kStrategy strat, int atT)
intvec * MivMatrixOrderRefine(intvec *iv, intvec *iw)
static ideal LastGB(ideal G, intvec *curr_weight, int tp_deg)
#define omFreeSize(addr, size)
static poly MpolyInitialForm(poly g, intvec *curr_weight)
const CanonicalForm CFMap CFMap int &both_non_zero int n
void id_Delete(ideal *h, ring r)
intvec * ivCopy(const intvec *o)
void enterpairsSpecial(poly h, int k, int ecart, int pos, kStrategy strat, int atR=-1)
int MivSame(intvec *u, intvec *v)
intvec * MivWeightOrderdp(intvec *ivstart)
static int MLmWeightedDegree(const poly p, intvec *weight)
void WerrorS(const char *s)
static intvec * MivSub(intvec *a, intvec *b)
static char const ** rParameter(const ring r)
(r->cf->parameter)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
static ring VMatrRefine(intvec *va, intvec *vb)
#define pEqualPolys(p1, p2)
void Set_Error(BOOLEAN f)
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
int(* posInT)(const TSet T, const int tl, LObject &h)
ideal Mfrwalk(ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad)
static void VMrDefaultlp(void)
static int pLength(poly a)
static long MivDotProduct(intvec *a, intvec *b)
int posInT0(const TSet, const int length, LObject &)
static void cancel(mpz_t zaehler, mpz_t nenner)
intvec * MPertVectorslp(ideal G, intvec *ivtarget, int pdeg)
static poly redBba(poly h, int maxIndex, kStrategy strat)
void(* initEcart)(TObject *L)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pGetExp(p, i)
Exponent.
void initS(ideal F, ideal Q, kStrategy strat)
static int rBlocks(ring r)
#define SI_RESTORE_OPT(A, B)
Coefficient rings, fields and other domains suitable for Singular polynomials.
ideal MAltwalk1(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight)
#define TEST_OPT_INTSTRATEGY
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
static int islengthpoly2(ideal G)
static void VMrHomogeneous(intvec *va, intvec *vb)
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
static int max(int a, int b)
ideal Mprwalk(ideal Go, intvec *curr_weight, intvec *target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)
static ideal idHeadCC(ideal h)
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl.cc )
int M3ivSame(intvec *temp, intvec *u, intvec *v)
ideal Mrwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int pert_deg, ring baseRing)
ideal Mpwalk(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP)
gmp_float sqrt(const gmp_float &a)
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
void idDelete(ideal *h, ring r=currRing)
delete an ideal
static intvec * MwalkNextWeightCC(intvec *curr_weight, intvec *target_weight, ideal G)
void initBuchMoraCrit(kStrategy strat)
static intvec * NewVectorlp(ideal I)
static ideal Mpwalk_MAltwalk1(ideal Go, intvec *curr_weight, int tp_deg)
void PrintS(const char *s)
void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
static ideal Rec_LastGB(ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
intvec * MPertVectors(ideal G, intvec *ivtarget, int pdeg)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
static void MLmWeightedDegree_gmp(mpz_t result, const poly p, intvec *weight)
void idSkipZeroes(ideal ide)
static ideal MstdhomCC(ideal G)
#define rHasLocalOrMixedOrdering_currRing()
void rChangeCurrRing(ring r)
static void DefRingParlp(void)
static int isNolVector(intvec *hilb)
ideal idInit(int idsize, int rank)
static ideal MstdCC(ideal G)
const Variable & v
< [in] a sqrfree bivariate poly
static ideal rec_r_fractal_call(ideal G, int nlev, intvec *omtmp, int weight_rad)
static long gcd(const long a, const long b)
static int lengthpoly(ideal G)
static intvec * MExpPol(poly f)
static void DefRingPar(intvec *va)
ideal idVec2Ideal(poly vec, const ring R=currRing)
BOOLEAN rHasGlobalOrdering(const ring r)
ideal TranMImprovwalk(ideal G, intvec *curr_weight, intvec *target_tmp, int nP)
static ideal kInterRedCC(ideal F, ideal Q)
static ideal MidMult(ideal A, ideal B)
static int MwalkWeightDegree(poly p, intvec *weight_vector)
ideal id_Head(ideal h, const ring r)
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
static void MivString(intvec *iva, intvec *ivb, intvec *ivc)
static ideal rec_fractal_call(ideal G, int nlev, intvec *omtmp)
void updateS(BOOLEAN toT, kStrategy strat)
intvec * MivMatrixOrderdp(int nV)
#define SI_SAVE_OPT(A, B)
void CleanUp(ring r=currRing)
void completeReduce(kStrategy strat, BOOLEAN withT)
ideal MAltwalk2(ideal Go, intvec *curr_weight, intvec *target_weight)
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit)
static void p_Setm(poly p, const ring r)
ideal idCopy(ideal A, const ring R=currRing)
static intset initec(int maxnr)
static poly redMora(poly h, int maxIndex, kStrategy strat)
void initEcartNormal(TObject *h)
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
void enterSBba(LObject p, int atS, kStrategy strat, int atR)
ideal Mwalk(ideal Go, intvec *orig_M, intvec *target_M, ring baseRing)
ideal MwalkAlt(ideal Go, intvec *curr_weight, intvec *target_weight)
static void ivString(intvec *iv, const char *ch)
ideal MwalkInitialForm(ideal G, intvec *ivw)
void(* enterS)(LObject h, int pos, kStrategy strat, int atR)
static ring VMrRefine(intvec *va, intvec *vb)
BOOLEAN lRingDependend(lists L)
intvec * MivMatrixOrderlp(int nV)
static intvec * MWalkRandomNextWeight(ideal G, intvec *curr_weight, intvec *target_weight, int weight_rad, int pert_deg)
static ring VMrDefault(intvec *va)
#define pCopy(p)
return a copy of the poly
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
static int * initS_2_R(int maxnr)