nn::math::TinyMt Class

Header file: nn/math.h

Syntax

class TinyMt

Description

A random number generator class using TinyMT.

Although Tiny Mersenne Twister (TinyMT) suffers in comparison to the Mersenne Twister, it is still a random number generating algorithm that produces good pseudo-random numbers. Compared to the 2.5 KB of internal state required for the Mersenne Twister, the TinyMT only needs an internal state of 16 bytes.

The parameters for this class (mat1, mat2, tmat) are hard-coded (0x8f7011ee, 0xfc78ff1f, 0x3793fdff).

The random number cycle is 2^127 - 1. Normally, the random number series does not cycle.

Structures

nn::math::TinyMt::State Structure for saving the internal state of random number generation.

Member Functions

Initialization and Finalization
Initialize Performs initialization.
Finalize Performs finalization.
State Saving and Restoration
SaveState Saves the internal state.
RestoreState Restores the internal state.
Random Number Generation
GenerateRandomU32 Generates an unsigned 32-bit random integer.
GenerateRandomU64 Generates an unsigned 64-bit random integer.
GenerateRandomF32 Generates a single, precision floating-point random number.
GenerateRandomF64 Generates a double, precision floating-point random number.
GenerateRandomN Generates a random number that is less than the specified number.
GenerateRandomBytes Generates a series of random bytes.

Revision History

2012/05/11
Initial version.

CONFIDENTIAL