[Rcpp-devel] Loops, iterators and accumulate

Hadley Wickham h.wickham at gmail.com
Thu Nov 15 14:49:49 CET 2012


> | I'm trying to get a better handle on writing efficient numerical code
> | with C++.  I've attached five implementations of a simple sum function
> | (mostly ignoring NAs) and timed them below:
>
> Did you see the (fairly extensive) comparison in
>       examples/ConvolveBenchmarks/
> which compares running across vectors in similar ways? There is more code in
> the main file than currently tickled so you may want to revisit this in some
> detail. Also compares to R's C API -- a fresh set of eyes (yours!!) would be
> welcome.

I didn't, but I'm looking at it now, thanks.  The main problem is that
many of the examples use C++ idioms I don't understand - and as I
mentioned below, that code uses iterators in a way that I haven't seen
anywhere else.

> No, if I dare make a quick guess before heading to work it is because Romain
> sneakily unrolls some loops for us in sugar --- fewer if() comparisons,
> faster code.

Ah cool, thanks.

Hadley

-- 
RStudio / Rice University
http://had.co.nz/


More information about the Rcpp-devel mailing list