Skip to content

Commit

Permalink
Add skeleton of impl based on packing complex nums
Browse files Browse the repository at this point in the history
  • Loading branch information
smu160 committed May 13, 2024
1 parent 443d6e2 commit a227dad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 178 deletions.
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ impl_fft_with_opts_and_plan_for!(
16
);

// TODO: make this generic over f64/f32 using macro
/// Real-to-Complex FFT `f64`. Note the input is a real-valued signal.
pub fn fft_64_r2c(signal: &mut [f64]) -> (Vec<f64>, Vec<f64>) {
let n = signal.len();

Check failure on line 179 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused variable: `n`

Check failure on line 179 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused variable: `n`

Check warning on line 179 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test

unused variable: `n`

Check warning on line 179 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test

unused variable: `n`
let (mut reals, mut imags): (Vec<f64>, Vec<f64>) =
signal.chunks_exact(2).map(|c| (c[0], c[1])).unzip();

fft_64(&mut reals, &mut imags, Direction::Forward);

// TODO: implement/fix untangle
todo!();
(reals, imags)

Check failure on line 187 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

unreachable expression

Check failure on line 187 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

unreachable expression

Check warning on line 187 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test

unreachable expression

Check warning on line 187 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test

unreachable expression
}

#[cfg(test)]
mod tests {
use std::ops::Range;
Expand Down Expand Up @@ -308,4 +322,22 @@ mod tests {
}
}
}

#[test]
fn fft_r2c_vs_c2c() {
let n = 4;
let big_n = 1 << n;
let mut reals: Vec<f64> = (1..=big_n).map(|i| i as f64).collect();

let (signal_re, signal_im) = fft_64_r2c(&mut reals);
println!("{:?}", signal_re);
println!("{:?}\n", signal_im);

let mut reals: Vec<f64> = (1..=big_n).map(|i| i as f64).collect();
let mut imags = vec![0.0; big_n];
fft_64(&mut reals, &mut imags, Direction::Forward);

println!("{:?}", reals);
println!("{:?}\n", imags);
}
}
178 changes: 0 additions & 178 deletions src/r2c_kernels.rs

This file was deleted.

0 comments on commit a227dad

Please sign in to comment.