ztcl::tensor matmul
Gives the matrix product of two matrices.
ztcl::tensor matmul A B
Description
Gives the product of A (n by m) and B (m by k), of one dtype. Each output element adds its m products in rising order, with a multiply and then an add, so the bits are the same in each build. The cost is n * m * k operations.
Returns
A tensor of n by k.
Examples
Each example of this page runs after package require ztcl::tensor.
% set a [ztcl::tensor of {{1 2 3} {4 5 6}}]; ztcl::tensor matmul $a [ztcl::tensor transpose $a]
tensor f32 {2 2} {14.0 32.0 32.0 77.0}
Errors
% set a [ztcl::tensor of {{1 2 3} {4 5 6}}]; ztcl::tensor matmul $a $a
tensor matmul: the shapes {2 3} and {2 3} do not match
-errorcode ZTCL TENSOR
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.4
- Compute cost
- A cost for each element operation by its kind (a copy, an add, a division, a math function, a multiply-add of a matmul), set so that one compute unit takes about the time of one unit of plain Tcl. docs/modules/tensor.md has the table.