extmat-class | R Documentation |
"extmat"
'extmat' is a convenient wrapper which allows one provide just the routines which will multiply with matrix and the transposed one (e.g. if the matrix is sparse or structured) and allow to use the SVD routines of the package. This S4 wrapper allows the use of usual matrix operations on such objects.
Objects can be created by calls of the form extmat(mul, tmul, nrow, ncol, env = parent.frame())
.
extmat
## Not run:
library(Matrix)
f <- function(v) as.numeric(A %*% v) # Convert Matrix object back to vector
tf <- function(v) as.numeric(tA %*% v) # Convert Matrix object back to vector
e <- new.env()
assign("A", USCounties, e)
assign("tA", t(USCounties), e)
environment(f) <- e
environment(tf) <- e
m <-extmat(f, tf, nrow(USCounties), ncol(USCounties))
system.time(v1 <- propack.svd(m, neig = 10))
# user system elapsed
# 0.252 0.007 0.259
system.time(v2 <- propack.svd(as.matrix(USCounties), neig = 10))
# user system elapsed
# 8.563 0.027 8.590
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.