aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2019-11-14 14:58:08 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2019-11-14 14:58:08 +0100
commitb9837ca9aeccb933e410102125fcd475e6cbcada (patch)
treee6660f907faface1660bf434c77a0802133dabfe /unsupported/test
parent0fb6e244081bb5acf7d14b26001459c6df1a6c58 (diff)
bug #1281: fix AutoDiffScalar's make_coherent for nested expression of constant ADs.
Diffstat (limited to 'unsupported/test')
-rw-r--r--unsupported/test/autodiff.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/unsupported/test/autodiff.cpp b/unsupported/test/autodiff.cpp
index bafea6ae9..2cea56ba5 100644
--- a/unsupported/test/autodiff.cpp
+++ b/unsupported/test/autodiff.cpp
@@ -352,6 +352,21 @@ double bug_1264() {
return v2(0).value();
}
+// check with expressions on constants
+double bug_1281() {
+ int n = 2;
+ typedef AutoDiffScalar<VectorXd> AD;
+ const AD c = 1.;
+ AD x0(2,n,0);
+ AD y1 = (AD(c)+AD(c))*x0;
+ y1 = x0 * (AD(c)+AD(c));
+ AD y2 = (-AD(c))+x0;
+ y2 = x0+(-AD(c));
+ AD y3 = (AD(c)*(-AD(c))+AD(c))*x0;
+ y3 = x0 * (AD(c)*(-AD(c))+AD(c));
+ return (y1+y2+y3).value();
+}
+
#endif
EIGEN_DECLARE_TEST(autodiff)
@@ -367,5 +382,6 @@ EIGEN_DECLARE_TEST(autodiff)
CALL_SUBTEST_5( bug_1223() );
CALL_SUBTEST_5( bug_1260() );
CALL_SUBTEST_5( bug_1261() );
+ CALL_SUBTEST_5( bug_1281() );
}