https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: Registration: Start to use milena transformations.
* jardonnet/test/registration.cc: Add use of milena trasformation.
* jardonnet/registration/quat7.hh: Replace quat7 by a generic T.
* jardonnet/registration/registration.hh: Replace quat7 by a generic T..
Start working on .hxx creation using perl:
* jardonnet/perl/hxx.pl: Script.
* jardonnet/perl/test,
* jardonnet/perl/test/ops.hh,
* jardonnet/perl/test/c.hh,
* jardonnet/perl/test/i2v,
* jardonnet/perl/test/i2v/all.hh,
* jardonnet/perl/test/i2v/all_to.hh,
* jardonnet/perl/test/i2v/array.hh,
* jardonnet/perl/test/x2x,
* jardonnet/perl/test/x2x/all.hh,
* jardonnet/perl/test/x2x/geom,
* jardonnet/perl/test/x2x/geom/composed.hh,
* jardonnet/perl/test/x2x/geom/translation.hh,
* jardonnet/perl/test/x2x/geom/rotation.hh,
* jardonnet/perl/test/x2x/interpol,
* jardonnet/perl/test/x2x/interpol/bilinear.hh,
* jardonnet/perl/test/x2x/interpol/test.cc,
* jardonnet/perl/test/x2x/interpol/linear.hh,
* jardonnet/perl/test/p2b,
* jardonnet/perl/test/p2b/chess.hh,
* jardonnet/perl/test/p2b/all.hh,
* jardonnet/perl/test/p2b/has.hh,
* jardonnet/perl/test/vv2v,
* jardonnet/perl/test/vv2v/min.hh,
* jardonnet/perl/test/vv2v/max.hh,
* jardonnet/perl/test/all.hh,
* jardonnet/perl/test/p2v,
* jardonnet/perl/test/p2v/elifs.hh,
* jardonnet/perl/test/p2v/ternary.hh,
* jardonnet/perl/test/p2v/all.hh,
* jardonnet/perl/test/p2v/iota.hh,
* jardonnet/perl/test/cast.hh,
* jardonnet/perl/test/v2b,
* jardonnet/perl/test/v2b/threshold.hh,
* jardonnet/perl/test/internal,
* jardonnet/perl/test/internal/x2x_linear_impl.hh,
* jardonnet/perl/test/internal/selector.hh,
* jardonnet/perl/test/v2v,
* jardonnet/perl/test/v2v/abs.hh,
* jardonnet/perl/test/v2v/enc.hh,
* jardonnet/perl/test/v2v/saturate.hh,
* jardonnet/perl/test/v2v/all.hh,
* jardonnet/perl/test/v2v/inc.hh,
* jardonnet/perl/test/v2v/linear.hh,
* jardonnet/perl/test/v2v/cast.hh,
* jardonnet/perl/test/v2v/norm.hh,
* jardonnet/perl/test/v2v/dec.hh,
* jardonnet/perl/test/v2v/id.hh,
* jardonnet/perl/test/v2v/rgb_to_hsi.hh: Add test files.
perl/hxx.pl | 27 +++
perl/test/all.hh | 63 +++++++
perl/test/c.hh | 140 ++++++++++++++++
perl/test/cast.hh | 85 ++++++++++
perl/test/i2v/all.hh | 56 ++++++
perl/test/i2v/all_to.hh | 108 ++++++++++++
perl/test/i2v/array.hh | 147 +++++++++++++++++
perl/test/internal/selector.hh | 200 +++++++++++++++++++++++
perl/test/internal/x2x_linear_impl.hh | 102 ++++++++++++
perl/test/ops.hh | 199 +++++++++++++++++++++++
perl/test/p2b/all.hh | 56 ++++++
perl/test/p2b/chess.hh | 78 +++++++++
perl/test/p2b/has.hh | 137 ++++++++++++++++
perl/test/p2v/all.hh | 58 ++++++
perl/test/p2v/elifs.hh | 85 ++++++++++
perl/test/p2v/iota.hh | 106 ++++++++++++
perl/test/p2v/ternary.hh | 120 ++++++++++++++
perl/test/v2b/threshold.hh | 90 ++++++++++
perl/test/v2v/abs.hh | 78 +++++++++
perl/test/v2v/all.hh | 61 +++++++
perl/test/v2v/cast.hh | 81 +++++++++
perl/test/v2v/dec.hh | 78 +++++++++
perl/test/v2v/enc.hh | 77 +++++++++
perl/test/v2v/id.hh | 78 +++++++++
perl/test/v2v/inc.hh | 78 +++++++++
perl/test/v2v/linear.hh | 94 +++++++++++
perl/test/v2v/norm.hh | 130 +++++++++++++++
perl/test/v2v/rgb_to_hsi.hh | 143 +++++++++++++++++
perl/test/v2v/saturate.hh | 129 +++++++++++++++
perl/test/vv2v/max.hh | 77 +++++++++
perl/test/vv2v/min.hh | 77 +++++++++
perl/test/x2x/all.hh | 66 +++++++
perl/test/x2x/geom/composed.hh | 285 ++++++++++++++++++++++++++++++++++
perl/test/x2x/geom/rotation.hh | 243 ++++++++++++++++++++++++++++
perl/test/x2x/geom/translation.hh | 152 ++++++++++++++++++
perl/test/x2x/interpol/bilinear.hh | 139 ++++++++++++++++
perl/test/x2x/interpol/linear.hh | 124 ++++++++++++++
perl/test/x2x/interpol/test.cc | 14 +
registration/quat7.hh | 3
registration/registration.hh | 16 +
test/registration.cc | 73 ++------
41 files changed, 4088 insertions(+), 65 deletions(-)
Index: jardonnet/test/registration.cc
--- jardonnet/test/registration.cc (revision 2468)
+++ jardonnet/test/registration.cc (working copy)
@@ -12,6 +12,8 @@
#include <sandbox/jardonnet/registration/final_qk.hh>
#include <mln/geom/bbox.hh>
+#include <mln/fun/x2x/all.hh>
+
void usage(char *argv[])
{
std::cout << "usage : " << argv[0]
@@ -26,83 +28,42 @@
// usage
float q = std::atof(argv[3]);
int e = std::atoi(argv[4]);
- if (argc != 5)
- usage(argv);
- if (q < 1 or e < 1)
- usage(argv);
+ if ((argc != 5) || (q < 1 or e < 1)) usage(argv);
using namespace mln;
typedef image2d< bool > image2db;
+
+ //declare image
image2db img1;
image2db img2;
+
//load images
io::pbm::load(img1, argv[1]);
io::pbm::load(img2, argv[2]);
- //build p_arrays.
+
+ //build p_arrays
p_array<mln_psite_(image2db)> c = convert::to< p_array<point2d>
>(img1);
p_array<mln_psite_(image2db)> x = convert::to< p_array<point2d>
>(img2);
+
//working box
const box<point2d> working_box =
enlarge(bigger(geom::bbox(c), geom::bbox(x)), 100);
- //Make a lazy_image map via function closest_point
- closest_point<mln_psite_(image2db)> fun(x, working_box);
-
- // * Use real lazy image
- lazy_image<image2d<bool>, closest_point<mln_psite_(image2db)>, box2d
> map(fun, fun.domain());
- quat7<2> qk ;//= registration::icp(c, map, q, e, x);
-
-#ifndef NDEBUG
- std::cout << "closest_point(Ck[i]) = " << fun.i <<
std::endl;
- std::cout << "Pts processed = " << registration::pts
<< std::endl;
-#endif
-
- qk.apply_on(c, c, c.nsites());
-
- float stddev, mean;
- registration::mean_stddev(c, map, mean, stddev);
-
-#ifndef NDEBUG
- std::cout << "mean : " << mean << std::endl;
- std::cout << "stddev : " << stddev << std::endl;
-#endif
- std::vector<float> length(c.nsites());
- for (size_t i = 0; i < c.nsites(); i++)
- length[i] = norm::l2( convert::to< algebra::vec<2,float> >(c[i] -
map(c[i])));
-
-
- // final transform
- quat7<2> fqk = registration::final_qk2(c, map, 2*stddev);
- fqk.apply_on(c, c, c.nsites());
-
-
- //init output image
- image2d<value::rgb8> output(convert::to_box2d(working_box), 0);
- level::fill(output, literal::white);
-
-
- //print x
- for (unsigned i = 0; i < x.nsites(); i++)
- {
- //Xk points
- point2d px(x[i][0], x[i][1]);
- if (output.has(px))
- output(px) = literal::black;
- }
+ //make a lazy_image map via function closest_point
+ closest_point<mln_psite_(image2db)> fun(x, working_box);
+ lazy_image<image2d<bool>, closest_point<mln_psite_(image2db)>, box2d
>
+ map(fun, fun.domain());
- for (unsigned i = 0; i < c.nsites(); i++)
- {
- //Ck points
- point2d p(c[i][0], c[i][1]);
- if (output.has(p))
- output(p) = literal::green;
- }
+ //do registration
+ using namespace fun::x2x::geom;
+ composed<rotation<2u, float>, translation<2u, float> > rigid_tr =
+ registration::icp(c, map, q, e, x);
io::ppm::save(output, "registred.ppm");
Index: jardonnet/perl/test/ops.hh
--- jardonnet/perl/test/ops.hh (revision 0)
+++ jardonnet/perl/test/ops.hh (revision 0)
@@ -0,0 +1,199 @@
+// Copyright (C) 2007, 2008 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_FUN_OPS_HH
+# define MLN_FUN_OPS_HH
+
+/*! \file mln/fun/ops.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+# include <mln/trait/all.hh>
+
+
+
+# define mln_decl_binary_expr_(In, Out, Name, Symbol) \
+ \
+ namespace fun \
+ { \
+ \
+ template <typename L, typename R> \
+ struct Name##_##Out##_expr_ \
+ : public Function_##Out < Name##_##Out##_expr_<L,R> > \
+ { \
+ typedef typename mln::trait::op:: Name < mln_result(L), \
+ mln_result(R) >::ret result; \
+ \
+ Name##_##Out##_expr_() \
+ { \
+ } \
+ \
+ Name##_##Out##_expr_(const L& l, const R& r) \
+ : l_(l), r_(r) \
+ { \
+ } \
+ \
+ template <typename P> \
+ result operator()(const P& p) const \
+ { \
+ return l_(p) Symbol r_(p); \
+ } \
+ \
+ protected: \
+ L l_; \
+ R r_; \
+ }; \
+ \
+ } \
+ \
+ namespace trait \
+ { \
+ \
+ template <typename L, typename R> \
+ struct set_binary_< op::Name, \
+ Function_##In, L, \
+ Function_##In, R > \
+ { \
+ typedef fun::Name##_##Out##_expr_<L,R> ret; \
+ }; \
+ } \
+ \
+ template <typename L, typename R> \
+ fun::Name##_##Out##_expr_<L,R> \
+ operator Symbol (const Function_##In<L>& lhs, const
Function_##In<R>& rhs) \
+ { \
+ fun::Name##_##Out##_expr_<L,R> tmp(exact(lhs), exact(rhs)); \
+ return tmp; \
+ } \
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
+# define mln_decl_unary_expr_(In, Out, Name, Symbol) \
+ \
+ namespace fun \
+ { \
+ \
+ template <typename F> \
+ struct Name##_##Out##_expr_ \
+ : public Function_##Out< Name##_##Out##_expr_<F> > \
+ { \
+ typedef typename mln::trait::op:: Name < mln_result(F) >::ret result; \
+ \
+ Name##_##Out##_expr_() \
+ { \
+ } \
+ \
+ Name##_##Out##_expr_(const F& f) \
+ : f_(f) \
+ { \
+ } \
+ \
+ template <typename P> \
+ result operator()(const P& p) const \
+ { \
+ return Symbol f_(p); \
+ } \
+ \
+ protected: \
+ F f_; \
+ }; \
+ \
+ } \
+ \
+ namespace trait \
+ { \
+ template <typename F> \
+ struct set_unary_< op::Name, \
+ Function_##In, F > \
+ { \
+ typedef fun::Name##_##Out##_expr_<F> ret; \
+ }; \
+ } \
+ \
+ template <typename F> \
+ fun::Name##_##Out##_expr_<F> \
+ operator Symbol (const Function_##In<F>& f) \
+ { \
+ fun::Name##_##Out##_expr_<F> tmp(exact(f)); \
+ return tmp; \
+ } \
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
+
+namespace mln
+{
+ // -> p2v
+
+ mln_decl_binary_expr_(p2v, p2b, eq, ==);
+ mln_decl_binary_expr_(p2v, p2b, neq, !=);
+
+ mln_decl_binary_expr_(p2v, p2b, less, <);
+ mln_decl_binary_expr_(p2v, p2b, leq , <=);
+ mln_decl_binary_expr_(p2v, p2b, geq, >=);
+ mln_decl_binary_expr_(p2v, p2b, greater, >);
+
+ mln_decl_binary_expr_(p2b, p2b, and_, &&);
+ mln_decl_binary_expr_(p2b, p2b, or_, ||);
+ mln_decl_binary_expr_(p2b, p2b, xor_, ^);
+
+ mln_decl_unary_expr_(p2b, p2b, not_, !);
+
+ mln_decl_binary_expr_(p2v, p2v, plus, +);
+ mln_decl_binary_expr_(p2v, p2v, minus, -);
+ mln_decl_binary_expr_(p2v, p2v, times, *);
+ mln_decl_binary_expr_(p2v, p2v, div, /);
+ mln_decl_binary_expr_(p2v, p2v, mod, %);
+
+ mln_decl_unary_expr_(p2v, p2v, uplus, +);
+ mln_decl_unary_expr_(p2v, p2v, uminus, -);
+
+ // -> v2b
+
+ mln_decl_binary_expr_(v2v, v2b, eq, ==);
+ mln_decl_binary_expr_(v2v, v2b, neq, !=);
+
+ mln_decl_binary_expr_(v2v, v2b, less, <);
+ mln_decl_binary_expr_(v2v, v2b, leq, <=);
+ mln_decl_binary_expr_(v2v, v2b, geq, >=);
+ mln_decl_binary_expr_(v2v, v2b, greater, >);
+
+ mln_decl_binary_expr_(v2b, v2b, and_, &&);
+ mln_decl_binary_expr_(v2b, v2b, or_, ||);
+ mln_decl_binary_expr_(v2b, v2b, xor_, ^);
+
+ mln_decl_unary_expr_(v2b, v2b, not_, !);
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_OPS_HH
Index: jardonnet/perl/test/c.hh
--- jardonnet/perl/test/c.hh (revision 0)
+++ jardonnet/perl/test/c.hh (revision 0)
@@ -0,0 +1,140 @@
+// Copyright (C) 2007, 2008 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_FUN_C_HH
+# define MLN_FUN_C_HH
+
+/*! \file mln/fun/c.hh
+ *
+ * \brief Encapsulate a plain (C language-like) pointer to function
+ * into a functor.
+ */
+
+# include <mln/fun/internal/selector.hh>
+# include <mln/metal/unqualif.hh>
+
+
+namespace mln
+{
+
+ /// Concept-like.
+ template <typename E>
+ struct C_Function;
+
+
+ /// Category declaration for a unary C function.
+ template <typename R, typename A>
+ struct category< R (*)(A) >
+ {
+ typedef C_Function<void> ret;
+ };
+
+
+
+ // Forward declaration.
+ namespace fun { template <typename F> struct C; }
+
+
+
+ namespace trait
+ {
+
+ template <template <class> class Op,
+ typename R, typename A>
+ struct set_unary_< Op, C_Function, R (*)(A) >
+ {
+ typedef Op< fun::C<R (*)(A)> > Op_;
+ typedef typename Op_::ret ret;
+ };
+
+ template <template <class, class> class Op,
+ typename O,
+ typename R, typename A>
+ struct set_binary_< Op,
+ Object, O,
+ C_Function, R (*)(A) >
+ {
+ typedef Op< O, fun::C<R (*)(A)> > Op_;
+ typedef typename Op_::ret ret;
+ };
+
+ } // end of namespace trait
+
+
+
+ namespace fun
+ {
+
+ template <typename F> struct C;
+
+
+ // FIXME: Doc!
+ template <typename R, typename A>
+ struct C< R (*)(A) >
+ :
+ fun::internal::selector_< R, A, C<R(*)(A)> >::ret
+ {
+ C();
+ C(R (*f)(A));
+ typedef R result;
+ R operator()(const mlc_unqualif(A)& a) const;
+ protected:
+ R (*f_)(A);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename R, typename A>
+ inline
+ C<R(*)(A)>::C()
+ {
+ }
+
+ template <typename R, typename A>
+ inline
+ C<R(*)(A)>::C(R (*f)(A))
+ : f_(f)
+ {
+ }
+
+ template <typename R, typename A>
+ inline
+ R
+ C<R(*)(A)>::operator()(const mlc_unqualif(A)& a) const
+ {
+ return f_(a);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_C_HH
Index: jardonnet/perl/test/i2v/all.hh
--- jardonnet/perl/test/i2v/all.hh (revision 0)
+++ jardonnet/perl/test/i2v/all.hh (revision 0)
@@ -0,0 +1,56 @@
+// 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_FUN_I2V_ALL_HH
+# define MLN_FUN_I2V_ALL_HH
+
+/*! \file mln/fun/i2v/all.hh
+ *
+ * \brief File that includes all functions from index to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from index to value.
+ namespace i2v
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/i2v/all_to.hh>
+
+
+
+#endif // ! MLN_FUN_I2V_ALL_HH
Index: jardonnet/perl/test/i2v/all_to.hh
--- jardonnet/perl/test/i2v/all_to.hh (revision 0)
+++ jardonnet/perl/test/i2v/all_to.hh (revision 0)
@@ -0,0 +1,108 @@
+// 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_FUN_I2V_ALL_TO_HH
+# define MLN_FUN_I2V_ALL_TO_HH
+
+/*! \file mln/fun/i2v/all_to.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ struct all_to : public Function_i2v< all_to<T> >
+ {
+ typedef T result;
+ all_to(T t);
+ template <typename U>
+ T operator()(const U&) const;
+ private:
+ T t_;
+ };
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ fun::i2v::all_to<T> all_to(T t);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ inline
+ all_to<T>::all_to(T t)
+ : t_(t)
+ {
+ }
+
+ template <typename T>
+ template <typename U>
+ inline
+ T
+ all_to<T>::operator()(const U&) const
+ {
+ return t_;
+ }
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ inline
+ fun::i2v::all_to<T> all_to(T t)
+ {
+ fun::i2v::all_to<T> tmp(t);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_I2V_ALL_TO_HH
Index: jardonnet/perl/test/i2v/array.hh
--- jardonnet/perl/test/i2v/array.hh (revision 0)
+++ jardonnet/perl/test/i2v/array.hh (revision 0)
@@ -0,0 +1,147 @@
+// Copyright (C) 2008 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_FUN_I2V_ARRAY_HH
+# define MLN_FUN_I2V_ARRAY_HH
+
+/*! \file mln/fun/i2v/array.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <vector>
+# include <algorithm>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ class array : public Function_i2v< array<T> >
+ {
+ public:
+
+ typedef T result;
+
+ array();
+ array(unsigned n);
+
+ void resize(unsigned n);
+ unsigned size() const;
+
+ T operator()(unsigned i) const;
+ T& operator()(unsigned i);
+
+ private:
+ std::vector<T> v_;
+ };
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ inline
+ array<T>::array()
+ {
+ }
+
+ template <typename T>
+ inline
+ array<T>::array(unsigned n)
+ {
+ resize(n);
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::resize(unsigned n)
+ {
+ v_.resize(n);
+ }
+
+ template <typename T>
+ inline
+ unsigned
+ array<T>::size() const
+ {
+ return v_.size();
+ }
+
+ template <typename T>
+ inline
+ T
+ array<T>::operator()(unsigned i) const
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename T>
+ inline
+ T&
+ array<T>::operator()(unsigned i)
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ inline
+ fun::i2v::array<T> array(T t)
+ {
+ fun::i2v::array<T> tmp(t);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_I2V_ARRAY_HH
Index: jardonnet/perl/test/x2x/all.hh
--- jardonnet/perl/test/x2x/all.hh (revision 0)
+++ jardonnet/perl/test/x2x/all.hh (revision 0)
@@ -0,0 +1,66 @@
+// 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_FUN_X2X_ALL_HH
+# define MLN_FUN_X2X_ALL_HH
+
+/*! \file mln/fun/x2x/all.hh
+ *
+ * \brief File that includes all functions from vector to vector.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from vector to vector.
+ namespace x2x
+ {
+
+ /// Internal namespace of functions form vector to vector.
+ namespace internal
+ {
+ }
+ }
+ }
+
+}
+
+
+# include <mln/fun/x2x/geom/composed.hh>
+# include <mln/fun/x2x/geom/rotation.hh>
+# include <mln/fun/x2x/geom/translation.hh>
+
+# include <mln/fun/x2x/interpol/linear.hh>
+# include <mln/fun/x2x/interpol/bilinear.hh>
+
+
+
+#endif // ! MLN_FUN_X2X_ALL_HH
Index: jardonnet/perl/test/x2x/geom/composed.hh
--- jardonnet/perl/test/x2x/geom/composed.hh (revision 0)
+++ jardonnet/perl/test/x2x/geom/composed.hh (revision 0)
@@ -0,0 +1,285 @@
+// 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_FUN_X2X_GEOM_COMPOSED_HH
+# define MLN_FUN_X2X_GEOM_COMPOSED_HH
+
+/*! \file mln/fun/x2x/composed.hh
+ *
+ * \brief Definition of a composed transformation.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/x2x_linear_impl.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/metal/is.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/algebra/h_mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ // Fwd decl.
+ template <typename F, typename G>
+ struct composed;
+
+ namespace internal
+ {
+ template <typename F, typename G, typename E, bool is_bij>
+ struct helper_composed_;
+
+
+ /// Helper for describing a bijective composition.
+ template <typename F, typename G, typename E>
+ struct helper_composed_< F, G, E, true>
+ : public fun::internal::x2x_linear_impl_<mln_result(F), E >,
+ public Bijection_x2x<E>
+ {
+ typedef fun::internal::x2x_linear_impl_<typename F::result, E >
super_;
+
+ using super_::dim;
+
+ /// Constructor without argument.
+ helper_composed_();
+ /// Constructor with the two transformation to be composed.
+ helper_composed_(const F& f, const G& g);
+
+ using super_::operator();
+
+ /// Set the new first transformation.
+ void set_first(const F& f);
+ /// Set the new second transformation.
+ void set_second(const G& g);
+
+ /// Type of the inverse function.
+ typedef composed<mln_invert(G),mln_invert(F)> invert;
+ /// Return the inverse function.
+ invert inv() const;
+
+ protected:
+
+ F f_;
+ G g_;
+ };
+
+ /// Helper for describing a non bijective composition.
+ template <typename F, typename G, typename E>
+ struct helper_composed_< F, G, E, false>
+ : public fun::internal::x2x_linear_impl_<mln_result(F), E >,
+ public Function_x2x<E>
+ {
+ typedef fun::internal::x2x_linear_impl_<typename F::result, E >
super_;
+
+ using super_::dim;
+
+ /// Constructor without argument.
+ helper_composed_();
+ /// Constructor with the two transformation to be composed.
+ helper_composed_(const F& f, const G& g);
+
+ using super_::operator();
+
+ /// Set the new first transformation.
+ void set_first(const F& f);
+ /// Set the new second transformation.
+ void set_second(const G& g);
+
+ protected:
+
+ F f_;
+ G g_;
+ };
+
+ } // end of namespace mln::fun::x2x::geom::internal
+
+
+ /*! \brief Represent a composition of two transformations.
+ *
+ */
+ template <typename F, typename G>
+ struct composed
+ : public internal::helper_composed_<F, G, composed<F,G>,
+ mlc_is(F, Bijection_x2x<F>)::value
&&
+ mlc_is(G,
Bijection_x2x<G>)::value>,
+ private metal::and_< metal::bool_<(F::dim == G::dim)>,
+ metal::is<mln_argument(F), mln_result(G)>
+ >::check_t
+ {
+ /// Constructor without argument.
+ composed() {}
+
+ /// Constructor with the two transformation to be composed.
+ composed(const F& f, const G& g)
+ : internal::helper_composed_<F, G, composed<F,G>,
+ mlc_is(F, Bijection_x2x<F>)::value
&&
+ mlc_is(G, Bijection_x2x<G>)::value>(f,
g)
+ {
+ }
+ };
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+
+ /*! \brief Do a composition of two transformations
+ *
+ * \param[in] f The first transformation.
+ * \param[in] g The second transformation.
+ *
+ * \return The composed transformation fog.
+ */
+ template <typename F, typename G>
+ fun::x2x::geom::composed<F,G> compose(F f, G g);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ namespace internal
+ {
+
+ // Implementation of the bijective version.
+
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,true>::helper_composed_()
+ {
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,true>::helper_composed_(const F& f, const
G& g)
+ :f_(f),
+ g_(g)
+ {
+ this->m_ = f_.mat() * g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ typename helper_composed_<F,G,E,true>::invert
+ helper_composed_<F,G,E,true>::inv() const
+ {
+ return compose(g_.inv(), f_.inv());
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,true>::set_first(const F& f)
+ {
+ this->f_ = f;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,true>::set_second(const G& g)
+ {
+ this->g_ = g;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ // Implementation of the non bijective version.
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,false>::helper_composed_()
+ {
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ helper_composed_<F,G,E,false>::helper_composed_(const F& f, const
G& g)
+ :f_(f),
+ g_(g)
+ {
+ this->m_ = f_.mat() * g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,false>::set_first(const F& f)
+ {
+ this->f_ = f;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ template <typename F, typename G, typename E>
+ inline
+ void
+ helper_composed_<F,G,E,false>::set_second(const G& g)
+ {
+ this->g_ = g;
+ this->m_ = this->f_.mat() * this->g_.mat();
+ }
+
+ } // end of namespace mln::fun::x2x::geom::internal
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+ template <typename F, typename G>
+ inline
+ fun::x2x::geom::composed<F,G> compose(F f, G g)
+ {
+ trace::entering("fun::x2x::compose");
+ fun::x2x::geom::composed<F,G> comp(f, g);
+ trace::exiting("fun::x2x::compose");
+ return comp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_GEOM_COMPOSED_HH
Index: jardonnet/perl/test/x2x/geom/translation.hh
--- jardonnet/perl/test/x2x/geom/translation.hh (revision 0)
+++ jardonnet/perl/test/x2x/geom/translation.hh (revision 0)
@@ -0,0 +1,152 @@
+// 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_FUN_X2X_TRANSLATION_HH
+# define MLN_FUN_X2X_TRANSLATION_HH
+
+/*! \file mln/fun/x2x/translation.hh
+ *
+ * \brief Define a translation function.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/x2x_linear_impl.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/h_mat.hh>
+# include <mln/fun/i2v/all.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ /*! \brief Represent a translation function.
+ *
+ */
+ template <unsigned n, typename C>
+ struct translation
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>,
translation<n,C> >
+ , public Bijection_x2x< translation<n,C> >
+ {
+ typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>,
translation<n,C> > super_;
+
+ /// Type of the inverse function.
+ typedef translation<n,C> invert;
+ /// Return the inverse function.
+ invert inv() const;
+
+ /// Constructor without argument.
+ translation();
+ /// Constructor with the translation vector.
+ translation(const algebra::vec<n,C>& t);
+
+ using super_::operator();
+ /// Perform the translation of the given vector
+ algebra::vec<n,C> operator()(const algebra::vec<n,C>& v)
const;
+
+ /// Set a net translation vector.
+ void set_t(const algebra::vec<n,C>& t);
+
+ protected:
+ void update();
+
+ algebra::vec<n,C> t_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n, typename C>
+ inline
+ translation<n,C>::translation()
+ {
+ }
+
+ template <unsigned n, typename C>
+ inline
+ translation<n,C>::translation(const algebra::vec<n,C>& t)
+ :t_(t)
+ {
+ this->update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ algebra::vec<n,C>
+ translation<n,C>::operator()(const algebra::vec<n,C>& v) const
+ {
+ return v + t_;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ translation<n,C>
+ translation<n,C>::inv() const
+ {
+ typename translation::invert res(-t_);
+
+ return res;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ translation<n,C>::set_t(const algebra::vec<n,C>& t)
+ {
+ this->t_ = t;
+ this->update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ translation<n,C>::update()
+ {
+ this->m_ = algebra::h_mat<n,C>::Id;
+ for (unsigned i = 0; i < n; ++i)
+ this->m_(i,n) = this->t_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_TRANSLATION_HH
Index: jardonnet/perl/test/x2x/geom/rotation.hh
--- jardonnet/perl/test/x2x/geom/rotation.hh (revision 0)
+++ jardonnet/perl/test/x2x/geom/rotation.hh (revision 0)
@@ -0,0 +1,243 @@
+// 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_FUN_X2X_ROTATION_HH
+# define MLN_FUN_X2X_ROTATION_HH
+
+/*! \file mln/fun/x2x/rotation.hh
+ *
+ * \brief Define a rotation function.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/x2x_linear_impl.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
+# include <cmath>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace geom
+ {
+
+ namespace internal
+ {
+ template < unsigned n, typename C >
+ algebra::h_mat<n, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
+ {
+ assert(!"get_h_mat : n not implemented");
+ }
+
+ template <typename C >
+ algebra::h_mat<3, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<3,C>& axis_)
+ {
+ algebra::h_mat<3, C> m_;
+
+ const float cos_a = cos(alpha_);
+ const float sin_a = sin(alpha_);
+ const float u = axis_[0];
+ const float v = axis_[1];
+ const float w = axis_[2];
+ const float u2 = u * u;
+ const float v2 = v * v;
+ const float w2 = w * w;
+ const float uvw2 = u2 + v2 + w2;
+
+ m_(0,0) = (u2 + (v2 + w2) * cos_a) / uvw2;
+ m_(0,1) = (u*v * (1 - cos_a) - u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(0,2) = (u*w * (1 - cos_a) + v * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(0,3) = 0;
+
+ m_(1,0) = (u*v * (1 - cos_a) + w * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(1,1) = (v2 + (u2 + w2) * cos_a) / uvw2;
+ m_(1,2) = (v*w * (1 - cos_a) - u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(1,3) = 0;
+
+ m_(2,0) = (u*w * (1 - cos_a) - v * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(2,1) = (v*w * (1 - cos_a) + u * std::sqrt(uvw2) * sin_a) / uvw2;
+ m_(2,1) = (u2 + (u2 + v2) * cos_a) / uvw2;
+ m_(2,3) = 0;
+
+ m_(2,0) = 0;
+ m_(2,1) = 0;
+ m_(2,1) = 0;
+ m_(2,3) = 1;
+
+ return m_;
+ }
+
+ template <typename C >
+ algebra::h_mat<2, C>
+ get_rot_h_mat(const float alpha_, const algebra::vec<2,C>&)
+ {
+ algebra::h_mat<2, C> m_;
+
+ const float cos_a = cos(alpha_);
+ const float sin_a = sin(alpha_);
+
+ m_(0,0) = cos_a; m_(0,1) = -sin_a; m_(0,2) = 0;
+
+ m_(1,0) = sin_a; m_(1,1) = cos_a; m_(1,2) = 0;
+
+ m_(2,0) = 0; m_(2,1) = 0; m_(2,2) = 1;
+
+ return m_;
+ }
+ }
+
+
+ /*! \brief Represent a rotation function.
+ *
+ */
+ template <unsigned n, typename C>
+ struct rotation
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
+ , public Bijection_x2x< rotation<n,C> >
+ {
+ typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C>
> super_;
+
+ /// Type of the inverse function.
+ typedef rotation<n,C> invert;
+ /// Return the invere function.
+ invert inv() const;
+
+ /// Constructor without argument.
+ rotation();
+ /// Constructor with grade alpha and a facultative direction (rotation axis).
+ rotation(float alpha, const algebra::vec<n,float>& axis);
+
+ using super_::operator();
+ /// Perform the rotation of the given vector.
+ algebra::vec<n,C> operator()(const algebra::vec<n,C>& v) const;
+
+ /// Set a new grade alpha.
+ void set_alpha(float alpha);
+ /// Set a new rotation axis.
+ void set_dir(unsigned dir);
+
+ protected:
+ void update();
+
+ float alpha_;
+ algebra::vec <n,float> axis_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n, typename C>
+ inline
+ rotation<n,C>::rotation()
+ {
+ }
+
+ template <unsigned n, typename C>
+ inline
+ rotation<n,C>::rotation(float alpha, const algebra::vec<n,float>&
axis)
+ :alpha_(alpha),
+ axis_(axis)
+ {
+ this->m_ = algebra::h_mat<n,C>::Id;
+ update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ algebra::vec<n,C>
+ rotation<n,C>::operator()(const algebra::vec<n,C>& v) const
+ {
+ algebra::mat<n+1,1,C> hmg;
+ algebra::mat<n+1,1,C> tmp;
+ algebra::vec<n,C> res;
+
+ for (unsigned i = 0; i < n; ++i)
+ hmg(i,0) = v[i];
+ hmg(n,0) = 1;
+ tmp = this->m_ * hmg;
+ mln_assertion(tmp(n,0) == 1);
+ for (unsigned i = 0; i < n; ++i)
+ res[i] = tmp(i,0);
+ return res;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ rotation<n,C>
+ rotation<n,C>::inv() const
+ {
+ typename rotation::invert res(-alpha_, axis_);
+ return res;
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ rotation<n,C>::set_alpha(float alpha)
+ {
+ alpha_ = alpha;
+ update();
+ }
+
+ template <unsigned n, typename C>
+ inline
+ void
+ rotation<n,C>::set_dir(unsigned dir)
+ {
+ update();
+ }
+
+ // Homogenous matrix for a rotation of a point (x,y,z)
+ // about the vector (u,v,w) by the angle alpha
+ template <unsigned n, typename C>
+ inline
+ void
+ rotation<n,C>::update()
+ {
+ this->m_ = internal::get_rot_h_mat(alpha_, axis_);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::geom
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_ROTATION_HH
Index: jardonnet/perl/test/x2x/interpol/bilinear.hh
--- jardonnet/perl/test/x2x/interpol/bilinear.hh (revision 0)
+++ jardonnet/perl/test/x2x/interpol/bilinear.hh (revision 0)
@@ -0,0 +1,139 @@
+// Copyright (C) 2008 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_FUN_X2X_INTERPOL_BILINEAR_HH
+# define MLN_FUN_X2X_INTERPOL_BILINEAR_HH
+
+# include <mln/core/image/image2d.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+
+/*! \file mln/fun/x2x/interpol/bilinear.hh
+ *
+ * \brief Define a bilinear interpolation of values from an underlying image
+ */
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace interpol
+ {
+
+
+ /*! \brief Represent a bilinear interolation of values from an underlying image
+ *
+ */
+ template < typename I >
+ struct bilinear
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is
n,T)
+ mln_value(I), bilinear<I> >::ret
+ {
+ typedef mln_value(I) result;
+
+ bilinear(const I& ima);
+
+ template <unsigned n, typename T>
+ mln_value(I)
+ operator()(const algebra::vec<n,T>& v) const;
+
+ const I& ima;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ bilinear<I>::bilinear(const I& ima) : ima(ima)
+ {
+ mlc_bool(I::psite::dim == 2)::check();
+ }
+
+ template <typename I>
+ template <unsigned n, typename T>
+ mln_value(I)
+ bilinear<I>::operator()(const algebra::vec<n,T>& v) const
+ {
+ typedef mln_sum(mln_value(I)) vsum;
+
+ // q12----r2----q22
+ // | | |
+ // | x |
+ // | | |
+ // q11----r1----q21
+
+ // looking for img(P(x,y))
+ double x = v[0];
+ double y = v[1];
+
+ double x1 = std::floor(v[0]);
+ double x2 = std::floor(v[0]) + 1;
+ double y1 = std::floor(v[1]);
+ double y2 = std::floor(v[1]) + 1;
+
+ //if (not ima.has(point2d(x1, y1))) return mln_value(I)();
+ vsum q11 = ima(point2d(x1, y1));
+ vsum q12 = ima(point2d(x1, y2));
+ vsum q21 = ima(point2d(x2, y1));
+ vsum q22 = ima(point2d(x2, y2));
+
+ double x2_x1 = x2 - x1;
+ double y2_y1 = y2 - y1;
+
+ // linear interpolation #1
+ vsum img_r1 = q11 * (x2 - x) / (x2_x1) +
+ q21 * (x - x1) / (x2_x1);
+
+ // linear interpolation #2
+ vsum img_r2 = q12 * (x2 - x) / (x2_x1) + q22 * (x - x1) / (x2_x1);
+
+ // interpolating in y direction
+ vsum res = (img_r1 * (y2 - y) / (y2_y1)
+ + img_r2 * (y - y1) / (y2_y1));
+
+ return convert::to<mln_value(I)>(res);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::interpol
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_INTERPOL_BILINEAR_HH
Index: jardonnet/perl/test/x2x/interpol/test.cc
--- jardonnet/perl/test/x2x/interpol/test.cc (revision 0)
+++ jardonnet/perl/test/x2x/interpol/test.cc (revision 0)
@@ -0,0 +1,14 @@
+#include "bilinear.hh"
+#include "linear.hh"
+
+int main()
+{
+ typedef mln::image2d<int> I;
+ typedef mln::image1d<int> II;
+
+ I ima2d;
+ II ima1d;
+
+ mln::fun::x2x::interpol::bilinear<I> interp(ima2d);
+ mln::fun::x2x::interpol::linear<II> interp3(ima1d);
+}
Index: jardonnet/perl/test/x2x/interpol/linear.hh
--- jardonnet/perl/test/x2x/interpol/linear.hh (revision 0)
+++ jardonnet/perl/test/x2x/interpol/linear.hh (revision 0)
@@ -0,0 +1,124 @@
+// Copyright (C) 2008 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_FUN_X2X_INTERPOL_LINEAR_HH
+# define MLN_FUN_X2X_INTERPOL_LINEAR_HH
+
+/*! \file mln/fun/x2x/interpol/linear.hh
+ *
+ * \brief Define a linear interpolation of values from an underlying image
+ */
+
+# include <mln/core/image/image1d.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ namespace interpol
+ {
+
+
+ /*! \brief Represent a linear interolation of values from an underlying image
+ *
+ */
+ template < typename I >
+ struct linear
+ : public fun::internal::selector_<const algebra::vec<1,float>,
+ // float is a dummy parameter (real is C)
+ mln_value(I), linear<I> >::ret
+ {
+ typedef mln_value(I) result;
+
+ /// Constructor with the underlying image
+ linear(const I& ima);
+
+ /// Return the interpolated value in the underlying image
+ /// at the given 'point' v.
+ template <typename C>
+ mln_value(I)
+ operator()(const algebra::vec<1,C>& v) const;
+
+ /// Underlying image
+ const I& ima;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ linear<I>::linear(const I& ima) : ima(ima)
+ {
+ mlc_bool(I::psite::dim == 1)::check();
+ }
+
+ template <typename I>
+ template <typename C>
+ mln_value(I)
+ linear<I>::operator()(const algebra::vec<1,C>& v) const
+ {
+ typedef mln_sum(mln_value(I)) vsum;
+
+ // looking for img(x);
+ double x = v[0];
+
+ // p1
+ double xa = mln_point(I)::coord(v[0]);
+ vsum ya = ima(point1d(xa));
+
+ // x makes sens in img
+ if (x == xa)
+ return ima(xa);
+
+ // p2
+ double xb = mln_point(I)::coord(v[0] + 1);
+ vsum yb = ima(point1d(xb));
+
+ // Taylor-young
+ return convert::to<mln_value(I)>
+ (ya + (x - xa) * (yb - ya) / (xb - xa));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x::interpol
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_INTERPOL_HH
Index: jardonnet/perl/test/p2b/chess.hh
--- jardonnet/perl/test/p2b/chess.hh (revision 0)
+++ jardonnet/perl/test/p2b/chess.hh (revision 0)
@@ -0,0 +1,78 @@
+// 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_FUN_P2B_CHESS_HH
+# define MLN_FUN_P2B_CHESS_HH
+
+/*! \file mln/fun/p2b/chess.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/alias/point2d.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ // FIXME: Doc!
+
+ struct chess_t : public Function_p2b< chess_t >
+ {
+ typedef bool result;
+ bool operator()(const point2d& p) const;
+ }
+
+ chess;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ bool
+ chess_t::operator()(const point2d& p) const
+ {
+ return (p.row() + p.col()) % 2 == 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_CHESS_HH
Index: jardonnet/perl/test/p2b/all.hh
--- jardonnet/perl/test/p2b/all.hh (revision 0)
+++ jardonnet/perl/test/p2b/all.hh (revision 0)
@@ -0,0 +1,56 @@
+// 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_FUN_P2B_ALL_HH
+# define MLN_FUN_P2B_ALL_HH
+
+/*! \file mln/fun/p2b/all.hh
+ *
+ * \brief File that includes all functions from point to boolean.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from point to boolean.
+ namespace p2b
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/p2b/chess.hh>
+
+
+
+#endif // ! MLN_FUN_P2B_ALL_HH
Index: jardonnet/perl/test/p2b/has.hh
--- jardonnet/perl/test/p2b/has.hh (revision 0)
+++ jardonnet/perl/test/p2b/has.hh (revision 0)
@@ -0,0 +1,137 @@
+// Copyright (C) 2008 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_FUN_P2B_HAS_HH
+# define MLN_FUN_P2B_HAS_HH
+
+/*! \file mln/fun/p2b/has.hh
+ *
+ * \brief Function "psite-> bool" that maps the call
"ima.has(p)".
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/const.hh>
+# include <mln/metal/unconst.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ // FIXME: Doc!
+
+ template <typename I>
+ struct has
+
+ : public Function_p2b< has<I> >,
+ private mlc_is_a(I, Image)::check_t
+ {
+ /// Result associated type.
+ typedef bool result;
+
+ /// Apply the function on the psite \p p.
+ bool operator()(const mln_psite(I)& p) const;
+
+
+ /// Constructor without argument.
+ has();
+
+ /// Constructor from an image \p ima.
+ has(mlc_const(I)& ima);
+
+
+ /// Copy constructor.
+ has(const has<I>& rhs);
+
+ /// Assignment operator.
+ has<I>& operator=(const has<I>& rhs);
+
+ private:
+ mlc_const(I) ima_;
+ typedef Function_p2b< has<I> > super_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ bool
+ has<I>::operator()(const mln_psite(I)& p) const
+ {
+ return ima_.has(p);
+ }
+
+ template <typename I>
+ inline
+ has<I>::has()
+ : ima_()
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>::has(mlc_const(I)& ima)
+ : ima_(ima)
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>::has(const has<I>& rhs)
+ : Function_v2v< has<I> >(), // Please g++.
+ super_(),
+ ima_(rhs.ima_)
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>&
+ has<I>::operator=(const has<I>& rhs)
+ {
+ if (&rhs == this)
+ return *this;
+ const_cast<mlc_unconst(I)&>(this->ima_) = rhs.ima_;
+ return *this;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_HAS_HH
Index: jardonnet/perl/test/vv2v/min.hh
--- jardonnet/perl/test/vv2v/min.hh (revision 0)
+++ jardonnet/perl/test/vv2v/min.hh (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_FUN_VV2V_MIN_HH
+# define MLN_FUN_VV2V_MIN_HH
+
+/// \file mln/fun/vv2v/min.hh
+/// \brief computing the minimum of two values using a functor.
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/min.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ // FIXME: Doc.
+
+ /// \brief A functor computing the minimum of two values.
+ template <typename V>
+ struct min : public Function_vv2v< min<V> >
+ {
+ typedef V result;
+ V operator()(const V& v1, const V& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ min<V>::operator()(const V& v1, const V& v2) const
+ {
+ return mln::math::min(v1, v2);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2V_MIN_HH
Index: jardonnet/perl/test/vv2v/max.hh
--- jardonnet/perl/test/vv2v/max.hh (revision 0)
+++ jardonnet/perl/test/vv2v/max.hh (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_FUN_VV2V_MAX_HH
+# define MLN_FUN_VV2V_MAX_HH
+
+/// \file mln/fun/vv2v/max.hh
+/// \brief Computing the maximum of two values using a functor.
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/max.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ // FIXME: Doc.
+
+ /// \brief A functor computing the maximum of two values.
+ template <typename V>
+ struct max : public Function_vv2v< max<V> >
+ {
+ typedef V result;
+ V operator()(const V& v1, const V& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ max<V>::operator()(const V& v1, const V& v2) const
+ {
+ return mln::math::max(v1, v2);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2V_MAX_HH
Index: jardonnet/perl/test/all.hh
--- jardonnet/perl/test/all.hh (revision 0)
+++ jardonnet/perl/test/all.hh (revision 0)
@@ -0,0 +1,63 @@
+// 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_FUN_ALL_HH
+# define MLN_FUN_ALL_HH
+
+/*! \file mln/fun/all.hh
+ *
+ * \brief File that includes all fun-related routines.
+ */
+
+
+namespace mln
+{
+
+ /// Namespace of image processing routines related to functions.
+ namespace fun
+ {
+
+ /// Internal namespace of functions.
+ namespace internal
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/c.hh>
+# include <mln/fun/ops.hh>
+# include <mln/fun/i2v/all.hh>
+# include <mln/fun/p2b/all.hh>
+# include <mln/fun/p2v/all.hh>
+# include <mln/fun/v2v/all.hh>
+# include <mln/fun/x2x/all.hh>
+
+
+
+#endif // ! MLN_FUN_ALL_HH
Index: jardonnet/perl/test/p2v/elifs.hh
--- jardonnet/perl/test/p2v/elifs.hh (revision 0)
+++ jardonnet/perl/test/p2v/elifs.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_FUN_P2V_ELIFS_HH
+# define MLN_FUN_P2V_ELIFS_HH
+
+/*! \file mln/fun/p2v/elifs.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/fun/p2v/ternary.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ template <typename T1, typename N1,
+ typename T2, typename N2,
+ typename O>
+ ternary_<T1, N1,
+ ternary_<T2, N2, O> >
+ elifs(const Function_p2b<T1>& f_if_1, const Function_p2v<N1>&
f_then_1,
+ const Function_p2b<T2>& f_if_2, const Function_p2v<N2>&
f_then_2,
+ const Function_p2v<O>& f_otherwise);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T1, typename N1,
+ typename T2, typename N2,
+ typename O>
+ inline
+ ternary_<T1, N1,
+ ternary_<T2, N2, O> >
+ elifs(const Function_p2b<T1>& f_if_1, const Function_p2v<N1>&
f_then_1,
+ const Function_p2b<T2>& f_if_2, const Function_p2v<N2>&
f_then_2,
+ const Function_p2v<O>& f_otherwise)
+ {
+ typedef ternary_<T2, N2, O> T2_N2_O;
+ T2_N2_O f_otherwise_1(f_if_2, f_then_2, f_otherwise);
+ ternary_<T1, N1, T2_N2_O> tmp(f_if_1, f_then_1, f_otherwise_1);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_ELIFS_HH
Index: jardonnet/perl/test/p2v/ternary.hh
--- jardonnet/perl/test/p2v/ternary.hh (revision 0)
+++ jardonnet/perl/test/p2v/ternary.hh (revision 0)
@@ -0,0 +1,120 @@
+// 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_FUN_P2V_TERNARY_HH
+# define MLN_FUN_P2V_TERNARY_HH
+
+/*! \file mln/fun/p2v/ternary.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ template <typename P, typename T, typename F>
+ struct ternary_
+ : fun::internal::selector_p2_<mln_result(T), ternary_<P,T,F> >::ret
+ {
+ typedef mln_result(T) result;
+
+ ternary_(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false);
+
+ template <typename Pt>
+ result operator()(const Pt& p) const;
+
+ protected:
+ const P f_pred_;
+ const T f_true_;
+ const F f_false_;
+ };
+
+
+ template <typename P, typename T, typename F>
+ ternary_<P, T, F>
+ ternary(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T, typename F>
+ inline
+ ternary_<P,T,F>::ternary_(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false)
+ : f_pred_(exact(f_pred)),
+ f_true_(exact(f_true)),
+ f_false_(exact(f_false))
+ {
+ }
+
+ template <typename P, typename T, typename F>
+ template <typename Pt>
+ inline
+ mln_result(T)
+ ternary_<P,T,F>::operator()(const Pt& p) const
+ {
+ return f_pred_(p) ? f_true_(p) : f_false_(p);
+ }
+
+
+ template <typename P, typename T, typename F>
+ inline
+ ternary_<P, T, F>
+ ternary(const Function_p2b<P>& f_pred,
+ const Function_p2v<T>& f_true,
+ const Function_p2v<F>& f_false)
+ {
+ ternary_<P, T, F> tmp(exact(f_pred),
+ exact(f_true),
+ exact(f_false));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_TERNARY_HH
Index: jardonnet/perl/test/p2v/all.hh
--- jardonnet/perl/test/p2v/all.hh (revision 0)
+++ jardonnet/perl/test/p2v/all.hh (revision 0)
@@ -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.
+
+#ifndef MLN_FUN_P2V_ALL_HH
+# define MLN_FUN_P2V_ALL_HH
+
+/*! \file mln/fun/p2v/all.hh
+ *
+ * \brief File that includes all functions from point to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from point to value.
+ namespace p2v
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/p2v/elifs.hh>
+# include <mln/fun/p2v/iota.hh>
+# include <mln/fun/p2v/ternary.hh>
+
+
+
+#endif // ! MLN_FUN_P2V_ALL_HH
Index: jardonnet/perl/test/p2v/iota.hh
--- jardonnet/perl/test/p2v/iota.hh (revision 0)
+++ jardonnet/perl/test/p2v/iota.hh (revision 0)
@@ -0,0 +1,106 @@
+// 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_FUN_P2V_IOTA_HH
+# define MLN_FUN_P2V_IOTA_HH
+
+/*! \file mln/fun/p2v/iota.hh
+ *
+ * \brief Iota function.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ struct iota_t : public Function_p2v< iota_t >
+ {
+ typedef unsigned result;
+
+ iota_t();
+
+ template <typename P>
+ unsigned operator()(const P&) const;
+
+ unsigned value() const;
+ void reset() const;
+
+ protected:
+ mutable unsigned i_;
+ }
+
+ iota;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ iota_t::iota_t()
+ {
+ reset();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ iota_t::operator()(const P&) const
+ {
+ return ++i_;
+ }
+
+ inline
+ unsigned
+ iota_t::value() const
+ {
+ return i_;
+ }
+
+ inline
+ void
+ iota_t::reset() const
+ {
+ i_ = 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_IOTA_HH
Index: jardonnet/perl/test/cast.hh
--- jardonnet/perl/test/cast.hh (revision 0)
+++ jardonnet/perl/test/cast.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_FUN_CAST_HH
+# define MLN_FUN_CAST_HH
+
+/*! \file mln/fun/cast.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ // FIXME: Doc!
+ template <typename V, typename F>
+ struct cast_p2v_expr_ : public Function_p2v< cast_p2v_expr_<V,F> >
+ {
+ typedef V result;
+
+ cast_p2v_expr_(const F& f)
+ : f_(f)
+ {}
+
+ template <typename P>
+ V operator()(const P& p) const
+ {
+ return static_cast<V>(f_(p)); // FIXME: value::cast?
+ }
+
+ protected:
+ const F f_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename F>
+ inline
+ cast_p2v_expr_<V, F>
+ cast(const Function_p2v<F>& f)
+ {
+ cast_p2v_expr_<V, F> tmp(exact(f));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_CAST_HH
Index: jardonnet/perl/test/v2b/threshold.hh
--- jardonnet/perl/test/v2b/threshold.hh (revision 0)
+++ jardonnet/perl/test/v2b/threshold.hh (revision 0)
@@ -0,0 +1,90 @@
+// Copyright (C) 2008 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_FUN_V2B_THRESHOLD_HH
+# define MLN_FUN_V2B_THRESHOLD_HH
+
+/*! \file mln/fun/v2b/threshold.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2b
+ {
+
+ /*!
+ *\brief Threshold function.
+ * f(v) = (v >= threshold).
+ *
+ */
+ template <typename V>
+ struct threshold : public Function_v2b< threshold<V> >
+ {
+ typedef bool result;
+ bool operator()(const V& v) const;
+
+ threshold(const V& a);
+ V a;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ threshold<V>::threshold(const V& a)
+ : a(a)
+ {
+ }
+
+ template <typename V>
+ inline
+ bool
+ threshold<V>::operator()(const V& v) const
+ {
+ return (v >= a);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2B_THRESHOLD_HH
Index: jardonnet/perl/test/internal/x2x_linear_impl.hh
--- jardonnet/perl/test/internal/x2x_linear_impl.hh (revision 0)
+++ jardonnet/perl/test/internal/x2x_linear_impl.hh (revision 0)
@@ -0,0 +1,102 @@
+// 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_FUN_INTERNAL_X2X_LINEAR_IMPL_HH
+# define MLN_FUN_INTERNAL_X2X_LINEAR_IMPL_HH
+
+/*! \file mln/fun/internal/x2x_linear_impl.hh
+ *
+ * \brief Implementation class for every linear Function_x2x.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/h_mat.hh>
+# include <mln/algebra/h_vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ template <typename V, typename E>
+ struct x2x_linear_impl_
+ {
+ static const unsigned dim = V::dim; // To please g++ when comparing dim in metal
bexpr.
+
+ typedef V argument;
+ typedef V result;
+ typedef typename V::coord coord;
+ typedef algebra::h_mat<dim, coord> matrix;
+
+ V operator()(const V& x) const
+ {
+ algebra::h_vec<dim, coord> tmp = m_ * x.to_h_vec();
+ return tmp.to_vec();
+ }
+
+ const matrix& mat() const;
+
+ protected:
+ x2x_linear_impl_();
+
+ matrix m_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename E>
+ inline
+ x2x_linear_impl_<V,E>::x2x_linear_impl_()
+ {
+ }
+
+
+ template <typename V, typename E>
+ inline
+ const typename x2x_linear_impl_<V,E>::matrix&
+ x2x_linear_impl_<V,E>::mat() const
+ {
+ return m_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_INTERNAL_X2X_LINEAR_IMPL_HH
Index: jardonnet/perl/test/internal/selector.hh
--- jardonnet/perl/test/internal/selector.hh (revision 0)
+++ jardonnet/perl/test/internal/selector.hh (revision 0)
@@ -0,0 +1,200 @@
+// Copyright (C) 2007, 2008 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_FUN_INTERNAL_SELECTOR_HH
+# define MLN_FUN_INTERNAL_SELECTOR_HH
+
+/*! \file mln/fun/internal/selector.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/site.hh>
+# include <mln/core/concept/pseudo_site.hh>
+# include <mln/metal/unqualif.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/is_a.hh>
+# include <mln/algebra/vec.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ // Function_v2v
+ // |
+ // + ---------------------- Function_v2b
+ // | |
+ // + -- Function_i2v |
+ // | |
+ // + -- Function_x2x |
+ // | |
+ // + -- Function_p2v |
+ // | |
+ // + -- Function_p2b -- +
+ // |
+ // + -- Function_p2p
+
+ enum
+ {
+ b_,
+ i_,
+ p_,
+ v_,
+ x_
+ };
+
+ template <int arg, int res, typename E> struct helper_selector_;
+
+ // b2* => v2v type, except for v2b
+ template <typename E>
+ struct helper_selector_< b_, b_, E > { typedef Function_v2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, v_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< b_, x_, E > { typedef Function_v2v<E> ret; };
+
+ // i2* => i2v type
+ template <typename E>
+ struct helper_selector_< i_, b_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, i_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, p_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, v_, E > { typedef Function_i2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< i_, x_, E > { typedef Function_i2v<E> ret; };
+
+ // p2*
+ template <typename E>
+ struct helper_selector_< p_, b_, E > { typedef Function_p2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, i_, E > { typedef Function_p2v<E> ret; };
// no p2i type => p2v
+ template <typename E>
+ struct helper_selector_< p_, p_, E > { typedef Function_p2p<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, v_, E > { typedef Function_p2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< p_, x_, E > { typedef Function_p2v<E> ret; };
+
+ // v2* => v2v type, except for v2b
+ template <typename E>
+ struct helper_selector_< v_, b_, E > { typedef Function_v2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, v_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< v_, x_, E > { typedef Function_v2v<E> ret; };
+
+ // x2* => v2v type
+ template <typename E>
+ struct helper_selector_< x_, b_, E > { typedef Function_v2b<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, i_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, p_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, v_, E > { typedef Function_v2v<E> ret; };
+ template <typename E>
+ struct helper_selector_< x_, x_, E > { typedef Function_v2v<E> ret; };
+
+ // tag_
+
+ template <typename T> struct tag_;
+
+ template <>
+ struct tag_< bool >
+ {
+ enum { value = b_ };
+ };
+
+ template <>
+ struct tag_< unsigned >
+ {
+ enum { value = i_ };
+ };
+
+ template <unsigned n, typename T>
+ struct tag_< algebra::vec<n,T> >
+ {
+ enum { value = x_ };
+ };
+
+ template <typename T>
+ struct tag_
+ {
+ enum { value = (mlc_is_a(T, Site)::value || mlc_is_a(T, Pseudo_Site)::value)
+ ? p_
+ : v_ };
+ };
+
+
+ template <typename R_, typename A_, typename E>
+ struct selector_
+ {
+ typedef mlc_unqualif(R_) R;
+ typedef mlc_unqualif(A_) A;
+ enum { arg = tag_<A>::value,
+ res = tag_<R>::value };
+ typedef typename helper_selector_<arg, res, E>::ret ret;
+ private:
+ selector_();
+ };
+
+
+ template <typename R_, typename E>
+ struct selector_p2_
+ {
+ typedef mlc_unqualif(R_) R;
+ enum { res = tag_<R>::value };
+ typedef typename helper_selector_<p_, res, E>::ret ret;
+ private:
+ selector_p2_();
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_INTERNAL_SELECTOR_HH
Index: jardonnet/perl/test/v2v/abs.hh
--- jardonnet/perl/test/v2v/abs.hh (revision 0)
+++ jardonnet/perl/test/v2v/abs.hh (revision 0)
@@ -0,0 +1,78 @@
+// 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_FUN_V2V_ABS_HH
+# define MLN_FUN_V2V_ABS_HH
+
+/*! \file mln/fun/v2v/abs.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/math/abs.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct abs : public Function_v2v< abs<V> >
+ {
+ typedef V result;
+ V operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ abs<V>::operator()(const V& v) const
+ {
+ return mln::math::abs(v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ABS_HH
Index: jardonnet/perl/test/v2v/enc.hh
--- jardonnet/perl/test/v2v/enc.hh (revision 0)
+++ jardonnet/perl/test/v2v/enc.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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_FUN_V2V_ENC_HH
+# define MLN_FUN_V2V_ENC_HH
+
+/*! \file mln/fun/v2v/enc.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct enc : public Function_v2v< enc<V> >
+ {
+ typedef typename V::enc result;
+ result operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ typename V::enc
+ enc<V>::operator()(const V& v) const
+ {
+ return v.to_enc();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ENC_HH
Index: jardonnet/perl/test/v2v/saturate.hh
--- jardonnet/perl/test/v2v/saturate.hh (revision 0)
+++ jardonnet/perl/test/v2v/saturate.hh (revision 0)
@@ -0,0 +1,129 @@
+// 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_FUN_V2V_SATURATE_HH
+# define MLN_FUN_V2V_SATURATE_HH
+
+/*! \file mln/fun/v2v/saturate.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/converts_to.hh>
+# include <mln/trait/value_.hh>
+# include <mln/value/cast.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct saturate : public Function_v2v< saturate<V> >
+ {
+ saturate();
+ saturate(const V& min, const V& max);
+
+ typedef V result;
+
+ template <typename W>
+ V operator()(const W& w) const;
+
+ protected:
+ V min_, max_;
+ mutable bool needs_update_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ saturate<V>::saturate()
+ : min_(mln_min(V)),
+ max_(mln_max(V))
+ {
+ needs_update_ = true;
+ }
+
+ template <typename V>
+ inline
+ saturate<V>::saturate(const V& min, const V& max)
+ : min_(min),
+ max_(max)
+ {
+ mln_precondition(max > min);
+ needs_update_ = true;
+ }
+
+ template <typename V>
+ template <typename W>
+ inline
+ V
+ saturate<V>::operator()(const W& w) const
+ {
+ // FIXME: Check that W is a larger type than V; otherwise
+ // alt code.
+
+ static W min_W, max_W;
+ if (needs_update_)
+ {
+ min_W = mln::value::cast<W>(min_);
+ max_W = mln::value::cast<W>(max_);
+ needs_update_ = false;
+ }
+
+ // FIXME: Below we need something more powerful that mlc_converts_to
+ // for instance, with W=int_s<10u> and V=int_u<8u>, it does not
+ // works cause the cast is not obvious...
+ // mlc_converts_to(W, V)::check();
+
+ if (w < min_W)
+ return min_;
+ if (w > max_W)
+ return max_;
+ return mln::value::cast<W>(w);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_SATURATE_HH
Index: jardonnet/perl/test/v2v/all.hh
--- jardonnet/perl/test/v2v/all.hh (revision 0)
+++ jardonnet/perl/test/v2v/all.hh (revision 0)
@@ -0,0 +1,61 @@
+// 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_FUN_V2V_ALL_HH
+# define MLN_FUN_V2V_ALL_HH
+
+/*! \file mln/fun/v2v/all.hh
+ *
+ * \brief File that includes all functions from value to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from value to value.
+ namespace v2v
+ {
+ }
+ }
+
+}
+
+
+# include <mln/fun/v2v/abs.hh>
+# include <mln/fun/v2v/cast.hh>
+# include <mln/fun/v2v/enc.hh>
+# include <mln/fun/v2v/id.hh>
+# include <mln/fun/v2v/linear.hh>
+# include <mln/fun/v2v/saturate.hh>
+
+
+
+#endif // ! MLN_FUN_V2V_ALL_HH
Index: jardonnet/perl/test/v2v/inc.hh
--- jardonnet/perl/test/v2v/inc.hh (revision 0)
+++ jardonnet/perl/test/v2v/inc.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2008 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_FUN_V2V_INC_HH
+# define MLN_FUN_V2V_INC_HH
+
+/*! \file mln/fun/v2v/inc.hh
+ *
+ * \brief Incrementation function.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct inc
+ : fun::internal::selector_<T, T, inc<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T
+ inc<T>::operator()(const T& t) const
+ {
+ return t + 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_INC_HH
Index: jardonnet/perl/test/v2v/linear.hh
--- jardonnet/perl/test/v2v/linear.hh (revision 0)
+++ jardonnet/perl/test/v2v/linear.hh (revision 0)
@@ -0,0 +1,94 @@
+// 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_FUN_V2V_LINEAR_HH
+# define MLN_FUN_V2V_LINEAR_HH
+
+/*! \file mln/fun/v2v/linear.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /*!
+ *\brief Linear function.
+ * f(v) = a * v + b.
+ * \c V is the type of input values; \c T is the type used to
+ * compute the result; \c R is the result type.
+ *
+ * By defaut, \c T is \c V and \c R is \c T.
+ */
+ template <typename V, typename T = V, typename R = T>
+ struct linear : public Function_v2v< linear<V,T,R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+
+ linear(T a, T b);
+ T a, b;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename T, typename R>
+ inline
+ linear<V,T,R>::linear(T a, T b)
+ : a(a),
+ b(b)
+ {
+ }
+
+ template <typename V, typename T, typename R>
+ inline
+ R
+ linear<V,T,R>::operator()(const V& v) const
+ {
+ return R(a * T(v) + b);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_LINEAR_HH
Index: jardonnet/perl/test/v2v/cast.hh
--- jardonnet/perl/test/v2v/cast.hh (revision 0)
+++ jardonnet/perl/test/v2v/cast.hh (revision 0)
@@ -0,0 +1,81 @@
+// 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_FUN_V2V_CAST_HH
+# define MLN_FUN_V2V_CAST_HH
+
+/*! \file mln/fun/v2v/cast.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/value/cast.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename V>
+ struct cast : public Function_v2v< cast<V> >
+ {
+ typedef V result;
+
+ template <typename W>
+ V operator()(const W& w) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ template <typename W>
+ inline
+ V
+ cast<V>::operator()(const W& w) const
+ {
+ return mln::value::cast<V>(w);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_CAST_HH
Index: jardonnet/perl/test/v2v/norm.hh
--- jardonnet/perl/test/v2v/norm.hh (revision 0)
+++ jardonnet/perl/test/v2v/norm.hh (revision 0)
@@ -0,0 +1,130 @@
+// 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_FUN_V2V_NORM_HH
+# define MLN_FUN_V2V_NORM_HH
+
+/*! \file mln/fun/v2v/norm.hh
+ *
+ * \brief Norm functors.
+ *
+ * \see mln/norm/.
+ */
+
+// FIXME: Move to mln/fun/x2v/?
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/norm/all.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /*! \brief L1-norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::l1.
+ */
+ template <typename V, typename R>
+ struct l1_norm : public Function_v2v< l1_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+ /*! \brief L2-norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::l2.
+ */
+ template <typename V, typename R>
+ struct l2_norm : public Function_v2v< l2_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+ /*! \brief L-infty norm.
+ *
+ * \c V is the type of input values; \c R is the result type.
+ *
+ * \see mln::norm::linfty.
+ */
+ template <typename V, typename R>
+ struct linfty_norm : public Function_v2v< linfty_norm<V, R> >
+ {
+ typedef R result;
+ R operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V, typename R>
+ inline
+ R
+ l1_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::l1 (v);
+ }
+
+ template <typename V, typename R>
+ inline
+ R
+ l2_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::l2 (v);
+ }
+
+ template <typename V, typename R>
+ inline
+ R
+ linfty_norm<V, R>::operator()(const V& v) const
+ {
+ return mln::norm::linfty (v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_NORM_HH
Index: jardonnet/perl/test/v2v/dec.hh
--- jardonnet/perl/test/v2v/dec.hh (revision 0)
+++ jardonnet/perl/test/v2v/dec.hh (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (C) 2008 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_FUN_V2V_DEC_HH
+# define MLN_FUN_V2V_DEC_HH
+
+/*! \file mln/fun/v2v/dec.hh
+ *
+ * \brief Decrementation function.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct dec
+ : fun::internal::selector_<T, T, dec<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T
+ dec<T>::operator()(const T& t) const
+ {
+ return t - 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_DEC_HH
Index: jardonnet/perl/test/v2v/id.hh
--- jardonnet/perl/test/v2v/id.hh (revision 0)
+++ jardonnet/perl/test/v2v/id.hh (revision 0)
@@ -0,0 +1,78 @@
+// 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_FUN_V2V_ID_HH
+# define MLN_FUN_V2V_ID_HH
+
+/*! \file mln/fun/v2v/id.hh
+ *
+ * \brief Identity function.
+ */
+
+# include <mln/fun/internal/selector.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ // FIXME: Doc!
+
+ template <typename T>
+ struct id
+ : fun::internal::selector_<T, T, id<T> >::ret
+ {
+ typedef T result;
+ T operator()(const T& t) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T
+ id<T>::operator()(const T& t) const
+ {
+ return t;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_ID_HH
Index: jardonnet/perl/test/v2v/rgb_to_hsi.hh
--- jardonnet/perl/test/v2v/rgb_to_hsi.hh (revision 0)
+++ jardonnet/perl/test/v2v/rgb_to_hsi.hh (revision 0)
@@ -0,0 +1,143 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_RGB_TO_HSI_HH
+# define MLN_FUN_V2V_RGB_TO_HSI_HH
+
+#include <cmath>
+
+#include <mln/value/rgb8.hh>
+#include <mln/math/round.hh>
+
+#include <mln/value/hsi.hh>
+
+
+// FIXME: Split interface and implementation.
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename T_hsi>
+ struct f_rgb_to_hsi_ : public Function_v2v< f_rgb_to_hsi_<T_hsi> >
+ {
+ typedef T_hsi result;
+
+ template <typename T_rgb>
+ T_hsi operator()(const T_rgb& rgb) const
+ {
+ // Locals.
+ static const double sqrt3_3 = std::sqrt(3) / 3;
+ static const double inv_sqrt6 = 1 / std::sqrt(6);
+ static const double inv_sqrt2 = 1 / std::sqrt(2);
+
+ T_hsi hsi;
+
+ double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue();
+ double beta =
+ 2 * inv_sqrt6 * rgb.red() -
+ inv_sqrt6 * rgb.green() -
+ inv_sqrt6 * rgb.blue();
+
+
+ hsi.hue() = atan2(beta, alpha) / 3.1415 * 180.0;
+ if (hsi.hue() < 0)
+ hsi.hue() = hsi.hue() + 360.0;
+ mln_invariant(hsi.hue() >= 0);
+ hsi.sat() = std::sqrt(alpha * alpha + beta * beta);
+ hsi.inty() =
+ sqrt3_3 * rgb.red() +
+ sqrt3_3 * rgb.green() +
+ sqrt3_3 * rgb.blue();
+
+ return hsi;
+ }
+ };
+
+ typedef f_rgb_to_hsi_<value::hsi_f> f_rgb_to_hsi_f_t;
+
+ // FIXME: Warning: global object.
+ f_rgb_to_hsi_f_t f_rgb_to_hsi_f;
+
+
+ template <typename T_rgb>
+ struct f_hsi_to_rgb_ : public Function_v2v< f_hsi_to_rgb_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_hsi>
+ T_rgb operator()(const T_hsi& hsi) const
+ {
+ typedef typename T_rgb::red_t red_t;
+ typedef typename T_rgb::green_t green_t;
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<red_t> to_r;
+ static math::round<green_t> to_g;
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsi.hue() / 180.0 * 3.1415,
+ alpha = hsi.sat() * std::cos(h),
+ beta = hsi.sat() * std::sin(h);
+
+
+ red_t r = to_r(sqrt3_3 * hsi.inty() + 2 * inv_sqrt6 * beta);
+ green_t g =
+ to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ blue_t b =
+ to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+
+ T_rgb rgb(r, g, b);
+
+ return rgb;
+ }
+ };
+
+ typedef f_hsi_to_rgb_<value::rgb8> f_hsi_to_rgb_3x8_t;
+
+ // FIXME: Warning: global object.
+ f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8;
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_HSI_HH
Index: jardonnet/perl/hxx.pl
--- jardonnet/perl/hxx.pl (revision 0)
+++ jardonnet/perl/hxx.pl (revision 0)
@@ -0,0 +1,27 @@
+#!/usr/bin/env perl
+
+# while (<>) {
+# print if /\# ifndef MLN_INCLUDE_ONLY/ .. /\# endif \/\/ ! MLN_INCLUDE_ONLY/
+# }
+# perl -0777 -ne 'print "$1\n" while /ifndef MLN_INCLUDE_ONLY(.*?)#
endif/gs'
+
+sub process($)
+{
+ $file = shift;
+
+ open(IN, '<', $file) or die "Failed to open `$file' for reading:
$!";
+ $_ = join('', <IN>);
+ close(IN) or die "Failed to close `$file': $!";
+
+ print if /\# ifndef MLN_INCLUDE_ONLY/ .. /\# endif \/\/ ! MLN_INCLUDE_ONLY/;
+
+ #open(OUT, '>', $file) or die "Failed to open `$file' for
writing: $!";
+ #print OUT;
+ #close(OUT) or die "Failed to close `$file': $!";
+}
+
+my @input_files = @ARGV; #parse_options();
+foreach my $file (@input_files)
+{
+ process $file;
+}
Property changes on: jardonnet/perl/hxx.pl
___________________________________________________________________
Name: svn:executable
+ *
Index: jardonnet/registration/quat7.hh
--- jardonnet/registration/quat7.hh (revision 2468)
+++ jardonnet/registration/quat7.hh (working copy)
@@ -179,9 +179,6 @@
algebra::quat qR(literal::zero);
qR = jacobi(Qk);
- //std::cout << qR << std::endl;
- //qR = power_it(Qk);
- //std::cout << qR << std::endl;
// qT
const algebra::vec<P::dim,float> qT = mu_Xk - rotate(qR, mu_C);
Index: jardonnet/registration/registration.hh
--- jardonnet/registration/registration.hh (revision 2468)
+++ jardonnet/registration/registration.hh (working copy)
@@ -61,13 +61,10 @@
namespace registration
{
-#ifndef NDEBUG
- static unsigned pts = 0;
-#endif
+
+ using namespace fun::x2x::geom;
/*! Registration FIXME : doxy
- *
- *
*/
template <typename I, typename J>
inline
@@ -75,11 +72,14 @@
registration(const Image<I>& cloud,
const Image<J>& surface);
+
# ifndef MLN_INCLUDE_ONLY
+
namespace impl
{
+
template <typename P, typename M, typename T>
inline
void
@@ -133,11 +133,12 @@
} // end of namespace mln::registration::impl
+
// FIXME: Separate icp.hh registration.hh multiscale_registration.hh
// FIXME: Make it works in 3d *AND* 2d
template <typename P, typename M>
inline
- quat7<P::dim> // what is it suposed to return tr(rot()), rot(tr()) or something
else ...
+ composed< rotation<P::dim, float>, translation<P::dim, float> >
registration(p_array<P>& cloud,
const M& map,
const p_array<P>& x)
@@ -158,10 +159,13 @@
return qk;
}
+
# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln::registration
+
} // end of namespace mln