[Rd] overhead of function calls

2006-11-18 Thread Tamas K Papp
Hi, Profiling shows that 65-70% of the time of my program is spent inside a single function -- this is not surprising, as it is inside an optimize call inside a loop (this is a dynamic programming problem). I would like to speed this up. The function does very little: has a single argument, evalu

Re: [Rd] overhead of function calls

2006-11-18 Thread Gabor Grothendieck
I don't know if this would have an appreciable effect or not but you could also check whether passing the free variables explicitly speeds it up so that they don't have to be looked up each time in the outside environment. On 11/18/06, Tamas K Papp <[EMAIL PROTECTED]> wrote: > Hi, > > Profiling sh

Re: [Rd] overhead of function calls

2006-11-18 Thread Prof Brian Ripley
On Sat, 18 Nov 2006, Tamas K Papp wrote: > Hi, > > Profiling shows that 65-70% of the time of my program is spent inside > a single function -- this is not surprising, as it is inside an > optimize call inside a loop (this is a dynamic programming problem). > I would like to speed this up. > > The

[Rd] array indexes in C

2006-11-18 Thread Tamas K Papp
I am passing (numeric) arrays to a C function, called with .C. To the best of my knowledge, I can do this in R by passing it as a vector (with as.vector) to the .C call. However, it would be useful to access the array as an array inside C, ie not have to calculate how array indices (i,j,k) map to