Skip to content
Prev 2283 / 10988 Next

[Rcpp-devel] Rcpp equivalent of sample()?

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)
{
  int r;
  r=a+b;
  return (r);
}
NumericVector xx(x);
return(xx);
'
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
me.

Thanks in advance.
Chris

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:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110514/ce466c71/attachment.htm>