I have just encountered what I believe is a bug when using FFTW.jl to compute inverse 2D FFT. As reproduced in the MWE below, the use of mul!(A,P,B)
modifies the input array B
.
using FFTW, LinearAlgebra;
N = 1;
B = rand(ComplexF64,(N+1,2*N));
P = plan_irfft(B,2*N);
A = zeros(Float64,(2*N,2*N));
#####
v0 = B[1,1];
mul!(A,P,B);
v1 = B[1,1];
#####
println(v0 == v1) # --> Returns false
Playing around with these functions, the bug seems to go away if (i) the FFT is 1D rather than 2D; or if (ii) one uses the forward transform plan_rfft
rather than the inverse one.
Unfortunately, I am not versed enough in julia to dig further the origin of this behaviour. Maybe someone else would be more lucky?
If useful:
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 12 × Apple M2 Pro
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)