From ef9564eb90672944605e492f7c259db3658caa42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Thu, 29 Jun 2023 19:12:06 +0200 Subject: [PATCH] Fix bin tuning for double and float One should add much more test cases to check validity/reproductibility of reproductible summations --- src/utils/ReproductibleSumUtils.hpp | 4 ++-- tests/test_ItemValueUtils.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/ReproductibleSumUtils.hpp b/src/utils/ReproductibleSumUtils.hpp index bab97230e..e1f78a37f 100644 --- a/src/utils/ReproductibleSumUtils.hpp +++ b/src/utils/ReproductibleSumUtils.hpp @@ -78,9 +78,9 @@ constexpr inline size_t bin_size<float> = 12; template <typename DataType> constexpr inline double bin_epsilon = 0; template <> -constexpr inline double bin_epsilon<double> = 1.11022302462516e-16; // std::pow(2., -53) +constexpr inline double bin_epsilon<double> = std::numeric_limits<double>::epsilon(); template <> -constexpr inline double bin_epsilon<float> = 5.96046447753906e-08; // std::pow(2., -24) +constexpr inline double bin_epsilon<float> = std::numeric_limits<float>::epsilon(); // number of bins: improves precision template <typename DataType> diff --git a/tests/test_ItemValueUtils.cpp b/tests/test_ItemValueUtils.cpp index b1901713a..e9df51a05 100644 --- a/tests/test_ItemValueUtils.cpp +++ b/tests/test_ItemValueUtils.cpp @@ -242,7 +242,7 @@ TEST_CASE("ItemValueUtils", "[mesh]") std::array mesh_list = MeshDataBaseForTests::get().all1DMeshes(); for (const auto& named_mesh : mesh_list) { - SECTION(named_mesh.name() + "for size_t data") + SECTION(named_mesh.name() + " for size_t data") { auto mesh_1d = named_mesh.mesh(); @@ -269,7 +269,7 @@ TEST_CASE("ItemValueUtils", "[mesh]") REQUIRE(sum(cell_value) == global_sum); } - SECTION(named_mesh.name() + "for double data") + SECTION(named_mesh.name() + " for double data") { auto mesh_1d = named_mesh.mesh(); -- GitLab