kml_sparse_?csrsm
Solve a system of triangular matrix equations. One of the matrices is a sparse matrix in the CSR format. The operation is defined as follows:
- A * y = alpha * x
- AT * y = alpha * x
- AH * y = alpha * x
x and y are m x n matrices, and A is a sparse matrix (m x m) stored in the CSR format. The non-zero elements of a given row in matrix A must be stored in the same order as they are displayed in the row (from left to right).
Table 1 describes the 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_scsrsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, const float alpha, const char *matdescra, const float *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const float *x, const KML_INT ldx, float *y , const KML_INT ldy);
kml_sparse_status_t kml_sparse_dcsrsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, const double alpha, const char *matdescra, const double *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre,const double *x, const KML_INT ldx, double *y , const KML_INT ldy);
kml_sparse_status_t kml_sparse_ccsrsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, 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 *x, const KML_INT ldx, KML_Complex8 *y, const KML_INT ldy);
kml_sparse_status_t kml_sparse_zcsrsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, 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 *x, const KML_INT ldx, KML_Complex16 *y , const KML_INT ldy);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
opt |
Enumeration type kml_sparse_operation_t |
Indicates whether to transpose.
|
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 x. The value range is [1, MAX_KML_INT]. |
Input |
alpha |
|
Scalar alpha |
Input |
matdescra |
Char pointer |
Matrix operation attribute. For details, see the description of matdescra. |
Input |
val |
|
Array values storing non-zero elements of matrix A in the CSR format. The length is pntre[m-1] - pntrb[0]. |
Input |
indx |
Integer array |
Array columns in the CSR format, which contains the column indices for non-zero elements in matrix A |
Input |
pntrb |
Integer array |
Array of length m, containing row indices of matrix A. pntrb[i] - pntrb[0] indicates the subscript of the first non-zero element in row i in the val and indx arrays. |
Input |
pntre |
Integer array |
Array of length m, containing row indices of matrix A. pntre[i] - pntrb[0]-1 indicates the subscript of the last non-zero element in row i in the val and indx arrays. |
Input |
x |
|
Array value of matrix x |
Input |
ldx |
Integer array |
|
Input |
y |
|
Array value of matrix y |
Input/Output |
ldy |
Integer array |
|
Input |
Table 2 describes the parameter constraints on matrix x.
opt |
Matrix Scale |
Data Layout |
Value Range |
|---|---|---|---|
op(A) = A, AT, or AH |
m x n |
Row-major order |
m * ldb |
op(A) = A, AT, or AH |
m x n |
Column-major order |
ldb * n |
Table 3 describes the parameter constraints on matrix y.
opt |
Matrix Scale |
Data Layout |
Value Range |
|---|---|---|---|
op(A) = A, AT, or AH |
m x n |
Row-major order |
m * ldc |
op(A) = A, AT, or AH |
m x n |
Column-major order |
ldc * n |
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 = 4;
KML_INT n = 2;
float alpha = 1.0;
char *matdescra = "TLNF"; // Triangular matrix with one-based indexing
float val[9] = {2, -3, 7, 1, -6, 8, -4, 5, 9};
KML_INT indx[9] = {1, 2, 4, 2, 4, 1, 3, 1, 4};
KML_INT pntrb[4] = {1, 4, 6, 8};
KML_INT pntre[4] = {4, 6, 8, 10};
float x[8] = {1, 3, -2, 5, 7, -3, 6, 8};
float y[8] = {0, 0, 0, 0, 0, 0, 0, 0};
KML_INT ldx = 4;
KML_INT ldy = 4;
kml_sparse_status_t status = kml_sparse_scsrsm(opt, m, n, alpha, matdescra, val, indx, pntrb, pntre, x, ldx, y, ldy);
/*
* Output Y:
* 0.500000 3.000000 1.500000 0.277778
3.500000 -3.000000 5.500000 -1.055556
*
* */
