vigra - UniformIntRandomFunctor< Engine > Class Template Reference

[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| UniformIntRandomFunctor< Engine > Class Template Reference Random Number Generation |

`#include <vigra/random.hxx>`

## Public Types
typedef UInt32 | argument_type
| STL required functor argument type.
typedef UInt32 | result_type
| STL required functor result type.

## Public Member Functions
UInt32 | operator() () const
UInt32 | operator() (UInt32 beyond) const
| UniformIntRandomFunctor (Engine const &generator=Engine::global())
| UniformIntRandomFunctor (UInt32 lower, UInt32 upper, Engine const &generator=Engine::global(), bool useLowBits=true)

## Detailed Description

### template<class Engine = MersenneTwister>
class vigra::UniformIntRandomFunctor< Engine >

Functor to create uniformly distributed integer random numbers.

This functor encapsulates the appropriate functions of the given random number `Engine` (usually `RandomTT800` or `RandomMT19937`) in an STL-compatible interface.

Traits defined:

    FunctorTraits<UniformIntRandomFunctor<Engine> >::isInitializer

and

    FunctorTraits<UniformIntRandomFunctor<Engine> >::isUnaryFunctor

are true (`VigraTrueType`).

## Constructor & Destructor Documentation

UniformIntRandomFunctor | ( | Engine const & | generator = `Engine::global()` | ) |
| explicit

Create functor for uniform random integers in the range [0, 232) using the given engine.

That is, the generated numbers satisfy 0 <= i < 232.

UniformIntRandomFunctor | ( | UInt32 | lower,
|  | UInt32 | upper,
|  | Engine const & | generator = `Engine::global()`,
|  | bool | useLowBits = `true`
| ) |  |

Create functor for uniform random integers in the range [`lower`, `upper`] using the given engine.

That is, the generated numbers satisfy `lower` <= i <= `upper`. useLowBits should be set to `false` when the engine generates random numbers whose low bits are significantly less random than the high bits. This does not apply to `RandomTT800` and `RandomMT19937`, but is necessary for simpler linear congruential generators.

## Member Function Documentation

UInt32 operator() | ( |  | ) | const

Return a random number as specified in the constructor.

UInt32 operator() | ( | UInt32 | beyond | ) | const

Return a uniformly distributed integer random number in the range [0, `beyond`).

That is, 0 <= i < `beyond`. This is a required interface for `std::random_shuffle`. It ignores the limits specified in the constructor and the flag `useLowBits`.

The documentation for this class was generated from the following file:

- vigra/random.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.10.0 (Mon Nov 18 2013)