This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch lambdas-as-milena-functions has been updated
via 8fa6d867f923cd7f7b7ca5d4d4e308fb0a9dc9a7 (commit)
via 1a8f8432210c92df9f46f4daa66839953d59d286 (commit)
via a067f791e3cd82592e0a87a353992be93d148ac9 (commit)
from 9a717ea467c439f46436fdf3a66d2df44e5d23bc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
8fa6d86 Exercise mln::transform with lambdas with more than one argument.
1a8f843 Simplify and generalize the wrapping of lambdas in Milena functions.
a067f79 Clean up tests/data/transform-lambda.cc.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 28 +++++++++
milena/tests/data/transform-lambda.cc | 101 ++++++++++++++++++++-------------
2 files changed, 90 insertions(+), 39 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* tests/data/transform-lambda.cc (mln::fun::C< R (*)(A1, A2) >):
New explicit class template specialization.
(mln::category< R (*)(A1, A2) >): Likewise.
(main): Use `mln::test::predicate' and a binary lambda to check
the output instead of a hand-made browsing.
---
milena/ChangeLog | 10 ++++++
milena/tests/data/transform-lambda.cc | 55 ++++++++++++++++++++++++++++++--
2 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a4f8dfb..e8c17cd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2012-05-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Exercise mln::transform with lambdas with more than one argument.
+
+ * tests/data/transform-lambda.cc (mln::fun::C< R (*)(A1, A2) >):
+ New explicit class template specialization.
+ (mln::category< R (*)(A1, A2) >): Likewise.
+ (main): Use `mln::test::predicate' and a binary lambda to check
+ the output instead of a hand-made browsing.
+
+2012-05-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Simplify and generalize the wrapping of lambdas in Milena functions.
* tests/data/transform-lambda.cc (first_arg_of, return_of):
diff --git a/milena/tests/data/transform-lambda.cc b/milena/tests/data/transform-lambda.cc
index 1873b16..242a3e8 100644
--- a/milena/tests/data/transform-lambda.cc
+++ b/milena/tests/data/transform-lambda.cc
@@ -36,6 +36,55 @@
#include <mln/data/transform.hh>
#include <mln/debug/iota.hh>
+#include <mln/test/predicate.hh>
+
+
+/*---------------------------------------------------.
+| Extension of mln::fun::C to 2-argument functions. |
+`---------------------------------------------------*/
+
+// FIXME: To be completed, revamped and moved into Milena.
+namespace mln
+{
+
+ /// Category declaration for a unary C function.
+ template <typename R, typename A1, typename A2>
+ struct category< R (*)(A1, A2) >
+ {
+ typedef C_Function<void> ret;
+ };
+
+ namespace fun
+ {
+
+ /// Wrapper of a pointer to a 2-argument function into a Milena
+ /// function.
+ template <typename R, typename A1, typename A2>
+ struct C< R (*)(A1, A2) >
+ :
+ // FIXME: Hard-coded base class, so as to make this part of the
+ // code as small as possible for this test.
+ //
+ // This functor should inherit from either `Function_vv2b' or
+ // `Function_vv2b', depending on the result type. See how it is
+ // implemented in `C< R (*)(A) >' (located in mln/fun/c.hh).
+ Function_vv2b< C< R (*)(A1, A2) > >
+ {
+ C() {}
+ C(R (*f)(A1, A2)) : f_(f) {}
+ typedef R result;
+ R operator()(const mlc_unqualif(A1)& a, const mlc_unqualif(A2)& b) const
+ {
+ return f_(a, b);
+ }
+ protected:
+ R (*f_)(A1, A2);
+ };
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln::fun
+
/*----------------.
| Lambda traits. |
@@ -92,8 +141,6 @@ main()
I output = data::transform(input, to_fun([](V x) { return x * x; }));
- // FIXME: Or use mln::test instead?
- mln_piter_(I) p(output.domain());
- for_all(p)
- mln_assertion(output(p) = math::sqr(input(p)));
+ mln_assertion(test::predicate(output, input,
+ to_fun([](V x, V y) { return x == y * y; })));
}
--
1.7.2.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch lambdas-as-milena-functions has been created
at 9a717ea467c439f46436fdf3a66d2df44e5d23bc (commit)
- Log -----------------------------------------------------------------
9a717ea Add an optional test to exercise mln::transform with lambdas.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
* tests/data/transform-lambda.cc: New.
* tests/data/Makefile.am (EXTRA_PROGRAMS)
(transform_lambda_SOURCES): New.
(extra-check): New (phony) target.
---
milena/ChangeLog | 9 +++
milena/tests/data/Makefile.am | 12 +++
milena/tests/data/transform-lambda.cc | 123 +++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+), 0 deletions(-)
create mode 100644 milena/tests/data/transform-lambda.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5712ee9..65f6803 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2012-05-22 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Add an optional test to exercise mln::transform with lambdas.
+
+ * tests/data/transform-lambda.cc: New.
+ * tests/data/Makefile.am (EXTRA_PROGRAMS)
+ (transform_lambda_SOURCES): New.
+ (extra-check): New (phony) target.
+
2011-09-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix Scribo build system.
diff --git a/milena/tests/data/Makefile.am b/milena/tests/data/Makefile.am
index 205337e..269567b 100644
--- a/milena/tests/data/Makefile.am
+++ b/milena/tests/data/Makefile.am
@@ -74,3 +74,15 @@ MOSTLYCLEANFILES = \
median-out_line.pgm \
median-out_rect.pgm \
median_fast-out.pgm
+
+
+# FIXME: We should introduce a conditional (e.g named HAVE_CXX_LAMBDA)
+# to guard these lines, and make them actually part of the test suite
+# if the C++ compiler found by `configure' supports lambda
+# abstractions.
+EXTRA_PROGRAMS = transform-lambda
+transform_lambda_SOURCES = transform-lambda.cc
+
+.PHONY: extra-check
+extra-check: transform-lambda
+ ./transform-lambda$(EXEEXT)
diff --git a/milena/tests/data/transform-lambda.cc b/milena/tests/data/transform-lambda.cc
new file mode 100644
index 0000000..25de53a
--- /dev/null
+++ b/milena/tests/data/transform-lambda.cc
@@ -0,0 +1,123 @@
+// Copyright (C) 2012 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.
+
+/// \file
+/// Exercise mln::data::transform with a lambda abstraction.
+
+#include <type_traits>
+
+#include <mln/core/concept/function.hh>
+#include <mln/fun/c.hh>
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/data/transform.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+
+/*----------------.
+| Lambda traits. |
+`----------------*/
+
+// Metaprogramming traits for the deduction of return and argument
+// types of lambda asbtractions. Inspired from
+// http://stackoverflow.com/questions/6512019/can-we-get-the-type-of-a-lambda-…
+
+/// Deduce the type of \p F's first argument.
+template <typename F>
+struct first_arg_of
+{
+ template <typename Ret, typename A, typename... Rest>
+ static A
+ helper(Ret (F::*)(A, Rest...));
+
+ template <typename Ret, typename A, typename... Rest>
+ static A
+ helper(Ret (F::*)(A, Rest...) const);
+
+ typedef decltype( helper(&F::operator()) ) type;
+};
+
+/// Deduce the type of \p F's first argument.
+///
+/// This traits works with lambdas, whereas std::result_of does not.
+template <typename F>
+struct return_of
+{
+ template <typename Ret, typename A, typename... Rest>
+ static Ret
+ helper(Ret (F::*)(A, Rest...));
+
+ template <typename Ret, typename A, typename... Rest>
+ static Ret
+ helper(Ret (F::*)(A, Rest...) const);
+
+ typedef decltype( helper(&F::operator()) ) type;
+};
+
+
+/*---------------------.
+| Conversion routine. |
+`---------------------*/
+
+/// Convert a lambda abstraction into a Milena function (functor).
+
+template <typename F>
+auto
+to_fun (F f) -> mln::fun::C< typename return_of<F>::type (*) (typename first_arg_of<F>::type) >
+{
+ return mln::fun::C< typename return_of<F>::type (*) (typename first_arg_of<F>::type) > (f);
+}
+
+
+/*-------.
+| Test. |
+`-------*/
+
+int
+main()
+{
+ using namespace mln;
+
+ // FIXME: Replacing unsigned by int_u8 would trigger a bug here, as
+ // the (low quantization) implementation of data::transform would
+ // create values that would not fit in int_u8 (e.g. sqr(16) = 256).
+ typedef unsigned V;
+ typedef image2d<V> I;
+
+ I input(3, 3);
+ debug::iota(input);
+
+ auto sqr = [](V x) { return x * x; };
+
+ I output = data::transform(input, to_fun([](V x) { return x * x; }));
+ debug::println(output);
+
+ // FIXME: Or use mln::test instead?
+ mln_piter_(I) p(output.domain());
+ for_all(p)
+ mln_assertion(output(p) = math::sqr(input(p)));
+}
--
1.7.2.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch try-next has been updated
discards e70efe8043ed2830cc8df93c9dd2c18e8e440e11 (commit)
discards 0dc6cfc9c85080214b1a5faa741befe50ec73b11 (commit)
via 856f489ee9fbbfde026dddff7377f7a27e7c9452 (commit)
via 258c4cb992df1c43678d39bd7bbe2dc4dd18f6db (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (e70efe8043ed2830cc8df93c9dd2c18e8e440e11)
\
N -- N -- N (856f489ee9fbbfde026dddff7377f7a27e7c9452)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
856f489 Fix compilation in Scribo.
258c4cb Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
-----------------------------------------------------------------------
Summary of changes:
milena/mln/convert/from_to.hh | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch try-next has been updated
discards 8e3077c5446de47913d316aef34a6b7092554938 (commit)
discards 3ec756e51e4ef0fc2c76a782baef5ac8c50d7900 (commit)
via e70efe8043ed2830cc8df93c9dd2c18e8e440e11 (commit)
via 0dc6cfc9c85080214b1a5faa741befe50ec73b11 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (8e3077c5446de47913d316aef34a6b7092554938)
\
N -- N -- N (e70efe8043ed2830cc8df93c9dd2c18e8e440e11)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
e70efe8 Fix compilation in Scribo.
0dc6cfc Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 67 ++++++++++++++++++++
milena/mln/convert/from_to.hh | 21 ++++---
scribo/src/content_in_hdoc.cc | 3 +-
scribo/src/contest/DAE-2011/content_in_doc_dae.cc | 3 +-
scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc | 3 +-
.../contest/hdlac-2011/content_in_hdoc_hdlac.cc | 2 +-
scribo/src/non_text_components.cc | 3 +-
7 files changed, 84 insertions(+), 18 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform