From eade17a0366cbfbf2f48c025d11f7fba363d5b5f Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Wed, 7 Apr 2010 19:32:59 +0000 Subject: [PATCH] see #3539: changed implementation of norm_inf and norm_1 for complex types to use abs(z) instead of max(abs(real(z)),abs(imag(z))). svn path=/trunk/boost/numeric/ublas/; revision=61136 --- include/boost/numeric/ublas/traits.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index 7b01fecf..62828441 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -306,8 +306,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE real_type norm_1 (const_reference t) { - return type_traits::type_abs (self_type::real (t)) + - type_traits::type_abs (self_type::imag (t)); + return self_type::type_abs (t); + // original computation has been replaced because a complex number should behave like a scalar type + // return type_traits::type_abs (self_type::real (t)) + + // type_traits::type_abs (self_type::imag (t)); } static BOOST_UBLAS_INLINE @@ -317,8 +319,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { - return (std::max) (type_traits::type_abs (self_type::real (t)), - type_traits::type_abs (self_type::imag (t))); + return self_type::type_abs (t); + // original computation has been replaced because a complex number should behave like a scalar type + // return (std::max) (type_traits::type_abs (self_type::real (t)), + // type_traits::type_abs (self_type::imag (t))); } static