From 0c0181b11ee6499d44d6a02179563a8196d1be0a Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Thu, 11 Jan 2018 11:19:46 +0100 Subject: [PATCH 1/5] [All] Fix compatibility with Eigen 3.2.x --- src/fwd.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fwd.hpp b/src/fwd.hpp index d5d1f2e66..5f00431f6 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -28,9 +28,14 @@ #include #ifdef NPY_ALIGNED -#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned16 +#if EIGEN_VERSION_AT_LEAST(3,2,90) + #define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned16 #else -#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Unaligned + #define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned +#endif +#else + #define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Unaligned #endif #endif // ifndef __eigenpy_fwd_hpp__ + From 403fd7ab22760ab8418b301a5fc869f7763b76c1 Mon Sep 17 00:00:00 2001 From: jcarpent Date: Thu, 11 Jan 2018 13:46:03 +0100 Subject: [PATCH 2/5] [CMake] Use "-isystem" for dependencies and remove useless lines --- CMakeLists.txt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae903e99..b57443ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,13 +55,8 @@ ENDIF(WIN32) # ---------------------------------------------------- # --- OPTIONS --------------------------------------- # ---------------------------------------------------- -OPTION (EIGEN_NUMPY_ALIGNED "Directly aligned data between Numpy and Eigen" OFF) OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON) -IF(EIGEN_NUMPY_ALIGNED) - ADD_DEFINITIONS(-DEIGENPY_ALIGNED) -ENDIF(EIGEN_NUMPY_ALIGNED) - # ---------------------------------------------------- # --- DEPENDANCIES ----------------------------------- # ---------------------------------------------------- @@ -157,13 +152,9 @@ ADD_SUBDIRECTORY(python) # ---------------------------------------------------- ADD_SUBDIRECTORY(unittest) -IF(EIGEN_NUMPY_ALIGNED) - PKG_CONFIG_APPEND_CFLAGS("-DEIGENPY_ALIGNED") -ENDIF(EIGEN_NUMPY_ALIGNED) - PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME}) -PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}") -PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}") +PKG_CONFIG_APPEND_CFLAGS("-isystem ${PYTHON_INCLUDE_DIRS}") +PKG_CONFIG_APPEND_CFLAGS("-isystem ${NUMPY_INCLUDE_DIRS}") PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS}) SETUP_PROJECT_FINALIZE() From 1054dce9a2b4aa6a2cee9818697c7e7f263383bf Mon Sep 17 00:00:00 2001 From: jcarpent Date: Thu, 11 Jan 2018 13:46:33 +0100 Subject: [PATCH 3/5] [Core] Change minimal Eigen version --- src/ref.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ref.hpp b/src/ref.hpp index 641228e18..c651e1dd4 100644 --- a/src/ref.hpp +++ b/src/ref.hpp @@ -21,7 +21,7 @@ // For old Eigen versions, EIGEN_DEVICE_FUNC is not defined. // We must define it just in the scope of this file. -#if not EIGEN_VERSION_AT_LEAST(3,2,91) +#if not EIGEN_VERSION_AT_LEAST(3,2,90) #define EIGEN_DEVICE_FUNC #endif @@ -58,7 +58,7 @@ namespace eigenpy 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. */ typedef typename Eigen::internal::ref_selector::type Nested; typedef typename Eigen::internal::traits::StorageKind StorageKind; -#if EIGEN_VERSION_AT_LEAST(3,2,91) +#if EIGEN_VERSION_AT_LEAST(3,2,90) typedef typename Eigen::internal::traits::StorageIndex StorageIndex; #else typedef typename Eigen::internal::traits::Index StorageIndex; @@ -104,7 +104,7 @@ namespace eigenpy }; // struct Ref } -#if not EIGEN_VERSION_AT_LEAST(3,2,91) +#if not EIGEN_VERSION_AT_LEAST(3,2,90) #undef EIGEN_DEVICE_FUNC #endif From aacde1619b9883420e75732a6148a410aa329b7f Mon Sep 17 00:00:00 2001 From: jcarpent Date: Thu, 11 Jan 2018 13:53:26 +0100 Subject: [PATCH 4/5] [Core] Move stride to a dedicated file --- CMakeLists.txt | 1 + src/map.hpp | 1 + src/ref.hpp | 14 ++------------ src/stride.hpp | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/stride.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b57443ed4..86250e5a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ SET(HEADERS registration.hpp angle-axis.hpp quaternion.hpp + stride.hpp ref.hpp ) diff --git a/src/map.hpp b/src/map.hpp index 2a2fb4b27..c7414355d 100644 --- a/src/map.hpp +++ b/src/map.hpp @@ -17,6 +17,7 @@ #include "eigenpy/fwd.hpp" #include #include "eigenpy/exception.hpp" +#include "eigenpy/stride.hpp" namespace eigenpy { diff --git a/src/ref.hpp b/src/ref.hpp index c651e1dd4..367bf0f8a 100644 --- a/src/ref.hpp +++ b/src/ref.hpp @@ -18,6 +18,7 @@ #define __eigenpy_ref_hpp__ #include "eigenpy/fwd.hpp" +#include "eigenpy/stride.hpp" // For old Eigen versions, EIGEN_DEVICE_FUNC is not defined. // We must define it just in the scope of this file. @@ -27,18 +28,7 @@ namespace eigenpy { - template - struct StrideType - { - typedef Eigen::Stride type; - }; - - template - struct StrideType - { - typedef Eigen::InnerStride type; - }; - + template struct Ref : Eigen::Ref::type> { diff --git a/src/stride.hpp b/src/stride.hpp new file mode 100644 index 000000000..438b818aa --- /dev/null +++ b/src/stride.hpp @@ -0,0 +1,37 @@ +/* + * Copyright 2018, Justin Carpentier , LAAS-CNRS + * + * This file is part of eigenpy. + * eigenpy is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * eigenpy is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. You should + * have received a copy of the GNU Lesser General Public License along + * with eigenpy. If not, see . + */ + +#ifndef __eigenpy_stride_hpp__ +#define __eigenpy_stride_hpp__ + +#include + +namespace eigenpy +{ + template + struct StrideType + { + typedef Eigen::Stride type; + }; + + template + struct StrideType + { + typedef Eigen::InnerStride type; + }; +} + +#endif // ifndef __eigenpy_stride_hpp__ From 412720a57e44116a337f5189e1430b362d448d1d Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Thu, 11 Jan 2018 13:57:11 +0100 Subject: [PATCH 5/5] Fix compatibility with Eigen 3.0.5 --- src/details.hpp | 2 ++ src/eigenpy.hpp | 8 ++++++++ src/solvers/preconditioners.cpp | 10 +++++++++- src/solvers/solvers.cpp | 9 ++++++++- unittest/CMakeLists.txt | 4 +++- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/details.hpp b/src/details.hpp index 6fe8295d2..f99467fc6 100644 --- a/src/details.hpp +++ b/src/details.hpp @@ -85,6 +85,7 @@ namespace eigenpy } }; +#if EIGEN_VERSION_AT_LEAST(3,2,0) template struct EigenObjectAllocator< eigenpy::Ref > { @@ -101,6 +102,7 @@ namespace eigenpy MapNumpy::map(pyArray) = mat; } }; +#endif /* --- TO PYTHON -------------------------------------------------------------- */ template diff --git a/src/eigenpy.hpp b/src/eigenpy.hpp index 9fcecc7ce..8ecf798f9 100644 --- a/src/eigenpy.hpp +++ b/src/eigenpy.hpp @@ -19,12 +19,20 @@ #include "eigenpy/fwd.hpp" #include "eigenpy/deprecated.hh" +#if EIGEN_VERSION_AT_LEAST(3,2,0) #include "eigenpy/ref.hpp" #define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \ enableEigenPySpecific(); \ enableEigenPySpecific< eigenpy::Ref >(); +#else + +#define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \ + enableEigenPySpecific(); + +#endif + namespace eigenpy { /* Enable Eigen-Numpy serialization for a set of standard MatrixBase instance. */ diff --git a/src/solvers/preconditioners.cpp b/src/solvers/preconditioners.cpp index fb2f2e35a..1854170f7 100644 --- a/src/solvers/preconditioners.cpp +++ b/src/solvers/preconditioners.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2017, Justin Carpentier, LAAS-CNRS + * Copyright 2017-2018, Justin Carpentier, LAAS-CNRS * * This file is part of eigenpy. * eigenpy is free software: you can redistribute it and/or @@ -14,12 +14,16 @@ * with eigenpy. If not, see . */ +#include + +#if EIGEN_VERSION_AT_LEAST(3,2,0) #include "eigenpy/solvers/preconditioners.hpp" #include "eigenpy/solvers/BasicPreconditioners.hpp" //#include "eigenpy/solvers/BFGSPreconditioners.hpp" namespace eigenpy { + void exposePreconditioners() { using namespace Eigen; @@ -32,4 +36,8 @@ namespace eigenpy // LimitedBFGSPreconditionerBaseVisitor< LimitedBFGSPreconditioner >::expose("LimitedBFGSPreconditioner"); } + } // namespace eigenpy + +#endif + diff --git a/src/solvers/solvers.cpp b/src/solvers/solvers.cpp index d0d7103ff..8a30217dd 100644 --- a/src/solvers/solvers.cpp +++ b/src/solvers/solvers.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2017, Justin Carpentier, LAAS-CNRS + * Copyright 2017-2018, Justin Carpentier, LAAS-CNRS * * This file is part of eigenpy. * eigenpy is free software: you can redistribute it and/or @@ -14,6 +14,10 @@ * with eigenpy. If not, see . */ +#include + +#if EIGEN_VERSION_AT_LEAST(3,2,0) + #include "eigenpy/solvers/solvers.hpp" #include "eigenpy/solvers/ConjugateGradient.hpp" @@ -43,3 +47,6 @@ namespace eigenpy ; } } // namespace eigenpy + +#endif + diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 8b0a15c8e..76a817fd5 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -40,5 +40,7 @@ ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) ADD_LIB_UNIT_TEST(matrix "eigen3") ADD_LIB_UNIT_TEST(geometry "eigen3") -ADD_LIB_UNIT_TEST(ref "eigen3") +IF(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0") + ADD_LIB_UNIT_TEST(ref "eigen3") +ENDIF()