Regression: max/minCoeff() of vector containing AutoDiffScalar
Submitted by Daniel Vollmer
Assigned to Nobody
Link to original bugzilla bug (#1261)
Version: 3.3 (current stable)
Description
The following example (which works in the 3.2 branch) demonstrates the problem with Eigen-3.3 beta2:
#include "Eigen/Core"
#include "unsupported/Eigen/AutoDiff"
using namespace Eigen;
int main (int argc, char const *argv[])
{
using AD = AutoDiffScalar<Matrix<double, 2, 1> >;
using ADVec = Matrix<AD, 2, 1>;
ADVec v;
const AD maxVal = v.maxCoeff();
/* code */
return 0;
}
The error is as follows:
clang++ -std=c++11 eigen_3.3_repo.cpp -I thirdparty/eigen-3.3
In file included from eigen_3.3_repo.cpp:1:
In file included from thirdparty/eigen-3.3/Eigen/Core:330:
thirdparty/eigen-3.3/Eigen/src/Core/MathFunctions.h:810:10: error: call to 'max' is ambiguous
return max EIGEN_NOT_A_MACRO (x,y);
^~~
thirdparty/eigen-3.3/Eigen/src/Core/functors/BinaryFunctors.h:170:134: note: in instantiation of function template specialization 'Eigen::numext::maxi<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> > >'
requested here
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return numext::maxi(a, b); }
^
thirdparty/eigen-3.3/Eigen/src/Core/Redux.h:102:12: note: in instantiation of member function 'Eigen::internal::scalar_max_op<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >,
Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> > >::operator()' requested here
return func(redux_novec_unroller<Func, Derived, Start, HalfLength>::run(mat,func),
^
thirdparty/eigen-3.3/Eigen/src/Core/Redux.h:418:53: note: in instantiation of member function 'Eigen::internal::redux_novec_unroller<Eigen::internal::scalar_max_op<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1>
>, Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> > >, Eigen::internal::redux_evaluator<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, 2, 1, 0, 2, 1> >, 0, 2>::run' requested
here
return internal::redux_impl<Func, ThisEvaluator>::run(thisEval, func);
^
thirdparty/eigen-3.3/Eigen/src/Core/Redux.h:438:20: note: in instantiation of function template specialization 'Eigen::DenseBase<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, 2, 1, 0, 2, 1>
>::redux<Eigen::internal::scalar_max_op<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> > > >' requested here
return derived().redux(Eigen::internal::scalar_max_op<Scalar,Scalar>());
^
eigen_3.3_repo.cpp:12:23: note: in instantiation of member function 'Eigen::DenseBase<Eigen::Matrix<Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, 2, 1, 0, 2, 1> >::maxCoeff' requested here
const AD maxVal = v.maxCoeff();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:2654:1: note: candidate function [with _Tp = Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >]
max(const _Tp& __a, const _Tp& __b)
^
thirdparty/eigen-3.3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h:567:90: note: candidate function [with DerType = Eigen::Matrix<double, 2, 1, 0, 2, 1>, T = Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >]
inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (max)(const AutoDiffScalar<DerType>& x, const T& y) {
^
thirdparty/eigen-3.3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h:577:90: note: candidate function [with DerType = Eigen::Matrix<double, 2, 1, 0, 2, 1>, T = Eigen::AutoDiffScalar<Eigen::Matrix<double, 2, 1, 0, 2, 1> >]
inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (max)(const T& x, const AutoDiffScalar<DerType>& y) {
^
1 error generated.