Created attachment 599 [details] cmake project showing error It seems that if unsupported/Eigen/AutoDiffScalar is included before unsupported/Eigen/Polynomials, MSVC 2010 and 2013 have trouble with LLDT::rankUpdate: c:\users\twan\code\eigenautodiffpolynomial\install\include\eigen3\eigen\src/Cholesky/LDLT.h(489): error C2244: 'Eigen::LDLT<_MatrixType,_UpLo>::rankUpdate' : unable to match function definition to an existing declaration [C:\Users\Twan\code\eigenAutoDiffPolynomial\build\eigenAutoDiffPolynomial\src\eigenAutoDiffPolynomial-build\autoDiffPolynomials.vcxproj][C:\Users\Twan\code\eigenAutoDiffPolynomial\build\eigenAutoDiffPolynomial.vcxproj] This issue does not appear in MSVC 2015. I'm having trouble understanding why the order of includes matters, but it does. See attachment for a tiny project showing the error.
I can't reproduce this on gcc or clang with neither 3.2 or the devel-branch, so it appears to be an MSVC issue. I'm tending to make this a WONTFIX, unless someone is willing to investigate this and finds a simple workaround (an obvious workaround would be to include Polynomials from AutoDiff, though I'm not sure that's worth it ...) Can you reproduce this error with the devel-branch? And can you attach the full error output? Or better, can you try to find out what's the minimal thing to include from AutoDiff to fix this? (It looks like including <Eigen/Core> would be a good idea anyways ...)
Sorry about the delay. I have an easy fix, see end of message. This is still an issue with the devel branch (3.2.90). I agree that it's an MSVC issue, specifically 2010 and 2013 since it's fixed in 2015. A smaller set of includes that triggers the error is the following: #include <Eigen/Core> #include <unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h> #include <Eigen/src/Cholesky/LDLT.h> I think the underlying reason is the following. "template<typename _MatrixType, int _UpLo> class LDLT" contains a function declaration with signature: template <typename Derived> LDLT& rankUpdate(const MatrixBase<Derived>& w, const RealScalar& alpha=1); where RealScalar is typedef'd as typename NumTraits<typename MatrixType::Scalar>::Real and MatrixType is typedef'd as _MatrixType. rankUpdate is implemented out of line with a function signature: template<typename MatrixType, int _UpLo> template<typename Derived> LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename NumTraits<typename MatrixType::Scalar>::Real& sigma) i.e. it directly refers to NumTraits<typename MatrixType::Scalar>, whereas the declaration strictly speaking refers to typename LDLT<MatrixType, _UpLo>::RealScalar. These are of course the same thing, but MSVC 2010 and 2013 aren't able to figure that out. AutoDiffScalar defines a new NumTraits specialization; that's probably related, but I don't currently see how exactly. In any case, this can be fixed by changing the method signature of the out of line definition to template<typename MatrixType, int _UpLo> template<typename Derived> LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename LDLT<MatrixType,_UpLo>::RealScalar& sigma)
Thank you for investigating it and for the nice fix. Applied in default and 3.2 branches: https://bitbucket.org/eigen/eigen/commits/8358f4574c9d/ https://bitbucket.org/eigen/eigen/commits/bf4f76c91ff7/
Great, thanks!
-- 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/1057.