@@ -177,12 +177,6 @@ class DECLDIR IO : public LogUser
177177 */
178178 std::vector<uint64_t > Serialize (const XYZQuat& m);
179179
180- /* * @brief Pack a list to make it writable
181- * @param m The list
182- * @return The packed list
183- */
184- std::vector<uint64_t > Serialize (const list& m);
185-
186180 /* * @brief Pack a list of floating point numbers to make it writable
187181 * @param l The list
188182 * @return The packed list
@@ -213,23 +207,25 @@ class DECLDIR IO : public LogUser
213207 */
214208 std::vector<uint64_t > Serialize (const std::vector<mat6>& l);
215209
216- /* * @brief Pack an arbitrarily large vector
217- * @param l The list
210+ /* * @brief Pack an arbitrarily large matrix
211+ * @param l The matrix
218212 * @return The packed list
219213 */
220- template <typename T>
221214 inline std::vector<uint64_t > Serialize (
222- const Eigen::Matrix<T , Eigen::Dynamic, 1 >& l)
215+ const Eigen::Matrix<real , Eigen::Dynamic, Eigen::Dynamic >& l)
223216 {
224217 std::vector<uint64_t > data;
225218 const uint64_t n = l.rows ();
219+ const uint64_t m = l.cols ();
220+ data.reserve (2 + n * m);
226221 data.push_back (Serialize (n));
222+ data.push_back (Serialize (m));
227223 for (uint64_t i = 0 ; i < n; i++) {
228- std::vector<uint64_t > subdata = Serialize (l (i));
229- data.insert (data.end (), subdata.begin (), subdata.end ());
224+ for (uint64_t j = 0 ; j < m; j++) {
225+ data.push_back (Serialize (l (i, j)));
226+ }
230227 }
231228 return data;
232-
233229 }
234230
235231 /* * @brief Pack a list of lists to make it writable
@@ -313,13 +309,6 @@ class DECLDIR IO : public LogUser
313309 */
314310 uint64_t * Deserialize (const uint64_t * in, XYZQuat& out);
315311
316- /* * @brief Unpack a loaded list
317- * @param in The pointer to the next unread value
318- * @param out The unpacked value
319- * @return The new pointer to the remaining data to be read
320- */
321- uint64_t * Deserialize (const uint64_t * in, list& out);
322-
323312 /* * @brief Unpack a loaded list of floating point numbers
324313 * @param in The pointer to the next unread value
325314 * @param out The unpacked value
@@ -355,21 +344,25 @@ class DECLDIR IO : public LogUser
355344 */
356345 uint64_t * Deserialize (const uint64_t * in, std::vector<mat6>& out);
357346
358- /* * @brief Unpack an arbitrarily large vector
347+ /* * @brief Unpack an arbitrarily large matrix
359348 * @param in The pointer to the next unread value
360349 * @param out The unpacked vector
361350 * @return The new pointer to the remaining data to be read
362351 */
363- template < typename Type>
364- uint64_t * Deserialize ( const uint64_t * in,
365- Eigen::Matrix<Type , Eigen::Dynamic, 1 >& out)
352+ uint64_t * Deserialize (
353+ const uint64_t * in,
354+ Eigen::Matrix<real , Eigen::Dynamic, Eigen::Dynamic >& out)
366355 {
367- uint64_t n;
368- uint64_t * remaining = Deserialize (in, n);
369- if (out.rows () != n)
370- out.resize (n);
356+ uint64_t * remaining;
357+ uint64_t n, m;
358+ remaining = Deserialize (in, n);
359+ remaining = Deserialize (remaining, m);
360+ if ((out.rows () != n) || (out.cols () != m))
361+ out.resize (n, m);
371362 for (unsigned int i = 0 ; i < n; i++) {
372- remaining = Deserialize (remaining, out (i));
363+ for (unsigned int j = 0 ; j < m; j++) {
364+ remaining = Deserialize (remaining, out (i, j));
365+ }
373366 }
374367 return remaining;
375368 }
0 commit comments