OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
element-prime.h
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 openf4.
5  *
6  * openf4 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  * openf4 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 openf4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 #ifndef OPENF4_ELEMENT_PRIME_H
27 #define OPENF4_ELEMENT_PRIME_H
28 
30 #include "global.h"
31 #include <iostream>
32 #include <string.h>
33 #include <cassert>
34 #include <cmath>
40 namespace F4
41 {
46  template <typename baseType>
48  {
49  public:
50 
51  /* static methods */
52 
57  static void setModulo(baseType modulo);
58 
63  static baseType getModulo();
64 
69  static baseType getMax();
70 
71 
72  /* No constructor because POD */
73 
74  /* No Destructor because POD */
75 
76 
77  /* Miscellaneous */
78 
84  baseType modulo ();
85 
90  baseType getElement ();
91 
102 
110 
114  void printElementPrime (std::ostream & stream) const;
115 
121  bool isZero() const;
122 
128  bool isOne() const;
129 
133  void setZero();
134 
138  void setOne();
139 
140 
141  /* Internal operators */
142 
149  ElementPrime & operator=(baseType element);
150 
159  ElementPrime & operator*=(ElementPrime const & mult);
160 
161 
162  /* Public attribute because POD */
163 
164  baseType _element;
166  static baseType MODULO;
167  static baseType MAX;
168  };
169 
170 
171  /* External operators */
172 
177  template <typename baseType>
178  std::ostream & operator<<(std::ostream & stream, ElementPrime<baseType> const & element);
179 
184  template <typename baseType>
186 
191  template <typename baseType>
193 }
194 
196 #include "../src/element-prime.inl"
199 #endif // OPENF4_ELEMENT_PRIME_H
static baseType getModulo()
Get the static variable MODULO.
void setZero()
Set the element to zero.
static baseType getMax()
Get the static variable MAX.
ElementPrime< baseType > operator-(ElementPrime< baseType > const &element)
Overload the operator -.
bool isOne() const
Test if this is one (neutral multiplicative element).
ElementPrime & operator=(baseType element)
Overload the operator =.
ElementPrime< baseType > & addMult(ElementPrime< baseType > const &element, ElementPrime< baseType > const &mult)
Set this+=(mult*element).
baseType modulo()
Set this in [-MODULO/2, MODULO/2].
ElementPrime< baseType > & inverse()
Inverse this according to the base field.
Wrapper for config.h in order to avoid multiple definitions.
void printElementPrime(std::ostream &stream) const
Print the element.
Term< Element > operator*(Monomial const &mon, Term< Element > const &term)
Overload the operator *.
Represent an element of a prime field, this class is a POD (Plain Old Data) because of the alignement...
Definition: element-prime.h:47
ElementPrime & operator*=(ElementPrime const &mult)
Overload the operator *=.
void setOne()
Set the element to one.
static void setModulo(baseType modulo)
Set the static variable MODULO.
static baseType MAX
bool isZero() const
Test if this is nul.
static baseType MODULO
baseType getElement()
Return this.