I have a numpy array of integers.
I have two other arrays representing the start and length (or it could be start and end) indices into this array that identify sequences of integers that I need to process. The sequences are variable length.
x=numpy.array([2,3,5,7,9,12,15,21,27,101, 250]) #Can have length of millions
starts=numpy.array([2,7]) # Can have lengths of thousands
ends=numpy.array([5,9])
# required output is x[2:5],x[7:9] in flat 1D array
# [5,7,9,12,21,27,101]
I can do this easily with for loops but the application is performance sensitive so I'm looking for a way to do it without Python iteration.
Any help will be gratefully received!
Doug
x[2:5],x[3:9]etc? If so, would be the overlaps be included as many times as they occur?x[2:5] + x[3:9]orx[2:5] + x[5:9]?