Your first transform
FFTL.jl computes the discrete Fourier transform (DFT) of arrays with any number of dimensions and any length. using FFTL makes the transform functions available under the names of FFTW.jl (fft, ifft, rfft, dct, … and their plan_ forms).
using FFTL, LinearAlgebra, Random
Random.seed!(1);A transform checked against the definition
The forward transform of a vector fft:
n = 8
x = randn(ComplexF64, n);
X_direct = [sum(x[j + 1] * cis(-2π * j * k / n) for j in 0:n-1) for k in 0:n-1]
X = fft(x)
norm(X - X_direct)7.73360193344466e-15The forward transform is not normalised, the inverse is: ifft(fft(x)) ≈ x. bfft is the unnormalised backward transform.
ifft(X) ≈ xtruePlans
fft(x) makes a plan and applies it. A plan holds everything that depends only on the size and the dimensions: radix sequence, twiddle tables and work buffers. Make it once and apply it many times, in place or out of place:
p = plan_fft(x)
y = p * x
z = similar(x)
mul!(z, p, x)
y ≈ X, z ≈ X(true, true)Plans are AbstractFFTs.Plans, so inv(p) and p \ y give the normalised inverse.
p \ X ≈ xtrueSeveral dimensions
An array is transformed along all its dimensions by default. A region selects some of them:
A = randn(ComplexF64, 16, 12)
size(fft(A)), size(fft(A, 1))((16, 12), (16, 12))Real input
For real data, rfft returns the half spectrum: the values for frequencies
r = randn(1000)
R = rfft(r)
size(R), irfft(R, 1000) ≈ r((501,), true)Orthonormal cosine transform
dct is the DCT-II scaled to an orthonormal map, so it preserves the Euclidean norm and idct is its exact inverse:
c = randn(100)
D = dct(c)
norm(D) ≈ norm(c), idct(D) ≈ c(true, true)Next: the tutorials apply these to real problems, and the how-to guides explain the options.
This page was generated using Literate.jl.