Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template linear_feedback_shift_engine

boost::random::linear_feedback_shift_engine

Synopsis

// In header: <boost/random/linear_feedback_shift.hpp>

template<typename UIntType, int w, int k, int q, int s> 
class linear_feedback_shift_engine {
public:
  // types
  typedef UIntType result_type;

  // construct/copy/destruct
  linear_feedback_shift_engine();
  explicit linear_feedback_shift_engine(UIntType);
  template<typename SeedSeq> explicit linear_feedback_shift_engine(SeedSeq &);
  template<typename It> linear_feedback_shift_engine(It &, It);

  // public static functions
  static result_type min();
  static result_type max();

  // public member functions
  void seed();
  void seed(UIntType);
  template<typename SeedSeq> void seed(SeedSeq &);
  template<typename It> void seed(It &, It);
  result_type operator()();
  template<typename Iter> void generate(Iter, Iter);
  void discard(boost::uintmax_t);

  // friend functions
  template<typename CharT, typename Traits> 
    friend std::basic_ostream< CharT, Traits > & 
    operator<<(std::basic_ostream< CharT, Traits > &, 
               const linear_feedback_shift_engine &);
  template<typename CharT, typename Traits> 
    friend std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, 
               const linear_feedback_shift_engine &);
  friend bool operator==(const linear_feedback_shift_engine &, 
                         const linear_feedback_shift_engine &);
  friend bool operator!=(const linear_feedback_shift_engine &, 
                         const linear_feedback_shift_engine &);

  // public data members
  static const bool has_fixed_range;
  static const int word_size;
  static const int exponent1;
  static const int exponent2;
  static const int step_size;
  static const UIntType default_seed;
};

Description

Instatiations of linear_feedback_shift model a pseudo-random number generator . It was originally proposed in

"Random numbers generated by linear recurrence modulo two.", Tausworthe, R. C.(1965), Mathematics of Computation 19, 201-209.

linear_feedback_shift_engine public construct/copy/destruct

  1. linear_feedback_shift_engine();

    Constructs a linear_feedback_shift_engine, using the default seed.

  2. explicit linear_feedback_shift_engine(UIntType s0);

    Constructs a linear_feedback_shift_engine, seeding it with s0.

  3. template<typename SeedSeq> 
      explicit linear_feedback_shift_engine(SeedSeq & seq);

    Constructs a linear_feedback_shift_engine, seeding it with seq.

  4. template<typename It> linear_feedback_shift_engine(It & first, It last);

    Constructs a linear_feedback_shift_engine, seeding it with values from the range [first, last).

linear_feedback_shift_engine public static functions

  1. static result_type min();

    Returns the smallest value that the generator can produce.

  2. static result_type max();

    Returns the largest value that the generator can produce.

linear_feedback_shift_engine public member functions

  1. void seed();

    Seeds a linear_feedback_shift_engine with the default seed.

  2. void seed(UIntType s0);

    Seeds a linear_feedback_shift_engine with s0.

  3. template<typename SeedSeq> void seed(SeedSeq & seq);

    Seeds a linear_feedback_shift_engine with values produced by seq.generate().

  4. template<typename It> void seed(It & first, It last);

    Seeds a linear_feedback_shift_engine with values from the range [first, last).

  5. result_type operator()();

    Returns the next value of the generator.

  6. template<typename Iter> void generate(Iter first, Iter last);

    Fills a range with random values

  7. void discard(boost::uintmax_t z);

    Advances the state of the generator by z.

linear_feedback_shift_engine friend functions

  1. template<typename CharT, typename Traits> 
      friend std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > & os, 
                 const linear_feedback_shift_engine & x);

    Writes the textual representation of the generator to a std::ostream.

  2. template<typename CharT, typename Traits> 
      friend std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & is, 
                 const linear_feedback_shift_engine & x);

    Reads the textual representation of the generator from a std::istream.

  3. friend bool operator==(const linear_feedback_shift_engine & x, 
                           const linear_feedback_shift_engine & y);

    Returns true if the two generators will produce identical sequences of outputs.

  4. friend bool operator!=(const linear_feedback_shift_engine & lhs, 
                           const linear_feedback_shift_engine & rhs);

    Returns true if the two generators will produce different sequences of outputs.


PrevUpHomeNext