Pseudo-random number generators.
These are good enough for music DSP applications but should not be considered crypthographically secure.
All functions in this module are reentrant, RT-safe, thread-safe, and have no side effects.
The algorithms are based on the "simplified" Permuted Congruential Generator (PCG) by Chris Wellons, which is itself taken from
M. E. O'Neill, "PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation", September 2014, available at https://www.cs.hmc.edu/tr/hmc-cs-2014-0905.pdf.
Version: 1.1.0
License:
Requires:
Included in Brickworks, which is:
Module type: Utility
static inline uint32_t bw_randu32(
uint64_t * BW_RESTRICT state);
Returns a pseudo-random unsigned 32-bit integer in the range [0
, UINT32_MAX
].
state
is a pointer to a 64-bit unsigned integer storing the state between calls and which gets updated by this function.
static inline float bw_randf(
uint64_t * BW_RESTRICT state);
Returns a pseudo-random unsigned 32-bit floating point number in the range [-1.f
, 1.f
].
state
is a pointer to a 64-bit unsigned integer storing the state between calls and which gets updated by this function.
BW_INCLUDE_WITH_QUOTES
and BW_CXX_NO_EXTERN_C
.BW_NULL
.bw_randf()
.bw_randu32()
.