...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::linear_congruential_engine — 'Quick and Dirty' linear congruential engine
// In header: <boost/compute/random/linear_congruential_engine.hpp> template<typename T = uint_> class linear_congruential_engine { public: // types typedef T result_type; // construct/copy/destruct explicit linear_congruential_engine(command_queue &, result_type = default_seed); linear_congruential_engine(const linear_congruential_engine< T > &); linear_congruential_engine< T > & operator=(const linear_congruential_engine< T > &); ~linear_congruential_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 a; static const size_t threads; };
Quick and dirty linear congruential engine to generate low quality random numbers very quickly. For uses in which good quality of random numbers is required(Monte-Carlo Simulations), use other engines like Mersenne Twister instead.
linear_congruential_engine
public
construct/copy/destructexplicit linear_congruential_engine(command_queue & queue, result_type value = default_seed);Creates a new
linear_congruential_engine
and seeds it with value
. linear_congruential_engine(const linear_congruential_engine< T > & other);Creates a new
linear_congruential_engine
object as a copy of other
. linear_congruential_engine< T > & operator=(const linear_congruential_engine< T > & other);Copies
other
to *this
. ~linear_congruential_engine();Destroys the
linear_congruential_engine
object. linear_congruential_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.