13#if !defined(VITA_RANDOM_H)
21#include "utility/xoshiro256ss.h"
26enum class distribution {uniform, normal};
38template<
class T> [[nodiscard]] T
sup(T);
40[[nodiscard]]
unsigned ring(
unsigned,
unsigned,
unsigned);
42[[nodiscard]]
bool boolean(
double = 0.5);
62 case distribution::uniform:
65 case distribution::normal:
66 return std::normal_distribution<T>(p1, p2)(
engine);
84std::enable_if_t<std::is_floating_point_v<T>, T>
89 std::uniform_real_distribution<T> d(min,
sup);
107std::enable_if_t<std::is_integral_v<T>, T>
112 std::uniform_int_distribution<T> d(min,
sup - 1);
117std::enable_if_t<std::is_enum_v<T>, T>
122 return static_cast<T
>(between<std::underlying_type_t<T>>(min, sup));
134 return between(r.first, r.second);
154const typename C::value_type &
element(
const C &c)
160 static_cast<typename C::difference_type
>(
sup(c.size())));
174 static_cast<typename C::difference_type
>(
sup(c.size())));
188 std::bernoulli_distribution d(p);
std::pair< T, T > range_t
Right-open interval.
unsigned ring(unsigned base, unsigned width, unsigned n)
Returns a random number in a modular arithmetic system.
void seed(unsigned s)
Initalizes the random number generator.
engine_t engine
The shared random engine generator.
void randomize()
Sets the shared engine to an unpredictable state.
std::enable_if_t< std::is_floating_point_v< T >, T > between(T min, T sup)
A specialization for floating point values of the random::between(T, T) template function.
T in(range_t< T > r)
Uniformly extracts a random value in a range.
vigna::xoshiro256ss engine_t
xoshiro256** (XOR/shift/rotate) is an all-purpose, rock-solid generator (not a cryptographically secu...
const C::value_type & element(const C &c)
T ephemeral(distribution d, T p1, T p2)
Used for ephemeral random constant generation.