Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class rand48

boost::random::rand48

Synopsis

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


class rand48 {
public:
  // types
  typedef boost::uint32_t ;

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

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

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

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

  // public data members
  static const bool has_fixed_range;
};

Description

Class rand48 models a pseudo-random number generator . It uses the linear congruential algorithm with the parameters a = 0x5DEECE66D, c = 0xB, m = 2**48. It delivers identical results to the lrand48() function available on some systems (assuming lcong48 has not been called).

It is only available on systems where uint64_t is provided as an integral type, so that for example static in-class constants and/or enum definitions with large uint64_t numbers work.

rand48 public construct/copy/destruct

  1. ();

    Seeds the generator with the default seed.

  2. (result_type x0);

    Constructs a rand48 generator with x(0) := (x0 << 16) | 0x330e.

  3. template<typename SeedSeq> (SeedSeq & seq);

    Seeds the generator with values produced by seq.generate().

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

    Seeds the generator using values from an iterator range, and updates first to point one past the last value consumed.

rand48 public static functions

  1. constexpr uint32_t ();

    Returns the smallest value that the generator can produce

  2. constexpr uint32_t ();

    Returns the largest value that the generator can produce

rand48 public member functions

  1. void ();

    Seeds the generator with the default seed.

  2. void (result_type x0);

    Changes the current value x(n) of the generator to (x0 << 16) | 0x330e.

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

    Seeds the generator using values from an iterator range, and updates first to point one past the last value consumed.

  4. template<typename SeedSeq> void (SeedSeq & seq);

    Seeds the generator with values produced by seq.generate().

  5. uint32_t ();

    Returns the next value of the generator.

  6. void (boost::uintmax_t z);

    Advances the state of the generator by z.

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

    Fills a range with random values

rand48 friend functions

  1. template<typename CharT, typename Traits> 
      CharT, Traits > & 
      (CharT, Traits > & os, const rand48 & r);

    Writes a rand48 to a std::ostream.

  2. template<typename CharT, typename Traits> 
      CharT, Traits > & 
      (CharT, Traits > & is, rand48 & r);

    Reads a rand48 from a std::istream.

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

    Returns true if the two generators will produce identical sequences of values.

  4. bool (const rand48 & x, const rand48 & y);

    Returns true if the two generators will produce different sequences of values.


PrevUpHomeNext