Philox4x64Engine.SetKey Method

Sets the key to the specified value.

Definition

Namespace: Numerics.NET.Random.Engines
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public void SetKey(
	ReadOnlySpan<ulong> key
)

Parameters

key  ReadOnlySpan<UInt64>
The new key value. Length must exactly match KeyLength.

Implements

ICounterBased<T>.SetKey(ReadOnlySpan<T>)

Remarks

Setting the key changes the parameterization of the generator. The same counter value with different keys produces different output blocks.

Consistency Protocol:

After calling SetKey(ReadOnlySpan<T>), the engine enters an inconsistent state where the cached block does not correspond to the current key/counter coordinates. Callers must invoke GenerateBlock() before using any output mapping methods (Output(Int32) or Fill(Int32, Span<T>)). Invoking output methods while inconsistent results in undefined behavior.

Exceptions

ArgumentException Thrown when key.Length != KeyLength.

See Also