...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::threefry_engine — Threefry pseudorandom number generator.
// In header: <boost/compute/random/threefry_engine.hpp> template<typename T = uint_> class threefry_engine { public: // types typedef T result_type; // construct/copy/destruct explicit threefry_engine(command_queue &, ulong_ = default_seed); threefry_engine(const threefry_engine< T > &); threefry_engine< T > & operator=(const threefry_engine< T > &); ~threefry_engine(); // public member functions void seed(ulong_, 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 &); // private member functions void load_program(); // public data members static const ulong_ default_seed; };
threefry_engine
public
construct/copy/destructexplicit threefry_engine(command_queue & queue, ulong_ value = default_seed);Creates a new
threefry_engine
and seeds it with value
. threefry_engine(const threefry_engine< T > & other);Creates a new
threefry_engine
object as a copy of other
. threefry_engine< T > & operator=(const threefry_engine< T > & other);Copies
other
to *this
. ~threefry_engine();Destroys the
threefry_engine
object. threefry_engine
public member functionsvoid seed(ulong_ 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.