![]() |
Blaze 3.9
|
Multiplying two matrices with the same dimensions (i.e. the same number of rows and columns) via the modulo operator results in a componentwise multiplication (Schur product) of the two matrices:
Both dense and sparse matrices can be used for a Schur product. The storage order of the two matrices poses no restrictions on the operation, all variations are possible. It is also possible to multiply two matrices with different element type, as long as the element types themselves can be multiplied.
The matrix/matrix product can be formulated exactly as in mathematical textbooks:
The storage order of the two matrices poses no restrictions on the operation, all variations are possible. It is also possible to multiply two matrices with different element type, as long as the element types themselves can be multiplied and added. Note however that the highest performance for a multiplication between two matrices can be expected for two matrices with the same scalar element type.
In case the resulting matrix is known to be symmetric, Hermitian, lower triangular, upper triangular, or diagonal, the computation can be optimized by explicitly declaring the multiplication as symmetric, Hermitian, lower triangular, upper triangular, or diagonal by means of the Declaration Operations :
Using a declaration operation on the a multiplication expression can speed up the computation by a factor of 2. Note however that the caller of the according declaration operation takes full responsibility for the correctness of the declaration. Falsely declaring a multiplication as symmetric, Hermitian, lower triangular, upper triangular, or diagonal leads to undefined behavior!
The Kronecker product of two matrices can be computed via the kron() function:
Both dense and sparse matrices can be used for a Kronecker product. The storage order of the two matrices poses no restrictions on the operation, all variations are possible. It is also possible to multiply two matrices with different element type, as long as the element types themselves can be multiplied.
Previous: Matrix/Vector Multiplication Next: Bitwise Operations