SCM Repository

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

View of /pkg/man/tcrossprod.Rd

Parent Directory Parent Directory | Revision Log Revision Log

Revision 976 - (download) (as text) (annotate)
Fri Oct 7 20:18:29 2005 UTC (13 years, 11 months ago) by maechler
File size: 1548 byte(s)
more examples; update
% more \alias{tcrossprod,...}es in *-class*.Rd files
\title{Cross-product of transpose}
  Take the cross-product of the transpose of a matrix.
  This is formally equivalent to, but faster than, the
  call \code{x \%*\% t(x)}.
  \item{x}{a matrix-like object}
  For some classes in the \code{Matrix} package, such as the
  \code{\link{dgCMatrix-class}}, it is much faster to calculate the
  cross-product of the transpose directly instead of calculating the
  transpose first and then its cross-product.
  An object of an appropriate symmetric matrix class.
    \item{x = "dgCMatrix"}{method for compressed, sparse,
      column-oriented matrices.}
 ## A random sparce "incidence" matrix :
 m <- matrix(0, 400, 500)
 m[runif(314, 0, length(m))] <- 1
 mm <- as(m, "dgCMatrix")
 object.size(m) / object.size(mm) # smaller by a factor of 242.88

 ## tcrossprod() is very fast:
 system.time(tCmm <- tcrossprod(mm))# 0   (PIII, 933 MHz)
 system.time(cm <- crossprod(t(m))) # 0.16
 system.time(cm. <- tcrossprod(m))  # 0.02

 stopifnot(identical(cm, as(tCmm, "matrix")))

 ## show sparse sub matrix
 tCmm[1:16, 1:30]
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge