No subject


Mon Oct 17 11:22:36 CEST 2011


"If R/C++ types match, use pointer to x."
Use a non-integer input to your function and see if that works.  Take
a look at this example:

src <- '
Rcpp::NumericMatrix r_m(mem);
int nn =3D r_m.nrow() * r_m.ncol();
// int nn =3D r_m.size();
// above doesnt work with NumericMatrix, .size() is ambiguous??
for (int ii =3D0; ii < nn; ii++) {
    r_m[ii] =3D r_m[ii] + r_m[ii];
}
return r_m;
'

require(inline)
require(RcppArmadillo)
myfun =3D cxxfunction(signature(mem=3D'numeric'), src, plugin=3D'Rcpp')

ll <<- mm <<- matrix((1:10)/10, nrow=3D2)
llint <<- mmint <<- matrix(1:10, nrow=3D2)
myfun(mm)
## should be false, since myfun modifies mm directly?
print(all.equal(mm, ll))
print(all.equal(mmint, llint))

hth,
-Christian


--=20
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal =E2=80=93 Panama!


More information about the Rcpp-devel mailing list