diff --git a/dlib/matrix/matrix_utilities.h b/dlib/matrix/matrix_utilities.h index ffa922c3b..caec2707d 100644 --- a/dlib/matrix/matrix_utilities.h +++ b/dlib/matrix/matrix_utilities.h @@ -171,6 +171,11 @@ namespace dlib const matrix_exp& m ) { + DLIB_ASSERT(m.size() > 0, + "\ttype max(const matrix_exp& m)" + << "\n\tYou can't ask for the max() of an empty matrix" + << "\n\tm.size(): " << m.size() + ); typedef typename matrix_exp::type type; type val = m(0,0); @@ -195,6 +200,11 @@ namespace dlib const matrix_exp& m ) { + DLIB_ASSERT(m.size() > 0, + "\ttype min(const matrix_exp& m)" + << "\n\tYou can't ask for the min() of an empty matrix" + << "\n\tm.size(): " << m.size() + ); typedef typename matrix_exp::type type; type val = m(0,0); diff --git a/dlib/matrix/matrix_utilities_abstract.h b/dlib/matrix/matrix_utilities_abstract.h index 2763a7c9c..e9e1f80af 100644 --- a/dlib/matrix/matrix_utilities_abstract.h +++ b/dlib/matrix/matrix_utilities_abstract.h @@ -682,6 +682,8 @@ namespace dlib const matrix_exp& m ); /*! + requires + - m.size() > 0 ensures - returns the value of the smallest element of m !*/ @@ -692,6 +694,8 @@ namespace dlib const matrix_exp& m ); /*! + requires + - m.size() > 0 ensures - returns the value of the biggest element of m !*/