Re: Using Fourier and InverseFourier instead of Convolve
- To: mathgroup at smc.vnet.net
- Subject: [mg85875] Re: Using Fourier and InverseFourier instead of Convolve
- From: m.r at inbox.ru
- Date: Tue, 26 Feb 2008 07:47:12 -0500 (EST)
- References: <fpooi0$1cg$1@smc.vnet.net>
On Feb 23, 3:21=A0am, "Solomon, Joshua" <J.A.Solo... at city.ac.uk> wrote:
> OK, I must admit that I do not understand everything ListConvolve does, bu=
t
> I get the convolution I need when I do
> ListConvolve[list1, list2, {1, -1}, 0]
> In particular, the output has the appropriate length:
> Length[list1]+Length[list2]-1.
> Now, I would like to get the identical using Fourier and InverseFourier.
> Is this possible? What is the appropriate syntax?
> j
It's certainly possible:
In[1]:= {m, n} = {100, 200};
{list1, list2} = RandomReal[{-10, 10}, #]& /@ {m, n};
In[3]:= Norm[ListConvolve[list1, list2, {1, -1}, 0] -
Sqrt[m + n - 1] InverseFourier[
Fourier[PadRight[list1, m + n - 1, 0.]]
Fourier[PadRight[list2, m + n - 1, 0.]]]]
Out[3]= 2.5382019*10^-12
Maxim Rytin
m.r at inbox.ru