This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1261

Summary: Regression: max/minCoeff() of vector containing AutoDiffScalar
Product: Eigen Reporter: Daniel Vollmer <daniel.vollmer>
Component: Unsupported modulesAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: Unknown CC: chtz, gael.guennebaud
Priority: Normal    
Version: 3.3 (current stable)   
Hardware: All   
OS: All   
Whiteboard:

Description Daniel Vollmer 2016-07-27 09:03:52 UTC
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.
Comment 1 Gael Guennebaud 2016-07-27 12:54:02 UTC
That one was not a duplicate ;)

Fixed:

https://bitbucket.org/eigen/eigen/commits/35c72567c385/
Summary:     Big 1261: add missing max(ADS,ADS) overload (same for min)
Comment 2 Nobody 2019-12-04 16:01:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com'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: https://gitlab.com/libeigen/eigen/issues/1261.