[Rcpp-devel] Rcpp equivalent of sample()?
chris.dubois at gmail.com
Sun May 15 02:13:53 CEST 2011
Thanks Dirk. Quick newbie followup question: Can we put functions within
the inline C++ code? The following doesn't compile, for example:
src <- '
int addition (int a, int b)
testfun = cxxfunction(signature(x="numeric"),body=src,plugin="Rcpp")
On a related note, would you mind showing a quick working example using
std::accumulate? The one below from the quick reference doesn't compile for
Thanks in advance.
std::accumulate( xx.begin(), xx.end(),std::plus<double>(), 0.0 );
On Sat, May 14, 2011 at 2:54 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
> On 14 May 2011 at 14:11, Chris DuBois wrote:
> | I'm just getting my feet wet with some Rcpp. I'm comfortable with R but
> | to C++. In the Rcpp vignettes, I found some of the R-like functions for
> | sampling from distributions (runif, rnorm, etc), but I didn't see a
> | mimicking sample(). I checked the list of unit tests and didn't see it
> | either. Have I missed it? Is there a C++ function I should be using to
> | sample (with replacement in my particular situation) from a vector (with
> | provided weights).
> No, sorry, I think you'd have to write a local version.
> Gauss once played himself in a zero-sum game and won $50.
> -- #11 at http://www.gaussfacts.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel