summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Bauer <mail@ulrich-bauer.org>2017-08-24 12:34:45 +0200
committerUlrich Bauer <mail@ulrich-bauer.org>2017-08-24 12:34:45 +0200
commit0969baa58afd624a32fa73a1a7993d2d256bfa6d (patch)
tree717aa8140c16bcd63117ca99f41cb638ff7209c5
parentad8ae0cfc24300996505fe1a2bd6795fbc6a2ed1 (diff)
limits and thresholds for sparse distance matrices
-rw-r--r--ripser.cpp16
1 files 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<value_t>::max();
+ value_t threshold = std::numeric_limits<value_t>::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<value_t>::infinity(), max = -std::numeric_limits<value_t>::infinity();
+
+ for (auto d: dist.distances) {
+ if (d != std::numeric_limits<value_t>::infinity() ) {
+ min = std::min(min, d);
+ max = std::max(max, d);
+ } else {
+ threshold = std::min(threshold, std::numeric_limits<value_t>::max());
+ }
+ }
+
+ std::cout << "value range: [" << min << "," << max << "]"
<< std::endl;
ripser(std::move(dist), dim_max, threshold, modulus).compute_barcodes();