Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread S Ellison
I am using a sum of squared differences in the objective function of an optimization problem I am doing and I have managed to speed it up using the outer function versus the nested for loops, but my suspicion is that the calculation could be done even quicker. Please see the code below for a

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread S Ellison
Conclusion: hard to beat outer() for this purpose in R ... unless you use Ken Knoblauch's suggestion of dist() or Rccp. Nice indeed. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}}

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Kenneth Knoblauch
Actually, you don't need to use c() in the dist example, either, which should shave off a few microseconds for a function call. It was late last night ... Ken On 22-10-2013 15:08, S Ellison wrote: Conclusion: hard to beat outer() for this purpose in R ... unless you use Ken Knoblauch's

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Bos, Roger
Cc: r-help@r-project.org Subject: Re: [R] speeding up sum of squared differences calculation Actually, you don't need to use c() in the dist example, either, which should shave off a few microseconds for a function call. It was late last night ... Ken On 22-10-2013 15:08, S Ellison wrote

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Hadley Wickham
There's little practical difference; both hover from 0.00 to 0.03 s system time. I could barely tell the difference even averaged over 100 runs; I was getting an average around 0.007 (system time) and 2.5s user time for both methods. It's almost always better to use a high precision timer,

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread William Dunlap
wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of S Ellison Sent: Tuesday, October 22, 2013 6:08 AM To: r-help@r-project.org Cc: Ken Knoblauch Subject: Re: [R] speeding up sum of squared differences calculation

[R] speeding up sum of squared differences calculation

2013-10-21 Thread Bos, Roger
All, I am using a sum of squared differences in the objective function of an optimization problem I am doing and I have managed to speed it up using the outer function versus the nested for loops, but my suspicion is that the calculation could be done even quicker. Please see the code below