Skip to content
Back to formatted view

Raw Message

Message-ID: <19775.5040.107659.24030@max.nulle.part>
Date: 2011-01-25T18:17:20Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] passing function
In-Reply-To: <4D3F1017.9020802@wustl.edu>

On 25 January 2011 at 12:01, Siddhartha Chib wrote:
| Is it possible to pass a user defined function
| written in R for use in rccparma.  For example, is it possible to have a

(What is rccparma?)

| function
| SEXP myfunction(SEXP g, SEXP a)
| where g is a function object and a is a
| matrix, the argument of g?

Have you looked at   

     examples/functionCallback/newApiExample.r

which installed with your copy of Rcpp -- it uses Rcpp to sweep a
user-supplied R function over a vector.  Doing this with a matrix is close.

And just for completeness, there is more in other place; my RcppDE riff on
the the DEoptim software allows you to pass objective functions as either R
or C++ functions; the C++ side then needs external pointers.

Hope this helps,  Dirk

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