Made the matrix length() routine work with integer valued matricies when used

in visual studio.
This commit is contained in:
Davis King 2012-09-03 14:02:10 -04:00
parent 67ac182f26
commit 8e537c9772
1 changed files with 19 additions and 2 deletions

View File

@ -230,7 +230,24 @@ namespace dlib
template <
typename EXP
>
const typename matrix_exp<EXP>::type length (
typename enable_if_c<std::numeric_limits<typename EXP::type>::is_integer, double>::type length (
const matrix_exp<EXP>& m
)
{
DLIB_ASSERT(is_vector(m) == true,
"\ttype length(const matrix_exp& m)"
<< "\n\tm must be a row or column vector"
<< "\n\tm.nr(): " << m.nr()
<< "\n\tm.nc(): " << m.nc()
);
return std::sqrt(static_cast<double>(sum(squared(m))));
}
template <
typename EXP
>
typename disable_if_c<std::numeric_limits<typename EXP::type>::is_integer, const typename EXP::type>::type length (
const matrix_exp<EXP>& m
)
{
@ -242,7 +259,7 @@ namespace dlib
);
return std::sqrt(sum(squared(m)));
}
// ----------------------------------------------------------------------------------------
template <