URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-09 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add composed transformation. (Does not work !).
* mln/fun/x2x/bijective_tr.hh: Bijective transformation.
* mln/fun/x2x/composed.hh: Composed tranformation.
* mln/fun/x2x/rotation.hh: Update.
* mln/fun/x2x/translation.hh: Update.
---
bijective_tr.hh | 68 +++++++++++++++++++++++
composed.hh | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rotation.hh | 4 -
translation.hh | 4 -
4 files changed, 233 insertions(+), 4 deletions(-)
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 0)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1284)
@@ -0,0 +1,161 @@
+// 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_COMPOSED_HH
+# define MLN_FUN_X2X_COMPOSED_HH
+
+/*! \file mln/fun/x2x/composed.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/vec.hh>
+# include <mln/metal/mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ // Fwd decl.
+ template <typename L, typename M>
+ struct composed;
+
+ namespace internal
+ {
+
+ template <unsigned n, typename L, unsigned m, typename M, typename E>
+ struct helper_;
+
+ template <unsigned n, typename L, typename M, typename E>
+ struct helper_<n, Function_x2x<L>, n, Function_x2x<M> > :
Function_x2x<E>
+ {
+ enum {dim = n};
+ };
+
+ template <unsigned n, typename L, typename M, typename E>
+ struct helper_<n, bijective_tr<L>, n, bijective_tr<M> > :
bijective_tr<E>
+ {
+ enum {dim = n};
+ typedef composed<M::invert,L::invert> invert;
+
+ invert inv() const;
+ };
+ }
+
+ // FIXME: Doc!
+
+ template <typename L, typename M>
+ struct composed : public internal::helper_< L::dim, L, M::dim, M,
composed<L,M> >
+ {
+
+ typedef internal::helper_< L::dim, L, M::dim, M, composed<L,M> > Super
+
+ enum {dim = Super::dim};
+
+ typedef metal::vec<n,C> result;
+
+ composed();
+ composed(const L& tr_l, const M& tr_m);
+
+ result operator()(const metal::vec<n,C>& v) const;
+
+ void set_first(const L& tr_l);
+ void set_second(const M& tr_m);
+
+ protected:
+
+ L tr1_;
+ M tr2_;
+ metal::mat<n + 1,n + 1,C> m_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename M>
+ composed<L,M>::composed()
+ {
+ t_ = make::vec<n,C>(0);
+ m_ = metal::mat<n+1,n+1,C>::Id;
+ }
+
+ template <typename L, typename M>
+ composed<L,M>::composed(const L& tr_l, const M& tr_m)
+ :tr1_(tr_l),
+ tr2_(tr_m)
+ {
+ m_ = metal::mat<n+1,n+1,C>::Id;
+ m_ = tr1_ * tr2_;
+ }
+
+ template <typename L, typename M>
+ composed<L,M>::result
+ composed<L,M>::operator()(const metal::vec<n,C>& v) const
+ {
+ return m_(v);
+ }
+
+ template <typename L, typename M>
+ composed<L,M>::invert
+ composed<L,M>::inv() const
+ {
+ typename composed::invert res(tr2_.inv(), tr1_.inv());
+
+ return res;
+ }
+
+ template <typename L, typename M>
+ void
+ composed<L,M>::set_first(const L& tr_l)
+ {
+ tr1_ = tr_l;
+ }
+
+ template <typename L, typename M>
+ void
+ composed<L,M>::set_second(const M& tr_m)
+ {
+ tr2_ = tr_m;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_COMPOSED_HH
Index: trunk/milena/mln/fun/x2x/bijective_tr.hh
===================================================================
--- trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 0)
+++ trunk/milena/mln/fun/x2x/bijective_tr.hh (revision 1284)
@@ -0,0 +1,68 @@
+// 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_BIJECTIVE_TR_HH
+# define MLN_FUN_X2X_BIJECTIVE_TR_HH
+
+/*! \file mln/fun/x2x/bijective_tr.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/vec.hh>
+# include <mln/metal/mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace x2x
+ {
+
+ // FIXME: Doc!
+
+ template <typename E>
+ struct bijective_tr : public Function_x2x< E >
+ {
+ typedef E::result result;
+ typedef E::invert invert;
+
+ invert inv() const;
+ };
+
+ } // end of namespace mln::fun::x2x
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2X_BIJECTIVE_TR_HH
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1283)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1284)
@@ -33,7 +33,7 @@
* \brief FIXME.
*/
-# include <mln/core/concept/function.hh>
+# include <mln/fun/x2x/bijective_tr.hh>
# include <mln/metal/vec.hh>
# include <mln/metal/mat.hh>
@@ -50,7 +50,7 @@
// FIXME: Doc!
template <unsigned n, typename C>
- struct translation : public Function_x2x< translation<n,C> >
+ struct translation : public bijective_tr< translation<n,C> >
{
enum {dim = n};
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1283)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1284)
@@ -33,7 +33,7 @@
* \brief FIXME.
*/
-# include <mln/core/concept/function.hh>
+# include <mln/fun/x2x/bijective_tr.hh>
# include <mln/metal/vec.hh>
# include <mln/metal/mat.hh>
# include <cmath>
@@ -51,7 +51,7 @@
// FIXME: Doc!
template <unsigned n, typename C>
- struct rotation : public Function_x2x< rotation<n,C> >
+ struct rotation : public bijective_tr< rotation<n,C> >
{
enum {dim = n};