diff options
author | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2019-12-19 19:48:39 +0100 |
---|---|---|
committer | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2019-12-19 19:48:39 +0100 |
commit | d86544d6549078997f5986015f5a86c493cd5ee3 (patch) | |
tree | 0c98b88f87a7d04c4602839fc7f58fd5602c424f /unsupported/Eigen/src | |
parent | dde279f57dd5149d31b5d6c71b27e11f93d02489 (diff) |
Reduce code duplication and avoid confusing Doxygen
Diffstat (limited to 'unsupported/Eigen/src')
-rwxr-xr-x | unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h | 25 |
1 files changed, 15 insertions, 10 deletions
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 @@ -566,37 +566,42 @@ struct ScalarBinaryOpTraits<typename DerType::Scalar,AutoDiffScalar<DerType>, Bi } template<typename DerType> +struct CleanedUpDerType { + typedef AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> type; +}; + +template<typename DerType> inline const AutoDiffScalar<DerType>& conj(const AutoDiffScalar<DerType>& x) { return x; } template<typename DerType> inline const AutoDiffScalar<DerType>& real(const AutoDiffScalar<DerType>& x) { return x; } template<typename DerType> inline typename DerType::Scalar imag(const AutoDiffScalar<DerType>&) { return 0.; } template<typename DerType, typename T> -inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (min)(const AutoDiffScalar<DerType>& x, const T& y) { - typedef AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> ADS; +inline typename CleanedUpDerType<DerType>::type (min)(const AutoDiffScalar<DerType>& x, const T& y) { + typedef typename CleanedUpDerType<DerType>::type ADS; return (x <= y ? ADS(x) : ADS(y)); } template<typename DerType, typename T> -inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (max)(const AutoDiffScalar<DerType>& x, const T& y) { - typedef AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> ADS; +inline typename CleanedUpDerType<DerType>::type (max)(const AutoDiffScalar<DerType>& x, const T& y) { + typedef typename CleanedUpDerType<DerType>::type ADS; return (x >= y ? ADS(x) : ADS(y)); } template<typename DerType, typename T> -inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (min)(const T& x, const AutoDiffScalar<DerType>& y) { - typedef AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> ADS; +inline typename CleanedUpDerType<DerType>::type (min)(const T& x, const AutoDiffScalar<DerType>& y) { + typedef typename CleanedUpDerType<DerType>::type ADS; return (x < y ? ADS(x) : ADS(y)); } template<typename DerType, typename T> -inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (max)(const T& x, const AutoDiffScalar<DerType>& y) { - typedef AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> ADS; +inline typename CleanedUpDerType<DerType>::type (max)(const T& x, const AutoDiffScalar<DerType>& y) { + typedef typename CleanedUpDerType<DerType>::type ADS; return (x > y ? ADS(x) : ADS(y)); } template<typename DerType> -inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (min)(const AutoDiffScalar<DerType>& x, const AutoDiffScalar<DerType>& y) { +inline typename CleanedUpDerType<DerType>::type (min)(const AutoDiffScalar<DerType>& x, const AutoDiffScalar<DerType>& y) { return (x.value() < y.value() ? x : y); } template<typename DerType> -inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> (max)(const AutoDiffScalar<DerType>& x, const AutoDiffScalar<DerType>& y) { +inline typename CleanedUpDerType<DerType>::type (max)(const AutoDiffScalar<DerType>& x, const AutoDiffScalar<DerType>& y) { return (x.value() >= y.value() ? x : y); } |