I have a symmetric NumPy matrix D of non-negative floating point numbers. A number in the ith row and jth column represents the distance between objects i and j, whatever they are. The matrix is large (~10,000 rows/columns). I would like to check if all the distances in the matrix obey the triangle inequality, that is: D[i,j]<=D[i,k]+D[k,j] for all i, j, k.
The problem can be solved, quite inefficiently, by using a triple-nested loop. But is there a faster, vectorized solution?