Expand description
§ndrustfft: n-dimensional complex-to-complex FFT, real-to-complex FFT and real-to-real DCT
This library is a wrapper for RustFFT
, RustDCT
and RealFft
that enables performing FFTs and DCTs of complex- and real-valued
data on n-dimensional arrays (ndarray).
ndrustfft provides Handler structs for FFT’s and DCTs, which must be provided alongside with the arrays to the respective functions (see below) . The Handlers implement a process function, which is a wrapper around Rustfft’s process. Transforms along the outermost axis are in general the fastest, while transforms along other axis’ will temporarily create copies of the input array.
§Parallel
The library ships all functions with a parallel version which leverages the parallel iterators of the ndarray crate.
§Available transforms
§Complex-to-complex
fft
:ndfft
,ndfft_par
ifft
:ndifft
,ndifft_par
§Real-to-complex
fft_r2c
:ndfft_r2c
,ndfft_r2c_par
,
§Complex-to-real
ifft_r2c
:ndifft_r2c
,ndifft_r2c_par
§Real-to-real
dct1
:nddct1
,nddct1_par
dct2
:nddct2
,nddct2_par
dct3
:nddct3
,nddct3_par
dct4
:nddct4
,nddct4_par
§Example
2-Dimensional real-to-complex fft along first axis
use ndarray::{Array2, Dim, Ix};
use ndrustfft::{ndfft_r2c, Complex, R2cFftHandler};
let (nx, ny) = (6, 4);
let mut data = Array2::<f64>::zeros((nx, ny));
let mut vhat = Array2::<Complex<f64>>::zeros((nx / 2 + 1, ny));
for (i, v) in data.iter_mut().enumerate() {
*v = i as f64;
}
let mut fft_handler = R2cFftHandler::<f64>::new(nx);
ndfft_r2c(
&data.view(),
&mut vhat.view_mut(),
&mut fft_handler,
0,
);
§Normalization
RustFFT
, RustDCT
and RealFft
do not normalise,
while this library applies normalization as scipy by default.
This means, inverse ffts are divided by a factor of data.len()
,
and dcts are multiplied by two. It is possible to switch from the
default normalization to no normalization, or to apply a custom
normalization by using the normalization builder.
See: examples/fft_norm
§Features
- parallel: Enables parallel transform using
ndarrays
+rayon
(enabled by default) - avx: Enables
rustfft
’s avx feature (enabled by default) - sse: Enables
rustfft
’s sse feature (enabled by default) - neon: Enables
rustfft
’s neon feature (enabled by default)
§Documentation
§Versions
Structs§
- Complex
- A complex number in Cartesian form.
- DctHandler
- n-dimensional real-to-real Cosine Transform.
- FftHandler
- n-dimensional complex-to-complex Fourier Transform.
- R2cFft
Handler - n-dimensional real-to-complex Fourier Transform.
Enums§
- Normalization
- Represents different types of normalization methods.
Traits§
- FftNum
- Generic floating point number, implemented for f32 and f64
- Zero
- Defines an additive identity element for
Self
.
Functions§
- nddct1
- Real-to-real Discrete Cosine Transform of type 1 DCT-I (serial).
- nddct2
- Real-to-real Discrete Cosine Transform of type 2 DCT-2 (serial).
- nddct3
- Real-to-real Discrete Cosine Transform of type 3 DCT-3 (serial).
- nddct4
- Real-to-real Discrete Cosine Transform of type 4 DCT-4 (serial).
- nddct1_
par - Real-to-real Discrete Cosine Transform of type 1 DCT-I (parallel).
- nddct2_
par - Real-to-real Discrete Cosine Transform of type 2 DCT-2 (parallel).
- nddct3_
par - Real-to-real Discrete Cosine Transform of type 3 DCT-3 (parallel).
- nddct4_
par - Real-to-real Discrete Cosine Transform of type 4 DCT-4 (parallel).
- ndfft
- Complex-to-complex Fourier Transform (serial).
- ndfft_
par - Complex-to-complex Fourier Transform (parallel).
- ndfft_
r2c - Real-to-complex Fourier Transform (serial).
- ndfft_
r2c_ par - Real-to-complex Fourier Transform (parallel).
- ndifft
- Complex-to-complex Inverse Fourier Transform (serial).
- ndifft_
par - Complex-to-complex inverse Fourier Transform (parallel).
- ndifft_
r2c - Complex-to-real inverse Fourier Transform (serial).
- ndifft_
r2c_ par - Complex-to-real inverse Fourier Transform (parallel).