/*---- Test suite ----*/ private static void TestFastDctLeeVsNaive() { for (int len = 1; len <= (1 << 13); len *= 2) { double[] vector = RandomVector(len); double[] expect = NaiveDct.Transform(vector); double[] actual = (double[])vector.Clone(); FastDctLee.Transform(actual); AssertArrayEquals(expect, actual, EPSILON); expect = NaiveDct.InverseTransform(vector); actual = (double[])vector.Clone(); FastDctLee.InverseTransform(actual); AssertArrayEquals(expect, actual, EPSILON); } }
private static void TestFastDctFftVsNaive() { for (int i = 0, prev = 0; i <= 100; i++) { int len = (int)Math.Round(Math.Pow(3000, i / 100.0)); if (len <= prev) { continue; } prev = len; double[] vector = RandomVector(len); double[] expect = NaiveDct.Transform(vector); double[] actual = (double[])vector.Clone(); FastDctFft.Transform(actual); AssertArrayEquals(expect, actual, EPSILON); expect = NaiveDct.InverseTransform(vector); actual = (double[])vector.Clone(); FastDctFft.InverseTransform(actual); AssertArrayEquals(expect, actual, EPSILON); } }
private static void TestFastDct8VsNaive() { double[] vector = RandomVector(8); double[] expect = NaiveDct.Transform(vector); for (int i = 0; i < expect.Length; i++) { expect[i] /= i == 0 ? Math.Sqrt(8) : 2; } double[] actual = (double[])vector.Clone(); FastDct8.Transform(actual); AssertArrayEquals(expect, actual, EPSILON); expect = (double[])vector.Clone(); for (int i = 0; i < expect.Length; i++) { expect[i] /= i == 0 ? Math.Sqrt(2) : 2; } expect = NaiveDct.InverseTransform(expect); actual = (double[])vector.Clone(); FastDct8.InverseTransform(actual); AssertArrayEquals(expect, actual, EPSILON); }