[Rd] Call R function in C in "optim fashion"

bstr nicola.lunardon at hotmail.it
Thu Apr 16 09:02:01 CEST 2015


I am trying to extend an R package which is totally written in C. I have the
following issue: in the C code I want to make a call to an R defined
function as optim routine does. Nevertheless, when I try to trace down the
main steps in optim, I am (more or less) able to follow the steps in the C
source code, but as soon as I try to understand how optim is called from R
(via .External2) I cannot even figure out what is the link between the
arguments passed through .External2 to optim. Specificaly, in
src/library/stats/src/optim.c we have the following

SEXP optim(SEXP call, SEXP op, SEXP args, SEXP rho)

and in src/library/stats/R/optim.R we have that optim is called in this way
(at least this is what I suppose to be the call)

.External2(C_optim, par, fn1, gr1, method, con, lower, upper)

How arguments call, op, args and rho are passed to optim by .External2?





--
View this message in context: http://r.789695.n4.nabble.com/Call-R-function-in-C-in-optim-fashion-tp4705924.html
Sent from the R devel mailing list archive at Nabble.com.



More information about the R-devel mailing list