Add random::uniform helper function
This commit is contained in:
parent
9d29e3a656
commit
e87c4508fc
1 changed files with 12 additions and 0 deletions
|
|
@ -11,4 +11,16 @@ namespace psemek::random
|
|||
template <typename T>
|
||||
using uniform_distribution = std::conditional_t<std::is_floating_point_v<T>, uniform_real_distribution<T>, uniform_int_distribution<T>>;
|
||||
|
||||
template <typename T, typename RNG>
|
||||
T uniform(RNG && rng, geom::interval<T> const & range)
|
||||
{
|
||||
return uniform_distribution<T>{range}(rng);
|
||||
}
|
||||
|
||||
template <typename T, typename RNG>
|
||||
T uniform(RNG && rng, T min, T max)
|
||||
{
|
||||
return uniform<T>(rng, {min, max});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue