Unverified Commit 2509447f authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #23 from jcarpent/devel

Fix compatibility with Eigen 3.0.5 and 3.2.x
parents 32b3ae69 412720a5
......@@ -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()
......@@ -85,6 +85,7 @@ namespace eigenpy
}
};
#if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType>
struct EigenObjectAllocator< eigenpy::Ref<MatType> >
{
......@@ -101,6 +102,7 @@ namespace eigenpy
MapNumpy<MatType>::map(pyArray) = mat;
}
};
#endif
/* --- TO PYTHON -------------------------------------------------------------- */
template<typename MatType>
......
......@@ -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<TYPE>(); \
enableEigenPySpecific< eigenpy::Ref<TYPE> >();
#else
#define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \
enableEigenPySpecific<TYPE>();
#endif
namespace eigenpy
{
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instance. */
......
......@@ -28,9 +28,14 @@
#include <numpy/noprefix.h>
#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__
......@@ -17,6 +17,7 @@
#include "eigenpy/fwd.hpp"
#include <numpy/arrayobject.h>
#include "eigenpy/exception.hpp"
#include "eigenpy/stride.hpp"
namespace eigenpy
{
......
......@@ -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<typename MatType, int IsVectorAtCompileTime = MatType::IsVectorAtCompileTime>
struct StrideType
{
typedef Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic> type;
};
template<typename MatType>
struct StrideType<MatType,1>
{
typedef Eigen::InnerStride<Eigen::Dynamic> type;
};
template<typename PlainObjectType>
struct Ref : Eigen::Ref<PlainObjectType,EIGENPY_DEFAULT_ALIGNMENT_VALUE,typename StrideType<PlainObjectType>::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<Base>::type Nested;
typedef typename Eigen::internal::traits<Base>::StorageKind StorageKind;
#if EIGEN_VERSION_AT_LEAST(3,2,91)
#if EIGEN_VERSION_AT_LEAST(3,2,90)
typedef typename Eigen::internal::traits<Base>::StorageIndex StorageIndex;
#else
typedef typename Eigen::internal::traits<Base>::Index StorageIndex;
......@@ -104,7 +94,7 @@ namespace eigenpy
}; // struct Ref<PlainObjectType>
}
#if not EIGEN_VERSION_AT_LEAST(3,2,91)
#if not EIGEN_VERSION_AT_LEAST(3,2,90)
#undef EIGEN_DEVICE_FUNC
#endif
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <Eigen/Core>
#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<double,Eigen::Dynamic,Eigen::Upper|Eigen::Lower> >::expose("LimitedBFGSPreconditioner");
}
} // namespace eigenpy
#endif
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <Eigen/Core>
#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
/*
* Copyright 2018, Justin Carpentier <jcarpent@laas.fr>, 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __eigenpy_stride_hpp__
#define __eigenpy_stride_hpp__
#include <Eigen/Core>
namespace eigenpy
{
template<typename MatType, int IsVectorAtCompileTime = MatType::IsVectorAtCompileTime>
struct StrideType
{
typedef Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic> type;
};
template<typename MatType>
struct StrideType<MatType,1>
{
typedef Eigen::InnerStride<Eigen::Dynamic> type;
};
}
#endif // ifndef __eigenpy_stride_hpp__
......@@ -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()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment