Hi Stephen,

On 7 August 2012 at 10:55, Stephen J. Barr wrote:
| Greetings,
| 
| I am new to Rcpp, RInside and the entire family of related packages. I am
| experienced with R and also C++ using Eigen but I have never combined the two
| before.

You are in a good starting position.

| I would like to create a matrix using R and then play with it using
| Eigen. From what I have read so far, it seems like I can use RInside to create
| an Rcpp::NumericMatrix. 

That works. Even one of the very oldest examples (rinside_sample1.cpp) does
something related with a Rcpp::NumericMatrix (eg creates one and passes it 
around).
 
| My question is this: to transform a matrix from a Rcpp::NumericMatrix to an
| Eigen MatrixXd, do I use RcppEigen? Or is RcppEigen only for calling C++/Eigen
| from R and not the other way around?

I think I have an idea as to what you are asking. I think it may help to step
back for a second and try to imagine the big picture:

a) Rcpp helps us with the interface defined by .Call:

     SEXP .Call(string somefuncname, SEXP arg1, SEXP arg2, ...)

   so everthing going in and out is a SEXP type.

b) RInside lets you interchange with an embedded R process, again talking
   SEXPs.

c) Packages like RcppEigen provide wrappers to and from SEXPs.

So if you don't need a Rcpp::NumericMatrix, don't create one.  Create an
Eigen matrix, and use RcppEigen's wrappers to pass it throught the SEXP
interfaces.  That should work just fine with RInside as well.  

You will have to expand the RInside Makefile to point to the RcppEigen
headers as well, and then it should just work.

Hope this helps,  Dirk

 
| Thanks,
| Stephen 
| 
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| [email protected]
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com  
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to