OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
term.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_TERM_H
27 #define OPENF4_TERM_H
28 
30 #include "global.h"
32 #include "monomial-array.h"
33 #include "element-prime.h"
34 #include "element-gf2.h"
35 #include "element-gf2-extension.h"
36 #ifdef HAVE_GIVARO
37 #include "element-givaro.h"
38 #endif // HAVE_GIVARO
39 
43 namespace F4
44 {
49  template <typename Element>
50  class Term
51  {
52  public:
53 
54  /* Static methods */
55 
60  static void setMonomialArray(MonomialArray * monomialArray);
61 
62 
63  /* Constructor */
64 
68  Term();
69 
75  Term(Element coeff, Monomial const & mon);
76 
82  Term(Element coeff, int numMon);
83 
88  Term(std::string const s);
89 
94  Term(Term const & toCopy);
95 
96 
97  /* Get / Set */
98 
103  Element getCoefficient() const;
104 
109  void setCoefficient(Element coeff);
110 
115  void setCoefficientOne();
116 
121  int getNumMonomial() const;
122 
127  void setNumMonomial(int numMon);
128 
133  void setTerm(std::string const s);
134 
135 
136  /* Miscellaneous */
137 
143  void readCoefficient(std::string const s);
144 
148  void printTerm (std::ostream & stream) const;
149 
154  void multNumMon(int numMon);
155 
163  int compareTerm(Term<Element> const & term) const;
164 
165 
166  /* Internal operators */
167 
173  Term & operator=(Term const & term);
174 
180  Term & operator*=(Monomial const & monomial);
181 
187  Term & operator*=(Element element);
188 
194  Term & operator*=(Term const & term);
195 
196  private:
197  Element _coefficient;
201  };
202 
203 
204  /* External operators */
205 
210  template <typename Element>
211  std::ostream & operator<<(std::ostream & stream, Term<Element> const & term);
212 
217  template <typename Element>
218  Term<Element> operator * (Monomial const & mon, Term<Element> const & term);
219 
224  template <typename Element>
225  Term<Element> operator * (Term<Element> const & term, Monomial const & mon);
226 
231  template <typename Element>
232  Term<Element> operator * (Term<Element> const & term1, Term<Element> const & term2);
233 
241  template <typename Element>
242  bool operator>(Term<Element> const & term1, Term<Element> const & term2);
243 
251  template <typename Element>
252  bool operator<(Term<Element> const & term1, Term<Element> const & term2);
253 }
254 
256 #include "../src/term.inl"
259 #endif // OPENF4_TERM_H
void printTerm(std::ostream &stream) const
Print the term.
Represent a monomial.
Definition: monomial.h:46
void setTerm(std::string const s)
Initialize this with s.
Declaration of class ElementPrime.
int getNumMonomial() const
Get the number of the monomial of this.
Term()
Constructor.
void readCoefficient(std::string const s)
Get the coefficient of the term written s. Must be specialized for each type of Element.
Represent a term.
Definition: term.h:50
int compareTerm(Term< Element > const &term) const
Compare terms according to the grevlex order. Coefficient are not taking into accout.
Wrapper for config.h in order to avoid multiple definitions.
Element _coefficient
Definition: term.h:197
Declaration of class ElementGF2.
Represent a array of monomials.
Term< Element > operator*(Monomial const &mon, Term< Element > const &term)
Overload the operator *.
int _numMonomial
Definition: term.h:198
void multNumMon(int numMon)
Multiply this with a monomial under integer form.
Declaration of class ElementGivaro.
Term & operator*=(Monomial const &monomial)
Overload the operator *= to multiply this with a monomial.
static void setMonomialArray(MonomialArray *monomialArray)
Set the monomial array to use.
Declaration of class MonomialArray.
void setCoefficientOne()
Set the coefficient of this to 1.
void setNumMonomial(int numMon)
Set the number of the monomial of this.
static MonomialArray * MONOMIAL_ARRAY
Definition: term.h:200
Element getCoefficient() const
Get the coefficient of this.
bool operator>(Term< Element > const &term1, Term< Element > const &term2)
Overload the operator >.
void setCoefficient(Element coeff)
Set the coefficient of this.
Declaration of class ElementGF2Extension.
Term & operator=(Term const &term)
Overload the operator =.