Rate This Document
Findability
Accuracy
Completeness
Readability

KmlScadssGENInit?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 LU method for clusters is initialized.

Interface Definition

C interface:

int KmlScadssGenInitSI(KmlScasolverTask **pHandle, int n, float *a, int *ja, int *ia, MPI_Comm comm);

int KmlScadssGenInitDI(KmlScasolverTask **pHandle, int n, double *a, int *ja, int *ia, MPI_Comm comm);

int KmlScadssGenInitCI(KmlScasolverTask **pHandle, int n, kml_complex_float *a, int *ja, int *ia, MPI_Comm comm);

int KmlScadssGenInitZI(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

  • float * in KmlScadssGenInitSI
  • double * in KmlScadssGenInitDI
  • kml_complex_float * in KmlScadssGenInitCI
  • kml_complex_double * in KmlScadssGenInitZI

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 = KmlScadssGenInitDI(&matrix_handle, n, a, ja, ia, MPI_COMM_WORLD);
ierr = KmlScadssGenAnalyzeDI(&matrix_handle);
ierr = KmlScadssGenFactorizeDI(&matrix_handle);
int nrhs = 1;
int ldx=n, ldb=n;
ierr = KmlScadssGenSolveDI(&matrix_handle, nrhs, x, ldx, b, ldb);
ierr = KmlScadssGenCleanDI(&matrix_handle);
if (ierr != 0) {
    printf("\nERROR in KmlScadssGenCleanDI: %d", ierr);
}