Random Source<TGenerator> Constructor
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
Overload List
| Random | Constructs a new instance of the random number generator using a high-entropy, automatically generated seed. |
| Random | Constructs a new random number generator from a pre-initialized generator. |
| Random | Constructs a new random number generator with advanced options. |
| Random | Constructs a new random number generator from saved state. |
| Random | Constructs a new random number generator with the specified seed. |
| Random | Constructs a new random number generator with a seed array. |
| Random | Constructs a new random number generator with a seed array. |
RandomSource<TGenerator>
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)
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)
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>)
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)
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
| Argument | seedProfile is not a valid SeedProfile value. |
RandomSource<TGenerator>(ReadOnlySpan<UInt32>, StreamAddress, SeedProfile)
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
| Argument | seed is null. |
| Argument | seedProfile is not a valid SeedProfile value. |
RandomSource<TGenerator>(ReadOnlySpan<UInt64>, StreamAddress, SeedProfile)
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
| Argument | seed is null. |
| Argument | seedProfile is not a valid SeedProfile value. |