gemv

General matrix-vector multiplication.

  1. void gemv(CR alpha, Slice!(ChopIterator!(J1*, Series!(I1*, T1*)), 1, kind1) a, Slice!(Iterator2, 1, kind2) x, CL beta, Slice!(Iterator3, 1, kind3) y)
    void
    gemv
    (
    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, 1, kind2) x
    ,
    in CL beta
    ,
    Slice!(Iterator3, 1, kind3) y
    )
  2. void gemv(CR alpha, Slice!(Iterator1, 2, kind1) a, Series!(I2*, T2*) x, CL beta, Slice!(Iterator3, 1, kind3) y)

Parameters

alpha CR

scalar

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

sparse matrix (CSR format)

x Slice!(Iterator2, 1, kind2)

dense vector

beta CL

scalar

y Slice!(Iterator3, 1, kind3)

dense vector

Return Value

Type: void

y = alpha * a × x + beta * y if beta does not equal null and y = alpha * a × x otherwise.

Examples

import mir.ndslice;
import mir.sparse;

auto slice = sparse!double(3, 5);
slice[] =
    [[ 0.0, 2.0,  3.0, 0.0, 0.0],
     [ 6.0, 0.0, 30.0, 8.0, 0.0],
     [ 6.0, 0.0, 30.0, 8.0, 0.0]];
auto alpha = 3.0;
auto a = slice.compress;
auto x =  [ 17.0, 19, 31, 3, 5].sliced;
auto beta = 2.0;
auto y = [1.0, 2, 3].sliced;
auto t = [131.0, 1056.0, 1056.0].sliced;
t[] *= alpha;
import mir.glas.l1: axpy;
axpy(beta, y, t);
gemv(alpha, a, x, beta, y);
assert(t == y);

Meta