diff --git a/dlib/matrix/matrix.h b/dlib/matrix/matrix.h index 574be43e1..940374531 100644 --- a/dlib/matrix/matrix.h +++ b/dlib/matrix/matrix.h @@ -1475,7 +1475,7 @@ namespace dlib } matrix& operator += ( - const T& val + const T val ) { const long size = nr()*nc(); @@ -1486,7 +1486,7 @@ namespace dlib } matrix& operator -= ( - const T& val + const T val ) { const long size = nr()*nc(); @@ -1497,7 +1497,7 @@ namespace dlib } matrix& operator *= ( - const T& a + const T a ) { const long size = data.nr()*data.nc(); @@ -1507,7 +1507,7 @@ namespace dlib } matrix& operator /= ( - const T& a + const T a ) { const long size = data.nr()*data.nc(); diff --git a/dlib/test/matrix.cpp b/dlib/test/matrix.cpp index 2efae0c4a..a37489a27 100644 --- a/dlib/test/matrix.cpp +++ b/dlib/test/matrix.cpp @@ -1212,6 +1212,43 @@ namespace m2 = 1; m1 = subm(m2,0,0,3,3)*m1; } + + { + matrix m(2,1); + + m = 3,3; + m /= m(0); + + DLIB_TEST(m(0) == 1); + DLIB_TEST(m(1) == 1); + } + { + matrix m(2,1); + + m = 3,3; + m *= m(0); + + DLIB_TEST(m(0) == 9); + DLIB_TEST(m(1) == 9); + } + { + matrix m(2,1); + + m = 3,3; + m -= m(0); + + DLIB_TEST(m(0) == 0); + DLIB_TEST(m(1) == 0); + } + { + matrix m(2,1); + + m = 3,3; + m += m(0); + + DLIB_TEST(m(0) == 6); + DLIB_TEST(m(1) == 6); + } }