From ||eeuv@@n @end|ng |rom gm@||@com  Wed May 22 00:57:12 2019
From: ||eeuv@@n @end|ng |rom gm@||@com (kklot)
Date: Tue, 21 May 2019 17:57:12 -0500 (CDT)
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: <1558479432626-0.post-6772@n4.nabble.com>


perhaps you don't need this anymore but now after extract the dimension m, n,
we can simply generate arma matrix as
mat an_arma_mat(REAL(RA), m, n);
similarly you can convert RB to an arma matrix pointer, operate on it then
return directly RB to R.


I am testing a simple C++ function that takes a double matrix as
argument and which uses routines provided by the C++ Armadillo
package. I am aware of the nice capabilities of Rcpp and RcppArmadillo
which helps simplifying a lot and that I have already successfully
tested. However, I had a hard time trying to figure out how the
coercion from a REALSPX matrix to an arma::mat = arma::Mat<double>
matrix (double matrix in Armadillo) is done. In this particular case,
because of the simplicity of my function, I would like to use base R
only.



--
Sent from: http://r.789695.n4.nabble.com/R-devel-f909078.html



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