scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
dft(n, scale=None)

Create the matrix that computes the discrete Fourier transform of a sequence . The nth primitive root of unity used to generate the matrix is exp(-2*pi*i/n), where i = sqrt(-1).

Notes

When :None:None:`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 .

versionadded

Parameters

n : int

Size the matrix to create.

scale : str, optional

Must be None, 'sqrtn', or 'n'. If :None:None:`scale` is 'sqrtn', the matrix is divided by :None:None:`sqrt(n)`. If :None:None:`scale` is 'n', the matrix is divided by n. If :None:None:`scale` is 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) ndarray

The DFT matrix.

Discrete Fourier transform matrix.

Examples

>>> from scipy.linalg import dft
... np.set_printoptions(precision=2, suppress=True) # for compact output
... m = dft(5)
... m array([[ 1. +0.j , 1. +0.j , 1. +0.j , 1. +0.j , 1. +0.j ], [ 1. +0.j , 0.31-0.95j, -0.81-0.59j, -0.81+0.59j, 0.31+0.95j], [ 1. +0.j , -0.81-0.59j, 0.31+0.95j, 0.31-0.95j, -0.81+0.59j], [ 1. +0.j , -0.81+0.59j, 0.31-0.95j, 0.31+0.95j, -0.81-0.59j], [ 1. +0.j , 0.31+0.95j, -0.81+0.59j, -0.81-0.59j, 0.31-0.95j]])
>>> x = np.array([1, 2, 3, 0, 3])
... m @ x # Compute the DFT of x array([ 9. +0.j , 0.12-0.81j, -2.12+3.44j, -2.12-3.44j, 0.12+0.81j])

Verify that m @ x is the same as fft(x) .

>>> from scipy.fft import fft
... fft(x) # Same result as m @ x array([ 9. +0.j , 0.12-0.81j, -2.12+3.44j, -2.12-3.44j, 0.12+0.81j])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.linalg._special_matrices.dft

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/linalg/_special_matrices.py#972
type: <class 'function'>
Commit: