From 6ab0a9edda78f754487bc5d19fbbae506e96856e Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Sat, 22 Feb 2020 11:10:38 +0100 Subject: rearranged reduction code --- ripser.cpp | 42 ++++++++++++++++++++---------------------- 1 file 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); -- cgit v1.2.3