[Rcpp-devel] R.e. First foray into Rcpp and comparison of speed with R

Dirk Eddelbuettel edd at debian.org
Thu Sep 1 18:19:24 CEST 2011

On 1 September 2011 at 04:28, Christian Gunning wrote:
| > In R I was able to
| > vectorize all within line computations, but in C++ I have to use explicit
| > looping, right?
| At a glance, I don't see any glaring speed-related flaws.  Honestly,
| I'm curious to see what the R version of the Compute looks like.
| Others might advise on the use of iterators...
| >      w(i, t) = ped(i, t+3) - pa(i, t);
| This brings up a question that I've been meaning to ask the list --
| Last time I checked, with NumericVectors using myvec[i] was
| significantly faster than myvec(i) (due to bound and NA checking?).
| Now that I think of it, I seem to remember discussion of disabling
| these checks with NumericMatrix et al.  Of course, no checking is just
| another way to shoot my own foot -- I'm a big fan of myvec(i) in
| day-to-day use :)

I think (but feel to free me wrong by looking at headers and code :-) that
operator() and operator[] do the same thing.

There is a noNA() wrapper for Rcpp sugar to push performance -- NA checking
is implemented on access 'because that is how R does' (and our first task to
reproduce numbers you'd get at the R prompt) but if you know what you are
doing and are aware of possible pitfalls you can skip this. See
inst/examples/ConvolveBenchmarks/ and particularly convolve11_cpp.cpp.


Two new Rcpp master classes for R and C++ integration scheduled for 
New York (Sep 24) and San Francisco (Oct 8), more details are at

More information about the Rcpp-devel mailing list