Frobby 0.9.5
Polynomial.h
Go to the documentation of this file.
1/* Frobby: Software for monomial ideal computations.
2 Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see http://www.gnu.org/licenses/.
16*/
17#ifndef POLYNOMIAL_GUARD
18#define POLYNOMIAL_GUARD
19
20#include "Term.h"
21#include <vector>
22
24 public:
25 Polynomial();
26 Polynomial(size_t varCount);
27
28 size_t getVarCount() const;
29 size_t getTermCount() const;
30
31 const mpz_class& getCoef(size_t index) const;
32 const Term& getTerm(size_t index) const;
33
34 // Add coef*term to the polynomial. Does not collect terms with the
35 // same exponents. Does nothing if coef is zero.
36 void add(const mpz_class& coef, const Term& term);
37
38 // Sort the terms in reverse lexicographic order. Also adds
39 // same-monomial terms and removes zero coefficients if collect is
40 // true.
41 void sortTermsReverseLex(bool collect = true);
42
43 void clear();
44 void clearAndSetVarCount(size_t varCount);
45
46 void print(FILE* out);
47 void print(ostream& out);
48
49 private:
50 struct CoefTerm {
51 bool operator<(const CoefTerm& coefTerm) const;
52
53 mpz_class coef;
55 };
56
57 vector<CoefTerm> _terms;
58 size_t _varCount;
59};
60
61#endif
void clearAndSetVarCount(size_t varCount)
size_t getTermCount() const
void print(FILE *out)
size_t getVarCount() const
const Term & getTerm(size_t index) const
vector< CoefTerm > _terms
Definition Polynomial.h:57
void sortTermsReverseLex(bool collect=true)
size_t _varCount
Definition Polynomial.h:58
void add(const mpz_class &coef, const Term &term)
const mpz_class & getCoef(size_t index) const
Term represents a product of variables which does not include a coefficient.
Definition Term.h:49
bool operator<(const CoefTerm &coefTerm) const