---
title: KmlSolverMatrixDestroy
description: "销毁由KmlSolverMatrixCreate函数创建的矩阵句柄。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0895.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0895.html
indexId: 91eb4fd91141776d19c9c4ad7adcf34d7f06fc2bf84746e787d842d3ae7d20d261
---
# KmlSolverMatrixDestroy

销毁由KmlSolverMatrixCreate函数创建的矩阵句柄。

#### 接口定义

C Interface：

int KmlSolverMatrixDestroy(KmlSolverMatrix **pMatrix);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| pMatrix | KmlSolverMatrix \*\* | 由KmlSolverMatrixCreate函数创建的矩阵句柄。 | 输入/输出 |


#### 返回值

| 返回值 | 类型 | 描述 |
| --- | --- | --- |
| KMLSS\_NO\_ERROR | int | 正常执行。 |
| KMLSS\_INTERNAL\_ERROR | int | 内部错误。 |
| KMLSS\_NULL\_ARGUMENT | int | pMatrix为空参数。 |


#### 依赖

#include "kml_solver.h"


#### 示例

C Interface：

```
#include "kml_solver.h"
KmlSolverMatrix *handle;
int ierr;
int n = 8;
int ia[9] = {0, 3, 7, 10, 14, 17, 21, 23, 26};
int ja[26] = {0, 3, 4, 1, 2, 3, 5, 1, 2, 7, 0, 1, 3, 6, 0, 4, 5, 1, 4, 5, 7, 3, 6, 2, 5, 7};
double a[26] = {1.0, 1.0, 2.0, 9.0, 2.0, 1.0, -3.0, 2.0, 3.0, 2.0, 1.0, 1.0, 9.0, -5.0, 2.0, 6.0, 1.0, -3.0, 1.0, 4.0, 1.0, -5.0, 7.0, 2.0, 1.0, 2.0};
KmlSolverMatrixStore store;
store
.indexType = KMLSS_INDEX_INT32;
store
.valueType = KMLSS_VALUE_FP64;
store
.nRow = n;
store
.nCol = n;
store
.format = KMLSS_MATRIX_STORE_CSR;
store.csr.rowOffset = ia;
store.csr.colIndex = ja;
store.csr.value = a;
KmlSolverMatrixOption opt;
opt.fieldMask = KMLSS_MATRIX_OPTION_TYPE;
opt.type = KMLSS_MATRIX_GEN;
ierr = KmlSolverMatrixCreate(&handle, &store, &opt);
if (ierr != KMLSS_NO_ERROR) {
printf("\nERROR in KmlSolverMatrixCreate: %d", ierr);
return 1;
}
double b[26] = {2.0, 2.0, 3.0, 1.0, 3.0, 5.0, -7.0, 9.0, 2.0, 1.0, 2.0, 2.0, 4.0, -3.0, 3.0, 7.0, 3.0, -8.0, 6.0, 2.0, 3.0, -7.0, 2.0, 9.0, 2.0, 6.0};
ierr = KmlSolverMatrixSetValue(handle, b);
if (ierr != KMLSS_NO_ERROR) {
printf("\nERROR in KmlSolverMatrixSetValue: %d", ierr);
return 1;
}
ierr = KmlSolverMatrixDestroy(&handle);
if (ierr != KMLSS_NO_ERROR) {
printf("\nERROR in KmlSolverMatrixDestroy: %d", ierr);
return 1;
}
```
