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([ 4, 9, 13, 6, 10, 26, 24, 29, 3, 6, 4, 19, 21, 30, 10, 17, 24, 7, 4], 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([ 4, 9, 13, 6, 10, 26, 24, 29, 3, 6, 4, 19, 21, 30, 10, 17, 24, 7, 4])
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([ 93, 184, 168, 111, 127, 47, 68, 93, 78, 9, 91, 237, 61, 105, 44, 149, 189, 166, 176], order=2^8)