VectorSerialization.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 // Defined only if boost serialization is enabled
20 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
21 #pragma once
22 
23 #include <gtsam/base/Vector.h>
24 
25 #include <boost/serialization/array.hpp>
26 #include <boost/serialization/nvp.hpp>
27 #include <boost/serialization/split_free.hpp>
28 
29 namespace boost {
30 namespace serialization {
31 
32 // split version - copies into an STL vector for serialization
33 template <class Archive>
34 void save(Archive& ar, const gtsam::Vector& v, unsigned int /*version*/) {
35  const size_t size = v.size();
36  ar << BOOST_SERIALIZATION_NVP(size);
37  ar << make_nvp("data", make_array(v.data(), v.size()));
38 }
39 
40 template <class Archive>
41 void load(Archive& ar, gtsam::Vector& v, unsigned int /*version*/) {
42  size_t size;
43  ar >> BOOST_SERIALIZATION_NVP(size);
44  v.resize(size);
45  ar >> make_nvp("data", make_array(v.data(), v.size()));
46 }
47 
48 // split version - copies into an STL vector for serialization
49 template <class Archive, int D>
50 void save(Archive& ar, const Eigen::Matrix<double, D, 1>& v,
51  unsigned int /*version*/) {
52  ar << make_nvp("data", make_array(v.data(), v.RowsAtCompileTime));
53 }
54 
55 template <class Archive, int D>
56 void load(Archive& ar, Eigen::Matrix<double, D, 1>& v,
57  unsigned int /*version*/) {
58  ar >> make_nvp("data", make_array(v.data(), v.RowsAtCompileTime));
59 }
60 
61 } // namespace serialization
62 } // namespace boost
63 
64 BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector)
65 BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector2)
66 BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector3)
67 BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector6)
68 #endif
libsize.save
save
Definition: libsize.py:15
Vector.h
typedef and functions to augment Eigen's VectorXd
gtsam::Vector2
Eigen::Vector2d Vector2
Definition: Vector.h:42
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:43
boost
Definition: boostmultiprec.cpp:109
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:09:41