<div dir="ltr"><div><div><div><div><div><div>I have been exploring the use of RcppEigen more recently and stumbled upon an issue when passing R objects.  Is there a way to pass an R matrix and get it in to a mapped Eigen MatrixXf object?  I know R doesn't have a native float type so I am not overly surprised that I have run in to this issue.<br><br></div>For example, the following works simply when expecting a double matrix.<br><br>#include <RcppEigen.h><br><br>// [[Rcpp::depends(RcppEigen)]]<br><br>using Eigen::Map;<br>using Eigen::MatrixXd;<br><br>// [[Rcpp::export]]<br>void floatMatrix(Map<MatrixXd> M){<br>    std::cout << M << std::endl;<br>}<br><br></div>However, when I try to change MatrixXd to MatrixXf the compilation fails stating:<br><br></div>    no matching function for call to 'eigen::Map<Eigen::Matrix<float, -1, -1> ::Map(Rcpp::Vector<14, Rcpp::PreserveStorage>::iterator, int&, int&)'<br><br></div>I tried searching around online if I could downcast the Mapped MatrixXd but I have been unsuccessful.  Any insights would be appreciated.<br><br></div>Regards,<br></div>Charles<br></div>