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
abc9fae9
Commit
abc9fae9
authored
2 years ago
by
Wilson Jallet
Browse files
Options
Downloads
Patches
Plain Diff
std-vector: try setting elements to zero
* does not work properly
parent
51d1672e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unittest/python/test_std_vector.py
+23
-3
23 additions, 3 deletions
unittest/python/test_std_vector.py
unittest/vector.cpp
+15
-2
15 additions, 2 deletions
unittest/vector.cpp
with
38 additions
and
5 deletions
unittest/python/test_std_vector.py
+
23
−
3
View file @
abc9fae9
...
...
@@ -8,7 +8,7 @@ np.random.seed(0)
l1
=
[
np
.
random
.
randn
(
3
),
np
.
random
.
randn
(
2
)]
l2
=
eigenpy
.
StdVec_VectorXd
(
l1
)
l3
=
[
np
.
random
.
randn
(
2
,
2
),
np
.
random
.
randn
(
1
,
2
),
np
.
random
.
randn
(
2
,
6
)]
l3
=
[
np
.
random
.
randn
(
2
,
2
),
np
.
random
.
randn
(
3
,
1
),
np
.
random
.
randn
(
4
,
2
)]
def
checkAllValues
(
li1
,
li2
):
...
...
@@ -33,11 +33,31 @@ print()
l4
=
[
np
.
random
.
randn
(
3
,
3
)
for
_
in
range
(
4
)]
assert
"
StdVec_Mat3d
"
in
printVectorOf3x3
.
__doc__
printVectorOf3x3
(
l4
)
print
()
l4_copy
=
copyStdVector
(
l4
)
assert
isinstance
(
l4_copy
,
eigenpy
.
StdVec_MatrixXd
)
print
(
l4_copy
)
l4_copy2
=
vector
.
copyStdVec_3x3
(
l4
)
assert
isinstance
(
l4_copy2
,
vector
.
StdVec_Mat3d
)
print
(
l4_copy2
)
def
checkZero
(
l
):
for
x
in
l
:
assert
np
.
allclose
(
x
,
0.
),
"
x = {}
"
.
format
(
x
)
print
(
"
l1:
"
)
vector
.
setZero
(
l1
)
print
(
l1
)
checkZero
(
l1
)
print
(
"
l2:
"
)
l2_py
=
l2
.
tolist
()
vector
.
setZero
(
l2_py
)
print
(
l2_py
)
checkZero
(
l2_py
)
print
(
"
l3:
"
)
vector
.
setZero
(
l3
)
checkZero
(
l3
)
This diff is collapsed.
Click to expand it.
unittest/vector.cpp
+
15
−
2
View file @
abc9fae9
...
...
@@ -18,10 +18,19 @@ std::vector<MatType> copy(const std::vector<MatType> &Ms) {
return
out
;
}
template
<
typename
MatType
>
void
setZero
(
std
::
vector
<
MatType
>
Ms
)
{
for
(
std
::
size_t
i
=
0
;
i
<
Ms
.
size
();
i
++
)
{
Ms
[
i
].
setZero
();
}
}
BOOST_PYTHON_MODULE
(
vector
)
{
namespace
bp
=
boost
::
python
;
using
namespace
eigenpy
;
eigenpy
::
enableEigenPy
();
enableEigenPy
();
bp
::
def
(
"printVectorOfMatrix"
,
printVectorOfMatrix
<
Eigen
::
VectorXd
>
);
bp
::
def
(
"printVectorOfMatrix"
,
printVectorOfMatrix
<
Eigen
::
MatrixXd
>
);
...
...
@@ -29,8 +38,12 @@ BOOST_PYTHON_MODULE(vector) {
bp
::
def
(
"copyStdVector"
,
copy
<
Eigen
::
MatrixXd
>
);
bp
::
def
(
"copyStdVector"
,
copy
<
Eigen
::
VectorXd
>
);
eigenpy
::
StdVectorPythonVisitor
<
std
::
vector
<
Eigen
::
Matrix3d
>>::
expose
(
StdVectorPythonVisitor
<
std
::
vector
<
Eigen
::
Matrix3d
>>::
expose
(
"StdVec_Mat3d"
,
"3D matrices."
);
bp
::
def
(
"printVectorOf3x3"
,
printVectorOfMatrix
<
Eigen
::
Matrix3d
>
);
bp
::
def
(
"copyStdVec_3x3"
,
copy
<
Eigen
::
Matrix3d
>
,
bp
::
args
(
"mats"
));
typedef
Eigen
::
Ref
<
Eigen
::
MatrixXd
>
MatRef
;
StdVectorPythonVisitor
<
std
::
vector
<
MatRef
>
,
true
>::
expose
(
"StdVec_MatRef"
);
bp
::
def
(
"setZero"
,
setZero
<
MatRef
>
,
"Sets the coeff in [0,0] to 0."
);
}
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