Rate This Document
Findability
Accuracy
Completeness
Readability

KmlSolverMatrixDestroy

Destroy the matrix handle created by the KmlSolverMatrixCreate function.

Interface Definition

C interface:

int KmlSolverMatrixDestroy(KmlSolverMatrix **pMatrix);

Parameters

Parameter

Type

Description

Input/Output

pMatrix

KmlSolverMatrix **

Matrix handle created by KmlSolverMatrixCreate.

Input/Output

Return Value

Return Value

Type

Description

KMLSS_NO_ERROR

int

Normal execution.

KMLSS_INTERNAL_ERROR

int

Internal error.

KMLSS_NULL_ARGUMENT

int

The value of pMatrix is null.

Dependencies

#include "kml_solver.h"

Examples

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;
}