From e0634f23c228f5f4061b45a7b9af31a3310e11a4 Mon Sep 17 00:00:00 2001 From: glisse Date: Tue, 12 Jun 2018 13:58:44 +0000 Subject: Quick fix for infinite loop: drop extra precision in step computation. I am not saying this is what the code should optimally look like... git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3590 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0253d73afb1b1b565b45d214ea2d948e00c7db25 --- src/Bottleneck_distance/include/gudhi/Bottleneck.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Bottleneck_distance') diff --git a/src/Bottleneck_distance/include/gudhi/Bottleneck.h b/src/Bottleneck_distance/include/gudhi/Bottleneck.h index 41f8b16a..b0fc3949 100644 --- a/src/Bottleneck_distance/include/gudhi/Bottleneck.h +++ b/src/Bottleneck_distance/include/gudhi/Bottleneck.h @@ -30,6 +30,7 @@ #include // for numeric_limits #include +#include // FLT_EVAL_METHOD namespace Gudhi { @@ -43,6 +44,13 @@ double bottleneck_distance_approx(Persistence_graph& g, double e) { Graph_matching biggest_unperfect(g); while (b_upper_bound - b_lower_bound > 2 * e) { double step = b_lower_bound + (b_upper_bound - b_lower_bound) / alpha; +#if !defined FLT_EVAL_METHOD || FLT_EVAL_METHOD < 0 || FLT_EVAL_METHOD > 1 + // On platforms where double computation is done with excess precision, + // we force it to its true precision so the following test is reliable. + volatile double drop_excess_precision = step; + step = drop_excess_precision; + // Alternative: step = CGAL::IA_force_to_double(step); +#endif if (step <= b_lower_bound || step >= b_upper_bound) // Avoid precision problem break; m.set_r(step); -- cgit v1.2.3