Skip to content
GitLab
Menu
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
fa17abcb
Verified
Commit
fa17abcb
authored
Dec 10, 2019
by
Justin Carpentier
Browse files
core: fix issue when converting form Matrix to Eigen::MatrixBase<Matrix>
parent
ac25cd42
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/eigenpy/details.hpp
View file @
fa17abcb
...
...
@@ -49,6 +49,37 @@ struct implicit<Eigen::MatrixBase<MatType>,MatType>
}
};
template
<
class
MatType
>
struct
implicit
<
MatType
,
Eigen
::
MatrixBase
<
MatType
>
>
{
typedef
MatType
Source
;
typedef
Eigen
::
MatrixBase
<
MatType
>
Target
;
static
void
*
convertible
(
PyObject
*
obj
)
{
// Find a converter which can produce a Source instance from
// obj. The user has told us that Source can be converted to
// Target, and instantiating construct() below, ensures that
// at compile-time.
return
implicit_rvalue_convertible_from_python
(
obj
,
registered
<
Source
>::
converters
)
?
obj
:
0
;
}
static
void
construct
(
PyObject
*
obj
,
rvalue_from_python_stage1_data
*
data
)
{
void
*
storage
=
((
rvalue_from_python_storage
<
Source
>*
)
data
)
->
storage
.
bytes
;
arg_from_python
<
Source
>
get_source
(
obj
);
bool
convertible
=
get_source
.
convertible
();
BOOST_VERIFY
(
convertible
);
new
(
storage
)
Source
(
get_source
());
// record successful construction
data
->
convertible
=
storage
;
}
};
}}}
// namespace boost::python::converter
#define GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
...
...
unittest/python/test_matrix.py
View file @
fa17abcb
...
...
@@ -32,6 +32,10 @@ if verbose: print("===> From Py to Eigen::MatrixXd")
if
verbose
:
print
(
"===> From Py to Eigen::MatrixXd"
)
Mref
=
np
.
reshape
(
np
.
matrix
(
range
(
64
),
np
.
double
),[
8
,
8
])
# Test base function
Mref_from_base
=
eigenpy
.
base
(
Mref
)
assert
(
np
.
array_equal
(
Mref
,
Mref_from_base
)
);
if
verbose
:
print
(
"===> Matrix 8x8"
)
M
=
Mref
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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