Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

mkl_sparse_?_mm

Computes the product of a sparse matrix and a dense matrix and stores the result as a dense matrix.

Syntax

sparse_status_t mkl_sparse_s_mm (const sparse_operation_t operation, const float alpha, const sparse_matrix_t A, const struct matrix_descr descr, const sparse_layout_t layout, const float *B, const MKL_INT columns, const MKL_INT ldb, const float beta, float *C, const MKL_INT ldc);

sparse_status_t mkl_sparse_d_mm (const sparse_operation_t operation, const double alpha, const sparse_matrix_t A, const struct matrix_descr descr, const sparse_layout_t layout, const double *B, const MKL_INT columns, const MKL_INT ldb, const double beta, double *C, const MKL_INT ldc);

sparse_status_t mkl_sparse_c_mm (const sparse_operation_t operation, const MKL_Complex8 alpha, const sparse_matrix_t A, const struct matrix_descr descr, const sparse_layout_t layout, const MKL_Complex8 *B, const MKL_INT columns, const MKL_INT ldb, const MKL_Complex8 beta, MKL_Complex8 *C, const MKL_INT ldc);

sparse_status_t mkl_sparse_z_mm (const sparse_operation_t operation, const MKL_Complex16 alpha, const sparse_matrix_t A, const struct matrix_descr descr, const sparse_layout_t layout, const MKL_Complex16 *B, const MKL_INT columns, const MKL_INT ldb, const MKL_Complex16 beta, MKL_Complex16 *C, const MKL_INT ldc);

Include Files
  • mkl_spblas.h
Description

The mkl_sparse_?_mm routine performs a matrix-matrix operation:

C := alpha*op(A)*B + beta*C

where alpha and beta are scalars, A is a sparse matrix, op is a matrix modifier for matrix A, and B and C are dense matrices.

The mkl_sparse_?_mm and mkl_sparse_?_trsm routines support these configurations:

 

Column-major dense matrix: layout = SPARSE_LAYOUT_COLUMN_MAJOR

Row-major dense matrix: layout = SPARSE_LAYOUT_ROW_MAJOR

0-based sparse matrix: SPARSE_INDEX_BASE_ZERO

CSR

BSR: general non-transposed matrix multiplication only

All formats

1-based sparse matrix: SPARSE_INDEX_BASE_ONE

All formats

CSR

BSR: general non-transposed matrix multiplication only

NOTE:

For sparse matrices in the BSR format, the supported combinations of (indexing,block_layout) are:

  • (SPARSE_INDEX_BASE_ZERO, SPARSE_LAYOUT_ROW_MAJOR )

  • (SPARSE_INDEX_BASE_ONE, SPARSE_LAYOUT_COLUMN_MAJOR )

Input Parameters
operation

Specifies operation op() on input matrix.

SPARSE_OPERATION_NON_TRANSPOSE

Non-transpose, op(A) = A.

SPARSE_OPERATION_TRANSPOSE

Transpose, op(A) = AT.

SPARSE_OPERATION_CONJUGATE_TRANSPOSE

Conjugate transpose, op(A) = AH.

alpha

Specifies the scalar alpha.

A

Handle which contains the sparse matrix A.

descr

Structure specifying sparse matrix properties.

sparse_matrix_type_t type - Specifies the type of a sparse matrix:

SPARSE_MATRIX_TYPE_GENERAL

The matrix is processed as is.

SPARSE_MATRIX_TYPE_SYMMETRIC

The matrix is symmetric (only the requested triangle is processed).

SPARSE_MATRIX_TYPE_HERMITIAN

The matrix is Hermitian (only the requested triangle is processed).

SPARSE_MATRIX_TYPE_TRIANGULAR

The matrix is triangular (only the requested triangle is processed).

SPARSE_MATRIX_TYPE_DIAGONAL

The matrix is diagonal (only diagonal elements are processed).

SPARSE_MATRIX_TYPE_BLOCK_TRIANGULAR

The matrix is block-triangular (only requested triangle is processed). Applies to BSR format only.

SPARSE_MATRIX_TYPE_BLOCK_DIAGONAL

The matrix is block-diagonal (only diagonal blocks are processed). Applies to BSR format only.

sparse_fill_mode_t mode - Specifies the triangular matrix part for symmetric, Hermitian, triangular, and block-triangular matrices:

SPARSE_FILL_MODE_LOWER

The lower triangular matrix part is processed.

SPARSE_FILL_MODE_UPPER

The upper triangular matrix part is processed.

sparse_diag_type_t diag - Specifies diagonal type for non-general matrices:

SPARSE_DIAG_NON_UNIT

Diagonal elements might not be equal to one.

SPARSE_DIAG_UNIT

Diagonal elements are equal to one.
layout

Describes the storage scheme for the dense matrix:

SPARSE_LAYOUT_COLUMN_MAJOR

Storage of elements uses column major layout.

SPARSE_LAYOUT_ROW_MAJOR

Storage of elements uses row major layout.

B

Array of size at least rows*cols.

 

layout = SPARSE_LAYOUT_COLUMN_MAJOR

layout = SPARSE_LAYOUT_ROW_MAJOR

rows (number of rows in B)

ldb

If op(A) = A, number of columns in A

If op(A) = AT, number of rows in A

cols (number of columns in B)

columns

ldb

columns

Number of columns of matrix C.

ldb

Specifies the leading dimension of matrix B.

beta

Specifies the scalar beta

C

Array of size at least rows*cols, where

 

layout = SPARSE_LAYOUT_COLUMN_MAJOR

layout = SPARSE_LAYOUT_ROW_MAJOR

rows (number of rows in C)

ldc

If op(A) = A, number of rows in A

If op(A) = AT, number of columns in A

cols (number of columns in C)

columns

ldc

ldc

Specifies the leading dimension of matrix C.

Output Parameters
C

Overwritten by the updated matrix C.

Return Values

The function returns a value indicating whether the operation was successful or not, and why.

SPARSE_STATUS_SUCCESS

The operation was successful.

SPARSE_STATUS_NOT_INITIALIZED

The routine encountered an empty handle or matrix array.

SPARSE_STATUS_ALLOC_FAILED

Internal memory allocation failed.

SPARSE_STATUS_INVALID_VALUE

The input parameters contain an invalid value.

SPARSE_STATUS_EXECUTION_FAILED

Execution failed.

SPARSE_STATUS_INTERNAL_ERROR

An error in algorithm implementation occurred.

SPARSE_STATUS_NOT_SUPPORTED

The requested operation is not supported.