STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
normal_distribution< _Ty > Class Template Reference

Classes

struct  param_type
 

Public Types

typedef normal_distribution< _Ty > _Myt
 
typedef _Ty result_type
 

Public Member Functions

 _RNG_REQUIRE_REALTYPE (normal_distribution, _Ty)
 
 normal_distribution (_Ty _Mean0=0.0, _Ty _Sigma0=1.0)
 
 normal_distribution (const param_type &_Par0)
 
_Ty mean () const
 
_Ty sigma () const
 
_Ty stddev () const
 
param_type param () const
 
void param (const param_type &_Par0)
 
result_type() min () const
 
result_type() max () const
 
void reset ()
 
template<class _Engine >
result_type operator() (_Engine &_Eng)
 
template<class _Engine >
result_type operator() (_Engine &_Eng, const param_type &_Par0)
 
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
 

Private Member Functions

template<class _Engine >
result_type _Eval (_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
 

Private Attributes

param_type _Par
 
bool _Valid
 
_Ty _X2
 

Member Typedef Documentation

template<class _Ty = double>
typedef normal_distribution<_Ty> normal_distribution< _Ty >::_Myt
template<class _Ty = double>
typedef _Ty normal_distribution< _Ty >::result_type

Constructor & Destructor Documentation

template<class _Ty = double>
normal_distribution< _Ty >::normal_distribution ( _Ty  _Mean0 = 0.0,
_Ty  _Sigma0 = 1.0 
)
inlineexplicit
3672  : _Par(_Mean0, _Sigma0), _Valid(false), _X2(0)
3673  { // construct
3674  }
param_type _Par
Definition: random:3798
bool _Valid
Definition: random:3799
_Ty _X2
Definition: random:3800
template<class _Ty = double>
normal_distribution< _Ty >::normal_distribution ( const param_type _Par0)
inlineexplicit
3677  : _Par(_Par0), _Valid(false), _X2(0)
3678  { // construct from parameter package
3679  }
param_type _Par
Definition: random:3798
bool _Valid
Definition: random:3799
_Ty _X2
Definition: random:3800

Member Function Documentation

template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::_Eval ( _Engine &  _Eng,
const param_type _Par0,
bool  _Keep = true 
)
inlineprivate
3768  { // compute next value
3769  // Knuth, vol. 2, p. 122, alg. P
3770  _Ty _Res;
3771  if (_Keep && _Valid)
3772  { // return stored value
3773  _Res = _X2;
3774  _Valid = false;
3775  }
3776  else
3777  { // generate two values, store one, return one
3778  double _V1, _V2, _Sx;
3779  for (; ; )
3780  { // reject bad values
3781  _V1 = 2 * _NRAND(_Eng, _Ty) - 1.0;
3782  _V2 = 2 * _NRAND(_Eng, _Ty) - 1.0;
3783  _Sx = _V1 * _V1 + _V2 * _V2;
3784  if (_Sx < 1.0)
3785  break;
3786  }
3787  double _Fx = _CSTD sqrt(-2.0 * _CSTD log(_Sx) / _Sx);
3788  if (_Keep)
3789  { // save second value for next call
3790  _X2 = _Fx * _V2;
3791  _Valid = true;
3792  }
3793  _Res = _Fx * _V1;
3794  }
3795  return (_Res * _Par0._Sigma + _Par0._Mean);
3796  }
float sqrt(float _X) __GPU_ONLY
Calculates the square root of the argument
Definition: amp_math.h:1100
float log(float _X) __GPU_ONLY
Calculates the base-e logarithm of the argument
Definition: amp_math.h:774
bool _Valid
Definition: random:3799
_Ty _X2
Definition: random:3800
#define _NRAND(eng, resty)
Definition: random:345
#define _CSTD
Definition: yvals.h:570
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& normal_distribution< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
3739  { // read state from _Istr
3740  _Ty _Mean0;
3741  _Ty _Sigma0;
3742  _In(_Istr, _Mean0);
3743  _In(_Istr, _Sigma0);
3744  _Par._Init(_Mean0, _Sigma0);
3745 
3746  _Istr >> _Valid;
3747  _In(_Istr, _X2);
3748  return (_Istr);
3749  }
param_type _Par
Definition: random:3798
bool _Valid
Definition: random:3799
_Ty _X2
Definition: random:3800
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:156
void _Init(_Ty _Mean0, _Ty _Sigma0)
Definition: random:3659
template<class _Ty = double>
normal_distribution< _Ty >::_RNG_REQUIRE_REALTYPE ( normal_distribution< _Ty >  ,
_Ty   
)
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& normal_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3755  { // write state to _Ostr
3756  _Out(_Ostr, _Par._Mean);
3757  _Out(_Ostr, _Par._Sigma);
3758 
3759  _Ostr << ' ' << _Valid;
3760  _Out(_Ostr, _X2);
3761  return (_Ostr);
3762  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:174
param_type _Par
Definition: random:3798
_Ty _Mean
Definition: random:3667
bool _Valid
Definition: random:3799
_Ty _X2
Definition: random:3800
_Ty _Sigma
Definition: random:3668
template<class _Ty = double>
result_type() normal_distribution< _Ty >::max ( ) const
inline
3713  { // get largest possible result
3714  return ((numeric_limits<result_type>::max)());
3715  }
Definition: limits:102
template<class _Ty = double>
_Ty normal_distribution< _Ty >::mean ( ) const
inline
3682  { // return mean value
3683  return (_Par.mean());
3684  }
param_type _Par
Definition: random:3798
_Ty mean() const
Definition: random:3644
template<class _Ty = double>
result_type() normal_distribution< _Ty >::min ( ) const
inline
3708  { // get smallest possible result
3710  }
Definition: limits:102
template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::operator() ( _Engine &  _Eng)
inline
3724  { // return next value
3725  return (_Eval(_Eng, _Par));
3726  }
param_type _Par
Definition: random:3798
result_type _Eval(_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
Definition: random:3766
template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
)
inline
3730  { // return next value, given parameter package
3731  reset();
3732  return (_Eval(_Eng, _Par0, false));
3733  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
Definition: random:3766
void reset()
Definition: random:3717
template<class _Ty = double>
param_type normal_distribution< _Ty >::param ( ) const
inline
3697  { // return parameter package
3698  return (_Par);
3699  }
param_type _Par
Definition: random:3798
template<class _Ty = double>
void normal_distribution< _Ty >::param ( const param_type _Par0)
inline
3702  { // set parameter package
3703  _Par = _Par0;
3704  reset();
3705  }
param_type _Par
Definition: random:3798
void reset()
Definition: random:3717
template<class _Ty = double>
void normal_distribution< _Ty >::reset ( )
inline
3718  { // clear internal state
3719  _Valid = false;
3720  }
bool _Valid
Definition: random:3799
template<class _Ty = double>
_Ty normal_distribution< _Ty >::sigma ( ) const
inline
3687  { // return sigma value
3688  return (_Par.sigma());
3689  }
param_type _Par
Definition: random:3798
_Ty sigma() const
Definition: random:3649
template<class _Ty = double>
_Ty normal_distribution< _Ty >::stddev ( ) const
inline
3692  { // return sigma value
3693  return (_Par.sigma());
3694  }
param_type _Par
Definition: random:3798
_Ty sigma() const
Definition: random:3649

Member Data Documentation

template<class _Ty = double>
param_type normal_distribution< _Ty >::_Par
private
template<class _Ty = double>
bool normal_distribution< _Ty >::_Valid
private
template<class _Ty = double>
_Ty normal_distribution< _Ty >::_X2
private

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