diff options
Diffstat (limited to 'ot/lp/EMD_wrapper.cpp')
-rw-r--r-- | ot/lp/EMD_wrapper.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ot/lp/EMD_wrapper.cpp b/ot/lp/EMD_wrapper.cpp index 6bda6a7..c6cbb04 100644 --- a/ot/lp/EMD_wrapper.cpp +++ b/ot/lp/EMD_wrapper.cpp @@ -93,12 +93,14 @@ void EMD_wrap(int n1, int n2, double *X, double *Y, double *D, double *G, } } else { - *cost = net.totalCost(); + *cost = 0; Arc a; di.first(a); for (; a != INVALID; di.next(a)) { int i = di.source(a); int j = di.target(a); - *(G+indI[i]*n2+indJ[j-n]) = net.flow(a); + 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); *(beta + indJ[j-n]) = net.potential(j); } |