F4
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 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_TERM_H
27 #define F4_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  /* Destructor */
98 
102  ~Term();
103 
104 
105  /* Get / Set */
106 
111  Element getCoefficient() const;
112 
117  void setCoefficient(Element coeff);
118 
123  void setCoefficientOne();
124 
129  int getNumMonomial() const;
130 
135  void setNumMonomial(int numMon);
136 
141  void setTerm(std::string const s);
142 
143 
144  /* Miscellaneous */
145 
151  void readCoefficient(std::string const s);
152 
156  void printTerm (std::ostream & stream) const;
157 
162  void multNumMon(int numMon);
163 
171  int compareTerm(Term<Element> const & term) const;
172 
173 
174  /* Internal operators */
175 
181  Term & operator=(Term const & term);
182 
188  Term & operator*=(Monomial const & monomial);
189 
195  Term & operator*=(Element element);
196 
202  Term & operator*=(Term const & term);
203 
204  private:
205  Element _coefficient;
209  };
210 
211 
212  /* External operators */
213 
218  template <typename Element>
219  std::ostream & operator<<(std::ostream & stream, Term<Element> const & term);
220 
225  template <typename Element>
226  Term<Element> operator * (Monomial const & mon, Term<Element> const & term);
227 
232  template <typename Element>
233  Term<Element> operator * (Term<Element> const & term, Monomial const & mon);
234 
239  template <typename Element>
240  Term<Element> operator * (Term<Element> const & term1, Term<Element> const & term2);
241 
249  template <typename Element>
250  bool operator>(Term<Element> const & term1, Term<Element> const & term2);
251 
259  template <typename Element>
260  bool operator<(Term<Element> const & term1, Term<Element> const & term2);
261 }
262 
264 #include "../src/term.inl"
267 #endif // F4_TERM_H
void printTerm(std::ostream &stream) const
Print the term.
Represent a monomial.
Definition: monomial.h:46
ElementGF2Extension< baseType > operator*(ElementGF2Extension< baseType > const &element1, ElementGF2Extension< baseType > const &element2)
Overload the operator *.
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
~Term()
Destructor.
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:205
Declaration of class ElementGF2.
Represent a array of monomials.
int _numMonomial
Definition: term.h:206
void multNumMon(int numMon)
Multiply this with a monomial under integer form.
bool operator>(CriticalPair< Element > const &criticalPair1, CriticalPair< Element > const &criticalPair2)
Overload the operator >.
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:208
Element getCoefficient() const
Get the coefficient of this.
void setCoefficient(Element coeff)
Set the coefficient of this.
Declaration of class ElementGF2Extension.
Term & operator=(Term const &term)
Overload the operator =.