Class rng (o2scl)

O2scl : Class List

template<class fp_t = double>
class 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() const

Get the seed.

inline fp_t random() const

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) const

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

mutable std::mt19937 def_engine

Random number engine.

Protected Attributes

mutable std::uniform_real_distribution<fp_t> dist

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

unsigned int seed

Seed for the random number generator.