rfft2

paddle.fft. rfft2 ( x: Tensor, s: list[int] | tuple[int, int] | None = None, axes: list[int] | tuple[int, int] = (- 2, - 1), norm: _NormalizeMode = 'backward', name: str | None = None ) Tensor [source]

The two dimensional FFT with real tensor input.

This is really just rfftn with different default behavior. For more details see rfftn.

Parameters
  • x (Tensor) – Input tensor, taken to be real.

  • s (sequence[int]|None, optional) – Shape (length of each transformed axis) of the output. It should be a sequence of 2 integers. This corresponds to n for rfft(x, n). Along each axis, if the given shape 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. Default is None.

  • axes (sequence[int], optional) – Axes over which to compute the FFT. It should be a sequence of 2 integers. If not specified, the last two axes are used by default.

  • norm (str, optional) –

    {“backward”, “ortho”, “forward”}, default is “backward”. Indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor. 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 backward direction are both 1/sqrt(n).

    Where n is the multiplication of each element in s .

  • name (str|None, 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

The result of the real 2-D FFT.

Return type

out(Tensor)

Examples:

>>> import paddle

>>> arr = paddle.arange(5, dtype="float64")
>>> x = paddle.meshgrid(arr, arr)[0]

>>> result = paddle.fft.rfft2(x)
>>> print(result.numpy())
[[50. +0.j 0. +0.j 0. +0.j]
 [-12.5+17.20477401j 0. +0.j 0. +0.j]
 [-12.5 +4.0614962j 0. +0.j 0. +0.j]
 [-12.5 -4.0614962j 0. +0.j 0. +0.j]
 [-12.5-17.20477401j 0. +0.j 0. +0.j]]