It depends. Generally speaking, immutability is better.
First of all, it is automatically thread safe. Easier to maintain and test.
However, sometimes you need speed when creating new instances takes too much time.
(Note: if you are not 100% positive, you need such a number of revolutions, you do not need it. Think of high-frequency trading and applications with intensive math in real time. And although you should just go first and optimize later.)
As for static vs normal methods, after good OOP principles you shouldn't have static methods. To create new vectors / matrices, you can use the constructor.
Then what is your support structure? Best of all, probably one-dimensional arrays of twins for vectors and multi-dimensional arrays of twins for matrices. This at least allows you to stay relatively fast using primitive objects.
If you get to the point where you need even more performance, you can add modifiers to your vector / matrix that can change the backup data. You can even decide that the dimensions are unchangeable, but the contents are resized, which will also give you some other security measures.
Reverend gonzo
source share