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
pinocchio
Commits
68afcbfd
Verified
Commit
68afcbfd
authored
Dec 14, 2019
by
Justin Carpentier
Browse files
serialization: serialize Eigen::array
parent
0cd24f52
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/serialization/eigen.hpp
View file @
68afcbfd
...
...
@@ -25,11 +25,12 @@
THE SOFTWARE.
*/
#ifndef __pinocchio_serialization_eigen_matrix_hpp__
#define __pinocchio_serialization_eigen_matrix_hpp__
#include
<Eigen/Dense>
#include
"pinocchio/math/tensor.hpp"
#include
<boost/serialization/split_free.hpp>
#include
<boost/serialization/vector.hpp>
...
...
@@ -63,6 +64,24 @@ namespace boost
{
split_free
(
ar
,
m
,
version
);
}
template
<
class
Archive
,
typename
_IndexType
,
std
::
size_t
_NumIndices
>
void
save
(
Archive
&
ar
,
const
Eigen
::
array
<
_IndexType
,
_NumIndices
>
&
a
,
const
unsigned
int
/*version*/
)
{
ar
&
make_nvp
(
"array"
,
make_array
(
&
a
.
front
(),
_NumIndices
));
}
template
<
class
Archive
,
typename
_IndexType
,
std
::
size_t
_NumIndices
>
void
load
(
Archive
&
ar
,
Eigen
::
array
<
_IndexType
,
_NumIndices
>
&
a
,
const
unsigned
int
/*version*/
)
{
ar
>>
make_nvp
(
"array"
,
make_array
(
&
a
.
front
(),
_NumIndices
));
}
template
<
class
Archive
,
typename
_IndexType
,
std
::
size_t
_NumIndices
>
void
serialize
(
Archive
&
ar
,
Eigen
::
array
<
_IndexType
,
_NumIndices
>
&
a
,
const
unsigned
int
version
)
{
split_free
(
ar
,
a
,
version
);
}
}
}
...
...
unittest/serialization.cpp
View file @
68afcbfd
...
...
@@ -104,6 +104,9 @@ BOOST_AUTO_TEST_CASE(test_eigen_serialization)
Eigen
::
VectorXd
Vec
=
Eigen
::
VectorXd
::
Random
(
num_rows
*
num_cols
);
generic_test
(
Vec
,
TEST_SERIALIZATION_FOLDER
"/eigen_vector"
,
"vector"
);
Eigen
::
array
<
Eigen
::
DenseIndex
,
array_size
>
array
=
{
1
,
2
,
3
};
generic_test
(
array
,
TEST_SERIALIZATION_FOLDER
"/eigen_array"
,
"ar"
);
}
BOOST_AUTO_TEST_CASE
(
test_spatial_serialization
)
...
...
Write
Preview
Supports
Markdown
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