Commit f97644f3 authored by Davis King's avatar Davis King

Added some missing requirements to a few functions.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402905
parent 43354beb
...@@ -82,7 +82,7 @@ namespace dlib ...@@ -82,7 +82,7 @@ namespace dlib
long nc long nc
) )
{ {
DLIB_ASSERT(r >= 0 && c >= 0 && r+nr <= m.nr() && c+nc <= m.nc(), DLIB_ASSERT(r >= 0 && c >= 0 && nr >= 0 && nc >= 0 && r+nr <= m.nr() && c+nc <= m.nc(),
"\tconst matrix_exp subm(const matrix_exp& m, r, c, nr, nc)" "\tconst matrix_exp subm(const matrix_exp& m, r, c, nr, nc)"
<< "\n\tYou have specified invalid sub matrix dimensions" << "\n\tYou have specified invalid sub matrix dimensions"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -554,7 +554,7 @@ namespace dlib ...@@ -554,7 +554,7 @@ namespace dlib
long nc long nc
) )
{ {
DLIB_ASSERT(r >= 0 && c >= 0 && r+nr <= m.nr() && c+nc <= m.nc(), DLIB_ASSERT(r >= 0 && c >= 0 && nr >= 0 && nc >= 0 && r+nr <= m.nr() && c+nc <= m.nc(),
"\tassignable_matrix_expression set_subm(matrix& m, r, c, nr, nc)" "\tassignable_matrix_expression set_subm(matrix& m, r, c, nr, nc)"
<< "\n\tYou have specified invalid sub matrix dimensions" << "\n\tYou have specified invalid sub matrix dimensions"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
......
...@@ -104,8 +104,10 @@ namespace dlib ...@@ -104,8 +104,10 @@ namespace dlib
/*! /*!
requires requires
- row >= 0 - row >= 0
- row + nr <= m.nr()
- col >= 0 - col >= 0
- nr >= 0
- nc >= 0
- row + nr <= m.nr()
- col + nc <= m.nc() - col + nc <= m.nc()
ensures ensures
- returns a matrix R such that: - returns a matrix R such that:
...@@ -259,8 +261,10 @@ namespace dlib ...@@ -259,8 +261,10 @@ namespace dlib
/*! /*!
requires requires
- row >= 0 - row >= 0
- row + nr <= m.nr()
- col >= 0 - col >= 0
- nr >= 0
- nc >= 0
- row + nr <= m.nr()
- col + nc <= m.nc() - col + nc <= m.nc()
ensures ensures
- statements of the following form: - statements of the following form:
......
...@@ -416,10 +416,10 @@ namespace dlib ...@@ -416,10 +416,10 @@ namespace dlib
) )
{ {
// you can't remove a row from a matrix with only one row // you can't remove a row from a matrix with only one row
COMPILE_TIME_ASSERT(EXP::NR > R || EXP::NR == 0); COMPILE_TIME_ASSERT((EXP::NR > R && R >= 0) || EXP::NR == 0);
// you can't remove a column from a matrix with only one column // you can't remove a column from a matrix with only one column
COMPILE_TIME_ASSERT(EXP::NC > C || EXP::NR == 0); COMPILE_TIME_ASSERT((EXP::NC > C && C >= 0) || EXP::NR == 0);
DLIB_ASSERT(m.nr() > R && m.nc() > C, DLIB_ASSERT(m.nr() > R && R >= 0 && m.nc() > C && C >= 0,
"\tconst matrix_exp removerc<R,C>(const matrix_exp& m)" "\tconst matrix_exp removerc<R,C>(const matrix_exp& m)"
<< "\n\tYou can't remove a row/column from a matrix if it doesn't have that row/column" << "\n\tYou can't remove a row/column from a matrix if it doesn't have that row/column"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -440,7 +440,7 @@ namespace dlib ...@@ -440,7 +440,7 @@ namespace dlib
long C long C
) )
{ {
DLIB_ASSERT(m.nr() > R && m.nc() > C, DLIB_ASSERT(m.nr() > R && R >= 0 && m.nc() > C && C >= 0,
"\tconst matrix_exp removerc(const matrix_exp& m,R,C)" "\tconst matrix_exp removerc(const matrix_exp& m,R,C)"
<< "\n\tYou can't remove a row/column from a matrix if it doesn't have that row/column" << "\n\tYou can't remove a row/column from a matrix if it doesn't have that row/column"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -525,8 +525,8 @@ namespace dlib ...@@ -525,8 +525,8 @@ namespace dlib
{ {
// You can't remove the given column from the matrix because the matrix doesn't // You can't remove the given column from the matrix because the matrix doesn't
// have a column with that index. // have a column with that index.
COMPILE_TIME_ASSERT(EXP::NC > C || EXP::NC == 0); COMPILE_TIME_ASSERT((EXP::NC > C && C >= 0) || EXP::NC == 0);
DLIB_ASSERT(m.nc() > C , DLIB_ASSERT(m.nc() > C && C >= 0 ,
"\tconst matrix_exp remove_col<C>(const matrix_exp& m)" "\tconst matrix_exp remove_col<C>(const matrix_exp& m)"
<< "\n\tYou can't remove a col from a matrix if it doesn't have it" << "\n\tYou can't remove a col from a matrix if it doesn't have it"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -545,7 +545,7 @@ namespace dlib ...@@ -545,7 +545,7 @@ namespace dlib
long C long C
) )
{ {
DLIB_ASSERT(m.nc() > C , DLIB_ASSERT(m.nc() > C && C >= 0 ,
"\tconst matrix_exp remove_col(const matrix_exp& m,C)" "\tconst matrix_exp remove_col(const matrix_exp& m,C)"
<< "\n\tYou can't remove a col from a matrix if it doesn't have it" << "\n\tYou can't remove a col from a matrix if it doesn't have it"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -629,8 +629,8 @@ namespace dlib ...@@ -629,8 +629,8 @@ namespace dlib
{ {
// You can't remove the given row from the matrix because the matrix doesn't // You can't remove the given row from the matrix because the matrix doesn't
// have a row with that index. // have a row with that index.
COMPILE_TIME_ASSERT(EXP::NR > R || EXP::NR == 0); COMPILE_TIME_ASSERT((EXP::NR > R && R >= 0) || EXP::NR == 0);
DLIB_ASSERT(m.nr() > R , DLIB_ASSERT(m.nr() > R && R >= 0,
"\tconst matrix_exp remove_row<R>(const matrix_exp& m)" "\tconst matrix_exp remove_row<R>(const matrix_exp& m)"
<< "\n\tYou can't remove a row from a matrix if it doesn't have it" << "\n\tYou can't remove a row from a matrix if it doesn't have it"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -649,7 +649,7 @@ namespace dlib ...@@ -649,7 +649,7 @@ namespace dlib
long R long R
) )
{ {
DLIB_ASSERT(m.nr() > R , DLIB_ASSERT(m.nr() > R && R >= 0,
"\tconst matrix_exp remove_row(const matrix_exp& m, long R)" "\tconst matrix_exp remove_row(const matrix_exp& m, long R)"
<< "\n\tYou can't remove a row from a matrix if it doesn't have it" << "\n\tYou can't remove a row from a matrix if it doesn't have it"
<< "\n\tm.nr(): " << m.nr() << "\n\tm.nr(): " << m.nr()
...@@ -1218,18 +1218,6 @@ namespace dlib ...@@ -1218,18 +1218,6 @@ namespace dlib
const matrix_exp<EXP>& m const matrix_exp<EXP>& m
) )
{ {
// You can't rotate a matrix by more rows than it has.
COMPILE_TIME_ASSERT(R < EXP::NR || EXP::NR == 0);
// You can't rotate a matrix by more columns than it has.
COMPILE_TIME_ASSERT(C < EXP::NC || EXP::NC == 0);
DLIB_ASSERT( R < m.nr() && C < m.nc(),
"\tconst matrix_exp::type rotate(const matrix_exp& m)"
<< "\n\tYou can't rotate a matrix by more rows or columns than it has"
<< "\n\tm.nr(): " << m.nr()
<< "\n\tm.nc(): " << m.nc()
<< "\n\tR: " << R
<< "\n\tC: " << C
);
typedef matrix_unary_exp<EXP,op_rotate<R,C> > exp; typedef matrix_unary_exp<EXP,op_rotate<R,C> > exp;
return exp(m.ref()); return exp(m.ref());
} }
......
...@@ -261,9 +261,6 @@ namespace dlib ...@@ -261,9 +261,6 @@ namespace dlib
const matrix_exp& m const matrix_exp& m
); );
/*! /*!
requires
- R < m.nr()
- C < m.nc()
ensures ensures
- returns a matrix R such that: - returns a matrix R such that:
- R::type == the same type that was in m - R::type == the same type that was in m
...@@ -329,8 +326,8 @@ namespace dlib ...@@ -329,8 +326,8 @@ namespace dlib
); );
/*! /*!
requires requires
- m.nr() > R - m.nr() > R >= 0
- m.nc() > C - m.nc() > C >= 0
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
- M.nr() == m.nr() - 1 - M.nr() == m.nr() - 1
...@@ -347,8 +344,8 @@ namespace dlib ...@@ -347,8 +344,8 @@ namespace dlib
); );
/*! /*!
requires requires
- m.nr() > R - m.nr() > R >= 0
- m.nc() > C - m.nc() > C >= 0
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
- M.nr() == m.nr() - 1 - M.nr() == m.nr() - 1
...@@ -366,7 +363,7 @@ namespace dlib ...@@ -366,7 +363,7 @@ namespace dlib
); );
/*! /*!
requires requires
- m.nr() > R - m.nr() > R >= 0
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
- M.nr() == m.nr() - 1 - M.nr() == m.nr() - 1
...@@ -382,7 +379,7 @@ namespace dlib ...@@ -382,7 +379,7 @@ namespace dlib
); );
/*! /*!
requires requires
- m.nr() > R - m.nr() > R >= 0
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
- M.nr() == m.nr() - 1 - M.nr() == m.nr() - 1
...@@ -400,7 +397,7 @@ namespace dlib ...@@ -400,7 +397,7 @@ namespace dlib
); );
/*! /*!
requires requires
- m.nc() > C - m.nc() > C >= 0
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
- M.nr() == m.nr() - M.nr() == m.nr()
...@@ -416,7 +413,7 @@ namespace dlib ...@@ -416,7 +413,7 @@ namespace dlib
); );
/*! /*!
requires requires
- m.nc() > C - m.nc() > C >= 0
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
- M.nr() == m.nr() - M.nr() == m.nr()
......
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