This bugzilla service is closed. All entries have been migrated to
Bug 1057 - AutoDiffScalar and Polynomial
Summary: AutoDiffScalar and Polynomial
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: 3.2
Hardware: All Windows
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2015-08-19 06:30 UTC by twan_koolen
Modified: 2019-12-04 14:52 UTC (History)
2 users (show)

cmake project showing error (3.34 KB, application/x-zip-compressed)
2015-08-19 06:30 UTC, twan_koolen
no flags Details

Description twan_koolen 2015-08-19 06:30:40 UTC
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.
Comment 1 Christoph Hertzberg 2015-08-19 19:24:06 UTC
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 ...)
Comment 2 twan_koolen 2015-08-25 20:49:24 UTC
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)
Comment 3 Gael Guennebaud 2015-09-02 07:32:54 UTC
Thank you for investigating it and for the nice fix. Applied in default and 3.2 branches:
Comment 4 twan_koolen 2015-09-02 14:10:03 UTC
Great, thanks!
Comment 5 Nobody 2019-12-04 14:52:05 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:

Note You need to log in before you can comment on or make changes to this bug.