HLIBpro  2.9
Input/Output

𝖧𝖫𝖨𝖡𝗉𝗋𝗈 supports several file formats for reading/writing coordinates, vectors, matrices and files, e.g. Matlab, Harwell/Boeing, MatrixMarket, SAMG, PLY, Gmsh, SurfaceMesh. However, not all features of each file format is fully implemented in 𝖧𝖫𝖨𝖡𝗉𝗋𝗈, e.g. only a single object may be written to Matlab files and only triangular grids are supported in corresponding file formats.

Remarks
All I/O classes will automatically add a corresponding filename suffix, e.g. ".hm" in case of HLIBpro file format, if no suffix is present.

Coordinate I/O

Format Class Remarks
HLIBpro THLibCoordIO only format with full support
Matlab TMatlabCoordIO only dense matrix supported, no bounding box data
MatrixMarket TMMCoordIO only array format supported, no bounding box data
SAMG TSAMGCoordIO no bounding box data
PLTMG TPLTMGCoordIO no bounding box data

In case of the matrix based storage formats (Matlab and MatrixMarket), a matrix is expected where the number of columns corresponds to the dimension of the coordinates and the number of rows to the number of coordinates, respectively.

Only the HLIBpro format stores additional bounding box data for the coordinate set.

Vector I/O

Matrix I/O

The following file formats are supported for reading and writing matrices:

Format Class Remarks
𝖧𝖫𝖨𝖡𝗉𝗋𝗈 format THLibMatrixIO
  • H-, sparse and dense matrices (only format for H-matrices!).

Matlab v5 TMatlabMatrixIO
  • sparse and dense matrices in single and double precision
  • when writing files, only a single object may be stored
  • limited support for reading from structures
  • support for compression via zlib

Harwell/Boeing
Harwell/Rutherford
THBMatrixIO
  • sparse matrix format
  • no read support for elemental matrices

MatrixMarket TMMMatrixIO
  • sparse matrix format
  • only reading supported
  • only unsymmetric matrices supported
  • no support for array format

SAMG TSAMGMatrixIO
  • sparse matrix format

HDF5 THDF5MatrixIO
  • output of dense and low-rank matrices
  • input not yet implemented

All storage classes implement the same basic interface defined by the functions:

virtual void write ( const TMatrix * A, const String & name ) const;
virtual TMatrix * read ( const String & name ) const;

Furthermore, a class for reading/writing matrices with file format autodetection is available (TAutoMatrixIO). In case of reading from a file, the auto detection works by actually looking at the stored data and hence, is very robust in choosing the correct file format. On the other hand, if data output is used, only the file name is used to decide the format. The following rules apply based on the file name extension:

Extension File Format
hm HLIBpro format
mat, m Matlab format
hb, rb, rua, rsa, psa Harwell/Boeing format
mtx MatrixMarket format
amg SAMG format
hdf, h5 HDF5 format

The I/O functions from TAutoMatrixIO are also available in direct from via the functions:

TMatrix * read_matrix ( const char * filename );
void write_matrix ( const TMatrix * A,
const char * filename );

If the file format supports named storage, e.g. Matlab, the corresponding matrix name may be provided by an additional argument:

TMatrix * read_matrix ( const char * filename,
const char * matname );
void write_matrix ( const TMatrix * A,
const char * filename,
const char * matname );

For all other file formats, this parameter will be ignored.

Grid I/O

Format Class Remarks
HLIBpro THLibGridIO same format as in HLIB
PLY TPlyGridIO only ascii format and triangles supported;
vertices may have normal directions
surfacemesh TSurfMeshGridIO only 3d with triangles supported
Gmsh v2 TGMSHGridIO
auto detection TAutoGridIO

All grid IO classes support the interface

std::unique_ptr< TGrid > read ( const std::string & filename ) const;
void write ( const TGrid * grid,
const std::string & filename ) const;

for reading and writing grid data.

Furthermore, the functional versions

std::unique_ptr< TGrid > read_grid ( const char * filename );
void write_grid ( const TGrid * grid,
const char * filename );

are implemented which rely on TAutoGridIO.

HLIB::read_grid
std::unique_ptr< TGrid > read_grid(const std::string &filename)
Read grid from file with automatic file format detection.
HLIB::write_grid
void write_grid(const TGrid *grid, const std::string &filename)
Write grid to file with automatic file format detection.
HLIB::write_matrix
void write_matrix(const TMatrix *A, const std::string &filename)
Write matrix to file with automatic choice of file format.
HLIB::read_matrix
std::unique_ptr< TMatrix > read_matrix(const std::string &filename)
Read matrix from file with automatic file format detection.