summaryrefslogtreecommitdiff
path: root/src/Bottleneck_distance
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-16 12:19:22 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-16 12:19:22 +0000
commit66c657a9b422474a1a151fea2ba711b377dce57f (patch)
treed157bfe5bb06ebb7e0cb3f2bb52f175c9ea15976 /src/Bottleneck_distance
parentb638f095644a1cda0fac00e1b11f19b6cec50473 (diff)
modifs done
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1897 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f1c2ac9389d5da7556a5c47e90c68572ae97450b
Diffstat (limited to 'src/Bottleneck_distance')
-rw-r--r--src/Bottleneck_distance/include/gudhi/Bottleneck.h16
-rw-r--r--src/Bottleneck_distance/test/bottleneck_chrono.cpp2
2 files changed, 12 insertions, 6 deletions
diff --git a/src/Bottleneck_distance/include/gudhi/Bottleneck.h b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
index c34ea933..d7e11a05 100644
--- a/src/Bottleneck_distance/include/gudhi/Bottleneck.h
+++ b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
@@ -34,6 +34,12 @@ double bottleneck_distance_approx(Persistence_graph& g, double e) {
double b_lower_bound = 0.;
double b_upper_bound = g.diameter_bound();
const double alpha = std::pow(g.size(), 1./5.);
+ if(e < std::numeric_limits<double>::epsilon() * alpha){
+ e = std::numeric_limits<double>::epsilon() * alpha;
+#ifdef DEBUG_TRACES
+ std::cout << "Epsilon user given value is less than eps_min. Forced to eps_min by the application" << std::endl;
+#endif // DEBUG_TRACES
+ }
Graph_matching m(g);
Graph_matching biggest_unperfect(g);
while (b_upper_bound - b_lower_bound > 2*e) {
@@ -73,18 +79,18 @@ double bottleneck_distance_exact(Persistence_graph& g) {
return sd.at(lower_bound_i);
}
-/** \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.
+/** \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, you get an additive e-approximation, which is a lot faster to compute whatever is e.
+ * Thus, by default, e is a very small positive double, actually the smallest double possible such that the floating-point inaccuracies don't lead to a failure of the algorithm.
*
* \ingroup bottleneck_distance
*/
template<typename Persistence_diagram1, typename Persistence_diagram2>
-double bottleneck_distance(const Persistence_diagram1 &diag1, const Persistence_diagram2 &diag2, double e=0.) {
+double bottleneck_distance(const Persistence_diagram1 &diag1, const Persistence_diagram2 &diag2, double e=std::numeric_limits<double>::epsilon()) {
Persistence_graph g(diag1, diag2, e);
if(g.bottleneck_alive() == std::numeric_limits<double>::infinity())
return std::numeric_limits<double>::infinity();
- double b = (e == 0. ? bottleneck_distance_exact(g) : bottleneck_distance_approx(g, e));
- return std::max(g.bottleneck_alive(),b);
+ return std::max(g.bottleneck_alive(), e == 0. ? bottleneck_distance_exact(g) : bottleneck_distance_approx(g, e));
}
} // namespace persistence_diagram
diff --git a/src/Bottleneck_distance/test/bottleneck_chrono.cpp b/src/Bottleneck_distance/test/bottleneck_chrono.cpp
index b46a19e4..1bff96f4 100644
--- a/src/Bottleneck_distance/test/bottleneck_chrono.cpp
+++ b/src/Bottleneck_distance/test/bottleneck_chrono.cpp
@@ -51,7 +51,7 @@ int main(){
if(i%3==0)
v2.emplace_back(std::max(a,b),std::max(a,b)+y);
}
- double epsilon = std::numeric_limits<double>::min();
+ double epsilon = std::numeric_limits<double>::epsilon();
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
double b = bottleneck_distance(v1,v2, epsilon);
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();