I have a simple, immutable structure that wraps a statically sized matrix. When I construct it with an initialization value, it causes a memory allocation. I expected there to be no such allocation. Should there be an allocation, or is this an issue with the compiler? Here is the MWE:
using BenchmarkTools
using StaticArrays
struct MyMat
m::SMatrix{3, 3, Float64}
end
function test()
A = @SMatrix randn(3, 3)
@btime B = MyMat($A)
end
test();
4.750 ns (1 allocation: 80 bytes)