OPENF4
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 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_POLYNOMIAL_H
27 #define OPENF4_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  /* Memory management */
78 
82  void clear();
83 
88  void deleteAfter(NodeList<Element> * it);
89 
90 
91  /* Miscellaneous */
92 
96  void printPolynomial (std::ostream & stream) const;
97 
102  int getNbTerm() const;
103 
109  const Term<Element> & getLT() const;
110 
116  int getLM() const;
117 
123  Element getLC() const;
124 
129  Element getCoefficient(int numMon) const;
130 
136 
142 
148 
152  void deleteLT();
153 
157  void normalize();
158 
164  bool isEmpty();
165 
173  NodeList<Element> * emplaceAfter(NodeList<Element> * pos, Element coeff, int numMon);
174 
182  NodeList<Element> * emplaceOn(NodeList<Element> * pos, Element coeff, int numMon);
183 
184 
185  /* Internal operators */
186 
192  Polynomial & operator=(Polynomial const & polynomial);
193 
199  Polynomial & operator=(Polynomial && polynomial);
200 
206  Polynomial & operator*=(Monomial const & monomial);
207 
213  Polynomial & operator*=(Element element);
214 
220  Polynomial & operator*=(Term<Element> const & term);
221 
222  private:
224  };
225 
226 
227  /* External operators */
228 
233  template <typename Element>
234  std::ostream & operator<<(std::ostream & stream, Polynomial<Element> const & polynomial);
235 
242  template <typename Element>
243  Polynomial<Element> operator * (Monomial const & monomial, Polynomial<Element> const & polynomial);
244 
251  template <typename Element>
252  Polynomial<Element> operator * (Polynomial<Element> const & polynomial, Monomial const & monomial);
253 
260  template <typename Element>
261  Polynomial<Element> operator * (Element element, Polynomial<Element> const & polynomial);
262 
269  template <typename Element>
270  Polynomial<Element> operator * (Polynomial<Element> const & polynomial, Element element);
271 
278  template <typename Element>
279  Polynomial<Element> operator * (Term<Element> const & term, Polynomial<Element> const & polynomial);
280 
287  template <typename Element>
288  Polynomial<Element> operator * (Polynomial<Element> const & polynomial, Term<Element> const & term);
289 }
290 
292 #include "../src/polynomial.inl"
295 #endif // OPENF4_POLYNOMIAL_H
Represent a monomial.
Definition: monomial.h:46
Element getCoefficient(int numMon) const
Get the coefficient of the term of monomial numMon.
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:223
NodeList< Element > * getPolynomialBegin()
Get an iterator on the beginning of the polynomial.
void deleteLT()
Delete the leading term of this.
Term< Element > operator*(Monomial const &mon, Term< Element > const &term)
Overload the operator *.
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 =.