On Wed, Nov 2, 2011 at 4:00 AM, <rcpp-devel-requ...@r-forge.wu-wien.ac.at> wrote: > > > 1. in my previous post i used exactly that same constructor you are > talking about as you can see from the code i posted
Sorry about that, completely missed it... Using what's below, this should work fine. > 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 This is a little tricky, I almost missed it myself (again). From the Quickref: "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 = r_m.nrow() * r_m.ncol(); // int nn = r_m.size(); // above doesnt work with NumericMatrix, .size() is ambiguous?? for (int ii =0; ii < nn; ii++) { r_m[ii] = r_m[ii] + r_m[ii]; } return r_m; ' require(inline) require(RcppArmadillo) myfun = cxxfunction(signature(mem='numeric'), src, plugin='Rcpp') ll <<- mm <<- matrix((1:10)/10, nrow=2) llint <<- mmint <<- matrix(1:10, nrow=2) myfun(mm) ## should be false, since myfun modifies mm directly? print(all.equal(mm, ll)) print(all.equal(mmint, llint)) hth, -Christian -- A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama! _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel