Re: For loop avoidance - getting indices of real space [message #81451 is a reply to message #81226] |
Fri, 21 September 2012 13:06  |
simulana
Messages: 15 Registered: August 2012
|
Junior Member |
|
|
On Tuesday, August 28, 2012 5:41:29 PM UTC-4, JDS wrote:
> On Thursday, August 23, 2012 4:58:48 PM UTC-4, simu...@gmail.com wrote:
>
>> I have read and re-read until cross-eyed this post: http://www.idlcoyote.com/tips/forloops.html
>
>
>
> Just for the record, that particular post was made almost entirely in jest: sometimes a for loop is indeed what you want.
>
>
>
> JD
*Almost* entirely you say, but in my case entirely accurate. I reduced the runtime of my code from 10 minutes to 2 minutes by using the above arrays to find my indices instead of for loops, which seems significant to me, considering I need to run it over and over again. I was getting really bored.
In general I find that it's easy to loose focus on a problem if your runtime is approximately between 4 min - 2 hours. You feel like it's too short of a time to switch focus to another project and be productive at all. So, yay for code optimization.
In response to Yngvar:
I also had the problem that I had to add a constant value to each i,j,k specified by another array xBounds that gives the lower left corner of each grid. Since I was basically concatenating all the data from each grid, I could figure out how to add this lower left corner value to each data point before the reform.
|
|
|