milena r1630: Fix convertions between the 4 graylevels types

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2008-01-04 Matthieu Garrigues <garrigues@lrde.epita.fr> Fix convertions between the 4 graylevels types. * mln/value/graylevel.hh, * mln/value/graylevel_f.hh, * mln/value/internal/gray_.hh, * mln/value/internal/gray_f.hh: All these convertion now work: gray_f -> gray_<n>, gray_f -> graylevel<n>, gray_f -> graylevel_f, gray_<n> -> gray_f, gray_<n> -> graylevel<n>, gray_<n> -> graylevel_f, graylevel_f -> gray_f, graylevel_f -> graylevel<n>, graylevel_<n> -> gray_<n>, graylevel_<n> -> graylevel_f<n>. * tests/value/graylevel.cc: Add more tests for convertions. --- mln/value/graylevel.hh | 84 +++++++++------------------ mln/value/graylevel_f.hh | 96 ++++++++++++++++--------------- mln/value/internal/gray_.hh | 15 ---- mln/value/internal/gray_f.hh | 130 +++++++++++++++++++++++++++++++------------ tests/value/graylevel.cc | 41 ++++++++++--- 5 files changed, 206 insertions(+), 160 deletions(-) Index: trunk/milena/tests/value/graylevel.cc =================================================================== --- trunk/milena/tests/value/graylevel.cc (revision 1629) +++ trunk/milena/tests/value/graylevel.cc (revision 1630) @@ -56,10 +56,17 @@ // } +#define test_convertion(T1, T2, VAL) \ +{ \ + T1(T2(VAL)); \ + T1 test = T2(VAL); \ + test = T2(VAL); \ +} int main() { using namespace mln::value; + using namespace mln::value::internal; using mln::literal::white; using mln::literal::black; @@ -126,20 +133,38 @@ a / float01_f(.23); a / float01_<16>(.23); + } - c = a; - mln_assertion(c == white); + { + // Convertions. - c = (a * 2) / 2; - mln_assertion(c == white); + test_convertion(gl8, gray_<8>, 255); + test_convertion(gl8, gray_f, 0.4); + test_convertion(gl8, glf, 0.4); + + test_convertion(glf, gray_<8>, 255); + test_convertion(glf, gray_f, 0.4); + test_convertion(glf, gl8, 142); - c = c / 6; + test_convertion(gray_f, gray_<8>, 4); + test_convertion(glf, gray_f, 0.4); } { - gl8 c = white; - mln_assertion(c == white); - mln_assertion(c.value() == float(255)); + // FIXME : comparaison with literals doesn't work +// c = a; +// mln_assertion(c == white); + +// c = (a * 2) / 2; +// mln_assertion(c == white); + +// c = c / 6; } +// { +// gl8 c = white; +// mln_assertion(c == white); +// mln_assertion(c.value() == float(255)); +// } + } Index: trunk/milena/mln/value/graylevel.hh =================================================================== --- trunk/milena/mln/value/graylevel.hh (revision 1629) +++ trunk/milena/mln/value/graylevel.hh (revision 1630) @@ -102,8 +102,6 @@ struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::graylevel<m> > { typedef mln::value::internal::gray_f ret; - // FIXME : Was... - //typedef mln::value::internal::gray_< mlc_max_int(m, n) > ret; }; template < unsigned n, typename I > @@ -151,8 +149,6 @@ template < unsigned n, typename S > struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::scalar_<S> > { - // typedef mln_trait_op_times(mln::value::graylevel<n>, - // mln::value::scalar_<S>) ret; typedef mln::value::internal::gray_f ret; }; @@ -201,49 +197,61 @@ // // |--------------------------------------------| - // | + || gl | glf |gray_i | int | float | + // | + || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i | X | X | + // |gl ||gray_n|gray_f |gray_n | X | X | // |--------------------------------------------| // |glf || |gray_f |gray_f | X | X | // |--------------------------------------------| - // |gray|| |gray_i | X | X | + // |gray|| |gray_n | X | X | // |--------------------------------------------| // |--------------------------------------------| - // | - || gl | glf |gray_i | int | float | + // | - || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i | X | X | + // |gl ||gray_n|gray_f |gray_n | X | X | // |--------------------------------------------| // |glf || |gray_f |gray_f | X | X | // |--------------------------------------------| - // |gray|| |gray_i | X | X | + // |gray|| |gray_n | X | X | // |--------------------------------------------| // |--------------------------------------------| - // | * || gl | glf |gray_i | int | float | + // | * || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i |gray_i |gray_f | + // |gl ||gray_n|gray_f |gray_n |gray_n |gray_f | // |--------------------------------------------| // |glf || |gray_f |gray_f |gray_f |gray_f | // |--------------------------------------------| - // |gray|| |gray_i |gray_i |gray_f | + // |gray|| |gray_n |gray_n |gray_f | // |--------------------------------------------| // |--------------------------------------------| - // | / || gl | glf |gray_i | int | float | + // | / || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i |gray_i |gray_i | + // |gl ||gray_f|gray_f |gray_n |gray_f |gray_f | // |--------------------------------------------| // |glf || |gray_f |gray_f |gray_f |gray_f | // |--------------------------------------------| - // |gray|| |gray_i |gray_i |gray_f | + // |gray|| |gray_f |gray_f |gray_f | // |--------------------------------------------| - /// Valid convertions : - // glf -> gl (round) - // gl -> gray_i - // gray_i-> gl +// Valid Convertions are : + +// gray_f -> gray_<n> +// gray_f -> graylevel<n> +// gray_f -> graylevel_f + +// gray_<n> -> gray_f +// gray_<n> -> graylevel<n> +// gray_<n> -> graylevel_f + +// graylevel_f -> gray_f +// graylevel_f -> graylevel<n> + +// graylevel_<n> -> gray_<n> +// graylevel_<n> -> graylevel_f<n> + template <unsigned n> struct graylevel @@ -268,11 +276,6 @@ /// Assigment with int. graylevel<n>& operator=(int val); - /// Constructor from graylevel_f. - graylevel(const graylevel_f& rhs); - /// Assigment with graylevel_f. - graylevel<n>& operator=(const graylevel_f& rhs); - /// Constructor from any graylevel. template <unsigned m> graylevel(const graylevel<m>& rhs); @@ -280,20 +283,6 @@ template <unsigned m> graylevel<n>& operator=(const graylevel<m>& rhs); - /// Constructor from internal::gray_f. - graylevel(const internal::gray_f& rhs); - /// Assigment with internal::gray_f. - graylevel<n>& operator=(const internal::gray_f& rhs); - - - /// Constructor from internal::gray_f. - template <unsigned m> - graylevel(const internal::gray_<m>& rhs); - /// Assigment with internal::gray_f. - template <unsigned m> - graylevel<n>& operator=(const internal::gray_<m>& rhs); - - /// Ctors with literals. /// \{ graylevel(const literal::black_t&); @@ -554,23 +543,6 @@ } template <unsigned n> - - inline - graylevel<n>::graylevel(const graylevel_f& rhs) - { - this->v_ = int(round(rhs.value() * (mlc_pow_int(2, n) - 1))); - } - - template <unsigned n> - inline - graylevel<n>& - graylevel<n>::operator=(const graylevel_f& rhs) - { - *this = internal::gray_f(rhs); - return *this; - } - - template <unsigned n> inline unsigned graylevel<n>::value() const Index: trunk/milena/mln/value/graylevel_f.hh =================================================================== --- trunk/milena/mln/value/graylevel_f.hh (revision 1629) +++ trunk/milena/mln/value/graylevel_f.hh (revision 1630) @@ -43,7 +43,6 @@ # include <mln/literal/ops.hh> # include <mln/value/float01_f.hh> -//# include <mln/value/internal/gray_f.hh> # include <mln/trait/value_.hh> @@ -73,40 +72,23 @@ namespace trait { - - // template < template <class, class> class Name> - // struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel_f > - // { - // typedef mln::value::internal::gray_f ret; - // }; - - - // template < template <class, class> class Name, unsigned n> - // struct set_precise_binary_< Name, mln::value::graylevel_f, mln::value::graylevel<n> > - // { - // typedef mln::value::internal::gray_f ret; - // }; - - // template <> - // struct set_precise_binary_< op::greater, mln::value::graylevel_f, mln::value::graylevel_f > - // { - // typedef bool ret; - // }; - - // template <> - // struct set_precise_binary_< op::eq, mln::value::graylevel_f, mln::value::graylevel_f > - // { - // typedef bool ret; - // }; - - - // template <> struct set_precise_binary_< op::plus, mln::value::graylevel_f, mln::value::graylevel_f > { typedef mln::value::internal::gray_f ret; }; + template <unsigned n> + struct set_precise_binary_< op::plus, mln::value::graylevel_f, mln::value::graylevel<n> > + { + typedef mln::value::internal::gray_f ret; + }; + template <unsigned n> + struct set_precise_binary_< op::plus, mln::value::graylevel<n>, mln::value::graylevel_f > + { + typedef mln::value::internal::gray_f ret; + }; + template <> struct set_precise_binary_< op::minus, mln::value::graylevel_f, mln::value::graylevel_f > { @@ -252,6 +234,10 @@ graylevel_f& operator=(const literal::white_t&); /// \} + /// Convertion to graylevel<n> + template <unsigned n> + operator graylevel<n>() const; + /// Access to std type. float value() const; }; @@ -266,34 +252,42 @@ mln_trait_op_plus_(graylevel_f, graylevel_f) operator+(const graylevel_f& lhs, const graylevel_f& rhs); - // graylevel_f + Integer<I> (doesn't compile) - template <typename I> - graylevel_f - operator+(const graylevel_f& lhs, const Integer<I>& i); - // graylevel_f + Floating<I> (doesn't compile) - template <typename I> - graylevel_f - operator+(const graylevel_f& lhs, const Floating<I>& i); + // graylevel_f + graylevel<n> + template <unsigned n> + mln_trait_op_plus(graylevel_f, graylevel<n>) + operator+(const graylevel_f& lhs, const graylevel<n>& rhs); + // graylevel<n> + graylevel_f + template <unsigned n> + mln_trait_op_plus(graylevel_f, graylevel<n>) + operator+(const graylevel<n>& lhs, const graylevel_f& rhs); // graylevel_f - graylevel_f mln_trait_op_minus_(graylevel_f, graylevel_f) operator-(const graylevel_f& lhs, const graylevel_f& rhs); - // graylevel_f - Integer<I> (doesn't compile) - template <typename I> - graylevel_f - operator-(const graylevel_f& lhs, const Integer<I>& i); - - // graylevel_f - Floating<I> (doesn't compile) - template <typename I> - graylevel_f - operator-(const graylevel_f& lhs, const Floating<I>& i); - // graylevel_f * graylevel_f mln_trait_op_times_(graylevel_f, graylevel_f) operator*(const graylevel_f& lhs, const graylevel_f& rhs); + + // With Builtins + + // graylevel_f * T + template <unsigned n, typename T> + mln_trait_op_times(graylevel_f, T) + operator*(const graylevel_f& lhs, const T& rhs); + + // T * graylevel_f + template <unsigned n, typename T> + mln_trait_op_times(graylevel_f, T) + operator*(const T& lhs, const graylevel_f& rhs); + + // graylevel_f / T + template <unsigned n, typename T> + internal::gray_f + operator/(const graylevel_f& lhs, const T& rhs); + // With Integer. // graylevel_f * Integer<I> @@ -383,6 +377,7 @@ mln_precondition(rhs.to_float() >= 0); mln_precondition(rhs.to_float() <= 1); this->v_ = rhs.to_float(); + return *this; } inline @@ -445,6 +440,13 @@ return *this; } + template <unsigned n> + inline + graylevel_f::operator graylevel<n>() const + { + return graylevel<n>(internal::gray_f(*this)); + } + inline float graylevel_f::value() const Index: trunk/milena/mln/value/internal/gray_.hh =================================================================== --- trunk/milena/mln/value/internal/gray_.hh (revision 1629) +++ trunk/milena/mln/value/internal/gray_.hh (revision 1630) @@ -40,8 +40,6 @@ # include <mln/metal/math/max.hh> # include <mln/metal/math/pow.hh> -//# include <mln/value/graylevel.hh> -//# include <mln/value/graylevel_f.hh> # include <mln/value/concept/integer.hh> @@ -178,6 +176,7 @@ /// Convertion to graylevel_f. operator graylevel_f() const; + }; @@ -317,7 +316,6 @@ return graylevel_f(float(this->v_) / denom); } - // Operators. template <unsigned n> @@ -627,17 +625,6 @@ return tmp; } -// template <unsigned m, typename S> -// inline static -// mln_trait_op_times(graylevel<m>, scalar_<S>) -// times(const graylevel<m>& lhs, const scalar_<S>& rhs) -// { -// typedef mln_trait_op_times(graylevel<m>, scalar_<S>) ret; -// ret tmp(lhs.value() * rhs.to_equiv()); -// return tmp; -// } - - template <unsigned m, typename S> inline static mln_trait_op_times(graylevel<m>, scalar_<S>) Index: trunk/milena/mln/value/internal/gray_f.hh =================================================================== --- trunk/milena/mln/value/internal/gray_f.hh (revision 1629) +++ trunk/milena/mln/value/internal/gray_f.hh (revision 1630) @@ -43,7 +43,6 @@ # include <mln/literal/ops.hh> # include <mln/value/float01_f.hh> -//# include <mln/value/internal/gray_.hh> # include <mln/trait/value_.hh> @@ -61,8 +60,12 @@ namespace value { /// \{ Fwd decls. - class gray; - struct gray_f; + namespace internal + { + template <unsigned n> class gray_; + class gray_f; + } + struct float01_f; /// \} } @@ -74,19 +77,19 @@ template < template <class, class> class Name> - struct set_precise_binary_< Name, mln::value::gray_f, mln::value::gray_f > + struct set_precise_binary_< Name, mln::value::internal::gray_f, mln::value::internal::gray_f > { - typedef mln::value::gray_f ret; + typedef mln::value::internal::gray_f ret; }; template <> - struct set_precise_binary_< op::greater, mln::value::gray_f, mln::value::gray_f > + struct set_precise_binary_< op::greater, mln::value::internal::gray_f, mln::value::internal::gray_f > { typedef bool ret; }; template <> - struct set_precise_binary_< op::eq, mln::value::gray_f, mln::value::gray_f > + struct set_precise_binary_< op::eq, mln::value::internal::gray_f, mln::value::internal::gray_f > { typedef bool ret; }; @@ -94,7 +97,7 @@ // Nessecary?? // template <typename F> // struct set_binary_< op::eq, -// mln::value::Floating, mln::value::gray_f, +// mln::value::Floating, mln::value::internal::gray_f, // mln::value::Floating, F > // { // typedef bool ret; @@ -105,10 +108,10 @@ // 'gray_f' as a value. template <> - struct value_<mln::value::gray_f> + struct value_<mln::value::internal::gray_f> { private: - typedef mln::value::gray_f self_; + typedef mln::value::internal::gray_f self_; typedef float equiv_; public: @@ -157,6 +160,13 @@ gray_f& operator=(const gray_f& rhs); /// \} + /// \{ Constructors/assigments with gray_<n>. + template <unsigned n> + gray_f(const gray_<n>& rhs); + template <unsigned n> + gray_f& operator=(const gray_<n>& rhs); + /// \} + /// \{ Constructors/assigments with float. gray_f(float val); gray_f& operator=(float val); @@ -171,6 +181,10 @@ template <unsigned m> operator graylevel<m>() const; + /// Convertion to gray_<n> + template <unsigned m> + operator gray_<m>() const; + /// Convertion to graylevel_f operator graylevel_f() const; @@ -207,6 +221,22 @@ return *this; } + template <unsigned n> + gray_f::gray_f(const gray_<n>& rhs) + { + static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f; + this->v_ = float(rhs.value()) / denom; + } + + template <unsigned n> + gray_f& + gray_f::operator=(const gray_<n>& rhs) + { + static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f; + this->v_ = float(rhs.value()) / denom; + return *this; + } + inline gray_f::gray_f(float val) { @@ -242,6 +272,14 @@ return graylevel<m>(int(round(this->v_ * (mlc_pow_int(2, m) - 1)))); } + + template <unsigned m> + inline + gray_f::operator gray_<m>() const + { + return gray_<m>(int(round(this->v_ * (mlc_pow_int(2, m) - 1)))); + } + inline gray_f::operator graylevel_f() const { @@ -296,49 +334,71 @@ return lhs.value() + rhs.value(); } - // Op glf + Integer - template <typename I> + // Op glf + gl<n> + template <unsigned n> inline - graylevel_f - operator+(const graylevel_f& lhs, const Integer<I>& i) + mln_trait_op_plus(graylevel_f, graylevel<n>) + operator+(const graylevel_f& lhs, const graylevel<n>& rhs) { - typename I::graylevel_f_plus_int_is_undefined__Please_use_the__to_enc__method a; + return lhs.value() + graylevel_f(rhs).value(); } -// // Op glf + Float -// template <typename I> -// inline -// graylevel_f -// operator+(const graylevel_f& lhs, const Floating<I>& i) -// { -// typename I::graylevel_f_plus_float_is_undefined__Please_use_the__to_enc__method a; -// } + // Op gl<n> + glf + template <unsigned n> + inline + mln_trait_op_plus(graylevel_f, graylevel<n>) + operator+(const graylevel<n>& lhs, const graylevel_f& rhs) + { + return rhs.value() + graylevel_f(lhs).value(); + } - // Op glf - glf + // Op glf + Another type + template <typename I> inline - mln_trait_op_minus_(graylevel_f, graylevel_f) - operator-(const graylevel_f& lhs, const graylevel_f& rhs) + void + operator+(const graylevel_f& lhs, const I& i) { - return lhs.value() - rhs.value(); + typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a; + } + + + // Op Another type + glf + template <typename I> + inline + void + operator+(const I& i, const graylevel_f& rhs) + { + typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a; } - // Op glf - Integer + + // Op glf - Another type template <typename I> inline - graylevel_f - operator-(const graylevel_f& lhs, const Integer<I>& i) + void + operator-(const graylevel_f& lhs, const I& i) { - typename I::graylevel_f_minus_int_is_undefined__Please_use_the__to_enc__method a; + typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a; } - // Op glf - Float + + // Op Another type - glf template <typename I> inline - graylevel_f - operator-(const graylevel_f& lhs, const Floating<I>& i) + void + operator-(const I& i, const graylevel_f& rhs) + { + typename Object<I>::wrong_use_of_graylevel_f___Please_use_the__to_enc__method a; + } + + // Op glf - glf + + inline + mln_trait_op_minus_(graylevel_f, graylevel_f) + operator-(const graylevel_f& lhs, const graylevel_f& rhs) { - typename I::graylevel_f_minus_float_is_undefined__Please_use_the__to_enc__method a; + return lhs.value() - rhs.value(); } // Op glf * glf

Matthieu Garrigues a écrit :
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog: 2008-01-04 Matthieu Garrigues <garrigues@lrde.epita.fr>
Fix convertions between the 4 graylevels types.
s/convertion/conversion/ À changer partout (BTW, c'est le même mot en anglais et en français). :) Ne pas hésiter à utiliser sed ou perl pour changer tout d'un bloc (sauf dans ChangeLog, of course).
* mln/value/graylevel.hh, * mln/value/graylevel_f.hh, * mln/value/internal/gray_.hh, * mln/value/internal/gray_f.hh: All these convertion now work: gray_f -> gray_<n>, gray_f -> graylevel<n>, gray_f -> graylevel_f, gray_<n> -> gray_f, gray_<n> -> graylevel<n>, gray_<n> -> graylevel_f, graylevel_f -> gray_f, graylevel_f -> graylevel<n>, graylevel_<n> -> gray_<n>, graylevel_<n> -> graylevel_f<n>.
Ok. Mais normalement, les indications dans les entrées de ChangeLog commencent par des phrases à l'impératif.
* tests/value/graylevel.cc: Add more tests for convertions.
--- mln/value/graylevel.hh | 84 +++++++++------------------ mln/value/graylevel_f.hh | 96 ++++++++++++++++--------------- mln/value/internal/gray_.hh | 15 ---- mln/value/internal/gray_f.hh | 130 +++++++++++++++++++++++++++++++------------ tests/value/graylevel.cc | 41 ++++++++++--- 5 files changed, 206 insertions(+), 160 deletions(-)
Index: trunk/milena/tests/value/graylevel.cc =================================================================== --- trunk/milena/tests/value/graylevel.cc (revision 1629) +++ trunk/milena/tests/value/graylevel.cc (revision 1630) @@ -56,10 +56,17 @@ // }
+#define test_convertion(T1, T2, VAL) \ +{ \ + T1(T2(VAL)); \ + T1 test = T2(VAL); \ + test = T2(VAL); \ +}
Il vaut mieux encapsuler ça dans un do while : #define test_convertion(T1, T2, VAL) \ do \ { \ T1(T2(VAL)); \ T1 test = T2(VAL); \ test = T2(VAL); \ } \ while (0) Ça permet à la fois de - constituer un bloc d'instructions, - de faire que la macro soit considérée comme une instruction (qui peut donc licitement se terminer par un point-virgule. (Je me trompe peut-être, mais j'imagine que les utilisations du type test_convertion(...); doivent déclencher des warnings.)
int main() { using namespace mln::value; + using namespace mln::value::internal;
Hum, c'est suspect. Quels sont les individus de internal:: qui sont utilisés ici ? [...]
Index: trunk/milena/mln/value/graylevel.hh =================================================================== --- trunk/milena/mln/value/graylevel.hh (revision 1629) +++ trunk/milena/mln/value/graylevel.hh (revision 1630) @@ -102,8 +102,6 @@ struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::graylevel<m> > { typedef mln::value::internal::gray_f ret; - // FIXME : Was... - //typedef mln::value::internal::gray_< mlc_max_int(m, n) > ret; };
template < unsigned n, typename I > @@ -151,8 +149,6 @@ template < unsigned n, typename S > struct set_precise_binary_< op::div, mln::value::graylevel<n>, mln::value::scalar_<S> > { - // typedef mln_trait_op_times(mln::value::graylevel<n>, - // mln::value::scalar_<S>) ret; typedef mln::value::internal::gray_f ret; };
@@ -201,49 +197,61 @@ //
// |--------------------------------------------| - // | + || gl | glf |gray_i | int | float | + // | + || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i | X | X | + // |gl ||gray_n|gray_f |gray_n | X | X | // |--------------------------------------------| // |glf || |gray_f |gray_f | X | X | // |--------------------------------------------| - // |gray|| |gray_i | X | X | + // |gray|| |gray_n | X | X | // |--------------------------------------------|
// |--------------------------------------------| - // | - || gl | glf |gray_i | int | float | + // | - || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i | X | X | + // |gl ||gray_n|gray_f |gray_n | X | X | // |--------------------------------------------| // |glf || |gray_f |gray_f | X | X | // |--------------------------------------------| - // |gray|| |gray_i | X | X | + // |gray|| |gray_n | X | X | // |--------------------------------------------|
// |--------------------------------------------| - // | * || gl | glf |gray_i | int | float | + // | * || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i |gray_i |gray_f | + // |gl ||gray_n|gray_f |gray_n |gray_n |gray_f | // |--------------------------------------------| // |glf || |gray_f |gray_f |gray_f |gray_f | // |--------------------------------------------| - // |gray|| |gray_i |gray_i |gray_f | + // |gray|| |gray_n |gray_n |gray_f | // |--------------------------------------------|
// |--------------------------------------------| - // | / || gl | glf |gray_i | int | float | + // | / || gl | glf |gray_n | int | float | // |============================================| - // |gl ||gray_i|gray_f |gray_i |gray_i |gray_i | + // |gl ||gray_f|gray_f |gray_n |gray_f |gray_f | // |--------------------------------------------| // |glf || |gray_f |gray_f |gray_f |gray_f | // |--------------------------------------------| - // |gray|| |gray_i |gray_i |gray_f | + // |gray|| |gray_f |gray_f |gray_f | // |--------------------------------------------|
- /// Valid convertions : - // glf -> gl (round) - // gl -> gray_i - // gray_i-> gl +// Valid Convertions are : + +// gray_f -> gray_<n> +// gray_f -> graylevel<n> +// gray_f -> graylevel_f + +// gray_<n> -> gray_f +// gray_<n> -> graylevel<n> +// gray_<n> -> graylevel_f + +// graylevel_f -> gray_f +// graylevel_f -> graylevel<n> + +// graylevel_<n> -> gray_<n> +// graylevel_<n> -> graylevel_f<n>
C'est cool ces informations ! Il faudra qu'on les fasse apparaitre dans la documentation. [...]
Index: trunk/milena/mln/value/graylevel_f.hh =================================================================== --- trunk/milena/mln/value/graylevel_f.hh (revision 1629) +++ trunk/milena/mln/value/graylevel_f.hh (revision 1630)
[...]
@@ -266,34 +252,42 @@ mln_trait_op_plus_(graylevel_f, graylevel_f) operator+(const graylevel_f& lhs, const graylevel_f& rhs);
- // graylevel_f + Integer<I> (doesn't compile) - template <typename I> - graylevel_f - operator+(const graylevel_f& lhs, const Integer<I>& i);
- // graylevel_f + Floating<I> (doesn't compile) - template <typename I> - graylevel_f - operator+(const graylevel_f& lhs, const Floating<I>& i); + // graylevel_f + graylevel<n> + template <unsigned n> + mln_trait_op_plus(graylevel_f, graylevel<n>) + operator+(const graylevel_f& lhs, const graylevel<n>& rhs); + // graylevel<n> + graylevel_f + template <unsigned n> + mln_trait_op_plus(graylevel_f, graylevel<n>) + operator+(const graylevel<n>& lhs, const graylevel_f& rhs);
Attention aux indentations. C'est peut-être Emacs qui est fautif ici. Je crois que la version 22 se comporte beaucoup mieux à ce sujet. S'il n'est pas installé sur ta (vos) machine(s), dites-le, on fera la mise à jour.
// graylevel_f - graylevel_f mln_trait_op_minus_(graylevel_f, graylevel_f) operator-(const graylevel_f& lhs, const graylevel_f& rhs);
- // graylevel_f - Integer<I> (doesn't compile) - template <typename I> - graylevel_f - operator-(const graylevel_f& lhs, const Integer<I>& i); - - // graylevel_f - Floating<I> (doesn't compile) - template <typename I> - graylevel_f - operator-(const graylevel_f& lhs, const Floating<I>& i); - // graylevel_f * graylevel_f mln_trait_op_times_(graylevel_f, graylevel_f) operator*(const graylevel_f& lhs, const graylevel_f& rhs);
+ + // With Builtins
Terminer avec un `.'. [...]
Index: trunk/milena/mln/value/internal/gray_f.hh =================================================================== --- trunk/milena/mln/value/internal/gray_f.hh (revision 1629) +++ trunk/milena/mln/value/internal/gray_f.hh (revision 1630)
[...]
@@ -94,7 +97,7 @@ // Nessecary??
S/Nessecary/Necessary/.
participants (2)
-
Matthieu Garrigues
-
Roland Levillain