Commit 6ca45db0 authored by Davis King's avatar Davis King

Added max_point()

parent 4f2a07f5
......@@ -122,6 +122,41 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
template <
typename EXP
>
point max_point (
const matrix_exp<EXP>& m
)
{
DLIB_ASSERT(m.size() > 0,
"\tpoint max_point(const matrix_exp& m)"
<< "\n\tm can't be empty"
<< "\n\tm.size(): " << m.size()
<< "\n\tm.nr(): " << m.nr()
<< "\n\tm.nc(): " << m.nc()
);
typedef typename matrix_exp<EXP>::type type;
point best_point(0,0);
type val = m(0,0);
for (long r = 0; r < m.nr(); ++r)
{
for (long c = 0; c < m.nc(); ++c)
{
type temp = m(r,c);
if (dlib::impl::magnitude(temp) > dlib::impl::magnitude(val))
{
val = temp;
best_point = point(c,r);
}
}
}
return best_point;
}
// ----------------------------------------------------------------------------------------
template <
......
......@@ -1409,6 +1409,19 @@ namespace dlib
(i.e. m(index_of_min(m)) == min(m))
!*/
// ----------------------------------------------------------------------------------------
point max_point (
const matrix_exp& m
);
/*!
requires
- m.size() > 0
ensures
- returns the location of the maximum element of the array, that is, if the
returned point is P then it will be the case that: m(P.y(),P.x()) == max(m).
!*/
// ----------------------------------------------------------------------------------------
const matrix_exp::type sum (
......
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