From e6115eb234ee63b5eec3e2857251d01e4cb5f0fd Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 21 Dec 2016 20:22:56 +1100 Subject: [PATCH] point: use vector operations for distance functions --- point.ipp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/point.ipp b/point.ipp index 2635686b..d3fab7db 100644 --- a/point.ipp +++ b/point.ipp @@ -74,12 +74,7 @@ template constexpr typename std::common_type::type util::distance2 (point a, point b) { - typename std::common_type::type sum {0}; - - for (size_t i = 0; i < S; ++i) - sum += pow2 (a.data[i] - b.data[i]); - - return sum; + return sum (pow2 (a - b)); } @@ -112,12 +107,7 @@ template constexpr typename std::common_type::type util::manhattan (point a, point b) { - typename std::common_type::type sum {0}; - - for (size_t i = 0; i < S; ++i) - sum += util::abs (a.data[i] - b.data[i]); - - return sum; + return sum (abs (a - b)); }