From hin-tak.leung at cimr.cam.ac.uk  Fri Dec 29 23:20:07 2006
From: hin-tak.leung at cimr.cam.ac.uk (Hin-Tak Leung)
Date: Fri, 29 Dec 2006 22:20:07 +0000
Subject: [Rd] calling optimize/fmin from C code
In-Reply-To: <20061228144628.GA4458@pu100877.student.princeton.edu>
References: <20061228144628.GA4458@pu100877.student.princeton.edu>
Message-ID: <45959497.5040604@cimr.cam.ac.uk>

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



[Rd] calling optimize/fmin from C code
Hin-Tak Leung