fftshift¶
- paddle.fft. fftshift ( x, axes=None, name=None ) [source]
-
Shift the zero-frequency component to the center of the spectrum.
This function swaps half spaces for all the axes listed (all by default). Note that
y[0]
is the Nyquist component only iflen(x)
is even.- Parameters
-
n (int) – Dimension inputed.
axes (int|tuple, optional) – The axis on which to move. The default is none, which moves all axes. Default is None.
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
-
Tensor. The shifted tensor.
Examples
import numpy as np import paddle x = np.array([3, 1, 2, 2, 3], dtype=float) n = x.size fftfreq_xp = paddle.fft.fftfreq(n, d=0.3) res = paddle.fft.fftshift(fftfreq_xp).numpy() print(res) # [-1.3333334 -0.6666667 0. 0.6666667 1.3333334]