[SciPy-dev] numpy.dft.real_fft problems?

Andrew Jaffe a.h.jaffe at gmail.com
Fri Jan 13 09:00:16 EST 2006


Hi All,

[My apologies if this appears twice -- originally sent from a 
non-subscribed account; moderator, please delete the original if possible!]

There seems to be a problem with the real_fft routine; starting with a 
length n array, it should give a length n/2+1 array with real numbers
in the first and last positions (for n even). For a 2d array starting 
with an (n,n) array, it should give a (n,n/2+1) array with real numbers 
in the first and last positions on the first row. However, note that the 
last entry on the first row has a real part, as opposed to the 2d 
complex routine fft2d, which has it correct.

The weirdness of the real part seems to imply  it's due to uninitialized 
memory.

The problem persists in 2d, as well.

In [53]:a = numpy.randn(16)

In [54]:fa = numpy.dft.real_fft(a)

In [55]:fa
Out[55]:
array([ 0.4453+0.0000e+000j, -3.5009-3.4618e+000j, -0.1276+3.5740e-001j,
        -1.043+2.3504e+000j, -1.2028+1.6121e-001j, -7.1041-1.1182e+000j,
         0.09-1.6013e-001j,  4.2079-1.0106e-001j, -4.8295+2.3091e+251j])

In [56]:f2a = numpy.dft.fft(a)

In [57]:f2a
Out[57]:
array([  0.4453+0.j    , -3.5009-3.4618j, -0.1276+0.3574j,
         -1.043+2.3504j, -1.2028+0.1612j, -7.1041-1.1182j,  0.09-0.1601j,
          4.2079-0.1011j, -4.8295+0.j    ,
          4.2079+0.1011j,
          0.09+0.1601j, -7.1041+1.1182j, -1.2028-0.1612j, -1.043-2.3504j,
         -0.1276-0.3574j, -3.5009+3.4618j])

-Andrew





More information about the SciPy-Dev mailing list