Public Types | Public Member Functions | Static Public Attributes

r123::MicroURNG< CBRNG, _BITS > Class Template Reference

#include <Random123/MicroURNG.hpp>

List of all members.

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

result_type operator() ()
 MicroURNG (cbrng_type _b, ctr_type _c0, ukey_type _uk)
 MicroURNG (ctr_type _c0, ukey_type _uk)
result_type min () const
result_type max () const
const ctr_typecounter () const
void reset (ctr_type _c0, ukey_type _uk)

Static Public Attributes

static const unsigned BITS = _BITS

Detailed Description

template<typename CBRNG, unsigned int _BITS>
class r123::MicroURNG< CBRNG, _BITS >

Given a CBRNG whose ctr_type has an unsigned integral value_type, MicroURNG<CBRNG, BITS>(c, k) is a type that satisfies the requirements of a C++0x Uniform Random Number Generator.

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

The MicroURNG functor may only be called a limited number of times. After

ctr_type.size()*2^BITS,

calls, it throws a runtime_error.

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

Notice that you can carve out as many BITS as you like from the counter space, and are then free to call the MicroURNG until the bits run out. If you want a few dozen normally distributed randoms for each of your state/timestep/seed tuples, then give MicroURNG a few extra bits to work with and you're good to go:

       typedef ?someCBRNG? RNG;
       RNG::ctr_type c = ...; // under application control
       RNG::key_type k = ...; // 
       std::normal_distribution<float> nd;
       MicroURNG<RNG, 10> urng(c, k);
       for(???){
         ...
         nd(urng);  // may be called several hundred times with BITS=10
         ...
       }

Member Typedef Documentation

template<typename CBRNG , unsigned int _BITS>
typedef CBRNG r123::MicroURNG< CBRNG, _BITS >::cbrng_type
template<typename CBRNG , unsigned int _BITS>
typedef cbrng_type::ctr_type r123::MicroURNG< CBRNG, _BITS >::ctr_type
template<typename CBRNG , unsigned int _BITS>
typedef cbrng_type::key_type r123::MicroURNG< CBRNG, _BITS >::key_type
template<typename CBRNG , unsigned int _BITS>
typedef ctr_type::value_type r123::MicroURNG< CBRNG, _BITS >::result_type
template<typename CBRNG , unsigned int _BITS>
typedef cbrng_type::ukey_type r123::MicroURNG< CBRNG, _BITS >::ukey_type

Constructor & Destructor Documentation

template<typename CBRNG , unsigned int _BITS>
r123::MicroURNG< CBRNG, _BITS >::MicroURNG ( cbrng_type  _b,
ctr_type  _c0,
ukey_type  _uk 
) [inline]
template<typename CBRNG , unsigned int _BITS>
r123::MicroURNG< CBRNG, _BITS >::MicroURNG ( ctr_type  _c0,
ukey_type  _uk 
) [inline]

Member Function Documentation

template<typename CBRNG , unsigned int _BITS>
const ctr_type& r123::MicroURNG< CBRNG, _BITS >::counter (  )  const [inline]
template<typename CBRNG , unsigned int _BITS>
result_type r123::MicroURNG< CBRNG, _BITS >::max (  )  const [inline]
template<typename CBRNG , unsigned int _BITS>
result_type r123::MicroURNG< CBRNG, _BITS >::min (  )  const [inline]
template<typename CBRNG , unsigned int _BITS>
result_type r123::MicroURNG< CBRNG, _BITS >::operator() (  )  [inline]
template<typename CBRNG , unsigned int _BITS>
void r123::MicroURNG< CBRNG, _BITS >::reset ( ctr_type  _c0,
ukey_type  _uk 
) [inline]

Member Data Documentation

template<typename CBRNG , unsigned int _BITS>
const unsigned r123::MicroURNG< CBRNG, _BITS >::BITS = _BITS [static]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines