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_real_distribution

boost::compute::uniform_real_distribution — Produces uniformly distributed random floating-point numbers.

Synopsis

// In header: <boost/compute/random/uniform_real_distribution.hpp>

template<typename RealType = float> 
class uniform_real_distribution {
public:
  // types
  typedef RealType result_type;

  // construct/copy/destruct
  uniform_real_distribution(RealType = 0.f, RealType = 1.f);
  ~uniform_real_distribution();

  // public member functions
  result_type a() const;
  result_type b() const;
  template<typename OutputIterator, typename Generator> 
    void generate(OutputIterator, OutputIterator, Generator &, 
                  command_queue &);

  // private member functions
   BOOST_STATIC_ASSERT_MSG(boost::is_floating_point< RealType >::value, 
                           "Template argument must be a floating point type");
};

Description

The following example shows how to setup a uniform real distribution to produce random float values between 1 and 100.


See Also:

default_random_engine, normal_distribution

uniform_real_distribution public construct/copy/destruct

  1. uniform_real_distribution(RealType a = 0.f, RealType b = 1.f);

    Creates a new uniform distribution producing numbers in the range [a, b). Requires a < b

  2. ~uniform_real_distribution();
    Destroys the uniform_real_distribution object.

uniform_real_distribution public member functions

  1. result_type a() const;
    Returns the minimum value of the distribution.
  2. result_type b() const;
    Returns the maximum value of the distribution.
  3. template<typename OutputIterator, typename Generator> 
      void generate(OutputIterator first, OutputIterator last, 
                    Generator & generator, command_queue & queue);

    Generates uniformly distributed floating-point numbers and stores them to the range [first, last).

uniform_real_distribution private member functions

  1.  BOOST_STATIC_ASSERT_MSG(boost::is_floating_point< RealType >::value, 
                             "Template argument must be a floating point type");

PrevUpHomeNext