41 bool baseCaseSimple1(mpz_class& accumulator,
55 else if (genCount == 2)
65 bool optimizeSimpleFromDivCounts(mpz_class& accumulator,
73 for (
size_t var = 0; var < varCount; ++var) {
77 if (divCounts[var] < genCount - 2)
80 if (divCounts[var] == genCount - 1) {
81 const Word* nonMultiple =
91 }
else if (divCounts[var] == genCount - 2) {
102 ASSERT(divCounts[var] == genCount);
111 bool baseCaseSimple2(mpz_class& accumulator,
118 for (
size_t var = 0; var < varCount; ++var)
119 if (divCounts[var] != 1 && divCounts[var] != genCount)
123 accumulator += state.
getSign();
125 accumulator -= state.
getSign();
129 bool baseCasePreconditionSimplified(mpz_class& accumulator,
147 for (; var < varCount; ++var) {
148 if (divCounts[var] != 1)
160 for (++var; var < varCount; ++var) {
183 for (
size_t var = 0; var < varCount; ++var) {
204 ASSERT(state.debugIsValid());
206 if (baseCaseSimple1(
_euler, state))
213 optimizeOneDivCounts(state, divCountsTmp,
_termTmp))
216 optimizeSimpleFromDivCounts(
_euler, state, divCountsTmp,
_termTmp))
219 if (optimizeVarPairs(state,
_termTmp, divCountsTmp))
221 if (baseCasePreconditionSimplified(
_euler, state))
246 _useUniqueDivSimplify(true),
247 _useManyDivSimplify(true),
248 _useAllPairsSimplify(false),
249 _autoTranspose(true),
250 _initialAutoTranspose(true) {
303 if (nextState == 0) {
auto_ptr< PivotStrategy > newDefaultPivotStrategy()
static Arena & getArena()
Returns an arena object that can be used for non-thread safe scratch memory after static objects have...
void freeAndAllAfter(void *ptr)
Frees the buffer pointed to by ptr and all not yet freed allocations that have happened since that bu...
void removeGenerator(size_t index)
void toColonSubStateNoReminimizeNecessary(size_t pivotVar)
void compactEliminatedVariablesIfProfitable()
bool toColonSubState(const Word *pivot)
static EulerState * construct(const Ideal &idealParam, Arena *arena)
const Word * getEliminatedVars() const
size_t getVarCount() const
RawSquareFreeIdeal & getIdeal()
Represents a monomial ideal with int exponents.
size_t getGeneratorCount() const
size_t getVarCount() const
Emulates stack allocation of an array using an Arena.
bool _useAllPairsSimplify
EulerState * processState(EulerState &state)
bool _useUniqueDivSimplify
auto_ptr< PivotStrategy > _pivotStrategy
const mpz_class & computeEulerCharacteristic(const Ideal &ideal)
vector< size_t > _divCountsTmp
bool _initialAutoTranspose
bool autoTranspose(EulerState &state)
void computeEuler(EulerState *state)
void getPivot(const EulerState &state, Word *pivot)
A bit packed square free ideal placed in a pre-allocated buffer.
bool hasFullSupport(const Word *ignore) const
Returns true if for every variable it either divides ignore or it divides some (not necessarily minim...
void getVarDividesCounts(vector< size_t > &counts) const
Sets counts[var] to the number of generators that var divides.
size_t getVarCount() const
Word * getGenerator(size_t index)
Returns the generator at index.
size_t getNonMultiple(size_t var) const
Returns the index of the first generator that var does not divide or getGeneratorCount() if no such g...
size_t getMultiple(size_t var) const
Returns the index of the first generator that var divides or getGeneratorCount() if no such generator...
size_t getGeneratorCount() const
void getLcmOfNonMultiples(Word *lcm, size_t var) const
Sets lcm to be the least common multple of those generators that var does not divide.
void setExponent(Word *a, size_t var, bool value)
size_t getWordCount(size_t varCount)
bool hasFullSupport(const Word *a, size_t varCount)
void toZeroAtSupport(const Word *a, size_t *inc, size_t varCount)
For every variable var that divides a, set inc[var] to zero.
void lcmInPlace(Word *res, const Word *resEnd, const Word *a)
bool getExponent(const Word *a, size_t var)
returns true if var divides a and false otherwise.
void lcm(Word *res, const Word *resEnd, const Word *a, const Word *b)
void assign(Word *a, const Word *b, size_t varCount)
unsigned long Word
The native unsigned type for the CPU.