Crates.io | ffts-sys |
lib.rs | ffts-sys |
version | 0.1.3 |
source | src |
created_at | 2019-05-19 17:06:19.379508 |
updated_at | 2019-05-22 23:47:04.193277 |
description | Rust binding for ffts (The Fastest Fourier Transform in the South) |
homepage | |
repository | https://github.com/sevagh/ffts |
max_upload_size | |
id | 135290 |
size | 7,931 |
forked from anthonix/ffts
Build with CMake:
$ mkdir build && cd build
$ cmake .. && make && sudo make install
Rust (nightly only for now) bindings for ffts using bindgen.
Components:
Structs:
ffts_sys::ffts_plan_t
re: f32, im: f32
, 32-bit aligned as per ffts requirementsResult<T, FFTSError>
ffts_init_*
returns a nullptruse ffts::*;
let mut random_cmplex: Vec<FFTSComplex> = vec![
FFTSComplex { re: -15.0, im: 3.0 },
FFTSComplex { re: 32.0, im: 2.0 },
FFTSComplex {
re: -1337.0,
im: 1.0,
},
FFTSComplex {
re: 62.75,
im: -1.0,
},
];
let mut p_f = FFTSPlan::new_1d(4, FFTSDirection::Forward).unwrap();
let mut forward_vec = p_f.execute(&mut random_cmplex);
let mut p_b = FFTSPlan::new_1d(random_cmplex.len(), FFTSDirection::Backward).unwrap();
let backward_vec = p_b.execute(&mut forward_vec);
Compared to C:
#include <ffts/ffts.h>
const float _Complex nums[4] = {-15.0 + 0.0I, 32.0 + 0.0I, -1337.0 + 0.0I, 62.75 + 0.0I};
float _Complex out1[4] = {0.0 + 0.0I, 0.0 + 0.0I, 0.0 + 0.0I, 0.0 + 0.0I};
float _Complex out2[4] = {0.0 + 0.0I, 0.0 + 0.0I, 0.0 + 0.0I, 0.0 + 0.0I};
ffts_plan_t *p = ffts_init_1d(4, FFTS_FORWARD);
ffts_execute(p, nums, out1);
ffts_plan_t *p2 = ffts_init_1d(4, FFTS_BACKWARD);
ffts_execute(p2, out1, out2);
ffts_free(p);
ffts_free(p2);
return 0;