Skip to main content

Module dct

Module dct 

Source
Expand description

Discrete cosine and sine transforms of types I-IV, computed through complex FFTs.

Unnormalized definitions follow the common (SciPy / FFTW REDFT-RODFT) convention, for a length-N input x:

TypeCosine transform y_kSine transform y_k
Ix₀ + (−1)ᵏx_{N−1} + 2Σ_{n=1}^{N−2} x_n cos(πkn/(N−1))2Σ x_n sin(π(k+1)(n+1)/(N+1))
II2Σ x_n cos(πk(2n+1)/(2N))2Σ x_n sin(π(k+1)(2n+1)/(2N))
IIIx₀ + 2Σ_{n≥1} x_n cos(πn(2k+1)/(2N))(−1)ᵏx_{N−1} + 2Σ_{n<N−1} x_n sin(π(n+1)(2k+1)/(2N))
IV2Σ x_n cos(π(2n+1)(2k+1)/(4N))2Σ x_n sin(π(2n+1)(2k+1)/(4N))

Types II and III are mutual inverses up to 2N, types I and IV are their own inverses up to 2(N∓1) and 2N. TrigNormalization::Ortho scales each transform to an orthogonal matrix, so the inverse is the transpose (type II ↔ III, types I and IV self-inverse). Every transform is an O(N log N) FFT of a symmetric extension or twiddled zero-padding of length about 2N.

See the book entry Discrete cosine and sine transforms.

Enums§

TrigNormalization
Scaling of the forward transform.
TrigTransformType
The transform type.

Functions§

dct
The discrete cosine transform of the given type.
dst
The discrete sine transform of the given type.
idct
The inverse of dct with the same type and normalization.
idst
The inverse of dst with the same type and normalization.