From edd at debian.org  Mon Jan 11 13:53:57 2016
From: edd at debian.org (Dirk Eddelbuettel)
Date: Mon, 11 Jan 2016 06:53:57 -0600
Subject: [Rd] coerce SEXP type to C++ matrix class and back
In-Reply-To: <CABGWzFSLgybYi0Tw2XhWXZVdMf11HXF6EwLapugDaMqddg_wCA@mail.gmail.com>
References: <CABGWzFSLgybYi0Tw2XhWXZVdMf11HXF6EwLapugDaMqddg_wCA@mail.gmail.com>
Message-ID: <22163.42469.934862.828950@max.nulle.part>


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



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