29 void seed(uint64_t s0, uint64_t s1) {
40 static uint64_t
rotl(uint64_t x,
int k) {
41 return (x << k) | (x >> (64 - k));
45 uint64_t s0 =
state[0];
46 uint64_t s1 =
state[1];
47 uint64_t result = s0 + s1;
50 state[0] =
rotl(s0, 55) ^ s1 ^ (s1 << 14);
55 constexpr uint64_t
min()
const {
58 constexpr uint64_t
max()
const {
80inline uint32_t
get() {
86inline uint16_t
get() {
122 float radius = std::sqrt(-2.f * std::log(1.f -
get<float>()));
124 return radius * std::sin(theta);
136inline void buffer(uint8_t* out,
size_t len) {
138 for (
size_t i = 0; i < len; i += 4) {
144 out[i + 2] = r >> 16;
146 out[i + 3] = r >> 24;
151inline std::vector<uint8_t>
vector(
size_t len) {
152 std::vector<uint8_t> v(len);
float normal()
Returns a normal random number with mean 0 and standard deviation 1.
Definition random.hpp:120
void buffer(uint8_t *out, size_t len)
Fills an array with random bytes.
Definition random.hpp:136
Xoroshiro128Plus & local()
Returns the generator.
uint64_t u64()
Returns a uniform random uint64_t from 0 to UINT64_MAX.
Definition random.hpp:113
float uniform()
Returns a uniform random float in the interval [0.0, 1.0)
Definition random.hpp:117
std::vector< uint8_t > vector(size_t len)
Creates a vector of random bytes.
Definition random.hpp:151
T get()
Definition random.hpp:74
uint32_t u32()
Returns a uniform random uint32_t from 0 to UINT32_MAX.
Definition random.hpp:115
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
xoroshiro128+.
Definition random.hpp:26
constexpr uint64_t max() const
Definition random.hpp:58
constexpr uint64_t min() const
Definition random.hpp:55
void seed(uint64_t s0, uint64_t s1)
Definition random.hpp:29
static uint64_t rotl(uint64_t x, int k)
Definition random.hpp:40
uint64_t operator()()
Definition random.hpp:44
bool isSeeded()
Definition random.hpp:36
uint64_t state[2]
Definition random.hpp:27