def test_convolution_randomly(self): TRIALS = 100 for _ in range(TRIALS): veclen = random.randrange(100) + 1 maxval = random.randrange(100) + 1 vec0 = [random.randrange(maxval + 1) for _ in range(veclen)] vec1 = [random.randrange(maxval + 1) for _ in range(veclen)] actual = ntt.circular_convolve(vec0, vec1) expect = NumberTheoreticTransformTest._circular_convolve(vec0, vec1) self.assertEqual(expect, actual)
def test_automatic_convolution(self): actual = ntt.circular_convolve( [4, 1, 4, 2, 1, 3, 5, 6], [6, 1, 8, 0, 3, 3, 9, 8]) expect = [123, 120, 106, 92, 139, 144, 140, 124] self.assertEqual(expect, actual)