![]() |
The addition of vectors and matrices is as intuitive as the addition of scalar values. For both the vector addition as well as the matrix addition the addition operator can be used. It even enables the addition of dense and sparse vectors as well as the addition of dense and sparse matrices:
Note that it is necessary that both operands have exactly the same dimensions. Violating this precondition results in an exception. Also note that in case of vectors it is only possible to add vectors with the same transpose flag:
In case of matrices, however, it is possible to add row-major and column-major matrices. Note however that in favor of performance the addition of two matrices with the same storage order is favorable. The same argument holds for the element type: In case two vectors or matrices with the same element type are added, the performance can be much higher due to vectorization of the operation.
Previous: Arithmetic Operations Next: Subtraction