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

[Rcpp-devel] Summing over a numeric vector.

2011-01-03 Thread Cedric Ginestet
Dear Rcpp experts, I have the following bizarre problem. Although the second summing C++ function seems easier than the former, it does not produce the correct answer. See the following reproducible codes: ## Summing1 <- cxxfunction(signature(x="numeric

Re: [Rcpp-devel] Rcpp_0.9.0.tar.gz does not build on FreeBSD

2011-01-03 Thread Dirk Eddelbuettel
Rainer, Please use the rcpp-devel list for questions. You need to subscribe to post, or you can use a web-to-list interface to gmane.org. On 3 January 2011 at 11:54, Rainer Hurling wrote: | I want to build and install Rcpp_0.9.0.tar.gz in R-2.12.1 on FreeBSD | 9.0-CURRENT (amd64). The build pro