Frobby  0.9.5
TermTranslator.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 TERM_TRANSLATOR_GUARD
18 #define TERM_TRANSLATOR_GUARD
19 
20 #include "VarNames.h"
21 
22 #include <vector>
23 #include <ostream>
24 
25 class BigIdeal;
26 class Ideal;
27 class Term;
28 
42 public:
46  TermTranslator(size_t varCount, size_t upToExponent);
47 
52  TermTranslator(const BigIdeal& bigIdeal, Ideal& ideal, bool sortVars = true);
53 
59  TermTranslator(const vector<BigIdeal*>& bigIdeals, vector<Ideal*>& ideals);
60 
61  TermTranslator(const TermTranslator& translator);
63 
64  TermTranslator& operator=(const TermTranslator& translator);
65 
68  const mpz_class& getExponent(size_t variable, Exponent exponent) const;
69 
72  const mpz_class& getExponent(size_t variable, const Term& term) const;
73 
78  const char* getVarExponentString(size_t variable, Exponent exponent) const;
79 
83  const char* getExponentString(size_t variable, Exponent exponent) const;
84 
88  Exponent getMaxId(size_t variable) const;
89 
97  void addPurePowersAtInfinity(Ideal& ideal) const;
98 
103  void setInfinityPowersToZero(Ideal& ideal) const;
104 
105  const VarNames& getNames() const;
106  size_t getVarCount() const;
107 
111  void dualize(const vector<mpz_class>& a);
112 
114  void decrement();
115 
116  void renameVariables(const VarNames& names);
117  void swapVariables(size_t a, size_t b);
118 
119  bool lessThanReverseLex(const Exponent* a, const Exponent* b) const;
120 
121  void print(ostream& out) const;
122  string toString() const;
123 
124 private:
125  void makeStrings(bool includeVar) const;
126  void clearStrings();
127 
128  void initialize(const vector<BigIdeal*>& bigIdeals, bool sortVars);
129  void shrinkBigIdeal(const BigIdeal& bigIdeal, Ideal& ideal) const;
130  Exponent shrinkExponent(size_t var, const mpz_class& exponent) const;
131 
132  vector<vector<mpz_class> > _exponents;
133  mutable vector<vector<const char*> > _stringExponents;
134  mutable vector<vector<const char*> > _stringVarExponents;
136 };
137 
142  public:
144  _translator(translator) {
145  }
146 
147  bool operator()(const Term& a, const Term& b) const;
148  bool operator()(const Exponent* a, const Exponent* b) const;
149 
150  private:
152 };
153 
154 void setToZeroOne(TermTranslator& translator);
155 
156 ostream& operator<<(ostream& out, const TermTranslator& translator);
157 
158 #endif
void setToZeroOne(TermTranslator &translator)
ostream & operator<<(ostream &out, const TermTranslator &translator)
Represents a monomial ideal with int exponents.
Definition: Ideal.h:27
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
void swapVariables(size_t a, size_t b)
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
size_t getVarCount() const
void addPurePowersAtInfinity(Ideal &ideal) const
Adds a generator of the form v^e, e > 0, for any variable v where generator of that form is not alrea...
void renameVariables(const VarNames &names)
bool lessThanReverseLex(const Exponent *a, const Exponent *b) const
vector< vector< const char * > > _stringExponents
TermTranslator(size_t varCount, size_t upToExponent)
Constructs a translator of varCount variables that translates each number to itself,...
void makeStrings(bool includeVar) const
string toString() const
vector< vector< const char * > > _stringVarExponents
void dualize(const vector< mpz_class > &a)
Replaces var^v by var^(a[i] - v) except that var^0 is left alone.
TermTranslator & operator=(const TermTranslator &translator)
const char * getExponentString(size_t variable, Exponent exponent) const
as getExponent, except the string "e" is returned, where e is the exponent.
Exponent getMaxId(size_t variable) const
The assigned IDs are those in the range [0, getMaxId(var)].
Exponent shrinkExponent(size_t var, const mpz_class &exponent) const
void shrinkBigIdeal(const BigIdeal &bigIdeal, Ideal &ideal) const
vector< vector< mpz_class > > _exponents
void initialize(const vector< BigIdeal * > &bigIdeals, bool sortVars)
void setInfinityPowersToZero(Ideal &ideal) const
The method addPurePowersAtInfinity adds high exponents that map to zero.
const char * getVarExponentString(size_t variable, Exponent exponent) const
As getExponent, except the string "var^e" is returned or null if the exponent is zero,...
void decrement()
Replaces var^v by var^(v-1).
void print(ostream &out) const
const VarNames & getNames() const
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
A predicate that sorts according to reverse lexicographic order on the translated values of a term.
TranslatedReverseLexComparator(const TermTranslator &translator)
bool operator()(const Term &a, const Term &b) const
const TermTranslator & _translator
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
unsigned int Exponent
Definition: stdinc.h:89