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
500  { // construct from initial value
501  seed(_X0);
502  }
void seed(_Uint _X0=default_seed)
Definition: random:511
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
507  { // construct from generator
508  seed(_Gx);
509  }
void seed(_Uint _X0=default_seed)
Definition: random:511

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
544  { // return true if *this will generate same sequence as _Right
545  return (_Imp._Prev == _Right._Imp._Prev);
546  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:579
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Reset ( _Uint  _X0)
inlineprotected
572  { // reset sequence
573  _Imp._Prev = _Mx != 0 ? _X0 % _Mx : _X0;
574  if (_Imp._Prev == 0 && _Cx == 0)
575  _Imp._Prev = 1;
576  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:579
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
559  { // reset sequence from numeric value
560  _Reset((_Uint)_Gx);
561  }
void _Reset(_Uint _X0)
Definition: random:571
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
565  { // reset sequence from generator
566  _Reset(_Gx());
567  }
void _Reset(_Uint _X0)
Definition: random:571
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
552  { // write state to _Ostr
553  return (_Ostr << _Imp._Prev);
554  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:579
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::discard ( unsigned long long  _Nskip)
inline
538  { // discard _Nskip elements
539  for (; 0 < _Nskip; --_Nskip)
540  (*this)();
541  }
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint() linear_congruential< _Uint, _Ax, _Cx, _Mx >::max ( ) const
inline
528  { // return maximum possible generated value
529  return (_Mx != 0 ? _Mx - 1 : (numeric_limits<_Uint>::max)());
530  }
Definition: limits:102
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint() linear_congruential< _Uint, _Ax, _Cx, _Mx >::min ( ) const
inline
523  { // return minimum possible generated value
524  return (_Cx != 0 ? 0 : 1);
525  }
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::operator() ( )
inline
533  { // return next value
534  return (_Imp());
535  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:579
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::seed ( _Uint  _X0 = default_seed)
inline
512  { // reset sequence from numeric value
513  _Reset(_X0);
514  }
void _Reset(_Uint _X0)
Definition: random:571
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
518  { // reset sequence from generator
519  _Seed(_Gx, is_arithmetic<_Gen>());
520  }
Definition: xtr1common:282
void _Seed(_Gen &_Gx, true_type)
Definition: random:558

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: