Beispiel #1
0
        public void FourierNaiveIsReversible(FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();

            VerifyIsReversibleComplex(
                0x80,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.NaiveInverse(s, options));
        }
Beispiel #2
0
        public void FourierNaiveIsReversible(FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();

            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), GetUniform(1), 0x80);
            var work    = new Complex[samples.Length];

            samples.CopyTo(work, 0);

            work = dft.NaiveForward(work, options);
            Assert.IsFalse(work.ListAlmostEqual(samples, 6));

            work = dft.NaiveInverse(work, options);
            AssertHelpers.ListAlmostEqual(samples, work, 12);
        }
Beispiel #3
0
        public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options)
        {
            var dft     = new DiscreteFourierTransform();
            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x7F);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));
            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }
        public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();
            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x7F);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));
            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }
Beispiel #5
0
        public void FourierRadix2MatchesNaiveOnRealSine(FourierOptions options)
        {
            var dft     = new DiscreteFourierTransform();
            var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 16);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.Radix2Forward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.Radix2Inverse(s, options));
        }
Beispiel #6
0
        public void FourierRadix2MatchesNaiveOnRandom(FourierOptions options)
        {
            var dft     = new DiscreteFourierTransform();
            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x80);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.Radix2Forward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.Radix2Inverse(s, options));
        }
        public void FourierBluesteinMatchesNaiveOnRealSineNonPowerOfTwo(FourierOptions options)
        {
            var dft     = new DiscreteFourierTransform();
            var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 14);

            VerifyMatchesNaiveComplex(
                samples,
                12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }
Beispiel #8
0
        public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options)
        {
            var dft     = new DiscreteFourierTransform();
            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x80);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }
        public void FourierNaiveIsReversible([Values(FourierOptions.Default, FourierOptions.Matlab)] FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();

            VerifyIsReversibleComplex(
                0x80, 
                1e-12, 
                s => dft.NaiveForward(s, options), 
                s => dft.NaiveInverse(s, options));
        }
        public void FourierRadix2MatchesNaiveOnRealSine(FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();
            var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 16);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.Radix2Forward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.Radix2Inverse(s, options));
        }
        public void FourierRadix2MatchesNaiveOnRandom(FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();
            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), GetUniform(1), 0x80);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.Radix2Forward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.Radix2Inverse(s, options));
        }
        public void FourierBluesteinMatchesNaiveOnRealSineNonPowerOfTwo(FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();
            var samples = Sample.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 14);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }
        public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();
            var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x80);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }
        public void FourierBluesteinMatchesNaiveOnRealSineNonPowerOfTwo([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options)
        {
            var dft = new DiscreteFourierTransform();
            var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 14);

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveForward(s, options),
                s => dft.BluesteinForward(s, options));

            VerifyMatchesNaiveComplex(
                samples,
                1e-12,
                s => dft.NaiveInverse(s, options),
                s => dft.BluesteinInverse(s, options));
        }