Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rhysnewell/fftconvolve
Rust implementations of Fast Fourier Transform convolution and correlation for n-dimensional arrays
https://github.com/rhysnewell/fftconvolve
Last synced: 24 days ago
JSON representation
Rust implementations of Fast Fourier Transform convolution and correlation for n-dimensional arrays
- Host: GitHub
- URL: https://github.com/rhysnewell/fftconvolve
- Owner: rhysnewell
- License: bsd-3-clause
- Created: 2022-11-25T04:44:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-04T23:45:30.000Z (about 1 year ago)
- Last Synced: 2024-10-13T06:22:32.790Z (about 1 month ago)
- Language: Rust
- Size: 17.6 KB
- Stars: 46
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fftconvolve
Rust implementations of Fast Fourier Transform convolution and correlation for n-dimensional arrays# Examples
## 1-dimensional
```rust
use fftconvolve::{fftconvolve, Mode}let in1 = Array1::range(1.0, 4.0, 1.0);
let in2 = Array1::range(6.0, 3.0, -1.0);
let out = fftconvolve(&in1, &in2, Mode::Full).unwrap();
let expected = Array1::::from_vec(vec![6., 17., 32., 23., 12.]);
out.iter().zip(expected.iter()).for_each(|(a, b)| assert_aclose!(*a, *b, 1e-6));
```## 2-dimensional
```rust
use fftconvolve::{fftconvolve, Mode}let mat = Array2::from_shape_vec((3, 3),
vec![
0.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 0.0,
]).unwrap();
let kernel = Array2::from_shape_vec((2, 3),
vec![
1., 2., 3.,
4., 5., 6.,
]).unwrap();
let output = fftconvolve(&mat, &kernel, Mode::Full).unwrap();
let expected = Array2::from_shape_vec((4, 5),
vec![
0., 0., 0., 0., 0.,
0., 1., 2., 3., 0.,
0., 4., 5., 6., 0.,
0., 0., 0., 0., 0.,
]).unwrap();
output.iter().zip(expected.iter()).for_each(|(a, b)| assert_aclose!(*a, *b, 1e-6));
```