#fft #fftw #homomorphic #fhe #fully

concrete-fftw

Safe wrapper around FFTW

5 releases

0.1.4 Sep 22, 2022
0.1.3 Jul 13, 2022
0.1.2 Aug 9, 2021
0.1.1 Jul 26, 2021
0.1.0 Jul 5, 2021

#1216 in Math

30 downloads per month
Used in concrete-core-experimenta…

Custom license and GPL-2.0-or-later

10MB
285K SLoC

C 257K SLoC // 0.1% comments Shell 8K SLoC // 0.2% comments M4 8K SLoC // 0.2% comments OCaml 5.5K SLoC // 0.2% comments Rust 2K SLoC // 0.0% comments Perl 2K SLoC // 0.1% comments FORTRAN Modern 1K SLoC Automake 1K SLoC // 0.1% comments FORTRAN Legacy 109 SLoC // 0.2% comments

Concrete FFTW

This library contains a safe wrapper of the FFTW library.

To compile with fftw, you need to have libclang installed on your computer.

Fork

This crate is a fork of the rust-math/fftw wrapper of the FFTW library.


lib.rs:

Rust binding of FFTW

Examples

Complex-to-Complex

use concrete_fftw::array::AlignedVec;
use concrete_fftw::plan::*;
use concrete_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 concrete_fftw::array::AlignedVec;
use concrete_fftw::plan::*;
use concrete_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