No subject
Mon Oct 17 11:22:36 CEST 2011
"If R/C++ types match, use pointer to x."<br>
Use a non-integer input to your function and see if that works. =A0Take<br>
a look at this example:<br>
<br>
src <- '<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 < nn; ii++) {<br>
=A0 =A0r_m[ii] =3D r_m[ii] + r_m[ii];<br>
}<br>
return r_m;<br>
'<br>
<br>
require(inline)<br>
require(RcppArmadillo)<br>
myfun =3D cxxfunction(signature(mem=3D'numeric'), src, plugin=3D=
9;Rcpp')<br>
<br>
ll <<- mm <<- matrix((1:10)/10, nrow=3D2)<br>
llint <<- mmint <<- 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--
More information about the Rcpp-devel
mailing list