![]() |
Home | Libraries | License | Support | People | ALPS Web Site |
alps::buffered_rng_base — abstract base class of a runtime-polymorphic random number generator
// In header: <alps/random/buffered_rng.h> class buffered_rng_base { public: // types typedef uint32_t result_type; // we create random numbers of type uint32_t typedef std::vector< result_type > buffer_type; // construct/copy/destruct buffered_rng_base(std::size_t = 10240); buffered_rng_base(const buffered_rng_base &); ~buffered_rng_base(); // public member functions BOOST_STATIC_CONSTANT(bool, has_fixed_range = false); result_type operator()(); template<typename OutputIterator> OutputIterator generate_n(std::size_t, OutputIterator); void seed(uint32_t); void seed(); void seed(pseudo_des &); void write(std::ostream &) const; void read(std::istream &); void write_all(std::ostream &) const; void read_all(std::istream &); result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const; result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const; // private member functions void fill_buffer(); };
In order to mask the abstraction penalty, the derived generators do not produce single random numbers at each call, but instead a large buffer is filled in a virtual function call, and then numbers from this buffer used when operator() is called.
buffered_rng_base
public
construct/copy/destructbuffered_rng_base(std::size_t b = 10240);the constructor
Parameters: |
|
buffered_rng_base(const buffered_rng_base & gen);
~buffered_rng_base();
buffered_rng_base
public member functionsBOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
result_type operator()();returns the next random number
numbers are taken from the buffer, which is refilled by a call to fill_buffer when it gets empty
template<typename OutputIterator> OutputIterator generate_n(std::size_t n, OutputIterator it);
void seed(uint32_t);seed with an unsigned integer
void seed();seed with the default value
void seed(pseudo_des & inigen);seed with the pseudo_des generator
void write(std::ostream &) const;write the state to a std::ostream
void read(std::istream &);read the state from a std::istream
void write_all(std::ostream & os) const;write the full state (including buffer) to a std::ostream
void read_all(std::istream &);read the full state (including buffer) from a std::istream
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const;
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const;
Copyright © 2006-2008 Brigitte Surer, Matthias Troyer |