URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-19 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Review logical subdirectory and add tests.
Update
* mln/logical/and.hh,
* mln/logical/and_not.hh,
* mln/logical/not.hh,
* mln/logical/or.hh: Add tracing, generic namespace, remove
specializations and check typo.
* mln/logical/and.spe.hh,
* mln/logical/and_not.spe.hh,
* mln/logical/not.spe.hh,
* mln/logical/or.spe.hh: New specializations for logical.
Tests
* tests/Makefile.am: Add logical subdirectory.
* tests/logical: New subdirectory for logical checking.
* tests/logical/Makefile.am: Add test to check.
* tests/logical/and.cc,
* tests/logical/and_not.cc,
* tests/logical/not.cc,
* tests/logical/or.cc: New tests for logical.
---
mln/logical/and.hh | 24 ++++++------
mln/logical/and.spe.hh | 87 ++++++++++++++++++++++++++++++++++++++++++++
mln/logical/and_not.hh | 24 ++++++------
mln/logical/and_not.spe.hh | 88 +++++++++++++++++++++++++++++++++++++++++++++
mln/logical/not.hh | 19 +++++----
mln/logical/not.spe.hh | 84 ++++++++++++++++++++++++++++++++++++++++++
mln/logical/or.hh | 21 ++++------
mln/logical/or.spe.hh | 86 +++++++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 1
tests/logical/Makefile.am | 16 ++++++++
tests/logical/and.cc | 65 +++++++++++++++++++++++++++++++++
tests/logical/and_not.cc | 64 ++++++++++++++++++++++++++++++++
tests/logical/not.cc | 58 +++++++++++++++++++++++++++++
tests/logical/or.cc | 65 +++++++++++++++++++++++++++++++++
14 files changed, 657 insertions(+), 45 deletions(-)
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1498)
+++ trunk/milena/tests/Makefile.am (revision 1499)
@@ -5,6 +5,7 @@
SUBDIRS = norm \
level \
arith \
+ logical \
border
check_PROGRAMS = \
Index: trunk/milena/tests/logical/not.cc
===================================================================
--- trunk/milena/tests/logical/not.cc (revision 0)
+++ trunk/milena/tests/logical/not.cc (revision 1499)
@@ -0,0 +1,58 @@
+// 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.
+
+/*! \file tests/logical/not.cc
+ *
+ * \brief Tests on mln::logical::not.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/not.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool ws[3][3] = {
+ {0, 1, 0},
+ {1, 0, 1},
+ {0, 1, 0}
+ };
+
+ image2d<bool> ima (make::image2d(vs));
+ image2d<bool> ref (make::image2d(ws));
+
+ mln_assertion (logical::not_(ima) == ref);
+}
Index: trunk/milena/tests/logical/or.cc
===================================================================
--- trunk/milena/tests/logical/or.cc (revision 0)
+++ trunk/milena/tests/logical/or.cc (revision 1499)
@@ -0,0 +1,65 @@
+// 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.
+
+/*! \file tests/logical/or.cc
+ *
+ * \brief Tests on mln::logical::or.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/or.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool us[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {1, 1, 1}
+ };
+
+ bool ws[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {1, 1, 1}
+ };
+
+ image2d<bool> ima1 (make::image2d(vs));
+ image2d<bool> ima2 (make::image2d(us));
+ image2d<bool> ref (make::image2d(ws));
+
+ mln_assertion (logical::or_(ima1, ima2) == ref);
+}
Index: trunk/milena/tests/logical/and.cc
===================================================================
--- trunk/milena/tests/logical/and.cc (revision 0)
+++ trunk/milena/tests/logical/and.cc (revision 1499)
@@ -0,0 +1,65 @@
+// 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.
+
+/*! \file tests/logical/and.cc
+ *
+ * \brief Tests on mln::logical::and.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/and.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool us[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {1, 1, 1}
+ };
+
+ bool ws[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ image2d<bool> ima1 (make::image2d(vs));
+ image2d<bool> ima2 (make::image2d(us));
+ image2d<bool> ref (make::image2d(ws));
+
+ mln_assertion (logical::and_(ima1, ima2) == ref);
+}
Index: trunk/milena/tests/logical/and_not.cc
===================================================================
--- trunk/milena/tests/logical/and_not.cc (revision 0)
+++ trunk/milena/tests/logical/and_not.cc (revision 1499)
@@ -0,0 +1,64 @@
+// 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.
+
+/*! \file tests/logical/and_not.cc
+ *
+ * \brief Tests on mln::logical::and_not.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/logical/and_not.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ bool vs[3][3] = {
+ {1, 0, 1},
+ {0, 1, 0},
+ {1, 0, 1}
+ };
+
+ bool us[3][3] = {
+ {1, 1, 1},
+ {0, 1, 0},
+ {0, 1, 0}
+ };
+
+ bool ws[3][3] = {
+ {0, 0, 0},
+ {0, 0, 0},
+ {1, 0, 1}
+ };
+
+ image2d<bool> ima1 (make::image2d(vs));
+ image2d<bool> ima2 (make::image2d(us));
+ image2d<bool> ref (make::image2d(ws));
+ mln_assertion (logical::and_not(ima1, ima2) == ref);
+}
Index: trunk/milena/tests/logical/Makefile.am
===================================================================
--- trunk/milena/tests/logical/Makefile.am (revision 0)
+++ trunk/milena/tests/logical/Makefile.am (revision 1499)
@@ -0,0 +1,16 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ and \
+ and_not \
+ not \
+ or
+
+and_SOURCES = and.cc
+and_not_SOURCES = and_not.cc
+not_SOURCES = not.cc
+or_SOURCES = or.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/logical/and_not.hh
===================================================================
--- trunk/milena/mln/logical/and_not.hh (revision 1498)
+++ trunk/milena/mln/logical/and_not.hh (revision 1499)
@@ -37,6 +37,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/and_not.spe.hh>
+
namespace mln
{
@@ -76,24 +79,19 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R, typename O>
- void and_not_(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void and_not_(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("logical::impl::generic::and_not_");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) && ! rhs(p);
- }
- template <typename L, typename R, typename O>
- void and_not_(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() && ! rp.val();
+ trace::exiting("logical::impl::generic::and_not_");
+ }
}
} // end of namespace mln::logical::impl
@@ -105,6 +103,7 @@
mln_concrete(L) and_not(const Image<L>& lhs, const Image<R>&
rhs)
{
trace::entering("logical::and_not");
+
mln_precondition(exact(rhs).domain() == exact(lhs).domain());
mln_concrete(L) output;
@@ -120,6 +119,7 @@
void and_not_inplace(Image<L>& lhs, const Image<R>& rhs)
{
trace::entering("logical::and_not_inplace");
+
mln_precondition(exact(rhs).domain() >= exact(lhs).domain());
impl::and_not_(mln_trait_image_speed(L)(), exact(lhs),
Index: trunk/milena/mln/logical/and.hh
===================================================================
--- trunk/milena/mln/logical/and.hh (revision 1498)
+++ trunk/milena/mln/logical/and.hh (revision 1499)
@@ -37,6 +37,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/and.spe.hh>
+
namespace mln
{
@@ -76,26 +79,23 @@
namespace impl
{
+ namespace generic
+ {
+
template <typename L, typename R, typename O>
- void and__(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void and__(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("logical::impl::generic::and__");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) && rhs(p);
- }
- template <typename L, typename R, typename O>
- void and__(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() && rp.val();
+ trace::exiting("logical::impl::generic::and__");
}
+ } // end of namespace mln::logical::impl::generic
+
} // end of namespace mln::logical::impl
Index: trunk/milena/mln/logical/or.spe.hh
===================================================================
--- trunk/milena/mln/logical/or.spe.hh (revision 0)
+++ trunk/milena/mln/logical/or.spe.hh (revision 1499)
@@ -0,0 +1,86 @@
+// 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_LOGICAL_OR_SPE_HH
+# define MLN_LOGICAL_OR_SPE_HH
+
+/*! \file mln/logical/or.spe.hh
+ *
+ * \brief Specializations for mln::logical::or.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void or__(const L& lhs, const R& rhs, O& output);
+ }
+
+ template <typename L, typename R, typename O>
+ void or__(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::or__(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void or__(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("logical::impl::or__");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() || rp.val();
+
+ trace::entering("logical::impl::or__");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_OR_SPE_HH
Index: trunk/milena/mln/logical/not.spe.hh
===================================================================
--- trunk/milena/mln/logical/not.spe.hh (revision 0)
+++ trunk/milena/mln/logical/not.spe.hh (revision 1499)
@@ -0,0 +1,84 @@
+// 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_LOGICAL_NOT_SPE_HH
+# define MLN_LOGICAL_NOT_SPE_HH
+
+/*! \file mln/logical/not.spe.hh
+ *
+ * \brief Specializations for mln::logical::not.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename I, typename O>
+ void not__(const I& input, O& output);
+ }
+
+ template <typename I, typename O>
+ void not__(trait::image::speed::any, const I& input, O& output)
+ {
+ generic::not__(input, output);
+ }
+
+ template <typename I, typename O>
+ void not__(trait::image::speed::fastest, const I& input, O& output)
+ {
+ trace::entering("logical::impl::not__");
+
+ mln_pixter(const I) ip(input);
+ mln_pixter(O) op(output);
+ for_all_2(ip, op)
+ op.val() = ! ip.val();
+
+ trace::exiting("logical::impl::not__");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_NOT_HH
Index: trunk/milena/mln/logical/and_not.spe.hh
===================================================================
--- trunk/milena/mln/logical/and_not.spe.hh (revision 0)
+++ trunk/milena/mln/logical/and_not.spe.hh (revision 1499)
@@ -0,0 +1,88 @@
+// 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_LOGICAL_AND_NOT_SPE_HH
+# define MLN_LOGICAL_AND_NOT_SPE_HH
+
+/*! \file mln/logical/and_not.spe.hh
+ *
+ * \brief Specializations for mln::logical::and_not.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void and_not_(const L& lhs, const R& rhs, O& output);
+ }
+
+
+ template <typename L, typename R, typename O>
+ void and_not_(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::and_not_(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void and_not_(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("logical::impl::and_not_");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() && ! rp.val();
+
+ trace::exiting("logical::impl::and_not_");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_AND_NOT_SPE_HH
Index: trunk/milena/mln/logical/and.spe.hh
===================================================================
--- trunk/milena/mln/logical/and.spe.hh (revision 0)
+++ trunk/milena/mln/logical/and.spe.hh (revision 1499)
@@ -0,0 +1,87 @@
+// 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_LOGICAL_AND_SPE_HH
+# define MLN_LOGICAL_AND_SPE_HH
+
+/*! \file mln/logical/and.spe.hh
+ *
+ * \brief Specializations for mln::logical::and.
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace logical
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void and__(const L& lhs, const R& rhs, O& output);
+ }
+
+ template <typename L, typename R, typename O>
+ void and__(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs, O& output)
+ {
+ generic::and__(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ void and__(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs, O& output)
+ {
+ trace::entering("logical::impl::and__");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() && rp.val();
+
+ trace::exiting("logical::impl::and__");
+ }
+
+ } // end of namespace mln::logical::impl
+
+ } // end of namespace mln::logical
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_LOGICAL_AND_SPE_HH
Index: trunk/milena/mln/logical/not.hh
===================================================================
--- trunk/milena/mln/logical/not.hh (revision 1498)
+++ trunk/milena/mln/logical/not.hh (revision 1499)
@@ -37,6 +37,9 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/not.spe.hh>
+
namespace mln
{
@@ -72,21 +75,19 @@
namespace impl
{
+ namespace generic
+ {
template <typename I, typename O>
- void not__(trait::image::speed::any, const I& input, O& output)
+ void not__(const I& input, O& output)
{
+ trace::entering("logical::impl::generic::not__");
+
mln_piter(I) p(input.domain());
for_all(p)
output(p) = ! input(p);
- }
- template <typename I, typename O>
- void not__(trait::image::speed::fastest, const I& input, O& output)
- {
- mln_pixter(const I) ip(input);
- mln_pixter(O) op(output);
- for_all_2(ip, op)
- op.val() = ! ip.val();
+ trace::exiting("logical::impl::generic::not__");
+ }
}
} // end of namespace mln::logical::impl
Index: trunk/milena/mln/logical/or.hh
===================================================================
--- trunk/milena/mln/logical/or.hh (revision 1498)
+++ trunk/milena/mln/logical/or.hh (revision 1499)
@@ -37,6 +37,8 @@
# include <mln/core/concept/image.hh>
+// Specializations are in:
+# include <mln/logical/or.spe.hh>
namespace mln
{
@@ -76,24 +78,19 @@
namespace impl
{
+ namespace generic
+ {
template <typename L, typename R, typename O>
- void or__(trait::image::speed::any, const L& lhs,
- trait::image::speed::any, const R& rhs, O& output)
+ void or__(const L& lhs, const R& rhs, O& output)
{
+ trace::entering("logical::impl::generic::or__");
+
mln_piter(L) p(lhs.domain());
for_all(p)
output(p) = lhs(p) || rhs(p);
- }
- template <typename L, typename R, typename O>
- void or__(trait::image::speed::fastest, const L& lhs,
- trait::image::speed::fastest, const R& rhs, O& output)
- {
- mln_pixter(const L) lp(lhs);
- mln_pixter(const R) rp(rhs);
- mln_pixter(O) op(output);
- for_all_3(lp, rp, op)
- op.val() = lp.val() || rp.val();
+ trace::exiting("logical::impl::generic::or__");
+ }
}
} // end of namespace mln::logical::impl