[SciPy-user] Re: Help on performance of signal.convolve
Yichun Wei
yichunwe at usc.edu
Tue Jan 18 17:47:52 EST 2005
Hi Travis,
Travis Oliphant wrote:
> So, something like the following untested code should get you started:
>
> def convolvefft(arr1,arr2):
> s1 = array(arr1.shape())
> s2 = array(arr2.shape())
> fftsize = s1 + s2 - 1
> # finds the closest power of 2 in each dimension (you may comment
> this out and compare speeds)
> fftsize= pow(2,ceil(log2(fftsize)))
I tried for larger kernels. This does matters!
>
> ARR1 = fftn(arr1,fftsize)
> ARR2 = fftn(arr2,fftsize)
>
> RES = ifftn(ARR1*ARR2)
> #RES=RES[validpart] # I'm not sure how to get the correct part
> --- first try would be to just truncate to the shape you wanted
> return RES
Using this code a convolution of (16,16,40) kernel with (16,16,1800)
signal takes 5s to solve on my 1.8G P-IV CPU.
Because I am only interested in the "valid" convolution. What could be
used to speed this up a bit more? I am really in need of speed for I
have to do this convolution lots of times.
best,
- yichun
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: convolvefft.py
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20050118/af36fa32/attachment.ksh>
More information about the SciPy-User
mailing list