Skip to content
Prev 4890 / 10988 Next

[Rcpp-devel] Sparse matrices with RcppArmadillo

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