Class template linear_congruential_engine

| Home | Libraries | People | FAQ | More

## Class template linear_congruential_engine

boost::compute::linear_congruential_engine — 'Quick and Dirty' linear congruential engine

## Synopsis

    // 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;
    };

## Description

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/destruct

1.     explicit linear_congruential_engine(command_queue & queue,
                                           result_type value = default_seed);

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

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

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

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

   Copies `other` to `*this`.

4.     ~linear_congruential_engine();

   Destroys the `linear_congruential_engine` object.

### `linear_congruential_engine` public member functions

1.     void 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:

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

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

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

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

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

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

   Generates `z` random numbers and discards them.