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):
99 _enumerationOrder(enumerationOrder),
100 _deformationOrder(deformationOrder),
103 ASSERT(_enumerationOrder.get() != 0);
104 ASSERT(_deformationOrder.get() != 0);
116 Ideal deformed(ideal);
123 _params.getDeformToStronglyGeneric());
126 undeformer.beginConsuming();
127 ASSERT(_enumerationOrder.get() != 0);
128 _enumerationOrder->order(deformed);
129 enumerateScarfComplex(deformed, undeformer);
130 undeformer.doneConsuming();
132 if (_params.getPrintStatistics()) {
133 fputs(
"*** Statistics ***\n", stderr);
134 fprintf(stderr,
"Total states considered: %u\n",
135 static_cast<unsigned int>(_totalStates));
136 fprintf(stderr,
"Total faces accepted: %u\n",
137 static_cast<unsigned int>(_totalFaces));
142 size_t& activeStateCount) {
145 if (_params.getPrintDebug()) {
146 fputs(
"Enumerating faces of Scarf complex of:\n", stderr);
155 if (_states.size() < statesNeeded) {
156 _states.resize(statesNeeded);
157 for (
size_t i = 0; i < _states.size(); ++i) {
164 activeStateCount = 0;
169 _states[0].plus =
true;
170 _states[0].pos = ideal.
begin();
171 ASSERT(_states[0].term.isIdentity());
178 if (_params.getPrintDebug()) {
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);
240 if (_params.getPrintDebug()) {
241 fputs(
"DEBUG: Found base case with lcm(face)=", stderr);
260 size_t activeStateCount = 0;
261 initializeEnumeration(ideal, activeStateCount);
262 while (activeStateCount > 0) {
263 ASSERT(activeStateCount < _states.size());
264 State& currentState = _states[activeStateCount - 1];
265 State& nextState = _states[activeStateCount];
266 if (doEnumerationStep(ideal, tree, currentState, nextState))
269 doEnumerationBaseCase(currentState, consumer);
void runGeneric(const Ideal &ideal, CoefBigTermConsumer &consumer, bool univariate, bool canonical)
bool doEnumerationStep(const Ideal &ideal, const IdealTree &tree, State &state, State &nextState)
const VarNames & getNames() const
bool containsIdentity() const
void add(const mpz_class &coef, const Term &term)
Add coef*term to the polynomial.
size_t getVarCount() const
bool strictlyContains(const Exponent *term) const
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)
const_iterator begin() const
bool strictlyContains(const Exponent *term) const
void feedTo(const TermTranslator &translator, CoefBigTermConsumer &consumer, bool inCanonicalOrder) const
ScarfHilbertAlgorithm(const TermTranslator &translator, const ScarfParams ¶ms, auto_ptr< IdealOrderer > enumerationOrder, auto_ptr< IdealOrderer > deformationOrder)
Represents a monomial ideal with int exponents.
const_iterator end() const
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.
void initializeEnumeration(const Ideal &ideal, size_t &activeStateCount)
Objects of this class represents a monomial ideal.
const mpz_class & getExponent(size_t variable, Exponent exponent) const
This method translates from IDs to arbitrary precision integers.
size_t getVarCount() const
A sparse multivariate polynomial represented by a hash table mapping terms to coefficients.
size_t getGeneratorCount() const
size_t getVarCount() const
void feedTo(CoefBigTermConsumer &consumer, bool inCanonicalOrder=false) const
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.
void enumerateScarfComplex(const Ideal &ideal, CoefTermConsumer &consumer)
virtual void consume(const Polynomial &poly)
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.