Instantiations of class template linear_congruential_engine model a . More...
#include <linear_congruential.hpp>
Public Types | |
typedef IntType | result_type |
Public Member Functions | |
BOOST_STATIC_CONSTANT (bool, has_fixed_range=false) | |
BOOST_STATIC_CONSTANT (IntType, multiplier=a) | |
BOOST_STATIC_CONSTANT (IntType, increment=c) | |
BOOST_STATIC_CONSTANT (IntType, modulus=m) | |
BOOST_STATIC_CONSTANT (IntType, default_seed=1) | |
BOOST_STATIC_ASSERT (std::numeric_limits< IntType >::is_integer) | |
BOOST_STATIC_ASSERT (m==0||a< m) | |
BOOST_STATIC_ASSERT (m==0||c< m) | |
linear_congruential_engine () | |
Constructs a linear_congruential_engine , using the default seed. More... | |
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR (linear_congruential_engine, IntType, x0) | |
Constructs a linear_congruential_engine , seeding it with x0 . More... | |
BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR (linear_congruential_engine, SeedSeq, seq) | |
Constructs a linear_congruential_engine , seeding it with values produced by a call to seq.generate() . More... | |
template<class It > | |
linear_congruential_engine (It &first, It last) | |
Constructs a linear_congruential_engine and seeds it with values taken from the itrator range [first, last) and adjusts first to point to the element after the last one used. More... | |
void | seed () |
Calls seed(default_seed) More... | |
BOOST_RANDOM_DETAIL_ARITHMETIC_SEED (linear_congruential_engine, IntType, x0) | |
If c mod m is zero and x0 mod m is zero, changes the current value of the generator to 1. More... | |
BOOST_RANDOM_DETAIL_SEED_SEQ_SEED (linear_congruential_engine, SeedSeq, seq) | |
Seeds a linear_congruential_engine using values from a SeedSeq. More... | |
template<class It > | |
void | seed (It &first, It last) |
seeds a linear_congruential_engine with values taken from the itrator range [first, last) and adjusts first to point to the element after the last one used. More... | |
IntType | operator() () |
Returns the next value of the linear_congruential_engine . More... | |
template<class Iter > | |
void | generate (Iter first, Iter last) |
Fills a range with random values. More... | |
void | discard (boost::uintmax_t z) |
Advances the state of the generator by z . More... | |
Static Public Member Functions | |
static result_type min | BOOST_PREVENT_MACRO_SUBSTITUTION () |
Returns the smallest value that the linear_congruential_engine can produce. More... | |
static result_type max | BOOST_PREVENT_MACRO_SUBSTITUTION () |
Returns the largest value that the linear_congruential_engine can produce. More... | |
Friends | |
bool | operator== (const linear_congruential_engine &x, const linear_congruential_engine &y) |
bool | operator!= (const linear_congruential_engine &x, const linear_congruential_engine &y) |
template<class CharT , class Traits > | |
std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &os, const linear_congruential_engine &lcg) |
Writes a linear_congruential_engine to a std::ostream . More... | |
template<class CharT , class Traits > | |
std::basic_istream< CharT, Traits > & | operator>> (std::basic_istream< CharT, Traits > &is, linear_congruential_engine &lcg) |
Reads a linear_congruential_engine from a std::istream . More... | |
Instantiations of class template linear_congruential_engine model a .
Linear congruential pseudo-random number generators are described in:
"Mathematical methods in large-scale computing units", D. H. Lehmer, Proc. 2nd Symposium on Large-Scale Digital Calculating Machines, Harvard University Press, 1951, pp. 141-146
Let x(n) denote the sequence of numbers returned by some pseudo-random number generator. Then for the linear congruential generator, x(n+1) := (a * x(n) + c) mod m. Parameters for the generator are x(0), a, c, m. The template parameter IntType shall denote an integral type. It must be large enough to hold values a, c, and m. The template parameters a and c must be smaller than m.
Note: The quality of the generator crucially depends on the choice of the parameters. User code should use one of the sensibly parameterized generators such as minstd_rand instead.
typedef IntType boost::random::linear_congruential_engine< IntType, a, c, m >::result_type |
|
inline |
Constructs a linear_congruential_engine
, using the default seed.
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
|
inline |
Constructs a linear_congruential_engine
and seeds it with values taken from the itrator range [first, last) and adjusts first to point to the element after the last one used.
If there are not enough elements, throws std::invalid_argument
.
first and last must be input iterators.
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
|
inlinestatic |
Returns the smallest value that the linear_congruential_engine
can produce.
References boost::multiprecision::backends::c.
|
inlinestatic |
Returns the largest value that the linear_congruential_engine
can produce.
|
inline |
Constructs a linear_congruential_engine
, seeding it with x0
.
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
|
inline |
If c mod m is zero and x0 mod m is zero, changes the current value of the generator to 1.
Otherwise, changes it to x0 mod m. If c is zero, distinct seeds in the range [1,m) will leave the generator in distinct states. If c is not zero, the range is [0,m).
References BOOST_ASSERT, boost::numeric::ublas::increment(), boost::accumulators::extract::max, and boost::accumulators::extract::min.
|
inline |
Constructs a linear_congruential_engine
, seeding it with values produced by a call to seq.generate()
.
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
|
inline |
Seeds a linear_congruential_engine
using values from a SeedSeq.
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_ASSERT | ( | std::numeric_limits< IntType >::is_integer | ) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_ASSERT | ( | ) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_ASSERT | ( | ) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_CONSTANT | ( | bool | , |
has_fixed_range | = false |
||
) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_CONSTANT | ( | IntType | , |
multiplier | = a |
||
) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_CONSTANT | ( | IntType | , |
increment | = c |
||
) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_CONSTANT | ( | IntType | , |
modulus | = m |
||
) |
boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_STATIC_CONSTANT | ( | IntType | , |
default_seed | = 1 |
||
) |
|
inline |
Advances the state of the generator by z
.
References boost::a, boost::icl::add(), boost::multiprecision::backends::c, boost::iostreams::grep::invert, and pow().
|
inline |
Fills a range with random values.
|
inline |
Returns the next value of the linear_congruential_engine
.
References boost::a, and boost::multiprecision::backends::c.
|
inline |
Calls seed(default_seed)
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
Referenced by boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(), boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(), boost::random::linear_congruential_engine< IntType, a, c, m >::BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(), boost::random::linear_congruential_engine< IntType, a, c, m >::linear_congruential_engine(), and boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
|
inline |
seeds a linear_congruential_engine
with values taken from the itrator range [first, last) and adjusts first
to point to the element after the last one used.
If there are not enough elements, throws std::invalid_argument
.
first
and last
must be input iterators.
References boost::random::linear_congruential_engine< IntType, a, c, m >::seed().
|
friend |
|
friend |
Writes a linear_congruential_engine
to a std::ostream
.
|
friend |
|
friend |
Reads a linear_congruential_engine
from a std::istream
.