Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template lagged_fibonacci_01

boost::random::lagged_fibonacci_01

Synopsis

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

template<typename RealType, int w, unsigned int p, unsigned int q> 
class lagged_fibonacci_01 {
public:
  // types
  typedef RealType result_type;

  // construct/copy/destruct
  lagged_fibonacci_01();
  lagged_fibonacci_01(uint32_t);
  template<typename Generator> lagged_fibonacci_01(Generator &);
  template<typename It> lagged_fibonacci_01(It &, It);

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

  // public static functions
  static bool validation(result_type);
  static const bool has_fixed_range;
  static const int word_size;
  static const unsigned int long_lag;
  static const unsigned int short_lag;
};

Description

Instantiations of class template lagged_fibonacci_01 model a pseudo-random number generator . It uses a lagged Fibonacci algorithm with two lags p and q, evaluated in floating-point arithmetic: x(i) = x(i-p) + x(i-q) (mod 1) with p > q. See

"Uniform random number generators for supercomputers", Richard Brent, Proc. of Fifth Australian Supercomputer Conference, Melbourne, Dec. 1992, pp. 704-706.

[Note] Note

The quality of the generator crucially depends on the choice of the parameters. User code should employ one of the sensibly parameterized generators such as lagged_fibonacci607 instead.

The generator requires considerable amounts of memory for the storage of its state array. For example, lagged_fibonacci607 requires about 4856 bytes and lagged_fibonacci44497 requires about 350 KBytes.

lagged_fibonacci_01 public construct/copy/destruct

  1. lagged_fibonacci_01();

    Constructs a lagged_fibonacci_01 generator and calls seed().

  2. lagged_fibonacci_01(uint32_t value);

    Constructs a lagged_fibonacci_01 generator and calls seed(value).

  3. template<typename Generator> lagged_fibonacci_01(Generator & gen);

    Constructs a lagged_fibonacci_01 generator and calls seed(gen).

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

lagged_fibonacci_01 public member functions

  1. void seed();

    Calls seed(331u).

  2. void seed(uint32_t value);

    Constructs a minstd_rand0 generator with the constructor parameter value and calls seed with it. Distinct seeds in the range [1, 2147483647) will produce generators with different states. Other seeds will be equivalent to some seed within this range. See linear_congruential for details.

  3. template<typename Generator> void seed(Generator & gen);

    Sets the state of this lagged_fibonacci_01 to the values returned by p invocations of uniform_01<RealType>()(gen).

    Complexity: Exactly p invocations of gen.

  4. template<typename It> void seed(It & first, It last);
  5. result_type min() const;
  6. result_type max() const;
  7. result_type operator()();

lagged_fibonacci_01 public static functions

  1. static bool validation(result_type x);

PrevUpHomeNext