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

 _RNG_REQUIRE_UINTTYPE (independent_bits_engine, _UIntType)
 
 independent_bits_engine ()
 
 independent_bits_engine (const _Engine &_Ex)
 
 independent_bits_engine (_Engine &&_Ex)
 
 independent_bits_engine (result_type _X0)
 
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt, _Engine>::type>
 independent_bits_engine (_Seed_seq &_Seq)
 
void seed ()
 
void seed (result_type _X0)
 
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt>::type>
void 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 constexpr result_type() min ()
 
static constexpr 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
1847  { // construct
1848  _Init();
1849  }
void _Init()
Definition: random:1964
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( const _Engine &  _Ex)
inlineexplicit
1852  : _Eng(_Ex)
1853  { // construct with engine initializer _Ex
1854  _Init();
1855  }
_Engine _Eng
Definition: random:1992
void _Init()
Definition: random:1964
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Engine &&  _Ex)
inlineexplicit
1858  : _Eng(_STD forward<_Engine>(_Ex))
1859  { // construct with engine initializer _Ex
1860  _Init();
1861  }
_Engine _Eng
Definition: random:1992
void _Init()
Definition: random:1964
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( result_type  _X0)
inlineexplicit
1864  : _Eng(static_cast<_Eres>(_X0))
1865  { // construct from specified seed value
1866  _Init();
1867  }
_Engine _Eng
Definition: random:1992
void _Init()
Definition: random:1964
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt, _Engine>::type>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Seed_seq &  _Seq)
inlineexplicit
1872  : _Eng(_Seq)
1873  { // construct from seed sequence
1874  _Init();
1875  }
_Engine _Eng
Definition: random:1992
void _Init()
Definition: random:1964

Member Function Documentation

template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::_Init ( )
inlineprivate
1965  { // compute values for operator()
1966  size_t _Mx = 0;
1967  _Eres _Rx = (_Engine::max)() - (_Engine::min)() + 1;
1968 
1969  _Eres _Tmp = _Rx;
1970  if (_Tmp == 0)
1971  { // all bits used, make _Rx finite
1972  _Mx = 1;
1973  --_Tmp;
1974  }
1975  for (; 1 < _Tmp; _Tmp >>= 1)
1976  ++_Mx; // compute _Mx = floor(log2(_Rx))
1977 
1978  for (size_t _Nfix = 0; ; ++_Nfix)
1979  { // compute consistent set of parameters
1980  _Nx = (_Wx + _Mx - 1) / _Mx + _Nfix; // trial _Nx
1981  _W0 = _Wx / _Nx;
1982  _N0 = _Nx - _Wx % _Nx;
1983  _Y0 = (_Rx >> _W0) << _W0;
1984  _Y1 = (((_Rx >> _W0) >> 1) << _W0) << 1;
1985  if (_Nfix == 1 || _Rx - _Y0 <= _Y0 / _Nx)
1986  break; // also works if _Rx == 0 (_Mx == all bits)
1987  }
1988  --_Y0;
1989  --_Y1;
1990  }
#define min(a, b)
Definition: minmax.h:18
_Engine::result_type _Eres
Definition: random:1844
_Eres _Y1
Definition: random:1997
#define max(a,b)
Definition: minmax.h:14
size_t _Nx
Definition: random:1994
_Eres _Y0
Definition: random:1996
size_t _W0
Definition: random:1995
size_t _N0
Definition: random:1993
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
1951  { // read state from _Istr
1952  return (_Istr >> _Eng);
1953  }
_Engine _Eng
Definition: random:1992
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::_RNG_REQUIRE_UINTTYPE ( independent_bits_engine< _Engine, _Wx, _UIntType >  ,
_UIntType   
)
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
1959  { // write state to _Ostr
1960  return (_Ostr << _Eng);
1961  }
_Engine _Eng
Definition: random:1992
template<class _Engine, size_t _Wx, class _UIntType>
const _Engine& independent_bits_engine< _Engine, _Wx, _UIntType >::base ( ) const
inline
1895  { // return const reference to engine
1896  return (_Eng);
1897  }
_Engine _Eng
Definition: random:1992
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::discard ( unsigned long long  _Nskip)
inline
1942  { // discard _Nskip elements
1943  for (; 0 < _Nskip; --_Nskip)
1944  (*this)();
1945  }
template<class _Engine, size_t _Wx, class _UIntType>
static constexpr result_type() independent_bits_engine< _Engine, _Wx, _UIntType >::max ( )
inlinestatic
1905  { // return maximum possible generated value
1906  return ((((result_type)1 << (_Wx - 1)) << 1) - 1);
1907  }
_UIntType result_type
Definition: random:1843
template<class _Engine, size_t _Wx, class _UIntType>
static constexpr result_type() independent_bits_engine< _Engine, _Wx, _UIntType >::min ( )
inlinestatic
1900  { // return minimum possible generated value
1901  return (0);
1902  }
template<class _Engine, size_t _Wx, class _UIntType>
result_type independent_bits_engine< _Engine, _Wx, _UIntType >::operator() ( )
inline
1910  { // return next value
1911  size_t _Idx = 0;
1912  result_type _Res = 0;
1913  result_type _Mask = (((result_type)1 << (_W0 - 1)) << 1) - 1;
1914  _Eres _Val;
1915 
1916  for (; _Idx < _N0; ++_Idx)
1917  { // pack _W0-bit values
1918  for (; ; )
1919  { // get a small enough value
1920  _Val = _Eng() - (_Engine::min)();
1921  if (_Val <= _Y0)
1922  break;
1923  }
1924  _Res = _Res << _W0 | static_cast<result_type>(_Val) & _Mask;
1925  }
1926 
1927  _Mask = _Mask << 1 | 1;
1928  for (; _Idx < _Nx; ++_Idx)
1929  { // pack _W0+1-bit values
1930  for (; ; )
1931  { // get a small enough value
1932  _Val = _Eng() - (_Engine::min)();
1933  if (_Val <= _Y1)
1934  break;
1935  }
1936  _Res = (_Res << (_W0 + 1)) | static_cast<result_type>(_Val) & _Mask;
1937  }
1938  return (_Res);
1939  }
#define min(a, b)
Definition: minmax.h:18
_Engine::result_type _Eres
Definition: random:1844
_Eres _Y1
Definition: random:1997
_Engine _Eng
Definition: random:1992
_UIntType result_type
Definition: random:1843
size_t _Nx
Definition: random:1994
_Eres _Y0
Definition: random:1996
size_t _W0
Definition: random:1995
_CRT_MANAGED_FP_DEPRECATE _In_ unsigned int _Mask
Definition: float.h:235
_FwdIt const _Ty _Val
Definition: algorithm:1938
size_t _N0
Definition: random:1993
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( )
inline
1878  { // seed engine from default value
1879  _Eng.seed();
1880  }
_Engine _Eng
Definition: random:1992
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( result_type  _X0)
inline
1883  { // seed engine from specified value
1884  _Eng.seed(static_cast<_Eres>(_X0));
1885  }
_Engine _Eng
Definition: random:1992
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt>::type>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( _Seed_seq &  _Seq)
inline
1890  { // seed engine from seed sequence
1891  _Eng.seed(_Seq);
1892  }
_Engine _Eng
Definition: random:1992

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: