Re: [Rcpp-devel] Pass matrix by copy

2015-04-14 Thread Kevin Ushey
This is by design; we pass objects by reference for efficiency. Use `Rcpp::clone()` to explicitly duplicate objects. On Tue, Apr 14, 2015 at 10:15 AM, wrote: > Hello, > > I have just noticed that my small Rcpp function changes the original > matrix on the R side -- why and how to pass by copy? >

[Rcpp-devel] Pass matrix by copy

2015-04-14 Thread soeren . vogel
Hello, I have just noticed that my small Rcpp function changes the original matrix on the R side -- why and how to pass by copy? Thanks Sören #include using namespace Rcpp; // [[Rcpp::export]] NumericMatrix test_min( NumericMatrix M ) { int n = M.nrow(); for ( int i = 0; i <