I'm trying to figure out how to vectorize the following loop:
for i in range(1,size):
if a[i] < a[i-1]:
b[i] = a[i]
else: b[i] = b[i-1]
b is a (large) array of the same size as a. I could use
numpy.where(a[1:]<a[:-1])
to replace the if statement but how do you simultaneously replace the else statement?
vectorizedocs say it the vectorizing function accepts a sequence. Could you rewrite your loop as a generator instead?