From nicola.lunardon at hotmail.it  Thu Apr 16 09:02:01 2015
From: nicola.lunardon at hotmail.it (bstr)
Date: Thu, 16 Apr 2015 00:02:01 -0700 (PDT)
Subject: [Rd] Call R function in C in "optim fashion"
Message-ID: <1429167721769-4705924.post@n4.nabble.com>

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.



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