[Rcpp-devel] Rcpp syntactic sugar equivalent for R's optimize() function
Hideyoshi Maeda
hideyoshi.maeda at gmail.com
Fri Feb 28 09:17:49 CET 2014
I have just noticed that optimize() is already a C function, as is suggested below:
> stats::optimize
function (f, interval, ..., lower = min(interval), upper = max(interval),
maximum = FALSE, tol = .Machine$double.eps^0.25)
{
if (maximum) {
val <- .External2(C_do_fmin, function(arg) -f(arg, ...),
lower, upper, tol)
list(maximum = val, objective = f(val, ...))
}
else {
val <- .External2(C_do_fmin, function(arg) f(arg, ...),
lower, upper, tol)
list(minimum = val, objective = f(val, ...))
}
}
<bytecode: 0x7f943c4c2e00>
<environment: namespace:stats>
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?)
On 27 Feb 2014, at 20:02, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> Last time I neeed a 1-d solver, I just quicky coded one up, based on another
> implementation of Brent's method. That was a one-off and at work, but it
> really isn't that involved.
>
> Otherwise, please do look around at CRAN. There are now 176 packages using
> Rcpp, and quite a few use, or implement, optimization approaches. You just
> find something to work off.
>
> Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list