MRPT  1.9.9
CMatrix.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "math-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/CMatrix.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 CMatrix::serializeGetVersion() const { return 0; }
25 {
26  // First, write the number of rows and columns:
27  out << (uint32_t)rows() << (uint32_t)cols();
28 
29  if (rows() > 0 && cols() > 0)
30  for (Index i = 0; i < rows(); i++)
31  out.WriteBufferFixEndianness<Scalar>(&coeff(i, 0), cols());
32 }
33 
35 {
36  switch (version)
37  {
38  case 0:
39  {
40  uint32_t nRows, nCols;
41 
42  // First, write the number of rows and columns:
43  in >> nRows >> nCols;
44 
45  setSize(nRows, nCols);
46 
47  if (nRows > 0 && nCols > 0)
48  for (Index i = 0; i < rows(); i++)
49  in.ReadBufferFixEndianness<Scalar>(&coeffRef(i, 0), nCols);
50  }
51  break;
52  default:
54  };
55 }
double Scalar
Definition: KmUtils.h:44
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in 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:127
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CMatrix.cpp:24
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
This base provides a set of functions for maths stuff.
EIGEN_STRONG_INLINE void setSize(size_t row, size_t col)
Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...
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:52
GLuint in
Definition: glext.h:7274
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CMatrix.cpp:34
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:22
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020