io.harwell_boeing.hb

Implementation of Harwell-Boeing read/write.

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

Module Contents

Classes

MalformedHeader()
LineOverflow()
HBInfo(self,title,key,total_nlines,pointer_nlines,indices_nlines,values_nlines,mxtype,nrows,ncols,nnon_zeros,pointer_format_str,indices_format_str,values_format_str,right_hand_sides_nlines=0,nelementals=0)
HBMatrixType(self,value_type,structure,storage=”assembled”) Class to hold the matrix type.
HBFile(self,file,hb_info=None)

Functions

_nbytes_full(fmt,nlines) Return the number of bytes to read to get every full lines for the
_expect_int(value,msg=None)
_read_hb_data(content,header)
_write_data(m,fid,header)
hb_read(path_or_open_file) Read HB-format file.
hb_write(path_or_open_file,m,hb_info=None) Write HB-format file.
class MalformedHeader
class LineOverflow
_nbytes_full(fmt, nlines)

Return the number of bytes to read to get every full lines for the given parsed fortran format.

class HBInfo(title, key, total_nlines, pointer_nlines, indices_nlines, values_nlines, mxtype, nrows, ncols, nnon_zeros, pointer_format_str, indices_format_str, values_format_str, right_hand_sides_nlines=0, nelementals=0)
from_data(m, title="Default title", key="0", mxtype=None, fmt=None)

Create a HBInfo instance from an existing sparse matrix.

m : sparse matrix
the HBInfo instance will derive its parameters from m
title : str
Title to put in the HB header
key : str
Key
mxtype : HBMatrixType
type of the input matrix
fmt : dict
not implemented

hb_info : HBInfo instance

from_file(fid)

Create a HBInfo instance from a file object containg a matrix in the HB format.

fid : file-like matrix
File or file-like object containing a matrix in the HB format.

hb_info : HBInfo instance

__init__(title, key, total_nlines, pointer_nlines, indices_nlines, values_nlines, mxtype, nrows, ncols, nnon_zeros, pointer_format_str, indices_format_str, values_format_str, right_hand_sides_nlines=0, nelementals=0)

Do not use this directly, but the class ctrs (from_* functions).

dump()

Gives the header corresponding to this instance as a string.

_expect_int(value, msg=None)
_read_hb_data(content, header)
_write_data(m, fid, header)
class HBMatrixType(value_type, structure, storage="assembled")

Class to hold the matrix type.

from_fortran(fmt)
__init__(value_type, structure, storage="assembled")
fortran_format()
__repr__()
class HBFile(file, hb_info=None)
__init__(file, hb_info=None)

Create a HBFile instance.

file : file-object
StringIO work as well
hb_info : HBInfo, optional
Should be given as an argument for writing, in which case the file should be writable.
title()
key()
type()
structure()
storage()
read_matrix()
write_matrix(m)
hb_read(path_or_open_file)

Read HB-format file.

path_or_open_file : path-like or file-like
If a file-like object, it is used as-is. Otherwise it is opened before reading.
data : scipy.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
hb_write(path_or_open_file, m, hb_info=None)

Write HB-format file.

path_or_open_file : path-like or file-like
If a file-like object, it is used as-is. Otherwise it is opened before writing.
m : sparse-matrix
the sparse matrix to write
hb_info : HBInfo
contains the meta-data for write

None

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