我要评分
获取效率
正确性
完整性
易理解

KmlDssGenGet?I(D/S)

Obtain handle-related real-number values.

Interface Definition

C interface:

int KmlDssGenGetSIS(KmlSolverTask **pHandle, enum KmlSolverParam param, float *value, int nvalue);

int KmlDssGenGetDID(KmlSolverTask **pHandle, enum KmlSolverParam param, double *value, int nvalue);

int KmlDssGenGetCIS(KmlSolverTask **pHandle, enum KmlSolverParam param, float *value, int nvalue);

int KmlDssGenGetZID(KmlSolverTask **pHandle, enum KmlSolverParam param, double *value, int nvalue);

Parameters

Parameter

Type

Description

Input/Output

pHandle

KmlSolverTask **

Solver handle. pHandle cannot be a null pointer.

Input

param

enum KmlSolverParam

KMLSS_REFINEMENT_RESIDUAL indicates the residual of iterative refinement.

Input

value

double or float

Array containing parameters related to direct resolution

Input

nvalue

int

Number of elements in the value array

Input

Return Value

Return Value

Type

Description

KMLSS_NO_ERROR

int

The execution is successful.

KMLSS_NULL_ARGUMENT

int

The pHandle or data pointer is null, or the internal parameter is improper.

KMLSS_BAD_HANDLE

int

The format of pHandle is incorrect.

KMLSS_BAD_DATA_SIZE

int

The user-defined length (nvalue) of the value array is improper. That is, nvalue is inconsistent with the number of RHS terms.

KMLSS_BAD_SELECTOR

int

The input value of KML_SOLVER_PARAM is not supported currently or does not exist during the analysis.

Dependencies

#include "kml_dss.h" or #include "kml_solver.h"

Examples

C interface:

int n = 8;
int ia[9] = {0, 2, 4, 6, 7, 8, 10, 12, 14};
int ja[14] = {0, 7, 1, 6, 2, 5, 3, 4, 2, 5, 1, 6, 0, 7};
double a[14] = {1.0, 2.0, -2.0, 3.0, 3.0, 4.0, -4.0, 5.0, 4.0, -6.0, 3.0, 7.0, 2.0, 8.0};

double b[8] = {3.0, 1.0, 7.0, -4.0, 5.0, -2.0, 10.0, 10.0};
double x[8];
int nrhs = 1;
int ldx = n, ldb = n;

KmlSolverTask *handle;
int ierr = KmlDssGenInitDI(&handle, n, a, ja, ia);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenInitDI: %d", ierr);
}
ierr = KmlDssGenAnalyzeDI(&handle);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenAnalyzeDI: %d", ierr);
}
ierr = KmlDssGenFactorizeDI(&handle);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenFactorizeDI: %d", ierr);
}

double tolerance = 1.e-12;
ierr = KmlDssGenSetDID(&handle, KMLSS_REFINEMENT_TOLERANCE_LEVEL, &tolerance, 1);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenSetDID: %d", ierr);
}
int nsteps = 2;
ierr = KmlDssGenSetDII(&handle, KMLSS_REFINEMENT_MAX_STEPS, &nsteps, 1);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenSetDII: %d", ierr);
}

ierr = KmlDssGenSolveDI(&handle, nrhs, x, ldx, b, ldb);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenSolveDI: %d", ierr);
}
double res;
ierr = KmlDssGenGetDID(&handle, KMLSS_REFINEMENT_RESIDUAL, &res, 1);
if (ierr != 0) {
    printf("\nERROR in KmlDssGenGetDID: %d", ierr);
}
printf("REFINEMENT_RESIDUAL = %f\n", res);
Output:
REFINEMENT_RESIDUAL = 0.000000