Re: [Rd] An example of very slow computation

2011-09-01 Thread Martin Maechler
. Ravi. From: peter dalgaard [pda...@gmail.com] Sent: Thursday, August 18, 2011 6:37 PM To: Ravi Varadhan Cc: 'cbe...@tajo.ucsd.edu'; r-de...@stat.math.ethz.ch; 'nas...@uottawa.ca' Subject: Re: [Rd] An example of very slow computation

Re: [Rd] An example of very slow computation

2011-08-18 Thread peter dalgaard
: Wednesday, August 17, 2011 2:33 PM To: 'cbe...@tajo.ucsd.edu'; r-de...@stat.math.ethz.ch; 'nas...@uottawa.ca' Subject: Re: [Rd] An example of very slow computation Yes, the culprit is the evaluation of expm(A*t). This is a lazy way of solving the system of ODEs, where you save analytic

Re: [Rd] An example of very slow computation

2011-08-18 Thread Ravi Varadhan
Varadhan Cc: 'cbe...@tajo.ucsd.edu'; r-de...@stat.math.ethz.ch; 'nas...@uottawa.ca' Subject: Re: [Rd] An example of very slow computation On Aug 17, 2011, at 23:24 , Ravi Varadhan wrote: A principled way to solve this system of ODEs is to use the idea of fundamental matrix, which is the same

Re: [Rd] An example of very slow computation

2011-08-18 Thread Michael Lachmann
] On Behalf Of Ravi Varadhan Sent: Wednesday, August 17, 2011 2:33 PM To: 'cbe...@tajo.ucsd.edu'; r-de...@stat.math.ethz.ch; 'nas...@uottawa.ca' Subject: Re: [Rd] An example of very slow computation Yes, the culprit is the evaluation of expm(A*t). This is a lazy way of solving the system of ODEs

[Rd] An example of very slow computation

2011-08-17 Thread John C Nash
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but a bit turned out to be a factor of 1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our

Re: [Rd] An example of very slow computation

2011-08-17 Thread Michael Lachmann
I think one difference is that negll() is fully vectorized - no loops, whereas nlogL calls the function sol() inside sapply, i.e. a loop. Michael On 17 Aug 2011, at 10:27AM, John C Nash wrote: This message is about a curious difference in timing between two ways of computing the same

Re: [Rd] An example of very slow computation

2011-08-17 Thread cberry
John C Nash nas...@uottawa.ca writes: This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but a bit turned out to be a factor of 1000. The code is below. We would be grateful if anyone can

Re: [Rd] An example of very slow computation

2011-08-17 Thread Ravi Varadhan
- From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of cbe...@tajo.ucsd.edu Sent: Wednesday, August 17, 2011 1:08 PM To: r-de...@stat.math.ethz.ch Subject: Re: [Rd] An example of very slow computation John C Nash nas...@uottawa.ca writes: This message is about

Re: [Rd] An example of very slow computation

2011-08-17 Thread Ravi Varadhan
-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of Ravi Varadhan Sent: Wednesday, August 17, 2011 2:33 PM To: 'cbe...@tajo.ucsd.edu'; r-de...@stat.math.ethz.ch; 'nas...@uottawa.ca' Subject: Re: [Rd] An example of very slow computation Yes, the culprit is the evaluation

Re: [Rd] An example of very slow computation

2011-08-17 Thread Michael Lachmann
On 17 Aug 2011, at 7:08PM, cbe...@tajo.ucsd.edu cbe...@tajo.ucsd.edu wrote: John C Nash nas...@uottawa.ca writes: This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but a bit turned out

Re: [Rd] An example of very slow computation

2011-08-17 Thread Michael Lachmann
Just a small addition: If you replace below sol-function(t)100-sum(expm(A*t)%*%x0) by sol-function(t){A@x=A@x*t;100-sum(expm(A)@x * x0)} (ugly! But avoiding the conversions and generics) The time on my machine drop further down to 0.3 seconds. (from the original 13 seconds, and then from the