OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
element-gf2.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_H
27 #define OPENF4_ELEMENT_GF2_H
28 
30 #include "global.h"
31 #include <iostream>
32 #include <string.h>
33 #include <cassert>
34 #include <cmath>
40 namespace F4
41 {
46  class ElementGF2
47  {
48  public:
49 
50  /* No constructor because POD */
51 
52  /* No Destructor because POD */
53 
54 
55  /* Miscellaneous */
56 
61  bool getElement ();
62 
69  ElementGF2 & addMult(ElementGF2 const & element, ElementGF2 const & mult);
70 
75  ElementGF2 & inverse();
76 
80  void printElementGF2 (std::ostream & stream) const;
81 
87  bool isZero() const;
88 
94  bool isOne() const;
95 
99  void setZero();
100 
104  void setOne();
105 
106 
107  /* Internal operators */
108 
114  ElementGF2 & operator=(bool element);
115 
121  ElementGF2 & operator*=(ElementGF2 const & mult);
122 
123 
124  /* Public attribute because POD */
125 
126  bool _element;
128  };
129 
130 
131  /* External operators */
132 
137  std::ostream & operator<<(std::ostream & stream, ElementGF2 const & element);
138 
143  ElementGF2 operator * (ElementGF2 const & element1, ElementGF2 const & element2);
144 
149  ElementGF2 operator - (ElementGF2 const & element);
150 }
151 
153 #include "../src/element-gf2.inl"
156 #endif // OPENF4_ELEMENT_GF2_H
void setOne()
Set the element to one.
void setZero()
Set the element to zero.
ElementPrime< baseType > operator-(ElementPrime< baseType > const &element)
Overload the operator -.
void printElementGF2(std::ostream &stream) const
Print the element.
bool isZero() const
Test if this is nul.
Wrapper for config.h in order to avoid multiple definitions.
ElementGF2 & addMult(ElementGF2 const &element, ElementGF2 const &mult)
Set this+=(mult*element).
ElementGF2 & operator=(bool element)
Overload the operator =.
bool getElement()
Return this.
Term< Element > operator*(Monomial const &mon, Term< Element > const &term)
Overload the operator *.
Represent an element of the field GF(2), this class is a POD (Plain Old Data) because of the aligneme...
Definition: element-gf2.h:46
ElementGF2 & inverse()
Inverse this according to the base field (for genericity).
bool isOne() const
Test if this is one (neutral multiplicative element).
ElementGF2 & operator*=(ElementGF2 const &mult)
Overload the operator *=.
std::ostream & operator<<(std::ostream &stream, Term< Element > const &term)
Overload the operator <<.