Enter the Matrix class for VBA
The Elementary Row Operations are destructive, because doing otherwise would degrade the performance too much.
The Matrix operations are non-destructive, in that they create a new Matrix with the results and return it. This allows method chaining , such as Set D = A.Multiply(B).Add(C).ScalarMultiply(5)
, and the intuitive behavior such that C = A x B and A and B themselves are not modified in the process. I'm tempted to make these methods destructive to improve performance (an object is created for every intermediate matrix operation), but I'm not sure how intuitive it would be that the result of A.Multiply(B)
would be A
.
And here are a couple examples of use:
And here are a couple examples:
The Elementary Row Operations are destructive, because doing otherwise would degrade the performance too much.
The Matrix operations are non-destructive, in that they create a new Matrix with the results and return it. This allows method chaining , such as Set D = A.Multiply(B).Add(C).ScalarMultiply(5)
, and the intuitive behavior such that C = A x B and A and B themselves are not modified in the process. I'm tempted to make these methods destructive to improve performance (an object is created for every intermediate matrix operation), but I'm not sure how intuitive it would be that the result of A.Multiply(B)
would be A
.
And here are a couple examples of use: