44import pandas as pd
55import numpy as np
66
7+ import numba
8+
79import tdamapper .utils .metrics as metrics
810
911
12+ @numba .njit (fastmath = True )
1013def euclidean_numpy (a , b ):
1114 return np .sqrt (np .sum ((a - b ) ** 2 ))
1215
1316
17+ @numba .njit (fastmath = True )
1418def euclidean_numpy_linalg (a , b ):
1519 return np .linalg .norm (a - b )
1620
1721
22+ @numba .njit (fastmath = True )
1823def manhattan_numpy (a , b ):
1924 return np .sum (np .abs (a - b ))
2025
2126
27+ @numba .njit (fastmath = True )
2228def manhattan_numpy_linalg (a , b ):
2329 return np .linalg .norm (a - b , ord = 1 )
2430
2531
32+ @numba .njit (fastmath = True )
2633def chebyshev_numpy (a , b ):
2734 return np .max (np .abs (a - b ))
2835
2936
37+ @numba .njit (fastmath = True )
3038def chebyshev_numpy_linalg (a , b ):
3139 return np .linalg .norm (a - b , ord = np .inf )
3240
@@ -37,7 +45,8 @@ def eval_dist(X, d):
3745
3846
3947def run_dist_bench (X , d ):
40- return timeit .timeit (lambda : eval_dist (X , d ), number = 30 )
48+ eval_dist (X , d )
49+ return timeit .timeit (lambda : eval_dist (X , d ), number = 100 )
4150
4251
4352def run_euclidean_bench (X ):
0 commit comments