diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs b/src/Numerics/IntegralTransforms/Fourier.Bluestein.cs
similarity index 88%
rename from src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs
rename to src/Numerics/IntegralTransforms/Fourier.Bluestein.cs
index 4ec01aa1..26fdd824 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Bluestein.cs
+++ b/src/Numerics/IntegralTransforms/Fourier.Bluestein.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -31,7 +31,7 @@
using System;
using MathNet.Numerics.Threading;
-namespace MathNet.Numerics.IntegralTransforms.Algorithms
+namespace MathNet.Numerics.IntegralTransforms
{
#if !NOSYSNUMERICS
@@ -41,21 +41,21 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Complex Fast (FFT) Implementation of the Discrete Fourier Transform (DFT).
///
- public partial class DiscreteFourierTransform
+ public static partial class Fourier
{
///
/// Generate the bluestein sequence for the provided problem size.
///
/// Number of samples.
/// Bluestein sequence exp(I*Pi*k^2/N)
- private static Complex[] BluesteinSequence(int n)
+ static Complex[] BluesteinSequence(int n)
{
- double s = Constants.Pi / n;
+ double s = Constants.Pi/n;
var sequence = new Complex[n];
for (int k = 0; k < sequence.Length; k++)
{
- double t = s * (k * k);
+ double t = s*(k*k);
sequence[k] = new Complex(Math.Cos(t), Math.Sin(t));
}
@@ -66,7 +66,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Convolution with the bluestein sequence (Parallel Version).
///
/// Sample Vector.
- private static void BluesteinConvolutionParallel(Complex[] samples)
+ static void BluesteinConvolutionParallel(Complex[] samples)
{
int n = samples.Length;
Complex[] sequence = BluesteinSequence(n);
@@ -97,7 +97,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
// Build and transform padded sequence a_k = x_k * exp(-I*Pi*k^2/N)
for (int i = 0; i < samples.Length; i++)
{
- a[i] = sequence[i].Conjugate() * samples[i];
+ a[i] = sequence[i].Conjugate()*samples[i];
}
Radix2(a, -1);
@@ -110,10 +110,10 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
Radix2Parallel(a, 1);
- var nbinv = 1.0 / m;
+ var nbinv = 1.0/m;
for (int i = 0; i < samples.Length; i++)
{
- samples[i] = nbinv * sequence[i].Conjugate() * a[i];
+ samples[i] = nbinv*sequence[i].Conjugate()*a[i];
}
}
@@ -121,7 +121,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Swap the real and imaginary parts of each sample.
///
/// Sample Vector.
- private static void SwapRealImaginary(Complex[] samples)
+ static void SwapRealImaginary(Complex[] samples)
{
for (int i = 0; i < samples.Length; i++)
{
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Sample vector, where the FFT is evaluated in place.
/// Fourier Transform Convention Options.
- public void BluesteinForward(Complex[] samples, FourierOptions options)
+ public static void BluesteinForward(Complex[] samples, FourierOptions options)
{
Bluestein(samples, SignByOptions(options));
ForwardScaleByOptions(options, samples);
@@ -172,10 +172,10 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Sample vector, where the FFT is evaluated in place.
/// Fourier Transform Convention Options.
- public void BluesteinInverse(Complex[] samples, FourierOptions options)
+ public static void BluesteinInverse(Complex[] samples, FourierOptions options)
{
Bluestein(samples, -SignByOptions(options));
InverseScaleByOptions(options, samples);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Naive.cs b/src/Numerics/IntegralTransforms/Fourier.Naive.cs
similarity index 80%
rename from src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Naive.cs
rename to src/Numerics/IntegralTransforms/Fourier.Naive.cs
index 4c2b890d..d1664b3e 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Naive.cs
+++ b/src/Numerics/IntegralTransforms/Fourier.Naive.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -28,10 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-namespace MathNet.Numerics.IntegralTransforms.Algorithms
+using System;
+using MathNet.Numerics.Threading;
+
+namespace MathNet.Numerics.IntegralTransforms
{
- using System;
- using Threading;
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
@@ -40,7 +41,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Complex Fast (FFT) Implementation of the Discrete Fourier Transform (DFT).
///
- public partial class DiscreteFourierTransform
+ public static partial class Fourier
{
///
/// Naive generic DFT, useful e.g. to verify faster algorithms.
@@ -54,20 +55,20 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
var spectrum = new Complex[samples.Length];
CommonParallel.For(0, samples.Length, (u, v) =>
+ {
+ for (int i = u; i < v; i++)
{
- for (int i = u; i < v; i++)
+ var wk = w0*i;
+ var sum = Complex.Zero;
+ for (var n = 0; n < samples.Length; n++)
{
- var wk = w0*i;
- var sum = Complex.Zero;
- for (var n = 0; n < samples.Length; n++)
- {
- var w = n*wk;
- sum += samples[n]*new Complex(Math.Cos(w), Math.Sin(w));
- }
-
- spectrum[i] = sum;
+ var w = n*wk;
+ sum += samples[n]*new Complex(Math.Cos(w), Math.Sin(w));
}
- });
+
+ spectrum[i] = sum;
+ }
+ });
return spectrum;
}
@@ -78,7 +79,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Time-space sample vector.
/// Fourier Transform Convention Options.
/// Corresponding frequency-space vector.
- public Complex[] NaiveForward(Complex[] timeSpace, FourierOptions options)
+ public static Complex[] NaiveForward(Complex[] timeSpace, FourierOptions options)
{
var frequencySpace = Naive(timeSpace, SignByOptions(options));
ForwardScaleByOptions(options, frequencySpace);
@@ -91,7 +92,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Frequency-space sample vector.
/// Fourier Transform Convention Options.
/// Corresponding time-space vector.
- public Complex[] NaiveInverse(Complex[] frequencySpace, FourierOptions options)
+ public static Complex[] NaiveInverse(Complex[] frequencySpace, FourierOptions options)
{
var timeSpace = Naive(frequencySpace, -SignByOptions(options));
InverseScaleByOptions(options, timeSpace);
diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Options.cs b/src/Numerics/IntegralTransforms/Fourier.Options.cs
similarity index 86%
rename from src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Options.cs
rename to src/Numerics/IntegralTransforms/Fourier.Options.cs
index b13366c1..d1d24e91 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.Options.cs
+++ b/src/Numerics/IntegralTransforms/Fourier.Options.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -28,9 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-namespace MathNet.Numerics.IntegralTransforms.Algorithms
+using System;
+
+namespace MathNet.Numerics.IntegralTransforms
{
- using System;
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
@@ -39,7 +40,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Complex Fast (FFT) Implementation of the Discrete Fourier Transform (DFT).
///
- public partial class DiscreteFourierTransform
+ public static partial class Fourier
{
///
/// Extract the exponent sign to be used in forward transforms according to the
@@ -47,7 +48,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Fourier Transform Convention Options.
/// Fourier series exponent sign.
- private static int SignByOptions(FourierOptions options)
+ static int SignByOptions(FourierOptions options)
{
return (options & FourierOptions.InverseExponent) == FourierOptions.InverseExponent ? 1 : -1;
}
@@ -57,7 +58,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Fourier Transform Convention Options.
/// Sample Vector.
- private static void ForwardScaleByOptions(FourierOptions options, Complex[] samples)
+ static void ForwardScaleByOptions(FourierOptions options, Complex[] samples)
{
if ((options & FourierOptions.NoScaling) == FourierOptions.NoScaling ||
(options & FourierOptions.AsymmetricScaling) == FourierOptions.AsymmetricScaling)
@@ -65,7 +66,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
return;
}
- var scalingFactor = Math.Sqrt(1.0 / samples.Length);
+ var scalingFactor = Math.Sqrt(1.0/samples.Length);
for (int i = 0; i < samples.Length; i++)
{
samples[i] *= scalingFactor;
@@ -77,14 +78,14 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Fourier Transform Convention Options.
/// Sample Vector.
- private static void InverseScaleByOptions(FourierOptions options, Complex[] samples)
+ static void InverseScaleByOptions(FourierOptions options, Complex[] samples)
{
if ((options & FourierOptions.NoScaling) == FourierOptions.NoScaling)
{
return;
}
- var scalingFactor = 1.0 / samples.Length;
+ var scalingFactor = 1.0/samples.Length;
if ((options & FourierOptions.AsymmetricScaling) != FourierOptions.AsymmetricScaling)
{
scalingFactor = Math.Sqrt(scalingFactor);
diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.RadixN.cs b/src/Numerics/IntegralTransforms/Fourier.RadixN.cs
similarity index 92%
rename from src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.RadixN.cs
rename to src/Numerics/IntegralTransforms/Fourier.RadixN.cs
index f7069dfd..c63373dd 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteFourierTransform.RadixN.cs
+++ b/src/Numerics/IntegralTransforms/Fourier.RadixN.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -32,7 +32,7 @@ using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
-namespace MathNet.Numerics.IntegralTransforms.Algorithms
+namespace MathNet.Numerics.IntegralTransforms
{
#if !NOSYSNUMERICS
@@ -42,7 +42,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Complex Fast (FFT) Implementation of the Discrete Fourier Transform (DFT).
///
- public partial class DiscreteFourierTransform
+ public static partial class Fourier
{
///
/// Radix-2 Reorder Helper Method
@@ -136,12 +136,12 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
var size = levelSize;
CommonParallel.For(0, size, (u, v) =>
+ {
+ for (int i = u; i < v; i++)
{
- for (int i = u; i < v; i++)
- {
- Radix2Step(samples, exponentSign, size, i);
- }
- });
+ Radix2Step(samples, exponentSign, size, i);
+ }
+ });
}
}
@@ -151,7 +151,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Sample vector, where the FFT is evaluated in place.
/// Fourier Transform Convention Options.
///
- public void Radix2Forward(Complex[] samples, FourierOptions options)
+ public static void Radix2Forward(Complex[] samples, FourierOptions options)
{
Radix2Parallel(samples, SignByOptions(options));
ForwardScaleByOptions(options, samples);
@@ -163,7 +163,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Sample vector, where the FFT is evaluated in place.
/// Fourier Transform Convention Options.
///
- public void Radix2Inverse(Complex[] samples, FourierOptions options)
+ public static void Radix2Inverse(Complex[] samples, FourierOptions options)
{
Radix2Parallel(samples, -SignByOptions(options));
InverseScaleByOptions(options, samples);
diff --git a/src/Numerics/IntegralTransforms/FourierOptions.cs b/src/Numerics/IntegralTransforms/FourierOptions.cs
index a08b5a92..a7f7c35c 100644
--- a/src/Numerics/IntegralTransforms/FourierOptions.cs
+++ b/src/Numerics/IntegralTransforms/FourierOptions.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace MathNet.Numerics.IntegralTransforms
{
- using System;
-
///
/// Fourier Transform Convention
///
diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteHartleyTransform.Naive.cs b/src/Numerics/IntegralTransforms/Hartley.Naive.cs
similarity index 91%
rename from src/Numerics/IntegralTransforms/Algorithms/DiscreteHartleyTransform.Naive.cs
rename to src/Numerics/IntegralTransforms/Hartley.Naive.cs
index 6c5905d9..5d7c68fd 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteHartleyTransform.Naive.cs
+++ b/src/Numerics/IntegralTransforms/Hartley.Naive.cs
@@ -28,15 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-namespace MathNet.Numerics.IntegralTransforms.Algorithms
-{
- using System;
- using Threading;
+using System;
+using MathNet.Numerics.Threading;
+namespace MathNet.Numerics.IntegralTransforms
+{
///
/// Fast (FHT) Implementation of the Discrete Hartley Transform (DHT).
///
- public partial class DiscreteHartleyTransform
+ public static partial class Hartley
{
///
/// Naive generic DHT, useful e.g. to verify faster algorithms.
@@ -73,7 +73,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Time-space sample vector.
/// Hartley Transform Convention Options.
/// Corresponding frequency-space vector.
- public double[] NaiveForward(double[] timeSpace, HartleyOptions options)
+ public static double[] NaiveForward(double[] timeSpace, HartleyOptions options)
{
var frequencySpace = Naive(timeSpace);
ForwardScaleByOptions(options, frequencySpace);
@@ -86,7 +86,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
/// Frequency-space sample vector.
/// Hartley Transform Convention Options.
/// Corresponding time-space vector.
- public double[] NaiveInverse(double[] frequencySpace, HartleyOptions options)
+ public static double[] NaiveInverse(double[] frequencySpace, HartleyOptions options)
{
var timeSpace = Naive(frequencySpace);
InverseScaleByOptions(options, timeSpace);
diff --git a/src/Numerics/IntegralTransforms/Algorithms/DiscreteHartleyTransform.Options.cs b/src/Numerics/IntegralTransforms/Hartley.Options.cs
similarity index 86%
rename from src/Numerics/IntegralTransforms/Algorithms/DiscreteHartleyTransform.Options.cs
rename to src/Numerics/IntegralTransforms/Hartley.Options.cs
index 403ee533..7e4c896a 100644
--- a/src/Numerics/IntegralTransforms/Algorithms/DiscreteHartleyTransform.Options.cs
+++ b/src/Numerics/IntegralTransforms/Hartley.Options.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -28,21 +28,21 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-namespace MathNet.Numerics.IntegralTransforms.Algorithms
-{
- using System;
+using System;
+namespace MathNet.Numerics.IntegralTransforms
+{
///
/// Fast (FHT) Implementation of the Discrete Hartley Transform (DHT).
///
- public partial class DiscreteHartleyTransform
+ public static partial class Hartley
{
///
/// Rescale FFT-the resulting vector according to the provided convention options.
///
/// Fourier Transform Convention Options.
/// Sample Vector.
- private static void ForwardScaleByOptions(HartleyOptions options, double[] samples)
+ static void ForwardScaleByOptions(HartleyOptions options, double[] samples)
{
if ((options & HartleyOptions.NoScaling) == HartleyOptions.NoScaling ||
(options & HartleyOptions.AsymmetricScaling) == HartleyOptions.AsymmetricScaling)
@@ -50,7 +50,7 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
return;
}
- var scalingFactor = Math.Sqrt(1.0 / samples.Length);
+ var scalingFactor = Math.Sqrt(1.0/samples.Length);
for (int i = 0; i < samples.Length; i++)
{
samples[i] *= scalingFactor;
@@ -62,14 +62,14 @@ namespace MathNet.Numerics.IntegralTransforms.Algorithms
///
/// Fourier Transform Convention Options.
/// Sample Vector.
- private static void InverseScaleByOptions(HartleyOptions options, double[] samples)
+ static void InverseScaleByOptions(HartleyOptions options, double[] samples)
{
if ((options & HartleyOptions.NoScaling) == HartleyOptions.NoScaling)
{
return;
}
- var scalingFactor = 1.0 / samples.Length;
+ var scalingFactor = 1.0/samples.Length;
if ((options & HartleyOptions.AsymmetricScaling) != HartleyOptions.AsymmetricScaling)
{
scalingFactor = Math.Sqrt(scalingFactor);
diff --git a/src/Numerics/IntegralTransforms/Transform.cs b/src/Numerics/IntegralTransforms/Transform.cs
index 7fe56944..371758ef 100644
--- a/src/Numerics/IntegralTransforms/Transform.cs
+++ b/src/Numerics/IntegralTransforms/Transform.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2010 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -28,8 +28,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-using MathNet.Numerics.IntegralTransforms.Algorithms;
-
namespace MathNet.Numerics.IntegralTransforms
{
@@ -42,15 +40,13 @@ namespace MathNet.Numerics.IntegralTransforms
///
public static class Transform
{
- private static readonly DiscreteFourierTransform DFT = new DiscreteFourierTransform();
-
///
/// Applies the forward Fast Fourier Transform (FFT) to arbitrary-length sample vectors.
///
/// Sample vector, where the FFT is evaluated in place.
public static void FourierForward(Complex[] samples)
{
- DFT.BluesteinForward(samples, FourierOptions.Default);
+ Fourier.BluesteinForward(samples, FourierOptions.Default);
}
///
@@ -60,7 +56,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Fourier Transform Convention Options.
public static void FourierForward(Complex[] samples, FourierOptions options)
{
- DFT.BluesteinForward(samples, options);
+ Fourier.BluesteinForward(samples, options);
}
///
@@ -69,7 +65,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Sample vector, where the FFT is evaluated in place.
public static void FourierInverse(Complex[] samples)
{
- DFT.BluesteinInverse(samples, FourierOptions.Default);
+ Fourier.BluesteinInverse(samples, FourierOptions.Default);
}
///
@@ -79,7 +75,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// Fourier Transform Convention Options.
public static void FourierInverse(Complex[] samples, FourierOptions options)
{
- DFT.BluesteinInverse(samples, options);
+ Fourier.BluesteinInverse(samples, options);
}
}
}
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index 7f874aff..d96ef466 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -371,14 +371,14 @@
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/src/UnitTests/IntegralTransformsTests/FourierTest.cs b/src/UnitTests/IntegralTransformsTests/FourierTest.cs
index 54860777..c73aca92 100644
--- a/src/UnitTests/IntegralTransformsTests/FourierTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/FourierTest.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 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
@@ -12,8 +14,10 @@
// 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
@@ -27,7 +31,6 @@
using System;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.IntegralTransforms;
-using MathNet.Numerics.IntegralTransforms.Algorithms;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
@@ -60,8 +63,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var samples = Generate.PeriodicMap(16, w => new Complex(Math.Sin(w), 0), 16, 1.0, Constants.Pi2);
// real-odd transforms to imaginary odd
- var dft = new DiscreteFourierTransform();
- var spectrum = dft.NaiveForward(samples, FourierOptions.Matlab);
+ var spectrum = Fourier.NaiveForward(samples, FourierOptions.Matlab);
// all real components must be zero
foreach (var c in spectrum)
@@ -94,12 +96,11 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
public void Radix2ThrowsWhenNotPowerOfTwo()
{
var samples = Generate.RandomComplex(0x7F, GetUniform(1));
- var dft = new DiscreteFourierTransform();
- Assert.Throws(typeof (ArgumentException), () => dft.Radix2Forward(samples, FourierOptions.Default));
- Assert.Throws(typeof (ArgumentException), () => dft.Radix2Inverse(samples, FourierOptions.Default));
- Assert.Throws(typeof (ArgumentException), () => DiscreteFourierTransform.Radix2(samples, -1));
- Assert.Throws(typeof (ArgumentException), () => DiscreteFourierTransform.Radix2Parallel(samples, -1));
+ Assert.Throws(typeof (ArgumentException), () => Fourier.Radix2Forward(samples, FourierOptions.Default));
+ Assert.Throws(typeof (ArgumentException), () => Fourier.Radix2Inverse(samples, FourierOptions.Default));
+ Assert.Throws(typeof (ArgumentException), () => Fourier.Radix2(samples, -1));
+ Assert.Throws(typeof (ArgumentException), () => Fourier.Radix2Parallel(samples, -1));
}
}
}
diff --git a/src/UnitTests/IntegralTransformsTests/HartleyTest.cs b/src/UnitTests/IntegralTransformsTests/HartleyTest.cs
index 1374e670..a2da4c73 100644
--- a/src/UnitTests/IntegralTransformsTests/HartleyTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/HartleyTest.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 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
@@ -12,8 +14,10 @@
// 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
@@ -27,7 +31,6 @@
using System;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.IntegralTransforms;
-using MathNet.Numerics.IntegralTransforms.Algorithms;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
@@ -80,7 +83,6 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(HartleyOptions.NoScaling, FourierOptions.NoScaling)]
public void NaiveMatchesDft(HartleyOptions hartleyOptions, FourierOptions fourierOptions)
{
- var dht = new DiscreteHartleyTransform();
var samples = Generate.Random(0x80, GetUniform(1));
VerifyMatchesDft(
@@ -88,13 +90,13 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
5,
false,
s => Transform.FourierForward(s, fourierOptions),
- s => dht.NaiveForward(s, hartleyOptions));
+ s => Hartley.NaiveForward(s, hartleyOptions));
VerifyMatchesDft(
samples,
5,
true,
s => Transform.FourierInverse(s, fourierOptions),
- s => dht.NaiveInverse(s, hartleyOptions));
+ s => Hartley.NaiveInverse(s, hartleyOptions));
}
}
}
diff --git a/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs b/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
index 0da1f5ae..85e288c3 100644
--- a/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 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
@@ -12,8 +14,10 @@
// 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
@@ -26,7 +30,6 @@
using MathNet.Numerics.Distributions;
using MathNet.Numerics.IntegralTransforms;
-using MathNet.Numerics.IntegralTransforms.Algorithms;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
@@ -58,16 +61,14 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.Matlab)]
public void FourierNaiveIsReversible(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
-
var samples = Generate.RandomComplex(0x80, GetUniform(1));
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
- work = dft.NaiveForward(work, options);
+ work = Fourier.NaiveForward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
- work = dft.NaiveInverse(work, options);
+ work = Fourier.NaiveInverse(work, options);
AssertHelpers.ListAlmostEqual(samples, work, 12);
}
@@ -79,16 +80,14 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.Matlab)]
public void FourierRadix2IsReversible(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
-
var samples = Generate.RandomComplex(0x8000, GetUniform(1));
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
- dft.Radix2Forward(work, options);
+ Fourier.Radix2Forward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
- dft.Radix2Inverse(work, options);
+ Fourier.Radix2Inverse(work, options);
AssertHelpers.ListAlmostEqual(samples, work, 12);
}
@@ -100,16 +99,14 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.Matlab)]
public void FourierBluesteinIsReversible(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
-
var samples = Generate.RandomComplex(0x7FFF, GetUniform(1));
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
- dft.BluesteinForward(work, options);
+ Fourier.BluesteinForward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
- dft.BluesteinInverse(work, options);
+ Fourier.BluesteinInverse(work, options);
AssertHelpers.ListAlmostEqual(samples, work, 10);
}
@@ -121,16 +118,14 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(HartleyOptions.AsymmetricScaling)]
public void HartleyNaiveIsReversible(HartleyOptions options)
{
- var dht = new DiscreteHartleyTransform();
-
var samples = Generate.Random(0x80, GetUniform(1));
var work = new double[samples.Length];
samples.CopyTo(work, 0);
- work = dht.NaiveForward(work, options);
+ work = Hartley.NaiveForward(work, options);
Assert.IsFalse(work.ListAlmostEqual(samples, 6));
- work = dht.NaiveInverse(work, options);
+ work = Hartley.NaiveInverse(work, options);
AssertHelpers.ListAlmostEqual(samples, work, 12);
}
diff --git a/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs b/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
index a61e9f4f..8a94c543 100644
--- a/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 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
@@ -12,8 +14,10 @@
// 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
@@ -27,7 +31,6 @@
using System;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.IntegralTransforms;
-using MathNet.Numerics.IntegralTransforms.Algorithms;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
@@ -78,20 +81,19 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.NumericalRecipes)]
public void FourierRadix2MatchesNaiveOnRealSine(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
var samples = Generate.PeriodicMap(16, w => new Complex(Math.Sin(w), 0), 16, 1.0, Constants.Pi2);
VerifyMatchesNaiveComplex(
samples,
12,
- s => dft.NaiveForward(s, options),
- s => dft.Radix2Forward(s, options));
+ s => Fourier.NaiveForward(s, options),
+ s => Fourier.Radix2Forward(s, options));
VerifyMatchesNaiveComplex(
samples,
12,
- s => dft.NaiveInverse(s, options),
- s => dft.Radix2Inverse(s, options));
+ s => Fourier.NaiveInverse(s, options),
+ s => Fourier.Radix2Inverse(s, options));
}
///
@@ -103,20 +105,19 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.NumericalRecipes)]
public void FourierRadix2MatchesNaiveOnRandom(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
var samples = Generate.RandomComplex(0x80, GetUniform(1));
VerifyMatchesNaiveComplex(
samples,
10,
- s => dft.NaiveForward(s, options),
- s => dft.Radix2Forward(s, options));
+ s => Fourier.NaiveForward(s, options),
+ s => Fourier.Radix2Forward(s, options));
VerifyMatchesNaiveComplex(
samples,
10,
- s => dft.NaiveInverse(s, options),
- s => dft.Radix2Inverse(s, options));
+ s => Fourier.NaiveInverse(s, options),
+ s => Fourier.Radix2Inverse(s, options));
}
///
@@ -128,20 +129,19 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.NumericalRecipes)]
public void FourierBluesteinMatchesNaiveOnRealSineNonPowerOfTwo(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
var samples = Generate.PeriodicMap(14, w => new Complex(Math.Sin(w), 0), 14, 1.0, Constants.Pi2);
VerifyMatchesNaiveComplex(
samples,
12,
- s => dft.NaiveForward(s, options),
- s => dft.BluesteinForward(s, options));
+ s => Fourier.NaiveForward(s, options),
+ s => Fourier.BluesteinForward(s, options));
VerifyMatchesNaiveComplex(
samples,
12,
- s => dft.NaiveInverse(s, options),
- s => dft.BluesteinInverse(s, options));
+ s => Fourier.NaiveInverse(s, options),
+ s => Fourier.BluesteinInverse(s, options));
}
///
@@ -153,20 +153,19 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.NumericalRecipes)]
public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
var samples = Generate.RandomComplex(0x80, GetUniform(1));
VerifyMatchesNaiveComplex(
samples,
10,
- s => dft.NaiveForward(s, options),
- s => dft.BluesteinForward(s, options));
+ s => Fourier.NaiveForward(s, options),
+ s => Fourier.BluesteinForward(s, options));
VerifyMatchesNaiveComplex(
samples,
10,
- s => dft.NaiveInverse(s, options),
- s => dft.BluesteinInverse(s, options));
+ s => Fourier.NaiveInverse(s, options),
+ s => Fourier.BluesteinInverse(s, options));
}
///
@@ -178,19 +177,18 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
[TestCase(FourierOptions.NumericalRecipes)]
public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options)
{
- var dft = new DiscreteFourierTransform();
var samples = Generate.RandomComplex(0x7F, GetUniform(1));
VerifyMatchesNaiveComplex(
samples,
10,
- s => dft.NaiveForward(s, options),
- s => dft.BluesteinForward(s, options));
+ s => Fourier.NaiveForward(s, options),
+ s => Fourier.BluesteinForward(s, options));
VerifyMatchesNaiveComplex(
samples,
10,
- s => dft.NaiveInverse(s, options),
- s => dft.BluesteinInverse(s, options));
+ s => Fourier.NaiveInverse(s, options),
+ s => Fourier.BluesteinInverse(s, options));
}
}
}
diff --git a/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs b/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
index 7d8d1c0c..ca7cfe2a 100644
--- a/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
+++ b/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 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
@@ -12,8 +14,10 @@
// 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
@@ -27,7 +31,6 @@
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.IntegralTransforms;
-using MathNet.Numerics.IntegralTransforms.Algorithms;
using MathNet.Numerics.Statistics;
using NUnit.Framework;
@@ -91,12 +94,10 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
samples.CopyTo(work, 0);
// Default -> Symmetric Scaling
- var dht = new DiscreteHartleyTransform();
- work = dht.NaiveForward(work, HartleyOptions.Default);
+ work = Hartley.NaiveForward(work, HartleyOptions.Default);
var frequencySpaceEnergy = (from s in work select s*s).Mean();
Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12);
}
}
}
-