summaryrefslogtreecommitdiff
path: root/src/Bottleneck_distance/include/gudhi/Bottleneck.h
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-06 16:20:10 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-06 16:20:10 +0000
commitd0db67f8ff185a7698d2f6643d86e43955bab882 (patch)
treea46d3f9d3029a09dfa21f9d4b744a94a73e57118 /src/Bottleneck_distance/include/gudhi/Bottleneck.h
parent3e2c4df7d6ac217f09d3aff6d238e71de8229e5b (diff)
infinite points separately computed
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1828 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5d1cd63a1b8ff26feffce86a4febe2f42d52340d
Diffstat (limited to 'src/Bottleneck_distance/include/gudhi/Bottleneck.h')
-rw-r--r--src/Bottleneck_distance/include/gudhi/Bottleneck.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Bottleneck_distance/include/gudhi/Bottleneck.h b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
index 20225e80..4a69fb96 100644
--- a/src/Bottleneck_distance/include/gudhi/Bottleneck.h
+++ b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
@@ -24,12 +24,13 @@
#define BOTTLENECK_H_
#include <gudhi/Graph_matching.h>
+#include <cmath>
namespace Gudhi {
namespace bottleneck_distance {
-/** \brief Function to use in order to compute the Bottleneck distance between two persistence diagrams.
+/** \brief Function to use in order to compute the Bottleneck distance between two persistence diagrams (see Concepts).
* If the last parameter e is not 0 (default value if not explicited), you get an additive e-approximation.
*
* \ingroup bottleneck_distance
@@ -37,7 +38,8 @@ namespace bottleneck_distance {
template<typename Persistence_diagram1, typename Persistence_diagram2>
double compute(const Persistence_diagram1 &diag1, const Persistence_diagram2 &diag2, double e=0.) {
Persistence_graph g(diag1, diag2, e);
- if(!g.alive_match())
+ double b = g.bottleneck_alive();
+ if(b == std::numeric_limits<double>::infinity())
return std::numeric_limits<double>::infinity();
std::vector<double> sd;
if(e == 0.)
@@ -45,7 +47,7 @@ double compute(const Persistence_diagram1 &diag1, const Persistence_diagram2 &di
long idmin = 0;
long idmax = e==0. ? sd.size() - 1 : g.diameter_bound()/e + 1;
// alpha can change the complexity
- double alpha = pow(idmax, 0.25);
+ double alpha = std::pow(idmax, 0.25);
Graph_matching m(g);
Graph_matching biggest_unperfect(g);
while (idmin != idmax) {
@@ -61,7 +63,8 @@ double compute(const Persistence_diagram1 &diag1, const Persistence_diagram2 &di
idmin = idmin + step + 1;
}
}
- return e == 0. ? sd.at(idmin) : e*(idmin);
+ b = std::max(b, e == 0. ? sd.at(idmin) : e*(idmin));
+ return b;
}