Skip to content

Instantly share code, notes, and snippets.

@floswald
Created July 8, 2014 10:13
Show Gist options
  • Save floswald/ffa0e77370e03872f6ac to your computer and use it in GitHub Desktop.
Save floswald/ffa0e77370e03872f6ac to your computer and use it in GitHub Desktop.
Rcpp::NumericVector -> std::vector
library(inline)
body='NumericVector xx(x);
std::vector<double> X(xx.begin(),xx.end());
for (int i = 0;i<X.size();i++) {
std::cout << "X[i] = " << X.at(i) << std::endl;
}
return (xx);'
tfun = cxxfunction(signature(x="numeric"),body,plugin="Rcpp")
tfun(c(1,2.2,4,3.19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment