[Rcpp-devel] R.e. Speed gain assistance (Wray, Christopher)
No probs - and sorry for the unclear post! Thanks
No worries. There are some important points here, some that have been raised repeatedly. On Thu, Aug 18, 2011 at 7:57 AM,
<rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
R> (1:50)[runif(10,0,20)] And I was wondering if I had missed some sugar-type of construct that would allow me to avoid the explicit 1e7 loop - and instead make use of some Rcpp vectorised/optimised/ machinery. Christian's sugg' of allowing double->int did speed things up enough, by me to chuck away the "floor"...
A big point here is that loops aren't "bad" in C++ -- the speed penalties are much less if you're using pure C++ within them, not making spurious function calls in them, etc. Sugar is exactly what the name implies -- syntactic sugar that beautifies code. It's not secret turbo-sauce -- that's what the compiler is for. -xian