Ahhh. sqrt()is now overloaded in Rcpp sugar, so you need to explicitly refer to a character from the C ++ global namespace that is imported from C. Try this line instead:
std::transform(orig.begin(),orig.end(),vec.begin(),::sqrt);
which he works with here:
R> require(inline)
R> src <- '
+ Rcpp::NumericVector orig(vector);
+ Rcpp::NumericVector vec(orig.size());
+ std::transform(orig.begin(), orig.end(), vec.begin(), ::sqrt);
+ return Rcpp::List::create(Rcpp::Named("result") = vec,
+ Rcpp::Named("original") = orig);
+ '
R> fun <- cxxfunction(signature(vector="numeric"), src, plugin="Rcpp")
R> fun(1:9)
$result
[1] 1.00000 1.41421 1.73205 2.00000 2.23607 2.44949 2.64575 2.82843 3.00000
$original
[1] 1 2 3 4 5 6 7 8 9
R>
Can you send me the URL of the page / example for which an update is required?
source
share