Toggle main menu visibility
Loading...
Searching...
No Matches
eigen-matrix.hpp
Go to the documentation of this file.
1
// Copyright (c) 2015-2018, CNRS
2
// Authors: Justin Carpentier <jcarpent@laas.fr>
3
4
/*
5
Code adapted from:
6
https://gist.githubusercontent.com/mtao/5798888/raw/5be9fa9b66336c166dba3a92c0e5b69ffdb81501/eigen_boost_serialization.hpp
7
Copyright (c) 2015 Michael Tao
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
THE SOFTWARE.
26
*/
27
28
#ifndef EIGEN_BOOST_SERIALIZATION
29
#define EIGEN_BOOST_SERIALIZATION
30
31
#include <Eigen/Dense>
32
#include <boost/serialization/split_free.hpp>
33
#include <boost/serialization/vector.hpp>
34
35
namespace
boost
{
36
namespace
serialization
{
37
template
<
class
Archive,
typename
_Scalar,
int
_Rows,
int
_Cols,
int
_Options,
38
int
_MaxRows,
int
_MaxCols>
39
void
save
(
40
Archive& ar,
41
const
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& m,
42
const
unsigned
int
version) {
43
if
(version) {
44
// Do something
45
}
46
Eigen::DenseIndex rows(m.rows()), cols(m.cols());
47
ar& BOOST_SERIALIZATION_NVP(rows);
48
ar& BOOST_SERIALIZATION_NVP(cols);
49
ar& make_nvp(
"data"
, make_array(m.data(), (
size_t
)m.size()));
50
}
51
52
template
<
class
Archive,
typename
_Scalar,
int
_Rows,
int
_Cols,
int
_Options,
53
int
_MaxRows,
int
_MaxCols>
54
void
load
(Archive& ar,
55
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& m,
56
const
unsigned
int
version) {
57
if
(version) {
58
// Do something
59
}
60
Eigen::DenseIndex rows, cols;
61
ar >> BOOST_SERIALIZATION_NVP(rows);
62
ar >> BOOST_SERIALIZATION_NVP(cols);
63
m.resize(rows, cols);
64
// if(m.size() > 0)
65
ar >> make_nvp(
"data"
, make_array(m.data(), (
size_t
)m.size()));
66
}
67
68
template
<
class
Archive,
typename
_Scalar,
int
_Rows,
int
_Cols,
int
_Options,
69
int
_MaxRows,
int
_MaxCols>
70
void
serialize
(
71
Archive& ar,
72
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& m,
73
const
unsigned
int
version) {
74
split_free(ar, m, version);
75
}
76
77
}
// namespace serialization
78
}
// namespace boost
79
80
#endif
// ifndef __multicontact_api_serialization_eigen_matrix_hpp__
boost::serialization
boost::serialization::load
void load(Archive &ar, Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &m, const unsigned int)
boost::serialization::save
void save(Archive &ar, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &m, const unsigned int)
boost::serialization::serialize
void serialize(Archive &ar, Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &m, const unsigned int version)
boost
include
multicontact-api
serialization
eigen-matrix.hpp
Generated by
1.17.0