Created
July 17, 2013 05:10
-
-
Save goog/6017837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numba import double | |
from numba.decorators import jit | |
@jit(argtypes=[double[:,:], double[:,:]]) | |
def pairwise_numba(X, D): | |
M = X.shape[0] | |
N = X.shape[1] | |
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] = np.sqrt(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment