-
Notifications
You must be signed in to change notification settings - Fork 3
/
emd_dst.pyx
12 lines (11 loc) · 1.68 KB
/
emd_dst.pyx
1
2
3
4
5
6
7
8
9
10
11
12
cimport cython
from libc.math cimport sqrt
@cython.boundscheck(False)
cpdef float dist_for_emd(a1, a2, theta):
return sqrt(theta[0]*(a1[0] - a2[0])*(a1[0] - a2[0]) + theta[1]*(a1[1] - a2[1])*(a1[1] - a2[1]) + theta[2]*(a1[2] - a2[2])*(a1[2] - a2[2]) + theta[3]*(a1[3] - a2[3])*(a1[3] - a2[3]) + theta[4]*(a1[4] - a2[4])*(a1[4] - a2[4]) + theta[5]*(a1[5] - a2[5])*(a1[5] - a2[5]) + theta[6]*(a1[6] - a2[6])*(a1[6] - a2[6]) + theta[7]*(a1[7] - a2[7])*(a1[7] - a2[7]) + theta[8]*(a1[8] - a2[8])*(a1[8] - a2[8]) + theta[9]*(a1[9] - a2[9])*(a1[9] - a2[9]) + theta[10]*(a1[10] - a2[10])*(a1[10] - a2[10]) + theta[11]*(a1[11] - a2[11])*(a1[11] - a2[11]) + theta[12]*(a1[12] - a2[12])*(a1[12] - a2[12]) + theta[13]*(a1[13] - a2[13])*(a1[13] - a2[13]) + theta[14]*(a1[14] - a2[14])*(a1[14] - a2[14]) + theta[15]*(a1[15] - a2[15])*(a1[15] - a2[15]) + theta[16]*(a1[16] - a2[16])*(a1[16] - a2[16]) + theta[17]*(a1[17] - a2[17])*(a1[17] - a2[17]) + theta[18]*(a1[18] - a2[18])*(a1[18] - a2[18]) + theta[19]*(a1[19] - a2[19])*(a1[19] - a2[19]) + theta[20]*(a1[20] - a2[20])*(a1[20] - a2[20]) + theta[21]*(a1[21] - a2[21])*(a1[21] - a2[21]) + theta[22]*(a1[22] - a2[22])*(a1[22] - a2[22]) + theta[23]*(a1[23] - a2[23])*(a1[23] - a2[23]) + theta[24]*(a1[24] - a2[24])*(a1[24] - a2[24]) + theta[25]*(a1[25] - a2[25])*(a1[25] - a2[25]) + theta[26]*(a1[26] - a2[26])*(a1[26] - a2[26]) + theta[27]*(a1[27] - a2[27])*(a1[27] - a2[27]) + theta[28]*(a1[28] - a2[28])*(a1[28] - a2[28]) + theta[29]*(a1[29] - a2[29])*(a1[29] - a2[29]) + theta[30]*(a1[30] - a2[30])*(a1[30] - a2[30]))
# cdef int i
# cdef float s
# s = 0.0
# for i in range(len(a1)):
# s += theta[i]*(a1[i] - a2[i])*(a1[i] - a2[i])
# return s