I tested the four methods of re-creating the multidimensional array (C) from my vector B.
So here are the results:
julia> @btime begin
C = Array{Float64}(undef,size(B[1])...,length(B))
for i in 1:length(B)
C[:,:,i] = B[i]
end
end
2.167 μs (24 allocations: 976 bytes)
julia> @btime C = cat(B..., dims=3);
7.225 μs (81 allocations: 3.48 KiB)
julia> @btime A = reshape(reduce(hcat, B), 2,3,5);
323.305 ns (4 allocations: 480 bytes)
julia> @btime stack(B);
25.301 ns (1 allocation: 16 bytes)
Clear winner is the LazyStack.stack() (“view”) method. Disadvantage of this method is the need to install another package. Method reshape is also good.