kml_csparse_?csrtrsv
求解稀疏三角线性方程组计算,稀疏矩阵采用CSR格式存储,具体执行操作如下:
- x = A * y
- x = AT * y
- x = AH * y
A为3数组CSR格式稀疏矩阵,x、y为向量,仅支持zero-based indexing。矩阵A中的给定行的非零元素的存储顺序必须与行中显示的顺序相同(从左到右)。
接口定义
C interface:
kml_sparse_status_t kml_csparse_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_csparse_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_csparse_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_csparse_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);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
uplo |
枚举类型kml_sparse_fill_mode_t uplo |
指示矩阵A的上三角或者下三角被使用:
|
输入 |
opt |
枚举类型kml_sparse_operation_t |
表示矩阵A的操作,
|
输入 |
diag |
枚举类型kml_sparse_diag_type_t |
对角元素是否是单位元素。
|
输入 |
m |
整型数 |
表示A矩阵的行数和列数,取值范围为[1, MAX_KML_INT]。 |
输入 |
a |
|
A矩阵中的非零元素。 |
输入 |
ia |
整型数组 |
长度为m+1的向量。 ia[i]表示A矩阵第i行第一个非零元素在val数组中的索引。 |
输入 |
ja |
整型数组 |
ja[i]表示val数组中第i个元素在矩阵A中的列序号。 |
输入 |
x |
|
向量x。 |
输入 |
y |
|
向量y, 更新后输出。 |
输入/输出 |
返回值
函数执行状态,枚举类型kml_sparse_status_t。
依赖
C: "kspblas.h"
Fortran: "kspblas.f03"
示例
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] = {3, 0, 3, 1, 2, 2, 3, 3, 1}; KML_INT ia[5] = {0, 2, 5, 7, 9}; float x[4] = {6, 6, 4, 6}; float y[4] = {1, 1, 6, 1}; kml_sparse_status_t status = kml_csparse_scsrtrsv(uplo, opt, diag, m, val, ia, ja, x, y); /* * Output Y: * -3.000000 1.200000 0.500000 1.800000 * * */