[Numpy-discussion] 2-D FFT input/ouput storage
Robert Kern
rkern at ucsd.edu
Wed Jul 27 15:03:08 EDT 2005
Daniel Sheltraw wrote:
> Hello All
>
> Now that I have Numeric loading properly at the Python command line I
> went in search of some docs on the 2-D FFT. How are the input and output
> to the forward and inverse 2-D FFTs stored? Is it simply a 2-D version
> of the 1-D storage? When I do "print FFT.inverse_fft2d.__doc__" I get no
> helpful info about storage.
The 2-D layout follows directly as a consequence of the 1-D layout and
the definition of a 2-D FFT.
In [14]: import FFT
In [15]: def my2dfft(A):
....: A = array(A, Complex)
....: for i in range(A.shape[0]):
....: A[i] = FFT.fft(A[i])
....: for i in range(A.shape[-1]):
....: A[:,i] = FFT.fft(A[:,i])
....: return A
....:
In [16]: A = reshape(arange(16.), (4,4))
In [17]: my2dfft(A)
Out[17]:
array([[ 120. +0.j, -8. +8.j, -8. +0.j, -8. -8.j],
[ -32.+32.j, 0. +0.j, 0. +0.j, 0. +0.j],
[ -32. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
[ -32.-32.j, 0. +0.j, 0. +0.j, 0. +0.j]])
In [18]: FFT.fft2d(A)
Out[18]:
array([[ 120. +0.j, -8. +8.j, -8. +0.j, -8. -8.j],
[ -32.+32.j, 0. +0.j, 0. +0.j, 0. +0.j],
[ -32. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
[ -32.-32.j, 0. +0.j, 0. +0.j, 0. +0.j]])
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the NumPy-Discussion
mailing list