39 bool doStrongDeformation):
41 _tmp(toDeform.getVarCount()),
42 _deformer(toDeform, order, doStrongDeformation),
46 _poly(toDeform.getVarCount()) {
56 virtual void consume(
const mpz_class& coef,
const Term& term) {
62 if (_tmp.getVarCount() == 0)
66 for (
size_t var = 1; var < _tmp.getVarCount(); ++var)
95 auto_ptr<IdealOrderer> enumerationOrder,
96 auto_ptr<IdealOrderer> deformationOrder):
97 _translator(translator),
99 _enumerationOrder(enumerationOrder),
100 _deformationOrder(deformationOrder),
103 ASSERT(_enumerationOrder.get() != 0);
104 ASSERT(_deformationOrder.get() != 0);
116 Ideal deformed(ideal);
126 undeformer.beginConsuming();
130 undeformer.doneConsuming();
133 fputs(
"*** Statistics ***\n", stderr);
134 fprintf(stderr,
"Total states considered: %u\n",
136 fprintf(stderr,
"Total faces accepted: %u\n",
142 size_t& activeStateCount) {
146 fputs(
"Enumerating faces of Scarf complex of:\n", stderr);
155 if (
_states.size() < statesNeeded) {
157 for (
size_t i = 0; i <
_states.size(); ++i) {
164 activeStateCount = 0;
179 fputs(
"DEBUG:*Looking at element ", stderr);
180 if (state.
pos == ideal.
end())
181 fputs(
"end", stderr);
184 fputs(
" with lcm(face)=", stderr);
186 fputs(
" and face=", stderr);
187 if (state.
face.empty())
188 fputs(
"empty", stderr);
189 for (
size_t i = 0; i < state.
face.size(); ++i) {
190 fputs(
"\nDEBUG: ", stderr);
203 termToAdd = *state.
pos;
215 for (
size_t i = 0; i < state.
face.size(); ++i) {
231 nextState.
pos = state.
pos;
233 nextState.
face.push_back(termToAdd);
241 fputs(
"DEBUG: Found base case with lcm(face)=", stderr);
260 size_t activeStateCount = 0;
262 while (activeStateCount > 0) {
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
void runGeneric(const Ideal &ideal, CoefBigTermConsumer &consumer, bool univariate, bool canonical)
bool doEnumerationStep(const Ideal &ideal, const IdealTree &tree, State &state, State &nextState)
void add(const mpz_class &coef, const Term &term)
Add coef*term to the polynomial.
A sparse univariate polynomial represented by a hash table mapping terms to coefficients.
void print(FILE *file) const
void doEnumerationBaseCase(const State &state, CoefTermConsumer &consumer)
bool getPrintStatistics() const
Returns whether to print statistics on what the algorithm did to standard error after it has run...
bool getPrintDebug() const
Returns whether to print information about what the algorithm is doing to standard error as it runs...
ScarfHilbertAlgorithm(const TermTranslator &translator, const ScarfParams ¶ms, auto_ptr< IdealOrderer > enumerationOrder, auto_ptr< IdealOrderer > deformationOrder)
Represents a monomial ideal with int exponents.
Defines the variables of a polynomial ring and facilities IO involving them.
static bool strictlyDivides(const Exponent *a, const Exponent *b, size_t varCount)
Returns whether a strictly divides b.
size_t getVarCount() const
void initializeEnumeration(const Ideal &ideal, size_t &activeStateCount)
const auto_ptr< IdealOrderer > _deformationOrder
size_t getVarCount() const
Objects of this class represents a monomial ideal.
size_t getVarCount() const
bool containsIdentity() const
const ScarfParams & _params
A sparse multivariate polynomial represented by a hash table mapping terms to coefficients.
const VarNames & getNames() const
const_iterator end() const
const auto_ptr< IdealOrderer > _enumerationOrder
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Ideal::const_iterator pos
void add(bool plus, const mpz_class &exponent)
Add +t^exponent or -t^exponent to the polynomial depending on whether plus is true or false...
static void print(FILE *file, const Exponent *e, size_t varCount)
Writes e to file in a format suitable for debug output.
const TermTranslator & _translator
void enumerateScarfComplex(const Ideal &ideal, CoefTermConsumer &consumer)
void feedTo(const TermTranslator &translator, CoefBigTermConsumer &consumer, bool inCanonicalOrder) const
bool strictlyContains(const Exponent *term) const
const_iterator begin() const
void feedTo(CoefBigTermConsumer &consumer, bool inCanonicalOrder=false) const
virtual void consume(const Polynomial &poly)
bool getDeformToStronglyGeneric() const
Returns true if deforming to a strongly generic ideal.
static void lcm(Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
Sets res equal to the least commom multiple of a and b.
vector< Exponent * > face
Term represents a product of variables which does not include a coefficient.
bool strictlyContains(const Exponent *term) const
size_t getGeneratorCount() const