diff options
author | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-06-12 13:58:44 +0000 |
---|---|---|
committer | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-06-12 13:58:44 +0000 |
commit | e0634f23c228f5f4061b45a7b9af31a3310e11a4 (patch) | |
tree | f22f8ec41d3aa4cc94c388b977a130cda6a53ca4 /src/Bottleneck_distance/include/gudhi | |
parent | 5397788ef9b387267eaadee682f2b50bc3503de3 (diff) |
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
Diffstat (limited to 'src/Bottleneck_distance/include/gudhi')
-rw-r--r-- | src/Bottleneck_distance/include/gudhi/Bottleneck.h | 8 |
1 files changed, 8 insertions, 0 deletions
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 <limits> // for numeric_limits #include <cmath> +#include <cfloat> // 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); |