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 input_type
 
typedef _Ty result_type
 

Public Member Functions

 normal_distribution (_Ty _Mean0=0.0, _Ty _Sigma0=1.0)
 
 normal_distribution (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 >::input_type
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
3925  : _Par(_Mean0, _Sigma0), _Valid(false), _X2(0)
3926  { // construct
3927  }
param_type _Par
Definition: random:4051
bool _Valid
Definition: random:4052
_Ty _X2
Definition: random:4053
template<class _Ty = double>
normal_distribution< _Ty >::normal_distribution ( param_type  _Par0)
inlineexplicit
3930  : _Par(_Par0), _Valid(false), _X2(0)
3931  { // construct from parameter package
3932  }
param_type _Par
Definition: random:4051
bool _Valid
Definition: random:4052
_Ty _X2
Definition: random:4053

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
4021  { // compute next value
4022  // Knuth, vol. 2, p. 122, alg. P
4023  _Ty _Res;
4024  if (_Keep && _Valid)
4025  { // return stored value
4026  _Res = _X2;
4027  _Valid = false;
4028  }
4029  else
4030  { // generate two values, store one, return one
4031  double _V1, _V2, _Sx;
4032  for (; ; )
4033  { // reject bad values
4034  _V1 = 2 * _NRAND(_Eng, _Ty) - 1.0;
4035  _V2 = 2 * _NRAND(_Eng, _Ty) - 1.0;
4036  _Sx = _V1 * _V1 + _V2 * _V2;
4037  if (_Sx < 1.0)
4038  break;
4039  }
4040  double _Fx = _CSTD sqrt(-2.0 * _CSTD log(_Sx) / _Sx);
4041  if (_Keep)
4042  { // save second value for next call
4043  _X2 = _Fx * _V2;
4044  _Valid = true;
4045  }
4046  _Res = _Fx * _V1;
4047  }
4048  return (_Res * _Par0._Sigma + _Par0._Mean);
4049  }
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:4052
_Ty _X2
Definition: random:4053
#define _NRAND(eng, resty)
Definition: random:74
#define _CSTD
Definition: yvals.h:559
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& normal_distribution< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
3992  { // read state from _Istr
3993  _Ty _Mean0;
3994  _Ty _Sigma0;
3995  _In(_Istr, _Mean0);
3996  _In(_Istr, _Sigma0);
3997  _Par._Init(_Mean0, _Sigma0);
3998 
3999  _Istr >> _Valid;
4000  _In(_Istr, _X2);
4001  return (_Istr);
4002  }
param_type _Par
Definition: random:4051
bool _Valid
Definition: random:4052
_Ty _X2
Definition: random:4053
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:151
void _Init(_Ty _Mean0, _Ty _Sigma0)
Definition: random:3912
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& normal_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
4008  { // write state to _Ostr
4009  _Out(_Ostr, _Par._Mean);
4010  _Out(_Ostr, _Par._Sigma);
4011 
4012  _Ostr << ' ' << _Valid;
4013  _Out(_Ostr, _X2);
4014  return (_Ostr);
4015  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:169
param_type _Par
Definition: random:4051
_Ty _Mean
Definition: random:3920
bool _Valid
Definition: random:4052
_Ty _X2
Definition: random:4053
_Ty _Sigma
Definition: random:3921
template<class _Ty = double>
result_type() normal_distribution< _Ty >::max ( ) const
inline
3966  { // get largest possible result
3967  return ((numeric_limits<result_type>::max)());
3968  }
Definition: limits:79
template<class _Ty = double>
_Ty normal_distribution< _Ty >::mean ( ) const
inline
3935  { // return mean value
3936  return (_Par.mean());
3937  }
param_type _Par
Definition: random:4051
_Ty mean() const
Definition: random:3897
template<class _Ty = double>
result_type() normal_distribution< _Ty >::min ( ) const
inline
3961  { // get smallest possible result
3962  return (-(numeric_limits<result_type>::max)());
3963  }
Definition: limits:79
template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::operator() ( _Engine &  _Eng)
inline
3977  { // return next value
3978  return (_Eval(_Eng, _Par));
3979  }
param_type _Par
Definition: random:4051
result_type _Eval(_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
Definition: random:4019
template<class _Ty = double>
template<class _Engine >
result_type normal_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
)
inline
3983  { // return next value, given parameter package
3984  reset();
3985  return (_Eval(_Eng, _Par0, false));
3986  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0, bool _Keep=true)
Definition: random:4019
void reset()
Definition: random:3970
template<class _Ty = double>
param_type normal_distribution< _Ty >::param ( ) const
inline
3950  { // return parameter package
3951  return (_Par);
3952  }
param_type _Par
Definition: random:4051
template<class _Ty = double>
void normal_distribution< _Ty >::param ( const param_type _Par0)
inline
3955  { // set parameter package
3956  _Par = _Par0;
3957  reset();
3958  }
param_type _Par
Definition: random:4051
void reset()
Definition: random:3970
template<class _Ty = double>
void normal_distribution< _Ty >::reset ( )
inline
3971  { // clear internal state
3972  _Valid = false;
3973  }
bool _Valid
Definition: random:4052
template<class _Ty = double>
_Ty normal_distribution< _Ty >::sigma ( ) const
inline
3940  { // return sigma value
3941  return (_Par.sigma());
3942  }
param_type _Par
Definition: random:4051
_Ty sigma() const
Definition: random:3902
template<class _Ty = double>
_Ty normal_distribution< _Ty >::stddev ( ) const
inline
3945  { // return sigma value
3946  return (_Par.sigma());
3947  }
param_type _Par
Definition: random:4051
_Ty sigma() const
Definition: random:3902

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: