From 4f7ef5f49de18cba14e7410e334bac603a8ac305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 18 Feb 2010 12:32:59 +0100 Subject: [PATCH] Estimation DLL, matrix library: added utility for computing A=B' --- mex/sources/estimation/libmat/Matrix.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mex/sources/estimation/libmat/Matrix.hh b/mex/sources/estimation/libmat/Matrix.hh index 657eb4035..fa83c2868 100644 --- a/mex/sources/estimation/libmat/Matrix.hh +++ b/mex/sources/estimation/libmat/Matrix.hh @@ -285,6 +285,17 @@ namespace mat std::swap(M(i,j), M(j,i)); } + //! Computes M2 = M1' (even for rectangular matrices) + template + 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 void