| Home | Libraries | People | FAQ | More

## Class template shuffle_output

boost::random::shuffle_output

## Synopsis

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

    template<typename UniformRandomNumberGenerator, int k,
             typename UniformRandomNumberGenerator::result_type val = 0>
    class shuffle_output {
    public:
      // types
      typedef UniformRandomNumberGenerator base_type;
      typedef base_type::result_type       result_type;

      // construct/copy/destruct
      shuffle_output();
      template<typename T> shuffle_output(T);
      shuffle_output(const base_type &);
      template<typename It> shuffle_output(It &, It);

      // public member functions
      void seed();
      template<typename T> void seed(T);
      template<typename It> void seed(It &, It);
      const base_type & base() const;
      result_type operator()();
      result_type min() const;
      result_type max() const;

      // public static functions
      static bool validation(result_type);

      // private member functions
      void init();
      static const bool has_fixed_range;
      static const int buffer_size;
    };

## Description

Instatiations of class template shuffle_output model a pseudo-random number generator . It mixes the output of some (usually linear_congruential) uniform random number generator to get better statistical properties. The algorithm is described in

> "Improving a poor random number generator", Carter Bays and S.D. Durham, ACM Transactions on Mathematical Software, Vol 2, No. 1, March 1976, pp. 59-64. http://doi.acm.org/10.1145/355666.355670

The output of the base generator is buffered in an array of length k. Every output X(n) has a second role: It gives an index into the array where X(n+1) will be retrieved. Used array elements are replaced with fresh output from the base generator.

Template parameters are the base generator and the array length k, which should be around 100. The template parameter val is the validation value checked by validation.

### `shuffle_output` public construct/copy/destruct

1.     shuffle_output();

   Constructs a `shuffle_output` generator by invoking the default constructor of the base generator.

   Complexity: Exactly k+1 invocations of the base generator.

2.     template<typename T> shuffle_output(T s);

   Constructs a shuffle_output generator by invoking the one-argument constructor of the base generator with the parameter seed.

   Complexity: Exactly k+1 invocations of the base generator.

3.     shuffle_output(const base_type & rng);

   Constructs a shuffle_output generator by using a copy of the provided generator.

   Precondition: The template argument UniformRandomNumberGenerator shall denote a CopyConstructible type.

   Complexity: Exactly k+1 invocations of the base generator.

4.     template<typename It> shuffle_output(It & first, It last);

### `shuffle_output` public member functions

1.     void seed();

2.     template<typename T> void seed(T s);

   Invokes the one-argument seed method of the base generator with the parameter seed and re-initializes the internal buffer array.

   Complexity: Exactly k+1 invocations of the base generator.

3.     template<typename It> void seed(It & first, It last);

4.     const base_type & base() const;

5.     result_type operator()();

6.     result_type min() const;

7.     result_type max() const;

### `shuffle_output` public static functions

1.     static bool validation(result_type x);

### `shuffle_output` private member functions

1.     void init();