44 const size_t*
it =
rare + 1;
45 for (;
it != end; ++
it)
58 for (
size_t var = 0; var <
varCount; ++var)
63 class RawSquareFreeTerm {
65 RawSquareFreeTerm(): _term(0), _capacity(0) {}
68 operator Word*() {
return _term;}
69 operator const Word*()
const {
return _term;}
71 void reserve(
const size_t varCount) {
92 RawSquareFreeTerm _term;
95 class StdStrategy :
public WithPivotTerm {
101 return state.getVarCount() >
state.getIdeal().getGeneratorCount();
105 class StdPopVar :
public StdStrategy {
120 static const char* staticGetName() {
125 out << staticGetName();
129 class StdRareVar :
public StdStrategy {
144 static const char* staticGetName() {
149 out << staticGetName();
153 class StdPopGcd :
public StdStrategy {
173 for (;
it != end; ++
it) {
188 static const char* staticGetName() {
193 out << staticGetName();
197 class StdRandom :
public StdStrategy {
213 static const char* staticGetName() {
218 out << staticGetName();
231 class StdAny :
public StdStrategy {
247 static const char* staticGetName() {
252 out << staticGetName();
257 for (
size_t var = 0; ; ++var) {
265 class StdWiden :
public WithPivotTerm {
269 ASSERT(_strat.get() != 0);
282 _strat->getName(
out);
286 _strat->computationCompleted(
alg);
290 return _strat->shouldTranspose(
state);
297 class GenStrategy :
public WithPivotTerm {
301 virtual iterator
filter(iterator begin, iterator end,
306 return state.getVarCount() <
state.getIdeal().getGeneratorCount();
310 class GenPopVar :
public GenStrategy {
319 virtual iterator
filter(iterator begin, iterator end,
325 for (
size_t var = 0; var <
varCount; ++var)
330 for (iterator
it = begin;
it != end; ++
it) {
339 static const char* staticGetName() {
344 out << staticGetName();
348 class GenRareMax :
public GenStrategy {
356 const const_iterator end = ideal.
end();
358 const_iterator
best = end;
359 for (const_iterator
it = ideal.
begin();
it != end; ++
it) {
372 virtual iterator
filter(iterator begin, iterator end,
379 for (iterator
it = begin;
it != end; ++
it) {
395 static const char* staticGetName() {
400 out << staticGetName();
404 class GenRareVar :
public GenStrategy {
413 virtual iterator
filter(iterator begin, iterator end,
419 for (iterator
it = begin;
it != end; ++
it) {
428 static const char* staticGetName() {
433 out << staticGetName();
441 _filtersDeleter(_filters) {
452 const iterator begin =
state.getIdeal().begin();
453 iterator end =
state.getIdeal().end();
456 for (
size_t i = 0;
i < _filters.size(); ++
i)
460 return state.inPlaceGenSplit(0);
464 for (
size_t i = 0;
i < _filters.size(); ++
i) {
467 _filters[
i]->getName(
out);
472 for (
size_t i = 0;
i < _filters.size(); ++
i)
473 _filters[
i]->computationCompleted(
alg);
477 return _filters.front()->shouldTranspose(
state);
485 class GenRarestVars :
public GenStrategy {
491 return state.inPlaceGenSplit(0);
494 virtual iterator
filter(iterator begin, iterator end,
498 while (end - begin > 1) {
499 size_t minDivCount = numeric_limits<size_t>::max();
500 for (
size_t var = 0; var <
varCount; ++var)
512 static const char* staticGetName() {
517 out << staticGetName();
521 iterator
filter(iterator begin, iterator end,
528 for (
size_t var = 0; var <
varCount; ++var)
538 for (iterator
it = begin;
it != end; ++
it) {
581 for (
size_t var = 0; var <
varCount; ++var) {
623 RawSquareFreeTerm _tmp;
626 class GenMaxSupport :
public GenStrategy {
632 virtual iterator
filter(iterator begin, iterator end,
637 for (iterator
it = begin;
it != end; ++
it) {
651 static const char* staticGetName() {
656 out << staticGetName();
660 class GenMinSupport :
public GenStrategy {
666 virtual iterator
filter(iterator begin, iterator end,
671 for (iterator
it = begin;
it != end; ++
it) {
685 static const char* staticGetName() {
690 out << staticGetName();
694 class GenAny :
public GenStrategy {
700 virtual iterator
filter(iterator begin, iterator end,
706 static const char* staticGetName() {
711 out << staticGetName();
715 class GenRandom :
public GenStrategy {
722 virtual iterator
filter(iterator begin, iterator end,
725 const size_t genCount = end - begin;
731 static const char* staticGetName() {
736 out << staticGetName();
747 if (
state.getNonEliminatedVarCount() <
748 state.getIdeal().getGeneratorCount())
756 _stdStrat->getName(
out);
758 _genStrat->getName(
out);
763 _stdStrat->computationCompleted(
alg);
764 _genStrat->computationCompleted(
alg);
783 const char*
str1 =
"\n\n\n"
784 "********************************(debug output)********************************\n"
785 "********** Processing this simplified state that is not a base case **********\n";
793 "<<<<<<<<<<<<<<<<<<<<<<<<<<<< Substate 1 of 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n";
798 "<<<<<<<<<<<<<<<<<<<<<<<<<<<< Substate 2 of 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n";
806 _strat->getName(
out);
810 _strat->computationCompleted(
alg);
811 fputs(
"Debug: Euler characteristic computation completed.\n", _out);
812 gmp_fprintf(_out,
"Debug: Computed Euler characteristics was %Zd.\n",
813 alg.getComputedEulerCharacteristic().get_mpz_t());
817 return _strat->shouldTranspose(
state);
828 _strat(
strat), _out(
out), _statesSplit(0), _transposes(0) {}
836 _strat->getName(
out);
840 _strat->computationCompleted(
alg);
841 fputs(
"******** Statistics for Euler characteristic computation *****\n", _out);
842 fprintf(_out,
"* Using unique div simplify: %s\n",
843 alg.getUseUniqueDivSimplify() ?
"yes" :
"no");
844 fprintf(_out,
"* Using many div simplify: %s\n",
845 alg.getUseManyDivSimplify() ?
"yes" :
"no");
846 fprintf(_out,
"* Using implied div simplify: %s\n",
847 alg.getUseAllPairsSimplify() ?
"yes" :
"no");
848 fprintf(_out,
"* Do initial autotranspose: %s\n",
849 alg.getInitialAutoTranspose() ?
"yes" :
"no");
850 fprintf(_out,
"* Do autotranspose at each step: %s\n",
851 alg.getAutoTranspose() ?
"yes" :
"no");
861 fprintf(_out,
"* Transposes taken: %lu\n", (
unsigned long)_transposes);
862 fputs(
"********\n", _out);
866 const bool should = _strat->shouldTranspose(
state);
875 unsigned long _statesSplit;
876 mutable unsigned long _transposes;
906 if (
name.compare(0, 6,
"widen_") != 0) {
918 if (
name.find(
'_') == string::npos) {
930 part =
name.substr(pos, string::npos);
939 }
while (pos != string::npos);
void exceptionSafePushBack(Container &container, auto_ptr< Element > pointer)
void nameFactoryRegister(NameFactory< AbstractProduct > &factory)
Registers the string returned by ConcreteProduct::getStaticName() to a function that default-construc...
auto_ptr< PivotStrategy > newStdPivotStrategy(const string &name)
auto_ptr< PivotStrategy > newHybridPivotStrategy(auto_ptr< PivotStrategy > stdStrat, auto_ptr< PivotStrategy > genStrat)
auto_ptr< PivotStrategy > newStatisticsPivotStrategy(auto_ptr< PivotStrategy > strat, FILE *out)
auto_ptr< PivotStrategy > newDefaultPivotStrategy()
auto_ptr< PivotStrategy > newDebugPivotStrategy(auto_ptr< PivotStrategy > strat, FILE *out)
auto_ptr< PivotStrategy > newGenPivotStrategy(const string &name)
A wrapper for a SliceStrategy that prints out what is going out for debugging purposes,...
EulerState * inPlaceGenSplit(size_t pivotIndex)
RawSquareFreeIdeal & getIdeal()
size_t getVarCount() const
EulerState * inPlaceStdSplit(size_t pivotVar)
A NameFactory takes a name and then creates an instance of a class that has been previously registere...
A pivot selection strategy for the Euler algorithm.
const_iterator doesn't have all it needs to be a proper STL iterator.
iterator doesn't have all it needs to be a proper STL iterator.
A bit packed square free ideal placed in a pre-allocated buffer.
size_t getVarCount() const
size_t getGeneratorCount() const
void setExponent(Word *a, size_t var, bool value)
Word * newTerm(size_t varCount)
Returns identity term of varCount variables.
size_t getSizeOfSupport(const Word *a, size_t varCount)
bool getExponent(const Word *a, size_t var)
returns true if var divides a and false otherwise.
void swap(Word *a, Word *b, size_t varCount)
void deleteTerm(Word *term)
Deletes term previously returned by newTerm().
void gcdInPlace(Word *res, const Word *resEnd, const Word *a)
void assign(Word *a, const Word *b, size_t varCount)
bool isRelativelyPrime(const Word *a, const Word *b, size_t varCount)
void gcd(Word *res, const Word *resEnd, const Word *a, const Word *b)
void setToIdentity(Word *res, const Word *resEnd)
unsigned long Word
The native unsigned type for the CPU.