Commit fafa738f authored by Davis King's avatar Davis King

Fixed a compile time bug in the pinv() function. It didn't compile

when used on statically sized matrices when they weren't square.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402620
parent e26feaa8
...@@ -2429,7 +2429,7 @@ namespace dlib ...@@ -2429,7 +2429,7 @@ namespace dlib
template < template <
typename EXP typename EXP
> >
inline const typename matrix_exp<EXP>::matrix_type pinv ( inline const matrix<typename EXP::type,EXP::NC,EXP::NR,typename EXP::mem_manager_type> pinv (
const matrix_exp<EXP>& m const matrix_exp<EXP>& m
) )
{ {
......
...@@ -707,13 +707,13 @@ namespace dlib ...@@ -707,13 +707,13 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
const matrix_exp::matrix_type pinv ( const matrix pinv (
const matrix_exp& m const matrix_exp& m
); );
/*! /*!
ensures ensures
- returns the Moore-Penrose pseudoinverse of m. - returns the Moore-Penrose pseudoinverse of m.
- The returned matrix has m.nr() columns and m.nc() rows. - The returned matrix has m.nc() rows and m.nr() columns.
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -910,6 +910,26 @@ namespace ...@@ -910,6 +910,26 @@ namespace
} }
{
matrix<double,5,2> m;
for (long r = 0; r < m.nr(); ++r)
{
for (long c = 0; c < m.nc(); ++c)
{
m(r,c) = r*c;
}
}
m = cos(exp(m));
matrix<double> mi = pinv(m );
DLIB_CASSERT(mi.nr() == m.nc(),"");
DLIB_CASSERT(mi.nc() == m.nr(),"");
DLIB_CASSERT((equal(round_zeros(mi*m,0.000001) , identity_matrix<double,2>())),"");
}
{ {
matrix<double> m(5,2); matrix<double> m(5,2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment