mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 18:19:34 +08:00
Big 1261: add missing max(ADS,ADS) overload (same for min)
This commit is contained in:
parent
5d94dc85e5
commit
8972323c08
@ -562,6 +562,15 @@ inline AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::Plain
|
||||
typedef AutoDiffScalar<typename Eigen::internal::remove_all<DerType>::type::PlainObject> 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) {
|
||||
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) {
|
||||
return (x.value() >= y.value() ? x : y);
|
||||
}
|
||||
|
||||
|
||||
EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs,
|
||||
using std::abs;
|
||||
|
@ -245,6 +245,17 @@ void bug_1260() {
|
||||
A*v;
|
||||
}
|
||||
|
||||
// check a compilation issue with numext::max
|
||||
double bug_1261() {
|
||||
typedef AutoDiffScalar<Matrix2d> AD;
|
||||
typedef Matrix<AD,2,1> VectorAD;
|
||||
|
||||
VectorAD v;
|
||||
const AD maxVal = v.maxCoeff();
|
||||
const AD minVal = v.minCoeff();
|
||||
return maxVal.value() + minVal.value();
|
||||
}
|
||||
|
||||
void test_autodiff()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
@ -257,5 +268,6 @@ void test_autodiff()
|
||||
bug_1222();
|
||||
bug_1223();
|
||||
bug_1260();
|
||||
bug_1261();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user