From 76e9252dd33b97a438af8e05e6d4f0ffe0a625d0 Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Sun, 28 Aug 2016 09:58:16 +0200 Subject: cleaned up detection of apparent persistence pairs --- ripser.cpp | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/ripser.cpp b/ripser.cpp index d3b969a..aec4e86 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -141,13 +141,11 @@ struct entry_t { static_assert(sizeof(entry_t) == sizeof(index_t), "size of entry_t is not the same as index_t"); - entry_t make_entry(index_t _index, coefficient_t _coefficient) { return entry_t(_index, _coefficient); } index_t get_index(entry_t e) { return e.index; } index_t get_coefficient(entry_t e) { return e.coefficient; } void set_coefficient(entry_t& e, const coefficient_t c) { e.coefficient = c; } - bool operator==(const entry_t& e1, const entry_t& e2) { return get_index(e1) == get_index(e2) && get_coefficient(e1) == get_coefficient(e2); } @@ -435,12 +433,12 @@ public: return entries.cbegin() + bounds[index]; } - template void append(Iterator begin, Iterator end) { + template void append_column(Iterator begin, Iterator end) { for (Iterator it = begin; it != end; ++it) { entries.push_back(*it); } bounds.push_back(entries.size()); } - void append() { bounds.push_back(entries.size()); } + void append_column() { bounds.push_back(entries.size()); } void push_back(ValueType e) { assert(0 < size()); @@ -454,8 +452,8 @@ public: --bounds.back(); } - template void append(const Collection collection) { - append(collection.cbegin(), collection.cend()); + template void append_column(const Collection collection) { + append_column(collection.cbegin(), collection.cend()); } }; @@ -527,7 +525,8 @@ void compute_pairs(std::vector& columns_to_reduce, hash_map, - greater_diameter_or_smaller_index> working_coboundary; + greater_diameter_or_smaller_index> + working_coboundary; value_t diameter = get_diameter(column_to_reduce); @@ -539,18 +538,14 @@ void compute_pairs(std::vector& columns_to_reduce, hash_map& columns_to_reduce, hash_map& columns_to_reduce, hash_map& columns_to_reduce, hash_map= 0); diameter_entry_t coface_entry = make_diameter_entry(coface_diameter, coface_index, coface_coefficient); coface_entries.push_back(coface_entry); - if (might_be_apparent_pair && (simplex_diameter == coface_diameter)) { + if (might_be_apparent_pair && (get_diameter(simplex) == coface_diameter)) { if (pivot_column_index.find(coface_index) == pivot_column_index.end()) { pivot = coface_entry; goto found_persistence_pair; @@ -629,7 +621,6 @@ void compute_pairs(std::vector& columns_to_reduce, hash_mapsecond; - column_to_add = columns_to_reduce[j]; continue; } } else { @@ -848,7 +839,9 @@ int main(int argc, char** argv) { for (index_t i = 1; i < argc; ++i) { const std::string arg(argv[i]); - if (arg == "--help") { print_usage_and_exit(0); } else if (arg == "--dim") { + if (arg == "--help") { + print_usage_and_exit(0); + } else if (arg == "--dim") { std::string parameter = std::string(argv[++i]); size_t next_pos; dim_max = std::stol(parameter, &next_pos); -- cgit v1.2.3