---
title: KmlIssGcrSpmv
description: "计算GCR算法中的稀疏矩阵向量乘。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0850.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0850.html
indexId: af0ea31319910178f0f2d8cbed4c8787070d9ace7fa56641023299aa9f2d8f2861
---
# KmlIssGcrSpmv

计算GCR算法中的稀疏矩阵向量乘。

#### 接口定义

C Interface：

int KmlIssGcrSpmv(const float *a, const float *x, float *b, const int *xl, const int *xr, const int *yl, const int *yr, const int *zl, const int *ybegin, const int *yend, const int *zbegin, const int *zend);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| a | const float \* | 矩阵a，按(z,x,y)方向存储。 | 输入 |
| x | const float \* | 向量x，按(z,x,y)方向存储。 | 输入 |
| b | double \* | 计算结果b。 | 输入/输出 |
| xl | const int \* | 求解空间x方向起始位置。 | 输入 |
| xr | const int \* | 求解空间x方向结束位置。 | 输入 |
| yl | const int \* | 求解空间y方向起始位置。 | 输入 |
| yr | const int \* | 求解空间y方向结束位置。 | 输入 |
| zl | const int \* | 求解空间z方向起始位置。 | 输入 |
| ybegin | const int \* | 辅助求解空间y方向起始位置。 | 输入 |
| yend | const int \* | 辅助求解空间y方向结束位置。 | 输入 |
| zbegin | const int \* | 辅助求解空间z方向起始位置。 | 输入 |
| zend | const int \* | 辅助求解空间z方向结束位置。 | 输入 |


#### 返回值

| 返回值 | 类型 | 描述 |
| --- | --- | --- |
| KMLSS\_NO\_ERROR | int | 正常执行。 |
| KMLSS\_NULL\_ARGUMENT | int | 输入中存在空指针。 |
| KMLSS\_BAD\_DATA | int | 求解空间相关参数为无效参数。 |


#### 依赖

#include "kml_gcr_specific.h"


#### 示例

C Interface：```
int xl = 5;
int yl = 5;
int zl = 5;
int xr = 6;
int yr = 6;
int zr = 6;
int ybegin = 5;
int yend = 6;
int zbegin = 5;
int zend = 6;
float *a = (float*)malloc(sizeof(float) * 45);
float *x = (float*)malloc(sizeof(float) * 3);
float *b = (float*)malloc(sizeof(float) * 45);
for (int i=0; i<45; i++) {
    a[i] = rand();
    b[i] = rand();
}
for (int i=0; i<3; i++) {
    x[i] = rand();
}

KmlIssGcrSpmv(a, x, b, &xl, &xr, &yl, &yr, &zl, &ybegin, &yend, &zbegin, &zend);
```
