Gröbner basis project
Codebase for research into Gröbner basis computation
test_initial_analysis.cpp
1 /*****************************************************************************\
2 * This file is part of DynGB. *
3 * *
4 * DynGB is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * Foobar is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
16 \*****************************************************************************/
17 
18 #include <iostream>
19 
20 #include "system_constants.hpp"
21 
22 #include "monomial.hpp"
23 #include "polynomial.hpp"
24 #include "algorithm_buchberger_basic.hpp"
25 #include "algorithm_buchberger_dynamic.hpp"
26 
27 int main() {
28  Prime_Field FF = Prime_Field(32003);
29  string X [9] = {"t", "x", "y", "z", "a", "b", "c", "d", "e"} ;
30  Polynomial_Ring R(9, FF, X );
31  Prime_Field_Element a = FF.unity();
32  // set up our polynomials
33  // first poly
34  Monomial t11 { 0, 32, 0, 32, 0, 0, 0, 0, 0 };
35  Monomial t12 { 0, 0, 82, 0, 1, 0, 0, 0, 0 };
36  Monomial M1 [] { t11, t12 };
37  Prime_Field_Element C1 [] { a, -a };
38  Constant_Polynomial f1(2, R, M1, C1);
39  f1.sort_by_order();
40  // second poly
41  Monomial t21 { 0, 45, 0, 0, 0, 0, 0, 0, 0 };
42  Monomial t22 { 0, 0, 13, 21, 0, 1, 0, 0, 0 };
43  Monomial M2 [] { t21, t22 };
44  Prime_Field_Element C2 [] { a, -a };
45  Constant_Polynomial f2(2, R, M2, C2);
46  f2.sort_by_order();
47  // third poly
48  Monomial t31 { 0, 41, 0, 0, 0, 0, 1, 0, 0 };
49  Monomial t32 { 0, 0, 33, 12, 0, 0, 0, 0, 0 };
50  Monomial M3 [] { t31, t32 };
51  Prime_Field_Element C3 [] { a, -a };
52  Constant_Polynomial f3(2, R, M3, C3);
53  f3.sort_by_order();
54  // fourth poly
55  Monomial t41 { 0, 22, 0, 0, 0, 0, 0, 0, 0 };
56  Monomial t42 { 0, 0, 33, 12, 0, 0, 0, 1, 0 };
57  Monomial M4 [] { t41, t42 };
58  Prime_Field_Element C4 [] { a, -a };
59  Constant_Polynomial f4(2, R, M4, C4);
60  f4.sort_by_order();
61  // fifth poly
62  Monomial t51 { 0, 5, 17, 22, 0, 0, 0, 0, 1 };
63  Monomial t52 { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
64  Monomial M5 [] { t51, t52 };
65  Prime_Field_Element C5 [] { a, -a };
66  Constant_Polynomial f5(2, R, M5, C5);
67  f5.sort_by_order();
68  // sixth poly
69  Monomial t61 { 1, 1, 1, 1, 0, 0, 0, 0, 0 };
70  Monomial t62 { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
71  Monomial M6 [] { t61, t62 };
72  Prime_Field_Element C6 [] { a, -a };
73  Constant_Polynomial f6(2, R, M6, C6);
74  f6.sort_by_order();
75  // message
76  cout << "Trying an initial analysis on"
77  << ":\n\t" << f1
78  << ",\n\t" << f2
79  << ",\n\t" << f3
80  << ",\n\t" << f4
81  << ",\n\t" << f5
82  << ",\n\t" << f6
83  << endl;
84  // compute basis
85  list<Abstract_Polynomial *> F;
86  F.push_back(&f1); F.push_back(&f2); F.push_back(&f3);
87  F.push_back(&f4); F.push_back(&f5); F.push_back(&f6);
88  Monomial_Ordering * mord;
89  skeleton * skel = new skeleton(9);
90  initial_analysis(F, mord, skel);
91  cout << "Chose leading monomials:\n";
92  for (auto f : F) {
93  f->set_monomial_ordering(mord);
94  cout << f->leading_monomial() << ", ";
95  }
96  cout << endl;
97 }
A Constant_Polynomial is a polynomial that should not change.
Information necessary for a field modulo a prime.
Definition: fields.hpp:49
Prime_Field_Element unity()
“unity” is the multiplicative identity.
Definition: fields.cpp:188
skeleton of a polyhedral cone, with methods allowing definition and refinement
Definition: skeleton.hpp:178
Implementation of monomials.
Definition: monomial.hpp:69
Element of a field of prime characteristic.
Definition: fields.hpp:137
interface to a monomial ordering
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...