ThreadSafeRandomSource Class

A thread-safe random number generator source that provides per-thread instances of a specified generator type.

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
public sealed class ThreadSafeRandomSource : IRandomSource<ScalarGenerator64<Xoshiro256StarStarEngine>>, 
	IRandomSource, IStateful
Inheritance
Object  →  ThreadSafeRandomSource
Implements
IRandomSource, IRandomSource<ScalarGenerator64<Xoshiro256StarStarEngine>>, IStateful

Remarks

This class ensures that each thread has its own instance of the random number generator, providing thread safety without the need for locks.

Constructors

ThreadSafeRandomSourceInitializes a new instance of the ThreadSafeRandomSource class

Properties

BitsPerWord Gets the number of bits per word in the generator's native output.
Instance Provides a globally accessible, thread-safe instance of the random number generator.
Name Gets a human-readable name for this random number generator.
StateSize Gets the number of bytes required to save/load this generator's state.

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Fill(Span<Double>) Fills a span with random double-precision floating-point numbers in [0, 1).
Fill(Span<Int32>) Fills a span with random 32-bit signed integers.
Fill(Span<Int64>) Fills a span with random 64-bit signed integers.
Fill(Span<Single>) Fills a span with random single-precision floating-point numbers in [0, 1).
Fill(Span<UInt32>) Fills a span with random 32-bit unsigned integer values.
Fill(Span<UInt64>) Fills a span with random 64-bit unsigned integer values.
Fill(Span<Int32>, Int32) Fills a span with random 32-bit signed integers less than the specified maximum.
Fill(Span<Int64>, Int64) Fills a span with random 64-bit signed integers less than the specified maximum.
Fill(Span<Int32>, Int32, Int32) Fills a span with random 32-bit signed integers within a specified range.
Fill(Span<Int64>, Int64, Int64) Fills a span with random 64-bit signed integers within a specified range.
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetState Returns the current state of the generator as a byte array.
GetTypeGets the Type of the current instance.
(Inherited from Object)
LoadState Loads the generator's state from the source span in a stable little-endian format.
Next() Returns a non-negative random integer.
Next(Int32) Returns a non-negative random integer less than the specified maximum.
Next(Int32, Int32) Returns a random integer within a specified range.
NextBytes(Byte[]) Fills the elements of a specified array of bytes with random numbers.
NextBytes(Span<Byte>) Fills the elements of a specified span of bytes with random numbers.
NextDouble Returns a random floating-point number in the range [0.0, 1.0).
NextInt64() Returns a non-negative random 64-bit integer.
NextInt64(Int64) Returns a non-negative random 64-bit integer less than the specified maximum.
NextInt64(Int64, Int64) Returns a random 64-bit integer within a specified range.
NextSingle Returns a random single-precision floating-point number in the range [0.0, 1.0).
NextUInt32 Returns a random 32-bit unsigned integer.
NextUInt64 Returns a random 64-bit unsigned integer.
SaveState Saves the generator's state to the destination span in a stable little-endian format.
ToStringReturns a string that represents the current object.
(Inherited from Object)

Extension Methods

AsRandom Converts a random source to a Random.
(Defined by RandomInteropExtensions)
CorrelatedSamples Generates a series of random variables with the specified correlation matrix.
(Defined by RandomSamplingExtensions)
CorrelatedSamples<ScalarGenerator64<Xoshiro256StarStarEngine>> Generates a series of random variables with the specified correlation matrix.
(Defined by RandomSamplingExtensions)
Fill Fills the elements of a specified span with random double-precision floating-point numbers.
(Defined by RandomSourceExtensions)
Fill Fills the elements of a specified span with random double-precision floating-point numbers.
(Defined by RandomSourceExtensions)
Fill Fills the elements of a specified span with random single-precision floating-point numbers.
(Defined by RandomSourceExtensions)
Fill Fills the elements of a specified span with random 32-bit signed integers.
(Defined by RandomSourceExtensions)
Fill Fills the elements of a specified span with random 64-bit signed integers.
(Defined by RandomSourceExtensions)
Fill Fills a span with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Fill Fills a span with random samples from the specified discrete distribution.
(Defined by RandomSamplingExtensions)
Fill Fills the elements of a specified span with random 32-bit signed integers less than the specified maximum.
(Defined by RandomSourceExtensions)
Fill Fills the elements of a specified span with random 64-bit signed integers less than the specified maximum.
(Defined by RandomSourceExtensions)
Fill Fills a vector with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Fill Fills the elements of a specified span with random 32-bit signed integers within a specified range.
(Defined by RandomSourceExtensions)
Fill Fills the elements of a specified span with random 64-bit signed integers within a specified range.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random double-precision floating-point numbers.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random single-precision floating-point numbers.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random 32-bit signed integers.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random 64-bit signed integers.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills a span with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills a span with random samples from the specified discrete distribution.
(Defined by RandomSamplingExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random 32-bit signed integers less than the specified maximum.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random 64-bit signed integers less than the specified maximum.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills a vector with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills a vector with random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random 32-bit signed integers within a specified range.
(Defined by RandomSourceExtensions)
Fill<ScalarGenerator64<Xoshiro256StarStarEngine>> Fills the elements of a specified span with random 64-bit signed integers within a specified range.
(Defined by RandomSourceExtensions)
FillWithoutReplacement Populates the specified span with numbers chosen at random between 0 and the provided count without replacement.
(Defined by RandomSourceExtensions)
FillWithoutReplacement<ScalarGenerator64<Xoshiro256StarStarEngine>> Populates the specified span with numbers chosen at random between 0 and the provided count without replacement.
(Defined by RandomSourceExtensions)
Next Returns a non-negative random integer.
(Defined by RandomSourceExtensions)
Next Generates a random sample from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Next Generates a random sample from the specified discrete distribution.
(Defined by RandomSamplingExtensions)
Next Returns a non-negative random integer that is less than the specified maximum.
(Defined by RandomSourceExtensions)
Next Generates an array of random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Next Generates an array of random samples from the specified discrete distribution.
(Defined by RandomSamplingExtensions)
Next Returns a random integer that is within a specified range.
(Defined by RandomSourceExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a non-negative random integer.
(Defined by RandomSourceExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Generates a random sample from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Generates a random sample from the specified discrete distribution.
(Defined by RandomSamplingExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a non-negative random integer that is less than the specified maximum.
(Defined by RandomSourceExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Generates an array of random samples from the specified continuous distribution.
(Defined by RandomSamplingExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Generates an array of random samples from the specified discrete distribution.
(Defined by RandomSamplingExtensions)
Next<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a random integer that is within a specified range.
(Defined by RandomSourceExtensions)
NextDouble Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Defined by RandomSourceExtensions)
NextDouble<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Defined by RandomSourceExtensions)
NextInt32 Returns a non-negative random 32-bit integer.
(Defined by RandomSourceExtensions)
NextInt32<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a non-negative random 32-bit integer.
(Defined by RandomSourceExtensions)
NextInt64 Returns a non-negative random 64-bit integer.
(Defined by RandomSourceExtensions)
NextInt64 Returns a non-negative random 64-bit integer that is less than the specified maximum.
(Defined by RandomSourceExtensions)
NextInt64 Returns a random 64-bit integer that is within a specified range.
(Defined by RandomSourceExtensions)
NextInt64<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a non-negative random 64-bit integer.
(Defined by RandomSourceExtensions)
NextInt64<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a non-negative random 64-bit integer that is less than the specified maximum.
(Defined by RandomSourceExtensions)
NextInt64<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a random 64-bit integer that is within a specified range.
(Defined by RandomSourceExtensions)
NextSingle Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Defined by RandomSourceExtensions)
NextSingle<ScalarGenerator64<Xoshiro256StarStarEngine>> Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Defined by RandomSourceExtensions)
Shuffle<T> Shuffles the elements of an IList<T> in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions)
Shuffle<T> Shuffles the elements of an array in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions)
Shuffle<T> Shuffles the elements of a span in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions)
Shuffle<ScalarGenerator64<Xoshiro256StarStarEngine>, T> Shuffles the elements of an array in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions)
Shuffle<ScalarGenerator64<Xoshiro256StarStarEngine>, T> Shuffles the elements of a span in place using the Fisher-Yates algorithm.
(Defined by RandomSourceExtensions)

See Also