Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::random::inversive_congruential_engine< IntType, a, b, p > Class Template Reference

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 ()
 

Detailed Description

template<class IntType, IntType a, IntType b, IntType p>
class boost::random::inversive_congruential_engine< IntType, a, b, p >

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.

Member Typedef Documentation

template<class IntType, IntType a, IntType b, IntType p>
typedef IntType boost::random::inversive_congruential_engine< IntType, a, b, p >::result_type

Constructor & Destructor Documentation

template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::inversive_congruential_engine ( )
inline
template<class IntType, IntType a, IntType b, IntType p>
template<class It >
boost::random::inversive_congruential_engine< IntType, a, b, p >::inversive_congruential_engine ( It &  first,
It  last 
)
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().

Member Function Documentation

template<class IntType, IntType a, IntType b, IntType p>
static result_type min boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_PREVENT_MACRO_SUBSTITUTION ( )
inlinestatic

References boost::asio::b.

template<class IntType, IntType a, IntType b, IntType p>
static result_type max boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_PREVENT_MACRO_SUBSTITUTION ( )
inlinestatic
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR ( inversive_congruential_engine< IntType, a, b, p >  ,
IntType  ,
x0   
)
inline
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_ARITHMETIC_SEED ( inversive_congruential_engine< IntType, a, b, p >  ,
IntType  ,
x0   
)
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.

template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR ( inversive_congruential_engine< IntType, a, b, p >  ,
,
 
)
inline

Returns true if the two generators will produce identical sequences of outputs.

References boost::flyweights::x, and boost::polygon::y().

template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR ( is  ,
inversive_congruential_engine< IntType, a, b, p >  ,
 
)
inline

Reads the textual representation of the generator from a std::istream.

References boost::flyweights::x.

template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR ( os  ,
inversive_congruential_engine< IntType, a, b, p >  ,
 
)
inline

Writes the textual representation of the generator to a std::ostream.

References boost::flyweights::x.

template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR ( inversive_congruential_engine< IntType, a, b, p >  ,
SeedSeq  ,
seq   
)
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().

template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_RANDOM_DETAIL_SEED_SEQ_SEED ( inversive_congruential_engine< IntType, a, b, p >  ,
SeedSeq  ,
seq   
)
inline
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT ( bool  ,
has_fixed_range  = false 
)
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT ( result_type  ,
multiplier  = a 
)
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT ( result_type  ,
increment  = b 
)
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT ( result_type  ,
modulus  = p 
)
template<class IntType, IntType a, IntType b, IntType p>
boost::random::inversive_congruential_engine< IntType, a, b, p >::BOOST_STATIC_CONSTANT ( IntType  ,
default_seed  = 1 
)
template<class IntType, IntType a, IntType b, IntType p>
void boost::random::inversive_congruential_engine< IntType, a, b, p >::discard ( boost::uintmax_t  z)
inline

Advances the state of the generator by z.

template<class IntType, IntType a, IntType b, IntType p>
template<class Iter >
void boost::random::inversive_congruential_engine< IntType, a, b, p >::generate ( Iter  first,
Iter  last 
)
inline

Fills a range with random values.

template<class IntType, IntType a, IntType b, IntType p>
IntType boost::random::inversive_congruential_engine< IntType, a, b, p >::operator() ( )
inline

Returns the next output of the generator.

References boost::a, boost::asio::b, and boost::iostreams::grep::invert.

template<class IntType, IntType a, IntType b, IntType p>
template<class It >
void boost::random::inversive_congruential_engine< IntType, a, b, p >::seed ( It &  first,
It  last 
)
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().


The documentation for this class was generated from the following file: