[Rcpp-devel] Map Eigen MatrixXf?
Charles Determan
cdetermanjr at gmail.com
Wed Jun 24 21:31:56 CEST 2015
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150624/65f1cada/attachment-0001.html>
More information about the Rcpp-devel
mailing list