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

      // public member functions
      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();
      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 member functions

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.

5.     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: |
   `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.