22 #if GTSAM_ENABLE_BOOST_SERIALIZATION
27 #include <Eigen/Sparse>
28 #include <boost/serialization/array.hpp>
29 #include <boost/serialization/nvp.hpp>
30 #include <boost/serialization/split_free.hpp>
33 namespace serialization {
51 template <
class Archive,
typename Scalar_,
int Rows_,
int Cols_,
int Ops_,
52 int MaxRows_,
int MaxCols_>
56 const unsigned int ) {
58 ar << BOOST_SERIALIZATION_NVP(
rows);
59 ar << BOOST_SERIALIZATION_NVP(
cols);
60 ar << make_nvp(
"data", make_array(
m.data(),
m.size()));
63 template <
class Archive,
typename Scalar_,
int Rows_,
int Cols_,
int Ops_,
64 int MaxRows_,
int MaxCols_>
65 void load(Archive& ar,
67 const unsigned int ) {
69 ar >> BOOST_SERIALIZATION_NVP(
rows);
70 ar >> BOOST_SERIALIZATION_NVP(
cols);
72 ar >> make_nvp(
"data", make_array(
m.data(),
m.size()));
76 template <
class Archive,
typename Scalar_,
int Rows_,
int Cols_,
int Ops_,
77 int MaxRows_,
int MaxCols_>
86 template <
class Archive>
93 template <
class Archive,
typename _Scalar,
int _Options,
typename _Index>
95 const unsigned int ) {
96 _Index
size =
m.size();
98 std::vector<std::pair<Eigen::Index, _Scalar>>
data;
102 data.push_back({it.index(), it.value()});
104 ar << BOOST_SERIALIZATION_NVP(
size);
105 ar << BOOST_SERIALIZATION_NVP(
data);
108 template <
class Archive,
typename _Scalar,
int _Options,
typename _Index>
110 const unsigned int ) {
112 ar >> BOOST_SERIALIZATION_NVP(
size);
115 std::vector<std::pair<Eigen::Index, _Scalar>>
data;
116 ar >> BOOST_SERIALIZATION_NVP(
data);
118 for (
auto&&
d :
data) {
119 m.coeffRef(
d.first) =
d.second;
123 template <
class Archive,
typename _Scalar,
int _Options,
typename _Index>