@code_warntype with StaticArrays

StaticArrays are type-inferred if the size is known at compile time, not runtime. In your case, n is only known at run-time, so the type can’t be inferred. Moreover, in the MMatrix constructor, you need to specify the fourth parameter, which is the length of the array n^2.

1 Like