F4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
polynomial.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 F4.
5  *
6  * F4 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  * F4 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 F4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 #ifndef F4_POLYNOMIAL_H
27 #define F4_POLYNOMIAL_H
28 
30 #include "global.h"
31 #include <algorithm>
32 #include <cctype>
33 #include <list>
35 #include "single-list.h"
36 
40 namespace F4
41 {
46  template <typename Element>
47  class Polynomial
48  {
49  public:
50 
51  /* Constructor */
52 
56  Polynomial();
57 
62  Polynomial(std::string const s);
63 
68  Polynomial(Polynomial const & polynomial);
69 
74  Polynomial(Polynomial && polynomial);
75 
76 
77  /* Destructor */
78 
82  ~Polynomial();
83 
87  void clear();
88 
93  void deleteAfter(NodeList<Element> * it);
94 
95 
96  /* Miscellaneous */
97 
101  void printPolynomial (std::ostream & stream) const;
102 
107  int getNbTerm() const;
108 
114  const Term<Element> & getLT() const;
115 
121  int getLM() const;
122 
128  Element getLC() const;
129 
134  Element getCoefficient(int numMon) const;
135 
141 
147 
153 
157  void deleteLT();
158 
162  void normalize();
163 
169  bool isEmpty();
170 
178  NodeList<Element> * emplaceAfter(NodeList<Element> * pos, Element coeff, int numMon);
179 
187  NodeList<Element> * emplaceOn(NodeList<Element> * pos, Element coeff, int numMon);
188 
189 
190  /* Internal operators */
191 
197  Polynomial & operator=(Polynomial const & polynomial);
198 
204  Polynomial & operator=(Polynomial && polynomial);
205 
211  Polynomial & operator*=(Monomial const & monomial);
212 
218  Polynomial & operator*=(Element element);
219 
225  Polynomial & operator*=(Term<Element> const & term);
226 
227  private:
229  };
230 
231 
232  /* External operators */
233 
238  template <typename Element>
239  std::ostream & operator<<(std::ostream & stream, Polynomial<Element> const & polynomial);
240 
247  template <typename Element>
248  Polynomial<Element> operator * (Monomial const & monomial, Polynomial<Element> const & polynomial);
249 
256  template <typename Element>
257  Polynomial<Element> operator * (Polynomial<Element> const & polynomial, Monomial const & monomial);
258 
265  template <typename Element>
266  Polynomial<Element> operator * (Element element, Polynomial<Element> const & polynomial);
267 
274  template <typename Element>
275  Polynomial<Element> operator * (Polynomial<Element> const & polynomial, Element element);
276 
283  template <typename Element>
284  Polynomial<Element> operator * (Term<Element> const & term, Polynomial<Element> const & polynomial);
285 
292  template <typename Element>
293  Polynomial<Element> operator * (Polynomial<Element> const & polynomial, Term<Element> const & term);
294 }
295 
297 #include "../src/polynomial.inl"
300 #endif // F4_POLYNOMIAL_H
Represent a monomial.
Definition: monomial.h:46
Element getCoefficient(int numMon) const
Get the coefficient of the term of monomial numMon.
~Polynomial()
Destructor.
ElementGF2Extension< baseType > operator*(ElementGF2Extension< baseType > const &element1, ElementGF2Extension< baseType > const &element2)
Overload the operator *.
void printPolynomial(std::ostream &stream) const
Print the polynomial.
NodeList< Element > * emplaceOn(NodeList< Element > *pos, Element coeff, int numMon)
Add a term after pos. Beware to keep a correct order.
int getNbTerm() const
Get the number of terms of this.
Polynomial & operator*=(Monomial const &monomial)
Overload the operator *= to multiply this with a monomial. Prefer multNumMon(int numMon) if the monom...
bool isEmpty()
Test if the polynomial is empty or not.
Declaration of class SingleList.
Represent a term.
Definition: term.h:50
Represent a single chained list.
Definition: single-list.h:117
NodeList< Element > const * getPolynomialBeginConst() const
Get a constant iterator on the beginning of the polynomial.
void normalize()
Normalize this.
NodeList< Element > * emplaceAfter(NodeList< Element > *pos, Element coeff, int numMon)
Add a term after pos. Beware to keep a correct order.
Wrapper for config.h in order to avoid multiple definitions.
SingleList< Element > _polynomial
Definition: polynomial.h:228
NodeList< Element > * getPolynomialBegin()
Get an iterator on the beginning of the polynomial.
void deleteLT()
Delete the leading term of this.
void clear()
Delete all the terms.
int getLM() const
Get the number of the leading monomial of this.
Polynomial()
Constructor.
Represent a polynomial.
Definition: polynomial.h:47
void deleteAfter(NodeList< Element > *it)
Erase all the term from it to the end of the polynomial.
NodeList< Element > * getPolynomialBeforeBegin()
Get an iterator before the beginning of the polynomial.
const Term< Element > & getLT() const
Get the leading term of this.
Element getLC() const
Get the leading coefficient of this.
Represent a node of the single chained list.
Definition: single-list.h:47
Polynomial & operator=(Polynomial const &polynomial)
Overload the operator =.