Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

random_lcg Class Reference

random_lcg Class Reference

A 32 bit random number generator. More...

#include <random.h>

Inherits etl::random.

Public Member Functions

 random_lcg ()
 Default constructor.
 random_lcg (uint32_t seed)
 Constructor with seed value.
void initialise (uint32_t seed)
 Initialises the sequence with a new seed value.
uint32_t operator() ()
 Get the next random_clcg number.
uint32_t range (uint32_t low, uint32_t high)
 Get the next random_clcg number in a specified inclusive range.

Detailed Description

A 32 bit random number generator.

Uses a linear congruential generator. https://cs.adelaide.edu.au/~paulc/teaching/montecarlo/node107.html

Definition at line 81 of file random.h.


Constructor & Destructor Documentation

random_lcg (  )

Default constructor.

Attempts to come up with a unique non-zero seed.

Definition at line 114 of file random.cpp.

random_lcg ( uint32_t  seed ) [explicit]

Constructor with seed value.

Parameters:
seedThe new seed value.

Definition at line 127 of file random.cpp.


Member Function Documentation

void initialise ( uint32_t  seed ) [virtual]

Initialises the sequence with a new seed value.

Parameters:
seedThe new seed value.

Implements random.

Definition at line 136 of file random.cpp.

uint32_t operator() (  ) [virtual]

Get the next random_clcg number.

Implements random.

Definition at line 145 of file random.cpp.

uint32_t range ( uint32_t  low,
uint32_t  high 
) [virtual]

Get the next random_clcg number in a specified inclusive range.

Implements random.

Definition at line 155 of file random.cpp.