
* mln/make/h_mat.hh: fix wrong loop. * tests/make/Makefile.am, * tests/make/h_mat.cc: add a missing test. --- milena/ChangeLog | 9 ++++++ milena/mln/make/h_mat.hh | 13 ++++---- milena/tests/make/Makefile.am | 2 + milena/tests/make/h_mat.cc | 65 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 milena/tests/make/h_mat.cc diff --git a/milena/ChangeLog b/milena/ChangeLog index 219f400..25aa240 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2009-02-05 Guillaume Lazzara <z@lrde.epita.fr> + Fix make::h_mat. + + * mln/make/h_mat.hh: fix wrong loop. + + * tests/make/Makefile.am, + * tests/make/h_mat.cc: add a missing test. + +2009-02-05 Guillaume Lazzara <z@lrde.epita.fr> + Fix wrong comments in fun::x2x:composed. * mln/fun/x2x/composed.hh: Comments were wrong, they are fixed. The diff --git a/milena/mln/make/h_mat.hh b/milena/mln/make/h_mat.hh index 930c133..243278d 100644 --- a/milena/mln/make/h_mat.hh +++ b/milena/mln/make/h_mat.hh @@ -78,22 +78,23 @@ namespace mln template <typename T, unsigned d> inline algebra::h_mat<d,T> - h_mat(const T (&tab)[(d+1)*(d+1)]) + h_mat(const T (&tab)[(d)*(d)]) { + std::cout << "plap" << std::endl; algebra::h_mat<d,T> tmp; - for (unsigned i = 0; i <= d; ++i) - tmp(i / (d+1), i % (d+1)) = tab[i]; + for (unsigned i = 0; i < d; ++i) + tmp(i / (d), i % (d)) = tab[i]; return tmp; } template <typename T, unsigned d> algebra::h_mat<d,T> - h_mat(const T (&tab)[d+1][d+1]) + h_mat(const T (&tab)[d][d]) { algebra::h_mat<d,T> tmp; - for (unsigned i = 0; i <= d; ++i) - for (unsigned j = 0; j <= d; ++j) + for (unsigned i = 0; i < d; ++i) + for (unsigned j = 0; j < d; ++j) tmp(i, j) = tab[i][j]; return tmp; } diff --git a/milena/tests/make/Makefile.am b/milena/tests/make/Makefile.am index 7d0c2f5..913867c 100644 --- a/milena/tests/make/Makefile.am +++ b/milena/tests/make/Makefile.am @@ -4,6 +4,7 @@ include $(top_srcdir)/milena/tests/tests.mk check_PROGRAMS = \ dual_neighb \ + h_mat \ image2d \ image3d \ mat \ @@ -11,6 +12,7 @@ check_PROGRAMS = \ w_window_directional dual_neighb_SOURCES = dual_neighb.cc +h_mat_SOURCES = h_mat.cc image2d_SOURCES = image2d.cc image3d_SOURCES = image3d.cc mat_SOURCES = mat.cc diff --git a/milena/tests/make/h_mat.cc b/milena/tests/make/h_mat.cc new file mode 100644 index 0000000..a8df474 --- /dev/null +++ b/milena/tests/make/h_mat.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/// \file tests/make/h_mat.cc +/// +/// Tests on mln::make::h_mat. + +#include <mln/make/h_mat.hh> + + +static const int result[4][4] = { { 2, 3, 4, 0 }, + { 5, 6, 7, 0 }, + { 8, 9, 10, 0 }, + { 0, 0, 0, 1 } }; + +int main() +{ + using namespace mln; + + { + int vals[9] = { 2, 3, 4, + 5, 6, 7, + 8, 9, 10 }; + algebra::h_mat<3,int> m = make::h_mat(vals); + + for (unsigned i = 0; i < 4; ++i) + for (unsigned j = 0; j < 4; ++j) + mln_assertion(m(i,j) == result[i][j]); + } + + { + int vals[3][3] = { { 2, 3, 4 }, + { 5, 6, 7 }, + { 8, 9, 10 } }; + algebra::h_mat<3,int> m = make::h_mat(vals); + + for (unsigned i = 0; i < 4; ++i) + for (unsigned j = 0; j < 4; ++j) + mln_assertion(m(i,j) == result[i][j]); + } +} -- 1.5.6.5
participants (1)
-
Guillaume Lazzara