Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
preiter committed Aug 10, 2021
1 parent fa63aa4 commit e50810e
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 491 deletions.
51 changes: 47 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "ndrustfft"
version = "0.1.6"
version = "0.2.0"
authors = ["preiter <[email protected]>"]
edition = "2018"
description = "N-dimensional real-to-complex FFT and real-to-real DCT for Rust"
description = "N-dimensional c2c FFT, r2c FFT and r2r DCT for Rust"
repository = "https://github.com/preiter93/ndrustfft"
keywords = ["fft", "dft", "dct", "rustfft", "ndarray"]
keywords = ["fft", "dft", "dct", "rustfft", "realfft", "rustdct", "ndarray"]
readme = "README.md"
license = "MIT"

Expand All @@ -15,8 +15,10 @@ path = "src/lib.rs"

[dependencies]
ndarray = { version = "0.15.0", features = ["rayon"] }
rustfft = "6.0.1"
rustfft = "6.0"
num-traits = "0.2.12"
rustdct = "0.6"
realfft = "2.0.1"

[dev-dependencies]
criterion = { version = "0.3.4", features = ["html_reports"] }
Expand Down
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@

## ndrustfft: *n*-dimensional complex-to-complex FFT, real-to-complex FFT and real-to-real DCT

This library is a wrapper for `RustFFT` that enables performing FFTs of complex-, real-valued
data and DCT's on *n*-dimensional arrays (ndarray).
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
to the respective function (see implemented transforms below) alongside with the arrays.
The Handlers contain the transform plans and buffers which reduce allocation cost.
ndrustfft provides Handler structs for FFT's and DCTs, which must be provided alongside
with the arrays to the respective function (see below) .
The Handlers implement a process function, which is a wrapper around Rustfft's
process function with additional functionality.
Transforms along the outermost axis are in general the fastest, while transforms along
other axis' will create temporary copies of the input array.

### Implemented transforms
#### Complex-to-complex
- `fft` / `ifft`: [`ndfft`],[`ndfft_par`], [`ndifft`],[`ndifft_par`]
- `fft` : [`ndfft`], [`ndfft_par`]
- `ifft`: [`ndifft`],[`ndifft_par`]
#### Real-to-complex
- `fft_r2c` / `ifft_r2c`: [`ndfft_r2c`],[`ndfft_r2c_par`], [`ndifft_r2c`],[`ndifft_r2c_par`]
- `fft_r2c` : [`ndfft_r2c`], [`ndfft_r2c_par`],
#### Complex-to-real
- `ifft_r2c`: [`ndifft_r2c`],[`ndifft_r2c_par`]
#### Real-to-real
- `fft_r2hc` / `ifft_r2hc`: [`ndfft_r2hc`],[`ndfft_r2hc_par`], [`ndifft_r2hc`],[`ndifft_r2hc_par`]
- `dct1`: [`nddct1`],[`nddct1_par`]
- `dct2`: [`nddct2`],[`nddct2_par`]
- `dct3`: [`nddct3`],[`nddct3_par`]
- `dct4`: [`nddct4`],[`nddct4_par`]

### Parallel
The library ships all functions with a parallel version
Expand All @@ -30,15 +35,15 @@ which leverages the parallel abilities of ndarray.
2-Dimensional real-to-complex fft along first axis
```rust
use ndarray::{Array2, Dim, Ix};
use ndrustfft::{ndfft_r2c, Complex, FftHandler};
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: FftHandler<f64> = FftHandler::new(nx);
let mut fft_handler = R2cFftHandler::<f64>::new(nx);
ndfft_r2c(
&mut data.view_mut(),
&mut vhat.view_mut(),
Expand Down
7 changes: 4 additions & 3 deletions benches/ndrustfft.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use criterion::{criterion_group, criterion_main, Criterion};
use ndarray::{Array, Dim, Ix};
use ndrustfft::{nddct1, DctHandler};
use ndrustfft::{ndfft, ndrfft, Complex, FftHandler};
use ndrustfft::{ndfft, Complex, FftHandler};
use ndrustfft::{ndfft_r2c, R2cFftHandler};
const SIZES: [usize; 4] = [128, 264, 512, 1024];

pub fn bench_fft2d(c: &mut Criterion) {
Expand Down Expand Up @@ -32,9 +33,9 @@ pub fn bench_rfft2d(c: &mut Criterion) {
for (i, v) in data.iter_mut().enumerate() {
*v = i as f64;
}
let mut handler: FftHandler<f64> = FftHandler::new(*n);
let mut handler = R2cFftHandler::<f64>::new(*n);
group.bench_function(&name, |b| {
b.iter(|| ndrfft(&mut data.view_mut(), &mut vhat.view_mut(), &mut handler, 0))
b.iter(|| ndfft_r2c(&mut data.view_mut(), &mut vhat.view_mut(), &mut handler, 0))
});
}
group.finish();
Expand Down
8 changes: 5 additions & 3 deletions benches/ndrustfft_par.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use criterion::{criterion_group, criterion_main, Criterion};
use ndarray::{Array, Dim, Ix};
use ndrustfft::{nddct1_par, DctHandler};
use ndrustfft::{ndfft_par, ndrfft_par, Complex, FftHandler};
use ndrustfft::{ndfft_par, Complex, FftHandler};
use ndrustfft::{ndfft_r2c_par, R2cFftHandler};

const SIZES: [usize; 4] = [128, 264, 512, 1024];

pub fn bench_fft2d(c: &mut Criterion) {
Expand Down Expand Up @@ -32,9 +34,9 @@ pub fn bench_rfft2d(c: &mut Criterion) {
for (i, v) in data.iter_mut().enumerate() {
*v = i as f64;
}
let mut handler: FftHandler<f64> = FftHandler::new(*n);
let mut handler = R2cFftHandler::<f64>::new(*n);
group.bench_function(&name, |b| {
b.iter(|| ndrfft_par(&mut data.view_mut(), &mut vhat.view_mut(), &mut handler, 0))
b.iter(|| ndfft_r2c_par(&mut data.view_mut(), &mut vhat.view_mut(), &mut handler, 0))
});
}
group.finish();
Expand Down
Loading

0 comments on commit e50810e

Please sign in to comment.