summaryrefslogtreecommitdiff
path: root/geom_matching/wasserstein/src/wasserstein.cpp
diff options
context:
space:
mode:
authorArnur Nigmetov <a.nigmetov@gmail.com>2017-04-24 16:49:37 +0600
committerArnur Nigmetov <a.nigmetov@gmail.com>2017-04-24 16:49:37 +0600
commitbd3300343726981dbb7b7f45d1cabc9d781e28a1 (patch)
tree1ea381d8265df271fb4215f75ae8b301253d2c18 /geom_matching/wasserstein/src/wasserstein.cpp
parent0d3a01257675ee637c09046c739eaa235984b515 (diff)
Empty diagram bug for Wasserstein fixed
Diffstat (limited to 'geom_matching/wasserstein/src/wasserstein.cpp')
-rw-r--r--geom_matching/wasserstein/src/wasserstein.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/geom_matching/wasserstein/src/wasserstein.cpp b/geom_matching/wasserstein/src/wasserstein.cpp
index 8776b5f..b8a75ef 100644
--- a/geom_matching/wasserstein/src/wasserstein.cpp
+++ b/geom_matching/wasserstein/src/wasserstein.cpp
@@ -74,6 +74,25 @@ double wassersteinDistVec(const std::vector<DiagramPoint>& A,
throw std::runtime_error("Bad epsilon factor in Wasserstein " + std::to_string(_epsFactor));
}
+ if (A.empty() && B.empty())
+ return 0.0;
+
+ if (A.empty()) {
+ double result { 0.0 } ;
+ for(const auto& pt : B) {
+ result += pt.persistenceLp(_internal_p);
+ }
+ return result;
+ }
+
+ if (B.empty()) {
+ double result { 0.0 } ;
+ for(const auto& pt : A) {
+ result += pt.persistenceLp(_internal_p);
+ }
+ return result;
+ }
+
#ifdef GAUSS_SEIDEL_AUCTION
AuctionRunnerGS auction(A, B, q, delta, _internal_p, _initialEpsilon, _epsFactor);