Estimation DLL, matrix library: added utility for computing A=B'

time-shift
Sébastien Villemot 2010-02-18 12:32:59 +01:00
parent b737535955
commit 4f7ef5f49d
1 changed files with 11 additions and 0 deletions

View File

@ -285,6 +285,17 @@ namespace mat
std::swap(M(i,j), M(j,i));
}
//! Computes M2 = M1' (even for rectangular matrices)
template<class Mat1, class Mat2>
inline void
transpose(Mat1 &M1, Mat2 &M2)
{
assert(M1.getRows() == M2.getCols() && M1.getCols() == M2.getRows());
for (size_t i = 0; i < M1.getRows(); i++)
for (size_t j = 0; j < M1.getCols(); j++)
M2(j, i) = M1(i, j);
}
//! Computes m1 = m1 + m2
template<class Mat1, class Mat2>
void