paddle.fft. rfft ( x, n=None, axis=- 1, norm='backward', name=None ) [source]

The one dimensional FFT for real input.

This function computes the one dimensional n-point discrete Fourier Transform (DFT) of a real-valued tensor by means of an efficient algorithm called the Fast Fourier Transform (FFT).

When the DFT is computed for purely real input, the output is Hermitian-symmetric. This function does not compute the negative frequency terms, and the length of the transformed axis of the output is therefore n//2 + 1.

  • x (Tensor) – Real-valued input tensor

  • n (int, optional) – Number of points along transformation axis in the input to use. If n is smaller than the length of the input, the input is cropped. If it is larger, the input is padded with zeros. If n is not given, the length of the input along the axis specified by axis is used.

  • axis (int, optional) – Axis over which to compute the FFT. Default value is last axis.

  • norm (str, optional) –

    Normalization mode, indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor. Include {“backward”, “ortho”, “forward”}, default value is “backward”.

    • ”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 .


complex tensor

Return type



>>> import paddle

>>> x = paddle.to_tensor([0.0, 1.0, 0.0, 0.0])
>>> print(paddle.fft.rfft(x))
Tensor(shape=[3], dtype=complex64, place=Place(cpu), stop_gradient=True,
[(1+0j), -1j, (-1+0j)])