bundles / numpy 2.4.3 / numpy / fft / fft
_ArrayFunctionDispatcher
numpy.fft:fft
source: /numpy/fft/_pocketfft.py :120
Signature
def fft ( a , n = None , axis = -1 , norm = None , out = None ) Summary
Compute the one-dimensional discrete Fourier Transform.
Extended Summary
This function computes the one-dimensional n-point discrete Fourier Transform (DFT) with the efficient Fast Fourier Transform (FFT) algorithm [CT].
Parameters
a: array_likeInput array, can be complex.
n: int, optionalLength of the transformed axis of the output. If
nis smaller than the length of the input, the input is cropped. If it is larger, the input is padded with zeros. Ifnis not given, the length of the input along the axis specified byaxisis used.axis: int, optionalAxis over which to compute the FFT. If not given, the last axis is used.
norm: {"backward", "ortho", "forward"}, optionalNormalization mode (see numpy.fft). Default is "backward". Indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor.
out: complex ndarray, optionalIf provided, the result will be placed in this array. It should be of the appropriate shape and dtype.
Returns
out: complex ndarrayThe truncated or zero-padded input, transformed along the axis indicated by
axis, or the last one ifaxisis not specified.
Raises
: IndexErrorIf
axisis not a valid axis ofa.
Notes
FFT (Fast Fourier Transform) refers to a way the discrete Fourier Transform (DFT) can be calculated efficiently, by using symmetries in the calculated terms. The symmetry is highest when n is a power of 2, and the transform is therefore most efficient for these sizes.
The DFT is defined, with the conventions used in this implementation, in the documentation for the numpy.fft module.
Examples
import numpy as np
✓np.fft.fft(np.exp(2j * np.pi * np.arange(8) / 8))
✗import matplotlib.pyplot as plt t = np.arange(256) sp = np.fft.fft(np.sin(t)) freq = np.fft.fftfreq(t.shape[-1]) _ = plt.plot(freq, sp.real, freq, sp.imag) plt.show()✓

See also
Aliases
-
numpy.fft.fft