From 92672591c114b442d3471bba600f6201f2d08b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 16 Sep 2023 21:29:47 +0200 Subject: [PATCH] Make jackknife TU-local to stats.cpp --- src/catch2/benchmark/detail/catch_stats.cpp | 36 ++++++++++----------- src/catch2/benchmark/detail/catch_stats.hpp | 5 --- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index d745bb1f..ac255e36 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -197,6 +197,24 @@ namespace Catch { # pragma GCC diagnostic pop #endif + + static sample jackknife( double ( *estimator )( double const*, + double const* ), + double* first, + double* last ) { + const auto second = first + 1; + sample results; + results.reserve( static_cast( last - first ) ); + + for ( auto it = first; it != last; ++it ) { + std::iter_swap( it, first ); + results.push_back( estimator( second, last ) ); + } + + return results; + } + + } // namespace } // namespace Detail } // namespace Benchmark @@ -263,24 +281,6 @@ namespace Catch { return sum / static_cast(count); } - sample jackknife( double ( *estimator )( double const*, - double const* ), - double* first, - double* last ) { - auto n = static_cast( last - first ); - auto second = first; - ++second; - sample results; - results.reserve( n ); - - for ( auto it = first; it != last; ++it ) { - std::iter_swap( it, first ); - results.push_back( estimator( second, last ) ); - } - - return results; - } - double normal_cdf( double x ) { return std::erfc( -x / std::sqrt( 2.0 ) ) / 2.0; } diff --git a/src/catch2/benchmark/detail/catch_stats.hpp b/src/catch2/benchmark/detail/catch_stats.hpp index 5b7c8808..3bea612f 100644 --- a/src/catch2/benchmark/detail/catch_stats.hpp +++ b/src/catch2/benchmark/detail/catch_stats.hpp @@ -30,11 +30,6 @@ namespace Catch { double mean( double const* first, double const* last ); - sample jackknife( double ( *estimator )( double const*, - double const* ), - double* first, - double* last ); - double normal_cdf( double x ); double erfc_inv(double x);