What is the performance penalty for using MVector and MMatrix vs SVector and SMatrix

How do the two data types store data underneath?

As a more general question, when is an SVector or SMatrix allocated on the stack? Are MVector and MMatrix ever constructed on the stack?

If the mutable type does not escape, it can be stack allocated. For example: Help with allocations (variable length least squares) - #6 by lmiq


Most of the time MVector is fast, but in some cases not. So benchmark your code and make sure there are no allocations.

1 Like