[Numpy-discussion] numpy.fft.irfftn fails apparently unexpectedly

Warren Focke focke@slac.stanford....
Tue Feb 7 13:53:21 CST 2012



On Tue, 7 Feb 2012, Henry Gomersall wrote:

> On Tue, 2012-02-07 at 01:04 +0100, Torgil Svensson wrote:
>> irfftn is an optimization for real input and does not take complex
>> input. You have to use numpy.fft.ifftn instead:
>>
> hmmm, that doesn't sound right to me (though there could be some non
> obvious DFT magic that I'm missing). Indeed,
>
> np.irfftn(np.rfftn(a)) ~= a  # The interim array is complex
>
> Though the documentation is a bit vague as to what inputs are expected!
>
> Actually, reading the fftpack docs, it *does* seem that this is the
> correct behaviour (assuming when it says "Fourier coefficients" it means
> complex), though I've not read any of the Python code.
>

You're not doing anything wrong.
irfftn takes complex input and returns real output.
The exception is a bug which is triggered because max(axes) >= len(axes).

Warren Focke



More information about the NumPy-Discussion mailing list