PYTHON
How can I compute the Euclidean distance matrix using only one for-loop. Note: only make use of Numpy, not other packages.
Thank you in advance.
This is my code using two for-loops:
m = 10
X = np.random.randint(10, size =(m,m))
D = np.zeros((m,m), dtype = int)
for i in range(0, m):
for j in range(0, m):
v = X[i,:] - X[j,:]
D[i][j] = np.linalg.norm(v)
D