Skip to main content

Module helpers

Module helpers 

Source
Expand description

Frequency grids, fast transform lengths, N-dimensional real FFTs and N-dimensional DCTs and DSTs, following scipy.fft: fftfreq, rfftfreq, next_fast_len, ifftshift, rfftn/irfftn and dctn/idctn/dstn/idstn.

See the book entry Real and multidimensional FFTs.

Functions§

dctn
The N-dimensional DCT (SciPy’s dctn): the 1-D dct along every axis in turn, which is valid because the transform is separable.
dstn
The N-dimensional DST (SciPy’s dstn).
fftfreq
The sample frequencies of an n-point DFT with sample spacing d (NumPy’s fftfreq): [0, 1, …, ⌈n/2⌉−1, −⌊n/2⌋, …, −1] / (n d), in the order the FFT returns its bins.
fftshift_1d
One-dimensional fftshift for a slice of any element type.
idctn
The inverse of dctn with the same type and normalization.
idstn
The inverse of dstn with the same type and normalization.
ifftshift
The inverse of fftshift: moves the zero-frequency bin from the centre back to index 0 along every axis (they differ for odd lengths).
ifftshift_1d
One-dimensional ifftshift for a slice of any element type.
irfftn
The inverse of rfftn (SciPy’s irfftn): shape is the shape of the real output, needed because the last axis of length n and n + 1 have the same half spectrum when n is even. Scaled so that irfftn(rfftn(x), x.shape()) = x.
next_fast_len
The smallest length ≥ target whose prime factors are all small, which FFTs handle fastest (SciPy’s next_fast_len): 2, 3 and 5 for real transforms (real = true), and also 7 and 11 for complex ones. Found by enumerating the products of powers of the allowed primes.
rfftfreq
The non-negative sample frequencies of an n-point real FFT, [0, 1, …, ⌊n/2⌋] / (n d) (NumPy’s rfftfreq).
rfftn
The N-dimensional DFT of real data (SciPy’s rfftn): a real FFT along the last axis, keeping the ⌊n/2⌋ + 1 non-negative frequencies, then complex FFTs along the other axes. The result has the input’s shape with the last axis shortened.