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([14, 9, 9, 21, 6, 1, 15, 23, 17, 11, 29, 12, 16, 14, 15, 26, 11, 1, 25], 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([14, 9, 9, 21, 6, 1, 15, 23, 17, 11, 29, 12, 16, 14, 15, 26, 11, 1, 25])
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([236, 61, 176, 184, 171, 41, 239, 21, 77, 172, 123, 97, 71, 33, 204, 247, 97, 186, 115], order=2^8)