librfn
An ad-hoc utility library
Macros | Functions
Random numbers

Pseudo random number generators. More...

Macros

#define RAND31_VAR_INIT   1
 

Functions

uint32_t rand31_r (uint32_t *seedp)
 

Detailed Description

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.

Macro Definition Documentation

#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.

Definition at line 38 of file rand.h.

Function Documentation

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.

Parameters
[in,out]seedpCurrent state of the PRNG, initalized using RAND31_VAR_INIT

Definition at line 23 of file rand.c.