coord: add elementwise abs function

This commit is contained in:
Danny Robson 2015-05-29 15:51:08 +10:00
parent 882fd9c87a
commit 8e0e65e2b8

View File

@ -19,6 +19,7 @@
#include "../preprocessor.hpp"
#include "../maths.hpp"
#include "../types/bits.hpp"
#include <cstdlib>
@ -228,7 +229,7 @@ namespace util {
template <
size_t S,
typename T,
template<size_t,typename> class A,
template <size_t,typename> class A,
template <size_t,typename> class B
>
T dot (A<S,T> a, B<S,T> b)
@ -239,6 +240,21 @@ namespace util {
return sum;
}
//-------------------------------------------------------------------------
template <
size_t S,
typename T,
template <size_t,typename> class K
>
K<S,T>
abs (K<S,T> k)
{
for (auto &v: k)
v = std::abs (v);
return k;
}
///////////////////////////////////////////////////////////////////////////
// logical element operators