I've created a 2D mesh grid w = np.meshgrid(x,y) which I'm trying to input into the following function:
def f(w):
eigs = np.linalg.eigvals(A0 + w[0]*A1 + w[1]*A2)
return abs(eigs[0] - eigs[-1])
where A0,A1,A2 are square arrays. But I'm getting an error which tells me that the operands cannot be broadcast together. Basically what's happening is that the w[0]*A1 is not vectorized and so w[0] is the entire block of x-values of the mesh instead of each individual x-value, same thing for w[1]*A2 but with the y-values.
I've tried doing np.vectorize(func) but that doesn't work and I get an IndexError.