Re: Confused by FFTW output

From: Martin Brown (|||newspam|||_at_nezumi.demon.co.uk)
Date: 03/15/05


Date: Tue, 15 Mar 2005 18:16:40 +0000

Tom wrote:

> Hi,
> I am trying to get acquainted with the latest FFTW and wrote a small
> test program to ensure correct usage by comparing a computed spectrum
> with an analytical solution. For a start, I chose a Gaussian,
> f(t)=exp(-a*t^2), whose spectrum is a purely real function, namely
> F(w)=sqrt(pi/(4a))*exp(-w^2/(4a)). However, when computing the spectrum
> with FFTW, I get a nonvanishing imaginary part in the transform,

This is because the function you have input is not symmetrical about the
phase centre. Its FFT must contain non-zero sine coefficeints.

> real, dimension(n) :: sig
> complex, dimension(n/2+1) :: spec
> a=0.2
> ttot=10.
> dt=ttot/float(n-1)
> df=1./(2.*dt*float(n/2))
> ! signal
> do i=1,n
> t=(i-1)*dt-ttot/2
> sig(i)=exp(-a*t*t)
> write(10,*) i,t,sig(i)
> end do

This isn't a symmetric function. Hence the phase structure.
It should satisfy something like sig(1+i) == sig(n+1-i) for i>1
(perhaps with a shift by n/2)

Regards,
Martin Brown


Loading