Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#7378 from EricCousineau-TRI/featur…
Browse files Browse the repository at this point in the history
…e/eigen_version_autodiff

Add version checks for Eigen for AutoDiff when using as installed library. Handle >=v3.3.3
  • Loading branch information
sammy-tri authored Oct 31, 2017
2 parents 0807d87 + d550346 commit a8e962e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions drake/common/autodiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <Eigen/Core>
#include <unsupported/Eigen/AutoDiff>

static_assert(EIGEN_VERSION_AT_LEAST(3, 3, 3),
"Drake requires Eigen >= v3.3.3.");

// Do not alpha-sort the following block of hard-coded #includes, which is
// protected by `clang-format on/off`.
//
Expand Down
13 changes: 8 additions & 5 deletions drake/common/eigen_autodiff_limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#endif

#include <limits>
// If you see a 'duplicate specialization' compiler error here, then Eigen must
// have started providing this itself; conditionalize or remove Drake's own
// specialization.

// Eigen provides `numeric_limits<AutoDiffScalar<T>>` starting with v3.3.4.
#if !EIGEN_VERSION_AT_LEAST(3, 3, 4) // Eigen Version < v3.3.4

namespace std {
template <typename T>
class numeric_limits<Eigen::AutoDiffScalar<T> >
: public numeric_limits<typename T::Scalar> {};
class numeric_limits<Eigen::AutoDiffScalar<T>>
: public numeric_limits<typename T::Scalar> {};

} // namespace std

#endif // Eigen Version < v3.3.4

0 comments on commit a8e962e

Please sign in to comment.