| Home | Libraries | People | FAQ | More

## Class template threefry_engine

boost::compute::threefry_engine — Threefry pseudorandom number generator.

## Synopsis

    // In header: <boost/compute/random/threefry_engine.hpp>

    template<typename T = uint_>
    class threefry_engine {
    public:
      // types
      typedef T result_type;

      // public member functions
      explicit threefry_engine(command_queue &, ulong_ = default_seed);
      threefry_engine(const threefry_engine< T > &);
      threefry_engine< T > & operator=(const threefry_engine< T > &);
      ~threefry_engine();
      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;
    };

## Description

### `threefry_engine` public member functions

1.     explicit threefry_engine(command_queue & queue, ulong_ value = default_seed);

   Creates a new threefry_engine and seeds it with `value`.

2.     threefry_engine(const threefry_engine< T > & other);

   Creates a new threefry_engine object as a copy of `other`.

3.     threefry_engine< T > & operator=(const threefry_engine< T > & other);

   Copies `other` to `*this`.

4.     ~threefry_engine();

   Destroys the threefry_engine object.

5.     void seed(ulong_ value, command_queue & queue);

   Seeds the random number generator with `value`.

   If no seed value is provided, `default_seed` is used.

   Parameters: |
   `value` | seed value for the random-number generator
   `queue` | command queue to perform the operation

6.     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.

7.     template<typename OutputIterator>
         void generate(OutputIterator first, OutputIterator last,
                       command_queue & queue);

   Generates random numbers and stores them to the range [`first`, `last`).

8.     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`).

9.     void discard(size_t z, command_queue & queue);

   Generates `z` random numbers and discards them.

### `threefry_engine` private member functions

1.     void load_program();