From b9837ca9aeccb933e410102125fcd475e6cbcada Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 14 Nov 2019 14:58:08 +0100 Subject: bug #1281: fix AutoDiffScalar's make_coherent for nested expression of constant ADs. --- unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'unsupported/Eigen/src') diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h index 2db914765..88edd6b72 100755 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h @@ -453,6 +453,24 @@ struct auto_diff_special_op<_DerType, false> void operator+() const; }; +template +void make_coherent_expression(CwiseBinaryOp xpr, const RefType &ref) +{ + make_coherent(xpr.const_cast_derived().lhs(), ref); + make_coherent(xpr.const_cast_derived().rhs(), ref); +} + +template +void make_coherent_expression(const CwiseUnaryOp &xpr, const RefType &ref) +{ + make_coherent(xpr.nestedExpression().const_cast_derived(), ref); +} + +// needed for compilation only +template +void make_coherent_expression(const CwiseNullaryOp &, const RefType &) +{} + template struct make_coherent_impl, B> { typedef Matrix A; @@ -462,6 +480,10 @@ struct make_coherent_impl struct make_coherent_impl, - Matrix > { + Matrix > { typedef Matrix A; typedef Matrix B; static void run(A& a, B& b) { -- cgit v1.2.3