mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Make jackknife TU-local to stats.cpp
This commit is contained in:
parent
56fcd584c1
commit
92672591c1
@ -197,6 +197,24 @@ namespace Catch {
|
|||||||
# pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
#endif
|
#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<size_t>( last - first ) );
|
||||||
|
|
||||||
|
for ( auto it = first; it != last; ++it ) {
|
||||||
|
std::iter_swap( it, first );
|
||||||
|
results.push_back( estimator( second, last ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
} // namespace Benchmark
|
} // namespace Benchmark
|
||||||
@ -263,24 +281,6 @@ namespace Catch {
|
|||||||
return sum / static_cast<double>(count);
|
return sum / static_cast<double>(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
sample jackknife( double ( *estimator )( double const*,
|
|
||||||
double const* ),
|
|
||||||
double* first,
|
|
||||||
double* last ) {
|
|
||||||
auto n = static_cast<size_t>( 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 ) {
|
double normal_cdf( double x ) {
|
||||||
return std::erfc( -x / std::sqrt( 2.0 ) ) / 2.0;
|
return std::erfc( -x / std::sqrt( 2.0 ) ) / 2.0;
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,6 @@ namespace Catch {
|
|||||||
|
|
||||||
double mean( double const* first, double const* last );
|
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 normal_cdf( double x );
|
||||||
|
|
||||||
double erfc_inv(double x);
|
double erfc_inv(double x);
|
||||||
|
Loading…
Reference in New Issue
Block a user