OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
tutorial-big-modulo-method3.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Antoine Joux, Vanessa Vitse and Titouan Coladon
3  *
4  * This file is part of openf4.
5  *
6  * openf4 is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openf4 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with openf4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
28 #include <iostream>
29 #include <openf4.h>
30 
31 using namespace F4;
32 using namespace std;
33 
34 // Global variable
35 int F4::VERBOSE=0;
36 #ifdef USE_OPENMP
37 int F4::NB_THREAD=omp_get_num_procs();
38 #else
39 int F4::NB_THREAD=1;
40 #endif
41 
42 int main (int argc, char **argv)
43 {
44  cout << "#########################################################" << endl;
45  cout << "# TUTORIAL WITH SOURCES USE #" << endl;
46  cout << "#########################################################" << endl << endl;
47 
48  // Init element-givaro tools
49  typedef Givaro::Modular<Givaro::Integer> Field;
50  Givaro::Integer modulo(Givaro::Integer("115792089237316195423570985008687907853269984665640564039457584007913129640233"));
51  Field F(modulo);
52  typedef ElementGivaro<Field> eltType;
53  eltType::setField(F);
54 
55  // Init monomial tools
57 
58  // Create variable name array
59  string * vars = new string[6];
60  for(int i = 0; i < 6; i++)
61  {
62  vars[i]='x'+to_string(i);
63  }
65 
66  // Create polynomial array
67  vector<Polynomial<eltType>> polynomialArray;
68 
69  // Fill the polynomial array
70  polynomialArray.emplace_back("x0+x1+x2+x3+x4+x5");
71  polynomialArray.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x0*x5+x4*x5");
72  polynomialArray.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x0*x1*x5+x0*x4*x5+x3*x4*x5");
73  polynomialArray.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");
74  polynomialArray.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");
75  polynomialArray.emplace_back("x0*x1*x2*x3*x4*x5-1");
76 
77  // Create cyclic6 ideal.
78  Ideal<eltType> cyclic6(polynomialArray, 6);
79 
80  // Compute a reduced groebner basis.
81  int nbGen=cyclic6.f4();
82  cout << "The groebner basis has " << nbGen << " generators " << endl << endl;
83 
84  // Get the reduced groebner basis under string format.
85  vector<string> basis = cyclic6.getReducedGroebnerBasis();
86 
87  // Print the reduce groebner basis.
88  for(size_t i = 0; i < basis.size(); i++)
89  {
90  cout << basis[i] << endl;
91  }
92 
93  return 0;
94 }
Declaration of class F4 methods.
Represent an ideal.
Definition: ideal.h:67
static void initMonomial(int nbVariable, short degree=1)
Initialise the static parameters of Monomial.
static void setVariable(std::string const *vars)
Modify the static variable VARS.