Browse Source

transforms: now testing parseval's theorem

Signed-off-by: Christoph Ruegg <git@cdrnet.ch>
pull/2/head
Christoph Ruegg 17 years ago
parent
commit
208828f07f
  1. 20
      src/Managed.UnitTests/IntegralTransformsTests/DftTest.cs
  2. 2
      src/Managed.UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs
  3. 2
      src/Managed.UnitTests/StatisticsTests/StatTestData.cs
  4. 2
      src/Managed.UnitTests/StatisticsTests/StatisticsTests.cs

20
src/Managed.UnitTests/IntegralTransformsTests/DftTest.cs

@ -29,9 +29,11 @@
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{ {
using System; using System;
using System.Linq;
using MbUnit.Framework; using MbUnit.Framework;
using IntegralTransforms; using IntegralTransforms;
using IntegralTransforms.Algorithms; using IntegralTransforms.Algorithms;
using Statistics;
[TestFixture] [TestFixture]
public class DftTest public class DftTest
@ -242,5 +244,23 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
AssertHelpers.AlmostEqualList(samples, work, 1e-12); AssertHelpers.AlmostEqualList(samples, work, 1e-12);
} }
[Test]
public void TransformSatisfiesParsevalsTheorem()
{
var samples = ProvideSamples(0x1000);
var timeSpaceEnergy = (from s in samples select s.ModulusSquared).Mean();
var work = new Complex[samples.Length];
samples.CopyTo(work, 0);
// Only symmetric scaling scaling satisfies the theorem, hence FourierOptions.Default.
Transform.FourierForward(work, FourierOptions.Default);
var frequencySpaceEnergy = (from s in work select s.ModulusSquared).Mean();
Assert.AreApproximatelyEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12);
}
} }
} }

2
src/Managed.UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs

@ -26,7 +26,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
namespace MathNet.Numerics.UnitTests.Statistics namespace MathNet.Numerics.UnitTests.StatisticsTests
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

2
src/Managed.UnitTests/StatisticsTests/StatTestData.cs

@ -26,7 +26,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
namespace MathNet.Numerics.UnitTests.Statistics namespace MathNet.Numerics.UnitTests.StatisticsTests
{ {
using System.IO; using System.IO;
using System.Linq; using System.Linq;

2
src/Managed.UnitTests/StatisticsTests/StatisticsTests.cs

@ -26,7 +26,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
namespace MathNet.Numerics.UnitTests.Statistics namespace MathNet.Numerics.UnitTests.StatisticsTests
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

Loading…
Cancel
Save