Made mat() work on empty tensors.

This commit is contained in:
Davis King 2016-06-11 21:15:36 -04:00
parent dd8bf7553d
commit 8f3e8a6ca7
2 changed files with 12 additions and 13 deletions

View File

@ -192,9 +192,9 @@ namespace dlib
long nc
)
{
DLIB_ASSERT(nr > 0 && nc > 0 ,
DLIB_ASSERT(nr >= 0 && nc >= 0 ,
"\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 nc: " << nc
);
@ -212,12 +212,10 @@ namespace dlib
const tensor& t
)
{
DLIB_ASSERT(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());
if (t.size() != 0)
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 (

View File

@ -333,8 +333,8 @@ namespace dlib
);
/*!
requires
- nr > 0
- nc > 0
- nr >= 0
- nc >= 0
- nr*nc == t.size()
ensures
- returns a matrix M such that:
@ -350,10 +350,11 @@ namespace dlib
const tensor& t
);
/*!
requires
- t.size() != 0
ensures
- returns mat(t, t.num_samples(), t.size()/t.num_samples())
- if (t.size() != 0) then
- returns mat(t, t.num_samples(), t.size()/t.num_samples())
- else
- returns an empty matrix.
!*/
const matrix_exp image_plane (