Slice CSM in column-major order
Change order of CSM indices from CSM(NF,M,M) to CSM(M,M,NF). Gives a 4X speed up!
Benchmarked with:
function beamformer(csm,v)
M,M,Nf = size(csm)
N = size(v,2)
b = Array{Float64, 2}(undef, N, Nf) # Should be Array{T, 2}(undef, N, Nf)
#csmd = Array{Complex{Float64},2}(undef,M,M)
for j in 1:Nf
tmp = view(csm,:,:,j) # THIS LINE changed from view(csm,j,:,:)
for i in 1:N
b[i,j] = real(view(v,:,i,j)'*tmp*view(v,:,i,j))
end
end
return b
end
function test1()
Nf = 20
M = 64
N = 100
c = rand(Complex{Float64},M,M,Nf)
v = rand(M,N,Nf)
@btime beamformer($c,$v)
end
test1()
Edited by ollyl