...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::random::lagged_fibonacci_01
// 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; };
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 | |
---|---|
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/destructlagged_fibonacci_01();
Constructs a lagged_fibonacci_01
generator and calls seed()
.
lagged_fibonacci_01(uint32_t value);
Constructs a lagged_fibonacci_01
generator and calls seed(value)
.
template<typename Generator> lagged_fibonacci_01(Generator & gen);
Constructs a lagged_fibonacci_01
generator and calls seed(gen)
.
template<typename It> lagged_fibonacci_01(It & first, It last);
lagged_fibonacci_01
public member functionsvoid seed();
Calls seed(331u).
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.
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.
template<typename It> void seed(It & first, It last);
result_type min() const;
result_type max() const;
result_type operator()();