Rate This Document
Findability
Accuracy
Completeness
Readability

KmlDssSymSolve?I

Solve LDLTx=b.

Interface Definition

C interface:

int KmlDssSymSolveSI(KmlSolverTask **pHandle, int nb, float *x, int ldx, float *b, int ldb);

int KmlDssSymSolveSI(KmlSolverTask **pHandle, int nb, double *x, int ldx, double *b, int ldb);

int KmlDssSymSolveSI(KmlSolverTask **pHandle, int nb, kml_complex_float *x, int ldx, kml_complex_float *b, int ldb);

int KmlDssSymSolveSI(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 transfers a variable defined previously.

Input

nb

int

Number of RHS vectors.

Input

x

  • float * in KmlDssSymSolveSI
  • double * in KmlDssSymSolveDI
  • kml_complex_float * in KmlDssSymSolveCI
  • kml_complex_double * in KmlDssSymSolveZI

Dense vector that stores the solution result. The quantity of elements is ldx*nb, and the i-th element location of the k-th vector is x[i + k * ldx].

Output

ldx

int

Leading dimension of x. ldx ≥ max(1, n).

Input

b

  • float * in KmlDssSymSolveSI
  • double * in KmlDssSymSolveDI
  • kml_complex_float * in KmlDssSymSolveCI
  • kml_complex_double * in KmlDssSymSolveZI

Dense vector that stores the RHS terms. The quantity of elements is ldb*nb, and the i-th element location of the k-th vector is b[i + k * ldb].

Input

ldb

int

Leading dimension of b. ldb ≥ max(1, n).

Input

Return Values

Return Value

Type

Description

KMLSS_NO_ERROR

int

The execution is successful.

KMLSS_NULL_ARGUMENT

int

A null argument 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

The function execution sequence is incorrect. The solution function is executed in advance before the decomposition phase is executed.

KMLSS_NO_MEMORY

int

Failed to allocate memory.

Dependency

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

Example

C interface:
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");
Output:
1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000