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 <e...@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 | e...@debian.org | http://dirk.eddelbuettel.com >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel