matr_mul - ObjectVision/GeoDMS GitHub Wiki
Matrix functions matr_mul
The matr_mul function performs matrix multiplication using Boost uBLAS.
matr_mul(matrix1: RxC1->Float, matrix2: C1xC2->Float, resultDomain: RxC2) -> RxC2->Float
Computes the matrix product of two matrices. If matrix1 has dimensions R×C1 and matrix2 has dimensions C1×C2, the result has dimensions R×C2.
The value at result[i,j] is: Σ(k=0 to C1-1) matrix1[i,k] × matrix2[k,j]
| argument | description | type |
|---|---|---|
| matrix1 | First matrix attribute | attribute |
| matrix2 | Second matrix attribute | attribute |
| resultDomain | Domain unit for the result (must have appropriate dimensions) | unit |
Uses the Boost uBLAS library for efficient matrix operations. Complexity is O(R × C1 × C2) - standard matrix multiplication complexity.
For large matrices, performance depends on:
- Matrix dimensions
- Memory access patterns
- Cache utilization
- Width(matrix1) must equal Height(matrix2)
- Height(resultDomain) must equal Height(matrix1)
- Width(resultDomain) must equal Width(matrix2)
- Value types must be Float32 or Float64
// Define matrix domains
unit<SPoint> MatrixA := range(SPoint, point_xy(0s, 0s), point_xy(3s, 4s)); // 3x4
unit<SPoint> MatrixB := range(SPoint, point_xy(0s, 0s), point_xy(4s, 2s)); // 4x2
unit<SPoint> MatrixR := range(SPoint, point_xy(0s, 0s), point_xy(3s, 2s)); // 3x2
attribute<Float64> A (MatrixA); // input
attribute<Float64> B (MatrixB); // input
attribute<Float64> Result (MatrixR) := matr_mul(A, B, MatrixR);
7.0