I want to store a large number of Diagonal 3x3 matrices. I am considering using a HybridArray
whose individual elements are these 3x3 matrices. In my case I know that the matrices are Diagonal
. I’m not sure which of these two are the best choices:
-
Diagonal(::SVector{3})
: preserves structure, but not static. It might be possible to wrap the size around this to obtain that information in at compile time. -
SMatrix{3,3}
: Static, but stores unnecessary zeros and does not preserve structure.
Assuming that memory isn’t the main limitation, is it better to use the SMatrix
approach over the Diagonal
one? Of course the specific choice will depend on the limiting factor in the problem, but I just wanted to know if there is any obvious pitfall with either of these approaches when it comes to performance.