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

Public Member Functions

 gamma_distribution (_Ty _Alpha0=_Ty(1), _Ty _Beta0=_Ty(1))
 
 gamma_distribution (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 >::input_type
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
4137  : _Par(_Alpha0, _Beta0)
4138  { // construct
4139  }
param_type _Par
Definition: random:4274
template<class _Ty = double>
gamma_distribution< _Ty >::gamma_distribution ( param_type  _Par0)
inlineexplicit
4142  : _Par(_Par0)
4143  { // construct from parameter package
4144  }
param_type _Par
Definition: random:4274

Member Function Documentation

template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::_Eval ( _Engine &  _Eng,
param_type  _Par0 
) const
inlineprivate
4218  { // return next value
4219  _Ty _Ux, _Vx;
4220  _Ty _Xx, _Yx, _Qx;
4221  int _Count;
4222  if (_Par0._Alpha < 1)
4223  { // small values of alpha
4224  // from Knuth
4225  for (; ; )
4226  { // generate and reject
4227  _Ux = _NRAND(_Eng, _Ty);
4228  while ((_Vx = _NRAND(_Eng, _Ty)) == 0)
4229  ;
4230  if (_Ux < _Par0._Px)
4231  { // small _Ux
4232  _Xx = _CSTD pow(_Vx, _Ty(1) / _Par0._Alpha);
4233  _Qx = _CSTD exp(-_Xx);
4234  }
4235  else
4236  { // large _Ux
4237  _Xx = 1 - _CSTD log(_Vx);
4238  _Qx = _CSTD pow(_Xx, _Par0._Alpha - 1);
4239  }
4240  if (_NRAND(_Eng, _Ty) < _Qx)
4241  return (_Par0._Beta * _Xx);
4242  }
4243  }
4244  else if (_Par0._Alpha == 1)
4245  return (_Par0._Beta * _Par0._Exp(_Eng));
4246  else if ((_Count = (int)_Par0._Alpha) == _Par0._Alpha
4247  && _Count < 20)
4248  { // _Alpha is small integer, compute directly
4249  _Yx = _NRAND(_Eng, _Ty);
4250  while (--_Count)
4251  { // adjust result
4252  while ((_Ux = _NRAND(_Eng, _Ty)) == 0)
4253  ;
4254  _Yx *= _Ux;
4255  }
4256  return (_Par0._Beta * -_CSTD log(_Yx));
4257  }
4258  else
4259  { // no shortcuts
4260  for (; ; )
4261  { // generate and reject
4262  _Yx = (_Ty)_CSTD tan(_Pi * _NRAND(_Eng, _Ty));
4263  _Xx = _Par0._Sqrt * _Yx + _Par0._Alpha - 1;
4264  if (0 < _Xx &&
4265  _NRAND(_Eng, _Ty) <= (1 + _Yx * _Yx)
4266  * _CSTD exp((_Par0._Alpha - 1)
4267  * _CSTD log(_Xx / (_Par0._Alpha - 1))
4268  - _Par0._Sqrt * _Yx))
4269  return (_Par0._Beta * _Xx);
4270  }
4271  }
4272  }
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:74
static const long double _Pi
Definition: random:62
_Diff _Count
Definition: algorithm:1941
#define _CSTD
Definition: yvals.h:559
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
4196  { // read state from _Istr
4197  _Ty _Alpha0;
4198  _Ty _Beta0;
4199  _In(_Istr, _Alpha0);
4200  _In(_Istr, _Beta0);
4201  _Par._Init(_Alpha0, _Beta0);
4202  return (_Istr);
4203  }
void _Init(_Ty _Alpha0, _Ty _Beta0)
Definition: random:4117
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:151
param_type _Par
Definition: random:4274
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& gamma_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
4209  { // write state to _Ostr
4210  _Out(_Ostr, _Par._Alpha);
4211  _Out(_Ostr, _Par._Beta);
4212  return (_Ostr);
4213  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:169
_Ty _Alpha
Definition: random:4129
_Ty _Beta
Definition: random:4130
param_type _Par
Definition: random:4274
template<class _Ty = double>
_Ty gamma_distribution< _Ty >::alpha ( ) const
inline
4147  { // return alpha value
4148  return (_Par.alpha());
4149  }
_Ty alpha() const
Definition: random:4107
param_type _Par
Definition: random:4274
template<class _Ty = double>
_Ty gamma_distribution< _Ty >::beta ( ) const
inline
4152  { // return beta value
4153  return (_Par.beta());
4154  }
_Ty beta() const
Definition: random:4112
param_type _Par
Definition: random:4274
template<class _Ty = double>
result_type() gamma_distribution< _Ty >::max ( ) const
inline
4172  { // get largest possible result
4173  return ((numeric_limits<result_type>::max)());
4174  }
Definition: limits:79
template<class _Ty = double>
result_type() gamma_distribution< _Ty >::min ( ) const
inline
4167  { // get smallest possible result
4169  }
Definition: limits:79
template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
4182  { // return next value
4183  return (_Eval(_Eng, _Par));
4184  }
result_type _Eval(_Engine &_Eng, param_type _Par0) const
Definition: random:4217
param_type _Par
Definition: random:4274
template<class _Ty = double>
template<class _Engine >
result_type gamma_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
4188  { // return next value, given parameter package
4189  return (_Eval(_Eng, _Par0));
4190  }
result_type _Eval(_Engine &_Eng, param_type _Par0) const
Definition: random:4217
template<class _Ty = double>
param_type gamma_distribution< _Ty >::param ( ) const
inline
4157  { // return parameter package
4158  return (_Par);
4159  }
param_type _Par
Definition: random:4274
template<class _Ty = double>
void gamma_distribution< _Ty >::param ( const param_type _Par0)
inline
4162  { // set parameter package
4163  _Par = _Par0;
4164  }
param_type _Par
Definition: random:4274
template<class _Ty = double>
void gamma_distribution< _Ty >::reset ( )
inline
4177  { // clear internal state
4178  }

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: