|
Re: FFT in 1 dimension [message #28494 is a reply to message #28492] |
Fri, 07 December 2001 13:41  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
hradilv.nospam@yahoo.com wrote:
> Here's what I came up with. Any comments?
I haven't examined your code in detail, but there is one line where the
speed of the program can be improved significantly:
Instead of writing
for i=0, nlines-1 do fdata[*,i] = fft(fdata[*,i],inverse=inverse)
write
for i=0, nlines-1 do fdata[0,i] = fft(fdata[*,i],inverse=inverse)
I'm actually not sure why this speed things up. I suppose by writing
fdata[0,i] on the left hand side, you've directly specified a starting
location to place the computation, but if you instead write fdata[*,i]
then IDL first extracts a temporary variable, assigns it to the value of
the computation, and then writes the temporary variable back into
fdata. Still, I would think that the compiler could recognize that
these two notations are equivalent.
--Wayne Landsman landsman@mpb.gsfc.nasa.gov
|
|
|
Re: FFT in 1 dimension [message #28498 is a reply to message #28494] |
Fri, 07 December 2001 12:10  |
hradilv.nospam
Messages: 19 Registered: November 2001
|
Junior Member |
|
|
OOPS - I think this one works:
function ft1d, data, dim, inverse=inverse
ds = size(data)
ndim = ds[0]
nlines = n_elements(data)/ds[dim]
dims = lindgen(ndim)+1
dims[dim-1] = -1
porder = sort(dims)
fdata = transpose(data,porder)
fdata = reform(fdata,ds[dim],nlines)
for i=0, nlines-1 do fdata[*,i] = fft(fdata[*,i],inverse=inverse)
dims[0] = dim
porder = sort(dims)
fdata = reform(fdata,(ds[1:ndim])[porder])
fdata = transpose(fdata,porder)
return, fdata
end
On Fri, 07 Dec 2001 19:05:36 GMT, hradilv.nospam@yahoo.com wrote:
> Here's what I came up with. Any comments?
>
> function ft1d, data, dim, inverse=inverse
>
> ds = size(data)
> ndim = ds[0]
> nlines = n_elements(data)/ds[dim]
>
> dims = lindgen(ndim)+1
> dims[dim-1] = -1
> porder = sort(dims)
>
> fdata = transpose(data,porder)
> fdata = reform(fdata,ds[dim],nlines)
>
> for i=0, nlines-1 do fdata[*,i] = fft(fdata[*,i],inverse=inverse)
>
> porder = (ds[1:ndim])[sort(dims)]
> fdata = reform(fdata,porder)
> fdata = transpose(fdata,sort(porder))
>
> return, fdata
> end
>
|
|
|
Re: FFT in 1 dimension [message #28500 is a reply to message #28498] |
Fri, 07 December 2001 11:05  |
hradilv.nospam
Messages: 19 Registered: November 2001
|
Junior Member |
|
|
Here's what I came up with. Any comments?
function ft1d, data, dim, inverse=inverse
ds = size(data)
ndim = ds[0]
nlines = n_elements(data)/ds[dim]
dims = lindgen(ndim)+1
dims[dim-1] = -1
porder = sort(dims)
fdata = transpose(data,porder)
fdata = reform(fdata,ds[dim],nlines)
for i=0, nlines-1 do fdata[*,i] = fft(fdata[*,i],inverse=inverse)
porder = (ds[1:ndim])[sort(dims)]
fdata = reform(fdata,porder)
fdata = transpose(fdata,sort(porder))
return, fdata
end
|
|
|