MRPT  1.9.9
CMatrixD.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/CMatrixD.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::math;
18 
19 // This must be added to any CSerializable class implementation file.
21 
22 uint8_t CMatrixD::serializeGetVersion() const { return 0; }
24 {
25  // First, write the number of rows and columns:
26  out << (uint32_t)rows() << (uint32_t)cols();
27 
28  if (rows() > 0 && cols() > 0)
29  for (Index i = 0; i < rows(); i++)
30  out.WriteBufferFixEndianness<Scalar>(&coeff(i, 0), cols());
31 }
33 {
34  switch (version)
35  {
36  case 0:
37  {
38  uint32_t nRows, nCols;
39 
40  // First, write the number of rows and columns:
41  in >> nRows >> nCols;
42 
43  setSize(nRows, nCols);
44 
45  if (nRows > 0 && nCols > 0)
46  for (Index i = 0; i < rows(); i++)
47  in.ReadBufferFixEndianness<Scalar>(&coeffRef(i, 0), nCols);
48  }
49  break;
50  default:
52  };
53 }
double Scalar
Definition: KmUtils.h:44
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:22
#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
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.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CMatrixD.cpp:32
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
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CMatrixD.cpp:23
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