bundles / scipy 1.17.1 / scipy / linalg / _special_matrices / dft
function
scipy.linalg._special_matrices:dft
Signature
def dft ( n , scale = None ) Summary
Discrete Fourier transform matrix.
Extended Summary
Create the matrix that computes the discrete Fourier transform of a sequence [1]. The nth primitive root of unity used to generate the matrix is exp(-2*pi*i/n), where i = sqrt(-1).
Parameters
n: intSize the matrix to create.
scale: str, optionalMust be None, 'sqrtn', or 'n'. If
scaleis 'sqrtn', the matrix is divided bysqrt(n). Ifscaleis 'n', the matrix is divided byn. Ifscaleis None (the default), the matrix is not normalized, and the return value is simply the Vandermonde matrix of the roots of unity.
Returns
m: (n, n) ndarrayThe DFT matrix.
Notes
When scale is None, multiplying a vector by the matrix returned by dft is mathematically equivalent to (but much less efficient than) the calculation performed by scipy.fft.fft.
Examples
import numpy as np from scipy.linalg import dft np.set_printoptions(precision=2, suppress=True) # for compact output m = dft(5)✓
m
✗x = np.array([1, 2, 3, 0, 3]) m @ x # Compute the DFT of x✓
from scipy.fft import fft
✓fft(x) # Same result as m @ x
✗Aliases
-
scipy.linalg.dft