SCM Repository

[matrix] View of /pkg/Matrix/man/externalFormats.Rd
ViewVC logotype

View of /pkg/Matrix/man/externalFormats.Rd

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2677 - (download) (as text) (annotate)
Sat Jun 25 19:18:12 2011 UTC (7 years, 7 months ago) by mmaechler
File size: 3216 byte(s)
finally a working C level Csparse_subassign() - to solve the memory-explode issue .. *BUT* it`s still too slow, even if I never remove but use drop0(.) in the end ... commit now before South America ... in case I get hit by a truck :-)
% \alias{writeHB}
\title{Read and write external matrix formats}
  Read matrices stored in the Harwell-Boeing or MatrixMarket formats
  or write \code{\linkS4class{sparseMatrix}} objects to one of these
writeMM(obj, file, ...)
 \item{obj}{a real sparse matrix}
 \item{file}{for \code{writeMM} - the name of the file to be written.
   For \code{readHB} and \code{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 \code{".rua"} or \code{".rsa"}.
   Those storing matrices in the MatrixMarket format usually end in

   Alternatively, \code{readHB} and \code{readMM} accept connection objects.}
 \item{\dots}{optional additional arguments. Currently none are used in
   any methods.}
  The \code{readHB} and \code{readMM} functions return an object that
  inherits from the \code{"\linkS4class{Matrix}"} class.  Methods for the
  \code{writeMM} generic functions usually return
  \code{\link{NULL}} and, as a side effect, the matrix \code{obj} is
  written to \code{file} in the MatrixMarket format (writeMM).
  The Harwell-Boeing format is older and less flexible than the
  MatrixMarket format.  The function \code{writeHB} was deprecated and
  has now been removed.  Please use \code{writeMM} instead.

  A very simple way to export small sparse matrices \code{S}, is to use
  \code{summary(S)} which returns a \code{\link{data.frame}} with
  columns \code{i}, \code{j}, and possibly \code{x}, see \code{summary} in
  \code{\link{sparseMatrix-class}}, and an example below.

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")))
## NOTE: The following examples take quite some time
## ----  even on a fast internet connection:
if(FALSE) # the URL has been corrected, but we need an un-tar step!
str(sm <-

str(jgl009 <-
writeMM(KNex$mm, "mmMM.mtx")

## very simple export - in triplet format - to text file:
s.CA <- summary(CAex)
message("writing to ", outf <- tempfile())
write.table(s.CA, file = outf, row.names=FALSE)
## and read it back -- showing off  sparseMatrix():
dd <- read.table(outf, header=TRUE)
mm <-, dd)
stopifnot(all.equal(mm, CAex, tol=1e-15))
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge