Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----------------------------------
# ----------------------------------------------------
Expand Down Expand Up @@ -103,6 +98,7 @@ SET(HEADERS
registration.hpp
angle-axis.hpp
quaternion.hpp
stride.hpp
ref.hpp
)

Expand Down Expand Up @@ -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()
2 changes: 2 additions & 0 deletions src/details.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace eigenpy
}
};

#if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType>
struct EigenObjectAllocator< eigenpy::Ref<MatType> >
{
Expand All @@ -101,6 +102,7 @@ namespace eigenpy
MapNumpy<MatType>::map(pyArray) = mat;
}
};
#endif

/* --- TO PYTHON -------------------------------------------------------------- */
template<typename MatType>
Expand Down
8 changes: 8 additions & 0 deletions src/eigenpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
9 changes: 7 additions & 2 deletions src/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__

1 change: 1 addition & 0 deletions src/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "eigenpy/fwd.hpp"
#include <numpy/arrayobject.h>
#include "eigenpy/exception.hpp"
#include "eigenpy/stride.hpp"

namespace eigenpy
{
Expand Down
20 changes: 5 additions & 15 deletions src/ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
{
Expand All @@ -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;
Expand Down Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion src/solvers/preconditioners.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -32,4 +36,8 @@ namespace eigenpy
// LimitedBFGSPreconditionerBaseVisitor< LimitedBFGSPreconditioner<double,Eigen::Dynamic,Eigen::Upper|Eigen::Lower> >::expose("LimitedBFGSPreconditioner");

}

} // namespace eigenpy

#endif

9 changes: 8 additions & 1 deletion src/solvers/solvers.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"

Expand Down Expand Up @@ -43,3 +47,6 @@ namespace eigenpy
;
}
} // namespace eigenpy

#endif

37 changes: 37 additions & 0 deletions src/stride.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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__
4 changes: 3 additions & 1 deletion unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()