URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update level and add specialization for algorithm.
* mln/level/assign.hh,
* mln/level/fill.hh,
* mln/level/take.hh,
* mln/level/apply.hh: Remove specialization stuff and add
generic namespace.
Specialization files
* mln/level/assign.spe.hh,
* mln/level/fill.spe.hh,
* mln/level/take.spe.hh,
* mln/level/apply.spe.hh: New file for specialization.
Update
* mln/level/abs.hh,
* mln/level/all.hh,
* mln/level/compare.hh,
* mln/level/sort_points.hh: Update.
---
abs.hh | 4 ++
all.hh | 1
apply.hh | 24 +++++++++-----
apply.spe.hh | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
assign.hh | 32 ++++++++++++-------
assign.spe.hh | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fill.hh | 38 ++++++++++++++++++-----
fill.spe.hh | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
take.hh | 24 +++++++++-----
take.spe.hh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 440 insertions(+), 39 deletions(-)
Index: trunk/milena/mln/level/sort_points.hh
===================================================================
Index: trunk/milena/mln/level/take.hh
===================================================================
--- trunk/milena/mln/level/take.hh (revision 1488)
+++ trunk/milena/mln/level/take.hh (revision 1489)
@@ -36,6 +36,8 @@
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/level/take.spe.hh>
namespace mln
{
@@ -62,22 +64,22 @@
namespace impl
{
+ namespace generic
+ {
template <typename A, typename I>
- void take(trait::image::speed::any, const I& input, A& a)
+ void take_(const I& input, A& a)
{
+ trace::entering("level::impl::generic::take");
+
mln_piter(I) p(input.domain());
for_all(p)
a.take(input(p));
- }
- template <typename A, typename I>
- void take(trait::image::speed::fastest, const I& input, A& a)
- {
- mln_pixter(const I) pxl(input);
- for_all(pxl)
- a.take(pxl.val());
+ trace::exiting("level::impl::generic::take");
}
+ } // end of namespace mln::level::impl::generic
+
} // end of namespace mln::level::impl
@@ -86,9 +88,13 @@
template <typename A, typename I>
void take(const Image<I>& input, Accumulator<A>& a)
{
+ trace::entering("level::take");
+
mln_precondition(exact(input).has_data());
- impl::take(mln_trait_image_speed(I)(), exact(input),
+ impl::take_(mln_trait_image_speed(I)(), exact(input),
exact(a));
+
+ trace::exiting("level::take");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/assign.hh
===================================================================
--- trunk/milena/mln/level/assign.hh (revision 1488)
+++ trunk/milena/mln/level/assign.hh (revision 1489)
@@ -38,6 +38,11 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/level/assign.spe.hh>
+
+
+
namespace mln
{
@@ -64,34 +69,37 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R>
- void assign(trait::image::speed::any, L& target,
- trait::image::speed::any, const R& data)
+ void assign_(L& target, const R& data)
{
+ trace::entering("level::impl::generic::assign_");
+
mln_piter(L) p(target.domain());
for_all(p)
target(p) = data(p);
- }
- template <typename L, typename R>
- void assign(trait::image::speed::fastest, L& target,
- trait::image::speed::fastest, const R& data)
- {
- mln_pixter(L) lhs(target);
- mln_pixter(const R) rhs(data);
- for_all_2(lhs, rhs)
- lhs.val() = rhs.val();
+ trace::exiting("level::impl::generic::assign_");
}
+ } // end of namespace mln::level::impl::generic
+
} // end of namespace mln::level::impl
+ // Facade.
+
template <typename L, typename R>
void assign(Image<L>& target, const Image<R>& data)
{
+ trace::entering("level::assign");
+
mln_precondition(exact(data).domain() == exact(target).domain());
- impl::assign(mln_trait_image_speed(L)(), exact(target),
+ impl::assign_(mln_trait_image_speed(L)(), exact(target),
mln_trait_image_speed(R)(), exact(data));
+
+ trace::exiting("level::assign");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/apply.hh
===================================================================
--- trunk/milena/mln/level/apply.hh (revision 1488)
+++ trunk/milena/mln/level/apply.hh (revision 1489)
@@ -36,6 +36,9 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
+// Specializations are in:
+# include <mln/level/apply.spe.hh>
+
namespace mln
{
@@ -66,22 +69,23 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename I, typename F>
- void apply_(trait::image::speed::any, I& input, const F& f)
+ void apply_(I& input, const F& f)
{
+ trace::entering("level::impl::generic::apply_");
+
mln_piter(I) p(input.domain());
for_all(p)
input(p) = f(input(p));
- }
- template <typename I, typename F>
- void apply_(trait::image::speed::fastest, I& input, const F& f)
- {
- mln_pixter(I) pxl(input);
- for_all(pxl)
- pxl.val() = f(pxl.val());
+ trace::exiting("level::impl::generic::apply_");
}
+ } // end of namespace mln::level::impl::generic
+
} // end of namespace mln::level::impl
@@ -90,9 +94,13 @@
template <typename I, typename F>
void apply(Image<I>& input, const Function_v2v<F>& f)
{
+ trace::entering("level::apply");
+
mln_precondition(exact(input).has_data());
impl::apply_(mln_trait_image_speed(I)(), exact(input),
exact(f));
+
+ trace::exiting("level::apply");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/compare.hh
===================================================================
Index: trunk/milena/mln/level/fill.hh
===================================================================
--- trunk/milena/mln/level/fill.hh (revision 1488)
+++ trunk/milena/mln/level/fill.hh (revision 1489)
@@ -43,6 +43,9 @@
# include <mln/level/memset_.hh>
+// Specializations are in:
+# include <mln/level/fill.spe.hh>
+
namespace mln
{
@@ -132,25 +135,22 @@
namespace impl
{
-
- // fill_with_value
-
+ namespace generic
+ {
template <typename I>
void fill_with_value(trait::image::speed::any, I& ima,
const mln_value(I)& value)
{
+ trace::entering("level::impl::generic::fill_with_value");
+
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = value;
- }
- template <typename I>
- void fill_with_value(trait::image::speed::fastest, I& ima,
- const mln_value(I)& value)
- {
- level::memset_(ima, ima.point_at_offset(0), value, ima.ncells());
+ trace::exiting("level::impl::generic::fill_with_value");
}
+ } // end if namespace mln::level::impl::generic
} // end of namespace mln::level::impl
@@ -161,10 +161,14 @@
template <typename I>
void fill(Image<I>& ima, const mln_value(I)& value)
{
+ trace::entering("level::fill");
+
mlc_is(mln_trait_image_io(I), trait::image::io::write)::check(); // FIXME: Only the
upcoming general facade!!!
mln_precondition(exact(ima).has_data());
impl::fill_with_value(mln_trait_image_speed(I)(), exact(ima),
value);
+
+ trace::exiting("level::fill");
}
@@ -173,12 +177,16 @@
template <typename I, typename F>
void fill(Image<I>& ima_, const Function_p2v<F>& f_)
{
+ trace::entering("level::fill");
+
I& ima = exact(ima_);
mln_precondition(ima.has_data());
const F& f = exact(f_);
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = f(p);
+
+ trace::exiting("level::fill");
}
@@ -188,12 +196,16 @@
void fill_f(Image<I>& ima_,
mln_value(I) (*f)(const mln_point(I)& p))
{
+ trace::entering("level::fill_f");
+
mln_precondition(f != 0);
I& ima = exact(ima_);
mln_precondition(ima.has_data());
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = f(p);
+
+ trace::exiting("level::fill_f");
}
@@ -202,6 +214,8 @@
template <typename I, unsigned N>
void fill(Image<I>& ima_, mln_value(I) (&arr)[N])
{
+ trace::entering("level::fill");
+
I& ima = exact(ima_);
mln_precondition(ima.has_data());
mln_precondition(N == ima.npoints());
@@ -209,6 +223,8 @@
unsigned i = 0;
for_all(p)
ima(p) = arr[i++];
+
+ trace::exiting("level::fill");
}
@@ -217,6 +233,8 @@
template <typename I, typename J>
void fill(Image<I>& ima_, const Image<J>& data_)
{
+ trace::entering("level::fill");
+
I& ima = exact(ima_);
const J& data = exact(data_);
mln_precondition(ima.domain() <= data.domain());
@@ -224,6 +242,8 @@
mln_piter(I) p(ima.domain());
for_all(p)
ima(p) = data(p);
+
+ trace::exiting("level::fill");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/abs.hh
===================================================================
--- trunk/milena/mln/level/abs.hh (revision 1488)
+++ trunk/milena/mln/level/abs.hh (revision 1489)
@@ -68,15 +68,19 @@
template <typename I, typename O>
void abs(const Image<I>& input, Image<O>& output)
{
+ trace::entering("level::abs");
mln_precondition(exact(input).domain() == exact(output).domain());
level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+ trace::exiting("level::abs");
}
template <typename I>
void abs_inplace(Image<I>& input)
{
+ trace::entering("level::abs_inplace");
mln_precondition(exact(input).has_data());
level::apply(input, fun::v2v::abs<mln_value(I)>());
+ trace::exiting("level::abs_inplace");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/level/all.hh
===================================================================
--- trunk/milena/mln/level/all.hh (revision 1488)
+++ trunk/milena/mln/level/all.hh (revision 1489)
@@ -47,7 +47,6 @@
}
# include <mln/level/abs.hh>
-# include <mln/level/all.hh>
# include <mln/level/apply.hh>
# include <mln/level/approx/all.hh>
# include <mln/level/assign.hh>
Index: trunk/milena/mln/level/assign.spe.hh
===================================================================
--- trunk/milena/mln/level/assign.spe.hh (revision 0)
+++ trunk/milena/mln/level/assign.spe.hh (revision 1489)
@@ -0,0 +1,92 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_LEVEL_ASSIGN_SPE_HH
+# define MLN_LEVEL_ASSIGN_SPE_HH
+
+/*! \file mln/level/assign.spe.hh
+ *
+ * \brief Specializations for mln::level::assign.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R>
+ void assign_(L& target, const R& data);
+ }
+
+
+ // Disjunction.
+
+
+ template <typename L, typename R>
+ void assign_(trait::image::speed::any, L& target,
+ trait::image::speed::any, const R& data)
+ {
+ generic::assign_(target, data);
+ }
+
+ template <typename L, typename R>
+ void assign_(trait::image::speed::fastest, L& target,
+ trait::image::speed::fastest, const R& data)
+ {
+ trace::entering("level::impl::assign_");
+
+ mln_pixter(L) lhs(target);
+ mln_pixter(const R) rhs(data);
+ for_all_2(lhs, rhs)
+ lhs.val() = rhs.val();
+
+ trace::exiting("level::impl::assign_");
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LEVEL_ASSIGN_SPE_HH
Index: trunk/milena/mln/level/take.spe.hh
===================================================================
--- trunk/milena/mln/level/take.spe.hh (revision 0)
+++ trunk/milena/mln/level/take.spe.hh (revision 1489)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_LEVEL_TAKE_SPE_HH
+# define MLN_LEVEL_TAKE_SPE_HH
+
+/*! \file mln/level/take.spe.hh
+ *
+ * \brief Specializations for mln::level::take.
+ */
+
+# include <mln/core/concept/accumulator.hh>
+# include <mln/core/concept/image.hh>
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename A, typename I>
+ void take_(const I& input, A& a);
+ }
+
+ template <typename A, typename I>
+ void take_(trait::image::speed::any, const I& input, A& a)
+ {
+ generic::take_(input, a);
+ }
+
+ template <typename A, typename I>
+ void take_(trait::image::speed::fastest, const I& input, A& a)
+ {
+ trace::entering("level::impl::take");
+
+ mln_pixter(const I) pxl(input);
+ for_all(pxl)
+ a.take(pxl.val());
+
+ trace::exiting("level::impl::take");
+ }
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LEVEL_TAKE_HH
Index: trunk/milena/mln/level/apply.spe.hh
===================================================================
--- trunk/milena/mln/level/apply.spe.hh (revision 0)
+++ trunk/milena/mln/level/apply.spe.hh (revision 1489)
@@ -0,0 +1,89 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_LEVEL_APPLY_SPE_HH
+# define MLN_LEVEL_APPLY_SPE_HH
+
+/*! \file mln/level/apply.spe.hh
+ *
+ * \brief Specializations for mln::level::apply.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I, typename F>
+ void apply_(I& input, const F& f);
+ }
+
+
+ // Disjunction.
+
+ template <typename I, typename F>
+ void apply_(trait::image::speed::any, I& input, const F& f)
+ {
+ generic::apply_(input, f);
+ }
+
+ template <typename I, typename F>
+ void apply_(trait::image::speed::fastest, I& input, const F& f)
+ {
+ trace::entering("level::impl::apply_");
+
+ mln_pixter(I) pxl(input);
+ for_all(pxl)
+ pxl.val() = f(pxl.val());
+
+ trace::exiting("level::impl::apply_");
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+#endif // ! MLN_LEVEL_APPLY_HH
Index: trunk/milena/mln/level/fill.spe.hh
===================================================================
--- trunk/milena/mln/level/fill.spe.hh (revision 0)
+++ trunk/milena/mln/level/fill.spe.hh (revision 1489)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_LEVEL_FILL_SPE_HH
+# define MLN_LEVEL_FILL_SPE_HH
+
+/*! \file mln/level/fill.spe.hh
+ *
+ * \brief Specializations for mln::level::fill.
+ *
+ */
+
+# include <cstring>
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/inplace.hh>
+# include <mln/level/memset_.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I>
+ void fill_with_value(I& ima, const mln_value(I)& value);
+ }
+
+
+ // Disjunction.
+
+
+ template <typename I>
+ void fill_with_value(trait::image::speed::any, I& ima,
+ const mln_value(I)& value)
+ {
+ generic::fill_with_value(ima, value);
+ }
+
+ template <typename I>
+ void fill_with_value(trait::image::speed::fastest, I& ima,
+ const mln_value(I)& value)
+ {
+ trace::entering("level::impl::fill_with_value");
+
+ level::memset_(ima, ima.point_at_offset(0), value, ima.ncells());
+
+ trace::exiting("level::impl::fill_with_value");
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LEVEL_FILL_SPE_HH