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 template uniform_int_distribution

boost::compute::uniform_int_distribution — Produces uniformily distributed random integers.

Synopsis

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

template<typename IntType = uint_> 
class uniform_int_distribution {
public:
  // types
  typedef IntType result_type;

  // construct/copy/destruct
  explicit uniform_int_distribution(IntType = 0, 
                                    IntType = (std::numeric_limits< IntType >::max)());
  ~uniform_int_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_integral< IntType >::value, 
                           "Template argument must be integral");
};

Description

The following example shows how to setup a uniform int distribution to produce random integers 0 and 1.


uniform_int_distribution public construct/copy/destruct

  1. explicit uniform_int_distribution(IntType a = 0, 
                                      IntType b = (std::numeric_limits< IntType >::max)());

    Creates a new uniform distribution producing numbers in the range [a, b].

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

uniform_int_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 uniformily distributed integers and stores them to the range [first, last).

uniform_int_distribution private member functions

  1.  BOOST_STATIC_ASSERT_MSG(boost::is_integral< IntType >::value, 
                             "Template argument must be integral");

PrevUpHomeNext