diff options
author | Gard Spreemann <gspr@nonempty.org> | 2020-01-17 15:37:17 +0100 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2020-01-17 15:37:17 +0100 |
commit | 9acc59fcc1d5001a212e7b9cd6f00a569a625882 (patch) | |
tree | 0f8c3a3c29a9fef6394394a9650198b348bff130 /src/common/include/gudhi/Unitary_tests_utils.h | |
parent | 5ccee32ec2ba38743c6b96867db3e1b5151e45e4 (diff) | |
parent | cabc43b34723efa7640313348b844eabe9971e38 (diff) |
Merge tag 'tags/gudhi-release-3.1.0.rc1' into dfsg/latest
Diffstat (limited to 'src/common/include/gudhi/Unitary_tests_utils.h')
-rw-r--r-- | src/common/include/gudhi/Unitary_tests_utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h index 4ad4dae8..9b86460a 100644 --- a/src/common/include/gudhi/Unitary_tests_utils.h +++ b/src/common/include/gudhi/Unitary_tests_utils.h @@ -14,6 +14,7 @@ #include <iostream> #include <limits> // for std::numeric_limits<> +#include <cmath> // for std::fabs template<typename FloatingType > void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, @@ -25,4 +26,15 @@ void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, BOOST_CHECK(std::fabs(a - b) <= epsilon); } +// That's the usual x86 issue where a+b==a+b can return false (without any NaN) because one of them was stored in +// memory (and thus rounded to 64 bits) while the other is still in a register (80 bits). +template<typename FloatingType > +FloatingType GUDHI_PROTECT_FLOAT(FloatingType value) { + volatile FloatingType protected_value = value; +#ifdef DEBUG_TRACES + std::cout << "GUDHI_PROTECT_FLOAT - " << protected_value << std::endl; +#endif + return protected_value; +} + #endif // UNITARY_TESTS_UTILS_H_ |