Skip to content

Commit 54ed477

Browse files
committed
[Core] Fix compatibility with version of Eigen lower than 3.3.x
1 parent b77b9aa commit 54ed477

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/ref.hpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
#include "eigenpy/fwd.hpp"
2121

22+
// For old Eigen versions, EIGEN_DEVICE_FUNC is not defined.
23+
// We must define it just in the scope of this file.
24+
#if not EIGEN_VERSION_AT_LEAST(3,2,91)
25+
#define EIGEN_DEVICE_FUNC
26+
#endif
27+
2228
namespace eigenpy
2329
{
2430
template<typename MatType, int IsVectorAtCompileTime = MatType::IsVectorAtCompileTime>
@@ -49,17 +55,21 @@ namespace eigenpy
4955

5056
typedef typename Eigen::internal::traits<Base>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \
5157
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \
52-
typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \
53-
typedef typename Eigen::internal::ref_selector<Base>::type Nested; \
54-
typedef typename Eigen::internal::traits<Base>::StorageKind StorageKind; \
55-
typedef typename Eigen::internal::traits<Base>::StorageIndex StorageIndex; \
56-
enum { RowsAtCompileTime = Eigen::internal::traits<Base>::RowsAtCompileTime, \
57-
ColsAtCompileTime = Eigen::internal::traits<Base>::ColsAtCompileTime, \
58-
Flags = Eigen::internal::traits<Base>::Flags, \
59-
SizeAtCompileTime = Base::SizeAtCompileTime, \
60-
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
61-
IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
62-
using Base::derived; \
58+
typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */
59+
typedef typename Eigen::internal::ref_selector<Base>::type Nested;
60+
typedef typename Eigen::internal::traits<Base>::StorageKind StorageKind;
61+
#if EIGEN_VERSION_AT_LEAST(3,2,91)
62+
typedef typename Eigen::internal::traits<Base>::StorageIndex StorageIndex;
63+
#else
64+
typedef typename Eigen::internal::traits<Base>::Index StorageIndex;
65+
#endif
66+
enum { RowsAtCompileTime = Eigen::internal::traits<Base>::RowsAtCompileTime,
67+
ColsAtCompileTime = Eigen::internal::traits<Base>::ColsAtCompileTime,
68+
Flags = Eigen::internal::traits<Base>::Flags,
69+
SizeAtCompileTime = Base::SizeAtCompileTime,
70+
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime,
71+
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
72+
using Base::derived;
6373
using Base::const_cast_derived;
6474
typedef typename Base::PacketScalar PacketScalar;
6575

@@ -94,4 +104,8 @@ namespace eigenpy
94104
}; // struct Ref<PlainObjectType>
95105
}
96106

107+
#if not EIGEN_VERSION_AT_LEAST(3,2,91)
108+
#undef EIGEN_DEVICE_FUNC
109+
#endif
110+
97111
#endif // ifndef __eigenpy_ref_hpp__

0 commit comments

Comments
 (0)