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
  uniform_int_distribution(IntType = 0, IntType = 1);
  ~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 &);
};

Description

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

// initialize the default random engine
boost::compute::default_random_engine engine(queue);

// setup the uniform distribution to produce integers 0 and 1
boost::compute::uniform_int_distribution<uint_> distribution(0, 1);

// generate the random values and store them to 'vec'
distribution.generate(vec.begin(), vec.end(), engine, queue);

uniform_int_distribution public construct/copy/destruct

  1. uniform_int_distribution(IntType a = 0, IntType b = 1);

    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).


PrevUpHomeNext