EN
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助
鲲鹏小智

KmlDssGenSet?I(D/S)

设置与handle关联的实数型值。

接口定义

C Interface:

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

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

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

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

参数

参数名

类型

描述

输入/输出

pHandle

KmlSolverTask **

求解器句柄,pHandle不可为空指针。

输入

param

enum KmlSolverParam

  • KMLSS_REFINEMENT_TOLERANCE_LEVEL表示迭代优化算法设置的阈值。
  • KMLSS_PIVOTING_THRESHOLD表示迭代pivot算法设置的阈值,对应的value即为取值。

输入

value

double或float

直接求解相关参数数组。

输入

nvalue

int

value数组元素个数。

输入

返回值

返回值

类型

描述

KMLSS_NO_ERROR

int

正常执行。

KMLSS_BAD_SELECTOR

int

用户的KML_SOLVER_PARAM输入当前不支持,或在求解过程中不存在。

依赖

#include "kml_dss.h"或#include "kml_solver.h"

示例

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);
}
for (int i = 0; i < n; i++) {
    printf("%lf ", x[i]);
}
printf("\n");
运行结果:
1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词