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
gamma_distribution< _Ty > Class Template Reference

Classes

struct  param_type
 

Public Types

typedef gamma_distribution< _Ty > _Myt
 
typedef _Ty result_type
 

Public Member Functions

 gamma_distribution (_Ty _Alpha0=_Ty(1), _Ty _Beta0=_Ty(1))
 
 gamma_distribution (const param_type &_Par0)
 
_Ty alpha () const
 
_Ty beta () 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) const
 
template<class _Engine >
result_type operator() (_Engine &_Eng, const param_type &_Par0) const
 
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, param_type _Par0) const
 

Private Attributes

param_type _Par
 

Member Typedef Documentation

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

Constructor & Destructor Documentation

template<class _Ty = double>
gamma_distribution< _Ty >::gamma_distribution ( _Ty  _Alpha0 = _Ty(1),
_Ty  _Beta0 = _Ty(1) 
)
inlineexplicit
3870  : _Par(_Alpha0, _Beta0)
3871  { // construct
3872  }
param_type _Par
Definition: random:4007
template<class _Ty = double>
gamma_distribution< _Ty >::gamma_distribution ( const param_type _Par0)
inlineexplicit
3875  : _Par(_Par0)
3876  { // construct from parameter package
3877  }
param_type _Par
Definition: random:4007

Member Function Documentation

template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::_Eval ( _Engine &  _Eng,
param_type  _Par0 
) const
inlineprivate
3951  { // return next value
3952  _Ty _Ux, _Vx;
3953  _Ty _Xx, _Yx, _Qx;
3954  int _Count;
3955  if (_Par0._Alpha < 1)
3956  { // small values of alpha
3957  // from Knuth
3958  for (; ; )
3959  { // generate and reject
3960  _Ux = _NRAND(_Eng, _Ty);
3961  while ((_Vx = _NRAND(_Eng, _Ty)) == 0)
3962  ;
3963  if (_Ux < _Par0._Px)
3964  { // small _Ux
3965  _Xx = _CSTD pow(_Vx, _Ty(1) / _Par0._Alpha);
3966  _Qx = _CSTD exp(-_Xx);
3967  }
3968  else
3969  { // large _Ux
3970  _Xx = 1 - _CSTD log(_Vx);
3971  _Qx = _CSTD pow(_Xx, _Par0._Alpha - 1);
3972  }
3973  if (_NRAND(_Eng, _Ty) < _Qx)
3974  return (_Par0._Beta * _Xx);
3975  }
3976  }
3977  else if (_Par0._Alpha == 1)
3978  return (_Par0._Beta * _Par0._Exp(_Eng));
3979  else if ((_Count = (int)_Par0._Alpha) == _Par0._Alpha
3980  && _Count < 20)
3981  { // _Alpha is small integer, compute directly
3982  _Yx = _NRAND(_Eng, _Ty);
3983  while (--_Count)
3984  { // adjust result
3985  while ((_Ux = _NRAND(_Eng, _Ty)) == 0)
3986  ;
3987  _Yx *= _Ux;
3988  }
3989  return (_Par0._Beta * -_CSTD log(_Yx));
3990  }
3991  else
3992  { // no shortcuts
3993  for (; ; )
3994  { // generate and reject
3995  _Yx = (_Ty)_CSTD tan(_Pi * _NRAND(_Eng, _Ty));
3996  _Xx = _Par0._Sqrt * _Yx + _Par0._Alpha - 1;
3997  if (0 < _Xx &&
3998  _NRAND(_Eng, _Ty) <= (1 + _Yx * _Yx)
3999  * _CSTD exp((_Par0._Alpha - 1)
4000  * _CSTD log(_Xx / (_Par0._Alpha - 1))
4001  - _Par0._Sqrt * _Yx))
4002  return (_Par0._Beta * _Xx);
4003  }
4004  }
4005  }
unsigned int _Count
Definition: xcomplex:668
static constexpr long double _Pi
Definition: random:77
float exp(float _X) __GPU_ONLY
Calculates the base-e exponential of the argument
Definition: amp_math.h:471
float log(float _X) __GPU_ONLY
Calculates the base-e logarithm of the argument
Definition: amp_math.h:774
#define _NRAND(eng, resty)
Definition: random:323
#define _CSTD
Definition: yvals.h:570
float tan(float _X) __GPU_ONLY
Calculates the tangent value of the argument
Definition: amp_math.h:1128
float pow(float _X, float _Y) __GPU_ONLY
Calculates _X raised to the power of _Y
Definition: amp_math.h:898
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& gamma_distribution< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
3929  { // read state from _Istr
3930  _Ty _Alpha0;
3931  _Ty _Beta0;
3932  _In(_Istr, _Alpha0);
3933  _In(_Istr, _Beta0);
3934  _Par._Init(_Alpha0, _Beta0);
3935  return (_Istr);
3936  }
void _Init(_Ty _Alpha0, _Ty _Beta0)
Definition: random:3850
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:133
param_type _Par
Definition: random:4007
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& gamma_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3942  { // write state to _Ostr
3943  _Out(_Ostr, _Par._Alpha);
3944  _Out(_Ostr, _Par._Beta);
3945  return (_Ostr);
3946  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:151
_Ty _Alpha
Definition: random:3862
_Ty _Beta
Definition: random:3863
param_type _Par
Definition: random:4007
template<class _Ty = double>
_Ty gamma_distribution< _Ty >::alpha ( ) const
inline
3880  { // return alpha value
3881  return (_Par.alpha());
3882  }
_Ty alpha() const
Definition: random:3840
param_type _Par
Definition: random:4007
template<class _Ty = double>
_Ty gamma_distribution< _Ty >::beta ( ) const
inline
3885  { // return beta value
3886  return (_Par.beta());
3887  }
_Ty beta() const
Definition: random:3845
param_type _Par
Definition: random:4007
template<class _Ty = double>
result_type() gamma_distribution< _Ty >::max ( ) const
inline
3905  { // get largest possible result
3906  return ((numeric_limits<result_type>::max)());
3907  }
Definition: limits:101
template<class _Ty = double>
result_type() gamma_distribution< _Ty >::min ( ) const
inline
3900  { // get smallest possible result
3902  }
Definition: limits:101
template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
3915  { // return next value
3916  return (_Eval(_Eng, _Par));
3917  }
result_type _Eval(_Engine &_Eng, param_type _Par0) const
Definition: random:3950
param_type _Par
Definition: random:4007
template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
3921  { // return next value, given parameter package
3922  return (_Eval(_Eng, _Par0));
3923  }
result_type _Eval(_Engine &_Eng, param_type _Par0) const
Definition: random:3950
template<class _Ty = double>
param_type gamma_distribution< _Ty >::param ( ) const
inline
3890  { // return parameter package
3891  return (_Par);
3892  }
param_type _Par
Definition: random:4007
template<class _Ty = double>
void gamma_distribution< _Ty >::param ( const param_type _Par0)
inline
3895  { // set parameter package
3896  _Par = _Par0;
3897  }
param_type _Par
Definition: random:4007
template<class _Ty = double>
void gamma_distribution< _Ty >::reset ( )
inline
3910  { // clear internal state
3911  }

Member Data Documentation

template<class _Ty = double>
param_type gamma_distribution< _Ty >::_Par
private

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