rcolyer.net
RC Lib  Version 202403231100
Public Member Functions | Static Public Attributes | List of all members
RC::RND Class Reference

A Mersenne Twister random number generator class with integer, array, or time-based seeding. More...

#include <RND.h>

Inheritance diagram for RC::RND:
RC::BaseRND

Public Member Functions

void Seed (u32 seed)
 Reseed the random number generator with the value seed.
 
void Seed (const Data1D< u32 > &init_key)
 Reseed the generator with up to the first 624 values of init_key.
 
 RND (u32 seed)
 Construct the generator with the initial seed given.
 
 RND (const Data1D< u32 > &init_key)
 Construct the generator with the initial seed being the first 624 values of init_key.
 
 RND ()
 Default constructor, which seeds using the system time and 64 bits of environmental entropy.
 
void Seed_urandom ()
 Seed the genederator by reading 624 u32's from /dev/urandom.
 
virtual u32 Get_u32 ()
 Provides random u32 values.
 
- Public Member Functions inherited from RC::BaseRND
 BaseRND ()
 Default constructor.
 
u32 operator() ()
 Equivalent to Get_u32().
 
i32 Get_i32 ()
 Provides random i32 values.
 
u64 Get_u64 ()
 Provides random u64 values.
 
i64 Get_i64 ()
 Provides random i64 values.
 
f32 Get_f32 ()
 Provides a random f32 in the range [0,1).
 
f64 Get_f64 ()
 Provides a random f64 in the range [0,1).
 
u8 Get_u8 ()
 Provides random u8 values.
 
i8 Get_i8 ()
 Provides random i8 values.
 
char Get_char ()
 Provides random char values.
 
u16 Get_u16 ()
 Provides random u16 values.
 
i16 Get_i16 ()
 Provides random i16 values.
 
void Get (u8 &x)
 Overloaded function to extract type u8 from this class. More...
 
void Get (i8 &x)
 Overloaded function to extract type i8 from this class. More...
 
void Get (char &x)
 Overloaded function to extract type char from this class. More...
 
void Get (u16 &x)
 Overloaded function to extract type u16 from this class. More...
 
void Get (i16 &x)
 Overloaded function to extract type i16 from this class. More...
 
void Get (u32 &x)
 Overloaded function to extract type u32 from this class. More...
 
void Get (i32 &x)
 Overloaded function to extract type i32 from this class. More...
 
void Get (u64 &x)
 Overloaded function to extract type u64 from this class. More...
 
void Get (i64 &x)
 Overloaded function to extract type i64 from this class. More...
 
void Get (f32 &x)
 Overloaded function to extract type f32 from this class. More...
 
void Get (f64 &x)
 Overloaded function to extract type f64 from this class. More...
 
bool GetProb (f64 probability)
 Returns true with probability, which should be in the range [0,1]. More...
 
bool GetProb (f32 probability)
 Returns true with probability, which should be in the range [0,1]. More...
 
u64 GetRange (u64 range)
 Returns [0,range) More...
 
i64 GetRange (i64 range)
 Like GetRange() but for i64.
 
u32 GetRange (u32 range)
 Like GetRange() but for i32. More...
 
i32 GetRange (i32 range)
 Like GetRange() but for i32.
 
template<class T >
GetRange (T low, T high)
 Provides a random integer value in the range [low,high].
 
f64 GetFRange (f64 low, f64 high)
 Provides a random float in the range [low,high).
 
template<class T >
void Fill (Data1D< T > &data)
 For any supported data type, fills the Data1D with random values.
 
template<class T >
GetFrom (Data1D< T > &data)
 Returns a random element from the Data1D.
 

Static Public Attributes

static const u32 CONST_SEED =5489
 The reference implementation's recommended seed.
 

Additional Inherited Members

- Public Types inherited from RC::BaseRND
typedef u32 result_type
 For UniformRandomNumberGenerator compliance.
 
- Static Public Member Functions inherited from RC::BaseRND
constexpr static u32 min ()
 Returns 0 for UniformRandomNumberGenerator compliance.
 
constexpr static u32 max ()
 Returns u32 max for UniformRandomNumberGenerator compliance.
 
static u64 GetEntropy ()
 Provides 64 bits of environmental entropy. More...
 

Detailed Description

A Mersenne Twister random number generator class with integer, array, or time-based seeding.

The output of this class is compliant with the mt19937ar reference implementation by Nishimura & Matsumoto.


The documentation for this class was generated from the following file:
email address
— (c) 2015