mtimes
result = matmul(A, B)
Input: A, B · Output: result
What it is
Matrix multiplication of A (r×k) and B (k×c), both Mat (inner dimensions must agree).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = matmul(A, B) | A Matnot documented yetB Matnot documented yet | result Mat | Returns an r×c Mat. mtimes is the exact same builtin under a second, MATLAB-flavored name. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
row = [1, 1, 0, 0] -> (1, 4)
col = [1; 2; 3; 4]
print(matmul(row, col)) # 3 — inner product (dot product) of the two
print(matmul(col, row)) # 4x4 outer product: [1,1,0,0; 2,2,0,0; 3,3,0,0; 4,4,0,0]
A = [1, 2; 3, 4]
B = [5, 6; 7, 8]
print(matmul(A, B))
print(mtimes(A, B)) # matmul and mtimes are the same builtin under two names
output
3 [1, 1, 0, 0; 2, 2, 0, 0; 3, 3, 0, 0; 4, 4, 0, 0] [19, 22; 43, 50] [19, 22; 43, 50]
from core-math
See also
matmul — documented in the same entry.