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

◆ hb_write()

void hb_write ( 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  base,
int  fchk,
int  format,
int  int_n,
int  int_w,
int  dbl_n,
int  dbl_w,
int  dbl_d,
int *  info 
)

Write a matrix to the file in Harwell-Boeing format

Purpose
This routine writes a sparse (CSR, CSC oe COO format) or finite-element matrix (unassembled format) to the Harwell-Boeing file.

The data is written as it is without checking the contents such as the order.
Parameters
[in]fnameOutput file name.
If fname = NULL, stdout is assumed.
[out]titleArray title[ltitle]
Title string (leading 72 characters are valid).
[out]keyArray key[lkey]
Key string (leading 8 characters are valid).
[in]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.
[in]nrowNumber of rows of the matrix (if sparse matrix).
Number of variables (nu) (if finite element matrix).
(nrow >= 0) (If nrow = 0, returns without computation)
[in]ncolNumber of columns of the matrix (if sparse matrix).
Number of elemental matrices (if finite element matrix).
(ncol >= 0) (If ncol = 0, returns without computation)
[in]nnzNumber of non-zero elements (if sparse matrix). (= ptr[nrow] - ptr[0] (CSR) or ptr[ncol] - ptr[0] (CSC))
Number of variable indices (if finite element matrix). (= ptr[ne] - ptr[0])
(nnz >= 0) (If nnz = 0, returns without computation)
[in]neltvlNot used (if sparse matrix).
Number of elements (if finite element matrix). (neltvl >= 0) (If neltvl = 0, returns without computation)
[in]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.
[in]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))
[in]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)
[in]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.
[in]nrhsNumber of columns of RHS matrix. (nrhs >= 0)
[in]nrhsixNumber of row indices of RHS. (nrhsix > 0) (if rhstyp[0] = 'M', mxtype[2] = 'A' (sparse matrix))
[in]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.
[in]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))
[in]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)
[in]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.
[in]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]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]fchkSpecify whether to check if the specified file already exists.
= 0: Overwrites without checking.
= 1: Returns an error (info = 2) if the specified file already exists.
[in]formatSparse matrix format.
= 0: CSR format.
= 1: CSC format.
= 2: COO format.
[in]int_nOutput format of integer values (Numbers per line). (If int_n = 0, int_n = 9 and int_w = 10 are assumed)
[in]int_wOutput format of integer values (Width (number of digits)).
[in]dbl_nOutput format of double values (Numbers per line). (If dbl_n = 0, dbl_n = 3, dbl_w = 23 and dbl_d = 15 are assumed)
[in]dbl_wOutput format of double values (Width (number of digits)).
[in]dbl_dOutput format of double values (Width of fractional part (number of digits)).
[out]info= 0: Successful exit.
< 0: The (-info)-th argument is invalid.
= 1: Failed to open file.
= 2: File already exists.
= 4: Invalid read format.