From dc0fd24d8984d71f7bdd48416e78cf4600305eb7 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 12 Jul 2014 14:47:52 -0400 Subject: [PATCH] Harmonized the array2d::set_size and matrix::set_size methods. In particular, array2d::set_size() now simply allows any row and column sizes so long as they are non-negative. --- dlib/array2d/array2d_kernel.h | 10 ++++------ dlib/array2d/array2d_kernel_abstract.h | 6 ++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dlib/array2d/array2d_kernel.h b/dlib/array2d/array2d_kernel.h index 7eba6ad48..95bddc8b1 100644 --- a/dlib/array2d/array2d_kernel.h +++ b/dlib/array2d/array2d_kernel.h @@ -149,10 +149,9 @@ namespace dlib at_start_(true) { // make sure requires clause is not broken - DLIB_ASSERT((nc__ > 0 && nr__ > 0) || - (nc__ == 0 && nr__ == 0), + DLIB_ASSERT((nc__ >= 0 && nr__ >= 0), "\t array2d::array2d(long nr__, long nc__)" - << "\n\t You have to give a non zero nc and nr or just make both zero." + << "\n\t The array2d can't have negative rows or columns." << "\n\t this: " << this << "\n\t nc__: " << nc__ << "\n\t nr__: " << nr__ @@ -419,10 +418,9 @@ namespace dlib ) { // make sure requires clause is not broken - DLIB_ASSERT((nc__ > 0 && nr__ > 0) || - (nc__ == 0 && nr__ == 0), + DLIB_ASSERT((nc__ >= 0 && nr__ >= 0) , "\tvoid array2d::set_size(long nr__, long nc__)" - << "\n\tYou have to give a non zero nc and nr or just make both zero." + << "\n\tThe array2d can't have negative rows or columns." << "\n\tthis: " << this << "\n\tnc__: " << nc__ << "\n\tnr__: " << nr__ diff --git a/dlib/array2d/array2d_kernel_abstract.h b/dlib/array2d/array2d_kernel_abstract.h index d78ad1c71..f037522b8 100644 --- a/dlib/array2d/array2d_kernel_abstract.h +++ b/dlib/array2d/array2d_kernel_abstract.h @@ -128,8 +128,7 @@ namespace dlib ); /*! requires - - cols > 0 && rows > 0 or - cols == 0 && rows == 0 + - rows >= 0 && cols >= 0 ensures - #nc() == cols - #nr() == rows @@ -174,8 +173,7 @@ namespace dlib ); /*! requires - - cols > 0 && rows > 0 or - cols == 0 && rows == 0 + - rows >= 0 && cols >= 0 ensures - #nc() == cols - #nr() == rows