I'm seeking some advice on effectively using the new Matrix
library in R1.9.0 for operations with large dense matrices. I'm working on
integral operator models (implemented numerically via matrix operations)
and except for the way entries are generated, the examples below really are
representative of my problem sizes.
My main concern is speed of large dense matrix multiplication.
In R 1.8.1 (Windows2000 Professional, dual AthlonMP 2800)
a=matrix(rnorm(2500*2500),2500,2500); v=rnorm(2500);
system.time(a%*%v);
[1] 0.11 0.00 0.12 NA NA
In R 1.9.0, same platform:
a=matrix(rnorm(2500*2500),2500,2500); v=rnorm(2500);
system.time(a%*%v);
[1] 0.24 0.00 0.25 NA NA
These differences are consistent. But using the Matrix library
in 1.9.0, the discrepancy disappears
library(Matrix);
a=Matrix(rnorm(2500*2500),2500,2500); v=Matrix(rnorm(2500),2500,1);
system.time(a%*%v);
[1] 0.11 0.00 0.11 NA NA
The problem is
Error in a/3 : non-numeric argument to binary operator
which seems to mean that I can't just rewrite code to use Matrix
instead of matrix objects -- I would have to do lots and lots of
conversions between Matrix and matrix. Am I missing a trick
here somewhere, that would let me use only Matrix objects and do
with them the things one can do with matrix objects? Or some other
way to avoid the twofold speed hit in moving to 1.9?