[Rcpp-devel] exposing a C++ function to RInside
Stephen J. Barr
stephenjbarr at gmail.com
Sun Aug 19 01:24:23 CEST 2012
On Sat, Aug 18, 2012 at 3:46 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 18 August 2012 at 14:08, Stephen J. Barr wrote:
> | Hello,
> |
> | I have a quick design question. I am working on a program that uses
> RInside and
> | RcppEigen, and I want to expose a function back to R. Specifically, I
> have a
> | C++ function with the following signature:
> |
> | double nll_singleton(
> | const VectorXd& theta,
> | const MatrixXd& ua,
> | const MatrixXd& ub,
> | const MatrixXd& Xmat,
> | const MatrixXd& Ymat);
> |
> | I would like to run R's optim over this function, where 'theta' is the
> vector
> | that I am optimizing over. Would I use RCpp::InternalFunction for this?
>
> Per rinside_sample9.cpp, possibly.
>
> | nll_singleton is going to call MPI and I would rather do it this way
> than use
> | mpi over R, if this is possible.
>
> Right.
>
What I meant was, rather than recode everything in R and use Rmpi.
I guess my question was, say I use RCpp::InternalFunction with
nll_singleton, can I just pass in a vector and a few matrices like:
>R.parseEval("nll_singleton(c(1,2,3), matrix(1:10, nrow=3), ...etc..")
?
I would think that I would have to define some mapping back to the Eigen
matrices.
Thanks,
Stephen
> Doug Bates and have both (and indepdently) used Rcpp::XPtr to pass function
> pointers around to C-level optimisation functions. My use case in my
> "port"
> of DEoption to Rcpp, ie in RcppDE.
>
> Good luck, 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/20120818/68c64abf/attachment.html>
More information about the Rcpp-devel
mailing list