How can I vectorize this code snippet and eliminate this double loop? Even with "only" 1001 elements in a
this takes almost 30s.
a = np.linspace(-.5, .5, 1001)
S = np.zeros((a.size, a.size))
# east, north and tp are np.arrays of equal length
for l, sy in enumerate(a):
for k, sx in enumerate(a):
S[l,k] = np.sum((east*sx + north*sy - tp)**2)