irfftn

paddle.fft. irfftn ( x, s=None, axes=None, norm='backward', name=None ) [source]

Computes the inverse of rfftn.

This function computes the inverse of the N-D discrete Fourier Transform for real input over any number of axes in an M-D array by means of the Fast Fourier Transform (FFT). In other words, irfftn(rfftn(x), x.shape) == x to within numerical accuracy. (The x.shape is necessary like len(x) is for irfft, and for the same reason.)

The input should be ordered in the same way as is returned by rfftn, i.e., as for irfft for the final transformation axis, and as for ifftn along all the other axes.

Parameters
  • x (Tensor) – The input data. It’s a Tensor type.

  • s (sequence of ints, optional) –

    The length of the output transform axis. (s[0] refers to axis 0, s[1] to axis 1, etc.).

    • s is also the number of input points used along this axis, except for the last axis, where s[-1]//2+1 points of the input are used.

    • Along any axis, if the shape indicated by s is smaller than that of the input, the input is cropped. If it is larger, the input is padded with zeros.

    • If s is not given, the shape of the input along the axes specified by axes is used. Except for the last axis which is taken to be 2*(k-1)

    where k is the length of the input along that axis.

  • axes (sequence of ints, optional) – Axes over which to compute the inverse FFT. If not given, the last len(s) axes are used, or all axes if s is also not specified.

  • norm (str) –

    Indicates which direction to scale the forward or backward transform pair and what normalization factor to use. The parameter value must be one of “forward” or “backward” or “ortho”. Default is “backward”. The details of three operations are shown below:

    • ”backward”: The factor of forward direction and backward direction are 1 and 1/n respectively;

    • ”forward”: The factor of forward direction and backward direction are 1/n and 1 respectively;

    • ”ortho”: The factor of forward direction and backword direction are both 1/sqrt(n).

    Where n is the multiplication of each element in s .

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

Real tensor. The truncated or zero-padded input, transformed along the axes indicated by axes, or by a combination of s or x, as explained in the parameters section above. The length of each transformed axis is as given by the corresponding element of s, or the length of the input in every axis except for the last one if s is not given. In the final transformed axis the length of the output when s is not given is 2*(m-1), where m is the length of the final transformed axis of the input. To get an odd number of output points in the final axis, s must be specified.

Examples

>>> import paddle

>>> x = paddle.to_tensor([2.+2.j, 2.+2.j, 3.+3.j]).astype(paddle.complex128)
>>> print(x)
Tensor(shape=[3], dtype=complex128, place=Place(cpu), stop_gradient=True,
[(2+2j), (2+2j), (3+3j)])

>>> irfftn_x = paddle.fft.irfftn(x)
>>> print(irfftn_x)
Tensor(shape=[4], dtype=float64, place=Place(cpu), stop_gradient=True,
[2.25000000, -1.25000000, 0.25000000, 0.75000000])