Greetings, I am an (very) grateful user of Rcpp. As such I defined a function // [[Rcpp::export]] NumericVector leftShift(NumericVector x){ for(int i=0;i<n-1;i++) x[i]=x[i+1]; return x; } expecting this function not to affect the parameter x outside the function body as it is passed in by value. However subsequent tests showed that it does affect x. What is going on here? Is sourceCpp rewriting this code in somne fashion?? Michael Meyer
Michael Meyer via R-help <r-help <at> r-project.org> writes:> I am an (very) grateful user of Rcpp.Glad to hear that! But you are on the wrong mailing list. Please ask on rcpp-devel. Dirk
On 27 Aug 2015, at 17:40 , Dirk Eddelbuettel <edd at debian.org> wrote:> Michael Meyer via R-help <r-help <at> r-project.org> writes: > >> I am an (very) grateful user of Rcpp. > > Glad to hear that! > > But you are on the wrong mailing list. Please ask on rcpp-devel.But for the benefit of the rest of us: A NumericVector is a pointer, right? -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com