OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
element-gf2-extension.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_GF2_EXTENSION_H
27 #define OPENF4_ELEMENT_GF2_EXTENSION_H
28 
30 #include "global.h"
31 #include <iostream>
32 #include <string.h>
33 #include <cassert>
34 #include <algorithm>
35 #include <cctype>
41 namespace F4
42 {
47  template <typename baseType>
49  {
50  public:
51 
52  /* static methods */
53 
58  static void setModulo(baseType modulo);
59 
64  static void setModulo(std::string modulo);
65 
70  static baseType getModulo();
71 
76  static void setVariableName(std::string var);
77 
82  static baseType getMask();
83 
88  static baseType getMaskBit();
89 
90 
91  /* No constructor because POD */
92 
93  /* No Destructor because POD */
94 
95 
96  /* Miscellaneous */
97 
103  baseType modulo ();
104 
109  baseType getElement () const;
110 
121 
132 
143 
154 
165 
173 
177  void printElementGF2Extension (std::ostream & stream) const;
178 
184  bool isZero() const;
185 
191  bool isOne() const;
192 
196  void setZero();
197 
201  void setOne();
202 
203 
204  /* Internal operators */
205 
211  ElementGF2Extension & operator=(baseType const element);
212 
220  ElementGF2Extension & operator=(std::string element);
221 
231 
241 
251 
261 
271 
272  /* Public attribute because POD */
273 
274  baseType _element;
276  static baseType MODULO;
277  static baseType MASK_BIT;
278  static baseType MASK;
279  static std::string VARIABLE_NAME;
280  };
281 
282 
283  /* External operators */
284 
289  template <typename baseType>
290  std::ostream & operator<<(std::ostream & stream, ElementGF2Extension<baseType> const & element);
291 
296  template <typename baseType>
298 
303  template <typename baseType>
305 }
306 
308 #include "../src/element-gf2-extension.inl"
311 #endif // OPENF4_ELEMENT_GF2_EXTENSION_H
ElementGF2Extension & multBase256(ElementGF2Extension const &mult)
Multiply this by mult using base256 decomposition.
ElementGF2Extension & multBase4(ElementGF2Extension const &mult)
Multiply this by mult using base4 decomposition.
ElementGF2Extension & operator*=(ElementGF2Extension const &mult)
Overload the operator *=.
void setZero()
Set the element to zero.
ElementPrime< baseType > operator-(ElementPrime< baseType > const &element)
Overload the operator -.
void printElementGF2Extension(std::ostream &stream) const
Print the element.
ElementGF2Extension< baseType > & addMultBase256(ElementGF2Extension< baseType > const &element, ElementGF2Extension< baseType > const &mult)
Set this+=(mult*element). Use a base of 256.
static std::string VARIABLE_NAME
static void setVariableName(std::string var)
Set the static variable VARIABLE_NAME.
Wrapper for config.h in order to avoid multiple definitions.
bool isZero() const
Test if this is nul.
ElementGF2Extension< baseType > & addMultBase2(ElementGF2Extension< baseType > const &element, ElementGF2Extension< baseType > const &mult)
Set this+=(mult*element). Use a base of 2.
ElementGF2Extension< baseType > & inverse()
Inverse this according to the base field.
Term< Element > operator*(Monomial const &mon, Term< Element > const &term)
Overload the operator *.
Represent an element of an extension of GF2, this class is a POD (Plain Old Data) because of the alig...
void setOne()
Set the element to one.
ElementGF2Extension & multBase2(ElementGF2Extension const &mult)
Multiply this by mult using base2 decomposition.
ElementGF2Extension & operator=(baseType const element)
Overload the operator =.
static void setModulo(baseType modulo)
Set the static variable MODULO.
ElementGF2Extension< baseType > & addMult(ElementGF2Extension< baseType > const &element, ElementGF2Extension< baseType > const &mult)
Set this+=(mult*element).
baseType getElement() const
Return this.
bool isOne() const
Test if this is one (neutral multiplicative element).
baseType modulo()
Set this with a degree lower than MODULO.
ElementGF2Extension< baseType > & addMultBase4(ElementGF2Extension< baseType > const &element, ElementGF2Extension< baseType > const &mult)
Set this+=(mult*element). Use a base of 4.
static baseType getMask()
Get the static variable MASK.
ElementGF2Extension< baseType > & addMultBase16(ElementGF2Extension< baseType > const &element, ElementGF2Extension< baseType > const &mult)
Set this+=(mult*element). Use a base of 16.
static baseType getModulo()
Get the static variable MODULO.
ElementGF2Extension & multBase16(ElementGF2Extension const &mult)
Multiply this by mult using base16 decomposition.
static baseType getMaskBit()
Get the static variable MASK_BIT.