diff --git a/src/MathNet.Numerics.4.5.resharper b/src/MathNet.Numerics.4.5.resharper
index 73833a90..020c580c 100644
--- a/src/MathNet.Numerics.4.5.resharper
+++ b/src/MathNet.Numerics.4.5.resharper
@@ -841,6 +841,7 @@ Chebyshev
+
diff --git a/src/UnitTests/IntegralTransformsTests/FourierTest.cs b/src/UnitTests/IntegralTransformsTests/FourierTest.cs
index 265b341d..eceaa8ce 100644
--- a/src/UnitTests/IntegralTransformsTests/FourierTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/FourierTest.cs
@@ -29,14 +29,17 @@
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{
using System;
- using MbUnit.Framework;
+ using Distributions;
using IntegralTransforms;
using IntegralTransforms.Algorithms;
+ using MbUnit.Framework;
using Sampling;
[TestFixture]
public class FourierTest
{
+ private IContinuousDistribution _uniform = new ContinuousUniform(-1, 1);
+
[Test]
public void NaiveTransformsRealSineCorrectly()
{
@@ -53,9 +56,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
}
// all imaginary components except second and last musth be zero
- for(int i = 0; i new Complex(u, v), _uniform, 0x7F);
var dft = new DiscreteFourierTransform();
@@ -86,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
() => dft.Radix2Inverse(samples, FourierOptions.Default));
Assert.Throws(
- typeof (ArgumentException),
+ typeof(ArgumentException),
() => DiscreteFourierTransform.Radix2(samples, -1));
Assert.Throws(
@@ -94,4 +97,4 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
() => DiscreteFourierTransform.Radix2Parallel(samples, -1));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/UnitTests/IntegralTransformsTests/HartleyTest.cs b/src/UnitTests/IntegralTransformsTests/HartleyTest.cs
index 5e250fb4..0358269d 100644
--- a/src/UnitTests/IntegralTransformsTests/HartleyTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/HartleyTest.cs
@@ -29,13 +29,17 @@
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{
using System;
- using MbUnit.Framework;
+ using Distributions;
using IntegralTransforms;
using IntegralTransforms.Algorithms;
+ using MbUnit.Framework;
+ using Sampling;
[TestFixture]
public class HartleyTest
{
+ private IContinuousDistribution _uniform = new ContinuousUniform(-1, 1);
+
private static void VerifyMatchesDFT(
double[] samples,
double maximumError,
@@ -59,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
public void NaiveMatchesDFT(HartleyOptions hartleyOptions, FourierOptions fourierOptions)
{
var dht = new DiscreteHartleyTransform();
- var samples = SampleProvider.ProvideRealSamples(0x80);
+ var samples = Sample.Random(x => x, _uniform, 0x80);
VerifyMatchesDFT(
samples,
@@ -76,4 +80,4 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
s => dht.NaiveInverse(s, hartleyOptions));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs b/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
index 436ed383..f76a592a 100644
--- a/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
@@ -29,20 +29,24 @@
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{
using System;
+ using Distributions;
using IntegralTransforms;
using IntegralTransforms.Algorithms;
using MbUnit.Framework;
+ using Sampling;
[TestFixture]
public class InverseTransformTest
{
- private static void VerifyIsReversibleComplex(
+ private IContinuousDistribution _uniform = new ContinuousUniform(-1, 1);
+
+ private void VerifyIsReversibleComplex(
int count,
double maximumError,
Func forward,
Func inverse)
{
- var samples = SampleProvider.ProvideComplexSamples(count);
+ var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, count);
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
@@ -55,13 +59,13 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
AssertHelpers.AlmostEqualList(samples, work, maximumError);
}
- private static void VerifyIsReversibleReal(
+ private void VerifyIsReversibleReal(
int count,
double maximumError,
Func forward,
Func inverse)
{
- var samples = SampleProvider.ProvideRealSamples(count);
+ var samples = Sample.Random(x => x, _uniform, count);
var work = new double[samples.Length];
samples.CopyTo(work, 0);
@@ -149,7 +153,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[Test]
public void FourierDefaultTransformIsReversible()
{
- var samples = SampleProvider.ProvideComplexSamples(0x7FFF);
+ var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, 0x7FFF);
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
@@ -170,4 +174,4 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
AssertHelpers.AlmostEqualList(samples, work, 1e-12);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs b/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
index 784bdccd..ff4e16ee 100644
--- a/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
@@ -29,6 +29,7 @@
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{
using System;
+ using Distributions;
using IntegralTransforms;
using IntegralTransforms.Algorithms;
using MbUnit.Framework;
@@ -37,6 +38,8 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestFixture]
public class MatchingNaiveTransformTest
{
+ private IContinuousDistribution _uniform = new ContinuousUniform(-1, 1);
+
private static void VerifyMatchesNaiveComplex(
Complex[] samples,
double maximumError,
@@ -81,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
public void FourierRadix2MatchesNaiveOnRandom(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
- var samples = SampleProvider.ProvideComplexSamples(0x80);
+ var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, 0x80);
VerifyMatchesNaiveComplex(
samples,
@@ -125,7 +128,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
- var samples = SampleProvider.ProvideComplexSamples(0x80);
+ var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, 0x80);
VerifyMatchesNaiveComplex(
samples,
@@ -147,7 +150,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options)
{
var dft = new DiscreteFourierTransform();
- var samples = SampleProvider.ProvideComplexSamples(0x7F);
+ var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, 0x7F);
VerifyMatchesNaiveComplex(
samples,
@@ -162,4 +165,4 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
s => dft.BluesteinInverse(s, options));
}
}
-}
+}
\ No newline at end of file
diff --git a/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs b/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
index 40426719..84b70c19 100644
--- a/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
@@ -26,24 +26,27 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-using MathNet.Numerics.IntegralTransforms.Algorithms;
-
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{
using System.Linq;
- using MbUnit.Framework;
+ using Distributions;
using IntegralTransforms;
+ using IntegralTransforms.Algorithms;
+ using MbUnit.Framework;
+ using Sampling;
using Statistics;
[TestFixture]
public class ParsevalTheoremTest
{
+ private IContinuousDistribution _uniform = new ContinuousUniform(-1, 1);
+
[Test]
[Row(0x1000)]
[Row(0x7FF)]
public void FourierDefaultTransformSatisfiesParsevalsTheorem(int count)
{
- var samples = SampleProvider.ProvideComplexSamples(count);
+ var samples = Sample.Random((u, v) => new Complex(u, v), _uniform, count);
var timeSpaceEnergy = (from s in samples select s.ModulusSquared).Mean();
@@ -63,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[Row(0x1F)]
public void HartleyDefaultNaiveSatisfiesParsevalsTheorem(int count)
{
- var samples = SampleProvider.ProvideRealSamples(count);
+ var samples = Sample.Random(x => x, _uniform, count);
var timeSpaceEnergy = (from s in samples select s * s).Mean();
@@ -79,4 +82,4 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
Assert.AreApproximatelyEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/UnitTests/IntegralTransformsTests/SampleProvider.cs b/src/UnitTests/IntegralTransformsTests/SampleProvider.cs
deleted file mode 100644
index b1857908..00000000
--- a/src/UnitTests/IntegralTransformsTests/SampleProvider.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://mathnet.opensourcedotnet.info
-//
-// Copyright (c) 2009 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
-{
- using System;
-
- internal static class SampleProvider
- {
- private static readonly Random _random = new Random();
-
- internal static Complex[] ProvideComplexSamples(int count)
- {
- var samples = new Complex[count];
- for (int i = 0; i < samples.Length; i++)
- {
- samples[i] = Complex.WithRealImaginary(
- 1 - (2 * _random.NextDouble()),
- 1 - (2 * _random.NextDouble()));
- }
-
- return samples;
- }
-
- internal static double[] ProvideRealSamples(int count)
- {
- var samples = new double[count];
- for (int i = 0; i < samples.Length; i++)
- {
- samples[i] = 1 - (2 * _random.NextDouble());
- }
-
- return samples;
- }
- }
-}
\ No newline at end of file
diff --git a/src/UnitTests/IntegrationTests/IntegrationTest.cs b/src/UnitTests/IntegrationTests/IntegrationTest.cs
index 0038941a..98d99814 100644
--- a/src/UnitTests/IntegrationTests/IntegrationTest.cs
+++ b/src/UnitTests/IntegrationTests/IntegrationTest.cs
@@ -89,7 +89,8 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
TargetAreaA,
algorithm.Integrate(TargetFunctionA, StartA, StopA, targetRelativeError),
targetRelativeError * TargetAreaA,
- "DET Adaptive {0}", targetRelativeError);
+ "DET Adaptive {0}",
+ targetRelativeError);
}
[VerifyContract]
@@ -121,7 +122,8 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
TargetAreaA,
NewtonCotesTrapeziumRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions),
maxRelativeError * TargetAreaA,
- "Composite {0} Partitions", partitions);
+ "Composite {0} Partitions",
+ partitions);
}
[Test]
@@ -134,7 +136,8 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
TargetAreaA,
NewtonCotesTrapeziumRule.IntegrateAdaptive(TargetFunctionA, StartA, StopA, targetRelativeError),
targetRelativeError * TargetAreaA,
- "Adaptive {0}", targetRelativeError);
+ "Adaptive {0}",
+ targetRelativeError);
}
[VerifyContract]
@@ -181,7 +184,8 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
TargetAreaA,
SimpsonRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions),
maxRelativeError * TargetAreaA,
- "Composite {0} Partitions", partitions);
+ "Composite {0} Partitions",
+ partitions);
}
[VerifyContract]
@@ -202,4 +206,4 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests
}
};
}
-}
+}
\ No newline at end of file
diff --git a/src/UnitTests/UnitTests.csproj b/src/UnitTests/UnitTests.csproj
index ccaeee0b..e118bcba 100644
--- a/src/UnitTests/UnitTests.csproj
+++ b/src/UnitTests/UnitTests.csproj
@@ -74,7 +74,6 @@
-