From 14bbf619311968a39a98fdc3f6667384f5efc230 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 16 Jan 2020 10:19:22 +0100 Subject: Allow ranges of values, not just references --- geom_matching/wasserstein/include/wasserstein.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'geom_matching/wasserstein/include/wasserstein.h') diff --git a/geom_matching/wasserstein/include/wasserstein.h b/geom_matching/wasserstein/include/wasserstein.h index d8d6b2e..5be7691 100644 --- a/geom_matching/wasserstein/include/wasserstein.h +++ b/geom_matching/wasserstein/include/wasserstein.h @@ -106,11 +106,11 @@ namespace ws std::map m1, m2; - for(const auto& pair1 : dgm1) { + for(auto&& pair1 : dgm1) { m1[pair1]++; } - for(const auto& pair2 : dgm2) { + for(auto&& pair2 : dgm2) { m2[pair2]++; } @@ -296,7 +296,7 @@ wasserstein_cost(const PairContainer& A, std::vector x_plus_B, x_minus_B, y_plus_B, y_minus_B; // loop over A, add projections of A-points to corresponding positions // in B-vector - for(auto& pair_A : A) { + for(auto&& pair_A : A) { a_empty = false; RealType x = Traits::get_x(pair_A); RealType y = Traits::get_y(pair_A); @@ -315,7 +315,7 @@ wasserstein_cost(const PairContainer& A, } } // the same for B - for(auto& pair_B : B) { + for(auto&& pair_B : B) { b_empty = false; RealType x = Traits::get_x(pair_B); RealType y = Traits::get_y(pair_B); -- cgit v1.2.3 From 603f369bf32610bb8bfa9187a0d29a2ea6359b9e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 16 Jan 2020 14:10:55 +0100 Subject: Simplify DiagramTraits for pairs. --- geom_matching/wasserstein/include/wasserstein.h | 30 ++++--------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'geom_matching/wasserstein/include/wasserstein.h') diff --git a/geom_matching/wasserstein/include/wasserstein.h b/geom_matching/wasserstein/include/wasserstein.h index 5be7691..2705043 100644 --- a/geom_matching/wasserstein/include/wasserstein.h +++ b/geom_matching/wasserstein/include/wasserstein.h @@ -56,33 +56,11 @@ struct DiagramTraits static RealType get_y(const PointType& p) { return p[1]; } }; -template -struct DiagramTraits> +template +struct DiagramTraits> { - using PointType = std::pair; - using RealType = long double; - using Container = std::vector; - - static RealType get_x(const PointType& p) { return p.first; } - static RealType get_y(const PointType& p) { return p.second; } -}; - -template -struct DiagramTraits> -{ - using PointType = std::pair; - using RealType = double; - using Container = std::vector; - - static RealType get_x(const PointType& p) { return p.first; } - static RealType get_y(const PointType& p) { return p.second; } -}; - -template -struct DiagramTraits> -{ - using PointType = std::pair; - using RealType = float; + using RealType = RealType_; + using PointType = std::pair; using Container = std::vector; static RealType get_x(const PointType& p) { return p.first; } -- cgit v1.2.3 From 65758d72a31a01bd39c55d94ad1ce38f1969083f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 16 Jan 2020 14:12:18 +0100 Subject: Remove unused typedef Container. --- geom_matching/wasserstein/include/wasserstein.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'geom_matching/wasserstein/include/wasserstein.h') diff --git a/geom_matching/wasserstein/include/wasserstein.h b/geom_matching/wasserstein/include/wasserstein.h index 2705043..db6ce11 100644 --- a/geom_matching/wasserstein/include/wasserstein.h +++ b/geom_matching/wasserstein/include/wasserstein.h @@ -48,7 +48,6 @@ namespace hera template().begin())>::type > struct DiagramTraits { - using Container = PairContainer_; using PointType = PointType_; using RealType = typename std::remove_reference< decltype(std::declval()[0]) >::type; @@ -61,7 +60,6 @@ struct DiagramTraits> { using RealType = RealType_; using PointType = std::pair; - using Container = std::vector; static RealType get_x(const PointType& p) { return p.first; } static RealType get_y(const PointType& p) { return p.second; } -- cgit v1.2.3