From f7b395a87f77232cae0013446442cadd977af460 Mon Sep 17 00:00:00 2001 From: Davis King Date: Fri, 10 Jun 2016 16:40:50 -0400 Subject: [PATCH] Fixed minor bugs in join_rows() and join_cols(). They didn't work when one of the matrices was empty. --- dlib/matrix/matrix_utilities.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dlib/matrix/matrix_utilities.h b/dlib/matrix/matrix_utilities.h index 219ed8be7..3b7c199c5 100644 --- a/dlib/matrix/matrix_utilities.h +++ b/dlib/matrix/matrix_utilities.h @@ -4021,9 +4021,10 @@ namespace dlib template struct op_join_rows { - op_join_rows(const M1& m1_, const M2& m2_) : m1(m1_),m2(m2_) {} + op_join_rows(const M1& m1_, const M2& m2_) : m1(m1_),m2(m2_),_nr(std::max(m1.nr(),m2.nr())) {} const M1& m1; const M2& m2; + const long _nr; template struct type_selector; @@ -4054,7 +4055,7 @@ namespace dlib return m2(r,c-m1.nc()); } - long nr () const { return m1.nr(); } + long nr () const { return _nr; } long nc () const { return m1.nc()+m2.nc(); } template bool aliases ( const matrix_exp& item) const @@ -4095,9 +4096,10 @@ namespace dlib template struct op_join_cols { - op_join_cols(const M1& m1_, const M2& m2_) : m1(m1_),m2(m2_) {} + op_join_cols(const M1& m1_, const M2& m2_) : m1(m1_),m2(m2_),_nc(std::max(m1.nc(),m2.nc())) {} const M1& m1; const M2& m2; + const long _nc; template struct type_selector; @@ -4131,7 +4133,8 @@ namespace dlib } long nr () const { return m1.nr()+m2.nr(); } - long nc () const { return m1.nc(); } + long nc () const { return _nc; } + template bool aliases ( const matrix_exp& item) const { return m1.aliases(item) || m2.aliases(item); }