scalar
sparse matrix (CSR format)
dense matrix
scalar
dense matrix
c = alpha * a × b + beta * c if beta does not equal null and c = alpha * a × b otherwise.
import mir.ndslice; import mir.sparse; auto sp = sparse!int(3, 5); sp[] = [[-5, 1, 7, 7, -4], [-1, -5, 6, 3, -3], [-5, -2, -3, 6, 0]]; auto a = sp.compress; auto b = slice!double(5, 4); b[] = [[-5.0, -3, 3, 1], [4.0, 3, 6, 4], [-4.0, -2, -2, 2], [-1.0, 9, 4, 8], [9.0, 8, 3, -2]]; auto c = slice!double(3, 4); gemm(1.0, a, b, 0, c); assert(c == [[-42.0, 35, -7, 77], [-69.0, -21, -42, 21], [23.0, 69, 3, 29]]);
General matrix-matrix multiplication.