Benchmark with integer 16 bits coefficients.
#include <iostream>
using namespace F4;
using namespace std;
int F4::VERBOSE=0;
#ifdef USE_OPENMP
int F4::NB_THREAD=min(8, omp_get_num_procs());
#else
int F4::NB_THREAD=1;
#endif
int modulo=251;
int cyclic6F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# CYCLIC 6 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polCyclic6;
polCyclic6.emplace_back("x0+x1+x2+x3+x4+x5");
polCyclic6.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x0*x5+x4*x5");
polCyclic6.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x0*x1*x5+x0*x4*x5+x3*x4*x5");
polCyclic6.emplace_back("x0*x1*x2*x3+x1*x2*x3*x4+x0*x1*x2*x5+x0*x1*x4*x5+x0*x3*x4*x5+x2*x3*x4*x5");
polCyclic6.emplace_back("x0*x1*x2*x3*x4+x0*x1*x2*x3*x5+x0*x1*x2*x4*x5+x0*x1*x3*x4*x5+x0*x2*x3*x4*x5+x1*x2*x3*x4*x5");
polCyclic6.emplace_back("x0*x1*x2*x3*x4*x5-1");
nbGen=cyclic6.f4();
if(magma)
{
cyclic6.printReducedGroebnerBasis("cyclic6", modulo);
}
return nbGen;
}
int cyclic7F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# CYCLIC 7 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polCyclic7;
polCyclic7.emplace_back("x0+x1+x2+x3+x4+x5+x6");
polCyclic7.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x4*x5+x0*x6+x5*x6");
polCyclic7.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x3*x4*x5+x0*x1*x6+x0*x5*x6+x4*x5*x6");
polCyclic7.emplace_back("x0*x1*x2*x3+x1*x2*x3*x4+x2*x3*x4*x5+x0*x1*x2*x6+x0*x1*x5*x6+x0*x4*x5*x6+x3*x4*x5*x6");
polCyclic7.emplace_back("x0*x1*x2*x3*x4+x1*x2*x3*x4*x5+x0*x1*x2*x3*x6+x0*x1*x2*x5*x6+x0*x1*x4*x5*x6+x0*x3*x4*x5*x6+x2*x3*x4*x5*x6");
polCyclic7.emplace_back("x0*x1*x2*x3*x4*x5+x0*x1*x2*x3*x4*x6+x0*x1*x2*x3*x5*x6+x0*x1*x2*x4*x5*x6+x0*x1*x3*x4*x5*x6+x0*x2*x3*x4*x5*x6+x1*x2*x3*x4*x5*x6");
polCyclic7.emplace_back("x0*x1*x2*x3*x4*x5*x6-1");
nbGen=cyclic7.f4();
if(magma)
{
cyclic7.printReducedGroebnerBasis("cyclic7", modulo);
}
return nbGen;
}
int cyclic8F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# CYCLIC 8 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polCyclic8;
polCyclic8.emplace_back("x0+x1+x2+x3+x4+x5+x6+x7");
polCyclic8.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x4*x5+x5*x6+x0*x7+x6*x7");
polCyclic8.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x3*x4*x5+x4*x5*x6+x0*x1*x7+x0*x6*x7+x5*x6*x7");
polCyclic8.emplace_back("x0*x1*x2*x3+x1*x2*x3*x4+x2*x3*x4*x5+x3*x4*x5*x6+x0*x1*x2*x7+x0*x1*x6*x7+x0*x5*x6*x7+x4*x5*x6*x7");
polCyclic8.emplace_back("x0*x1*x2*x3*x4+x1*x2*x3*x4*x5+x2*x3*x4*x5*x6+x0*x1*x2*x3*x7+x0*x1*x2*x6*x7+x0*x1*x5*x6*x7+x0*x4*x5*x6*x7+x3*x4*x5*x6*x7");
polCyclic8.emplace_back("x0*x1*x2*x3*x4*x5+x1*x2*x3*x4*x5*x6+x0*x1*x2*x3*x4*x7+x0*x1*x2*x3*x6*x7+x0*x1*x2*x5*x6*x7+x0*x1*x4*x5*x6*x7+x0*x3*x4*x5*x6*x7+x2*x3*x4*x5*x6*x7");
polCyclic8.emplace_back("x0*x1*x2*x3*x4*x5*x6+x0*x1*x2*x3*x4*x5*x7+x0*x1*x2*x3*x4*x6*x7+x0*x1*x2*x3*x5*x6*x7+x0*x1*x2*x4*x5*x6*x7+x0*x1*x3*x4*x5*x6*x7+x0*x2*x3*x4*x5*x6*x7+x1*x2*x3*x4*x5*x6*x7");
polCyclic8.emplace_back("x0*x1*x2*x3*x4*x5*x6*x7-1");
nbGen=cyclic8.f4();
if(magma)
{
cyclic8.printReducedGroebnerBasis("cyclic8", modulo);
}
return nbGen;
}
int cyclic9F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# CYCLIC 9 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polCyclic9;
polCyclic9.emplace_back("x0+x1+x2+x3+x4+x5+x6+x7+x8");
polCyclic9.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x4*x5+x5*x6+x6*x7+x0*x8+x7*x8");
polCyclic9.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x3*x4*x5+x4*x5*x6+x5*x6*x7+x0*x1*x8+x0*x7*x8+x6*x7*x8");
polCyclic9.emplace_back("x0*x1*x2*x3+x1*x2*x3*x4+x2*x3*x4*x5+x3*x4*x5*x6+x4*x5*x6*x7+x0*x1*x2*x8+x0*x1*x7*x8+x0*x6*x7*x8+x5*x6*x7*x8");
polCyclic9.emplace_back("x0*x1*x2*x3*x4+x1*x2*x3*x4*x5+x2*x3*x4*x5*x6+x3*x4*x5*x6*x7+x0*x1*x2*x3*x8+x0*x1*x2*x7*x8+x0*x1*x6*x7*x8+x0*x5*x6*x7*x8+x4*x5*x6*x7*x8");
polCyclic9.emplace_back("x0*x1*x2*x3*x4*x5+x1*x2*x3*x4*x5*x6+x2*x3*x4*x5*x6*x7+x0*x1*x2*x3*x4*x8+x0*x1*x2*x3*x7*x8+x0*x1*x2*x6*x7*x8+x0*x1*x5*x6*x7*x8+x0*x4*x5*x6*x7*x8+x3*x4*x5*x6*x7*x8");
polCyclic9.emplace_back("x0*x1*x2*x3*x4*x5*x6+x1*x2*x3*x4*x5*x6*x7+x0*x1*x2*x3*x4*x5*x8+x0*x1*x2*x3*x4*x7*x8+x0*x1*x2*x3*x6*x7*x8+x0*x1*x2*x5*x6*x7*x8+x0*x1*x4*x5*x6*x7*x8+x0*x3*x4*x5*x6*x7*x8+x2*x3*x4*x5*x6*x7*x8");
polCyclic9.emplace_back("x0*x1*x2*x3*x4*x5*x6*x7+x0*x1*x2*x3*x4*x5*x6*x8+x0*x1*x2*x3*x4*x5*x7*x8+x0*x1*x2*x3*x4*x6*x7*x8+x0*x1*x2*x3*x5*x6*x7*x8+x0*x1*x2*x4*x5*x6*x7*x8+x0*x1*x3*x4*x5*x6*x7*x8+x0*x2*x3*x4*x5*x6*x7*x8+x1*x2*x3*x4*x5*x6*x7*x8");
polCyclic9.emplace_back("x0*x1*x2*x3*x4*x5*x6*x7*x8-1");
nbGen=cyclic9.f4();
if(magma)
{
cyclic9.printReducedGroebnerBasis("cyclic9", modulo);
}
return nbGen;
}
int katsura9F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# KATSURA 9 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polKatsura9;
polKatsura9.emplace_back("x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8-1");
polKatsura9.emplace_back("x0^2+2*x1^2+2*x2^2+2*x3^2+2*x4^2+2*x5^2+2*x6^2+2*x7^2+2*x8^2-x0");
polKatsura9.emplace_back("2*x0*x1+2*x1*x2+2*x2*x3+2*x3*x4+2*x4*x5+2*x5*x6+2*x6*x7+2*x7*x8-x1");
polKatsura9.emplace_back("x1^2+2*x0*x2+2*x1*x3+2*x2*x4+2*x3*x5+2*x4*x6+2*x5*x7+2*x6*x8-x2");
polKatsura9.emplace_back("2*x1*x2+2*x0*x3+2*x1*x4+2*x2*x5+2*x3*x6+2*x4*x7+2*x5*x8-x3");
polKatsura9.emplace_back("x2^2+2*x1*x3+2*x0*x4+2*x1*x5+2*x2*x6+2*x3*x7+2*x4*x8-x4");
polKatsura9.emplace_back("2*x2*x3+2*x1*x4+2*x0*x5+2*x1*x6+2*x2*x7+2*x3*x8-x5");
polKatsura9.emplace_back("x3^2+2*x2*x4+2*x1*x5+2*x0*x6+2*x1*x7+2*x2*x8-x6");
polKatsura9.emplace_back("2*x3*x4+2*x2*x5+2*x1*x6+2*x0*x7+2*x1*x8-x7");
nbGen=katsura9.f4();
if(magma)
{
katsura9.printReducedGroebnerBasis("katsura9", modulo);
}
return nbGen;
}
int katsura10F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# KATSURA 10 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polKatsura10;
polKatsura10.emplace_back("x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8+2*x9-1");
polKatsura10.emplace_back("x0^2+2*x1^2+2*x2^2+2*x3^2+2*x4^2+2*x5^2+2*x6^2+2*x7^2+2*x8^2+2*x9^2-x0");
polKatsura10.emplace_back("2*x0*x1+2*x1*x2+2*x2*x3+2*x3*x4+2*x4*x5+2*x5*x6+2*x6*x7+2*x7*x8+2*x8*x9-x1");
polKatsura10.emplace_back("x1^2+2*x0*x2+2*x1*x3+2*x2*x4+2*x3*x5+2*x4*x6+2*x5*x7+2*x6*x8+2*x7*x9-x2");
polKatsura10.emplace_back("2*x1*x2+2*x0*x3+2*x1*x4+2*x2*x5+2*x3*x6+2*x4*x7+2*x5*x8+2*x6*x9-x3");
polKatsura10.emplace_back("x2^2+2*x1*x3+2*x0*x4+2*x1*x5+2*x2*x6+2*x3*x7+2*x4*x8+2*x5*x9-x4");
polKatsura10.emplace_back("2*x2*x3+2*x1*x4+2*x0*x5+2*x1*x6+2*x2*x7+2*x3*x8+2*x4*x9-x5");
polKatsura10.emplace_back("x3^2+2*x2*x4+2*x1*x5+2*x0*x6+2*x1*x7+2*x2*x8+2*x3*x9-x6");
polKatsura10.emplace_back("2*x3*x4+2*x2*x5+2*x1*x6+2*x0*x7+2*x1*x8+2*x2*x9-x7");
polKatsura10.emplace_back("x4^2+2*x3*x5+2*x2*x6+2*x1*x7+2*x0*x8+2*x1*x9-x8");
nbGen=katsura10.f4();
if(magma)
{
katsura10.printReducedGroebnerBasis("katsura10", modulo);
}
return nbGen;
}
int katsura11F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# KATSURA 11 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polKatsura11;
polKatsura11.emplace_back("x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8+2*x9+2*x10-1");
polKatsura11.emplace_back("x0^2+2*x1^2+2*x2^2+2*x3^2+2*x4^2+2*x5^2+2*x6^2+2*x7^2+2*x8^2+2*x9^2+2*x10^2-x0");
polKatsura11.emplace_back("2*x0*x1+2*x1*x2+2*x2*x3+2*x3*x4+2*x4*x5+2*x5*x6+2*x6*x7+2*x7*x8+2*x8*x9+2*x9*x10-x1");
polKatsura11.emplace_back("x1^2+2*x0*x2+2*x1*x3+2*x2*x4+2*x3*x5+2*x4*x6+2*x5*x7+2*x6*x8+2*x7*x9+2*x8*x10-x2");
polKatsura11.emplace_back("2*x1*x2+2*x0*x3+2*x1*x4+2*x2*x5+2*x3*x6+2*x4*x7+2*x5*x8+2*x6*x9+2*x7*x10-x3");
polKatsura11.emplace_back("x2^2+2*x1*x3+2*x0*x4+2*x1*x5+2*x2*x6+2*x3*x7+2*x4*x8+2*x5*x9+2*x6*x10-x4");
polKatsura11.emplace_back("2*x2*x3+2*x1*x4+2*x0*x5+2*x1*x6+2*x2*x7+2*x3*x8+2*x4*x9+2*x5*x10-x5");
polKatsura11.emplace_back("x3^2+2*x2*x4+2*x1*x5+2*x0*x6+2*x1*x7+2*x2*x8+2*x3*x9+2*x4*x10-x6");
polKatsura11.emplace_back("2*x3*x4+2*x2*x5+2*x1*x6+2*x0*x7+2*x1*x8+2*x2*x9+2*x3*x10-x7");
polKatsura11.emplace_back("x4^2+2*x3*x5+2*x2*x6+2*x1*x7+2*x0*x8+2*x1*x9+2*x2*x10-x8");
polKatsura11.emplace_back("2*x4*x5+2*x3*x6+2*x2*x7+2*x1*x8+2*x0*x9+2*x1*x10-x9");
nbGen=katsura11.f4();
if(magma)
{
katsura11.printReducedGroebnerBasis("katsura11", modulo);
}
return nbGen;
}
int katsura12F4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# KATSURA 12 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polKatsura12;
polKatsura12.emplace_back("x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8+2*x9+2*x10+2*x11-1");
polKatsura12.emplace_back("x0^2+2*x1^2+2*x2^2+2*x3^2+2*x4^2+2*x5^2+2*x6^2+2*x7^2+2*x8^2+2*x9^2+2*x10^2+2*x11^2-x0");
polKatsura12.emplace_back("2*x0*x1+2*x1*x2+2*x2*x3+2*x3*x4+2*x4*x5+2*x5*x6+2*x6*x7+2*x7*x8+2*x8*x9+2*x9*x10+2*x10*x11-x1");
polKatsura12.emplace_back("x1^2+2*x0*x2+2*x1*x3+2*x2*x4+2*x3*x5+2*x4*x6+2*x5*x7+2*x6*x8+2*x7*x9+2*x8*x10+2*x9*x11-x2");
polKatsura12.emplace_back("2*x1*x2+2*x0*x3+2*x1*x4+2*x2*x5+2*x3*x6+2*x4*x7+2*x5*x8+2*x6*x9+2*x7*x10+2*x8*x11-x3");
polKatsura12.emplace_back("x2^2+2*x1*x3+2*x0*x4+2*x1*x5+2*x2*x6+2*x3*x7+2*x4*x8+2*x5*x9+2*x6*x10+2*x7*x11-x4");
polKatsura12.emplace_back("2*x2*x3+2*x1*x4+2*x0*x5+2*x1*x6+2*x2*x7+2*x3*x8+2*x4*x9+2*x5*x10+2*x6*x11-x5");
polKatsura12.emplace_back("x3^2+2*x2*x4+2*x1*x5+2*x0*x6+2*x1*x7+2*x2*x8+2*x3*x9+2*x4*x10+2*x5*x11-x6");
polKatsura12.emplace_back("2*x3*x4+2*x2*x5+2*x1*x6+2*x0*x7+2*x1*x8+2*x2*x9+2*x3*x10+2*x4*x11-x7");
polKatsura12.emplace_back("x4^2+2*x3*x5+2*x2*x6+2*x1*x7+2*x0*x8+2*x1*x9+2*x2*x10+2*x3*x11-x8");
polKatsura12.emplace_back("2*x4*x5+2*x3*x6+2*x2*x7+2*x1*x8+2*x0*x9+2*x1*x10+2*x2*x11-x9");
polKatsura12.emplace_back("x5^2+2*x4*x6+2*x3*x7+2*x2*x8+2*x1*x9+2*x0*x10+2*x1*x11-x10");
nbGen=katsura12.f4();
if(magma)
{
katsura12.printReducedGroebnerBasis("katsura12", modulo);
}
return nbGen;
}
int randomIdealF4(bool magma)
{
cout << "#########################################################" << endl;
cout << "# RANDOM 10 #" << endl;
cout << "#########################################################" << endl << endl;
int nbGen;
vector<Polynomial<eltType>> polRandomIdeal;
polRandomIdeal.emplace_back("-60*x0^3*x1^2 - 100*x2^4*x3 + 100*x0^2*x3^2*x4 - 88*x1*x3^2*x4^2 - 115*x1*x2*x3*x5^2 - 17*x2*x3*x4*x5^2 - 55*x4^4 - 36*x1*x3^2*x5 - 59*x2*x3^2*x5 - 78*x1*x2*x4");
polRandomIdeal.emplace_back("54*x1^2*x2^3 + 61*x3^5 + 18*x1^3*x3*x4 + 69*x1*x3^3*x4 + 17*x0^2*x2*x4^2 + 49*x0*x1*x3*x4*x5 + 18*x2*x3*x5^3 - 90*x0*x1*x3^2 - 65*x0 - 44*x3");
polRandomIdeal.emplace_back("-29*x0*x2^2*x3*x4 + 48*x0*x2*x3*x4^2 + 109*x0*x3*x4^2*x5 - 85*x0*x1*x3*x5^2 - 86*x0*x3^2*x4 + 95*x1^2*x4^2 + 109*x1^2*x2*x5 + 26*x0^2*x5 + 110*x0^2 + 103*x1^2");
polRandomIdeal.emplace_back("-6*x2^3*x3^2 + 13*x0*x1*x2*x3*x4 - 45*x2^3*x3*x4 + 99*x1^2*x2^2*x5 - 57*x0^3*x4*x5 + 31*x0^2*x2*x4*x5 + 55*x0*x2^2*x5^2 + 114*x0^2*x2*x5 - 46*x2^2*x5 + 83*x2*x5^2");
polRandomIdeal.emplace_back("-101*x0*x1^4 - 9*x1^2*x2^2*x3 + x4^5 + 75*x2*x4*x5^3 - 3*x0^2*x1*x2 - 104*x0*x1*x3*x4 - 68*x0*x2*x3*x4 - 64*x1^2*x3 - 54*x5^2");
polRandomIdeal.emplace_back("-105*x0^2*x4^3 + 83*x1^2*x3^2*x5 + 48*x2*x3^3*x5 + 23*x1*x4^3*x5 - 82*x0*x1*x5^3 - 77*x2^2*x4*x5 + 84*x1*x2*x5^2 - 14*x0^2*x2 + 75*x3^2*x4 - 91*x1*x5^2");
polRandomIdeal.emplace_back("-59*x0*x1^2*x2^2 - 62*x0*x1*x2^2*x3 - 104*x0*x1*x3*x4*x5 + 65*x0*x1*x2^2 - 95*x0^2*x3^2 - 60*x1^2*x4^2 - 6*x2*x4^3 + 119*x1*x3*x5^2 + 67*x2^3 - 52*x2*x5^2");
polRandomIdeal.emplace_back("32*x2^2*x3^3 - 70*x0*x1^2*x4^2 + 88*x0^4*x5 + 39*x0*x1*x3^2*x5 + 57*x1*x2*x3*x5^2 + 117*x1*x4^2*x5^2 - 105*x0*x1*x2^2 + 69*x1*x2*x5^2 - 119*x0*x5^3 + 86*x0*x1*x3");
polRandomIdeal.emplace_back("65*x1^3*x3^2 - 114*x0^2*x1*x2*x4 - 69*x0*x3^3*x4 - 84*x1^2*x4^3 + 43*x1^3*x4*x5 - 120*x1^3*x5^2 + 58*x0*x1^2*x3 - 61*x1*x2^2*x3 - 76*x1*x2^2*x4 - 46*x2*x3^2*x5");
polRandomIdeal.emplace_back("43*x1^4*x3 + 35*x2*x3*x4*x5^2 + 85*x0*x4*x5^3 + 48*x1*x2^2*x3 - 2*x1*x2*x3^2 - 52*x1^2*x3*x4 - 30*x1^2*x3*x5 + 11*x0*x3^2*x5 + 34*x0*x2*x4 - 3*x1*x3*x4");
nbGen=randomIdeal.f4();
if(magma)
{
randomIdeal.printReducedGroebnerBasis("randomIdeal", modulo);
}
return nbGen;
}
int main (int argc, char **argv)
{
cout << "#########################################################" << endl;
cout << "# BENCHMARK SHORT #" << endl;
cout << "#########################################################" << endl << endl;
chrono::steady_clock::time_point start;
typedef chrono::duration<int,milli> millisecs_t;
cout << NB_THREAD << " threads used " << endl << endl;
bool magma = false;
int nbGen;
ofstream file("benchmark-short.txt");
if (file)
{
file << "Benchmark for ideal with integer type coefficient." << endl << endl << endl;
}
start=chrono::steady_clock::now();
nbGen=randomIdealF4(magma);
if (file)
{
file << "Random 10 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
}
start=chrono::steady_clock::now();
nbGen=cyclic8F4(magma);
if (file)
{
file << "Cyclic 8 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
}
start=chrono::steady_clock::now();
nbGen=katsura12F4(magma);
if (file)
{
file << "Katsura 12 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
}
return 0;
}