matrix: add free 'transposed' function

This commit is contained in:
Danny Robson 2016-09-14 17:46:03 +10:00
parent ff7ce2f1ef
commit a4a08aaa72
2 changed files with 22 additions and 1 deletions

View File

@ -130,7 +130,22 @@ util::matrix<S,T>::inverse (void) const
}
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
matrix<S,T>
util::transposed (const matrix<S,T> &m)
{
util::matrix<S,T> res;
for (size_t y = 0; y < S; ++y)
for (size_t x = 0; x < S; ++x)
res[y][x] = m[x][y];
return res;
}
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
matrix<S,T>
matrix<S,T>::operator* (const matrix<S,T> &rhs) const

View File

@ -137,6 +137,12 @@ namespace util {
matrix<S,T>
inverse (const matrix<S,T>&);
template <size_t S, typename T>
matrix<S,T>
transposed (const matrix<S,T>&);
///////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
matrix<S,T>
abs (const matrix<S,T>&);