* mln/arith/revert.hh: Here.
* mln/arith/revert.spe.hh: Remove.
* mln/fun/v2v/revert.hh: New.
---
milena/ChangeLog | 10 +++
milena/mln/arith/revert.hh | 97 ++---------------------
milena/mln/arith/revert.spe.hh | 84 --------------------
milena/mln/fun/{vv2v/span.hh => v2v/revert.hh} | 32 +++++----
4 files changed, 37 insertions(+), 186 deletions(-)
delete mode 100644 milena/mln/arith/revert.spe.hh
copy milena/mln/fun/{vv2v/span.hh => v2v/revert.hh} (72%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index cafb263..078df3a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-04 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Make use of data::transform in arith::revert.
+
+ * mln/arith/revert.hh: Here.
+
+ * mln/arith/revert.spe.hh: Remove.
+
+ * mln/fun/v2v/revert.hh: New.
+
2012-11-29 Guillaume Lazzara <z(a)lrde.epita.fr>
Remove kn::internal::display.
diff --git a/milena/mln/arith/revert.hh b/milena/mln/arith/revert.hh
index 2ac3710..eefcb83 100644
--- a/milena/mln/arith/revert.hh
+++ b/milena/mln/arith/revert.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,19 +30,11 @@
/// \file
///
/// Point-wise revert (min -> max and max -> min) of images.
-///
-/// \todo Add static assertion and save one iterator in in-place version.
# include <mln/core/concept/image.hh>
-# include <mln/trait/value_.hh>
-
-// Specializations are in:
-# include <mln/arith/revert.spe.hh>
-
-
-// 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.)
+# include <mln/fun/v2v/revert.hh>
+# include <mln/data/transform.hh>
+# include <mln/data/transform_inplace.hh>
namespace mln
@@ -82,77 +74,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
-
- namespace generic
- {
-
- template <typename I, typename O>
- inline
- 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)
- output(p) = mln_min(V) + (mln_max(V) - input(p));
-
- trace::exiting("arith::impl::generic::revert_");
- }
-
- } // end of namespace mln::arith::impl::generic
-
- } // 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>
inline
mln_concrete(I) revert(const Image<I>& input)
@@ -161,9 +82,8 @@ namespace mln
mln_precondition(exact(input).is_valid());
- mln_concrete(I) output;
- initialize(output, input);
- internal::revert_dispatch(exact(input), exact(output));
+ typedef mln_value(I) V;
+ mln_concrete(I) output = data::transform(input, fun::v2v::revert<V>());
trace::exiting("arith::revert");
return output;
@@ -177,7 +97,8 @@ namespace mln
mln_precondition(exact(input).is_valid());
- internal::revert_dispatch(exact(input), exact(input));
+ typedef mln_value(I) V;
+ data::transform_inplace(input, fun::v2v::revert<V>());
trace::exiting("arith::revert_inplace");
}
diff --git a/milena/mln/arith/revert.spe.hh b/milena/mln/arith/revert.spe.hh
deleted file mode 100644
index 2df8bc0..0000000
--- a/milena/mln/arith/revert.spe.hh
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef MLN_ARITH_REVERT_SPE_HH
-# define MLN_ARITH_REVERT_SPE_HH
-
-/// \file
-///
-/// Specializations for mln::arith::revert.
-
-# ifndef MLN_ARITH_REVERT_HH
-# error "Forbidden inclusion of *.spe.hh"
-# endif // ! MLN_ARITH_REVERT_HH
-
-# include <mln/core/concept/image.hh>
-# include <mln/trait/value_.hh>
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-namespace mln
-{
-
- namespace arith
- {
-
- namespace impl
- {
-
- // FIXME: This is a fast implementation not a fastest one!
- template <typename I, typename O>
- inline
- void revert_fastest(const Image<I>& input_, Image<O>& output_)
- {
- trace::entering("arith::impl::revert_fastest");
-
- 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);
- mln_pixter(O) op(output);
- for_all_2(ip, op)
- op.val() = mln_min(V) + (mln_max(V) - ip.val());
-
- trace::entering("arith::impl::revert_fastest");
- }
-
- } // end of namespace mln::arith::impl
-
- } // end of namespace mln::arith
-
-} // end of namespace mln
-
-# endif // ! MLN_INCLUDE_ONLY
-
-#endif // ! MLN_ARITH_REVERT_SPE_HH
diff --git a/milena/mln/fun/vv2v/span.hh b/milena/mln/fun/v2v/revert.hh
similarity index 72%
copy from milena/mln/fun/vv2v/span.hh
copy to milena/mln/fun/v2v/revert.hh
index 680db34..b62fd26 100644
--- a/milena/mln/fun/vv2v/span.hh
+++ b/milena/mln/fun/v2v/revert.hh
@@ -23,15 +23,18 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_FUN_VV2V_SPAN_HH
-# define MLN_FUN_VV2V_SPAN_HH
+#ifndef MLN_FUN_V2V_REVERT_HH
+# define MLN_FUN_V2V_REVERT_HH
/// \file
///
-/// Functor that computes the spanimum of two values.
+/// Function reverting given values.
-# include <mln/math/span.hh>
-# include <mln/core/concept/function.hh>
+// FIXME: Revert on int value 0 does not give 0 (since min != - max;
+// idem for float etc.)
+
+
+# include <mln/fun/internal/selector.hh>
namespace mln
@@ -40,18 +43,19 @@ namespace mln
namespace fun
{
- namespace vv2v
+ namespace v2v
{
- // FIXME: Doc.
+ // FIXME: Doc!
- /// \brief A functor computing the span of two interval values.
template <typename T, typename R = T>
- struct span : public Function_vv2v< span<T,R> >
+ struct revert
+ : fun::internal::selector_<R, T, revert<T,R> >::ret
{
typedef R result;
+ typedef T argument;
- R operator()(const T& v1, const T& v2) const;
+ R operator()(const T& v) const;
};
@@ -59,18 +63,18 @@ namespace mln
template <typename T, typename R>
R
- span<T,R>::operator()(const T& v1, const T& v2) const
+ revert<T,R>::operator()(const T& v) const
{
- return R(math::span(v1, v2));
+ return static_cast<R>(mln_min(T) + (mln_max(T) - v));
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::fun::vv2v
+ } // end of namespace mln::fun::v2v
} // end of namespace mln::fun
} // end of namespace mln
-#endif // ! MLN_FUN_VV2V_SPAN_HH
+#endif // ! MLN_FUN_V2V_REVERT_HH
--
1.7.2.5