Commit 46072c8c authored by Davis King's avatar Davis King

Added min_point()

parent 6ca45db0
......@@ -157,6 +157,41 @@ namespace dlib
return best_point;
}
// ----------------------------------------------------------------------------------------
template <
typename EXP
>
point min_point (
const matrix_exp<EXP>& m
)
{
DLIB_ASSERT(m.size() > 0,
"\tpoint min_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 <
......
......@@ -1422,6 +1422,19 @@ namespace dlib
returned point is P then it will be the case that: m(P.y(),P.x()) == max(m).
!*/
// ----------------------------------------------------------------------------------------
point min_point (
const matrix_exp& m
);
/*!
requires
- m.size() > 0
ensures
- returns the location of the minimum element of the array, that is, if the
returned point is P then it will be the case that: m(P.y(),P.x()) == min(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