[Rcpp-devel] Sparse matrices with RcppArmadillo

Dirk Eddelbuettel edd at debian.org
Sat Dec 8 13:28:36 CET 2012


Hi Søren,

On 8 December 2012 at 08:45, Søren Højsgaard wrote:
| 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.

I fear that we only have as<>() and wrap() converters for dense Armadillo
matrices.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list