MRPT  1.9.9
CMatrixF.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "math-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/CMatrixF.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::math;
18 using namespace mrpt::serialization;
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 uint8_t CMatrixF::serializeGetVersion() const { return 0; }
25 {
26  // First, write the number of rows and columns:
27  out << static_cast<uint32_t>(rows()) << static_cast<uint32_t>(cols());
28 
29  // Since mrpt-1.9.9, dynamic matrices are stored as a contiguous vector:
30  if (rows() > 0 && cols() > 0)
32  &(*this)(0, 0), cols() * rows());
33 }
34 
36 {
37  switch (version)
38  {
39  case 0:
40  {
41  uint32_t nRows, nCols;
42 
43  // First, write the number of rows and columns:
44  in >> nRows >> nCols;
45 
46  setSize(nRows, nCols);
47 
48  if (nRows > 0 && nCols > 0)
49  in.ReadBufferFixEndianness<value_type>(
50  &(*this)(0, 0), nRows * nCols);
51  }
52  break;
53  default:
55  };
56 }
57 
58 /** Serialize CSerializable Object to CSchemeArchiveBase derived object*/
60 {
62  out["nrows"] = static_cast<uint32_t>(this->rows());
63  out["ncols"] = static_cast<uint32_t>(this->cols());
64  out["data"] = this->inMatlabFormat();
65 }
66 /** Serialize CSchemeArchiveBase derived object to CSerializable Object*/
68 {
69  uint8_t version;
71  switch (version)
72  {
73  case 1:
74  {
75  this->fromMatlabStringFormat(static_cast<std::string>(in["data"]));
76  }
77  break;
78  default:
80  }
81 }
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
Definition: CArchive.h:128
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Serialize CSchemeArchiveBase derived object to CSerializable Object.
Definition: CMatrixF.cpp:35
unsigned char uint8_t
Definition: rptypes.h:44
Virtual base class for "schematic archives" (JSON, XML,...)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This base provides a set of functions for maths stuff.
T value_type
The type of the matrix elements.
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods.
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrixF.h:22
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
GLuint in
Definition: glext.h:7391
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
void serializeTo(mrpt::serialization::CArchive &out) const override
Serialize CSerializable Object to CSchemeArchiveBase derived object.
Definition: CMatrixF.cpp:24
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods.
unsigned __int32 uint32_t
Definition: rptypes.h:50



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019