From 7fc0f5e240549a8e22e4c52a94b9a73783b5f2bc Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Fri, 21 Feb 2020 09:51:04 +0100 Subject: [PATCH] core: add default exposition of RowMajor Eigen types --- include/eigenpy/eigenpy.hpp | 36 +++++++++++++++++------------- src/eigenpy.cpp | 1 - src/matrix-complex-double.cpp | 1 + src/matrix-complex-float.cpp | 1 + src/matrix-complex-long-double.cpp | 1 + src/matrix-double.cpp | 1 + src/matrix-float.cpp | 1 + src/matrix-int.cpp | 1 + src/matrix-long-double.cpp | 1 + src/matrix-long.cpp | 1 + 10 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/eigenpy/eigenpy.hpp b/include/eigenpy/eigenpy.hpp index b9668da4..75c2c73e 100644 --- a/include/eigenpy/eigenpy.hpp +++ b/include/eigenpy/eigenpy.hpp @@ -24,28 +24,28 @@ #endif // if EIGEN_VERSION_AT_LEAST(3,2,0) -#define EIGENPY_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ +#define EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, Size, SizeSuffix) \ /** \ingroup matrixtypedefs */ \ - typedef Eigen::Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \ + typedef Eigen::Matrix<Type, Size, Size, Options> Matrix##SizeSuffix##TypeSuffix; \ /** \ingroup matrixtypedefs */ \ typedef Eigen::Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \ /** \ingroup matrixtypedefs */ \ typedef Eigen::Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix; -#define EIGENPY_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \ +#define EIGENPY_MAKE_FIXED_TYPEDEFS(Type, Options, TypeSuffix, Size) \ /** \ingroup matrixtypedefs */ \ - typedef Eigen::Matrix<Type, Size, Eigen::Dynamic> Matrix##Size##X##TypeSuffix; \ + typedef Eigen::Matrix<Type, Size, Eigen::Dynamic, Options> Matrix##Size##X##TypeSuffix; \ /** \ingroup matrixtypedefs */ \ - typedef Eigen::Matrix<Type, Eigen::Dynamic, Size> Matrix##X##Size##TypeSuffix; + typedef Eigen::Matrix<Type, Eigen::Dynamic, Size, Options> Matrix##X##Size##TypeSuffix; -#define EIGENPY_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ - EIGENPY_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ - EIGENPY_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ - EIGENPY_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ - EIGENPY_MAKE_TYPEDEFS(Type, TypeSuffix, Eigen::Dynamic, X) \ - EIGENPY_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \ - EIGENPY_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \ - EIGENPY_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4) +#define EIGENPY_MAKE_TYPEDEFS_ALL_SIZES(Type, Options, TypeSuffix) \ + EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, 2, 2) \ + EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, 3, 3) \ + EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, 4, 4) \ + EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, Eigen::Dynamic, X) \ + EIGENPY_MAKE_FIXED_TYPEDEFS(Type, Options, TypeSuffix, 2) \ + EIGENPY_MAKE_FIXED_TYPEDEFS(Type, Options, TypeSuffix, 3) \ + EIGENPY_MAKE_FIXED_TYPEDEFS(Type, Options, TypeSuffix, 4) namespace eigenpy { @@ -65,10 +65,10 @@ namespace eigenpy template<typename MatType,typename EigenEquivalentType> EIGENPY_DEPRECATED void enableEigenPySpecific(); - template<typename Scalar> + template<typename Scalar, int Options> EIGEN_DONT_INLINE void exposeType() { - EIGENPY_MAKE_TYPEDEFS_ALL_SIZES(Scalar,s); + EIGENPY_MAKE_TYPEDEFS_ALL_SIZES(Scalar,Options,s); ENABLE_SPECIFIC_MATRIX_TYPE(Vector2s); ENABLE_SPECIFIC_MATRIX_TYPE(RowVector2s); @@ -93,6 +93,12 @@ namespace eigenpy ENABLE_SPECIFIC_MATRIX_TYPE(MatrixXs); } + template<typename Scalar> + EIGEN_DONT_INLINE void exposeType() + { + exposeType<Scalar,0>(); + } + } // namespace eigenpy #include "eigenpy/details.hpp" diff --git a/src/eigenpy.cpp b/src/eigenpy.cpp index c85030b1..85d6f5b1 100644 --- a/src/eigenpy.cpp +++ b/src/eigenpy.cpp @@ -6,7 +6,6 @@ #include "eigenpy/eigenpy.hpp" #include <stdlib.h> - namespace eigenpy { diff --git a/src/matrix-complex-double.cpp b/src/matrix-complex-double.cpp index 899f88fc..a3fa1634 100644 --- a/src/matrix-complex-double.cpp +++ b/src/matrix-complex-double.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixComplexDouble() { exposeType<std::complex<double> >(); + exposeType<std::complex<double>,Eigen::RowMajor>(); } } diff --git a/src/matrix-complex-float.cpp b/src/matrix-complex-float.cpp index 323c52d7..885d2a3e 100644 --- a/src/matrix-complex-float.cpp +++ b/src/matrix-complex-float.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixComplexFloat() { exposeType<std::complex<float> >(); + exposeType<std::complex<float>,Eigen::RowMajor>(); } } diff --git a/src/matrix-complex-long-double.cpp b/src/matrix-complex-long-double.cpp index 1f987ae1..b27cf1dd 100644 --- a/src/matrix-complex-long-double.cpp +++ b/src/matrix-complex-long-double.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixComplexLongDouble() { exposeType<std::complex<long double> >(); + exposeType<std::complex<long double>,Eigen::RowMajor>(); } } diff --git a/src/matrix-double.cpp b/src/matrix-double.cpp index dc84a9c2..13215978 100644 --- a/src/matrix-double.cpp +++ b/src/matrix-double.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixDouble() { exposeType<double>(); + exposeType<double,Eigen::RowMajor>(); } } diff --git a/src/matrix-float.cpp b/src/matrix-float.cpp index 100b8e9e..44779560 100644 --- a/src/matrix-float.cpp +++ b/src/matrix-float.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixFloat() { exposeType<float>(); + exposeType<float,Eigen::RowMajor>(); } } diff --git a/src/matrix-int.cpp b/src/matrix-int.cpp index a4b0d8b2..476746cc 100644 --- a/src/matrix-int.cpp +++ b/src/matrix-int.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixInt() { exposeType<int>(); + exposeType<int,Eigen::RowMajor>(); } } diff --git a/src/matrix-long-double.cpp b/src/matrix-long-double.cpp index 1b2a8f71..41bcb699 100644 --- a/src/matrix-long-double.cpp +++ b/src/matrix-long-double.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixLongDouble() { exposeType<long double>(); + exposeType<long double,Eigen::RowMajor>(); } } diff --git a/src/matrix-long.cpp b/src/matrix-long.cpp index 835b6cce..6d34fcef 100644 --- a/src/matrix-long.cpp +++ b/src/matrix-long.cpp @@ -9,5 +9,6 @@ namespace eigenpy void exposeMatrixLong() { exposeType<long>(); + exposeType<long,Eigen::RowMajor>(); } } -- GitLab