Halving the size of a 2D wave: different speed options
Fri, 05/08/2020 - 08:35 am
I am developing code in which I have to repetitively and quickly extract half a 2D wave's data, i.e. extract the first half of the columns from a DP N=(501,400) 'wave0' into an N=(501,200) 'wave1'. I want to retain the full original wave, so reducing its size is not a good option and I don't want to duplicate a copy first.
The most obvious and concise method is simply to use
where the 'q' index from the small wave goes from 0-199. The tested execution time on my Intel laptop with IP8 (64bit) is 3372 microsecond/iteration. The next easiest improvement is to try MultiThread
This reduced the execution time to 1485 microseconds. Finally, I found that the 'redimension' option for MatrixOP does not truncate the source wave.
This was by far the fastest method, taking 146 microseconds. [All times are subject to many microseconds fluctuation.]
I wanted to bring this to Igor Pro's users attention to reinforce the old point that the most concise code is not always fastest, and to solicit other suggestions.