Re: [Rcpp-devel] Summing over a numeric vector.

2011-01-03 Thread Richard Chandler
You could also use this: Summing3 <- cxxfunction(signature(x="numeric"), ' Rcpp::NumericVector Dvec(x); double out = sum(Dvec); return Rcpp::wrap(out); ',plugin="Rcpp") x <- rnorm(100) Summing3(x); sum(x) Richard On Mon, Jan 3, 2011 at 11:04 AM, Cedric Ginestet < c.gineste...@go

Re: [Rcpp-devel] Summing over a numeric vector.

2011-01-03 Thread Cedric Ginestet
Thanks Douglas, How stupid of me! Cheers, On 03/01/11 16:00, Douglas Bates wrote: You forgot to initialize i in both loops. It should be for(int i = 0; i< Ne; i++) On Mon, Jan 3, 2011 at 9:50 AM, Cedric Ginestet wrote: Dear Rcpp experts, I have the following bizarre problem. Although the

Re: [Rcpp-devel] Summing over a numeric vector.

2011-01-03 Thread Douglas Bates
You forgot to initialize i in both loops. It should be for(int i = 0; i < Ne; i++) On Mon, Jan 3, 2011 at 9:50 AM, Cedric Ginestet wrote: > Dear Rcpp experts, > > I have the following bizarre problem. Although the second summing C++ > function seems easier than the former, it does not produce t