[Rcpp-devel] Sparse matrices with RcppArmadillo

Søren Højsgaard sorenh at math.aau.dk
Sat Dec 8 09:45:56 CET 2012


Dear all,

I want to use a matrix (of type "dgCMatrix" from the Matrix package) in RcppArmadillo, so I do:

library(inline)
src <- '
using namespace arma;
using namespace Rcpp;
SpMat<double> X = as<SpMat<double> >(XX_);
'
foo <- cxxfunction(signature(XX_=""), body=src, plugin="RcppArmadillo")

- but this fails. It seems to me (browsing the web) that SpMat are supported, but I might be wrong here. I have no indication that dgCMatrix matrices can be "converted" to SpMat's. I know that I can work with dgCMatrix matrices with RcppEigen, but what I need is to extract submatrices and that is very easy to do with RcppArmadillo.

Any thoughts? Thanks in advance.
Regards
Søren


More information about the Rcpp-devel mailing list