Read HB-format file.

path_or_open_filepath-like or file-like

If a file-like object, it is used as-is. Otherwise, it is opened before reading.

datascipy.sparse.csc_matrix instance

The data read from the HB file as a sparse matrix.


At the moment not the full Harwell-Boeing format is supported. Supported features are:

  • assembled, non-symmetric, real matrices

  • integer for pointer/indices

  • exponential format for float values, and int format


We can read and write a harwell-boeing format file:

>>> from import hb_read, hb_write
>>> from scipy.sparse import csr_matrix, eye
>>> data = csr_matrix(eye(3))  # create a sparse matrix
>>> hb_write("data.hb", data)  # write a hb file
>>> print(hb_read("data.hb"))  # read a hb file
  (0, 0)    1.0
  (1, 1)    1.0
  (2, 2)    1.0

Previous topic

Next topic