ScalarGenerator64<TEngine> Structure

A generator struct that adapts a 64-bit scalar engine into the IRandomGenerator interface, with uint caching for efficient 32-bit word generation.

Definition

Namespace: Numerics.NET.Random.Generators
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public struct ScalarGenerator64<TEngine> : IRandomGenerator, 
	IStateful
where TEngine : struct, new(), IScalarEngine<ulong>, IStateful
Inheritance
Object  →  ValueType  →  ScalarGenerator64<TEngine>
Implements
IRandomGenerator, IStateful

Type Parameters

TEngine
The engine type, which must be a struct implementing IScalarEngine<T> for UInt64 and IStateful.

Remarks

ScalarGenerator64<TEngine> wraps a scalar 64-bit engine and provides:

Uint Caching:

When NextUInt32() is called, if no cached value exists, the generator calls NextUInt64(), returns the low 32 bits, and caches the high 32 bits for the next call.

State Persistence:

Layer 2 state includes engine state plus the cached uint (4 bytes LE) and cache flag (1 byte).

Constructors

ScalarGenerator64<TEngine> Initializes a new instance of the ScalarGenerator64<TEngine> struct with the specified engine.

Properties

StateSize Gets the number of bytes required to save/load this engine's state.

Methods

EqualsIndicates whether this instance and a specified object are equal.
(Inherited from ValueType)
Fill(Span<Double>) Fills the specified span with random double-precision floating-point numbers.
Fill(Span<Single>) Fills the specified span with random single-precision floating-point numbers.
Fill(Span<UInt32>) Fills the specified span with random 32-bit unsigned integers.
Fill(Span<UInt64>) Fills the specified span with random 64-bit unsigned integers.
GetHashCodeReturns the hash code for this instance.
(Inherited from ValueType)
GetTypeGets the Type of the current instance.
(Inherited from Object)
LoadState Loads the engine's state from the source span in a stable little-endian format.
NextBytes Fills the specified span with random bytes in little-endian order.
NextDouble Generates the next double-precision floating-point number.
NextSingle Generates the next single-precision floating-point number.
NextUInt32 Generates the next 32-bit unsigned integer.
NextUInt64 Generates the next 64-bit unsigned integer.
SaveState Saves the engine's state to the destination span in a stable little-endian format.
ToStringReturns the fully qualified type name of this instance.
(Inherited from ValueType)

See Also