Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template subtract_with_carry_engine

boost::random::subtract_with_carry_engine

Synopsis

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

template<typename IntType,  w,  s,  r> 
class subtract_with_carry_engine {
public:
  // types
  typedef IntType ;

  // construct/copy/destruct
  ();
  (IntType);
  template<typename SeedSeq> (SeedSeq &);
  template<typename It> (It &, It);

  // public member functions
  void ();
  void (IntType);
  template<typename SeedSeq> void (SeedSeq &);
  template<typename It> void (It &, It);
   ();
  void (boost::uintmax_t);
  template<typename It> void (It, It);

  // public static functions
  constexpr  ();
  constexpr  ();

  // friend functions
  template<typename CharT, typename Traits> 
    CharT, Traits > & 
    (CharT, Traits > &, 
               const subtract_with_carry_engine &);
  template<typename CharT, typename Traits> 
    CharT, Traits > & 
    (CharT, Traits > &, 
               const subtract_with_carry_engine &);
  bool (const subtract_with_carry_engine &, 
                  const subtract_with_carry_engine &);
  bool (const subtract_with_carry_engine &, 
                  const subtract_with_carry_engine &);

  // public data members
  static const  word_size;
  static const  long_lag;
  static const  short_lag;
  static const uint32_t default_seed;
  static const bool has_fixed_range;
  static const  modulus;
};

Description

Instantiations of subtract_with_carry_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_engine public construct/copy/destruct

  1. ();

    Constructs a new subtract_with_carry_engine and seeds it with the default seed.

  2. (IntType value);

    Constructs a new subtract_with_carry_engine and seeds it with value.

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

    Constructs a new subtract_with_carry_engine and seeds it with values produced by seq.generate().

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

    Constructs a new subtract_with_carry_engine and seeds it with values from a range. first is updated to point one past the last value consumed. If there are not enough elements in the range to fill the entire state of the generator, throws std::invalid_argument.

subtract_with_carry_engine public member functions

  1. void ();

    Seeds the generator with the default seed.

  2. void (IntType value);
  3. template<typename SeedSeq> void (SeedSeq & seq);

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

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

    Seeds the generator with values from a range. Updates first to point one past the last consumed value. If the range does not contain enough elements to fill the entire state of the generator, throws std::invalid_argument.

  5.  ();

    Returns the next value of the generator.

  6. void (boost::uintmax_t z);

    Advances the state of the generator by z.

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

    Fills a range with random values.

subtract_with_carry_engine public static functions

  1. constexpr  ();

    Returns the smallest value that the generator can produce.

  2. constexpr  ();

    Returns the largest value that the generator can produce.

subtract_with_carry_engine friend functions

  1. template<typename CharT, typename Traits> 
      CharT, Traits > & 
      (CharT, Traits > & os, 
                 const subtract_with_carry_engine & f);

    Writes a subtract_with_carry_engine to a std::ostream.

  2. template<typename CharT, typename Traits> 
      CharT, Traits > & 
      (CharT, Traits > & is, 
                 const subtract_with_carry_engine & f);

    Reads a subtract_with_carry_engine from a std::istream.

  3. bool (const subtract_with_carry_engine & x, 
                    const subtract_with_carry_engine & y);

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

  4. bool (const subtract_with_carry_engine & lhs, 
                    const subtract_with_carry_engine & rhs);

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


PrevUpHomeNext