13 releases (7 breaking)

0.8.0 Apr 29, 2023
0.7.0 Feb 23, 2021
0.6.2 Jun 20, 2020
0.6.0 May 2, 2019
0.1.0 Mar 1, 2017

#544 in Math

Download history 90/week @ 2024-01-03 60/week @ 2024-01-10 41/week @ 2024-01-17 84/week @ 2024-01-24 324/week @ 2024-01-31 135/week @ 2024-02-07 281/week @ 2024-02-14 1480/week @ 2024-02-21 529/week @ 2024-02-28 201/week @ 2024-03-06 183/week @ 2024-03-13 246/week @ 2024-03-20 459/week @ 2024-03-27 309/week @ 2024-04-03 357/week @ 2024-04-10 170/week @ 2024-04-17

1,323 downloads per month
Used in 8 crates

Custom license and maybe GPL-2.0-or-later

58KB
1.5K SLoC

rust-fftw3

Rust

Rust bindings for the FFTW C-library for computing discrete Fourier transforms, as well as discrete cosine and sine transforms.

This repository includes three crates:

  • Crate docs.rs fftw: A safe wrapper in Rust
  • Crate docs.rs fftw-sys: An unsafe wrapper in Rust
  • Crate docs.rs fftw-src: A crate for downloading and compiling the FFTW library

Feature flags

  • source: Download and compile FFTW (default)
    • (Linux, macOS) Needs a C-compiler and the make build tool to compile the FFTW library
    • (Windows) Downloads a precompiled binary from the FFTW website
  • system: Use the system's libfftw3 (experimental)
    • You must install FFTW before building this crate
    • For Linux systems, please install FFTW using your package manager, e.g. in Debian or Ubuntu run apt install libfftw3-dev
    • For macOS, please run brew install fftw by using homebrew
    • This feature is unsupported on Windows
  • intel-mkl Use Intel MKL backend through intel-mkl-src
    • Only Linux and Windows are supported
Feature Linux Windows macOS
source ✔️ ✔️ ✔️
system ✔️ - ✔️
intel-mkl ✔️ ✔️ -

LICENSE

See LICENSE.md


lib.rs:

Rust binding of FFTW

Examples

Complex-to-Complex

use fftw::array::AlignedVec;
use fftw::plan::*;
use fftw::types::*;
use std::f64::consts::PI;

let n = 128;
let mut plan: C2CPlan64 = C2CPlan::aligned(&[n], Sign::Forward, Flag::MEASURE).unwrap();
let mut a = AlignedVec::new(n);
let mut b = AlignedVec::new(n);
let k0 = 2.0 * PI / n as f64;
for i in 0..n {
    a[i] = c64::new((k0 * i as f64).cos(), 0.0);
}
plan.c2c(&mut a, &mut b).unwrap();

Complex-to-Real

use fftw::array::AlignedVec;
use fftw::plan::*;
use fftw::types::*;
use std::f64::consts::PI;

let n = 128;
let mut c2r: C2RPlan64 = C2RPlan::aligned(&[n], Flag::MEASURE).unwrap();
let mut a = AlignedVec::new(n / 2 + 1);
let mut b = AlignedVec::new(n);
for i in 0..(n / 2 + 1) {
    a[i] = c64::new(1.0, 0.0);
}
c2r.c2r(&mut a, &mut b).unwrap();

Dependencies

~1.7–5MB
~103K SLoC