diff options
| author | Martin Hořeňovský | 2023-11-19 21:00:53 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-12-10 18:44:10 +0100 |
| commit | d139b4ff7cd8823923e8616e8fef954e09e46322 (patch) | |
| tree | cd0e03dde2d2b3e72911d27182355b63c6540d70 /src/catch2/benchmark | |
| parent | bfd9f0f5a67c0127b25ac82eb828f6ab71aaae1e (diff) | |
| download | catch3-d139b4ff7cd8823923e8616e8fef954e09e46322.tar.gz | |
Add implementation of helpers for uniform float distribution
Specifically we add
* `gamma(a, b)`, which returns the magnitude of largest 1-ULP
step in range [a, b].
* `count_equidistant_float(a, b, distance)`, which returns the
number of equi-distant floats in range [a, b].
Diffstat (limited to 'src/catch2/benchmark')
| -rw-r--r-- | src/catch2/benchmark/detail/catch_stats.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index ac255e36..6030e55c 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -10,6 +10,7 @@ #include <catch2/benchmark/detail/catch_stats.hpp> #include <catch2/internal/catch_compiler_capabilities.hpp> +#include <catch2/internal/catch_floating_point_helpers.hpp> #include <algorithm> #include <cassert> @@ -184,20 +185,6 @@ namespace Catch { return std::sqrt( variance ); } -#if defined( __GNUC__ ) || defined( __clang__ ) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - // Used when we know we want == comparison of two doubles - // to centralize warning suppression - static bool directCompare( double lhs, double rhs ) { - return lhs == rhs; - } -#if defined( __GNUC__ ) || defined( __clang__ ) -# pragma GCC diagnostic pop -#endif - - static sample jackknife( double ( *estimator )( double const*, double const* ), double* first, @@ -234,7 +221,7 @@ namespace Catch { double g = idx - j; std::nth_element(first, first + j, last); auto xj = first[j]; - if ( directCompare( g, 0 ) ) { + if ( Catch::Detail::directCompare( g, 0 ) ) { return xj; } @@ -338,7 +325,7 @@ namespace Catch { [point]( double x ) { return x < point; } ) / static_cast<double>( n ); // degenerate case with uniform samples - if ( directCompare( prob_n, 0. ) ) { + if ( Catch::Detail::directCompare( prob_n, 0. ) ) { return { point, point, point, confidence_level }; } |