librfn
An ad-hoc utility library
|
Pseudo random number generators. More...
Macros | |
#define | RAND31_VAR_INIT 1 |
Functions | |
uint32_t | rand31_r (uint32_t *seedp) |
Pseudo random number generators.
The algorithms selected here tend towards the quick 'n dirty (and very fast on microcontrollers) rather than the high quality state-of-the-art ones you might expect in a random number library.
#define RAND31_VAR_INIT 1 |
Initialize a seed value used by rand31_r().
The only actualy requirement on the initial seed is that it must be strictly greater than zero (and 32-bit). However for simplicity we choose 1.
uint32_t rand31_r | ( | uint32_t * | seedp | ) |
Generate a 31-bit random number.
From http://www.firstpr.com.au/dsp/rand31/ : Park-Miller "minimal standard" 31 bit pseudo-random number generator, implemented with David G. Carta's optimization: with 32 bit math and without division.
[in,out] | seedp | Current state of the PRNG, initalized using RAND31_VAR_INIT |