mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-14 15:04:09 +00:00
add random::result, random::next
This commit is contained in:
parent
3879666b02
commit
769e18178a
23 changed files with 191 additions and 136 deletions
|
@ -20,7 +20,7 @@
|
|||
#include <sprout/math/floor.hpp>
|
||||
#include <sprout/random/random_result.hpp>
|
||||
#include <sprout/random/uniform_01.hpp>
|
||||
#include <sprout/generator/functions.hpp>
|
||||
#include <sprout/random/result.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||
# include <sprout/workaround/recursive_function_template.hpp>
|
||||
|
@ -321,7 +321,7 @@ namespace sprout {
|
|||
template<typename Engine, typename Random>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
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<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -332,9 +332,9 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
invert2_0(IntType t, sprout::random::random_result<Engine, binomial_distribution> const& rnd) const {
|
||||
return sprout::random::random_result<Engine, binomial_distribution>(
|
||||
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<typename Engine>
|
||||
|
@ -488,11 +488,11 @@ namespace sprout {
|
|||
generate_2(Random const& rnd, RealType v) const {
|
||||
return v >= btrd_.v_r
|
||||
? generate_3<D + 1>(
|
||||
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<D + 1>(
|
||||
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<int D, typename Engine, typename Random, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate_0(Random const& rnd) const {
|
||||
return generate_1<D + 1>(sprout::generators::next_generator(rnd).engine(), sprout::generators::generated_value(rnd));
|
||||
return generate_1<D + 1>(sprout::random::next(rnd).engine(), sprout::random::result(rnd));
|
||||
}
|
||||
template<int D, typename Engine, typename Random, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -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<typename Engine, typename Random>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
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<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
|
@ -682,9 +682,9 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
generate2_0(IntType t, sprout::random::random_result<Engine, binomial_distribution> const& rnd) const {
|
||||
return sprout::random::random_result<Engine, binomial_distribution>(
|
||||
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<typename Engine>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue