externalFormats {Matrix}R Documentation

Read and write external matrix formats

Description

Read matrices stored in the Harwell-Boeing or MatrixMarket formats or write sparseMatrix objects to one of these formats.

Usage

readHB(file)
readMM(file)
writeHB(obj, file, ...)
writeMM(obj, file, ...)

Arguments

obj a real sparse matrix
file for writeHB and writeMM - the name of the file to be written. For readHB and readMM the name of the file to read, as a character scalar. The names of files storing matrices in the Harwell-Boeing format usually end in ".rua" or ".rsa". Those storing matrices in the MatrixMarket format usually end in {".mtx"}.
Alternatively, readHB accepts a connection object.
... optional additional arguments. Currently none are used in any methods.

Value

The readHB and readMM functions return an object that inherits from the "Matrix" class. Methods for the writeHB and writeMM generic functions usually return NULL and, as a side effect, the matrix obj is written to file in the Harwell-Boeing format (writeHB) or the MatrixMarket format (writeMM).

References

http://math.nist.gov/MatrixMarket

http://www.cise.ufl.edu/research/sparse/matrices

Examples

str(pores <- readMM(system.file("external/pores_1.mtx",
                                package = "Matrix")))
str(utm <- readHB(system.file("external/utm300.rua",
                               package = "Matrix")))
str(lundA <- readMM(system.file("external/lund_a.mtx",
                                package = "Matrix")))
str(lundA <- readHB(system.file("external/lund_a.rsa",
                                package = "Matrix")))
## Not run: 
## NOTE: The following examples take quite some time
## ----  even on a fast internet connection:
str(sm <-
 readHB(gzcon(url("http://www.cise.ufl.edu/research/sparse/HBformat/Boeing/msc00726.rsa.gz"))))
str(jgl009 <-
 readMM(gzcon(url("ftp://math.nist.gov/pub/MatrixMarket2/Harwell-Boeing/counterx/jgl009.mtx.gz"))))
## End(Not run)
data(KNex)
writeHB(KNex$mm, "mmHB.rua")
writeMM(KNex$mm, "mmMM.mtx")

[Package Matrix version 0.995-11 Index]