private static void TestFastDctFftInvertibility() { for (int i = 0, prev = 0; i <= 30; i++) { int len = (int)Math.Round(Math.Pow(1000000, i / 30.0)); if (len <= prev) { continue; } prev = len; double[] vector = RandomVector(len); double[] temp = (double[])vector.Clone(); FastDctFft.Transform(temp); FastDctFft.InverseTransform(temp); for (int j = 0; j < temp.Length; j++) { temp[j] /= len / 2.0; } AssertArrayEquals(vector, temp, 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); } }