From 9816e8532ef40986e549a201bf7f0f774305501d Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 12 Apr 2013 15:26:55 +0200 Subject: [PATCH] Fix bug #482: pass scalar value by const reference (it remained a few cases) --- Eigen/src/Core/DenseBase.h | 4 ++-- Eigen/src/Core/GlobalFunctions.h | 2 +- Eigen/src/Core/MatrixBase.h | 2 +- Eigen/src/Core/ProductBase.h | 4 ++-- Eigen/src/Core/Select.h | 6 +++--- Eigen/src/Core/SelfAdjointView.h | 4 ++-- Eigen/src/Core/products/SelfadjointProduct.h | 2 +- Eigen/src/Core/products/SelfadjointRank2Update.h | 2 +- Eigen/src/Geometry/Quaternion.h | 4 ++-- unsupported/Eigen/src/MatrixFunctions/MatrixPower.h | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 62c73f1a9..c17364f30 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -442,11 +442,11 @@ template class DenseBase template inline const Select - select(const DenseBase& thenMatrix, typename ThenDerived::Scalar elseScalar) const; + select(const DenseBase& thenMatrix, const typename ThenDerived::Scalar& elseScalar) const; template inline const Select - select(typename ElseDerived::Scalar thenScalar, const DenseBase& elseMatrix) const; + select(const typename ElseDerived::Scalar& thenScalar, const DenseBase& elseMatrix) const; template RealScalar lpNorm() const; diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index daf72e6bb..02cae552e 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -70,7 +70,7 @@ namespace Eigen **/ template inline const Eigen::CwiseUnaryOp, const Derived> - operator/(typename Derived::Scalar s, const Eigen::ArrayBase& a) + operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase& a) { return Eigen::CwiseUnaryOp, const Derived>( a.derived(), diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index e12a6763e..198e51084 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -457,7 +457,7 @@ template class MatrixBase const MatrixFunctionReturnValue sin() const; const MatrixSquareRootReturnValue sqrt() const; const MatrixLogarithmReturnValue log() const; - const MatrixPowerReturnValue pow(RealScalar p) const; + const MatrixPowerReturnValue pow(const RealScalar& p) const; #ifdef EIGEN2_SUPPORT template diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 5bb7e342a..a494b5f87 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -195,7 +195,7 @@ class ScaledProduct; // Also note that here we accept any compatible scalar types template const ScaledProduct -operator*(const ProductBase& prod, typename Derived::Scalar x) +operator*(const ProductBase& prod, const typename Derived::Scalar& x) { return ScaledProduct(prod.derived(), x); } template @@ -207,7 +207,7 @@ operator*(const ProductBase& prod, const typename Derived::Real template const ScaledProduct -operator*(typename Derived::Scalar x,const ProductBase& prod) +operator*(const typename Derived::Scalar& x,const ProductBase& prod) { return ScaledProduct(prod.derived(), x); } template diff --git a/Eigen/src/Core/Select.h b/Eigen/src/Core/Select.h index 7ee8f23ba..87993bbb5 100644 --- a/Eigen/src/Core/Select.h +++ b/Eigen/src/Core/Select.h @@ -136,7 +136,7 @@ template template inline const Select DenseBase::select(const DenseBase& thenMatrix, - typename ThenDerived::Scalar elseScalar) const + const typename ThenDerived::Scalar& elseScalar) const { return Select( derived(), thenMatrix.derived(), ThenDerived::Constant(rows(),cols(),elseScalar)); @@ -150,8 +150,8 @@ DenseBase::select(const DenseBase& thenMatrix, template template inline const Select -DenseBase::select(typename ElseDerived::Scalar thenScalar, - const DenseBase& elseMatrix) const +DenseBase::select(const typename ElseDerived::Scalar& thenScalar, + const DenseBase& elseMatrix) const { return Select( derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived()); diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index 82cc4da73..d43789123 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -132,7 +132,7 @@ template class SelfAdjointView * \sa rankUpdate(const MatrixBase&, Scalar) */ template - SelfAdjointView& rankUpdate(const MatrixBase& u, const MatrixBase& v, Scalar alpha = Scalar(1)); + SelfAdjointView& rankUpdate(const MatrixBase& u, const MatrixBase& v, const Scalar& alpha = Scalar(1)); /** Perform a symmetric rank K update of the selfadjoint matrix \c *this: * \f$ this = this + \alpha ( u u^* ) \f$ where \a u is a vector or matrix. @@ -145,7 +145,7 @@ template class SelfAdjointView * \sa rankUpdate(const MatrixBase&, const MatrixBase&, Scalar) */ template - SelfAdjointView& rankUpdate(const MatrixBase& u, Scalar alpha = Scalar(1)); + SelfAdjointView& rankUpdate(const MatrixBase& u, const Scalar& alpha = Scalar(1)); /////////// Cholesky module /////////// diff --git a/Eigen/src/Core/products/SelfadjointProduct.h b/Eigen/src/Core/products/SelfadjointProduct.h index 773ba2ff2..6ca4ae6c0 100644 --- a/Eigen/src/Core/products/SelfadjointProduct.h +++ b/Eigen/src/Core/products/SelfadjointProduct.h @@ -111,7 +111,7 @@ struct selfadjoint_product_selector template template SelfAdjointView& SelfAdjointView -::rankUpdate(const MatrixBase& u, Scalar alpha) +::rankUpdate(const MatrixBase& u, const Scalar& alpha) { selfadjoint_product_selector::run(_expression().const_cast_derived(), u.derived(), alpha); diff --git a/Eigen/src/Core/products/SelfadjointRank2Update.h b/Eigen/src/Core/products/SelfadjointRank2Update.h index 0a5e4fd0f..4b57f189d 100644 --- a/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -58,7 +58,7 @@ template struct conj_expr_if template template SelfAdjointView& SelfAdjointView -::rankUpdate(const MatrixBase& u, const MatrixBase& v, Scalar alpha) +::rankUpdate(const MatrixBase& u, const MatrixBase& v, const Scalar& alpha) { typedef internal::blas_traits UBlasTraits; typedef typename UBlasTraits::DirectLinearAccessType ActualUType; diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index e7801abf9..e135f2b66 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -154,7 +154,7 @@ public: * \a t in [0;1] * see http://en.wikipedia.org/wiki/Slerp */ - template Quaternion slerp(Scalar t, const QuaternionBase& other) const; + template Quaternion slerp(const Scalar& t, const QuaternionBase& other) const; /** \returns \c true if \c *this is approximately equal to \a other, within the precision * determined by \a prec. @@ -683,7 +683,7 @@ QuaternionBase::angularDistance(const QuaternionBase& oth template template Quaternion::Scalar> -QuaternionBase::slerp(Scalar t, const QuaternionBase& other) const +QuaternionBase::slerp(const Scalar& t, const QuaternionBase& other) const { using std::acos; using std::sin; diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h index f2b1a5993..e75fc25b4 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h @@ -535,7 +535,7 @@ class MatrixPowerReturnValue : public ReturnByValue -const MatrixPowerReturnValue MatrixBase::pow(RealScalar p) const +const MatrixPowerReturnValue MatrixBase::pow(const RealScalar& p) const { return MatrixPowerReturnValue(derived(), p); } } // namespace Eigen