[Rcpp-devel] clarification of interaction between RInside and RcppEigen
Stephen J. Barr
stephenjbarr at gmail.com
Tue Aug 7 23:43:41 CEST 2012
Thanks for the pointer to sugar.
I was just trying to think of a simple example. So my C++ code will be
essentially:
int main() {
RInside R(argc, argv); // create an embedded R instance
R.parseEval("X = generateSomeMatrix()");
Eigen::MatrixXd Xeigen;
// this is the part that I am still a bit unclear of:
// use Rcpp::as to make Xeigen take the value of X
}
On Tue, Aug 7, 2012 at 2:34 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> Also note that "just" getting random numbers is taken care of via Rcpp
> sugar
> which wraps rnorm() etc:
>
> R> library(inline)
> R>
> R> R> f <- cxxfunction(signature(), plugin="Rcpp", body='
> + Rcpp::RNGScope tmp;
> + return rnorm(3);
> + ')
> R>
> R> set.seed(42)
> R> rnorm(3) ## using R
> [1] 1.370958 -0.564698 0.363128
> R> set.seed(42)
> R> f() ## using the Rcpp function just created
> [1] 1.370958 -0.564698 0.363128
> R>
>
> Same RNG draws, as we deal properly with the RNG state (where RNGScope
> helps). Look at the list archives, this has been discussed a few times if
> it seems too "magic".
>
> Dirk
>
>
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120807/1dae211c/attachment.html>
More information about the Rcpp-devel
mailing list