public void HartleyNaiveIsReversible(HartleyOptions options) { var samples = Generate.Random(0x80, GetUniform(1)); var work = new double[samples.Length]; samples.CopyTo(work, 0); work = Hartley.NaiveForward(work, options); Assert.IsFalse(work.ListAlmostEqual(samples, 6)); work = Hartley.NaiveInverse(work, options); AssertHelpers.AlmostEqual(samples, work, 12); }
public void HartleyDefaultNaiveSatisfiesParsevalsTheorem64(int count) { var samples = Generate.Random(count, GetUniform(1)); var timeSpaceEnergy = (from s in samples select s * s).Mean(); var spectrum = new double[samples.Length]; samples.CopyTo(spectrum, 0); spectrum = Hartley.NaiveForward(spectrum, HartleyOptions.Default); var frequencySpaceEnergy = (from s in spectrum select s * s).Mean(); Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12); }
public void HartleyDefaultNaiveSatisfiesParsevalsTheorem(int count) { var samples = Generate.Random(count, GetUniform(1)); var timeSpaceEnergy = (from s in samples select s * s).Mean(); var work = new double[samples.Length]; samples.CopyTo(work, 0); // Default -> Symmetric Scaling work = Hartley.NaiveForward(work, HartleyOptions.Default); var frequencySpaceEnergy = (from s in work select s * s).Mean(); Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12); }
public void NaiveMatchesDft(HartleyOptions hartleyOptions, FourierOptions fourierOptions) { var samples = Generate.Random(0x80, GetUniform(1)); VerifyMatchesDft( samples, 5, false, s => Fourier.Forward(s, fourierOptions), s => Hartley.NaiveForward(s, hartleyOptions)); VerifyMatchesDft( samples, 5, true, s => Fourier.Inverse(s, fourierOptions), s => Hartley.NaiveInverse(s, hartleyOptions)); }