milena r1543: Fix a bug in int_u

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-11-26 Matthieu Garrigues <garrigues@lrde.epita.fr> Fix a bug in int_u. * mln/value/int_u.hh: Replace argument type by (unsigned int) when it was (int). (value_integer_::max()) : Replace card - 1 by mln_max(enc_) to avoid returning -1 for high quantized values. * tests/io/ppm/ppm16.cc, * tests/io/ppm/ppm23.cc: Update the path of the input image. --- mln/value/int_u.hh | 12 +++++++----- tests/io/ppm/ppm16.cc | 2 +- tests/io/ppm/ppm23.cc | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) Index: trunk/milena/tests/io/ppm/ppm23.cc =================================================================== --- trunk/milena/tests/io/ppm/ppm23.cc (revision 1542) +++ trunk/milena/tests/io/ppm/ppm23.cc (revision 1543) @@ -81,7 +81,7 @@ // load a 8bits image A image2d<rgb8> - a = io::ppm::load<rgb8>("../img/lena.ppm"); + a = io::ppm::load<rgb8>("../../../img/lena.ppm"); image2d<rgb23> b(a.domain()); image2d<rgb8>::fwd_piter p(b.domain()); Index: trunk/milena/tests/io/ppm/ppm16.cc =================================================================== --- trunk/milena/tests/io/ppm/ppm16.cc (revision 1542) +++ trunk/milena/tests/io/ppm/ppm16.cc (revision 1543) @@ -81,7 +81,7 @@ // load a 8bits image A image2d<rgb8> - a = io::ppm::load<rgb8>("../img/lena.ppm"); + a = io::ppm::load<rgb8>("../../../img/lena.ppm"); image2d<rgb16> b(a.domain()); image2d<rgb8>::fwd_piter p(b.domain()); Index: trunk/milena/mln/value/int_u.hh =================================================================== --- trunk/milena/mln/value/int_u.hh (revision 1542) +++ trunk/milena/mln/value/int_u.hh (revision 1543) @@ -80,6 +80,7 @@ { private: typedef mln::value::int_u<n> self_; + typedef typename mln::value::internal::encoding_unsigned_<n>::ret enc_; public: enum { @@ -92,7 +93,8 @@ typedef mln_value_quant_from_(card) quant; static const self_ min() { return 0; } - static const self_ max() { return card - 1; } + //FIXME : Is it too much or not? (the exact max is mlc_pow_int(2, n) ) + static const self_ max() { return mln_max(enc_); } static const self_ epsilon() { return 0; } typedef float sum; @@ -129,7 +131,7 @@ int_u(); /// Constructor from an integer. - int_u(int i); + int_u(unsigned int i); /// \{ Constructors/assignments with literals. int_u(const literal::zero_t&); @@ -145,7 +147,7 @@ int operator-() const; /// Assignment from an integer. - int_u<n>& operator=(int i); + int_u<n>& operator=(unsigned int i); }; @@ -179,7 +181,7 @@ } template <unsigned n> - int_u<n>::int_u(int i) + int_u<n>::int_u(unsigned int i) { mln_precondition(i >= 0); mln_precondition(unsigned(i) <= mln_max(enc_)); @@ -229,7 +231,7 @@ template <unsigned n> int_u<n>& - int_u<n>::operator=(int i) + int_u<n>::operator=(unsigned int i) { mln_precondition(i >= 0); mln_precondition(unsigned(i) <= mln_max(enc_));
participants (1)
-
Matthieu Garrigues