[Rd] calling optimize/fmin from C code

Hin-Tak Leung hin-tak.leung at cimr.cam.ac.uk
Fri Dec 29 23:20:07 CET 2006


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
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list