Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eigenpy
Commits
cd361037
Verified
Commit
cd361037
authored
Apr 19, 2022
by
Justin Carpentier
Browse files
core: fix strides for Eigen::Ref
parent
19f41401
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/eigenpy/numpy-allocator.hpp
View file @
cd361037
...
...
@@ -70,9 +70,15 @@ struct NumpyAllocator<Eigen::Ref<MatType, Options, Stride> > {
if
(
NumpyType
::
sharedMemory
())
{
const
int
Scalar_type_code
=
Register
::
getTypeCode
<
Scalar
>
();
Eigen
::
DenseIndex
inner_stride
=
mat
.
innerStride
(),
outer_stride
=
mat
.
outerStride
();
const
int
elsize
=
call_PyArray_DescrFromType
(
Scalar_type_code
)
->
elsize
;
npy_intp
strides
[
2
]
=
{
elsize
*
inner_stride
,
elsize
*
outer_stride
};
PyArrayObject
*
pyArray
=
(
PyArrayObject
*
)
call_PyArray_New
(
getPyArrayType
(),
static_cast
<
int
>
(
nd
),
shape
,
Scalar_type_code
,
mat
.
data
(),
NPY_ARRAY_MEMORY_CONTIGUOUS
|
NPY_ARRAY_ALIGNED
);
strides
,
mat
.
data
(),
NPY_ARRAY_MEMORY_CONTIGUOUS
|
NPY_ARRAY_ALIGNED
);
return
pyArray
;
}
else
{
...
...
@@ -125,9 +131,15 @@ struct NumpyAllocator<const Eigen::Ref<const MatType, Options, Stride> > {
if
(
NumpyType
::
sharedMemory
())
{
const
int
Scalar_type_code
=
Register
::
getTypeCode
<
Scalar
>
();
Eigen
::
DenseIndex
inner_stride
=
mat
.
innerStride
(),
outer_stride
=
mat
.
outerStride
();
const
int
elsize
=
call_PyArray_DescrFromType
(
Scalar_type_code
)
->
elsize
;
npy_intp
strides
[
2
]
=
{
elsize
*
inner_stride
,
elsize
*
outer_stride
};
PyArrayObject
*
pyArray
=
(
PyArrayObject
*
)
call_PyArray_New
(
getPyArrayType
(),
static_cast
<
int
>
(
nd
),
shape
,
Scalar_type_code
,
const_cast
<
Scalar
*>
(
mat
.
data
()),
strides
,
const_cast
<
Scalar
*>
(
mat
.
data
()),
NPY_ARRAY_MEMORY_CONTIGUOUS_RO
|
NPY_ARRAY_ALIGNED
);
return
pyArray
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment