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!(kind1, [1], FieldIterator!(CompressedField!(T1, I1, J1))) a, Slice!(kind2, [1], Iterator2) x, in CL beta, Slice!(kind3, [1], Iterator3) y);
    General matrix-vector multiplication.
    Parameters:
    CR alpha scalar
    Slice!(kind1, [1], FieldIterator!(CompressedField!(T1, I1, J1))) a sparse matrix (CSR format)
    Slice!(kind2, [1], Iterator2) x dense vector
    CL beta scalar
    Slice!(kind3, [1], Iterator3) y dense 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!(kind1, [1], FieldIterator!(CompressedField!(T1, I1, J1))) a, Slice!(kind2, [1], Iterator2) x, in CL beta, Slice!(kind3, [1], Iterator3) y);
    General matrix-vector multiplication with transposition.
    Parameters:
    CR alpha scalar
    Slice!(kind1, [1], FieldIterator!(CompressedField!(T1, I1, J1))) a sparse matrix (CSR format)
    Slice!(kind2, [1], Iterator2) x dense vector
    CL beta scalar
    Slice!(kind3, [1], Iterator3) y dense 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!(kind1, [2], Iterator1) a, CompressedArray!(T2, I2) x, in CL beta, Slice!(kind3, [1], Iterator3) y);
    General matrix-vector multiplication for sparse vectors.
    Parameters:
    CR alpha scalar
    Slice!(kind1, [2], Iterator1) a dense matrix
    CompressedArray!(T2, I2) x sparse vector
    CL beta scalar
    Slice!(kind3, [1], Iterator3) y dense 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!(kind1, [2], T*) a, Slice!(kind2, [1], T*) x, CompressedArray!(T3, I3) y);
    Selective general matrix-vector multiplication with a selector sparse vector.
    Parameters:
    Slice!(kind1, [2], T*) a dense matrix
    Slice!(kind2, [1], T*) x dense vector
    CompressedArray!(T3, I3) y sparse vector (compressed)
    Returns:
    y[available indexes] <op>= (alpha * a × x)[available indexes].