Created
August 15, 2012 18:59
-
-
Save alexbw/3362603 to your computer and use it in GitHub Desktop.
Numba code for comparison against http://jakevdp.github.com/blog/2012/08/08/memoryview-benchmarks/
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
from numba.decorators import jit as jit | |
@jit(arg_types=[[['d']], [['d']]], ret_type=[['d']]) | |
def pairwise_numba(X, output): | |
n_samples, n_dim = X.shape | |
n_samples1, n_samples2 = output.shape | |
for ii in range(n_samples): | |
for jj in range(n_samples): | |
result = 0.0; | |
for kk in range(n_dim): | |
result += (X[ii,kk] - X[jj,kk]) * (X[ii,kk] - X[jj,kk]) | |
output[ii,jj] = result | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just out of curiosity: why do you "import jit as jit"?