Project Alice
Loading...
Searching...
No Matches
r123::MicroURNG< CBRNG > Class Template Reference

#include <MicroURNG.hpp>

Public Types

typedef CBRNG cbrng_type
 
typedef cbrng_type::ctr_type ctr_type
 
typedef cbrng_type::key_type key_type
 
typedef cbrng_type::ukey_type ukey_type
 
typedef ctr_type::value_type result_type
 

Public Member Functions

 R123_STATIC_ASSERT (std::numeric_limits< result_type >::digits >=BITS, "The result_type must have at least 32 bits")
 
result_type operator() ()
 
 MicroURNG (cbrng_type _b, ctr_type _c0, ukey_type _uk)
 
 MicroURNG (ctr_type _c0, ukey_type _uk)
 
ctr_type const & counter () const
 
void reset (ctr_type _c0, ukey_type _uk)
 

Static Public Member Functions

static R123_CONSTEXPR result_type min R123_NO_MACRO_SUBST ()
 
static R123_CONSTEXPR result_type max R123_NO_MACRO_SUBST ()
 

Static Public Attributes

static int const BITS = 32
 
static const result_type _Min = 0
 
static const result_type _Max = ~((result_type)0)
 

Detailed Description

template<typename CBRNG>
class r123::MicroURNG< CBRNG >
Given a CBRNG whose ctr_type has an unsigned integral value_type,
MicroURNG<CBRNG>(c, k) is a type that satisfies the
requirements of a C++11 Uniform Random Number Generator.

The intended purpose is for a MicroURNG to be passed
as an argument to a C++11 Distribution, e.g.,
std::normal_distribution.  See examples/MicroURNG.cpp.

The MicroURNG functor has a period of "only"

     ctr_type.size()*2^32,

after which it will silently repeat.

The high 32 bits of the highest word in the counter c, passed to
the constructor must be zero.  MicroURNG uses these bits to
"count".

Older versions of the library permitted a second template
parameter by which the caller could control the number of
bits devoted to the URNG's internal counter.  This flexibility
has been disabled because URNGs created with different
numbers of counter bits could, conceivably "collide".
typedef ?someCBRNG? RNG;
RNG::ctr_type c = ...; // under application control
RNG::key_type k = ...; //
std::normal_distribution<float> nd;
MicroURNG<RNG> urng(c, k);
for(???){
...
nd(urng); // may be called several hundred times with BITS=10
...
}

Definition at line 79 of file MicroURNG.hpp.

Member Typedef Documentation

◆ cbrng_type

template<typename CBRNG >
typedef CBRNG r123::MicroURNG< CBRNG >::cbrng_type

Definition at line 86 of file MicroURNG.hpp.

◆ ctr_type

template<typename CBRNG >
typedef cbrng_type::ctr_type r123::MicroURNG< CBRNG >::ctr_type

Definition at line 88 of file MicroURNG.hpp.

◆ key_type

template<typename CBRNG >
typedef cbrng_type::key_type r123::MicroURNG< CBRNG >::key_type

Definition at line 89 of file MicroURNG.hpp.

◆ result_type

template<typename CBRNG >
typedef ctr_type::value_type r123::MicroURNG< CBRNG >::result_type

Definition at line 91 of file MicroURNG.hpp.

◆ ukey_type

template<typename CBRNG >
typedef cbrng_type::ukey_type r123::MicroURNG< CBRNG >::ukey_type

Definition at line 90 of file MicroURNG.hpp.

Constructor & Destructor Documentation

◆ MicroURNG() [1/2]

template<typename CBRNG >
r123::MicroURNG< CBRNG >::MicroURNG ( cbrng_type  _b,
ctr_type  _c0,
ukey_type  _uk 
)
inline

Definition at line 107 of file MicroURNG.hpp.

◆ MicroURNG() [2/2]

template<typename CBRNG >
r123::MicroURNG< CBRNG >::MicroURNG ( ctr_type  _c0,
ukey_type  _uk 
)
inline

Definition at line 110 of file MicroURNG.hpp.

Member Function Documentation

◆ counter()

template<typename CBRNG >
ctr_type const & r123::MicroURNG< CBRNG >::counter ( ) const
inline

Definition at line 126 of file MicroURNG.hpp.

◆ operator()()

template<typename CBRNG >
result_type r123::MicroURNG< CBRNG >::operator() ( )
inline

Definition at line 95 of file MicroURNG.hpp.

◆ R123_NO_MACRO_SUBST() [1/2]

template<typename CBRNG >
static R123_CONSTEXPR result_type min r123::MicroURNG< CBRNG >::R123_NO_MACRO_SUBST ( )
inlinestatic

Definition at line 119 of file MicroURNG.hpp.

◆ R123_NO_MACRO_SUBST() [2/2]

template<typename CBRNG >
static R123_CONSTEXPR result_type max r123::MicroURNG< CBRNG >::R123_NO_MACRO_SUBST ( )
inlinestatic

Definition at line 122 of file MicroURNG.hpp.

◆ R123_STATIC_ASSERT()

template<typename CBRNG >
r123::MicroURNG< CBRNG >::R123_STATIC_ASSERT ( std::numeric_limits< result_type >::digits >=  BITS,
"The result_type must have at least 32 bits"   
)

◆ reset()

template<typename CBRNG >
void r123::MicroURNG< CBRNG >::reset ( ctr_type  _c0,
ukey_type  _uk 
)
inline

Definition at line 129 of file MicroURNG.hpp.

Member Data Documentation

◆ _Max

template<typename CBRNG >
const result_type r123::MicroURNG< CBRNG >::_Max = ~((result_type)0)
static

Definition at line 117 of file MicroURNG.hpp.

◆ _Min

template<typename CBRNG >
const result_type r123::MicroURNG< CBRNG >::_Min = 0
static

Definition at line 116 of file MicroURNG.hpp.

◆ BITS

template<typename CBRNG >
int const r123::MicroURNG< CBRNG >::BITS = 32
static

Definition at line 87 of file MicroURNG.hpp.


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