gemm

General matrix-matrix multiplication.

void
gemm
(
CR
CL
SliceKind kind1
T1
I1
J1
SliceKind kind2
Iterator2
SliceKind kind3
Iterator3
)
(
in CR alpha
,
Slice!(ChopIterator!(J1*, Series!(I1*, T1*)), 1, kind1) a
,
Slice!(Iterator2, 2, kind2) b
,
in CL beta
,
Slice!(Iterator3, 2, kind3) c
)

Parameters

alpha CR

scalar

a Slice!(ChopIterator!(J1*, Series!(I1*, T1*)), 1, kind1)

sparse matrix (CSR format)

b Slice!(Iterator2, 2, kind2)

dense matrix

beta CL

scalar

c Slice!(Iterator3, 2, kind3)

dense matrix

Return Value

Type: void

c = alpha * a × b + beta * c if beta does not equal null and c = alpha * a × b otherwise.

Examples

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]]);

Meta