kml_sparse_?cscmv
矩阵与向量乘积,矩阵是CSC格式的稀疏矩阵。
- y = alpha * A * x + beta * y
- y = alpha * AT * x + beta * y
- y = alpha * AH * x + beta * y
其中,alpha和beta是缩放系数,x和y是向量,A是CSC格式的稀疏向量。
接口定义
C interface:
kml_sparse_status_t kml_sparse_scscmv(const kml_sparse_operation_t opt, const KML_INT m, 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 *x, const float beta, float *y);
kml_sparse_status_t kml_sparse_dcscmv(const kml_sparse_operation_t opt, const KML_INT m, 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 *x, const double beta, double *y);
kml_sparse_status_t kml_sparse_ccscmv(const kml_sparse_operation_t opt, const KML_INT m, 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 *x, const KML_Complex8 beta, KML_Complex8 *y);
kml_sparse_status_t kml_sparse_zcscmv(const kml_sparse_operation_t opt, const KML_INT m, 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 *x, const KML_Complex16 beta, KML_Complex16 *y);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
opt |
枚举类型kml_sparse_operation_t |
表示矩阵A的操作。
|
输入 |
m |
整型数 |
表示A矩阵的行数,取值范围为[1, MAX_KML_INT]。 |
输入 |
k |
整型数 |
表示A矩阵的列数,取值范围为[1, MAX_KML_INT]。 |
输入 |
alpha |
|
表示系数。 |
输入 |
matdescra |
char指针 |
矩阵的操作属性,具体参考matdescra说明。 |
输入 |
val |
|
A矩阵中的非零元素。 |
输入 |
indx |
整型数组 |
indx[i]表示val数组中第i个元素在矩阵A中的行序号。 |
输入 |
pntrb |
整型数组 |
长度为m的数组,包含矩阵A的列索引,pntrb[i] - pntrb[0]表示第i列第一个非零元素在val和indx数组内的下标。 |
输入 |
pntre |
整型数组 |
长度为m的数组,包含矩阵A的列索引,pntre[i] - pntrb[0]-1表示第i列最后一个非零元素在val和indx数组内的下标。 |
输入 |
x |
|
向量x。 |
输入 |
beta |
|
表示系数。 |
输入 |
y |
|
向量y, 更新后输出。 |
输入/输出 |
返回值
函数执行状态,枚举类型kml_sparse_status_t。
依赖
C: "kspblas.h"
Fortran: "kspblas.f03"
示例
C interface:
kml_sparse_operation_t opt = KML_SPARSE_OPERATION_NON_TRANSPOSE; char *matdescra = "G00C"; KML_INT m = 4; KML_INT k = 4; float alpha = 1.0; float beta = 1.0; float val[9] = {2, 3, 1, 5, 7, 8, 3, 6, 7}; KML_INT indx[9] = {0, 1, 2, 1, 1, 2, 3, 0, 3}; KML_INT pntrb[4] = {0, 3, 4, 7}; KML_INT pntre[4] = {3, 4, 7, 9}; float x[4] = {6, 6, 4, 6}; float y[4] = {1, 1, 6, 1}; kml_sparse_status_t status = kml_sparse_scscmv(opt, m, k, alpha, matdescra, val, indx, pntrb, pntre, x, beta, y); /* * Output Y: * 49.000000 77.000000 44.000000 55.000000 * * */