Discrete Fourier transform matrix.
Create the matrix that computes the discrete Fourier transform of a sequence [R66]. The n-th primitive root of unity used to generate the matrix is exp(-2*pi*i/n), where i = sqrt(-1).
Parameters: | n : int
scale : str, optional
|
---|---|
Returns: | m : (n, n) ndarray
|
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.fftpack.fft.
New in version 0.14.0.
References
[R66] | (1, 2) “DFT matrix”, http://en.wikipedia.org/wiki/DFT_matrix |
Examples
>>> np.set_printoptions(precision=5, suppress=True)
>>> x = np.array([1, 2, 3, 0, 3, 2, 1, 0])
>>> m = dft(8)
>>> m.dot(x) # Comute the DFT of x
array([ 12.+0.j, -2.-2.j, 0.-4.j, -2.+2.j, 4.+0.j, -2.-2.j,
-0.+4.j, -2.+2.j])
Verify that m.dot(x) is the same as fft(x).
>>> from scipy.fftpack import fft
>>> fft(x) # Same result as m.dot(x)
array([ 12.+0.j, -2.-2.j, 0.-4.j, -2.+2.j, 4.+0.j, -2.-2.j,
0.+4.j, -2.+2.j])