Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
eigenpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
eigenpy
Commits
73212cc8
Verified
Commit
73212cc8
authored
4 years ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
core: add option to swap dimensions in case of np.array of single dimension
parent
9aabfab7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/eigenpy/numpy-map.hpp
+22
-10
22 additions, 10 deletions
include/eigenpy/numpy-map.hpp
with
22 additions
and
10 deletions
include/eigenpy/numpy-map.hpp
+
22
−
10
View file @
73212cc8
...
...
@@ -22,7 +22,7 @@ namespace eigenpy
typedef
NumpyMapTraits
<
MatType
,
InputScalar
,
AlignmentValue
,
Stride
>
Impl
;
typedef
typename
Impl
::
EigenMap
EigenMap
;
static
EigenMap
map
(
PyArrayObject
*
pyArray
);
static
EigenMap
map
(
PyArrayObject
*
pyArray
,
bool
swap_dimensions
=
false
);
};
}
// namespace eigenpy
...
...
@@ -39,7 +39,7 @@ namespace eigenpy
typedef
Eigen
::
Matrix
<
InputScalar
,
MatType
::
RowsAtCompileTime
,
MatType
::
ColsAtCompileTime
,
MatType
::
Options
>
EquivalentInputMatrixType
;
typedef
Eigen
::
Map
<
EquivalentInputMatrixType
,
AlignmentValue
,
Stride
>
EigenMap
;
static
EigenMap
mapImpl
(
PyArrayObject
*
pyArray
)
static
EigenMap
mapImpl
(
PyArrayObject
*
pyArray
,
bool
swap_dimensions
=
false
)
{
enum
{
OuterStrideAtCompileTime
=
Stride
::
OuterStrideAtCompileTime
,
...
...
@@ -77,11 +77,22 @@ namespace eigenpy
assert
(
(
PyArray_DIMS
(
pyArray
)[
0
]
<
INT_MAX
)
&&
(
PyArray_STRIDE
(
pyArray
,
0
)
<
INT_MAX
));
rows
=
(
int
)
PyArray_DIMS
(
pyArray
)[
0
];
cols
=
1
;
inner_stride
=
(
int
)
PyArray_STRIDE
(
pyArray
,
0
)
/
(
int
)
itemsize
;
outer_stride
=
0
;
if
(
!
swap_dimensions
)
{
rows
=
(
int
)
PyArray_DIMS
(
pyArray
)[
0
];
cols
=
1
;
inner_stride
=
(
int
)
PyArray_STRIDE
(
pyArray
,
0
)
/
(
int
)
itemsize
;
outer_stride
=
0
;
}
else
{
rows
=
1
;
cols
=
(
int
)
PyArray_DIMS
(
pyArray
)[
0
];
inner_stride
=
0
;
outer_stride
=
(
int
)
PyArray_STRIDE
(
pyArray
,
0
)
/
(
int
)
itemsize
;
}
}
// Specific care for Eigen::Stride<-1,0>
...
...
@@ -113,8 +124,9 @@ namespace eigenpy
typedef
Eigen
::
Matrix
<
InputScalar
,
MatType
::
RowsAtCompileTime
,
MatType
::
ColsAtCompileTime
,
MatType
::
Options
>
EquivalentInputMatrixType
;
typedef
Eigen
::
Map
<
EquivalentInputMatrixType
,
AlignmentValue
,
Stride
>
EigenMap
;
static
EigenMap
mapImpl
(
PyArrayObject
*
pyArray
)
static
EigenMap
mapImpl
(
PyArrayObject
*
pyArray
,
bool
swap_dimensions
=
false
)
{
EIGENPY_UNUSED_VARIABLE
(
swap_dimensions
);
assert
(
PyArray_NDIM
(
pyArray
)
<=
2
);
int
rowMajor
;
...
...
@@ -141,9 +153,9 @@ namespace eigenpy
template
<
typename
MatType
,
typename
InputScalar
,
int
AlignmentValue
,
typename
Stride
>
typename
NumpyMap
<
MatType
,
InputScalar
,
AlignmentValue
,
Stride
>::
EigenMap
NumpyMap
<
MatType
,
InputScalar
,
AlignmentValue
,
Stride
>::
map
(
PyArrayObject
*
pyArray
)
NumpyMap
<
MatType
,
InputScalar
,
AlignmentValue
,
Stride
>::
map
(
PyArrayObject
*
pyArray
,
bool
swap_dimensions
)
{
return
Impl
::
mapImpl
(
pyArray
);
return
Impl
::
mapImpl
(
pyArray
,
swap_dimensions
);
}
}
// namespace eigenpy
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment