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?
>
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 <