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 to view this page for the latest version.
PrevUpHomeNext

Class template uniform_on_sphere

boost::random::uniform_on_sphere

Synopsis

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

template<typename RealType = double, typename Cont = std::vector<RealType> > 
class uniform_on_sphere {
public:
  // types
  typedef RealType input_type; 
  typedef Cont     result_type;

  // member classes/structs/unions

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

    // construct/copy/destruct
    explicit param_type(int = 2);

    // public member functions
    int dim() const;

    // 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 &);
  };

  // construct/copy/destruct
  explicit uniform_on_sphere(int = 2);
  explicit uniform_on_sphere(const param_type &);

  // public member functions
  int dim() const;
  param_type param() const;
  void param(const param_type &);
  result_type min() const;
  result_type max() const;
  void reset();
  template<typename Engine> const result_type & operator()(Engine &);
  template<typename Engine> 
    result_type operator()(Engine &, const param_type &) const;

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

Description

Instantiations of class template uniform_on_sphere model a random distribution . Such a distribution produces random numbers uniformly distributed on the unit sphere of arbitrary dimension dim. The Cont template parameter must be a STL-like container type with begin and end operations returning non-const ForwardIterators of type Cont::iterator.

uniform_on_sphere public construct/copy/destruct

  1. explicit uniform_on_sphere(int dim = 2);

    Constructs a uniform_on_sphere distribution. dim is the dimension of the sphere.

    Requires: dim >= 0

  2. explicit uniform_on_sphere(const param_type & param);

    Constructs a uniform_on_sphere distribution from its parameters.

uniform_on_sphere public member functions

  1. int dim() const;

    Returns the dimension of the sphere.

  2. param_type param() const;

    Returns the parameters of the distribution.

  3. void param(const param_type & param);

    Sets the parameters of the distribution.

  4. result_type min() const;

    Returns the smallest value that the distribution can produce. Note that this is required to approximate the standard library's requirements. The behavior is defined according to lexicographical comparison so that for a container type of std::vector, dist.min() <= x <= dist.max() where x is any value produced by the distribution.

  5. result_type max() const;

    Returns the largest value that the distribution can produce. Note that this is required to approximate the standard library's requirements. The behavior is defined according to lexicographical comparison so that for a container type of std::vector, dist.min() <= x <= dist.max() where x is any value produced by the distribution.

  6. void reset();

    Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset.

  7. template<typename Engine> const result_type & operator()(Engine & eng);

    Returns a point uniformly distributed over the surface of a sphere of dimension dim().

  8. template<typename Engine> 
      result_type operator()(Engine & eng, const param_type & param) const;

    Returns a point uniformly distributed over the surface of a sphere of dimension param.dim().

uniform_on_sphere friend functions

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

    Writes the distribution to a std::ostream.

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

    Reads the distribution from a std::istream.

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

    Returns true if the two distributions will produce identical sequences of values, given equal generators.

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

    Returns true if the two distributions may produce different sequences of values, given equal generators.


PrevUpHomeNext