coord: add elementwise abs function
This commit is contained in:
parent
882fd9c87a
commit
8e0e65e2b8
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user