Skip to content
Snippets Groups Projects
Commit f5d6650e authored by Radek Hušek's avatar Radek Hušek Committed by Radek Hušek
Browse files

Alternative way to generate next forbidden mapping

The new way avoids using modulo operation and is
nicer to optimized Mapping structures.
parent 10a336a3
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,15 @@
#endif
#ifndef USE_NEXT_FORB
#define USE_NEXT_FORB 1
#endif
#if USE_NEXT_FORB
#pragma message "USE_NEXT_FORB ON"
#else
#pragma message "USE_NEXT_FORB off"
#endif
#ifndef MAX_EDGES
#define MAX_EDGES 48
......
......@@ -77,6 +77,7 @@ struct Tester : public AbstractTester {
}
}
#if !USE_NEXT_FORB
Mapping& unpack(size_t index, Mapping& ret) {
size_t m = Ring::size - 1;
......@@ -87,6 +88,7 @@ struct Tester : public AbstractTester {
return ret;
}
#endif
Mapping& cannonize(Mapping& map) {
for (const auto &i : nonClassEdges) {
......@@ -121,15 +123,44 @@ struct Tester : public AbstractTester {
#endif
}
#if USE_NEXT_FORB
bool nextForb(Mapping& forb) {
for (size_t i = 0; i < edges; i++) {
T v = forb[i] + 1;
if (v >= Ring::size) {
forb.assign(i, 1);
} else {
forb.assign(i, v);
return true;
}
}
return false;
}
#endif
virtual bool run() {
Mapping forb(edges);
#if USE_NEXT_FORB
for (size_t i = 0; i < edges; i++)
forb.assign(i, 1);
do {
Mapping copy(forb);
#if SAVE_MEMORY
classes[pack(cannonize(copy))] = true;
#else
classes[pack(cannonize(copy))]++;
#endif
} while (nextForb(forb));
#else // ! USE_NEXT_FORB
for (size_t i = 0; i < numForb; i++)
#if SAVE_MEMORY
classes[pack(cannonize(unpack(i, forb)))] = true;
#else
classes[pack(cannonize(unpack(i, forb)))]++;
#endif
#endif
for (const auto &c : classes) if (!c) return (isConnected = false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment