[Numpy-discussion] numpy.fft.irfftn fails apparently unexpectedly
Henry Gomersall
heng at cantab.net
Tue Feb 7 04:15:36 EST 2012
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.
> >>>> import numpy
> >>>> a_shape = (63, 4, 98)
> >>>> a = numpy.complex128(numpy.random.rand(*a_shape)+\
> > ... 1j*numpy.random.rand(*a_shape))
> >>>>
> >>>> axes = [0, 2]
> >>>>
> >>>> numpy.fft.ifftn(a, axes=axes)
>
> Or do you mean if the error message is expected?
Yeah, the question was regarding the error message. Specifically, the
problem it seems to have with an axes argument like that.
Cheers,
Henry
More information about the NumPy-Discussion
mailing list