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
bf7840fe
Commit
bf7840fe
authored
2 years ago
by
Wilson Jallet
Browse files
Options
Downloads
Patches
Plain Diff
unittest/eigen_ref: rename asRef overload to "getRefToStatic"
& update its docstring
parent
b3b2aafb
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
unittest/eigen_ref.cpp
+4
-5
4 additions, 5 deletions
unittest/eigen_ref.cpp
unittest/python/test_eigen_ref.py
+3
-2
3 additions, 2 deletions
unittest/python/test_eigen_ref.py
with
7 additions
and
7 deletions
unittest/eigen_ref.cpp
+
4
−
5
View file @
bf7840fe
...
@@ -58,8 +58,9 @@ void fill(Eigen::Ref<MatType> mat, const typename MatType::Scalar& value) {
...
@@ -58,8 +58,9 @@ void fill(Eigen::Ref<MatType> mat, const typename MatType::Scalar& value) {
mat
.
fill
(
value
);
mat
.
fill
(
value
);
}
}
/// Get ref to a static matrix of size ( @p rows, @p cols )
template
<
typename
MatType
>
template
<
typename
MatType
>
Eigen
::
Ref
<
MatType
>
asRef
(
const
int
rows
,
const
int
cols
)
{
Eigen
::
Ref
<
MatType
>
getRefToStatic
(
const
int
rows
,
const
int
cols
)
{
static
MatType
mat
(
rows
,
cols
);
static
MatType
mat
(
rows
,
cols
);
std
::
cout
<<
"create ref to matrix of size ("
<<
rows
<<
","
<<
cols
<<
")
\n
"
;
std
::
cout
<<
"create ref to matrix of size ("
<<
rows
<<
","
<<
cols
<<
")
\n
"
;
return
mat
;
return
mat
;
...
@@ -113,10 +114,8 @@ BOOST_PYTHON_MODULE(eigen_ref) {
...
@@ -113,10 +114,8 @@ BOOST_PYTHON_MODULE(eigen_ref) {
bp
::
def
(
"fillVec"
,
fill
<
VectorXd
>
);
bp
::
def
(
"fillVec"
,
fill
<
VectorXd
>
);
bp
::
def
(
"fill"
,
fill
<
MatrixXd
>
);
bp
::
def
(
"fill"
,
fill
<
MatrixXd
>
);
bp
::
def
<
Eigen
::
Ref
<
MatrixXd
>
(
*
)(
const
int
,
const
int
)
>
(
"asRef"
,
bp
::
def
(
"getRefToStatic"
,
getRefToStatic
<
MatrixXd
>
);
asRef
<
MatrixXd
>
);
bp
::
def
(
"asRef"
,
asRef
<
MatrixXd
>
);
bp
::
def
<
Eigen
::
Ref
<
MatrixXd
>
(
*
)(
Eigen
::
Ref
<
MatrixXd
>
)
>
(
"asRef"
,
asRef
<
MatrixXd
>
);
bp
::
def
(
"asConstRef"
,
asConstRef
<
MatrixXd
>
);
bp
::
def
(
"asConstRef"
,
asConstRef
<
MatrixXd
>
);
bp
::
def
(
"getBlock"
,
&
getBlock
<
MatrixXd
>
);
bp
::
def
(
"getBlock"
,
&
getBlock
<
MatrixXd
>
);
...
...
This diff is collapsed.
Click to expand it.
unittest/python/test_eigen_ref.py
+
3
−
2
View file @
bf7840fe
import
numpy
as
np
import
numpy
as
np
from
eigen_ref
import
(
from
eigen_ref
import
(
printMatrix
,
printMatrix
,
getRefToStatic
,
asRef
,
asRef
,
asConstRef
,
asConstRef
,
fill
,
fill
,
...
@@ -30,11 +31,11 @@ def test_create_ref_to_static(mat):
...
@@ -30,11 +31,11 @@ def test_create_ref_to_static(mat):
# create ref to static:
# create ref to static:
print
()
print
()
print
(
"
[asRef(int, int)]
"
)
print
(
"
[asRef(int, int)]
"
)
A_ref
=
asRef
(
mat
.
shape
[
0
],
mat
.
shape
[
1
])
A_ref
=
getRefToStatic
(
mat
.
shape
[
0
],
mat
.
shape
[
1
])
A_ref
.
fill
(
1.0
)
A_ref
.
fill
(
1.0
)
A_ref
[
0
,
1
]
=
-
1.0
A_ref
[
0
,
1
]
=
-
1.0
print
(
"
make second reference:
"
)
print
(
"
make second reference:
"
)
A_ref2
=
asRef
(
mat
.
shape
[
0
],
mat
.
shape
[
1
])
A_ref2
=
getRefToStatic
(
mat
.
shape
[
0
],
mat
.
shape
[
1
])
print
(
A_ref2
)
print
(
A_ref2
)
assert
np
.
array_equal
(
A_ref
,
A_ref2
)
assert
np
.
array_equal
(
A_ref
,
A_ref2
)
...
...
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