comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Inverse FFT
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Inverse FFT [message #33280 is a reply to message #33221] Tue, 17 December 2002 07:02 Go to previous messageGo to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
Here is an (main level) example that hopefully does what you want.
Note the slightly better precision of the fft method, due to the superior
method of calculating the same thing. Also, there is a huge difference
in speed, especially as N gets larger than say 10 or so.
On my computer 1.6Ghz athlon, the times are about a factor of 20.
(i.e. fft 20 times faster than "by hand").
The point I am getting to is "don't inverse fft by hand".


And note that I left the resulting
arrays as complex, but it is equal to the original time series, since the
imaginary part is zero. You may want to cast them to float (or double)

Cheers,
bob stockwell



; make a time series
len = 16
a = randomn(seed,len)
a = double(a)

; calc spectrum
ft = fft(a)

; inverse by fft FAST!
tic = systime(1)
ift = fft(ft,/inverse)
toc = systime(1)
print,'fft time = ', (toc - tic)*1000d ; microseconds

; inverse by hand SLOW!
tic = systime(1)
byhand = dcomplexarr(len)
t = dindgen(len)
for i = 0,len-1 do begin
byhand = byhand + ft[i]*exp(complex(0,1)*2*!dpi*t*i/len)
endfor
toc = systime(1)
print,'by hand time = ', (toc - tic)*1000d

; print out results
print,'original time series'
print,a
print,'inverse by fft'
print,ift
print,'inverse by hand'
print,byhand

; plot out results
!p.multi = [ 0,1,3]
plot,a,tit='timeseries'
plot,ift,tit='by fft'
oplot,imaginary(ift),linestyle=2
plot,byhand,tit='byhand'
oplot,imaginary(byhand),linestyle=2
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: What I Want for Christmas.
Next Topic: Re: IDLDE refresh in Windows XP (IDL 5.2.1)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 09:48:34 PDT 2025

Total time taken to generate the page: 0.39096 seconds