The following example fails to compile:
int main (int argc, char const *argv)
typedef Eigen::AutoDiffScalar<Eigen::Vector3d> AD;
const double _cv1_3 = 1.0;
const AD chi_3 = 1.0;
// this line doesn't work, because operator+ returns ADS<DerType&>, which then cannot be converted to ADS<DerType>
const AD denom = chi_3 + _cv1_3;
I'm not sure what the intent is for operator+ (and -) to return ADS<DerType&> (probably to reuse the original derivatives?), but then the conversion from ADS<DerType&> to ADS<DerType> doesn't seem allowed, the intended constructor fails due to the unexpected reference in OtherDerType.
Applying the following patch seems to work around the problem for me:
--- a/AutoDiffScalar.h 2016-05-10 04:24:55.000000000 +0200
+++ b/AutoDiffScalar.h 2016-05-10 16:47:36.000000000 +0200
@@ -101,7 +101,7 @@
AutoDiffScalar(const AutoDiffScalar<OtherDerType>& other
- , typename internal::enable_if<internal::is_same<Scalar,typename OtherDerType::Scalar>::value,void*>::type = 0
+ , typename internal::enable_if<internal::is_same<Scalar, typename Eigen::internal::traits<typename Eigen::internal::remove_all<DerType>::type>::Scalar>::value,void*>::type = 0
: m_value(other.value()), m_derivatives(other.derivatives())
Thanks for the patch, but it should be OtherDerType instead of DerType. Also, this issue applies to 3.3 only.
Backport of the unit test to 3.2: https://bitbucket.org/eigen/eigen/commits/638f9632e24c
Ah yes, I had taken the most recent AutoDiffScalar from the default branch to get the fix to http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1189 which might be why I saw this problem using an otherwise vanilla Eigen 3.2.
-- 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/1222.