[Rcpp-devel] Question on syntactic sugar

Gregor Kastner mailinglist at gmx.at
Mon Jan 9 12:46:55 CET 2012


Thanks for the reply, Dirk.

> | I.e., is there a way to reproduce the following R code with Rcpp
> (without | using loops)?
> | 
> | r <- c(1,11,111)
> | index <- c(2,2,1)
> | r[index]
> 
> That was just discussed _yesterday_ on this list.
> 
> And no, I don't think it is. Would be nice -- patches welcome.

I have caught up on older discussions - sorry, I just joined recently. Given
my limited knowledge, the latest discussion about the convolution, and the
digging I have been doing, I came up with the following rule of thumb. Am I
right / do you agree?

Use native C/C++ data structures within loops whenever possible, paying
attention to the "natural" storage order of objects if applicable.
Alternatively, use iterators or pay the - application dependent - price of
operator overloading as discussed in your JSS article.

At the current point of development, "syntactic sugar indexing" can only be
used for _assignment_ of a certain (consecutive) range, but not for
extraction.

Thanks for the comments and for this great piece of software.

/g


More information about the Rcpp-devel mailing list