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 UniformRandomNumberGenerator ;  
  typedef base_type::result_type       ;

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

  // public member functions
  void ();
  void (result_type);
  template<typename SeedSeq> void (SeedSeq &);
  template<typename It> void (It &, It);
  const base_type & () ;
  result_type ();
  void (boost::uintmax_t);
  template<typename Iter> void (Iter, Iter);

  // public static functions
  constexpr result_type ();
  constexpr result_type ();

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

  // public data members
  static const bool has_fixed_range;
  static const  buffer_size;
  static const  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. (result_type 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> (SeedSeq & seq);
  4. (const base_type & 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. (base_type && rng);
  6. template<typename It> (It & first, It last);

shuffle_order_engine public member functions

  1. void ();
  2. void (result_type 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> void (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> void (It & first, It last);
  5. const base_type & () ;
  6. result_type ();
  7. void (boost::uintmax_t z);

    Advances the generator by z steps.

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

    Fills a range with pseudo-random values.

shuffle_order_engine public static functions

  1. constexpr result_type ();

    Returns the smallest value that the generator can produce.

  2. constexpr result_type ();

    Returns the largest value that the generator can produce.

shuffle_order_engine friend functions

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

    Writes a shuffle_order_engine to a std::ostream.

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

    Reads a shuffle_order_engine from a std::istream.

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

    Returns true if the two generators will produce identical sequences.

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

    Returns true if the two generators will produce different sequences.


PrevUpHomeNext