From 94eb1f7db4421e324a827590f60aa236af56666c Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Tue, 20 Aug 2019 22:58:21 +0200 Subject: coboundary enumerator cleanup --- ripser.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ripser.cpp b/ripser.cpp index 4d8e8f3..5549016 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -718,18 +718,17 @@ public: } bool has_next(bool all_cofacets = true) { - while ((v != -1) && (binomial_coeff(v, k) <= idx_below)) { - if (!all_cofacets) return false; + return (v >= k && (all_cofacets || binomial_coeff(v, k) > idx_below)); + } + + diameter_entry_t next() { + while ((binomial_coeff(v, k) <= idx_below)) { idx_below -= binomial_coeff(v, k); idx_above += binomial_coeff(v, k + 1); --v; --k; assert(k != -1); } - return v != -1; - } - - diameter_entry_t next() { value_t cofacet_diameter = get_diameter(simplex); for (index_t w : vertices) cofacet_diameter = std::max(cofacet_diameter, dist(v, w)); index_t cofacet_index = idx_above + binomial_coeff(v--, k + 1) + idx_below; @@ -754,10 +753,10 @@ template <> class ripser::simplex_coboundary_enumerator public: simplex_coboundary_enumerator(const diameter_entry_t _simplex, const index_t _dim, const ripser& _parent) - : parent(_parent), idx_below(get_index(_simplex)), idx_above(0), - k(_dim + 1), - vertices(_dim + 1), simplex(_simplex), modulus(parent.modulus), dist(parent.dist), binomial_coeff(parent.binomial_coeff), - neighbor_it(dist.neighbor_it), neighbor_end(dist.neighbor_end) { + : parent(_parent), idx_below(get_index(_simplex)), idx_above(0), k(_dim + 1), + vertices(_dim + 1), simplex(_simplex), modulus(parent.modulus), dist(parent.dist), + binomial_coeff(parent.binomial_coeff), neighbor_it(dist.neighbor_it), + neighbor_end(dist.neighbor_end) { neighbor_it.clear(); neighbor_end.clear(); @@ -1003,7 +1002,8 @@ void print_usage_and_exit(int exit_code) { << " --dim compute persistent homology up to dimension k" << std::endl << " --threshold compute Rips complexes up to diameter t" << std::endl #ifdef USE_COEFFICIENTS - << " --modulus

compute homology with coefficients in the prime field Z/pZ" << std::endl + << " --modulus

compute homology with coefficients in the prime field Z/pZ" + << std::endl #endif << " --ratio only show persistence pairs with death/birth ratio > r" << std::endl << std::endl; -- cgit v1.2.3