5 #ifndef __pinocchio_serialization_eigen_matrix_hpp__ 6 #define __pinocchio_serialization_eigen_matrix_hpp__ 9 #include "pinocchio/math/tensor.hpp" 11 #include <boost/serialization/split_free.hpp> 12 #include <boost/serialization/vector.hpp> 13 #include <boost/serialization/array.hpp> 20 template <
class Archive,
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
21 void save(Archive & ar,
const Eigen::Matrix<Scalar,Rows,Cols,Options,MaxRows,MaxCols> & m,
const unsigned int )
23 Eigen::DenseIndex
rows(m.rows()),
cols(m.cols());
24 if (Rows == Eigen::Dynamic)
25 ar & BOOST_SERIALIZATION_NVP(rows);
26 if (Cols == Eigen::Dynamic)
27 ar & BOOST_SERIALIZATION_NVP(cols);
28 ar &
make_nvp(
"data",make_array(m.data(), (size_t)m.size()));
31 template <
class Archive,
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
32 void load(Archive & ar, Eigen::Matrix<Scalar,Rows,Cols,Options,MaxRows,MaxCols> & m,
const unsigned int )
34 Eigen::DenseIndex
rows = Rows,
cols = Cols;
35 if (Rows == Eigen::Dynamic)
36 ar >> BOOST_SERIALIZATION_NVP(rows);
37 if (Cols == Eigen::Dynamic)
38 ar >> BOOST_SERIALIZATION_NVP(cols);
40 ar >>
make_nvp(
"data",make_array(m.data(), (size_t)m.size()));
43 template <
class Archive,
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
44 void serialize(Archive & ar, Eigen::Matrix<Scalar,Rows,Cols,Options,MaxRows,MaxCols> & m,
const unsigned int version)
46 split_free(ar,m,version);
49 template <
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
50 void save(Archive & ar,
const Eigen::Map<PlainObjectBase,MapOptions,StrideType> & m,
const unsigned int )
52 Eigen::DenseIndex rows(m.rows()), cols(m.cols());
53 if (PlainObjectBase::RowsAtCompileTime == Eigen::Dynamic)
54 ar & BOOST_SERIALIZATION_NVP(rows);
55 if (PlainObjectBase::ColsAtCompileTime == Eigen::Dynamic)
56 ar & BOOST_SERIALIZATION_NVP(cols);
57 ar &
make_nvp(
"data",make_array(m.data(), (size_t)m.size()));
60 template <
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
61 void load(Archive & ar, Eigen::Map<PlainObjectBase,MapOptions,StrideType> & m,
const unsigned int )
63 Eigen::DenseIndex rows = PlainObjectBase::RowsAtCompileTime, cols = PlainObjectBase::ColsAtCompileTime;
64 if (PlainObjectBase::RowsAtCompileTime == Eigen::Dynamic)
65 ar >> BOOST_SERIALIZATION_NVP(rows);
66 if (PlainObjectBase::ColsAtCompileTime == Eigen::Dynamic)
67 ar >> BOOST_SERIALIZATION_NVP(cols);
69 ar >>
make_nvp(
"data",make_array(m.data(), (size_t)m.size()));
72 template <
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
73 void serialize(Archive & ar, Eigen::Map<PlainObjectBase,MapOptions,StrideType> & m,
const unsigned int version)
75 split_free(ar,m,version);
78 #if !defined(PINOCCHIO_WITH_EIGEN_TENSOR_MODULE) && ((__cplusplus <= 199711L && EIGEN_COMP_MSVC < 1900) || defined(__CUDACC__) || defined(EIGEN_AVOID_STL_ARRAY)) 79 template <
class Archive,
typename _IndexType, std::
size_t _NumIndices>
85 template <
class Archive,
typename _IndexType, std::
size_t _NumIndices>
91 template <
class Archive,
typename _IndexType, std::
size_t _NumIndices>
94 split_free(ar,a,version);
97 template <
class Archive,
class T, std::
size_t N>
98 void save(Archive& ar,
const std::array<T,N> &
a,
const unsigned int version)
100 typedef std::array<T,N> Array;
101 serialize(ar,const_cast<Array&>(a),version);
104 template <
class Archive,
class T, std::
size_t N>
105 void load(Archive& ar, std::array<T,N> & a,
const unsigned int version)
111 #ifdef PINOCCHIO_WITH_EIGEN_TENSOR_MODULE 113 template <
class Archive,
typename _IndexType,
int _NumIndices>
114 void save(Archive & ar,
const Eigen::DSizes<_IndexType,_NumIndices> & ds,
const unsigned int version)
119 template <
class Archive,
typename _IndexType,
int _NumIndices>
120 void load(Archive & ar, Eigen::DSizes<_IndexType,_NumIndices> & ds,
const unsigned int version)
125 template <
class Archive,
typename _IndexType,
int _NumIndices>
126 void serialize(Archive & ar, Eigen::DSizes<_IndexType,_NumIndices> & ds,
const unsigned int version)
133 template <
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
134 void save(Archive & ar, const ::pinocchio::Tensor<_Scalar,_NumIndices,_Options,_IndexType> &
t,
const unsigned int )
136 typedef ::pinocchio::Tensor<_Scalar,_NumIndices,_Options,_IndexType> Tensor;
137 const typename Tensor::Dimensions & dimensions = t.dimensions();
139 ar & BOOST_SERIALIZATION_NVP(dimensions);
140 ar &
make_nvp(
"data",make_array(t.data(), (size_t)t.size()));
143 template <
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
146 typedef ::pinocchio::Tensor<_Scalar,_NumIndices,_Options,_IndexType> Tensor;
147 typename Tensor::Dimensions dimensions;
149 ar >> BOOST_SERIALIZATION_NVP(dimensions);
155 template <
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
158 split_free(ar,t,version);
164 #endif // ifndef __pinocchio_serialization_eigen_matrix_hpp__
void save(Archive &ar, const hpp::fcl::Contact &contact, const unsigned int)
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T & front()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
EIGEN_DEVICE_FUNC void resize(const Eigen::array< Index, NumIndices > &dimensions)
void load(Archive &ar, hpp::fcl::Contact &contact, const unsigned int)
const nvp< typename pinocchio::container::aligned_vector< T >::vector_base > make_nvp(const char *name, pinocchio::container::aligned_vector< T > &t)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const