Monday, May 5, 2014

Using RcppEigen with sparseMatrix class

ecode <- '
using Eigen::Map;
using Eigen::MatrixXd;
using Eigen::MappedSparseMatrix;
using Eigen::SparseMatrix;

MappedSparseMatrix<double> X(as<MappedSparseMatrix<double> >(XX));

SparseMatrix<double> Xc = SparseMatrix<double>(X);
Xc = SparseMatrix<double>(Xc.selfadjointView<Eigen::Lower>());

return wrap(Xc);
'

SeigenXSX <- cxxfunction(signature(SS = "matrix", XX="dgCMatrix"), ecode,
plugin = "RcppEigen")

No comments:

Post a Comment