last-svn-commit-515-g3086fc9 Improve the genericity of vector normalization.

* mln/algebra/vec.hh (mln::algebra::vec<n,T>::normalize): Use mln_sum_product(T,T) instead of the hard-coded type `float' as return value of mln::norm::l2. --- milena/ChangeLog | 8 ++++++++ milena/mln/algebra/vec.hh | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 9ed9189..fb2b087 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2010-10-21 Roland Levillain <roland@lrde.epita.fr> + Improve the genericity of vector normalization. + + * mln/algebra/vec.hh (mln::algebra::vec<n,T>::normalize): Use + mln_sum_product(T,T) instead of the hard-coded type `float' as + return value of mln::norm::l2. + +2010-10-21 Roland Levillain <roland@lrde.epita.fr> + * mln/fun/x2x/rotation.hh: Aesthetic changes. 2010-10-21 Roland Levillain <roland@lrde.epita.fr> diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh index 096f558..22ebc02 100644 --- a/milena/mln/algebra/vec.hh +++ b/milena/mln/algebra/vec.hh @@ -540,8 +540,8 @@ namespace mln inline const vec<n, T>& vec<n, T>::normalize() { - float l2_norm = float(norm::l2(*this)); - mln_assertion(l2_norm > 0.f); + mln_sum_product(T,T) l2_norm = norm::l2(*this); + mln_assertion(l2_norm > mln_sum_product(T,T)(0)); for (unsigned i = 0; i < n; ++i) data_[i] = static_cast<T>(data_[i] / l2_norm); return *this; -- 1.5.6.5
participants (1)
-
Roland Levillain