Frobby  0.9.5
BigPolynomial.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 BIG_POLYNOMIAL_GUARD
18 #define BIG_POLYNOMIAL_GUARD
19 
20 class VarNames;
21 class Term;
22 class TermTranslator;
23 
24 #include "VarNames.h"
25 #include <vector>
26 
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 
75  vector<BigCoefTerm> _coefTerms;
76 };
77 
78 ostream& operator<<(ostream& out, const BigPolynomial& ideal);
79 
80 #endif
ostream & operator<<(ostream &out, const BigPolynomial &ideal)
mpz_class & getLastCoef()
const vector< mpz_class > & getTerm(size_t index) const
size_t getTermCount() const
vector< BigCoefTerm >::const_iterator const_iterator
Definition: BigPolynomial.h:69
vector< BigCoefTerm > _coefTerms
Definition: BigPolynomial.h:75
void add(const mpz_class &coef, const vector< mpz_class > term)
VarNames _names
Definition: BigPolynomial.h:74
size_t getVarCount() const
void sortVariables()
void clearAndSetNames(const VarNames &names)
const mpz_class & getCoef(size_t index) const
void renameVars(const VarNames &names)
vector< BigCoefTerm >::iterator iterator
Definition: BigPolynomial.h:68
void print(FILE *file) const
vector< mpz_class > & getLastTerm()
const VarNames & getNames() const
bool operator==(const BigPolynomial &poly) const
void sortTermsReverseLex()
static bool compareCoefTermsReverseLex(const BigCoefTerm &a, const BigCoefTerm &b)
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
vector< mpz_class > term
Definition: BigPolynomial.h:64
bool operator==(const BigCoefTerm &coefTerm) const