Instantiations of class template inversive_congruential_engine
model a .
More...
#include <inversive_congruential.hpp>
Public Types | |
typedef IntType | result_type |
Public Member Functions | |
BOOST_STATIC_CONSTANT (bool, has_fixed_range=false) | |
BOOST_STATIC_CONSTANT (result_type, multiplier=a) | |
BOOST_STATIC_CONSTANT (result_type, increment=b) | |
BOOST_STATIC_CONSTANT (result_type, modulus=p) | |
BOOST_STATIC_CONSTANT (IntType, default_seed=1) | |
inversive_congruential_engine () | |
Constructs an inversive_congruential_engine , seeding it with the default seed. More... | |
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR (inversive_congruential_engine, IntType, x0) | |
Constructs an inversive_congruential_engine , seeding it with x0 . More... | |
BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR (inversive_congruential_engine, SeedSeq, seq) | |
Constructs an inversive_congruential_engine , seeding it with values produced by a call to seq.generate() . More... | |
template<class It > | |
inversive_congruential_engine (It &first, It last) | |
Constructs an inversive_congruential_engine , 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 (inversive_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 (inversive_congruential_engine, SeedSeq, seq) | |
Seeds an inversive_congruential_engine using values from a SeedSeq. More... | |
template<class It > | |
void | seed (It &first, It last) |
seeds an inversive_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 output of the generator. 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... | |
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR (os, inversive_congruential_engine, x) | |
Writes the textual representation of the generator to a std::ostream . More... | |
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR (is, inversive_congruential_engine, x) | |
Reads the textual representation of the generator from a std::istream . More... | |
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR (inversive_congruential_engine, x, y) | |
Returns true if the two generators will produce identical sequences of outputs. More... | |
Static Public Member Functions | |
static result_type min | BOOST_PREVENT_MACRO_SUBSTITUTION () |
static result_type max | BOOST_PREVENT_MACRO_SUBSTITUTION () |
Instantiations of class template inversive_congruential_engine
model a .
It uses the inversive congruential algorithm (ICG) described in
"Inversive pseudorandom number generators: concepts, results and links", Peter Hellekalek, In: "Proceedings of the 1995 Winter Simulation Conference", C. Alexopoulos, K. Kang, W.R. Lilegdon, and D. Goldsman (editors), 1995, pp. 255-262. ftp://random.mat.sbg.ac.at/pub/data/wsc95.ps
The output sequence is defined by x(n+1) = (a*inv(x(n)) - b) (mod p), where x(0), a, b, and the prime number p are parameters of the generator. The expression inv(k) denotes the multiplicative inverse of k in the field of integer numbers modulo p, with inv(0) := 0.
The template parameter IntType shall denote a signed integral type large enough to hold p; a, b, and p are the parameters of the generators. The template parameter val is the validation value checked by validation.
The implementation currently uses the Euclidian Algorithm to compute the multiplicative inverse. Therefore, the inversive generators are about 10-20 times slower than the others (see section"performance"). However, the paper talks of only 3x slowdown, so the Euclidian Algorithm is probably not optimal for calculating the multiplicative inverse.
typedef IntType boost::random::inversive_congruential_engine< IntType, a, b, p >::result_type |
|
inline |
Constructs an inversive_congruential_engine
, seeding it with the default seed.
References boost::random::inversive_congruential_engine< IntType, a, b, p >::seed().
|
inline |
Constructs an inversive_congruential_engine
, 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::inversive_congruential_engine< IntType, a, b, p >::seed().
|
inlinestatic |
References boost::asio::b.
|
inlinestatic |
References boost::multiprecision::backends::p.
|
inline |
Constructs an inversive_congruential_engine
, seeding it with x0
.
References boost::random::inversive_congruential_engine< IntType, a, b, p >::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 |
Returns true if the two generators will produce identical sequences of outputs.
References boost::flyweights::x, and boost::polygon::y().
|
inline |
Reads the textual representation of the generator from a std::istream
.
References boost::flyweights::x.
|
inline |
Writes the textual representation of the generator to a std::ostream
.
References boost::flyweights::x.
|
inline |
Constructs an inversive_congruential_engine
, seeding it with values produced by a call to seq.generate()
.
References boost::random::inversive_congruential_engine< IntType, a, b, p >::seed().
|
inline |
Seeds an inversive_congruential_engine
using values from a SeedSeq.
References boost::random::inversive_congruential_engine< IntType, a, b, p >::seed().
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT | ( | bool | , |
has_fixed_range | = false |
||
) |
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT | ( | result_type | , |
multiplier | = a |
||
) |
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT | ( | result_type | , |
increment | = b |
||
) |
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT | ( | result_type | , |
modulus | = p |
||
) |
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT | ( | IntType | , |
default_seed | = 1 |
||
) |
|
inline |
Advances the state of the generator by z
.
|
inline |
Fills a range with random values.
|
inline |
Returns the next output of the generator.
References boost::a, boost::asio::b, and boost::iostreams::grep::invert.
|
inline |
Calls seed(default_seed)
References boost::random::inversive_congruential_engine< IntType, a, b, p >::seed().
Referenced by boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(), boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(), boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(), boost::random::inversive_congruential_engine< IntType, a, b, p >::inversive_congruential_engine(), and boost::random::inversive_congruential_engine< IntType, a, b, p >::seed().
|
inline |
seeds an inversive_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::inversive_congruential_engine< IntType, a, b, p >::seed().