
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-09-20 Simon Nivault <simon.nivault@lrde.epita.fr> Add props for vector and matrix * mln/make/vec.hh: The new constructor fill any vector. * mln/value/props.hh: Update. --- make/vec.hh | 20 +++++++++++--------- value/props.hh | 28 +++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 10 deletions(-) Index: trunk/milena/mln/value/props.hh =================================================================== --- trunk/milena/mln/value/props.hh (revision 1141) +++ trunk/milena/mln/value/props.hh (revision 1142) @@ -41,6 +41,9 @@ # include <mln/core/macros.hh> # include <mln/value/kind.hh> # include <mln/metal/bool.hh> +# include <mln/metal/vec.hh> +# include <mln/metal/mat.hh> +# include <mln/metal/binary_arith_trait.hh> /// Get the minimum value of type \c T. @@ -154,7 +157,7 @@ { static const signed short min() { return -32768; } static const signed short max() { return 32767; } - static const std::size_t card_ = 655356; + static const std::size_t card_ = 65536; typedef data_kind kind; typedef float sum; }; @@ -224,6 +227,29 @@ typedef double sum; }; + // records + + template <> + template <unsigned n, typename T> + struct props<metal::vec<n,T> > + { + static const metal::vec<n,T> min() { return make::vec<n>(mln_min(T)); } + static const metal::vec<n,T> max() { return make::vec<n>(mln_max(T)); } + typedef data_kind kind; + static const std::size_t card_ = n * mln_card_(T); + typedef binary_arith_trait<float,T> sum; + }; + + template <unsigned n, unsigned m, typename T> + struct props<metal::mat<n,m,T> > + { + static const metal::mat<n,m,T> min() { return make::mat<n,m>(mln_min(T)); } + static const metal::mat<n,m,T> max() { return make::mat<n,m>(mln_max(T)); } + typedef data_kind kind; + static const std::size_t card_ = n * m * mln_card_(T); + typedef binary_arith_trait<float,T> sum; + }; + } // end of namespace mln::value } // end of namespace mln Index: trunk/milena/mln/make/vec.hh =================================================================== --- trunk/milena/mln/make/vec.hh (revision 1141) +++ trunk/milena/mln/make/vec.hh (revision 1142) @@ -41,14 +41,15 @@ namespace make { - /*! \brief Create an mln::metal::vec<1,T>. + + /*! \brief Create an mln::metal::vec<n,T>. * - * \param[in] v_0 First coordinate. + * \param[in] v Value. * - * \return A 1D vector. + * \return A nD vector filled with \p v. */ - template <typename T> - metal::vec<1, T> vec(const T& v_0); + template <unsigned n, typename T> + metal::vec<n, T> vec(const T& v); /*! \brief Create an mln::metal::vec<2,T>. * @@ -86,11 +87,12 @@ # ifndef MLN_INCLUDE_ONLY - template <typename T> - metal::vec<1, T> vec(const T& v_0) + template <unsigned n, typename T> + metal::vec<n, T> vec(const T& v) { - metal::vec<1, T> tmp; - tmp[0] = v_0; + metal::vec<n, T> tmp; + for (unsigned i = 0; i < n; ++i) + tmp[i] = v; return tmp; }