Counter Based Generator 32<TEngine>.Set Key Method
Sets the key to the specified value.
Definition
Namespace: Numerics.NET.Random.Generators
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public void SetKey(
ReadOnlySpan<uint> key
)Parameters
- key ReadOnlySpan<UInt32>
- 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
| Argument | Thrown when key.Length != KeyLength. |