STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
independent_bits_engine< _Engine, _Wx, _UIntType > Class Template Reference

Public Types

typedef independent_bits_engine< _Engine, _Wx, _UIntType > _Myt
 
typedef _Engine base_type
 
typedef _UIntType result_type
 
typedef _Engine::result_type _Eres
 

Public Member Functions

 independent_bits_engine ()
 
 independent_bits_engine (const independent_bits_engine &_Right)
 
 independent_bits_engine (independent_bits_engine &_Right)
 
 independent_bits_engine (const _Engine &_Ex)
 
 independent_bits_engine (_Engine &_Ex)
 
 independent_bits_engine (_Engine &&_Ex)
 
 independent_bits_engine (result_type _X0)
 
template<class _Seed_seq , class = typename enable_if< !is_convertible<_Seed_seq, result_type>::value, void>::type>
 independent_bits_engine (_Seed_seq &_Seq)
 
void seed ()
 
void seed (result_type _X0)
 
template<class _Seed_seq >
enable_if< !is_convertible< _Seed_seq, result_type >::value, void >::type seed (_Seed_seq &_Seq)
 
const _Engine & base () const _NOEXCEPT
 
result_type operator() ()
 
void discard (unsigned long long _Nskip)
 
template<class _Elem , class _Traits >
basic_istream< _Elem, _Traits > & _Read (basic_istream< _Elem, _Traits > &_Istr)
 
template<class _Elem , class _Traits >
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr) const
 

Static Public Member Functions

static result_type() min ()
 
static result_type() max ()
 

Private Member Functions

void _Init ()
 

Private Attributes

_Engine _Eng
 
size_t _N0
 
size_t _Nx
 
size_t _W0
 
_Eres _Y0
 
_Eres _Y1
 

Member Typedef Documentation

template<class _Engine, size_t _Wx, class _UIntType>
typedef _Engine::result_type independent_bits_engine< _Engine, _Wx, _UIntType >::_Eres
template<class _Engine, size_t _Wx, class _UIntType>
typedef independent_bits_engine<_Engine, _Wx, _UIntType> independent_bits_engine< _Engine, _Wx, _UIntType >::_Myt
template<class _Engine, size_t _Wx, class _UIntType>
typedef _Engine independent_bits_engine< _Engine, _Wx, _UIntType >::base_type
template<class _Engine, size_t _Wx, class _UIntType>
typedef _UIntType independent_bits_engine< _Engine, _Wx, _UIntType >::result_type

Constructor & Destructor Documentation

template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( )
inline
1924  { // construct
1925  _Init();
1926  }
void _Init()
Definition: random:2061
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( const independent_bits_engine< _Engine, _Wx, _UIntType > &  _Right)
inline
1929  { // construct by copying
1930  *this = _Right;
1931  }
const _Ty & _Right
Definition: algorithm:4087
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( independent_bits_engine< _Engine, _Wx, _UIntType > &  _Right)
inline
1934  { // construct by copying
1935  *this = _Right;
1936  }
const _Ty & _Right
Definition: algorithm:4087
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( const _Engine &  _Ex)
inlineexplicit
1939  : _Eng(_Ex)
1940  { // construct with engine initializer _Ex
1941  _Init();
1942  }
_Engine _Eng
Definition: random:2089
void _Init()
Definition: random:2061
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Engine &  _Ex)
inlineexplicit
1945  : _Eng((const _Engine&)_Ex)
1946  { // construct with engine initializer _Ex
1947  _Init();
1948  }
_Engine _Eng
Definition: random:2089
void _Init()
Definition: random:2061
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Engine &&  _Ex)
inlineexplicit
1951  : _Eng(_STD forward<_Engine>(_Ex))
1952  { // construct with engine initializer _Ex
1953  _Init();
1954  }
_Engine _Eng
Definition: random:2089
void _Init()
Definition: random:2061
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( result_type  _X0)
inlineexplicit
1957  : _Eng(_X0)
1958  { // construct from specified seed value
1959  _Init();
1960  }
_Engine _Eng
Definition: random:2089
void _Init()
Definition: random:2061
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Seed_seq , class = typename enable_if< !is_convertible<_Seed_seq, result_type>::value, void>::type>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Seed_seq &  _Seq)
inlineexplicit
1967  : _Eng(_Seq)
1968  { // construct from seed sequence
1969  _Init();
1970  }
_Engine _Eng
Definition: random:2089
void _Init()
Definition: random:2061

Member Function Documentation

template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::_Init ( )
inlineprivate
2062  { // compute values for operator()
2063  size_t _Mx = 0;
2064  _Eres _Rx = (_Eng.max)() - (_Eng.min)() + 1;
2065 
2066  _Eres _Tmp = _Rx;
2067  if (_Tmp == 0)
2068  { // all bits used, make _Rx finite
2069  _Mx = 1;
2070  --_Tmp;
2071  }
2072  for (; 1 < _Tmp; _Tmp >>= 1)
2073  ++_Mx; // compute _Mx = floor(log2(_Rx))
2074 
2075  for (size_t _Nfix = 0; ; ++_Nfix)
2076  { // compute consistent set of parameters
2077  _Nx = (_Wx + _Mx - 1) / _Mx + _Nfix; // trial _Nx
2078  _W0 = _Wx / _Nx;
2079  _N0 = _Nx - _Wx % _Nx;
2080  _Y0 = (_Rx >> _W0) << _W0;
2081  _Y1 = (((_Rx >> _W0) >> 1) << _W0) << 1;
2082  if (_Nfix == 1 || _Rx - _Y0 <= _Y0 / _Nx)
2083  break; // also works if _Rx == 0 (_Mx == all bits)
2084  }
2085  --_Y0;
2086  --_Y1;
2087  }
_Engine::result_type _Eres
Definition: random:1921
_Eres _Y1
Definition: random:2094
_Engine _Eng
Definition: random:2089
size_t _Nx
Definition: random:2091
_Eres _Y0
Definition: random:2093
size_t _W0
Definition: random:2092
size_t _N0
Definition: random:2090
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& independent_bits_engine< _Engine, _Wx, _UIntType >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
2048  { // read state from _Istr
2049  return (_Istr >> _Eng);
2050  }
_Engine _Eng
Definition: random:2089
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& independent_bits_engine< _Engine, _Wx, _UIntType >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
2056  { // write state to _Ostr
2057  return (_Ostr << _Eng);
2058  }
_Engine _Eng
Definition: random:2089
template<class _Engine, size_t _Wx, class _UIntType>
const _Engine& independent_bits_engine< _Engine, _Wx, _UIntType >::base ( ) const
inline
1992  { // return const reference to engine
1993  return (_Eng);
1994  }
_Engine _Eng
Definition: random:2089
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::discard ( unsigned long long  _Nskip)
inline
2039  { // discard _Nskip elements
2040  for (; 0 < _Nskip; --_Nskip)
2041  (*this)();
2042  }
template<class _Engine, size_t _Wx, class _UIntType>
static result_type() independent_bits_engine< _Engine, _Wx, _UIntType >::max ( )
inlinestatic
2002  { // return maximum possible generated value
2003  return ((((result_type)1 << (_Wx - 1)) << 1) - 1);
2004  }
_UIntType result_type
Definition: random:1920
template<class _Engine, size_t _Wx, class _UIntType>
static result_type() independent_bits_engine< _Engine, _Wx, _UIntType >::min ( )
inlinestatic
1997  { // return minimum possible generated value
1998  return (0);
1999  }
template<class _Engine, size_t _Wx, class _UIntType>
result_type independent_bits_engine< _Engine, _Wx, _UIntType >::operator() ( )
inline
2007  { // return next value
2008  size_t _Idx = 0;
2009  result_type _Res = 0;
2010  result_type _Mask = (((result_type)1 << (_W0 - 1)) << 1) - 1;
2011  _Eres _Val;
2012 
2013  for (; _Idx < _N0; ++_Idx)
2014  { // pack _W0-bit values
2015  for (; ; )
2016  { // get a small enough value
2017  _Val = _Eng() - (_Eng.min)();
2018  if (_Val <= _Y0)
2019  break;
2020  }
2021  _Res = _Res << _W0 | _Val & _Mask;
2022  }
2023 
2024  _Mask = _Mask << 1 | 1;
2025  for (; _Idx < _Nx; ++_Idx)
2026  { // pack _W0+1-bit values
2027  for (; ; )
2028  { // get a small enough value
2029  _Val = _Eng() - (_Eng.min)();
2030  if (_Val <= _Y1)
2031  break;
2032  }
2033  _Res = (_Res << (_W0 + 1)) | _Val & _Mask;
2034  }
2035  return (_Res);
2036  }
_Engine::result_type _Eres
Definition: random:1921
_Eres _Y1
Definition: random:2094
_Engine _Eng
Definition: random:2089
_UIntType result_type
Definition: random:1920
size_t _Nx
Definition: random:2091
_Eres _Y0
Definition: random:2093
size_t _W0
Definition: random:2092
_CRT_MANAGED_FP_DEPRECATE _In_ unsigned int _Mask
Definition: float.h:120
_FwdIt const _Ty _Val
Definition: algorithm:1938
size_t _N0
Definition: random:2090
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( )
inline
1973  { // seed engine from default value
1974  _Eng.seed();
1975  }
_Engine _Eng
Definition: random:2089
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( result_type  _X0)
inline
1978  { // seed engine from specified value
1979  _Eng.seed(_X0);
1980  }
_Engine _Eng
Definition: random:2089
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Seed_seq >
enable_if< !is_convertible<_Seed_seq, result_type>::value, void>::type independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( _Seed_seq &  _Seq)
inline
1987  { // seed engine from seed sequence
1988  _Eng.seed(_Seq);
1989  }
_Engine _Eng
Definition: random:2089

Member Data Documentation

template<class _Engine, size_t _Wx, class _UIntType>
_Engine independent_bits_engine< _Engine, _Wx, _UIntType >::_Eng
private
template<class _Engine, size_t _Wx, class _UIntType>
size_t independent_bits_engine< _Engine, _Wx, _UIntType >::_N0
private
template<class _Engine, size_t _Wx, class _UIntType>
size_t independent_bits_engine< _Engine, _Wx, _UIntType >::_Nx
private
template<class _Engine, size_t _Wx, class _UIntType>
size_t independent_bits_engine< _Engine, _Wx, _UIntType >::_W0
private
template<class _Engine, size_t _Wx, class _UIntType>
_Eres independent_bits_engine< _Engine, _Wx, _UIntType >::_Y0
private
template<class _Engine, size_t _Wx, class _UIntType>
_Eres independent_bits_engine< _Engine, _Wx, _UIntType >::_Y1
private

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