<div dir="ltr">Hi all,<div> </div><div>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..</div><div><br></div><div><div>// [[Rcpp::export]]</div><div>NumericVector gm(NumericVector& v1)</div><div>{</div><div>  return(gamma(v1));</div><div>}</div></div><div><br></div><div>In R, I compared the calculation with R as follows,</div><div><div>> microbenchmark(gm(1:10),gamma(1:10))</div><div>Unit: nanoseconds</div><div>  Â  Â  Â  expr Â min Â  lq Â  Â mean median Â  uq Â  max neval</div><div>  Â  gm(1:10) 1510 1510 1854.26 Â  1812 1812 13282 Â  100</div><div> gamma(1:10) Â 604 Â 605 Â 776.65 Â  Â 906 Â 906 Â 2114 Â  100</div></div><div><br></div><div>May I ask is this normal and how can I speed up the calculation here?</div><div> </div><div>Many thanks!</div><div>Eridk</div><div><br></div></div>