Gröbner basis project
Codebase for research into Gröbner basis computation
fields.hpp
1 #ifndef __FIELDS_H_
2 #define __FIELDS_H_
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 <iostream>
22 using std::ostream;
23 
24 #include "system_constants.hpp"
25 
31 // forward declaration
33 
50 {
51 public:
53 
65  Prime_Field(UCOEF_TYPE modulus, bool show_modulus = false);
72  Prime_Field(const Prime_Field & F);
74 
75  ~Prime_Field();
78 
83 
85  inline unsigned modulus() const { return m; }
94  COEF_TYPE inverse(COEF_TYPE a);
100 
101 
103  void set_print_modulus(bool b);
105  bool get_print_modulus();
107 protected:
109  UCOEF_TYPE m;
114  COEF_TYPE *Fi;
119 };
120 
138 {
139 public:
141 
162  Prime_Field_Element(COEF_TYPE value, Prime_Field *field);
164 
168 
170  COEF_TYPE value() const;
172  unsigned modulus() const;
174  Prime_Field * field() const;
176  bool like(const Prime_Field_Element & b) const;
178  COEF_TYPE inverse() const;
180  inline bool is_zero() const { return a == 0; };
182  bool is_one() const;
184 
185 
187  void assign(COEF_TYPE val, Prime_Field * K) {
188  a = val; F = K; m = F->modulus();
189  }
191 
195 
197  void negate();
202  void operator +=(const Prime_Field_Element &other);
207  void operator -=(const Prime_Field_Element &other);
212  void operator *=(const Prime_Field_Element &other);
219  void operator *=(const COEF_TYPE b);
224  void operator /=(const Prime_Field_Element &other);
226 
229 
232  const Prime_Field_Element &);
235  const Prime_Field_Element &);
238  const Prime_Field_Element &);
240  friend Prime_Field_Element operator+(const Prime_Field_Element &, const int);
242  friend Prime_Field_Element operator-(const Prime_Field_Element &, const int);
244  friend Prime_Field_Element operator*(const Prime_Field_Element &, const int);
251 
254  friend ostream & operator << (ostream &, const Prime_Field_Element &);
257 protected:
263  COEF_TYPE a;
268  unsigned m;
269 };
270 
271 #endif
COEF_TYPE * Fi
for , is multiplicative inverse of , mod
Definition: fields.hpp:114
ray operator-(const ray &r1, const ray &r2)
Subtract the two rays.
Definition: lp_solver.cpp:270
unsigned m
the number’ modulus, stored here to avoid the expense of accessing it in .
Definition: fields.hpp:268
ray operator+(ray &r1, ray &r2)
Add the two rays.
Definition: lp_solver.cpp:259
bool is_zero() const
Is this the additive identity?
Definition: fields.hpp:180
Prime_Field_Element zero()
“zero” is the additive identity.
Definition: fields.cpp:192
Information necessary for a field modulo a prime.
Definition: fields.hpp:49
UCOEF_TYPE m
characteristic/modulus of the field
Definition: fields.hpp:109
bool get_print_modulus()
indicates whether to print the modulus
Definition: fields.cpp:61
Prime_Field_Element unity()
“unity” is the multiplicative identity.
Definition: fields.cpp:188
COEF_TYPE inverse(COEF_TYPE a)
Returns the inverse of , modulo .
Definition: fields.cpp:55
ray operator*(RAYENT_TYPE a, ray &r)
Multiply every coordinate in the given ray by the given scalar.
Definition: lp_solver.cpp:222
bool print_modulus
determines whether a coefficient&#39;s modulus is printed
Definition: fields.hpp:118
COEF_TYPE a
the number’s value; descendants should ensure
Definition: fields.hpp:263
unsigned modulus() const
Returns the field&#39;s modulus.
Definition: fields.hpp:85
Prime_Field(UCOEF_TYPE modulus, bool show_modulus=false)
Please read detailed information.
Definition: fields.cpp:23
Element of a field of prime characteristic.
Definition: fields.hpp:137
Prime_Field * F
the field this element lives in; used to find inverses
Definition: fields.hpp:259
void set_print_modulus(bool b)
determines whether to print the modulus
Definition: fields.cpp:59
void assign(COEF_TYPE val, Prime_Field *K)
for initializing arrays of Prime_Field_Element
Definition: fields.hpp:187