From 0969baa58afd624a32fa73a1a7993d2d256bfa6d Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Thu, 24 Aug 2017 12:34:45 +0200 Subject: limits and thresholds for sparse distance matrices --- ripser.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ripser.cpp b/ripser.cpp index d3aa615..fceba33 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -855,7 +855,7 @@ int main(int argc, char** argv) { file_format format = DISTANCE_MATRIX; index_t dim_max = 1; - value_t threshold = std::numeric_limits::max(); + value_t threshold = std::numeric_limits::infinity(); #ifdef USE_COEFFICIENTS coefficient_t modulus = 2; @@ -917,7 +917,19 @@ int main(int argc, char** argv) { std::cout << "distance matrix with " << dist.size() << " points" << std::endl; auto value_range = std::minmax_element(dist.distances.begin(), dist.distances.end()); - std::cout << "value range: [" << *value_range.first << "," << *value_range.second << "]" + + value_t min = std::numeric_limits::infinity(), max = -std::numeric_limits::infinity(); + + for (auto d: dist.distances) { + if (d != std::numeric_limits::infinity() ) { + min = std::min(min, d); + max = std::max(max, d); + } else { + threshold = std::min(threshold, std::numeric_limits::max()); + } + } + + std::cout << "value range: [" << min << "," << max << "]" << std::endl; ripser(std::move(dist), dim_max, threshold, modulus).compute_barcodes(); -- cgit v1.2.3