![]() |
The subtraction of vectors and matrices works exactly as intuitive as the addition, but with the subtraction operator. For both the vector subtraction as well as the matrix subtraction the subtraction operator can be used. It also enables the subtraction of dense and sparse vectors as well as the subtraction 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 subtract vectors with the same transpose flag:
In case of matrices, however, it is possible to subtract row-major and column-major matrices. Note however that in favor of performance the subtraction 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.