Mersenne Twister 64Engine Structure
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public struct MersenneTwister64Engine : IBlockEngine<ulong>,
IRandomEngine, IStateful- Implements
- IBlockEngine<UInt64>, IRandomEngine, IStateful
Remarks
The MT19937-64 engine is the 64-bit variant of the Mersenne Twister algorithm, developed by Takuji Nishimura and Makoto Matsumoto. It features a 312 × 64-bit state with a period of 219937 - 1, optimized for 64-bit architectures.
Algorithm Details:
- State size: 19968 bits (312 × 64-bit words + index)
- Period: 219937 - 1
- Equidistribution: 311-dimensionally equidistributed to 64-bit accuracy
- Output function: 64-bit tempering with different constants than MT19937
Differences from MT19937:
MT19937-64 is not a simple extension of the 32-bit MT19937. It uses different state update rules and tempering functions, producing completely different output sequences from the same seed. Both share the same period length but have different equidistribution properties.
Historical Context:
MT19937-64 is the standard implementation for C++11's std::mt19937_64 and is widely used in scientific computing on 64-bit platforms. Like its 32-bit counterpart, it has a large state size (2.5 KB) and does not support modern features like jumping or fast-forward.
Modern Alternatives:
For new applications requiring 64-bit output, consider modern generators like Xoshiro256StarStarEngine or Pcg64Engine which offer comparable quality with smaller state and additional features.
Note: This generator is provided for legacy compatibility and historical reproducibility. It does not support jumping or fast-forward operations.
Reference: Takuji Nishimura and Makoto Matsumoto. "Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator." ACM Trans. Model. Comput. Simul. 1998.
See also: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html
Example
var engine = new MersenneTwister64Engine();
engine.Seed(SeedSequences.SplitMix64(5489));
ulong value = engine.Next();
ulong[] values = new ulong[100];
engine.Fill(values);
// Save and restore state
byte[] state = new byte[engine.StateSize];
engine.SaveState(state);
engine.LoadState(state);Constructors
| Mersenne | Initializes a new MT19937-64 engine. |
Properties
| Bits | Gets the native word size in bits. |
| Block | Gets the number of native words addressable in each block. |
| Name | Gets a human-readable name for this engine. |
| State | Gets the number of bytes required to save/load this engine's state. |
Methods
| Advance | Advances the engine state to the next block (next entropy window). |
| Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType) |
| Fill | Fills the destination span with values from a contiguous range of indices within the current block. |
| Get | Returns the hash code for this instance. (Inherited from ValueType) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Load | Loads the engine's state from the source span in a stable little-endian format. |
| Output | Returns the native word at the specified index within the current block. |
| Save | Saves the engine's state to the destination span in a stable little-endian format. |
| Seed( | Initializes the generator with an array of keys (init_by_array64). |
| Seed( | Initializes the engine state from a seed sequence. |
| Seed( | Initializes the generator with a single seed (init_genrand64). |
| ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType) |