KmlDss(Spd/Hpd)Get?II
获取与handle关联的整型值。
接口定义
C Interface:
int KmlDssSpdGetSII(KmlSolverTask **pHandle, enum KmlSolverParam param, int *value, int nvalue);
int KmlDssSpdGetDII(KmlSolverTask **pHandle, enum KmlSolverParam param, int *value, int nvalue);
int KmlDssHpdGetCII(KmlSolverTask **pHandle, enum KmlSolverParam param, int *value, int nvalue);
int KmlDssHpdGetZII(KmlSolverTask **pHandle, enum KmlSolverParam param, int *value, int nvalue);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
pHandle |
KmlSolverTask ** |
求解器句柄,pHandle不可为空指针。 |
输入 |
param |
enum KmlSolverParam |
当前仅支持KMLSS_REFINEMENT_STEPS,表示迭代优化次数。 |
输入 |
value |
int |
直接求解相关参数数组。 |
输出 |
nvalue |
int |
value数组元素个数,目前要求为1。 |
输入 |
返回值
返回值 |
类型 |
描述 |
---|---|---|
KMLSS_NO_ERROR |
int |
正常执行。 |
KMLSS_NULL_ARGUMENT |
int |
pHandle或data为空指针。 |
KMLSS_BAD_HANDLE |
int |
pHandle格式存在问题。 |
KMLSS_BAD_DATA_SIZE |
int |
用户设定的value数组长度nvalue不合理,即不为1。 |
KMLSS_BAD_SELECTOR |
int |
用户的KML_SOLVER_PARAM输入当前不支持,或在求解过程中不存在。 |
依赖
#include "kml_dss.h"或#include "kml_solver.h"
示例
C Interface:
int n = 2; int ia[3] = {0,2,4}; int ja[4] = {0,1,0,1}; double a[4] = {2,1,1,2}; double b[2] = {3,1}; double x[2]; int nrhs = 1; int ldx = n, ldb = n; KmlSolverTask *handle; int ierr = KmlDssSpdInitDI(&handle, n, a, ja, ia); if (ierr != 0) { printf("\nERROR in KmlDssSpdInitDI: %d", ierr); } ierr = KmlDssSpdAnalyzeDI(&handle); if (ierr != 0) { printf("\nERROR in KmlDssSpdAnalyzeDI: %d", ierr); } ierr = KmlDssSpdFactorizeDI(&handle); if (ierr != 0) { printf("\nERROR in KmlDssSpdFactorizeDI: %d", ierr); } double tolerance = 1.e-12; ierr = KmlDssSpdSetDID(&handle, KMLSS_REFINEMENT_TOLERANCE_LEVEL, &tolerance, 1); if (ierr != 0) { printf("\nERROR in KmlDssSpdSetDID: %d", ierr); } int nsteps = 2; ierr = KmlDssSpdSetDII(&handle, KMLSS_REFINEMENT_MAX_STEPS, &nsteps, 1); if (ierr != 0) { printf("\nERROR in KmlDssSpdSetDII: %d", ierr); } ierr = KmlDssSpdSolveDI(&handle, nrhs, x, ldx, b, ldb); if (ierr != 0) { printf("\nERROR in KmlDssSpdSolveDI: %d", ierr); } printf("\n"); int nstep; ierr = KmlDssSpdGetDII(&handle, KMLSS_REFINEMENT_STEPS, &nstep, 1); if (ierr != 0) { printf("\nERROR in KmlDssSpdGetDII: %d", ierr); } printf("REFINEMENT_STEP = %d\n", nstep);
REFINEMENT_STEP = 1