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
e0c48bf7
Unverified
Commit
e0c48bf7
authored
6 years ago
by
Justin Carpentier
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #37 from jcarpent/devel
Register Eigen::MatrixBase
parents
aaa031dc
ce9e361c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/eigenpy/details.hpp
+30
-8
30 additions, 8 deletions
include/eigenpy/details.hpp
unittest/matrix.cpp
+10
-0
10 additions, 0 deletions
unittest/matrix.cpp
with
40 additions
and
8 deletions
include/eigenpy/details.hpp
+
30
−
8
View file @
e0c48bf7
...
...
@@ -183,13 +183,6 @@ namespace eigenpy
template
<
typename
MatType
>
struct
EigenFromPy
{
EigenFromPy
()
{
bp
::
converter
::
registry
::
push_back
(
reinterpret_cast
<
void
*
(
*
)(
_object
*
)
>
(
&
convertible
),
&
construct
,
bp
::
type_id
<
MatType
>
());
}
// Determine if obj_ptr can be converted in a Eigenvec
static
void
*
convertible
(
PyArrayObject
*
obj_ptr
)
{
...
...
@@ -330,6 +323,34 @@ namespace eigenpy
enableEigenPySpecific
<
MatType
>
();
}
template
<
typename
MatType
>
struct
EigenFromPyConverter
{
static
void
registration
()
{
bp
::
converter
::
registry
::
push_back
(
reinterpret_cast
<
void
*
(
*
)(
_object
*
)
>
(
&
EigenFromPy
<
MatType
>::
convertible
),
&
EigenFromPy
<
MatType
>::
construct
,
bp
::
type_id
<
MatType
>
());
// Add also conversion to Eigen::MatrixBase<MatType>
bp
::
converter
::
registry
::
push_back
(
reinterpret_cast
<
void
*
(
*
)(
_object
*
)
>
(
&
EigenFromPy
<
MatType
>::
convertible
),
&
EigenFromPy
<
MatType
>::
construct
,
bp
::
type_id
<
Eigen
::
MatrixBase
<
MatType
>
>
());
}
};
template
<
typename
MatType
>
struct
EigenFromPyConverter
<
eigenpy
::
Ref
<
MatType
>
>
{
static
void
registration
()
{
bp
::
converter
::
registry
::
push_back
(
reinterpret_cast
<
void
*
(
*
)(
_object
*
)
>
(
&
EigenFromPy
<
MatType
>::
convertible
),
&
EigenFromPy
<
MatType
>::
construct
,
bp
::
type_id
<
MatType
>
());
}
};
template
<
typename
MatType
>
void
enableEigenPySpecific
()
{
...
...
@@ -337,7 +358,8 @@ namespace eigenpy
if
(
check_registration
<
MatType
>
())
return
;
bp
::
to_python_converter
<
MatType
,
EigenToPy
<
MatType
>
>
();
EigenFromPy
<
MatType
>
();
EigenFromPyConverter
<
MatType
>::
registration
();
}
}
// namespace eigenpy
...
...
This diff is collapsed.
Click to expand it.
unittest/matrix.cpp
+
10
−
0
View file @
e0c48bf7
...
...
@@ -72,8 +72,15 @@ Eigen::MatrixXd reflex(const MatType & M, bool verbose)
return
Eigen
::
MatrixXd
(
M
);
}
template
<
typename
MatrixDerived
>
MatrixDerived
base
(
const
Eigen
::
MatrixBase
<
MatrixDerived
>
&
m
)
{
return
m
.
derived
();
}
BOOST_PYTHON_MODULE
(
matrix
)
{
using
namespace
Eigen
;
namespace
bp
=
boost
::
python
;
eigenpy
::
enableEigenPy
();
...
...
@@ -92,4 +99,7 @@ BOOST_PYTHON_MODULE(matrix)
bp
::
def
(
"emptyVector"
,
emptyVector
);
bp
::
def
(
"emptyMatrix"
,
emptyMatrix
);
bp
::
def
(
"base"
,
base
<
VectorXd
>
);
bp
::
def
(
"base"
,
base
<
MatrixXd
>
);
}
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