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

 _RNG_REQUIRE_REALTYPE (gamma_distribution, _Ty)
 
 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
3896  : _Par(_Alpha0, _Beta0)
3897  { // construct
3898  }
param_type _Par
Definition: random:4033
template<class _Ty = double>
gamma_distribution< _Ty >::gamma_distribution ( const param_type _Par0)
inlineexplicit
3901  : _Par(_Par0)
3902  { // construct from parameter package
3903  }
param_type _Par
Definition: random:4033

Member Function Documentation

template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::_Eval ( _Engine &  _Eng,
param_type  _Par0 
) const
inlineprivate
3977  { // return next value
3978  _Ty _Ux, _Vx;
3979  _Ty _Xx, _Yx, _Qx;
3980  int _Count;
3981  if (_Par0._Alpha < 1)
3982  { // small values of alpha
3983  // from Knuth
3984  for (; ; )
3985  { // generate and reject
3986  _Ux = _NRAND(_Eng, _Ty);
3987  while ((_Vx = _NRAND(_Eng, _Ty)) == 0)
3988  ;
3989  if (_Ux < _Par0._Px)
3990  { // small _Ux
3991  _Xx = _CSTD pow(_Vx, _Ty(1) / _Par0._Alpha);
3992  _Qx = _CSTD exp(-_Xx);
3993  }
3994  else
3995  { // large _Ux
3996  _Xx = 1 - _CSTD log(_Vx);
3997  _Qx = _CSTD pow(_Xx, _Par0._Alpha - 1);
3998  }
3999  if (_NRAND(_Eng, _Ty) < _Qx)
4000  return (_Par0._Beta * _Xx);
4001  }
4002  }
4003  else if (_Par0._Alpha == 1)
4004  return (_Par0._Beta * _Par0._Exp(_Eng));
4005  else if ((_Count = (int)_Par0._Alpha) == _Par0._Alpha
4006  && _Count < 20)
4007  { // _Alpha is small integer, compute directly
4008  _Yx = _NRAND(_Eng, _Ty);
4009  while (--_Count)
4010  { // adjust result
4011  while ((_Ux = _NRAND(_Eng, _Ty)) == 0)
4012  ;
4013  _Yx *= _Ux;
4014  }
4015  return (_Par0._Beta * -_CSTD log(_Yx));
4016  }
4017  else
4018  { // no shortcuts
4019  for (; ; )
4020  { // generate and reject
4021  _Yx = (_Ty)_CSTD tan(_Pi * _NRAND(_Eng, _Ty));
4022  _Xx = _Par0._Sqrt * _Yx + _Par0._Alpha - 1;
4023  if (0 < _Xx &&
4024  _NRAND(_Eng, _Ty) <= (1 + _Yx * _Yx)
4025  * _CSTD exp((_Par0._Alpha - 1)
4026  * _CSTD log(_Xx / (_Par0._Alpha - 1))
4027  - _Par0._Sqrt * _Yx))
4028  return (_Par0._Beta * _Xx);
4029  }
4030  }
4031  }
constexpr long double _Pi
Definition: random:100
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:345
_Diff _Count
Definition: algorithm:1941
#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
3955  { // read state from _Istr
3956  _Ty _Alpha0;
3957  _Ty _Beta0;
3958  _In(_Istr, _Alpha0);
3959  _In(_Istr, _Beta0);
3960  _Par._Init(_Alpha0, _Beta0);
3961  return (_Istr);
3962  }
void _Init(_Ty _Alpha0, _Ty _Beta0)
Definition: random:3876
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:156
param_type _Par
Definition: random:4033
template<class _Ty = double>
gamma_distribution< _Ty >::_RNG_REQUIRE_REALTYPE ( gamma_distribution< _Ty >  ,
_Ty   
)
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& gamma_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3968  { // write state to _Ostr
3969  _Out(_Ostr, _Par._Alpha);
3970  _Out(_Ostr, _Par._Beta);
3971  return (_Ostr);
3972  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:174
_Ty _Alpha
Definition: random:3888
_Ty _Beta
Definition: random:3889
param_type _Par
Definition: random:4033
template<class _Ty = double>
_Ty gamma_distribution< _Ty >::alpha ( ) const
inline
3906  { // return alpha value
3907  return (_Par.alpha());
3908  }
_Ty alpha() const
Definition: random:3866
param_type _Par
Definition: random:4033
template<class _Ty = double>
_Ty gamma_distribution< _Ty >::beta ( ) const
inline
3911  { // return beta value
3912  return (_Par.beta());
3913  }
_Ty beta() const
Definition: random:3871
param_type _Par
Definition: random:4033
template<class _Ty = double>
result_type() gamma_distribution< _Ty >::max ( ) const
inline
3931  { // get largest possible result
3932  return ((numeric_limits<result_type>::max)());
3933  }
Definition: limits:102
template<class _Ty = double>
result_type() gamma_distribution< _Ty >::min ( ) const
inline
3926  { // get smallest possible result
3928  }
Definition: limits:102
template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
3941  { // return next value
3942  return (_Eval(_Eng, _Par));
3943  }
result_type _Eval(_Engine &_Eng, param_type _Par0) const
Definition: random:3976
param_type _Par
Definition: random:4033
template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
3947  { // return next value, given parameter package
3948  return (_Eval(_Eng, _Par0));
3949  }
result_type _Eval(_Engine &_Eng, param_type _Par0) const
Definition: random:3976
template<class _Ty = double>
param_type gamma_distribution< _Ty >::param ( ) const
inline
3916  { // return parameter package
3917  return (_Par);
3918  }
param_type _Par
Definition: random:4033
template<class _Ty = double>
void gamma_distribution< _Ty >::param ( const param_type _Par0)
inline
3921  { // set parameter package
3922  _Par = _Par0;
3923  }
param_type _Par
Definition: random:4033
template<class _Ty = double>
void gamma_distribution< _Ty >::reset ( )
inline
3936  { // clear internal state
3937  }

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: