Closed rhysnewell closed 1 year ago
EDIT: Oops, just saw you using the range
function and not just declaring an array.
this should produce [ 4, 13, 28, 27, 18] but instead produces [23, 12.000000000000005, 6.000000000000002, 17, 31.999999999999993]
AFAICT it should produce 6 17 32 23 12
.
octave:14> a = [1, 2, 3]
a =
1 2 3
octave:15> b = [6, 5, 4]
b =
6 5 4
octave:16> conv(a,b)
ans =
6 17 32 23 12
Although not sure why you're declaring the arrays using the range stuff, easy to make mistakes with.
Your pad_with_zeros
function pads at the start and end. You need to only pad at the end.
You were right on both counts, thank you! I must have got mixed up when I was looking at the output from scipy convolve
and correlate
. Making the padding only occur at the end of the array fixed the issue and made it return the correct result. Thank you!
Thanks for the help @WalterSmuts, N-dimensional implementations of convolve and correlate can be found here: https://github.com/rhysnewell/fftconvolve I'll publish as crate at some point soon
Hello,
Thanks for making this crate. I'm hoping that you'll be able to help me out and perhaps provide some answers on the results I'm getting when using
rustfft
. I'm attempting to implement both 1D and 2D fft convolution as is done inscipy.signal.convolve
andscipy.signal.correlate
. The idea being that I'll be able to speed up some large pairwise matrix correlation calculations that I need to perform. Here is my current attempt at a 1-dimensional convolution algorithm which is the easy case:I've got this simple test case:
this should produce
[ 4, 13, 28, 27, 18]
but instead produces[23, 12.000000000000005, 6.000000000000002, 17, 31.999999999999993]
ignore the floating point imprecision. At this point, I can't really tell where I am going wrong. I feel like it has something to do with the normalization, but I think I'm doing that right so I'm really not sure. Any help you could provide would be great.Also, I feel like a convolution algorithm is a logical next step for
rustfft
so I was hoping if I could get this working we could add it into a pull request or something if you would likeCheers, Rhys