RandomSource<TGenerator>.Reinitialize Method

Reinitializes this random number generator using the specified initialization options.

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public void Reinitialize(
	 in RandomOptions options
)

Parameters

options  RandomOptions
The RandomOptions describing the seeding profile, seed material, stream identifiers, and other initialization parameters to apply.

Remarks

This method resets the generator's internal state by running the same initialization logic used during construction. It is equivalent to creating a new instance with the same options, but reuses the current object.

  Important

Reinitialize(RandomOptions) is a reseeding/reset operation, not a state-based restart. It does not return the generator to a previously saved state. To restart from an exact prior state, use SaveState(Span<Byte>) or GetState() immediately after creation to capture the state of a newly created generator, and restore it later with LoadState(ReadOnlySpan<Byte>).

Typical use cases:

  • Starting a new random stream with a new seed or spawn key sequence.
  • Resetting an RNG instance inside long-running workflows without allocating a new object.
  • Reproducing the same initialization behavior as the constructor using explicit options.

Any cached or buffered state associated with derived sampling methods (if applicable) is cleared as part of reinitialization.

  Caution

Reinitialize(RandomOptions) may be more expensive than restoring a previously saved state, since it reruns the full initialization procedure. If exact restart behavior is required, prefer SaveState/LoadState.

Exceptions

ArgumentExceptionoptions is not valid or not supported by this generator.

See Also