RandomSource<TGenerator> Constructor

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0

Overload List

RandomSource<TGenerator>() Constructs a new instance of the random number generator using a high-entropy, automatically generated seed.
RandomSource<TGenerator>(TGenerator) Constructs a new random number generator from a pre-initialized generator.
RandomSource<TGenerator>(RandomOptions) Constructs a new random number generator with advanced options.
RandomSource<TGenerator>(ReadOnlySpan<Byte>) Constructs a new random number generator from saved state.
RandomSource<TGenerator>(Int64, StreamAddress, SeedProfile) Constructs a new random number generator with the specified seed.
RandomSource<TGenerator>(ReadOnlySpan<UInt32>, StreamAddress, SeedProfile) Constructs a new random number generator with a seed array.
RandomSource<TGenerator>(ReadOnlySpan<UInt64>, StreamAddress, SeedProfile) Constructs a new random number generator with a seed array.

RandomSource<TGenerator>

Constructs a new instance of the random number generator using a high-entropy, automatically generated seed.
C#
protected RandomSource()

Remarks

This constructor uses the Independent seed profile. It provides a convenient way to create a unique, statistically sound random source without requiring manual seed management.

For large-scale parallel simulations requiring a high degree of coordination between many streams, consider using the explicit streaming methods provided by RandomStreamTree<TRandom> or RandomStreamPartition<TRandom>.

RandomSource<TGenerator>(TGenerator)

Constructs a new random number generator from a pre-initialized generator.
C#
protected RandomSource(
	 in TGenerator generator
)

Parameters

generator  TGenerator
The pre-initialized generator to use.

Remarks

This constructor bypasses normal initialization and directly uses the provided generator. Use this for constructors that call engine Seed methods directly.

RandomSource<TGenerator>(RandomOptions)

Constructs a new random number generator with advanced options.
C#
protected RandomSource(
	 in RandomOptions options
)

Parameters

options  RandomOptions
The initialization options containing seed, stream ID, and seed profile.

Remarks

This constructor validates the options and calls Initialize(RandomOptions, TGenerator) to configure the generator.

RandomSource<TGenerator>(ReadOnlySpan<Byte>)

Constructs a new random number generator from saved state.
C#
protected RandomSource(
	ReadOnlySpan<byte> state
)

Parameters

state  ReadOnlySpan<Byte>
The saved state to restore.

Remarks

This constructor bypasses normal initialization and directly loads the state. Use this for exact continuation from a previously saved state.

RandomSource<TGenerator>(Int64, StreamAddress, SeedProfile)

Constructs a new random number generator with the specified seed.
C#
protected RandomSource(
	long seed,
	StreamAddress streamAddress,
	SeedProfile seedProfile
)

Parameters

seed  Int64
The initial seed of the generator.
streamAddress  StreamAddress
Optional stream identifier for stream selection (default: empty).
seedProfile  SeedProfile
The seed profile (default: Default).

Remarks

This constructor validates inputs and calls Initialize(RandomOptions, TGenerator) to configure the generator according to the specified seed profile.

Exceptions

ArgumentOutOfRangeExceptionseedProfile is not a valid SeedProfile value.

RandomSource<TGenerator>(ReadOnlySpan<UInt32>, StreamAddress, SeedProfile)

Constructs a new random number generator with a seed array.
C#
protected RandomSource(
	ReadOnlySpan<uint> seed,
	StreamAddress streamAddress,
	SeedProfile seedProfile
)

Parameters

seed  ReadOnlySpan<UInt32>
The seed array values.
streamAddress  StreamAddress
Optional stream identifier for stream selection (default: null).
seedProfile  SeedProfile
The seed profile (default: Default).

Remarks

This constructor validates inputs and calls Initialize(RandomOptions, TGenerator) to configure the generator according to the specified seed profile.

Note: ToArray() is necessary here because RandomOptions requires array input for immutability. The span is copied into an array that RandomOptions then stores internally.

Exceptions

ArgumentNullExceptionseed is null.
ArgumentOutOfRangeExceptionseedProfile is not a valid SeedProfile value.

RandomSource<TGenerator>(ReadOnlySpan<UInt64>, StreamAddress, SeedProfile)

Constructs a new random number generator with a seed array.
C#
protected RandomSource(
	ReadOnlySpan<ulong> seed,
	StreamAddress streamAddress,
	SeedProfile seedProfile
)

Parameters

seed  ReadOnlySpan<UInt64>
The seed array values.
streamAddress  StreamAddress
Optional stream identifier for stream selection (default: null).
seedProfile  SeedProfile
The seed profile (default: Default).

Remarks

This constructor validates inputs and calls Initialize(RandomOptions, TGenerator) to configure the generator according to the specified seed profile.

Note: ToArray() is necessary here because RandomOptions requires array input for immutability. The span is copied into an array that RandomOptions then stores internally.

Exceptions

ArgumentNullExceptionseed is null.
ArgumentOutOfRangeExceptionseedProfile is not a valid SeedProfile value.

See Also