diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae903e99..86250e5a6 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 ----------------------------------- # ---------------------------------------------------- @@ -103,6 +98,7 @@ SET(HEADERS registration.hpp angle-axis.hpp quaternion.hpp + stride.hpp ref.hpp ) @@ -157,13 +153,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() 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/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__ + 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 641228e18..367bf0f8a 100644 --- a/src/ref.hpp +++ b/src/ref.hpp @@ -18,27 +18,17 @@ #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. -#if not EIGEN_VERSION_AT_LEAST(3,2,91) +#if not EIGEN_VERSION_AT_LEAST(3,2,90) #define EIGEN_DEVICE_FUNC #endif namespace eigenpy { - template - struct StrideType - { - typedef Eigen::Stride type; - }; - - template - struct StrideType - { - typedef Eigen::InnerStride type; - }; - + template struct Ref : Eigen::Ref::type> { @@ -58,7 +48,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 +94,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 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/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__ 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()