Home | Libraries | People | FAQ | More |
boost::random::lagged_fibonacci
// In header: <boost/random/lagged_fibonacci.hpp> template<typename UIntType, int w, unsigned int p, unsigned int q, UIntType val = 0> class lagged_fibonacci { public: // types typedef UIntType result_type; // construct/copy/destruct lagged_fibonacci(); lagged_fibonacci(uint32_t); template<typename It> lagged_fibonacci(It &, It); // public member functions result_type min() const; result_type max() const; void seed(uint32_t = 331u); template<typename It> void seed(It &, It); 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 model a pseudo-random number generator . It uses a lagged Fibonacci algorithm with two lags p
and q:
x(i) = x(i-p) + x(i-q) (mod 2w) with p > q.
lagged_fibonacci
public
construct/copy/destructlagged_fibonacci();
Creates a new lagged_fibonacci
generator and calls seed()
lagged_fibonacci(uint32_t value);
Creates a new lagged_fibonacci
generator and calls seed(value)
template<typename It> lagged_fibonacci(It & first, It last);
Creates a new lagged_fibonacci
generator and calls seed(first, last)
lagged_fibonacci
public member functionsresult_type min() const;
Returns: the smallest value that the generator can produce
result_type max() const;
Returns: the largest value that the generator can produce
void seed(uint32_t value = 331u);
Sets the state of the generator to values produced by a minstd_rand
generator.
template<typename It> void seed(It & first, It last);
Sets the state of the generator to values from the iterator range [first, last). If there are not enough elements in the range [first, last) throws std::invalid_argument
.
result_type operator()();
Returns: the next value of the generator