Chris, i set a tiny matrix <br><br><br>mm&lt;-matrix(1:10, nr=2),<br><br>cut your code  pasted it into R <br><br>after i run myfun(mm), i still have exactly the same matrix when i print mm as before, not a doubled matrix <br>
<br>The function myfun did return a doubled matrix, but original matrix mm stayed the same, so it still appears that original R memory was not changed from C++<br><br>I maybe missing something very obvious, i don&#39;t understand how it&#39;s possible that the same code seems to give you a different result, just reporting what i personally observe when i go exactly through the motions you suggested<br>
<br><br><br><br><br><div class="gmail_quote">On Wed, Nov 2, 2011 at 9:53 PM, Christian Gunning <span dir="ltr">&lt;<a href="mailto:xian@unm.edu">xian@unm.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, Nov 2, 2011 at 4:00 AM,<br>
&lt;<a href="mailto:rcpp-devel-request@r-forge.wu-wien.ac.at">rcpp-devel-request@r-forge.wu-wien.ac.at</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; 1. in my previous post  i used exactly that same constructor you are<br>
&gt; talking about as you can see from the code i posted<br>
<br>
</div>Sorry about that, completely missed it...<br>
Using what&#39;s below, this should work fine.<br>
<div class="im"><br>
&gt; 3. i am not 100% sure but this toy test that i did seem to indicate to me<br>
&gt; that a copy is done regardless by NumericalMatrix. I need to see the code<br>
&gt; for NumericMatrix to be absolutely sure, but i cannot explain things<br>
&gt; otherwise<br>
<br>
</div>This is a little tricky, I almost missed it myself (again).<br>