[Rcpp-devel] clarification of interaction between RInside and RcppEigen

Dirk Eddelbuettel edd at debian.org
Tue Aug 7 23:56:34 CEST 2012


On 7 August 2012 at 14:43, Stephen J. Barr wrote:
| 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()");

You need something like we use in the example rinside_sample1.cpp I already
pointed you too:

    Rcpp::NumericVector v = R.parseEval(str);   // eval string, Z then assigned to num. vec              

as you need __assign__ the result of the parseEval() to something.

This could be as generic as

    SEXP mytmp = R.parseEval("X = generateSomeMatrix()");

and you can then use mytmp instantiate an RcppEigen object as you would have
if the object had been passed down from R.

Hth, Dirk

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


More information about the Rcpp-devel mailing list