Gröbner basis project
Codebase for research into Gröbner basis computation
test_finite_fields.cpp
1 #include <iostream>
2 using std::cout; using std::endl;
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 #include "fields.hpp"
22 
23 int main()
24 {
25  Prime_Field F7(7);
26  Prime_Field_Element one_mod_7(1, &F7);
27  cout << one_mod_7 << ":\t" << one_mod_7.inverse() << endl;
28  unsigned p = 11;
29  Prime_Field Fp(p);
30  Prime_Field_Element sixteen_mod_p(16, &Fp);
31  Prime_Field_Element sixteen_mod_p_inverse(sixteen_mod_p.inverse(), &Fp);
32  cout << sixteen_mod_p << ":\t" << sixteen_mod_p_inverse << endl;
33  cout << "verification: " << sixteen_mod_p * sixteen_mod_p_inverse << endl;
34  p = 21;
35  Prime_Field Fq(p);
36  Prime_Field_Element nineteen_mod_p(19, &Fq);
37  Prime_Field_Element nineteen_mod_p_inverse(nineteen_mod_p.inverse(), &Fq);
38  cout << nineteen_mod_p << ":\t" << nineteen_mod_p_inverse << endl;
39  cout << "verification: " << nineteen_mod_p * nineteen_mod_p_inverse << endl;
40 }
Information necessary for a field modulo a prime.
Definition: fields.hpp:49
Element of a field of prime characteristic.
Definition: fields.hpp:137