This is a simplification of my question. I have a numpy array:
x = np.array([0,1,2,3])
and I have a function:
def f(y): return y**2
I can compute f(x).
Now suppose I really want to compute f(x) for a repeated x:
x = np.array([0,1,2,3,0,1,2,3,0,1,2,3])
Is there a way to do this without creating a repeated version of x and in a way that is transparent to f?
In my particular case, f is an involved function and one of the arguments is x. I would like to be able to calculate f when x is repeated without actually repeating it as it wont fit into memory.
Rewriting f to handle repeated x would be work and I was hoping for a clever way possibly to subclass a numpy array to do this.
Any tips appreciated.
(A A A)for some matrixA?