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
85 #if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703)
90 class binary_iarchive;
125 #endif // MSVC with C++17
142 const Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> &
m,
145 Eigen::DenseIndex
rows(
m.rows()),
cols(
m.cols());
147 ar & BOOST_SERIALIZATION_NVP(rows);
149 ar & BOOST_SERIALIZATION_NVP(cols);
150 ar &
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
163 Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> &
m,
166 Eigen::DenseIndex
rows = Rows,
cols = Cols;
168 ar >> BOOST_SERIALIZATION_NVP(rows);
170 ar >> BOOST_SERIALIZATION_NVP(cols);
171 m.resize(rows, cols);
172 ar >>
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
185 Eigen::Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> &
m,
191 template<
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
194 const Eigen::Map<PlainObjectBase, MapOptions, StrideType> &
m,
197 Eigen::DenseIndex
rows(
m.rows()),
cols(
m.cols());
199 ar & BOOST_SERIALIZATION_NVP(rows);
201 ar & BOOST_SERIALIZATION_NVP(cols);
202 ar &
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
205 template<
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
208 Eigen::Map<PlainObjectBase, MapOptions, StrideType> &
m,
211 Eigen::DenseIndex
rows = PlainObjectBase::RowsAtCompileTime,
212 cols = PlainObjectBase::ColsAtCompileTime;
214 ar >> BOOST_SERIALIZATION_NVP(rows);
216 ar >> BOOST_SERIALIZATION_NVP(cols);
217 m.resize(rows, cols);
218 ar >>
make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
221 template<
class Archive,
typename PlainObjectBase,
int MapOptions,
typename Str
ideType>
224 Eigen::Map<PlainObjectBase, MapOptions, StrideType> &
m,
230 #if !defined(PINOCCHIO_WITH_EIGEN_TENSOR_MODULE) \
231 && ((__cplusplus <= 199711L && EIGEN_COMP_MSVC < 1900) || defined(__CUDACC__) || defined(EIGEN_AVOID_STL_ARRAY))
232 template<
class Archive,
typename _IndexType, std::
size_t _NumIndices>
236 ar &
make_nvp(
"array", make_array(&
a.front(), _NumIndices));
239 template<
class Archive,
typename _IndexType, std::
size_t _NumIndices>
243 ar >>
make_nvp(
"array", make_array(&
a.front(), _NumIndices));
246 template<
class Archive,
typename _IndexType, std::
size_t _NumIndices>
253 template<
class Archive,
class T, std::
size_t N>
254 void save(Archive & ar,
const std::array<T, N> &
a,
const unsigned int version)
256 typedef std::array<T, N> Array;
260 template<
class Archive,
class T, std::
size_t N>
261 void load(Archive & ar, std::array<T, N> &
a,
const unsigned int version)
267 #ifdef PINOCCHIO_WITH_EIGEN_TENSOR_MODULE
269 template<
class Archive,
typename _IndexType,
int _NumIndices>
271 Archive & ar,
const Eigen::DSizes<_IndexType, _NumIndices> & ds,
const unsigned int version)
276 template<
class Archive,
typename _IndexType,
int _NumIndices>
277 void load(Archive & ar, Eigen::DSizes<_IndexType, _NumIndices> & ds,
const unsigned int version)
282 template<
class Archive,
typename _IndexType,
int _NumIndices>
284 serialize(Archive & ar, Eigen::DSizes<_IndexType, _NumIndices> & ds,
const unsigned int version)
291 template<
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
294 const ::pinocchio::Tensor<_Scalar, _NumIndices, _Options, _IndexType> &
t,
297 typedef ::pinocchio::Tensor<_Scalar, _NumIndices, _Options, _IndexType> Tensor;
298 const typename Tensor::Dimensions & dimensions =
t.dimensions();
300 ar & BOOST_SERIALIZATION_NVP(dimensions);
301 ar &
make_nvp(
"data", make_array(
t.data(), (
size_t)
t.size()));
304 template<
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
310 typedef ::pinocchio::Tensor<_Scalar, _NumIndices, _Options, _IndexType> Tensor;
311 typename Tensor::Dimensions dimensions;
313 ar >> BOOST_SERIALIZATION_NVP(dimensions);
314 t.resize(dimensions);
316 ar >>
make_nvp(
"data", make_array(
t.data(), (
size_t)
t.size()));
319 template<
class Archive,
typename _Scalar,
int _NumIndices,
int _Options,
typename _IndexType>
331 #endif // ifndef __pinocchio_serialization_eigen_matrix_hpp__