11 #ifndef BOGUS_EIGEN_SERIALIZATION_HPP
12 #define BOGUS_EIGEN_SERIALIZATION_HPP
16 #ifndef BOGUS_BLOCK_WITHOUT_EIGEN_SPARSE
17 #include "SparseHeader.hpp"
22 namespace serialization
25 template<
typename Archive,
typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
28 Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & matrix,
29 const unsigned int file_version
33 ar & make_array( matrix.data(), matrix.size() ) ;
36 template<
typename Archive,
typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
39 const Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & matrix,
40 const unsigned int file_version
44 ar & make_array( matrix.data(), matrix.size() ) ;
48 template<
typename Archive,
typename _Scalar,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
51 Eigen::Matrix<_Scalar, Eigen::Dynamic, _Cols, _Options, _MaxRows, _MaxCols> & matrix,
52 const unsigned int file_version
58 matrix.resize( rows, _Cols ) ;
59 ar & make_array( matrix.data(), matrix.size() ) ;
62 template<
typename Archive,
typename _Scalar,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
65 const Eigen::Matrix<_Scalar, Eigen::Dynamic, _Cols, _Options, _MaxRows, _MaxCols> & matrix,
66 const unsigned int file_version
70 int rows = matrix.rows() ;
72 ar & make_array( matrix.data(), matrix.size() ) ;
76 template<
typename Archive,
typename _Scalar,
int _Rows,
int _Options,
int _MaxRows,
int _MaxCols>
79 Eigen::Matrix<_Scalar, _Rows, Eigen::Dynamic, _Options, _MaxRows, _MaxCols> & matrix,
80 const unsigned int file_version
86 matrix.resize( _Rows, cols ) ;
87 ar & make_array( matrix.data(), matrix.size() ) ;
90 template<
typename Archive,
typename _Scalar,
int _Rows,
int _Options,
int _MaxRows,
int _MaxCols>
93 const Eigen::Matrix<_Scalar, _Rows, Eigen::Dynamic, _Options, _MaxRows, _MaxCols> & matrix,
94 const unsigned int file_version
98 int cols = matrix.cols() ;
100 ar & make_array( matrix.data(), matrix.size() ) ;
103 template<
typename Archive,
typename _Scalar,
int _Options,
int _MaxRows,
int _MaxCols>
106 Eigen::Matrix<_Scalar, Eigen::Dynamic, Eigen::Dynamic, _Options, _MaxRows, _MaxCols> & matrix,
107 const unsigned int file_version
110 (void) file_version ;
114 matrix.resize( rows, cols ) ;
115 ar & make_array( matrix.data(), matrix.size() ) ;
118 template<
typename Archive,
typename _Scalar,
int _Options,
int _MaxRows,
int _MaxCols>
121 const Eigen::Matrix<_Scalar, Eigen::Dynamic, Eigen::Dynamic, _Options, _MaxRows, _MaxCols> & matrix,
122 const unsigned int file_version
125 (void) file_version ;
126 int rows = matrix.rows(), cols = matrix.cols() ;
129 ar & make_array( matrix.data(), matrix.size() ) ;
132 template<
typename Archive,
typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
133 inline void serialize(
135 Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & matrix,
136 const unsigned int file_version
139 split_free( ar, matrix, file_version ) ;
142 #ifdef BOGUS_WITH_EIGEN_STABLE_SPARSE_API
144 template<
typename Archive,
typename _Scalar,
int _Options,
typename _Index >
147 Eigen::SparseMatrix<_Scalar, _Options, _Index> & matrix,
148 const unsigned int file_version
151 (void) file_version ;
157 matrix.resize( rows, cols ) ;
158 matrix.resizeNonZeros( nnz ) ;
159 ar & make_array( matrix.outerIndexPtr(), matrix.outerSize()+1 ) ;
160 ar & make_array( matrix.innerIndexPtr(), nnz ) ;
161 ar & make_array( matrix.valuePtr(), nnz ) ;
164 template<
typename Archive,
typename _Scalar,
int _Options,
typename _Index >
167 const Eigen::SparseMatrix<_Scalar, _Options, _Index> & matrix,
168 const unsigned int file_version
171 (void) file_version ;
172 assert( matrix.isCompressed() ) ;
174 _Index rows = matrix.rows(), cols = matrix.cols() ;
175 unsigned nnz = matrix.data().size() ;
179 ar & make_array( matrix.outerIndexPtr(), matrix.outerSize()+1 ) ;
180 ar & make_array( matrix.innerIndexPtr(), nnz ) ;
181 ar & make_array( matrix.valuePtr(), nnz ) ;
184 template<
typename Archive,
typename _Scalar,
int _Options,
typename _Index >
185 inline void serialize(
187 Eigen::SparseMatrix<_Scalar, _Options, _Index> & matrix,
188 const unsigned int file_version
191 split_free( ar, matrix, file_version ) ;