From 9e9e99a42e136d4fde22f408438c6afa06e49a85 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 29 Apr 2009 14:57:18 +0000 Subject: [PATCH] casting to the same type no longer generates a CwiseUnaryOp --- Eigen/src/Core/CwiseUnaryOp.h | 6 +++++- Eigen/src/Core/MatrixBase.h | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index 076d568e0..5915dad54 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -188,7 +188,11 @@ MatrixBase::imag() const { return derived(); } */ template template -EIGEN_STRONG_INLINE const CwiseUnaryOp::Scalar, NewType>, Derived> +EIGEN_STRONG_INLINE +typename ei_cast_return_type< + const Derived&, + const CwiseUnaryOp::Scalar, NewType>, Derived> + >::type MatrixBase::cast() const { return derived(); diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index a4e4e15d7..7eb7c1eff 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -504,8 +504,12 @@ template class MatrixBase template - const CwiseUnaryOp::Scalar, NewType>, Derived> cast() const; - + typename ei_cast_return_type< + const Derived&, + const CwiseUnaryOp::Scalar, NewType>, Derived> + >::type + cast() const; + /** \returns the matrix or vector obtained by evaluating this expression. * * Notice that in the case of a plain matrix or vector (not an expression) this function just returns