Version: SMASH-3.1
smash::random::uniform_dist< T > Class Template Reference

#include <random.h>

template<typename T>
class smash::random::uniform_dist< T >

Provides uniform random numbers on a fixed interval.

objects of uniform_dist can be used to provide a large number of random numbers in the same interval. Example:

using namespace random;
double sum = 0.0;
auto uniform_0_to_3 = uniform_dist(0., 3.);
for (MANY_TIMES) {
sum += uniform_0_to_3();
}
uniform_dist(T min, T max)
Creates the object and fixes the interval.
Definition: random.h:57

The random number engine is completely hidden inside the object.

Definition at line 49 of file random.h.

Public Member Functions

 uniform_dist (T min, T max)
 Creates the object and fixes the interval. More...
 
operator() ()
 

Private Attributes

std::uniform_real_distribution< T > distribution
 The distribution object that is being used. More...
 

Constructor & Destructor Documentation

◆ uniform_dist()

template<typename T >
smash::random::uniform_dist< T >::uniform_dist ( min,
max 
)
inline

Creates the object and fixes the interval.

Parameters
minLower bound of interval.
maxUpper bound of interval.

Definition at line 57 of file random.h.

57 : distribution(min, max) {}
std::uniform_real_distribution< T > distribution
The distribution object that is being used.
Definition: random.h:63

Member Function Documentation

◆ operator()()

template<typename T >
T smash::random::uniform_dist< T >::operator() ( )
inline
Returns
A random number in the interval.

Definition at line 59 of file random.h.

59 { return distribution(engine); }
Engine engine
The engine that is used commonly by all distributions.
Definition: random.cc:18

Member Data Documentation

◆ distribution

template<typename T >
std::uniform_real_distribution<T> smash::random::uniform_dist< T >::distribution
private

The distribution object that is being used.

Definition at line 63 of file random.h.


The documentation for this class was generated from the following file: