Commit f8fe979b authored by Davis King's avatar Davis King

Made the specs a little more clear and added some more tests

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402310
parent 9328d209
...@@ -253,13 +253,23 @@ namespace dlib ...@@ -253,13 +253,23 @@ namespace dlib
) const; ) const;
/*! /*!
ensures ensures
- returns true if the following expression would evaluate incorrectly and false otherwise: - if (aliases(item)) then
for (long r = 0; r < nr(); ++r) - if (nr() != item.nr() || nc() != item.nc()
for (long c = 0; c < nc(); ++c) - returns true
item(r,c) = (*this)(r,c) (i.e. if this expression has different dimensions than item then
- That is, if this matrix expression aliases item in such a way that a modification we have destructive aliasing)
to element item(r,c) causes a change in the value of something other than
(*this)(r,c) then this function returns true. Otherwise, returns false - returns true if the following expression would evaluate incorrectly:
for (long r = 0; r < nr(); ++r)
for (long c = 0; c < nc(); ++c)
item(r,c) = (*this)(r,c)
- That is, if this matrix expression aliases item in such a way that a modification
to element item(r,c) causes a change in the value of something other than
(*this)(r,c) then this function returns true.
- returns false if none of the above conditions say we should return true
- else
- returns false
!*/ !*/
const ref_type& ref ( const ref_type& ref (
......
...@@ -1269,6 +1269,19 @@ namespace ...@@ -1269,6 +1269,19 @@ namespace
DLIB_CASSERT(remove_row(res,2).nr() == 4,""); DLIB_CASSERT(remove_row(res,2).nr() == 4,"");
DLIB_CASSERT(remove_row(res,2).nc() == 5,""); DLIB_CASSERT(remove_row(res,2).nc() == 5,"");
temp = matrix<long,5,5>(res_vals);
temp = remove_row(res,2);
DLIB_CASSERT((temp == matrix<long,4,5>(res_vals_r2)),"");
temp = matrix<long,5,5>(res_vals);
temp = remove_col(res,3);
DLIB_CASSERT((temp == matrix<long,5,4>(res_vals_c3)),"");
matrix<long,3,1> vect;
set_all_elements(vect,1);
temp = identity_matrix<long>(3);
temp = temp*vect;
DLIB_CASSERT(temp == vect,"");
temp = matrix<long,5,4>(res_vals_c3); temp = matrix<long,5,4>(res_vals_c3);
DLIB_CASSERT(remove_col(res,3) == temp,""); DLIB_CASSERT(remove_col(res,3) == temp,"");
DLIB_CASSERT(remove_col(res,3)(2,3) == 0,""); DLIB_CASSERT(remove_col(res,3)(2,3) == 0,"");
......
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