Applied .NET 7 syntax or feature changes

This commit is contained in:
Thorsten Sommer 2023-07-06 10:26:12 +02:00
parent 38764d5d97
commit e8cf1284d7
No known key found for this signature in database
GPG Key ID: B0B7E2FC074BF1F5
55 changed files with 3485 additions and 3567 deletions

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class BetaA2B2 : Distribution
{
private const float ALPHA = 2f;
@ -14,4 +14,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * MathF.Pow(x, ALPHA - 1f) * MathF.Pow(1f - x, BETA - 1f);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class BetaA2B5 : Distribution
{
private const float ALPHA = 2f;
@ -14,4 +14,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * MathF.Pow(x, ALPHA - 1f) * MathF.Pow(1f - x, BETA - 1f);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class BetaA5B2 : Distribution
{
private const float ALPHA = 5f;
@ -14,4 +14,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * MathF.Pow(x, ALPHA - 1f) * MathF.Pow(1f - x, BETA - 1f);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class CauchyLorentzX0 : Distribution
{
private const float CONSTANT = 0.31f;
@ -14,4 +14,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * (1.0f / (MathF.PI * SCALE)) * ((SCALE * SCALE) / (MathF.Pow(x - MEDIAN, 2f) + (SCALE * SCALE)));
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class CauchyLorentzX1 : Distribution
{
private const float CONSTANT = 0.31f;
@ -14,4 +14,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * (1.0f / (MathF.PI * SCALE)) * ((SCALE * SCALE) / (MathF.Pow(x - MEDIAN, 2f) + (SCALE * SCALE)));
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class ChiSquareK1 : Distribution
{
private const float K = 1.0f;
@ -24,4 +24,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * ((MathF.Pow(x, K_HALF_MINUS_ONE) * MathF.Exp(-x * 0.5f)) / DIVISOR);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class ChiSquareK10 : Distribution
{
private const float K = 10.0f;
@ -24,4 +24,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * ((MathF.Pow(x, K_HALF_MINUS_ONE) * MathF.Exp(-x * 0.5f)) / DIVISOR);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class ChiSquareK4 : Distribution
{
private const float K = 4.0f;
@ -24,4 +24,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * ((MathF.Pow(x, K_HALF_MINUS_ONE) * MathF.Exp(-x * 0.5f)) / DIVISOR);
}
}

View File

@ -2,20 +2,18 @@ using System;
using System.Threading;
using System.Threading.Tasks;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public abstract class Distribution : IDistribution
{
private readonly ShapeFitter fitter;
private readonly IRandom random;
protected Distribution(IRandom rng)
{
if (rng == null)
throw new ArgumentNullException(nameof(rng), "An IRandom implementation is needed.");
this.random = rng;
this.fitter = new ShapeFitter(this.ShapeFunction, this.random, 100);
this.fitter = new ShapeFitter(this.ShapeFunction, rng, 100);
}
private protected abstract float ShapeFunction(float x);
@ -24,40 +22,31 @@ namespace FastRng.Distributions
public async ValueTask<uint> NextNumber(uint rangeStart, uint rangeEnd, CancellationToken cancel = default)
{
// Swap the values if the range start is greater than the range end:
if (rangeStart > rangeEnd)
{
var tmp = rangeStart;
rangeStart = rangeEnd;
rangeEnd = tmp;
}
(rangeStart, rangeEnd) = (rangeEnd, rangeStart);
var range = rangeEnd - rangeStart;
var distributedValue = await this.GetDistributedValue(cancel);
return (uint) ((distributedValue * range) + rangeStart);
}
public async ValueTask<ulong> NextNumber(ulong rangeStart, ulong rangeEnd, CancellationToken cancel = default(CancellationToken))
public async ValueTask<ulong> NextNumber(ulong rangeStart, ulong rangeEnd, CancellationToken cancel = default)
{
// Swap the values if the range start is greater than the range end:
if (rangeStart > rangeEnd)
{
var tmp = rangeStart;
rangeStart = rangeEnd;
rangeEnd = tmp;
}
(rangeStart, rangeEnd) = (rangeEnd, rangeStart);
var range = rangeEnd - rangeStart;
var distributedValue = await this.GetDistributedValue(cancel);
return (ulong) ((distributedValue * range) + rangeStart);
}
public async ValueTask<float> NextNumber(float rangeStart, float rangeEnd, CancellationToken cancel = default(CancellationToken))
public async ValueTask<float> NextNumber(float rangeStart, float rangeEnd, CancellationToken cancel = default)
{
// Swap the values if the range start is greater than the range end:
if (rangeStart > rangeEnd)
{
var tmp = rangeStart;
rangeStart = rangeEnd;
rangeEnd = tmp;
}
(rangeStart, rangeEnd) = (rangeEnd, rangeStart);
var range = rangeEnd - rangeStart;
var distributedValue = await this.GetDistributedValue(cancel);
@ -72,4 +61,3 @@ namespace FastRng.Distributions
return number > above && number < below;
}
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class ExponentialLa10 : Distribution
{
private const float LAMBDA = 10.0f;
@ -13,4 +13,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * LAMBDA * MathF.Exp(-LAMBDA * x);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class ExponentialLa5 : Distribution
{
private const float LAMBDA = 5.0f;
@ -13,4 +13,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * LAMBDA * MathF.Exp(-LAMBDA * x);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class GammaA5B15 : Distribution
{
private const float ALPHA = 5.0f;
@ -23,4 +23,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * ((BETA_TO_THE_ALPHA * MathF.Pow(x, ALPHA - 1.0f) * MathF.Exp(-BETA * x)) / GAMMA_ALPHA);
}
}

View File

@ -1,8 +1,8 @@
using System.Threading;
using System.Threading.Tasks;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public interface IDistribution
{
public ValueTask<float> GetDistributedValue(CancellationToken token);
@ -17,4 +17,3 @@ namespace FastRng.Distributions
public ValueTask<bool> HasDecisionBeenMade(float above, float below = 1.0f, CancellationToken cancel = default);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class InverseExponentialLa10 : Distribution
{
private const float LAMBDA = 10.0f;
@ -13,4 +13,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * LAMBDA * MathF.Exp(LAMBDA * x);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class InverseExponentialLa5 : Distribution
{
private const float LAMBDA = 5.0f;
@ -13,4 +13,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * LAMBDA * MathF.Exp(LAMBDA * x);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class InverseGammaA3B05 : Distribution
{
private const float ALPHA = 3.0f;
@ -24,4 +24,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => FACTOR_LEFT * MathF.Pow(x, -ALPHA - 1.0f) * MathF.Exp(-BETA / x);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class LaplaceB01M0 : Distribution
{
private const float B = 0.1f;
@ -21,4 +21,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => FACTOR_LEFT * MathF.Exp(-MathF.Abs(x - MU) / B);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class LaplaceB01M05 : Distribution
{
private const float B = 0.1f;
@ -21,4 +21,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => FACTOR_LEFT * MathF.Exp(-MathF.Abs(x - MU) / B);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class LogNormalS1M0 : Distribution
{
private const float SIGMA = 1.0f;
@ -21,4 +21,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => (CONSTANT / (x * FACTOR)) * MathF.Exp( -(MathF.Pow(MathF.Log(x) - MU, 2f) / (2f * MathF.Pow(SIGMA, 2f))));
}
}

View File

@ -1,17 +1,16 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class NormalS02M05 : Distribution
{
private const float SQRT_2_PI = 2.506628275f;
private const float STDDEV = 0.2f;
private const float STD_DEV = 0.2f;
private const float MEAN = 0.5f;
public NormalS02M05(IRandom rng) : base(rng)
{
}
private protected override float ShapeFunction(float x) => 1.0f / (STDDEV * SQRT_2_PI) * MathF.Exp(-0.5f * MathF.Pow((x - MEAN) / STDDEV, 2.0f));
}
private protected override float ShapeFunction(float x) => 1.0f / (STD_DEV * SQRT_2_PI) * MathF.Exp(-0.5f * MathF.Pow((x - MEAN) / STD_DEV, 2.0f));
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class StudentTNu1 : Distribution
{
private const float NU = 1.0f;
@ -26,4 +26,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * MathF.Pow((DIVIDEND / DIVISOR) * MathF.Pow(1.0f + MathF.Pow(START + x * COMPRESS, 2f) / NU, EXPONENT), COMPRESS);
}
}

View File

@ -2,58 +2,46 @@ using System;
using System.Threading;
using System.Threading.Tasks;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class Uniform : IDistribution
{
private readonly IRandom rng;
public Uniform(IRandom rng)
{
if (rng == null)
throw new ArgumentNullException(nameof(rng), "An IRandom implementation is needed.");
this.rng = rng;
this.rng = rng ?? throw new ArgumentNullException(nameof(rng), "An IRandom implementation is needed.");
}
public async ValueTask<float> GetDistributedValue(CancellationToken token = default) => await this.rng.GetUniform(token);
public async ValueTask<uint> NextNumber(uint rangeStart, uint rangeEnd, CancellationToken cancel = default)
{
// Swap the values if the range start is greater than the range end:
if (rangeStart > rangeEnd)
{
var tmp = rangeStart;
rangeStart = rangeEnd;
rangeEnd = tmp;
}
(rangeStart, rangeEnd) = (rangeEnd, rangeStart);
var range = rangeEnd - rangeStart;
var distributedValue = await this.GetDistributedValue(cancel);
return (uint) ((distributedValue * range) + rangeStart);
}
public async ValueTask<ulong> NextNumber(ulong rangeStart, ulong rangeEnd, CancellationToken cancel = default(CancellationToken))
public async ValueTask<ulong> NextNumber(ulong rangeStart, ulong rangeEnd, CancellationToken cancel = default)
{
// Swap the values if the range start is greater than the range end:
if (rangeStart > rangeEnd)
{
var tmp = rangeStart;
rangeStart = rangeEnd;
rangeEnd = tmp;
}
(rangeStart, rangeEnd) = (rangeEnd, rangeStart);
var range = rangeEnd - rangeStart;
var distributedValue = await this.GetDistributedValue(cancel);
return (ulong) ((distributedValue * range) + rangeStart);
}
public async ValueTask<float> NextNumber(float rangeStart, float rangeEnd, CancellationToken cancel = default(CancellationToken))
public async ValueTask<float> NextNumber(float rangeStart, float rangeEnd, CancellationToken cancel = default)
{
// Swap the values if the range start is greater than the range end:
if (rangeStart > rangeEnd)
{
var tmp = rangeStart;
rangeStart = rangeEnd;
rangeEnd = tmp;
}
(rangeStart, rangeEnd) = (rangeEnd, rangeStart);
var range = rangeEnd - rangeStart;
var distributedValue = await this.GetDistributedValue(cancel);
@ -68,4 +56,3 @@ namespace FastRng.Distributions
return number > above && number < below;
}
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng.Distributions
{
namespace FastRng.Distributions;
public sealed class WeibullK05La1 : Distribution
{
private const float K = 0.5f;
@ -14,4 +14,3 @@ namespace FastRng.Distributions
private protected override float ShapeFunction(float x) => CONSTANT * ( (K / LAMBDA) * MathF.Pow(x / LAMBDA, K - 1.0f) * MathF.Exp(-MathF.Pow(x/LAMBDA, K)));
}
}

View File

@ -2,8 +2,8 @@ using System;
using System.Threading;
using System.Threading.Tasks;
namespace FastRng
{
namespace FastRng;
/// <summary>
/// Interface for random number generators.
/// </summary>
@ -20,4 +20,3 @@ namespace FastRng
/// <param name="cancel">An optional cancellation token.</param>
public ValueTask<float> GetUniform(CancellationToken cancel = default);
}
}

View File

@ -1,7 +1,7 @@
using System;
namespace FastRng
{
namespace FastRng;
/// <summary>
/// Provides some mathematical function, which are not available within in the .NET framework.
/// </summary>
@ -40,14 +40,14 @@ namespace FastRng
A8 / (z + 6) +
A9 / (z + 7);
return MathTools.SQRT_2 * MathTools.SQRT_PI * MathF.Pow(t, z - 0.5f) * MathF.Exp(-t) * x;
return SQRT_2 * SQRT_PI * MathF.Pow(t, z - 0.5f) * MathF.Exp(-t) * x;
}
/// <summary>
/// The mathematical factorial function for floating-point numbers.
/// </summary>
/// <param name="x">The value, for which you want to know the factorial.</param>
public static float Factorial(float x) => MathTools.Gamma(x + 1.0f);
public static float Factorial(float x) => Gamma(x + 1.0f);
/// <summary>
/// The mathematical factorial function for integer numbers.
@ -77,7 +77,6 @@ namespace FastRng
if(x < 0)
throw new ArgumentOutOfRangeException(nameof(x), "Given value must be greater as zero.");
return MathTools.Factorial((uint) x);
}
return Factorial((uint) x);
}
}

View File

@ -4,8 +4,8 @@ using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
namespace FastRng
{
namespace FastRng;
/// <summary>
/// A fast multi-threaded pseudo random number generator.
/// </summary>
@ -37,16 +37,16 @@ namespace FastRng
private const int QUEUE_SIZE = 2;
// Gets used to stop the producer threads:
private readonly CancellationTokenSource producerTokenSource = new CancellationTokenSource();
private readonly CancellationTokenSource producerTokenSource = new();
// The time a thread waits e.g. to check if the queue needs a new buffer:
private readonly TimeSpan waiter = TimeSpan.FromMilliseconds(10);
// The first queue, where to store buffers of random uint numbers:
private readonly ConcurrentQueue<uint[]> queueIntegers = new ConcurrentQueue<uint[]>();
private readonly ConcurrentQueue<uint[]> queueIntegers = new();
// The second queue, where to store buffers of uniform random floating point numbers:
private readonly ConcurrentQueue<float[]> queueFloats = new ConcurrentQueue<float[]>();
private readonly ConcurrentQueue<float[]> queueFloats = new();
// The uint producer thread:
private Thread producerRandomUint;
@ -354,4 +354,3 @@ namespace FastRng
#endregion
}
}

View File

@ -3,8 +3,8 @@ using System.Threading;
using System.Threading.Tasks;
using FastRng.Distributions;
namespace FastRng
{
namespace FastRng;
/// <summary>
/// ShapeFitter is a rejection sampler, cf. https://en.wikipedia.org/wiki/Rejection_sampling
/// </summary>
@ -75,4 +75,3 @@ namespace FastRng
return float.NaN;
}
}
}

View File

@ -6,8 +6,8 @@ using NUnit.Framework;
using Uniform = FastRng.Distributions.Uniform;
using WeibullK05La1 = FastRng.Distributions.WeibullK05La1;
namespace FastRngTests
{
namespace FastRngTests;
[ExcludeFromCodeCoverage]
public class DecisionTester
{
@ -59,4 +59,3 @@ namespace FastRngTests
Assert.That(max - min, Is.LessThanOrEqualTo(2_800));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class BetaA2B2
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.BetaA2B2(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class BetaA2B5
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.BetaA2B5(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class BetaA5B2
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.BetaA5B2(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class CauchyLorentzX0
{
@ -84,4 +84,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.CauchyLorentzX0(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class CauchyLorentzX1
{
@ -84,4 +84,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.CauchyLorentzX1(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class ChiSquareK1
{
@ -84,4 +84,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.ChiSquareK1(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class ChiSquareK10
{
@ -84,4 +84,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.ChiSquareK10(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class ChiSquareK4
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.ChiSquareK4(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class ExponentialLa10
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.ExponentialLa10(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class ExponentialLa5
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.ExponentialLa5(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class GammaA5B15
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.GammaA5B15(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class InverseExponentialLa10
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.InverseExponentialLa10(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class InverseExponentialLa5
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.InverseExponentialLa5(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class InverseGammaA3B05
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.InverseGammaA3B05(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class LaplaceB01M0
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.LaplaceB01M0(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class LaplaceB01M05
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.LaplaceB01M05(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class LogNormalS1M0
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.LogNormalS1M0(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class NormalS02M05
{
@ -77,4 +77,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.NormalS02M05(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class StudentTNu1
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.StudentTNu1(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class Uniform
{
@ -294,4 +294,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.Uniform(null));
}
}
}

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using FastRng;
using NUnit.Framework;
namespace FastRngTests.Distributions
{
namespace FastRngTests.Distributions;
[ExcludeFromCodeCoverage]
public class WeibullK05La1
{
@ -81,4 +81,3 @@ namespace FastRngTests.Distributions
Assert.Throws<ArgumentNullException>(() => new FastRng.Distributions.WeibullK05La1(null));
}
}
}

View File

@ -3,8 +3,8 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
namespace FastRngTests
{
namespace FastRngTests;
[ExcludeFromCodeCoverage]
public sealed class FrequencyAnalysis
{
@ -46,7 +46,7 @@ namespace FastRngTests
public float[] NormalizeAndPlotEvents(Action<string> writer)
{
var result = this.Normalize();
FrequencyAnalysis.Plot(result, writer, "Event Distribution");
Plot(result, writer, "Event Distribution");
return result;
}
@ -54,7 +54,7 @@ namespace FastRngTests
public void PlotOccurence(Action<string> writer)
{
var data = this.data.Select(n => n > 0f ? 1.0f : 0.0f).ToArray();
FrequencyAnalysis.Plot(data, writer, "Occurrence Distribution");
Plot(data, writer, "Occurrence Distribution");
}
private static void Plot(float[] data, Action<string> writer, string name)
@ -81,4 +81,3 @@ namespace FastRngTests
writer.Invoke(string.Empty);
}
}
}

View File

@ -3,8 +3,8 @@ using System.Diagnostics.CodeAnalysis;
using FastRng;
using NUnit.Framework;
namespace FastRngTests
{
namespace FastRngTests;
[ExcludeFromCodeCoverage]
public class MathToolsTests
{
@ -338,4 +338,3 @@ namespace FastRngTests
#endregion
}
}

View File

@ -6,8 +6,8 @@ using FastRng;
using FastRng.Distributions;
using NUnit.Framework;
namespace FastRngTests
{
namespace FastRngTests;
[ExcludeFromCodeCoverage]
public class MultiThreadedRngTests
{
@ -622,4 +622,3 @@ namespace FastRngTests
Assert.That(await dist.NextNumber(1, 100), Is.EqualTo(56));
}
}
}

View File

@ -9,8 +9,8 @@ using MathNet.Numerics.Distributions;
using MathNet.Numerics.Random;
using NUnit.Framework;
namespace FastRngTests
{
namespace FastRngTests;
[ExcludeFromCodeCoverage]
public class PerformanceTests
{
@ -134,4 +134,3 @@ namespace FastRngTests
#endregion
}
}

View File

@ -1,8 +1,8 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace FastRngTests
{
namespace FastRngTests;
[ExcludeFromCodeCoverage]
internal sealed class RunningStatistics
{
@ -11,11 +11,7 @@ namespace FastRngTests
private float nextM;
private float nextS;
public RunningStatistics()
{
}
public int NumberRecords { get; private set; } = 0;
private int NumberRecords { get; set; } = 0;
public void Clear() => this.NumberRecords = 0;
@ -46,4 +42,3 @@ namespace FastRngTests
public float StandardDeviation => MathF.Sqrt(this.Variance);
}
}

View File

@ -1,6 +1,6 @@
namespace FastRngTests
{
public class TestCategories
namespace FastRngTests;
public static class TestCategories
{
public const string COVER = "cover";
public const string PERFORMANCE = "performance";
@ -8,4 +8,3 @@ namespace FastRngTests
public const string EXAMPLE = "example";
public const string LONG_RUNNING = "long running";
}
}