mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Cleanup types in resample
This commit is contained in:
		| @@ -38,21 +38,16 @@ namespace Catch { | ||||
|                           double const* last, | ||||
|                           Estimator& estimator ) { | ||||
|                     auto n = static_cast<size_t>( last - first ); | ||||
|                     std::uniform_int_distribution<decltype( n )> dist( 0, | ||||
|                                                                        n - 1 ); | ||||
|                     std::uniform_int_distribution<size_t> dist( 0, n - 1 ); | ||||
|  | ||||
|                     sample out; | ||||
|                     out.reserve( resamples ); | ||||
|                     // We allocate the vector outside the loop to avoid realloc | ||||
|                     // per resample | ||||
|                     std::vector<double> resampled; | ||||
|                     resampled.reserve( n ); | ||||
|                     for ( size_t i = 0; i < resamples; ++i ) { | ||||
|                         resampled.clear(); | ||||
|                         for ( size_t s = 0; s < n; ++s ) { | ||||
|                             resampled.push_back( | ||||
|                                 first[static_cast<std::ptrdiff_t>( | ||||
|                                     dist( rng ) )] ); | ||||
|                             resampled.push_back( first[dist( rng )] ); | ||||
|                         } | ||||
|                         const auto estimate = | ||||
|                             estimator( resampled.data(), resampled.data() + resampled.size() ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský