...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::compute::mersenne_twister_engine — Mersenne twister pseudorandom number generator.
// In header: <boost/compute/random/mersenne_twister_engine.hpp> template<typename T> class mersenne_twister_engine { public: // types typedef T result_type; // construct/copy/destruct explicit mersenne_twister_engine(command_queue &, result_type = default_seed); mersenne_twister_engine(const mersenne_twister_engine< T > &); mersenne_twister_engine< T > & operator=(const mersenne_twister_engine< T > &); ~mersenne_twister_engine(); // public member functions void seed(result_type, command_queue &); void seed(command_queue &); template<typename OutputIterator> void generate(OutputIterator, OutputIterator, command_queue &); template<typename OutputIterator, typename Function> void generate(OutputIterator, OutputIterator, Function, command_queue &); void discard(size_t, command_queue &); // public data members static const T default_seed; static const T n; static const T m; };
mersenne_twister_engine
public
construct/copy/destructexplicit mersenne_twister_engine(command_queue & queue, result_type value = default_seed);Creates a new
mersenne_twister_engine
and seeds it with value
. mersenne_twister_engine(const mersenne_twister_engine< T > & other);Creates a new
mersenne_twister_engine
object as a copy of other
. mersenne_twister_engine< T > & operator=(const mersenne_twister_engine< T > & other);Copies
other
to *this
. ~mersenne_twister_engine();Destroys the
mersenne_twister_engine
object. mersenne_twister_engine
public member functionsvoid seed(result_type value, command_queue & queue);
Seeds the random number generator with value
.
If no seed value is provided, default_seed
is used.
Parameters: |
|
void seed(command_queue & queue);This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<typename OutputIterator> void generate(OutputIterator first, OutputIterator last, command_queue & queue);Generates random numbers and stores them to the range [
first
, last
). template<typename OutputIterator, typename Function> void generate(OutputIterator first, OutputIterator last, Function op, command_queue & queue);
Generates random numbers, transforms them with op
, and then stores them to the range [first
, last
).
void discard(size_t z, command_queue & queue);Generates
z
random numbers and discards them.