
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Move h_vec and h_mat in mln/ from core/ to algebra/. * mln/core/h_vec.hh, * mln/core/h_mat.hh: Rename as... * mln/algebra/h_vec.hh, * mln/algebra/h_mat.hh: ...these. Update. * tests/core/h_vec.cc, * tests/algebra/vec2.cc, * tests/algebra/mat.cc, * mln/core/point.hh, * mln/metal/vec.hh, * mln/fun/x2x/composed.hh, * mln/fun/x2x/translation.hh, * mln/fun/x2x/rotation.hh, * mln/fun/internal/x2x_linear_impl.hh, * mln/algebra/vec.hh: Update. mln/algebra/h_mat.hh | 27 +++++++++++------ mln/algebra/h_vec.hh | 55 ++++++++++++++++++++---------------- mln/algebra/vec.hh | 2 - mln/core/point.hh | 10 +++--- mln/fun/internal/x2x_linear_impl.hh | 8 ++--- mln/fun/x2x/composed.hh | 2 - mln/fun/x2x/rotation.hh | 2 - mln/fun/x2x/translation.hh | 4 +- mln/metal/vec.hh | 2 - tests/algebra/mat.cc | 10 +++--- tests/algebra/vec2.cc | 8 ++--- tests/core/h_vec.cc | 16 +++++----- 12 files changed, 81 insertions(+), 65 deletions(-) Index: tests/core/h_vec.cc --- tests/core/h_vec.cc (revision 2177) +++ tests/core/h_vec.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -27,10 +27,10 @@ /*! \file tests/h_vec.cc * - * \brief Tests on mln::h_vec. + * \brief Tests on mln::algebra::h_vec. */ -#include <mln/core/h_vec.hh> +#include <mln/algebra/h_vec.hh> #include <mln/core/alias/point3d.hh> using namespace mln; @@ -40,12 +40,12 @@ { } -void run_in_3d_h(const h_vec<3, int>&) +void run_in_3d_h(const algebra::h_vec<3, int>&) { } -void foo(const mln::h_vec<3,float>&) +void foo(const mln::algebra::h_vec<3,float>&) { } @@ -54,9 +54,9 @@ { algebra::vec<3, int> x; - h_vec<3, int> w = x.to_h_vec(); + algebra::h_vec<3, int> w = x.to_h_vec(); - typedef h_vec<3, int> p3d; + typedef algebra::h_vec<3, int> p3d; p3d p; run_in_3d(p.to_vec()); @@ -66,7 +66,7 @@ { algebra::vec<3,float> v; - h_vec<3,float> w(v.to_h_vec()); + algebra::h_vec<3,float> w(v.to_h_vec()); w = v.to_h_vec(); foo(v.to_h_vec()); } Index: tests/algebra/vec2.cc --- tests/algebra/vec2.cc (revision 2177) +++ tests/algebra/vec2.cc (working copy) @@ -34,7 +34,7 @@ #include <iostream> #include <mln/fun/i2v/all_to.hh> #include <mln/algebra/vec.hh> -#include <mln/core/h_vec.hh> +#include <mln/algebra/h_vec.hh> @@ -45,10 +45,10 @@ algebra::vec<1,float> v1(all_to(4.)); algebra::vec<2,float> v2 = make::vec(6., 2.8); - h_vec<1,float> hv1; - h_vec<2,float> hv2 = v2.to_h_vec(); // Immersion into homogeneous. + algebra::h_vec<1,float> hv1; + algebra::h_vec<2,float> hv2 = v2.to_h_vec(); // Immersion into homogeneous. - h_vec<3,float> hv3(all_to(1.5)); + algebra::h_vec<3,float> hv3(all_to(1.5)); hv3 += make::vec(0., 0., 0., 0.5); Index: tests/algebra/mat.cc --- tests/algebra/mat.cc (revision 2177) +++ tests/algebra/mat.cc (working copy) @@ -34,7 +34,7 @@ #include <iostream> #include <mln/fun/i2v/all_to.hh> #include <mln/algebra/mat.hh> -#include <mln/core/h_mat.hh> +#include <mln/algebra/h_mat.hh> @@ -45,9 +45,9 @@ algebra::mat<1,3,float> m1(all_to(4.)); algebra::mat<2,2,float> m2 = algebra::mat<2,2,float>::Id; - h_mat<1,float> hm1(m2); - h_mat<2,float> hm2; - h_mat<3,float> hm3(all_to(1.5)); + algebra::h_mat<1,float> hm1(m2); + algebra::h_mat<2,float> hm2; + algebra::h_mat<3,float> hm3(all_to(1.5)); algebra::mat<4,4,float> m4 = hm3; @@ -59,7 +59,7 @@ std::cout << "hm3 = " << hm3 << ";" << std::endl; { - h_mat<2,float> m, m2; + algebra::h_mat<2,float> m, m2; m = m2; // FIXME: Test *many* => runs ok... } Index: mln/core/point.hh --- mln/core/point.hh (revision 2177) +++ mln/core/point.hh (working copy) @@ -42,7 +42,7 @@ # include <mln/metal/is_not.hh> # include <mln/algebra/vec.hh> # include <mln/metal/converts_to.hh> -# include <mln/core/h_vec.hh> +# include <mln/algebra/h_vec.hh> # include <mln/util/yes.hh> @@ -69,7 +69,7 @@ struct point_to_ { typedef algebra::vec<G::dim, C> metal_vec; - typedef mln::h_vec<G::dim, C> h_vec; + typedef mln::algebra::h_vec<G::dim, C> h_vec; }; } // end of namespace mln::internal @@ -174,7 +174,7 @@ const algebra::vec<G::dim, C>& to_vec() const; /// Transform to point in homogene coordinate system. - h_vec<G::dim, C> to_h_vec() const; + algebra::h_vec<G::dim, C> to_h_vec() const; /// Point with all coordinates set to the maximum value. static const point<G,C>& plus_infty(); @@ -394,9 +394,9 @@ template <typename G, typename C> inline - h_vec<G::dim, C> point<G,C>::to_h_vec() const + algebra::h_vec<G::dim, C> point<G,C>::to_h_vec() const { - h_vec<G::dim, C> tmp; + algebra::h_vec<G::dim, C> tmp; for (unsigned i = 0; i < dim; ++i) tmp[i] = coord_[i]; tmp[G::dim] = 1; Index: mln/metal/vec.hh --- mln/metal/vec.hh (revision 2177) +++ mln/metal/vec.hh (working copy) @@ -191,7 +191,7 @@ // Immersion of the vector into its homogeneous space. - h_vec<n, T> to_h_vec() const; + algebra::h_vec<n, T> to_h_vec() const; const T& operator[](unsigned i) const; Index: mln/fun/x2x/composed.hh --- mln/fun/x2x/composed.hh (revision 2177) +++ mln/fun/x2x/composed.hh (working copy) @@ -38,7 +38,7 @@ # include <mln/algebra/vec.hh> # include <mln/metal/is.hh> # include <mln/metal/bexpr.hh> -# include <mln/core/h_mat.hh> +# include <mln/algebra/h_mat.hh> namespace mln Index: mln/fun/x2x/translation.hh --- mln/fun/x2x/translation.hh (revision 2177) +++ mln/fun/x2x/translation.hh (working copy) @@ -36,7 +36,7 @@ # include <mln/core/concept/function.hh> # include <mln/fun/internal/x2x_linear_impl.hh> # include <mln/algebra/vec.hh> -# include <mln/core/h_mat.hh> +# include <mln/algebra/h_mat.hh> # include <mln/fun/i2v/all.hh> namespace mln @@ -97,7 +97,7 @@ translation<n,C>::translation(const algebra::vec<n,C>& t) :t_(t) { - this->m_ = h_mat<n,C>::Id; + this->m_ = algebra::h_mat<n,C>::Id; this->update(); } Index: mln/fun/x2x/rotation.hh --- mln/fun/x2x/rotation.hh (revision 2177) +++ mln/fun/x2x/rotation.hh (working copy) @@ -100,7 +100,7 @@ dir_(dir) { mln_precondition(dir == 2 || n == 3); - this->m_ = h_mat<n,C>::Id; + this->m_ = algebra::h_mat<n,C>::Id; update(); } Index: mln/fun/internal/x2x_linear_impl.hh --- mln/fun/internal/x2x_linear_impl.hh (revision 2177) +++ mln/fun/internal/x2x_linear_impl.hh (working copy) @@ -34,8 +34,8 @@ */ # include <mln/core/concept/function.hh> -# include <mln/core/h_mat.hh> -# include <mln/core/h_vec.hh> +# include <mln/algebra/h_mat.hh> +# include <mln/algebra/h_vec.hh> namespace mln { @@ -54,11 +54,11 @@ typedef V argument; typedef V result; typedef typename V::coord coord; - typedef h_mat<dim, coord> matrix; + typedef algebra::h_mat<dim, coord> matrix; V operator()(const V& x) const { - h_vec<dim, coord> tmp = m_ * x.to_h_vec(); + algebra::h_vec<dim, coord> tmp = m_ * x.to_h_vec(); return tmp.to_vec(); } Index: mln/algebra/h_vec.hh --- mln/algebra/h_vec.hh (revision 2177) +++ mln/algebra/h_vec.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,10 +25,10 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_CORE_H_VEC_HH -# define MLN_CORE_H_VEC_HH +#ifndef MLN_ALGEBRA_H_VEC_HH +# define MLN_ALGEBRA_H_VEC_HH -/*! \file mln/core/h_vec.hh +/*! \file mln/algebra/h_vec.hh * * \brief Definition of a vector with homogeneous coordinates. */ @@ -36,12 +36,14 @@ # include <mln/algebra/vec.hh> # include <mln/literal/one.hh> + namespace mln { - // Fwd decl. + // Forward declaration. + namespace algebra { template <unsigned d, typename C> struct h_vec; - + } namespace trait @@ -51,10 +53,10 @@ template < template <class> class Name, unsigned d, typename C > - struct set_precise_unary_< Name, h_vec<d, C> > + struct set_precise_unary_< Name, algebra::h_vec<d, C> > { typedef mln_trait_unary(Name, C) V; - typedef h_vec<d, V> ret; + typedef algebra::h_vec<d, V> ret; }; // For binary traits. @@ -63,30 +65,35 @@ unsigned d, typename C, typename Q > struct set_precise_binary_< Name, - h_vec<d, C>, h_vec<d, Q> > + algebra::h_vec<d, C>, algebra::h_vec<d, Q> > { typedef mln_trait_binary(Name, C, Q) V; - typedef h_vec<d, V> ret; + typedef algebra::h_vec<d, V> ret; }; template < template <class, class> class Name, unsigned d, typename C, typename S > struct set_precise_binary_< Name, - h_vec<d, C>, mln::value::scalar_<S> > + algebra::h_vec<d, C>, mln::value::scalar_<S> > { typedef mln_trait_binary(Name, C, S) V; - typedef h_vec<d, V> ret; + typedef algebra::h_vec<d, V> ret; }; } // end of namespace mln::trait + + namespace algebra + { + + /*! \brief N-Dimensional vector with homogeneous coordinates. * */ template <unsigned d, typename C> - struct h_vec : public algebra::vec<d + 1, C> + struct h_vec : public vec<d + 1, C> { /// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim + 1). enum { dim = d }; @@ -94,12 +101,12 @@ /// Constructor without argument. h_vec(); /// Constructor with the underlying vector. - h_vec(const algebra::vec<d+1, C>& other); + h_vec(const vec<d+1, C>& other); - h_vec& operator=(const algebra::vec<d+1, C>& rhs); + h_vec& operator=(const vec<d+1, C>& rhs); /// Back to the natural (non-homogeneous) space. - algebra::vec<d,C> to_vec() const; + vec<d,C> to_vec() const; }; @@ -119,18 +126,18 @@ template <unsigned d, typename C> inline - h_vec<d,C>::h_vec(const algebra::vec<d+1, C>& other) - : algebra::vec<d+1, C>(other) + h_vec<d,C>::h_vec(const vec<d+1, C>& other) + : vec<d+1, C>(other) { } template <unsigned d, typename C> inline - h_vec<d,C>& h_vec<d,C>::operator=(const algebra::vec<d+1, C>& rhs) + h_vec<d,C>& h_vec<d,C>::operator=(const vec<d+1, C>& rhs) { if (& rhs == this) return *this; - this->algebra::vec<d+1, C>::operator=(rhs); + this->vec<d+1, C>::operator=(rhs); return *this; } @@ -154,12 +161,12 @@ template <unsigned d, typename C> inline - algebra::vec<d,C> h_vec<d,C>::to_vec() const + vec<d,C> h_vec<d,C>::to_vec() const { const C w = this->data_[d]; mln_assertion(w != 0); - algebra::vec<d,C> tmp; + vec<d,C> tmp; for (unsigned i = 0; i < d; ++i) tmp[i] = this->data_[i] / w; return tmp; @@ -167,7 +174,9 @@ # endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::algebra + } // end of namespace mln -#endif // ! MLN_CORE_H_VEC_HH +#endif // ! MLN_ALGEBRA_H_VEC_HH Index: mln/algebra/h_mat.hh --- mln/algebra/h_mat.hh (revision 2177) +++ mln/algebra/h_mat.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,12 +25,14 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_CORE_H_MAT_HH -# define MLN_CORE_H_MAT_HH +#ifndef MLN_ALGEBRA_H_MAT_HH +# define MLN_ALGEBRA_H_MAT_HH -/*! \file mln/core/h_mat.hh +/*! \file mln/algebra/h_mat.hh * * \brief Definition of a matrix with homogeneous coordinates. + * + * \todo Add traits. */ # include <mln/algebra/mat.hh> @@ -39,11 +41,14 @@ namespace mln { + namespace algebra + { + /*! \brief N-Dimensional matrix with homogeneous coordinates. * */ template <unsigned d, typename T> - struct h_mat : public algebra::mat<d+1, d+1, T> + struct h_mat : public mat<d+1, d+1, T> { /// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim + 1) enum { N = d, @@ -53,7 +58,7 @@ /// Constructor without argument. h_mat(); /// Constructor with the underlying matrix. - h_mat(const algebra::mat<d+1, d+1, T>& x); + h_mat(const mat<d+1, d+1, T>& x); }; @@ -62,21 +67,23 @@ template <unsigned d, typename T> inline h_mat<d,T>::h_mat() - : algebra::mat<d+1, d+1, T>(algebra::mat<d+1, d+1, T>::Id) + : mat<d+1, d+1, T>(mat<d+1, d+1, T>::Id) { } template <unsigned d, typename T> inline - h_mat<d,T>::h_mat(const algebra::mat<d+1, d+1, T>& x) - : algebra::mat<d+1, d+1, T>(x) + h_mat<d,T>::h_mat(const mat<d+1, d+1, T>& x) + : mat<d+1, d+1, T>(x) { } # endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::algebra + } // end of namespace mln -#endif // ! MLN_CORE_H_MAT_HH +#endif // ! MLN_ALGEBRA_H_MAT_HH Index: mln/algebra/vec.hh --- mln/algebra/vec.hh (revision 2177) +++ mln/algebra/vec.hh (working copy) @@ -197,7 +197,7 @@ // Immersion of the vector into its homogeneous space. - h_vec<n, T> to_h_vec() const; + algebra::h_vec<n, T> to_h_vec() const; const T& operator[](unsigned i) const;