Rate This Document
Findability
Accuracy
Completeness
Readability

KmlScadss(SPD/HPD)Solve?I

Solve LLT x = b or LLH x = b.

Interface Definition

C interface:

int KmlScadssSpdSolveSI(KmlScaSolverTask **pHandle, int nb, float *x, int ldx, float *b, int ldb);

int KmlScadssSpdSolveDI(KmlScaSolverTask **pHandle, int nb, double *x, int ldx, double *b, int ldb);

int KmlScadssHpdSolveCI(KmlScaSolverTask **pHandle, int nb, kml_complex_float *x, int ldx, kml_complex_float *b, int ldb);

int KmlScadssHpdSolveZI(KmlScaSolverTask **pHandle, int nb, kml_complex_double *x, int ldx, kml_complex_double *b, int ldb);

Parameters

Parameter

Type

Description

Input/Output

pHandle

KmlScasolverTask **

Solver handle, which is a variable transferred previously

Input/Output

nb

int

Number of right-hand side vectors

Input

x

  • float * in KmlScadssSpdSolveSI
  • double * in KmlScadssSpdSolveDI
  • kml_complex_float * in KmlScadssHpdSolveCI
  • kml_complex_double * in KmlScadssHpdSolveZI

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

Input/Output

ldx

int

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

Input

b

  • float * in KmlScadssSpdSolveSI
  • double * in KmlScadssSpdSolveDI
  • kml_complex_float * in KmlScadssHpdSolveCI
  • kml_complex_double * in KmlScadssHpdSolveZI

Dense vector that stores right-hand sides. The quantity of elements is ldb*nb, and the ith element location of the kth vector is 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 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 previous phase is not Factorize.

Dependencies

#include "kml_scadss.h"

Examples

C interface:
MPI_Init(NULL, NULL);
int size, rank;
MPI_Comm_size(MPI_COMM_WORLD, &size);// Obtain the total number of processes.
MPI_Comm_rank(MPI_COMM_WORLD, &rank);// Obtain the current process ID.

int n = 8;
int ia[9] = {0, 3, 7, 9, 11, 13, 15, 16, 17};
int ja[17] = {0, 3, 4, 1, 2, 3, 5, 2, 7, 3, 6, 4, 5, 5, 7, 6, 7};
double a[17] = {1.0, 1.0, 2.0, 9.0, 2.0, 1.0, -3.0, 3.0, 2.0, 9.0, -5.0, 6.0, 1.0, 4.0, 1.0, 7.0, 2.0};
double b[8] = {4.0, 9.0, 7.0, 6.0, 9.0, 3.0, 2.0, 5.0};
double x[8];
KmlScasolverTask* matrix_handle = NULL;
int ierr = KmlScadssSpdInitDI(&matrix_handle, n, a, ja, ia, MPI_COMM_WORLD);
ierr = KmlScadssSpdAnalyzeDI(&matrix_handle);

int nrhs = 1;
int ldx=n, ldb=n;
ierr = KmlScadssSpdSolveDI(&matrix_handle, nrhs, x, ldx, b, ldb);
if (ierr != 0) {
    printf("\nERROR in KmlScadssSpdSolveDI: %d", ierr);
}
if (rank == 0) {
    for (int i = 0; i < n; i++) {
        printf("%lf ", x[i]);
    }
    printf("\n");
}
Execution result
1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000