Browse Source

Merge e293cc3f8e into e989ab7302

pull/886/merge
hikari 5 years ago
committed by GitHub
parent
commit
2df1faac70
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/Numerics/Random/SystemRandomSource.cs

16
src/Numerics/Random/SystemRandomSource.cs

@ -49,16 +49,26 @@ namespace MathNet.Numerics.Random
/// <summary> /// <summary>
/// Construct a new random number generator with a random seed. /// Construct a new random number generator with a random seed.
/// </summary> /// </summary>
public SystemRandomSource() : this(RandomSeed.Robust()) public SystemRandomSource()
{ {
#if NETCOREAPP
_random = new System.Random();
#else
_random = new System.Random(RandomSeed.Robust());
#endif
} }
/// <summary> /// <summary>
/// Construct a new random number generator with random seed. /// Construct a new random number generator with random seed.
/// </summary> /// </summary>
/// <param name="threadSafe">if set to <c>true</c> , the class is thread safe.</param> /// <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)
{ {
#if NETCOREAPP
_random = new System.Random();
#else
_random = new System.Random(RandomSeed.Robust());
#endif
} }
/// <summary> /// <summary>
@ -80,7 +90,7 @@ namespace MathNet.Numerics.Random
_random = new System.Random(seed); _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> /// <summary>
/// Default instance, thread-safe. /// Default instance, thread-safe.

Loading…
Cancel
Save