Christian,<br><br>1. in my previous post  i used exactly that same constructor you are talking about as you can see from the code i posted<br><br>2. i am not doing any math in this illustrative example, i am just modifying a toy matrix and showing that this modification didn&#39;t propagate back to R. Which means i am operating on a different chunk of memory, i.e. i made a copy somewhere. In real life I need to do a some fairly involved manipulations on several matrices each couple of gigs big, so it&#39;d be nice not to copy. I have armadillo code that does the job, but i wanted to call it from R without copying the matrices. In pure R this stuff takes very long time. <br>
 <br>3. i am not 100% sure but this toy test that i did seem to indicate to me that a copy is done regardless by NumericalMatrix. I need to see the code for NumericMatrix to be absolutely sure, but i cannot explain things otherwise<br>
<br><div class="gmail_quote">On Wed, Nov 2, 2011 at 12:31 AM, 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;">
<br>
1:  For the NumericMatrix-&gt;arma, you can use an advanced constructor<br>
to get the behavior that you desire.<br>
<a href="http://arma.sourceforge.net/docs.html#Mat" target="_blank">http://arma.sourceforge.net/docs.html#Mat</a> -- you&#39;ll want copy_aux_mem<br>
= false.<br>
<br>
2:  Are you actually doing matrix math?  If you&#39;re just doing simple<br>
element-by-element arithmetic, you might get just as good performance<br>
with a simple loop or iterator.  You might try this first to<br>
understand the R/C++ process, and *then* move to using Armadillo :)<br>
<br>
3:  For completeness, note that &quot;Rcpp::NumericMatrix r_m(clone(mem));&quot;<br>
*forces* a copy, thus restoring R&#39;s &quot;no side-effects&quot; semantics.<br>
<br>
-Christian<br>
<font color="#888888"><br>
<br>
<br>
--<br>
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!<br>
</font></blockquote></div><br>