Skip to content

Instantly share code, notes, and snippets.

@goog
Created July 17, 2013 05:10
Show Gist options
  • Save goog/6017837 to your computer and use it in GitHub Desktop.
Save goog/6017837 to your computer and use it in GitHub Desktop.
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