m(rows) x k(cols) matrix
k(rows) x n(cols) matrix Result: m(rows) x n(cols)
import mir.ndslice; auto a = [-5, 1, 7, 7, -4, -1, -5, 6, 3, -3, -5, -2, -3, 6, 0].sliced(3, 5); auto b = slice!double(5, 4); b[] = [[-5, -3, 3, 1], [ 4, 3, 6, 4], [-4, -2, -2, 2], [-1, 9, 4, 8], [ 9, 8, 3, -2]]; assert(mtimes(a, b) == [[-42, 35, -7, 77], [-69, -21, -42, 21], [ 23, 69, 3, 29]] );
ger specialized case in mtimes
import mir.ndslice; // from https://github.com/kaleidicassociates/lubeck/issues/8 { auto a = [1.0f, 2.0f].sliced(2, 1); auto b = [1.0f, 2.0f].sliced(2, 1); assert(mtimes(a, b.transposed) == [[1, 2], [2, 4]]); } { auto a = [1.0, 2.0].sliced(1, 2); auto b = [1.0, 2.0].sliced(1, 2); assert(mtimes(a.transposed, b) == [[1, 2], [2, 4]]); }
import mir.ndslice; // from https://github.com/kaleidicassociates/lubeck/issues/3 Slice!(float*, 2) a = slice!float(1, 1); Slice!(float*, 2, Universal) b1 = slice!float(16, 1).transposed; Slice!(float*, 2) b2 = slice!float(1, 16); a[] = 3; b1[] = 4; b2[] = 4; // Confirm that this message does not appear // Outputs: ** On entry to SGEMM parameter number 8 had an illegal value assert(a.mtimes(b1) == a.mtimes(b2));
General matrix-matrix multiplication. Allocates result to an uninitialized slice using GC.