URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-19 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add vector and interpolated image based on it.
* mln/core/interpolated.hh: Interpolated image.
* mln/make/vec.hh: Build a vector.
* sandbox/nivault/binary_arith.hh: Rename to...
* mln/metal/binary_arith_trait.hh: ...this, Promotion.
* mln/metal/vec.hh: Update.
* sandbox/nivault/tests/test.cc: Rename to ....
* tests/interpolated.cc: ...this.
* tests/metal_vec.cc: New.
---
trunk/milena/mln/core/interpolated.hh | 186 +++++++++++++++++
trunk/milena/mln/make/vec.hh | 133 ++++++++++++
trunk/milena/mln/metal/binary_arith_trait.hh | 73 ++++++
trunk/milena/mln/metal/vec.hh | 293 ++++++++++++++++++++++-----
trunk/milena/tests/interpolated.cc | 70 ++++++
trunk/milena/tests/metal_vec.cc | 43 +++
6 files changed, 752 insertions(+), 46 deletions(-)
Index: trunk/milena/tests/metal_vec.cc
===================================================================
--- trunk/milena/tests/metal_vec.cc (revision 0)
+++ trunk/milena/tests/metal_vec.cc (revision 1130)
@@ -0,0 +1,43 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/level_median.cc
+ *
+ * \brief Test on mln::median::median_dir.
+ */
+
+#include <mln/metal/vec.hh>
+
+int main()
+{
+ using namespace mln;
+
+ metal::vec<3,int> v_int = make::vec(3,6,7);
+ metal::vec<3,float> v_f = make::vec(2.6, 1.9, 5.2);
+
+ std::cout << v_int + v_f << std::endl;
+}
Index: trunk/milena/tests/interpolated.cc
===================================================================
--- trunk/milena/tests/interpolated.cc (revision 0)
+++ trunk/milena/tests/interpolated.cc (revision 1130)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/image2d_b.cc
+ *
+ * \brief Tests on mln::image2d_b.
+ */
+
+
+#include <iostream>
+#include <mln/core/image2d_b.hh>
+#include <mln/core/interpolated.hh>\
+
+#include <mln/metal/vec.hh>
+
+#include <mln/level/fill.hh>
+
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned nrows = 4;
+ const unsigned ncols = 4;
+ const unsigned border = 4;
+
+ image2d_b<float> f(nrows, ncols, border);
+ float tab[] = {1., 3., 5., 7.,
+ 4., 7., 10., 13.,
+ 7., 11., 15., 19.,
+ 10., 15., 20., 25.};
+ level::fill(f, tab);
+
+ interpolated<image2d_b<float> > inter(f);
+
+ metal::vec<2, float> v1 = make::vec(2.3, 0.6);
+ metal::vec<2, float> v2 = make::vec(3.2, 1.8);
+
+ debug::println(f);
+
+ std::cout << v1 << " : " << inter(v1) << std::endl;
+ std::cout << v2 << " : " << inter(v2) << std::endl;
+}
Index: trunk/milena/mln/core/interpolated.hh
===================================================================
--- trunk/milena/mln/core/interpolated.hh (revision 0)
+++ trunk/milena/mln/core/interpolated.hh (revision 1130)
@@ -0,0 +1,186 @@
+// 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_CORE_INTERPOLATED_HH
+# define MLN_CORE_INTERPOLATED_HH
+
+/*! \file mln/core/interpolated.hh
+ *
+ * \brief Definition of an image class FIXME
+ */
+
+# include <cmath>
+
+# include <mln/core/concept/image.hh>
+# include <mln/metal/vec.hh>
+
+
+namespace mln
+{
+
+ /*! \brief FIXME
+ *
+ */
+ template <typename I>
+ struct interpolated : public mln::internal::image_base_< mln_pset(I),
interpolated<I> >
+ {
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef mln_value(I) value;
+
+ /// Return type of read-write access.
+ typedef mln_lvalue(I) lvalue;
+
+ /// Return type of read-only access.
+ typedef mln_rvalue(I) rvalue;
+
+ /// Value set associated type.
+ typedef mln::value::set<value> vset;
+
+
+
+ /// Constructor.
+ interpolated(const Image<I>& ima);
+
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Test if a pixel value is accessible at \p p.
+ bool owns_(const psite& p) const;
+
+ /// Give the definition domain.
+ const mln_pset(I)& domain() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ mln_value(I) operator()(const psite& p) const;
+
+ /// Mutable access is only OK for reading (not writing).
+ mln_value(I) operator()(const psite& p);
+
+ mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v)
const;
+
+ mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v);
+
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Change value type.
+ template <typename U>
+ struct change_value
+ {
+ typedef mln_ch_value(I, U) ret;
+ };
+
+ protected:
+ const I& ima_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ interpolated<I>::interpolated(const Image<I>& ima)
+ : ima_(exact(ima))
+ {
+ mln_precondition(exact(ima).has_data());
+ }
+
+ template <typename I>
+ bool interpolated<I>::has_data() const
+ {
+ mln_invariant(ima_.has_data());
+ return true;
+ }
+
+ template <typename I>
+ bool interpolated<I>::owns_(const psite& p) const
+ {
+ return ima_.owns_(p);
+ }
+
+ template <typename I>
+ const mln_pset(I)&
+ interpolated<I>::domain() const
+ {
+ return ima_.domain();
+ }
+
+ template <typename I>
+ mln_value(I)
+ interpolated<I>::operator()(const psite& p) const
+ {
+ mln_precondition(ima_.owns_(p));
+ return ima_(p);
+ }
+
+ template <typename I>
+ mln_value(I)
+ interpolated<I>::operator()(const psite& p)
+ {
+ return ima_(p);
+ }
+
+ template <typename I>
+ mln_value(I)
+ interpolated<I>::operator()(const mln::metal::vec<I::point::dim,
float>& v) const
+ {
+ mln_point(I) p;
+ for (unsigned i = 0; i < I::point::dim; ++i)
+ p[i] = static_cast<int>(round(v[i]));
+ mln_assertion(ima_.owns_(p));
+ return (ima_(p));
+ }
+
+ template <typename I>
+ mln_value(I)
+ interpolated<I>::operator()(const mln::metal::vec<I::point::dim,
float>& v)
+ {
+ mln_point(I) p;
+ for (unsigned i = 0; i < I::point::dim; ++i)
+ p[i] = static_cast<int>(round(v[i]));
+ mln_assertion(ima_.owns_(p));
+ return (ima_(p));
+ }
+
+ template <typename I>
+ const mln::value::set<mln_value(I) >&
+ interpolated<I>::values() const
+ {
+ return vset::the();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERPOLATED_HH
Index: trunk/milena/mln/metal/vec.hh
===================================================================
--- trunk/milena/mln/metal/vec.hh (revision 1129)
+++ trunk/milena/mln/metal/vec.hh (revision 1130)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -25,12 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_METAL_VEC_HH
-# define MLN_CORE_METAL_VEC_HH
+#ifndef MLN_METAL_VEC_HH
+# define MLN_METAL_VEC_HH
-# include <cstdarg>
+# include <iostream>
-# include <mln/core/concept/object.hh>
+# include <mln/core/contract.hh>
+# include <mln/metal/binary_arith_trait.hh>
+
+// FIXME: Document.
namespace mln
@@ -39,76 +42,137 @@
namespace metal
{
- // FIXME: Doc! + Change coord into comp.
+ namespace internal
+ {
template <unsigned n, typename T>
- struct vec : public Object< vec<n,T> >
+ class vec_base_
{
- enum { dim = n };
- typedef T coord;
+ protected:
+ T data_[n];
+ };
+
+ template <typename T>
+ class vec_base_ <1, T>
+ {
+ public:
+ void set(const T& val0)
+ {
+ data_[0] = val0;
+ }
+ protected:
+ T data_[1];
+ };
- vec();
- vec(T (&values)[n]);
+ template <typename T>
+ class vec_base_ <2, T>
+ {
+ public:
+ void set(const T& val0, const T& val1)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ }
+ protected:
+ T data_[2];
+ };
- T& operator[](unsigned i);
- T operator[](unsigned i) const;
+ template <typename T>
+ class vec_base_ <3, T>
+ {
+ public:
+ void set(const T& val0, const T& val1, const T& val2)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ data_[2] = val2;
+ }
+ protected:
+ T data_[3];
+ };
+ template <typename T>
+ class vec_base_ <4, T>
+ {
+ public:
+ void set(const T& val0, const T& val1, const T& val2, const T& val3)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ data_[2] = val2;
+ data_[3] = val3;
+ }
protected:
- T coord_[n];
+ T data_[4];
};
- template <unsigned n, typename T>
- std::ostream& operator<<(std::ostream& ostr, const vec<n,T>&
v);
+ } // end of namespace mln::metal::internal
+
template <unsigned n, typename T>
- bool operator==(const vec<n,T>& lhs, const vec<n,T>& rhs);
+ class vec : public internal::vec_base_<n, T>
+ {
+ typedef internal::vec_base_<n,T> super;
+ using super::data_;
+ public:
-# ifndef MLN_INCLUDE_ONLY
+ typedef T value_type;
+ enum { dim = n };
- template <unsigned n, typename T>
- vec<n,T>::vec()
+ vec()
{
}
- template <unsigned n, typename T>
- vec<n,T>::vec(T (&values)[n])
+ template <typename U>
+ vec(const vec<n, U>& rhs)
{
for (unsigned i = 0; i < n; ++i)
- coord_[i] = values[i];
+ data_[i] = rhs[i];
}
- template <unsigned n, typename T>
- T&
- vec<n,T>::operator[](unsigned i)
+ template <typename U>
+ vec& operator=(const vec<n, U>& rhs)
{
- mln_precondition(i < n);
- return coord_[i];
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = rhs[i];
+ return *this;
}
- template <unsigned n, typename T>
- T
- vec<n,T>::operator[](unsigned i) const
+ const T& operator[](unsigned i) const
{
- mln_precondition(i < n);
- return coord_[i];
+ mln_precondition(i < dim);
+ return data_[i];
}
- // operators
+ T& operator[](unsigned i)
+ {
+ mln_precondition(i < dim);
+ return data_[i];
+ }
- template <unsigned n, typename T>
- std::ostream& operator<<(std::ostream& ostr, const vec<n,T>&
v)
+ void set_all(const T& val)
{
- ostr << "[ ";
for (unsigned i = 0; i < n; ++i)
- ostr << v[i] << ' ';
- return ostr << ']';
+ data_[i] = val;
}
- template <unsigned n, typename T>
- bool operator==(const vec<n,T>& lhs, const vec<n,T>& rhs)
+ unsigned size() const
+ {
+ return n;
+ }
+
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // eq
+
+ template <unsigned n, typename T, typename U>
+ bool operator==(const vec<n,T>& lhs, const vec<n,U>& rhs)
{
for (unsigned i = 0; i < n; ++i)
if (lhs[i] != rhs[i])
@@ -116,15 +180,152 @@
return true;
}
-# endif // ! MLN_INCLUDE_ONLY
+ template <unsigned n, typename T, typename U>
+ bool operator!=(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ return not (lhs == rhs);
+ }
+
+ // +
- } // end of namespace mln::metal
+ template <unsigned n, typename T, typename U>
+ vec<n,T>&
+ operator+=(vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] += rhs[i];
+ return lhs;
+ }
+
+ template <unsigned n, typename T, typename U>
+ vec<n, typename binary_arith_trait<T, U>::ret >
+ operator+(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ vec<n, typename binary_arith_trait<T, U>::ret> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] + rhs[i];
+ return tmp;
+ }
+
+
+ // -
+
+ template <unsigned n, typename T, typename U>
+ vec<n,T>&
+ operator-=(vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] -= rhs[i];
+ return lhs;
+ }
+
+ template <unsigned n, typename T, typename U>
+ vec<n, typename binary_arith_trait<T, U>::ret>
+ operator-(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ vec<n, typename binary_arith_trait<T, U>::ret> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] - rhs[i];
+ return tmp;
+ }
+
+ template <unsigned n, typename T>
+ vec<n, T>
+ operator-(const vec<n,T>& lhs)
+ {
+ vec<n, T> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = - lhs[i];
+ return tmp;
+ }
+
+
+ // *
+
+ template <unsigned n, typename T, typename S>
+ vec<n,T>&
+ operator*=(vec<n,T>& lhs, const S& scalar)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] *= scalar;
+ return lhs;
+ }
+
+ template <unsigned n, typename T, typename S>
+ vec<n, typename binary_arith_trait<T, S>::ret>
+ operator*(const vec<n,T>& lhs, const S& scalar)
+ {
+ vec<n, typename binary_arith_trait<T, S>::ret> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] * scalar;
+ return tmp;
+ }
-} // end of namespace mln
+ // /
-# include <mln/metal/make/vec.hh>
+ template <unsigned n, typename T, typename S>
+ vec<n,T>&
+ operator/=(vec<n,T>& lhs, const S& scalar)
+ {
+ precondition(scalar != 0);
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] /= scalar;
+ return lhs;
+ }
+
+ template <unsigned n, typename T, typename S>
+ vec<n, typename binary_arith_trait<T, S>::ret>
+ operator/(const vec<n,T>& lhs, const S& scalar)
+ {
+ precondition(scalar != 0);
+ vec<n, typename binary_arith_trait<T, S>::ret> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] / scalar;
+ return tmp;
+ }
+
+
+ // <<
+
+ template <unsigned n, typename T>
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,T>& v)
+ {
+ ostr << '(';
+ for (unsigned i = 0; i < n; ++i)
+ ostr << v[i] << (i == n - 1 ? ")" : ", ");
+ return ostr;
+ }
+
+ template <unsigned n>
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,unsigned char>& v)
+ {
+ ostr << '(';
+ for (unsigned i = 0; i < n; ++i)
+ ostr << (unsigned int)(v[i]) << (i == n - 1 ? ")" : ",
");
+ return ostr;
+ }
+
+ template <unsigned n>
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,signed char>& v)
+ {
+ ostr << '(';
+ for (unsigned i = 0; i < n; ++i)
+ ostr << (signed int)(v[i]) << (i == n - 1 ? ")" : ",
");
+ return ostr;
+ }
+
+
+# endif // MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+# include <mln/make/vec.hh>
-#endif // ! MLN_CORE_METAL_VEC_HH
+#endif // ! MLN_METAL_VEC_HH
Index: trunk/milena/mln/metal/binary_arith_trait.hh
===================================================================
--- trunk/milena/mln/metal/binary_arith_trait.hh (revision 0)
+++ trunk/milena/mln/metal/binary_arith_trait.hh (revision 1130)
@@ -0,0 +1,73 @@
+// 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_METAL_BINARY_ARITH_TRAIT_HH
+# define MLN_METAL_BINARY_ARITH_TRAIT_HH
+
+
+ template <typename T, typename U>
+ struct binary_arith_trait
+ {
+ typedef T ret;
+ };
+
+
+ template <>
+ struct binary_arith_trait<int, float>
+ {
+ typedef float ret;
+ };
+ template <>
+ struct binary_arith_trait<float, int>
+ {
+ typedef float ret;
+ };
+
+ template <>
+ struct binary_arith_trait<int, double>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct binary_arith_trait<double, int>
+ {
+ typedef double ret;
+ };
+
+ template <>
+ struct binary_arith_trait<double, float>
+ {
+ typedef double ret;
+ };
+ template <>
+ struct binary_arith_trait<float, double>
+ {
+ typedef double ret;
+ };
+
+
+#endif // ! MLN_METAL_BINARY_ARITH_TRAIT_HH
Index: trunk/milena/mln/make/vec.hh
===================================================================
--- trunk/milena/mln/make/vec.hh (revision 0)
+++ trunk/milena/mln/make/vec.hh (revision 1130)
@@ -0,0 +1,133 @@
+// 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_MAKE_VEC_HH
+# define MLN_METAL_VEC_HH
+
+/*! \file mln/make/vec.hh
+ *
+ * \brief Routine to construct an mln::metal::vec.
+ */
+
+# include <mln/metal/vec.hh>
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::metal::vec<1,T>.
+ *
+ * \param[in] v_0 First coordinate.
+ *
+ * \return A 1D vector.
+ */
+ template <typename T>
+ mln::metal::vec<1, T> vec(const T& v_0);
+
+ /*! \brief Create an mln::metal::vec<2,T>.
+ *
+ * \param[in] v_0 First coordinate.
+ * \param[in] v_1 Second coordinate.
+ *
+ * \return A 2D vector.
+ */
+ template <typename T>
+ mln::metal::vec<2, T> vec(const T& v_0, const T& v_1);
+
+ /*! \brief Create an mln::metal::vec<3,T>.
+ *
+ * \param[in] v_0 First coordinate.
+ * \param[in] v_1 Second coordinate.
+ * \param[in] v_2 Third coordinate.
+ *
+ * \return A 3D vector.
+ */
+ template <typename T>
+ mln::metal::vec<3, T> vec(const T& v_0, const T& v_1, const T&
v_2);
+
+ /*! \brief Create an mln::metal::vec<4,T>.
+ *
+ * \param[in] v_0 First coordinate.
+ * \param[in] v_1 Second coordinate.
+ * \param[in] v_2 Third coordinate.
+ * \param[in] v_3 Fourth coordinate.
+ *
+ * \return A 4D vector.
+ */
+ template <typename T>
+ mln::metal::vec<4, T> vec(const T& v_0, const T& v_1, const T& v_2,
const T& v_3);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ mln::metal::vec<1, T> vec(const T& v_0)
+ {
+ mln::metal::vec<1, T> tmp;
+ tmp[0] = v_0;
+ return tmp;
+ }
+
+ template <typename T>
+ mln::metal::vec<2, T> vec(const T& v_0, const T& v_1)
+ {
+ mln::metal::vec<2, T> tmp;
+ tmp[0] = v_0;
+ tmp[1] = v_1;
+ return tmp;
+ }
+
+ template <typename T>
+ mln::metal::vec<3, T> vec(const T& v_0, const T& v_1, const T&
v_2)
+ {
+ mln::metal::vec<3, T> tmp;
+ tmp[0] = v_0;
+ tmp[1] = v_1;
+ tmp[2] = v_2;
+ return tmp;
+ }
+
+ template <typename T>
+ mln::metal::vec<4, T> vec(const T& v_0, const T& v_1, const T& v_2,
const T& v_3)
+ {
+ mln::metal::vec<4, T> tmp;
+ tmp[0] = v_0;
+ tmp[1] = v_1;
+ tmp[2] = v_2;
+ tmp[3] = v_3;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace make
+
+} // end of namespace mln
+
+#endif // ! MLN_METAL_VEC_HH
Index: trunk/milena/sandbox/nivault/binary_arith.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/nivault/tests/test.cc (deleted)
===================================================================