Re: [Rd] calling optimize/fmin from C code

From: Hin-Tak Leung <>
Date: Fri 29 Dec 2006 - 22:20:07 GMT

To find out what those parameters are, I would suggest "May the Source be with you".

What's I like to point out though, is that in R, sometimes it is the loop construct which is slow; and also the slower part may not be where you think it is. I would suggest looking into (1) moving the whole loop into C, (2) replace explicit loops with mapply/tapply/sapply , (3) run Rprof() to learn which part of your code is the slowest - it might not be where you think it is.

Good luck.

Hin-Tak Leung

Tamas K Papp wrote:
> Hi,
> To make a calculation (an innermost loop) that uses optimize faster, I
> think I should write things in C. Is it possible to call fmin, which
> is called by optimize, from C? It is not listed in Writing R
> extensions, but I found
> double Brent_fmin(double ax, double bx, double (*f)(double, void *),
> void *info, double tol);
> in Applic.h. Is this the function I am looking for?
> My guess is that ax and bx are the endpoints, f is the function, but
> what is it's second argument (void *)? What is *info?
> Or is it some other function altogether?
> Thanks,
> Tamas
> ______________________________________________
> mailing list
> mailing list Received on Sat Dec 30 09:24:08 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 31 Dec 2006 - 01:30:58 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.