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 <e...@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 | e...@debian.org | http://dirk.eddelbuettel.com

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to