URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-01 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add trait for operators * + -.
* mln/core/trait/mult.hh: Rename as...
* mln/core/trait/op_mult.hh: ...this.
* mln/core/trait/op_minus.hh: New.
* mln/core/trait/op_plus.hh: New.
* mln/core/trait/op_uminus.hh: New.
* mln/core/trait/all.hh: Include files above.
---
all.hh | 5 ++
op_minus.hh | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
op_mult.hh | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
op_plus.hh | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
op_uminus.hh | 83 ++++++++++++++++++++++++++++++++++
5 files changed, 505 insertions(+)
Index: trunk/milena/mln/core/trait/mult.hh (deleted)
===================================================================
Index: trunk/milena/mln/core/trait/op_plus.hh
===================================================================
--- trunk/milena/mln/core/trait/op_plus.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_plus.hh (revision 1200)
@@ -0,0 +1,135 @@
+// Copyright (C) 2006 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_TRAIT_OP_PLUS_HH
+# define MLN_TRAIT_OP_PLUS_HH
+
+
+# define mln_op_plus(T, U) typename mln::trait::op_plus< T , U >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T, typename U>
+ struct op_plus;
+
+
+ template <typename T>
+ struct op_plus<T, T>
+ {
+ typedef T ret;
+ };
+
+ template <>
+ struct op_plus<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct op_plus<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct op_plus<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_plus<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct op_plus<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_plus<float, double>
+ {
+ typedef double ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_plus<metal::vec<n, T>, U>
+ {
+ typedef metal::vec<n, mln_op_plus(T, U)> ret;
+ };
+ template <typename U, unsigned n, typename T>
+ struct op_plus<U, metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_plus(T, U)> ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_plus<metal::vec<n, T>, metal::vec<n, U> >
+ {
+ typedef metal::vec<n, mln_op_plus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_plus<metal::mat<n, m, T>, U>
+ {
+ typedef metal::mat<n, m, mln_op_plus(T, U)> ret;
+ };
+ template <typename U, unsigned n, unsigned m, typename T>
+ struct op_plus<U, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_plus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_plus<metal::mat<n, m, T>, metal::mat<n, m, U> >
+ {
+ typedef metal::mat<n, m, mln_op_plus(T, U)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_PLUS_HH
Index: trunk/milena/mln/core/trait/all.hh
===================================================================
--- trunk/milena/mln/core/trait/all.hh (revision 1199)
+++ trunk/milena/mln/core/trait/all.hh (revision 1200)
@@ -46,6 +46,11 @@
# include <mln/core/trait/is_fast.hh>
# include <mln/core/trait/pixter.hh>
+# include <mln/core/trait/op_mult.hh>
+# include <mln/core/trait/op_plus.hh>
+# include <mln/core/trait/op_minus.hh>
+# include <mln/core/trait/op_uminus.hh>
+# include <mln/core/trait/promote.hh>
#endif // ! MLN_CORE_TRAIT_ALL_HH
Index: trunk/milena/mln/core/trait/op_minus.hh
===================================================================
--- trunk/milena/mln/core/trait/op_minus.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_minus.hh (revision 1200)
@@ -0,0 +1,141 @@
+// Copyright (C) 2006 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_TRAIT_OP_MINUS_HH
+# define MLN_TRAIT_OP_MINUS_HH
+
+
+# define mln_op_minus(T, U) typename mln::trait::op_minus< T , U >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T, typename U>
+ struct op_minus;
+
+
+ template <typename T>
+ struct op_minus<T, T>
+ {
+ typedef T ret;
+ };
+
+ template <typename T>
+ struct op_minus<unsigned, T>
+ {
+ typedef mln_op_minus(signed, T) ret;
+ };
+
+ template <>
+ struct op_minus<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct op_minus<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct op_minus<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_minus<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct op_minus<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_minus<float, double>
+ {
+ typedef double ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_minus<metal::vec<n, T>, U>
+ {
+ typedef metal::vec<n, mln_op_minus(T, U)> ret;
+ };
+ template <typename U, unsigned n, typename T>
+ struct op_minus<U, metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_minus(T, U)> ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_minus<metal::vec<n, T>, metal::vec<n, U> >
+ {
+ typedef metal::vec<n, mln_op_minus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_minus<metal::mat<n, m, T>, U>
+ {
+ typedef metal::mat<n, m, mln_op_minus(T, U)> ret;
+ };
+ template <typename U, unsigned n, unsigned m, typename T>
+ struct op_minus<U, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_minus(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_minus<metal::mat<n, m, T>, metal::mat<n, m, U> >
+ {
+ typedef metal::mat<n, m, mln_op_minus(T, U)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_MINUS_HH
Index: trunk/milena/mln/core/trait/op_uminus.hh
===================================================================
--- trunk/milena/mln/core/trait/op_uminus.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_uminus.hh (revision 1200)
@@ -0,0 +1,83 @@
+// Copyright (C) 2006 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_TRAIT_OP_UMINUS_HH
+# define MLN_TRAIT_OP_UMINUS_HH
+
+
+# define mln_op_uminus(T) typename mln::trait::op_uminus< T >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct op_uminus
+ {
+ typedef T ret;
+ };
+
+
+ template <>
+ struct op_uminus<unsigned>
+ {
+ typedef signed ret;
+ };
+
+ template <unsigned n, typename T>
+ struct op_uminus<metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_uminus(T)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T>
+ struct op_uminus<metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_uminus(T)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_UMINUS_HH
Index: trunk/milena/mln/core/trait/op_mult.hh
===================================================================
--- trunk/milena/mln/core/trait/op_mult.hh (revision 0)
+++ trunk/milena/mln/core/trait/op_mult.hh (revision 1200)
@@ -0,0 +1,141 @@
+// Copyright (C) 2006 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_TRAIT_OP_MULT_HH
+# define MLN_TRAIT_OP_MULT_HH
+
+
+# define mln_op_mult(T, U) typename mln::trait::op_mult< T , U >::ret
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <unsigned n, typename T>
+ class vec;
+
+ template <unsigned n, unsigned m, typename T>
+ class mat;
+
+ } // end of namespace mln::metal
+
+ namespace trait
+ {
+
+ template <typename T, typename U>
+ struct op_mult;
+
+
+ template <typename T>
+ struct op_mult<T, T>
+ {
+ typedef T ret;
+ };
+
+ template <>
+ struct op_mult<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct op_mult<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct op_mult<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_mult<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct op_mult<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct op_mult<float, double>
+ {
+ typedef double ret;
+ };
+
+ template <unsigned n, typename T, typename U>
+ struct op_mult<metal::vec<n, T>, U>
+ {
+ typedef metal::vec<n, mln_op_mult(T, U)> ret;
+ };
+ template <typename U, unsigned n, typename T>
+ struct op_mult<U, metal::vec<n, T> >
+ {
+ typedef metal::vec<n, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ struct op_mult<metal::mat<n, m, T>, U>
+ {
+ typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ };
+ template <typename U, unsigned n, unsigned m, typename T>
+ struct op_mult<U, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned n, unsigned o, typename T, unsigned m, typename U>
+ struct op_mult<metal::mat<n, o, T>, metal::mat<o, m, U> >
+ {
+ typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned m, unsigned n, typename T, typename U>
+ struct op_mult<metal::mat<m, n, T>, metal::vec<n, U> >
+ {
+ typedef metal::mat<m, 1, mln_op_mult(T, U)> ret;
+ };
+
+ template <unsigned n, typename U, unsigned m, typename T>
+ struct op_mult< metal::vec<n, U>, metal::mat<n, m, T> >
+ {
+ typedef metal::mat<1, m, mln_op_mult(T, U)> ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_OP_MULT_HH