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,10 +16,11 @@ 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;
// the index of the coset that would complete the loop // the index of the coset that would complete the loop
size_t lst_idx = 0; size_t lst_idx = 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,21 +153,25 @@ 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) {
// loop is closed, but internal, so the target links to itself via this generator. if (trow.gnr == rel.mult) {
// todo might be able to move this logic up into the (target == coset) block and avoid those computations. // loop is closed, but internal, so the target links to itself via this generator.
facts.push(target * ngens + other_gen); // todo might be able to move this logic up into the (target == coset) block and avoid those computations.
} else if (trow.gnr == rel.mult - 1) { facts.push(target * ngens + other_gen);
// loop is almost closed. record that the target closes this loop. }
lst_vals[trow.lst_idx] = target; } else {
} else if (trow.gnr == rel.mult) { if (trow.gnr == rel.mult - 1) {
// loop is closed. We know the last element in the loop must link with this one. // loop is almost closed. record that the target closes this loop.
lst = lst_vals[trow.lst_idx]; lst_vals[trow.lst_idx] = target;
} else if (trow.gnr == rel.mult) {
// loop is closed. We know the last element in the loop must link with this one.
lst = lst_vals[trow.lst_idx];
// delete trow.lst_ptr; // delete trow.lst_ptr;
facts.push(lst * ngens + other_gen); facts.push(lst * ngens + other_gen);
}
} }
} }
} }
@@ -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;
} }
} }
} }