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)
 
 linear_congruential (const linear_congruential &_Right)
 
 linear_congruential (linear_congruential &_Right)
 
template<class _Gen >
 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 const _Uint multiplier = _Ax
 
static const _Uint increment = _Cx
 
static const _Uint modulus = _Mx
 
static const _Uint default_seed = 1U
 

Protected Member Functions

template<class _Gen >
void _Seed (_Gen &_Gx, const true_type &)
 
template<class _Gen >
void _Seed (_Gen &_Gx, const 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
504  { // construct from initial value
505  seed(_X0);
506  }
void seed(_Uint _X0=default_seed)
Definition: random:524
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
linear_congruential< _Uint, _Ax, _Cx, _Mx >::linear_congruential ( const linear_congruential< _Uint, _Ax, _Cx, _Mx > &  _Right)
inline
509  { // construct by copying
510  *this = _Right;
511  }
const _Ty & _Right
Definition: algorithm:4087
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
linear_congruential< _Uint, _Ax, _Cx, _Mx >::linear_congruential ( linear_congruential< _Uint, _Ax, _Cx, _Mx > &  _Right)
inline
514  { // construct by copying
515  *this = _Right;
516  }
const _Ty & _Right
Definition: algorithm:4087
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen >
linear_congruential< _Uint, _Ax, _Cx, _Mx >::linear_congruential ( _Gen &  _Gx)
inline
520  { // construct from generator
521  seed(_Gx);
522  }
void seed(_Uint _X0=default_seed)
Definition: random:524

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
557  { // return true if *this will generate same sequence as _Right
558  return (_Imp._Prev == _Right._Imp._Prev);
559  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:590
const _Ty & _Right
Definition: algorithm:4087
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Reset ( _Uint  _X0)
inlineprotected
582  { // reset sequence
583  _Uint _Divisor = _Mx; // to quiet diagnostics
584 
585  _Imp._Prev = _Mx != 0 ? _X0 % _Divisor : _X0;
586  if (_Imp._Prev == 0 && _Cx == 0)
587  _Imp._Prev = 1;
588  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:590
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen >
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Seed ( _Gen &  _Gx,
const true_type  
)
inlineprotected
571  { // reset sequence from numeric value
572  _Reset((_Uint)_Gx);
573  }
void _Reset(_Uint _X0)
Definition: random:581
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
template<class _Gen >
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::_Seed ( _Gen &  _Gx,
const false_type  
)
inlineprotected
577  { // reset sequence from generator
578  _Reset(_Gx());
579  }
void _Reset(_Uint _X0)
Definition: random:581
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
564  { // write state to _Ostr
565  return (_Ostr << _Imp._Prev);
566  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:590
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::discard ( unsigned long long  _Nskip)
inline
551  { // discard _Nskip elements
552  for (; 0 < _Nskip; --_Nskip)
553  (*this)();
554  }
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint() linear_congruential< _Uint, _Ax, _Cx, _Mx >::max ( ) const
inline
541  { // return maximum possible generated value
542  return (_Mx != 0 ? _Mx - 1 : (numeric_limits<_Uint>::max)());
543  }
Definition: limits:79
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint() linear_congruential< _Uint, _Ax, _Cx, _Mx >::min ( ) const
inline
536  { // return minimum possible generated value
537  return (_Cx != 0 ? 0 : 1);
538  }
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
_Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::operator() ( )
inline
546  { // return next value
547  return (_Imp());
548  }
_Select< _Uint, _Ax, _Cx, _Mx >::type _Imp
Definition: random:590
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
void linear_congruential< _Uint, _Ax, _Cx, _Mx >::seed ( _Uint  _X0 = default_seed)
inline
525  { // reset sequence from numeric value
526  _Reset(_X0);
527  }
void _Reset(_Uint _X0)
Definition: random:581
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
531  { // reset sequence from generator
532  _Seed(_Gx, _Is_numeric<_Gen>());
533  }
void _Seed(_Gen &_Gx, const true_type &)
Definition: random:570
Definition: xtr1common:306

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>
const _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::default_seed = 1U
static
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
const _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::increment = _Cx
static
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
const _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::modulus = _Mx
static
template<class _Uint, _Uint _Ax, _Uint _Cx, _Uint _Mx>
const _Uint linear_congruential< _Uint, _Ax, _Cx, _Mx >::multiplier = _Ax
static

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