5 #ifndef __pinocchio_serialization_eigen_matrix_hpp__
6 #define __pinocchio_serialization_eigen_matrix_hpp__
11 #include <boost/serialization/split_free.hpp>
12 #include <boost/serialization/vector.hpp>
13 #include <boost/serialization/array.hpp>
19 #if defined PINOCCHIO_WITH_HPP_FCL
20 #include <hpp/fcl/config.hh>
21 #if !HPP_FCL_VERSION_AT_LEAST(3, 0, 0) // hpp-fcl < 3.0.0
22 #define HPP_FCL_SKIP_EIGEN_BOOST_SERIALIZATION
24 #else // hpp-fcl >= 3.0.0
28 #if __GNUC__ >= 7 && __cplusplus >= 201703L
53 #else // !PINOCCHIO_WITH_HPP_FCL
57 #if __GNUC__ >= 7 && __cplusplus >= 201703L
98 const Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & m,
101 Eigen::DenseIndex
rows(
m.rows()),
cols(
m.cols());
103 ar & BOOST_SERIALIZATION_NVP(rows);
105 ar & BOOST_SERIALIZATION_NVP(cols);
106 ar &
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
119 Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & m,
122 Eigen::DenseIndex
rows = Rows,
cols = Cols;
124 ar >> BOOST_SERIALIZATION_NVP(rows);
126 ar >> BOOST_SERIALIZATION_NVP(cols);
127 m.resize(rows, cols);
128 ar >>
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
141 Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> & m,
147 template<
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
150 const Eigen::Map<PlainObjectBase, MapOptions, StrideType> & m,
153 Eigen::DenseIndex
rows(
m.rows()),
cols(
m.cols());
155 ar & BOOST_SERIALIZATION_NVP(rows);
157 ar & BOOST_SERIALIZATION_NVP(cols);
158 ar &
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
161 template<
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
164 Eigen::Map<PlainObjectBase, MapOptions, StrideType> & m,
167 Eigen::DenseIndex
rows = PlainObjectBase::RowsAtCompileTime,
168 cols = PlainObjectBase::ColsAtCompileTime;
170 ar >> BOOST_SERIALIZATION_NVP(rows);
172 ar >> BOOST_SERIALIZATION_NVP(cols);
173 m.resize(rows, cols);
174 ar >>
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
177 template<
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
180 Eigen::Map<PlainObjectBase, MapOptions, StrideType> & m,
186 #if !defined(PINOCCHIO_WITH_EIGEN_TENSOR_MODULE) \
187 && ((__cplusplus <= 199711L && EIGEN_COMP_MSVC < 1900) || defined(__CUDACC__) || defined(EIGEN_AVOID_STL_ARRAY))
188 template<
class Archive,
typename _IndexType, std::
size_t _NumIndices>
192 ar &
make_nvp(
"array", make_array(&
a.front(), _NumIndices));
195 template<
class Archive,
typename _IndexType, std::
size_t _NumIndices>
199 ar >>
make_nvp(
"array", make_array(&
a.front(), _NumIndices));
202 template<
class Archive,
typename _IndexType, std::
size_t _NumIndices>
209 template<
class Archive,
class T, std::
size_t N>
210 void save(Archive & ar,
const std::array<T, N> &
a,
const unsigned int version)
212 typedef std::array<T, N> Array;
216 template<
class Archive,
class T, std::
size_t N>
217 void load(Archive & ar, std::array<T, N> &
a,
const unsigned int version)
223 #ifdef PINOCCHIO_WITH_EIGEN_TENSOR_MODULE
225 template<
class Archive,
typename _IndexType,
int _NumIndices>
227 Archive & ar,
const Eigen::DSizes<_IndexType, _NumIndices> & ds,
const unsigned int version)
232 template<
class Archive,
typename _IndexType,
int _NumIndices>
233 void load(Archive & ar, Eigen::DSizes<_IndexType, _NumIndices> & ds,
const unsigned int version)
238 template<
class Archive,
typename _IndexType,
int _NumIndices>
240 serialize(Archive & ar, Eigen::DSizes<_IndexType, _NumIndices> & ds,
const unsigned int version)
247 template<
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
250 const ::pinocchio::Tensor<_Scalar, _NumIndices, _Options, _IndexType> &
t,
253 typedef ::pinocchio::Tensor<_Scalar, _NumIndices, _Options, _IndexType> Tensor;
254 const typename Tensor::Dimensions & dimensions =
t.dimensions();
256 ar & BOOST_SERIALIZATION_NVP(dimensions);
257 ar &
make_nvp(
"data", make_array(
t.data(), (
size_t)
t.size()));
260 template<
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
266 typedef ::pinocchio::Tensor<_Scalar, _NumIndices, _Options, _IndexType> Tensor;
267 typename Tensor::Dimensions dimensions;
269 ar >> BOOST_SERIALIZATION_NVP(dimensions);
270 t.resize(dimensions);
272 ar >>
make_nvp(
"data", make_array(
t.data(), (
size_t)
t.size()));
275 template<
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
287 #endif // ifndef __pinocchio_serialization_eigen_matrix_hpp__