Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.sparse.blas.gemv

Authors:
Ilya Yaroshenko
  • void gemv(CR, CL, SliceKind kind1, T1, I1, J1, SliceKind kind2, Iterator2, SliceKind kind3, Iterator3)(in CR alpha, Slice!(FieldIterator!(CompressedField!(T1, I1, J1)), 1, kind1) a, Slice!(Iterator2, 1, kind2) x, in CL beta, Slice!(Iterator3, 1, kind3) y);
    General matrix-vector multiplication.
    Parameters:
    CR alphascalar
    Slice!(FieldIterator!(CompressedField!(T1, I1, J1)), 1, kind1) asparse matrix (CSR format)
    Slice!(Iterator2, 1, kind2) xdense vector
    CL betascalar
    Slice!(Iterator3, 1, kind3) ydense vector
    Returns:
    y = alpha * a × x + beta * y if beta does not equal null and y = alpha * a × x otherwise.
    Examples:
    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);
    
  • void gemtv(CR, CL, SliceKind kind1, T1, I1, J1, SliceKind kind2, Iterator2, SliceKind kind3, Iterator3)(in CR alpha, Slice!(FieldIterator!(CompressedField!(T1, I1, J1)), 1, kind1) a, Slice!(Iterator2, 1, kind2) x, in CL beta, Slice!(Iterator3, 1, kind3) y);
    General matrix-vector multiplication with transposition.
    Parameters:
    CR alphascalar
    Slice!(FieldIterator!(CompressedField!(T1, I1, J1)), 1, kind1) asparse matrix (CSR format)
    Slice!(Iterator2, 1, kind2) xdense vector
    CL betascalar
    Slice!(Iterator3, 1, kind3) ydense vector
    Returns:
    y = alpha * aᵀ × x + beta * y if beta does not equal null and y = alpha * aᵀ × x otherwise.
    Examples:
    auto slice = sparse!double(5, 3);
    slice[] =
        [[0.0,  6.0,  6.0],
         [2.0,  0.0,  0.0],
         [3.0, 30.0, 30.0],
         [0.0,  8.0,  8.0],
         [0.0,  0.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);
    gemtv(alpha, a, x, beta, y);
    assert(t == y);
    
  • void gemv(CR, CL, SliceKind kind1, Iterator1, T2, I2, SliceKind kind3, Iterator3)(in CR alpha, Slice!(Iterator1, 2, kind1) a, CompressedArray!(T2, I2) x, in CL beta, Slice!(Iterator3, 1, kind3) y);
    General matrix-vector multiplication for sparse vectors.
    Parameters:
    CR alphascalar
    Slice!(Iterator1, 2, kind1) adense matrix
    CompressedArray!(T2, I2) xsparse vector
    CL betascalar
    Slice!(Iterator3, 1, kind3) ydense vector
    Returns:
    y = alpha * a × x + beta * y if beta does not equal null and y = alpha * a × x otherwise.
    Examples:
    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);
    
  • void selectiveGemv(string op = "", SliceKind kind1, SliceKind kind2, T, T3, I3)(Slice!(T*, 2, kind1) a, Slice!(T*, 1, kind2) x, CompressedArray!(T3, I3) y);
    Selective general matrix-vector multiplication with a selector sparse vector.
    Parameters:
    Slice!(T*, 2, kind1) adense matrix
    Slice!(T*, 1, kind2) xdense vector
    CompressedArray!(T3, I3) ysparse vector (compressed)
    Returns:
    y[available indexes] <op>= (alpha * a × x)[available indexes].