From e2097c55f8b130cac62d52af2cd7d8717ec0d5c1 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 31 May 2010 22:46:18 +0200 Subject: [PATCH] fix issue #125 - *norm() return RealScalar and not Scalar --- Eigen/src/Array/VectorwiseOp.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Eigen/src/Array/VectorwiseOp.h b/Eigen/src/Array/VectorwiseOp.h index b809283a7..f495aae40 100644 --- a/Eigen/src/Array/VectorwiseOp.h +++ b/Eigen/src/Array/VectorwiseOp.h @@ -178,14 +178,16 @@ template class VectorwiseOp public: typedef typename ExpressionType::Scalar Scalar; + typedef typename ExpressionType::RealScalar RealScalar; typedef typename ExpressionType::Index Index; typedef typename ei_meta_if::ret, ExpressionType, const ExpressionType&>::ret ExpressionTypeNested; - template class Functor> struct ReturnType + template class Functor, + typename Scalar=typename ei_traits::Scalar> struct ReturnType { typedef PartialReduxExpr::Scalar>, + Functor, Direction > Type; }; @@ -285,7 +287,7 @@ template class VectorwiseOp * Output: \verbinclude PartialRedux_squaredNorm.out * * \sa DenseBase::squaredNorm() */ - const typename ReturnType::Type squaredNorm() const + const typename ReturnType::Type squaredNorm() const { return _expression(); } /** \returns a row (or column) vector expression of the norm @@ -295,7 +297,7 @@ template class VectorwiseOp * Output: \verbinclude PartialRedux_norm.out * * \sa DenseBase::norm() */ - const typename ReturnType::Type norm() const + const typename ReturnType::Type norm() const { return _expression(); } @@ -304,7 +306,7 @@ template class VectorwiseOp * blue's algorithm. * * \sa DenseBase::blueNorm() */ - const typename ReturnType::Type blueNorm() const + const typename ReturnType::Type blueNorm() const { return _expression(); } @@ -313,7 +315,7 @@ template class VectorwiseOp * underflow and overflow. * * \sa DenseBase::stableNorm() */ - const typename ReturnType::Type stableNorm() const + const typename ReturnType::Type stableNorm() const { return _expression(); } @@ -322,7 +324,7 @@ template class VectorwiseOp * underflow and overflow using a concatenation of hypot() calls. * * \sa DenseBase::hypotNorm() */ - const typename ReturnType::Type hypotNorm() const + const typename ReturnType::Type hypotNorm() const { return _expression(); } /** \returns a row (or column) vector expression of the sum