KmlScadssSYMInit?I
Initialize the data structure and associate a provided coefficient matrix with the solution system. The upper triangular part of the matrix in CSR format is used when the LDLT method for clusters is initialized.
Interface Definition
C interface:
int KmlScadssSymInitSI(KmlScasolverTask **pHandle, int n, float *a, int *ja, int *ia, MPI_Comm comm);
int KmlScadssSymInitDI(KmlScasolverTask **pHandle, int n, double *a, int *ja, int *ia, MPI_Comm comm);
int KmlScadssSymInitCI(KmlScasolverTask **pHandle, int n, kml_complex_float *a, int *ja, int *ia, MPI_Comm comm);
int KmlScadssSymInitZI(KmlScasolverTask **pHandle, int n, kml_complex_double *a, int *ja, int *ia, MPI_Comm comm);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
pHandle |
KmlScasolverTask ** |
Solver handle, which is a variable passed from a previous step. |
Input/Output |
n |
int |
Dimension of matrix A. |
Input |
a |
|
Array whose dimension corresponds to the number of non-zero elements. a[i] is the value of the i-th non-zero element. The lifecycle of this array is the same as that of handle. |
Input |
ja |
int * |
Column index array in CSR format. ja[i] is the column ID of the i-th non-zero element. The lifecycle of this array is the same as that of handle. |
Input |
ia |
int * |
Row offset array in CSR format. ia[i] is the index of the first non-zero element in i-th row in all non-zero elements. ia[0] = 0. The lifecycle of this array is the same as that of handle. |
Input |
comm |
MPI_Comm |
Communicator of the MPI process. |
Input |
Return Value
Return Value |
Type |
Description |
|---|---|---|
KMLSS_NO_ERROR |
int |
Normal execution. |
KMLSS_NULL_ARGUMENT |
int |
Invalid parameter. |
KMLSS_BAD_HANDLE |
int |
Incorrect format of pHandle. |
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 rank.
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 = KmlScadssSymInitDI(&matrix_handle, n, a, ja, ia, MPI_COMM_WORLD);
ierr = KmlScadssSymAnalyzeDI(&matrix_handle);
ierr = KmlScadssSymFactorizeDI(&matrix_handle);
int nrhs = 1;
int ldx=n, ldb=n;
ierr = KmlScadssSymSolveDI(&matrix_handle, nrhs, x, ldx, b, ldb);
ierr = KmlScadssSymCleanDI(&matrix_handle);
if (ierr != 0) {
printf("\nERROR in KmlScadssSymCleanDI: %d", ierr);
}