diff --git a/src/shamira/tests/test_fft.py b/src/shamira/tests/test_fft.py --- a/src/shamira/tests/test_fft.py +++ b/src/shamira/tests/test_fft.py @@ -31,11 +31,11 @@ class TestFFT(TestCase): for divisors in [[3], [2, 3], [3, 5], [3, 5, 17], [2, 3, 5, 7, 11]]: n = functools.reduce(operator.mul, divisors) coefficients = [random.randint(-128, 127) for i in range(n)] - a = prime_fft(coefficients, divisors) + a = prime_fft(coefficients, divisors, complex_dft) b = complex_dft(coefficients) all(self.assertAlmostEqual(ai, bi) for (ai, bi) in zip(a, b)) - def test_dft(self): + def test_finite_dft(self): random.seed(1918) x = {i: precompute_x(i) for i in [3, 5, 15, 17]} # all sets of xs @@ -45,3 +45,12 @@ class TestFFT(TestCase): dft(coefficients), batch_evaluate(coefficients[::-1], x[n]) ) + + def test_finite_prime_fft(self): + random.seed(1918) + for divisors in [[3], [3, 5], [3, 17], [5, 17], [3, 5, 17]]: + n = functools.reduce(operator.mul, divisors) + coefficients = [random.randint(0, 255) for i in range(n)] + a = prime_fft(coefficients, divisors) + b = dft(coefficients) + all(self.assertAlmostEqual(ai, bi) for (ai, bi) in zip(a, b))