| Home | Libraries | People | FAQ | More

## 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;

      // public member functions
      explicit uniform_int_distribution(IntType = 0,
                                        IntType = (std::numeric_limits< IntType >::max)());
      ~uniform_int_distribution();
      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 member functions

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.

3.     result_type a() const;

   Returns the minimum value of the distribution.

4.     result_type b() const;

   Returns the maximum value of the distribution.

5.     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");