Rate This Document
Findability
Accuracy
Completeness
Readability

kml_sparse_?cscmm

Compute the product of matrices. One of them is a sparse matrix in the CSC format. The operation is defined as follows:

  • C = alpha * A*B + beta * C
  • C = alpha * AT * B + beta * C
  • C = alpha * AH * B + beta * C

B and C are dense matrices, and A is a sparse matrix (m x k) stored in the CSC format.

Table 1 describes the relationship between layout and sparse matrix indexing.

Table 1 Relationship between layout and sparse matrix indexing

Sparse matrix indexing

Dense matrix layout

KML_SPARSE_INDEX_BASE_ZERO

KML_SPARSE_LAYOUT_ROW_MAJOR

KML_SPARSE_INDEX_BASE_ONE

KML_SPARSE_LAYOUT_COLUMN_MAJOR

Interface Definition

C interface:

kml_sparse_status_t kml_sparse_scscmm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, const KML_INT k, const float alpha, const char *matdescra, const float *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const float *b, const KML_INT ldb, const float beta , float *c , const KML_INT ldc);

kml_sparse_status_t kml_sparse_dcscmm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, const KML_INT k, const double alpha, const char *matdescra, const double *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const double *b, const KML_INT ldb, const double beta , double *c , const KML_INT ldc);

kml_sparse_status_t kml_sparse_ccscmm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, const KML_INT k, const KML_Complex8 alpha, const char *matdescra, const KML_Complex8 *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const KML_Complex8 *b, const KML_INT ldb, const KML_Complex8 beta , KML_Complex8 *c , const KML_INT ldc);

kml_sparse_status_t kml_sparse_zcscmm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, const KML_INT k, const KML_Complex16 alpha, const char *matdescra, const KML_Complex16 *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const KML_Complex16 *b, const KML_INT ldb, const KML_Complex16 beta , KML_Complex16 *c , const KML_INT ldc);

Parameters

Parameter

Type

Description

Input/Output

opt

Enumeration type kml_sparse_operation_t

Indicates whether to transpose.

  • If opt = KML_SPARSE_OPERATION_NON_TRANSPOSE, then C = alpha*A*B + beta*C.
  • If opt = KML_SPARSE_OPERATION_TRANSPOSE, then C = alpha*AT*B + beta*C.
  • If opt = KML_SPARSE_OPERATION_CONJUGATE_TRANSPOSE, then C = alpha*AH*B + beta*C.

Input

m

Integer

Number of rows in matrix A. The value range is [1, MAX_KML_INT].

Input

n

Integer

Number of columns in matrix C. The value range is [1, MAX_KML_INT].

Input

k

Integer

Number of columns in matrix A. The value range is [1, MAX_KML_INT].

Input

alpha

  • For scscmm, alpha is of the single-precision floating-point type.
  • For dcscmm, alpha is of the double-precision floating-point type.
  • For ccscmm, alpha is a single-precision complex number.
  • For zcscmm, alpha is a double-precision complex number.

Scalar alpha

Input

matdescra

Char pointer

Matrix operation attribute. For details, see the description of matdescra.

Input

val

  • For scscmm, val is a single-precision floating-point array.
  • For dcscmm, val is a double-precision floating-point array.
  • For ccscmm, val is a single-precision complex number array.
  • For zcscmm, val is a double-precision complex number array.

Array values storing non-zero elements of matrix A in the CSC format. The length is pntre[m-1] - pntrb[0].

Input

indx

Integer array

Array columns in the CSC format, which contains the row indices for non-zero elements in matrix A

Input

pntrb

Integer array

Array of length m, containing column indices of matrix A. pntrb[i] - pntrb[0] indicates the subscript of the first non-zero element in column i in the val and indx arrays.

Input

pntre

Integer array

Array of length m, containing column indices of matrix A. pntre[i] - pntrb[0]-1 indicates the subscript of the last non-zero element in column i in the val and indx arrays.

Input

b

  • For scscmm, b is a single-precision floating-point array.
  • For dcscmm, b is a double-precision floating-point array.
  • For ccscmm, b is a single-precision complex number array.
  • For zcscmm, b is a double-precision complex number array.

Array value of matrix B

Input

ldb

Integer array

  • Size of the leading dimension of matrix B for one-based indexing
  • Size of the second dimension of matrix B for zero-based indexing

Input

beta

  • For scscmm, beta is of the single-precision floating-point type.
  • For dcscmm, beta is of the double-precision floating-point type.
  • For ccscmm, beta is a single-precision complex number.
  • For zcscmm, beta is a double-precision complex number.

Scalar beta

Input

c

  • For scscmm, c is a single-precision floating-point array.
  • For dcscmm, c is a double-precision floating-point array.
  • For ccscmm, c is a single-precision complex number array.
  • For zcscmm, c is a double-precision complex number array.

Array value of matrix C

Input/Output

ldc

Integer array

  • Size of the leading dimension of matrix C for one-based indexing
  • Size of the second dimension of matrix C for zero-based indexing

Input

Table 2 describes the parameter constraints on matrix B.

Table 2 Parameter constraints on matrix B

opt

Matrix Scale

Data Layout

Value Range

op(A) = A

k * n

Row-major order

k * ldbMAX_KML_INT

op(A) = A

k * n

Column-major order

ldb * n MAX_KML_INT

op(A) = AT or AH

m x n

Row-major order

m * ldbMAX_KML_INT

op(A) = AT or AH

m x n

Column-major order

ldb * n MAX_KML_INT

Table 3 describes the parameter constraints on matrix C.

Table 3 Parameter constraints on matrix C

opt

Matrix Scale

Data Layout

Value Range

op(A) = A

m x n

Row-major order

m * ldcMAX_KML_INT

op(A) = A

m x n

Column-major order

ldc * n MAX_KML_INT

op(A) = AT or AH

k * n

Row-major order

k * ldc MAX_KML_INT

op(A) = AT or AH

k * n

Column-major order

ldc * n MAX_KML_INT

The function does not verify the integrity of parameters. Ensure that the elements in pntrb and pntre do not exceed the maximum index value of the input matrix.

Return Value

Function execution status. The enumeration type is kml_sparse_status_t.

Dependencies

C: "kspblas.h"

Fortran: "kspblas.f03"

Examples

C interface:

    kml_sparse_operation_t opt = KML_SPARSE_OPERATION_NON_TRANSPOSE; 
    KML_INT m = 3; 
    KML_INT n = 3; 
    KML_INT k = 3; 
    float alpha = 1.0; 
    float beta = 1.0; 
    char *matdescra = "G00C"; // General matrix with zero-based indexing
    float val[4] = {8, 5, 2, 9}; 
    KML_INT indx[4] = {0, 1, 2, 0}; 
    KML_INT pntrb[3] = {0, 0, 1}; 
    KML_INT pntre[3] = {0, 1, 4}; 
    float b[9] = {1, 5, 7, 4, 7, 7, 3, 3, 7}; 
    float c[9] = {0, 8, 8, 0, 2, 8, 3, 5, 6}; 
    KML_INT ldb = 3; 
    KML_INT ldc = 3; 
    kml_sparse_status_t status = kml_sparse_scscmm(opt, m, n, k, alpha, matdescra, val, indx, pntrb, pntre, b, ldb, beta, c, ldc); 
     
    /* 
     *  Output c: 
     *    59.00  91.00  127.00   
15.00  17.00  43.00   
9.00  11.00  20.00 
     * 
     * */