YAKL
|
Non-cryptographic pseudo-random number generator with a very small internal state. More...
#include <YAKL_random.h>
Public Member Functions | |
YAKL_INLINE | Random () |
Initializes a prng object with the seed 1368976481. Warm-up of 20 iterations. More... | |
YAKL_INLINE | Random (Random &&in) |
Moves a Random object. More... | |
YAKL_INLINE | Random (Random const &in) |
Copies a Random object. More... | |
YAKL_INLINE | Random (u8 seed) |
Initializes a prng object with the specified seed. Warm-up of 20 iterations. More... | |
YAKL_INLINE u8 | gen () |
Generates a random unsigned integer between zero and std::numeric_limits<u8>::max() - 1 More... | |
template<class T > | |
YAKL_INLINE T | genFP () |
Generates a random floating point value between 0 and 1 More... | |
template<class T > | |
YAKL_INLINE T | genFP (T lb, T ub) |
Generates a random floating point value between lb and ub More... | |
YAKL_INLINE Random & | operator= (Random &&in) |
Moves a Random object. More... | |
YAKL_INLINE Random & | operator= (Random const &in) |
Copies a Random object. More... | |
YAKL_INLINE void | set_seed (u8 seed) |
Assigns a seed. Warm-up of 20 iterations. More... | |
Non-cryptographic pseudo-random number generator with a very small internal state.
Based on the algorithm here: https://burtleburtle.net/bob/rand/smallprng.html The author wrote the following statement on the website (Accessed Aug 1 2022):
I wrote this PRNG. I place it in the public domain. Same goes for at least the implementation of all those tests linked to above.
IMPORTANT: When creating a Random object inside a parallel_for
kernel, please ensure each thread's object has a different and unique initial seed.
|
inline |
Initializes a prng object with the seed 1368976481. Warm-up of 20 iterations.
|
inline |
Initializes a prng object with the specified seed. Warm-up of 20 iterations.
|
inline |
Copies a Random object.
|
inline |
Moves a Random object.
|
inline |
Generates a random unsigned integer between zero and std::numeric_limits<u8>::max() - 1
|
inline |
Generates a random floating point value between 0
and 1
T | The type of the floating point number |
|
inline |
Generates a random floating point value between lb
and ub
T | The type of the floating point number |
lb | Lower bound of the random number |
ub | Upper bound of the random number |
|
inline |
Moves a Random object.
|
inline |
Copies a Random object.
|
inline |
Assigns a seed. Warm-up of 20 iterations.