mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix ambiguous sqrt() overload caused by ADL
Here's the compiler error:
```
/home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/src/Householder/Householder.h:82:16: error: call of overloaded ‘sqrt(boost::decimal::decimal64_t)’ is ambiguous
82 | beta = sqrt(numext::abs2(c0) + tailSqNorm);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/src/Householder/Householder.h:82:16: note: there are 2 candidates
In file included from /home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/Core:198,
from /home/tav/git/Sleipnir/test/src/optimization/cart_pole_problem_test.cpp:8:
/home/tav/git/Sleipnir/build/_deps/eigen3-src/Eigen/src/Core/MathFunctions.h:1384:75: note: candidate 1: ‘typename Eigen::internal::sqrt_retval<typename Eigen::internal::global_math_functions_filtering_base<Scalar>::type>::type Eigen::numext::sqrt(const Scalar&) [with Scalar = boost::decimal::decimal64_t; typename Eigen::internal::sqrt_retval<typename Eigen::internal::global_math_functions_filtering_base<Scalar>::type>::type = boost::decimal::decimal64_t; typename Eigen::internal::global_math_functions_filtering_base<Scalar>::type = boost::decimal::decimal64_t]’
1384 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE EIGEN_MATHFUNC_RETVAL(sqrt, Scalar) sqrt(const Scalar& x) {
| ^~~~
In file included from /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal/detail/cmath/ellint_1.hpp:16,
from /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal/cmath.hpp:18,
from /home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal.hpp:33,
from /home/tav/git/Sleipnir/test/include/scalar_types_under_test.hpp:6,
from /home/tav/git/Sleipnir/test/src/optimization/cart_pole_problem_test.cpp:19:
/home/tav/git/Sleipnir/build/_deps/decimal-src/include/boost/decimal/detail/cmath/sqrt.hpp:167:16: note: candidate 2: ‘constexpr T boost::decimal::sqrt(T) requires is_decimal_floating_point_v<T> [with T = decimal64_t]’
167 | constexpr auto sqrt(const T val) noexcept
| ^~~~
```
Calling a function via its unqualified name invokes argument-dependent lookup. In this case, since `using numext::sqrt;` was used, both `numext::sqrt()` and `boost::decimal::sqrt()` participated in overload resolution. Since only `numext::sqrt()` was intended, the fix is to call that overload directly instead.
See merge request libeigen/eigen!2044
(cherry picked from commit be56fff1ff)
This commit is contained in:
committed by
Antonio Sanchez
parent
da889c88f9
commit
a9110bfc87
@@ -65,7 +65,6 @@ template <typename EssentialPart>
|
||||
EIGEN_DEVICE_FUNC void MatrixBase<Derived>::makeHouseholder(EssentialPart& essential, Scalar& tau,
|
||||
RealScalar& beta) const {
|
||||
using numext::conj;
|
||||
using numext::sqrt;
|
||||
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
|
||||
VectorBlock<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size() - 1);
|
||||
@@ -79,7 +78,7 @@ EIGEN_DEVICE_FUNC void MatrixBase<Derived>::makeHouseholder(EssentialPart& essen
|
||||
beta = numext::real(c0);
|
||||
essential.setZero();
|
||||
} else {
|
||||
beta = sqrt(numext::abs2(c0) + tailSqNorm);
|
||||
beta = numext::sqrt(numext::abs2(c0) + tailSqNorm);
|
||||
if (numext::real(c0) >= RealScalar(0)) beta = -beta;
|
||||
essential = tail / (c0 - beta);
|
||||
tau = conj((beta - c0) / beta);
|
||||
|
||||
Reference in New Issue
Block a user