Hi all,
I am just starting using Rcpp to accelerate some computations. I need to
evaluate some likelihood using common math functions like beta, lbeta,
gamma, lgamma, choose, lchoose, etc. But I found that it could be even
slower in Rcpp than R? Please see the example below using Rcpp..
// [[Rcpp::export]]
NumericVector gm(NumericVector& v1)
{
return(gamma(v1));
}
In R, I compared the calculation with R as follows,
> microbenchmark(gm(1:10),gamma(1:10))
Unit: nanoseconds
expr min lq mean median uq max neval
gm(1:10) 1510 1510 1854.26 1812 1812 13282 100
gamma(1:10) 604 605 776.65 906 906 2114 100
May I ask is this normal and how can I speed up the calculation here?
Many thanks!
Eridk
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel