From 25b789fd093f554160e74d7f96951d2c6992511e Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Fri, 18 Dec 2020 14:14:03 +0100 Subject: [PATCH] core: move EIGENPY_MAKE_TYPEDEFS to a dedicated file --- CMakeLists.txt | 1 + include/eigenpy/eigen-typedef.hpp | 33 +++++++++++++++++++++++++++++++ include/eigenpy/eigenpy.hpp | 24 +--------------------- 3 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 include/eigenpy/eigen-typedef.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 762bc035..133f9f82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ SET(${PROJECT_NAME}_HEADERS include/eigenpy/eigen-allocator.hpp include/eigenpy/eigen-to-python.hpp include/eigenpy/eigen-from-python.hpp + include/eigenpy/eigen-typedef.hpp include/eigenpy/numpy-map.hpp include/eigenpy/geometry.hpp include/eigenpy/geometry-conversion.hpp diff --git a/include/eigenpy/eigen-typedef.hpp b/include/eigenpy/eigen-typedef.hpp new file mode 100644 index 00000000..c8a05a2f --- /dev/null +++ b/include/eigenpy/eigen-typedef.hpp @@ -0,0 +1,33 @@ +// +// Copyright (c) 2020 INRIA +// + +#ifndef __eigenpy_eigen_typedef_hpp__ +#define __eigenpy_eigen_typedef_hpp__ + +#include "eigenpy/fwd.hpp" + +#define EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, Size, SizeSuffix) \ + /** \ingroup matrixtypedefs */ \ + 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, Options, TypeSuffix, Size) \ + /** \ingroup matrixtypedefs */ \ + typedef Eigen::Matrix<Type, Size, Eigen::Dynamic, Options> Matrix##Size##X##TypeSuffix; \ + /** \ingroup matrixtypedefs */ \ + typedef Eigen::Matrix<Type, Eigen::Dynamic, Size, Options> Matrix##X##Size##TypeSuffix; + +#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) + +#endif // ifndef __eigenpy_eigen_typedef_hpp__ diff --git a/include/eigenpy/eigenpy.hpp b/include/eigenpy/eigenpy.hpp index 49544cca..e33442a7 100644 --- a/include/eigenpy/eigenpy.hpp +++ b/include/eigenpy/eigenpy.hpp @@ -9,33 +9,11 @@ #include "eigenpy/fwd.hpp" #include "eigenpy/deprecated.hpp" #include "eigenpy/config.hpp" +#include "eigenpy/eigen-typedef.hpp" #define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \ ::eigenpy::enableEigenPySpecific<TYPE>(); -#define EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, Size, SizeSuffix) \ - /** \ingroup matrixtypedefs */ \ - 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, Options, TypeSuffix, Size) \ - /** \ingroup matrixtypedefs */ \ - typedef Eigen::Matrix<Type, Size, Eigen::Dynamic, Options> Matrix##Size##X##TypeSuffix; \ - /** \ingroup matrixtypedefs */ \ - typedef Eigen::Matrix<Type, Eigen::Dynamic, Size, Options> Matrix##X##Size##TypeSuffix; - -#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 { -- GitLab