In my first post I wrote:
setindex!.((A,), 1, fft(getindex.(A,1))
what is wrong. This will write the value 1 in the position given by the fft, what makes no sense:
A[fft(getindex.(A,1))] .= 1
@jleman has probably corrected the order of the parameters to:
setindex!.((A,), fft(getindex.(A,1), 1)
But this is:
A[1] .= fft(getindex.(A,1)
What explains some gain in performance, it is overwriting contiguous positions in the first matrix with the the fft
values, instead of overwriting the first value in each of the matrices. (I am not sure, however, how it did not have a type problem, as the fft
return is a vector, not a matrix.)
The correct version is:
@btime @inbounds setindex!.($A, fft!(getindex.($A,1)), 1);
That somehow is slightly faster than looping to me, even if it makes one extra allocation. (I will need to investigate further, it does not make sense to me why it does make an extra allocation nor why it is faster/equivalent despite that.)
I am sorry for the noise.