Support for Numpy convolve mode 'valid'
See original GitHub issueFeature request
I’ve been working with model simulations and there’s the need for np.convolve(a, k, mode='valid').
I wish to have support for this for use with @jit/@njit decorators.
I have this example implementation from one of the discussions about using Numba for such situation, but I’d rather not have to resort to it in projects which require valid mode.
def numba_convolve_mode_valid_as_loop(arr, kernel):
m = arr.size
n = kernel.size
out_size = m - n + 1
out = np.empty(out_size, dtype=np.complex128)
kernel = np.flip(kernel) # wrong results otherwise
for i in range(out_size):
out[i] = np.dot(arr[i:i + n], kernel)
return out
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
numpy.convolve — NumPy v1.24 Manual
Mode 'valid' returns output of length max(M, N) - min(M, N) + 1 . The convolution product is only given for points where...
Read more >Understanding NumPy's Convolve - python - Stack Overflow
An array in numpy is a signal. The convolution of two signals is defined as the integral of the first signal, reversed, sweeping...
Read more >np.convolve: How to Use Numpy convolve() Method
The np.convolve() is a built-in numpy library method that returns discrete, linear convolution of two one-dimensional vectors. The numpy ...
Read more >What is the numpy.convolve() method in Python? - Educative.io
Overview. In Python, we use the numpy.convolve() method to calculate the combination of two one-dimensional vectors discretely and linearly.
Read more >Numpy Convolve For Different Modes in Python
In this article, we will discuss the Numpy convolve function in Python. The convolution operator is a mathematical operator primarily used ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hello @danilo-bc, are you still working on this ? Otherwise, I would gladly give it a try!
Labelling as “good second issue” as most of the parts needed for the implementation are already present, but need connecting together. Se e.g. https://github.com/numba/numba/blob/master/numba/np/arraymath.py#L4230-L4251.