matrix: add elementwise abs

This commit is contained in:
Danny Robson 2016-08-15 18:44:27 +10:00
parent 277dfaafae
commit 2daa70bae0
2 changed files with 12 additions and 0 deletions

View File

@ -99,6 +99,10 @@ namespace util {
matrix<S,T>
inverse (const matrix<S,T>&);
template <size_t S, typename T>
matrix<S,T>
abs (const matrix<S,T>&);
template <typename T> using matrix3 = matrix<3,T>;
template <typename T> using matrix4 = matrix<4,T>;

View File

@ -106,6 +106,14 @@ util::matrix<S,T>::cast (void) const
}
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
util::matrix<S,T>
util::abs (const util::matrix<S,T> &src)
{
util::matrix<S,T> dst;
std::transform (std::cbegin (src), std::cend (src), std::begin (dst), util::abs<T>);
return dst;
}