28 for (
size_t var = 0; var < str.size(); ++var) {
29 ASSERT(str[var] ==
'0' || str[var] ==
'1');
35 void print(FILE* file,
const Word* term,
size_t varCount) {
37 print(out, term, varCount);
38 fputs(out.str().c_str(), file);
41 void print(ostream& out,
const Word* term,
size_t varCount) {
42 ASSERT(term != 0 || varCount == 0);
45 for (
size_t var = 0; var < varCount; ++var) {
52 for (; a != aEnd; ++a)
101 const Word* remove,
size_t varCount) {
102 size_t newVarCount = 0;
103 for (
size_t var = 0; var < varCount; ++var) {
109 for (; newVarCount %
BitsPerWord != 0; ++newVarCount)
116 for (; res != resEnd; ++res)
132 const Word fullSupportWord = (((
Word)1) << varCount) - 1;
133 *res = fullSupportWord;
163 Word xorAB = (*a) ^ (*b);
165 Word leastSignificantBit = xorAB & (-xorAB);
166 return (*a & leastSignificantBit) == 0;
177 for (; res != resEnd; ++res, ++a, ++b)
182 for (; res != resEnd; ++res, ++b)
195 while (var < varCount) {
201 else if (term[var] != 0)
205 }
while (bit != 0 && var < varCount);
211 bool encodeTerm(
Word* encoded,
const std::vector<mpz_class>& term,
const size_t varCount) {
213 while (var < varCount) {
219 else if (term[var] != 0)
223 }
while (bit != 0 && var < varCount);
229 bool encodeTerm(
Word* encoded,
const std::vector<std::string>& term,
const size_t varCount) {
231 while (var < varCount) {
235 if (!term[var].empty()) {
236 if (term[var].size() > 1)
238 if (term[var][0] ==
'1')
240 else if (term[var][0] !=
'0')
245 }
while (bit != 0 && var < varCount);
253 for (; res != resEnd; ++a, ++b, ++res)
265 for (; res != resEnd; ++a, ++res)
277 for (; res != resEnd; ++a, ++b, ++res)
289 for (; res != resEnd; ++a, ++res)
315 const Word fullSupportWord = (((
Word)1) << varCount) - 1;
316 *a = (~*a) & fullSupportWord;
324 size_t varsToGo = varCount;
344 while ((word & 1) == 0) {
361 size_t* intraWordInc = inc;
363 *intraWordInc -= word & 1;
381 size_t* intraWordInc = inc;
421 const Word fullSupportWord = (((
Word)1) << varCount) - 1;
422 return ((*a) & ~fullSupportWord) == 0;
void setExponent(Word *a, size_t var, bool value)
Word * newTerm(size_t varCount)
Returns identity term of varCount variables.
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)
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...
size_t getVarIfPure(const Word *const a, size_t varCount)
Returns var if a equals var.
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.
void decrementAtSupport(const Word *a, size_t *inc, size_t varCount)
For every variable var that divides a, decrement inc[var] by one.
bool lexLess(const Word *a, const Word *b, size_t varCount)
bool isIdentity(const Word *a, Word *aEnd)
void toZeroAtSupport(const Word *a, size_t *inc, size_t varCount)
For every variable var that divides a, set inc[var] to zero.
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 print(FILE *file, const Word *term, size_t varCount)
void compact(Word *compacted, const Word *term, const Word *remove, size_t varCount)
For every variable var that divides remove, remove the space for that variable in term and put the re...
void lcm(Word *res, const Word *resEnd, const Word *a, const Word *b)
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.
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)
static const size_t BitsPerWord
unsigned long Word
The native unsigned type for the CPU.