Exemplo n.º 1
0
        public void Transform1DArguments()
        {
            Assert.Throws <ArgumentNullException>(() => FastFourierTransformF.Transform1D(null, true));
            Assert.Throws <ArgumentNullException>(() => FastFourierTransformF.Transform1D(null, 2, true));

            Assert.Throws <ArgumentException>(() => FastFourierTransformF.Transform1D(new Vector2F[0], true));
            Assert.Throws <ArgumentException>(() => FastFourierTransformF.Transform1D(new Vector2F[13], true));

            FastFourierTransformF.Transform1D(new Vector2F[1], true);

            // This is ok.
            FastFourierTransformF.Transform1D(new Vector2F[2], true);
            FastFourierTransformF.Transform1D(new Vector2F[16], false);
        }
Exemplo n.º 2
0
        public void Transform1DComparedWithDft()
        {
            // Transform forward and inverse and compare with initial values.
            var random = new Random(1234567);

            var s = new Vector2F[16];
            var t = new Vector2F[16];

            for (int i = 0; i < s.Length; i++)
            {
                s[i] = random.NextVector2F(-10, 10);
                t[i] = s[i];
            }

            FastFourierTransformF.DFT(s, true);
            FastFourierTransformF.Transform1D(t, true);

            for (int i = 0; i < s.Length; i++)
            {
                Assert.IsTrue(Vector2F.AreNumericallyEqual(s[i], t[i]));
            }
        }
Exemplo n.º 3
0
        public void Transform1DAs2DRow()
        {
            // Result of 2D with one row/column must be the same as 1D.
            var fft = new FastFourierTransformF(16);

            var random = new Random(1234567);

            var s1D = new Vector2F[8];
            var s2D = new Vector2F[1, 8];

            for (int i = 0; i < s1D.Length; i++)
            {
                s1D[i]    = random.NextVector2F(-10, 10);
                s2D[0, i] = s1D[i];
            }

            FastFourierTransformF.Transform1D(s1D, true);
            fft.Transform2D(s2D, true);

            for (int i = 0; i < s1D.Length; i++)
            {
                Assert.AreEqual(s1D[i], s2D[0, i]);
            }
        }