Skip to content
Prev 23051 / 63421 Next

Matrix*vector: coercing sparse to dense matrix for arithmetic

On 11/29/06, Tamas K Papp <tpapp at princeton.edu> wrote:

            
I would suggest premultiplying by a diagonal matrix.  However, when I
look at the method dispatch after an example it doesn't appear to be
making a good choice.  What I think should work well (and Martin or I
will make the necessary changes to ensure that it does) is

library(Matrix)
data(KNex); mm <- KNex$mm
system.time(Diagonal(x = rnorm(nrow(mm))) %*% mm)