np.convolve
- np.convolve(a, b)
Convolves the input arrays.
See: https://numpy.org/doc/stable/reference/generated/numpy.convolve.html
Examples
In [1]: GF = galois.GF(31) In [2]: a = GF.Random(10) In [3]: b = GF.Random(10) In [4]: np.convolve(a, b) Out[4]: GF([12, 23, 19, 1, 25, 22, 9, 23, 11, 24, 9, 18, 6, 15, 27, 5, 1, 23, 28], order=31) # Equivalent implementation with native numpy In [5]: np.convolve(a.view(np.ndarray).astype(int), b.view(np.ndarray).astype(int)) % 31 Out[5]: array([12, 23, 19, 1, 25, 22, 9, 23, 11, 24, 9, 18, 6, 15, 27, 5, 1, 23, 28])
In [6]: GF = galois.GF(2**8) In [7]: a = GF.Random(10) In [8]: b = GF.Random(10) In [9]: np.convolve(a, b) Out[9]: GF([ 26, 237, 73, 123, 78, 142, 170, 64, 114, 126, 218, 41, 53, 162, 82, 109, 134, 114, 67], order=2^8)