extmat-class {svd}R Documentation

Class "extmat"

Description

'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 from the Class

Objects can be created by calls of the form extmat(mul, tmul, nrow, ncol, env = parent.frame()).

See Also

extmat

Examples

## 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)

[Package svd version 0.5.5 Index]