Skip to content
Snippets Groups Projects
Verified Commit 53563e52 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: full templatization of Eigen::Map

parent 9872bfb9
Branches
Tags
No related merge requests found
...@@ -204,10 +204,10 @@ namespace eigenpy ...@@ -204,10 +204,10 @@ namespace eigenpy
}; };
#if EIGEN_VERSION_AT_LEAST(3,2,0) #if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType> template<typename MatType, int Options, typename Stride>
struct EigenAllocator< Eigen::Ref<MatType> > struct EigenAllocator<Eigen::Ref<MatType,Options,Stride> >
{ {
typedef Eigen::Ref<MatType> RefType; typedef Eigen::Ref<MatType,Options,Stride> RefType;
typedef typename MatType::Scalar Scalar; typedef typename MatType::Scalar Scalar;
typedef typename ::boost::python::detail::referent_storage<RefType&>::StorageType StorageType; typedef typename ::boost::python::detail::referent_storage<RefType&>::StorageType StorageType;
...@@ -215,7 +215,7 @@ namespace eigenpy ...@@ -215,7 +215,7 @@ namespace eigenpy
static void allocate(PyArrayObject * pyArray, static void allocate(PyArrayObject * pyArray,
bp::converter::rvalue_from_python_storage<RefType> * storage) bp::converter::rvalue_from_python_storage<RefType> * storage)
{ {
typedef typename StrideType<MatType,Eigen::internal::traits<RefType>::StrideType::InnerStrideAtCompileTime, Eigen::internal::traits<RefType>::StrideType::OuterStrideAtCompileTime >::type Stride; typedef typename StrideType<MatType,Eigen::internal::traits<RefType>::StrideType::InnerStrideAtCompileTime, Eigen::internal::traits<RefType>::StrideType::OuterStrideAtCompileTime >::type NumpyMapStride;
bool need_to_allocate = false; bool need_to_allocate = false;
const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray);
...@@ -278,7 +278,7 @@ namespace eigenpy ...@@ -278,7 +278,7 @@ namespace eigenpy
else else
{ {
assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code); assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code);
typename MapNumpy<MatType,Scalar,Stride>::EigenMap numpyMap = MapNumpy<MatType,Scalar,Stride>::map(pyArray); typename MapNumpy<MatType,Scalar,NumpyMapStride>::EigenMap numpyMap = MapNumpy<MatType,Scalar,NumpyMapStride>::map(pyArray);
RefType mat_ref(numpyMap); RefType mat_ref(numpyMap);
new (raw_ptr) StorageType(mat_ref,pyArray); new (raw_ptr) StorageType(mat_ref,pyArray);
} }
......
...@@ -35,12 +35,12 @@ namespace eigenpy ...@@ -35,12 +35,12 @@ namespace eigenpy
}; };
#if EIGEN_VERSION_AT_LEAST(3,2,0) #if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType> struct referent_storage_eigen_ref; template<typename MatType, int Options, typename Stride> struct referent_storage_eigen_ref;
template<typename MatType> template<typename MatType, int Options, typename Stride>
struct referent_storage_eigen_ref struct referent_storage_eigen_ref
{ {
typedef Eigen::Ref<MatType> RefType; typedef Eigen::Ref<MatType,Options,Stride> RefType;
typedef ::boost::python::detail::aligned_storage< typedef ::boost::python::detail::aligned_storage<
::boost::python::detail::referent_size<RefType&>::value ::boost::python::detail::referent_size<RefType&>::value
...@@ -89,10 +89,10 @@ namespace eigenpy ...@@ -89,10 +89,10 @@ namespace eigenpy
namespace boost { namespace python { namespace detail { namespace boost { namespace python { namespace detail {
#if EIGEN_VERSION_AT_LEAST(3,2,0) #if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType> template<typename MatType, int Options, typename Stride>
struct referent_storage<Eigen::Ref<MatType> &> struct referent_storage<Eigen::Ref<MatType,Options,Stride> &>
{ {
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType> StorageType; typedef ::eigenpy::details::referent_storage_eigen_ref<MatType,Options,Stride> StorageType;
typedef aligned_storage< typedef aligned_storage<
::boost::python::detail::referent_size<StorageType&>::value ::boost::python::detail::referent_size<StorageType&>::value
> type; > type;
...@@ -166,10 +166,10 @@ namespace boost { namespace python { namespace converter { ...@@ -166,10 +166,10 @@ namespace boost { namespace python { namespace converter {
#undef RVALUE_FROM_PYTHON_DATA_INIT #undef RVALUE_FROM_PYTHON_DATA_INIT
template<typename MatType> template<typename MatType, int Options, typename Stride>
struct rvalue_from_python_data<Eigen::Ref<MatType> &> : rvalue_from_python_storage<Eigen::Ref<MatType> &> struct rvalue_from_python_data<Eigen::Ref<MatType,Options,Stride> &> : rvalue_from_python_storage<Eigen::Ref<MatType,Options,Stride> &>
{ {
typedef Eigen::Ref<MatType> T; typedef Eigen::Ref<MatType,Options,Stride> T;
# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ # if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ && (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \
...@@ -196,7 +196,7 @@ namespace boost { namespace python { namespace converter { ...@@ -196,7 +196,7 @@ namespace boost { namespace python { namespace converter {
// Destroys any object constructed in the storage. // Destroys any object constructed in the storage.
~rvalue_from_python_data() ~rvalue_from_python_data()
{ {
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType> StorageType; typedef ::eigenpy::details::referent_storage_eigen_ref<MatType, Options,Stride> StorageType;
if (this->stage1.convertible == this->storage.bytes) if (this->stage1.convertible == this->storage.bytes)
static_cast<StorageType *>((void *)this->storage.bytes)->~StorageType(); static_cast<StorageType *>((void *)this->storage.bytes)->~StorageType();
} }
...@@ -418,10 +418,10 @@ namespace eigenpy ...@@ -418,10 +418,10 @@ namespace eigenpy
#if EIGEN_VERSION_AT_LEAST(3,2,0) #if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType, int Options, typename StrideType> template<typename MatType, int Options, typename Stride>
struct EigenFromPy<Eigen::Ref<MatType,Options,StrideType> > struct EigenFromPy<Eigen::Ref<MatType,Options,Stride> >
{ {
typedef Eigen::Ref<MatType,Options,StrideType> RefType; typedef Eigen::Ref<MatType,Options,Stride> RefType;
typedef typename MatType::Scalar Scalar; typedef typename MatType::Scalar Scalar;
/// \brief Determine if pyObj can be converted into a MatType object /// \brief Determine if pyObj can be converted into a MatType object
......
...@@ -52,8 +52,8 @@ namespace eigenpy ...@@ -52,8 +52,8 @@ namespace eigenpy
#if EIGEN_VERSION_AT_LEAST(3,2,0) #if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType> template<typename MatType, int Options, typename Stride>
struct NumpyAllocator<Eigen::Ref<MatType> > : NumpyAllocator<MatType &> struct NumpyAllocator<Eigen::Ref<MatType,Options,Stride> > : NumpyAllocator<MatType &>
{ {
}; };
...@@ -81,8 +81,8 @@ namespace eigenpy ...@@ -81,8 +81,8 @@ namespace eigenpy
#if EIGEN_VERSION_AT_LEAST(3,2,0) #if EIGEN_VERSION_AT_LEAST(3,2,0)
template<typename MatType> template<typename MatType, int Options, typename Stride>
struct NumpyAllocator<const Eigen::Ref<const MatType> > : NumpyAllocator<const MatType &> struct NumpyAllocator<const Eigen::Ref<const MatType,Options,Stride> > : NumpyAllocator<const MatType &>
{ {
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment