USML
randgen Class Reference

Detailed Description

Singleton class for integrating the Boost Random Number Library with uBLAS vectors and matrices.

Implemented as a singleton to ensure that all random numbers are created from the same pseudo-random number generation pool. This is designed to prevent un-intentional correlation between random series in different parts of the application.

Because all of the methods are declared static, the developer never actually creates a class of this type.

Member Typedef Documentation

typedef boost::kreutzer1986 random_type

Defines the class for the basic random number generator.

This implementation combines a linear congruential generator with a shuffling algorithm.

Constructor & Destructor Documentation

randgen ( )
inlineprivate

Don't allow users to construct this class.

Member Function Documentation

static void fill ( vector< T > &  result,
Random &  rand 
)
inlinestaticprivate

Quickly fill a vector with random numbers.

Designed to handle both double and complex<double> vectors.

Parameters
resultVector of random numbers.
randRandom number generator.
static void fill ( matrix< T > &  result,
Random &  rand 
)
inlinestaticprivate

Quickly fill a matrix with random numbers.

Designed to handle both double and complex<double> matrices.

Parameters
resultMatrix of random numbers.
randRandom number generator.
static double gaussian ( )
inlinestatic

Generate a single random number from a Gaussian distribution.

Examples:
ublas/test/randgen_test.cc.
static vector<double> gaussian ( int  N)
inlinestatic

Generate a vector of random numbers from a Gaussian distribution.

Parameters
NLength of the output vector.
static matrix<double> gaussian ( int  N,
int  M 
)
inlinestatic

Generate a matrix of random numbers from a Gaussian distribution.

Parameters
NRows of the output matrix.
MColumns of the output matrix.
static vector< complex<double> > noise ( int  N)
inlinestatic

Generate a vector of complex random numbers from a Gaussian distribution.

Parameters
NLength of the output vector.
Examples:
ublas/test/randgen_test.cc.
static matrix< complex<double> > noise ( int  N,
int  M 
)
inlinestatic

Generate a matrix of complex random numbers from a Gaussian distribution.

Parameters
NRows of the output matrix.
MColumns of the output matrix.
static void seed ( random_type::result_type  value)
inlinestatic

Initialize the random number generator with a specific seed.

This allows the system to re-create random signals from run-to-run.

Parameters
valueNew seed for the random number generator.
Examples:
ublas/test/randgen_test.cc.
static double uniform ( )
inlinestatic

Generate a single random number from a Uniform distribution.

Examples:
ublas/test/randgen_test.cc.
static vector<double> uniform ( int  N)
inlinestatic

Generate a vector of random numbers from a Uniform distribution.

Parameters
NLength of the output vector.
static matrix<double> uniform ( int  N,
int  M 
)
inlinestatic

Generate a matrix of random numbers from a Uniform distribution.

Parameters
NRows of the output matrix.
MColumns of the output matrix.

Member Data Documentation

boost::normal_distribution< double > gaussian_dist
staticprivate

variate_generator<> requires reference to abstract distribution.

boost::variate_generator< randgen::random_type, boost::normal_distribution< double > > gaussian_gen
staticprivate

Gaussian random number generator with sigma = 1.

Gaussian ransom number generator with sigma = 1.

randgen::random_type master_gen
staticprivate

Master generator that underlies all distributions.

Seeded with the current system time at initialization.

boost::uniform_01< randgen::random_type, double > uniform_gen
staticprivate

Uniform random number generator for the range [0,1).