Skip to content

Commit 5276da3

Browse files
committed
Log information about a real-to-complex FFT edge case. This does not affect computation and was previously dropped silently. We want to keep this information though, in case we need to report this upstream
1 parent e59a9e1 commit 5276da3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/autocorrelation.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,21 @@ fn convolution(a: &[f64], b: &[f64]) -> Array1<f64> {
4040
let ifft = planner.plan_fft_inverse(length);
4141
let mut out_ab = ifft.make_output_vec();
4242

43-
ifft.process(&mut in_ab, &mut out_ab).unwrap();
43+
// For some sequences (like GUGCCUUGCGCCGGGAAACCACGCAAGGGGCGUAUGGCGCGCCGAUGAAGGUGUAGA)
44+
// the forward real-to-complex FFT produces non-zero imaginary parts in the first vector component.
45+
// This error appears to originate in rustfft or realfft.
46+
// However, the non-zero imaginary parts seem to be very small (i.e. approximately zero).
47+
// Therefore, we consider this to be non-critical and proceed with the computation.
48+
//
49+
// Nevertheless, we still want to report on these for now, might be relevent at some point.
50+
// This should probably be reported using the `log` crate but the warnings can be piped away using
51+
// `2> /dev/null` on the commandline.
52+
//
53+
// See also https://github.com/HEnquist/realfft/issues/11
54+
match ifft.process(&mut in_ab, &mut out_ab) {
55+
Ok(()) => (),
56+
Err(error) => eprintln!("[autocorrelation.rs] INFO: {}", error),
57+
}
4458

4559
Array1::from_vec(out_ab)
4660
}

0 commit comments

Comments
 (0)