Skip to content

Commit 0cd5f10

Browse files
committed
core: add template AlignmentValue to MapNumpy
1 parent a110f41 commit 0cd5f10

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

include/eigenpy/map.hpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
namespace eigenpy
1414
{
15-
template<typename MatType, typename InputScalar, typename Stride, bool IsVector = MatType::IsVectorAtCompileTime>
15+
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride, bool IsVector = MatType::IsVectorAtCompileTime>
1616
struct MapNumpyTraits {};
1717

1818
/* Wrap a numpy::array with an Eigen::Map. No memory copy. */
19-
template<typename MatType, typename InputScalar, typename Stride = typename StrideType<MatType>::type>
19+
template<typename MatType, typename InputScalar, int AlignmentValue = EIGENPY_NO_ALIGNMENT_VALUE, typename Stride = typename StrideType<MatType>::type>
2020
struct MapNumpy
2121
{
22-
typedef MapNumpyTraits<MatType, InputScalar, Stride> Impl;
22+
typedef MapNumpyTraits<MatType, InputScalar, AlignmentValue, Stride> Impl;
2323
typedef typename Impl::EigenMap EigenMap;
2424

2525
static EigenMap map(PyArrayObject* pyArray);
@@ -33,11 +33,11 @@ namespace eigenpy
3333

3434
namespace eigenpy
3535
{
36-
template<typename MatType, typename InputScalar, typename Stride>
37-
struct MapNumpyTraits<MatType,InputScalar,Stride,false>
36+
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride>
37+
struct MapNumpyTraits<MatType,InputScalar,AlignmentValue,Stride,false>
3838
{
3939
typedef Eigen::Matrix<InputScalar,MatType::RowsAtCompileTime,MatType::ColsAtCompileTime,MatType::Options> EquivalentInputMatrixType;
40-
typedef Eigen::Map<EquivalentInputMatrixType,EIGENPY_DEFAULT_ALIGNMENT_VALUE,Stride> EigenMap;
40+
typedef Eigen::Map<EquivalentInputMatrixType,AlignmentValue,Stride> EigenMap;
4141

4242
static EigenMap mapImpl(PyArrayObject* pyArray)
4343
{
@@ -103,15 +103,21 @@ namespace eigenpy
103103

104104
InputScalar* pyData = reinterpret_cast<InputScalar*>(PyArray_DATA(pyArray));
105105

106+
std::cout << "OuterStrideAtCompileTime: " << OuterStrideAtCompileTime << std::endl;
107+
std::cout << "InnerStrideAtCompileTime: " << InnerStrideAtCompileTime << std::endl;
108+
std::cout << "rows: " << rows << std::endl;
109+
std::cout << "cols: " << cols << std::endl;
110+
std::cout << "inner_stride: " << inner_stride << std::endl;
111+
std::cout << "outer_stride: " << outer_stride << std::endl;
106112
return EigenMap(pyData, rows, cols, stride);
107113
}
108114
};
109115

110-
template<typename MatType, typename InputScalar, typename Stride>
111-
struct MapNumpyTraits<MatType,InputScalar,Stride,true>
116+
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride>
117+
struct MapNumpyTraits<MatType,InputScalar,AlignmentValue,Stride,true>
112118
{
113119
typedef Eigen::Matrix<InputScalar,MatType::RowsAtCompileTime,MatType::ColsAtCompileTime,MatType::Options> EquivalentInputMatrixType;
114-
typedef Eigen::Map<EquivalentInputMatrixType,EIGENPY_DEFAULT_ALIGNMENT_VALUE,Stride> EigenMap;
120+
typedef Eigen::Map<EquivalentInputMatrixType,AlignmentValue,Stride> EigenMap;
115121

116122
static EigenMap mapImpl(PyArrayObject* pyArray)
117123
{
@@ -139,9 +145,9 @@ namespace eigenpy
139145
}
140146
};
141147

142-
template<typename MatType, typename InputScalar, typename Stride>
143-
typename MapNumpy<MatType,InputScalar,Stride>::EigenMap
144-
MapNumpy<MatType,InputScalar,Stride>::map(PyArrayObject * pyArray)
148+
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride>
149+
typename MapNumpy<MatType,InputScalar,AlignmentValue,Stride>::EigenMap
150+
MapNumpy<MatType,InputScalar,AlignmentValue,Stride>::map(PyArrayObject * pyArray)
145151
{
146152
return Impl::mapImpl(pyArray);
147153
}

0 commit comments

Comments
 (0)