KmlDss(Spd/Hpd)Solve?I
Solve LLT x = b or LLH x = b.
Interface Definition
C interfaces:
int KmlDssSpdSolveSI(KmlSolverTask **pHandle, int nb, float *x, int ldx, float *b, int ldb);
int KmlDssSpdSolveDI(KmlSolverTask **pHandle, int nb, double *x, int ldx, double *b, int ldb);
int KmlDssHpdSolveCI(KmlSolverTask **pHandle, int nb, kml_complex_float *x, int ldx, kml_complex_float *b, int ldb);
int KmlDssHpdSolveZI(KmlSolverTask **pHandle, int nb, kml_complex_double *x, int ldx, kml_complex_double *b, int ldb);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
pHandle |
KmlSolverTask ** |
Solver handle, which is a variable passed from a previous step. |
Input |
nb |
int |
Number of RHS vectors. |
Input |
x |
|
Dense vector that stores the solution result. The number of elements is ldx*nb. The i-th element of the k-th vector is stored at x[i + k * ldx]. |
Output |
ldx |
int |
Leading dimension of x. ldx ≥ max(1, n). |
Input |
b |
|
Dense vector that stores the RHS. The quantity of elements is ldb*nb. The i-th element of the k-th vector is stored at b[i + k * ldb]. |
Input |
ldb |
int |
Leading dimension of b. ldb ≥ max(1, n). |
Input |
Return Value
Return Value |
Type |
Description |
|---|---|---|
KMLSS_NO_ERROR |
int |
The execution is successful. |
KMLSS_NULL_ARGUMENT |
int |
A null parameter exists in {pHandle, x, b}. |
KMLSS_BAD_NB |
int |
The value of nb is less than or equal to 0. |
KMLSS_BAD_HANDLE |
int |
The format of pHandle is incorrect. |
KMLSS_BAD_LDX |
int |
The value of ldx is out of the valid range. |
KMLSS_BAD_LDB |
int |
The value of ldb is out of the valid range. |
KMLSS_INVALID_CALL_ORDER |
int |
Incorrect function execution sequence: The solution function is executed without prior factorization. |
KMLSS_NO_MEMORY |
int |
Memory allocation failed. |
Dependencies
#include "kml_dss.h" or #include "kml_solver.h"
Examples
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);
}
ierr = KmlDssSpdSolveDI(&handle, nrhs, x, ldx, b, ldb);
if (ierr != 0) {
printf("\nERROR in KmlDssSpdSolveDI: %d", ierr);
}
for (int i = 0; i < n; i++) {
printf("%lf ", x[i]);
}
printf("\n");
1.666667 -0.333333