[Numpy-discussion] Re: Weird (wrong?) real fft 2d behavior

Andrew Jaffe a.h.jaffe at gmail.com
Wed Jan 25 02:05:03 CST 2006


Andrew Jaffe wrote:
> If I start with what I thought was an appropriate (n, n/2+1) complex 
> matrix which should have a real inverse fft, and then take its real fft, 
> I don't get back the original matrix.
> 
> Note the presence of very small but nonzero reals in the final matrix, 
> and the fact that the 2d and 4th rows are duplicates. This seems to be a 
>  mistake somewhere.
> 
> Or am I just misunderstanding/misremembering something about 2d real ffts?

and I should point out that
	delta_rp = N.dft.real_fft2d(delta_kp)
is 'allclose' to the original delta_r (which leads me to believe that I 
may indeed be misunderstanding something).

Andrew


> 
> Andrew
> 
> 
> In [41]: dims=(4,4)
> 
> In [42]: delta_k = aniso.dft_realizn(dims, P)
>          #### this just makes an appropriate matrix
> 
> In [43]: delta_k
> Out[43]:
> array([[-0.    +0.j    ,  0.5904+0.0429j,  0.9063+0.j    ],
>        [-0.221 +0.j    ,  0.4169+0.4602j, -0.6909+0.j    ],
>        [ 0.9059+0.j    , -0.8037+0.2604j,  1.835 +0.j    ],
>        [ 1.7436+0.j    , -0.2382+0.221j , -0.0607+0.j    ]])
>        #### 16 real numbers
> 
> In [44]: delta_r = N.dft.inverse_real_fft2d(delta_k)
> 
> In [45]: delta_r
> Out[45]:
> array([[ 0.2718, -0.0956,  0.2805,  0.1505],
>        [ 0.0297, -0.0533, -0.259 ,  0.0561],
>        [ 0.1308, -0.2096,  0.2288, -0.3041],
>        [ 0.0895,  0.1105, -0.3188, -0.1076]])
> 
> In [46]: delta_kp = N.dft.real_fft2d(delta_r)
> 
> In [47]: delta_kp
> Out[47]:
> array([[ 0.     +0.00e+00j,  0.5904 +4.2938e-02j,  0.9063 +0.0000e+00j],
>        [ 0.7613 +5.5511e-17j,0.4169 +4.6020e-01j, -0.3758 +5.5511e-17j],
>        [ 0.9059 +0.0000e+00j,-0.8037+2.6038e-01j, 1.835  +0.0000e+00j],
>        [ 0.7613 -5.5511e-17j,-0.2382+2.2099e-01j,-0.3758-5.5511e-17j]])
> 
> In [48]: N.__version__
> Out[48]: '0.9.5.1982'
> ------------------------





More information about the Numpy-discussion mailing list