ExRandom  3.0
exrandom::rand_digit< b > Class Template Reference

Machinery to convert a random generator into a random digit. More...

#include <exrandom/rand_digit.hpp>

Public Member Functions

 rand_digit ()
 
template<typename Generator >
uint_t operator() (Generator &g)
 
long long count () const
 

Static Public Member Functions

template<typename RealType >
static RealType invrealbase ()
 

Static Public Attributes

static const uint_t base
 
static const uint_t min_value
 
static const uint_t max_value
 
static const int bits
 
static const bool power_of_two
 

Detailed Description

template<uint_t b>
class exrandom::rand_digit< b >

Machinery to convert a random generator into a random digit.

Template Parameters
bthe base for the digits.

This produces random digits in the range [0,b). In addition it keeps count of how many digits are produced.

Examples
count_bits.cpp, discrete_count_bits.cpp, hist_data.cpp, sample_discrete_normal.cpp, sample_exponential.cpp, sample_normal.cpp, and sample_uniform.cpp.

Definition at line 34 of file rand_digit.hpp.

Constructor & Destructor Documentation

◆ rand_digit()

template<uint_t b>
exrandom::rand_digit< b >::rand_digit ( )
inline

The constructor (which initializes the count to 0).

Definition at line 59 of file rand_digit.hpp.

Member Function Documentation

◆ operator()()

template<uint_t b>
template<typename Generator >
uint_t exrandom::rand_digit< b >::operator() ( Generator &  g)
inline
Template Parameters
Generatorthe type of g.
Parameters
gthe random generator engine.
Returns
the random digit.

Definition at line 66 of file rand_digit.hpp.

◆ count()

template<uint_t b>
long long exrandom::rand_digit< b >::count ( ) const
inline
Returns
the count.

Definition at line 87 of file rand_digit.hpp.

◆ invrealbase()

template<uint_t b>
template<typename RealType >
static RealType exrandom::rand_digit< b >::invrealbase ( )
inlinestatic
Template Parameters
thefloating point type of the result.
Returns
1/base as a floating point number.

Definition at line 93 of file rand_digit.hpp.

Member Data Documentation

◆ base

template<uint_t b>
const uint_t exrandom::rand_digit< b >::base
static

The base for the digits (or 0 if the base is 232).

Definition at line 39 of file rand_digit.hpp.

◆ min_value

template<uint_t b>
const uint_t exrandom::rand_digit< b >::min_value
static

The minimum value produced by operator().

Definition at line 43 of file rand_digit.hpp.

◆ max_value

template<uint_t b>
const uint_t exrandom::rand_digit< b >::max_value
static

The maximum value produced by operator().

Definition at line 47 of file rand_digit.hpp.

◆ bits

template<uint_t b>
const int exrandom::rand_digit< b >::bits
static

The number of bits needed to represent a digit.

Definition at line 51 of file rand_digit.hpp.

◆ power_of_two

template<uint_t b>
const bool exrandom::rand_digit< b >::power_of_two
static

Is the base a power of two?

Definition at line 55 of file rand_digit.hpp.


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