This bugzilla service is closed. All entries have been migrated to

Bug 482

Summary: Pass scalar arguments by const ref
Product: Eigen Reporter: Gael Guennebaud <gael.guennebaud>
Component: GeneralAssignee: Nobody <eigen.nobody>
Severity: Unknown CC: gael.guennebaud, jacob.benoit.1
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 387    
Description Flags
replace 'RealScalar' arguments by 'const RealScalar&' in the Core module none

Description Gael Guennebaud 2012-06-27 17:12:59 UTC
Created attachment 281 [details]
replace 'RealScalar' arguments by 'const RealScalar&' in the Core module

This is needed when the scalar type requires some specific alignment since MSVC cannot align function arguments.
Comment 1 Gael Guennebaud 2012-06-27 17:14:13 UTC
the patch is incomplete, we need to check the other modules too.
Comment 2 Gael Guennebaud 2012-06-28 02:20:21 UTC
a first pass:
changeset:   0c5fc8f89361
user:        ggael
date:        2012-06-28 02:08:59
summary:     bug 482: pass scalar arguments by const references. This changeset only concerns the Core and Geometry modules

We need an automatic process to track them.
Comment 3 Gael Guennebaud 2012-06-28 21:07:21 UTC
pass on sparse module:
changeset:   28c7f269dac7
user:        ggael
date:        2012-06-28 21:01:02
summary:     bug 482: pass scalar by const ref - pass on the sparse module
(also fix a compilation issue due to previous pass)
Comment 4 Gael Guennebaud 2013-02-25 18:07:33 UTC
Pass 3:
changeset:   56956bb0c314
user:        ggael
date:        2013-02-25 18:05:57
summary:     bug 482: pass scalar arguments by const references.

It only remains the following cases that I'm not sure about because I thin they might break the ABI:

Eigen/src/Core/DenseBase.h:    select(const DenseBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
Eigen/src/Core/DenseBase.h:    select(typename ElseDerived::Scalar thenScalar, const DenseBase<ElseDerived>& elseMatrix) const;
Eigen/src/Core/GlobalFunctions.h:    operator/(typename Derived::Scalar s, const Eigen::ArrayBase<Derived>& a)
Eigen/src/Core/MatrixBase.h:    const MatrixPowerReturnValue<Derived> pow(RealScalar p) const;
Eigen/src/Core/ProductBase.h:operator*(const ProductBase<Derived,Lhs,Rhs>& prod, typename Derived::Scalar x)
Eigen/src/Core/ProductBase.h:operator*(typename Derived::Scalar x,const ProductBase<Derived,Lhs,Rhs>& prod)
Eigen/src/Core/products/SelfadjointProduct.h:::rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha)
Eigen/src/Core/products/SelfadjointRank2Update.h:::rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha)
Eigen/src/Core/SelfAdjointView.h:    SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, Scalar alpha = Scalar(1));
Eigen/src/Core/SelfAdjointView.h:    SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha = Scalar(1));
Eigen/src/Geometry/Quaternion.h:  template<class OtherDerived> Quaternion<Scalar> slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const;
Eigen/src/Geometry/Quaternion.h:QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const
Eigen/src/SuperLUSupport/SuperLUSupport.h:      eigen_assert(false && "Scalar type not supported by SuperLU");
Comment 5 Gael Guennebaud 2013-04-12 15:29:07 UTC
Finally, I don't think such a change might break ABI in practice, and moreover such a change is really important to preserve alignment.
Changeset:   6332c61ffc97
User:        ggael
Date:        2013-04-12 15:26:55
Summary:     Fix bug 482: pass scalar value by const reference (it remained a few cases)
Comment 6 Nobody 2019-12-04 11:45:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: