mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
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:
parent
e26feaa806
commit
fafa738f61
@ -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
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
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
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user