* mln/arith/revert.hh,
* mln/arith/revert.spe.hh: Add a standard dispatch.
---
milena/ChangeLog | 7 +++++
milena/mln/arith/revert.hh | 56 ++++++++++++++++++++++++++++++++++++---
milena/mln/arith/revert.spe.hh | 28 ++++++++-----------
3 files changed, 70 insertions(+), 21 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b72dafb..fcb0afe 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Improve dispatch in arith::revert routine.
+
+ * mln/arith/revert.hh,
+ * mln/arith/revert.spe.hh: Add a standard dispatch.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/data/paste_without_localization.hh: Remove duplicate
declarations.
diff --git a/milena/mln/arith/revert.hh b/milena/mln/arith/revert.hh
index 60f46af..2ac3710 100644
--- a/milena/mln/arith/revert.hh
+++ b/milena/mln/arith/revert.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -40,7 +41,8 @@
// FIXME: Rely instead on mln/fun/v2v/revert.hh.
-// FIXME: Revert on int value 0 does not give 0 (since min != - max; idem for float
etc.)
+// FIXME: Revert on int value 0 does not give 0 (since min != - max;
+// idem for float etc.)
namespace mln
@@ -88,10 +90,17 @@ namespace mln
template <typename I, typename O>
inline
- void revert_(const I& input, O& output)
+ void revert(const Image<I>& input_, Image<O>& output_)
{
trace::entering("arith::impl::generic::revert_");
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(output.is_valid());
+ mln_precondition(input.domain() == output.domain());
+
typedef mln_value(I) V;
mln_piter(I) p(input.domain());
for_all(p)
@@ -105,6 +114,43 @@ namespace mln
} // end of namespace mln::arith::impl
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I, typename O>
+ inline
+ void
+ revert_dispatch(trait::image::speed::any, const I& input, O& output)
+ {
+ impl::generic::revert(input, output);
+ }
+
+ template <typename I, typename O>
+ inline
+ void
+ revert_dispatch(trait::image::speed::fastest, const I& input, O& output)
+ {
+ impl::revert_fastest(input, output);
+ }
+
+ template <typename I, typename O>
+ inline
+ void
+ revert_dispatch(const Image<I>& input, Image<O>& output)
+ {
+ revert_dispatch(mln_trait_image_speed(I)(),
+ exact(input), exact(output));
+
+ }
+
+
+ } // end of namespace mln::arith::internal
+
+
+
// Facades.
template <typename I>
@@ -117,7 +163,7 @@ namespace mln
mln_concrete(I) output;
initialize(output, input);
- impl::revert_(mln_trait_image_speed(I)(), exact(input), output);
+ internal::revert_dispatch(exact(input), exact(output));
trace::exiting("arith::revert");
return output;
@@ -131,7 +177,7 @@ namespace mln
mln_precondition(exact(input).is_valid());
- impl::revert_(mln_trait_image_speed(I)(), exact(input), exact(input));
+ internal::revert_dispatch(exact(input), exact(input));
trace::exiting("arith::revert_inplace");
}
diff --git a/milena/mln/arith/revert.spe.hh b/milena/mln/arith/revert.spe.hh
index 6fef77c..2df8bc0 100644
--- a/milena/mln/arith/revert.spe.hh
+++ b/milena/mln/arith/revert.spe.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -49,24 +50,19 @@ namespace mln
namespace impl
{
- namespace generic
- {
- template <typename I, typename O>
- void revert_(const I& input, O& output);
- }
-
+ // FIXME: This is a fast implementation not a fastest one!
template <typename I, typename O>
inline
- void revert_(trait::image::speed::any, const I& input, O& output)
+ void revert_fastest(const Image<I>& input_, Image<O>& output_)
{
- generic::revert_(input, output);
- }
+ trace::entering("arith::impl::revert_fastest");
- template <typename I, typename O>
- inline
- void revert_(trait::image::speed::fastest, const I& input, O& output)
- {
- trace::entering("arith::impl::revert_");
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(output.is_valid());
+ mln_precondition(input.domain() == output.domain());
typedef mln_value(I) V;
mln_pixter(const I) ip(input);
@@ -74,7 +70,7 @@ namespace mln
for_all_2(ip, op)
op.val() = mln_min(V) + (mln_max(V) - ip.val());
- trace::entering("arith::impl::revert_");
+ trace::entering("arith::impl::revert_fastest");
}
} // end of namespace mln::arith::impl
--
1.5.6.5