Frobby  0.9.0
HashPolynomial.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2009 University of Aarhus
3  Contact Bjarke Hammersholt Roune for license information (www.broune.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see http://www.gnu.org/licenses/.
17 */
18 #ifndef HASH_POLYNOMIAL_GUARD
19 #define HASH_POLYNOMIAL_GUARD
20 
21 #include "Term.h"
22 #include "HashMap.h"
23 
25 class TermTranslator;
26 
30 template<>
31 class FrobbyHash<Term> {
32  public:
33  size_t operator()(const Term& t) const {
34  return t.getHashCode();
35  }
36 };
37 
43  public:
44  HashPolynomial(size_t varCount = 0);
45 
46  void clearAndSetVarCount(size_t varCount);
47 
49  void add(const mpz_class& coef, const Term& term);
50 
53  void add(bool plus, const Term& term);
54 
55  void feedTo(const TermTranslator& translator,
56  CoefBigTermConsumer& consumer,
57  bool inCanonicalOrder) const;
58 
59  size_t getTermCount() const;
60 
61  private:
62  size_t _varCount;
63 
66 };
67 
68 #endif
HashMap< Term, mpz_class >
CoefBigTermConsumer
Definition: CoefBigTermConsumer.h:29
HashPolynomial::clearAndSetVarCount
void clearAndSetVarCount(size_t varCount)
Definition: HashPolynomial.cpp:31
HashPolynomial
A sparse multivariate polynomial represented by a hash table mapping terms to coefficients.
Definition: HashPolynomial.h:42
HashPolynomial::_varCount
size_t _varCount
Definition: HashPolynomial.h:62
HashPolynomial::_terms
TermMap _terms
Definition: HashPolynomial.h:65
Term.h
TermTranslator
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Definition: TermTranslator.h:41
HashPolynomial::TermMap
HashMap< Term, mpz_class > TermMap
Definition: HashPolynomial.h:64
HashPolynomial::getTermCount
size_t getTermCount() const
Definition: HashPolynomial.cpp:117
Term
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
HashPolynomial::feedTo
void feedTo(const TermTranslator &translator, CoefBigTermConsumer &consumer, bool inCanonicalOrder) const
Definition: HashPolynomial.cpp:77
FrobbyHash
Definition: HashMap.h:35
Term::getHashCode
static size_t getHashCode(const Exponent *a, size_t varCount)
Definition: Term.h:416
HashMap.h
HashPolynomial::HashPolynomial
HashPolynomial(size_t varCount=0)
Definition: HashPolynomial.cpp:27
FrobbyHash< Term >::operator()
size_t operator()(const Term &t) const
Definition: HashPolynomial.h:33
HashPolynomial::add
void add(const mpz_class &coef, const Term &term)
Add coef*term to the polynomial.
Definition: HashPolynomial.cpp:36