Public Member Functions | Static Private Member Functions | List of all members
ecl::RandomNumberGenerator< T > Class Template Reference

A random number generator. More...

#include <random_number_generator.hpp>

Public Member Functions

gaussian (const T &std, const T &mu=0)
 
 RandomNumberGenerator ()
 
 RandomNumberGenerator (const unsigned int randSeed)
 
uniform ()
 
uniform (const T &range)
 

Static Private Member Functions

static void seed ()
 Seed the system random number generator. More...
 

Detailed Description

template<typename T>
class ecl::RandomNumberGenerator< T >

A random number generator.

Definition at line 47 of file random_number_generator.hpp.

Constructor & Destructor Documentation

◆ RandomNumberGenerator() [1/2]

template<typename T >
ecl::RandomNumberGenerator< T >::RandomNumberGenerator ( const unsigned int  randSeed)
inline

Definition at line 58 of file random_number_generator.hpp.

◆ RandomNumberGenerator() [2/2]

template<typename T >
ecl::RandomNumberGenerator< T >::RandomNumberGenerator ( )
inline

Definition at line 63 of file random_number_generator.hpp.

Member Function Documentation

◆ gaussian()

template<typename T >
T ecl::RandomNumberGenerator< T >::gaussian ( const T &  std,
const T &  mu = 0 
)
inline

Definition at line 78 of file random_number_generator.hpp.

◆ seed()

template<typename T >
static void ecl::RandomNumberGenerator< T >::seed ( )
inlinestaticprivate

Seed the system random number generator.

Here we create a seed by hashing from three independent sources. This is a more robust way to get a reliable seed that allows you to get the typically para-optimal traits

1) fine grained (e.g. you want to call srand two times in a very short interval) 2) low chance of collisions over a long period

It also avoids having to use esoteric linux functions lick clock_gettime that aren't available on all platforms.

References:

-h ttp://stackoverflow.com/questions/322938/recommended-way-to-initialize-srand

Definition at line 125 of file random_number_generator.hpp.

◆ uniform() [1/2]

template<typename T >
T ecl::RandomNumberGenerator< T >::uniform ( )
inline

Definition at line 73 of file random_number_generator.hpp.

◆ uniform() [2/2]

template<typename T >
T ecl::RandomNumberGenerator< T >::uniform ( const T &  range)
inline

Definition at line 68 of file random_number_generator.hpp.


The documentation for this class was generated from the following file:


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:19