Hello,

There was an earlier post on this subject, but based on my experimentation, the 
behaviour of modifying input argument is different depending on how the matrix 
was initialization and other factors...

I wrote a Rcpp function to modify an input matrix. After calling this function, 
the input matrix is modified under some circumstances and not modified under 
others. The behaviour is the same on repeat runs and on both Linux 
(3.16.3-1-ARCH) and Mac (OSX 10.9).

The R script, C++ code, and the results are available on Bitbucket:

https://bitbucket.org/dshih/rcpp_inplace

I don't quite understand when the input matrix is modified in place by the Rcpp 
function and when the input matrix is be copied on write in the Rcpp function.

When I stay within Rcpp/C++, a input argument can be modified in-place by a 
function. (This feature was critical to my optimization.)

After the code returns to R, I would expect either copy-on-write or in-place 
modification but not both.

What is the correct behaviour?


Thank you,

David J. H. Shih

The Hospital for Sick Children
Peter Gilgan Centre for Research and Learning
686 Bay St
17th floor, Room 17.9707
Toronto, ON  M5G 0A4
Canada
Tel:  (416) 813-7654 x309157
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to