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

Classes

struct  param_type
 

Public Types

typedef piecewise_linear_distribution< _Ty > _Myt
 
typedef discrete_distribution< size_t_Mybase
 
typedef _Mybase::param_type _Mypbase
 
typedef _Mypbase::_Noinit _Noinit
 
typedef _Ty result_type
 
- Public Types inherited from discrete_distribution< size_t >
typedef discrete_distribution< size_t_Myt
 
typedef vector< double > _Myvec
 
typedef size_t result_type
 

Public Member Functions

 piecewise_linear_distribution ()
 
template<class _InIt1 , class _Init2 >
 piecewise_linear_distribution (_InIt1 _First1, _InIt1 _Last1, _Init2 _First2)
 
template<class _Fn >
 piecewise_linear_distribution (_XSTD initializer_list< _Ty > _Ilist, _Fn _Func)
 
template<class _Fn >
 piecewise_linear_distribution (size_t _Count, _Ty _Low, _Ty _High, _Fn _Func)
 
 piecewise_linear_distribution (const param_type &_Par0)
 
vector< _Ty > intervals () const
 
vector< _Ty > densities () 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
 
template<class _Engine >
result_type _Eval (_Engine &_Eng, const param_type &_Par0) const
 
- Public Member Functions inherited from discrete_distribution< size_t >
 discrete_distribution ()
 
 discrete_distribution (_XSTD initializer_list< double > _Ilist)
 
 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 ()
 
result_type operator() (_Engine &_Eng) const
 
result_type operator() (_Engine &_Eng, const param_type &_Par0) const
 
basic_istream< _Elem, _Traits > & _Read (basic_istream< _Elem, _Traits > &_Istr, param_type &_Par0)
 
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr, const param_type &_Par0) const
 

Public Attributes

param_type _Par
 
- Public Attributes inherited from discrete_distribution< size_t >
param_type _Par
 

Member Typedef Documentation

template<class _Ty = double>
typedef discrete_distribution<size_t> piecewise_linear_distribution< _Ty >::_Mybase
template<class _Ty = double>
typedef _Mybase::param_type piecewise_linear_distribution< _Ty >::_Mypbase
template<class _Ty = double>
typedef piecewise_linear_distribution<_Ty> piecewise_linear_distribution< _Ty >::_Myt
template<class _Ty = double>
typedef _Mypbase::_Noinit piecewise_linear_distribution< _Ty >::_Noinit
template<class _Ty = double>
typedef _Ty piecewise_linear_distribution< _Ty >::result_type

Constructor & Destructor Documentation

template<class _Ty = double>
piecewise_linear_distribution< _Ty >::piecewise_linear_distribution ( )
inline
6294  { // default constructor
6295  }
template<class _Ty = double>
template<class _InIt1 , class _Init2 >
piecewise_linear_distribution< _Ty >::piecewise_linear_distribution ( _InIt1  _First1,
_InIt1  _Last1,
_Init2  _First2 
)
inline
6301  : _Par(_First1, _Last1, _First2)
6302  { // construct from [_First1, _Last1) and [_First2, ...)
6303  }
param_type _Par
Definition: random:6430
template<class _Ty = double>
template<class _Fn >
piecewise_linear_distribution< _Ty >::piecewise_linear_distribution ( _XSTD initializer_list< _Ty >  _Ilist,
_Fn  _Func 
)
inline
6308  : _Par(_Ilist, _Func)
6309  { // construct from _Ilist and function
6310  }
param_type _Par
Definition: random:6430
template<class _Ty = double>
template<class _Fn >
piecewise_linear_distribution< _Ty >::piecewise_linear_distribution ( size_t  _Count,
_Ty  _Low,
_Ty  _High,
_Fn  _Func 
)
inline
6315  : _Par(_Count, _Low, _High, _Func)
6316  { // construct from value range and function
6317  }
param_type _Par
Definition: random:6430
_Diff _Count
Definition: algorithm:1941
template<class _Ty = double>
piecewise_linear_distribution< _Ty >::piecewise_linear_distribution ( const param_type _Par0)
inlineexplicit
6320  : _Par(_Par0)
6321  { // construct from parameter package
6322  }
param_type _Par
Definition: random:6430

Member Function Documentation

template<class _Ty = double>
template<class _Engine >
result_type piecewise_linear_distribution< _Ty >::_Eval ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
6411  { // return next value
6412  size_t _Px = (*(_Mybase *)this)(_Eng, _Par0);
6413  double _P0 = _Par0._Pvec[_Px];
6414  double _P1 = _Par0._Pvec[_Px + 1];
6415  double _Sum = _P0 + _P1;
6416 
6417  if (_Sum <= 0.0)
6418  return (_Par0._Bvec[_Px + 1]);
6419  else
6420  { // distribute result between (Bx, Px) and (Bx+1, Px+1)
6421  uniform_real<_Ty> _Dist;
6422  result_type _X0 = _Dist(_Eng);
6423 
6424  _X0 = ((_P1 - _P0) * _X0 + (_P0 + _P0)) * _X0 / _Sum;
6425  return (_Par0._Bvec[_Px]
6426  + _X0 * (_Par0._Bvec[_Px + 1] - _Par0._Bvec[_Px]));
6427  }
6428  }
Definition: random:3520
_Ty result_type
Definition: random:6163
discrete_distribution< size_t > _Mybase
Definition: random:6160
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& piecewise_linear_distribution< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr,
param_type _Par0 
)
inline
6375  { // read state from _Istr
6376  size_t _Nvals;
6377  _Istr >> _Nvals;
6378  _Par0._Pvec.clear();
6379  for (; 0 < _Nvals; --_Nvals)
6380  { // get a value and add to vector
6381  double _Val;
6382  _In(_Istr, _Val);
6383  _Par0._Pvec.push_back(_Val);
6384  }
6385  _Par0._Init(false); // don't renormalize, just compute CDF
6386 
6387  _Par._Bvec.clear();
6388  for (size_t _Idx = _Par._Pvec.size(); 0 < _Idx; --_Idx)
6389  { // get a value and add to intervals vector
6390  double _Val;
6391  _In(_Istr, _Val);
6392  _Par._Bvec.push_back(_Val);
6393  }
6394  return (_Istr);
6395  }
vector< _Ty > _Bvec
Definition: random:6290
void __CLR_OR_THIS_CALL clear(iostate _State=goodbit, bool _Reraise=false)
Definition: ios:42
void clear() _NOEXCEPT
Definition: vector:1506
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:151
void push_back(value_type &&_Val)
Definition: vector:864
param_type _Par
Definition: random:6430
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<class _Ty = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& piecewise_linear_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
6401  { // write state to _Ostr
6402  _Mybase::_Write(_Ostr, _Par);
6403 
6404  for (size_t _Idx = 0; _Idx < _Par._Bvec.size(); ++_Idx)
6405  _Out(_Ostr, _Par._Bvec[_Idx]);
6406  return (_Ostr);
6407  }
vector< _Ty > _Bvec
Definition: random:6290
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:169
size_type size() const _NOEXCEPT
Definition: vector:1146
param_type _Par
Definition: random:6430
basic_ostream< _Elem, _Traits > & _Write(basic_ostream< _Elem, _Traits > &_Ostr, const param_type &_Par0) const
Definition: random:5844
template<class _Ty = double>
vector<_Ty> piecewise_linear_distribution< _Ty >::densities ( ) const
inline
6330  { // return densities vector
6331  return (_Par.densities());
6332  }
param_type _Par
Definition: random:6430
vector< _Ty > densities() const
Definition: random:6249
template<class _Ty = double>
vector<_Ty> piecewise_linear_distribution< _Ty >::intervals ( ) const
inline
6325  { // return intervals vector
6326  return (_Par.intervals());
6327  }
param_type _Par
Definition: random:6430
vector< _Ty > intervals() const
Definition: random:6244
template<class _Ty = double>
result_type() piecewise_linear_distribution< _Ty >::max ( ) const
inline
6350  { // return maximum possible generated value
6351  return (_Par._Bvec.back());
6352  }
vector< _Ty > _Bvec
Definition: random:6290
reference back()
Definition: vector:1232
param_type _Par
Definition: random:6430
template<class _Ty = double>
result_type() piecewise_linear_distribution< _Ty >::min ( ) const
inline
6345  { // return minimum possible generated value
6346  return (_Par._Bvec.front());
6347  }
vector< _Ty > _Bvec
Definition: random:6290
reference front()
Definition: vector:1222
param_type _Par
Definition: random:6430
template<class _Ty = double>
template<class _Engine >
result_type piecewise_linear_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
6360  { // return next value
6361  return (_Eval(_Eng, _Par));
6362  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:6410
param_type _Par
Definition: random:6430
template<class _Ty = double>
template<class _Engine >
result_type piecewise_linear_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
6366  { // return next value, given parameter package
6367  return (_Eval(_Eng, _Par0));
6368  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:6410
template<class _Ty = double>
param_type piecewise_linear_distribution< _Ty >::param ( ) const
inline
6335  { // return parameter package
6336  return (_Par);
6337  }
param_type _Par
Definition: random:6430
template<class _Ty = double>
void piecewise_linear_distribution< _Ty >::param ( const param_type _Par0)
inline
6340  { // set parameter package
6341  _Par = _Par0;
6342  }
param_type _Par
Definition: random:6430
template<class _Ty = double>
void piecewise_linear_distribution< _Ty >::reset ( )
inline
6355  { // clear internal state
6356  }

Member Data Documentation

template<class _Ty = double>
param_type piecewise_linear_distribution< _Ty >::_Par

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