fft

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

Calculate one-dimensional discrete Fourier transform.

This function uses the efficient fast Fourier transform (FFT) algorithm [1] to calculate the 1-D * n * point discrete Fourier transform (DFT).

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

  • n (int, optional) – The length of the output transform axis. If n is less than the length input, the input will be cropped. If larger, the input is filled with zeros. If n is not given, the input length along the axis specified by axis is used.

  • axis (int, optional) – Axis used to calculate FFT. If not specified, the last axis is used by default.

  • norm (str, optional) – 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”, meaning no normalization on the forward transforms and scaling by 1/n on the ifft. “forward” instead applies the 1/n factor on the forward transform. For norm="ortho", both directions are scaled by 1/sqrt(n).

  • 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

complex tensor. The truncated or zero-padded input, transformed along the axis indicated by axis, or the last one if axis is not specified.

Examples

>>> import numpy as np
>>> import paddle

>>> x = np.exp(3j * np.pi * np.arange(7) / 7)
>>> xp = paddle.to_tensor(x)
>>> fft_xp = paddle.fft.fft(xp).numpy().round(3)
>>> print(fft_xp)
[1.+1.254j 1.+4.381j 1.-4.381j 1.-1.254j 1.-0.482j 1.+0.j 1.+0.482j]