summaryrefslogtreecommitdiff
path: root/src/Bottleneck_distance/include/gudhi/Bottleneck.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bottleneck_distance/include/gudhi/Bottleneck.h')
-rw-r--r--src/Bottleneck_distance/include/gudhi/Bottleneck.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/Bottleneck_distance/include/gudhi/Bottleneck.h b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
index 2b7e4767..b90a0ee0 100644
--- a/src/Bottleneck_distance/include/gudhi/Bottleneck.h
+++ b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
@@ -24,6 +24,11 @@
#define BOTTLENECK_H_
#include <gudhi/Graph_matching.h>
+
+#include <vector>
+#include <algorithm> // for max
+#include <limits> // for numeric_limits
+
#include <cmath>
namespace Gudhi {
@@ -41,7 +46,7 @@ double bottleneck_distance_approx(Persistence_graph& g, double e) {
if (step <= b_lower_bound || step >= b_upper_bound) // Avoid precision problem
break;
m.set_r(step);
- while (m.multi_augment()); // compute a maximum matching (in the graph corresponding to the current r)
+ while (m.multi_augment()) {}; // compute a maximum matching (in the graph corresponding to the current r)
if (m.perfect()) {
m = biggest_unperfect;
b_upper_bound = step;
@@ -63,7 +68,7 @@ double bottleneck_distance_exact(Persistence_graph& g) {
while (lower_bound_i != upper_bound_i) {
long step = lower_bound_i + static_cast<long> ((upper_bound_i - lower_bound_i - 1) / alpha);
m.set_r(sd.at(step));
- while (m.multi_augment()); // compute a maximum matching (in the graph corresponding to the current r)
+ while (m.multi_augment()) {}; // compute a maximum matching (in the graph corresponding to the current r)
if (m.perfect()) {
m = biggest_unperfect;
upper_bound_i = step;
@@ -75,11 +80,22 @@ 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, 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.
+/** \brief Function to compute the Bottleneck distance between two persistence diagrams.
+ *
+ * \tparam Persistence_diagram1,Persistence_diagram2
+ * models of the concept `PersistenceDiagram`.
+ * \param[in] e
+ * \parblock
+ * If `e` is 0, this uses an expensive algorithm to compute the exact distance.
+ *
+ * If `e` is not 0, it asks for an additive `e`-approximation, and currently
+ * also allows a small multiplicative error (the last 2 or 3 bits of the
+ * mantissa may be wrong). This version of the algorithm takes advantage of the
+ * limited precision of `double` and is usually a lot faster to compute,
+ * whatever the value of `e`.
+ *
+ * Thus, by default, `e` is the smallest positive double.
+ * \endparblock
*
* \ingroup bottleneck_distance
*/