Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-08 Thread Simon Zehnder
Hi Romain, I considered the implicit use of Rcpp::as<>() inside of the arma::mat() constructor. My target was to reuse memory and try to use a very simple setting, i.e. (at least in my opinion) not too much lines of code. You answered to my question "On the other side I then assume, that the

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-08 Thread Kevin Ushey
I'm pretty the sure the Rcpp / RcppArmadillo way is to reuse memory whenever the types match between the as'ed containers, and copy if type coercion makes sense. Ie, an R integer vector --> an Rcpp IntegerVector would reuse the same memory, while an R integer vector --> an Rcpp NumericVector would

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-08 Thread Dirk Eddelbuettel
On 8 June 2013 at 12:48, Kevin Ushey wrote: | I'm pretty the sure the Rcpp / RcppArmadillo way is to reuse memory whenever | the types match between the as'ed containers, and copy if type coercion makes | sense. Ie, an R integer vector --> an Rcpp IntegerVector would reuse the same | memory, while

Re: [Rcpp-devel] Integer matrices in Rcpp and Armadillo

2013-06-08 Thread Dirk Eddelbuettel
Simon, You (in my eyes needlessly) complicate matters further with the S4 wrapping. The base case is simple, shown/used in src/fastLm.cpp right in the middle of RcppArmadillo and discussed a million times: extern "C" SEXP fastLm(SEXP Xs, SEXP ys) { try { Rcpp::NumericVector yr(ys);