From d86544d6549078997f5986015f5a86c493cd5ee3 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 19 Dec 2019 19:48:39 +0100 Subject: Reduce code duplication and avoid confusing Doxygen --- unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'unsupported/Eigen/src') diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h index 88edd6b72..0ef159e30 100755 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h @@ -565,6 +565,11 @@ struct ScalarBinaryOpTraits, Bi CODE; \ } +template +struct CleanedUpDerType { + typedef AutoDiffScalar::type::PlainObject> type; +}; + template inline const AutoDiffScalar& conj(const AutoDiffScalar& x) { return x; } template @@ -572,31 +577,31 @@ inline const AutoDiffScalar& real(const AutoDiffScalar& x) { template inline typename DerType::Scalar imag(const AutoDiffScalar&) { return 0.; } template -inline AutoDiffScalar::type::PlainObject> (min)(const AutoDiffScalar& x, const T& y) { - typedef AutoDiffScalar::type::PlainObject> ADS; +inline typename CleanedUpDerType::type (min)(const AutoDiffScalar& x, const T& y) { + typedef typename CleanedUpDerType::type ADS; return (x <= y ? ADS(x) : ADS(y)); } template -inline AutoDiffScalar::type::PlainObject> (max)(const AutoDiffScalar& x, const T& y) { - typedef AutoDiffScalar::type::PlainObject> ADS; +inline typename CleanedUpDerType::type (max)(const AutoDiffScalar& x, const T& y) { + typedef typename CleanedUpDerType::type ADS; return (x >= y ? ADS(x) : ADS(y)); } template -inline AutoDiffScalar::type::PlainObject> (min)(const T& x, const AutoDiffScalar& y) { - typedef AutoDiffScalar::type::PlainObject> ADS; +inline typename CleanedUpDerType::type (min)(const T& x, const AutoDiffScalar& y) { + typedef typename CleanedUpDerType::type ADS; return (x < y ? ADS(x) : ADS(y)); } template -inline AutoDiffScalar::type::PlainObject> (max)(const T& x, const AutoDiffScalar& y) { - typedef AutoDiffScalar::type::PlainObject> ADS; +inline typename CleanedUpDerType::type (max)(const T& x, const AutoDiffScalar& y) { + typedef typename CleanedUpDerType::type ADS; return (x > y ? ADS(x) : ADS(y)); } template -inline AutoDiffScalar::type::PlainObject> (min)(const AutoDiffScalar& x, const AutoDiffScalar& y) { +inline typename CleanedUpDerType::type (min)(const AutoDiffScalar& x, const AutoDiffScalar& y) { return (x.value() < y.value() ? x : y); } template -inline AutoDiffScalar::type::PlainObject> (max)(const AutoDiffScalar& x, const AutoDiffScalar& y) { +inline typename CleanedUpDerType::type (max)(const AutoDiffScalar& x, const AutoDiffScalar& y) { return (x.value() >= y.value() ? x : y); } -- cgit v1.2.3