Skip to content

Real data ​

Real input has a spectrum with Hermitian symmetry:  . Half of it is redundant, and the real transforms return only the other half. That halves the work and the memory.

julia
using FFTL, Random
Random.seed!(5)

x = randn(1000, 300)
X = rfft(x)
size(X)
(501, 300)

The first transformed dimension is halved:     values for frequencies . The other dimensions keep their length. The complex array has the same type as a complex transform's output.

Going back ​

The inverse needs the length of the real array, because an odd and an even length can give the same half spectrum. irfft takes it explicitly:

julia
irfft(X, 1000) ≈ x
true
julia
y = randn(999)
Y = rfft(y)
size(Y), irfft(Y, 999) ≈ y
((500,), true)

brfft is the unnormalised inverse, the real counterpart of bfft. It differs from irfft by the product of the transformed lengths, the number of elements in the region; for one dimension, the length of the real array:

julia
y1 = randn(999)
Y1 = rfft(y1)
brfft(Y1, 999) ≈ 999 .* irfft(Y1, 999)
true

Which dimension is halved ​

The half spectrum is taken along the first dimension of the region. To halve dimension 2 of a matrix, put it first in the region:

julia
Z = randn(64, 128)
size(rfft(Z, (2, 1)))
(33, 128)

Plans ​

plan_rfft, plan_irfft and plan_brfft return plans with the same rules as the complex ones, including inv for the normalised inverse. Use them when the same real size is transformed many times; see Plans and reuse.