Class rng (o2scl)

O2scl : Class List

template<class fp_t = double>
class o2scl::rng

Simple C++11 random number generator class.

Public Functions

inline rng()
inline void clock_seed()

Set the seed using time(0)

inline unsigned int get_seed()

Get the seed.

inline fp_t random()

Return a random number in \((0,1]\).

inline void set_seed(unsigned int s)

Set the seed.

inline unsigned long int random_int(unsigned long int max = 1)

Return random integer in \([0,\mathrm{max}-1]\).

inline rng &operator=(const rng &rg)

Copy constructor with equals operator.

inline rng(const rng &rg)

Copy constructor.

Public Members

std::mt19937 def_engine

Random number engine.

Protected Attributes

std::uniform_real_distribution<fp_t> dist

Distribution for \( [0,1) \).

unsigned int seed

Seed for the random number generator.