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
This commit is contained in:
Davis King 2008-10-31 17:19:04 +00:00
parent e26feaa806
commit fafa738f61
3 changed files with 23 additions and 3 deletions

View File

@ -2429,7 +2429,7 @@ namespace dlib
template <
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
)
{

View File

@ -707,13 +707,13 @@ namespace dlib
// ----------------------------------------------------------------------------------------
const matrix_exp::matrix_type pinv (
const matrix pinv (
const matrix_exp& m
);
/*!
ensures
- 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.
!*/
// ----------------------------------------------------------------------------------------

View File

@ -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);