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
f15dab93
Verified
Commit
f15dab93
authored
Aug 24, 2020
by
Justin Carpentier
Browse files
test: test to-python for Eigen::Ref
parent
115ed938
Pipeline
#10829
passed with stage
in 16 minutes and 24 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
unittest/eigen_ref.cpp
View file @
f15dab93
...
...
@@ -37,6 +37,14 @@ void fill(Eigen::Ref<MatType> mat, const typename MatType::Scalar & value)
mat
.
fill
(
value
);
}
template
<
typename
MatType
>
Eigen
::
Ref
<
MatType
>
asRef
(
const
int
rows
,
const
int
cols
)
{
static
MatType
mat
(
rows
,
cols
);
std
::
cout
<<
"mat:
\n
"
<<
mat
<<
std
::
endl
;
return
mat
;
}
BOOST_PYTHON_MODULE
(
eigen_ref
)
{
namespace
bp
=
boost
::
python
;
...
...
@@ -56,4 +64,6 @@ BOOST_PYTHON_MODULE(eigen_ref)
bp
::
def
(
"fillVec3"
,
fill
<
Vector3d
>
);
bp
::
def
(
"fillVec"
,
fill
<
VectorXd
>
);
bp
::
def
(
"fill"
,
fill
<
MatrixXd
>
);
bp
::
def
(
"asRef"
,
asRef
<
MatrixXd
>
);
}
unittest/python/test_eigen_ref.py
View file @
f15dab93
...
...
@@ -8,6 +8,16 @@ def test(mat):
printMatrix
(
mat
)
assert
np
.
array_equal
(
mat
,
np
.
full
(
mat
.
shape
,
1.
))
A_ref
=
asRef
(
mat
.
shape
[
0
],
mat
.
shape
[
1
])
A_ref
.
fill
(
1.
)
A_ref2
=
asRef
(
mat
.
shape
[
0
],
mat
.
shape
[
1
])
assert
np
.
array_equal
(
A_ref
,
A_ref2
)
A_ref2
.
fill
(
0
)
assert
np
.
array_equal
(
A_ref
,
A_ref2
)
rows
=
10
cols
=
30
...
...
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