Verified Commit 68afcbfd authored by Justin Carpentier's avatar Justin Carpentier
Browse files

serialization: serialize Eigen::array

parent 0cd24f52
......@@ -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);
}
}
}
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment