Browse Source

Match the behavior of SystemRandomSource to System.Random

Match the behavior of "SystemRandomSource" to "System.Random"
https://github.com/dotnet/runtime/pull/47085
pull/886/head
hikari 5 years ago
committed by GitHub
parent
commit
a9ecbca652
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/Numerics/Random/SystemRandomSource.cs

8
src/Numerics/Random/SystemRandomSource.cs

@ -49,16 +49,18 @@ namespace MathNet.Numerics.Random
/// <summary>
/// Construct a new random number generator with a random seed.
/// </summary>
public SystemRandomSource() : this(RandomSeed.Robust())
public SystemRandomSource()
{
_random = new System.Random();
}
/// <summary>
/// Construct a new random number generator with random seed.
/// </summary>
/// <param name="threadSafe">if set to <c>true</c> , the class is thread safe.</param>
public SystemRandomSource(bool threadSafe) : this(RandomSeed.Robust(), threadSafe)
public SystemRandomSource(bool threadSafe) : base(threadSafe)
{
_random = new System.Random();
}
/// <summary>
@ -80,7 +82,7 @@ namespace MathNet.Numerics.Random
_random = new System.Random(seed);
}
static readonly ThreadLocal<SystemRandomSource> DefaultInstance = new ThreadLocal<SystemRandomSource>(() => new SystemRandomSource(RandomSeed.Robust(), true));
static readonly ThreadLocal<SystemRandomSource> DefaultInstance = new ThreadLocal<SystemRandomSource>(() => new SystemRandomSource(true));
/// <summary>
/// Default instance, thread-safe.

Loading…
Cancel
Save