[Rd] coerce SEXP type to C++ matrix class and back

Dirk Eddelbuettel edd at debian.org
Mon Jan 11 13:53:57 CET 2016


I don't want to sound disrespectful, but why not use RcppArmadillo if
simplicity is you goal?

It is hard to beat the _fully automatic_ conversion:

R> cppFunction("arma::mat doubleUp(const arma::mat & x) { return 2*x; }", depends="RcppArmadillo")
R> doubleUp(matrix(1:9,3,3))
     [,1] [,2] [,3]
[1,]    2    8   14
[2,]    4   10   16
[3,]    6   12   18
R> 

You can of course do all that by hand too, but why do you think both Rcpp and
RcppArmadillo have, respectively, tens of thousands of lines of code?

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-devel mailing list