Skip to content

Commit b376198

Browse files
committed
Fix c2c2c_identity test
Reusing a plan for different arrays than it was created with requires that they have the same size and alignment as was used for creating the plan. While the size of `a` and `b` is identical, there is no such guarantee for their alignment. Therefore one may not simply swap them. Fix this by using separate plans for the `in: a, out: b` and `in: b, out: a` invocations.
1 parent e5ef1d9 commit b376198

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fftw/tests/c2c.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ fn c2c2c_identity() {
88
let n = 32;
99
let mut a = vec![c64::zero(); n];
1010
let mut b = vec![c64::zero(); n];
11-
let mut plan: C2CPlan64 =
11+
12+
let mut plan_ab: C2CPlan64 =
1213
C2CPlan::new(&[n], &mut a, &mut b, Sign::Forward, Flag::MEASURE).unwrap();
14+
let mut plan_ba: C2CPlan64 =
15+
C2CPlan::new(&[n], &mut b, &mut a, Sign::Forward, Flag::MEASURE).unwrap();
16+
1317
for i in 0..n {
1418
a[i] = c64::new(1.0, 0.0);
1519
}
16-
plan.c2c(&mut a, &mut b).unwrap();
17-
plan.c2c(&mut b, &mut a).unwrap();
20+
21+
plan_ab.c2c(&mut a, &mut b).unwrap();
22+
plan_ba.c2c(&mut b, &mut a).unwrap();
1823
for v in a.iter() {
1924
let ans = c64::new(n as f64, 0.0);
2025
let dif = (v - ans).norm();

0 commit comments

Comments
 (0)