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
9e606508
Verified
Commit
9e606508
authored
5 years ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
test: add test for Eigen::Ref
parent
1fe6a61c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
unittest/CMakeLists.txt
+1
-0
1 addition, 0 deletions
unittest/CMakeLists.txt
unittest/eigen_ref.cpp
+12
-4
12 additions, 4 deletions
unittest/eigen_ref.cpp
unittest/python/test_eigen_ref.py
+16
-0
16 additions, 0 deletions
unittest/python/test_eigen_ref.py
with
29 additions
and
4 deletions
unittest/CMakeLists.txt
+
1
−
0
View file @
9e606508
...
...
@@ -42,6 +42,7 @@ ADD_PYTHON_UNIT_TEST("py-matrix" "unittest/python/test_matrix.py" "unittest")
ADD_PYTHON_UNIT_TEST
(
"py-geometry"
"unittest/python/test_geometry.py"
"unittest"
)
ADD_PYTHON_UNIT_TEST
(
"py-complex"
"unittest/python/test_complex.py"
"unittest"
)
ADD_PYTHON_UNIT_TEST
(
"py-return-by-ref"
"unittest/python/test_return_by_ref.py"
"unittest"
)
ADD_PYTHON_UNIT_TEST
(
"py-eigen-ref"
"unittest/python/test_eigen_ref.py"
"unittest"
)
ADD_PYTHON_UNIT_TEST
(
"py-switch"
"unittest/python/test_switch.py"
"python/eigenpy"
)
SET_TESTS_PROPERTIES
(
"py-switch"
PROPERTIES DEPENDS
${
PYWRAP
}
)
...
...
This diff is collapsed.
Click to expand it.
unittest/eigen_ref.cpp
+
12
−
4
View file @
9e606508
...
...
@@ -10,7 +10,7 @@ using namespace Eigen;
using
namespace
eigenpy
;
template
<
typename
MatType
>
void
printMatrix
(
const
Eigen
::
Ref
<
MatType
>
&
mat
)
void
printMatrix
(
const
Eigen
::
Ref
<
const
MatType
>
mat
)
{
if
(
MatType
::
IsVectorAtCompileTime
)
std
::
cout
<<
"isVector"
<<
std
::
endl
;
...
...
@@ -19,7 +19,7 @@ void printMatrix(const Eigen::Ref<MatType> & mat)
}
template
<
typename
VecType
>
void
printVector
(
const
Eigen
::
Ref
<
VecType
>
&
vec
)
void
printVector
(
const
Eigen
::
Ref
<
const
VecType
>
&
vec
)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY
(
VecType
);
printMatrix
(
vec
);
...
...
@@ -28,9 +28,13 @@ void printVector(const Eigen::Ref<VecType> & vec)
template
<
typename
MatType
>
void
setOnes
(
Eigen
::
Ref
<
MatType
>
mat
)
{
printMatrix
(
mat
);
mat
.
setOnes
();
printMatrix
(
mat
);
}
template
<
typename
MatType
>
void
fill
(
Eigen
::
Ref
<
MatType
>
mat
,
const
typename
MatType
::
Scalar
&
value
)
{
mat
.
fill
(
value
);
}
BOOST_PYTHON_MODULE
(
eigen_ref
)
...
...
@@ -48,4 +52,8 @@ BOOST_PYTHON_MODULE(eigen_ref)
bp
::
def
(
"setOnes"
,
setOnes
<
Vector3d
>
);
bp
::
def
(
"setOnes"
,
setOnes
<
VectorXd
>
);
bp
::
def
(
"setOnes"
,
setOnes
<
MatrixXd
>
);
bp
::
def
(
"fillVec3"
,
fill
<
Vector3d
>
);
bp
::
def
(
"fillVec"
,
fill
<
VectorXd
>
);
bp
::
def
(
"fill"
,
fill
<
MatrixXd
>
);
}
This diff is collapsed.
Click to expand it.
unittest/python/test_eigen_ref.py
0 → 100644
+
16
−
0
View file @
9e606508
import
numpy
as
np
from
eigen_ref
import
*
def
test
(
mat
):
printMatrix
(
mat
)
fill
(
mat
,
1.
)
printMatrix
(
mat
)
assert
np
.
array_equal
(
mat
,
np
.
full
(
mat
.
shape
,
1.
))
rows
=
10
cols
=
30
mat
=
np
.
array
(
np
.
zeros
((
rows
,
cols
)))
test
(
mat
)
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