Hi Gang: I am working with some C++ code that uses pointers. I know I could change the code. But, I was wondering if there is an easy way to map the double pointer into the R data via Rcpp. I have been using RcppEigen to do that. For example...
RcppExport SEXP myfunc(SEXP _n, SEXP _x) { const int n=Rcpp::as<int>(_n); double *x=(double *)malloc(n*sizeof(double)); Eigen::Map<Eigen::VectorXd> map_x(x, n); map_x=Rcpp::as< Eigen::Map<Eigen::VectorXd> >(_x); double a=fit(x, n); ... It seems to me there should be an easier way like ... RcppExport SEXP myfunc(SEXP _n, SEXP _x) { const int n=Rcpp::as<int>(_n); double *x=Rcpp::as<double*>(_x); // or a const-correct version double a=fit(x, n); ... Thanks, Rodney _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel