# No subject

Mon Oct 17 11:22:36 CEST 2011

```&quot;If R/C++ types match, use pointer to x.&quot;<br>
Use a non-integer input to your function and see if that works. =A0Take<br>
a look at this example:<br>
<br>
src &lt;- &#39;<br>
Rcpp::NumericMatrix r_m(mem);<br>
int nn =3D r_m.nrow() * r_m.ncol();<br>
// int nn =3D r_m.size();<br>
// above doesnt work with NumericMatrix, .size() is ambiguous??<br>
for (int ii =3D0; ii &lt; nn; ii++) {<br>
=A0 =A0r_m[ii] =3D r_m[ii] + r_m[ii];<br>
}<br>
return r_m;<br>
&#39;<br>
<br>
require(inline)<br>
myfun =3D cxxfunction(signature(mem=3D&#39;numeric&#39;), src, plugin=3D&#3=
9;Rcpp&#39;)<br>
<br>
ll &lt;&lt;- mm &lt;&lt;- matrix((1:10)/10, nrow=3D2)<br>
llint &lt;&lt;- mmint &lt;&lt;- matrix(1:10, nrow=3D2)<br>
myfun(mm)<br>
## should be false, since myfun modifies mm directly?<br>
print(all.equal(mm, ll))<br>
print(all.equal(mmint, llint))<br>
<br>
hth,<br>
<div><div></div><div class=3D"h5">-Christian<br>
<br>
<br>
--<br>
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal =96 Panama!<br>
</div></div></blockquote></div><br>

--00151758f34c6dac6504b0e0a5ea--
```