diff --git a/include/boost/math/tools/random_vector.hpp b/include/boost/math/tools/random_vector.hpp index d1954ee3b5..79c0af4030 100644 --- a/include/boost/math/tools/random_vector.hpp +++ b/include/boost/math/tools/random_vector.hpp @@ -4,10 +4,10 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include -#include +#include namespace boost { namespace math { @@ -25,12 +25,12 @@ std::vector generate_random_vector(std::size_t size, std::size_t seed) } std::vector v(size); - std::mt19937 gen(seed); + std::mt19937_64 gen(seed); std::normal_distribution dis(0, 1); - for(std::size_t i = 0; i < v.size(); ++i) + for (auto& x : v) { - v[i] = dis(gen); + x = dis(gen); } return v; } @@ -49,9 +49,9 @@ std::vector generate_random_uniform_vector(std::size_t size, std::size_t seed std::uniform_real_distribution dis(lower_bound, upper_bound); - for (auto& i : v) + for (auto& x : v) { - i = dis(gen); + x = dis(gen); } return v; @@ -70,9 +70,9 @@ std::vector generate_random_vector(std::size_t size, std::size_t seed, T mean std::mt19937 gen(seed); std::normal_distribution dis(mean, stddev); - for (std::size_t i = 0; i < v.size(); ++i) + for (auto& x : v) { - v[i] = dis(gen); + x = dis(gen); } return v; } @@ -87,13 +87,13 @@ std::vector generate_random_vector(std::size_t size, std::size_t seed) } std::vector v(size); - std::mt19937 gen(seed); + std::mt19937_64 gen(seed); // Rescaling by larger than 2 is UB! std::uniform_int_distribution dis(std::numeric_limits::lowest()/2, (std::numeric_limits::max)()/2); - for (std::size_t i = 0; i < v.size(); ++i) + for (auto& x : v) { - v[i] = dis(gen); + x = dis(gen); } return v; }