[Rd] Error from sparse pattern matrix product

From: Niels Richard Hansen <Niels.R.Hansen+lists_at_math.ku.dk>
Date: Fri, 19 Nov 2010 12:28:03 -0800


The following attempt to minimize memory consumption fails.

m1 <- Matrix(c(rep(1,1000), rep(0,2000)), 1500) m2 <- as(m1, "ngCMatrix")


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


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


R version 2.12.0 (2010-10-15)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

[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 Ø

R-devel_at_r-project.org mailing list
Received on Fri 19 Nov 2010 - 20:35:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 20 Nov 2010 - 07:50:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive