![]() |
Home | Libraries | People | FAQ | More |
boost::random::additive_combine_engine
// In header: <boost/random/additive_combine.hpp> template<typename MLCG1, typename MLCG2> class additive_combine_engine { public: // types typedef MLCG1 first_base; typedef MLCG2 second_base; typedef MLCG1::result_type result_type; // construct/copy/destruct additive_combine_engine(); additive_combine_engine(typename MLCG1::result_type, typename MLCG2::result_type); template<typename It> additive_combine_engine(It &, It); // public member functions BOOST_STATIC_CONSTANT(bool, has_fixed_range = false); BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(additive_combine_engine, result_type, seed_arg); BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(additive_combine_engine, SeedSeq, seq); void seed(); BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(additive_combine_engine, result_type, seed_arg); BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(additive_combine_engine, SeedSeq, seq); void seed(typename MLCG1::result_type, typename MLCG2::result_type); template<typename It> void seed(It &, It); result_type operator()(); template<typename Iter> void generate(Iter, Iter); void discard(boost::uintmax_t); BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, additive_combine_engine, r); BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, additive_combine_engine, r); BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(additive_combine_engine, x, y); // public static functions static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION(); static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION(); // public data members BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(additive_combine_engine) private MLCG2 _mlcg2; };
An instantiation of class template additive_combine_engine
models a pseudo-random number generator . It combines two multiplicative linear_congruential_engine number generators, i.e. those with c
= 0. It is described in
"Efficient and Portable Combined Random Number Generators", Pierre L'Ecuyer, Communications of the ACM, Vol. 31, No. 6, June 1988, pp. 742-749, 774
The template parameters MLCG1 and MLCG2 shall denote two different linear_congruential_engine number generators, each with c = 0. Each invocation returns a random number X(n) := (MLCG1(n) - MLCG2(n)) mod (m1 - 1), where m1 denotes the modulus of MLCG1.
additive_combine_engine
public
construct/copy/destructadditive_combine_engine();
Constructs an
using the default constructors of the two base generators. additive_combine_engine
additive_combine_engine(typename MLCG1::result_type seed1, typename MLCG2::result_type seed2);
Constructs an
, using additive_combine_engine
seed1
and seed2
as the constructor argument to the first and second base generators, respectively.
template<typename It> additive_combine_engine(It & first, It last);
Contructs an
with values from the range defined by the input iterators first and last. first will be modified to point to the element after the last one used.additive_combine_engine
Throws: std::invalid_argument
if the input range is too small.
Exception Safety: Basic
additive_combine_engine
public member functionsBOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(additive_combine_engine, result_type, seed_arg);
Constructs an
, using seed as the constructor argument for both base generators. additive_combine_engine
BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(additive_combine_engine, SeedSeq, seq);
Constructs an
, using seq as the constructor argument for both base generators.additive_combine_engine
![]() |
Warning |
---|---|
The semantics of this function are liable to change. A |
void seed();
Seeds an
using the default seeds of the two base generators. additive_combine_engine
BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(additive_combine_engine, result_type, seed_arg);
Seeds an
, using additive_combine_engine
seed
as the seed for both base generators.
BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(additive_combine_engine, SeedSeq, seq);
Seeds an
, using additive_combine_engine
seq
to seed both base generators.
See the warning on the corresponding constructor.
void seed(typename MLCG1::result_type seed1, typename MLCG2::result_type seed2);
Seeds an additive_combine
generator, using seed1
and seed2
as the seeds to the first and second base generators, respectively.
template<typename It> void seed(It & first, It last);
Seeds an
with values from the range defined by the input iterators first and last. first will be modified to point to the element after the last one used.additive_combine_engine
Throws: std::invalid_argument
if the input range is too small.
Exception Safety: Basic
result_type operator()();
Returns the next value of the generator.
template<typename Iter> void generate(Iter first, Iter last);
Fills a range with random values
void discard(boost::uintmax_t z);
Advances the state of the generator by z
.
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, additive_combine_engine, r);
Writes the state of an
to a additive_combine_engine
std::ostream
. The textual representation of an
is the textual representation of the first base generator followed by the textual representation of the second base generator. additive_combine_engine
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, additive_combine_engine, r);
Reads the state of an
from a additive_combine_engine
std::istream
.
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(additive_combine_engine, x, y);
Returns: true iff the two additive_combine_engines
will produce the same sequence of values.
additive_combine_engine
public
public data membersBOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(additive_combine_engine) private MLCG2 _mlcg2;
Returns: true iff the two additive_combine_engines
will produce different sequences of values.