Skip to content

Commit

Permalink
Merge branch 'main' of github.com:QuState/PhastFT
Browse files Browse the repository at this point in the history
  • Loading branch information
smu160 committed Feb 9, 2024
2 parents 2a2ead9 + 221db1d commit f49eb48
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ pub fn fft_with_opts_and_plan(
let twiddles_re = &mut planner.twiddles_re;
let twiddles_im = &mut planner.twiddles_im;

// We shouldn't be able to execute FFT if the # of twiddles isn't equal to the distance between pairs
assert!(twiddles_re.len() / 2 == reals.len() && twiddles_im.len() / 2 == imags.len());

for t in (0..n).rev() {
let dist = 1 << t;
let chunk_size = dist << 1;
Expand Down Expand Up @@ -123,6 +126,24 @@ mod tests {
fft_with_opts_and_plan(&mut reals, &mut imags, &opts, &mut planner);
}

// a regression test to make sure planner is always compatible with fft execution
#[should_panic]
#[test]
fn wrong_num_points_in_planner() {
let n = 16;
let num_points = 1 << n;

// this test will actually always fail at this stage

let mut planner = Planner::new(n, Direction::Forward);
let mut reals = vec![0.0; num_points];
let mut imags = vec![0.0; num_points];
let opts = Options::guess_options(reals.len());

// but this call should panic as well
fft_with_opts_and_plan(&mut reals, &mut imags, &opts, &mut planner);
}

#[test]
fn fft_correctness() {
let range = Range { start: 4, end: 17 };
Expand Down

0 comments on commit f49eb48

Please sign in to comment.