UniHashPolynomial.h
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2009 University of Aarhus
Contact Bjarke Hammersholt Roune for license information (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#ifndef UNI_HASH_POLYNOMIAL_GUARD
#define UNI_HASH_POLYNOMIAL_GUARD
#include "HashMap.h"
class CoefBigTermConsumer;
template<>
class FrobbyHash<mpz_class> {
public:
size_t operator()(const mpz_class& i) const {
// The constant is a prime. This method needs to be improved.
return mpz_fdiv_ui(i.get_mpz_t(), 2106945901u);
}
};
class UniHashPolynomial {
public:
void add(bool plus, const mpz_class& exponent);
void add(int coef, size_t exponent);
void add(const mpz_class& coef, const mpz_class& exponent);
void feedTo(CoefBigTermConsumer& consumer, bool inCanonicalOrder = false) const;
size_t getTermCount() const;
private:
typedef HashMap<mpz_class, mpz_class> TermMap;
TermMap _terms;
};
#endif
HashMap.h
The purpose of this file is to provide a definition of a hash map whenever possible.
CoefBigTermConsumer
Definition CoefBigTermConsumer.h:29
FrobbyHash< mpz_class >::operator()
size_t operator()(const mpz_class &i) const
Definition UniHashPolynomial.h:31
FrobbyHash
Definition HashMap.h:35
HashMap
Definition HashMap.h:93
UniHashPolynomial
A sparse univariate polynomial represented by a hash table mapping terms to coefficients.
Definition UniHashPolynomial.h:41
UniHashPolynomial::TermMap
HashMap< mpz_class, mpz_class > TermMap
Definition UniHashPolynomial.h:58
UniHashPolynomial::_terms
TermMap _terms
Definition UniHashPolynomial.h:59
UniHashPolynomial::getTermCount
size_t getTermCount() const
Definition UniHashPolynomial.cpp:110
UniHashPolynomial::feedTo
void feedTo(CoefBigTermConsumer &consumer, bool inCanonicalOrder=false) const
Definition UniHashPolynomial.cpp:64
UniHashPolynomial::add
void add(bool plus, const mpz_class &exponent)
Add +t^exponent or -t^exponent to the polynomial depending on whether plus is true or false,...
Definition UniHashPolynomial.cpp:25