41 template<
class Iter,
class Pred>
91 p->_memoryEnd =
p->_memory;
141 if (
this == &ideal) {
187 out <<
"//------------ Ideal (Square Free):\n";
189 for (
size_t var = 0; var <
varCount; ++var)
193 out <<
"------------\\\\\n";
533 for (
size_t gen = 0; ; ++
gen) {
614 struct CmpForSortLexAscending : std::binary_function<size_t, size_t, bool> {
615 bool operator()(
size_t a,
size_t b)
const {
616 return Ops::lexLess(ideal->getGenerator(
a), ideal->getGenerator(
b),
617 ideal->getVarCount());
628 CmpForSortLexAscending
cmp;
666 struct ColonReminimizeTermHelper {
667 bool operator()(
const Word* term) {
671 const Word* colonEnd;
715 struct ColonReminimizeVarHelper {
716 bool operator()(
const Word* term) {
821 vector<string>
lines;
826 lines.push_back(line);
841 delete[]
reinterpret_cast<char*
>(ideal);
void nameFactoryRegister(NameFactory< AbstractProduct > &factory)
Registers the string returned by ConcreteProduct::getStaticName() to a function that default-construc...
RSFIdeal * newRawSquareFreeIdeal(size_t varCount, size_t capacity)
Allocates object with enough memory for capacity generators in varCount variables.
RawSquareFreeIdeal RSFIdeal
void deleteRawSquareFreeIdeal(RSFIdeal *ideal)
RawSquareFreeIdeal * newRawSquareFreeIdealParse(const char *str)
Allocates and returns an ideal based on str.
static void countVarDividesBlockUpTo15(const Word *it, size_t genCount, const size_t wordsPerTerm, size_t *counts)
RawSquareFreeIdeal * newRawSquareFreeIdeal(size_t varCount, size_t capacity)
Allocates object with enough memory for capacity generators in varCount variables.
void deleteRawSquareFreeIdeal(RawSquareFreeIdeal *ideal)
Deallocates memory returned by newRawSquareFreeIdeal().
This is an arena allocator.
static Arena & getArena()
Returns an arena object that can be used for non-thread safe scratch memory after static objects have...
size_t getVarCount() const
size_t getGeneratorCount() const
Represents a monomial ideal with int exponents.
size_t getGeneratorCount() const
size_t getVarCount() const
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.
void sortLexAscending()
Sorts the generators in ascending lex order.
static RawSquareFreeIdeal * construct(void *buffer, size_t varCount=0)
size_t getNotRelativelyPrime(const Word *term)
Returns the index of the first generator that is not relatively prime with term.
bool isValid() const
Returns true if the internal invariants of ideal are satisfied.
bool hasFullSupport(const Word *ignore) const
Returns true if for every variable it either divides ignore or it divides some (not necessarily minim...
void getGcdOfMultiples(Word *gcd, size_t var) const
Sets gcd to be the greatest common denominator of those generators that are divisible by var.
bool operator==(const RawSquareFreeIdeal &ideal) const
Returns true if *this equals ideal.
void colon(const Word *by)
size_t getExclusiveVarGenerator()
Returns the index of a generator that is the only one to be divisible by some variable.
void getLcm(Word *lcm) const
Puts the least common multiple of the generators of the ideal into lcm.
size_t getMinSupportGen() const
Returns the index of a generator with minimum support.
void getVarDividesCounts(vector< size_t > &counts) const
Sets counts[var] to the number of generators that var divides.
void compact(const Word *remove)
Removes the variables that divide remove.
void removeGenerator(size_t index)
Removes the generator at index.
void print(FILE *file) const
Print a debug-suitable representation of this object to file.
static size_t getBytesOfMemoryFor(size_t varCount, size_t generatorCount)
Returns the number of bytes of memory necessary to contain an ideal with the given parameters.
size_t getMaxSupportGen() const
Returns the index of a generator with maximum support.
size_t getVarCount() const
Word * getGenerator(size_t index)
Returns the generator at index.
void colonReminimize(const Word *colon)
Performs a colon and minimize.
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
size_t insert(const Ideal &ideal)
Inserts the generators of ideal from index 0 onward until reaching a non-squarefree generator or all ...
void transpose(Word *eraseVars=0)
Equivalent to setToTransposeOf(this, eraseVars).
void swap01Exponents()
Change 0 exponents into 1 and vice versa.
void swap(size_t a, size_t b)
void setToTransposeOf(const RawSquareFreeIdeal &ideal, Word *eraseVars=0)
Resets this object to the transpose of ideal.
bool isMinimallyGenerated() const
Returns true if no generator divides another.
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 insertNonMultiples(const Word *term, const RawSquareFreeIdeal &ideal)
Insert those generators of ideal that are not multiples of term.
size_t getWordsPerTerm() const
size_t getWordOffset(size_t var)
void setExponent(Word *a, size_t var, bool value)
bool isValid(const Word *a, size_t varCount)
The unused bits at the end of the last word must be zero for the functions here to work correctly.
size_t getWordCount(size_t varCount)
void colon(Word *res, const Word *resEnd, const Word *a, const Word *b)
size_t getBitOffset(size_t var)
bool encodeTerm(Word *encoded, const Exponent *term, const size_t varCount)
Assigns the RawSquareFreeTerm-encoded form of term to encoded and returns true if term is square free...
Word * newTermParse(const char *strParam)
Allocates and returns a term based on str.
void invert(Word *a, size_t varCount)
Make 0 exponents 1 and make 1 exponents 0.
bool lexLess(const Word *a, const Word *b, size_t varCount)
size_t getSizeOfSupport(const Word *a, size_t varCount)
void colonInPlace(Word *res, const Word *resEnd, const Word *b)
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 setToAllVarProd(Word *res, size_t varCount)
Sets all exponents of res to 1.
bool equals(const Word *a, const Word *b, size_t varCount)
Returns true if a equals b.
bool divides(const Word *a, const Word *aEnd, const Word *b)
Returns true if a divides b.
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 setToIdentity(Word *res, const Word *resEnd)
static const size_t BitsPerWord
unsigned long Word
The native unsigned type for the CPU.