40 TEST(RawSquareFreeTerm, SetAndGetExponent) {
44 for (
size_t var = 0; var < varCount; ++var) {
50 for (
size_t var = 0; var < varCount; ++var) {
57 TEST(RawSquareFreeTerm, Assign) {
68 assign(b, b + wordCount, a);
82 TEST(RawSquareFreeTerm, HasFullSupport) {
85 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
88 for (
size_t var = 0; var < varCount; ++var) {
94 for (
size_t var = 0; var < varCount; ++var) {
106 TEST(RawSquareFreeTerm, IsIdentity) {
108 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
113 for (
size_t var = 0; var < varCount; ++var) {
125 TEST(RawSquareFreeTerm, GetSizeOfSupport) {
127 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
131 for (
size_t var = 0; var < varCount; ++var) {
137 for (
size_t var = 0; var < varCount; ++var) {
146 TEST(RawSquareFreeTerm, SetToIdentity) {
148 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
153 for (
size_t var = 0; var < varCount; ++var) {
167 TEST(RawSquareFreeTerm, SetToAllVarProd) {
169 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
174 for (
size_t var = 0; var < varCount; ++var) {
185 TEST(RawSquareFreeTerm, IsRelativelyPrime) {
187 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
195 for (
size_t var = 0; var < varCount; ++var) {
212 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
251 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
286 TEST(RawSquareFreeTerm, Colon) {
288 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
294 colon(c, cEnd, a, b);
305 colon(c, cEnd, a, b);
323 TEST(RawSquareFreeTerm, Divides) {
325 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
332 for (
size_t var = 0; var < varCount; ++var) {
345 TEST(RawSquareFreeTerm, LexLess) {
347 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
358 for (
size_t var = 0; var < varCount - 1; ++var) {
379 TEST(RawSquareFreeTerm, Invert) {
381 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
406 TEST(RawSquareFreeTerm, GetVarIfPure) {
408 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
412 for (
size_t v1 = 0; v1 < varCount; ++v1) {
415 for (
size_t v2 = 0; v2 < varCount; ++v2) {
469 TEST(RawSquareFreeTerm, IsValid) {
493 TEST(RawSquareFreeTerm, NewTermParse) {
504 (
"11011000000000000000000000000000000000000000000000000000000000001");
518 TEST(RawSquareFreeTerm, Equals) {
520 for (
size_t varCount = 0; varCount <= maxVarCount; ++varCount) {
525 for (
size_t var = 0; var < varCount; ++var) {
540 #define TEST_COMPACT(A,B,C) { \
541 size_t varCount = strlen(A); \
542 Word* a = newTermParse(A); \
543 Word* b = newTermParse(B); \
544 Word* c = newTermParse(C); \
545 size_t varCountAfter = strlen(C); \
546 Word* d = newTerm(varCountAfter); \
547 compact(d, a, b, varCount); \
548 ASSERT_TRUE(equals(d, c, varCountAfter)); \
549 compact(a, a, b, varCount); \
550 ASSERT_TRUE(equals(a, c, varCountAfter)); \
556 TEST(RawSquareFreeTerm, Compact) {
562 TEST_COMPACT(
"000000000000000000001111111111111111111111111111",
563 "000000000000000000000000000000000000000000000000",
564 "000000000000000000001111111111111111111111111111");
565 TEST_COMPACT(
"000000000000000000001111111111111111111111111111",
566 "111111111111111111111111111111111111111111111111",
568 TEST_COMPACT(
"111100001111000011110000111100001111000011110000",
569 "101010101010101010101010101010101010101010101010",
570 "110011001100110011001100");
571 TEST_COMPACT(
"000000000000000000000000000000100000000000000001",
572 "011111111111111111111111111111011111111111111101",
574 TEST_COMPACT(
"011111111111111111111111111111011111111111111101",
575 "000000000000000000000000000000100000000000000001",
576 "0111111111111111111111111111111111111111111110");
#define TEST_COMPACT(A, B, C)
TEST(RawSquareFreeTerm, getWordCount)
#define ASSERT_TRUE_SILENT(VALUE)
#define ASSERT_EQ_SILENT(A, B)
#define ASSERT_TRUE(VALUE)
#define ASSERT_FALSE_SILENT(VALUE)
#define ASSERT_FALSE(VALUE)
#define TEST_SUITE(SUITE)
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)
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.
bool lexLess(const Word *a, const Word *b, size_t varCount)
bool isIdentity(const Word *a, Word *aEnd)
bool hasFullSupport(const Word *a, size_t varCount)
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 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.
bool divides(const Word *a, const Word *aEnd, const Word *b)
Returns true if a divides b.
void deleteTerm(Word *term)
Deletes term previously returned by newTerm().
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.