summaryrefslogtreecommitdiff
path: root/ot/lp
diff options
context:
space:
mode:
authorarolet <antoine.rolet@gmail.com>2017-07-21 13:34:09 +0900
committerarolet <antoine.rolet@gmail.com>2017-07-21 13:34:09 +0900
commitc1980a414c879dd1bc1d8904fd43426326741385 (patch)
tree2513d6ed5ee49d351652e0f989d83cb8298e72fa /ot/lp
parentdb2a70b1f5146d6374af57f4bea66ab95b202e77 (diff)
Added and passed tests for dual variables
Diffstat (limited to 'ot/lp')
-rw-r--r--ot/lp/EMD_wrapper.cpp2
-rw-r--r--ot/lp/emd_wrap.pyx4
2 files changed, 3 insertions, 3 deletions
diff --git a/ot/lp/EMD_wrapper.cpp b/ot/lp/EMD_wrapper.cpp
index c6cbb04..0977e75 100644
--- a/ot/lp/EMD_wrapper.cpp
+++ b/ot/lp/EMD_wrapper.cpp
@@ -101,7 +101,7 @@ void EMD_wrap(int n1, int n2, double *X, double *Y, double *D, double *G,
double flow = net.flow(a);
*cost += flow * (*(D+indI[i]*n2+indJ[j-n]));
*(G+indI[i]*n2+indJ[j-n]) = flow;
- *(alpha + indI[i]) = net.potential(i);
+ *(alpha + indI[i]) = -net.potential(i);
*(beta + indJ[j-n]) = net.potential(j);
}
diff --git a/ot/lp/emd_wrap.pyx b/ot/lp/emd_wrap.pyx
index 813596f..435a270 100644
--- a/ot/lp/emd_wrap.pyx
+++ b/ot/lp/emd_wrap.pyx
@@ -57,7 +57,7 @@ def emd_c( np.ndarray[double, ndim=1, mode="c"] a,np.ndarray[double, ndim=1, mod
cdef int n1= M.shape[0]
cdef int n2= M.shape[1]
- cdef float cost=0
+ cdef double cost=0
cdef np.ndarray[double, ndim=2, mode="c"] G=np.zeros([n1, n2])
cdef np.ndarray[double, ndim=1, mode="c"] alpha=np.zeros(n1)
cdef np.ndarray[double, ndim=1, mode="c"] beta=np.zeros(n2)
@@ -116,7 +116,7 @@ def emd2_c( np.ndarray[double, ndim=1, mode="c"] a,np.ndarray[double, ndim=1, mo
cdef int n1= M.shape[0]
cdef int n2= M.shape[1]
- cdef float cost=0
+ cdef double cost=0
cdef np.ndarray[double, ndim=2, mode="c"] G=np.zeros([n1, n2])
cdef np.ndarray[double, ndim = 1, mode = "c"] alpha = np.zeros([n1])