Re: [Rd] An example of very slow computation

2011-09-01 Thread Martin Maechler
>>> Ravi Varadhan, Ph.D. >>> Assistant Professor, >>> Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University >>> >>> Ph. (410) 502-2619 >>> email: rvarad

Re: [Rd] An example of very slow computation

2011-08-18 Thread Michael Lachmann
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

Re: [Rd] An example of very slow computation

2011-08-18 Thread Ravi Varadhan
: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 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

Re: [Rd] An example of very slow computation

2011-08-18 Thread peter dalgaard
cine Johns > Hopkins University > > Ph. (410) 502-2619 > email: rvarad...@jhmi.edu > > > -Original Message- > From: r-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

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 th

Re: [Rd] An example of very slow computation

2011-08-17 Thread Michael Lachmann
On 17 Aug 2011, at 7:08PM, wrote: > John C Nash 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. > > Looks like A

Re: [Rd] An example of very slow computation

2011-08-17 Thread Ravi Varadhan
619 email: rvarad...@jhmi.edu -Original Message- From: r-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' Subje

Re: [Rd] An example of very slow computation

2011-08-17 Thread Ravi Varadhan
al Message- 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 writes: > This message is ab

Re: [Rd] An example of very slow computation

2011-08-17 Thread cberry
John C Nash 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 > point ou

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 fun

[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 ou