Skip to content

Commit 53563e5

Browse files
committed
core: full templatization of Eigen::Map
1 parent 9872bfb commit 53563e5

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

include/eigenpy/eigen-allocator.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,18 @@ namespace eigenpy
204204
};
205205

206206
#if EIGEN_VERSION_AT_LEAST(3,2,0)
207-
template<typename MatType>
208-
struct EigenAllocator< Eigen::Ref<MatType> >
207+
template<typename MatType, int Options, typename Stride>
208+
struct EigenAllocator<Eigen::Ref<MatType,Options,Stride> >
209209
{
210-
typedef Eigen::Ref<MatType> RefType;
210+
typedef Eigen::Ref<MatType,Options,Stride> RefType;
211211
typedef typename MatType::Scalar Scalar;
212212

213213
typedef typename ::boost::python::detail::referent_storage<RefType&>::StorageType StorageType;
214214

215215
static void allocate(PyArrayObject * pyArray,
216216
bp::converter::rvalue_from_python_storage<RefType> * storage)
217217
{
218-
typedef typename StrideType<MatType,Eigen::internal::traits<RefType>::StrideType::InnerStrideAtCompileTime, Eigen::internal::traits<RefType>::StrideType::OuterStrideAtCompileTime >::type Stride;
218+
typedef typename StrideType<MatType,Eigen::internal::traits<RefType>::StrideType::InnerStrideAtCompileTime, Eigen::internal::traits<RefType>::StrideType::OuterStrideAtCompileTime >::type NumpyMapStride;
219219

220220
bool need_to_allocate = false;
221221
const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray);
@@ -278,7 +278,7 @@ namespace eigenpy
278278
else
279279
{
280280
assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code);
281-
typename MapNumpy<MatType,Scalar,Stride>::EigenMap numpyMap = MapNumpy<MatType,Scalar,Stride>::map(pyArray);
281+
typename MapNumpy<MatType,Scalar,NumpyMapStride>::EigenMap numpyMap = MapNumpy<MatType,Scalar,NumpyMapStride>::map(pyArray);
282282
RefType mat_ref(numpyMap);
283283
new (raw_ptr) StorageType(mat_ref,pyArray);
284284
}

include/eigenpy/eigen-from-python.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ namespace eigenpy
3535
};
3636

3737
#if EIGEN_VERSION_AT_LEAST(3,2,0)
38-
template<typename MatType> struct referent_storage_eigen_ref;
38+
template<typename MatType, int Options, typename Stride> struct referent_storage_eigen_ref;
3939

40-
template<typename MatType>
40+
template<typename MatType, int Options, typename Stride>
4141
struct referent_storage_eigen_ref
4242
{
43-
typedef Eigen::Ref<MatType> RefType;
43+
typedef Eigen::Ref<MatType,Options,Stride> RefType;
4444

4545
typedef ::boost::python::detail::aligned_storage<
4646
::boost::python::detail::referent_size<RefType&>::value
@@ -89,10 +89,10 @@ namespace eigenpy
8989

9090
namespace boost { namespace python { namespace detail {
9191
#if EIGEN_VERSION_AT_LEAST(3,2,0)
92-
template<typename MatType>
93-
struct referent_storage<Eigen::Ref<MatType> &>
92+
template<typename MatType, int Options, typename Stride>
93+
struct referent_storage<Eigen::Ref<MatType,Options,Stride> &>
9494
{
95-
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType> StorageType;
95+
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType,Options,Stride> StorageType;
9696
typedef aligned_storage<
9797
::boost::python::detail::referent_size<StorageType&>::value
9898
> type;
@@ -166,10 +166,10 @@ namespace boost { namespace python { namespace converter {
166166

167167
#undef RVALUE_FROM_PYTHON_DATA_INIT
168168

169-
template<typename MatType>
170-
struct rvalue_from_python_data<Eigen::Ref<MatType> &> : rvalue_from_python_storage<Eigen::Ref<MatType> &>
169+
template<typename MatType, int Options, typename Stride>
170+
struct rvalue_from_python_data<Eigen::Ref<MatType,Options,Stride> &> : rvalue_from_python_storage<Eigen::Ref<MatType,Options,Stride> &>
171171
{
172-
typedef Eigen::Ref<MatType> T;
172+
typedef Eigen::Ref<MatType,Options,Stride> T;
173173

174174
# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
175175
&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \
@@ -196,7 +196,7 @@ namespace boost { namespace python { namespace converter {
196196
// Destroys any object constructed in the storage.
197197
~rvalue_from_python_data()
198198
{
199-
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType> StorageType;
199+
typedef ::eigenpy::details::referent_storage_eigen_ref<MatType, Options,Stride> StorageType;
200200
if (this->stage1.convertible == this->storage.bytes)
201201
static_cast<StorageType *>((void *)this->storage.bytes)->~StorageType();
202202
}
@@ -418,10 +418,10 @@ namespace eigenpy
418418

419419
#if EIGEN_VERSION_AT_LEAST(3,2,0)
420420

421-
template<typename MatType, int Options, typename StrideType>
422-
struct EigenFromPy<Eigen::Ref<MatType,Options,StrideType> >
421+
template<typename MatType, int Options, typename Stride>
422+
struct EigenFromPy<Eigen::Ref<MatType,Options,Stride> >
423423
{
424-
typedef Eigen::Ref<MatType,Options,StrideType> RefType;
424+
typedef Eigen::Ref<MatType,Options,Stride> RefType;
425425
typedef typename MatType::Scalar Scalar;
426426

427427
/// \brief Determine if pyObj can be converted into a MatType object

include/eigenpy/numpy-allocator.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ namespace eigenpy
5252

5353
#if EIGEN_VERSION_AT_LEAST(3,2,0)
5454

55-
template<typename MatType>
56-
struct NumpyAllocator<Eigen::Ref<MatType> > : NumpyAllocator<MatType &>
55+
template<typename MatType, int Options, typename Stride>
56+
struct NumpyAllocator<Eigen::Ref<MatType,Options,Stride> > : NumpyAllocator<MatType &>
5757
{
5858
};
5959

@@ -81,8 +81,8 @@ namespace eigenpy
8181

8282
#if EIGEN_VERSION_AT_LEAST(3,2,0)
8383

84-
template<typename MatType>
85-
struct NumpyAllocator<const Eigen::Ref<const MatType> > : NumpyAllocator<const MatType &>
84+
template<typename MatType, int Options, typename Stride>
85+
struct NumpyAllocator<const Eigen::Ref<const MatType,Options,Stride> > : NumpyAllocator<const MatType &>
8686
{
8787
};
8888

0 commit comments

Comments
 (0)