Message-ID: <CADNH-PtmJL8noMqHOaQCa9xHv8Qe9jqta_nAz=sFScWku-X2Eg@mail.gmail.com>
Date: 2011-08-18T23:33:30Z
From: Christian Gunning
Subject: [Rcpp-devel] R.e. Speed gain assistance (Wray, Christopher)
In-Reply-To: <49B98DAFD025E24981E0DC5A9D8100CE459047@DB3PRD0104MB119.eurprd01.prod.exchangelabs.com>
> 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