diff --git a/sprout/algorithm/fixed/random_swap.hpp b/sprout/algorithm/fixed/random_swap.hpp index 312b02bf..14af7507 100644 --- a/sprout/algorithm/fixed/random_swap.hpp +++ b/sprout/algorithm/fixed/random_swap.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -27,14 +27,14 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::array make_random_swap_indexes_2(Random const& rnd, std::ptrdiff_t i0) { - return sprout::array{{i0, sprout::generators::generated_value(rnd)}}; + return sprout::array{{i0, sprout::random::result(rnd)}}; } template inline SPROUT_CONSTEXPR sprout::array make_random_swap_indexes_1(Random const& rnd) { return sprout::fixed::detail::make_random_swap_indexes_2( - sprout::generators::next_generator(rnd)(), - sprout::generators::generated_value(rnd) + sprout::random::next(rnd)(), + sprout::random::result(rnd) ); } template diff --git a/sprout/algorithm/fixed/random_swap_result.hpp b/sprout/algorithm/fixed/random_swap_result.hpp index 7d6627a9..e9d87538 100644 --- a/sprout/algorithm/fixed/random_swap_result.hpp +++ b/sprout/algorithm/fixed/random_swap_result.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -33,16 +33,16 @@ namespace sprout { make_random_swap_result_indexes_2(Random const& rnd, std::ptrdiff_t i0) { typedef sprout::pair, typename std::decay::type> result_type; return result_type( - sprout::array{{i0, sprout::generators::generated_value(rnd)}}, - sprout::generators::next_generator(rnd).engine() + sprout::array{{i0, sprout::random::result(rnd)}}, + sprout::random::next(rnd).engine() ); } template inline SPROUT_CONSTEXPR sprout::pair, typename std::decay::type> make_random_swap_result_indexes_1(Random const& rnd) { return sprout::fixed::detail::make_random_swap_result_indexes_2( - sprout::generators::next_generator(rnd)(), - sprout::generators::generated_value(rnd) + sprout::random::next(rnd)(), + sprout::random::result(rnd) ); } template diff --git a/sprout/algorithm/fixed/shuffle.hpp b/sprout/algorithm/fixed/shuffle.hpp index d2c54954..a03c0708 100644 --- a/sprout/algorithm/fixed/shuffle.hpp +++ b/sprout/algorithm/fixed/shuffle.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -33,11 +33,11 @@ namespace sprout { return i < n - 1 ? sprout::fixed::detail::make_shuffle_indexes_1( n, - sprout::generators::next_generator(rnd)(), - sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::generators::generated_value(rnd)), + sprout::random::next(rnd)(), + sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::random::result(rnd)), i + 1 ) - : sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::generators::generated_value(rnd)) + : sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::random::result(rnd)) ; } template diff --git a/sprout/algorithm/fixed/shuffle_result.hpp b/sprout/algorithm/fixed/shuffle_result.hpp index 6b9363be..b86a0724 100644 --- a/sprout/algorithm/fixed/shuffle_result.hpp +++ b/sprout/algorithm/fixed/shuffle_result.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -37,13 +37,13 @@ namespace sprout { return i < n - 1 ? sprout::fixed::detail::make_shuffle_result_indexes_1( n, - sprout::generators::next_generator(rnd)(), - sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::generators::generated_value(rnd)), + sprout::random::next(rnd)(), + sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::random::result(rnd)), i + 1 ) : result_type( - sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::generators::generated_value(rnd)), - sprout::generators::next_generator(rnd).engine() + sprout::fixed::swap_element(arr, arr.begin() + i, arr.begin() + sprout::random::result(rnd)), + sprout::random::next(rnd).engine() ) ; } diff --git a/sprout/random/additive_combine.hpp b/sprout/random/additive_combine.hpp index e9f9910f..f48b348d 100644 --- a/sprout/random/additive_combine.hpp +++ b/sprout/random/additive_combine.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -53,12 +53,12 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate(Random1 const& rnd1, Random2 const& rnd2) const { return sprout::random::random_result( - sprout::generators::generated_value(rnd2) < sprout::generators::generated_value(rnd1) - ? sprout::generators::generated_value(rnd1) - sprout::generators::generated_value(rnd2) - : sprout::generators::generated_value(rnd1) - sprout::generators::generated_value(rnd2) + base1_type::modulus - 1 + sprout::random::result(rnd2) < sprout::random::result(rnd1) + ? sprout::random::result(rnd1) - sprout::random::result(rnd2) + : sprout::random::result(rnd1) - sprout::random::result(rnd2) + base1_type::modulus - 1 , additive_combine_engine( - sprout::generators::next_generator(rnd1), sprout::generators::next_generator(rnd2), + sprout::random::next(rnd1), sprout::random::next(rnd2), private_construct_t() ) ); diff --git a/sprout/random/bernoulli_distribution.hpp b/sprout/random/bernoulli_distribution.hpp index 7d9ec82e..f7e170d5 100644 --- a/sprout/random/bernoulli_distribution.hpp +++ b/sprout/random/bernoulli_distribution.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -83,10 +83,10 @@ namespace sprout { ) const { return sprout::random::random_result( - RealType(sprout::generators::generated_value(rnd) - sprout::generators::next_generator(rnd).min()) - <= p_ * RealType(sprout::generators::next_generator(rnd).max() - sprout::generators::next_generator(rnd).min()) + RealType(sprout::random::result(rnd) - sprout::random::next(rnd).min()) + <= p_ * RealType(sprout::random::next(rnd).max() - sprout::random::next(rnd).min()) , - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), *this ); } diff --git a/sprout/random/binomial_distribution.hpp b/sprout/random/binomial_distribution.hpp index 43ee5905..e265665d 100644 --- a/sprout/random/binomial_distribution.hpp +++ b/sprout/random/binomial_distribution.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE # include @@ -321,7 +321,7 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result invert_0(IntType t, RealType p, Random const& rnd) const { - return invert_1(t, p, sprout::generators::next_generator(rnd).engine(), sprout::generators::generated_value(rnd)); + return invert_1(t, p, sprout::random::next(rnd).engine(), sprout::random::result(rnd)); } template SPROUT_CONSTEXPR sprout::random::random_result @@ -332,9 +332,9 @@ namespace sprout { SPROUT_CONSTEXPR sprout::random::random_result invert2_0(IntType t, sprout::random::random_result const& rnd) const { return sprout::random::random_result( - t - sprout::generators::generated_value(rnd), - sprout::generators::next_generator(rnd).engine(), - sprout::generators::next_generator(rnd).distribution() + t - sprout::random::result(rnd), + sprout::random::next(rnd).engine(), + sprout::random::next(rnd).distribution() ); } template @@ -488,11 +488,11 @@ namespace sprout { generate_2(Random const& rnd, RealType v) const { return v >= btrd_.v_r ? generate_3( - sprout::generators::next_generator(rnd).engine(), v, - sprout::generators::generated_value(rnd) - RealType(0.5) + sprout::random::next(rnd).engine(), v, + sprout::random::result(rnd) - RealType(0.5) ) : generate_3( - sprout::generators::next_generator(rnd).engine(), sprout::generators::generated_value(rnd) * btrd_.v_r, + sprout::random::next(rnd).engine(), sprout::random::result(rnd) * btrd_.v_r, ((v / btrd_.v_r - RealType(0.93)) < 0 ? RealType(-0.5) : RealType(0.5)) - (v / btrd_.v_r - RealType(0.93)) ) ; @@ -531,7 +531,7 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_0(Random const& rnd) const { - return generate_1(sprout::generators::next_generator(rnd).engine(), sprout::generators::generated_value(rnd)); + return generate_1(sprout::random::next(rnd).engine(), sprout::random::result(rnd)); } template SPROUT_CONSTEXPR sprout::random::random_result @@ -639,13 +639,13 @@ namespace sprout { generate_2(Random const& rnd, RealType v) const { return v >= btrd_.v_r ? generate_3( - sprout::generators::next_generator(rnd).engine(), + sprout::random::next(rnd).engine(), v, - sprout::generators::generated_value(rnd) - RealType(0.5) + sprout::random::result(rnd) - RealType(0.5) ) : generate_3( - sprout::generators::next_generator(rnd).engine(), - sprout::generators::generated_value(rnd) * btrd_.v_r, + sprout::random::next(rnd).engine(), + sprout::random::result(rnd) * btrd_.v_r, ((v / btrd_.v_r - RealType(0.93)) < 0 ? RealType(-0.5) : RealType(0.5)) - (v / btrd_.v_r - RealType(0.93)) ) ; @@ -670,7 +670,7 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_0(Random const& rnd) const { - return generate_1(sprout::generators::next_generator(rnd).engine(), sprout::generators::generated_value(rnd)); + return generate_1(sprout::random::next(rnd).engine(), sprout::random::result(rnd)); } template SPROUT_CONSTEXPR sprout::random::random_result @@ -682,9 +682,9 @@ namespace sprout { SPROUT_CONSTEXPR sprout::random::random_result generate2_0(IntType t, sprout::random::random_result const& rnd) const { return sprout::random::random_result( - t - sprout::generators::generated_value(rnd), - sprout::generators::next_generator(rnd).engine(), - sprout::generators::next_generator(rnd).distribution() + t - sprout::random::result(rnd), + sprout::random::next(rnd).engine(), + sprout::random::next(rnd).distribution() ); } template diff --git a/sprout/random/detail/uniform_int_float.hpp b/sprout/random/detail/uniform_int_float.hpp index 02b10046..688b4274 100644 --- a/sprout/random/detail/uniform_int_float.hpp +++ b/sprout/random/detail/uniform_int_float.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT @@ -39,8 +39,8 @@ namespace sprout { ) const { return sprout::random::random_result( - static_cast(sprout::generators::generated_value(rnd) * (static_cast(max()) + 1)), - uniform_int_float(sprout::generators::next_generator(rnd)) + static_cast(sprout::random::result(rnd) * (static_cast(max()) + 1)), + uniform_int_float(sprout::random::next(rnd)) ); } public: diff --git a/sprout/random/generate_array.hpp b/sprout/random/generate_array.hpp index b42216fe..85213b23 100644 --- a/sprout/random/generate_array.hpp +++ b/sprout/random/generate_array.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -44,8 +44,8 @@ namespace sprout { typename sprout::generators::results::next_generator::type > const pair_type; return pair_type{ - sprout::array{{args..., sprout::generators::generated_value(rnd)}}, - sprout::generators::next_generator(rnd) + sprout::array{{args..., sprout::random::result(rnd)}}, + sprout::random::next(rnd) }; } template @@ -57,8 +57,8 @@ namespace sprout { > const >::type generate_array_impl(Random const& rnd, Args const&... args) { return sprout::random::detail::generate_array_impl( - sprout::generators::next_generator(rnd)(), - args..., sprout::generators::generated_value(rnd) + sprout::random::next(rnd)(), + args..., sprout::random::result(rnd) ); } } // namespace detail diff --git a/sprout/random/generate_canonical.hpp b/sprout/random/generate_canonical.hpp index 404fdce5..c38bbb4f 100644 --- a/sprout/random/generate_canonical.hpp +++ b/sprout/random/generate_canonical.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT @@ -92,8 +92,8 @@ namespace sprout { r, limit, s + RealType( sprout::random::detail::subtract()( - sprout::generators::generated_value(rnd), - sprout::generators::next_generator(rnd).min() + sprout::random::result(rnd), + sprout::random::next(rnd).min() ) ) * mult, mult * r, @@ -102,11 +102,11 @@ namespace sprout { : pair_type( (s + RealType( sprout::random::detail::subtract()( - sprout::generators::generated_value(rnd), - sprout::generators::next_generator(rnd).min() + sprout::random::result(rnd), + sprout::random::next(rnd).min() ) ) * mult) / (mult * r), - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) ) ; } @@ -119,8 +119,8 @@ namespace sprout { r, limit, RealType( sprout::random::detail::subtract()( - sprout::generators::generated_value(rnd), - sprout::generators::next_generator(rnd).min() + sprout::random::result(rnd), + sprout::random::next(rnd).min() ) ), r, @@ -129,11 +129,11 @@ namespace sprout { : pair_type( RealType( sprout::random::detail::subtract()( - sprout::generators::generated_value(rnd), - sprout::generators::next_generator(rnd).min() + sprout::random::result(rnd), + sprout::random::next(rnd).min() ) ) / r, - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) ) ; } @@ -157,16 +157,16 @@ namespace sprout { return mult * r < limit ? sprout::random::detail::generate_canonical_impl_0_1( r, limit, s + sprout::math::floor( - (RealType(sprout::generators::generated_value(rnd)) - RealType(sprout::generators::next_generator(rnd).min())) * r + (RealType(sprout::random::result(rnd)) - RealType(sprout::random::next(rnd).min())) * r ) * mult, mult * r, rnd() ) : pair_type( (s + sprout::math::floor( - (RealType(sprout::generators::generated_value(rnd)) - RealType(sprout::generators::next_generator(rnd).min())) * r + (RealType(sprout::random::result(rnd)) - RealType(sprout::random::next(rnd).min())) * r ) * mult) / (mult * r), - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) ) ; } @@ -176,13 +176,13 @@ namespace sprout { typedef sprout::pair const pair_type; return r < limit ? sprout::random::detail::generate_canonical_impl_0_1( r, limit, - RealType(sprout::generators::generated_value(rnd) - sprout::generators::next_generator(rnd).min()), + RealType(sprout::random::result(rnd) - sprout::random::next(rnd).min()), r, rnd() ) : pair_type( - RealType(sprout::generators::generated_value(rnd) - sprout::generators::next_generator(rnd).min()) / r, - sprout::generators::next_generator(rnd) + RealType(sprout::random::result(rnd) - sprout::random::next(rnd).min()) / r, + sprout::random::next(rnd) ) ; } diff --git a/sprout/random/geometric_distribution.hpp b/sprout/random/geometric_distribution.hpp index 2ef9a86c..13d1f09a 100644 --- a/sprout/random/geometric_distribution.hpp +++ b/sprout/random/geometric_distribution.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -91,8 +91,8 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_1(Random const& rnd) const { return sprout::random::random_result( - static_cast(sprout::math::floor(sprout::math::log(RealType(1) - sprout::generators::generated_value(rnd)) / log_1mp_)), - sprout::generators::next_generator(rnd).engine(), + static_cast(sprout::math::floor(sprout::math::log(RealType(1) - sprout::random::result(rnd)) / log_1mp_)), + sprout::random::next(rnd).engine(), *this ); } diff --git a/sprout/random/linear_congruential.hpp b/sprout/random/linear_congruential.hpp index 54a635d1..8053453a 100644 --- a/sprout/random/linear_congruential.hpp +++ b/sprout/random/linear_congruential.hpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -212,8 +212,8 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate(EngineResult const& rnd) const { return sprout::random::random_result( - static_cast(sprout::generators::generated_value(rnd)) >> 17, - rand48(sprout::generators::next_generator(rnd), private_construct_t()) + static_cast(sprout::random::result(rnd)) >> 17, + rand48(sprout::random::next(rnd), private_construct_t()) ); } public: diff --git a/sprout/random/normal_distribution.hpp b/sprout/random/normal_distribution.hpp index c6fb062e..117a150e 100644 --- a/sprout/random/normal_distribution.hpp +++ b/sprout/random/normal_distribution.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -141,14 +141,14 @@ namespace sprout { SPROUT_CONSTEXPR sprout::random::random_result generate_1_1(RealType r1, Random const& rnd) const { return generate_2( - sprout::generators::next_generator(rnd).engine(), r1, sprout::generators::generated_value(rnd), - sprout::sqrt(-result_type(2) * sprout::math::log(result_type(1) - sprout::generators::generated_value(rnd))), true + sprout::random::next(rnd).engine(), r1, sprout::random::result(rnd), + sprout::sqrt(-result_type(2) * sprout::math::log(result_type(1) - sprout::random::result(rnd))), true ); } template SPROUT_CONSTEXPR sprout::random::random_result generate_1(Random const& rnd) const { - return generate_1_1(sprout::generators::generated_value(rnd), sprout::generators::next_generator(rnd)()); + return generate_1_1(sprout::random::result(rnd), sprout::random::next(rnd)()); } template SPROUT_CONSTEXPR sprout::random::random_result diff --git a/sprout/random/random_result.hpp b/sprout/random/random_result.hpp index 8b678d2b..76bf058b 100644 --- a/sprout/random/random_result.hpp +++ b/sprout/random/random_result.hpp @@ -98,6 +98,12 @@ namespace sprout { SPROUT_CONSTEXPR result_type const& result() const SPROUT_NOEXCEPT { return result_; } + SPROUT_CXX14_CONSTEXPR generator_type& next() SPROUT_NOEXCEPT { + return generator_; + } + SPROUT_CONSTEXPR generator_type const& next() const SPROUT_NOEXCEPT { + return generator_; + } SPROUT_CXX14_CONSTEXPR engine_type& engine() SPROUT_NOEXCEPT { return generator_.engine(); } @@ -225,6 +231,12 @@ namespace sprout { SPROUT_CONSTEXPR result_type const& result() const SPROUT_NOEXCEPT { return result_; } + SPROUT_CXX14_CONSTEXPR generator_type& next() SPROUT_NOEXCEPT { + return generator_; + } + SPROUT_CONSTEXPR generator_type const& next() const SPROUT_NOEXCEPT { + return generator_; + } SPROUT_CXX14_CONSTEXPR engine_type& engine() SPROUT_NOEXCEPT { return generator_; } diff --git a/sprout/random/result.hpp b/sprout/random/result.hpp new file mode 100644 index 00000000..68de620e --- /dev/null +++ b/sprout/random/result.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_RANDOM_RESULT_HPP +#define SPROUT_RANDOM_RESULT_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace random { + // + // result + // + template + inline SPROUT_CONSTEXPR decltype(sprout::generators::generated_value(std::declval())) + result(T&& t) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generated_value(std::declval()))) + { + return sprout::generators::generated_value(sprout::forward(t)); + } + + // + // next + // + template + inline SPROUT_CONSTEXPR decltype(sprout::generators::next_generator(std::declval())) + next(T&& t) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::next_generator(std::declval()))) + { + return sprout::generators::next_generator(sprout::forward(t)); + } + } // namespace random +} // namespace sprout + +#endif // #ifndef SPROUT_RANDOM_RESULT_HPP diff --git a/sprout/random/shuffle_order.hpp b/sprout/random/shuffle_order.hpp index 21664573..0f2400c3 100644 --- a/sprout/random/shuffle_order.hpp +++ b/sprout/random/shuffle_order.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,9 +86,9 @@ namespace sprout { member_type >::type init_member_4(sprout::index_tuple, sprout::array const& a, EngineResult const& rnd, Args const&... args) { return member_type{ - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), sprout::array{{a[Indexes]..., args...}}, - sprout::generators::generated_value(rnd) + sprout::random::result(rnd) }; } template @@ -103,7 +103,7 @@ namespace sprout { (M + sizeof...(Args) < k), member_type >::type init_member_3(sprout::array const& a, EngineResult const& rnd, Args const&... args) { - return init_member_3(a, sprout::generators::next_generator(rnd)(), args..., sprout::generators::generated_value(rnd)); + return init_member_3(a, sprout::random::next(rnd)(), args..., sprout::random::result(rnd)); } template static SPROUT_CONSTEXPR member_type init_member_2(Pair const& p) { @@ -116,9 +116,9 @@ namespace sprout { member_type >::type init_member_1(EngineResult const& rnd, Args const&... args) { return member_type{ - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), sprout::array{{args...}}, - sprout::generators::generated_value(rnd) + sprout::random::result(rnd) }; } template @@ -126,7 +126,7 @@ namespace sprout { (sizeof...(Args) < k), member_type >::type init_member_1(EngineResult const& rnd, Args const&... args) { - return init_member_1(sprout::generators::next_generator(rnd)(), args..., sprout::generators::generated_value(rnd)); + return init_member_1(sprout::random::next(rnd)(), args..., sprout::random::result(rnd)); } static SPROUT_CONSTEXPR member_type init_member_0(base_type const& rng, std::true_type) { return init_member_2(sprout::random::generate_array(rng)); @@ -156,8 +156,8 @@ namespace sprout { return sprout::random::random_result( v_[j], shuffle_order_engine( - sprout::generators::next_generator(rnd), - sprout::fixed::set(v_, j, sprout::generators::generated_value(rnd)), + sprout::random::next(rnd), + sprout::fixed::set(v_, j, sprout::random::result(rnd)), v_[j], private_construct_t() ) diff --git a/sprout/random/uniform_01.hpp b/sprout/random/uniform_01.hpp index c6402bc4..a5235661 100644 --- a/sprout/random/uniform_01.hpp +++ b/sprout/random/uniform_01.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE # include #endif @@ -66,7 +66,7 @@ namespace sprout { generate_1(Engine const&, EngineResult const& rnd, result_type result) const { return result < result_type(1) ? sprout::random::random_result(result, rnd.engine(), *this) - : generate(sprout::generators::next_generator(rnd), sprout::generators::next_generator(rnd)()) + : generate(sprout::random::next(rnd), sprout::random::next(rnd)()) ; } template @@ -81,7 +81,7 @@ namespace sprout { return generate_1( eng, rnd, - result_type(sprout::generators::generated_value(rnd) - eng.min()) * ( + result_type(sprout::random::result(rnd) - eng.min()) * ( result_type(1) / ( result_type(eng.max() - eng.min()) + result_type( sprout::numeric_limits::is_integer ? 1 : 0 @@ -101,7 +101,7 @@ namespace sprout { generate_1(Engine const&, EngineResult const& rnd, result_type result) const { return result < result_type(1) ? sprout::random::random_result(result, rnd.engine(), *this) - : generate(sprout::generators::next_generator(rnd), sprout::generators::next_generator(rnd)()) + : generate(sprout::random::next(rnd), sprout::random::next(rnd)()) ; } template @@ -111,7 +111,7 @@ namespace sprout { return generate_1( eng, rnd, - result_type(sprout::generators::generated_value(rnd) - eng.min()) * ( + result_type(sprout::random::result(rnd) - eng.min()) * ( result_type(1) / ( result_type(eng.max() - eng.min()) + result_type( sprout::numeric_limits::is_integer ? 1 : 0 diff --git a/sprout/random/uniform_int_distribution.hpp b/sprout/random/uniform_int_distribution.hpp index 2921f41f..0fd34393 100644 --- a/sprout/random/uniform_int_distribution.hpp +++ b/sprout/random/uniform_int_distribution.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -183,9 +183,9 @@ namespace sprout { ) { return sprout::random::detail::generate_uniform_int_true_3_1_1( - sprout::generators::next_generator(rnd), min_value, range, + sprout::random::next(rnd), min_value, range, bmin, brange, bucket_size, - sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin) / bucket_size + sprout::random::detail::subtract()(sprout::random::result(rnd), bmin) / bucket_size ); } template @@ -329,14 +329,14 @@ namespace sprout { return mult * RangeType(brange) == range - mult + 1 ? sprout::random::detail::generate_uniform_int_result{ static_cast( - result + static_cast(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin) * mult) + result + static_cast(sprout::random::detail::subtract()(sprout::random::result(rnd), bmin) * mult) ), - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) } : sprout::random::detail::generate_uniform_int_true_2_1( - sprout::generators::next_generator(rnd), min_value, range, + sprout::random::next(rnd), min_value, range, bmin, brange, limit, - result + static_cast(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin) * mult), + result + static_cast(sprout::random::detail::subtract()(sprout::random::result(rnd), bmin) * mult), mult * (RangeType(brange) + RangeType(1)) ) ; @@ -423,10 +423,10 @@ namespace sprout { typedef typename std::make_unsigned::type base_unsigned; return sprout::random::detail::generate_uniform_int_result{ sprout::random::detail::add()( - base_unsigned(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin)), + base_unsigned(sprout::random::detail::subtract()(sprout::random::result(rnd), bmin)), min_value ), - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) }; } template @@ -557,9 +557,9 @@ namespace sprout { ) { return sprout::random::detail::generate_uniform_int_true_3_1_1( - sprout::generators::next_generator(rnd), min_value, range, + sprout::random::next(rnd), min_value, range, bmin, brange, bucket_size, - sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin) / bucket_size + sprout::random::detail::subtract()(sprout::random::result(rnd), bmin) / bucket_size ); } template @@ -645,14 +645,14 @@ namespace sprout { return mult * RangeType(brange) == range - mult + 1 ? sprout::random::detail::generate_uniform_int_result{ static_cast( - result + static_cast(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin) * mult) + result + static_cast(sprout::random::detail::subtract()(sprout::random::result(rnd), bmin) * mult) ), - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) } : sprout::random::detail::generate_uniform_int_true_2_1( - sprout::generators::next_generator(rnd), min_value, range, + sprout::random::next(rnd), min_value, range, bmin, brange, limit, - result + static_cast(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin) * mult), + result + static_cast(sprout::random::detail::subtract()(sprout::random::result(rnd), bmin) * mult), mult * (RangeType(brange) + RangeType(1)) ) ; @@ -711,10 +711,10 @@ namespace sprout { typedef typename std::make_unsigned::type base_unsigned; return sprout::random::detail::generate_uniform_int_result{ sprout::random::detail::add()( - base_unsigned(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), bmin)), + base_unsigned(sprout::random::detail::subtract()(sprout::random::result(rnd), bmin)), min_value ), - sprout::generators::next_generator(rnd) + sprout::random::next(rnd) }; } template diff --git a/sprout/random/uniform_real_distribution.hpp b/sprout/random/uniform_real_distribution.hpp index 202d68ab..5ec9544d 100644 --- a/sprout/random/uniform_real_distribution.hpp +++ b/sprout/random/uniform_real_distribution.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -149,10 +149,10 @@ namespace sprout { ) { return sprout::random::detail::generate_uniform_real_false_2( - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), min_value, max_value, - static_cast(sprout::generators::generated_value(rnd) - sprout::generators::next_generator(rnd).min()), - static_cast(sprout::generators::next_generator(rnd).max() - sprout::generators::next_generator(rnd).min()) + static_cast(sprout::random::result(rnd) - sprout::random::next(rnd).min()), + static_cast(sprout::random::next(rnd).max() - sprout::random::next(rnd).min()) ); } template @@ -234,10 +234,10 @@ namespace sprout { { typedef typename EngineResult::result_type base_result; return sprout::random::detail::generate_uniform_real_true_2( - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), min_value, max_value, - static_cast(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), sprout::generators::next_generator(rnd).min())), - static_cast(sprout::random::detail::subtract()(sprout::generators::next_generator(rnd).max(), sprout::generators::next_generator(rnd).min())) + 1 + static_cast(sprout::random::detail::subtract()(sprout::random::result(rnd), sprout::random::next(rnd).min())), + static_cast(sprout::random::detail::subtract()(sprout::random::next(rnd).max(), sprout::random::next(rnd).min())) + 1 ); } template @@ -293,10 +293,10 @@ namespace sprout { ) { return sprout::random::detail::generate_uniform_real_false_2( - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), min_value, max_value, - static_cast(sprout::generators::generated_value(rnd) - sprout::generators::next_generator(rnd).min()), - static_cast(sprout::generators::next_generator(rnd).max() - sprout::generators::next_generator(rnd).min()) + static_cast(sprout::random::result(rnd) - sprout::random::next(rnd).min()), + static_cast(sprout::random::next(rnd).max() - sprout::random::next(rnd).min()) ); } template @@ -343,10 +343,10 @@ namespace sprout { { typedef typename EngineResult::result_type base_result; return sprout::random::detail::generate_uniform_real_true_2( - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), min_value, max_value, - static_cast(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), sprout::generators::next_generator(rnd).min())), - static_cast(sprout::random::detail::subtract()(sprout::generators::next_generator(rnd).max(), sprout::generators::next_generator(rnd).min())) + 1 + static_cast(sprout::random::detail::subtract()(sprout::random::result(rnd), sprout::random::next(rnd).min())), + static_cast(sprout::random::detail::subtract()(sprout::random::next(rnd).max(), sprout::random::next(rnd).min())) + 1 ); } #endif diff --git a/sprout/random/uniform_smallint.hpp b/sprout/random/uniform_smallint.hpp index e200e57d..a282dea8 100644 --- a/sprout/random/uniform_smallint.hpp +++ b/sprout/random/uniform_smallint.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -136,12 +136,12 @@ namespace sprout { return range >= base_range ? sprout::random::random_result( sprout::random::detail::add()(static_cast(val), min_), - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), *this ) : sprout::random::random_result( sprout::random::detail::add()(static_cast(val % (static_cast(range) + 1)), min_), - sprout::generators::next_generator(rnd), + sprout::random::next(rnd), *this ) ; @@ -160,7 +160,7 @@ namespace sprout { rnd, range, base_range, - BaseUnsigned(sprout::random::detail::subtract()(sprout::generators::generated_value(rnd), eng.min())) + BaseUnsigned(sprout::random::detail::subtract()(sprout::random::result(rnd), eng.min())) ); } template @@ -190,12 +190,12 @@ namespace sprout { return offset > range ? sprout::random::random_result( max_, - sprout::generators::next_generator(rnd).engine(), + sprout::random::next(rnd).engine(), *this ) : sprout::random::random_result( sprout::random::detail::add()(offset, min_), - sprout::generators::next_generator(rnd).engine(), + sprout::random::next(rnd).engine(), *this ) ; @@ -212,7 +212,7 @@ namespace sprout { eng, rnd, static_cast(sprout::random::detail::subtract()(max_, min_)), - static_cast(sprout::generators::generated_value(rnd) * (static_cast(range) + 1)) + static_cast(sprout::random::result(rnd) * (static_cast(range) + 1)) ); } template diff --git a/sprout/random/utility.hpp b/sprout/random/utility.hpp index fa414aab..ae1c1d2e 100644 --- a/sprout/random/utility.hpp +++ b/sprout/random/utility.hpp @@ -16,5 +16,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_RANDOM_UTILITY_HPP diff --git a/sprout/random/xor_combine.hpp b/sprout/random/xor_combine.hpp index a3d70394..ca11c417 100644 --- a/sprout/random/xor_combine.hpp +++ b/sprout/random/xor_combine.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT @@ -47,9 +47,9 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate(EngineResult1 const& rnd1, EngineResult2 const& rnd2) const { return sprout::random::random_result( - (sprout::generators::generated_value(rnd1) << s1) ^ (sprout::generators::generated_value(rnd2) << s2), + (sprout::random::result(rnd1) << s1) ^ (sprout::random::result(rnd2) << s2), xor_combine_engine( - sprout::generators::next_generator(rnd1), sprout::generators::next_generator(rnd2) + sprout::random::next(rnd1), sprout::random::next(rnd2) ) ); } diff --git a/sprout/uuid/random_generator.hpp b/sprout/uuid/random_generator.hpp index 83312700..aee09f1f 100644 --- a/sprout/uuid/random_generator.hpp +++ b/sprout/uuid/random_generator.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include namespace sprout { namespace uuids { @@ -59,14 +59,14 @@ namespace sprout { sizeof...(Args) == 3, result_type >::type random_to_uuid(Random const& rnd, Args... args) const { - return random_to_uuid_1(args..., sprout::generators::generated_value(rnd)); + return random_to_uuid_1(args..., sprout::random::result(rnd)); } template SPROUT_CONSTEXPR typename std::enable_if< sizeof...(Args) != 3, result_type >::type random_to_uuid(Random const& rnd, Args... args) const { - return random_to_uuid(sprout::generators::next_generator(rnd)(), args..., sprout::generators::generated_value(rnd)); + return random_to_uuid(sprout::random::next(rnd)(), args..., sprout::random::result(rnd)); } public: SPROUT_CONSTEXPR basic_random_generator()