I will work in R with a rather large (7 e6 x 4.5 e3), but very sparse matrix. Therefore, I am trying to understand how to work effectively with sparse matrices. I have two related questions.
First: I was given to understand that the package is Matrixautomatically linked to the compiled DLLs LAPACK and SuiteSparse. (I work on Windows.) It seemed to me that using SuiteSparse routines would reduce execution time compared to using dense matrices using the LAPACK package. But the test run below shows that the runtime for a sparse version of the matrix is much slower than the dense version.
> library(Matrix)
> sparse <- sparseMatrix(1:4, 1:4, x=rnorm(4))
> dense <- as.matrix(sparse)
> x <- 1:4
> system.time(for (i in 1:10000) sparse %*% x)
user system elapsed
0.23 0.00 0.23
> system.time(for (i in 1:10000) dense %*% x)
user system elapsed
0 0 0
> system.time(for (i in 1:1000) solve(sparse))
user system elapsed
3.94 0.00 3.94
> system.time(for (i in 1:1000) solve(dense))
user system elapsed
0.05 0.00 0.05
a) , Matrix ? , DLL?
) , ?
-: RcppEigen RcppArmadillo. RcppArmadillo ( ). RcppEigen, , . - , Eddelbuettel Sanderson, RcppEigen?