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

 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
3645  : _Par(_Mean0, _Sigma0), _Valid(false), _X2(0)
3646  { // construct
3647  }
param_type _Par
Definition: random:3771
bool _Valid
Definition: random:3772
_Ty _X2
Definition: random:3773
template<class _Ty = double>
normal_distribution< _Ty >::normal_distribution ( const param_type _Par0)
inlineexplicit
3650  : _Par(_Par0), _Valid(false), _X2(0)
3651  { // construct from parameter package
3652  }
param_type _Par
Definition: random:3771
bool _Valid
Definition: random:3772
_Ty _X2
Definition: random:3773

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
3741  { // compute next value
3742  // Knuth, vol. 2, p. 122, alg. P
3743  _Ty _Res;
3744  if (_Keep && _Valid)
3745  { // return stored value
3746  _Res = _X2;
3747  _Valid = false;
3748  }
3749  else
3750  { // generate two values, store one, return one
3751  double _V1, _V2, _Sx;
3752  for (; ; )
3753  { // reject bad values
3754  _V1 = 2 * _NRAND(_Eng, _Ty) - 1.0;
3755  _V2 = 2 * _NRAND(_Eng, _Ty) - 1.0;
3756  _Sx = _V1 * _V1 + _V2 * _V2;
3757  if (_Sx < 1.0)
3758  break;
3759  }
3760  double _Fx = _CSTD sqrt(-2.0 * _CSTD log(_Sx) / _Sx);
3761  if (_Keep)
3762  { // save second value for next call
3763  _X2 = _Fx * _V2;
3764  _Valid = true;
3765  }
3766  _Res = _Fx * _V1;
3767  }
3768  return (_Res * _Par0._Sigma + _Par0._Mean);
3769  }
float sqrt(float _X) __GPU_ONLY
Calculates the squre 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:3772
_Ty _X2
Definition: random:3773
#define _NRAND(eng, resty)
Definition: random:323
#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
3712  { // read state from _Istr
3713  _Ty _Mean0;
3714  _Ty _Sigma0;
3715  _In(_Istr, _Mean0);
3716  _In(_Istr, _Sigma0);
3717  _Par._Init(_Mean0, _Sigma0);
3718 
3719  _Istr >> _Valid;
3720  _In(_Istr, _X2);
3721  return (_Istr);
3722  }
param_type _Par
Definition: random:3771
bool _Valid
Definition: random:3772
_Ty _X2
Definition: random:3773
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:133
void _Init(_Ty _Mean0, _Ty _Sigma0)
Definition: random:3632
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& normal_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3728  { // write state to _Ostr
3729  _Out(_Ostr, _Par._Mean);
3730  _Out(_Ostr, _Par._Sigma);
3731 
3732  _Ostr << ' ' << _Valid;
3733  _Out(_Ostr, _X2);
3734  return (_Ostr);
3735  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:151
param_type _Par
Definition: random:3771
_Ty _Mean
Definition: random:3640
bool _Valid
Definition: random:3772
_Ty _X2
Definition: random:3773
_Ty _Sigma
Definition: random:3641
template<class _Ty = double>
result_type() normal_distribution< _Ty >::max ( ) const
inline
3686  { // get largest possible result
3687  return ((numeric_limits<result_type>::max)());
3688  }
Definition: limits:101
template<class _Ty = double>
_Ty normal_distribution< _Ty >::mean ( ) const
inline
3655  { // return mean value
3656  return (_Par.mean());
3657  }
param_type _Par
Definition: random:3771
_Ty mean() const
Definition: random:3617
template<class _Ty = double>
result_type() normal_distribution< _Ty >::min ( ) const
inline
3681  { // get smallest possible result
3683  }
Definition: limits:101
template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::operator() ( _Engine &  _Eng)
inline
3697  { // return next value
3698  return (_Eval(_Eng, _Par));
3699  }
param_type _Par
Definition: random:3771
result_type _Eval(_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
Definition: random:3739
template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
)
inline
3703  { // return next value, given parameter package
3704  reset();
3705  return (_Eval(_Eng, _Par0, false));
3706  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
Definition: random:3739
void reset()
Definition: random:3690
template<class _Ty = double>
param_type normal_distribution< _Ty >::param ( ) const
inline
3670  { // return parameter package
3671  return (_Par);
3672  }
param_type _Par
Definition: random:3771
template<class _Ty = double>
void normal_distribution< _Ty >::param ( const param_type _Par0)
inline
3675  { // set parameter package
3676  _Par = _Par0;
3677  reset();
3678  }
param_type _Par
Definition: random:3771
void reset()
Definition: random:3690
template<class _Ty = double>
void normal_distribution< _Ty >::reset ( )
inline
3691  { // clear internal state
3692  _Valid = false;
3693  }
bool _Valid
Definition: random:3772
template<class _Ty = double>
_Ty normal_distribution< _Ty >::sigma ( ) const
inline
3660  { // return sigma value
3661  return (_Par.sigma());
3662  }
param_type _Par
Definition: random:3771
_Ty sigma() const
Definition: random:3622
template<class _Ty = double>
_Ty normal_distribution< _Ty >::stddev ( ) const
inline
3665  { // return sigma value
3666  return (_Par.sigma());
3667  }
param_type _Par
Definition: random:3771
_Ty sigma() const
Definition: random:3622

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: