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

Click here to view the latest version of this page.
PrevUpHomeNext

Class template lagged_fibonacci_engine

boost::random::lagged_fibonacci_engine

Synopsis

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

template<typename UIntType, int w, unsigned int p, unsigned int q> 
class lagged_fibonacci_engine {
public:
  // types
  typedef UIntType result_type;

  // construct/copy/destruct
  lagged_fibonacci_engine();
  explicit lagged_fibonacci_engine(UIntType);
  template<typename SeedSeq> explicit lagged_fibonacci_engine(SeedSeq &);
  template<typename It> lagged_fibonacci_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 lagged_fibonacci_engine &);
  template<typename CharT, typename Traits> 
    friend std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, 
               const lagged_fibonacci_engine &);
  friend bool operator==(const lagged_fibonacci_engine &, 
                         const lagged_fibonacci_engine &);
  friend bool operator!=(const lagged_fibonacci_engine &, 
                         const lagged_fibonacci_engine &);

  // public data members
  static const bool has_fixed_range;
  static const int word_size;
  static const unsigned int long_lag;
  static const unsigned int short_lag;
  static const UIntType default_seed;
};

Description

Instantiations of class template lagged_fibonacci_engine model a pseudo-random number generator . It uses a lagged Fibonacci algorithm with two lags p and q: x(i) = x(i-p) + x(i-q) (mod 2w) with p > q.

lagged_fibonacci_engine public construct/copy/destruct

  1. lagged_fibonacci_engine();

    Creates a new lagged_fibonacci_engine and calls seed().

  2. explicit lagged_fibonacci_engine(UIntType value);

    Creates a new lagged_fibonacci_engine and calls seed(value).

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

    Creates a new lagged_fibonacci_engine and calls seed(seq).

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

    Creates a new lagged_fibonacci_engine and calls seed(first, last).

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

lagged_fibonacci_engine public member functions

  1. void seed();

    Calls seed(default_seed).

  2. void seed(UIntType value);

    Sets the state of the generator to values produced by a minstd_rand0 generator.

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

    Sets the state of the generator using values produced by seq.

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

    Sets the state of the generator to values from the iterator range [first, last). If there are not enough elements in the range [first, last) throws std::invalid_argument.

  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.

lagged_fibonacci_engine friend functions

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

    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 lagged_fibonacci_engine & f);

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

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

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

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

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


PrevUpHomeNext