Use idem instead of gnr<0

This commit is contained in:
David Allemang
2022-09-14 21:01:30 -04:00
parent c815ea3152
commit 73c6d800cc

View File

@@ -16,6 +16,7 @@ namespace tc {
*/ */
struct Row { struct Row {
bool free = true; bool free = true;
bool idem = false;
// the number of cosets identified so far // the number of cosets identified so far
int gnr = 0; int gnr = 0;
@@ -83,7 +84,8 @@ namespace tc {
row.gnr = 0; row.gnr = 0;
} else { } else {
row.free = false; row.free = false;
row.gnr = -1; row.gnr = 1;
row.idem = true;
} }
} }
// endregion // endregion
@@ -151,14 +153,17 @@ namespace tc {
// trow.free = crow.free; // trow.free = crow.free;
// trow.gnr = crow.gnr + 1; // trow.gnr = crow.gnr + 1;
if (crow.gnr < 0) // if (crow.gnr < 0)
trow.gnr -= 2; // trow.gnr -= 2;
if (trow.gnr == -rel.mult) { if (trow.idem) {
if (trow.gnr == rel.mult) {
// loop is closed, but internal, so the target links to itself via this generator. // loop is closed, but internal, so the target links to itself via this generator.
// todo might be able to move this logic up into the (target == coset) block and avoid those computations. // todo might be able to move this logic up into the (target == coset) block and avoid those computations.
facts.push(target * ngens + other_gen); facts.push(target * ngens + other_gen);
} else if (trow.gnr == rel.mult - 1) { }
} else {
if (trow.gnr == rel.mult - 1) {
// loop is almost closed. record that the target closes this loop. // loop is almost closed. record that the target closes this loop.
lst_vals[trow.lst_idx] = target; lst_vals[trow.lst_idx] = target;
} else if (trow.gnr == rel.mult) { } else if (trow.gnr == rel.mult) {
@@ -170,6 +175,7 @@ namespace tc {
} }
} }
} }
}
// If any target row wasn't identified with a loop, // If any target row wasn't identified with a loop,
// then assign it a new loop. // then assign it a new loop.
@@ -186,7 +192,8 @@ namespace tc {
trow.gnr = 0; trow.gnr = 0;
} else { } else {
trow.free = false; trow.free = false;
trow.gnr = -1; trow.gnr = 1;
trow.idem = true;
} }
} }
} }