Computational Thinking, Linear Algebra, Linear Regression, Python, Jupyter Notebook.
cdef int M = X.shape[0] cdef int N = X.shape[1] cdef double tmp, d for i in range(M): for j in range(M): d = 0.0 for k in range(N): tmp = X[i, k] - X[j, k] d += tmp * tmp D[i, j] = sqrt(d) Running this shows about a 30% speedup over numba: X = np.random.random((1000, 3)) D = np.empty((1000, 1000))