18#define CHECK_IDEAL_MWALK
23#define INVEPS_SMALL_IN_FRACTAL
24#define INVEPS_SMALL_IN_MPERTVECTOR
25#define INVEPS_SMALL_IN_TRAN
27#define FIRST_STEP_FRACTAL
91VAR clock_t xtif, xtstd, xtlift, xtred, xtnw;
92VAR clock_t xftostd, xtextra, xftinput, to;
105 return (
unsigned long*)
omAlloc0(maxnr*
sizeof(
unsigned long));
109 return (
int*)
omAlloc0(maxnr*
sizeof(
int));
299 if(rHasLocalOrMixedOrdering(
currRing))
350 ideal shdl=strat->
Shdl;
358static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
359 clock_t tlf,clock_t tred, clock_t tnw,
int step)
361 double totm = ((double) (clock() - tinput))/1000000;
362 double ostd,mostd, mif, mstd, mlf, mred, mnw, mxif,mxstd,mxlf,mxred,mxnw,tot;
364 Print(
"\n// total time = %.2f sec", totm);
365 Print(
"\n// tostd = %.2f sec = %.2f", ostd=((
double) tostd)/1000000,
366 mostd=((((
double) tostd)/1000000)/totm)*100);
367 Print(
"\n// tif = %.2f sec = %.2f", ((
double) tif)/1000000,
368 mif=((((
double) tif)/1000000)/totm)*100);
369 Print(
"\n// std = %.2f sec = %.2f", ((
double) tstd)/1000000,
370 mstd=((((
double) tstd)/1000000)/totm)*100);
371 Print(
"\n// lift = %.2f sec = %.2f", ((
double) tlf)/1000000,
372 mlf=((((
double) tlf)/1000000)/totm)*100);
373 Print(
"\n// ired = %.2f sec = %.2f", ((
double) tred)/1000000,
374 mred=((((
double) tred)/1000000)/totm)*100);
375 Print(
"\n// nextw = %.2f sec = %.2f", ((
double) tnw)/1000000,
376 mnw=((((
double) tnw)/1000000)/totm)*100);
377 PrintS(
"\n Time for the last step:");
378 Print(
"\n// xinfo = %.2f sec = %.2f", ((
double) xtif)/1000000,
379 mxif=((((
double) xtif)/1000000)/totm)*100);
380 Print(
"\n// xstd = %.2f sec = %.2f", ((
double) xtstd)/1000000,
381 mxstd=((((
double) xtstd)/1000000)/totm)*100);
382 Print(
"\n// xlift = %.2f sec = %.2f", ((
double) xtlift)/1000000,
383 mxlf=((((
double) xtlift)/1000000)/totm)*100);
384 Print(
"\n// xired = %.2f sec = %.2f", ((
double) xtred)/1000000,
385 mxred=((((
double) xtred)/1000000)/totm)*100);
386 Print(
"\n// xnextw= %.2f sec = %.2f", ((
double) xtnw)/1000000,
387 mxnw=((((
double) xtnw)/1000000)/totm)*100);
389 tot=mostd+mif+mstd+mlf+mred+mnw+mxif+mxstd+mxlf+mxred+mxnw;
390 double res = (double) 100 - tot;
391 Print(
"\n// &%d&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f(%.2f)\\ \\",
392 step, ostd, totm, mostd,mif,mstd,mlf,mred,mnw,mxif,mxstd,mxlf,mxred,mxnw,tot,
res,
393 ((((
double) xtextra)/1000000)/totm)*100);
396static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
397 clock_t textra, clock_t tlf,clock_t tred, clock_t tnw)
400 double totm = ((double) (clock() - tinput))/1000000;
401 double ostd, mostd, mif, mstd, mextra, mlf, mred, mnw, tot,
res;
402 Print(
"\n// total time = %.2f sec", totm);
403 Print(
"\n// tostd = %.2f sec = %.2f", ostd=((
double) tostd)/1000000,
404 mostd=((((
double) tostd)/1000000)/totm)*100);
405 Print(
"\n// tif = %.2f sec = %.2f", ((
double) tif)/1000000,
406 mif=((((
double) tif)/1000000)/totm)*100);
407 Print(
"\n// std = %.2f sec = %.2f", ((
double) tstd)/1000000,
408 mstd=((((
double) tstd)/1000000)/totm)*100);
409 Print(
"\n// xstd = %.2f sec = %.2f", ((
double) textra)/1000000,
410 mextra=((((
double) textra)/1000000)/totm)*100);
411 Print(
"\n// lift = %.2f sec = %.2f", ((
double) tlf)/1000000,
412 mlf=((((
double) tlf)/1000000)/totm)*100);
413 Print(
"\n// ired = %.2f sec = %.2f", ((
double) tred)/1000000,
414 mred=((((
double) tred)/1000000)/totm)*100);
415 Print(
"\n// nextw = %.2f sec = %.2f", ((
double) tnw)/1000000,
416 mnw=((((
double) tnw)/1000000)/totm)*100);
417 tot = mostd+mif+mstd+mextra+mlf+mred+mnw;
418 res = (double) 100.00-tot;
419 Print(
"\n// &%.2f &%.2f&%.2f &%.2f &%.2f &%.2f &%.2f &%.2f &%.2f&%.2f&%.2f\\ \\ ",
420 ostd,totm,mostd,mif,mstd,mextra,mlf,mred,mnw,tot,
res);
424#ifdef CHECK_IDEAL_MWALK
429 Print(
"\n// ideal %s = ", st);
430 for(
i=0;
i<nL-1;
i++)
496 Print(
"\n// intvec %s = ", ch);
498 for(
int i=0;
i<nV;
i++)
502 Print(
"%d;", (*iv)[nV]);
515 Print(
"%d) ==> (", (*iva)[nV]);
520 Print(
"%d) := (", (*ivb)[nV]);
526 Print(
"%d)", (*ivc)[nV]);
533static inline long gcd(
const long a,
const long b)
535 long r, p0 = a, p1 =
b;
589static void cancel(mpz_t zaehler, mpz_t nenner)
594 mpz_gcd(
g, zaehler, nenner);
596 mpz_div(zaehler , zaehler,
g);
597 mpz_div(nenner , nenner,
g);
604static int isVectorNeg(
intvec* omega)
626 mpz_init_set_ui(sing_int, 2147483647);
639 mpz_set_si(zvec, (*weight)[
i-1]);
641 mpz_add(zsum, zsum, zmul);
644 wgrad = mpz_get_ui(zsum);
646 if(mpz_cmp(zsum, sing_int)>0)
651 PrintS(
"\n// ** OVERFLOW in \"MwalkInitialForm\": ");
652 mpz_out_str( stdout, 10, zsum);
653 PrintS(
" is greater than 2147483647 (max. integer representation)");
672 int max = 0, maxtemp;
695 mpz_init_set_ui(sing_int, 2147483647);
708 mpz_set_si(zvec, (*weight)[
i-1]);
710 mpz_add(ztmp, ztmp, zmul);
730 mpz_t maxtmp; mpz_init(maxtmp);
732 poly hg, in_w_g =
NULL;
740 if(mpz_cmp(maxtmp,
max)>0)
742 mpz_set(
max, maxtmp);
748 if(mpz_cmp(maxtmp,
max)==0)
768 ideal Gomega =
idInit(nG, 1);
770 for(
i=nG-1;
i>=0;
i--)
790 PrintS(
"//** the result may be WRONG, i.e. 0!!\n");
800 for(
i=nG-1;
i>=0;
i--)
836static inline long Mlcm(
long &i1,
long &i2)
838 long temp =
gcd(i1, i2);
839 return ((i1 / temp)* i2);
852 for(
i=n-1;
i>=0;
i--)
868 for(
i=n-1;
i>=0;
i--)
870 (*result)[
i] = (*a)[
i] - (*b)[
i];
883 for(
i=nR-1;
i>=0;
i--)
900 for (
i=0;
i<niv;
i++)
902 if ((*u)[
i] != (*
v)[
i])
972 (*ivm)[
i] = (*iv)[
i];
976 (*ivm)[
i*nR+
i-1] = 1;
993 (*ivm)[
i] = (*iv)[
i];
999 (*ivm)[
j+
i*nR] = (*iw)[
j+
i*nR];
1013 for(
i=nR-1;
i>=0;
i--)
1099 if(pdeg > nV || pdeg <= 0)
1101 WerrorS(
"//** The perturbed degree is wrong!!");
1110 mpz_t *pert_vector = (mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
1111 mpz_t *pert_vector1 = (mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
1115 mpz_init_set_si(pert_vector[
i], (*ivtarget)[
i]);
1116 mpz_init_set_si(pert_vector1[
i], (*ivtarget)[
i]);
1120 int ntemp, maxAi, maxA=0;
1121 for(
i=1;
i<pdeg;
i++)
1123 maxAi = (*ivtarget)[
i*nV];
1128 for(
j=
i*nV+1;
j<(
i+1)*nV;
j++)
1130 ntemp = (*ivtarget)[
j];
1147 mpz_t tot_deg; mpz_init(tot_deg);
1148 mpz_t maxdeg; mpz_init(maxdeg);
1149 mpz_t inveps; mpz_init(inveps);
1152 for(
i=nG-1;
i>=0;
i--)
1155 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1157 mpz_set(tot_deg, maxdeg);
1162 mpz_mul_ui(inveps, tot_deg, maxA);
1163 mpz_add_ui(inveps, inveps, 1);
1167#ifdef INVEPS_SMALL_IN_MPERTVECTOR
1168 if(mpz_cmp_ui(inveps, pdeg)>0 && pdeg > 3)
1171 mpz_fdiv_q_ui(inveps, inveps, pdeg);
1176 mpz_out_str(stdout, 10, inveps);
1181 for(
i=1;
i < pdeg;
i++ )
1185 mpz_mul(pert_vector[
j], pert_vector[
j], inveps);
1186 if((*ivtarget)[
i*nV+
j]<0)
1188 mpz_sub_ui(pert_vector[
j], pert_vector[
j],-(*ivtarget)[
i*nV+
j]);
1192 mpz_add_ui(pert_vector[
j], pert_vector[
j],(*ivtarget)[
i*nV+
j]);
1199 mpz_init_set_ui(sing_int, 2147483647);
1202 mpz_init_set_ui(check_int, 100000);
1206 mpz_set(ztemp, pert_vector[0]);
1209 mpz_gcd(ztemp, ztemp, pert_vector[
i]);
1210 if(mpz_cmp_si(ztemp, 1) == 0)
1215 if(mpz_cmp_si(ztemp, 1) != 0)
1219 mpz_divexact(pert_vector[
i], pert_vector[
i], ztemp);
1225 if(mpz_cmp(pert_vector[
i], check_int)>=0)
1229 mpz_fdiv_q_ui(pert_vector1[
j], pert_vector[
j], 100);
1240 (*result)[
i] = mpz_get_si(pert_vector1[
i]);
1241 if(mpz_cmp(pert_vector1[
i], sing_int)>=0)
1251 (*result)[
i] = mpz_get_si(pert_vector[
i]);
1252 if(mpz_cmp(pert_vector[
i], sing_int)>=0)
1258 PrintS(
"\n// ** OVERFLOW in \"MPertvectors\": ");
1259 mpz_out_str( stdout, 10, pert_vector[
i]);
1260 PrintS(
" is greater than 2147483647 (max. integer representation)");
1261 Print(
"\n// So vector[%d] := %d is wrong!!",
i+1, (*
result)[
i]);
1269 Print(
"\n// %d element(s) of it is overflow!!", ntrue);
1274 mpz_clear(sing_int);
1275 mpz_clear(check_int);
1310 if(pdeg > nV || pdeg <= 0)
1312 WerrorS(
"//** The perturbed degree is wrong!!");
1317 (*pert_vector)[
i]=(*ivtarget)[
i];
1325 int ntemp, maxAi, maxA=0;
1326 for(
i=1;
i<pdeg;
i++)
1328 maxAi = (*ivtarget)[
i*nV];
1329 for(
j=
i*nV+1;
j<(
i+1)*nV;
j++)
1331 ntemp = (*ivtarget)[
j];
1341 int inveps, tot_deg = 0, maxdeg;
1344 for(
i=nG-1;
i>=0;
i--)
1348 if (maxdeg > tot_deg )
1355 inveps = (tot_deg * maxA) + 1;
1357#ifdef INVEPS_SMALL_IN_FRACTAL
1359 if(inveps > pdeg && pdeg > 3)
1361 inveps = inveps / pdeg;
1365 PrintS(
"\n// the \"big\" inverse epsilon %d", inveps);
1369 for (
i=1;
i < pdeg;
i++ )
1373 (*pert_vector)[
j] = inveps*((*pert_vector)[
j]) + (*ivtarget)[
i*nV+
j];
1377 int temp = (*pert_vector)[0];
1380 temp =
gcd(temp, (*pert_vector)[
i]);
1390 (*pert_vector)[
i] = (*pert_vector)[
i] / temp;
1409 (*ivM)[
i*nV +
i] = 1;
1429 (*ivM)[(
i+1)*nV -
i] = -1;
1440 int nV = ivstart->
length();
1445 (*ivM)[
i] = (*ivstart)[
i];
1449 (*ivM)[
i*nV +
i-1] = 1;
1460 int nV = ivstart->
length();
1465 (*ivM)[
i] = (*ivstart)[
i];
1473 (*ivM)[(
i+1)*nV -
i] = -1;
1501 for(
i=nV-1;
i>=0;
i--)
1522 int ntemp, maxAi, maxA=0;
1525 maxAi = (*ivtarget)[
i*nV];
1530 for(
j=
i*nV+1;
j<(
i+1)*nV;
j++)
1532 ntemp = (*ivtarget)[
j];
1542 maxA = maxA + maxAi;
1547 mpz_t tot_deg; mpz_init(tot_deg);
1548 mpz_t maxdeg; mpz_init(maxdeg);
1549 mpz_t inveps; mpz_init(inveps);
1552 for(
i=nG-1;
i>=0;
i--)
1555 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1557 mpz_set(tot_deg, maxdeg);
1563 mpz_mul_ui(inveps, tot_deg, maxA);
1564 mpz_add_ui(inveps, inveps, 1);
1567#ifdef INVEPS_SMALL_IN_FRACTAL
1568 if(mpz_cmp_ui(inveps, nV)>0 && nV > 3)
1570 mpz_cdiv_q_ui(inveps, inveps, nV);
1578 mpz_t *ivtemp=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
1579 mpz_t *pert_vector=(mpz_t *)
omAlloc(niv*
sizeof(mpz_t));
1581 for(
i=0;
i < nV;
i++)
1583 mpz_init_set_si(ivtemp[
i], (*ivtarget)[
i]);
1584 mpz_init_set_si(pert_vector[
i], (*ivtarget)[
i]);
1587 mpz_t ztmp; mpz_init(ztmp);
1594 mpz_mul(ztmp, inveps, ivtemp[
j]);
1595 if((*ivtarget)[
i*nV+
j]<0)
1597 mpz_sub_ui(ivtemp[
j], ztmp, -(*ivtarget)[
i*nV+
j]);
1601 mpz_add_ui(ivtemp[
j], ztmp,(*ivtarget)[
i*nV+
j]);
1607 mpz_init_set(pert_vector[
i*nV+
j],ivtemp[
j]);
1613 mpz_init_set_ui(sing_int, 2147483647);
1619 mpz_set(ztmp, pert_vector[0]);
1620 for(
i=0;
i<niv;
i++)
1622 mpz_gcd(ztmp, ztmp, pert_vector[
i]);
1623 if(mpz_cmp_si(ztmp, 1)==0)
1629 for(
i=0;
i<niv;
i++)
1631 mpz_divexact(pert_vector[
i], pert_vector[
i], ztmp);
1632 (* result)[
i] = mpz_get_si(pert_vector[
i]);
1637 for(
i=0;
i<niv;
i++)
1639 if(mpz_cmp(pert_vector[
i], sing_int)>0)
1646 Print(
"\n// Xlev = %d and the %d-th element is",
Xnlev,
i+1);
1647 PrintS(
"\n// ** OVERFLOW in \"Mfpertvector\": ");
1648 mpz_out_str( stdout, 10, pert_vector[
i]);
1649 PrintS(
" is greater than 2147483647 (max. integer representation)");
1650 Print(
"\n// So vector[%d] := %d is wrong!!",
i+1, (*
result)[
i]);
1664 mpz_clear(sing_int);
1746 F->m[
i] =
pAdd(F->m[
i], idLG->m[
j]);
1805 if((*iva)[
i] - (*ivb)[
i] != 0)
1827 for(
i=1;
i < (
vec->length());
i++)
2242 mpz_t t_zaehler, t_nenner;
2243 mpz_init(t_zaehler);
2246 mpz_t s_zaehler, s_nenner, temp, MwWd;
2247 mpz_init(s_zaehler);
2254 mpz_set_ui(sing_int, 2147483647);
2256 mpz_t sing_int_half;
2257 mpz_init(sing_int_half);
2258 mpz_set_ui(sing_int_half, 3*(1073741824/2));
2260 mpz_t deg_w0_p1, deg_d0_p1;
2261 mpz_init(deg_w0_p1);
2262 mpz_init(deg_d0_p1);
2286 for (
j=0;
j<nRing;
j++)
2288 (*diff_weight1)[
j] = (*curr_weight)[
j];
2292 for(
j=0;
j<nRing;
j++)
2294 (*curr_weight)[
j] = (*diff_weight1)[
j];
2296 for(
j=0;
j<nRing;
j++)
2298 (*diff_weight1)[
j] = ((*diff_weight1)[
j] + 5) / 10;
2304 for(
j=0;
j<nRing;
j++)
2306 (*diff_weight1)[
j] = (*curr_weight)[
j];
2311 (*curr_weight)[
j] = (*diff_weight1)[
j];
2313 (*diff_weight1)[
j] = ((*diff_weight1)[
j] + 5) / 10;
2318 intvec* diff_weight =
MivSub(target_weight, curr_weight);
2321 for (
j=0;
j<nG;
j++)
2336 mpz_sub(s_zaehler, deg_w0_p1, MwWd);
2337 if(mpz_cmp(s_zaehler, t_null) != 0)
2340 mpz_sub(s_nenner, MwWd, deg_d0_p1);
2342 if( (mpz_cmp(s_zaehler,t_null) > 0 &&
2343 mpz_cmp(s_nenner, s_zaehler)>=0) ||
2344 (mpz_cmp(s_zaehler, t_null) < 0 &&
2345 mpz_cmp(s_nenner, s_zaehler)<=0))
2348 if (mpz_cmp(s_zaehler, t_null) < 0)
2350 mpz_neg(s_zaehler, s_zaehler);
2351 mpz_neg(s_nenner, s_nenner);
2355 cancel(s_zaehler, s_nenner);
2357 if(mpz_cmp(t_nenner, t_null) != 0)
2359 mpz_mul(sztn, s_zaehler, t_nenner);
2360 mpz_mul(sntz, s_nenner, t_zaehler);
2362 if(mpz_cmp(sztn,sntz) < 0)
2364 mpz_add(t_nenner, t_null, s_nenner);
2365 mpz_add(t_zaehler,t_null, s_zaehler);
2370 mpz_add(t_nenner, t_null, s_nenner);
2371 mpz_add(t_zaehler,t_null, s_zaehler);
2381 mpz_t *
vec=(mpz_t*)
omAlloc(nRing*
sizeof(mpz_t));
2386 if(mpz_cmp(t_nenner, t_null) == 0)
2392 diff_weight =
ivCopy(curr_weight);
2397 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
2400 diff_weight =
ivCopy(target_weight);
2407 gcd_tmp = (*curr_weight)[0];
2409 for (
j=1;
j<nRing;
j++)
2411 gcd_tmp =
gcd(gcd_tmp, (*curr_weight)[
j]);
2419 for (
j=0;
j<nRing;
j++)
2421 gcd_tmp =
gcd(gcd_tmp, (*diff_weight)[
j]);
2430 for (
j=0;
j<nRing;
j++)
2432 (*curr_weight)[
j] = (*curr_weight)[
j]/gcd_tmp;
2433 (*diff_weight)[
j] = (*diff_weight)[
j]/gcd_tmp;
2437#ifdef NEXT_VECTORS_CC
2438 Print(
"\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
2442 PrintS(
"\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler);
2443 PrintS(
", t_nenner: "); mpz_out_str( stdout, 10, t_nenner);
2451 for (
j=0;
j<nRing;
j++)
2453 mpz_set_si(dcw, (*curr_weight)[
j]);
2454 mpz_mul(s_nenner, t_nenner, dcw);
2456 if( (*diff_weight)[
j]>0)
2458 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[
j]);
2462 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[
j]);
2463 mpz_neg(s_zaehler, s_zaehler);
2465 mpz_add(sntz, s_nenner, s_zaehler);
2466 mpz_init_set(
vec[
j], sntz);
2468#ifdef NEXT_VECTORS_CC
2469 Print(
"\n// j = %d ==> ",
j);
2471 mpz_out_str( stdout, 10, t_nenner);
2472 Print(
" * %d)", (*curr_weight)[
j]);
2473 PrintS(
" + ("); mpz_out_str( stdout, 10, t_zaehler);
2474 Print(
" * %d) = ", (*diff_weight)[
j]);
2475 mpz_out_str( stdout, 10, s_nenner);
2477 mpz_out_str( stdout, 10, s_zaehler);
2478 PrintS(
" = "); mpz_out_str( stdout, 10, sntz);
2479 Print(
" ==> vector[%d]: ",
j); mpz_out_str(stdout, 10,
vec[
j]);
2488 if(mpz_cmp_si(ggt,1) != 0)
2490 mpz_gcd(ggt, ggt, sntz);
2495 if(mpz_cmp_si(ggt,1) != 0)
2497 for (
j=0;
j<nRing;
j++)
2502#ifdef NEXT_VECTORS_CC
2503 PrintS(
"\n// gcd of elements of the vector: ");
2504 mpz_out_str( stdout, 10, ggt);
2507 for (
j=0;
j<nRing;
j++)
2509 (*diff_weight)[
j] = mpz_get_si(
vec[
j]);
2514 for (
j=0;
j<nRing;
j++)
2516 if(mpz_cmp(
vec[
j], sing_int)>=0)
2521 PrintS(
"\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
2522 mpz_out_str( stdout, 10,
vec[
j]);
2523 PrintS(
" is greater than 2147483647 (max. integer representation)\n");
2530 delete diff_weight1;
2531 mpz_clear(t_zaehler);
2532 mpz_clear(t_nenner);
2533 mpz_clear(s_zaehler);
2534 mpz_clear(s_nenner);
2539 mpz_clear(deg_w0_p1);
2540 mpz_clear(deg_d0_p1);
2543 mpz_clear(sing_int_half);
2544 mpz_clear(sing_int);
2691 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2693 r->wvhdl[0][
i] = (*va)[
i];
2697 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2698 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2742 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2743 r->wvhdl[1] = (
int*)
omAlloc(nv*
sizeof(
int));
2747 r->wvhdl[0][
i] = (*vb)[
i];
2748 r->wvhdl[1][
i] = (*va)[
i];
2753 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2754 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2801 r->wvhdl[0] = (
int*)
omAlloc(nv*nv*
sizeof(
int));
2805 for(
i=0;
i<nv*nv;
i++)
2806 r->wvhdl[0][
i] = (*va)[
i];
2810 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2811 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2853 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2854 r->wvhdl[1] = (
int*)
omAlloc(nvs*
sizeof(
int));
2857 for(
i=0;
i<nvs;
i++)
2859 r->wvhdl[1][
i] = (*va)[
i];
2863 r->wvhdl[0][
i] = (*vb)[
i];
2867 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2868 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2912 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2913 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2949 res->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2950 for(
int i=0;
i<nv;
i++)
2951 res->wvhdl[0][
i] = (*va)[
i];
2956 res->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2957 res->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2962 res->block1[0] = nv;
2967 res->block1[1] = nv;
3003 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
3004 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
3084 poly
p,lm,factor1,factor2;
3105 lm =
pCopy(Gomega->m[
j]);
3152 int nwalk=0, endwalks=0, nnwinC=1;
3154 ideal Gomega,
M, F, Gomega1, Gomega2, M1,
F1,
result,ssG;
3155 ring newRing, oldRing, TargetRing;
3159 intvec* pert_target_vector;
3164#ifndef BUCHBERGER_ALG
3170 for(
i=nV-1;
i>0;
i--)
3172 (*last_omega)[
i] = 1;
3174 (*last_omega)[0] = 10000;
3179 if(tp_deg > 1 && tp_deg <= nV)
3196 pert_target_vector = target_weight;
3203 target_weight =
Mivlp(nV);
3217 xtnw=xtnw+clock()-to;
3221 MivString(curr_weight, target_weight, next_weight);
3240 if(
MivComp(next_weight, ivNull) == 1)
3248 if(
MivComp(next_weight, target_weight) == 1)
3251 for(
i=nV-1;
i>=0;
i--)
3253 (*extra_curr_weight)[
i] = (*curr_weight)[
i];
3256 for(
i=nV-1;
i>=0;
i--)
3258 (*curr_weight)[
i] = (*next_weight)[
i];
3267 xtif=xtif+clock()-to;
3281#ifndef BUCHBERGER_ALG
3282 if(isNolVector(curr_weight) == 0)
3309#ifdef BUCHBERGER_ALG
3316 xtstd=xtstd+clock()-to;
3329 xtlift=xtlift+clock()-to;
3345 xtred=xtred+clock()-to;
3378 Print(
"\n// takes %d steps and calls the recursion of level %d:",
3427 delete target_weight;
3448 && (
G->m[
i]->next->next!=
NULL)
3449 && (
G->m[
i]->next->next->next!=
NULL)
3450 && (
G->m[
i]->next->next->next->next!=
NULL) )
3466 k = pLength(
G->m[
i]);
3485 && (
G->m[
i]->next->next!=
NULL))
3520 for (
i=nH-1;
i>=0;
i--)
3541 for(
i=nG-1;
i>=0;
i--)
3609 int mtmp,
m=(*iva)[0];
3630 mpz_set_si(ndeg, Trandegreebound(
G)+1);
3636 mpz_init_set_si(maxdeg, Trandegreebound(
G));
3639 mpz_pow_ui(ztmp, maxdeg, 2);
3640 mpz_mul_ui(ztmp, ztmp, 2);
3641 mpz_mul_ui(maxdeg, maxdeg, nV+1);
3642 mpz_add(ndeg, ztmp, maxdeg);
3643 mpz_mul_ui(ndeg, ndeg,
m);
3651#ifdef INVEPS_SMALL_IN_TRAN
3652 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
3654 mpz_cdiv_q_ui(ndeg, ndeg, nV);
3660 mpz_init_set(deg_tmp, ndeg);
3662 VAR mpz_t *ivres=( mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3663 mpz_init_set_ui(ivres[nV-1],1);
3665 for(
i=nV-2;
i>=0;
i--)
3667 mpz_init_set(ivres[
i], deg_tmp);
3668 mpz_mul(deg_tmp, deg_tmp, ndeg);
3671 VAR mpz_t *ivtmp=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3677 mpz_init_set_ui(sing_int, 2147483647);
3686 if( (*ivMat)[
i*nV+
j] >= 0 )
3688 mpz_mul_ui(ivres[
i], ivres[
i], (*ivMat)[
i*nV+
j]);
3692 mpz_mul_ui(ivres[
i], ivres[
i], -(*ivMat)[
i*nV+
j]);
3693 mpz_neg(ivres[
i], ivres[
i]);
3695 mpz_add(ivtmp[
j], ivtmp[
j], ivres[
i]);
3703 (*repr_vector)[
i] = mpz_get_si(ivtmp[
i]);
3704 if(mpz_cmp(ivtmp[
i], sing_int)>=0)
3711 PrintS(
"\n// ** OVERFLOW in \"Repr.Vector\": ");
3712 mpz_out_str( stdout, 10, ivtmp[
i]);
3713 PrintS(
" is greater than 2147483647 (max. integer representation)");
3714 Print(
"\n// So vector[%d] := %d is wrong!!\n",
i+1,(*repr_vector)[
i]);
3720 ivString(repr_vector,
"repvector");
3721 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3730 mpz_clear(sing_int);
3740static intvec* TranPertVector_lp(ideal
G)
3754 mpz_set_si(ndeg, Trandegreebound(
G)+1);
3760 mpz_init_set_si(maxdeg, Trandegreebound(
G));
3763 mpz_pow_ui(ztmp, maxdeg, 2);
3764 mpz_mul_ui(ztmp, ztmp, 2);
3765 mpz_mul_ui(maxdeg, maxdeg, nV+1);
3766 mpz_add(ndeg, ztmp, maxdeg);
3775#ifdef INVEPS_SMALL_IN_TRAN
3776 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
3777 mpz_cdiv_q_ui(ndeg, ndeg, nV);
3784 mpz_init_set(deg_tmp, ndeg);
3786 VAR mpz_t *ivres=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3787 mpz_init_set_ui(ivres[nV-1], 1);
3789 for(
i=nV-2;
i>=0;
i--)
3791 mpz_init_set(ivres[
i], deg_tmp);
3792 mpz_mul(deg_tmp, deg_tmp, ndeg);
3796 mpz_init_set_ui(sing_int, 2147483647);
3802 (*repr_vector)[
i] = mpz_get_si(ivres[
i]);
3804 if(mpz_cmp(ivres[
i], sing_int)>=0)
3810 PrintS(
"\n// ** OVERFLOW in \"Repr.Vector\": ");
3811 mpz_out_str( stdout, 10, ivres[
i]);
3812 PrintS(
" is greater than 2147483647 (max. integer representation)");
3813 Print(
"\n// So vector[%d] := %d is wrong!!\n",
i+1,(*repr_vector)[
i]);
3819 ivString(repr_vector,
"repvector");
3820 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3828 mpz_clear(sing_int);
3845 int degtmp, maxdeg = 0;
3856 mpz_init_set_si(ztmp, maxdeg);
3857 mpz_t *ivres=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3858 mpz_init_set_ui(ivres[nV-1], 1);
3860 for(
i=nV-2;
i>=0;
i--)
3862 mpz_init_set(ivres[
i], ztmp);
3863 mpz_mul_ui(ztmp, ztmp, maxdeg);
3866 mpz_t *ivtmp=(mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
3874 if((*
M)[
i*nV+
j] < 0)
3876 mpz_mul_ui(ztmp, ivres[
i], -(*
M)[
i*nV+
j]);
3877 mpz_neg(ztmp, ztmp);
3880 mpz_mul_ui(ztmp, ivres[
i], (*
M)[
i*nV+
j]);
3882 mpz_add(ivtmp[
j], ivtmp[
j], ztmp);
3886 mpz_init_set_ui(sing_int, 2147483647);
3892 (*repvector)[
i] = mpz_get_si(ivtmp[
i]);
3893 if(mpz_cmp(ivtmp[
i], sing_int)>0)
3899 PrintS(
"\n// ** OVERFLOW in \"Repr.Matrix\": ");
3900 mpz_out_str( stdout, 10, ivtmp[
i]);
3901 PrintS(
" is greater than 2147483647 (max. integer representation)");
3902 Print(
"\n// So vector[%d] := %d is wrong!!\n",
i+1,(*repvector)[
i]);
3909 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3915 mpz_clear(sing_int);
3935 intvec* orig_target_weight,
int tp_deg,
int npwinc)
3943 clock_t tinput = clock();
3947 int nwalk=0, endwalks=0, nnwinC=1;
3949 ideal Gomega,
M, F, Gomega1, Gomega2, M1,
F1,
result,ssG;
3950 ring newRing, oldRing, TargetRing;
3957#ifndef BUCHBERGER_ALG
3963 for(
i=nV-1;
i>0;
i--)
3964 (*last_omega)[
i] = 1;
3965 (*last_omega)[0] = 10000;
3970 if(tp_deg > 1 && tp_deg <= nV)
4042 xtif=xtif+clock()-to;
4045#ifndef BUCHBERGER_ALG
4046 if(isNolVector(curr_weight) == 0)
4073#ifdef BUCHBERGER_ALG
4080 xtstd=xtstd+clock()-to;
4093 xtlift=xtlift+clock()-to;
4109 xtred=xtred+clock()-to;
4125 xtnw=xtnw+clock()-to;
4128 MivString(curr_weight, target_weight, next_weight);
4146 if(
MivComp(next_weight, ivNull) == 1)
4153 if(
MivComp(next_weight, target_weight) == 1)
4164 tproc=tproc+clock()-tinput;
4170 G =
Rec_LastGB(
G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4177 for(
i=nV-1;
i>=0;
i--)
4179 (*curr_weight)[
i] = (*next_weight)[
i];
4205 tproc=tproc+clock()-tinput;
4207 F1 =
Rec_LastGB(
F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4209 delete target_weight;
4246 xtextra=xtextra+clock()-to;
4288 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
4290 clock_t tostd, tproc;
4294 int nwalk=0, endwalks=0;
4296 ideal Gomega,
M, F, Gomega1, Gomega2, M1,
F1,
G;
4299 ring newRing, oldRing;
4317 Print(
"\n// Computation of the first std took = %.2f sec",
4318 ((
double) tostd)/1000000);
4334 xtif=xtif+clock()-to;
4364 xtstd=xtstd+clock()-to;
4377 xtlift=xtlift+clock()-to;
4392 xtred=xtred+clock()-to;
4406 xtnw=xtnw+clock()-to;
4409 MivString(curr_weight, target_weight, next_weight);
4419 goto TEST_OVERFLOW_OI;
4438 if(
MivComp(next_weight, ivNull) == 1)
4445 if(
MivComp(next_weight, target_weight) == 1)
4447 if(
MivSame(target_weight, exivlp)==1)
4452 tproc = clock()-xftinput;
4464 for(
i=nV-1;
i>=0;
i--)
4467 (*curr_weight)[
i] = (*next_weight)[
i];
4483 TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw);
4518 int weight_rad,
int pert_deg)
4521 target_weight !=
NULL &&
G->m[0] !=
NULL);
4532 (*curr_weight)[
i] = (*orig_M)[
i];
4535 int k=0,weight_norm;
4541 ideal G_test, G_test1, G_test2;
4549 while(weight_norm == 0)
4553 (*next_weight2)[
i] = rand() % 60000 - 30000;
4554 weight_norm = weight_norm + (*next_weight2)[
i]*(*next_weight2)[
i];
4556 weight_norm = 1 +
static_cast<int>(
sqrt(
double(weight_norm)));
4560 if((*next_weight2)[
i] < 0)
4562 (*next_weight2)[
i] = 1 + (*curr_weight)[
i] + weight_rad*(*next_weight2)[
i]/weight_norm;
4566 (*next_weight2)[
i] = (*curr_weight)[
i] + weight_rad*(*next_weight2)[
i]/weight_norm;
4576 found_random_weight =
TRUE;
4588 delete curr_weight1;
4606 if(found_random_weight ==
TRUE)
4615 (*result)[
i] = (*next_weight2)[
i];
4622 (*result)[
i] = (*next_weight1)[
i];
4632 (*result)[
i] = (*next_weight2)[
i];
4639 (*result)[
i] = (*next_weight)[
i];
4651 (*result)[
i] = (*next_weight1)[
i];
4658 (*result)[
i] = (*next_weight)[
i];
4666 if(found_random_weight ==
TRUE)
4672 (*result)[
i] = (*next_weight2)[
i];
4679 (*result)[
i] = (*next_weight)[
i];
4687 (*result)[
i] = (*next_weight)[
i];
4693 delete next_weight2;
4696 if(found_random_weight ==
TRUE)
4703 delete next_weight1;
4710 return next_weight1;
4721 int tp_deg,
int npwinc)
4727 int nwalk=0, endwalks=0, nnwinC=1, nlast = 0;
4728 ideal Gomega,
M, F, Gomega1, Gomega2, M1,
F1,
result,ssG;
4729 ring newRing, oldRing, TargetRing;
4732#ifndef BUCHBERGER_ALG
4736 for(
i=nV-1;
i>0;
i--)
4738 (*last_omega)[
i] = 1;
4740 (*last_omega)[0] = 10000;
4747 if(tp_deg > 1 && tp_deg <= nV)
4808 xtif = xtif + clock()-to;
4811#ifndef BUCHBERGER_ALG
4812 if(isNolVector(curr_weight) == 0)
4840#ifdef BUCHBERGER_ALG
4847 xtstd = xtstd + clock() - to;
4861 xtlift = xtlift + clock() -to;
4879 xtred = xtred + clock() -to;
4897 xtnw = xtnw + clock() - to;
4901 MivString(curr_weight, target_weight, next_weight);
4915 if(
MivComp(next_weight, ivNull) == 1)
4922 if(
MivComp(next_weight, target_weight) == 1)
4930 G =
REC_GB_Mwalk(
G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4937 for(
i=nV-1;
i>=0;
i--)
4939 (*curr_weight)[
i] = (*next_weight)[
i];
4971 delete target_weight;
5019#ifndef BUCHBERGER_ALG
5035 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5038 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5046 ideal Gomega,
M, F, Gomega1, Gomega2, M1,
F1,
G;
5048 ring newRing, oldRing;
5051#ifndef BUCHBERGER_ALG
5055 for(
i=nV-1;
i>=0;
i--)
5056 (*tmp_weight)[
i] = (*curr_weight)[
i];
5060 for(
i=nV-1;
i>0;
i--)
5061 (*last_omega)[
i] = 1;
5062 (*last_omega)[0] = 10000;
5088 tif = tif + clock()-to;
5099#ifdef CHECK_IDEAL_MWALK
5100 Print(
"\n// **** Groebnerwalk took %d steps and ", nwalk);
5101 PrintS(
"\n// **** call the rec. Pert. Walk to compute a red GB of:");
5105 if(
MivSame(exivlp, target_weight)==1)
5110 Print(
"\n// time for the last std(Gw) = %.2f sec",
5111 ((
double) (clock()-tim)/1000000));
5126 xtlift = xtlift + clock() - to;
5150#ifndef BUCHBERGER_ALG
5151 if(isNolVector(curr_weight) == 0)
5177#ifdef BUCHBERGER_ALG
5184 tstd = tstd + clock() - to;
5200 tlift = tlift + clock() - to;
5220 tred = tred + clock() - to;
5224 xtred = xtred + clock() - to;
5239 tnw = tnw + clock() - to;
5242 MivString(curr_weight, target_weight, next_weight);
5249 PrintS(
"\n// ** The computed vector does NOT stay in Cone!!\n");
5267 if(
MivComp(next_weight, ivNull) == 1)
5273 if(
MivComp(next_weight, target_weight) == 1)
5277 for(
i=nV-1;
i>=0;
i--)
5279 (*tmp_weight)[
i] = (*curr_weight)[
i];
5280 (*curr_weight)[
i] = (*next_weight)[
i];
5292 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5304 ring baseRing,
int reduction,
int printout)
5317 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5318 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5324 int nV = baseRing->N;
5326 ideal Gomega,
M, F, FF, Gomega1, Gomega2, M1;
5328 ring XXRing = baseRing;
5343 (*curr_weight)[
i] = (*orig_M)[
i];
5344 (*target_weight)[
i] = (*target_M)[
i];
5346#ifndef BUCHBERGER_ALG
5350 for(
i=nV-1;
i>0;
i--)
5352 (*last_omega)[
i] = 1;
5354 (*last_omega)[0] = 10000;
5357#ifdef CHECK_IDEAL_MWALK
5364 if(target_M->
length() == nV)
5373 if(orig_M->
length() == nV)
5377 newRing=
VMrRefine(target_weight, curr_weight);
5409 tif = tif + clock()-to;
5412#ifdef CHECK_IDEAL_MWALK
5415 idString(Gomega,
"//** Mwalk: Gomega");
5424 PrintS(
"middle of Cone");
5432#ifndef BUCHBERGER_ALG
5433 if(isNolVector(curr_weight) == 0)
5445 if(orig_M->
length() == nV)
5449 newRing=
VMrRefine(target_weight, curr_weight);
5458 if(target_M->
length() == nV)
5462 newRing=
VMrRefine(target_weight, curr_weight);
5481#ifndef BUCHBERGER_ALG
5488 tstd = tstd + clock() - to;
5491#ifdef CHECK_IDEAL_MWALK
5510 tlift = tlift + clock() - to;
5512#ifdef CHECK_IDEAL_MWALK
5526#ifdef CHECK_IDEAL_MWALK
5553 tnw = tnw + clock() - to;
5558 MivString(curr_weight, target_weight, next_weight);
5563 if(
MivComp(curr_weight,next_weight)==1)
5568 if(
MivComp(target_weight,curr_weight) == 1)
5573 for(
i=nV-1;
i>=0;
i--)
5576 (*curr_weight)[
i] = (*next_weight)[
i];
5587#ifndef BUCHBERGER_ALG
5591 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5597 Print(
"\n//** Mwalk: Groebner Walk took %d steps.\n",
nstep);
5605 int reduction,
int printout)
5617 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5618 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5634 if(pert_deg > nV || pert_deg < 1)
5636 WerrorS(
"Invalid perturbation degree.\n");
5640 ideal Gomega,
M, F,FF, Gomega1, Gomega2, M1;
5653 (*curr_weight)[
i] = (*orig_M)[
i];
5654 (*target_weight)[
i] = (*target_M)[
i];
5657#ifndef BUCHBERGER_ALG
5661 for(
i=nV-1;
i>0;
i--)
5663 (*last_omega)[
i] = 1;
5665 (*last_omega)[0] = 10000;
5669 if(target_M->
length() == nV)
5677 if(orig_M->
length() == nV)
5680 newRing=
VMrRefine(target_weight, curr_weight);
5702 tif = tif + clock()-to;
5709#ifdef CHECK_IDEAL_MWALK
5712 idString(Gomega,
"//** Mrwalk: Gomega");
5726#ifndef BUCHBERGER_ALG
5727 if(isNolVector(curr_weight) == 0)
5738 if(orig_M->
length() == nV)
5741 newRing=
VMrRefine(target_weight, curr_weight);
5750 if(target_M->
length() == nV)
5753 newRing=
VMrRefine(target_weight, curr_weight);
5767#ifndef BUCHBERGER_ALG
5774 tstd = tstd + clock() - to;
5777#ifdef CHECK_IDEAL_MWALK
5796 tlift = tlift + clock() - to;
5798#ifdef CHECK_IDEAL_MWALK
5812 tstd = tstd + clock() - to;
5815#ifdef CHECK_IDEAL_MWALK
5842 tnw = tnw + clock() - to;
5850 tif = tif + clock()-to;
5860 if(target_M->
length() == nV)
5874 tnw = tnw + clock() - to;
5882 tif = tif + clock()-to;
5888 if(
MivComp(next_weight, ivNull) == 1 ||
MivComp(target_weight,curr_weight) == 1)
5896 if(
MivComp(curr_weight,next_weight)==1)
5904 MivString(curr_weight, target_weight, next_weight);
5908 for(
i=nV-1;
i>=0;
i--)
5910 (*curr_weight)[
i] = (*next_weight)[
i];
5919#ifndef BUCHBERGER_ALG
5924 Print(
"\n//** Mrwalk: Groebner Walk took %d steps.\n",
nstep);
5927 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5949 intvec* target_weight,
int nP,
int reduction,
int printout)
5961 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5963 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5969 int i, ntwC=1, ntestw=1, nV =
currRing->N;
5972 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
5974 WerrorS(
"Invalid perturbation degree.\n");
5979 ideal Gomega,
M, F, FF,
G, Gomega1, Gomega2, M1,
F1,Eresult,ssG;
5980 ring newRing, oldRing, TargetRing;
5984 intvec* orig_target = target_weight;
5985 intvec* pert_target_vector = target_weight;
5988#ifndef BUCHBERGER_ALG
5995 for(
i=nV-1;
i>0;
i--)
5996 (*last_omega)[
i] = 1;
5997 (*last_omega)[0] = 10000;
6004 if(
MivComp(curr_weight, iv_dp) == 1)
6038 if(op_deg != 1)
delete iv_M_dp;
6043 if(tp_deg > 1 && tp_deg <= nV)
6055 if(
MivSame(target_weight, exivlp) == 1)
6066 pert_target_vector = target_weight;
6072 Print(
"\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6074 ivString(curr_weight,
"//** Mpwalk: new current weight");
6075 ivString(target_weight,
"//** Mpwalk: new target weight");
6088 tif = tif + clock()-to;
6090#ifdef CHECK_IDEAL_MWALK
6093 idString(Gomega,
"//** Mpwalk: Gomega");
6096 if(reduction == 0 &&
nstep > 1)
6109 if(endwalks ==
TRUE)
6120#ifndef BUCHBERGER_ALG
6121 if(isNolVector(curr_weight) == 0)
6149 PrintS(
"\n// compute a rGB of Gw:\n");
6151#ifndef BUCHBERGER_ALG
6161#ifdef BUCHBERGER_ALG
6168 if(endwalks ==
TRUE)
6171 xtstd = xtstd+clock()-to;
6177 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
6178 ((
double) clock())/1000000 -((
double)tim) /1000000);
6186 tstd=tstd+clock()-to;
6189#ifdef CHECK_IDEAL_MWALK
6207 if(endwalks ==
FALSE)
6208 tlift = tlift+clock()-to;
6212#ifdef CHECK_IDEAL_MWALK
6234 PrintS(
"\n //** Mpwalk: reduce the Groebner basis.\n");
6241 if(endwalks ==
FALSE)
6242 tred = tred+clock()-to;
6248 if(endwalks ==
TRUE)
6263 MivString(curr_weight, target_weight, next_weight);
6276 if(
MivComp(next_weight, ivNull) == 1){
6282 if(
MivComp(next_weight, target_weight) == 1)
6285 for(
i=nV-1;
i>=0;
i--)
6286 (*curr_weight)[
i] = (*next_weight)[
i];
6294 if(
MivSame(orig_target, exivlp) == 1) {
6318 if( ntestw != 1 || ntwC == 0)
6320 if(ntestw != 1 && printout >2)
6322 ivString(pert_target_vector,
"tau");
6323 PrintS(
"\n// ** perturbed target vector doesn't stay in cone!!");
6332 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1){
6341 eF1 =
LastGB(
F2, curr_weight, tp_deg-1);
6364 delete target_weight;
6373 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6381 Print(
"\n//** Mpwalk: Perturbation Walk took %d steps.\n",
nstep);
6390 int op_deg,
int tp_deg,
int nP,
int reduction,
int printout)
6402 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
6404 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
6410 int i, ntwC=1, ntestw=1, nV =
currRing->N;
6420 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
6422 WerrorS(
"Invalid perturbation degree.\n");
6428 ideal Gomega,
M, F, FF,
G, Gomega1, Gomega2, M1,
F1,Eresult,ssG;
6429 ring newRing, oldRing, TargetRing;
6438 (*curr_weight)[
i] = (*orig_M)[
i];
6439 (*target_weight)[
i] = (*target_M)[
i];
6441 intvec* orig_target = target_weight;
6442 intvec* pert_target_vector = target_weight;
6445#ifndef BUCHBERGER_ALG
6452 for(
i=nV-1;
i>0;
i--)
6453 (*last_omega)[
i] = 1;
6454 (*last_omega)[0] = 10000;
6459 if(orig_M->
length() == nV)
6461 if(
MivComp(curr_weight, iv_dp) == 1)
6517 if(op_deg != 1)
delete iv_M_dp;
6522 if(target_M->
length() == nV)
6524 if(tp_deg > 1 && tp_deg <= nV)
6533 if(
MivSame(target_weight, exivlp) == 1)
6544 pert_target_vector = target_weight;
6551 if(tp_deg > 1 && tp_deg <= nV)
6561 Print(
"\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6562 ivString(curr_weight,
"//** Mprwalk: new current weight");
6563 ivString(target_weight,
"//** Mprwalk: new target weight");
6571 tif = tif + clock()-to;
6577#ifdef CHECK_IDEAL_MWALK
6580 idString(Gomega,
"//** Mprwalk: Gomega");
6584 if(reduction == 0 &&
nstep > 1)
6597 if(endwalks ==
TRUE)
6608#ifndef BUCHBERGER_ALG
6609 if(isNolVector(curr_weight) == 0)
6617 if(target_M->
length() == nV)
6634 if(endwalks ==
TRUE)
6643 PrintS(
"\n// compute a rGB of Gw:\n");
6645#ifndef BUCHBERGER_ALG
6655#ifdef BUCHBERGER_ALG
6661#ifdef CHECK_IDEAL_MWALK
6668 if(endwalks ==
TRUE)
6670 xtstd = xtstd+clock()-to;
6672 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
6673 ((
double) clock())/1000000 -((
double)tim) /1000000);
6677 tstd=tstd+clock()-to;
6691 if(endwalks ==
FALSE)
6692 tlift = tlift+clock()-to;
6696#ifdef CHECK_IDEAL_MWALK
6718 PrintS(
"\n //** Mprwalk: reduce the Groebner basis.\n");
6725 if(endwalks ==
FALSE)
6726 tred = tred+clock()-to;
6733 if(endwalks ==
TRUE)
6742 tnw = tnw + clock() - to;
6751 tif = tif + clock()-to;
6759 PrintS(
"\n Mpwalk: there is a polynomial in Gomega with at least 3 monomials.\n");
6763 if(target_M->
length() == nV)
6776 tnw = tnw + clock() - to;
6784 tif = tif + clock()-to;
6792 MivString(curr_weight, target_weight, next_weight);
6804 if(
MivComp(next_weight, ivNull) == 1){
6810 if(
MivComp(next_weight, target_weight) == 1)
6813 for(
i=nV-1;
i>=0;
i--)
6814 (*curr_weight)[
i] = (*next_weight)[
i];
6822 if(target_M->
length() == nV)
6824 if(
MivSame(orig_target, exivlp) == 1)
6847 if(ntestw != 1 || ntwC == 0)
6849 if(ntestw != 1 && printout > 2)
6852 ivString(pert_target_vector,
"tau");
6854 PrintS(
"\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
6863 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1 || target_M->
length() != nV)
6867 PrintS(
"\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
6876 PrintS(
"\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
6880 eF1 =
LastGB(
F2, curr_weight, tp_deg-1);
6905 delete target_weight;
6914 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6923 Print(
"\n//** Mprwalk: Perturbation Walk took %d steps.\n",
nstep);
6940 (*ivM)[
i*nV +
j] = 1;
6953 int reduction,
int printout)
6958 Print(
"\n\n// Entering the %d-th recursion:", nlev);
6961 ring new_ring, testring;
6963 ideal Gomega, Gomega1, Gomega2, FF, F, Gresult, Gresult1, G1, Gt;
6966#ifndef BUCHBERGER_ALG
6975 for(
i = nV -1;
i>=0;
i--)
6977 (*omtmp)[
i] = (*ivtarget)[
i];
6983 for(
i=nV-1;
i>0;
i--)
6984 (*last_omega)[
i] = 1;
6985 (*last_omega)[0] = 10000;
6988 for(
i=0;
i<nV;
i++) {
6990 (*omega)[
i] = (*Xsigma)[
i];
6992 (*omega)[
i] = (*Xsigma)[(nV*(nlev-1))+
i];
6994 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+
i];
6997 if(nlev == 1)
Xcall = 1;
7004#ifdef FIRST_STEP_FRACTAL
7007 if((nlev == 1 &&
Xcall == 0) || (nlev == 2 &&
Xngleich == 1))
7017 NEXT_VECTOR_FRACTAL:
7024 xtnw=xtnw+clock()-to;
7030 if (
MivComp(next_vect, omega2) == 1)
7036 Print(
"\n//** rec_fractal_call: Perturb the both vectors with degree %d.",nlev);
7043 if(ivtarget->
length() == nV)
7062 if(ivtarget->
length() == nV)
7081 for(
i=nV-1;
i>=0;
i--) {
7082 (*omega2)[
i] = (*Xtau)[nV+
i];
7083 (*omega)[
i] = (*Xsigma)[nV+
i];
7094 xtnw=xtnw+clock()-to;
7101 MivString(omega, omega2, next_vect);
7111 if(ivtarget->
length() == nV)
7128 Gt =
NULL;
return(Gt);
7132 Print(
"\n//** rec_fractal_call: Applying Buchberger's algorithm in ring r = %s;",
7141 xtextra=xtextra+clock()-to;
7149 Print(
"\n//** rec_fractal_call: Overflow. (4) Leaving the %d-th recursion with %d steps.\n",
7169 if(ivtarget->
length() == nV)
7194 Print(
"\n//** rec_fractal_call: Correct cone. (5) Leaving the %d-th recursion with %d steps.\n",
7199 idString(Gt,
"//** rec_fractal_call: Gt");
7207 PrintS(
"\n//** rec_fractal_call: Wrong cone. Tau doesn't stay in the correct cone.\n");
7210#ifndef MSTDCC_FRACTAL
7212 if(ivtarget->
length() == nV)
7222 Gt =
NULL;
return(Gt);
7229 PrintS(
"\n//** rec_fractal_call: Updated vectors are equal to the old vectors.\n");
7232 goto FRACTAL_MSTDCC;
7238 for(
i=nV-1;
i>=0;
i--)
7239 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+
i];
7244 goto NEXT_VECTOR_FRACTAL;
7250 Print(
"\n//** rec_fractal_call: Wrong cone. Applying Buchberger's algorithm in ring = %s.\n",
7258 xtextra=xtextra+clock()-to;
7263 if(ivtarget->
length() == nV)
7287 if(ivtarget->
length() == nV)
7306 Print(
"\n//** rec_fractal_call: Vectors updated. (6) Leaving the %d-th recursion with %d steps.\n",
7318 for(
i=nV-1;
i>=0;
i--) {
7320 (*omega)[
i] = (*next_vect)[
i];
7329 xtif=xtif+clock()-to;
7331#ifdef CHECK_IDEAL_MWALK
7334 idString(Gomega,
"//** rec_fractal_call: Gomega");
7348 goto NEXT_VECTOR_FRACTAL;
7352#ifndef BUCHBERGER_ALG
7353 if(isNolVector(omega) == 0)
7359 if(ivtarget->
length() == nV)
7382 PrintS(
"\n//** rec_fractal_call: Maximal recursion depth.\n");
7387#ifdef BUCHBERGER_ALG
7394 xtstd=xtstd+clock()-to;
7403#ifdef CHECK_IDEAL_MWALK
7406 idString(Gresult,
"//** rec_fractal_call: M");
7421 xtlift=xtlift+clock()-to;
7423#ifdef CHECK_IDEAL_MWALK
7426 idString(F,
"//** rec_fractal_call: F");
7455 int weight_rad,
int reduction,
int printout)
7461 ring new_ring, testring;
7463 ideal Gomega, Gomega1, Gomega2, F, FF, Gresult, Gresult1, G1, Gt;
7468#ifndef BUCHBERGER_ALG
7480 for(
i = nV -1;
i>=0;
i--)
7482 (*omtmp)[
i] = (*ivtarget)[
i];
7486 for(
i=nV-1;
i>0;
i--)
7487 (*last_omega)[
i] = 1;
7488 (*last_omega)[0] = 10000;
7491 for(
i=0;
i<nV;
i++) {
7493 (*omega)[
i] = (*Xsigma)[
i];
7495 (*omega)[
i] = (*Xsigma)[(nV*(nlev-1))+
i];
7497 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+
i];
7500 if(nlev == 1)
Xcall = 1;
7507#ifdef FIRST_STEP_FRACTAL
7512 if((nlev == 1 &&
Xcall == 0) || (nlev == 2 &&
Xngleich == 1))
7522 NEXT_VECTOR_FRACTAL:
7529 xtnw=xtnw+clock()-to;
7535 PrintS(
"\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n");
7544 xtnw=xtnw+clock()-to;
7554 xtnw=xtnw+clock()-to;
7562 if (
MivComp(next_vect, omega2) == 1)
7568 Print(
"\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev);
7573 if(ivtarget->
length() == nV)
7592 if(ivtarget->
length() == nV)
7608 if(ivtarget->
length() > nV)
7616 for(
i=nV-1;
i>=0;
i--)
7618 (*omega2)[
i] = (*Xtau)[nV+
i];
7619 (*omega)[
i] = (*Xsigma)[nV+
i];
7631 xtnw=xtnw+clock()-to;
7643 xtnw=xtnw+clock()-to;
7654 xtnw=xtnw+clock()-to;
7662 MivString(omega, omega2, next_vect);
7673 if(ivtarget->
length() == nV)
7699 Print(
"\n//** rec_r_fractal_call: applying Buchberger's algorithm in ring r = %s;",
7708 xtextra=xtextra+clock()-to;
7716 Print(
"\n//** rec_r_fractal_call: (1) Leaving the %d-th recursion with %d steps.\n",
7735 if(ivtarget->
length() == nV)
7760 Print(
"\n//** rec_r_fractal_call: (2) Leaving the %d-th recursion with %d steps.\n",
7770 Print(
"\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n");
7773#ifndef MSTDCC_FRACTAL
7781 if(ivtarget->
length() == nV)
7791 Gt =
NULL;
return(Gt);
7798 goto FRACTAL_MSTDCC;
7810 for(
i=nV-1;
i>=0;
i--)
7811 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+
i];
7817 goto NEXT_VECTOR_FRACTAL;
7823 Print(
"\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n",
7831 xtextra=xtextra+clock()-to;
7836 if(ivtarget->
length() == nV)
7860 if(ivtarget->
length() == nV)
7879 Print(
"\n//** rec_r_fractal_call: (3) Leaving the %d-th recursion with %d steps.\n",
7891 for(
i=nV-1;
i>=0;
i--)
7893 (*altomega)[
i] = (*omega)[
i];
7894 (*omega)[
i] = (*next_vect)[
i];
7903 xtif=xtif+clock()-to;
7907#ifdef CHECK_IDEAL_MWALK
7910 idString(Gomega,
"//** rec_r_fractal_call: Gomega");
7924 goto NEXT_VECTOR_FRACTAL;
7928#ifndef BUCHBERGER_ALG
7929 if(isNolVector(omega) == 0)
7934 if(ivtarget->
length() == nV)
7958#ifdef BUCHBERGER_ALG
7965 xtstd=xtstd+clock()-to;
7974#ifdef CHECK_IDEAL_MWALK
7977 idString(Gresult,
"//** rec_r_fractal_call: M");
7992 xtlift=xtlift+clock()-to;
7994#ifdef CHECK_IDEAL_MWALK
7997 idString(F,
"//** rec_r_fractal_call: F");
8033 int reduction,
int printout)
8050 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
8070#ifdef FIRST_STEP_FRACTAL
8075 && (Gw->m[
i]->next!=
NULL)
8076 && (Gw->m[
i]->next->next!=
NULL))
8080 if(ivstart->
length() == nV)
8082 if(
MivSame(ivstart, iv_dp) != 1)
8107 if(ivtarget->
length() == nV)
8147 if(ivtarget->
length() == nV)
8170 xftostd=xftostd+clock()-to;
8191 TimeStringFractal(xftinput, xftostd, xtif, xtstd, xtextra,
8192 xtlift, xtred, xtnw);
8197 Print(
"\n// the numbers of Overflow_Error (%d)",
nnflow);
8214 int weight_rad,
int reduction,
int printout)
8237 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
8257#ifdef FIRST_STEP_FRACTAL
8262 && (Gw->m[
i]->next!=
NULL)
8263 && (Gw->m[
i]->next->next!=
NULL))
8267 if(ivstart->
length() == nV)
8269 if(
MivSame(ivstart, iv_dp) != 1)
8294 if(ivtarget->
length() == nV)
8334 if(ivtarget->
length() == nV)
8357 xftostd=xftostd+clock()-to;
8378 TimeStringFractal(xftinput, xftostd, xtif, xtstd, xtextra,
8379 xtlift, xtred, xtnw);
8384 Print(
"\n// the numbers of Overflow_Error (%d)",
nnflow);
8400 clock_t mtim = clock();
8408 clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
8409 clock_t tinput = clock();
8411 int nsteppert=0,
i, nV =
currRing->N, nwalk=0, npert_tmp=0;
8412 int *npert=(
int*)
omAlloc(2*nV*
sizeof(
int));
8413 ideal Gomega,
M,F, G1, Gomega1, Gomega2, M1,
F1;
8415 ring newRing, oldRing, lpRing;
8423 int nGB, endwalks = 0, nwalkpert=0;
8426#ifndef BUCHBERGER_ALG
8431 for(
i=nV-1;
i>0;
i--)
8432 (*last_omega)[
i] = 1;
8433 (*last_omega)[0] = 10000;
8437 for(
i=nV-1;
i>=0;
i--)
8438 (*target_weight)[
i] = (*target_tmp)[
i];
8447 if(
MivComp(curr_weight, iv_dp) == 1)
8463#ifdef REPRESENTATION_OF_SIGMA
8469 if(
MivComp(curr_weight, iv_dp) == 1)
8470 MDp = MatrixOrderdp(nV);
8474 curr_weight = RepresentationMatrix_Dp(
G, MDp);
8491 tostd=tostd+clock()-to;
8494 goto COMPUTE_NEW_VECTOR;
8513#ifndef BUCHBERGER_ALG
8514 if(isNolVector(curr_weight) == 0)
8535#ifdef BUCHBERGER_ALG
8542 tstd=tstd+clock()-to;
8558 tlift=tlift+clock()-to;
8575 tred=tred+clock()-to;
8593 MivString(curr_weight, target_weight, next_weight);
8605 OMEGA_OVERFLOW_TRAN_NEW:
8617 if(
MivSame(target_tmp, iv_lp) == 1)
8635 if(nP == 0 ||
MivSame(target_tmp, iv_lp) == 0){
8644 G =
LastGB(G1, curr_weight, nV-1);
8652 npert[endwalks]=nwalk-npert_tmp;
8661 if(
MivComp(next_weight, target_weight) == 1 ||
8662 MivComp(next_weight, curr_weight) == 1 )
8668 npert[endwalks]=nwalk-npert_tmp;
8674 if(endwalks == 1 &&
MivComp(next_weight, curr_weight) == 1){
8681 if(
MivSame(target_tmp, iv_lp) == 1)
8728 if(
p->next !=
NULL &&
8729 p->next->next !=
NULL &&
8730 p->next->next->next !=
NULL)
8735 (*vector_tmp)[
i] = (*target_weight)[
i];
8737 delete target_weight;
8740 if(
MivComp(vector_tmp, target_weight)==1)
8745 goto OMEGA_OVERFLOW_TRAN_NEW;
8752 goto OMEGA_OVERFLOW_TRAN_NEW;
8762 if(plength3 ==
FALSE)
8787 goto COMPUTE_NEW_VECTOR;
8791 for(
i=nV-1;
i>=0;
i--)
8792 (*curr_weight)[
i] = (*next_weight)[
i];
8827ideal TranMrImprovwalk(ideal
G,
intvec* curr_weight,
intvec* target_tmp,
int nP,
int weight_rad,
int pert_deg)
8830 clock_t mtim = clock();
8838 VAR clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
8839 VAR clock_t tinput = clock();
8841 VAR int nsteppert=0,
i, nV =
currRing->N, nwalk=0, npert_tmp=0;
8842 VAR int *npert=(
int*)
omAlloc(2*nV*
sizeof(
int));
8843 INST_VAR ideal Gomega,
M,F, G1, Gomega1, Gomega2, M1,
F1;
8845 VAR ring newRing, oldRing, lpRing;
8853 VAR int weight_norm, nGB, endwalks = 0, nwalkpert=0, npertstep=0;
8856#ifndef BUCHBERGER_ALG
8861 for(
i=nV-1;
i>0;
i--)
8863 (*last_omega)[
i] = 1;
8865 (*last_omega)[0] = 10000;
8869 for(
i=nV-1;
i>=0;
i--)
8871 (*target_weight)[
i] = (*target_tmp)[
i];
8880 if(
MivComp(curr_weight, iv_dp) == 1)
8903#ifdef REPRESENTATION_OF_SIGMA
8909 if(
MivComp(curr_weight, iv_dp) == 1)
8911 MDp = MatrixOrderdp(nV);
8917 curr_weight = RepresentationMatrix_Dp(
G, MDp);
8938 tostd=tostd+clock()-to;
8941 goto COMPUTE_NEW_VECTOR;
8960#ifndef BUCHBERGER_ALG
8961 if(isNolVector(curr_weight) == 0)
8989#ifdef BUCHBERGER_ALG
8996 tstd=tstd+clock()-to;
9011 tlift=tlift+clock()-to;
9028 tred=tred+clock()-to;
9122 MivString(curr_weight, target_weight, next_weight);
9134 OMEGA_OVERFLOW_TRAN_NEW:
9141#ifdef CHECK_IDEAL_MWALK
9146 if(
MivSame(target_tmp, iv_lp) == 1)
9175 if(nP == 0 ||
MivSame(target_tmp, iv_lp) == 0)
9186 G =
LastGB(G1, curr_weight, nV-1);
9194 npert[endwalks]=nwalk-npert_tmp;
9203 if(
MivComp(next_weight, target_weight) == 1 ||
MivComp(next_weight, curr_weight) == 1 )
9209 npert[endwalks]=nwalk-npert_tmp;
9215 if(endwalks == 1 &&
MivComp(next_weight, curr_weight) == 1)
9223 if(
MivSame(target_tmp, iv_lp) == 1)
9279 if(
p->next !=
NULL &&
9280 p->next->next !=
NULL &&
9281 p->next->next->next !=
NULL)
9287 (*vector_tmp)[
i] = (*target_weight)[
i];
9289 delete target_weight;
9292 if(
MivComp(vector_tmp, target_weight)==1)
9297 goto OMEGA_OVERFLOW_TRAN_NEW;
9304 goto OMEGA_OVERFLOW_TRAN_NEW;
9314 if(plength3 ==
FALSE)
9340 goto COMPUTE_NEW_VECTOR;
9344 for(
i=nV-1;
i>=0;
i--)
9346 (*curr_weight)[
i] = (*next_weight)[
i];
9358 VAR delete next_weight;
9363 Print(
"\n// Computation took %d steps and %.2f sec", nwalk, ((
double) (clock()-mtim)/1000000));
9365 TimeStringFractal(tinput, tostd, tif, tstd, textra, tlift, tred, tnw);
9384 clock_t tinput=clock();
9389 if(tp_deg < 1 || tp_deg > nV)
9391 WerrorS(
"Invalid perturbation degree.\n");
9395 int nwalk=0, endwalks=0, ntestwinC=1;
9396 int tp_deg_tmp = tp_deg;
9397 ideal Gomega,
M, F,
G, M1,
F1, Gomega1, Gomega2, G1;
9398 ring newRing, oldRing, TargetRing;
9431 target_weight =
Mivlp(nV);
9441 if(tp_deg != tp_deg_tmp)
9451#ifndef BUCHBERGER_ALG
9456 for(
i=nV-1;
i>0;
i--)
9458 (*last_omega)[
i] = 1;
9460 (*last_omega)[0] = 10000;
9480 xtif=xtif+clock()-to;
9483#ifndef BUCHBERGER_ALG
9484 if(isNolVector(curr_weight) == 0)
9517#ifdef BUCHBERGER_ALG
9524 xtstd=xtstd+clock()-to;
9540 xtlift=xtlift+clock()-to;
9557 xtred=xtred+clock()-to;
9572 xtnw=xtnw+clock()-to;
9575 MivString(curr_weight, target_weight, next_weight);
9584 tproc = tproc+clock()-tinput;
9597 if(
MivComp(next_weight, ivNull) == 1)
9603 if(
MivComp(next_weight, target_weight) == 1)
9607 for(
i=nV-1;
i>=0;
i--)
9610 (*curr_weight)[
i] = (*next_weight)[
i];
9639 xtextra=xtextra+clock()-to;
9649 tproc = tproc+clock()-tinput;
9662 delete target_weight;
9683 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
9685 clock_t tostd, tproc;
9690 int nwalk=0, endwalks=0;
9691 int op_tmp = op_deg;
9692 ideal Gomega,
M, F,
G, Gomega1, Gomega2, M1,
F1;
9693 ring newRing, oldRing;
9700#ifndef BUCHBERGER_ALG
9703 intvec* cw_tmp = curr_weight;
9707 for(
i=nV-1;
i>0;
i--)
9709 (*last_omega)[
i] = 1;
9711 (*last_omega)[0] = 10000;
9725 if(
MivComp(curr_weight, iv_dp) == 1)
9728 if(op_tmp == op_deg)
9740 if(op_tmp == op_deg)
9764 curr_weight = cw_tmp;
9796 xtif=xtif+clock()-to;
9801 for(
i=nV-1;
i>=0;
i--)
9802 (*curr_weight)[
i] = (*extra_curr_weight)[
i];
9803 delete extra_curr_weight;
9809#ifndef BUCHBERGER_ALG
9810 if(isNolVector(curr_weight) == 0)
9838#ifdef BUCHBERGER_ALG
9845 xtstd=xtstd+clock()-to;
9859 xtlift=xtlift+clock()-to;
9878 xtred=xtred+clock()-to;
9893 xtnw=xtnw+clock()-to;
9896 MivString(curr_weight, target_weight, next_weight);
9919 if(
MivComp(next_weight, ivNull) == 1)
9926 if(
MivComp(next_weight, target_weight) == 1)
9928 if(tp_deg == 1 ||
MivSame(target_weight, exivlp) == 0)
9935 tproc = clock()-xftinput;
9948 for(
i=nV-1;
i>=0;
i--)
9951 (*curr_weight)[
i] = (*next_weight)[
i];
const CanonicalForm CFMap CFMap & N
poly singclap_pdivide(poly f, poly g, const ring r)
void(*) initEcart(TObject *L)
int(*) posInT(const TSet T, const int tl, LObject &h)
void(*) enterS(LObject *h, int pos, kStrategy strat, int atR)
Coefficient rings, fields and other domains suitable for Singular polynomials.
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
#define idDelete(H)
delete an ideal
static ideal idVec2Ideal(poly vec)
intvec * ivCopy(const intvec *o)
KINLINE TObject ** initR()
KINLINE unsigned long * initsevT()
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
void enterSBba(LObject *p, int atS, kStrategy strat, int atR)
int posInT0(const TSet, const int length, LObject &)
static intset initec(const int maxnr)
void initS(ideal F, ideal Q, kStrategy strat)
void initEcartNormal(TObject *h)
void updateS(BOOLEAN toT, kStrategy strat)
static int * initS_2_R(const int maxnr)
void initBuchMoraCrit(kStrategy strat)
void completeReduce(kStrategy strat, BOOLEAN withT)
static unsigned long * initsevS(const int maxnr)
gmp_float max(const gmp_float &a, const gmp_float &b)
gmp_float sqrt(const gmp_float &a)
#define omFreeSize(addr, size)
#define SI_SAVE_OPT(A, B)
#define TEST_OPT_INTSTRATEGY
#define SI_RESTORE_OPT(A, B)
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatibility 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 pIsConstant(p)
like above, except that Comp must be 0
#define pGetExp(p, i)
Exponent.
#define pEqualPolys(p1, p2)
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
#define pCopy(p)
return a copy of the poly
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
void PrintS(const char *s)
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...
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
void rDelete(ring r)
unconditionally deletes fields in r
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_Normalize(ideal I, const ring r)
normialize all polys in id
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
int F1(int a1, int &r1)
F1.
void F2(int a2, int &r2)
F2.
int M3ivSame(intvec *temp, intvec *u, intvec *v)
static ideal REC_GB_Mwalk(ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
static void ivString(intvec *iv, const char *ch)
intvec * MivWeightOrderdp(intvec *ivstart)
static ideal kInterRedCC(ideal F, ideal Q)
static int MivAbsMaxArg(intvec *vec)
intvec * MMatrixone(int nV)
static ideal idHeadCC(ideal h)
static ideal MstdhomCC(ideal G)
static ring VMrRefine(intvec *va, intvec *vb)
static ideal rec_r_fractal_call(ideal G, int nlev, intvec *ivtarget, int weight_rad, int reduction, int printout)
static void cancel(mpz_t zaehler, mpz_t nenner)
static intvec * MExpPol(poly f)
ideal TranMImprovwalk(ideal G, intvec *curr_weight, intvec *target_tmp, int nP)
static int lengthpoly(ideal G)
static long Mlcm(long &i1, long &i2)
static int MivComp(intvec *iva, intvec *ivb)
static int MwalkWeightDegree(poly p, intvec *weight_vector)
intvec * MivMatrixOrderdp(int nV)
ideal Mfwalk(ideal G, intvec *ivstart, intvec *ivtarget, int reduction, int printout)
static intvec * MivSub(intvec *a, intvec *b)
intvec * MPertVectors(ideal G, intvec *ivtarget, int pdeg)
ideal MwalkAlt(ideal Go, intvec *curr_weight, intvec *target_weight)
static ideal MidMult(ideal A, ideal B)
intvec * MivWeightOrderlp(intvec *ivstart)
static ideal middleOfCone(ideal G, ideal Gomega)
ideal Mprwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout)
intvec * MivMatrixOrder(intvec *iv)
static int MLmWeightedDegree(const poly p, intvec *weight)
static ideal rec_fractal_call(ideal G, int nlev, intvec *ivtarget, int reduction, int printout)
void Set_Error(BOOLEAN f)
static ideal Mpwalk_MAltwalk1(ideal Go, intvec *curr_weight, int tp_deg)
static ideal MLifttwoIdeal(ideal Gw, ideal M, ideal G)
static ring VMrDefault(intvec *va)
static int maxlengthpoly(ideal G)
static int isNegNolVector(intvec *hilb)
static void DefRingParlp(void)
static long MivDotProduct(intvec *a, intvec *b)
ideal MAltwalk2(ideal Go, intvec *curr_weight, intvec *target_weight)
static void MLmWeightedDegree_gmp(mpz_t result, const poly p, intvec *weight)
static int islengthpoly2(ideal G)
static intvec * MWalkRandomNextWeight(ideal G, intvec *orig_M, intvec *target_weight, int weight_rad, int pert_deg)
ideal MAltwalk1(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight)
ideal Mrwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int pert_deg, int reduction, int printout)
static ring VMatrRefine(intvec *va, intvec *vb)
intvec * MivMatrixOrderRefine(intvec *iv, intvec *iw)
ideal Mfrwalk(ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad, int reduction, int printout)
ideal Mwalk(ideal Go, intvec *orig_M, intvec *target_M, ring baseRing, int reduction, int printout)
VAR BOOLEAN Overflow_Error
static poly MpolyInitialForm(poly g, intvec *curr_weight)
ideal Mpwalk(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP, int reduction, int printout)
static intvec * NewVectorlp(ideal I)
int MivSame(intvec *u, intvec *v)
ideal MwalkInitialForm(ideal G, intvec *ivw)
static ideal LastGB(ideal G, intvec *curr_weight, int tp_deg)
intvec * MivMatrixOrderlp(int nV)
static void idString(ideal L, const char *st)
static int MivAbsMax(intvec *vec)
intvec * Mfpertvector(ideal G, intvec *ivtarget)
static ring VMatrDefault(intvec *va)
intvec * MPertVectorslp(ideal G, intvec *ivtarget, int pdeg)
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
static void VMrDefaultlp(void)
static void DefRingPar(intvec *va)
static ideal MstdCC(ideal G)
static intvec * MwalkNextWeightCC(intvec *curr_weight, intvec *target_weight, ideal G)
static int test_w_in_ConeCC(ideal G, intvec *iv)
static int test_G_GB_walk(ideal H0, ideal H1)
static ideal Rec_LastGB(ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)