ALPS Home Libraries License Support People ALPS Web Site

PrevUpHomeNext

Class pseudo_des

alps::pseudo_des — A random number generator using the pseudo-DES algorithm.

Synopsis

// In header: <alps/random/pseudo_des.h>


class pseudo_des {
public:
  // types
  typedef uint32_t result_type;  // type of the random numbers 

  // construct/copy/destruct
  pseudo_des();
  explicit pseudo_des(uint32_t);

  // public member functions
   BOOST_STATIC_CONSTANT(uint32_t, default_seed = 4357);
  result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const;
  result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const;
  void seed(uint32_t = default_seed);
  result_type operator()();
  void operator+=(uint32_t);
  std::ostream & write(std::ostream &) const;
  std::istream & read(std::istream &);
  bool operator==(const pseudo_des &) const;

  // public static functions
  static uint32_t hash(uint32_t, uint32_t);

  // protected static functions
  static uint32_t low_bits(uint32_t);
  static uint32_t high_bits(uint32_t);
  static uint32_t swap_bits(uint32_t);

  // public data members
  static const bool has_fixed_range;  // the range is fixed 
  static const result_type min_value;  // minimum value is 0 
  static const result_type max_value;  // maximum value is 2^32-1 
};

Description

The random number generator follows the BOOST (standard C++) specifications

pseudo_des public construct/copy/destruct

  1. pseudo_des();
    the default constructor
  2. explicit pseudo_des(uint32_t s);
    construct with specified seed

pseudo_des public member functions

  1.  BOOST_STATIC_CONSTANT(uint32_t, default_seed = 4357);
    the default seed is 4357
  2. result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const;
    minim value is 0
  3. result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const;
    maximum value is 2^32-1
  4. void seed(uint32_t s = default_seed);
    seed the generator
  5. result_type operator()();
    get the next value
  6. void operator+=(uint32_t skip);
    skip forward by skip numbers
  7. std::ostream & write(std::ostream & os) const;
    write the state to a std::ostream
  8. std::istream & read(std::istream & is);
    read the state from a std::istream
  9. bool operator==(const pseudo_des & rhs) const;
    check whether the initial seed and current state of two generators is the same

pseudo_des public static functions

  1. static uint32_t hash(uint32_t w0, uint32_t w1);

pseudo_des protected static functions

  1. static uint32_t low_bits(uint32_t d);
  2. static uint32_t high_bits(uint32_t d);
  3. static uint32_t swap_bits(uint32_t d);
Copyright © 2006-2008 Brigitte Surer, Matthias Troyer

PrevUpHomeNext