SCM Repository

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

View of /pkg/man/band.Rd

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1331 - (download) (as text) (annotate)
Sat Jul 22 17:59:53 2006 UTC (13 years, 8 months ago) by maechler
File size: 2189 byte(s)
many method cleanups; notably some "dgC" -> "Csparse" generaliztations
\title{Extract bands of a matrix}
  Returns a new matrix formed by extracting the lower triangle
  (\code{tril}) or the upper triangle (\code{triu}) or a general band
  relative to the diagonal (\code{band}), and setting other elements
  to zero.  The general forms of these functions include integer
  arguments to specify how many diagonal bands above or below the main
  diagonal are not set to zero.
band(x, k1, k2, \dots)
tril(x, k = 0, \dots)
triu(x, k = 0, \dots)
  \item{x}{a matrix-like object}
  \item{k,k1,k2}{integers specifying the diagonal bands that will not
  be set to zero.  These are given relative to the main diagonal,
  which is \code{k=0}.  A negative value of \code{k} indicates a
  diagonal below the main diagonal and a positive value indicates a
  diagonal above the main diagonal.}
 \item{\dots}{Optional arguments used by specific methods. (None used at present.)}
  An object of an appropriate matrix class.  The class of the value of
  \code{tril} or \code{triu} inherits from
  \code{\linkS4class{triangularMatrix}} when appropriate.
    \item{x = "CsparseMatrix"}{method for compressed, sparse,
      column-oriented matrices.}
## A random sparse matrix :
m <- matrix(0, 5, 5)
m[sample(length(m), size = 14)] <- rep(1:9, length=14)
(mm <- as(m, "dgCMatrix"))

tril(mm)        # lower triangle
tril(mm, -1)    # strict lower triangle
triu(mm,  1)    # strict upper triangle
band(mm, -1, 2) # general band
\dontshow{ ## this uses special methods
(x.x <- crossprod(mm))
xx <- tril(x.x) + triu(x.x, 1) ## the same as x.x (but stored differently):
stopifnot(identical(triu(x.x), t(tril(x.x))),
          identical(x.x, t(as(xx, "dsCMatrix"))))
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge