Other sparse matrix operations

template<typename T, SparseMatrix SpMat>
inline void RandBLAS::spmm(blas::Layout layout, blas::Op opA, blas::Op opB, int64_t m, int64_t n, int64_t k, T alpha, SpMat &A, int64_t ro_a, int64_t co_a, const T *B, int64_t ldb, T beta, T *C, int64_t ldc)

Perform an SPMM-like operation, multiplying a dense matrix on the left with a (submatrix of a) sparse matrix:

\[\operatorname{mat}(C) = \alpha \cdot \underbrace{\operatorname{op}(\operatorname{submat}(A))}_{m \times k} \cdot \underbrace{\operatorname{op}(\operatorname{mat}(B))}_{k \times n} + \beta \cdot \underbrace{\operatorname{mat}(C)}_{m \times n}, \tag{$\star$}\]

where \(\alpha\) and \(\beta\) are real scalars, \(\operatorname{op}(X)\) either returns a matrix \(X\) or its transpose, and \(A\) is a sparse matrix.

Full parameter descriptions
layout - [in]
  • Layout::ColMajor or Layout::RowMajor.

  • Matrix storage for \(\operatorname{mat}(B)\) and \(\operatorname{mat}(C)\).

opA - [in]
  • If \(\texttt{opA}\) == NoTrans, then \(\operatorname{op}(\operatorname{submat}(A)) = \operatorname{submat}(A)\).

  • If \(\texttt{opA}\) == Trans, then \(\operatorname{op}(\operatorname{submat}(A)) = \operatorname{submat}(A)^T\).

opB - [in]
  • If \(\texttt{opB}\) = NoTrans, then \(\operatorname{op}(\operatorname{mat}(B)) = \operatorname{mat}(B)\).

  • If \(\texttt{opB}\) = Trans, then \(\operatorname{op}(\operatorname{mat}(B)) = \operatorname{mat}(B)^T\).

m - [in]
  • A nonnegative integer.

  • The number of rows in \(\operatorname{mat}(C)\).

  • The number of rows in \(\operatorname{op}(\operatorname{submat}(A))\).

n - [in]
  • A nonnegative integer.

  • The number of columns in \(\operatorname{mat}(C)\)

  • The number of columns in \(\operatorname{op}(\operatorname{mat}(B))\).

k - [in]
  • A nonnegative integer.

  • The number of columns in \(\operatorname{op}(\operatorname{submat}(A))\)

  • The number of rows in \(\operatorname{op}(\operatorname{mat}(B))\).

alpha - [in]
  • A real scalar.

A - [in]
  • A RandBLAS sparse matrix object.

  • Defines \(\operatorname{submat}(A)\).

ro_a - [in]
  • A nonnegative integer.

  • The rows of \(\operatorname{submat}(A)\) are a contiguous subset of rows of \(A.\)

  • The rows of \(\operatorname{submat}(A)\) start at \(A[\texttt{ro_a}, :].\)

co_a - [in]
  • A nonnegative integer.

  • The columns of \(\operatorname{submat}(A)\) are a contiguous subset of columns of \(A\).

  • The columns \(\operatorname{submat}(A)\) start at \(A[:,\texttt{co_a}]\).

B - [in]
  • Pointer to 1D array of real scalars that define \(\operatorname{mat}(B)\).

ldb - [in]
  • A nonnegative integer.

  • The leading dimension of \(\operatorname{mat}(B)\) when reading from \(B.\)

beta - [in]
  • A real scalar.

  • If zero, then \(C\) need not be set on input.

C - [in, out]
  • Pointer to 1D array of real scalars.

  • On entry, defines \(\operatorname{mat}(C)\) on the RIGHT-hand side of \((\star)\).

  • On exit, defines \(\operatorname{mat}(C)\) on the LEFT-hand side of \((\star)\).

ldc - [in]
  • A nonnegative integer.

  • Leading dimension of \(\operatorname{mat}(C)\) when reading from \(C\).

template<typename T, SparseMatrix SpMat>
inline void RandBLAS::spmm(blas::Layout layout, blas::Op opA, blas::Op opB, int64_t m, int64_t n, int64_t k, T alpha, const T *A, int64_t lda, SpMat &B, int64_t ro_b, int64_t co_b, T beta, T *C, int64_t ldc)

Perform an SPMM-like operation, multiplying a dense matrix on the right with a (submatrix of a) sparse matrix:

\[\operatorname{mat}(C) = \alpha \cdot \underbrace{\operatorname{op}(\operatorname{mat}(A))}_{m \times k} \cdot \underbrace{\operatorname{op}(\operatorname{submat}(B))}_{k \times n} + \beta \cdot \underbrace{\operatorname{mat}(C)}_{m \times n}, \tag{$\star$}\]

where \(\alpha\) and \(\beta\) are real scalars, \(\operatorname{op}(X)\) either returns a matrix \(X\) or its transpose, and \(B\) is a sparse matrix.

Full parameter descriptions
layout - [in]
  • Layout::ColMajor or Layout::RowMajor.

  • Matrix storage for \(\operatorname{mat}(A)\) and \(\operatorname{mat}(C)\).

opA - [in]
  • If \(\texttt{opA}\) = NoTrans, then \(\operatorname{op}(\operatorname{mat}(A)) = \operatorname{mat}(A)\).

  • If \(\texttt{opA}\) = Trans, then \(\operatorname{op}(\operatorname{mat}(A)) = \operatorname{mat}(A)^T\).

opB - [in]
  • If \(\texttt{opB}\) = NoTrans, then \(\operatorname{op}(\operatorname{submat}(B)) = \operatorname{submat}(B)\).

  • If \(\texttt{opB}\) = Trans, then \(\operatorname{op}(\operatorname{submat}(B)) = \operatorname{submat}(B)^T\).

m - [in]
  • A nonnegative integer.

  • The number of rows in \(\operatorname{mat}(C)\).

  • The number of rows in \(\operatorname{op}(\operatorname{mat}(A))\).

n - [in]
  • A nonnegative integer.

  • The number of columns in \(\operatorname{mat}(C)\).

  • The number of columns in \(\operatorname{op}(\operatorname{submat}(B))\).

k - [in]
  • A nonnegative integer.

  • The number of columns in \(\operatorname{op}(\operatorname{mat}(A))\)

  • The number of rows in \(\operatorname{op}(\operatorname{submat}(B))\).

alpha - [in]
  • A real scalar.

A - [in]
  • Pointer to a 1D array of real scalars.

lda - [in]
  • A nonnegative integer.

  • Leading dimension of \(\operatorname{mat}(A)\) when reading from \(A\).

B - [in]
  • A RandBLAS sparse matrix object.

  • Defines \(\operatorname{submat}(B)\).

ro_b - [in]
  • A nonnegative integer.

  • The rows of \(\operatorname{submat}(B)\) are a contiguous subset of rows of \(B\).

  • The rows of \(\operatorname{submat}(B)\) start at \(B[\texttt{ro_b}, :]\).

co_b - [in]
  • A nonnegative integer.

  • The columns of \(\operatorname{submat}(B)\) are a contiguous subset of columns of \(B\).

  • The columns \(\operatorname{submat}(B)\) start at \(B[:,\texttt{co_a}]\).

beta - [in]
  • A real scalar.

  • If zero, then \(C\) need not be set on input.

C - [in, out]
  • Pointer to 1D array of real scalars.

  • On entry, defines \(\operatorname{mat}(C)\) on the RIGHT-hand side of \((\star)\).

  • On exit, defines \(\operatorname{mat}(C)\) on the LEFT-hand side of \((\star)\).

ldc - [in]
  • A nonnegative integer.

  • Leading dimension of \(\operatorname{mat}(C)\) when reading from \(C\).