KmlDssSymSolve?I
Solve LDLTx=b.
Interface Definition
C interface:
int KmlDssSymSolveSI(KmlSolverTask **pHandle, int nb, float *x, int ldx, float *b, int ldb);
int KmlDssSymSolveDI(KmlSolverTask **pHandle, int nb, double *x, int ldx, double *b, int ldb);
int KmlDssSymSolveCI(KmlSolverTask **pHandle, int nb, kml_complex_float *x, int ldx, kml_complex_float *b, int ldb);
int KmlDssSymSolveZI(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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | int n = 8; int ia[9] = {0, 2, 4, 6, 7, 8, 9, 10, 11}; int ja[11] = {0, 7, 1, 6, 2, 5, 3, 4, 5, 6, 7}; double a[11] = {1.0, 2.0, -2.0, 3.0, 3.0, 4.0, -4.0, 5.0, -6.0, 7.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 = KmlDssSymInitDI(&handle, n, a, ja, ia); if (ierr != 0) { printf("\nERROR in KmlDssSymInitDI: %d", ierr); } ierr = KmlDssSymAnalyzeDI(&handle); if (ierr != 0) { printf("\nERROR in KmlDssSymAnalyzeDI: %d", ierr); } ierr = KmlDssSymFactorizeDI(&handle); if (ierr != 0) { printf("\nERROR in KmlDssSymFactorizeDI: %d", ierr); } ierr = KmlDssSymSolveDI(&handle, nrhs, x, ldx, b, ldb); if (ierr != 0) { printf("\nERROR in KmlDssSymSolveDI: %d", ierr); } for (int i = 0; i < n; i++) { printf("%lf ", x[i]); } printf("\n"); |
1 | 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 |