Frobby 0.10.0
Loading...
Searching...
No Matches
BigPolynomial.h
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 BIG_POLYNOMIAL_GUARD
18#define BIG_POLYNOMIAL_GUARD
19
20class VarNames;
21class Term;
22class TermTranslator;
23
24#include "VarNames.h"
25#include <vector>
26
27class BigPolynomial {
28 public:
29 BigPolynomial();
30 BigPolynomial(const VarNames& names);
31
32 size_t getTermCount() const;
33 size_t getVarCount() const;
34 const VarNames& getNames() const;
35
36 // Removes all terms but does not change getNames().
37 void clear();
38 void clearAndSetNames(const VarNames& names);
39
40 void sortTermsReverseLex();
41 void sortVariables();
42
43 const mpz_class& getCoef(size_t index) const;
44 const vector<mpz_class>& getTerm(size_t index) const;
45
46 void newLastTerm();
47 vector<mpz_class>& getLastTerm();
48 mpz_class& getLastCoef();
49
50 void renameVars(const VarNames& names);
51
52 void add(const mpz_class& coef, const vector<mpz_class> term);
53 void add(const mpz_class& coef, const Term& term,
54 const TermTranslator& translator);
55
56 bool operator==(const BigPolynomial& poly) const;
57
58 void print(FILE* file) const;
59 void print(ostream& out) const;
60
61 private:
62 struct BigCoefTerm {
63 mpz_class coef;
64 vector<mpz_class> term;
65
66 bool operator==(const BigCoefTerm& coefTerm) const;
67 };
68 typedef vector<BigCoefTerm>::iterator iterator;
69 typedef vector<BigCoefTerm>::const_iterator const_iterator;
70
71 static bool compareCoefTermsReverseLex
72 (const BigCoefTerm& a, const BigCoefTerm& b);
73
74 VarNames _names;
75 vector<BigCoefTerm> _coefTerms;
76};
77
78ostream& operator<<(ostream& out, const BigPolynomial& ideal);
79
80#endif
Definition BigPolynomial.h:27
Definition TermTranslator.h:41
Definition Term.h:49
Definition VarNames.h:38