Frobby 0.9.5
UniHashPolynomial.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 UNI_HASH_POLYNOMIAL_GUARD
19#define UNI_HASH_POLYNOMIAL_GUARD
20
21#include "HashMap.h"
22
24
28template<>
29class FrobbyHash<mpz_class> {
30 public:
31 size_t operator()(const mpz_class& i) const {
32 // The constant is a prime. This method needs to be improved.
33 return mpz_fdiv_ui(i.get_mpz_t(), 2106945901u);
34 }
35};
36
42 public:
45 void add(bool plus, const mpz_class& exponent);
46
48 void add(int coef, size_t exponent);
49
51 void add(const mpz_class& coef, const mpz_class& exponent);
52
53 void feedTo(CoefBigTermConsumer& consumer, bool inCanonicalOrder = false) const;
54
55 size_t getTermCount() const;
56
57 private:
60};
61
62#endif
The purpose of this file is to provide a definition of a hash map whenever possible.
size_t operator()(const mpz_class &i) const
A sparse univariate polynomial represented by a hash table mapping terms to coefficients.
size_t getTermCount() const
void feedTo(CoefBigTermConsumer &consumer, bool inCanonicalOrder=false) const
HashMap< mpz_class, mpz_class > TermMap
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,...