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

 discrete_distribution ()
 
 discrete_distribution (_XSTD 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
5762  { // default constructor
5763  }
template<class _Ty = int>
discrete_distribution< _Ty >::discrete_distribution ( _XSTD initializer_list< double >  _Ilist)
inline
5766  : _Par(_Ilist)
5767  { // construct from initializer list
5768  }
param_type _Par
Definition: random:5881
template<class _Ty = int>
template<class _Fn >
discrete_distribution< _Ty >::discrete_distribution ( size_t  _Count,
double  _Low,
double  _High,
_Fn  _Func 
)
inline
5773  : _Par(_Count, _Low, _High, _Func)
5774  { // construct from function
5775  }
param_type _Par
Definition: random:5881
_Diff _Count
Definition: algorithm:1941
template<class _Ty = int>
discrete_distribution< _Ty >::discrete_distribution ( const param_type _Par0)
inlineexplicit
5778  : _Par(_Par0)
5779  { // construct from parameter package
5780  }
param_type _Par
Definition: random:5881

Member Function Documentation

template<class _Ty = int>
template<class _Engine >
result_type discrete_distribution< _Ty >::_Eval ( _Engine &  _Eng,
const param_type _Par0 
) const
inlineprivate
5859  { // return next value
5860  double _Px = _NRAND(_Eng, double);
5861  result_type _Count = (result_type)_Par0._Pcdf.size();
5862  result_type _First = 0;
5863 
5864  while (0 < _Count)
5865  { // divide and conquer, find half that contains answer
5866  result_type _Count2 = _Count / 2;
5867  result_type _Mid = _First + _Count2;
5868 
5869  if (_Px <= _Par0._Pcdf[_Mid])
5870  _Count = _Count2; // answer in first half, stay there
5871  else
5872  { // answer in second half, move up
5873  _First = ++_Mid;
5874  _Count -= _Count2 + 1;
5875  }
5876  }
5877  return (_First);
5878  }
#define _NRAND(eng, resty)
Definition: random:74
_Ty result_type
Definition: random:5669
_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
5828  { // read state from _Istr
5829  size_t _Nvals;
5830  _Istr >> _Nvals;
5831  _Par0._Pvec.clear();
5832  for (; 0 < _Nvals; --_Nvals)
5833  { // get a value and add to vector
5834  double _Val;
5835  _In(_Istr, _Val);
5836  _Par0._Pvec.push_back(_Val);
5837  }
5838  _Par0._Init(false); // don't renormalize, just compute CDF
5839  return (_Istr);
5840  }
void __CLR_OR_THIS_CALL clear(iostate _State=goodbit, bool _Reraise=false)
Definition: ios:42
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:151
_FwdIt const _Ty _Val
Definition: algorithm:1938
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
5847  { // write state to _Ostr
5848  size_t _Nvals = _Par0._Pvec.size();
5849  _Ostr << ' ' << _Nvals;
5850 
5851  for (size_t _Idx = 0; _Idx < _Par0._Pvec.size(); ++_Idx)
5852  _Out(_Ostr, _Par0._Pvec[_Idx]);
5853  return (_Ostr);
5854  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:169
template<class _Ty = int>
result_type() discrete_distribution< _Ty >::max ( ) const
inline
5803  { // return maximum possible generated value
5804  return ((result_type)(_Par._Pvec.size() - 1));
5805  }
param_type _Par
Definition: random:5881
size_type size() const _NOEXCEPT
Definition: vector:1146
_Ty result_type
Definition: random:5669
_Myvec _Pvec
Definition: random:5757
template<class _Ty = int>
result_type() discrete_distribution< _Ty >::min ( ) const
inline
5798  { // return minimum possible generated value
5799  return (0);
5800  }
template<class _Ty = int>
template<class _Engine >
result_type discrete_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
5813  { // return next value
5814  return (_Eval(_Eng, _Par));
5815  }
param_type _Par
Definition: random:5881
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:5858
template<class _Ty = int>
template<class _Engine >
result_type discrete_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
5819  { // return next value, given parameter package
5820  return (_Eval(_Eng, _Par0));
5821  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:5858
template<class _Ty = int>
param_type discrete_distribution< _Ty >::param ( ) const
inline
5788  { // return parameter package
5789  return (_Par);
5790  }
param_type _Par
Definition: random:5881
template<class _Ty = int>
void discrete_distribution< _Ty >::param ( const param_type _Par0)
inline
5793  { // set parameter package
5794  _Par = _Par0;
5795  }
param_type _Par
Definition: random:5881
template<class _Ty = int>
_Myvec discrete_distribution< _Ty >::probabilities ( ) const
inline
5783  { // return scaled probabilities vector
5784  return (_Par.probabilities());
5785  }
_Myvec probabilities() const
Definition: random:5720
param_type _Par
Definition: random:5881
template<class _Ty = int>
void discrete_distribution< _Ty >::reset ( )
inline
5808  { // clear internal state
5809  }

Member Data Documentation

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

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