kml_sparse_?csrtrsv
Solve a system of linear equations for a triangular sparse matrix that is stored in the CSR format. The operation is defined as follows:
- x = A * y
- x = AT * y
- x = AH * y
A is a sparse matrix stored in the CSR format (3-array variation), x and y are vectors, and only one-based indexing is supported. 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).
Interface Definition
C interface:
kml_sparse_status_t kml_sparse_scsrtrsv(const char uplo, const kml_sparse_operation_t opt, const char diag, const KML_INT m, const float *a, const KML_INT *ia, const KML_INT *ja, const float *x, float *y);
kml_sparse_status_t kml_sparse_dcsrtrsv(const char uplo, const kml_sparse_operation_t opt, const char diag, const KML_INT m, const double *a, const KML_INT *ia, const KML_INT *ja, const double *x, double *y);
kml_sparse_status_t kml_sparse_ccsrtrsv(const char uplo, const kml_sparse_operation_t opt, const char *diag, const KML_INT m, const KML_Complex8 *a, const KML_INT *ia, const KML_INT *ja, const KML_Complex8 *x, KML_Complex8 *y);
kml_sparse_status_t kml_sparse_zcsrtrsv(const char uplo, const kml_sparse_operation_t opt, const char *diag, const KML_INT m, const KML_Complex16 *a, const KML_INT *ia, const KML_INT *ja, const KML_Complex16 *x, KML_Complex16 *y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
uplo |
Enumeration type kml_sparse_fill_mode_t uplo |
Indicates whether the upper triangle or lower triangle of matrix A is used.
|
Input |
opt |
Enumeration type kml_sparse_operation_t |
Operation on matrix A.
|
Input |
diag |
Enumeration type kml_sparse_diag_type_t |
Whether the diagonal element is a unit element. U: unit element N: non-unit element |
Input |
m |
Integer |
Number of rows and columns in matrix A. The value range is [1, MAX_KML_INT]. |
Input |
a |
|
Non-zero elements in matrix A |
Input |
ia |
Integer array |
Vector whose length is m+1. ia[i]-1 indicates the index of the first non-zero element in the ith row of matrix A in the val array. |
Input |
ja |
Integer array |
ja[i] indicates the column number of the ith element of the val array in matrix A. |
Input |
x |
|
Vector x |
Input |
y |
|
Vector y. This parameter is output after update. |
Input/Output |
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_fill_mode_t uplo = KML_SPARSE_FILL_MODE_LOWER;
kml_sparse_diag_type_t diag = KML_SPARSE_DIAG_NON_UNIT;
kml_sparse_operation_t opt = KML_SPARSE_OPERATION_NON_TRANSPOSE;
KML_INT m = 4;
float val[9] = {2, -2, 1, 5, 3, 8, 6, 2, 2};
KML_INT ja[9] = {4, 1, 4, 2, 3, 3, 4, 4, 2};
KML_INT ia[5] = {1, 3, 6, 8, 10};
float x[4] = {6, 6, 4, 6};
float y[4] = {1, 1, 6, 1};
kml_sparse_status_t status = kml_sparse_scsrtrsv(uplo, opt, diag, m, val, ia, ja, x, y);
/*
* Output Y:
* -3.000000 1.200000 0.500000 1.800000
*
* */


