From 8e0e65e2b85480d344a25989873606ef686a06c4 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 29 May 2015 15:51:08 +1000 Subject: [PATCH] coord: add elementwise abs function --- coord/ops.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/coord/ops.hpp b/coord/ops.hpp index 39ddcb92..080b95f9 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -19,6 +19,7 @@ #include "../preprocessor.hpp" #include "../maths.hpp" +#include "../types/bits.hpp" #include @@ -228,7 +229,7 @@ namespace util { template < size_t S, typename T, - template class A, + template class A, template class B > T dot (A a, B b) @@ -239,6 +240,21 @@ namespace util { return sum; } + //------------------------------------------------------------------------- + template < + size_t S, + typename T, + template class K + > + K + abs (K k) + { + for (auto &v: k) + v = std::abs (v); + return k; + } + + /////////////////////////////////////////////////////////////////////////// // logical element operators