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.
For example, the following works simply when expecting a double matrix.
#include <RcppEigen.h>
// [[Rcpp::depends(RcppEigen)]]
using Eigen::Map;
using Eigen::MatrixXd;
// [[Rcpp::export]]
void floatMatrix(Map<MatrixXd> M){
std::cout << M << std::endl;
}
However, when I try to change MatrixXd to MatrixXf the compilation fails
stating:
no matching function for call to 'eigen::Map<Eigen::Matrix<float, -1,
-1> ::Map(Rcpp::Vector<14, Rcpp::PreserveStorage>::iterator, int&, int&)'
I tried searching around online if I could downcast the Mapped MatrixXd but
I have been unsuccessful. Any insights would be appreciated.
Regards,
Charles
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel