Commit 8f3e8a6c authored by Davis King's avatar Davis King

Made mat() work on empty tensors.

parent dd8bf755
...@@ -192,9 +192,9 @@ namespace dlib ...@@ -192,9 +192,9 @@ namespace dlib
long nc long nc
) )
{ {
DLIB_ASSERT(nr > 0 && nc > 0 , DLIB_ASSERT(nr >= 0 && nc >= 0 ,
"\tconst matrix_exp mat(tensor, nr, nc)" "\tconst matrix_exp mat(tensor, nr, nc)"
<< "\n\t nr and nc must be bigger than 0" << "\n\t nr and nc must be >= 0"
<< "\n\t nr: " << nr << "\n\t nr: " << nr
<< "\n\t nc: " << nc << "\n\t nc: " << nc
); );
...@@ -212,12 +212,10 @@ namespace dlib ...@@ -212,12 +212,10 @@ namespace dlib
const tensor& t const tensor& t
) )
{ {
DLIB_ASSERT(t.size() != 0, if (t.size() != 0)
"\tconst matrix_exp mat(tensor)"
<< "\n\t The tensor can't be empty."
);
return mat(t, t.num_samples(), t.size()/t.num_samples()); return mat(t, t.num_samples(), t.size()/t.num_samples());
else
return mat((float*)0,0,0);
} }
inline const matrix_op<op_pointer_to_mat<float> > image_plane ( inline const matrix_op<op_pointer_to_mat<float> > image_plane (
......
...@@ -333,8 +333,8 @@ namespace dlib ...@@ -333,8 +333,8 @@ namespace dlib
); );
/*! /*!
requires requires
- nr > 0 - nr >= 0
- nc > 0 - nc >= 0
- nr*nc == t.size() - nr*nc == t.size()
ensures ensures
- returns a matrix M such that: - returns a matrix M such that:
...@@ -350,10 +350,11 @@ namespace dlib ...@@ -350,10 +350,11 @@ namespace dlib
const tensor& t const tensor& t
); );
/*! /*!
requires
- t.size() != 0
ensures ensures
- if (t.size() != 0) then
- returns mat(t, t.num_samples(), t.size()/t.num_samples()) - returns mat(t, t.num_samples(), t.size()/t.num_samples())
- else
- returns an empty matrix.
!*/ !*/
const matrix_exp image_plane ( const matrix_exp image_plane (
......
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