mctc_csrlist_linal Module

Sparse matrix-vector and matrix-matrix routines for CSR compressed matrices. The routines follow the argument conventions of the MKL sparse BLAS.



Interfaces

public interface spmm_csr

Performs the Compressed Sparse Row (CSR) matrix-matrix operations

C := op(A)B (sparse B and C) C := alphaop(A)B + betaC (dense B and C)

with op(A) = A or A^T.

  • private recursive subroutine spspmm_csr(trans, request, sort, m, n, k, a, ja, ia, b, jb, ib, c, jc, ic, nzmax, info)

    Multiply two CSR matrices, C := op(A)*B, with a CSR result. The columns of each row of C are returned in ascending order.

    Arguments

    Type IntentOptional Attributes Name
    character(len=1), intent(in) :: trans

    Operation selector, ‘N’ for AB, ‘T’ or ‘C’ for A^TB

    integer, intent(in) :: request

    Computation stage, 0 computes ic, jc and c within nzmax elements, 1 computes only ic, 2 computes jc and c from an ic of a previous call

    integer, intent(in) :: sort

    Reordering selector, accepted for compatibility only since the inputs need no sorting and the result is always sorted

    integer, intent(in) :: m

    Number of rows of the matrix A

    integer, intent(in) :: n

    Number of columns of the matrix A

    integer, intent(in) :: k

    Number of columns of the matrix B

    real(kind=wp), intent(in) :: a(:)

    Non-zero elements of the matrix A

    integer, intent(in) :: ja(:)

    Column indices of the non-zero elements of A

    integer(kind=i8), intent(in) :: ia(:)

    Row offsets of A into a and ja, size m + 1

    real(kind=wp), intent(in) :: b(:)

    Non-zero elements of the matrix B

    integer, intent(in) :: jb(:)

    Column indices of the non-zero elements of B

    integer(kind=i8), intent(in) :: ib(:)

    Row offsets of B into b and jb, size n + 1 for ‘N’ and m + 1 for ‘T’

    real(kind=wp), intent(inout) :: c(:)

    Non-zero elements of the matrix C, not referenced for request 1

    integer, intent(inout) :: jc(:)

    Column indices of the non-zero elements of C, not referenced for request 1

    integer(kind=i8), intent(inout) :: ic(:)

    Row offsets of C into c and jc, size m + 1 for ‘N’ and n + 1 for ‘T’

    integer(kind=i8), intent(in) :: nzmax

    Maximum number of non-zero elements of C, only referenced for request 0

    integer, intent(out) :: info

    Exit status, zero on success, or the row of C exceeding nzmax for request 0

  • private subroutine spgemm_csr(transa, m, n, k, alpha, matdescra, val, indx, pntrb, pntre, b, ldb, beta, c, ldc)

    Multiply a CSR matrix by a dense matrix, C := alphaop(A)B + beta*C.

    Arguments

    Type IntentOptional Attributes Name
    character(len=1), intent(in) :: transa

    Operation selector, ‘N’ for AB, ‘T’ or ‘C’ for A^TB

    integer, intent(in) :: m

    Number of rows of the matrix A

    integer, intent(in) :: n

    Number of columns of the matrices B and C

    integer, intent(in) :: k

    Number of columns of the matrix A

    real(kind=wp), intent(in) :: alpha

    Matrix scaling factor

    character(len=*), intent(in) :: matdescra

    Matrix descriptor, structure in the first and triangle in the second character, the triangle is only referenced for symmetric matrices

    real(kind=wp), intent(in) :: val(:)

    Non-zero elements of the matrix A

    integer, intent(in) :: indx(:)

    Column indices of the non-zero elements of A

    integer(kind=i8), intent(in) :: pntrb(:)

    Offsets of the first element of each row of A, size m

    integer(kind=i8), intent(in) :: pntre(:)

    Offsets past the last element of each row of A, size m

    real(kind=wp), intent(in) :: b(ldb,n)

    Dense right-hand side block, k-by-n for ‘N’ and m-by-n for ‘T’

    integer, intent(in) :: ldb

    Leading dimension of B

    real(kind=wp), intent(in) :: beta

    Existing-matrix scaling factor

    real(kind=wp), intent(inout) :: c(ldc,n)

    Dense product block, m-by-n for ‘N’ and k-by-n for ‘T’

    integer, intent(in) :: ldc

    Leading dimension of C


Subroutines

public subroutine spgemv_csr(m, a, ia, ja, x, y, transa)

Multiply a general CSR matrix by a vector

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: m

Number of rows of the matrix A

real(kind=wp), intent(in) :: a(:)

Non-zero elements of the matrix A

integer(kind=i8), intent(in) :: ia(:)

Row offsets of A into a and ja, size m + 1

integer, intent(in) :: ja(:)

Column indices of the non-zero elements of A

real(kind=wp), intent(in) :: x(:)

Input vector

real(kind=wp), intent(inout) :: y(:)

Output vector, its first m elements are overwritten

character(len=1), intent(in), optional :: transa

Operation selector, ‘N’ for Ax (default), ‘T’ or ‘C’ for A^Tx

public subroutine spmspv_csr(list, mlist, xptr, xval, yptr, yval, alpha)

Multiply a CSR matrix given in complete storage by a sparse vector

Arguments

Type IntentOptional Attributes Name
type(csr_list), intent(in) :: list

CSR neighbour-list structure

real(kind=wp), intent(in) :: mlist(:)

Matrix elements in CSR order

integer, intent(in) :: xptr(:)

Row indices of the non-zero elements of the input vector

real(kind=wp), intent(in) :: xval(:)

Values of the non-zero elements of the input vector

integer, intent(out), allocatable :: yptr(:)

Row indices of the non-zero elements of the product vector, allocated here

real(kind=wp), intent(out), allocatable :: yval(:)

Values of the non-zero elements of the product vector, allocated here

real(kind=wp), intent(in), optional :: alpha

Matrix scaling factor, defaults to one

public subroutine spsymv_csr(m, a, ia, ja, x, y, uplo)

Multiply a symmetric CSR matrix by a vector

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: m

Number of rows of the matrix A

real(kind=wp), intent(in) :: a(:)

Non-zero elements of the matrix A

integer(kind=i8), intent(in) :: ia(:)

Row offsets of A into a and ja, size m + 1

integer, intent(in) :: ja(:)

Column indices of the non-zero elements of A

real(kind=wp), intent(in) :: x(:)

Input vector

real(kind=wp), intent(inout) :: y(:)

Output vector, its first m elements are overwritten

character(len=1), intent(in), optional :: uplo

Triangle selector, ‘U’ for the upper (default), ‘L’ for the lower one