Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template subtract_with_carry_01_engine

boost::random::subtract_with_carry_01_engine

Synopsis

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

template<typename RealType, std::size_t w, std::size_t s, std::size_t r> 
class subtract_with_carry_01_engine {
public:
  // types
  typedef RealType result_type;

  // construct/copy/destruct
  subtract_with_carry_01_engine();
  explicit subtract_with_carry_01_engine(boost::uint32_t);
  template<typename SeedSeq> explicit subtract_with_carry_01_engine(SeedSeq &);
  template<typename It> subtract_with_carry_01_engine(It &, It);

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

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

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

  // public data members
  static const bool has_fixed_range;
  static const std::size_t word_size;
  static const std::size_t long_lag;
  static const std::size_t short_lag;
  static const boost::uint32_t default_seed;
};

Description

Instantiations of subtract_with_carry_01_engine model a pseudo-random number generator . The algorithm is described in

"A New Class of Random Number Generators", George Marsaglia and Arif Zaman, Annals of Applied Probability, Volume 1, Number 3 (1991), 462-480.

subtract_with_carry_01_engine public construct/copy/destruct

  1. subtract_with_carry_01_engine();

    Creates a new subtract_with_carry_01_engine using the default seed.

  2. explicit subtract_with_carry_01_engine(boost::uint32_t value);

    Creates a new subtract_with_carry_01_engine and seeds it with value.

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

    Creates a new subtract_with_carry_01_engine and seeds with with values produced by seq.generate().

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

    Creates a new subtract_with_carry_01_engine and seeds it with values from a range. Advances first to point one past the last consumed value. If the range does not contain enough elements to fill the entire state, throws std::invalid_argument.

subtract_with_carry_01_engine public member functions

  1. void seed();

    Seeds the generator with the default seed.

  2. void seed(boost::uint32_t value);

    Seeds the generator with value.

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

    Seeds the generator with values produced by seq.generate().

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

    Seeds the generator with values from a range. Updates first to point one past the last consumed element. If there are not enough elements in the range to fill the entire state, throws std::invalid_argument.

  5. result_type operator()();

    Returns the next value of the generator.

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

    Advances the state of the generator by z.

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

    Fills a range with random values.

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

subtract_with_carry_01_engine friend functions

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

    Writes a subtract_with_carry_01_engine to a std::ostream.

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

    Reads a subtract_with_carry_01_engine from a std::istream.

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

    Returns true if the two generators will produce identical sequences.

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

    Returns true if the two generators will produce different sequences.


PrevUpHomeNext