Drake C++ Documentation
RandomGenerator Class Reference

Detailed Description

Defines Drake's canonical implementation of the UniformRandomBitGenerator C++ concept (as well as a few conventional extras beyond the concept, e.g., seeds).

This uses the 32-bit Mersenne Twister mt19937 by Matsumoto and Nishimura, 1998. For more information, see https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine

#include <drake/common/random.h>

Public Types

using result_type = std::mt19937::result_type

Public Member Functions

 RandomGenerator ()=default
 Creates a generator using the default_seed. More...
 RandomGenerator (result_type seed)
 Creates a generator using given seed. More...
result_type operator() ()
 Generates a pseudo-random value. More...
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 RandomGenerator (const RandomGenerator &)=default
RandomGeneratoroperator= (const RandomGenerator &)=default
 RandomGenerator (RandomGenerator &&)=default
RandomGeneratoroperator= (RandomGenerator &&)=default

Static Public Member Functions

static constexpr result_type min ()
static constexpr result_type max ()

Static Public Attributes

static constexpr result_type default_seed = std::mt19937::default_seed

Member Typedef Documentation

◆ result_type

using result_type = std::mt19937::result_type

Constructor & Destructor Documentation

◆ RandomGenerator() [1/4]

RandomGenerator ( const RandomGenerator )

◆ RandomGenerator() [2/4]

RandomGenerator ( RandomGenerator &&  )

◆ RandomGenerator() [3/4]

RandomGenerator ( )

Creates a generator using the default_seed.

Actual creation of the generator is deferred until first use so this constructor is fast and does not allocate any heap memory.

◆ RandomGenerator() [4/4]

RandomGenerator ( result_type  seed)

Creates a generator using given seed.

Member Function Documentation

◆ max()

static constexpr result_type max ( )

◆ min()

static constexpr result_type min ( )

◆ operator()()

result_type operator() ( )

Generates a pseudo-random value.

◆ operator=() [1/2]

RandomGenerator& operator= ( const RandomGenerator )

◆ operator=() [2/2]

RandomGenerator& operator= ( RandomGenerator &&  )

Member Data Documentation

◆ default_seed

constexpr result_type default_seed = std::mt19937::default_seed

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