Random Number Generator Library --- Miscellaneous Decorators

Introduction

These decorator class templates allow adaptation of the random number generators and distribution functions to concepts found in the C++ Standard Library, in particular the RandomNumberGenerator and the InputIterator concepts. The latter adaptation is useful, because the the basic random number generators do not implement the InputIterator requirements per se, in contrast to the distribution functions.

Synopsis of miscellaneous decorators in header <boost/random.hpp>

namespace boost {
  template<class UniformRandomNumberGenerator, class IntType = long>
  class random_number_generator;
} // namespace boost

Class template random_number_generator

Synopsis

template<class UniformRandomNumberGenerator, class IntType = long>
class random_number_generator
{
public:
  typedef UniformRandomNumberGenerator base_type;
  typedef IntType argument_type;
  typedef IntType result_type;
  random_number_generator(base_type & rng);
  result_type operator()(argument_type n);
};

Description

Instantiations of class template random_number_generator model a RandomNumberGenerator (std:25.2.11 [lib.alg.random.shuffle]). On each invocation, it returns a uniformly distributed integer in the range [0..n).

The template parameter IntType shall denote some integer-like value type.

Note: I consider it unfortunate that the C++ Standard uses the name RandomNumberGenerator for something rather specific.

Members

random_number_generator(base_type & rng)

Effects: Constructs a random_number_generator functor with the given uniform random number generator as the underlying source of random numbers.

result_type operator()(argument_type n)

Returns: The value of uniform_int<base_type>(rng, 0, n-1)().


Valid HTML 4.01 Transitional

Revised 05 December, 2006

Copyright © 2000-2005 Jens Maurer

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)