Skip to content

Commit 471b8d6

Browse files
committed
core: handle RowMajor case for Eigen::Ref
1 parent a9653f1 commit 471b8d6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

include/eigenpy/numpy-allocator.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ struct NumpyAllocator<Eigen::Ref<MatType, Options, Stride> > {
7070

7171
if (NumpyType::sharedMemory()) {
7272
const int Scalar_type_code = Register::getTypeCode<Scalar>();
73-
Eigen::DenseIndex inner_stride = mat.innerStride(),
74-
outer_stride = mat.outerStride();
73+
74+
Eigen::DenseIndex inner_stride = MatType::IsRowMajor ? mat.outerStride()
75+
: mat.innerStride(),
76+
outer_stride = MatType::IsRowMajor ? mat.innerStride()
77+
: mat.outerStride();
7578

7679
const int elsize = call_PyArray_DescrFromType(Scalar_type_code)->elsize;
7780
npy_intp strides[2] = {elsize * inner_stride, elsize * outer_stride};
@@ -131,8 +134,11 @@ struct NumpyAllocator<const Eigen::Ref<const MatType, Options, Stride> > {
131134

132135
if (NumpyType::sharedMemory()) {
133136
const int Scalar_type_code = Register::getTypeCode<Scalar>();
134-
Eigen::DenseIndex inner_stride = mat.innerStride(),
135-
outer_stride = mat.outerStride();
137+
138+
Eigen::DenseIndex inner_stride = MatType::IsRowMajor ? mat.outerStride()
139+
: mat.innerStride(),
140+
outer_stride = MatType::IsRowMajor ? mat.innerStride()
141+
: mat.outerStride();
136142

137143
const int elsize = call_PyArray_DescrFromType(Scalar_type_code)->elsize;
138144
npy_intp strides[2] = {elsize * inner_stride, elsize * outer_stride};

0 commit comments

Comments
 (0)