
* mln/labeling/colorize.hh: make it deterministic whatever the compiler used. * mln/make/mat.hh: remove invalid overloads. * tests/labeling/colorize.cc: fix reference image. * tests/make/mat.cc: remove deprecated tests. --- milena/ChangeLog | 13 +++++++ milena/mln/labeling/colorize.hh | 17 +++++++-- milena/mln/make/mat.hh | 68 ++++--------------------------------- milena/tests/labeling/colorize.cc | 19 +++++++--- milena/tests/make/mat.cc | 36 ++++++++----------- 5 files changed, 62 insertions(+), 91 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index de00c9d..f279706 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,16 @@ +2009-07-08 Guillaume Lazzara <guillaume.lazzara@lrde.epita.fr> + + Fix last issues with ICC. + + * mln/labeling/colorize.hh: make it deterministic whatever the + compiler used. + + * mln/make/mat.hh: remove invalid overloads. + + * tests/labeling/colorize.cc: fix reference image. + + * tests/make/mat.cc: remove deprecated tests. + 2009-07-08 Edwin Carlinet <carlinet@lrde.epita.fr> Minor fixes in labeling/compute_image.hh. diff --git a/milena/mln/labeling/colorize.hh b/milena/mln/labeling/colorize.hh index 06a3b8e..26a78df 100644 --- a/milena/mln/labeling/colorize.hh +++ b/milena/mln/labeling/colorize.hh @@ -110,16 +110,27 @@ namespace mln return colorize_::min_value + last % colorize_::max_value; } + + // No random color generator is available for the value type V. template <typename V> V random_color(const V&); + template <unsigned n> mln::value::rgb<n> random_color(const mln::value::rgb<n>&) { - return mln::value::rgb<n>(random_number(), - random_number(), - random_number()); + // Make sure the numbers are generated in the same order + // whatever the compiler used. + // For instance, ICC does not compute function arguments in + // the same order as GCC does. + unsigned + red = random_number(), + green = random_number(), + blue = random_number(); + return mln::value::rgb<n>(red, + green, + blue); } } diff --git a/milena/mln/make/mat.hh b/milena/mln/make/mat.hh index ec2fbdf..ed72f60 100644 --- a/milena/mln/make/mat.hh +++ b/milena/mln/make/mat.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2006, 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -26,10 +27,10 @@ #ifndef MLN_MAKE_MAT_HH # define MLN_MAKE_MAT_HH -/*! \file - * - * \brief Routine to construct an mln::algebra::mat. - */ +/// \file +/// +/// \brief Routine to construct an mln::algebra::mat. + # include <mln/algebra/mat.hh> # include <mln/metal/math/sqrt.hh> @@ -51,34 +52,10 @@ namespace mln algebra::mat<n,m,T> mat(const T (&tab)[n*m]); - /*! \brief Create an mln::algebra::mat<n,m,T>. - * - * \param[in] tab Array of values. - * - * \pre The array dimension has to be n * m. - */ - template <typename T, unsigned n, unsigned m> - algebra::mat<n,m,T> mat(const T (&tab)[n][m]); - - - /*! \brief Create an mln::algebra::mat<n,n,T>. - * - * \param[in] tab C-array of values. - * - * \pre The array dimension N has to be square (N = n * n). - */ - template <typename T, unsigned N> - algebra::mat<mlc_sqrt_int(N), mlc_sqrt_int(N), T> - mat(const T (&tab)[N]); - - - template <unsigned n, unsigned m, typename T> - algebra::mat<n,m,T> mat(algebra::vec<n,T> v); - - # ifndef MLN_INCLUDE_ONLY + template <unsigned n, unsigned m, typename T> inline algebra::mat<n,m,T> mat(const T (&tab)[n*m]) @@ -89,37 +66,6 @@ namespace mln return tmp; } - template <typename T, unsigned n, unsigned m> - algebra::mat<n,m,T> mat(const T (&tab)[n][m]) - { - algebra::mat<n,m,T> tmp; - for (unsigned i = 0; i < n; ++i) - for (unsigned j = 0; j < m; ++j) - tmp(i, j) = tab[i][j]; - return tmp; - } - - template <typename T, unsigned N> - inline - algebra::mat<mlc_sqrt_int(N), mlc_sqrt_int(N), T> - mat(const T (&tab)[N]) - { - enum { n = mlc_sqrt_int(N) }; - mlc_bool(N == n * n)::check(); - algebra::mat<n,n,T> tmp; - for (unsigned i = 0; i < N; ++i) - tmp(i / n, i % n) = tab[i]; - return tmp; - } - - template <unsigned n, typename T> - algebra::mat<n,1,T> mat(algebra::vec<n,T> v) - { - algebra::mat<n,1,T> tmp; - for (unsigned i = 0; i < n; i++) - tmp(i,0) = v[i]; - return tmp; - } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/tests/labeling/colorize.cc b/milena/tests/labeling/colorize.cc index c0bba3c..9c4d352 100644 --- a/milena/tests/labeling/colorize.cc +++ b/milena/tests/labeling/colorize.cc @@ -23,11 +23,18 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -# include <mln/make/image.hh> -# include <mln/value/rgb8.hh> -# include <mln/value/int_u8.hh> -# include <mln/labeling/colorize.hh> -# include <mln/data/compare.hh> + +/// \file +/// +/// Test of labeling::colorize. + + +#include <mln/make/image.hh> +#include <mln/value/rgb8.hh> +#include <mln/value/int_u8.hh> +#include <mln/labeling/colorize.hh> +#include <mln/data/compare.hh> + int main() { @@ -37,7 +44,7 @@ int main() { 0, 0 } }; typedef value::rgb8 rgb_t; - value::rgb8 ref_data[][2] = { { rgb_t(231,46,171), rgb_t(231,46,171) }, + value::rgb8 ref_data[][2] = { { rgb_t(171,46,231), rgb_t(171,46,231) }, { rgb_t(0,0,0), rgb_t(0,0,0) } }; image2d<value::int_u8> ima = make::image(values); diff --git a/milena/tests/make/mat.cc b/milena/tests/make/mat.cc index b9db750..48d7c55 100644 --- a/milena/tests/make/mat.cc +++ b/milena/tests/make/mat.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -23,32 +24,25 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#include <mln/algebra/mat.hh> + +/// \file +/// +/// \brief Test of make::mat. +#include <mln/algebra/mat.hh> + int main() { using namespace mln; - { - int vals[] = { 1, 0, - 0, 1 }; - algebra::mat<2,2,int> m = make::mat(vals); - } - - { - int vals[] = { 1, 2, 3, - 4, 5, 6 }; - algebra::mat<2,3,int> m = make::mat<2,3>(vals); - std::cout << m << std::endl; - } - - { - int vals[][3] = { { 1, 2, 3 }, - { 4, 5, 6 } }; - algebra::mat<2,3,int> m = make::mat(vals); - std::cout << m << std::endl; - } + int vals[] = { 1, 2, 3, + 4, 5, 6 }; + + algebra::mat<2,3,int> m = make::mat<2,3>(vals); + for (int i = 0; i < 2; ++i) + for (int j = 0; j < 3; ++j) + mln_assertion(m(i, j) == vals[i + j + (i * 2)]); } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara