dense matrix
dense matrix
sparse matrix (CSR format)
c[available indexes] <op>= (a × b)[available indexes].
import mir.ndslice; import mir.sparse; auto a = slice!double(3, 5); a[] = [[-5, 1, 7, 7, -4], [-1, -5, 6, 3, -3], [-5, -2, -3, 6, 0]]; 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]]; // a * b == // [[-42.0, 35, -7, 77], // [-69.0, -21, -42, 21], // [23.0, 69, 3, 29]]); auto cs = sparse!double(3, 4); cs[0, 2] = 1; cs[0, 1] = 3; cs[2, 3] = 2; auto c = cs.compress; selectiveGemm!"*"(a, b, c); assert(c.length == 3); assert(c[0].index == [1, 2]); assert(c[0].value == [105, -7]); assert(c[1].empty); assert(c[2].index == [3]); assert(c[2].value == [58]);
Selective general matrix multiplication with selector sparse matrix.