I have a 2D numpy array S representing a state space, with 80000000 rows (as states) and 5 columns (as state variables).
I initialize K0 with S, and at each iteration, I apply a state transition function f(x) on all of the states in Ki, and delete states whose f(x) is not in Ki, resulting Ki+1. Until it converges i.e. Ki+1 = Ki.
Going like this would take ages:
K = S
to_delete = [0]
While to_delete:
to_delete = []
for i in xrange(len(K)):
if not f(i) in K:
to_delete.append(K(i))
K = delete(K,to_delete,0)
So I wanted to make a vectorized implementation :
slice K in columns, apply f and, join them once again, thus obtaining f(K) somehow.
The question now is how to get an array of length len(K), say Sel, where each row Sel[i] determine whether f(K[i]) is in K. Exactly like the function in1d works.
Then it would be simple to make
K=K[Sel]]