Gröbner basis project
Codebase for research into Gröbner basis computation
test_circle_hyperbola.cpp
1 #include <set>
2 #include <iostream>
3 
4 /*****************************************************************************\
5 * This file is part of DynGB. *
6 * *
7 * DynGB is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * Foobar is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
19 \*****************************************************************************/
20 
21 using std::set;
22 using std::cout; using std::endl;
23 
24 #include "algorithm_buchberger_basic.hpp"
25 #include "fields.hpp"
26 #include "monomial.hpp"
27 #include "polynomial.hpp"
28 
29 int main(int argc, char *argv[]) {
30  // set up the field
31  Prime_Field F43 = Prime_Field(43);
32  Prime_Field_Element a = F43.unity();
33  Prime_Field_Element b(-4, &F43);
34  Prime_Field_Element c(-1, &F43);
35  // set up our polynomials
36  // first poly: circle
37  unsigned e1 [] {2,0}; Monomial t1(2, e1); // x^2
38  unsigned e2 [] {0,2}; Monomial t2(2, e2); // y^2
39  unsigned e3 [] {0,0}; Monomial t3(2, e3); // 1
40  Monomial M1 [] { t1, t2, t3 };
41  Prime_Field_Element C1 [] { a, a, b };
42  Constant_Polynomial f1(3, M1, C1);
43  // second poly: hyperbola
44  unsigned e4 [] {1,1}; Monomial t4(2, e4); // xy
45  unsigned e5 [] {0,0}; Monomial t5(2, e5); // 1
46  Monomial M2 [] { t4, t5 };
47  Prime_Field_Element C2 [] { a, -a };
48  Constant_Polynomial f2(2, M2, C2);
49  // message
50  cout << "Computing a Groebner basis for " << f1 << ", " << f2 << endl;
51  // compute basis
52  set<Abstract_Polynomial *> F;
53  F.insert(&f1); F.insert(&f2);
54  set<Constant_Polynomial *> G = buchberger(F);
55  cout << "Basis:\n";
56  for (auto g = G.begin(); g != G.end(); ++g)
57  cout << '\t' << *(*g) << endl;
58  cout << "bye\n";
59 }
A Constant_Polynomial is a polynomial that should not change.
list< Constant_Polynomial * > buchberger(const list< Abstract_Polynomial *> &F, SPolyCreationFlags method, StrategyFlags strategy, WT_TYPE *strategy_weights)
Implementation of Buchberger’s algorithm.
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
Implementation of monomials.
Definition: monomial.hpp:69
Element of a field of prime characteristic.
Definition: fields.hpp:137