IdealConsolidator.cpp
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/.
*/
#include "stdinc.h"
#include "IdealConsolidator.h"
#include "Term.h"
#include "TermTranslator.h"
IdealConsolidator::IdealConsolidator(unique_ptr<BigTermConsumer> consumer):
_consumer(std::move(consumer)),
_inList(false),
_inIdeal(false) {
}
void IdealConsolidator::consumeRing(const VarNames& names) {
ASSERT(!_inIdeal);
_consumer->consumeRing(names);
_names = names;
_ideal.clearAndSetNames(names);
_tmp.resize(names.getVarCount());
}
void IdealConsolidator::beginConsumingList() {
ASSERT(!_inList);
ASSERT(!_inIdeal);
_consumer->beginConsumingList();
_inList = true;
}
void IdealConsolidator::beginConsuming() {
ASSERT(!_inIdeal);
_inIdeal = true;
}
void IdealConsolidator::consume(const Term& term) {
ASSERT(term.getVarCount() == _tmp.size());
for (size_t var = 0; var < term.getVarCount(); ++var)
_tmp[var] = term[var];
consume(_tmp);
}
void IdealConsolidator::consume
(const Term& term, const TermTranslator& translator) {
ASSERT(term.getVarCount() == _tmp.size());
for (size_t var = 0; var < term.getVarCount(); ++var)
_tmp[var] = translator.getExponent(var, term);
consume(_tmp);
}
void IdealConsolidator::consume(const vector<mpz_class>& term) {
ASSERT(term.size() == _ideal.getVarCount());
// TODO: Add a method to BigIdeal that does this in one step.
_ideal.newLastTerm();
_ideal.getLastTermRef() = term;
}
void IdealConsolidator::doneConsuming() {
ASSERT(_inIdeal);
_inIdeal = false;
_consumer->consume(_ideal);
_ideal.clear();
}
void IdealConsolidator::doneConsumingList() {
ASSERT(_inList);
_inList = false;
_consumer->doneConsumingList();
}
void IdealConsolidator::consume(const BigIdeal& ideal) {
_consumer->consume(ideal);
}
IdealConsolidator.h
TermTranslator.h
Term.h
BigIdeal
Definition BigIdeal.h:27
IdealConsolidator::_consumer
const unique_ptr< BigTermConsumer > _consumer
Definition IdealConsolidator.h:47
IdealConsolidator::_ideal
BigIdeal _ideal
Definition IdealConsolidator.h:48
IdealConsolidator::_names
VarNames _names
Definition IdealConsolidator.h:49
IdealConsolidator::_inList
bool _inList
Definition IdealConsolidator.h:50
IdealConsolidator::consumeRing
virtual void consumeRing(const VarNames &names)
Tell the consumer which ring is being used.
Definition IdealConsolidator.cpp:29
IdealConsolidator::IdealConsolidator
IdealConsolidator(unique_ptr< BigTermConsumer > consumer)
Definition IdealConsolidator.cpp:23
IdealConsolidator::consume
virtual void consume(const Term &term)
Consume a term.
Definition IdealConsolidator.cpp:52
IdealConsolidator::doneConsumingList
virtual void doneConsumingList()
Must be called once after each time beginConsumingList has been called.
Definition IdealConsolidator.cpp:84
IdealConsolidator::beginConsuming
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
Definition IdealConsolidator.cpp:47
IdealConsolidator::_inIdeal
bool _inIdeal
Definition IdealConsolidator.h:51
IdealConsolidator::_tmp
vector< mpz_class > _tmp
Definition IdealConsolidator.h:52
IdealConsolidator::beginConsumingList
virtual void beginConsumingList()
Tell the consumer that the ideals that are consumed until the next call to doneConsumingList are to b...
Definition IdealConsolidator.cpp:39
IdealConsolidator::doneConsuming
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
Definition IdealConsolidator.cpp:76
TermTranslator
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Definition TermTranslator.h:41
TermTranslator::getExponent
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
Definition TermTranslator.cpp:392
Term
Term represents a product of variables which does not include a coefficient.
Definition Term.h:49
Term::getVarCount
size_t getVarCount() const
Definition Term.h:85
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40
VarNames::getVarCount
size_t getVarCount() const
Returns the current number of variables.
Definition VarNames.h:113
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...
ASSERT
#define ASSERT(X)
Definition stdinc.h:86