Fastest way to append a wave to itself for N times
Sandbo
Let's say I have an inputWave with num of row = 100.
Then I want to have an outputWave which is made from 10 of inputWave stacked up together, which is finally of size 1000.
The naive way I am using is by a for-loop and assign it step-wise:
duplicate/o inputWave,outputWave
redimension/N=(LCM) outputWave
variable m
for (m=1;m<N;m=m+1)
outputWave[m*numRow,]=inputWave[p-m*numRow]
endfor
redimension/N=(LCM) outputWave
variable m
for (m=1;m<N;m=m+1)
outputWave[m*numRow,]=inputWave[p-m*numRow]
endfor
while it works, it takes very long when I have to stack it up for an N of order 1000.
I tried to use FastOp but it does not allow assignment with range.
Appreciated if you can give me a hint.
If you want the result as a 1D wave use:
I hope this helps,
A.G.
WaveMetrics, Inc.
April 2, 2018 at 04:21 pm - Permalink
That's a godsend, million times faster I guess.
Just that I am still working with Igor 6 so I separated the redimension command to a second call.
April 3, 2018 at 03:00 pm - Permalink
Moving Redimension outside MatrixOP should not affect performance but you should really consider upgrading.
April 3, 2018 at 03:56 pm - Permalink