Hi, "numeric" is specified as the signature. But it does not say whether it should be a matrix or a vector. The following example just assume the input is matrix. But should there be some checking to make sure the input is indeed a matrix before the conversion to NumericMatrix? Or the check has to be before "fun" is called?
Thanks! library(inline) src=' Rcpp::NumericVector mat = Rcpp::clone<Rcpp::NumericMatrix>(mx); std::transform(mat.begin(), mat.end(), mat.begin(), ::sqrt); return mat; ' fun=cxxfunction(signature(mx="numeric"), src, plugin="Rcpp") orig=matrix(1:9, 3, 3) fun(orig) -- Regards, Peng _______________________________________________ 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