HB Files
Harwell Boeing
Sparse Matrix File Format


HB, or the Harwell Boeing Sparse Matrix File Format, is used to store a sparse matrix in a file. The space required to represent the matrix is reduced by using a compressed column storage format. If the matrix is read from the file into memory, it is common to use the same compressed column storage to represent the matrix in memory.

A matrix is an m by n rectangular array of numbers. A sparse matrix is one in which "most" of the entries are zero. If the matrix is sparse enough, then it is often much more efficient not to allocate space for the full m*n set of entries, but rather to keep track of the location and value of the nonzero entries.

HB File Characteristics:

HB files begin with a header of 4, or sometimes 5, lines:

Line 1:
Line 2:
Line 3:
Line 4:
Line 5: (only present if 0 < RHSCRD!)

Each character of the MXTYPE variable specifies a separate fact about the matrix:

  1. R, C or P indicates that the matrix values are real, complex, or that only the pattern of nonzeroes is going to be supplied. Note that if complex arithmetic is specified, then any data vectors included in the file will also be assumed to be complex. FORTRAN I/O treats a complex number as a simple pair of real numbers. Thus, a line that records the single complex number 12+17i would look like
                12.0  17.0
              
  2. U, S, H, Z or R indicates that the matrix is symmetric, unsymmetric, Hermitian, skew symmetric, or rectangular. Each of these facts implies something about how the nonzero elements of the matrix are stored in the file.
  3. A indicates that the matrix is "assembled" (the typical case) while E indicates that the matrix is a finite element matrix that is going to be described as the "sum" of a set of smaller matrices.

Each character of the RHSTYP specifies a separate fact about the right hand side information. (Of course, if there are no right hand sides, (RHSCRD = 0) then there is no header line 5, and hence no need to worry about this variable!)

  1. F means that all vectors will be listed as "full" vectors, that is, as a list of NROW numbers; M means that, instead, all vectors will be listed in the same format as the matrix. The M option only makes sense if the matrix is being presented in unassembled format.
  2. G means that one or more starting guesses or approximate solution vectors are being supplied. If no guess vectors are supplied, this character should be blank (or, actually, anything but a G).
  3. X means that one or more exact solution vectors are being supplied. If no exact solution vectors are supplied, leave this character blank.

The Data Records

After the header lines comes data. This data is organized into four distinct sets, of pointers, indices, matrix values, and right hand side information. The number of lines devoted to each set of information were specified in header line number 2. It is common for the final set of data to be omitted. In a few cases, the third set, which describes matrix values, is omitted. In that case, the file only has information about where the nonzero entries of the matrix are, but does not actually specify what those values are. Such a matrix file is called a "pattern" matrix, and in fact, if this is the case, usually the first character of MXTYPE is given as P for "pattern only".

Reference:

  1. Iain Duff, Roger Grimes, John Lewis,
    User's Guide for the Harwell-Boeing Sparse Matrix Collection,
    Technical Report TR/PA/92/86,
    CERFACS, October 1992.
    "../../pdf/hbsmc.pdf"
  2. Iain Duff, Roger Grimes, John Lewis,
    Sparse Matrix Test Problems,
    ACM Transactions on Mathematical Software,
    Volume 15, Number 1, March 1989, pages 1-14.
  3. Web site:
    http://math.nist.gov/MatrixMarket/data/Harwell-Boeing/

Programs to read an HB file include:

Programs to convert a matrix to an HB file:

Programs to convert an HB file to another format:

Programs to write an HB file:

Sample Files:

You can go up one level to the DATA page.


Last revised on 09 March 2006.