Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class param_type

boost::random::piecewise_linear_distribution::param_type

Synopsis

// In header: <boost/random/piecewise_linear_distribution.hpp>



class param_type {
public:
  // types
  typedef piecewise_linear_distribution distribution_type;

  // construct/copy/destruct
  param_type();
  template<typename IntervalIter, typename WeightIter> 
    param_type(IntervalIter, IntervalIter, WeightIter);
  template<typename T, typename F> 
    param_type(const std::initializer_list< T > &, F);
  template<typename IntervalRange, typename WeightRange> 
    param_type(const IntervalRange &, const WeightRange &);
  template<typename F> param_type(std::size_t, RealType, RealType, F);

  // friend functions
  template<typename CharT, typename Traits> 
    friend std::basic_ostream< CharT, Traits > & 
    operator<<(std::basic_ostream< CharT, Traits > &, const param_type &);
  template<typename CharT, typename Traits> 
    friend std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, const param_type &);
  friend bool operator==(const param_type &, const param_type &);
  friend bool operator!=(const param_type &, const param_type &);

  // public member functions
  std::vector< RealType > intervals() const;
  std::vector< RealType > densities() const;
};

Description

param_type public construct/copy/destruct

  1. param_type();

    Constructs a param_type object, representing a distribution that produces values uniformly distributed in the range [0, 1).

  2. template<typename IntervalIter, typename WeightIter> 
      param_type(IntervalIter intervals_first, IntervalIter intervals_last, 
                 WeightIter weight_first);

    Constructs a param_type object from two iterator ranges containing the interval boundaries and weights at the boundaries. If there are fewer than two boundaries, then this is equivalent to the default constructor and the distribution will produce values uniformly distributed in the range [0, 1).

    The values of the interval boundaries must be strictly increasing, and the number of weights must be the same as the number of interval boundaries. If there are extra weights, they are ignored.

  3. template<typename T, typename F> 
      param_type(const std::initializer_list< T > & il, F f);

    Constructs a param_type object from an initializer_list containing the interval boundaries and a unary function specifying the weights at the boundaries. Each weight is determined by calling the function at the corresponding point.

    If the initializer_list contains fewer than two elements, this is equivalent to the default constructor and the distribution will produce values uniformly distributed in the range [0, 1).

  4. template<typename IntervalRange, typename WeightRange> 
      param_type(const IntervalRange & intervals_arg, 
                 const WeightRange & weights_arg);

    Constructs a param_type object from Boost.Range ranges holding the interval boundaries and the weights at the boundaries. If there are fewer than two interval boundaries, this is equivalent to the default constructor and the distribution will produce values uniformly distributed in the range [0, 1). The number of weights must be equal to the number of interval boundaries.

  5. template<typename F> 
      param_type(std::size_t nw, RealType xmin, RealType xmax, F f);

    Constructs the parameters for a distribution that approximates a function. The range of the distribution is [xmin, xmax). This range is divided into nw equally sized intervals and the weights are found by calling the unary function f on the boundaries of the intervals.

param_type friend functions

  1. template<typename CharT, typename Traits> 
      friend std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > & os, 
                 const param_type & param);

    Writes the parameters to a std::ostream.

  2. template<typename CharT, typename Traits> 
      friend std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & is, 
                 const param_type & param);

    Reads the parameters from a std::istream.

  3. friend bool operator==(const param_type & lhs, const param_type & rhs);

    Returns true if the two sets of parameters are the same.

  4. friend bool operator!=(const param_type & lhs, const param_type & rhs);

    Returns true if the two sets of parameters are different.

param_type public member functions

  1. std::vector< RealType > intervals() const;

    Returns a vector containing the interval boundaries.

  2. std::vector< RealType > densities() const;

    Returns a vector containing the probability densities at all the interval boundaries.


PrevUpHomeNext