SparseM.hb {SparseM}R Documentation

Harwell-Boeing Format Sparse Matrices

Description

Read, write and extract components of data in Harwell-Boeing sparse matrix format.

Usage

read.matrix.hb(filename)
write.matrix.hb(filename = "hb.out", X, title, key, mxtype, rhs = NULL, 
guess = FALSE,  xsol = FALSE, ptrfmt = "(16I5)", indfmt = "(16I5)",
valfmt = "(1P,5D16.9)", rhsfmt = "(1P,5D16.9)")
model.matrix(object, ...)
model.response(data,type)

Arguments

filename file name to read from or write to
data, object an object of either matrix.csc.hb or matrix.ssc.hb class
type One of `"any"', `"numeric"', `"double"'. Using the either of latter two coerces the result to have storage mode `"double"'
X coefficient matrix stored in csc (for unsymmetric and rectangular matrix) or ssc (for symmetric matrix) format
title 72-character title for the matrix
key 8-character identifier for the matrix
mxtype 3-character identifier for type of the coefficient matrix;
First character: currently only "R" for real matrix is supported; second character: "S" for symmetric, "U" for unsymmetric" and "R" for rectangular matrix; third character: currently only "A" for assembled matrix is supported
rhs vector or matrix of right-hand-side(s) including starting guesses and solution vectors if present stored in full storage mode
guess logical flag for the presence of initial guess of the solutions; if TRUE, the values of initial guess are appended to the end of rhs
xsol logical flag for the presence of exact solutions; if TRUE, the values of the exact solutions are appended to the end of rhs
ptrfmt printing format for the column pointers
indfmt printing format for the row indices
valfmt printing format for the values
rhsfmt printing format for the right-hand-sides
... additional arguments

Details

Sparse coefficient matrices in the Harwell-Boeing format are stored in 80-column records. Each file begins with a multiple line header block followed by two, three or four data blocks. The header block contains summary information on the storage formats and storage requirements. The data blocks contain information of the sparse coefficient matrix and data for the right-hand-side of the linear system of equations, initial guess of the solution and the exact solutions if they exist. The function model.matrix extracts the X matrix component. The function model.response extracts the y vector (or matrix).

Value

The function read.matrix.hb returns a list of class matrix.csc.hb or matrix.ssc.hb depending on how the coefficient matrix is stored in the file.

ra ra component of the csc or ssc format of the coefficient matrix, X.
ja ja component of the csc or ssc format of the coefficient matrix, X.
ia ia component of the csc or ssc format of the coefficient matrix, X.
rhs.ra ra component of the right-hand-side, y, if stored in csc or ssc format; right-hand-side stored in dense vector or matrix otherwise.
rhs.ja ja component of the right-hand-side, y, if stored in csc or ssc format; a null vector otherwise.
rhs.ia ia component of the right-hand-side, y, if stored in csc or ssc format; a null vector otherwise.
xexact vector of the exact solutions, b, if they exist; a null vector otherwise.
guess vector of the initial guess of the solutions if they exist; a null vector otherwise.
dimension dimenson of the coefficient matrix, X.
rhs.dim dimenson of the right-hand-side, y.
rhs.mode storage mode of the right-hand-side; can be full storage or same format as the coefficient matrix.


The function model.matrix returns the X matrix of class matrix.csr. The function model.response returns the y vector (or matrix).

Author(s)

Pin Ng

References

Duff, I.S., Grimes, R.G. and Lewis, J.G. (1992) User's Guide for Harwell-Boeing Sparse Matrix Collection at http://math.nist.gov/MatrixMarket/collections/hb.html

See Also

slm for sparse version of lm
SparseM.ops for operators on class matrix.csr
SparseM.solve for linear equation solving for class matrix.csr
SparseM.image for image plotting of class matrix.csr
SparseM.ontology for coercion of class matrix.csr

Examples

## Not run: 
read.matrix.hb(system.file("HBdata","lsq.rra",package = "SparseM"))-> hb.o
class(hb.o) # -> [1] "matrix.csc.hb"
model.matrix(hb.o)->X
class(X) # -> "matrix.csr"
dim(X) # -> [1] 1850  712
y <- model.response(hb.o) # extract the rhs
length(y) # [1] 1850
## End(Not run)

[Package SparseM version 0.54 Index]