Skip to content

Commit 362a7f8

Browse files
committed
Added RT as a contributor + "optimized" Cython math operations
1 parent c92e595 commit 362a7f8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ The contributors to this library are:
167167
* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home)
168168
* [Vayer Titouan](https://tvayer.github.io/)
169169
* [Hicham Janati](https://hichamjanati.github.io/) (Unbalanced OT)
170+
* [Romain Tavenard](https://rtavenar.github.io/) (1d Wasserstein)
170171

171172
This toolbox benefit a lot from open source research and we would like to thank the following persons for providing some code (in various languages):
172173

ot/lp/emd_wrap.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ def emd_1d_sorted(np.ndarray[double, ndim=1, mode="c"] u_weights,
156156
cdef int cur_idx = 0
157157
while i < n and j < m:
158158
if metric == 'sqeuclidean':
159-
m_ij = (u[i] - v[j]) ** 2
159+
m_ij = (u[i] - v[j]) * (u[i] - v[j])
160160
elif metric == 'cityblock' or metric == 'euclidean':
161-
m_ij = abs(u[i] - v[j])
161+
m_ij = math.fabs(u[i] - v[j])
162162
elif metric == 'minkowski':
163-
m_ij = math.pow(abs(u[i] - v[j]), p)
163+
m_ij = math.pow(math.fabs(u[i] - v[j]), p)
164164
else:
165165
m_ij = dist(u[i].reshape((1, 1)), v[j].reshape((1, 1)),
166166
metric=metric)[0, 0]

0 commit comments

Comments
 (0)