STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | List of all members
discrete_distribution< _Ty > Class Template Reference

Classes

struct  param_type
 

Public Types

typedef discrete_distribution< _Ty > _Myt
 
typedef vector< double > _Myvec
 
typedef _Ty result_type
 

Public Member Functions

 _RNG_REQUIRE_INTTYPE (discrete_distribution, _Ty)
 
 discrete_distribution ()
 
template<class _InIt >
 discrete_distribution (_InIt _First, _InIt _Last)
 
 discrete_distribution (initializer_list< double > _Ilist)
 
template<class _Fn >
 discrete_distribution (size_t _Count, double _Low, double _High, _Fn _Func)
 
 discrete_distribution (const param_type &_Par0)
 
_Myvec probabilities () 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, param_type &_Par0)
 
template<class _Elem , class _Traits >
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr, const param_type &_Par0) const
 

Public Attributes

param_type _Par
 

Private Member Functions

template<class _Engine >
result_type _Eval (_Engine &_Eng, const param_type &_Par0) const
 

Member Typedef Documentation

template<class _Ty = int>
typedef discrete_distribution<_Ty> discrete_distribution< _Ty >::_Myt
template<class _Ty = int>
typedef vector<double> discrete_distribution< _Ty >::_Myvec
template<class _Ty = int>
typedef _Ty discrete_distribution< _Ty >::result_type

Constructor & Destructor Documentation

template<class _Ty = int>
discrete_distribution< _Ty >::discrete_distribution ( )
inline
5645  { // default constructor
5646  }
template<class _Ty = int>
template<class _InIt >
discrete_distribution< _Ty >::discrete_distribution ( _InIt  _First,
_InIt  _Last 
)
inline
5650  : _Par(_First, _Last)
5651  { // construct from [_First, _Last)
5652  }
param_type _Par
Definition: random:5770
_FwdIt _Last
Definition: algorithm:1936
template<class _Ty = int>
discrete_distribution< _Ty >::discrete_distribution ( initializer_list< double >  _Ilist)
inline
5655  : _Par(_Ilist)
5656  { // construct from initializer list
5657  }
param_type _Par
Definition: random:5770
template<class _Ty = int>
template<class _Fn >
discrete_distribution< _Ty >::discrete_distribution ( size_t  _Count,
double  _Low,
double  _High,
_Fn  _Func 
)
inline
5662  : _Par(_Count, _Low, _High, _Func)
5663  { // construct from function
5664  }
param_type _Par
Definition: random:5770
_Diff _Count
Definition: algorithm:1941
template<class _Ty = int>
discrete_distribution< _Ty >::discrete_distribution ( const param_type _Par0)
inlineexplicit
5667  : _Par(_Par0)
5668  { // construct from parameter package
5669  }
param_type _Par
Definition: random:5770

Member Function Documentation

template<class _Ty = int>
template<class _Engine >
result_type discrete_distribution< _Ty >::_Eval ( _Engine &  _Eng,
const param_type _Par0 
) const
inlineprivate
5748  { // return next value
5749  double _Px = _NRAND(_Eng, double);
5750  result_type _Count = (result_type)_Par0._Pcdf.size();
5751  result_type _First = 0;
5752 
5753  while (0 < _Count)
5754  { // divide and conquer, find half that contains answer
5755  result_type _Count2 = _Count / 2;
5756  result_type _Mid = _First + _Count2;
5757 
5758  if (_Px <= _Par0._Pcdf[_Mid])
5759  _Count = _Count2; // answer in first half, stay there
5760  else
5761  { // answer in second half, move up
5762  _First = ++_Mid;
5763  _Count -= _Count2 + 1;
5764  }
5765  }
5766  return (_First);
5767  }
#define _NRAND(eng, resty)
Definition: random:345
_Ty result_type
Definition: random:5545
_Diff _Count
Definition: algorithm:1941
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& discrete_distribution< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr,
param_type _Par0 
)
inline
5717  { // read state from _Istr
5718  size_t _Nvals;
5719  _Istr >> _Nvals;
5720  _Par0._Pvec.clear();
5721  for (; 0 < _Nvals; --_Nvals)
5722  { // get a value and add to vector
5723  double _Val;
5724  _In(_Istr, _Val);
5725  _Par0._Pvec.push_back(_Val);
5726  }
5727  _Par0._Init(false); // don't renormalize, just compute CDF
5728  return (_Istr);
5729  }
void __CLR_OR_THIS_CALL clear(iostate _State=goodbit, bool _Reraise=false)
Definition: ios:41
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:156
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<class _Ty = int>
discrete_distribution< _Ty >::_RNG_REQUIRE_INTTYPE ( discrete_distribution< _Ty >  ,
_Ty   
)
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& discrete_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr,
const param_type _Par0 
) const
inline
5736  { // write state to _Ostr
5737  size_t _Nvals = _Par0._Pvec.size();
5738  _Ostr << ' ' << _Nvals;
5739 
5740  for (size_t _Idx = 0; _Idx < _Par0._Pvec.size(); ++_Idx)
5741  _Out(_Ostr, _Par0._Pvec[_Idx]);
5742  return (_Ostr);
5743  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:174
template<class _Ty = int>
result_type() discrete_distribution< _Ty >::max ( ) const
inline
5692  { // return maximum possible generated value
5693  return ((result_type)(_Par._Pvec.size() - 1));
5694  }
param_type _Par
Definition: random:5770
size_type size() const _NOEXCEPT
Definition: vector:1708
_Ty result_type
Definition: random:5545
_Myvec _Pvec
Definition: random:5640
template<class _Ty = int>
result_type() discrete_distribution< _Ty >::min ( ) const
inline
5687  { // return minimum possible generated value
5688  return (0);
5689  }
template<class _Ty = int>
template<class _Engine >
result_type discrete_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
5702  { // return next value
5703  return (_Eval(_Eng, _Par));
5704  }
param_type _Par
Definition: random:5770
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:5747
template<class _Ty = int>
template<class _Engine >
result_type discrete_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
5708  { // return next value, given parameter package
5709  return (_Eval(_Eng, _Par0));
5710  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:5747
template<class _Ty = int>
param_type discrete_distribution< _Ty >::param ( ) const
inline
5677  { // return parameter package
5678  return (_Par);
5679  }
param_type _Par
Definition: random:5770
template<class _Ty = int>
void discrete_distribution< _Ty >::param ( const param_type _Par0)
inline
5682  { // set parameter package
5683  _Par = _Par0;
5684  }
param_type _Par
Definition: random:5770
template<class _Ty = int>
_Myvec discrete_distribution< _Ty >::probabilities ( ) const
inline
5672  { // return scaled probabilities vector
5673  return (_Par.probabilities());
5674  }
_Myvec probabilities() const
Definition: random:5603
param_type _Par
Definition: random:5770
template<class _Ty = int>
void discrete_distribution< _Ty >::reset ( )
inline
5697  { // clear internal state
5698  }

Member Data Documentation

template<class _Ty = int>
param_type discrete_distribution< _Ty >::_Par

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