Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template shuffle_order_engine

boost::random::shuffle_order_engine

Synopsis

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

template<typename UniformRandomNumberGenerator,  k> 
class shuffle_order_engine {
public:
  // types
  typedef  ;  
  typedef        ;

  // construct/copy/destruct
  ();
  ();
  template<typename SeedSeq> ();
  ();
  ();
  template<typename It> (, );

  // public member functions
   ();
   ();
  template<typename SeedSeq>  ();
  template<typename It>  (, );
   () ;
   ();
   ();
  template<typename Iter>  (, );

  // public static functions
   ();
   ();

  // friend functions
  template<typename CharT, typename Traits> 
     
    (, 
               shuffle_order_engine &);
  template<typename CharT, typename Traits> 
     
    (, 
               shuffle_order_engine &);
   (shuffle_order_engine &, shuffle_order_engine &);
   (shuffle_order_engine &, shuffle_order_engine &);

  // public data members
  static  has_fixed_range;
  static  buffer_size;
  static  table_size;
};

Description

Instatiations of class template shuffle_order_engine model a pseudo-random number generator . It mixes the output of some (usually linear_congruential_engine) 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.

shuffle_order_engine public construct/copy/destruct

  1. ();

    Constructs a shuffle_order_engine by invoking the default constructor of the base generator.

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

  2. ( s);

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

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

  3. template<typename SeedSeq> ( seq);
  4. ( rng);

    Constructs a shuffle_output_engine 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.

  5. ( rng);
  6. template<typename It> ( first,  last);

shuffle_order_engine public member functions

  1.  ();
  2.  ( seed);

    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 SeedSeq>  ( seq);

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

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

  4. template<typename It>  ( first,  last);
  5.  () ;
  6.  ();
  7.  ( z);

    Advances the generator by z steps.

  8. template<typename Iter>  ( first,  last);

    Fills a range with pseudo-random values.

shuffle_order_engine public static functions

  1.  ();

    Returns the smallest value that the generator can produce.

  2.  ();

    Returns the largest value that the generator can produce.

shuffle_order_engine friend functions

  1. template<typename CharT, typename Traits> 
       
      ( os, 
                 shuffle_order_engine & s);

    Writes a shuffle_order_engine to a std::ostream.

  2. template<typename CharT, typename Traits> 
       
      ( is, 
                 shuffle_order_engine & s);

    Reads a shuffle_order_engine from a std::istream.

  3.  (shuffle_order_engine & x, 
                    shuffle_order_engine & y);

    Returns true if the two generators will produce identical sequences.

  4.  (shuffle_order_engine & lhs, 
                    shuffle_order_engine & rhs);

    Returns true if the two generators will produce different sequences.


PrevUpHomeNext