[Rcpp-devel] Rcpp syntactic sugar equivalent for R's optimize() function
Dirk Eddelbuettel
edd at debian.org
Fri Feb 28 13:14:16 CET 2014
On 28 February 2014 at 11:52, Gregor Kastner wrote:
| Hi Hideyoshi,
|
| > Is there a way I can just call that function in Rcpp rather than having to
| > install new libraries or create my own? (I presume that there is probably a
| > “C_do_fmin.c” file somewhere that I can use?)
|
| This questions has been discussed in this list about a month ago:
|
| http://r.789695.n4.nabble.com/Linking-to-native-routines-in-other-packages-tt4683969.html#none
Not exactly. That question was about calling from another package for which
the calling-registered-functions approach was discussed; Hideyoshi wants to
call a function from an R base package.
That can be done, but can also be tricky because they don't exactly have the
same calling interface:
/* fmin(f, xmin, xmax tol) */
SEXP do_fmin(SEXP call, SEXP op, SEXP args, SEXP rho)
It is a good exercise to work through the call, op, args arguments once :)
In short, this is not trivial. Which is why I chose to quickly reimplement /
rewrite the Brent algorithm in another function for (internal, not
distributed) use as I alluded to in my earlier answer.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list