예제 #1
0
        public void NaiveMatchesDft(HartleyOptions hartleyOptions, FourierOptions fourierOptions)
        {
            var dht = new DiscreteHartleyTransform();
            var samples = Generate.Random(0x80, GetUniform(1));

            VerifyMatchesDft(
                samples,
                5,
                false,
                s => Transform.FourierForward(s, fourierOptions),
                s => dht.NaiveForward(s, hartleyOptions));
            VerifyMatchesDft(
                samples,
                5,
                true,
                s => Transform.FourierInverse(s, fourierOptions),
                s => dht.NaiveInverse(s, hartleyOptions));
        }
        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
            var dht = new DiscreteHartleyTransform();
            work = dht.NaiveForward(work, HartleyOptions.Default);

            var frequencySpaceEnergy = (from s in work select s*s).Mean();
            Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12);
        }
        public void HartleyNaiveIsReversible(HartleyOptions options)
        {
            var dht = new DiscreteHartleyTransform();

            VerifyIsReversibleReal(
                0x80,
                1e-9,
                s => dht.NaiveForward(s, options),
                s => dht.NaiveInverse(s, options));
        }
        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);
            Assert.IsFalse(work.ListAlmostEqual(samples, 6));

            work = dht.NaiveInverse(work, options);
            AssertHelpers.ListAlmostEqual(samples, work, 12);
        }