def test_fast_dct_lee_vs_naive(self):
     for i in range(1, 12):
         n = 2**i
         vector = FastDctTest.random_vector(n)
         expect = naivedct.transform(vector)
         actual = fastdctlee.transform(vector)
         self.assertListAlmostEqual(actual, expect)
         expect = naivedct.inverse_transform(vector)
         actual = fastdctlee.inverse_transform(vector)
         self.assertListAlmostEqual(actual, expect)
	def test_fast_dct_lee_vs_naive(self):
		for i in range(1, 12):
			n = 2**i
			vector = FastDctTest.random_vector(n)
			expect = naivedct.transform(vector)
			actual = fastdctlee.transform(vector)
			self.assertListAlmostEqual(actual, expect)
			expect = naivedct.inverse_transform(vector)
			actual = fastdctlee.inverse_transform(vector)
			self.assertListAlmostEqual(actual, expect)
    def test_fast_dct8_vs_naive(self):
        vector = FastDctTest.random_vector(8)

        expect = naivedct.transform(vector)
        expect = [(val / (math.sqrt(8) if (i == 0) else 2))
                  for (i, val) in enumerate(expect)]
        actual = fastdct8.transform(vector)
        self.assertListAlmostEqual(actual, expect)

        expect = [(val / (math.sqrt(2) if (i == 0) else 2))
                  for (i, val) in enumerate(vector)]
        expect = naivedct.inverse_transform(expect)
        actual = fastdct8.inverse_transform(vector)
        self.assertListAlmostEqual(actual, expect)
	def test_fast_dct8_vs_naive(self):
		vector = FastDctTest.random_vector(8)
		
		expect = naivedct.transform(vector)
		expect = [(val / (math.sqrt(8) if (i == 0) else 2))
			for (i, val) in enumerate(expect)]
		actual = fastdct8.transform(vector)
		self.assertListAlmostEqual(actual, expect)
		
		expect = [(val / (math.sqrt(2) if (i == 0) else 2))
			for (i, val) in enumerate(vector)]
		expect = naivedct.inverse_transform(expect)
		actual = fastdct8.inverse_transform(vector)
		self.assertListAlmostEqual(actual, expect)
    def test_fast_dct8_vs_naive(self):
        n = 8
        vector = FastDctTest.random_vector(n)

        expect = naivedct.transform(vector)
        for i in range(n):
            expect[i] /= math.sqrt(4 * (2 if (i == 0) else 1))
        actual = fastdct8.transform(vector)
        self.assertListAlmostEqual(actual, expect)

        expect = [(val / math.sqrt(4 / (2 if (i == 0) else 1)))
                  for (i, val) in enumerate(vector)]
        expect = naivedct.inverse_transform(expect)
        actual = fastdct8.inverse_transform(vector)
        self.assertListAlmostEqual(actual, expect)
    def test_fast_dct_fft_vs_naive(self):
        prev = 0
        for i in range(100 + 1):
            n = round(1000**(i / 100.0))
            if n <= prev:
                continue
            prev = n
            vector = FastDctTest.random_vector(n)

            expect = naivedct.transform(vector)
            actual = fastdctfft.transform(vector)
            self.assertListAlmostEqual(actual, expect)

            expect = naivedct.inverse_transform(vector)
            actual = fastdctfft.inverse_transform(vector)
            self.assertListAlmostEqual(actual, expect)
	def test_fast_dct_fft_vs_naive(self):
		prev = 0
		for i in range(100 + 1):
			n = int(round(1000**(i / 100.0)))
			if n <= prev:
				continue
			prev = n
			vector = FastDctTest.random_vector(n)
			
			expect = naivedct.transform(vector)
			actual = fastdctfft.transform(vector)
			self.assertListAlmostEqual(actual, expect)
			
			expect = naivedct.inverse_transform(vector)
			actual = fastdctfft.inverse_transform(vector)
			self.assertListAlmostEqual(actual, expect)