summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Bauer <mail@ulrich-bauer.org>2020-02-22 11:10:38 +0100
committerUlrich Bauer <mail@ulrich-bauer.org>2020-02-22 11:10:38 +0100
commit6ab0a9edda78f754487bc5d19fbbae506e96856e (patch)
treee2b32c9e2e84b07a0067566c4ae2dc3050e27284
parent233b1278cc3330cd9f005dba33b3fa11f456ad80 (diff)
rearranged reduction code
-rw-r--r--ripser.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/ripser.cpp b/ripser.cpp
index 745fc18..d3687b5 100644
--- a/ripser.cpp
+++ b/ripser.cpp
@@ -742,34 +742,32 @@ public:
}
#endif
if (get_index(pivot) != -1) {
- auto check = get_apparent_facet(pivot, dim + 1);
-
- if (get_index(check) != -1) {
-
- set_coefficient(check, modulus - get_coefficient(check));
+ auto pair = pivot_column_index.find(get_entry(pivot));
+ if (pair != pivot_column_index.end()) {
+ entry_t other_pivot = pair->first;
+ index_t index_column_to_add = pair->second;
+
+ coefficient_t factor =
+ modulus - get_coefficient(pivot) *
+ multiplicative_inverse[get_coefficient(other_pivot)] %
+ modulus;
- add_simplex_coboundary(check, dim, working_reduction_column, working_coboundary);
+ add_coboundary(reduction_matrix, columns_to_reduce, index_column_to_add,
+ factor, dim, working_reduction_column, working_coboundary);
pivot = get_pivot(working_coboundary);
+ } else {
+ auto check = get_apparent_facet(pivot, dim + 1);
- }
- else
- {
+ if (get_index(check) != -1) {
+
+ set_coefficient(check, modulus - get_coefficient(check));
+
+ add_simplex_coboundary(check, dim, working_reduction_column,
+ working_coboundary);
- auto pair = pivot_column_index.find(get_entry(pivot));
- if (pair != pivot_column_index.end()) {
- entry_t other_pivot = pair->first;
- index_t index_column_to_add = pair->second;
-
- coefficient_t factor =
- modulus - get_coefficient(pivot) *
- multiplicative_inverse[get_coefficient(other_pivot)] %
- modulus;
-
- add_coboundary(reduction_matrix, columns_to_reduce, index_column_to_add,
- factor, dim, working_reduction_column, working_coboundary);
-
pivot = get_pivot(working_coboundary);
+
} else {
#ifdef PRINT_PERSISTENCE_PAIRS
value_t death = get_diameter(pivot);