[SciPy-user] numpy.dft.real+fft problem?

Andrew Jaffe a.h.jaffe at gmail.com
Mon Jan 16 09:35:33 CST 2006

Hi All,

[This has already appeared on python-scientific-devel; apologies to
those of you seeing it twice...]

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). However, note that the
last entry on the first row has a real part, as opposed to the
complex routine fft, which has it correct.

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

The problem persists in 2d, as well.

In [6]:numpy.__version__

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

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

In [55]:fa
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])
                                                 **wrong** ^^^^^^^^^^^^^

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

In [57]:f2a
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    ,
                                       **correct** ^^^
           0.09+0.1601j, -7.1041+1.1182j, -1.2028-0.1612j,
          -1.043-2.3504j,-0.1276-0.3574j, -3.5009+3.4618j])


More information about the SciPy-user mailing list