11 #ifndef COAL_SERIALIZATION_EIGEN_H
12 #define COAL_SERIALIZATION_EIGEN_H
14 #ifdef COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL
15 #ifdef HPP_FCL_SKIP_EIGEN_BOOST_SERIALIZATION
16 #define COAL_SKIP_EIGEN_BOOST_SERIALIZATION
20 #ifndef COAL_SKIP_EIGEN_BOOST_SERIALIZATION
22 #include <Eigen/Dense>
24 #include <boost/serialization/split_free.hpp>
25 #include <boost/serialization/vector.hpp>
26 #include <boost/serialization/array.hpp>
31 #if __GNUC__ >= 7 && __cplusplus >= 201703L
33 namespace serialization {
49 namespace serialization {
51 template <
class Archive,
typename S,
int Rows,
int Cols,
int Options,
52 int MaxRows,
int MaxCols>
54 const Eigen::Matrix<S, Rows, Cols, Options, MaxRows, MaxCols>&
m,
55 const unsigned int ) {
56 Eigen::DenseIndex
rows(
m.rows()),
cols(
m.cols());
57 if (Rows == Eigen::Dynamic) ar& BOOST_SERIALIZATION_NVP(
rows);
58 if (Cols == Eigen::Dynamic) ar& BOOST_SERIALIZATION_NVP(
cols);
59 ar& make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
62 template <
class Archive,
typename S,
int Rows,
int Cols,
int Options,
63 int MaxRows,
int MaxCols>
65 Eigen::Matrix<S, Rows, Cols, Options, MaxRows, MaxCols>&
m,
66 const unsigned int ) {
67 Eigen::DenseIndex
rows = Rows,
cols = Cols;
68 if (Rows == Eigen::Dynamic) ar >> BOOST_SERIALIZATION_NVP(
rows);
69 if (Cols == Eigen::Dynamic) ar >> BOOST_SERIALIZATION_NVP(
cols);
71 ar >> make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
74 template <
class Archive,
typename S,
int Rows,
int Cols,
int Options,
75 int MaxRows,
int MaxCols>
77 Eigen::Matrix<S, Rows, Cols, Options, MaxRows, MaxCols>&
m,
78 const unsigned int version) {
82 template <
class Archive,
typename PlainObjectBase,
int MapOptions,
85 const Eigen::Map<PlainObjectBase, MapOptions, StrideType>&
m,
86 const unsigned int ) {
87 Eigen::DenseIndex
rows(
m.rows()),
cols(
m.cols());
88 if (PlainObjectBase::RowsAtCompileTime == Eigen::Dynamic)
89 ar& BOOST_SERIALIZATION_NVP(
rows);
90 if (PlainObjectBase::ColsAtCompileTime == Eigen::Dynamic)
91 ar& BOOST_SERIALIZATION_NVP(
cols);
92 ar& make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
95 template <
class Archive,
typename PlainObjectBase,
int MapOptions,
97 void load(Archive& ar, Eigen::Map<PlainObjectBase, MapOptions, StrideType>&
m,
98 const unsigned int ) {
99 Eigen::DenseIndex
rows = PlainObjectBase::RowsAtCompileTime,
100 cols = PlainObjectBase::ColsAtCompileTime;
101 if (PlainObjectBase::RowsAtCompileTime == Eigen::Dynamic)
102 ar >> BOOST_SERIALIZATION_NVP(
rows);
103 if (PlainObjectBase::ColsAtCompileTime == Eigen::Dynamic)
104 ar >> BOOST_SERIALIZATION_NVP(
cols);
106 ar >> make_nvp(
"data", make_array(
m.data(), (
size_t)
m.size()));
109 template <
class Archive,
typename PlainObjectBase,
int MapOptions,
112 Eigen::Map<PlainObjectBase, MapOptions, StrideType>&
m,
113 const unsigned int version) {
120 #endif // ifned COAL_SKIP_EIGEN_BOOST_SERIALIZATION
122 #endif // ifndef COAL_SERIALIZATION_EIGEN_H