12 #define BUCHBERGER_ALG //we use the improved Buchberger alg. 19 #define CHECK_IDEAL_MWALK //to print intermediate results 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 29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if tau doesn't stay in the correct cone 87 #include <sys/types.h> 112 return (
unsigned long*)
omAlloc0(maxnr*
sizeof(
unsigned long));
116 return (
int*)
omAlloc0(maxnr*
sizeof(
int));
357 ideal shdl=strat->
Shdl;
365 static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
366 clock_t tlf,clock_t tred, clock_t tnw,
int step)
368 double totm = ((double) (clock() - tinput))/1000000;
369 double ostd,mostd, mif, mstd, mlf, mred, mnw, mxif,mxstd,mxlf,mxred,mxnw,tot;
371 Print(
"\n// total time = %.2f sec", totm);
372 Print(
"\n// tostd = %.2f sec = %.2f", ostd=((
double) tostd)/1000000,
373 mostd=((((
double) tostd)/1000000)/totm)*100);
374 Print(
"\n// tif = %.2f sec = %.2f", ((
double) tif)/1000000,
375 mif=((((
double) tif)/1000000)/totm)*100);
376 Print(
"\n// std = %.2f sec = %.2f", ((
double) tstd)/1000000,
377 mstd=((((
double) tstd)/1000000)/totm)*100);
378 Print(
"\n// lift = %.2f sec = %.2f", ((
double) tlf)/1000000,
379 mlf=((((
double) tlf)/1000000)/totm)*100);
380 Print(
"\n// ired = %.2f sec = %.2f", ((
double) tred)/1000000,
381 mred=((((
double) tred)/1000000)/totm)*100);
382 Print(
"\n// nextw = %.2f sec = %.2f", ((
double) tnw)/1000000,
383 mnw=((((
double) tnw)/1000000)/totm)*100);
384 PrintS(
"\n Time for the last step:");
385 Print(
"\n// xinfo = %.2f sec = %.2f", ((
double)
xtif)/1000000,
386 mxif=((((
double) xtif)/1000000)/totm)*100);
387 Print(
"\n// xstd = %.2f sec = %.2f", ((
double)
xtstd)/1000000,
388 mxstd=((((
double) xtstd)/1000000)/totm)*100);
389 Print(
"\n// xlift = %.2f sec = %.2f", ((
double)
xtlift)/1000000,
390 mxlf=((((
double) xtlift)/1000000)/totm)*100);
391 Print(
"\n// xired = %.2f sec = %.2f", ((
double)
xtred)/1000000,
392 mxred=((((
double) xtred)/1000000)/totm)*100);
393 Print(
"\n// xnextw= %.2f sec = %.2f", ((
double)
xtnw)/1000000,
394 mxnw=((((
double) xtnw)/1000000)/totm)*100);
396 tot=mostd+mif+mstd+mlf+mred+mnw+mxif+mxstd+mxlf+mxred+mxnw;
397 double res = (double) 100 - tot;
398 Print(
"\n// &%d&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f(%.2f)\\ \\",
399 step, ostd, totm, mostd,mif,mstd,mlf,mred,mnw,mxif,mxstd,mxlf,mxred,mxnw,tot,res,
400 ((((
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 436 Print(
"\n// ideal %s = ", st);
437 for(i=0; i<nL-1; i++)
503 Print(
"\n// intvec %s = ", ch);
505 for(
int i=0;
i<nV;
i++)
509 Print(
"%d;", (*iv)[nV]);
520 Print(
"%d, ", (*iva)[i]);
522 Print(
"%d) ==> (", (*iva)[nV]);
525 Print(
"%d, ", (*ivb)[i]);
527 Print(
"%d) := (", (*ivb)[nV]);
531 Print(
"%d, ", (*ivc)[i]);
533 Print(
"%d)", (*ivc)[nV]);
540 static inline long gcd(
const long a,
const long b)
542 long r, p0 =
a, p1 =
b;
596 static void cancel(mpz_t zaehler, mpz_t nenner)
601 mpz_gcd(g, zaehler, nenner);
603 mpz_div(zaehler , zaehler, g);
604 mpz_div(nenner , nenner, g);
611 static int isVectorNeg(
intvec* omega)
615 for(i=omega->
length(); i>=0; i--)
633 mpz_init_set_ui(sing_int, 2147483647);
646 mpz_set_si(zvec, (*weight)[i-1]);
647 mpz_mul_ui(zmul, zvec,
pGetExp(p, i));
648 mpz_add(zsum, zsum, zmul);
651 wgrad = mpz_get_ui(zsum);
653 if(mpz_cmp(zsum, sing_int)>0)
658 PrintS(
"\n// ** OVERFLOW in \"MwalkInitialForm\": ");
659 mpz_out_str( stdout, 10, zsum);
660 PrintS(
" is greater than 2147483647 (max. integer representation)");
679 int max = 0, maxtemp;
702 mpz_init_set_ui(sing_int, 2147483647);
715 mpz_set_si(zvec, (*weight)[i-1]);
716 mpz_mul_ui(zmul, zvec,
pGetExp(p, i));
717 mpz_add(ztmp, ztmp, zmul);
719 mpz_init_set(result, ztmp);
736 mpz_t
max; mpz_init(max);
737 mpz_t maxtmp; mpz_init(maxtmp);
747 if(mpz_cmp(maxtmp, max)>0)
749 mpz_set(max, maxtmp);
755 if(mpz_cmp(maxtmp, max)==0)
775 ideal Gomega =
idInit(nG, 1);
777 for(i=nG-1; i>=0; i--)
797 PrintS(
"//** the result may be WRONG, i.e. 0!!\n");
807 for(i=nG-1; i>=0; i--)
843 static inline long Mlcm(
long &i1,
long &i2)
845 long temp =
gcd(i1, i2);
846 return ((i1 / temp)* i2);
859 for(i=n-1; i>=0; i--)
861 result += (*a)[
i] * (*b)[
i];
875 for(i=n-1; i>=0; i--)
877 (*result)[
i] = (*a)[
i] - (*b)[
i];
890 for(i=nR-1; i>=0; i--)
907 for (i=0; i<niv; i++)
909 if ((*u)[i] != (*v)[i])
979 (*ivm)[
i] = (*iv)[
i];
983 (*ivm)[i*nR+i-1] = 1;
1000 (*ivm)[
i] = (*iv)[
i];
1006 (*ivm)[j+i*nR] = (*iw)[j+i*nR];
1020 for(i=nR-1; i>=0; i--)
1106 if(pdeg > nV || pdeg <= 0)
1108 WerrorS(
"//** The perturbed degree is wrong!!");
1117 mpz_t *pert_vector = (mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
1118 mpz_t *pert_vector1 = (mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
1122 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
1123 mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
1127 int ntemp, maxAi, maxA=0;
1128 for(i=1; i<pdeg; i++)
1130 maxAi = (*ivtarget)[i*nV];
1135 for(j=i*nV+1; j<(i+1)*nV; j++)
1137 ntemp = (*ivtarget)[
j];
1154 mpz_t tot_deg; mpz_init(tot_deg);
1155 mpz_t maxdeg; mpz_init(maxdeg);
1156 mpz_t inveps; mpz_init(inveps);
1159 for(i=nG-1; i>=0; i--)
1162 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1164 mpz_set(tot_deg, maxdeg);
1169 mpz_mul_ui(inveps, tot_deg, maxA);
1170 mpz_add_ui(inveps, inveps, 1);
1174 #ifdef INVEPS_SMALL_IN_MPERTVECTOR 1175 if(mpz_cmp_ui(inveps, pdeg)>0 && pdeg > 3)
1178 mpz_fdiv_q_ui(inveps, inveps, pdeg);
1183 mpz_out_str(stdout, 10, inveps);
1188 for( i=1; i < pdeg; i++ )
1192 mpz_mul(pert_vector[j], pert_vector[j], inveps);
1193 if((*ivtarget)[i*nV+j]<0)
1195 mpz_sub_ui(pert_vector[j], pert_vector[j],-(*ivtarget)[i*nV+j]);
1199 mpz_add_ui(pert_vector[j], pert_vector[j],(*ivtarget)[i*nV+j]);
1206 mpz_init_set_ui(sing_int, 2147483647);
1209 mpz_init_set_ui(check_int, 100000);
1213 mpz_set(ztemp, pert_vector[0]);
1216 mpz_gcd(ztemp, ztemp, pert_vector[i]);
1217 if(mpz_cmp_si(ztemp, 1) == 0)
1222 if(mpz_cmp_si(ztemp, 1) != 0)
1226 mpz_divexact(pert_vector[i], pert_vector[i], ztemp);
1232 if(mpz_cmp(pert_vector[i], check_int)>=0)
1236 mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100);
1247 (*result)[
i] = mpz_get_si(pert_vector1[i]);
1248 if(mpz_cmp(pert_vector1[i], sing_int)>=0)
1258 (*result)[
i] = mpz_get_si(pert_vector[i]);
1259 if(mpz_cmp(pert_vector[i], sing_int)>=0)
1265 PrintS(
"\n// ** OVERFLOW in \"MPertvectors\": ");
1266 mpz_out_str( stdout, 10, pert_vector[i]);
1267 PrintS(
" is greater than 2147483647 (max. integer representation)");
1268 Print(
"\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
1276 Print(
"\n// %d element(s) of it is overflow!!", ntrue);
1281 mpz_clear(sing_int);
1282 mpz_clear(check_int);
1317 if(pdeg > nV || pdeg <= 0)
1319 WerrorS(
"//** The perturbed degree is wrong!!");
1324 (*pert_vector)[
i]=(*ivtarget)[
i];
1332 int ntemp, maxAi, maxA=0;
1333 for(i=1; i<pdeg; i++)
1335 maxAi = (*ivtarget)[i*nV];
1336 for(j=i*nV+1; j<(i+1)*nV; j++)
1338 ntemp = (*ivtarget)[
j];
1348 int inveps, tot_deg = 0, maxdeg;
1351 for(i=nG-1; i>=0; i--)
1355 if (maxdeg > tot_deg )
1362 inveps = (tot_deg * maxA) + 1;
1364 #ifdef INVEPS_SMALL_IN_FRACTAL 1366 if(inveps > pdeg && pdeg > 3)
1368 inveps = inveps / pdeg;
1372 PrintS(
"\n// the \"big\" inverse epsilon %d", inveps);
1376 for ( i=1; i < pdeg; i++ )
1380 (*pert_vector)[
j] = inveps*((*pert_vector)[
j]) + (*ivtarget)[i*nV+
j];
1384 int temp = (*pert_vector)[0];
1387 temp =
gcd(temp, (*pert_vector)[i]);
1397 (*pert_vector)[
i] = (*pert_vector)[
i] / temp;
1416 (*ivM)[i*nV +
i] = 1;
1436 (*ivM)[(i+1)*nV - i] = -1;
1447 int nV = ivstart->
length();
1452 (*ivM)[
i] = (*ivstart)[
i];
1456 (*ivM)[i*nV + i-1] = 1;
1467 int nV = ivstart->
length();
1472 (*ivM)[
i] = (*ivstart)[
i];
1480 (*ivM)[(i+1)*nV - i] = -1;
1508 for(i=nV-1; i>=0; i--)
1529 int ntemp, maxAi, maxA=0;
1532 maxAi = (*ivtarget)[i*nV];
1537 for(j=i*nV+1; j<(i+1)*nV; j++)
1539 ntemp = (*ivtarget)[
j];
1549 maxA = maxA + maxAi;
1554 mpz_t tot_deg; mpz_init(tot_deg);
1555 mpz_t maxdeg; mpz_init(maxdeg);
1556 mpz_t inveps; mpz_init(inveps);
1559 for(i=nG-1; i>=0; i--)
1562 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1564 mpz_set(tot_deg, maxdeg);
1570 mpz_mul_ui(inveps, tot_deg, maxA);
1571 mpz_add_ui(inveps, inveps, 1);
1574 #ifdef INVEPS_SMALL_IN_FRACTAL 1575 if(mpz_cmp_ui(inveps, nV)>0 && nV > 3)
1577 mpz_cdiv_q_ui(inveps, inveps, nV);
1585 mpz_t *ivtemp=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
1586 mpz_t *pert_vector=(mpz_t *)
omAlloc(niv*
sizeof(mpz_t));
1588 for(i=0; i < nV; i++)
1590 mpz_init_set_si(ivtemp[i], (*ivtarget)[i]);
1591 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
1594 mpz_t ztmp; mpz_init(ztmp);
1601 mpz_mul(ztmp, inveps, ivtemp[j]);
1602 if((*ivtarget)[i*nV+j]<0)
1604 mpz_sub_ui(ivtemp[j], ztmp, -(*ivtarget)[i*nV+j]);
1608 mpz_add_ui(ivtemp[j], ztmp,(*ivtarget)[i*nV+j]);
1614 mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);
1620 mpz_init_set_ui(sing_int, 2147483647);
1627 mpz_set(ztmp, pert_vector[0]);
1628 for(i=0; i<niv; i++)
1630 mpz_gcd(ztmp, ztmp, pert_vector[i]);
1631 if(mpz_cmp_si(ztmp, 1)==0)
1637 for(i=0; i<niv; i++)
1639 mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
1640 (* result)[
i] = mpz_get_si(pert_vector[i]);
1645 for(i=0; i<niv; i++)
1647 if(mpz_cmp(pert_vector[i], sing_int)>0)
1654 Print(
"\n// Xlev = %d and the %d-th element is",
Xnlev, i+1);
1655 PrintS(
"\n// ** OVERFLOW in \"Mfpertvector\": ");
1656 mpz_out_str( stdout, 10, pert_vector[i]);
1657 PrintS(
" is greater than 2147483647 (max. integer representation)");
1658 Print(
"\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
1672 mpz_clear(sing_int);
1711 if (result->m[k]!=
NULL)
1752 for(j=
IDELEMS(idLG)-1; j>=0; j--)
1754 F->m[
i] =
pAdd(F->m[i], idLG->m[j]);
1811 for(i=iva->
length()-1; i>=0; i--)
1813 if((*iva)[
i] - (*ivb)[
i] != 0)
1835 for(i=1; i < (vec->
length()); i++)
1865 if((*vec)[i] == k || (*vec)[i] == -k)
2244 target_weight !=
NULL && G !=
NULL);
2250 mpz_t t_zaehler, t_nenner;
2251 mpz_init(t_zaehler);
2254 mpz_t s_zaehler, s_nenner, temp, MwWd;
2255 mpz_init(s_zaehler);
2262 mpz_set_si(sing_int, 2147483647);
2264 mpz_t sing_int_half;
2265 mpz_init(sing_int_half);
2266 mpz_set_si(sing_int_half, 3*(1073741824/2));
2268 mpz_t deg_w0_p1, deg_d0_p1;
2269 mpz_init(deg_w0_p1);
2270 mpz_init(deg_d0_p1);
2294 for (j=0; j<nRing; j++)
2296 (*diff_weight1)[
j] = (*curr_weight)[
j];
2300 for(j=0; j<nRing; j++)
2302 (*curr_weight)[
j] = (*diff_weight1)[
j];
2304 for(j=0; j<nRing; j++)
2306 (*diff_weight1)[
j] = floor(0.1*(*diff_weight1)[j] + 0.5);
2312 for(j=0; j<nRing; j++)
2314 (*diff_weight1)[
j] = (*curr_weight)[
j];
2319 (*curr_weight)[
j] = (*diff_weight1)[
j];
2321 (*diff_weight1)[
j] = floor(0.1*(*diff_weight1)[j] + 0.5);
2326 intvec* diff_weight =
MivSub(target_weight, curr_weight);
2329 for (j=0; j<nG; j++)
2344 mpz_sub(s_zaehler, deg_w0_p1, MwWd);
2345 if(mpz_cmp(s_zaehler, t_null) != 0)
2348 mpz_sub(s_nenner, MwWd, deg_d0_p1);
2350 if( (mpz_cmp(s_zaehler,t_null) > 0 &&
2351 mpz_cmp(s_nenner, s_zaehler)>=0) ||
2352 (mpz_cmp(s_zaehler, t_null) < 0 &&
2353 mpz_cmp(s_nenner, s_zaehler)<=0))
2356 if (mpz_cmp(s_zaehler, t_null) < 0)
2358 mpz_neg(s_zaehler, s_zaehler);
2359 mpz_neg(s_nenner, s_nenner);
2363 cancel(s_zaehler, s_nenner);
2365 if(mpz_cmp(t_nenner, t_null) != 0)
2367 mpz_mul(sztn, s_zaehler, t_nenner);
2368 mpz_mul(sntz, s_nenner, t_zaehler);
2370 if(mpz_cmp(sztn,sntz) < 0)
2372 mpz_add(t_nenner, t_null, s_nenner);
2373 mpz_add(t_zaehler,t_null, s_zaehler);
2378 mpz_add(t_nenner, t_null, s_nenner);
2379 mpz_add(t_zaehler,t_null, s_zaehler);
2389 mpz_t *
vec=(mpz_t*)
omAlloc(nRing*
sizeof(mpz_t));
2394 if(mpz_cmp(t_nenner, t_null) == 0)
2397 Print(
"\n//MwalkNextWeightCC: t_nenner=0\n");
2400 diff_weight =
ivCopy(curr_weight);
2405 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
2408 diff_weight =
ivCopy(target_weight);
2415 gcd_tmp = (*curr_weight)[0];
2417 for (j=1; j<nRing; j++)
2419 gcd_tmp =
gcd(gcd_tmp, (*curr_weight)[j]);
2427 for (j=0; j<nRing; j++)
2429 gcd_tmp =
gcd(gcd_tmp, (*diff_weight)[j]);
2438 for (j=0; j<nRing; j++)
2440 (*curr_weight)[
j] = (*curr_weight)[
j]/gcd_tmp;
2441 (*diff_weight)[
j] = (*diff_weight)[
j]/gcd_tmp;
2445 #ifdef NEXT_VECTORS_CC 2446 Print(
"\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
2450 PrintS(
"\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler);
2451 PrintS(
", t_nenner: "); mpz_out_str( stdout, 10, t_nenner);
2459 for (j=0; j<nRing; j++)
2461 mpz_set_si(dcw, (*curr_weight)[j]);
2462 mpz_mul(s_nenner, t_nenner, dcw);
2464 if( (*diff_weight)[j]>0)
2466 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
2470 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
2471 mpz_neg(s_zaehler, s_zaehler);
2473 mpz_add(sntz, s_nenner, s_zaehler);
2474 mpz_init_set(vec[j], sntz);
2476 #ifdef NEXT_VECTORS_CC 2477 Print(
"\n// j = %d ==> ", j);
2479 mpz_out_str( stdout, 10, t_nenner);
2480 Print(
" * %d)", (*curr_weight)[j]);
2481 Print(
" + ("); mpz_out_str( stdout, 10, t_zaehler);
2482 Print(
" * %d) = ", (*diff_weight)[j]);
2483 mpz_out_str( stdout, 10, s_nenner);
2485 mpz_out_str( stdout, 10, s_zaehler);
2486 PrintS(
" = "); mpz_out_str( stdout, 10, sntz);
2487 Print(
" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
2496 if(mpz_cmp_si(ggt,1) != 0)
2498 mpz_gcd(ggt, ggt, sntz);
2503 if(mpz_cmp_si(ggt,1) != 0)
2505 for (j=0; j<nRing; j++)
2507 mpz_divexact(vec[j], vec[j], ggt);
2510 #ifdef NEXT_VECTORS_CC 2511 PrintS(
"\n// gcd of elements of the vector: ");
2512 mpz_out_str( stdout, 10, ggt);
2515 for (j=0; j<nRing; j++)
2517 (*diff_weight)[
j] = mpz_get_si(vec[j]);
2522 for (j=0; j<nRing; j++)
2524 if(mpz_cmp(vec[j], sing_int)>=0)
2529 PrintS(
"\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
2530 mpz_out_str( stdout, 10, vec[j]);
2531 PrintS(
" is greater than 2147483647 (max. integer representation)\n");
2538 delete diff_weight1;
2539 mpz_clear(t_zaehler);
2540 mpz_clear(t_nenner);
2541 mpz_clear(s_zaehler);
2542 mpz_clear(s_nenner);
2547 mpz_clear(deg_w0_p1);
2548 mpz_clear(deg_d0_p1);
2551 mpz_clear(sing_int_half);
2552 mpz_clear(sing_int);
2699 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2701 r->wvhdl[0][i] = (*va)[
i];
2704 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2705 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2706 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2750 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2751 r->wvhdl[1] = (
int*)
omAlloc(nv*
sizeof(
int));
2755 r->wvhdl[0][
i] = (*vb)[
i];
2756 r->wvhdl[1][
i] = (*va)[
i];
2760 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2761 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2762 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2809 r->wvhdl[0] = (
int*)
omAlloc(nv*nv*
sizeof(
int));
2813 for(i=0; i<nv*nv; i++)
2814 r->wvhdl[0][i] = (*va)[
i];
2817 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2818 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2819 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2861 r->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2862 r->wvhdl[1] = (
int*)
omAlloc(nvs*
sizeof(
int));
2865 for(i=0; i<nvs; i++)
2867 r->wvhdl[1][
i] = (*va)[
i];
2871 r->wvhdl[0][
i] = (*vb)[
i];
2874 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2875 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2876 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2919 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2920 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2921 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2957 res->wvhdl[0] = (
int*)
omAlloc(nv*
sizeof(
int));
2959 res->wvhdl[0][i] = (*va)[
i];
2963 res->order = (
int *)
omAlloc(nb *
sizeof(
int *));
2964 res->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2965 res->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
2970 res->block1[0] = nv;
2975 res->block1[1] = nv;
3010 r->order = (
int *)
omAlloc(nb *
sizeof(
int *));
3011 r->block0 = (
int *)
omAlloc0(nb *
sizeof(
int *));
3012 r->block1 = (
int *)
omAlloc0(nb *
sizeof(
int *));
3073 for(i=hilb->
length()-1; i>=0; i--)
3092 poly p,lm,factor1,factor2;
3112 p =
pCopy(Gomega->m[i]);
3113 lm =
pCopy(Gomega->m[j]);
3160 int nwalk=0, endwalks=0, nnwinC=1;
3162 ideal Gomega,
M, F, Gomega1, Gomega2, M1,F1,
result,ssG;
3163 ring newRing, oldRing, TargetRing;
3167 intvec* pert_target_vector;
3172 #ifndef BUCHBERGER_ALG 3178 for(i=nV-1; i>0; i--)
3180 (*last_omega)[
i] = 1;
3182 (*last_omega)[0] = 10000;
3187 if(tp_deg > 1 && tp_deg <= nV)
3204 pert_target_vector = target_weight;
3211 target_weight =
Mivlp(nV);
3224 #ifdef PRINT_VECTORS 3225 MivString(curr_weight, target_weight, next_weight);
3244 if(
MivComp(next_weight, ivNull) == 1)
3252 if(
MivComp(next_weight, target_weight) == 1)
3255 for(i=nV-1; i>=0; i--)
3257 (*extra_curr_weight)[
i] = (*curr_weight)[
i];
3260 for(i=nV-1; i>=0; i--)
3262 (*curr_weight)[
i] = (*next_weight)[
i];
3281 #ifndef BUCHBERGER_ALG 3282 if(isNolVector(curr_weight) == 0)
3290 #endif // BUCHBERGER_ALG 3307 #ifdef BUCHBERGER_ALG 3312 #endif // BUCHBERGER_ALG 3366 Print(
"\n// takes %d steps and calls the recursion of level %d:",
3369 F1 =
LastGB(G,curr_weight, tp_deg-1);
3415 delete target_weight;
3432 for(i=
IDELEMS(G)-1; i>=0; i--)
3435 && (G->m[i]->next!=
NULL)
3436 && (G->m[i]->next->next!=
NULL)
3437 && (G->m[i]->next->next->next!=
NULL)
3438 && (G->m[i]->next->next->next->next!=
NULL) )
3452 for(i=
IDELEMS(G)-1; i>=0; i--)
3469 for(i=
IDELEMS(G)-1; i>=0; i--)
3472 && (G->m[i]->next!=
NULL)
3473 && (G->m[i]->next->next!=
NULL))
3508 for (i=nH-1;i>=0; i--)
3529 for(i=nG-1; i>=0; i--)
3597 int mtmp,
m=(*iva)[0];
3599 for(i=ivMat->
length(); i>=0; i--)
3618 mpz_set_si(ndeg, Trandegreebound(
G)+1);
3624 mpz_init_set_si(maxdeg, Trandegreebound(
G));
3627 mpz_pow_ui(ztmp, maxdeg, 2);
3628 mpz_mul_ui(ztmp, ztmp, 2);
3629 mpz_mul_ui(maxdeg, maxdeg, nV+1);
3630 mpz_add(ndeg, ztmp, maxdeg);
3631 mpz_mul_ui(ndeg, ndeg, m);
3637 #endif //UPPER_BOUND 3639 #ifdef INVEPS_SMALL_IN_TRAN 3640 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
3642 mpz_cdiv_q_ui(ndeg, ndeg, nV);
3648 mpz_init_set(deg_tmp, ndeg);
3650 mpz_t *ivres=( mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3651 mpz_init_set_si(ivres[nV-1],1);
3653 for(i=nV-2; i>=0; i--)
3655 mpz_init_set(ivres[i], deg_tmp);
3656 mpz_mul(deg_tmp, deg_tmp, ndeg);
3659 mpz_t *ivtmp=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3665 mpz_init_set_ui(sing_int, 2147483647);
3674 if( (*ivMat)[i*nV+j] >= 0 )
3676 mpz_mul_ui(ivres[i], ivres[i], (*ivMat)[i*nV+j]);
3680 mpz_mul_ui(ivres[i], ivres[i], -(*ivMat)[i*nV+j]);
3681 mpz_neg(ivres[i], ivres[i]);
3683 mpz_add(ivtmp[j], ivtmp[j], ivres[i]);
3691 (*repr_vector)[
i] = mpz_get_si(ivtmp[i]);
3692 if(mpz_cmp(ivtmp[i], sing_int)>=0)
3699 PrintS(
"\n// ** OVERFLOW in \"Repr.Vector\": ");
3700 mpz_out_str( stdout, 10, ivtmp[i]);
3701 PrintS(
" is greater than 2147483647 (max. integer representation)");
3702 Print(
"\n// So vector[%d] := %d is wrong!!\n",i+1,(*repr_vector)[i]);
3708 ivString(repr_vector,
"repvector");
3709 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3718 mpz_clear(sing_int);
3728 static intvec* TranPertVector_lp(ideal
G)
3742 mpz_set_si(ndeg, Trandegreebound(G)+1);
3748 mpz_init_set_si(maxdeg, Trandegreebound(G));
3751 mpz_pow_ui(ztmp, maxdeg, 2);
3752 mpz_mul_ui(ztmp, ztmp, 2);
3753 mpz_mul_ui(maxdeg, maxdeg, nV+1);
3754 mpz_add(ndeg, ztmp, maxdeg);
3763 #ifdef INVEPS_SMALL_IN_TRAN 3764 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
3765 mpz_cdiv_q_ui(ndeg, ndeg, nV);
3772 mpz_init_set(deg_tmp, ndeg);
3774 mpz_t *ivres=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3775 mpz_init_set_si(ivres[nV-1], 1);
3777 for(i=nV-2; i>=0; i--)
3779 mpz_init_set(ivres[i], deg_tmp);
3780 mpz_mul(deg_tmp, deg_tmp, ndeg);
3784 mpz_init_set_ui(sing_int, 2147483647);
3790 (*repr_vector)[
i] = mpz_get_si(ivres[i]);
3792 if(mpz_cmp(ivres[i], sing_int)>=0)
3798 PrintS(
"\n// ** OVERFLOW in \"Repr.Vector\": ");
3799 mpz_out_str( stdout, 10, ivres[i]);
3800 PrintS(
" is greater than 2147483647 (max. integer representation)");
3801 Print(
"\n// So vector[%d] := %d is wrong!!\n",i+1,(*repr_vector)[i]);
3807 ivString(repr_vector,
"repvector");
3808 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3816 mpz_clear(sing_int);
3833 int degtmp, maxdeg = 0;
3844 mpz_init_set_si(ztmp, maxdeg);
3845 mpz_t *ivres=(mpz_t *)
omAlloc(nV*
sizeof(mpz_t));
3846 mpz_init_set_si(ivres[nV-1], 1);
3848 for(i=nV-2; i>=0; i--)
3850 mpz_init_set(ivres[i], ztmp);
3851 mpz_mul_ui(ztmp, ztmp, maxdeg);
3854 mpz_t *ivtmp=(mpz_t*)
omAlloc(nV*
sizeof(mpz_t));
3862 if((*M)[i*nV+
j] < 0)
3864 mpz_mul_ui(ztmp, ivres[i], -(*M)[i*nV+j]);
3865 mpz_neg(ztmp, ztmp);
3868 mpz_mul_ui(ztmp, ivres[i], (*M)[i*nV+j]);
3870 mpz_add(ivtmp[j], ivtmp[j], ztmp);
3874 mpz_init_set_ui(sing_int, 2147483647);
3880 (*repvector)[
i] = mpz_get_si(ivtmp[i]);
3881 if(mpz_cmp(ivtmp[i], sing_int)>0)
3887 PrintS(
"\n// ** OVERFLOW in \"Repr.Matrix\": ");
3888 mpz_out_str( stdout, 10, ivtmp[i]);
3889 PrintS(
" is greater than 2147483647 (max. integer representation)");
3890 Print(
"\n// So vector[%d] := %d is wrong!!\n",i+1,(*repvector)[i]);
3897 Print(
"\n// %d element(s) of it are overflow!!", ntrue);
3903 mpz_clear(sing_int);
3923 intvec* orig_target_weight,
int tp_deg,
int npwinc)
3930 clock_t tinput = clock();
3933 int nwalk=0, endwalks=0, nnwinC=1;
3935 ideal Gomega,
M, F, Gomega1, Gomega2, M1,F1,
result,ssG;
3936 ring newRing, oldRing, TargetRing;
3943 #ifndef BUCHBERGER_ALG 3949 for(i=nV-1; i>0; i--)
3950 (*last_omega)[
i] = 1;
3951 (*last_omega)[0] = 10000;
3956 if(tp_deg > 1 && tp_deg <= nV)
4027 #ifndef BUCHBERGER_ALG 4028 if(isNolVector(curr_weight) == 0)
4036 #endif // BUCHBERGER_ALG 4053 #ifdef BUCHBERGER_ALG 4058 #endif // BUCHBERGER_ALG 4093 #ifdef PRINT_VECTORS 4094 MivString(curr_weight, target_weight, next_weight);
4099 #ifdef TEST_OVERFLOW 4112 if(
MivComp(next_weight, ivNull) == 1)
4119 if(
MivComp(next_weight, target_weight) == 1)
4129 tproc=tproc+clock()-tinput;
4134 G =
Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4141 for(i=nV-1; i>=0; i--)
4143 (*curr_weight)[
i] = (*next_weight)[
i];
4168 tproc=tproc+clock()-tinput;
4169 F1 =
Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4171 delete target_weight;
4248 clock_t tostd, tproc;
4252 int nwalk=0, endwalks=0;
4254 ideal Gomega,
M, F, Gomega1, Gomega2, M1, F1,
G;
4257 ring newRing, oldRing;
4275 Print(
"\n// Computation of the first std took = %.2f sec",
4276 ((
double) tostd)/1000000);
4366 #ifdef PRINT_VECTORS 4367 MivString(curr_weight, target_weight, next_weight);
4376 #ifdef TEST_OVERFLOW 4377 goto TEST_OVERFLOW_OI;
4396 if(
MivComp(next_weight, ivNull) == 1)
4403 if(
MivComp(next_weight, target_weight) == 1)
4405 if(
MivSame(target_weight, exivlp)==1)
4414 G =
Rec_LastGB(G, curr_weight, target_weight, 2,1);
4422 for(i=nV-1; i>=0; i--)
4425 (*curr_weight)[
i] = (*next_weight)[
i];
4429 #ifdef TEST_OVERFLOW 4476 int weight_rad,
int pert_deg)
4479 target_weight !=
NULL && G->m[0] !=
NULL);
4490 (*curr_weight)[
i] = (*orig_M)[
i];
4493 int k=0,weight_norm;
4500 ideal G_test, G_test1, G_test2;
4508 while(weight_norm == 0)
4512 (*next_weight2)[
i] = rand() % 60000 - 30000;
4513 weight_norm = weight_norm + (*next_weight2)[
i]*(*next_weight2)[
i];
4515 weight_norm = 1 + floor(
sqrt(weight_norm));
4519 if((*next_weight2)[i] < 0)
4521 (*next_weight2)[
i] = 1 + (*curr_weight)[
i] + floor(weight_rad*(*next_weight2)[i]/weight_norm);
4525 (*next_weight2)[
i] = (*curr_weight)[
i] + floor(weight_rad*(*next_weight2)[i]/weight_norm);
4535 found_random_weight =
TRUE;
4547 delete curr_weight1;
4565 if(found_random_weight ==
TRUE)
4574 (*result)[
i] = (*next_weight2)[
i];
4581 (*result)[
i] = (*next_weight1)[
i];
4591 (*result)[
i] = (*next_weight2)[
i];
4598 (*result)[
i] = (*next_weight)[
i];
4610 (*result)[
i] = (*next_weight1)[
i];
4617 (*result)[
i] = (*next_weight)[
i];
4625 if(found_random_weight ==
TRUE)
4631 (*result)[
i] = (*next_weight2)[
i];
4638 (*result)[
i] = (*next_weight)[
i];
4646 (*result)[
i] = (*next_weight)[
i];
4652 delete next_weight2;
4655 if(found_random_weight ==
TRUE)
4662 delete next_weight1;
4669 return next_weight1;
4680 int tp_deg,
int npwinc)
4686 int nwalk=0, endwalks=0, nnwinC=1, nlast = 0;
4687 ideal Gomega,
M, F, Gomega1, Gomega2, M1,F1,
result,ssG;
4688 ring newRing, oldRing, TargetRing;
4691 #ifndef BUCHBERGER_ALG 4695 for(i=nV-1; i>0; i--)
4697 (*last_omega)[
i] = 1;
4699 (*last_omega)[0] = 10000;
4706 if(tp_deg > 1 && tp_deg <= nV)
4766 #ifndef BUCHBERGER_ALG 4767 if(isNolVector(curr_weight) == 0)
4793 #ifdef BUCHBERGER_ALG 4839 #ifdef PRINT_VECTORS 4840 MivString(curr_weight, target_weight, next_weight);
4854 if(
MivComp(next_weight, ivNull) == 1)
4861 if(
MivComp(next_weight, target_weight) == 1)
4869 G =
REC_GB_Mwalk(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4876 for(i=nV-1; i>=0; i--)
4878 (*curr_weight)[
i] = (*next_weight)[
i];
4901 F1 =
REC_GB_Mwalk(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4907 F1 =
REC_GB_Mwalk(F1,curr_weight, orig_target_weight,tp_deg+1,nnwinC);
4910 delete target_weight;
4954 #ifndef BUCHBERGER_ALG 4969 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
4979 ideal Gomega,
M, F, Gomega1, Gomega2, M1, F1,
G;
4981 ring newRing, oldRing;
4984 #ifndef BUCHBERGER_ALG 4988 for(i=nV-1; i>=0; i--)
4989 (*tmp_weight)[
i] = (*curr_weight)[
i];
4993 for(i=nV-1; i>0; i--)
4994 (*last_omega)[
i] = 1;
4995 (*last_omega)[0] = 10000;
5014 tif = tif + clock()-
to;
5022 #ifdef CHECK_IDEAL_MWALK 5023 Print(
"\n// **** Groebnerwalk took %d steps and ", nwalk);
5024 PrintS(
"\n// **** call the rec. Pert. Walk to compute a red GB of:");
5028 if(
MivSame(exivlp, target_weight)==1)
5033 Print(
"\n// time for the last std(Gw) = %.2f sec",
5034 ((
double) (clock()-tim)/1000000));
5069 #ifndef BUCHBERGER_ALG 5070 if(isNolVector(curr_weight) == 0)
5078 #endif // BUCHBERGER_ALG 5094 #ifdef BUCHBERGER_ALG 5100 tstd = tstd + clock() -
to;
5112 tlift = tlift + clock() -
to;
5128 tred = tred + clock() -
to;
5143 tnw = tnw + clock() -
to;
5144 #ifdef PRINT_VECTORS 5145 MivString(curr_weight, target_weight, next_weight);
5152 PrintS(
"\n// ** The computed vector does NOT stay in Cone!!\n");
5170 if(
MivComp(next_weight, ivNull) == 1)
5176 if(
MivComp(next_weight, target_weight) == 1)
5180 for(i=nV-1; i>=0; i--)
5182 (*tmp_weight)[
i] = (*curr_weight)[
i];
5183 (*curr_weight)[
i] = (*next_weight)[
i];
5195 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5207 ring baseRing,
int reduction,
int printout)
5220 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5227 int nV = baseRing->N;
5229 ideal Gomega,
M, F, FF, Gomega1, Gomega2, M1;
5231 ring XXRing = baseRing;
5246 (*curr_weight)[
i] = (*orig_M)[
i];
5247 (*target_weight)[
i] = (*target_M)[
i];
5249 #ifndef BUCHBERGER_ALG 5253 for(i=nV-1; i>0; i--)
5255 (*last_omega)[
i] = 1;
5257 (*last_omega)[0] = 10000;
5260 #ifdef CHECK_IDEAL_MWALK 5267 if(target_M->
length() == nV)
5276 if(orig_M->
length() == nV)
5280 newRing=
VMrRefine(target_weight, curr_weight);
5312 tif = tif + clock()-
to;
5315 #ifdef CHECK_IDEAL_MWALK 5318 idString(Gomega,
"//** Mwalk: Gomega");
5327 PrintS(
"middle of Cone");
5335 #ifndef BUCHBERGER_ALG 5336 if(isNolVector(curr_weight) == 0)
5348 if(orig_M->
length() == nV)
5352 newRing=
VMrRefine(target_weight, curr_weight);
5361 if(target_M->
length() == nV)
5365 newRing=
VMrRefine(target_weight, curr_weight);
5384 #ifndef BUCHBERGER_ALG 5391 tstd = tstd + clock() -
to;
5394 #ifdef CHECK_IDEAL_MWALK 5413 tlift = tlift + clock() -
to;
5415 #ifdef CHECK_IDEAL_MWALK 5429 #ifdef CHECK_IDEAL_MWALK 5456 tnw = tnw + clock() -
to;
5458 #ifdef PRINT_VECTORS 5461 MivString(curr_weight, target_weight, next_weight);
5466 if(
MivComp(curr_weight,next_weight)==1)
5471 if(
MivComp(target_weight,curr_weight) == 1)
5476 for(i=nV-1; i>=0; i--)
5479 (*curr_weight)[
i] = (*next_weight)[
i];
5490 #ifndef BUCHBERGER_ALG 5494 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5500 Print(
"\n//** Mwalk: Groebner Walk took %d steps.\n",
nstep);
5521 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5533 Werror(
"Invalid radius.\n");
5538 if(pert_deg > nV || pert_deg < 1)
5540 Werror(
"Invalid perturbation degree.\n");
5544 ideal Gomega,
M, F,FF, Gomega1, Gomega2, M1;
5557 (*curr_weight)[
i] = (*orig_M)[
i];
5558 (*target_weight)[
i] = (*target_M)[
i];
5561 #ifndef BUCHBERGER_ALG 5565 for(i=nV-1; i>0; i--)
5567 (*last_omega)[
i] = 1;
5569 (*last_omega)[0] = 10000;
5573 if(target_M->
length() == nV)
5581 if(orig_M->
length() == nV)
5584 newRing=
VMrRefine(target_weight, curr_weight);
5606 tif = tif + clock()-
to;
5613 #ifdef CHECK_IDEAL_MWALK 5616 idString(Gomega,
"//** Mrwalk: Gomega");
5630 #ifndef BUCHBERGER_ALG 5631 if(isNolVector(curr_weight) == 0)
5642 if(orig_M->
length() == nV)
5645 newRing=
VMrRefine(target_weight, curr_weight);
5654 if(target_M->
length() == nV)
5657 newRing=
VMrRefine(target_weight, curr_weight);
5671 #ifndef BUCHBERGER_ALG 5678 tstd = tstd + clock() -
to;
5681 #ifdef CHECK_IDEAL_MWALK 5700 tlift = tlift + clock() -
to;
5702 #ifdef CHECK_IDEAL_MWALK 5716 tstd = tstd + clock() -
to;
5719 #ifdef CHECK_IDEAL_MWALK 5746 tnw = tnw + clock() -
to;
5754 tif = tif + clock()-
to;
5764 if(target_M->
length() == nV)
5778 tnw = tnw + clock() -
to;
5786 tif = tif + clock()-
to;
5792 if(
MivComp(next_weight, ivNull) == 1 ||
MivComp(target_weight,curr_weight) == 1)
5800 if(
MivComp(curr_weight,next_weight)==1)
5805 #ifdef PRINT_VECTORS 5808 MivString(curr_weight, target_weight, next_weight);
5812 for(i=nV-1; i>=0; i--)
5814 (*curr_weight)[
i] = (*next_weight)[
i];
5823 #ifndef BUCHBERGER_ALG 5828 Print(
"\n//** Mrwalk: Groebner Walk took %d steps.\n",
nstep);
5831 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw,
nstep);
5865 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5873 int i, ntwC=1, ntestw=1, nV =
currRing->N;
5876 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
5878 Werror(
"Invalid perturbation degree.\n");
5883 ideal Gomega,
M, F, FF,
G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
5884 ring newRing, oldRing, TargetRing;
5888 intvec* orig_target = target_weight;
5889 intvec* pert_target_vector = target_weight;
5892 #ifndef BUCHBERGER_ALG 5899 for(i=nV-1; i>0; i--)
5900 (*last_omega)[
i] = 1;
5901 (*last_omega)[0] = 10000;
5908 if(
MivComp(curr_weight, iv_dp) == 1)
5942 if(op_deg != 1)
delete iv_M_dp;
5947 if(tp_deg > 1 && tp_deg <= nV)
5959 if(
MivSame(target_weight, exivlp) == 1)
5970 pert_target_vector = target_weight;
5976 Print(
"\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
5977 #ifdef PRINT_VECTORS 5978 ivString(curr_weight,
"//** Mpwalk: new current weight");
5979 ivString(target_weight,
"//** Mpwalk: new target weight");
5992 tif = tif + clock()-
to;
5994 #ifdef CHECK_IDEAL_MWALK 5997 idString(Gomega,
"//** Mpwalk: Gomega");
6000 if(reduction == 0 &&
nstep > 1)
6013 if(endwalks ==
TRUE)
6024 #ifndef BUCHBERGER_ALG 6025 if(isNolVector(curr_weight) == 0)
6029 #endif // BUCHBERGER_ALG 6053 PrintS(
"\n// compute a rGB of Gw:\n");
6055 #ifndef BUCHBERGER_ALG 6065 #ifdef BUCHBERGER_ALG 6072 if(endwalks ==
TRUE)
6080 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
6081 ((
double) clock())/1000000 -((
double)tim) /1000000);
6088 tstd=tstd+clock()-
to;
6091 #ifdef CHECK_IDEAL_MWALK 6109 if(endwalks ==
FALSE)
6110 tlift = tlift+clock()-
to;
6114 #ifdef CHECK_IDEAL_MWALK 6136 PrintS(
"\n //** Mpwalk: reduce the Groebner basis.\n");
6143 if(endwalks ==
FALSE)
6144 tred = tred+clock()-
to;
6150 if(endwalks ==
TRUE)
6162 #ifdef PRINT_VECTORS 6165 MivString(curr_weight, target_weight, next_weight);
6178 if(
MivComp(next_weight, ivNull) == 1){
6184 if(
MivComp(next_weight, target_weight) == 1)
6187 for(i=nV-1; i>=0; i--)
6188 (*curr_weight)[
i] = (*next_weight)[
i];
6196 if(
MivSame(orig_target, exivlp) == 1) {
6220 if( ntestw != 1 || ntwC == 0)
6222 if(ntestw != 1 && printout >2)
6224 ivString(pert_target_vector,
"tau");
6225 PrintS(
"\n// ** perturbed target vector doesn't stay in cone!!");
6232 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1){
6241 eF1 =
LastGB(F2, curr_weight, tp_deg-1);
6262 delete target_weight;
6279 Print(
"\n//** Mpwalk: Perturbation Walk took %d steps.\n",
nstep);
6288 int op_deg,
int tp_deg,
int nP,
int reduction,
int printout)
6300 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
6308 int i, ntwC=1, ntestw=1, nV =
currRing->N;
6313 Werror(
"Invalid radius.\n");
6318 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
6320 Werror(
"Invalid perturbation degree.\n");
6326 ideal Gomega,
M, F, FF,
G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
6327 ring newRing, oldRing, TargetRing;
6336 (*curr_weight)[
i] = (*orig_M)[
i];
6337 (*target_weight)[
i] = (*target_M)[
i];
6339 intvec* orig_target = target_weight;
6340 intvec* pert_target_vector = target_weight;
6343 #ifndef BUCHBERGER_ALG 6350 for(i=nV-1; i>0; i--)
6351 (*last_omega)[
i] = 1;
6352 (*last_omega)[0] = 10000;
6357 if(orig_M->
length() == nV)
6359 if(
MivComp(curr_weight, iv_dp) == 1)
6415 if(op_deg != 1)
delete iv_M_dp;
6420 if(target_M->
length() == nV)
6422 if(tp_deg > 1 && tp_deg <= nV)
6431 if(
MivSame(target_weight, exivlp) == 1)
6442 pert_target_vector = target_weight;
6449 if(tp_deg > 1 && tp_deg <= nV)
6459 Print(
"\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6460 ivString(curr_weight,
"//** Mprwalk: new current weight");
6461 ivString(target_weight,
"//** Mprwalk: new target weight");
6469 tif = tif + clock()-
to;
6475 #ifdef CHECK_IDEAL_MWALK 6478 idString(Gomega,
"//** Mprwalk: Gomega");
6482 if(reduction == 0 &&
nstep > 1)
6495 if(endwalks ==
TRUE)
6506 #ifndef BUCHBERGER_ALG 6507 if(isNolVector(curr_weight) == 0)
6511 #endif // BUCHBERGER_ALG 6515 if(target_M->
length() == nV)
6532 if(endwalks ==
TRUE)
6541 PrintS(
"\n// compute a rGB of Gw:\n");
6543 #ifndef BUCHBERGER_ALG 6553 #ifdef BUCHBERGER_ALG 6559 #ifdef CHECK_IDEAL_MWALK 6566 if(endwalks ==
TRUE)
6570 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
6571 ((
double) clock())/1000000 -((
double)tim) /1000000);
6575 tstd=tstd+clock()-
to;
6589 if(endwalks ==
FALSE)
6590 tlift = tlift+clock()-
to;
6594 #ifdef CHECK_IDEAL_MWALK 6616 PrintS(
"\n //** Mprwalk: reduce the Groebner basis.\n");
6623 if(endwalks ==
FALSE)
6624 tred = tred+clock()-
to;
6631 if(endwalks ==
TRUE)
6640 tnw = tnw + clock() -
to;
6649 tif = tif + clock()-
to;
6657 Print(
"\n Mpwalk: there is a polynomial in Gomega with at least 3 monomials.\n");
6661 if(target_M->
length() == nV)
6674 tnw = tnw + clock() -
to;
6682 tif = tif + clock()-
to;
6687 #ifdef PRINT_VECTORS 6690 MivString(curr_weight, target_weight, next_weight);
6702 if(
MivComp(next_weight, ivNull) == 1){
6708 if(
MivComp(next_weight, target_weight) == 1)
6711 for(i=nV-1; i>=0; i--)
6712 (*curr_weight)[
i] = (*next_weight)[
i];
6720 if(target_M->
length() == nV)
6722 if(
MivSame(orig_target, exivlp) == 1)
6745 if(ntestw != 1 || ntwC == 0)
6747 if(ntestw != 1 && printout > 2)
6749 #ifdef PRINT_VECTORS 6750 ivString(pert_target_vector,
"tau");
6752 PrintS(
"\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
6761 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1 || target_M->
length() != nV)
6765 PrintS(
"\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
6774 PrintS(
"\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
6778 eF1 =
LastGB(F2, curr_weight, tp_deg-1);
6803 delete target_weight;
6821 Print(
"\n//** Mprwalk: Perturbation Walk took %d steps.\n",
nstep);
6838 (*ivM)[i*nV +
j] = 1;
6856 Print(
"\n\n// Entering the %d-th recursion:", nlev);
6859 ring new_ring, testring;
6861 ideal Gomega, Gomega1, Gomega2, FF, F, F1, Gresult, Gresult1, G1, Gt;
6864 #ifndef BUCHBERGER_ALG 6873 for(i = nV -1; i>=0; i--)
6875 (*omtmp)[
i] = (*ivtarget)[
i];
6881 for(i=nV-1; i>0; i--)
6882 (*last_omega)[
i] = 1;
6883 (*last_omega)[0] = 10000;
6886 for(i=0; i<nV; i++) {
6887 if(Xsigma->
length() == nV)
6888 (*omega)[
i] = (*Xsigma)[
i];
6890 (*omega)[
i] = (*Xsigma)[(nV*(nlev-1))+
i];
6892 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+i];
6895 if(nlev == 1)
Xcall = 1;
6902 #ifdef FIRST_STEP_FRACTAL 6905 if((nlev == 1 &&
Xcall == 0) || (nlev == 2 &&
Xngleich == 1))
6915 NEXT_VECTOR_FRACTAL:
6928 if (
MivComp(next_vect, omega2) == 1)
6934 Print(
"\n//** rec_fractal_call: Perturb the both vectors with degree %d.",nlev);
6941 if(ivtarget->
length() == nV)
6960 if(ivtarget->
length() == nV)
6979 for(i=nV-1; i>=0; i--) {
6980 (*omega2)[
i] = (*Xtau)[nV+
i];
6981 (*omega)[
i] = (*Xsigma)[nV+
i];
6996 #ifdef PRINT_VECTORS 6999 MivString(omega, omega2, next_vect);
7009 if(ivtarget->
length() == nV)
7024 #ifdef TEST_OVERFLOW 7026 Gt =
NULL;
return(Gt);
7030 Print(
"\n//** rec_fractal_call: Applying Buchberger's algorithm in ring r = %s;",
7047 Print(
"\n//** rec_fractal_call: Overflow. (4) Leaving the %d-th recursion with %d steps.\n",
7065 if (
MivComp(next_vect, XivNull) == 1)
7067 if(ivtarget->
length() == nV)
7092 Print(
"\n//** rec_fractal_call: Correct cone. (5) Leaving the %d-th recursion with %d steps.\n",
7097 idString(Gt,
"//** rec_fractal_call: Gt");
7105 Print(
"\n//** rec_fractal_call: Wrong cone. Tau doesn't stay in the correct cone.\n");
7108 #ifndef MSTDCC_FRACTAL 7110 if(ivtarget->
length() == nV)
7118 #ifdef TEST_OVERFLOW 7120 Gt =
NULL;
return(Gt);
7123 if(
MivSame(Xtau, Xtautmp) == 1)
7127 Print(
"\n//** rec_fractal_call: Updated vectors are equal to the old vectors.\n");
7130 goto FRACTAL_MSTDCC;
7136 for(i=nV-1; i>=0; i--)
7137 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+i];
7142 goto NEXT_VECTOR_FRACTAL;
7148 Print(
"\n//** rec_fractal_call: Wrong cone. Applying Buchberger's algorithm in ring = %s.\n",
7161 if(ivtarget->
length() == nV)
7185 if(ivtarget->
length() == nV)
7204 Print(
"\n//** rec_fractal_call: Vectors updated. (6) Leaving the %d-th recursion with %d steps.\n",
7216 for(i=nV-1; i>=0; i--) {
7218 (*omega)[
i] = (*next_vect)[
i];
7229 #ifdef CHECK_IDEAL_MWALK 7232 idString(Gomega,
"//** rec_fractal_call: Gomega");
7246 goto NEXT_VECTOR_FRACTAL;
7250 #ifndef BUCHBERGER_ALG 7251 if(isNolVector(omega) == 0)
7257 if(ivtarget->
length() == nV)
7280 Print(
"\n//** rec_fractal_call: Maximal recursion depth.\n");
7285 #ifdef BUCHBERGER_ALG 7301 #ifdef CHECK_IDEAL_MWALK 7304 idString(Gresult,
"//** rec_fractal_call: M");
7321 #ifdef CHECK_IDEAL_MWALK 7324 idString(F,
"//** rec_fractal_call: F");
7353 int weight_rad,
int reduction,
int printout)
7359 ring new_ring, testring;
7361 ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt;
7363 #ifndef BUCHBERGER_ALG 7375 for(
i = nV -1;
i>=0;
i--)
7377 (*omtmp)[
i] = (*ivtarget)[
i];
7381 for(
i=nV-1;
i>0;
i--)
7382 (*last_omega)[
i] = 1;
7383 (*last_omega)[0] = 10000;
7386 for(
i=0;
i<nV;
i++) {
7387 if(Xsigma->
length() == nV)
7388 (*omega)[
i] = (*Xsigma)[
i];
7390 (*omega)[
i] = (*Xsigma)[(nV*(nlev-1))+
i];
7392 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+
i];
7395 if(nlev == 1)
Xcall = 1;
7402 #ifdef FIRST_STEP_FRACTAL 7407 if((nlev == 1 &&
Xcall == 0) || (nlev == 2 &&
Xngleich == 1))
7417 NEXT_VECTOR_FRACTAL:
7430 PrintS(
"\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n");
7457 if (
MivComp(next_vect, omega2) == 1)
7463 Print(
"\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev);
7468 if(ivtarget->
length() == nV)
7487 if(ivtarget->
length() == nV)
7503 if(ivtarget->
length() > nV)
7511 for(
i=nV-1;
i>=0;
i--)
7513 (*omega2)[
i] = (*Xtau)[nV+
i];
7514 (*omega)[
i] = (*Xsigma)[nV+
i];
7554 #ifdef PRINT_VECTORS 7557 MivString(omega, omega2, next_vect);
7568 if(ivtarget->
length() == nV)
7587 #ifdef TEST_OVERFLOW 7594 Print(
"\n//** rec_r_fractal_call: applying Buchberger's algorithm in ring r = %s;",
7611 Print(
"\n//** rec_r_fractal_call: (1) Leaving the %d-th recursion with %d steps.\n",
7626 if (
MivComp(next_vect, XivNull) == 1)
7630 if(ivtarget->
length() == nV)
7655 Print(
"\n//** rec_r_fractal_call: (2) Leaving the %d-th recursion with %d steps.\n",
7665 Print(
"\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n");
7668 #ifndef MSTDCC_FRACTAL 7669 #ifdef PRINT_VECTORS 7676 if(ivtarget->
length() == nV)
7684 #ifdef TEST_OVERFLOW 7686 Gt =
NULL;
return(Gt);
7689 if(
MivSame(Xtau, Xtautmp) == 1)
7693 goto FRACTAL_MSTDCC;
7698 #ifdef PRINT_VECTORS 7705 for(
i=nV-1;
i>=0;
i--)
7706 (*omega2)[
i] = (*Xtau)[(nlev-1)*nV+
i];
7712 goto NEXT_VECTOR_FRACTAL;
7718 Print(
"\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n",
7731 if(ivtarget->
length() == nV)
7755 if(ivtarget->
length() == nV)
7774 Print(
"\n//** rec_r_fractal_call: (3) Leaving the %d-th recursion with %d steps.\n",
7786 for(
i=nV-1;
i>=0;
i--)
7788 (*altomega)[
i] = (*omega)[
i];
7789 (*omega)[
i] = (*next_vect)[
i];
7802 #ifdef CHECK_IDEAL_MWALK 7805 idString(Gomega,
"//** rec_r_fractal_call: Gomega");
7819 goto NEXT_VECTOR_FRACTAL;
7823 #ifndef BUCHBERGER_ALG 7824 if(isNolVector(omega) == 0)
7829 if(ivtarget->
length() == nV)
7853 #ifdef BUCHBERGER_ALG 7869 #ifdef CHECK_IDEAL_MWALK 7872 idString(Gresult,
"//** rec_r_fractal_call: M");
7889 #ifdef CHECK_IDEAL_MWALK 7892 idString(F,
"//** rec_r_fractal_call: F");
7950 XivNull =
new intvec(nV);
7951 Xivinput = ivtarget;
7965 #ifdef FIRST_STEP_FRACTAL 7967 for(i=
IDELEMS(Gw)-1; i>=0; i--)
7970 && (Gw->m[i]->next!=
NULL)
7971 && (Gw->m[i]->next->next!=
NULL))
7975 if(ivstart->
length() == nV)
7977 if(
MivSame(ivstart, iv_dp) != 1)
8002 if(ivtarget->
length() == nV)
8004 if(
MivComp(ivtarget, Xivlp) != 1)
8042 if(ivtarget->
length() == nV)
8092 Print(
"\n// the numbers of Overflow_Error (%d)",
nnflow);
8109 int weight_rad,
int reduction,
int printout)
8115 Werror(
"Invalid radius.\n");
8137 XivNull =
new intvec(nV);
8138 Xivinput = ivtarget;
8152 #ifdef FIRST_STEP_FRACTAL 8154 for(i=
IDELEMS(Gw)-1; i>=0; i--)
8157 && (Gw->m[i]->next!=
NULL)
8158 && (Gw->m[i]->next->next!=
NULL))
8162 if(ivstart->
length() == nV)
8164 if(
MivSame(ivstart, iv_dp) != 1)
8189 if(ivtarget->
length() == nV)
8191 if(
MivComp(ivtarget, Xivlp) != 1)
8229 if(ivtarget->
length() == nV)
8279 Print(
"\n// the numbers of Overflow_Error (%d)",
nnflow);
8295 clock_t mtim = clock();
8302 clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
8304 clock_t tinput = clock();
8306 int nsteppert=0,
i, nV =
currRing->N, nwalk=0, npert_tmp=0;
8307 int *npert=(
int*)
omAlloc(2*nV*
sizeof(
int));
8308 ideal Gomega,
M,F, G1, Gomega1, Gomega2, M1, F1;
8310 ring newRing, oldRing, lpRing;
8318 int nGB, endwalks = 0, nwalkpert=0, npertstep=0;
8321 #ifndef BUCHBERGER_ALG 8326 for(
i=nV-1;
i>0;
i--)
8327 (*last_omega)[
i] = 1;
8328 (*last_omega)[0] = 10000;
8332 for(
i=nV-1;
i>=0;
i--)
8333 (*target_weight)[
i] = (*target_tmp)[
i];
8340 if(
MivComp(curr_weight, iv_dp) == 1)
8354 #ifdef REPRESENTATION_OF_SIGMA 8360 if(
MivComp(curr_weight, iv_dp) == 1)
8361 MDp = MatrixOrderdp(nV);
8365 curr_weight = RepresentationMatrix_Dp(G, MDp);
8379 tostd=tostd+clock()-
to;
8381 goto COMPUTE_NEW_VECTOR;
8396 #ifndef BUCHBERGER_ALG 8397 if(isNolVector(curr_weight) == 0)
8401 #endif // BUCHBERGER_ALG 8416 #ifdef BUCHBERGER_ALG 8421 #endif // BUCHBERGER_ALG 8422 tstd=tstd+clock()-
to;
8434 tlift=tlift+clock()-
to;
8447 tred=tred+clock()-
to;
8459 #ifdef PRINT_VECTORS 8460 MivString(curr_weight, target_weight, next_weight);
8472 OMEGA_OVERFLOW_TRAN_NEW:
8475 #ifdef TEST_OVERFLOW 8484 if(
MivSame(target_tmp, iv_lp) == 1)
8500 if(nP == 0 ||
MivSame(target_tmp, iv_lp) == 0){
8509 G =
LastGB(G1, curr_weight, nV-1);
8515 npert[endwalks]=nwalk-npert_tmp;
8524 if(
MivComp(next_weight, target_weight) == 1 ||
8525 MivComp(next_weight, curr_weight) == 1 )
8531 npert[endwalks]=nwalk-npert_tmp;
8537 if(endwalks == 1 &&
MivComp(next_weight, curr_weight) == 1){
8544 if(
MivSame(target_tmp, iv_lp) == 1)
8591 if(p->next !=
NULL &&
8592 p->next->next !=
NULL &&
8593 p->next->next->next !=
NULL)
8598 (*vector_tmp)[
i] = (*target_weight)[
i];
8600 delete target_weight;
8603 if(
MivComp(vector_tmp, target_weight)==1)
8608 goto OMEGA_OVERFLOW_TRAN_NEW;
8615 goto OMEGA_OVERFLOW_TRAN_NEW;
8625 if(plength3 ==
FALSE)
8651 goto COMPUTE_NEW_VECTOR;
8655 for(
i=nV-1;
i>=0;
i--)
8656 (*curr_weight)[
i] = (*next_weight)[
i];
8660 #ifdef TEST_OVERFLOW 8691 ideal TranMrImprovwalk(ideal
G,
intvec* curr_weight,
intvec* target_tmp,
int nP,
int weight_rad,
int pert_deg)
8694 clock_t mtim = clock();
8701 clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
8703 clock_t tinput = clock();
8705 int nsteppert=0,
i, nV =
currRing->N, nwalk=0, npert_tmp=0;
8706 int *npert=(
int*)
omAlloc(2*nV*
sizeof(
int));
8707 ideal Gomega,
M,F, G1, Gomega1, Gomega2, M1, F1;
8709 ring newRing, oldRing, lpRing;
8717 int weight_norm, nGB, endwalks = 0, nwalkpert=0, npertstep=0;
8720 #ifndef BUCHBERGER_ALG 8725 for(
i=nV-1;
i>0;
i--)
8727 (*last_omega)[
i] = 1;
8729 (*last_omega)[0] = 10000;
8733 for(
i=nV-1;
i>=0;
i--)
8735 (*target_weight)[
i] = (*target_tmp)[
i];
8742 if(
MivComp(curr_weight, iv_dp) == 1)
8763 #ifdef REPRESENTATION_OF_SIGMA 8769 if(
MivComp(curr_weight, iv_dp) == 1)
8771 MDp = MatrixOrderdp(nV);
8777 curr_weight = RepresentationMatrix_Dp(
G, MDp);
8795 tostd=tostd+clock()-
to;
8797 goto COMPUTE_NEW_VECTOR;
8812 #ifndef BUCHBERGER_ALG 8813 if(isNolVector(curr_weight) == 0)
8821 #endif // BUCHBERGER_ALG 8839 #ifdef BUCHBERGER_ALG 8845 tstd=tstd+clock()-
to;
8856 tlift=tlift+clock()-
to;
8869 tred=tred+clock()-
to;
8957 #ifdef PRINT_VECTORS 8958 MivString(curr_weight, target_weight, next_weight);
8970 OMEGA_OVERFLOW_TRAN_NEW:
8973 #ifdef TEST_OVERFLOW 8977 #ifdef CHECK_IDEAL_MWALK 8982 if(
MivSame(target_tmp, iv_lp) == 1)
9009 if(nP == 0 ||
MivSame(target_tmp, iv_lp) == 0)
9020 G =
LastGB(G1, curr_weight, nV-1);
9026 npert[endwalks]=nwalk-npert_tmp;
9035 if(
MivComp(next_weight, target_weight) == 1 ||
MivComp(next_weight, curr_weight) == 1 )
9041 npert[endwalks]=nwalk-npert_tmp;
9047 if(endwalks == 1 &&
MivComp(next_weight, curr_weight) == 1)
9055 if(
MivSame(target_tmp, iv_lp) == 1)
9111 if(p->next !=
NULL &&
9112 p->next->next !=
NULL &&
9113 p->next->next->next !=
NULL)
9119 (*vector_tmp)[
i] = (*target_weight)[
i];
9121 delete target_weight;
9124 if(
MivComp(vector_tmp, target_weight)==1)
9129 goto OMEGA_OVERFLOW_TRAN_NEW;
9136 goto OMEGA_OVERFLOW_TRAN_NEW;
9146 if(plength3 ==
FALSE)
9172 goto COMPUTE_NEW_VECTOR;
9176 for(
i=nV-1;
i>=0;
i--)
9178 (*curr_weight)[
i] = (*next_weight)[
i];
9182 #ifdef TEST_OVERFLOW 9195 Print(
"\n// Computation took %d steps and %.2f sec", nwalk, ((
double) (clock()-mtim)/1000000));
9197 TimeStringFractal(tinput, tostd, tif, tstd, textra, tlift, tred, tnw);
9215 clock_t tinput=clock();
9219 if(tp_deg < 1 || tp_deg > nV)
9221 Werror(
"Invalid perturbation degree.\n");
9225 int nwalk=0, endwalks=0, ntestwinC=1;
9226 int tp_deg_tmp = tp_deg;
9227 ideal Gomega,
M, F,
G, M1, F1, Gomega1, Gomega2, G1;
9228 ring newRing, oldRing, TargetRing;
9261 target_weight =
Mivlp(nV);
9271 if(tp_deg != tp_deg_tmp)
9281 #ifndef BUCHBERGER_ALG 9286 for(i=nV-1; i>0; i--)
9288 (*last_omega)[
i] = 1;
9290 (*last_omega)[0] = 10000;
9309 #ifndef BUCHBERGER_ALG 9310 if(isNolVector(curr_weight) == 0)
9341 #ifdef BUCHBERGER_ALG 9346 #endif // BUCHBERGER_ALG 9384 #ifdef PRINT_VECTORS 9385 MivString(curr_weight, target_weight, next_weight);
9393 tproc = tproc+clock()-tinput;
9405 if(
MivComp(next_weight, ivNull) == 1)
9411 if(
MivComp(next_weight, target_weight) == 1)
9415 for(i=nV-1; i>=0; i--)
9418 (*curr_weight)[
i] = (*next_weight)[
i];
9452 tproc = tproc+clock()-tinput;
9464 delete target_weight;
9486 clock_t tostd, tproc;
9490 int nwalk=0, endwalks=0;
9491 int op_tmp = op_deg;
9492 ideal Gomega,
M, F,
G, Gomega1, Gomega2, M1, F1;
9493 ring newRing, oldRing;
9500 #ifndef BUCHBERGER_ALG 9503 intvec* cw_tmp = curr_weight;
9507 for(i=nV-1; i>0; i--)
9509 (*last_omega)[
i] = 1;
9511 (*last_omega)[0] = 10000;
9523 if(
MivComp(curr_weight, iv_dp) == 1)
9526 if(op_tmp == op_deg)
9538 if(op_tmp == op_deg)
9562 curr_weight = cw_tmp;
9593 for(i=nV-1; i>=0; i--)
9594 (*curr_weight)[
i] = (*extra_curr_weight)[
i];
9595 delete extra_curr_weight;
9601 #ifndef BUCHBERGER_ALG 9602 if(isNolVector(curr_weight) == 0)
9610 #endif // BUCHBERGER_ALG 9628 #ifdef BUCHBERGER_ALG 9633 #endif // BUCHBERGER_ALG 9671 #ifdef PRINT_VECTORS 9672 MivString(curr_weight, target_weight, next_weight);
9695 if(
MivComp(next_weight, ivNull) == 1)
9702 if(
MivComp(next_weight, target_weight) == 1)
9704 if(tp_deg == 1 ||
MivSame(target_weight, exivlp) == 0)
9724 for(i=nV-1; i>=0; i--)
9727 (*curr_weight)[
i] = (*next_weight)[
i];
static ideal MLifttwoIdeal(ideal Gw, ideal M, ideal G)
void id_Normalize(ideal I, const ring r)
normialize all polys in id
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)
#define idDelete(H)
delete an ideal
ideal Mpwalk(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP, int reduction, int printout)
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 ideal rec_r_fractal_call(ideal G, int nlev, intvec *ivtarget, int weight_rad, int reduction, int printout)
static ring VMatrDefault(intvec *va)
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)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
intvec * ivCopy(const intvec *o)
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
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 ring VMatrRefine(intvec *va, intvec *vb)
#define pEqualPolys(p1, p2)
poly singclap_pdivide(poly f, poly g, const ring r)
void Set_Error(BOOLEAN f)
int(* posInT)(const TSet T, const int tl, LObject &h)
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 int MivAbsMaxArg(intvec *vec)
static void cancel(mpz_t zaehler, mpz_t nenner)
intvec * MPertVectorslp(ideal G, intvec *ivtarget, int pdeg)
ideal Mfwalk(ideal G, intvec *ivstart, intvec *ivtarget, int reduction, int printout)
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)
return the maximal component number found in any polynomial in s
static int islengthpoly2(ideal G)
const CanonicalForm CFMap CFMap & N
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)
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
static ideal idHeadCC(ideal h)
int M3ivSame(intvec *temp, intvec *u, intvec *v)
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
ideal Mwalk(ideal Go, intvec *orig_M, intvec *target_M, ring baseRing, int reduction, int printout)
gmp_float sqrt(const gmp_float &a)
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
static intvec * MwalkNextWeightCC(intvec *curr_weight, intvec *target_weight, ideal G)
#define pIsConstant(p)
like above, except that Comp might be != 0
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)
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)
gives an ideal/module the minimal possible size
static ideal MstdhomCC(ideal G)
static intvec * MWalkRandomNextWeight(ideal G, intvec *orig_M, intvec *target_weight, int weight_rad, int pert_deg)
static ideal rec_fractal_call(ideal G, int nlev, intvec *ivtarget, int reduction, int printout)
#define rHasLocalOrMixedOrdering_currRing()
void rChangeCurrRing(ring r)
static void DefRingParlp(void)
ideal idInit(int idsize, int rank)
initialise an ideal / module
static ideal MstdCC(ideal G)
static int isNegNolVector(intvec *hilb)
const Variable & v
< [in] a sqrfree bivariate poly
static long gcd(const long a, const long b)
static int lengthpoly(ideal G)
static intvec * MExpPol(poly f)
static void DefRingPar(intvec *va)
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
static ideal middleOfCone(ideal G, ideal Gomega)
void reduction(LList *sPolyList, CListOld *critPairs, LList *gPrev, RList *rules, LTagList *lTag, RTagList *rTag, ideal gbPrev, PList *rejectedGBList, int plus)
void rDelete(ring r)
unconditionally deletes fields in 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)
returns the ideals of initial terms
void updateS(BOOLEAN toT, kStrategy strat)
static void idString(ideal L, const char *st)
intvec * MivMatrixOrderdp(int nV)
#define SI_SAVE_OPT(A, B)
void completeReduce(kStrategy strat, BOOLEAN withT)
ideal MAltwalk2(ideal Go, 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)
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)
static int maxlengthpoly(ideal G)
static intset initec(int maxnr)
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)
void initEcartNormal(TObject *h)
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
ideal MwalkAlt(ideal Go, intvec *curr_weight, intvec *target_weight)
static ideal idVec2Ideal(poly vec)
static void ivString(intvec *iv, const char *ch)
ideal MwalkInitialForm(ideal G, intvec *ivw)
ideal Mfrwalk(ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad, int reduction, int printout)
static ring VMrRefine(intvec *va, intvec *vb)
void Werror(const char *fmt,...)
intvec * MivMatrixOrderlp(int nV)
static ring VMrDefault(intvec *va)
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
#define pCopy(p)
return a copy of the poly
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
static int * initS_2_R(int maxnr)