F4
Library for Gröebner basis computation in finite field.
 All Classes Namespaces Files Functions Variables Friends Pages
benchmark-int.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 F4.
5  *
6  * F4 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  * F4 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 F4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
28 #include <iostream>
29 #include <f4.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=min(8, omp_get_num_procs());
38 #else
39 int F4::NB_THREAD=1;
40 #endif
41 
42 // Init element-prime tools
44 int modulo=65521;
45 
46 int cyclic6F4(bool magma)
47 {
48  cout << "#########################################################" << endl;
49  cout << "# CYCLIC 6 #" << endl;
50  cout << "#########################################################" << endl << endl;
51 
52  // Init element-prime tools
53  eltType::setModulo(modulo);
54 
55  // Number of generator
56  int nbGen;
57 
58  // Init monomial tools
60 
61  // Create polynomial array
62  vector<Polynomial<eltType>> polCyclic6;
63 
64  // Fill the polynomial array
65  polCyclic6.emplace_back("x0+x1+x2+x3+x4+x5");
66  polCyclic6.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x0*x5+x4*x5");
67  polCyclic6.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x0*x1*x5+x0*x4*x5+x3*x4*x5");
68  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");
69  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");
70  polCyclic6.emplace_back("x0*x1*x2*x3*x4*x5-1");
71 
72  // Create cyclic6 ideal;
73  Ideal<eltType> cyclic6(polCyclic6, 6, 100000);
74 
75  // Compute a reduced groebner basis;
76  nbGen=cyclic6.f4();
77 
78  // Print the reduced groebner basis into a file
79  if(magma)
80  {
81  cyclic6.printReducedGroebnerBasis("cyclic6", modulo);
82  }
83 
84  return nbGen;
85 }
86 
87 int cyclic7F4(bool magma)
88 {
89  cout << "#########################################################" << endl;
90  cout << "# CYCLIC 7 #" << endl;
91  cout << "#########################################################" << endl << endl;
92 
93  // Init element-prime tools
94  eltType::setModulo(modulo);
95 
96  // Number of generator
97  int nbGen;
98 
99  // Init monomial tools
101 
102  // Create polynomial array
103  vector<Polynomial<eltType>> polCyclic7;
104 
105  // Fill the polynomial array
106  polCyclic7.emplace_back("x0+x1+x2+x3+x4+x5+x6");
107  polCyclic7.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x4*x5+x0*x6+x5*x6");
108  polCyclic7.emplace_back("x0*x1*x2+x1*x2*x3+x2*x3*x4+x3*x4*x5+x0*x1*x6+x0*x5*x6+x4*x5*x6");
109  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");
110  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");
111  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");
112  polCyclic7.emplace_back("x0*x1*x2*x3*x4*x5*x6-1");
113 
114  // Create cyclic7 ideal;
115  Ideal<eltType> cyclic7(polCyclic7, 7 , 1000000);
116 
117  // Compute a reduced groebner basis;
118  nbGen=cyclic7.f4();
119 
120  // Print the reduced groebner basis into a file
121  if(magma)
122  {
123  cyclic7.printReducedGroebnerBasis("cyclic7", modulo);
124  }
125 
126  return nbGen;
127 }
128 
129 int cyclic8F4(bool magma)
130 {
131 
132  cout << "#########################################################" << endl;
133  cout << "# CYCLIC 8 #" << endl;
134  cout << "#########################################################" << endl << endl;
135 
136  // Init element-prime tools
137  eltType::setModulo(modulo);
138 
139  // Number of generator
140  int nbGen;
141 
142  // Init monomial tools
144 
145  // Create polynomial array
146  vector<Polynomial<eltType>> polCyclic8;
147 
148  // Fill the polynomial array
149  polCyclic8.emplace_back("x0+x1+x2+x3+x4+x5+x6+x7");
150  polCyclic8.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x4*x5+x5*x6+x0*x7+x6*x7");
151  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");
152  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");
153  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");
154  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");
155  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");
156  polCyclic8.emplace_back("x0*x1*x2*x3*x4*x5*x6*x7-1");
157 
158  // Create cyclic8 ideal;
159  Ideal<eltType> cyclic8(polCyclic8, 8, 1000000);
160 
161  // Compute a reduced groebner basis;
162  nbGen=cyclic8.f4();
163 
164  // Print the reduced groebner basis into a file
165  if(magma)
166  {
167  cyclic8.printReducedGroebnerBasis("cyclic8", modulo);
168  }
169 
170  return nbGen;
171 }
172 
173 int cyclic9F4(bool magma)
174 {
175 
176  cout << "#########################################################" << endl;
177  cout << "# CYCLIC 9 #" << endl;
178  cout << "#########################################################" << endl << endl;
179 
180  // Init element-prime tools
181  eltType::setModulo(modulo);
182 
183  // Number of generator
184  int nbGen;
185 
186  // Init monomial tools
188 
189  // Create polynomial array
190  vector<Polynomial<eltType>> polCyclic9;
191 
192  // Fill the polynomial array
193  polCyclic9.emplace_back("x0+x1+x2+x3+x4+x5+x6+x7+x8");
194  polCyclic9.emplace_back("x0*x1+x1*x2+x2*x3+x3*x4+x4*x5+x5*x6+x6*x7+x0*x8+x7*x8");
195  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");
196  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");
197  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");
198  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");
199  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");
200  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");
201  polCyclic9.emplace_back("x0*x1*x2*x3*x4*x5*x6*x7*x8-1");
202 
203  // Create cyclic9 ideal;
204  Ideal<eltType> cyclic9(polCyclic9, 9, 20000000);
205 
206  // Compute a reduced groebner basis;
207  nbGen=cyclic9.f4();
208 
209  // Print the reduced groebner basis into a file
210  if(magma)
211  {
212  cyclic9.printReducedGroebnerBasis("cyclic9", modulo);
213  }
214 
215  return nbGen;
216 }
217 
218 int katsura9F4(bool magma)
219 {
220  cout << "#########################################################" << endl;
221  cout << "# KATSURA 9 #" << endl;
222  cout << "#########################################################" << endl << endl;
223 
224  // Init element-prime tools
225  eltType::setModulo(modulo);
226 
227  // Number of generator
228  int nbGen;
229 
230  // Init monomial tools
232 
233  // Create polynomial array
234  vector<Polynomial<eltType>> polKatsura9;
235 
236  // Fill the polynomial array
237  polKatsura9.emplace_back("x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8-1");
238  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");
239  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");
240  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");
241  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");
242  polKatsura9.emplace_back("x2^2+2*x1*x3+2*x0*x4+2*x1*x5+2*x2*x6+2*x3*x7+2*x4*x8-x4");
243  polKatsura9.emplace_back("2*x2*x3+2*x1*x4+2*x0*x5+2*x1*x6+2*x2*x7+2*x3*x8-x5");
244  polKatsura9.emplace_back("x3^2+2*x2*x4+2*x1*x5+2*x0*x6+2*x1*x7+2*x2*x8-x6");
245  polKatsura9.emplace_back("2*x3*x4+2*x2*x5+2*x1*x6+2*x0*x7+2*x1*x8-x7");
246 
247  // Create katsura9 ideal;
248  Ideal<eltType> katsura9(polKatsura9, 9 ,1000000);
249 
250  // Compute a reduced groebner basis;
251  nbGen=katsura9.f4();
252 
253  // Print the reduced groebner basis into a file
254  if(magma)
255  {
256  katsura9.printReducedGroebnerBasis("katsura9", modulo);
257  }
258 
259  return nbGen;
260 }
261 
262 int katsura10F4(bool magma)
263 {
264  cout << "#########################################################" << endl;
265  cout << "# KATSURA 10 #" << endl;
266  cout << "#########################################################" << endl << endl;
267 
268  // Init element-prime tools
269  eltType::setModulo(modulo);
270 
271  // Number of generator
272  int nbGen;
273 
274  // Init monomial tools
276 
277  // Create polynomial array
278  vector<Polynomial<eltType>> polKatsura10;
279 
280  // Fill the polynomial array
281  polKatsura10.emplace_back("x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8+2*x9-1");
282  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");
283  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");
284  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");
285  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");
286  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");
287  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");
288  polKatsura10.emplace_back("x3^2+2*x2*x4+2*x1*x5+2*x0*x6+2*x1*x7+2*x2*x8+2*x3*x9-x6");
289  polKatsura10.emplace_back("2*x3*x4+2*x2*x5+2*x1*x6+2*x0*x7+2*x1*x8+2*x2*x9-x7");
290  polKatsura10.emplace_back("x4^2+2*x3*x5+2*x2*x6+2*x1*x7+2*x0*x8+2*x1*x9-x8");
291 
292  // Create katsura10 ideal;
293  Ideal<eltType> katsura10(polKatsura10, 10, 10000000);
294 
295  // Compute a reduced groebner basis;
296  nbGen=katsura10.f4();
297 
298  // Print the reduced groebner basis into a file
299  if(magma)
300  {
301  katsura10.printReducedGroebnerBasis("katsura10", modulo);
302  }
303  return nbGen;
304 }
305 
306 int katsura11F4(bool magma)
307 {
308  cout << "#########################################################" << endl;
309  cout << "# KATSURA 11 #" << endl;
310  cout << "#########################################################" << endl << endl;
311 
312  // Init element-prime tools
313  eltType::setModulo(modulo);
314 
315  // Number of generator
316  int nbGen;
317 
318  // Init monomial tools
320 
321  // Create polynomial array
322  vector<Polynomial<eltType>> polKatsura11;
323 
324  // Fill the polynomial array
325  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");
326  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");
327  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");
328  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");
329  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");
330  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");
331  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");
332  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");
333  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");
334  polKatsura11.emplace_back("x4^2+2*x3*x5+2*x2*x6+2*x1*x7+2*x0*x8+2*x1*x9+2*x2*x10-x8");
335  polKatsura11.emplace_back("2*x4*x5+2*x3*x6+2*x2*x7+2*x1*x8+2*x0*x9+2*x1*x10-x9");
336 
337  // Create katsura11 ideal;
338  Ideal<eltType> katsura11(polKatsura11, 11, 10000000);
339 
340  // Compute a reduced groebner basis;
341  nbGen=katsura11.f4();
342 
343  // Print the reduced groebner basis into a file
344  if(magma)
345  {
346  katsura11.printReducedGroebnerBasis("katsura11", modulo);
347  }
348  return nbGen;
349 }
350 
351 int katsura12F4(bool magma)
352 {
353  cout << "#########################################################" << endl;
354  cout << "# KATSURA 12 #" << endl;
355  cout << "#########################################################" << endl << endl;
356 
357  // Init element-prime tools
358  eltType::setModulo(modulo);
359 
360  // Number of generator
361  int nbGen;
362 
363  // Init monomial tools
365 
366  // Create polynomial array
367  vector<Polynomial<eltType>> polKatsura12;
368 
369  // Fill the polynomial array
370  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");
371  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");
372  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");
373  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");
374  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");
375  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");
376  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");
377  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");
378  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");
379  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");
380  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");
381  polKatsura12.emplace_back("x5^2+2*x4*x6+2*x3*x7+2*x2*x8+2*x1*x9+2*x0*x10+2*x1*x11-x10");
382 
383  // Create katsura12 ideal;
384  Ideal<eltType> katsura12(polKatsura12, 12, 20000000);
385 
386  // Compute a reduced groebner basis;
387  nbGen=katsura12.f4();
388 
389  // Print the reduced groebner basis into a file
390  if(magma)
391  {
392  katsura12.printReducedGroebnerBasis("katsura12", modulo);
393  }
394 
395  return nbGen;
396 }
397 
398 int randomIdealF4(bool magma)
399 {
400  cout << "#########################################################" << endl;
401  cout << "# RANDOM 10 #" << endl;
402  cout << "#########################################################" << endl << endl;
403 
404  // Init element-prime tools
405  eltType::setModulo(modulo);
406 
407  // Number of generator
408  int nbGen;
409 
410  // Init monomial tools
412 
413  // Create polynomial array
414  vector<Polynomial<eltType>> polRandomIdeal;
415 
416  // Fill the polynomial array
417  polRandomIdeal.emplace_back("-25655*x1^2*x2^2*x4 - 27093*x0*x2*x3*x5^2 + 15696*x5^5 - 31611*x0*x1^3 + 10089*x0^3*x2 - 2759*x1^2*x3^2 + 3186*x1*x3^2*x4 - 7916*x1*x2^2*x5 + 16867*x1*x4^2*x5 - 26502*x2^2*x4");
418  polRandomIdeal.emplace_back("24757*x2^4*x3 + 13532*x0*x1*x2*x3^2 - 32273*x2^2*x3^3 + 24976*x2*x3^4 + 6577*x0*x2^3*x5 - 14251*x1*x3^2*x4*x5 + 8633*x0*x3*x4^2 + 18508*x0*x4^3 + 12700*x1*x2*x5^2 + 21103*x1*x5");
419  polRandomIdeal.emplace_back("-14089*x0^2*x2^3 + 6374*x0*x1^2*x3^2 - 11572*x2^3*x3^2 + 17253*x0^3*x1*x4 - 26476*x2*x3*x4^3 - 5794*x2*x4^3*x5 - 9292*x0^3*x1 + 9740*x0^3*x2 - 9633*x0^2*x5^2 + 15791*x4");
420  polRandomIdeal.emplace_back("520*x0^2*x1*x3*x5 - 29475*x3^4*x5 + 19553*x1*x4^3*x5 - 23508*x0*x3^2*x5^2 - 5914*x0^2*x4*x5^2 - 1142*x0*x2*x4*x5 + 18000*x0*x2*x3 + 9342*x2*x3^2 + 8761*x0^2*x5 + 19293*x2*x5");
421  polRandomIdeal.emplace_back("-29406*x0^4*x1 - 6933*x1*x2^4 - 16593*x1^2*x2*x3^2 - 12720*x1*x3^4 - 8580*x4*x5^4 - 17076*x1^2*x3*x4 + 24339*x0*x2*x3*x4 + 7722*x1*x3*x4^2 - 14196*x1*x2*x3 - 15797*x1^2*x5");
422  polRandomIdeal.emplace_back("31060*x0^3*x1*x2 - 6848*x2*x3^3*x5 - 17952*x1*x3*x4^2*x5 + 24428*x0*x2*x3*x5^2 + 20435*x0^4 - 20926*x1^2*x2*x3 + 18778*x2^2*x3^2 + 24106*x2*x4^3 - 11252*x5^4 - 20128*x2*x3");
423  polRandomIdeal.emplace_back("2175*x0^3*x4^2 + 24248*x0^2*x3*x4*x5 - 25078*x0*x2*x3*x4*x5 + 17127*x0*x3^2*x4*x5 + 16204*x3^2*x4*x5^2 + 3683*x0*x1*x2*x3 + 14115*x1*x4^2*x5 - 32337*x0^2*x1 - 17348*x1^2*x5 + 3481*x1*x4");
424  polRandomIdeal.emplace_back("-10922*x2^3*x3^2 + 11055*x2^2*x3^3 - 24940*x2^2*x3*x5^2 - 2405*x2*x5^4 - 26339*x1*x2*x3^2 - 4489*x0*x3^2*x5 + 2022*x1*x3*x4*x5 + 6254*x3*x4^2*x5 + 19234*x1^2*x3 + 28792*x2*x4*x5");
425  polRandomIdeal.emplace_back("-30691*x0^2*x2*x3^2 + 6407*x0*x2*x4^3 + 30127*x1*x4^4 + 20623*x2*x3*x4^2*x5 + 14919*x0*x3^2*x5^2 + 11410*x1^2*x4^2 + 11040*x0*x2*x4^2 - 23568*x4*x5^3 + 12549*x1^2*x3 - 19452*x2^2*x3");
426  polRandomIdeal.emplace_back("-21749*x0^3*x1^2 + 31426*x2^3*x4^2 + 24770*x3^2*x4^3 - 8527*x0^3*x1*x5 - 24637*x0^2*x1*x3*x5 - 12368*x0*x1*x2*x3*x5 + 12346*x1*x2^2*x3*x5 - 27520*x0*x5^4 - 8249*x1^2*x3*x4 - 4866*x0*x2*x3*x4");
427 
428  // Create katsura12 ideal;
429  Ideal<eltType> randomIdeal(polRandomIdeal, 6);
430 
431  // Compute a reduced groebner basis;
432  nbGen=randomIdeal.f4();
433 
434  // Print the reduced groebner basis into a file
435  if(magma)
436  {
437  randomIdeal.printReducedGroebnerBasis("randomIdeal", modulo);
438  }
439 
440  return nbGen;
441 }
442 
443 int randomIdealExampleF4(bool magma)
444 {
445  cout << "#########################################################" << endl;
446  cout << "# RANDOM 4 #" << endl;
447  cout << "#########################################################" << endl << endl;
448 
449  // Init element-prime tools
450  eltType::setModulo(11);
451 
452  // Number of generator
453  int nbGen;
454 
455  // Init monomial tools
457 
458  // Create polynomial array
459  vector<Polynomial<eltType>> polRandomIdeal;
460 
461  // Fill the polynomial array
462  polRandomIdeal.emplace_back("x1+2*x2+3*x3");
463  polRandomIdeal.emplace_back("4*x0+5*x1+6*x2+7*x3");
464  polRandomIdeal.emplace_back("8*x0*x1+9*x1*x2+10*x2*x3");
465 
466 
467  // Create katsura12 ideal;
468  Ideal<eltType> randomIdeal(polRandomIdeal, 4);
469 
470  // Compute a reduced groebner basis;
471  nbGen=randomIdeal.f4();
472 
473  // Print the reduced groebner basis into a file
474  if(magma)
475  {
476  randomIdeal.printReducedGroebnerBasis("randomIdeal4", modulo);
477  }
478 
479  randomIdeal.printReducedGroebnerBasis(true);
480 
481  return nbGen;
482 }
483 
484 int main (int argc, char **argv)
485 {
486  cout << "#########################################################" << endl;
487  cout << "# BENCHMARK INT #" << endl;
488  cout << "#########################################################" << endl << endl;
489 
490  // Time
491  chrono::steady_clock::time_point start;
492  typedef chrono::duration<int,milli> millisecs_t;
493 
494  // Number of threads
495  cout << NB_THREAD << " threads used " << endl << endl;
496 
497  // Magma output
498  bool magma = false;
499 
500  // Number of generator
501  int nbGen;
502 
503  // File
504  ofstream file("benchmark-int.txt");
505  if (file)
506  {
507  file << "Benchmark for ideal with integer type coefficient." << endl << endl << endl;
508  }
509 
510  start=chrono::steady_clock::now();
511  nbGen=randomIdealF4(magma);
512  if (file)
513  {
514  file << "Random 10 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
515  }
516 
517  //start=chrono::steady_clock::now();
518  //nbGen=randomIdealExampleF4(magma);
519  //if (file)
520  //{
521  //file << "Random example : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
522  //}
523 
524  //start=chrono::steady_clock::now();
525  //nbGen=cyclic6F4(magma);
526  //if (file)
527  //{
528  //file << "Cyclic 6 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
529  //}
530 
531  //start=chrono::steady_clock::now();
532  //nbGen=cyclic7F4(magma);
533  //if (file)
534  //{
535  //file << "Cyclic 7 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
536  //}
537 
538  start=chrono::steady_clock::now();
539  nbGen=cyclic8F4(magma);
540  if (file)
541  {
542  file << "Cyclic 8 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
543  }
544 
545  //start=chrono::steady_clock::now();
546  //nbGen=cyclic9F4(magma);
547  //if (file)
548  //{
549  //file << "Cyclic 9 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
550  //}
551 
552  //start=chrono::steady_clock::now();
553  //nbGen=katsura9F4(magma);
554  //if (file)
555  //{
556  //file << "Katsura 9 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
557  //}
558 
559  //start=chrono::steady_clock::now();
560  //nbGen=katsura10F4(magma);
561  //if (file)
562  //{
563  //file << "Katsura 10 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
564  //}
565 
566  //start=chrono::steady_clock::now();
567  //nbGen=katsura11F4(magma);
568  //if (file)
569  //{
570  //file << "Katsura 11 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
571  //}
572 
573  start=chrono::steady_clock::now();
574  nbGen=katsura12F4(magma);
575  if (file)
576  {
577  file << "Katsura 12 : " << chrono::duration_cast<millisecs_t>(chrono::steady_clock::now()-start).count() << " ms (" << nbGen << " generators)" << endl << endl;
578  }
579 
580  return 0;
581 }
582 
583 
Represent an ideal.
Definition: ideal.h:68
static void initMonomial(int nbVariable, short degree=0)
Initialise the static parameters of Monomial.
Represent an element of an extension of GF2, this class is a POD (Plain Old Data) because of the alig...
Represent an element of a prime field, this class is a POD (Plain Old Data) because of the alignement...
Definition: element-prime.h:47
static void setModulo(baseType modulo)
Set the static variable MODULO.
Declaration of class F4 methods.