Random

Pseudo Random Number Generator (PRNG) More...

Detailed Description

Files

file  random.h
 Common interface to the software PRNG.
 

Macros

#define PRNG_FLOAT   (0)
 Enables support for floating point random number generation.
 

Functions

void random_init (uint32_t s)
 initializes PRNG with a seed More...
 
void random_init_by_array (uint32_t init_key[], int key_length)
 initialize by an array with array-length init_key is the array for initializing keys key_length is its length slight change for C++, 2004/2/26 More...
 
uint32_t random_uint32 (void)
 generates a random number on [0,0xffffffff]-interval More...
 
static uint32_t random_uint32_range (uint32_t a, uint32_t b)
 generates a random number r with a <= r < b. More...
 

Function Documentation

◆ random_init()

void random_init ( uint32_t  s)
Warning
Currently, the random module uses a global state => multiple calls to random_init will reset the existing state of the PRNG.
Parameters
sseed for the PRNG

◆ random_init_by_array()

void random_init_by_array ( uint32_t  init_key[],
int  key_length 
)
Parameters
init_keyarray of keys (seeds) to initialize the PRNG
key_lengthnumber of lements in init_key

◆ random_uint32()

uint32_t random_uint32 ( void  )
Returns
a random number on [0,0xffffffff]-interval

◆ random_uint32_range()

static uint32_t random_uint32_range ( uint32_t  a,
uint32_t  b 
)
inlinestatic
Parameters
[in]aminimum for random number
[in]bupper bound for random number
Precondition
a < b
Returns
a random number on [a,b)-interval

Definition at line 80 of file random.h.