I have a Rcpp code written with Armadillo. I would like to use the Eigen library to do the least square estimation with sparse matrix A in the equation Ax=b.
Question is how can I convert from an Armadillo sp_mat to an Eigen SparseMatrix and vice versa?
There is a similar question on How can I convert from an Armadillo Matrix to an Eigen MatrixXd and vice versa?
question link: Converting an Armadillo Matrix to an Eigen MatriXd and vice versa
EDIT mockup file
in the file mockup.cpp
#include <RcppArmadillo.h>
#include <RcppEigen.h>
#include <iostream>
// [[Rcpp::depends(RcppArmadillo, RcppEigen)]]
// the function logit is a demo in Rcpp
// [[Rcpp::export]]
List logit_(arma::sp_mat A, Eigen::SparseMatrix<double> B){
// arma documentation link: http://arma.sourceforge.net/docs.html#memptr
int numA = A.n_rows;
arma::sp_mat out_A;
out_A = A.t();
// eigen documentation link: http://eigen.tuxfamily.org/dox/group__QuickRefPage.html
int numB = B.rows();
Eigen::SparseMatrix<double> out_B;
out_B = B.transpose();
return List::create(Named("out_A") = out_A,Named("out_B") = out_B);
}