strumpack::random Namespace Reference

Classes

class  RandomGenerator
 Class for a random number generator. More...
 
class  RandomGeneratorBase
 class to wrap the C++11 random number generator/distribution More...
 

Enumerations

enum class  RandomEngine { LINEAR , MERSENNE }
 Random number engine. More...
 
enum class  RandomDistribution { NORMAL , UNIFORM }
 

Functions

std::string get_name (RandomEngine e)
 
std::string get_name (RandomDistribution d)
 
template<typename real_t >
std::unique_ptr< RandomGeneratorBase< real_t > > make_random_generator (std::size_t seed, RandomEngine e, RandomDistribution d)
 
template<typename real_t >
std::unique_ptr< RandomGeneratorBase< real_t > > make_random_generator (RandomEngine e, RandomDistribution d)
 
template<typename real_t >
std::unique_ptr< RandomGeneratorBase< real_t > > make_default_random_generator (std::size_t seed=0)
 

Detailed Description

Namespace containing simple wrappers around the C++11 random number generators and distributions.

Enumeration Type Documentation

◆ RandomDistribution

The random number distribution.

Enumerator
NORMAL 

Normal(0,1) distributed numbers, takes roughly 23 flops per random number.

UNIFORM 

Uniform [0,1] distributed numbers takes about 7 flops per random number.

◆ RandomEngine

Random number engine.

Enumerator
LINEAR 

The C++11 std::minstd_rand random number generator.

MERSENNE 

The C++11 std::mt19937 random number generator.

Function Documentation

◆ get_name() [1/2]

std::string strumpack::random::get_name ( RandomDistribution  d)
inline

Return a short string (name) for the random number distribution.

Parameters
drandom distribution
Returns
name of the random distribution

◆ get_name() [2/2]

std::string strumpack::random::get_name ( RandomEngine  e)
inline

Return a short string (name) for the random engine.

Parameters
erandom engine
Returns
name of the random engine

◆ make_default_random_generator()

template<typename real_t >
std::unique_ptr< RandomGeneratorBase< real_t > > strumpack::random::make_default_random_generator ( std::size_t  seed = 0)

Factory method to construct a RandomGeneratorBase with the default engine and distribution.

Template Parameters
real_tfloat or double
Parameters
seedseed for the gererator

◆ make_random_generator() [1/2]

template<typename real_t >
std::unique_ptr< RandomGeneratorBase< real_t > > strumpack::random::make_random_generator ( RandomEngine  e,
RandomDistribution  d 
)

Factory method to construct a RandomGeneratorBase with a specified random engine and random distribution, using seed 0.

Template Parameters
real_tfloat or double
Parameters
seedseed for the gererator
erandom engine
drandom distribution

◆ make_random_generator() [2/2]

template<typename real_t >
std::unique_ptr< RandomGeneratorBase< real_t > > strumpack::random::make_random_generator ( std::size_t  seed,
RandomEngine  e,
RandomDistribution  d 
)

Factory method to construct a RandomGeneratorBase with a specified random engine and random distribution, with seed s.

Template Parameters
real_tfloat or double
Parameters
seedseed for the gererator
erandom engine
drandom distribution