STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
linear_congruential< _Uint, _Ax, _Cx, _Mx > Class Template Reference
Inheritance diagram for linear_congruential< _Uint, _Ax, _Cx, _Mx >:
linear_congruential_engine< _Uint, _Ax, _Cx, _Mx >

Public Types

typedef linear_congruential< _Uint, _Ax, _Cx, _Mx > _Myt
 
typedef _Uint result_type
 

Public Member Functions

 linear_congruential (_Uint _X0=default_seed)
 
template<class _Gen , class = typename _Enable_if_seed_seq<_Gen, _Myt>::type>
 linear_congruential (_Gen &_Gx)
 
void seed (_Uint _X0=default_seed)
 
template<class _Gen >
void seed (_Gen &_Gx, bool=false)
 
_Uint() min () const
 
_Uint() max () const
 
_Uint operator() ()
 
void discard (unsigned long long _Nskip)
 
bool _Equals (const _Myt &_Right) const
 
template<class _Elem , class _Traits >
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr) const
 

Static Public Attributes

static constexpr _Uint multiplier = _Ax
 
static constexpr _Uint increment = _Cx
 
static constexpr _Uint modulus = _Mx
 
static constexpr _Uint default_seed = 1U
 

Protected Member Functions

template<class _Gen >
void _Seed (_Gen &_Gx, true_type)
 
template<class _Gen >
void _Seed (_Gen &_Gx, false_type)
 
void _Reset (_Uint _X0)
 

Protected Attributes

_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
 

Member Typedef Documentation

template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
typedef linear_congruential<_Uint, _Ax, _Cx, _Mx> linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Myt
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
typedef _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::result_type

Constructor & Destructor Documentation

template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
linear_congruential< _Uint, _Ax, _Cx, _Mx >::linear_congruential ( _Uint  _X0 = default_seed)
inlineexplicit
478  { // construct from initial value
479  seed(_X0);
480  }
void seed(_Uint _X0=default_seed)
Definition: random:489
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen , class = typename _Enable_if_seed_seq<_Gen, _Myt>::type>
linear_congruential< _Uint, _Ax, _Cx, _Mx >::linear_congruential ( _Gen &  _Gx)
inline
485  { // construct from generator
486  seed(_Gx);
487  }
void seed(_Uint _X0=default_seed)
Definition: random:489

Member Function Documentation

template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
bool linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Equals ( const _Myt _Right) const
inline
522  { // return true if *this will generate same sequence as _Right
523  return (_Imp._Prev == _Right._Imp._Prev);
524  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:557
constexpr const _Ty &() _Right
Definition: algorithm:3591
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Reset ( _Uint  _X0)
inlineprotected
550  { // reset sequence
551  _Imp._Prev = _Mx != 0 ? _X0 % _Mx : _X0;
552  if (_Imp._Prev == 0 && _Cx == 0)
553  _Imp._Prev = 1;
554  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:557
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen >
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Seed ( _Gen &  _Gx,
true_type   
)
inlineprotected
537  { // reset sequence from numeric value
538  _Reset((_Uint)_Gx);
539  }
void _Reset(_Uint _X0)
Definition: random:549
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen >
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Seed ( _Gen &  _Gx,
false_type   
)
inlineprotected
543  { // reset sequence from generator
544  _Reset(_Gx());
545  }
void _Reset(_Uint _X0)
Definition: random:549
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
530  { // write state to _Ostr
531  return (_Ostr << _Imp._Prev);
532  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:557
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::discard ( unsigned long long  _Nskip)
inline
516  { // discard _Nskip elements
517  for (; 0 < _Nskip; --_Nskip)
518  (*this)();
519  }
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint() linear_congruential< _Uint, _Ax, _Cx, _Mx >::max ( ) const
inline
506  { // return maximum possible generated value
507  return (_Mx != 0 ? _Mx - 1 : (numeric_limits<_Uint>::max)());
508  }
Definition: limits:101
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint() linear_congruential< _Uint, _Ax, _Cx, _Mx >::min ( ) const
inline
501  { // return minimum possible generated value
502  return (_Cx != 0 ? 0 : 1);
503  }
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::operator() ( )
inline
511  { // return next value
512  return (_Imp());
513  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:557
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::seed ( _Uint  _X0 = default_seed)
inline
490  { // reset sequence from numeric value
491  _Reset(_X0);
492  }
void _Reset(_Uint _X0)
Definition: random:549
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen >
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::seed ( _Gen &  _Gx,
bool  = false 
)
inline
496  { // reset sequence from generator
497  _Seed(_Gx, is_arithmetic<_Gen>());
498  }
Definition: xtr1common:287
void _Seed(_Gen &_Gx, true_type)
Definition: random:536

Member Data Documentation

template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Select<_Uint, _Ax, _Cx, _Mx>::type linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Imp
protected
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
constexpr _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::default_seed = 1U
static
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
constexpr _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::increment = _Cx
static
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
constexpr _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::modulus = _Mx
static
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
constexpr _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::multiplier = _Ax
static

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