BigIdeal.h
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#ifndef BIG_IDEAL_GUARD
#define BIG_IDEAL_GUARD
#include "VarNames.h"
#include <vector>
class TermTranslator;
class Ideal;
class SquareFreeIdeal;
class BigIdeal {
public:
BigIdeal();
BigIdeal(const VarNames& names);
void insert(const Ideal& ideal);
void insert(const Ideal& ideal, const TermTranslator& translator);
void insert(const SquareFreeIdeal& ideal);
void insert(const vector<mpz_class>& term);
void renameVars(const VarNames& names);
void newLastTerm();
void reserve(size_t capacity);
mpz_class& getLastTermExponentRef(size_t var);
vector<mpz_class>& getLastTermRef();
const vector<mpz_class>& getTerm(size_t term) const;
void getLcm(vector<mpz_class>& lcm) const;
const mpz_class& getExponent(size_t term, size_t var) const;
mpz_class& getExponent(size_t term, size_t var);
void setExponent(size_t term, size_t var, const mpz_class& exp);
bool operator==(const BigIdeal& b) const;
vector<mpz_class>& operator[](size_t index);
const vector<mpz_class>& operator[](size_t index) const;
void projectVar(size_t var);
// This also depends on the order of the variables.
bool operator<(const BigIdeal& ideal) const;
bool empty() const;
bool containsIdentity() const;
bool contains(const vector<mpz_class>& term) const;
void clear();
inline size_t getGeneratorCount() const;
size_t getVarCount() const;
void clearAndSetNames(const VarNames& names);
// Adds a variable to the VarNames associated to the ideal. It is an
// error to call this method when the ideal has any generators. If
// var is already a known variable, nothing is changed, and the
// return value is false. Otherwise, the return value is true.
bool addVarToClearedIdeal(const char* var);
// Remove variable from each generator and from the ring.
void eraseVar(size_t var);
const VarNames& getNames() const;
// Applies a generic deformation.
void deform();
// Takes the radical of every generator.
void takeRadical();
// Sorts the generators and removes duplicates.
void sortGeneratorsUnique();
// Sorts the generators.
void sortGenerators();
// Sorts the variables.
void sortVariables();
void swap(BigIdeal& ideal);
void print(FILE* file) const;
void print(ostream& out) const;
static bool bigTermCompare(const vector<mpz_class>& a,
const vector<mpz_class>& b);
private:
vector<vector<mpz_class> > _terms;
VarNames _names;
};
ostream& operator<<(ostream& out, const BigIdeal& ideal);
ostream& operator<<(ostream& out, const vector<BigIdeal>& ideals);
inline vector<mpz_class>& BigIdeal::operator[](size_t index) {
ASSERT(index < _terms.size());
return _terms[index];
}
inline const vector<mpz_class>& BigIdeal::operator[](size_t index) const {
ASSERT(index < _terms.size());
return _terms[index];
}
inline mpz_class& BigIdeal::getLastTermExponentRef(size_t var) {
ASSERT(!empty());
ASSERT(var < _names.getVarCount());
return _terms.back()[var];
}
inline vector<mpz_class>& BigIdeal::getLastTermRef() {
ASSERT(!empty());
return _terms.back();
}
inline const vector<mpz_class>& BigIdeal::getTerm(size_t term) const {
ASSERT(term < getGeneratorCount());
return _terms[term];
}
inline size_t BigIdeal::getGeneratorCount() const {
return _terms.size();
}
inline size_t BigIdeal::getVarCount() const {
return _names.getVarCount();
}
#endif
operator<<
ostream & operator<<(ostream &out, const BigIdeal &ideal)
Definition BigIdeal.cpp:361
VarNames.h
BigIdeal
Definition BigIdeal.h:27
BigIdeal::reserve
void reserve(size_t capacity)
Definition BigIdeal.cpp:112
BigIdeal::eraseVar
void eraseVar(size_t var)
Definition BigIdeal.cpp:233
BigIdeal::sortGenerators
void sortGenerators()
Definition BigIdeal.cpp:280
BigIdeal::clearAndSetNames
void clearAndSetNames(const VarNames &names)
Definition BigIdeal.cpp:222
BigIdeal::newLastTerm
void newLastTerm()
Definition BigIdeal.cpp:104
BigIdeal::swap
void swap(BigIdeal &ideal)
Definition BigIdeal.cpp:305
BigIdeal::bigTermCompare
static bool bigTermCompare(const vector< mpz_class > &a, const vector< mpz_class > &b)
Definition BigIdeal.cpp:349
BigIdeal::empty
bool empty() const
Definition BigIdeal.cpp:192
BigIdeal::sortGeneratorsUnique
void sortGeneratorsUnique()
Definition BigIdeal.cpp:273
BigIdeal::getTerm
const vector< mpz_class > & getTerm(size_t term) const
Definition BigIdeal.h:139
BigIdeal::getLastTermExponentRef
mpz_class & getLastTermExponentRef(size_t var)
Definition BigIdeal.h:126
BigIdeal::renameVars
void renameVars(const VarNames &names)
Definition BigIdeal.cpp:99
BigIdeal::getLcm
void getLcm(vector< mpz_class > &lcm) const
Definition BigIdeal.cpp:143
BigIdeal::contains
bool contains(const vector< mpz_class > &term) const
Definition BigIdeal.cpp:207
BigIdeal::_terms
vector< vector< mpz_class > > _terms
Definition BigIdeal.h:107
BigIdeal::deform
void deform()
Definition BigIdeal.cpp:257
BigIdeal::getVarCount
size_t getVarCount() const
Definition BigIdeal.h:148
BigIdeal::clear
void clear()
Definition BigIdeal.cpp:218
BigIdeal::operator==
bool operator==(const BigIdeal &b) const
Definition BigIdeal.cpp:154
BigIdeal::_names
VarNames _names
Definition BigIdeal.h:108
BigIdeal::insert
void insert(const Ideal &ideal)
Definition BigIdeal.cpp:60
BigIdeal::getNames
const VarNames & getNames() const
Definition BigIdeal.cpp:253
BigIdeal::getGeneratorCount
size_t getGeneratorCount() const
Definition BigIdeal.h:144
BigIdeal::BigIdeal
BigIdeal()
Definition BigIdeal.cpp:53
BigIdeal::projectVar
void projectVar(size_t var)
Definition BigIdeal.cpp:158
BigIdeal::sortVariables
void sortVariables()
Definition BigIdeal.cpp:298
BigIdeal::operator<
bool operator<(const BigIdeal &ideal) const
Definition BigIdeal.cpp:166
BigIdeal::print
void print(FILE *file) const
Definition BigIdeal.cpp:310
BigIdeal::operator[]
vector< mpz_class > & operator[](size_t index)
Definition BigIdeal.h:116
BigIdeal::takeRadical
void takeRadical()
Definition BigIdeal.cpp:264
BigIdeal::containsIdentity
bool containsIdentity() const
Definition BigIdeal.cpp:196
BigIdeal::getExponent
const mpz_class & getExponent(size_t term, size_t var) const
Definition BigIdeal.cpp:328
BigIdeal::addVarToClearedIdeal
bool addVarToClearedIdeal(const char *var)
Definition BigIdeal.cpp:227
BigIdeal::getLastTermRef
vector< mpz_class > & getLastTermRef()
Definition BigIdeal.h:133
BigIdeal::setExponent
void setExponent(size_t term, size_t var, const mpz_class &exp)
Definition BigIdeal.cpp:342
Ideal
Represents a monomial ideal with int exponents.
Definition Ideal.h:27
SquareFreeIdeal
Definition SquareFreeIdeal.h:24
TermTranslator
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Definition TermTranslator.h:41
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40
ASSERT
#define ASSERT(X)
Definition stdinc.h:86