Skip to content

Commit ce3bf3c

Browse files
committed
fix fft scaling
1 parent 7abc17d commit ce3bf3c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/algorithm/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,14 @@ fn fft_impl(
797797
return Ok(());
798798
}
799799
let mut planner = FftPlanner::new();
800+
let scaling_factor = 1.0 / (list_row_len as f64).sqrt();
800801
for row in arr.data.as_mut_slice().chunks_exact_mut(list_row_len) {
801802
let fft = plan(&mut planner, row.len());
802803
let slice: &mut [Complex64] = unsafe { transmute::<&mut [Complex], &mut [Complex64]>(row) };
803804
fft.process(slice);
805+
for c in row {
806+
*c = *c * scaling_factor;
807+
}
804808
}
805809
env.push(arr);
806810
Ok(())

0 commit comments

Comments
 (0)