
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-11-22 Guillaume Duhamel <guillaume.duhamel@lrde.epita.fr> Subdirectory arith ready for rereading. * mln/arith/all.hh, * mln/arith/min.hh, * mln/arith/min.spe.hh, * mln/arith/minus.hh, * mln/arith/plus.hh, * mln/arith/times.hh: + fix tracing, * mln/arith/revert.hh: Check typo. * tests/arith/plus.cc: Update test for not display. --- mln/arith/all.hh | 14 ++++++-- mln/arith/min.hh | 2 - mln/arith/min.spe.hh | 1 mln/arith/minus.hh | 15 ++++++--- mln/arith/plus.hh | 12 +++++++ mln/arith/revert.hh | 2 + mln/arith/times.hh | 16 ++++++++++ tests/arith/plus.cc | 81 +++++++++++++++++++++++++++++++++++---------------- 8 files changed, 108 insertions(+), 35 deletions(-) Index: trunk/milena/tests/arith/plus.cc =================================================================== --- trunk/milena/tests/arith/plus.cc (revision 1513) +++ trunk/milena/tests/arith/plus.cc (revision 1514) @@ -31,18 +31,9 @@ */ #include <mln/core/image2d.hh> -#include <mln/core/clone.hh> -#include <mln/value/int_u8.hh> - +#include <mln/debug/iota.hh> #include <mln/arith/plus.hh> -#include <mln/arith/times.hh> #include <mln/level/compare.hh> -#include <mln/fun/v2v/cast.hh> - -#include <mln/debug/iota.hh> -#include <mln/debug/println.hh> - - int main() { @@ -51,29 +42,69 @@ // trace::quiet = false; { - image2d<int> ref(3,3); - debug::iota(ref); + image2d<int> ima(3,3); + debug::iota(ima); - image2d<int> ima_i = clone(ref); - ima_i += ima_i; - mln_assertion(ima_i == 2 * ref); - - debug::println(ima_i); - ima_i += 1; - debug::println(ima_i); - - image2d<float> ima_f(3,3); - debug::iota(ima_f); - debug::println(ima_i + ima_f); + int vs[3][3] = { + { 4, 5, 6}, + { 7, 8, 9}, + {10, 11, 12} + }; - point2d p(0, 0); - std::cout << arith::plus<float>(ima_i, ima_i)(p) / 5 << std::endl; + ima += 2; + image2d<int> ref(make::image2d(vs)); + + mln_assertion (ima + 1 == ref); } } +// #include <mln/core/image2d.hh> +// #include <mln/core/clone.hh> +// #include <mln/value/int_u8.hh> + +// #include <mln/arith/plus.hh> +// #include <mln/arith/times.hh> +// #include <mln/level/compare.hh> +// #include <mln/fun/v2v/cast.hh> + +// #include <mln/debug/iota.hh> +// #include <mln/debug/println.hh> + + + +// int main() +// { +// using namespace mln; + +// // trace::quiet = false; + +// { +// image2d<int> ref(3,3); +// debug::iota(ref); + +// image2d<int> ima_i = clone(ref); +// ima_i += ima_i; +// mln_assertion(ima_i == 2 * ref); + +// debug::println(ima_i); +// ima_i += 1; +// debug::println(ima_i); + +// image2d<float> ima_f(3,3); +// debug::iota(ima_f); +// debug::println(ima_i + ima_f); + +// point2d p(0, 0); +// std::cout << arith::plus<float>(ima_i, ima_i)(p) / 5 << std::endl; +// } + +// } + + + // Bench: // { Index: trunk/milena/mln/arith/times.hh =================================================================== --- trunk/milena/mln/arith/times.hh (revision 1513) +++ trunk/milena/mln/arith/times.hh (revision 1514) @@ -221,35 +221,51 @@ template <typename L, typename R, typename O> void times(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output) { + trace::entering("arith::times"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_precondition(exact(output).domain() == exact(lhs).domain()); impl::times_(mln_trait_image_speed(L)(), exact(lhs), mln_trait_image_speed(R)(), exact(rhs), mln_trait_image_speed(O)(), exact(output)); + + trace::exiting("arith::times"); } template <typename I, typename V, typename O> void times_cst(const Image<I>& input, const V& val, Image<O>& output) { + trace::entering("arith::times_cst"); + mln_precondition(exact(output).domain() == exact(input).domain()); times(input, pw::cst(val) | exact(input).domain(), output); // Calls the previous version. + + trace::exiting("arith::times_cst"); } template <typename L, typename R> void times_inplace(Image<L>& lhs, const Image<R>& rhs) { + trace::entering("arith::times_inplace"); + mln_precondition(exact(rhs).domain() <= exact(lhs).domain()); impl::times_inplace_(mln_trait_image_speed(L)(), exact(lhs), mln_trait_image_speed(R)(), exact(rhs)); + + trace::exiting("arith::times_inplace"); } template <typename I, typename V> void times_cst_inplace(Image<I>& input, const V& val) { + trace::entering("arith::times_cst_inplace"); + mln_precondition(exact(input).has_data()); times_inplace(input, pw::cst(val) | exact(input).domain()); // Calls the previous version. + + trace::exiting("arith::times_cst_inplace"); } } // end of namespace mln::arith Index: trunk/milena/mln/arith/plus.hh =================================================================== --- trunk/milena/mln/arith/plus.hh (revision 1513) +++ trunk/milena/mln/arith/plus.hh (revision 1514) @@ -211,6 +211,7 @@ operator+(const Image<L>& lhs, const Image<R>& rhs) { trace::entering("operator::plus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_trait_op_plus(L,R) output = arith::plus(lhs, rhs); @@ -224,6 +225,7 @@ operator+=(Image<L>& lhs, const Image<R>& rhs) { trace::entering("operator::plus_eq"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); arith::plus_inplace(lhs, rhs); @@ -238,6 +240,7 @@ operator+(const Image<I>& ima, const value::Scalar<S>& s) { trace::entering("operator::plus"); + mln_precondition(exact(ima).has_data()); mln_trait_op_plus(I,S) output = arith::plus_cst(ima, exact(s)); @@ -251,6 +254,7 @@ operator+=(Image<I>& ima, const value::Scalar<S>& s) { trace::entering("operator::plus_eq"); + mln_precondition(exact(ima).has_data()); arith::plus_cst_inplace(ima, exact(s)); @@ -337,6 +341,7 @@ plus(const Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::plus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_trait_op_plus(L, R) output; @@ -354,6 +359,7 @@ plus(const Image<L>& lhs, const Image<R>& rhs, const Function_v2v<F>& f) { trace::entering("arith::plus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_ch_value(L, mln_result(F)) output; @@ -371,6 +377,7 @@ plus(const Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::plus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); // Calls the previous version. @@ -387,6 +394,7 @@ plus_cst(const Image<I>& input, const V& val) { trace::entering("arith::plus_cst"); + mln_precondition(exact(input).has_data()); // Calls the previous version. @@ -403,6 +411,7 @@ plus_cst(const Image<I>& input, const V& val, const Function_v2v<F>& f) { trace::entering("arith::plus_cst"); + mln_precondition(exact(input).has_data()); // Calls the previous version. @@ -420,6 +429,7 @@ plus_cst(const Image<I>& input, const V& val) { trace::entering("arith::plus_cst"); + mln_precondition(exact(input).has_data()); // Calls the previous version. @@ -436,6 +446,7 @@ plus_inplace(Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::plus_inplace"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); impl::plus_inplace_(mln_trait_image_speed(L)(), exact(lhs), @@ -450,6 +461,7 @@ plus_cst_inplace(Image<I>& input, const V& val) { trace::entering("arith::plus_cst_inplace"); + mln_precondition(exact(input).has_data()); // Calls the previous version. Index: trunk/milena/mln/arith/min.hh =================================================================== --- trunk/milena/mln/arith/min.hh (revision 1513) +++ trunk/milena/mln/arith/min.hh (revision 1514) @@ -127,8 +127,8 @@ void min_inplace(Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::min_inplace"); - mln_precondition(exact(rhs).domain() == exact(lhs).domain()); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); impl::min_inplace_(mln_trait_image_speed(L)(), exact(lhs), mln_trait_image_speed(R)(), exact(rhs)); Index: trunk/milena/mln/arith/revert.hh =================================================================== --- trunk/milena/mln/arith/revert.hh (revision 1513) +++ trunk/milena/mln/arith/revert.hh (revision 1514) @@ -113,6 +113,7 @@ mln_concrete(I) revert(const Image<I>& input) { trace::entering("arith::revert"); + mln_precondition(exact(input).has_data()); mln_concrete(I) output; @@ -127,6 +128,7 @@ void revert_inplace(Image<I>& input) { trace::entering("arith::revert_inplace"); + mln_precondition(exact(input).has_data()); impl::revert_(mln_trait_image_speed(I)(), exact(input), exact(input)); Index: trunk/milena/mln/arith/all.hh =================================================================== --- trunk/milena/mln/arith/all.hh (revision 1513) +++ trunk/milena/mln/arith/all.hh (revision 1514) @@ -41,18 +41,24 @@ namespace arith { /// Implementation namespace of arith namespace. - namespace impl {} + namespace impl { + + /// Generic implementation namespace of arith namespace. + namespace generic { + } } + } -# include <mln/arith/plus.hh> -# include <mln/arith/minus.hh> -# include <mln/arith/times.hh> +} # include <mln/arith/min.hh> +# include <mln/arith/minus.hh> +# include <mln/arith/plus.hh> # include <mln/arith/revert.hh> +# include <mln/arith/times.hh> #endif // ! MLN_ARITH_ALL_HH Index: trunk/milena/mln/arith/min.spe.hh =================================================================== --- trunk/milena/mln/arith/min.spe.hh (revision 1513) +++ trunk/milena/mln/arith/min.spe.hh (revision 1514) @@ -53,7 +53,6 @@ template <typename L, typename R> void min_inplace_(L& lhs, const R& rhs); - } template <typename L, typename R, typename O> Index: trunk/milena/mln/arith/minus.hh =================================================================== --- trunk/milena/mln/arith/minus.hh (revision 1513) +++ trunk/milena/mln/arith/minus.hh (revision 1514) @@ -197,8 +197,8 @@ operator-(const Image<L>& lhs, const Image<R>& rhs) { trace::entering("operator::minus"); - mln_precondition(exact(rhs).domain() == exact(lhs).domain()); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_trait_op_minus(L,R) output = arith::minus(lhs, rhs); trace::exiting("operator::minus"); @@ -210,8 +210,8 @@ operator-=(Image<L>& lhs, const Image<R>& rhs) { trace::entering("operator::minus_eq"); - mln_precondition(exact(rhs).domain() == exact(lhs).domain()); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); arith::minus_inplace(lhs, rhs); trace::exiting("operator::minus_eq"); @@ -224,8 +224,8 @@ operator-(const Image<I>& ima, const value::Scalar<S>& s) { trace::entering("operator::minus"); - mln_precondition(exact(ima).has_data()); + mln_precondition(exact(ima).has_data()); mln_trait_op_minus(I,S) output = arith::minus_cst(ima, exact(s)); trace::exiting("operator::minus"); @@ -237,8 +237,8 @@ operator-=(Image<I>& ima, const value::Scalar<S>& s) { trace::entering("operator::minus_eq"); - mln_precondition(exact(ima).has_data()); + mln_precondition(exact(ima).has_data()); arith::minus_cst_inplace(ima, exact(s)); trace::exiting("operator::minus_eq"); @@ -323,6 +323,7 @@ minus(const Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::minus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_trait_op_minus(L, R) output; @@ -340,6 +341,7 @@ minus(const Image<L>& lhs, const Image<R>& rhs, const Function_v2v<F>& f) { trace::entering("arith::minus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); mln_ch_value(L, mln_result(F)) output; @@ -357,6 +359,7 @@ minus(const Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::minus"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); // Calls the previous version. @@ -373,6 +376,7 @@ minus_cst(const Image<I>& input, const V& val) { trace::entering("arith::minus_cst"); + mln_precondition(exact(input).has_data()); // Calls the previous version. @@ -389,6 +393,7 @@ minus_cst(const Image<I>& input, const V& val, const Function_v2v<F>& f) { trace::entering("arith::minus_cst"); + mln_precondition(exact(input).has_data()); // Calls the previous version. @@ -406,6 +411,7 @@ minus_inplace(Image<L>& lhs, const Image<R>& rhs) { trace::entering("arith::minus_inplace"); + mln_precondition(exact(rhs).domain() == exact(lhs).domain()); impl::minus_inplace_(mln_trait_image_speed(L)(), exact(lhs), @@ -420,6 +426,7 @@ minus_cst_inplace(Image<I>& input, const V& val) { trace::entering("arith::minus_cst_inplace"); + mln_precondition(exact(input).has_data()); // Calls the previous version.