XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ hb_read()

void hb_read ( char *  fname,
char *  title,
char *  key,
char *  mxtype,
int *  nrow,
int *  ncol,
int *  nnz,
int *  neltvl,
double  val[],
int  lval,
int  ptr[],
int  lptr,
int  ind[],
int  lind,
char *  rhstyp,
int *  nrhs,
int *  nrhsix,
double  rhsval[],
int  lrhsval,
int  rhsptr[],
int  lrhsptr,
int  rhsind[],
int  lrhsind,
double  sguess[],
int  lsguess,
double  xexact[],
int  lxexact,
int  skip,
int  base,
int  format,
int  sort,
int *  info 
)

Read a matrix from the Harwell-Boeing file

Purpose
This routine reads a sparse or finite element matrix from the file in Harwell-Boeing format.

The matrix data is stored in the array as it is without checking the contents such as the order. Sparse matrices are stored in CSR, CSC or COO format. However, it is possible to sort sparse matrix elements in ascending order of column or row number within each row or column by option.
Parameters
[in]fnameInput file name.
If fname = NULL, stdin is assumed.
[out]titleArray title[ltitle] (ltitle >= 73)
Title string.
[out]keyArray key[lkey] (lkey >= 9)
Key string.
[out]mxtypeArray mxtype[3]
Matrix type.
mxtype[0]: Data type.
= 'R': Real.
= 'C': Complex.
= 'P': Pattern (no matrix data).
mxtype[1]: Matrix shape.
= 'U': Unsymmetric.
= 'S': Symmetric.
= 'Z': Skew-symmetric.
= 'H': Hermitian.
= 'R': Rectangular.
mxtype[2]: Storage format.
= 'A': Sparse matrix.
= 'E': Finite element matrix.
[out]nrowNumber of rows of the matrix (if sparse matrix).
Number of variables (Nu) (if finite-element matrix).
[out]ncolNumber of columns of the matrix (if sparse matrix).
Number of elemental matrices (if finite-element matrix).
[out]nnzNumber of non-zero elements (if sparse matrix).
Number of variable indices (Nind) (if finite-element matrix).
[out]neltvlNot used (if sparse matrix).
Number of elements (if finite-element matrix).
[out]val[]Array val[lval]
Nonzero elements of sparse matrix (if sparse matrix).
Numerical values of elements (if finite-element matrix).
Not referenced if mxtype[0] = 'P' (data type = pattern).
[in]lvalLength of array val[]. (lval >= nnz (if sparse matrix), lval >= neltvl (if finite element matrix))
If mxtype[0] = 'C' (data type = complex), lval must be double of above value.
[out]ptr[]Array ptr[lptr]
Row pointers (if CSR), column pointers (if CSC), or row indices (if COO) (if sparse matrix).
Pointers to variable indices (if finite-element matrix).
[in]lptrLength of array ptr[]. (lptr >= nrow + 1 (CSR), lptr >= ncol + 1 (CSC, finite element matrix) or lptr >= nnz (COO))
[out]ind[]Array ind[lind]
Column indices (if CSR or COO) or row indices (if CSC) (if sparse matrix).
Variable indices (if elemental matrix format).
[in]lindLength of array ind[]. (lind >= nnz)
[out]rhstyp[]Array rhstyp[3]
RHS matrix type.
rhstyp[0]: Storage format.
= 'F': Dense matrix.
= 'M': Same format with coefficient matrix.
rhstyp[1]: Initial guess vector.
= 'G': Initial guess vector is stored.
rhstyp[2]: Exact solution vector.
= 'X': Exact solution vector is stored.
Note - If RHS matrices are not stored (nrhs <= 0), rhstyp[] is not referenced.
[out]nrhsNumber of columns of RHS matrix.
[out]nrhsixNumber of row indices of RHS. (if rhstyp[0] = 'M', mxtype[2] = 'A' (sparse matrix))
[out]rhsval[]Array rhsval[lrhsval]
RHS matrix values.
[in]lrhsvalLength of array rhsval[]. (lrhsval >= nrow*nrhs (if rhstyp[0] = 'F' (dense matrix)), lrhsval >= nrhsix (if rhstyp[0] = 'M' and mxtype[2] = 'A' (sparse matrix)), lrhsval >= nnz*nrhs (if rhstyp[0] = 'M' and mxtype[2] = 'E' (finite element matrix)))
If mxtype[0] = 'C' (data type = complex), lrhsval must be double of above value.
[out]rhsptr[]Array rhsptr[lrhsptr]
Row pointers (if CSR), column pointers (if CSC), or row indices (if COO) of RHS. (if rhstyp[0] = 'M' and mxtype[2] = 'A' (sparse matrix)).
[in]lrhsptrLength of array rhsptr[]. (lrhsptr >= nrow + 1 (if CSR), lrhsptr >= nrhs + 1 (if CSC), lrhsptr >= nrhsix (if COO))
[out]rhsind[]Array rhsind[lrhsind]
Column indices (if CSR or COO), or row indices (if CSC) of RHS. (if rhstyp[0] = 'M' and mxtype[2] = 'A' (sparse matrix)).
[in]lrhsindLength of array rhsind[]. (lrhsind >= nrhsix)
[out]sguess[]Array sguess[lsguess]
Initial guess vector. (if rhstyp[1] = 'G')
[in]lsguessLength of array sguess[]. (lsguess >= nrow*nrhs)
If mxtype[0] = 'C' (data type = complex), lsguess must be double of above value.
[out]xexact[]Array xexact[lxexact]
Exact solution vector. (if rhstyp[2] = 'X')
[in]lxexactLength of array xexact[]. (lxexact >= nrow*nrhs)
If mxtype[0] = 'C' (data type = complex), lxexact must be double of above value.
[in]skipSet flag as follows to read a part of data.
Bit 1 (least significant bit) = 1: Do not read matrix data.
Bit 2 = 1: Do not read RHS matrix data (except initial guess and exact solution vactors).
Bit 3 = 1: Do not read initial guess vector.
Bit 4 = 1: Do not read wxact solution vector.
[in]baseIndex style of ptr, ind, rhsptr and rhsind.
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.
[in]formatSparse matrix format.
= 0: CSR format.
= 1: CSC format.
= 2: COO format.
[in]sortSpecify whether to sort elements of sparse matrix in ascending order of column number within each row (if CSR) or row number within each column (if CSC).
= 0: Do not sort elements.
= 1: Sort elements.
[out]info= 0: Successful exit.
< 0: The (-info)-th argument is invalid.
= 1: Could not open file.
= 3: File read error.
= 4: Invalid read format.
= 5: Memory allocation error.