diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-05-18 16:00:11 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-05-18 16:00:11 +0200 |
commit | 448d9d943c3996f6d74cebad457865d005248ddd (patch) | |
tree | c32225b0181baf617ecebe5e3ea7e33b5c0fe3f0 | |
parent | 5a71eb598585f0413ed630f5007f3c0295c7ba60 (diff) |
bug #1222: fix compilation in AutoDiffScalar and add respective unit test
-rwxr-xr-x | unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h | 2 | ||||
-rw-r--r-- | unsupported/test/autodiff.cpp | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h index 481dfa91a..dfc08f751 100755 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h @@ -101,7 +101,7 @@ class AutoDiffScalar template<typename OtherDerType> AutoDiffScalar(const AutoDiffScalar<OtherDerType>& other #ifndef EIGEN_PARSED_BY_DOXYGEN - , typename internal::enable_if<internal::is_same<Scalar,typename OtherDerType::Scalar>::value,void*>::type = 0 + , typename internal::enable_if<internal::is_same<Scalar, typename internal::traits<typename internal::remove_all<OtherDerType>::type>::Scalar>::value,void*>::type = 0 #endif ) : m_value(other.value()), m_derivatives(other.derivatives()) diff --git a/unsupported/test/autodiff.cpp b/unsupported/test/autodiff.cpp index c4606cd17..ad3f83d4e 100644 --- a/unsupported/test/autodiff.cpp +++ b/unsupported/test/autodiff.cpp @@ -207,7 +207,14 @@ void test_autodiff_hessian() VERIFY_IS_APPROX(y.derivatives()(1).derivatives(), -std::sin(s1*s3+s2*s4)*Vector2d(s3*s4,s4*s4)); } - +double bug_1222() { + typedef Eigen::AutoDiffScalar<Eigen::Vector3d> AD; + const double _cv1_3 = 1.0; + const AD chi_3 = 1.0; + // this line did not work, because operator+ returns ADS<DerType&>, which then cannot be converted to ADS<DerType> + const AD denom = chi_3 + _cv1_3; + return denom.value(); +} void test_autodiff() { @@ -217,5 +224,7 @@ void test_autodiff() CALL_SUBTEST_3( test_autodiff_jacobian<1>() ); CALL_SUBTEST_4( test_autodiff_hessian<1>() ); } + + bug_1222(); } |