[Rd] Error from sparse pattern matrix product
Niels Richard Hansen
Niels.R.Hansen+lists at math.ku.dk
Fri Nov 19 21:28:03 CET 2010
Hi
The following attempt to minimize memory consumption fails.
m1 <- Matrix(c(rep(1,1000), rep(0,2000)), 1500)
m2 <- as(m1, "ngCMatrix")
Then
m1 %*% c(1,2)
produces the desired matrix product, while
m2 %*% c(1,2)
results in the error
Error in x %*% y :
Cholmod error 'invalid xtype' at file:../MatrixOps/cholmod_sdmult.c, line 82
I might be making a wrong assumption that this should work, or another mistake,
but the error is somewhat cryptic, and reading the help pages and listing the
methods for %*% indicate that matrix products with x of class ngCMatrix
should work. Anyway
object.size(m1)/object.size(m2)
indicates that in this case there is a 2.7-fold gain in memory consumption by
storing only the pattern in the ngCMatrix. This could potentially be quite
useful for large model matrices.
Sincerely, Niels
sessionInfo:
R version 2.12.0 (2010-10-15)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Matrix_0.999375-45 lattice_0.19-13
loaded via a namespace (and not attached):
[1] grid_2.12.0
--
Niels Richard Hansen Web: www.math.ku.dk/~richard
Associate Professor Email: Niels.R.Hansen at math.ku.dk
Department of Mathematical Sciences nielsrichardhansen at gmail.com
University of Copenhagen Skype: nielsrichardhansen.dk
Universitetsparken 5 Phone: +1 510 502 8161
2100 Copenhagen Ø
Denmark
More information about the R-devel
mailing list